drv_soft_i2c.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2006-2018, Synwit Technology Co.,Ltd.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-12-10 Zohar_Lee first version
  9. * 2020-07-10 lik rewrite
  10. */
  11. #ifndef __DRV_SOFT_I2C_H__
  12. #define __DRV_SOFT_I2C_H__
  13. #include "board.h"
  14. /* swm config class */
  15. struct swm_soft_i2c_cfg
  16. {
  17. rt_uint8_t scl;
  18. rt_uint8_t sda;
  19. const char *name;
  20. };
  21. /* swm i2c dirver class */
  22. struct swm_i2c
  23. {
  24. struct rt_i2c_bit_ops ops;
  25. struct rt_i2c_bus_device i2c2_bus;
  26. };
  27. #ifdef BSP_USING_I2C0
  28. #define I2C0_BUS_CFG \
  29. { \
  30. .scl = BSP_I2C0_SCL_PIN, \
  31. .sda = BSP_I2C0_SDA_PIN, \
  32. .name = "i2c0", \
  33. }
  34. #endif
  35. #ifdef BSP_USING_I2C1
  36. #define I2C1_BUS_CFG \
  37. { \
  38. .scl = BSP_I2C1_SCL_PIN, \
  39. .sda = BSP_I2C1_SDA_PIN, \
  40. .name = "i2c1", \
  41. }
  42. #endif
  43. int rt_hw_i2c_init(void);
  44. #endif /* __DRV_SOFT_I2C_H__ */