drv_i2c.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (C) 2022-2024, Xiaohua Semiconductor Co., Ltd.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-04-28 CDT first version
  9. */
  10. #ifndef __DRV_I2C_H__
  11. #define __DRV_I2C_H__
  12. #include <rtdevice.h>
  13. #include "board_config.h"
  14. #include "drv_irq.h"
  15. #include "drv_dma.h"
  16. #ifdef BSP_USING_I2C
  17. /* C binding of definitions if building with C++ compiler */
  18. #ifdef __cplusplus
  19. extern "C"
  20. {
  21. #endif
  22. /*******************************************************************************
  23. * Global type definitions ('typedef')
  24. ******************************************************************************/
  25. struct hc32_i2c_config
  26. {
  27. const char *name;
  28. CM_I2C_TypeDef *Instance;
  29. rt_uint32_t clock;
  30. rt_uint32_t baudrate;
  31. rt_uint32_t timeout;
  32. struct dma_config *i2c_tx_dma;
  33. struct dma_config *i2c_rx_dma;
  34. };
  35. struct hc32_i2c
  36. {
  37. struct hc32_i2c_config *config;
  38. struct rt_i2c_bus_device i2c_bus;
  39. rt_uint8_t i2c_dma_flag;
  40. };
  41. /*******************************************************************************
  42. * Global pre-processor symbols/macros ('#define')
  43. ******************************************************************************/
  44. #define I2C_USING_TX_DMA_FLAG (1U)
  45. #define I2C_USING_RX_DMA_FLAG (1U << 1)
  46. #ifdef __cplusplus
  47. }
  48. #endif
  49. #endif /* BSP_USING_I2C */
  50. #endif /* __DRV_I2C_H__ */