drv_soft_i2c.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. * Copyright (c) 2022, Xiaohua Semiconductor Co., Ltd.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Change Logs:
  8. * Date Author Notes
  9. * 2022-04-28 CDT first version
  10. */
  11. #ifndef __DRV_I2C_H__
  12. #define __DRV_I2C_H__
  13. /*******************************************************************************
  14. * Include files
  15. ******************************************************************************/
  16. #include <rtdevice.h>
  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_soft_i2c_config
  26. {
  27. rt_uint16_t scl_pin;
  28. rt_uint16_t sda_pin;
  29. const char *bus_name;
  30. };
  31. struct hc32_i2c
  32. {
  33. struct rt_i2c_bit_ops ops;
  34. struct rt_i2c_bus_device i2c_bus;
  35. };
  36. #ifdef BSP_USING_I2C1
  37. #define I2C1_BUS_CONFIG \
  38. { \
  39. .scl_pin = BSP_I2C1_SCL_PIN, \
  40. .sda_pin = BSP_I2C1_SDA_PIN, \
  41. .bus_name = "i2c1", \
  42. }
  43. #endif
  44. #ifdef BSP_USING_I2C2
  45. #define I2C2_BUS_CONFIG \
  46. { \
  47. .scl_pin = BSP_I2C2_SCL_PIN, \
  48. .sda_pin = BSP_I2C2_SDA_PIN, \
  49. .bus_name = "i2c2", \
  50. }
  51. #endif
  52. #ifdef BSP_USING_I2C3
  53. #define I2C3_BUS_CONFIG \
  54. { \
  55. .scl_pin = BSP_I2C3_SCL_PIN, \
  56. .sda_pin = BSP_I2C3_SDA_PIN, \
  57. .bus_name = "i2c3", \
  58. }
  59. #endif
  60. #ifdef BSP_USING_I2C4
  61. #define I2C4_BUS_CONFIG \
  62. { \
  63. .scl_pin = BSP_I2C4_SCL_PIN, \
  64. .sda_pin = BSP_I2C4_SDA_PIN, \
  65. .bus_name = "i2c4", \
  66. }
  67. #endif
  68. #ifdef BSP_USING_I2C5
  69. #define I2C5_BUS_CONFIG \
  70. { \
  71. .scl_pin = BSP_I2C5_SCL_PIN, \
  72. .sda_pin = BSP_I2C5_SDA_PIN, \
  73. .bus_name = "i2c5", \
  74. }
  75. #endif
  76. #ifdef BSP_USING_I2C6
  77. #define I2C6_BUS_CONFIG \
  78. { \
  79. .scl_pin = BSP_I2C6_SCL_PIN, \
  80. .sda_pin = BSP_I2C6_SDA_PIN, \
  81. .bus_name = "i2c6", \
  82. }
  83. #endif
  84. #ifdef __cplusplus
  85. }
  86. #endif
  87. #endif /* __DRV_I2C_H__ */
  88. /*******************************************************************************
  89. * EOF (not truncated)
  90. ******************************************************************************/