drv_i2c.h 725 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2006-2024, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-4-1 IceBear003 the first version
  9. */
  10. #ifndef __DRV_I2C_H_
  11. #define __DRV_I2C_H_
  12. #include <rtthread.h>
  13. #include <rtdevice.h>
  14. struct i2c_bus_device
  15. {
  16. struct rt_i2c_bus_device parent;
  17. I2C_TypeDef *periph;
  18. };
  19. struct i2c_config
  20. {
  21. rt_uint32_t clock_speed;
  22. uint16_t duty_cycle;
  23. uint16_t own_address;
  24. uint8_t enable_ack;
  25. uint8_t is_7_bit_address;
  26. };
  27. struct i2c_config i2c_default_conf={5000, I2C_Mode_I2C, I2C_DutyCycle_2, 0, I2C_Ack_Disable, I2C_AcknowledgedAddress_7bit};
  28. int rt_hw_i2c_init(struct i2c_config *config);
  29. #endif