]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.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 Horn <hornmich@fel.cvut.cz>
Fri, 26 Jul 2013 14:09:02 +0000 (16:09 +0200)
commands/cmd_din.c
rpp/lib/rpp/src/rpp/din.c

index 082372ff0c2c2c810c6058c4bf315fd014035b20..25b09c9333832e4eb06305da7c9a7a20feebade5 100644 (file)
@@ -145,13 +145,13 @@ int cmd_do_din_diag(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
                return -CMDERR_BADPAR;
 
        if (rpp_din_update() == FAILURE) {
-               rpp_sci_printf("DIN SPI transfer failed.");
+               rpp_sci_printf("DIN SPI transfer failed.\n");
                return -CMDERR_EIO;
        }
 
        value = rpp_din_diag(pin);
        if (value == -1) {
-               rpp_sci_printf("Pin out of range.");
+               rpp_sci_printf("Pin out of range.\n");
                return -CMDERR_BADPAR;
        }
        return cmd_opchar_replong(cmd_io, param, value, 0, 16);
@@ -167,7 +167,7 @@ cmd_des_t const cmd_des_din_setup={
        "\n"
        "   dinsetupPIN:(A,B,C) \n"
        "where\n"
-       "* PIN is in range 1-16\n"
+       "* PIN is in range 0-15\n"
        "* A is in range 0-1 and\n"
        "** 1 = pull up (switch to ground)\n"
        "** 0 = pull down (switch to battery)\n"
@@ -202,7 +202,7 @@ cmd_des_t const cmd_des_din_get={
        "\n"
        "   dingetPIN:TR \n"
        "where\n"
-       "* PIN is in range 1-16\n"
+       "* PIN is in range 0-15\n"
        "* TR is not yet implemented\n"
        "\n"
        "=== Description ===\n"
@@ -223,7 +223,7 @@ cmd_des_t const cmd_des_din_diag={
        "=== Command syntax ===\n"
        "\n"
        "   dindiagPIN? \n"
-       "where PIN is in range 1-16\n"
+       "where PIN is in range 0-15\n"
        "\n"
        "=== Description ===\n"
        "\n"
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;