Skip to content

Commit

Permalink
Fix I2C read (more safe)
Browse files Browse the repository at this point in the history
  • Loading branch information
DiSlord committed Sep 16, 2024
1 parent d1349cc commit 32b980c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions NANOVNA_STM32_F072/i2c_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ bool i2c_transfer(uint8_t addr, const uint8_t *w, size_t wn)
// I2C TX and RX variant
bool i2c_receive(uint8_t addr, const uint8_t *w, size_t wn, uint8_t *r, size_t rn)
{
while(VNA_I2C->ISR & I2C_ISR_BUSY); // wait last transaction
VNA_I2C->CR1|= I2C_CR1_PE;
if (wn) {
VNA_I2C->CR2 = (addr << I2C_CR2_SADD_7BIT_SHIFT) | (wn << I2C_CR2_NBYTES_SHIFT);
Expand Down
1 change: 1 addition & 0 deletions NANOVNA_STM32_F303/i2c_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ bool i2c_transfer(uint8_t addr, const uint8_t *w, size_t wn)
// I2C TX and RX variant
bool i2c_receive(uint8_t addr, const uint8_t *w, size_t wn, uint8_t *r, size_t rn)
{
while(VNA_I2C->ISR & I2C_ISR_BUSY); // wait last transaction
VNA_I2C->CR1|= I2C_CR1_PE;
if (wn) {
VNA_I2C->CR2 = (addr << I2C_CR2_SADD_7BIT_SHIFT) | (wn << I2C_CR2_NBYTES_SHIFT);
Expand Down

0 comments on commit 32b980c

Please sign in to comment.