summaryrefslogtreecommitdiffstats
path: root/libk8055/libk8055.c
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-06-06 07:01:09 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-06-06 07:01:09 +0200
commitb019e00751a521524a5a3f8869cbf0f152ded52e (patch)
tree6e3406f6b695ea80ffb1e38edd7b52497c732257 /libk8055/libk8055.c
parent1dcf7f69f49dd11108c01c97025bfc1abd3b75d2 (diff)
downloadk8055-b019e00751a521524a5a3f8869cbf0f152ded52e.zip
k8055-b019e00751a521524a5a3f8869cbf0f152ded52e.tar.gz
rename k8055_digital_x to k8055_digital_input_x, add k8055_digital_output_x, same for analog
Diffstat (limited to 'libk8055/libk8055.c')
-rw-r--r--libk8055/libk8055.c46
1 files changed, 37 insertions, 9 deletions
diff --git a/libk8055/libk8055.c b/libk8055/libk8055.c
index 09691b1..4853cc3 100644
--- a/libk8055/libk8055.c
+++ b/libk8055/libk8055.c
@@ -143,31 +143,59 @@ int k8055_write( struct k8055_dev* dev ) {
return K8055_ERROR;
}
-int k8055_digital_1( struct k8055_dev* dev ) {
+int k8055_digital_output_1( struct k8055_dev* dev ) {
+ return ( ( dev->data_out[DIGITAL_OUT_OFFSET] ) & 0x01 );
+}
+
+int k8055_digital_output_2( struct k8055_dev* dev ) {
+ return ( ( dev->data_out[DIGITAL_OUT_OFFSET] >> 1 ) & 0x01 );
+}
+
+int k8055_digital_output_3( struct k8055_dev* dev ) {
+ return ( ( dev->data_out[DIGITAL_OUT_OFFSET] >> 2 ) & 0x01 );
+}
+
+int k8055_digital_output_4( struct k8055_dev* dev ) {
+ return ( ( dev->data_out[DIGITAL_OUT_OFFSET] >> 3 ) & 0x01 );
+}
+
+int k8055_digital_output_5( struct k8055_dev* dev ) {
+ return ( ( dev->data_out[DIGITAL_OUT_OFFSET] >> 4 ) & 0x01 );
+}
+
+int k8055_analog_output_1( struct k8055_dev* dev ) {
+ return dev->data_out[ANALOG_1_OFFSET];
+}
+
+int k8055_analog_output_2( struct k8055_dev* dev ) {
+ return dev->data_out[ANALOG_2_OFFSET];
+}
+
+int k8055_digital_input_1( struct k8055_dev* dev ) {
return ( ( dev->data_in[DIGITAL_INP_OFFSET] >> 4 ) & 0x01 );
}
-int k8055_digital_2( struct k8055_dev* dev ) {
+int k8055_digital_input_2( struct k8055_dev* dev ) {
return ( ( dev->data_in[DIGITAL_INP_OFFSET] >> 5 ) & 0x01 );
}
-int k8055_digital_3( struct k8055_dev* dev ) {
+int k8055_digital_input_3( struct k8055_dev* dev ) {
return ( ( dev->data_in[DIGITAL_INP_OFFSET] ) & 0x01 );
}
-int k8055_digital_4( struct k8055_dev* dev ) {
+int k8055_digital_input_4( struct k8055_dev* dev ) {
return ( ( dev->data_in[DIGITAL_INP_OFFSET] >> 6 ) & 0x01 );
}
-int k8055_digital_5( struct k8055_dev* dev ) {
+int k8055_digital_input_5( struct k8055_dev* dev ) {
return ( ( dev->data_in[DIGITAL_INP_OFFSET] >> 7 ) & 0x01 );
}
-int k8055_analog_1( struct k8055_dev* dev ) {
+int k8055_analog_input_1( struct k8055_dev* dev ) {
return dev->data_in[ANALOG_1_OFFSET];
}
-int k8055_analog_2( struct k8055_dev* dev ) {
+int k8055_analog_input_2( struct k8055_dev* dev ) {
return dev->data_in[ANALOG_2_OFFSET];
}
@@ -179,14 +207,14 @@ int k8055_counter_2( struct k8055_dev* dev ) {
return dev->data_in[COUNTER_2_OFFSET];
}
-/* If device is owned by some kernel driver, try to disconnect it and claim the device*/
+/* If device is owned by some kernel driver, try to disconnect it and clanalog_inputm the device*/
static int k8055_takeover_device( libusb_device_handle* handle, int interface ) {
char driver_name[STR_BUFF];
memset( driver_name, 0, STR_BUFF );
int ret = K8055_ERROR;
assert( handle != NULL );
if( libusb_detach_kernel_driver( handle, interface )!=0 ) {
- if( debug ) fprintf( stderr, "usb_detach_kernel_driver failure\n" );
+ if( debug ) fprintf( stderr, "usb_detach_kernel_driver fanalog_inputlure\n" );
}
if ( libusb_claim_interface( handle, interface )!=0 ) {
if( debug ) fprintf( stderr, "usb_claim_interface failure\n" );