Parcourir la source

Remove I2C time out check.

Vladimir N. Shilov il y a 2 ans
Parent
commit
d959c16fc2
2 fichiers modifiés avec 16 ajouts et 20 suppressions
  1. 16 15
      src/i2c.c
  2. 0 5
      src/rtos.c

+ 16 - 15
src/i2c.c

@@ -12,7 +12,6 @@
 #define TIM_CNT     TIM17->CNT
 
 /* Private variables */
-uint32_t I2C_tout = 0;
 static i2c_status_t st_Read = I2C_Ret_OK;
 
 /* Private function prototypes */
@@ -67,11 +66,12 @@ i2c_status_t user_i2c_read(const uint8_t id, const uint8_t reg_addr, uint8_t *da
   I2C1->CR2 |= I2C_CR2_START;
 
   /* wait for byte request or any error */
-  ENABLE_TIM;
+  //ENABLE_TIM;
   while ((I2C1->ISR & (I2C_ISR_TIMEOUT | I2C_ISR_ARLO | I2C_ISR_BERR | I2C_ISR_NACKF | I2C_ISR_TXE)) == 0) {
-    if (TIM_CNT == 0) {
-      return I2C_Ret_Tout;
-    }
+    //if (TIM_CNT == 0) {
+    //  return I2C_Ret_Tout;
+    //}
+    __NOP();
   }
 
   if ((I2C1->ISR & I2C_ISR_TXE) != 0) {
@@ -96,7 +96,7 @@ i2c_status_t user_i2c_read(const uint8_t id, const uint8_t reg_addr, uint8_t *da
   int cnt = 0;
   // Read data while no TC flag set.
   // Если взлетит NACK-флаг, приём прекращаем.
-  ENABLE_TIM;
+  //ENABLE_TIM;
   while ((((I2C1->ISR & I2C_ISR_TC)==0) && ((I2C1->ISR & I2C_ISR_NACKF)==0)) && (I2C1->ISR & I2C_ISR_BUSY)) {
     if (I2C1->ISR & I2C_ISR_RXNE) { // Reading data
       *data = I2C1->RXDR;
@@ -107,14 +107,14 @@ i2c_status_t user_i2c_read(const uint8_t id, const uint8_t reg_addr, uint8_t *da
         break;
       }
     }
-    if (TIM_CNT == 0) {
-      st_Read = I2C_Ret_Tout;
-      break;
-    }
+    //if (TIM_CNT == 0) {
+    //  st_Read = I2C_Ret_Tout;
+    //  break;
+    //}
   }
 
   /* wait for receiving data */
-//  while ((Flag.I2C_RX_End == 0) && (Flag.I2C_RX_Err == 0)) { __NOP(); };
+  //while ((Flag.I2C_RX_End == 0) && (Flag.I2C_RX_Err == 0)) { __NOP(); };
 
   /* Set STOP */
   //I2C1->CR2 |= I2C_CR2_STOP;
@@ -144,11 +144,12 @@ i2c_status_t user_i2c_write(const uint8_t id, const uint8_t reg_addr, uint8_t *d
   I2C1->CR2 |= ( id | (len + 1) << I2C_CR2_NBYTES_Pos );
   I2C1->CR2 |= ( I2C_CR2_START );
 
-  ENABLE_TIM;
+  //ENABLE_TIM;
   while ((I2C1->ISR & (I2C_ISR_ARLO | I2C_ISR_BERR | I2C_ISR_NACKF | I2C_ISR_TXE | I2C_ISR_TIMEOUT)) == 0) {
-    if (TIM_CNT == 0) {
-      return I2C_Ret_Tout;
-    }
+    //if (TIM_CNT == 0) {
+    //  return I2C_Ret_Tout;
+    //}
+    __NOP();
   }
 
   if ((I2C1->ISR & I2C_ISR_TXE) != 0) {

+ 0 - 5
src/rtos.c

@@ -186,9 +186,4 @@ void SysTick_Handler(void) {
   if (TDelay != 0) {
     TDelay --;
   }
-
-  /* decrement i2c counter */
-  if (I2C_tout != 0) {
-    I2C_tout --;
-  }
 }