1 /* 2 * Copyright (c) 2006-2022, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2021-12-20 BruceOu the first version 9 */ 10 11 #ifndef __DRV_I2C__ 12 #define __DRV_I2C__ 13 14 #include <rtthread.h> 15 #include <rthw.h> 16 #include <rtdevice.h> 17 #include <board.h> 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /* gd32 config class */ 24 struct gd32_soft_i2c_config 25 { 26 rt_uint8_t scl; 27 rt_uint8_t sda; 28 const char *bus_name; 29 }; 30 31 /* gd32 i2c dirver class */ 32 struct gd32_i2c 33 { 34 struct rt_i2c_bit_ops ops; 35 struct rt_i2c_bus_device i2c_bus; 36 }; 37 38 #ifdef BSP_USING_I2C0 39 #define I2C0_BUS_CONFIG \ 40 { \ 41 .scl = BSP_I2C0_SCL_PIN, \ 42 .sda = BSP_I2C0_SDA_PIN, \ 43 .bus_name = "i2c0", \ 44 } 45 #endif 46 47 #ifdef BSP_USING_I2C1 48 #define I2C1_BUS_CONFIG \ 49 { \ 50 .scl = BSP_I2C1_SCL_PIN, \ 51 .sda = BSP_I2C1_SDA_PIN, \ 52 .bus_name = "i2c1", \ 53 } 54 #endif 55 56 #ifdef BSP_USING_I2C2 57 #define I2C2_BUS_CONFIG \ 58 { \ 59 .scl = BSP_I2C2_SCL_PIN, \ 60 .sda = BSP_I2C2_SDA_PIN, \ 61 .bus_name = "i2c2", \ 62 } 63 #endif 64 65 #ifdef BSP_USING_I2C3 66 #define I2C3_BUS_CONFIG \ 67 { \ 68 .scl = BSP_I2C3_SCL_PIN, \ 69 .sda = BSP_I2C3_SDA_PIN, \ 70 .bus_name = "i2c3", \ 71 } 72 #endif 73 74 #ifdef __cplusplus 75 } 76 #endif 77 78 #endif /* __DRV_I2C__ */ 79