Browse Source

Fix error check.

Vladimir N. Shilov 3 years ago
parent
commit
0d4e592b46
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Src/main.c

+ 2 - 2
Src/main.c

@@ -284,7 +284,7 @@ int8_t i2c_check_err(void) {
   if ((I2C1->ISR & I2C_ISR_NACKF) != 0) {
   /* device not present */
     r = I2C_RET_NACK;
-  } else {
+  } else if ((I2C1->ISR & (I2C_ISR_ARLO | I2C_ISR_BERR)) != 0) {
   /* other error */
     r = I2C_RET_ERR;
   }
@@ -354,7 +354,7 @@ int8_t user_i2c_read(const uint8_t id, const uint8_t reg_addr, uint8_t *data, co
   I2C1->CR2 |= ( I2C_CR2_START );
 
   /* wait for receiving data */
-  while ((Flag.I2C_RX_End == 0) && (Flag.I2C_RX_Err == 0)) { __WFI(); };
+  while ((Flag.I2C_RX_End == 0) && (Flag.I2C_RX_Err == 0)) { __NOP(); };
 
   return r;
 }