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 * 2022-09-19 hg0720 the first version which add from wch 9 */ 10 11 #ifndef __DRV_I2C__ 12 #define __DRV_I2C__ 13 14 #include <rtthread.h> 15 #include <rthw.h> 16 #include <rtdevice.h> 17 18 /* ch32 config class */ 19 struct ch32_soft_i2c_config 20 { 21 rt_uint8_t scl; 22 rt_uint8_t sda; 23 const char *bus_name; 24 }; 25 26 /* ch32 i2c dirver class */ 27 struct ch32_i2c 28 { 29 struct rt_i2c_bit_ops ops; 30 struct rt_i2c_bus_device i2c_bus; 31 }; 32 33 #ifdef BSP_USING_I2C1 34 #define I2C1_BUS_CONFIG \ 35 { \ 36 .scl = BSP_I2C1_SCL_PIN, \ 37 .sda = BSP_I2C1_SDA_PIN, \ 38 .bus_name = "i2c1", \ 39 } 40 #endif 41 42 #ifdef BSP_USING_I2C2 43 #define I2C2_BUS_CONFIG \ 44 { \ 45 .scl = BSP_I2C2_SCL_PIN, \ 46 .sda = BSP_I2C2_SDA_PIN, \ 47 .bus_name = "i2c2", \ 48 } 49 #endif 50 51 int rt_hw_i2c_init(void); 52 53 #endif 54