Skip to content

Commit c6140f1

Browse files
committed
clear STOPPED event when start transmission, which could be caused by missing ack from previous transaction
1 parent e4251d9 commit c6140f1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libraries/Wire/Wire_nRF52.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ void TwoWire::begin(void) {
5151
//Main Mode
5252
master = true;
5353

54-
*pincfg_reg(_uc_pinSCL) = ((uint32_t)GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)
54+
*pincfg_reg(_uc_pinSCL) = ((uint32_t)GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)
5555
| ((uint32_t)GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
5656
| ((uint32_t)GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos)
5757
| ((uint32_t)GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos)
5858
| ((uint32_t)GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
5959

60-
*pincfg_reg(_uc_pinSDA) = ((uint32_t)GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)
60+
*pincfg_reg(_uc_pinSDA) = ((uint32_t)GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)
6161
| ((uint32_t)GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
6262
| ((uint32_t)GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos)
6363
| ((uint32_t)GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos)
@@ -218,6 +218,8 @@ uint8_t TwoWire::endTransmission(bool stopBit)
218218
// Start I2C transmission
219219
_p_twim->ADDRESS = txAddress;
220220

221+
// just in case twi is stopped by bus error such as secondary device reset/stalled without replying ACK/NACK
222+
_p_twim->EVENTS_STOPPED = 0x0UL;
221223
_p_twim->TASKS_RESUME = 0x1UL;
222224

223225
_p_twim->TXD.PTR = (uint32_t)txBuffer._aucBuffer;

0 commit comments

Comments
 (0)