i2c.h 726 B

1234567891011121314151617181920212223242526272829
  1. #ifndef I2C_H
  2. #define I2C_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include "stm32l1xx_hal.h"
  6. typedef enum
  7. {
  8. eI2CPinMode_Default,
  9. eI2CPinMode_KeepPullUp,
  10. eI2CPinMode_KeepPullDown,
  11. }
  12. eI2CPinMode_t;
  13. typedef struct
  14. {
  15. bool (*Init)( eI2CPinMode_t pinmode );
  16. HAL_StatusTypeDef (*Transmit)( uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  17. HAL_StatusTypeDef (*Receive)( uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  18. void (*DeInit)( eI2CPinMode_t pinmode );
  19. }
  20. I2C_Handle_t;
  21. #ifdef STM32L1XX_IT_C
  22. extern I2C_HandleTypeDef i2c_handle; // for stm32l1xx_it.c
  23. #endif
  24. extern const I2C_Handle_t I2C_Handle;
  25. #endif