drv_soft_i2c.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-07-29 KyleChan first version
  9. */
  10. #ifndef __DRV_I2C__
  11. #define __DRV_I2C__
  12. #include <rtthread.h>
  13. #include <rthw.h>
  14. #include <rtdevice.h>
  15. #include <rtdbg.h>
  16. /* ra config class */
  17. struct ra_soft_i2c_config
  18. {
  19. rt_uint32_t scl;
  20. rt_uint32_t sda;
  21. const char *bus_name;
  22. };
  23. /* ra i2c dirver class */
  24. struct ra_i2c
  25. {
  26. struct rt_i2c_bit_ops ops;
  27. struct rt_i2c_bus_device i2c2_bus;
  28. };
  29. #ifdef BSP_USING_I2C1
  30. #define I2C1_BUS_CONFIG \
  31. { \
  32. .scl = BSP_I2C1_SCL_PIN, \
  33. .sda = BSP_I2C1_SDA_PIN, \
  34. .bus_name = "i2c1", \
  35. }
  36. #endif
  37. #ifdef BSP_USING_I2C2
  38. #define I2C2_BUS_CONFIG \
  39. { \
  40. .scl = BSP_I2C2_SCL_PIN, \
  41. .sda = BSP_I2C2_SDA_PIN, \
  42. .bus_name = "i2c2", \
  43. }
  44. #endif
  45. int rt_hw_i2c_init(void);
  46. #endif