diff --git a/apps/chrg/.config b/apps/chrg/.config index 6cf8d0c..99e6fec 100644 --- a/apps/chrg/.config +++ b/apps/chrg/.config @@ -257,7 +257,36 @@ CONFIG_RT_USING_I2C=y # CONFIG_RT_I2C_DEBUG is not set CONFIG_RT_USING_I2C_BITOPS=y # CONFIG_RT_I2C_BITOPS_DEBUG is not set -# CONFIG_RT_USING_SOFT_I2C is not set +CONFIG_RT_USING_SOFT_I2C=y +# CONFIG_RT_USING_SOFT_I2C0 is not set +CONFIG_RT_USING_SOFT_I2C1=y +CONFIG_RT_SOFT_I2C1_SCL_PIN=34 +CONFIG_RT_SOFT_I2C1_SDA_PIN=35 +CONFIG_RT_SOFT_I2C1_BUS_NAME="i2c1" +CONFIG_RT_SOFT_I2C1_TIMING_DELAY=25 +CONFIG_RT_SOFT_I2C1_TIMING_TIMEOUT=10 +CONFIG_RT_USING_SOFT_I2C2=y +CONFIG_RT_SOFT_I2C2_SCL_PIN=4 +CONFIG_RT_SOFT_I2C2_SDA_PIN=5 +CONFIG_RT_SOFT_I2C2_BUS_NAME="i2c2" +CONFIG_RT_SOFT_I2C2_TIMING_DELAY=25 +CONFIG_RT_SOFT_I2C2_TIMING_TIMEOUT=10 +CONFIG_RT_USING_SOFT_I2C3=y +CONFIG_RT_SOFT_I2C3_SCL_PIN=36 +CONFIG_RT_SOFT_I2C3_SDA_PIN=37 +CONFIG_RT_SOFT_I2C3_BUS_NAME="i2c3" +CONFIG_RT_SOFT_I2C3_TIMING_DELAY=25 +CONFIG_RT_SOFT_I2C3_TIMING_TIMEOUT=10 +CONFIG_RT_USING_SOFT_I2C4=y +CONFIG_RT_SOFT_I2C4_SCL_PIN=30 +CONFIG_RT_SOFT_I2C4_SDA_PIN=31 +CONFIG_RT_SOFT_I2C4_BUS_NAME="i2c4" +CONFIG_RT_SOFT_I2C4_TIMING_DELAY=25 +CONFIG_RT_SOFT_I2C4_TIMING_TIMEOUT=10 +# CONFIG_RT_USING_SOFT_I2C5 is not set +# CONFIG_RT_USING_SOFT_I2C6 is not set +# CONFIG_RT_USING_SOFT_I2C7 is not set +# CONFIG_RT_USING_SOFT_I2C8 is not set # CONFIG_RT_USING_PHY is not set # CONFIG_RT_USING_PHY_V2 is not set # CONFIG_RT_USING_ADC is not set @@ -1460,11 +1489,7 @@ CONFIG_BSP_UART3_TX_USING_DMA=y CONFIG_BSP_USING_UART6=y CONFIG_BSP_UART6_RX_USING_DMA=y CONFIG_BSP_UART6_TX_USING_DMA=y -CONFIG_BSP_USING_I2C=y -CONFIG_BSP_USING_I2C1=y -CONFIG_BSP_USING_I2C2=y -CONFIG_BSP_USING_I2C3=y -CONFIG_BSP_USING_I2C4=y +# CONFIG_BSP_USING_I2C is not set # CONFIG_BSP_USING_CAN is not set # CONFIG_BSP_USING_ADC is not set # CONFIG_BSP_USING_ONCHIP_RTC is not set diff --git a/apps/chrg/applications/bsp/chrg_i2c.c b/apps/chrg/applications/bsp/chrg_i2c.c index f0c0ed4..1d00238 100644 --- a/apps/chrg/applications/bsp/chrg_i2c.c +++ b/apps/chrg/applications/bsp/chrg_i2c.c @@ -7,29 +7,37 @@ #define DBG_LEVEL DBG_LOG #include -struct chrg_i2c_t chrgi2c[TOTAL_I2C] = { +struct chrg_i2c_t chrgi2c[TOTAL_I2CS] = { [IDX_I2C_1] = { .dev = RT_NULL, .name = DEV_NAME_I2C1, .slave = SLAVE_PCF8574_ADDR, + .opened = 0, + .port_value = 0, .index = IDX_I2C_1, }, [IDX_I2C_2] = { .dev = RT_NULL, .name = DEV_NAME_I2C2, .slave = SLAVE_PCF8574_ADDR, + .opened = 0, + .port_value = 0, .index = IDX_I2C_2, }, [IDX_I2C_3] = { .dev = RT_NULL, .name = DEV_NAME_I2C3, .slave = SLAVE_PCF8574_ADDR, + .opened = 0, + .port_value = 0, .index = IDX_I2C_3, }, [IDX_I2C_4] = { .dev = RT_NULL, .name = DEV_NAME_I2C4, .slave = SLAVE_PCF8574_ADDR, + .opened = 0, + .port_value = 0, .index = IDX_I2C_4, } }; @@ -83,14 +91,24 @@ static int chrg_i2c_init (void) { struct chrg_i2c_t *pI2C = RT_NULL; int i = 0; + rt_err_t ret = RT_EOK; - for (i = 0; i < TOTAL_I2C; i++) { + for (i = 0; i < TOTAL_I2CS; i++) { pI2C = &chrgi2c[i]; pI2C->dev = (struct rt_i2c_bus_device *)rt_device_find(pI2C->name); if (RT_NULL == pI2C->dev) { LOG_E("dev '%s' not found.", pI2C->name); continue; } + + ret = rt_device_open(&pI2C->dev->parent, RT_NULL); + if (RT_EOK != ret) { + LOG_E("open '%s' failed.", pI2C->name); + pI2C->opened = 0; + continue; + } + + pI2C->opened = 1; } return RT_EOK; diff --git a/apps/chrg/applications/bsp/chrg_i2c.h b/apps/chrg/applications/bsp/chrg_i2c.h index 095018a..3616c50 100644 --- a/apps/chrg/applications/bsp/chrg_i2c.h +++ b/apps/chrg/applications/bsp/chrg_i2c.h @@ -4,7 +4,7 @@ #include #include -#define SLAVE_PCF8574_ADDR 0x40 +#define SLAVE_PCF8574_ADDR 0x20 #define DEV_NAME_I2C1 "i2c1" #define DEV_NAME_I2C2 "i2c2" @@ -17,7 +17,7 @@ typedef enum { IDX_I2C_3, // 2 IDX_I2C_4, // 3 - TOTAL_I2C + TOTAL_I2CS } eIDX_I2C; @@ -25,11 +25,13 @@ struct chrg_i2c_t { struct rt_i2c_bus_device *dev; const char *name; rt_uint8_t slave; // slave chip addr - eIDX_I2C index; - + rt_uint8_t opened; // 已开启I2C + rt_uint8_t port_value; // pcf8574 IO值 + eIDX_I2C index; // 索引 + }; -extern struct chrg_i2c_t chrgi2c[TOTAL_I2C]; +extern struct chrg_i2c_t chrgi2c[TOTAL_I2CS]; extern rt_uint8_t i2c_read_byte(struct chrg_i2c_t *pI2C, rt_uint8_t addr); diff --git a/apps/chrg/applications/bsp/chrg_intr.c b/apps/chrg/applications/bsp/chrg_intr.c index d28456a..cd8cc6f 100644 --- a/apps/chrg/applications/bsp/chrg_intr.c +++ b/apps/chrg/applications/bsp/chrg_intr.c @@ -3,12 +3,14 @@ #include #include "chrg_intr.h" +#include "chrg_i2c.h" +#include "chrg_pcf8574.h" #define LOG_TAG "chrg.intr" #define DBG_LEVEL DBG_LOG #include -struct chrg_intr_t chrgintr[TOTAL_INTR] = { +struct chrg_intr_t chrgintr[TOTAL_INTRS] = { [IDX_INTR_I2C1] = { .name = NAME_INTR_I2C1, .index = IDX_INTR_I2C1, @@ -76,11 +78,12 @@ static void chrg_intr_callback (void *args) struct chrg_intr_t *pINTR = (struct chrg_intr_t *)args; if (RT_NULL != pINTR) { - pINTR->value = rt_pin_read(pINTR->pin); - if (pINTR->delay) { - rt_timer_start(pINTR->tmr_fd); - } - LOG_I("pin '%s' intr %d.", pINTR->name, pINTR->value); + chrg_pcf8574_get_port((eIDX_I2C)pINTR->index); + //pINTR->value = rt_pin_read(pINTR->pin); + //if (pINTR->delay) { + // rt_timer_start(pINTR->tmr_fd); + //} + //LOG_I("pin '%s' intr %d.", pINTR->name, pINTR->value); } } @@ -90,7 +93,7 @@ static int chrg_intr_init (void) int i = 0; struct chrg_intr_t *pINTR = RT_NULL; - for (i = 0; i < TOTAL_INTR; i++) { + for (i = 0; i < TOTAL_INTRS; i++) { pINTR = &chrgintr[i]; rt_pin_mode(pINTR->pin, pINTR->mode); diff --git a/apps/chrg/applications/bsp/chrg_intr.h b/apps/chrg/applications/bsp/chrg_intr.h index 43a87f7..96777e8 100644 --- a/apps/chrg/applications/bsp/chrg_intr.h +++ b/apps/chrg/applications/bsp/chrg_intr.h @@ -6,6 +6,8 @@ #include "drv_gpio.h" +#include "chrg_i2c.h" + #define NAME_INTR_I2C1 "i2c1irq" #define NAME_INTR_I2C2 "i2c2irq" #define NAME_INTR_I2C3 "i2c3irq" @@ -17,12 +19,12 @@ #define PIN_INTR_I2C4 GET_PIN(B, 13) typedef enum { - IDX_INTR_I2C1 = 0, // 0 - IDX_INTR_I2C2, // 1 - IDX_INTR_I2C3, // 2 - IDX_INTR_I2C4, // 3 + IDX_INTR_I2C1 = IDX_I2C_1, // 0 中断脚关联 I2C1 + IDX_INTR_I2C2 = IDX_I2C_2, // 1 中断脚关联 I2C2 + IDX_INTR_I2C3 = IDX_I2C_3, // 2 中断脚关联 I2C3 + IDX_INTR_I2C4 = IDX_I2C_4, // 3 中断脚关联 I2C4 - TOTAL_INTR + TOTAL_INTRS } eIDX_INTR; struct chrg_intr_t { @@ -36,7 +38,7 @@ struct chrg_intr_t { eIDX_INTR index; }; -extern struct chrg_intr_t chrgintr[TOTAL_INTR]; +extern struct chrg_intr_t chrgintr[TOTAL_INTRS]; #endif diff --git a/apps/chrg/applications/bsp/chrg_tty.h b/apps/chrg/applications/bsp/chrg_tty.h index 82d6b3b..afe8061 100644 --- a/apps/chrg/applications/bsp/chrg_tty.h +++ b/apps/chrg/applications/bsp/chrg_tty.h @@ -14,13 +14,10 @@ typedef enum { IDX_TTY_NORTH, // 1 IDX_TTY_SOUTH, // 2 - TOTAL_TTY + TOTAL_TTYS } eIDX_TTY; -//#define TTY_USING_TEST //使用测试功能 -//#define TTY_USING_SAMPLE_SLAVE //使用从机示例 -//#define TTY_USING_SAMPLE_MASTER //使用主机示例 //#define TTY_USING_DMA_RX //使用DMA接收 //#define TTY_USING_INT_TX //使用中断发送 //#define TTY_USING_DMA_TX //使用DMA发送 diff --git a/apps/chrg/applications/utils/chrg_pcf8574.c b/apps/chrg/applications/utils/chrg_pcf8574.c index d8466c4..61b17b0 100644 --- a/apps/chrg/applications/utils/chrg_pcf8574.c +++ b/apps/chrg/applications/utils/chrg_pcf8574.c @@ -1,4 +1,132 @@ +#include +#include +#include +#include "chrg_i2c.h" #include "chrg_pcf8574.h" +#define LOG_TAG "chrg.pcf" +#define DBG_LEVEL DBG_LOG +#include + + +// 读取所有8口IO状态 +rt_uint8_t chrg_pcf8574_get_port (eIDX_I2C idx) +{ + rt_uint8_t value = 0; + if (idx >= TOTAL_I2CS) { + return 0; + } + + rt_ssize_t ret = 0; + struct chrg_i2c_t *pI2C = &chrgi2c[idx]; + + if (!pI2C->opened) { + return 0; + } + + ret = rt_device_read(&pI2C->dev->parent, pI2C->slave, &value, 1); + if (ret <= 0) { + LOG_E("read failed. [%d]", ret); + return 0; + } + + pI2C->port_value = value; + + return value; +} + +// 读取指定管脚状态值 +rt_uint8_t chrg_pcf8574_get_pin (eIDX_I2C idx, uint8_t bit) +{ + rt_uint8_t data = chrg_pcf8574_get_port(idx); + if (data & (1 << bit)) { + return 1; + } + + return 0; +} + +// 设置所有8口IO状态值 +int chrg_pcf8574_set_port (eIDX_I2C idx, uint8_t value) +{ + if (idx >= TOTAL_I2CS) { + return -1; + } + + rt_ssize_t ret = 0; + struct chrg_i2c_t *pI2C = &chrgi2c[idx]; + + if (!pI2C->opened) { + return -1; + } + + ret = rt_device_write(&pI2C->dev->parent, pI2C->slave, &value, 1); + + return ret; +} + +// 设置指定管脚状态值 +int chrg_pcf8574_set_pin (eIDX_I2C idx, uint8_t bit, uint8_t value) +{ + if (idx >= TOTAL_I2CS) { + return -1; + } + + int ret = 0; + struct chrg_i2c_t *pI2C = &chrgi2c[idx]; + + if (!pI2C->opened) { + return -1; + } + + rt_uint8_t data = chrg_pcf8574_get_port(idx); + if (value == 0) { + data &= ~(1 << bit); + } else { + data |= 1 << bit; + } + + ret = chrg_pcf8574_set_port(idx, data); + + return ret; +} + +#if 1 +int pcf_test (int argc, char **argv) +{ + if (argc < 3) { + rt_kprintf("help : %s <0|1|2|3> [0, 255]", argv[0]); + return -1; + } + + int idx = atoi(argv[2]); + if ((idx > 3)||(idx < 0)) { + rt_kprintf("help : %s <0|1|2|3> [0, 255]", argv[0]); + return -1; + } + + if (strcmp(argv[1], "set") == 0) { + if (argc != 4) { + rt_kprintf("help : %s <0|1|2|3> [0, 255]", argv[0]); + return -1; + } + rt_uint8_t val = (rt_uint8_t)atoi(argv[3]); + chrg_pcf8574_set_port((eIDX_I2C)idx, val); + } else if (strcmp(argv[1], "get") == 0) { + rt_uint8_t data = chrg_pcf8574_get_port((eIDX_I2C)idx); + rt_kprintf("value : 0x%02X", data); + } else { + return -1; + } + + return 0; +} + +MSH_CMD_EXPORT(pcf_test, test pcf8574 port/pin.); + +#endif + + + diff --git a/apps/chrg/applications/utils/chrg_pcf8574.h b/apps/chrg/applications/utils/chrg_pcf8574.h index 0ff5ba3..e159358 100644 --- a/apps/chrg/applications/utils/chrg_pcf8574.h +++ b/apps/chrg/applications/utils/chrg_pcf8574.h @@ -1,6 +1,22 @@ #ifndef __CHRG_PCF8574_H__ #define __CHRG_PCF8574_H__ +#include +#include +#include "chrg_i2c.h" + +// 读取所有8口IO状态 +extern rt_uint8_t chrg_pcf8574_get_port (eIDX_I2C idx); + +// 读取指定管脚状态值 +extern rt_uint8_t chrg_pcf8574_get_pin (eIDX_I2C idx, uint8_t bit); + +// 设置所有8口IO状态值 +extern int chrg_pcf8574_set_port (eIDX_I2C idx, uint8_t value); + +// 设置指定管脚状态值 +extern int chrg_pcf8574_set_pin (eIDX_I2C idx, uint8_t bit, uint8_t value); + #endif diff --git a/apps/chrg/applications/utils/chrg_pkg.c b/apps/chrg/applications/utils/chrg_pkg.c index f483055..e07498c 100644 --- a/apps/chrg/applications/utils/chrg_pkg.c +++ b/apps/chrg/applications/utils/chrg_pkg.c @@ -43,6 +43,8 @@ int chrg_pkg_send (eIDX_TTY idx, rt_uint8_t *data, rt_uint16_t len) case IDX_TTY_SOUTH: // pTTY = chrgsouth.tty; break; + default: + return -1; } if ((RT_NULL != pTTY)&&(RT_NULL != pTTY->dev)) { diff --git a/apps/chrg/board/Kconfig b/apps/chrg/board/Kconfig index 8643250..82e82ff 100644 --- a/apps/chrg/board/Kconfig +++ b/apps/chrg/board/Kconfig @@ -232,19 +232,19 @@ menu "On-chip Peripheral Drivers" default n select RT_USING_I2C if BSP_USING_I2C - config BSP_USING_I2C1 + config BSP_USING_HARD_I2C1 bool "Enable I2C1 BUS" default n - config BSP_USING_I2C2 + config BSP_USING_HARD_I2C2 bool "Enable I2C2 BUS" default n - config BSP_USING_I2C3 + config BSP_USING_HARD_I2C3 bool "Enable I2C3 BUS" default n - config BSP_USING_I2C4 + config BSP_USING_HARD_I2C4 bool "Enable I2C4 BUS" default n diff --git a/apps/chrg/chrg.uvprojx b/apps/chrg/chrg.uvprojx index 665372b..24bfff4 100644 --- a/apps/chrg/chrg.uvprojx +++ b/apps/chrg/chrg.uvprojx @@ -337,9 +337,9 @@ 0 - USE_HAL_DRIVER, __RTTHREAD__, RT_USING_LIBC, RT_USING_ARMLIBC, __CLK_TCK=RT_TICK_PER_SECOND, STM32F405xx, __STDC_LIMIT_MACROS + RT_USING_ARMLIBC, RT_USING_LIBC, __RTTHREAD__, __STDC_LIMIT_MACROS, STM32F405xx, __CLK_TCK=RT_TICK_PER_SECOND, USE_HAL_DRIVER - ..\..\rt-thread\components\drivers\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;..\..\libs\stm32f4\STM32F4_HAL\Inc;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;.;board;..\..\rt-thread\include;..\..\rt-thread\components\drivers\include;board\ports;applications;..\..\rt-thread\components\drivers\phy;..\..\libs\cmsis-core\Include;..\..\rt-thread\components\libc\posix\io\poll;..\..\rt-thread\components\libc\compilers\common\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\smp_call;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_flash;..\..\rt-thread\components\libc\posix\io\epoll;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\ipc;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\rt-thread\components\fal\inc;applications\utils;..\..\rt-thread\components\drivers\include;applications\thread;board\CubeMX_Config\Inc;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\components\legacy\usb\usbdevice;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;..\..\rt-thread\components\finsh;applications\bsp;..\..\rt-thread\libcpu\arm\common;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\io\eventfd;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\compilers\common\extension;..\..\rt-thread\libcpu\arm\cortex-m4;..\..\rt-thread\components\drivers\include + ..\..\rt-thread\libcpu\arm\common;..\..\rt-thread\components\finsh;board;..\..\rt-thread\components\libc\posix\io\eventfd;..\..\rt-thread\components\drivers\phy;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;.;applications;..\..\rt-thread\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;..\..\rt-thread\components\libc\posix\io\poll;..\..\rt-thread\components\drivers\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_flash;..\..\rt-thread\components\libc\posix\io\epoll;applications\thread;..\..\rt-thread\components\fal\inc;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\compilers\common\extension;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\ipc;..\..\rt-thread\components\libc\compilers\common\include;applications\utils;..\..\libs\cmsis-core\Include;board\CubeMX_Config\Inc;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;applications\bsp;..\..\rt-thread\components\drivers\include;..\..\rt-thread\libcpu\arm\cortex-m4;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;..\..\rt-thread\components\drivers\smp_call;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\legacy\usb\usbdevice;board\ports;..\..\rt-thread\components\drivers\include;..\..\libs\stm32f4\STM32F4_HAL\Inc;..\..\rt-thread\components\drivers\include @@ -393,35 +393,20 @@ Applications/bsp - - chrg_fal.c - 1 - applications\bsp\chrg_fal.c - - - chrg_switch.c - 1 - applications\bsp\chrg_switch.c - chrg_pin.c 1 applications\bsp\chrg_pin.c - - chrg_vcom.c - 1 - applications\bsp\chrg_vcom.c - chrg_tmr.c 1 applications\bsp\chrg_tmr.c - chrg_tty.c + chrg_wdt.c 1 - applications\bsp\chrg_tty.c + applications\bsp\chrg_wdt.c chrg_i2c.c @@ -429,40 +414,50 @@ applications\bsp\chrg_i2c.c - chrg_wdt.c + chrg_fal.c 1 - applications\bsp\chrg_wdt.c + applications\bsp\chrg_fal.c - chrg_intr.c + chrg_vcom.c 1 - applications\bsp\chrg_intr.c + applications\bsp\chrg_vcom.c + + + chrg_tty.c + 1 + applications\bsp\chrg_tty.c chrg_clk.c 1 applications\bsp\chrg_clk.c + + chrg_switch.c + 1 + applications\bsp\chrg_switch.c + + + chrg_intr.c + 1 + applications\bsp\chrg_intr.c + Applications/thread - chrg_lcd.c + chrg_north.c 1 - applications\thread\chrg_lcd.c + applications\thread\chrg_north.c chrg_south.c 1 applications\thread\chrg_south.c - - chrg_north.c - 1 - applications\thread\chrg_north.c - chrg_comm.c 1 @@ -473,6 +468,11 @@ 1 applications\thread\chrg_roll.c + + chrg_lcd.c + 1 + applications\thread\chrg_lcd.c + @@ -483,16 +483,16 @@ 1 applications\utils\chrg_sink.c - - chrg_utils.c - 1 - applications\utils\chrg_utils.c - chrg_pkg.c 1 applications\utils\chrg_pkg.c + + chrg_utils.c + 1 + applications\utils\chrg_utils.c + chrg_pcf8574.c 1 @@ -889,6 +889,62 @@ + + dev_soft_i2c.c + 1 + ..\..\rt-thread\components\drivers\i2c\dev_soft_i2c.c + + + 2 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + __RT_IPC_SOURCE__ + + + + + + + completion_comm.c 1 @@ -1591,11 +1647,6 @@ 1 ..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_gpio.c - - drv_soft_i2c.c - 1 - ..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_soft_i2c.c - drv_tim.c 1 @@ -1632,9 +1683,9 @@ ..\..\rt-thread\components\fal\src\fal_partition.c - fal_rtt.c + fal.c 1 - ..\..\rt-thread\components\fal\src\fal_rtt.c + ..\..\rt-thread\components\fal\src\fal.c fal_flash.c @@ -1642,25 +1693,25 @@ ..\..\rt-thread\components\fal\src\fal_flash.c - fal.c + fal_rtt.c 1 - ..\..\rt-thread\components\fal\src\fal.c + ..\..\rt-thread\components\fal\src\fal_rtt.c Finsh - - shell.c - 1 - ..\..\rt-thread\components\finsh\shell.c - cmd.c 1 ..\..\rt-thread\components\finsh\cmd.c + + shell.c + 1 + ..\..\rt-thread\components\finsh\shell.c + msh_parse.c 1 @@ -2521,11 +2572,6 @@ klibc - - kstdio.c - 1 - ..\..\rt-thread\src\klibc\kstdio.c - rt_vsnprintf_tiny.c 1 @@ -2546,6 +2592,11 @@ 1 ..\..\rt-thread\src\klibc\rt_vsscanf.c + + kstdio.c + 1 + ..\..\rt-thread\src\klibc\kstdio.c + @@ -2581,11 +2632,6 @@ rt_usbd - - cdc_vcom.c - 1 - ..\..\rt-thread\components\legacy\usb\usbdevice\class\cdc_vcom.c - usbdevice_core.c 1 @@ -2596,85 +2642,35 @@ 1 ..\..\rt-thread\components\legacy\usb\usbdevice\core\usbdevice.c + + cdc_vcom.c + 1 + ..\..\rt-thread\components\legacy\usb\usbdevice\class\cdc_vcom.c + STM32F4-CMSIS - - startup_stm32f405xx.s - 2 - ..\..\libs\stm32f4\STM32F4_CMSIS\Source\Templates\arm\startup_stm32f405xx.s - system_stm32f4xx.c 1 ..\..\libs\stm32f4\STM32F4_CMSIS\Source\Templates\system_stm32f4xx.c + + startup_stm32f405xx.s + 2 + ..\..\libs\stm32f4\STM32F4_CMSIS\Source\Templates\arm\startup_stm32f405xx.s + STM32F4-HAL - stm32f4xx_hal_tim.c + stm32f4xx_hal_uart.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim.c - - - stm32f4xx_hal_flash_ramfunc.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ramfunc.c - - - stm32f4xx_hal_pwr_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_ex.c - - - stm32f4xx_hal_cryp_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp_ex.c - - - stm32f4xx_hal_rcc.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc.c - - - stm32f4xx_hal_flash.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash.c - - - stm32f4xx_hal_tim_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim_ex.c - - - stm32f4xx_hal.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal.c - - - stm32f4xx_hal_dma_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma_ex.c - - - stm32f4xx_hal_pccard.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pccard.c - - - stm32f4xx_hal_flash_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ex.c - - - stm32f4xx_hal_dma.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_uart.c stm32f4xx_ll_usb.c @@ -2682,39 +2678,19 @@ ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_ll_usb.c - stm32f4xx_hal_wwdg.c + stm32f4xx_hal_crc.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_wwdg.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_crc.c - stm32f4xx_hal_rng.c + stm32f4xx_hal.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal.c - stm32f4xx_hal_hcd.c + stm32f4xx_hal_flash_ex.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_hcd.c - - - stm32f4xx_hal_cec.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cec.c - - - stm32f4xx_hal_pwr.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr.c - - - stm32f4xx_hal_uart.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_uart.c - - - stm32f4xx_hal_lptim.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_lptim.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ex.c stm32f4xx_hal_pcd_ex.c @@ -2722,39 +2698,24 @@ ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd_ex.c - stm32f4xx_hal_gpio.c + stm32f4xx_hal_pwr_ex.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_gpio.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_ex.c - stm32f4xx_hal_usart.c + stm32f4xx_hal_rng.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_usart.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c - stm32f4xx_hal_pcd.c + stm32f4xx_hal_tim_ex.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim_ex.c - stm32f4xx_hal_crc.c + stm32f4xx_hal_tim.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_crc.c - - - stm32f4xx_hal_cryp.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp.c - - - stm32f4xx_hal_rcc_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc_ex.c - - - stm32f4xx_hal_can.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_can.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim.c stm32f4xx_hal_iwdg.c @@ -2766,11 +2727,101 @@ 1 ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c.c + + stm32f4xx_hal_flash.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash.c + stm32f4xx_hal_i2c_ex.c 1 ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c_ex.c + + stm32f4xx_hal_rcc_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc_ex.c + + + stm32f4xx_hal_pcd.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd.c + + + stm32f4xx_hal_can.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_can.c + + + stm32f4xx_hal_pccard.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pccard.c + + + stm32f4xx_hal_dma.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma.c + + + stm32f4xx_hal_flash_ramfunc.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ramfunc.c + + + stm32f4xx_hal_cec.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cec.c + + + stm32f4xx_hal_cryp_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp_ex.c + + + stm32f4xx_hal_gpio.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_gpio.c + + + stm32f4xx_hal_pwr.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr.c + + + stm32f4xx_hal_usart.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_usart.c + + + stm32f4xx_hal_rcc.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc.c + + + stm32f4xx_hal_hcd.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_hcd.c + + + stm32f4xx_hal_wwdg.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_wwdg.c + + + stm32f4xx_hal_cryp.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp.c + + + stm32f4xx_hal_lptim.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_lptim.c + + + stm32f4xx_hal_dma_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma_ex.c + stm32f4xx_hal_cortex.c 1 diff --git a/apps/chrg/rtconfig.h b/apps/chrg/rtconfig.h index 94a379a..57a2484 100644 --- a/apps/chrg/rtconfig.h +++ b/apps/chrg/rtconfig.h @@ -160,6 +160,31 @@ #define RT_CANSND_MSG_TIMEOUT 100 #define RT_USING_I2C #define RT_USING_I2C_BITOPS +#define RT_USING_SOFT_I2C +#define RT_USING_SOFT_I2C1 +#define RT_SOFT_I2C1_SCL_PIN 34 +#define RT_SOFT_I2C1_SDA_PIN 35 +#define RT_SOFT_I2C1_BUS_NAME "i2c1" +#define RT_SOFT_I2C1_TIMING_DELAY 25 +#define RT_SOFT_I2C1_TIMING_TIMEOUT 10 +#define RT_USING_SOFT_I2C2 +#define RT_SOFT_I2C2_SCL_PIN 4 +#define RT_SOFT_I2C2_SDA_PIN 5 +#define RT_SOFT_I2C2_BUS_NAME "i2c2" +#define RT_SOFT_I2C2_TIMING_DELAY 25 +#define RT_SOFT_I2C2_TIMING_TIMEOUT 10 +#define RT_USING_SOFT_I2C3 +#define RT_SOFT_I2C3_SCL_PIN 36 +#define RT_SOFT_I2C3_SDA_PIN 37 +#define RT_SOFT_I2C3_BUS_NAME "i2c3" +#define RT_SOFT_I2C3_TIMING_DELAY 25 +#define RT_SOFT_I2C3_TIMING_TIMEOUT 10 +#define RT_USING_SOFT_I2C4 +#define RT_SOFT_I2C4_SCL_PIN 30 +#define RT_SOFT_I2C4_SDA_PIN 31 +#define RT_SOFT_I2C4_BUS_NAME "i2c4" +#define RT_SOFT_I2C4_TIMING_DELAY 25 +#define RT_SOFT_I2C4_TIMING_TIMEOUT 10 #define RT_USING_WDT #define RT_USING_PIN #define RT_USING_HWTIMER @@ -446,11 +471,6 @@ #define BSP_USING_UART6 #define BSP_UART6_RX_USING_DMA #define BSP_UART6_TX_USING_DMA -#define BSP_USING_I2C -#define BSP_USING_I2C1 -#define BSP_USING_I2C2 -#define BSP_USING_I2C3 -#define BSP_USING_I2C4 #define BSP_USING_WDT #define BSP_USING_USBD #define BSP_USING_ON_CHIP_FLASH diff --git a/rt-thread/bsp/stm32/libraries/HAL_Drivers/drivers/SConscript b/rt-thread/bsp/stm32/libraries/HAL_Drivers/drivers/SConscript index a9c7728..2f0b8fc 100644 --- a/rt-thread/bsp/stm32/libraries/HAL_Drivers/drivers/SConscript +++ b/rt-thread/bsp/stm32/libraries/HAL_Drivers/drivers/SConscript @@ -32,10 +32,10 @@ if GetDepend(['RT_USING_QSPI']): if GetDepend('RT_USING_SOFT_SPI'): src += ['drv_soft_spi.c'] -if GetDepend(['RT_USING_I2C', 'RT_USING_I2C_BITOPS']): - if GetDepend('BSP_USING_I2C1') or GetDepend('BSP_USING_I2C2') or GetDepend('BSP_USING_I2C3') or GetDepend('BSP_USING_I2C4'): - src += ['drv_soft_i2c.c'] - +#if GetDepend(['RT_USING_I2C', 'RT_USING_I2C_BITOPS']): +# if GetDepend('BSP_USING_I2C1') or GetDepend('BSP_USING_I2C2') or GetDepend('BSP_USING_I2C3') or GetDepend('BSP_USING_I2C4'): +# src += ['drv_soft_i2c.c'] + if GetDepend(['RT_USING_I2C']): if GetDepend('BSP_USING_HARD_I2C1') or GetDepend('BSP_USING_HARD_I2C2') or GetDepend('BSP_USING_HARD_I2C3') or GetDepend('BSP_USING_HARD_I2C4'): src += ['drv_hard_i2c.c'] diff --git a/rt-thread/components/libc/compilers/common/cwchar.c b/rt-thread/components/libc/compilers/common/cwchar.c index efa0a7c..8921f9c 100644 --- a/rt-thread/components/libc/compilers/common/cwchar.c +++ b/rt-thread/components/libc/compilers/common/cwchar.c @@ -112,13 +112,7 @@ int wcwidth(wchar_t ucs) (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */ (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */ (ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */ - (ucs >= 0xffe0 && ucs <= 0xffe6) || - #ifndef _WIN32 - (ucs >= 0x20000 && ucs <= 0x2ffff) - #else - 0 - #endif - )); + (ucs >= 0xffe0 && ucs <= 0xffe6))); } int wcswidth(const wchar_t *pwcs, size_t n)