summaryrefslogtreecommitdiffstats
path: root/libk8055
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
parentb019e00751a521524a5a3f8869cbf0f152ded52e (diff)
downloadk8055-e740fa93f096152ef6efe0d7c3246f0127cca9bb.zip
k8055-e740fa93f096152ef6efe0d7c3246f0127cca9bb.tar.gz
add k8055_digital_outputs, rename k8055_read_all_values parameters
Diffstat (limited to 'libk8055')
-rw-r--r--libk8055/k8055++.h1
-rw-r--r--libk8055/k8055.h3
-rw-r--r--libk8055/libk8055.c16
-rw-r--r--libk8055/libk8055.cpp4
4 files changed, 17 insertions, 7 deletions
diff --git a/libk8055/k8055++.h b/libk8055/k8055++.h
index 0f3a024..61822e3 100644
--- a/libk8055/k8055++.h
+++ b/libk8055/k8055++.h
@@ -35,6 +35,7 @@ class K8055 {
int read( void );
int write( void );
+ int digital_outputs( void );
int digital_output_1( void );
int digital_output_2( void );
int digital_output_3( void );
diff --git a/libk8055/k8055.h b/libk8055/k8055.h
index 259d00b..d889b60 100644
--- a/libk8055/k8055.h
+++ b/libk8055/k8055.h
@@ -50,6 +50,7 @@ extern "C" {
int k8055_write( struct k8055_dev* dev );
/* access output data */
+ int k8055_digital_outputs( struct k8055_dev* dev );
int k8055_digital_output_1( struct k8055_dev* dev );
int k8055_digital_output_2( struct k8055_dev* dev );
int k8055_digital_output_3( struct k8055_dev* dev );
@@ -97,7 +98,7 @@ extern "C" {
int k8055_read_all_digital( struct k8055_dev* dev );
int k8055_set_all_values( struct k8055_dev* dev, int d_data, int a_data1, int a_data2 );
- 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 );
int k8055_reset_counter( struct k8055_dev* dev, int counter );
int k8055_read_counter( struct k8055_dev* dev, int counter );
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;
}
diff --git a/libk8055/libk8055.cpp b/libk8055/libk8055.cpp
index f537676..f30e23e 100644
--- a/libk8055/libk8055.cpp
+++ b/libk8055/libk8055.cpp
@@ -39,6 +39,10 @@ int K8055::write( void ) {
return k8055_write( &dev );
}
+int K8055::digital_outputs( void ) {
+ return k8055_digital_outputs( &dev );
+}
+
int K8055::digital_output_1( void ) {
return k8055_digital_output_1( &dev );
}