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 * 2020-01-09 shelton 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 18 /* n32 config class */ 19 struct n32_soft_i2c_config 20 { 21 rt_uint8_t scl; 22 rt_uint8_t sda; 23 const char *bus_name; 24 }; 25 /* n32 i2c dirver class */ 26 struct n32_i2c 27 { 28 struct rt_i2c_bit_ops ops; 29 struct rt_i2c_bus_device i2c_bus; 30 }; 31 32 #ifdef BSP_USING_I2C1 33 #define I2C1_BUS_CONFIG \ 34 { \ 35 .scl = BSP_I2C1_SCL_PIN, \ 36 .sda = BSP_I2C1_SDA_PIN, \ 37 .bus_name = "i2c1", \ 38 } 39 #endif 40 41 #ifdef BSP_USING_I2C2 42 #define I2C2_BUS_CONFIG \ 43 { \ 44 .scl = BSP_I2C2_SCL_PIN, \ 45 .sda = BSP_I2C2_SDA_PIN, \ 46 .bus_name = "i2c2", \ 47 } 48 #endif 49 50 #ifdef BSP_USING_I2C3 51 #define I2C3_BUS_CONFIG \ 52 { \ 53 .scl = BSP_I2C3_SCL_PIN, \ 54 .sda = BSP_I2C3_SDA_PIN, \ 55 .bus_name = "i2c3", \ 56 } 57 #endif 58 59 #ifdef BSP_USING_I2C4 60 #define I2C4_BUS_CONFIG \ 61 { \ 62 .scl = BSP_I2C4_SCL_PIN, \ 63 .sda = BSP_I2C4_SDA_PIN, \ 64 .bus_name = "i2c4", \ 65 } 66 #endif 67 int rt_hw_i2c_init(void); 68 69 #endif 70