diff options
-rw-r--r-- | libk8055/k8055.h | 3 | ||||
-rw-r--r-- | libk8055/libk8055.c | 13 |
2 files changed, 15 insertions, 1 deletions
diff --git a/libk8055/k8055.h b/libk8055/k8055.h index 69defbd..c28d4ec 100644 --- a/libk8055/k8055.h +++ b/libk8055/k8055.h @@ -42,6 +42,9 @@ extern "C" { unsigned char data_in[PACKET_LEN+1]; unsigned char data_out[PACKET_LEN+1]; }; + struct k8055_dev* k8055_alloc( void ); + void k8055_free( struct k8055_dev* dev ); + int k8055_read( struct k8055_dev* dev ); int k8055_write( struct k8055_dev* dev ); diff --git a/libk8055/libk8055.c b/libk8055/libk8055.c index 00aab65..85ee4a3 100644 --- a/libk8055/libk8055.c +++ b/libk8055/libk8055.c @@ -79,8 +79,9 @@ **/ -#include <string.h> +#include <stdlib.h> #include <stdio.h> +#include <string.h> #include <assert.h> #include <math.h> #include <libusb.h> @@ -110,6 +111,16 @@ /* set debug to 0 to not print excess info */ static int debug = 0; +struct k8055_dev* k8055_alloc( void ) { + struct k8055_dev *dev = (struct k8055_dev*) malloc( sizeof(struct k8055_dev) ); + dev->dev_no=0; + return dev; +} + +void k8055_free( struct k8055_dev* dev ) { + free(dev); +} + /* Actual read of data from the device endpoint, retry READ_RETRY times if not responding ok */ int k8055_read( struct k8055_dev* dev ) { if( dev->dev_no==0 ) return K8055_ERROR; |