summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-06-04 08:07:46 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-06-04 08:07:46 +0200
commit3f6b29ca999bc27bd09f2053759e7a3c4f02de24 (patch)
tree1066410407b325505de3a39b240ccc7943b9b610
parent14a6dcb63e9d56dfaf22eb57ac7b8cbf3284d0c1 (diff)
downloadk8055-3f6b29ca999bc27bd09f2053759e7a3c4f02de24.zip
k8055-3f6b29ca999bc27bd09f2053759e7a3c4f02de24.tar.gz
add k8055_alloc and k8055_free
-rw-r--r--libk8055/k8055.h3
-rw-r--r--libk8055/libk8055.c13
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;