Skip to content

Commit e2cfdf5

Browse files
committed
Wire: add internal pullup
1 parent 6010af1 commit e2cfdf5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

libraries/Wire/Wire.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ bool TwoWire::cfg_pins(int max_index) {
214214
uint16_t cfg_scl = getPinCfg(cfg, PIN_CFG_REQ_SCL,require_sci);
215215
cfg = g_pin_cfg[sda_pin].list;
216216
uint16_t cfg_sda = getPinCfg(cfg, PIN_CFG_REQ_SDA,require_sci);
217+
217218
/* verify configuration are good */
218219
if(cfg_scl == 0 || cfg_sda == 0 ) {
219220
return false;
@@ -237,8 +238,8 @@ bool TwoWire::cfg_pins(int max_index) {
237238
ioport_sda = USE_SCI_EVEN_CFG(cfg_sda) ? IOPORT_PERIPHERAL_SCI0_2_4_6_8 : IOPORT_PERIPHERAL_SCI1_3_5_7_9;
238239
ioport_scl = USE_SCI_EVEN_CFG(cfg_scl) ? IOPORT_PERIPHERAL_SCI0_2_4_6_8 : IOPORT_PERIPHERAL_SCI1_3_5_7_9;
239240

240-
R_IOPORT_PinCfg(&g_ioport_ctrl, g_pin_cfg[sda_pin].pin, (uint32_t) (IOPORT_CFG_NMOS_ENABLE | IOPORT_CFG_PERIPHERAL_PIN | ioport_sda));
241-
R_IOPORT_PinCfg(&g_ioport_ctrl, g_pin_cfg[scl_pin].pin, (uint32_t) (IOPORT_CFG_NMOS_ENABLE | IOPORT_CFG_PERIPHERAL_PIN | ioport_scl));
241+
R_IOPORT_PinCfg(&g_ioport_ctrl, g_pin_cfg[sda_pin].pin, (uint32_t) (IOPORT_CFG_PULLUP_ENABLE | IOPORT_CFG_PERIPHERAL_PIN | ioport_sda));
242+
R_IOPORT_PinCfg(&g_ioport_ctrl, g_pin_cfg[scl_pin].pin, (uint32_t) (IOPORT_CFG_PULLUP_ENABLE | IOPORT_CFG_PERIPHERAL_PIN | ioport_scl));
242243

243244
}
244245
else {
@@ -249,8 +250,8 @@ bool TwoWire::cfg_pins(int max_index) {
249250
ioport_sda = IOPORT_PERIPHERAL_IIC;
250251
ioport_scl = IOPORT_PERIPHERAL_IIC;
251252

252-
R_IOPORT_PinCfg(&g_ioport_ctrl, g_pin_cfg[sda_pin].pin, (uint32_t) (IOPORT_CFG_DRIVE_MID | IOPORT_CFG_PERIPHERAL_PIN | ioport_sda));
253-
R_IOPORT_PinCfg(&g_ioport_ctrl, g_pin_cfg[scl_pin].pin, (uint32_t) (IOPORT_CFG_DRIVE_MID | IOPORT_CFG_PERIPHERAL_PIN | ioport_scl));
253+
R_IOPORT_PinCfg(&g_ioport_ctrl, g_pin_cfg[sda_pin].pin, (uint32_t) (IOPORT_CFG_PULLUP_ENABLE | IOPORT_CFG_DRIVE_MID | IOPORT_CFG_PERIPHERAL_PIN | ioport_sda));
254+
R_IOPORT_PinCfg(&g_ioport_ctrl, g_pin_cfg[scl_pin].pin, (uint32_t) (IOPORT_CFG_PULLUP_ENABLE | IOPORT_CFG_DRIVE_MID | IOPORT_CFG_PERIPHERAL_PIN | ioport_scl));
254255
}
255256

256257
return true;

0 commit comments

Comments
 (0)