diff options
| author | skullY <skullydazed@gmail.com> | 2019-08-30 11:19:03 -0700 |
|---|---|---|
| committer | skullydazed <skullydazed@users.noreply.github.com> | 2019-08-30 15:01:52 -0700 |
| commit | b624f32f944acdc59dcb130674c09090c5c404cb (patch) | |
| tree | bc13adbba137d122d9a2c2fb2fafcbb08ac10e25 /drivers/gpio/pca9555.c | |
| parent | 61af76a10d00aba185b8338604171de490a13e3b (diff) | |
| download | qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.tar.gz qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.zip | |
clang-format changes
Diffstat (limited to 'drivers/gpio/pca9555.c')
| -rw-r--r-- | drivers/gpio/pca9555.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/drivers/gpio/pca9555.c b/drivers/gpio/pca9555.c index b0e542d8d..496bbca04 100644 --- a/drivers/gpio/pca9555.c +++ b/drivers/gpio/pca9555.c | |||
| @@ -22,57 +22,57 @@ | |||
| 22 | #define TIMEOUT 100 | 22 | #define TIMEOUT 100 |
| 23 | 23 | ||
| 24 | enum { | 24 | enum { |
| 25 | CMD_INPUT_0 = 0, | 25 | CMD_INPUT_0 = 0, |
| 26 | CMD_INPUT_1, | 26 | CMD_INPUT_1, |
| 27 | CMD_OUTPUT_0, | 27 | CMD_OUTPUT_0, |
| 28 | CMD_OUTPUT_1, | 28 | CMD_OUTPUT_1, |
| 29 | CMD_INVERSION_0, | 29 | CMD_INVERSION_0, |
| 30 | CMD_INVERSION_1, | 30 | CMD_INVERSION_1, |
| 31 | CMD_CONFIG_0, | 31 | CMD_CONFIG_0, |
| 32 | CMD_CONFIG_1, | 32 | CMD_CONFIG_1, |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | void pca9555_init(uint8_t slave_addr) { | 35 | void pca9555_init(uint8_t slave_addr) { |
| 36 | static uint8_t s_init = 0; | 36 | static uint8_t s_init = 0; |
| 37 | if (!s_init) { | 37 | if (!s_init) { |
| 38 | i2c_init(); | 38 | i2c_init(); |
| 39 | 39 | ||
| 40 | s_init = 1; | 40 | s_init = 1; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | // TODO: could check device connected | 43 | // TODO: could check device connected |
| 44 | // i2c_start(SLAVE_TO_ADDR(slave) | I2C_WRITE); | 44 | // i2c_start(SLAVE_TO_ADDR(slave) | I2C_WRITE); |
| 45 | // i2c_stop(); | 45 | // i2c_stop(); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | void pca9555_set_config(uint8_t slave_addr, uint8_t port, uint8_t conf) { | 48 | void pca9555_set_config(uint8_t slave_addr, uint8_t port, uint8_t conf) { |
| 49 | uint8_t addr = SLAVE_TO_ADDR(slave_addr); | 49 | uint8_t addr = SLAVE_TO_ADDR(slave_addr); |
| 50 | uint8_t cmd = port ? CMD_CONFIG_1 : CMD_CONFIG_0; | 50 | uint8_t cmd = port ? CMD_CONFIG_1 : CMD_CONFIG_0; |
| 51 | 51 | ||
| 52 | i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); | 52 | i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); |
| 53 | if (ret != I2C_STATUS_SUCCESS) { | 53 | if (ret != I2C_STATUS_SUCCESS) { |
| 54 | print("pca9555_set_config::FAILED\n"); | 54 | print("pca9555_set_config::FAILED\n"); |
| 55 | } | 55 | } |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | void pca9555_set_output(uint8_t slave_addr, uint8_t port, uint8_t conf) { | 58 | void pca9555_set_output(uint8_t slave_addr, uint8_t port, uint8_t conf) { |
| 59 | uint8_t addr = SLAVE_TO_ADDR(slave_addr); | 59 | uint8_t addr = SLAVE_TO_ADDR(slave_addr); |
| 60 | uint8_t cmd = port ? CMD_OUTPUT_1 : CMD_OUTPUT_0; | 60 | uint8_t cmd = port ? CMD_OUTPUT_1 : CMD_OUTPUT_0; |
| 61 | 61 | ||
| 62 | i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); | 62 | i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT); |
| 63 | if (ret != I2C_STATUS_SUCCESS) { | 63 | if (ret != I2C_STATUS_SUCCESS) { |
| 64 | print("pca9555_set_output::FAILED\n"); | 64 | print("pca9555_set_output::FAILED\n"); |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | uint8_t pca9555_readPins(uint8_t slave_addr, uint8_t port) { | 68 | uint8_t pca9555_readPins(uint8_t slave_addr, uint8_t port) { |
| 69 | uint8_t addr = SLAVE_TO_ADDR(slave_addr); | 69 | uint8_t addr = SLAVE_TO_ADDR(slave_addr); |
| 70 | uint8_t cmd = port ? CMD_INPUT_1 : CMD_INPUT_0; | 70 | uint8_t cmd = port ? CMD_INPUT_1 : CMD_INPUT_0; |
| 71 | 71 | ||
| 72 | uint8_t data = 0; | 72 | uint8_t data = 0; |
| 73 | i2c_status_t ret = i2c_readReg(addr, cmd, &data, sizeof(data), TIMEOUT); | 73 | i2c_status_t ret = i2c_readReg(addr, cmd, &data, sizeof(data), TIMEOUT); |
| 74 | if (ret != I2C_STATUS_SUCCESS) { | 74 | if (ret != I2C_STATUS_SUCCESS) { |
| 75 | print("pca9555_readPins::FAILED\n"); | 75 | print("pca9555_readPins::FAILED\n"); |
| 76 | } | 76 | } |
| 77 | return data; | 77 | return data; |
| 78 | } | 78 | } |
