mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-01 02:40:12 +08:00
[bsp][bl] add drv_soft_i2c (#7406)
This commit is contained in:
1 parent
1dac7db9cd
commit
0c55c4d3ed
4 files changed
+308
-3
No files matched your search
@@ -174,6 +174,56 @@ menu "General Drivers Configuration"
|
||||
config BSP_USING_ON_CHIP_FLASH
|
||||
bool "Enable on-chip FLASH"
|
||||
default n
|
||||
|
||||
menu "General Purpose I2C"
|
||||
|
||||
menuconfig BSP_USING_I2C1
|
||||
bool "Enable I2C1"
|
||||
default n
|
||||
select BSP_USING_I2C
|
||||
select RT_USING_I2C
|
||||
select RT_USING_I2C_BITOPS
|
||||
select RT_USING_PIN
|
||||
if BSP_USING_I2C1
|
||||
choice
|
||||
prompt "I2C1 SCL PIN"
|
||||
default I2C1_SCL_USING_GPIO4 if BSP_USING_BL60X
|
||||
default I2C1_SCL_USING_GPIO10 if BSP_USING_BL61X
|
||||
default I2C1_SCL_USING_GPIO08 if BSP_USING_BL70X
|
||||
default I2C1_SCL_USING_GPIO20 if BSP_USING_BL808
|
||||
|
||||
config I2C1_SCL_USING_GPIO0
|
||||
bool "GPIO_0"
|
||||
config I2C1_SCL_USING_GPIO4
|
||||
bool "GPIO_4"
|
||||
config I2C1_SCL_USING_GPIO8
|
||||
bool "GPIO_8"
|
||||
config I2C1_SCL_USING_GPIO10
|
||||
bool "GPIO_10"
|
||||
config I2C1_SCL_USING_GPIO20
|
||||
bool "GPIO_20"
|
||||
|
||||
endchoice
|
||||
choice
|
||||
prompt "I2C1 SDA PIN"
|
||||
default I2C1_SDA_USING_GPIO3 if BSP_USING_BL60X
|
||||
default I2C1_SDA_USING_GPIO11 if BSP_USING_BL61X
|
||||
default I2C1_SDA_USING_GPIO7 if BSP_USING_BL70X
|
||||
default I2C1_SDA_USING_GPIO21 if BSP_USING_BL808
|
||||
|
||||
config I2C1_SDA_USING_GPIO1
|
||||
bool "GPIO_1"
|
||||
config I2C1_SDA_USING_GPIO3
|
||||
bool "GPIO_3"
|
||||
config I2C1_SDA_USING_GPIO7
|
||||
bool "GPIO_7"
|
||||
config I2C1_SDA_USING_GPIO11
|
||||
bool "GPIO_11"
|
||||
config I2C1_SDA_USING_GPIO21
|
||||
bool "GPIO_21"
|
||||
|
||||
endchoice
|
||||
endif
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -9,8 +9,8 @@ CPPPATH = [cwd]
|
||||
if GetDepend('BSP_USING_GPIO'):
|
||||
src += ['drv_gpio.c']
|
||||
|
||||
if GetDepend('BSP_USING_I2C'):
|
||||
src += ['drv_i2c.c']
|
||||
if GetDepend('RT_USING_I2C'):
|
||||
src += ['drv_soft_i2c.c']
|
||||
|
||||
if GetDepend('BSP_USING_ADC'):
|
||||
src += ['drv_adc.c']
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2023, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2023/04/15 chushicheng first version
|
||||
*/
|
||||
|
||||
#ifndef __DRV_I2C__
|
||||
#define __DRV_I2C__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
/* bl i2c dirver class */
|
||||
struct bl_i2c
|
||||
{
|
||||
struct rt_i2c_bit_ops ops;
|
||||
struct rt_i2c_bus_device i2c2_bus;
|
||||
};
|
||||
|
||||
/* bl config class */
|
||||
struct bl_soft_i2c_config
|
||||
{
|
||||
rt_uint8_t scl;
|
||||
rt_uint8_t sda;
|
||||
const char *bus_name;
|
||||
};
|
||||
|
||||
#ifdef BSP_USING_I2C1
|
||||
#define I2C1_BUS_CONFIG \
|
||||
{ \
|
||||
.scl = BSP_I2C1_SCL_PIN, \
|
||||
.sda = BSP_I2C1_SDA_PIN, \
|
||||
.bus_name = "i2c1", \
|
||||
}
|
||||
#endif
|
||||
|
||||
int rt_hw_i2c_init(void);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user