summaryrefslogtreecommitdiff
path: root/drivers/gpio
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/mcp23018.c12
-rw-r--r--drivers/gpio/pca9505.c10
-rw-r--r--drivers/gpio/pca9555.c12
-rw-r--r--drivers/gpio/sn74x138.c24
-rw-r--r--drivers/gpio/sn74x154.c18
5 files changed, 36 insertions, 40 deletions
diff --git a/drivers/gpio/mcp23018.c b/drivers/gpio/mcp23018.c
index 41cbfe087e..3eca4f9d34 100644
--- a/drivers/gpio/mcp23018.c
+++ b/drivers/gpio/mcp23018.c
@@ -33,13 +33,13 @@ bool mcp23018_set_config(uint8_t slave_addr, mcp23018_port_t port, uint8_t conf)
uint8_t cmdDirection = port ? CMD_IODIRB : CMD_IODIRA;
uint8_t cmdPullup = port ? CMD_GPPUB : CMD_GPPUA;
- i2c_status_t ret = i2c_writeReg(addr, cmdDirection, &conf, sizeof(conf), TIMEOUT);
+ i2c_status_t ret = i2c_write_register(addr, cmdDirection, &conf, sizeof(conf), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
dprintf("mcp23018_set_config::directionFAILED::%u\n", ret);
return false;
}
- ret = i2c_writeReg(addr, cmdPullup, &conf, sizeof(conf), TIMEOUT);
+ ret = i2c_write_register(addr, cmdPullup, &conf, sizeof(conf), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
dprintf("mcp23018_set_config::pullupFAILED::%u\n", ret);
return false;
@@ -52,7 +52,7 @@ bool mcp23018_set_output(uint8_t slave_addr, mcp23018_port_t port, uint8_t conf)
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
uint8_t cmd = port ? CMD_GPIOB : CMD_GPIOA;
- i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
+ i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
dprintf("mcp23018_set_output::FAILED::%u\n", ret);
return false;
@@ -65,7 +65,7 @@ bool mcp23018_set_output_all(uint8_t slave_addr, uint8_t confA, uint8_t confB) {
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
uint8_t conf[2] = {confA, confB};
- i2c_status_t ret = i2c_writeReg(addr, CMD_GPIOA, &conf[0], sizeof(conf), TIMEOUT);
+ i2c_status_t ret = i2c_write_register(addr, CMD_GPIOA, &conf[0], sizeof(conf), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
dprintf("mcp23018_set_output::FAILED::%u\n", ret);
return false;
@@ -78,7 +78,7 @@ bool mcp23018_readPins(uint8_t slave_addr, mcp23018_port_t port, uint8_t* out) {
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
uint8_t cmd = port ? CMD_GPIOB : CMD_GPIOA;
- i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
+ i2c_status_t ret = i2c_read_register(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
dprintf("mcp23018_readPins::FAILED::%u\n", ret);
return false;
@@ -97,7 +97,7 @@ bool mcp23018_readPins_all(uint8_t slave_addr, uint16_t* out) {
data16 data = {.u16 = 0};
- i2c_status_t ret = i2c_readReg(addr, CMD_GPIOA, &data.u8[0], sizeof(data), TIMEOUT);
+ i2c_status_t ret = i2c_read_register(addr, CMD_GPIOA, &data.u8[0], sizeof(data), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
dprintf("mcp23018_readPins::FAILED::%u\n", ret);
return false;
diff --git a/drivers/gpio/pca9505.c b/drivers/gpio/pca9505.c
index 5803746c96..5617a14a8b 100644
--- a/drivers/gpio/pca9505.c
+++ b/drivers/gpio/pca9505.c
@@ -41,8 +41,6 @@ void pca9505_init(uint8_t slave_addr) {
}
// TODO: could check device connected
- // i2c_start(SLAVE_TO_ADDR(slave) | I2C_WRITE);
- // i2c_stop();
}
bool pca9505_set_config(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) {
@@ -66,7 +64,7 @@ bool pca9505_set_config(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) {
break;
}
- i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
+ i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
print("pca9505_set_config::FAILED\n");
return false;
@@ -96,7 +94,7 @@ bool pca9505_set_polarity(uint8_t slave_addr, pca9505_port_t port, uint8_t conf)
break;
}
- i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
+ i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
print("pca9505_set_polarity::FAILED\n");
return false;
@@ -126,7 +124,7 @@ bool pca9505_set_output(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) {
break;
}
- i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
+ i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
print("pca9505_set_output::FAILED\n");
return false;
@@ -156,7 +154,7 @@ bool pca9505_readPins(uint8_t slave_addr, pca9505_port_t port, uint8_t* out) {
break;
}
- i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
+ i2c_status_t ret = i2c_read_register(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
print("pca9505_readPins::FAILED\n");
return false;
diff --git a/drivers/gpio/pca9555.c b/drivers/gpio/pca9555.c
index adcd040083..0fc30099ac 100644
--- a/drivers/gpio/pca9555.c
+++ b/drivers/gpio/pca9555.c
@@ -29,15 +29,13 @@ void pca9555_init(uint8_t slave_addr) {
}
// TODO: could check device connected
- // i2c_start(SLAVE_TO_ADDR(slave) | I2C_WRITE);
- // i2c_stop();
}
bool pca9555_set_config(uint8_t slave_addr, pca9555_port_t port, uint8_t conf) {
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
uint8_t cmd = port ? CMD_CONFIG_1 : CMD_CONFIG_0;
- i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
+ i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
print("pca9555_set_config::FAILED\n");
return false;
@@ -50,7 +48,7 @@ bool pca9555_set_output(uint8_t slave_addr, pca9555_port_t port, uint8_t conf) {
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
uint8_t cmd = port ? CMD_OUTPUT_1 : CMD_OUTPUT_0;
- i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
+ i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
print("pca9555_set_output::FAILED\n");
return false;
@@ -63,7 +61,7 @@ bool pca9555_set_output_all(uint8_t slave_addr, uint8_t confA, uint8_t confB) {
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
uint8_t conf[2] = {confA, confB};
- i2c_status_t ret = i2c_writeReg(addr, CMD_OUTPUT_0, &conf[0], sizeof(conf), TIMEOUT);
+ i2c_status_t ret = i2c_write_register(addr, CMD_OUTPUT_0, &conf[0], sizeof(conf), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
dprintf("pca9555_set_output::FAILED::%u\n", ret);
return false;
@@ -76,7 +74,7 @@ bool pca9555_readPins(uint8_t slave_addr, pca9555_port_t port, uint8_t* out) {
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
uint8_t cmd = port ? CMD_INPUT_1 : CMD_INPUT_0;
- i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
+ i2c_status_t ret = i2c_read_register(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
print("pca9555_readPins::FAILED\n");
return false;
@@ -95,7 +93,7 @@ bool pca9555_readPins_all(uint8_t slave_addr, uint16_t* out) {
data16 data = {.u16 = 0};
- i2c_status_t ret = i2c_readReg(addr, CMD_INPUT_0, &data.u8[0], sizeof(data), TIMEOUT);
+ i2c_status_t ret = i2c_read_register(addr, CMD_INPUT_0, &data.u8[0], sizeof(data), TIMEOUT);
if (ret != I2C_STATUS_SUCCESS) {
print("pca9555_readPins_all::FAILED\n");
return false;
diff --git a/drivers/gpio/sn74x138.c b/drivers/gpio/sn74x138.c
index 222e5db56c..1cf8e54f56 100644
--- a/drivers/gpio/sn74x138.c
+++ b/drivers/gpio/sn74x138.c
@@ -27,39 +27,39 @@ static const pin_t address_pins[ADDRESS_PIN_COUNT] = SN74X138_ADDRESS_PINS;
void sn74x138_init(void) {
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
- setPinOutput(address_pins[i]);
- writePinLow(address_pins[i]);
+ gpio_set_pin_output(address_pins[i]);
+ gpio_write_pin_low(address_pins[i]);
}
#if defined(SN74X138_E1_PIN)
- setPinOutput(SN74X138_E1_PIN);
- writePinHigh(SN74X138_E1_PIN);
+ gpio_set_pin_output(SN74X138_E1_PIN);
+ gpio_write_pin_high(SN74X138_E1_PIN);
#endif
#if defined(SN74X138_E2_PIN)
- setPinOutput(SN74X138_E2_PIN);
- writePinHigh(SN74X138_E2_PIN);
+ gpio_set_pin_output(SN74X138_E2_PIN);
+ gpio_write_pin_high(SN74X138_E2_PIN);
#endif
#if defined(SN74X138_E3_PIN)
- setPinOutput(SN74X138_E3_PIN);
- writePinLow(SN74X138_E3_PIN);
+ gpio_set_pin_output(SN74X138_E3_PIN);
+ gpio_write_pin_low(SN74X138_E3_PIN);
#endif
}
void sn74x138_set_enabled(bool enabled) {
#if defined(SN74X138_E1_PIN)
- writePin(SN74X138_E1_PIN, !enabled);
+ gpio_write_pin(SN74X138_E1_PIN, !enabled);
#endif
#if defined(SN74X138_E2_PIN)
- writePin(SN74X138_E2_PIN, !enabled);
+ gpio_write_pin(SN74X138_E2_PIN, !enabled);
#endif
#if defined(SN74X138_E3_PIN)
- writePin(SN74X138_E3_PIN, enabled);
+ gpio_write_pin(SN74X138_E3_PIN, enabled);
#endif
}
void sn74x138_set_addr(uint8_t address) {
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
- writePin(address_pins[i], address & (1 << i));
+ gpio_write_pin(address_pins[i], address & (1 << i));
}
}
diff --git a/drivers/gpio/sn74x154.c b/drivers/gpio/sn74x154.c
index 5f21f12b55..6226adf27e 100644
--- a/drivers/gpio/sn74x154.c
+++ b/drivers/gpio/sn74x154.c
@@ -27,32 +27,32 @@ static const pin_t address_pins[ADDRESS_PIN_COUNT] = SN74X154_ADDRESS_PINS;
void sn74x154_init(void) {
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
- setPinOutput(address_pins[i]);
- writePinLow(address_pins[i]);
+ gpio_set_pin_output(address_pins[i]);
+ gpio_write_pin_low(address_pins[i]);
}
#if defined(SN74X154_E0_PIN)
- setPinOutput(SN74X154_E0_PIN);
- writePinHigh(SN74X154_E0_PIN);
+ gpio_set_pin_output(SN74X154_E0_PIN);
+ gpio_write_pin_high(SN74X154_E0_PIN);
#endif
#if defined(SN74X154_E1_PIN)
- setPinOutput(SN74X154_E1_PIN);
- writePinHigh(SN74X154_E1_PIN);
+ gpio_set_pin_output(SN74X154_E1_PIN);
+ gpio_write_pin_high(SN74X154_E1_PIN);
#endif
}
void sn74x154_set_enabled(bool enabled) {
#if defined(SN74X154_E0_PIN)
- writePin(SN74X154_E0_PIN, !enabled);
+ gpio_write_pin(SN74X154_E0_PIN, !enabled);
#endif
#if defined(SN74X154_E1_PIN)
- writePin(SN74X154_E1_PIN, !enabled);
+ gpio_write_pin(SN74X154_E1_PIN, !enabled);
#endif
}
void sn74x154_set_addr(uint8_t address) {
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
- writePin(address_pins[i], address & (1 << i));
+ gpio_write_pin(address_pins[i], address & (1 << i));
}
}