Skip to content

Commit

Permalink
[stm32] Do not set invalid I2C_CR1_NOSTRETCH bit in master mode
Browse files Browse the repository at this point in the history
The reference manual states:

This bit is used to disable clock stretching in slave mode.
It must be kept cleared in master mode.
  • Loading branch information
chris-durand committed Feb 4, 2023
1 parent 588e9f1 commit 7cb16d6
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/modm/platform/i2c/stm32-extended/i2c_master.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ modm::platform::I2cMaster{{ id }}::initializeWithPrescaler(uint32_t timingRegist
Rcc::enable<Peripheral::I2c{{id}}>();

// Disable the I2C peripheral which causes a software reset
I2C{{ id }}->CR1 &= ~I2C_CR1_PE;
I2C{{ id }}->CR1 = 0;

// Configure I2Cx: Frequency range
// 39.4.8: Before enabling the peripheral, the I2C master clock must be configured by setting the
Expand Down Expand Up @@ -538,9 +538,6 @@ modm::platform::I2cMaster{{ id }}::initializeWithPrescaler(uint32_t timingRegist
// Disable Own Address 2
I2C{{ id }}->OAR2 = 0;

// Configure Generalcall and NoStretch mode
I2C{{ id }}->CR1 = (0 | I2C_CR1_NOSTRETCH);

%% if shared_interrupt
// Enable Interrupt
NVIC_SetPriority(I2C{{ id }}_IRQn, 10);
Expand All @@ -556,7 +553,7 @@ modm::platform::I2cMaster{{ id }}::initializeWithPrescaler(uint32_t timingRegist
%% endif

// Enable peripheral
I2C{{ id }}->CR1 |= I2C_CR1_PE;
I2C{{ id }}->CR1 = I2C_CR1_PE;
}

void
Expand Down

0 comments on commit 7cb16d6

Please sign in to comment.