mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-07 00:59:00 +08:00
[bsp][lpc55s69]add softi2c (#7221)
This commit is contained in:
@@ -49,6 +49,9 @@ if GetDepend('BSP_USING_I2S'):
|
||||
if GetDepend('BSP_USING_WM8904'):
|
||||
src += ['drv_sound_wm8904.c']
|
||||
|
||||
if GetDepend('BSP_USING_SOFT_I2C'):
|
||||
src += ['drv_soft_i2c.c']
|
||||
|
||||
path = [cwd,cwd + '/config']
|
||||
|
||||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2023, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2023-04-11 linshrie first version
|
||||
*/
|
||||
|
||||
#ifndef __DRV_I2C__
|
||||
#define __DRV_I2C__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
/* lpc55s69 config class */
|
||||
struct lpc55s69_soft_i2c_config
|
||||
{
|
||||
rt_uint8_t scl;
|
||||
rt_uint8_t sda;
|
||||
const char *bus_name;
|
||||
};
|
||||
/* lpc55s69 i2c dirver class */
|
||||
struct lpc55s69_i2c
|
||||
{
|
||||
struct rt_i2c_bit_ops ops;
|
||||
struct rt_i2c_bus_device i2c2_bus;
|
||||
};
|
||||
|
||||
#ifdef BSP_USING_SOFT_I2C1
|
||||
#define SOFT_I2C1_BUS_CONFIG \
|
||||
{ \
|
||||
.scl = BSP_SOFT_I2C1_SCL_PIN, \
|
||||
.sda = BSP_SOFT_I2C1_SCL_PIN, \
|
||||
.bus_name = "i2c1", \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_SOFT_I2C2
|
||||
#define SOFT_I2C2_BUS_CONFIG \
|
||||
{ \
|
||||
.scl = BSP_SOFT_I2C2_SCL_PIN, \
|
||||
.sda = BSP_SOFT_I2C2_SCL_PIN, \
|
||||
.bus_name = "i2c2", \
|
||||
}
|
||||
#endif /*BSP_USING_I2C2*/
|
||||
|
||||
int rt_hw_i2c_init(void);
|
||||
|
||||
#endif
|
||||
@@ -116,6 +116,48 @@ menu "On-chip Peripheral Drivers"
|
||||
endchoice
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_SOFT_I2C
|
||||
bool "Enable I2C Bus"
|
||||
select RT_USING_I2C
|
||||
select RT_USING_I2C_BITOPS
|
||||
select RT_USING_PIN
|
||||
default n
|
||||
|
||||
if BSP_USING_SOFT_I2C
|
||||
config BSP_USING_SOFT_I2C1
|
||||
bool "Enable I2C1 Bus (software simulation)"
|
||||
default n
|
||||
|
||||
if BSP_USING_SOFT_I2C1
|
||||
comment "Notice: PB10 --> 26; PB11 --> 27"
|
||||
|
||||
config BSP_SOFT_I2C1_SCL_PIN
|
||||
int "i2c1 SCL pin number"
|
||||
range 0 79
|
||||
default 26
|
||||
config BSP_SOFT_I2C1_SDA_PIN
|
||||
int "i2c1 SDA pin number"
|
||||
range 0 79
|
||||
default 27
|
||||
endif
|
||||
|
||||
config BSP_USING_SOFT_I2C2
|
||||
bool "Enable I2C2 Bus (software simulation)"
|
||||
default n
|
||||
|
||||
if BSP_USING_SOFT_I2C2
|
||||
comment "Notice: PC1 --> 33; PC0 --> 32"
|
||||
config BSP_SOFT_I2C2_SCL_PIN
|
||||
int "i2c2 SCL pin number"
|
||||
range 0 79
|
||||
default 32
|
||||
config BSP_SOFT_I2C2_SDA_PIN
|
||||
int "i2c2 SDA pin number"
|
||||
range 0 79
|
||||
default 33
|
||||
endif
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_SPI
|
||||
config BSP_USING_SPI
|
||||
|
||||
@@ -18,3 +18,20 @@ def dist_do_building(BSP_ROOT, dist_dir):
|
||||
print("=> copy bsp library")
|
||||
bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE))
|
||||
shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
|
||||
|
||||
# change RTT_ROOT in Kconfig
|
||||
if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')):
|
||||
return
|
||||
|
||||
with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
|
||||
data = f.readlines()
|
||||
with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
|
||||
found = 0
|
||||
for line in data:
|
||||
if line.find('RTT_ROOT') != -1:
|
||||
found = 1
|
||||
if line.find('../Libraries') != -1 and found:
|
||||
position = line.find('../Libraries')
|
||||
line = line[0:position] + 'Libraries/Kconfig"\n'
|
||||
found = 0
|
||||
f.write(line)
|
||||
|
||||
Reference in New Issue
Block a user