aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/NRF5/LLD/TWIMv1/hal_i2c_lld.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/ports/NRF5/LLD/TWIMv1/hal_i2c_lld.c')
-rw-r--r--os/hal/ports/NRF5/LLD/TWIMv1/hal_i2c_lld.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/os/hal/ports/NRF5/LLD/TWIMv1/hal_i2c_lld.c b/os/hal/ports/NRF5/LLD/TWIMv1/hal_i2c_lld.c
index 957c0be..7d5a26d 100644
--- a/os/hal/ports/NRF5/LLD/TWIMv1/hal_i2c_lld.c
+++ b/os/hal/ports/NRF5/LLD/TWIMv1/hal_i2c_lld.c
@@ -38,17 +38,17 @@
#define I2C_INPUT(p) do { IOPORT1->DIRCLR = (1UL << (p)); } while(0) /*!< Configures I2C pin as input */
#define I2C_OUTPUT(p) do { IOPORT1->DIRSET = (1UL << (p)); } while(0) /*!< Configures I2C pin as output */
-#define I2C_PIN_CNF \
+#define I2C_PIN_CNF(internal_pullup) \
((GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \
| (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) \
- | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) \
+ | (((internal_pullup) ? GPIO_PIN_CNF_PULL_Pullup : GPIO_PIN_CNF_PULL_Disabled) << GPIO_PIN_CNF_PULL_Pos) \
| (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) \
| (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos))
-#define I2C_PIN_CNF_CLR \
+#define I2C_PIN_CNF_CLR(internal_pullup) \
((GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \
| (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) \
- | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) \
+ | (((internal_pullup) ? GPIO_PIN_CNF_PULL_Pullup : GPIO_PIN_CNF_PULL_Disabled) << GPIO_PIN_CNF_PULL_Pos) \
| (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) \
| (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos))
@@ -97,14 +97,14 @@ static void i2c_clear_bus(I2CDriver *i2cp) {
const I2CConfig *cfg = i2cp->config;
uint8_t i;
- IOPORT1->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF;
- IOPORT1->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF;
+ IOPORT1->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF(cfg->scl_pullup);
+ IOPORT1->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF(cfg->sda_pullup);
I2C_HIGH(cfg->sda_pad);
I2C_HIGH(cfg->scl_pad);
- IOPORT1->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF_CLR;
- IOPORT1->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF_CLR;
+ IOPORT1->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF_CLR(cfg->scl_pullup);
+ IOPORT1->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF_CLR(cfg->sda_pullup);
nrf_delay_us(4);
@@ -233,8 +233,8 @@ void i2c_lld_start(I2CDriver *i2cp) {
i2c_clear_bus(i2cp);
- IOPORT1->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF;
- IOPORT1->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF;
+ IOPORT1->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF(cfg->scl_pullup);
+ IOPORT1->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF(cfg->sda_pullup);
i2c->SHORTS = 0;
@@ -300,8 +300,8 @@ void i2c_lld_stop(I2CDriver *i2cp) {
i2c->ENABLE = TWIM_ENABLE_ENABLE_Disabled << TWIM_ENABLE_ENABLE_Pos;
- IOPORT1->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF_CLR;
- IOPORT1->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF_CLR;
+ IOPORT1->PIN_CNF[cfg->scl_pad] = I2C_PIN_CNF_CLR(cfg->scl_pullup);
+ IOPORT1->PIN_CNF[cfg->sda_pad] = I2C_PIN_CNF_CLR(cfg->sda_pullup);
}
}