summaryrefslogtreecommitdiffstats
path: root/libk8055/libk8055.c
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-06-06 07:30:26 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-06-06 07:30:26 +0200
commite740fa93f096152ef6efe0d7c3246f0127cca9bb (patch)
treefca05a794336f69ad9c04d8130d26604c0de87c5 /libk8055/libk8055.c
parentb019e00751a521524a5a3f8869cbf0f152ded52e (diff)
downloadk8055-e740fa93f096152ef6efe0d7c3246f0127cca9bb.zip
k8055-e740fa93f096152ef6efe0d7c3246f0127cca9bb.tar.gz
add k8055_digital_outputs, rename k8055_read_all_values parameters
Diffstat (limited to 'libk8055/libk8055.c')
-rw-r--r--libk8055/libk8055.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/libk8055/libk8055.c b/libk8055/libk8055.c
index 4853cc3..33bff48 100644
--- a/libk8055/libk8055.c
+++ b/libk8055/libk8055.c
@@ -143,6 +143,10 @@ int k8055_write( struct k8055_dev* dev ) {
return K8055_ERROR;
}
+int k8055_digital_outputs( struct k8055_dev* dev ) {
+ return dev->data_out[DIGITAL_OUT_OFFSET];
+}
+
int k8055_digital_output_1( struct k8055_dev* dev ) {
return ( ( dev->data_out[DIGITAL_OUT_OFFSET] ) & 0x01 );
}
@@ -447,16 +451,16 @@ int k8055_read_all_digital( struct k8055_dev* dev ) {
return return_data;
}
-int k8055_read_all_values( struct k8055_dev* dev, int* data1, int* data2, int* data3, int* data4, int* data5 ) {
+int k8055_read_all_values( struct k8055_dev* dev, int* digital, int* analog1, int* analog2, int* counter1, int* counter2 ) {
if ( k8055_read( dev )!=0 ) return K8055_ERROR;
- if(data1) *data1 = (
+ if(digital) *digital = (
( ( dev->data_in[DIGITAL_INP_OFFSET] >> 4 ) & 0x03 ) | /* Input 1 and 2 */
( ( dev->data_in[DIGITAL_INP_OFFSET] << 2 ) & 0x04 ) | /* Input 3 */
( ( dev->data_in[DIGITAL_INP_OFFSET] >> 3 ) & 0x18 ) ); /* Input 4 and 5 */
- if(data2) *data2 = dev->data_in[ANALOG_1_OFFSET];
- if(data3) *data3 = dev->data_in[ANALOG_2_OFFSET];
- if(data4) *data4 = *( ( short int* )( &dev->data_in[COUNTER_1_OFFSET] ) );
- if(data5) *data5 = *( ( short int* )( &dev->data_in[COUNTER_2_OFFSET] ) );
+ if(analog1) *analog1 = dev->data_in[ANALOG_1_OFFSET];
+ if(analog2) *analog2 = dev->data_in[ANALOG_2_OFFSET];
+ if(counter1) *counter1 = *( ( short int* )( &dev->data_in[COUNTER_1_OFFSET] ) );
+ if(counter2) *counter2 = *( ( short int* )( &dev->data_in[COUNTER_2_OFFSET] ) );
return 0;
}