drv_soft_i2c.h 995 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. * 2023/06/01 chushicheng first version
  9. */
  10. #ifndef __DRV_SOFT_I2C__
  11. #define __DRV_SOFT_I2C__
  12. #include <rtdevice.h>
  13. #include "drv_gpio.h"
  14. #include "board.h"
  15. #ifdef BSP_USING_SOFT_I2C
  16. /* pico i2c dirver class */
  17. struct pico_i2c
  18. {
  19. struct rt_i2c_bit_ops ops;
  20. struct rt_i2c_bus_device i2c2_bus;
  21. };
  22. /* pico config class */
  23. struct pico_soft_i2c_config
  24. {
  25. rt_uint8_t scl;
  26. rt_uint8_t sda;
  27. const char *bus_name;
  28. };
  29. #ifdef BSP_USING_SOFT_I2C1
  30. #define I2C1_BUS_CONFIG \
  31. { \
  32. .scl = BSP_SOFT_I2C1_SCL_PIN, \
  33. .sda = BSP_SOFT_I2C1_SDA_PIN, \
  34. .bus_name = "i2c1", \
  35. }
  36. #endif
  37. int rt_soft_i2c_init(void);
  38. #endif /* BSP_USING_SOFT_I2C */
  39. #endif