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);
"\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"
"\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"
"=== 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"
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 {
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;
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;