drv_hard_i2c.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-02-17 Dyyt587 first version
  9. */
  10. #ifndef __DRV_HARD_I2C_H__
  11. #define __DRV_HARD_I2C_H__
  12. #include <drv_common.h>
  13. #include "drv_dma.h"
  14. #include "drv_config.h"
  15. #include <ipc/completion.h>
  16. /* C binding of definitions if building with C++ compiler */
  17. #ifdef __cplusplus
  18. extern "C"
  19. {
  20. #endif
  21. struct stm32_i2c_config
  22. {
  23. const char *name;
  24. I2C_TypeDef *Instance;
  25. rt_uint32_t timing;
  26. rt_uint32_t timeout;
  27. IRQn_Type evirq_type;
  28. IRQn_Type erirq_type;
  29. struct dma_config *dma_rx;
  30. struct dma_config *dma_tx;
  31. };
  32. struct stm32_i2c
  33. {
  34. I2C_HandleTypeDef handle;
  35. struct stm32_i2c_config *config;
  36. struct
  37. {
  38. DMA_HandleTypeDef handle_rx;
  39. DMA_HandleTypeDef handle_tx;
  40. } dma;
  41. rt_uint8_t i2c_dma_flag;
  42. struct rt_i2c_bus_device i2c_bus;
  43. struct rt_completion completion;
  44. };
  45. #define I2C_USING_TX_DMA_FLAG (1U)
  46. #define I2C_USING_RX_DMA_FLAG (1U << 1)
  47. #ifdef __cplusplus
  48. }
  49. #endif
  50. #endif /* __DRV_I2C_H__ */