diff options
Diffstat (limited to 'drivers/gpio')
| -rw-r--r-- | drivers/gpio/pca9555.c | 17 | ||||
| -rw-r--r-- | drivers/gpio/pca9555.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/drivers/gpio/pca9555.c b/drivers/gpio/pca9555.c index 496bbca04..02b5abbdd 100644 --- a/drivers/gpio/pca9555.c +++ b/drivers/gpio/pca9555.c | |||
| @@ -76,3 +76,20 @@ uint8_t pca9555_readPins(uint8_t slave_addr, uint8_t port) { | |||
| 76 | } | 76 | } |
| 77 | return data; | 77 | return data; |
| 78 | } | 78 | } |
| 79 | |||
| 80 | uint16_t pca9555_readAllPins(uint8_t slave_addr) { | ||
| 81 | uint8_t addr = SLAVE_TO_ADDR(slave_addr); | ||
| 82 | |||
| 83 | typedef union { | ||
| 84 | uint8_t u8[2]; | ||
| 85 | uint16_t u16; | ||
| 86 | } data16; | ||
| 87 | |||
| 88 | data16 data; | ||
| 89 | |||
| 90 | i2c_status_t ret = i2c_readReg(addr, CMD_INPUT_0, &data.u8[0], sizeof(data), TIMEOUT); | ||
| 91 | if (ret != I2C_STATUS_SUCCESS) { | ||
| 92 | print("pca9555_readAllPins::FAILED\n"); | ||
| 93 | } | ||
| 94 | return data.u16; | ||
| 95 | } | ||
diff --git a/drivers/gpio/pca9555.h b/drivers/gpio/pca9555.h index ebb97e2f3..3341ec3eb 100644 --- a/drivers/gpio/pca9555.h +++ b/drivers/gpio/pca9555.h | |||
| @@ -53,3 +53,5 @@ void pca9555_set_config(uint8_t slave_addr, uint8_t port, uint8_t conf); | |||
| 53 | void pca9555_set_output(uint8_t slave_addr, uint8_t port, uint8_t conf); | 53 | void pca9555_set_output(uint8_t slave_addr, uint8_t port, uint8_t conf); |
| 54 | 54 | ||
| 55 | uint8_t pca9555_readPins(uint8_t slave_addr, uint8_t port); | 55 | uint8_t pca9555_readPins(uint8_t slave_addr, uint8_t port); |
| 56 | |||
| 57 | uint16_t pca9555_readAllPins(uint8_t slave_addr); | ||
