From 050eb19fc8afc6a94ad5a9fe198f199651ebed13 Mon Sep 17 00:00:00 2001 From: wmano Date: Sat, 30 Aug 2025 23:48:55 +0800 Subject: [PATCH] add more files --- apps/chrg/applications/SConscript | 4 - apps/chrg/applications/bsp/SConscript | 16 + apps/chrg/applications/bsp/chrg_can.c | 3 + apps/chrg/applications/bsp/chrg_clk.c | 4 + apps/chrg/applications/bsp/chrg_fal.c | 5 +- apps/chrg/applications/bsp/chrg_i2c.c | 5 +- apps/chrg/applications/bsp/chrg_intr.c | 10 +- apps/chrg/applications/bsp/chrg_pin.c | 6 +- apps/chrg/applications/bsp/chrg_switch.c | 36 ++ apps/chrg/applications/bsp/chrg_tmr.c | 5 +- apps/chrg/applications/bsp/chrg_tty.c | 146 ++--- apps/chrg/applications/bsp/chrg_tty.h | 19 +- apps/chrg/applications/bsp/chrg_wdt.c | 4 + apps/chrg/applications/thread/SConscript | 16 + apps/chrg/applications/thread/chrg_comm.c | 7 + apps/chrg/applications/thread/chrg_comm.h | 9 + apps/chrg/applications/thread/chrg_lcd.c | 4 + apps/chrg/applications/thread/chrg_lcd.h | 7 + apps/chrg/applications/thread/chrg_north.c | 72 ++- apps/chrg/applications/thread/chrg_north.h | 14 +- apps/chrg/applications/thread/chrg_south.c | 78 ++- apps/chrg/applications/thread/chrg_south.h | 13 +- apps/chrg/applications/utils/SConscript | 16 + apps/chrg/applications/utils/chrg_pcf8574.c | 4 + apps/chrg/applications/utils/chrg_pcf8574.h | 7 + apps/chrg/applications/utils/chrg_sink.c | 4 + apps/chrg/applications/utils/chrg_sink.h | 37 ++ apps/chrg/applications/utils/chrg_source.c | 4 + apps/chrg/applications/utils/chrg_source.h | 7 + apps/chrg/applications/utils/chrg_utils.c | 43 ++ apps/chrg/applications/utils/chrg_utils.h | 11 + apps/chrg/project.uvprojx | 682 +++++++++++--------- keilkill.bat | 1 - 33 files changed, 820 insertions(+), 479 deletions(-) create mode 100644 apps/chrg/applications/bsp/SConscript create mode 100644 apps/chrg/applications/thread/SConscript create mode 100644 apps/chrg/applications/thread/chrg_comm.c create mode 100644 apps/chrg/applications/thread/chrg_comm.h create mode 100644 apps/chrg/applications/thread/chrg_lcd.c create mode 100644 apps/chrg/applications/thread/chrg_lcd.h create mode 100644 apps/chrg/applications/utils/SConscript create mode 100644 apps/chrg/applications/utils/chrg_pcf8574.c create mode 100644 apps/chrg/applications/utils/chrg_pcf8574.h create mode 100644 apps/chrg/applications/utils/chrg_sink.c create mode 100644 apps/chrg/applications/utils/chrg_sink.h create mode 100644 apps/chrg/applications/utils/chrg_source.c create mode 100644 apps/chrg/applications/utils/chrg_source.h create mode 100644 apps/chrg/applications/utils/chrg_utils.c create mode 100644 apps/chrg/applications/utils/chrg_utils.h diff --git a/apps/chrg/applications/SConscript b/apps/chrg/applications/SConscript index bc8e4a3..00751b3 100644 --- a/apps/chrg/applications/SConscript +++ b/apps/chrg/applications/SConscript @@ -3,12 +3,8 @@ import os cwd = GetCurrentDir() src = Glob('*.c') -src += Glob('bsp/*.c') -src += Glob('thread/*.c') path = [cwd] -path += [cwd + '/bsp'] -path += [cwd + '/thread'] group = DefineGroup('Applications', src, depend = [''], CPPPATH = path) diff --git a/apps/chrg/applications/bsp/SConscript b/apps/chrg/applications/bsp/SConscript new file mode 100644 index 0000000..2246a3b --- /dev/null +++ b/apps/chrg/applications/bsp/SConscript @@ -0,0 +1,16 @@ +from building import * +import os + +cwd = GetCurrentDir() +src = Glob('*.c') + +path = [cwd] + +group = DefineGroup('Applications/bsp', src, depend = [''], CPPPATH = path) + +list = os.listdir(cwd) +for item in list: + if os.path.isfile(os.path.join(cwd, item, 'SConscript')): + group = group + SConscript(os.path.join(item, 'SConscript')) + +Return('group') diff --git a/apps/chrg/applications/bsp/chrg_can.c b/apps/chrg/applications/bsp/chrg_can.c index 2a6ccb1..856adbc 100644 --- a/apps/chrg/applications/bsp/chrg_can.c +++ b/apps/chrg/applications/bsp/chrg_can.c @@ -5,6 +5,9 @@ #include "chrg_can.h" +#define LOG_TAG "chrg.can" +#define DBG_LEVEL DBG_LOG +#include struct chrg_can_t chrgcan[TOTAL_CAN] = { [IDX_CAN_1] = { diff --git a/apps/chrg/applications/bsp/chrg_clk.c b/apps/chrg/applications/bsp/chrg_clk.c index 4b12d44..208ae96 100644 --- a/apps/chrg/applications/bsp/chrg_clk.c +++ b/apps/chrg/applications/bsp/chrg_clk.c @@ -5,6 +5,10 @@ #include "chrg_clk.h" +#define LOG_TAG "chrg.clk" +#define DBG_LEVEL DBG_LOG +#include + struct chrg_clk_t chrgclk = { .cnt = 0, }; diff --git a/apps/chrg/applications/bsp/chrg_fal.c b/apps/chrg/applications/bsp/chrg_fal.c index f4e92e6..6607b3b 100644 --- a/apps/chrg/applications/bsp/chrg_fal.c +++ b/apps/chrg/applications/bsp/chrg_fal.c @@ -1,11 +1,8 @@ #include #include "fal.h" -#define LOG_TAG "etc2.fal" -#define DBG_ENABLE -#define DBG_SECTION_NAME LOG_TAG +#define LOG_TAG "chrg.fal" #define DBG_LEVEL DBG_LOG -#define DBG_COLOR #include static int chrg_fal_init (void) diff --git a/apps/chrg/applications/bsp/chrg_i2c.c b/apps/chrg/applications/bsp/chrg_i2c.c index 1cc33ba..b35469f 100644 --- a/apps/chrg/applications/bsp/chrg_i2c.c +++ b/apps/chrg/applications/bsp/chrg_i2c.c @@ -3,6 +3,9 @@ #include "chrg_i2c.h" +#define LOG_TAG "chrg.i2c" +#define DBG_LEVEL DBG_LOG +#include struct chrg_i2c_t chrgi2c[TOTAL_I2C] = { [IDX_I2C_1] = { @@ -85,7 +88,7 @@ static int chrg_i2c_init (void) pI2C = &chrgi2c[i]; pI2C->dev = (struct rt_i2c_bus_device *)rt_device_find(pI2C->name); if (RT_NULL == pI2C->dev) { - rt_kprintf("dev '%s' not found.\r\n", pI2C->name); + LOG_E("dev '%s' not found.", pI2C->name); continue; } } diff --git a/apps/chrg/applications/bsp/chrg_intr.c b/apps/chrg/applications/bsp/chrg_intr.c index 376da88..1dea843 100644 --- a/apps/chrg/applications/bsp/chrg_intr.c +++ b/apps/chrg/applications/bsp/chrg_intr.c @@ -4,6 +4,10 @@ #include "chrg_intr.h" +#define LOG_TAG "chrg.intr" +#define DBG_LEVEL DBG_LOG +#include + struct chrg_intr_t chrgintr[TOTAL_INTR] = { [IDX_INTR_I2C1] = { .name = NAME_INTR_I2C1, @@ -59,7 +63,7 @@ static void chrg_intr_tmr_callback (void* data) if (RT_NULL != pINTR) { rt_ssize_t val = rt_pin_read(pINTR->pin); if (pINTR->value == val) { - rt_kprintf("check pin '%s' intr %d.\r\n", pINTR->name, pINTR->value); + LOG_I("check pin '%s' intr %d.", pINTR->name, pINTR->value); } } } @@ -69,7 +73,7 @@ static int chrg_intr_tmr_create (struct chrg_intr_t *pINTR) pINTR->tmr_fd = rt_timer_create(pINTR->name, chrg_intr_tmr_callback, pINTR, pINTR->delay, RT_TIMER_FLAG_ONE_SHOT); if (pINTR->tmr_fd == RT_NULL) { - rt_kprintf("tmr create '%s' failed.\r\n", pINTR->name); + LOG_E("tmr create '%s' failed.", pINTR->name); return -1; } @@ -85,7 +89,7 @@ static void chrg_intr_callback (void *args) if (pINTR->delay) { rt_timer_start(pINTR->tmr_fd); } - rt_kprintf("pin '%s' intr %d.\r\n", pINTR->name, pINTR->value); + LOG_I("pin '%s' intr %d.", pINTR->name, pINTR->value); } } diff --git a/apps/chrg/applications/bsp/chrg_pin.c b/apps/chrg/applications/bsp/chrg_pin.c index df82045..2499563 100644 --- a/apps/chrg/applications/bsp/chrg_pin.c +++ b/apps/chrg/applications/bsp/chrg_pin.c @@ -2,6 +2,10 @@ #include #include "chrg_pin.h" +#define LOG_TAG "chrg.pin" +#define DBG_LEVEL DBG_LOG +#include + struct chrg_pin_t chrgpins[TOTAL_PINS] = { [IDX_PIN_LED1] = { .index = IDX_PIN_LED1, @@ -165,7 +169,7 @@ static rt_int32_t chrg_pin_timer_start (eIDX_PIN index) pPIN, pPIN->tmr_millis_on, RT_TIMER_FLAG_ONE_SHOT); if (pPIN->tmr_fd == RT_NULL) { - rt_kprintf("tmr create '%s' failed.\r\n", pPIN->tmr_name); + LOG_E("tmr create '%s' failed.", pPIN->tmr_name); return -1; } diff --git a/apps/chrg/applications/bsp/chrg_switch.c b/apps/chrg/applications/bsp/chrg_switch.c index 0c68d02..c4cecbe 100644 --- a/apps/chrg/applications/bsp/chrg_switch.c +++ b/apps/chrg/applications/bsp/chrg_switch.c @@ -1,3 +1,4 @@ +#include #include "chrg_switch.h" @@ -124,5 +125,40 @@ static int chrg_switch_init (void) INIT_ENV_EXPORT(chrg_switch_init); +static int north_ch(rt_uint8_t argc, char **argv) +{ + int ret = 0; + + if (2 != argc) { + rt_kprintf("help : %s [0-3]\r\n", argv[0]); + return -1; + } + + ret = chrg_switch_north((eIDX_CH)atoi(argv[1])); + + return ret; +} + + +MSH_CMD_EXPORT(north_ch, north channel select); + + +static int south_ch(rt_uint8_t argc, char **argv) +{ + int ret = 0; + + if (2 != argc) { + rt_kprintf("help : %s [0-7]\r\n", argv[0]); + return -1; + } + + ret = chrg_switch_south((eIDX_SOUTH_CH)atoi(argv[1])); + + return ret; +} + + +MSH_CMD_EXPORT(south_ch, south channel select); + diff --git a/apps/chrg/applications/bsp/chrg_tmr.c b/apps/chrg/applications/bsp/chrg_tmr.c index a41136c..c928967 100644 --- a/apps/chrg/applications/bsp/chrg_tmr.c +++ b/apps/chrg/applications/bsp/chrg_tmr.c @@ -4,10 +4,7 @@ #include "chrg_tmr.h" #define LOG_TAG "chrg.tmr" -#define DBG_ENABLE -#define DBG_SECTION_NAME LOG_TAG #define DBG_LEVEL DBG_LOG -#define DBG_COLOR #include struct chrg_tmr_t chrgtmr[TOTAL_TMRS] = { @@ -91,7 +88,7 @@ rt_err_t chrg_tmr_start (eIDX_TMR index, uint32_t timeo) pTMR->timeout.usec = timeo%1000000; if (rt_device_write(pTMR->dev, 0, &pTMR->timeout, sizeof(rt_hwtimerval_t)) != sizeof(rt_hwtimerval_t)) { - rt_kprintf("set '%s' timeout failed.\r\n", pTMR->name); + LOG_E("set timer '%s' timeout failed.", pTMR->name); return ret; } diff --git a/apps/chrg/applications/bsp/chrg_tty.c b/apps/chrg/applications/bsp/chrg_tty.c index 6efbab6..89f26a8 100644 --- a/apps/chrg/applications/bsp/chrg_tty.c +++ b/apps/chrg/applications/bsp/chrg_tty.c @@ -8,41 +8,54 @@ #include "chrg_north.h" #include "chrg_south.h" +#define LOG_TAG "chrg.tty" +#define DBG_LEVEL DBG_LOG +#include + struct chrg_tty_t chrgtty[TOTAL_TTY] = { [IDX_TTY_RS485] = { .dev = RT_NULL, .name = DEV_NAME_RS485, .index = IDX_TTY_RS485, + .baudrate = BAUD_RATE_115200, + .rb = RT_NULL, }, [IDX_TTY_LCD] = { .dev = RT_NULL, .name = DEV_NAME_LCD, .index = IDX_TTY_LCD, + .baudrate = BAUD_RATE_115200, + .rb = RT_NULL, }, [IDX_TTY_NORTH] = { .dev = RT_NULL, .name = DEV_NAME_NORTH, .index = IDX_TTY_NORTH, + .baudrate = BAUD_RATE_2000000, + .rb = RT_NULL, }, [IDX_TTY_SOUTH] = { .dev = RT_NULL, .name = DEV_NAME_SOUTH, .index = IDX_TTY_SOUTH, + .baudrate = BAUD_RATE_2000000, + .rb = RT_NULL, } }; static rt_err_t chrg_rs485_tty_input (rt_device_t dev, rt_size_t size) { - rt_err_t ret = RT_EOK; + rt_err_t ret; + rt_uint8_t ch; + rt_size_t i; struct chrg_tty_t *pTTY = &chrgtty[IDX_TTY_RS485]; - pTTY->msg.dev = dev; - pTTY->msg.size = size; - - ret = rt_mq_send(&pTTY->mq_rx, &pTTY->msg, sizeof(struct rx_msg_t)); - if (ret == -RT_EFULL) { - rt_kprintf("msg queue is full!\r\n"); + for (i = 0; i < size; i++) { + if (rt_device_read(dev, 0, &ch, 1)) { + rt_ringbuffer_put_force(pTTY->rb, &ch, 1); + ret = rt_sem_release(&pTTY->sem_rx); + } } return ret; @@ -50,15 +63,16 @@ static rt_err_t chrg_rs485_tty_input (rt_device_t dev, rt_size_t size) static rt_err_t chrg_lcd_tty_input (rt_device_t dev, rt_size_t size) { - rt_err_t ret = RT_EOK; + rt_err_t ret; + rt_uint8_t ch; + rt_size_t i; struct chrg_tty_t *pTTY = &chrgtty[IDX_TTY_LCD]; - pTTY->msg.dev = dev; - pTTY->msg.size = size; - - ret = rt_mq_send(&pTTY->mq_rx, &pTTY->msg, sizeof(struct rx_msg_t)); - if (ret == -RT_EFULL) { - rt_kprintf("msg queue is full!\r\n"); + for (i = 0; i < size; i++) { + if (rt_device_read(dev, 0, &ch, 1)) { + rt_ringbuffer_put_force(pTTY->rb, &ch, 1); + ret = rt_sem_release(&pTTY->sem_rx); + } } return ret; @@ -66,15 +80,16 @@ static rt_err_t chrg_lcd_tty_input (rt_device_t dev, rt_size_t size) static rt_err_t chrg_north_tty_input (rt_device_t dev, rt_size_t size) { - rt_err_t ret = RT_EOK; + rt_err_t ret; + rt_uint8_t ch; + rt_size_t i; struct chrg_tty_t *pTTY = &chrgtty[IDX_TTY_NORTH]; - pTTY->msg.dev = dev; - pTTY->msg.size = size; - - ret = rt_mq_send(&pTTY->mq_rx, &pTTY->msg, sizeof(struct rx_msg_t)); - if (ret == -RT_EFULL) { - rt_kprintf("msg queue is full!\r\n"); + for (i = 0; i < size; i++) { + if (rt_device_read(dev, 0, &ch, 1)) { + rt_ringbuffer_put_force(pTTY->rb, &ch, 1); + ret = rt_sem_release(&pTTY->sem_rx); + } } return ret; @@ -82,61 +97,31 @@ static rt_err_t chrg_north_tty_input (rt_device_t dev, rt_size_t size) static rt_err_t chrg_south_tty_input (rt_device_t dev, rt_size_t size) { - rt_err_t ret = RT_EOK; + rt_err_t ret; + rt_uint8_t ch; + rt_size_t i; struct chrg_tty_t *pTTY = &chrgtty[IDX_TTY_SOUTH]; - pTTY->msg.dev = dev; - pTTY->msg.size = size; - - ret = rt_mq_send(&pTTY->mq_rx, &pTTY->msg, sizeof(struct rx_msg_t)); - if (ret == -RT_EFULL) { - rt_kprintf("msg queue is full!\r\n"); + for (i = 0; i < size; i++) { + if (rt_device_read(dev, 0, &ch, 1)) { + rt_ringbuffer_put_force(pTTY->rb, &ch, 1); + ret = rt_sem_release(&pTTY->sem_rx); + } } return ret; } -static void chrg_tty_recv_entry (void *data) +rt_err_t chrg_tty_open (struct chrg_tty_t *pTTY) { - struct chrg_tty_t *pTTY = (struct chrg_tty_t *)data; - rt_err_t ret = RT_EOK; - rt_int32_t rx_len = 0; - rt_uint8_t rx_raw[RT_SERIAL_RB_BUFSZ]; - while (1) { - rt_memset(&pTTY->msg, 0, sizeof(struct rx_msg_t)); - - ret = rt_mq_recv(&pTTY->mq_rx, &pTTY->msg, sizeof(struct rx_msg_t), RT_WAITING_FOREVER); - if (ret == RT_EOK) { - rt_memset(rx_raw, 0, RT_SERIAL_RB_BUFSZ); - rx_len = rt_device_read(pTTY->msg.dev, 0, rx_raw, pTTY->msg.size); - if (rx_len > 0) { - switch (pTTY->index) { - case IDX_TTY_NORTH: { - struct chrg_north_t *pNOR = &chrgnor; - rt_memset(&pNOR->buf, 0, sizeof(pNOR->buf)); - strcpy((char *)pNOR->buf, "send mb msg"); - rt_mb_send(&pNOR->mb, (rt_uint32_t)&pNOR->buf); - } - break; - - default: - break; - } - - } - } + if (RT_NULL == pTTY) { + return RT_EEMPTY; } -} - -rt_err_t chrg_tty_thread (struct chrg_tty_t *pTTY) -{ - rt_err_t ret = RT_EOK; - rt_thread_t tid_tty; struct serial_configure cfg = { - .baud_rate = BAUD_RATE_115200, + .baud_rate = pTTY->baudrate, .data_bits = DATA_BITS_8, .stop_bits = STOP_BITS_1, .parity = PARITY_NONE, @@ -146,23 +131,21 @@ rt_err_t chrg_tty_thread (struct chrg_tty_t *pTTY) .flowcontrol = RT_SERIAL_FLOWCONTROL_NONE, }; + pTTY->dev = rt_device_find(pTTY->name); if (RT_NULL == pTTY->dev) { - rt_kprintf("dev is null.\r\n"); + LOG_E("dev '%s' not found.", pTTY->name); return RT_ERROR; } - rt_mq_init(&pTTY->mq_rx, pTTY->name, pTTY->pool_msg, - sizeof(struct rx_msg_t), sizeof(pTTY->pool_msg), RT_IPC_FLAG_FIFO); - ret = rt_device_open(pTTY->dev, RT_DEVICE_OFLAG_RDWR|RT_DEVICE_FLAG_INT_RX); if (ret != RT_EOK) { - rt_kprintf("open '%s' failed.\r\n", pTTY->name); + LOG_E("open '%s' failed.", pTTY->name); return ret; } ret = rt_device_control(pTTY->dev, RT_DEVICE_CTRL_CONFIG, &cfg); if (ret != RT_EOK) { - rt_kprintf("control '%s' failed.\r\n", pTTY->name); + LOG_E("control '%s' failed.", pTTY->name); return ret; } @@ -183,14 +166,16 @@ rt_err_t chrg_tty_thread (struct chrg_tty_t *pTTY) return RT_ERROR; } - tid_tty = rt_thread_create(pTTY->name, chrg_tty_recv_entry, - pTTY, 4096, RT_MAIN_THREAD_PRIORITY+2, 20); + ret = rt_sem_init(&pTTY->sem_rx, pTTY->name, 0, RT_IPC_FLAG_FIFO); + if (ret != RT_EOK) { + LOG_E("sem init '%s' failed.", pTTY->name); + return ret; + } - if (tid_tty != RT_NULL) { - rt_thread_startup(tid_tty); - } else { - rt_kprintf("create thread '%s' failed.\r\n", pTTY->name); - return -RT_ERROR; + pTTY->rb = rt_ringbuffer_create(64); + if (RT_NULL == pTTY->rb) { + rt_kprintf("create rb failed.\r\n"); + return RT_ERROR; } return RT_EOK; @@ -207,14 +192,7 @@ static int chrg_tty_init (void) } pTTY = &chrgtty[i]; - - pTTY->dev = rt_device_find(pTTY->name); - if (RT_NULL == pTTY->dev) { - rt_kprintf("dev '%s' not found.\r\n", pTTY->name); - return RT_ERROR; - } - - chrg_tty_thread(pTTY); + chrg_tty_open(pTTY); } return RT_EOK; diff --git a/apps/chrg/applications/bsp/chrg_tty.h b/apps/chrg/applications/bsp/chrg_tty.h index 4b62c3c..a28ced7 100644 --- a/apps/chrg/applications/bsp/chrg_tty.h +++ b/apps/chrg/applications/bsp/chrg_tty.h @@ -9,6 +9,8 @@ #define DEV_NAME_NORTH "uart3" #define DEV_NAME_SOUTH "uart6" +#define SIZE_BUF_UART 128 + typedef enum { IDX_TTY_RS485 = 0, // 0 IDX_TTY_LCD, // 1 @@ -18,22 +20,17 @@ typedef enum { TOTAL_TTY } eIDX_TTY; -struct rx_msg_t { - rt_device_t dev; - rt_size_t size; -}; struct chrg_tty_t { rt_device_t dev; const char *name; - - eIDX_TTY index; - rt_uint32_t len_rx; - rt_uint8_t buf_rx[RT_SERIAL_RB_BUFSZ]; - struct rt_messagequeue mq_rx; - struct rx_msg_t msg; - rt_uint8_t pool_msg[1024]; + rt_uint32_t baudrate; + eIDX_TTY index; + + struct rt_ringbuffer *rb; + struct rt_semaphore sem_rx; + }; extern struct chrg_tty_t chrgtty[TOTAL_TTY]; diff --git a/apps/chrg/applications/bsp/chrg_wdt.c b/apps/chrg/applications/bsp/chrg_wdt.c index 6d2c855..1839c71 100644 --- a/apps/chrg/applications/bsp/chrg_wdt.c +++ b/apps/chrg/applications/bsp/chrg_wdt.c @@ -4,6 +4,10 @@ #include "chrg_wdt.h" +#define LOG_TAG "chrg.wdt" +#define DBG_LEVEL DBG_LOG +#include + struct chrg_wdt_t chrgwdt = { .dev = RT_NULL, .name = DEV_NAME_WATCHDOG, diff --git a/apps/chrg/applications/thread/SConscript b/apps/chrg/applications/thread/SConscript new file mode 100644 index 0000000..f4792d2 --- /dev/null +++ b/apps/chrg/applications/thread/SConscript @@ -0,0 +1,16 @@ +from building import * +import os + +cwd = GetCurrentDir() +src = Glob('*.c') + +path = [cwd] + +group = DefineGroup('Applications/thread', src, depend = [''], CPPPATH = path) + +list = os.listdir(cwd) +for item in list: + if os.path.isfile(os.path.join(cwd, item, 'SConscript')): + group = group + SConscript(os.path.join(item, 'SConscript')) + +Return('group') diff --git a/apps/chrg/applications/thread/chrg_comm.c b/apps/chrg/applications/thread/chrg_comm.c new file mode 100644 index 0000000..590da25 --- /dev/null +++ b/apps/chrg/applications/thread/chrg_comm.c @@ -0,0 +1,7 @@ + +#include "chrg_comm.h" + + + + + diff --git a/apps/chrg/applications/thread/chrg_comm.h b/apps/chrg/applications/thread/chrg_comm.h new file mode 100644 index 0000000..92f8e78 --- /dev/null +++ b/apps/chrg/applications/thread/chrg_comm.h @@ -0,0 +1,9 @@ +#ifndef __CHRG_COMM_H__ +#define __CHRG_COMM_H__ + + + + + +#endif + diff --git a/apps/chrg/applications/thread/chrg_lcd.c b/apps/chrg/applications/thread/chrg_lcd.c new file mode 100644 index 0000000..3b7b08a --- /dev/null +++ b/apps/chrg/applications/thread/chrg_lcd.c @@ -0,0 +1,4 @@ + +#include "chrg_lcd.h" + + diff --git a/apps/chrg/applications/thread/chrg_lcd.h b/apps/chrg/applications/thread/chrg_lcd.h new file mode 100644 index 0000000..856043f --- /dev/null +++ b/apps/chrg/applications/thread/chrg_lcd.h @@ -0,0 +1,7 @@ +#ifndef __CHRG_LCD_H__ +#define __CHRG_LCD_H__ + + +#endif + + diff --git a/apps/chrg/applications/thread/chrg_north.c b/apps/chrg/applications/thread/chrg_north.c index 967a860..b63e399 100644 --- a/apps/chrg/applications/thread/chrg_north.c +++ b/apps/chrg/applications/thread/chrg_north.c @@ -4,58 +4,68 @@ #include "chrg_north.h" #define LOG_TAG "chrg.nor" -#define DBG_ENABLE -#define DBG_SECTION_NAME LOG_TAG #define DBG_LEVEL DBG_LOG -#define DBG_COLOR #include struct chrg_north_t chrgnor = { + .name = THR_NAME_NORTH, .tid = RT_NULL, - .name = THRED_NAME_NORTH, - + .tty = RT_NULL, + .rx_len = 0, }; -static void chrg_north_entry (void *data) +static void chrg_north_thread_entry (void *data) { + rt_err_t ret = RT_EOK; struct chrg_north_t *pNOR = (struct chrg_north_t *)data; - if (RT_NULL == pNOR) { + if ((RT_NULL == pNOR)||(RT_NULL == pNOR->tty)) { return ; } - char *str = RT_NULL; + rt_uint8_t ch; + struct chrg_tty_t *pTTY = pNOR->tty; while (1) { - if (rt_mb_recv(&pNOR->mb, (rt_uint32_t *)&str, RT_WAITING_FOREVER) == RT_EOK) { - rt_kprintf("%s recv %s\r\n", pNOR->name, str); + ret = rt_sem_take(&pTTY->sem_rx, RT_WAITING_FOREVER); + if (RT_EOK != ret) { + LOG_E("sem take failed. %d", ret); + continue; } - //rt_thread_mdelay(1000); + rt_ringbuffer_getchar(pTTY->rb, &ch); + if (pNOR->rx_len < SIZE_BUF_UART) { + pNOR->rx_buf[pNOR->rx_len++] = ch; + rt_kprintf("%c", ch); + } + + if (pNOR->rx_len >= 32) { + pNOR->rx_len = 0; + } } - rt_mb_detach(&pNOR->mb); } static int chrg_north_init (void) { rt_err_t ret; struct chrg_north_t *pNOR = &chrgnor; - ret = rt_mb_init(&pNOR->mb, "mb_nor", &pNOR->mb_pool[0], - sizeof(pNOR->mb_pool)/4, RT_IPC_FLAG_FIFO); - if (RT_NULL != ret) { - LOG_E("mb init failed."); - return RT_ENOMEM; + + pNOR->tty = &chrgtty[IDX_TTY_NORTH]; + rt_memset(pNOR->rx_buf, 0, SIZE_BUF_UART); + + ret = rt_mutex_init(&pNOR->lock, pNOR->name, RT_IPC_FLAG_FIFO); + if (ret != RT_EOK) { + LOG_E("init mutex '%s' failed.", pNOR->name); + return ret; } - pNOR->tid = rt_thread_create(pNOR->name, chrg_north_entry, pNOR, - 4096, RT_MAIN_THREAD_PRIORITY, 10); + pNOR->tid = rt_thread_create(pNOR->name, chrg_north_thread_entry, pNOR, 4096, + RT_MAIN_THREAD_PRIORITY, 20); if (RT_NULL != pNOR->tid) { rt_thread_startup(pNOR->tid); - LOG_I("start thread '%s'.", pNOR->name); } else { - LOG_E("start thread '%s' failed.", pNOR->name); - return -RT_ERROR; + LOG_E("create thread '%s' failed.", pNOR->name); } return 0; @@ -65,3 +75,21 @@ static int chrg_north_init (void) INIT_APP_EXPORT(chrg_north_init); +static int north_send(rt_uint8_t argc, char **argv) +{ + rt_ssize_t ret = 0; + struct chrg_north_t *pNOR = &chrgnor; + struct chrg_tty_t *pTTY = pNOR->tty; + + if (RT_NULL != pTTY->dev) { + ret = rt_device_write(pTTY->dev, 0, "1234567890abcdef", 16); + } + + return ret; +} + + +MSH_CMD_EXPORT(north_send, north send test); + + + diff --git a/apps/chrg/applications/thread/chrg_north.h b/apps/chrg/applications/thread/chrg_north.h index c41aeb0..edbcd61 100644 --- a/apps/chrg/applications/thread/chrg_north.h +++ b/apps/chrg/applications/thread/chrg_north.h @@ -2,16 +2,18 @@ #define __CHRG_NORTH_H__ #include +#include "chrg_tty.h" -#define THRED_NAME_NORTH "thr_nor" +#define THR_NAME_NORTH "thr_nor" struct chrg_north_t { - rt_thread_t tid; - const char *name; + const char *name; + struct rt_thread *tid; + struct rt_mutex lock; - struct rt_mailbox mb; - rt_uint8_t mb_pool[128]; - rt_uint8_t buf[256]; + struct chrg_tty_t *tty; + rt_uint16_t rx_len; + rt_uint8_t rx_buf[SIZE_BUF_UART]; }; extern struct chrg_north_t chrgnor; diff --git a/apps/chrg/applications/thread/chrg_south.c b/apps/chrg/applications/thread/chrg_south.c index a06d13d..a242189 100644 --- a/apps/chrg/applications/thread/chrg_south.c +++ b/apps/chrg/applications/thread/chrg_south.c @@ -4,39 +4,68 @@ #include "chrg_south.h" #define LOG_TAG "chrg.sou" -#define DBG_ENABLE -#define DBG_SECTION_NAME LOG_TAG #define DBG_LEVEL DBG_LOG -#define DBG_COLOR #include struct chrg_south_t chrgsou = { + .name = THR_NAME_SOUTH, .tid = RT_NULL, - .name = THRED_NAME_SOUTH, - + .tty = RT_NULL, + .rx_len = 0, }; -static void chrg_south_entry (void *data) +static void chrg_south_thread_entry (void *data) { - while (1) { - //rt_kprintf("sou\r\n"); - rt_thread_mdelay(1000); + rt_err_t ret = RT_EOK; + struct chrg_south_t *pSOU = (struct chrg_south_t *)data; + + if ((RT_NULL == pSOU)||(RT_NULL == pSOU->tty)) { + return ; } - + + rt_uint8_t ch; + struct chrg_tty_t *pTTY = pSOU->tty; + + while (1) { + ret = rt_sem_take(&pTTY->sem_rx, RT_WAITING_FOREVER); + if (RT_EOK != ret) { + LOG_E("sem take failed. %d", ret); + continue; + } + + rt_ringbuffer_getchar(pTTY->rb, &ch); + if (pSOU->rx_len < SIZE_BUF_UART) { + pSOU->rx_buf[pSOU->rx_len++] = ch; + rt_kprintf("%c", ch); + } + + if (pSOU->rx_len >= 32) { + pSOU->rx_len = 0; + } + } + } static int chrg_south_init (void) { + rt_err_t ret; struct chrg_south_t *pSOU = &chrgsou; - - pSOU->tid = rt_thread_create(pSOU->name, chrg_south_entry, pSOU, - 4096, RT_MAIN_THREAD_PRIORITY, 10); + + pSOU->tty = &chrgtty[IDX_TTY_NORTH]; + rt_memset(pSOU->rx_buf, 0, SIZE_BUF_UART); + + ret = rt_mutex_init(&pSOU->lock, pSOU->name, RT_IPC_FLAG_FIFO); + if (ret != RT_EOK) { + LOG_E("init mutex '%s' failed.", pSOU->name); + return ret; + } + + pSOU->tid = rt_thread_create(pSOU->name, chrg_south_thread_entry, pSOU, 4096, + RT_MAIN_THREAD_PRIORITY, 20); if (RT_NULL != pSOU->tid) { rt_thread_startup(pSOU->tid); - LOG_I("start thread '%s'.", pSOU->name); } else { - LOG_E("start thread '%s' failed.", pSOU->name); - return -RT_ERROR; + LOG_E("create thread '%s' failed.", pSOU->name); } return 0; @@ -45,4 +74,21 @@ static int chrg_south_init (void) INIT_APP_EXPORT(chrg_south_init); +static int south_send(rt_uint8_t argc, char **argv) +{ + rt_err_t ret; + struct chrg_south_t *pSOU = &chrgsou; + struct chrg_tty_t *pTTY = pSOU->tty; + + if (RT_NULL != pTTY->dev) { + ret = rt_device_write(pTTY->dev, 0, "1234567890abcdef", 16); + } + + return ret; +} + + +MSH_CMD_EXPORT(south_send, south send test); + + diff --git a/apps/chrg/applications/thread/chrg_south.h b/apps/chrg/applications/thread/chrg_south.h index 1b34e5e..21bce79 100644 --- a/apps/chrg/applications/thread/chrg_south.h +++ b/apps/chrg/applications/thread/chrg_south.h @@ -2,13 +2,18 @@ #define __CHRG_SOUTH_H__ #include +#include "chrg_tty.h" -#define THRED_NAME_SOUTH "thr_sou" +#define THR_NAME_SOUTH "thr_sou" struct chrg_south_t { - rt_thread_t tid; - const char *name; - + const char *name; + struct rt_thread *tid; + struct rt_mutex lock; + + struct chrg_tty_t *tty; + rt_uint16_t rx_len; + rt_uint8_t rx_buf[SIZE_BUF_UART]; }; extern struct chrg_south_t chrgsou; diff --git a/apps/chrg/applications/utils/SConscript b/apps/chrg/applications/utils/SConscript new file mode 100644 index 0000000..e0a2cae --- /dev/null +++ b/apps/chrg/applications/utils/SConscript @@ -0,0 +1,16 @@ +from building import * +import os + +cwd = GetCurrentDir() +src = Glob('*.c') + +path = [cwd] + +group = DefineGroup('Applications/utils', src, depend = [''], CPPPATH = path) + +list = os.listdir(cwd) +for item in list: + if os.path.isfile(os.path.join(cwd, item, 'SConscript')): + group = group + SConscript(os.path.join(item, 'SConscript')) + +Return('group') diff --git a/apps/chrg/applications/utils/chrg_pcf8574.c b/apps/chrg/applications/utils/chrg_pcf8574.c new file mode 100644 index 0000000..d8466c4 --- /dev/null +++ b/apps/chrg/applications/utils/chrg_pcf8574.c @@ -0,0 +1,4 @@ + +#include "chrg_pcf8574.h" + + diff --git a/apps/chrg/applications/utils/chrg_pcf8574.h b/apps/chrg/applications/utils/chrg_pcf8574.h new file mode 100644 index 0000000..0ff5ba3 --- /dev/null +++ b/apps/chrg/applications/utils/chrg_pcf8574.h @@ -0,0 +1,7 @@ +#ifndef __CHRG_PCF8574_H__ +#define __CHRG_PCF8574_H__ + + +#endif + + diff --git a/apps/chrg/applications/utils/chrg_sink.c b/apps/chrg/applications/utils/chrg_sink.c new file mode 100644 index 0000000..e1d9ced --- /dev/null +++ b/apps/chrg/applications/utils/chrg_sink.c @@ -0,0 +1,4 @@ + +#include "chrg_sink.h" + + diff --git a/apps/chrg/applications/utils/chrg_sink.h b/apps/chrg/applications/utils/chrg_sink.h new file mode 100644 index 0000000..8496101 --- /dev/null +++ b/apps/chrg/applications/utils/chrg_sink.h @@ -0,0 +1,37 @@ +#ifndef __CHRG_SINK_H__ +#define __CHRG_SINK_H__ + +#include + +#define SINK_ID 0x01 + +#define SINK_REG_GET_VOLTAGE 0x20 // 读取变电压板电压 +#define SINK_REG_GET_PD 0x13 // 读取源端的PD协议数据 +#define SINK_REG_SET_CC 0x17 // 设置CC线 +#define SINK_REG_SET_LEVEL 0x16 // 设置CC线电平 + +// 设置快充协议 +#define SINK_REG_SET_QC2 0xF8 // QC2.0 +#define SINK_REG_SET_QC3 0xF6 // QC3.0 +#define SINK_REG_SET_FCP 0xF2 // FCP +#define SINK_REG_SET_AFC 0xF9 // AFC +#define SINK_REG_SET_SCP 0xF3 // SCP +#define SINK_REG_SET_VIVO 0xFD // VIVO +#define SINK_REG_SET_TFC 0xF7 // TFC 传音 +#define SINK_REG_SET_PD0 0xFB // PD0 手动/自动 +#define SINK_REG_SET_PPS 0xFC // PPS 手动/自动 +#define SINK_REG_SET_PD3P1 0xE1 // PD3.1 +#define SINK_REG_SET_UFCS 0xE0 // UFCS +#define SINK_REG_SET_VOOC 0xE2 // VOOC +#define SINK_REG_SET_AVS 0xE3 // AVS + + +struct chrg_sink_t { + rt_uint8_t type; +}; + + + +#endif + + diff --git a/apps/chrg/applications/utils/chrg_source.c b/apps/chrg/applications/utils/chrg_source.c new file mode 100644 index 0000000..6c06c04 --- /dev/null +++ b/apps/chrg/applications/utils/chrg_source.c @@ -0,0 +1,4 @@ + +#include "chrg_source.h" + + diff --git a/apps/chrg/applications/utils/chrg_source.h b/apps/chrg/applications/utils/chrg_source.h new file mode 100644 index 0000000..fe8d80a --- /dev/null +++ b/apps/chrg/applications/utils/chrg_source.h @@ -0,0 +1,7 @@ +#ifndef __CHRG_SOURCE_H__ +#define __CHRG_SOURCE_H__ + + +#endif + + diff --git a/apps/chrg/applications/utils/chrg_utils.c b/apps/chrg/applications/utils/chrg_utils.c new file mode 100644 index 0000000..b13f51e --- /dev/null +++ b/apps/chrg/applications/utils/chrg_utils.c @@ -0,0 +1,43 @@ + +#include + +#include "chrg_utils.h" + + +rt_uint8_t _crc8 (rt_uint8_t res, rt_uint8_t data) +{ + rt_uint8_t i = 0, t = 0; + + for (i = 0; i < 8; i++) { + t = data^res; + if ((t & 0x01) == 0x01) { + res = res^0x18; + res >>= 1; + res |= 0x80; + } else { + res >>= 1; + } + + data >>= 1; + } + + return res; +} + +rt_uint8_t calc_crc8 (rt_uint8_t *data, rt_uint8_t length) +{ + rt_uint8_t i = 0, res = 0x55; + + for (i = 0; i < length; i++) { + res = _crc8(res, data[i]); + } + + return res; +} + + + + + + + diff --git a/apps/chrg/applications/utils/chrg_utils.h b/apps/chrg/applications/utils/chrg_utils.h new file mode 100644 index 0000000..d6954fa --- /dev/null +++ b/apps/chrg/applications/utils/chrg_utils.h @@ -0,0 +1,11 @@ +#ifndef __CHRG_UTILS_H__ +#define __CHRG_UTILS_H__ + +#include + +extern rt_uint8_t calc_crc8 (rt_uint8_t *data, rt_uint8_t length); + + +#endif + + diff --git a/apps/chrg/project.uvprojx b/apps/chrg/project.uvprojx index d799d84..f35c623 100644 --- a/apps/chrg/project.uvprojx +++ b/apps/chrg/project.uvprojx @@ -10,6 +10,7 @@ chrg 0x4 ARM-ADS + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 @@ -336,9 +337,9 @@ 0 - RT_USING_ARMLIBC, __RTTHREAD__, __CLK_TCK=RT_TICK_PER_SECOND, USE_HAL_DRIVER, STM32F405xx, __STDC_LIMIT_MACROS, RT_USING_LIBC + USE_HAL_DRIVER, RT_USING_ARMLIBC, __CLK_TCK=RT_TICK_PER_SECOND, __STDC_LIMIT_MACROS, RT_USING_LIBC, __RTTHREAD__, STM32F405xx - ..\..\libs\freemodbus\modbus\include;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\libcpu\arm\common;..\..\rt-thread\components\drivers\include;..\..\libs\freemodbus\modbus\rtu;..\..\rt-thread\components\drivers\phy;..\..\rt-thread\components\libc\posix\io\poll;board\CubeMX_Config\Inc;..\..\rt-thread\components\libc\compilers\common\extension;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;..\..\rt-thread\libcpu\arm\cortex-m4;..\..\libs\cmsis-core\Include;..\..\rt-thread\components\drivers\include;board;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_flash;..\..\libs\freemodbus\modbus\ascii;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\fal\inc;.;..\..\rt-thread\include;..\..\rt-thread\components\libc\posix\io\eventfd;..\..\rt-thread\components\drivers\smp_call;..\..\rt-thread\components\libc\compilers\common\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\ipc;..\..\rt-thread\components\drivers\include;..\..\libs\freemodbus\port;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\io\epoll;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;board\ports;..\..\rt-thread\components\drivers\include;applications\thread;applications\bsp;..\..\rt-thread\components\finsh;..\..\libs\stm32f4\STM32F4_HAL\Inc;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;..\..\rt-thread\components\drivers\include;..\..\libs\freemodbus\modbus\tcp;applications + ..\..\rt-thread\components\drivers\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;..\..\rt-thread\components\libc\posix\ipc;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\components\drivers\smp_call;.;..\..\rt-thread\libcpu\arm\common;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\libs\cmsis-core\Include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_flash;..\..\rt-thread\components\libc\posix\io\eventfd;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\compilers\common\extension;..\..\rt-thread\components\drivers\include;..\..\libs\stm32f4\STM32F4_HAL\Inc;..\..\rt-thread\components\drivers\include;..\..\libs\freemodbus\modbus\include;..\..\libs\freemodbus\modbus\tcp;..\..\rt-thread\components\drivers\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;..\..\libs\freemodbus\modbus\rtu;..\..\libs\freemodbus\modbus\ascii;..\..\rt-thread\include;board\ports;..\..\rt-thread\libcpu\arm\cortex-m4;..\..\rt-thread\components\drivers\include;applications\thread;..\..\rt-thread\components\drivers\include;..\..\libs\freemodbus\port;..\..\rt-thread\components\libc\compilers\common\include;board;..\..\rt-thread\components\fal\inc;board\CubeMX_Config\Inc;..\..\rt-thread\components\finsh;..\..\rt-thread\components\libc\posix\io\poll;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;applications\bsp;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;applications\utils;..\..\rt-thread\components\libc\posix\io\epoll;..\..\rt-thread\components\drivers\phy;applications;..\..\rt-thread\components\drivers\include @@ -383,59 +384,49 @@ Applications - chrg_wdt.c + main.c 1 - applications\bsp\chrg_wdt.c - - - chrg_north.c - 1 - applications\thread\chrg_north.c + applications\main.c + + + + Applications/bsp + chrg_i2c.c 1 applications\bsp\chrg_i2c.c - - chrg_clk.c - 1 - applications\bsp\chrg_clk.c - - - chrg_intr.c - 1 - applications\bsp\chrg_intr.c - - - chrg_pin.c - 1 - applications\bsp\chrg_pin.c - - - chrg_south.c - 1 - applications\thread\chrg_south.c - - - chrg_tty.c - 1 - applications\bsp\chrg_tty.c - chrg_can.c 1 applications\bsp\chrg_can.c - chrg_tmr.c + chrg_pin.c 1 - applications\bsp\chrg_tmr.c + applications\bsp\chrg_pin.c - main.c + chrg_intr.c 1 - applications\main.c + applications\bsp\chrg_intr.c + + + chrg_fal.c + 1 + applications\bsp\chrg_fal.c + + + chrg_wdt.c + 1 + applications\bsp\chrg_wdt.c + + + chrg_clk.c + 1 + applications\bsp\chrg_clk.c chrg_switch.c @@ -443,9 +434,64 @@ applications\bsp\chrg_switch.c - chrg_fal.c + chrg_tmr.c 1 - applications\bsp\chrg_fal.c + applications\bsp\chrg_tmr.c + + + chrg_tty.c + 1 + applications\bsp\chrg_tty.c + + + + + Applications/thread + + + chrg_lcd.c + 1 + applications\thread\chrg_lcd.c + + + chrg_north.c + 1 + applications\thread\chrg_north.c + + + chrg_comm.c + 1 + applications\thread\chrg_comm.c + + + chrg_south.c + 1 + applications\thread\chrg_south.c + + + + + Applications/utils + + + chrg_utils.c + 1 + applications\utils\chrg_utils.c + + + chrg_sink.c + 1 + applications\utils\chrg_sink.c + + + chrg_pcf8574.c + 1 + applications\utils\chrg_pcf8574.c + + + chrg_source.c + 1 + applications\utils\chrg_source.c @@ -547,7 +593,7 @@ __RT_IPC_SOURCE__ - + @@ -603,7 +649,7 @@ __RT_IPC_SOURCE__ - + @@ -659,7 +705,7 @@ __RT_IPC_SOURCE__ - + @@ -715,7 +761,7 @@ __RT_IPC_SOURCE__ - + @@ -771,7 +817,7 @@ __RT_IPC_SOURCE__ - + @@ -827,7 +873,7 @@ __RT_IPC_SOURCE__ - + @@ -883,7 +929,7 @@ __RT_IPC_SOURCE__ - + @@ -939,7 +985,7 @@ __RT_IPC_SOURCE__ - + @@ -995,7 +1041,7 @@ __RT_IPC_SOURCE__ - + @@ -1051,7 +1097,7 @@ __RT_IPC_SOURCE__ - + @@ -1107,7 +1153,7 @@ __RT_IPC_SOURCE__ - + @@ -1163,7 +1209,7 @@ __RT_IPC_SOURCE__ - + @@ -1219,7 +1265,7 @@ __RT_IPC_SOURCE__ - + @@ -1275,7 +1321,7 @@ __RT_IPC_SOURCE__ - + @@ -1331,7 +1377,7 @@ __RT_IPC_SOURCE__ - + @@ -1387,7 +1433,7 @@ __RT_IPC_SOURCE__ - + @@ -1443,7 +1489,7 @@ __RT_IPC_SOURCE__ - + @@ -1499,7 +1545,7 @@ __RT_IPC_SOURCE__ - + @@ -1555,7 +1601,7 @@ __RT_IPC_SOURCE__ - + @@ -1636,31 +1682,21 @@ 1 ..\..\rt-thread\components\fal\src\fal_rtt.c - - fal_partition.c - 1 - ..\..\rt-thread\components\fal\src\fal_partition.c - fal.c 1 ..\..\rt-thread\components\fal\src\fal.c + + fal_partition.c + 1 + ..\..\rt-thread\components\fal\src\fal_partition.c + Finsh - - cmd.c - 1 - ..\..\rt-thread\components\finsh\cmd.c - - - msh_parse.c - 1 - ..\..\rt-thread\components\finsh\msh_parse.c - msh.c 1 @@ -1671,151 +1707,161 @@ 1 ..\..\rt-thread\components\finsh\shell.c + + msh_parse.c + 1 + ..\..\rt-thread\components\finsh\msh_parse.c + + + cmd.c + 1 + ..\..\rt-thread\components\finsh\cmd.c + FreeModbus - - user_mb_app_m.c - 1 - ..\..\libs\freemodbus\port\user_mb_app_m.c - - - mbfuncholding.c - 1 - ..\..\libs\freemodbus\modbus\functions\mbfuncholding.c - - - porttcp.c - 1 - ..\..\libs\freemodbus\port\porttcp.c - - - mbfunccoils_m.c - 1 - ..\..\libs\freemodbus\modbus\functions\mbfunccoils_m.c - - - mbfuncother.c - 1 - ..\..\libs\freemodbus\modbus\functions\mbfuncother.c - - - port.c - 1 - ..\..\libs\freemodbus\port\port.c - - - mbrtu_m.c - 1 - ..\..\libs\freemodbus\modbus\rtu\mbrtu_m.c - - - mbfuncinput.c - 1 - ..\..\libs\freemodbus\modbus\functions\mbfuncinput.c - mbfuncdisc.c 1 ..\..\libs\freemodbus\modbus\functions\mbfuncdisc.c - - mb_m.c - 1 - ..\..\libs\freemodbus\modbus\mb_m.c - - - sample_mb_slave.c - 1 - ..\..\libs\freemodbus\samples\sample_mb_slave.c - - - mbrtu.c - 1 - ..\..\libs\freemodbus\modbus\rtu\mbrtu.c - - - mbfuncinput_m.c - 1 - ..\..\libs\freemodbus\modbus\functions\mbfuncinput_m.c - - - mb.c - 1 - ..\..\libs\freemodbus\modbus\mb.c - - - portevent_m.c - 1 - ..\..\libs\freemodbus\port\portevent_m.c - - - porttimer.c - 1 - ..\..\libs\freemodbus\port\porttimer.c - - - portserial_m.c - 1 - ..\..\libs\freemodbus\port\portserial_m.c - mbfuncdisc_m.c 1 ..\..\libs\freemodbus\modbus\functions\mbfuncdisc_m.c + + mbrtu.c + 1 + ..\..\libs\freemodbus\modbus\rtu\mbrtu.c + mbutils.c 1 ..\..\libs\freemodbus\modbus\functions\mbutils.c - mbfuncholding_m.c + porttcp.c 1 - ..\..\libs\freemodbus\modbus\functions\mbfuncholding_m.c + ..\..\libs\freemodbus\port\porttcp.c - portevent.c + port.c 1 - ..\..\libs\freemodbus\port\portevent.c - - - user_mb_app.c - 1 - ..\..\libs\freemodbus\port\user_mb_app.c - - - porttimer_m.c - 1 - ..\..\libs\freemodbus\port\porttimer_m.c - - - mbcrc.c - 1 - ..\..\libs\freemodbus\modbus\rtu\mbcrc.c - - - mbfunccoils.c - 1 - ..\..\libs\freemodbus\modbus\functions\mbfunccoils.c + ..\..\libs\freemodbus\port\port.c mbfuncdiag.c 1 ..\..\libs\freemodbus\modbus\functions\mbfuncdiag.c + + mb_m.c + 1 + ..\..\libs\freemodbus\modbus\mb_m.c + + + user_mb_app_m.c + 1 + ..\..\libs\freemodbus\port\user_mb_app_m.c + + + mbcrc.c + 1 + ..\..\libs\freemodbus\modbus\rtu\mbcrc.c + + + mbfunccoils_m.c + 1 + ..\..\libs\freemodbus\modbus\functions\mbfunccoils_m.c + + + user_mb_app.c + 1 + ..\..\libs\freemodbus\port\user_mb_app.c + + + mbfuncholding.c + 1 + ..\..\libs\freemodbus\modbus\functions\mbfuncholding.c + + + mbfuncinput_m.c + 1 + ..\..\libs\freemodbus\modbus\functions\mbfuncinput_m.c + portserial.c 1 ..\..\libs\freemodbus\port\portserial.c + + mbfuncinput.c + 1 + ..\..\libs\freemodbus\modbus\functions\mbfuncinput.c + + + mbfunccoils.c + 1 + ..\..\libs\freemodbus\modbus\functions\mbfunccoils.c + + + mb.c + 1 + ..\..\libs\freemodbus\modbus\mb.c + + + portevent.c + 1 + ..\..\libs\freemodbus\port\portevent.c + sample_mb_master.c 1 ..\..\libs\freemodbus\samples\sample_mb_master.c + + porttimer.c + 1 + ..\..\libs\freemodbus\port\porttimer.c + + + mbfuncholding_m.c + 1 + ..\..\libs\freemodbus\modbus\functions\mbfuncholding_m.c + + + mbrtu_m.c + 1 + ..\..\libs\freemodbus\modbus\rtu\mbrtu_m.c + + + porttimer_m.c + 1 + ..\..\libs\freemodbus\port\porttimer_m.c + + + portevent_m.c + 1 + ..\..\libs\freemodbus\port\portevent_m.c + + + portserial_m.c + 1 + ..\..\libs\freemodbus\port\portserial_m.c + + + mbfuncother.c + 1 + ..\..\libs\freemodbus\modbus\functions\mbfuncother.c + + + sample_mb_slave.c + 1 + ..\..\libs\freemodbus\samples\sample_mb_slave.c + @@ -1871,7 +1917,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1927,7 +1973,7 @@ __RT_KERNEL_SOURCE__ - + @@ -1983,7 +2029,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2039,7 +2085,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2095,7 +2141,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2151,7 +2197,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2207,7 +2253,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2263,7 +2309,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2319,7 +2365,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2375,7 +2421,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2431,7 +2477,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2487,7 +2533,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2543,7 +2589,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2599,7 +2645,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2655,7 +2701,7 @@ __RT_KERNEL_SOURCE__ - + @@ -2667,15 +2713,20 @@ klibc - kstdio.c + kstring.c 1 - ..\..\rt-thread\src\klibc\kstdio.c + ..\..\rt-thread\src\klibc\kstring.c rt_vsscanf.c 1 ..\..\rt-thread\src\klibc\rt_vsscanf.c + + kstdio.c + 1 + ..\..\rt-thread\src\klibc\kstdio.c + kerrno.c 1 @@ -2686,11 +2737,6 @@ 1 ..\..\rt-thread\src\klibc\rt_vsnprintf_tiny.c - - kstring.c - 1 - ..\..\rt-thread\src\klibc\kstring.c - @@ -2742,89 +2788,9 @@ STM32F4-HAL - stm32f4xx_hal_crc.c + stm32f4xx_hal_usart.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_crc.c - - - stm32f4xx_hal_i2c_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c_ex.c - - - stm32f4xx_hal_rtc.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rtc.c - - - stm32f4xx_hal_dma_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma_ex.c - - - stm32f4xx_hal.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal.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 - - - stm32f4xx_hal_tim.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim.c - - - stm32f4xx_hal_dma.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma.c - - - stm32f4xx_hal_cryp.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp.c - - - stm32f4xx_hal_cortex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cortex.c - - - stm32f4xx_hal_rcc.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc.c - - - stm32f4xx_hal_tim_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim_ex.c - - - stm32f4xx_hal_rtc_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rtc_ex.c - - - stm32f4xx_hal_pwr_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_ex.c - - - stm32f4xx_hal_uart.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_uart.c - - - stm32f4xx_hal_flash_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ex.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_usart.c stm32f4xx_hal_flash.c @@ -2832,44 +2798,14 @@ ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash.c - stm32f4xx_hal_wwdg.c + stm32f4xx_hal_dma.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_wwdg.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma.c - stm32f4xx_hal_rng.c + stm32f4xx_hal_rcc.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c - - - stm32f4xx_hal_usart.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_usart.c - - - stm32f4xx_hal_lptim.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_lptim.c - - - stm32f4xx_hal_i2c.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c.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 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc.c stm32f4xx_hal_cec.c @@ -2877,15 +2813,125 @@ ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cec.c - stm32f4xx_hal_flash_ramfunc.c + stm32f4xx_hal_lptim.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ramfunc.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_lptim.c + + + stm32f4xx_hal_flash_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ex.c + + + stm32f4xx_hal_uart.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_uart.c + + + stm32f4xx_hal_rcc_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc_ex.c + + + stm32f4xx_hal_rtc.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rtc.c + + + stm32f4xx_hal_wwdg.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_wwdg.c + + + stm32f4xx_hal_cortex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cortex.c + + + stm32f4xx_hal_rng.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c + + + stm32f4xx_hal_tim.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim.c + + + stm32f4xx_hal_i2c.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c.c + + + stm32f4xx_hal_crc.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_crc.c stm32f4xx_hal_iwdg.c 1 ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_iwdg.c + + stm32f4xx_hal_pwr.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr.c + + + stm32f4xx_hal_rtc_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rtc_ex.c + + + stm32f4xx_hal_i2c_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c_ex.c + + + stm32f4xx_hal.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal.c + + + stm32f4xx_hal_gpio.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_gpio.c + + + stm32f4xx_hal_dma_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma_ex.c + + + stm32f4xx_hal_flash_ramfunc.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ramfunc.c + + + stm32f4xx_hal_can.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_can.c + + + stm32f4xx_hal_cryp.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp.c + + + stm32f4xx_hal_cryp_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp_ex.c + + + stm32f4xx_hal_pwr_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_ex.c + + + stm32f4xx_hal_tim_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim_ex.c + diff --git a/keilkill.bat b/keilkill.bat index 4fba9c2..15ab31f 100644 --- a/keilkill.bat +++ b/keilkill.bat @@ -21,7 +21,6 @@ del *.dep /s del JLinkLog.txt /s del *.iex /s -del *.htm /s del *.map /s del *.dbgconf /s