]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
DIN pin index ranges changed from 1-16 to 0-15.
authorMichal Horn <hornmich@fel.cvut.cz>
Fri, 26 Jul 2013 14:09:02 +0000 (16:09 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 30 Jul 2013 09:39:41 +0000 (11:39 +0200)
rpp/src/rpp/din.c

index 7b990cd15bf073baa4045860ef3dce75f4401b6f..63fda55bd2e528de7cd6cbaee319b9c2ac3de747 100644 (file)
@@ -71,17 +71,17 @@ int8_t rpp_din_setup(uint8_t pin, boolean_t pull_type,
                       boolean_t active, boolean_t can_wake)
 {
     // Check range
-    if((pin < 1) || (pin > 16)) {
+    if(pin > 15) {
         return -1;
     }
 
     // Check programmable feature
-    if(pull_type && (pin > 8)) {
+    if(pull_type && (pin > 7)) {
         return -2;
     }
 
     // Set bits
-    uint8_t index = pin - 1;
+    uint8_t index = pin;
     if(pull_type) {
         bit_set(pull_cache, index);
     } else {
@@ -110,26 +110,26 @@ static uint16_t in_cache = 0x0;
 int8_t rpp_din_get(uint8_t pin, boolean_t var_thr)
 {
     // Check range
-    if((pin < 1) || (pin > 16)) {
+    if(pin > 15) {
         return -1;
     }
 
     // Check feature
-    if(var_thr && (pin < 9)) {
+    if(var_thr && (pin < 8)) {
         return -2;
     }
 
     // Use of variable threshold was requested
     if(var_thr) {
         #if rppCONFIG_DRV == 1
-        if(drv_din_get_varthr(pin - 1) == 1) {
+        if(drv_din_get_varthr(pin) == 1) {
             return HIGH;
         }
         #endif
         return LOW;
     }
 
-    if(is_bit_set(in_cache, pin - 1)) {
+    if(is_bit_set(in_cache, pin)) {
         return HIGH;
     }
     return LOW;
@@ -141,11 +141,11 @@ static uint16_t diag_cache = 0x0;
 int8_t rpp_din_diag(uint8_t pin)
 {
     // Check range
-    if((pin < 1) || (pin > 16)) {
+    if(pin > 15) {
         return -1;
     }
 
-    if(is_bit_set(diag_cache, pin - 1)) {
+    if(is_bit_set(diag_cache, pin)) {
         return HIGH;
     }
     return LOW;