Advertisement
miszczo

Untitled

Dec 2nd, 2019
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1.  
  2. static void keypad_pcf8574_write(keypad_t *s, uint8_t data){
  3.     s->iostate=data;
  4.     uint8_t error;
  5.     vTaskSuspendAll();
  6.     error = HAL_I2C_Master_Transmit(s->hi2c, (uint16_t)s->addr, &s->iostate, 1, 100);
  7.     xTaskResumeAll();
  8.     (void)error;
  9. #if DEBUG
  10.     dbg("write error code = %d\n\r",error);
  11. #endif
  12.    
  13.     // hardfix busy flag hardware problem,
  14.     // STM32F10xxC/D/E Errata sheet - page 23
  15.     if(error!=0){       // WARNING!!!
  16.         HAL_I2C_DeInit(s->hi2c);        // I2C RESET WHEN BUS FAULT, ITS WORKING ON F103
  17.         MX_I2C1_Init();
  18. #if DEBUG
  19.         dbg("restart i2c\n\r");
  20. #endif
  21.     }
  22.    
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement