roll south mb

This commit is contained in:
wmano
2025-10-26 22:05:19 +08:00
parent 604fe4688c
commit 8b6f231b28
23 changed files with 1053 additions and 550 deletions
+10 -9
View File
@@ -3,19 +3,20 @@
#include <rtthread.h>
#include "chrg_gpio.h"
#include "chrg_north.h"
#include "chrg_rel.h"
struct chrg_rel_t chrgrel[TOTAL_CHS] = {
[IDX_CH_0] = {GPO_PIN_CH1_P0, GPO_PIN_CH1_P1, GPO_PIN_CH1_P2},
[IDX_CH_1] = {GPO_PIN_CH2_P0, GPO_PIN_CH2_P1, GPO_PIN_CH2_P2},
[IDX_CH_2] = {GPO_PIN_CH3_P0, GPO_PIN_CH3_P1, GPO_PIN_CH3_P2},
[IDX_CH_3] = {GPO_PIN_CH4_P0, GPO_PIN_CH4_P1, GPO_PIN_CH4_P2}
struct chrg_rel_t chrgrel[TOTAL_NOR_CHS] = {
[IDX_NOR_CH1] = {GPO_PIN_CH1_P0, GPO_PIN_CH1_P1, GPO_PIN_CH1_P2},
[IDX_NOR_CH2] = {GPO_PIN_CH2_P0, GPO_PIN_CH2_P1, GPO_PIN_CH2_P2},
[IDX_NOR_CH3] = {GPO_PIN_CH3_P0, GPO_PIN_CH3_P1, GPO_PIN_CH3_P2},
[IDX_NOR_CH4] = {GPO_PIN_CH4_P0, GPO_PIN_CH4_P1, GPO_PIN_CH4_P2}
};
// 北向继电器组 组合切换
void chrg_nor_sw_rel (eIDX_CH ch, eIDX_ID id)
void chrg_nor_sw_rel (eIDX_NOR_CH ch, eIDX_ID id)
{
if (ch >= TOTAL_CHS) {
if (ch >= TOTAL_NOR_CHS) {
return ;
}
@@ -39,7 +40,7 @@ static int chrg_nor_rel_init (void)
{
int i = 0;
for (i = 0; i < TOTAL_CHS; i++) {
for (i = 0; i < TOTAL_NOR_CHS; i++) {
rt_pin_write(chrgrel[i].p2, PIN_LOW);
rt_pin_write(chrgrel[i].p0, PIN_LOW);
rt_pin_write(chrgrel[i].p1, PIN_LOW);
@@ -71,7 +72,7 @@ int rel_test (int argc, char **argv)
return -1;
}
rt_uint8_t val = (rt_uint8_t)atoi(argv[3]);
chrg_nor_sw_rel((eIDX_CH)idx, (eIDX_ID)val);
chrg_nor_sw_rel((eIDX_NOR_CH)idx, (eIDX_ID)val);
} else if (strcmp(argv[1], "get") == 0) {
rt_uint8_t data[3] = {0};
data[0] = rt_pin_read(chrgrel[idx].p0);
+3 -3
View File
@@ -3,7 +3,7 @@
#include <rtthread.h>
#include "chrg_switch.h"
#include "chrg_north.h"
#include "chrg_def.h"
struct chrg_rel_t {
@@ -12,9 +12,9 @@ struct chrg_rel_t {
rt_base_t p2; // connect K5 for GND/PGND
};
extern struct chrg_rel_t chrgrel[TOTAL_CHS];
extern struct chrg_rel_t chrgrel[TOTAL_NOR_CHS];
extern void chrg_nor_sw_rel (eIDX_CH ch, eIDX_ID id);
extern void chrg_nor_sw_rel (eIDX_NOR_CH ch, eIDX_ID id);
#endif
+6 -127
View File
@@ -1,6 +1,6 @@
#include <stdlib.h>
#include <rtthread.h>
#include <rtdevice.h>
#include "chrg_gpio.h"
#include "chrg_switch.h"
@@ -17,22 +17,22 @@ int chrg_switch_ch (rt_base_t inA, rt_base_t inB, eIDX_CH ch)
rt_uint8_t a,b;
switch (ch) {
case IDX_CH_0:
case IDX_CH1:
a = PIN_LOW;
b = PIN_LOW;
break;
case IDX_CH_1:
case IDX_CH2:
a = PIN_HIGH;
b = PIN_LOW;
break;
case IDX_CH_2:
case IDX_CH3:
a = PIN_LOW;
b = PIN_HIGH;
break;
case IDX_CH_3:
case IDX_CH4:
a = PIN_HIGH;
b = PIN_HIGH;
break;
@@ -47,133 +47,12 @@ int chrg_switch_ch (rt_base_t inA, rt_base_t inB, eIDX_CH ch)
return 0;
}
// 北向通道选择
int chrg_switch_north (eIDX_CH ch)
{
if (ch >= TOTAL_CHS) {
return -1;
}
return chrg_switch_ch(chrgios[IDX_GPO_NOR_SW_A].base,
chrgios[IDX_GPO_NOR_SW_B].base, ch);
}
// 南向1级选通
int chrg_switch_south_lv1 (eIDX_CH ch)
{
if (ch >= 2) {
return -1;
}
return chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV1_A].base,
chrgios[IDX_GPO_SOU_SW_LV1_B].base, ch);
}
// 南向2级左半
int chrg_switch_south_lv2_1 (eIDX_CH ch)
{
int ret = -1;
if (IDX_CH_0 == ch) {
ret = chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV2_A1].base,
chrgios[IDX_GPO_SOU_SW_LV2_B1].base, IDX_CH_2);
} else if (IDX_CH_1 == ch) {
ret = chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV2_A1].base,
chrgios[IDX_GPO_SOU_SW_LV2_B1].base, IDX_CH_0);
}
return ret;
}
// 南向2级右半
int chrg_switch_south_lv2_2 (eIDX_CH ch)
{
int ret = -1;
if (IDX_CH_0 == ch) {
ret = chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV2_A2].base,
chrgios[IDX_GPO_SOU_SW_LV2_B2].base, IDX_CH_2);
} else if (IDX_CH_1 == ch) {
ret = chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV2_A2].base,
chrgios[IDX_GPO_SOU_SW_LV2_B2].base, IDX_CH_0);
} else {
return -1;
}
return ret;
}
// 南向通道选择
int chrg_switch_south (eIDX_SOU_CH ch)
{
int ret = -1;
if (ch >= TOTAL_SOU_CHS) {
return -1;
}
// 1级/2级通道顺序反向
if ((IDX_SOU_CH1 == ch)||(IDX_SOU_CH2 == ch)) {
ret = chrg_switch_south_lv1(IDX_CH_1);
ret |= chrg_switch_south_lv2_2((eIDX_CH)ch);
} else if ((IDX_SOU_CH3 == ch)||(IDX_SOU_CH4 == ch)) {
ret = chrg_switch_south_lv1(IDX_CH_0);
ret |= chrg_switch_south_lv2_1((eIDX_CH)(ch-IDX_SOU_CH3));
} else {
return -1;
}
return ret;
}
static int chrg_switch_init (void)
{
chrg_switch_north(IDX_CH_0);
chrg_switch_south(IDX_SOU_CH1);
return 0;
}
INIT_ENV_EXPORT(chrg_switch_init);
#if 1
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_NOR_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_SOU_CH)atoi(argv[1]));
return ret;
}
MSH_CMD_EXPORT(south_ch, south channel select);
#endif
+1 -39
View File
@@ -2,48 +2,10 @@
#define __CHRG_SWITCH_H__
#include <rtthread.h>
#include <rtdevice.h>
#include "chrg_gpio.h"
#include "chrg_def.h"
#include "chrg_source.h"
#include "chrg_sink.h"
// 4路选通
typedef enum {
// U14 U23 U24 U25
// ----------------
IDX_CH_0 = 0, // J3 U24 J12 J16
IDX_CH_1, // J4 U25 -J13 -J17
IDX_CH_2, // J9 - J14 J18
IDX_CH_3, // J10 - -J15 -J19
TOTAL_CHS
} eIDX_CH, eIDX_NOR_CH;
// 南向选择 组合
typedef enum {
IDX_SOU_CH1 = 0, // U25_J18
IDX_SOU_CH2, // U25_J16
IDX_SOU_CH3, // U24_J14
IDX_SOU_CH4, // U24_J12
TOTAL_SOU_CHS
} eIDX_SOU_CH;
// 北向通道选择
extern int chrg_switch_north (eIDX_NOR_CH ch);
// 南向通道选择
extern int chrg_switch_south (eIDX_SOU_CH ch);
struct chrg_switch_t {
eIDX_ID id;
struct chrg_src_t source;
struct chrg_sink_t sink;
};
extern int chrg_switch_ch (rt_base_t inA, rt_base_t inB, eIDX_CH ch);
#endif
+4 -4
View File
@@ -483,7 +483,7 @@ eMBException funcWriteCoil (rt_uint8_t *reqFrame, rt_uint16_t reqLen,
return MB_EX_ILLEGAL_DATA_VALUE;
}
memcpy(resFrame, reqFrame, reqLen);
rt_memcpy(resFrame, reqFrame, reqLen);
*resLen = reqLen-2;
eRegStatus = mb_reg_coils_cb(RT_NULL, ucBuf, regAddress, 1, MB_REG_WRITE);
@@ -508,7 +508,7 @@ eMBException funcWriteHoldingRegister (rt_uint8_t *reqFrame, rt_uint16_t reqLen,
regAddress = u8v_to_u16(&reqFrame[2]);
memcpy(resFrame, reqFrame, reqLen);
rt_memcpy(resFrame, reqFrame, reqLen);
*resLen = reqLen-2;
eRegStatus = mb_reg_holding_cb(&reqFrame[4], &resFrame[3], regAddress, 1, MB_REG_WRITE);
@@ -544,7 +544,7 @@ eMBException funcWriteMultipleCoils (rt_uint8_t *reqFrame, rt_uint16_t reqLen,
return MB_EX_ILLEGAL_DATA_VALUE;
}
memcpy(resFrame, reqFrame, reqLen);
rt_memcpy(resFrame, reqFrame, reqLen);
*resLen = 6;
eRegStatus = mb_reg_coils_cb(reqFrame, &resFrame[3], regAddress, cntCoils, MB_REG_WRITE);
@@ -578,7 +578,7 @@ eMBException funcWriteMultipleHoldingRegister (rt_uint8_t *reqFrame, rt_uint16_t
return MB_EX_ILLEGAL_DATA_VALUE;
}
memcpy(resFrame, reqFrame, reqLen);
rt_memcpy(resFrame, reqFrame, reqLen);
*resLen = 6;
eRegStatus = mb_reg_holding_cb(reqFrame, &resFrame[3], regAddress, cntReg, MB_REG_WRITE);
+8 -8
View File
@@ -23,11 +23,11 @@ struct chrg_lcd_t chrglcd = {
static int chrg_lcd_parse (char *recv)
{
if (strstr(recv, "main.CH1_RunStop.txt")) {
if (strstr(recv, "run")) {
chrgnorth.enable[IDX_CH_0] = 1;
} else if (strstr(recv, "stop")) {
chrgnorth.enable[IDX_CH_0] = 0;
if (rt_strstr(recv, "main.CH1_RunStop.txt")) {
if (rt_strstr(recv, "run")) {
chrgnorth.enable[IDX_CH1] = 1;
} else if (rt_strstr(recv, "stop")) {
chrgnorth.enable[IDX_CH1] = 0;
}
// ...
@@ -46,15 +46,15 @@ int chrg_lcd_send (char *cmd)
return -1;
}
int len = strlen(cmd);
int len = rt_strlen(cmd);
rt_uint8_t *data = rt_malloc(len+3);
if (RT_NULL == data) {
LOG_E("malloc failed.");
return -1;
}
memcpy(data, cmd, len);
memset(&data[len], 0xFF, 3);
rt_memcpy(data, cmd, len);
rt_memset(&data[len], 0xFF, 3);
if (RT_NULL != pTTY) {
ret = chrg_tty_send(pTTY, data, len+3);
+43 -15
View File
@@ -1,35 +1,50 @@
#include <string.h>
#include <stdlib.h>
#include <rtthread.h>
#include "chrg_gpio.h"
#include "chrg_thread.h"
#include "chrg_pkg.h"
#include "chrg_north_pkg.h"
#include "chrg_north.h"
#include "chrg_roll_nor.h"
#include "chrg_switch.h"
#include "chrg_utils.h"
#define LOG_TAG "chrg.nor"
#define DBG_LEVEL DBG_LOG
#include <rtdbg.h>
struct chrg_north_t chrgnorth = {
.devname = DEV_NAME_NORTH,
.tty = RT_NULL,
.rx_len = 0,
.enable = {1, 1, 1, 1},
.sw[IDX_CH_0] = {
.sw[IDX_NOR_CH1] = {
.id = ID_SINK,
},
.sw[IDX_CH_1] = {
.sw[IDX_NOR_CH2] = {
.id = ID_SINK,
},
.sw[IDX_CH_2] = {
.sw[IDX_NOR_CH3] = {
.id = ID_SINK,
},
.sw[IDX_CH_3] = {
.sw[IDX_NOR_CH4] = {
.id = ID_SINK,
},
.manual = 0,
};
// 北向通道选择
int chrg_north_switch (eIDX_NOR_CH ch)
{
if (ch >= TOTAL_NOR_CHS) {
return -1;
}
return chrg_switch_ch(chrgios[IDX_GPO_NOR_SW_A].base,
chrgios[IDX_GPO_NOR_SW_B].base, (eIDX_CH)ch);
}
int chrg_north_send (rt_uint8_t *data, rt_size_t length)
{
rt_ssize_t ret = -1;
@@ -106,7 +121,7 @@ static int chrg_north_frame_head (struct rt_ringbuffer *rb, rt_uint8_t *head, eI
return -1;
}
int chrg_north_pickup_frame (struct rt_ringbuffer *rb,
static int chrg_north_pickup_frame (struct rt_ringbuffer *rb,
struct pickup_info_t *pFrame, eIDX_NOR_CH idx)
{
int cnt = 0;
@@ -142,14 +157,15 @@ int chrg_north_pickup_frame (struct rt_ringbuffer *rb,
return -4;
}
memcpy(pFrame->pMB->payload, pFrame->head, LEN_FRAME_HEAD);
rt_memcpy(pFrame->pMB->payload, pFrame->head, LEN_FRAME_HEAD);
len_rb = rt_ringbuffer_data_len(rb);
if (len_rb >= pFrame->len_msg - LEN_FRAME_HEAD) {
rt_ringbuffer_get(rb, &pFrame->pMB->payload[LEN_FRAME_HEAD], pFrame->len_msg - LEN_FRAME_HEAD);
rt_ringbuffer_get(rb, &pFrame->pMB->payload[LEN_FRAME_HEAD],
pFrame->len_msg - LEN_FRAME_HEAD);
chrg_thread_mb_send(IDX_THR_NORTH, pFrame->pMB);
//chrg_pkg_decode(pFrame->pMB->payload, pFrame->len_msg, pSW);
//chrg_north_pkg_decode(pFrame->pMB->payload, pFrame->len_msg, pSW);
pFrame->length = 0;
pFrame->len_msg = 0;
@@ -170,7 +186,7 @@ int chrg_north_pickup_frame (struct rt_ringbuffer *rb,
rt_ringbuffer_get(rb, &pFrame->pMB->payload[pFrame->length], len_need);
chrg_thread_mb_send(IDX_THR_NORTH, pFrame->pMB);
//chrg_pkg_decode(pFrame->pMB->payload, pFrame->len_msg, pSW);
//chrg_north_pkg_decode(pFrame->pMB->payload, pFrame->len_msg, pSW);
pFrame->length = 0;
pFrame->findhead = 0;
@@ -202,6 +218,8 @@ void chrg_north_thread_entry (void *data)
struct chrg_tty_t *pTTY = RT_NULL;
struct chrg_north_t *pNOR = &chrgnorth;
chrg_north_switch(IDX_NOR_CH1);
pTTY = chrg_tty_create(pNOR->devname, BAUD_RATE_2000000, 0, -1, 1);
if (RT_NULL == pTTY) {
LOG_E("tty can't create.");
@@ -245,14 +263,24 @@ void chrg_north_thread_entry (void *data)
}
#if 0
static int north_send(rt_uint8_t argc, char **argv)
#if 1
static int north_ch(rt_uint8_t argc, char **argv)
{
return source_get_vc(5000, 1000);
int ret = 0;
if (2 != argc) {
rt_kprintf("help : %s [0-3]\r\n", argv[0]);
return -1;
}
ret = chrg_north_switch((eIDX_NOR_CH)atoi(argv[1]));
return ret;
}
MSH_CMD_EXPORT(north_send, north send test);
MSH_CMD_EXPORT(north_ch, north channel select);
#endif
+24 -12
View File
@@ -4,8 +4,9 @@
#include <rtthread.h>
#include "chrg_tty.h"
#include "chrg_switch.h"
#include "chrg_source.h"
#include "chrg_sink.h"
#include "chrg_def.h"
#define THR_NAME_NORTH "thr.nor"
#define DEV_NAME_NORTH "uart3"
@@ -13,13 +14,21 @@
#define LEN_FRAME_HEAD (3) // [帧长, 0x00, id]
#define MIN_FRAME_LENGTH (5) // 帧最短5字节
struct pickup_info_t {
rt_tick_t last_tick; // 前次收数据时刻
rt_uint16_t length; // 已提取数据字节数
rt_uint8_t findhead; // 找到帧头
rt_uint8_t head[8]; // 帧头填充区
int len_msg; // 数据长度
struct mb_msg_t *pMB; // 邮件
// 北向4通路索引 U14 ->
typedef enum {
IDX_NOR_CH1 = IDX_CH1, // J3
IDX_NOR_CH2 = IDX_CH2, // J4
IDX_NOR_CH3 = IDX_CH3, // J9
IDX_NOR_CH4 = IDX_CH4, // J10
TOTAL_NOR_CHS
} eIDX_NOR_CH;
struct chrg_switch_t {
eIDX_ID id;
struct chrg_src_t source;
struct chrg_sink_t sink;
};
struct chrg_north_t {
@@ -29,16 +38,19 @@ struct chrg_north_t {
struct rt_ringbuffer *rb;
struct pickup_info_t frame;
rt_uint16_t rx_len;
rt_uint8_t rx_buf[SIZE_BUF_TTY];
rt_uint8_t enable[TOTAL_CHS]; // 通路使能
rt_uint8_t enable[TOTAL_NOR_CHS]; // 通路使能
rt_uint8_t manual; // 手动插入命令
eIDX_NOR_CH idx; // 当前通路
struct chrg_switch_t sw[TOTAL_CHS];
struct chrg_switch_t sw[TOTAL_NOR_CHS];
};
extern struct chrg_north_t chrgnorth;
// 北向通道选择
extern int chrg_north_switch (eIDX_NOR_CH ch);
extern int chrg_north_send (rt_uint8_t *data, rt_size_t length);
extern void chrg_north_thread_entry (void *data);
+62 -13
View File
@@ -1,4 +1,4 @@
#include <stdlib.h>
#include <rtthread.h>
#include "chrg_gpio.h"
@@ -6,21 +6,25 @@
#include "chrg_sink.h"
#include "chrg_source.h"
#include "chrg_roll_nor.h"
#include "chrg_north.h"
#include "chrg_switch.h"
#include "chrg_utils.h"
#define LOG_TAG "chrg.rollnor"
#include <rtdbg.h>
const rt_base_t sw_uart[TOTAL_CHS] = {
rt_uint8_t nor_ch = IDX_NOR_CH1;
const rt_base_t sw_uart[TOTAL_NOR_CHS] = {
IDX_GPO_UART_SW1,
IDX_GPO_UART_SW2,
IDX_GPO_UART_SW3,
IDX_GPO_UART_SW4
};
static void chrg_roll_nor_sw_uart (eIDX_CH ch, eIDX_ID id)
static void chrg_roll_nor_sw_uart (eIDX_NOR_CH ch, eIDX_ID id)
{
if (ch >= TOTAL_CHS) {
if (ch >= TOTAL_NOR_CHS) {
return ;
}
@@ -40,30 +44,36 @@ void chrg_roll_nor_thread_entry (void *data)
return ;
}
rt_uint8_t idx = 0, i = 0;
rt_uint8_t idx = 0, i = 0, manu = 0;
rt_uint8_t crc = 0;
rt_err_t ret = RT_EOK;
struct chrg_thread_t *pTN = &chrgthr[IDX_THR_NORTH];
struct chrg_north_t *pNOR = &chrgnorth;
struct chrg_switch_t *pSW = RT_NULL;
struct mb_msg_t *pMB_R = RT_NULL;
for (i = 0; i < TOTAL_CHS; i++) {
chrg_roll_nor_sw_uart((eIDX_CH)i, ID_SINK);
for (i = 0; i < TOTAL_NOR_CHS; i++) {
chrg_roll_nor_sw_uart((eIDX_NOR_CH)i, ID_SINK);
}
while (1) {
rt_mutex_take(pTHR->mutex, RT_WAITING_FOREVER);
pNOR->idx = idx%(TOTAL_CHS+TOTAL_SOU_CHS);
manu = pNOR->manual;
rt_mutex_release(pTHR->mutex);
if (pNOR->idx < TOTAL_CHS) {
if (1 == manu) {
chrg_north_switch((eIDX_NOR_CH)nor_ch);
source_get_vc(5000, 1000);
} else {
pNOR->idx = idx%TOTAL_NOR_CHS;
if (0 == pNOR->enable[pNOR->idx]) {
idx++;
rt_thread_mdelay(1);
continue;
} else {
pNOR->idx = (eIDX_CH)pNOR->idx;
chrg_switch_north(pNOR->idx);
chrg_north_switch(pNOR->idx);
pSW = &pNOR->sw[pNOR->idx];
if (ID_SOURCE == pSW->id) {
@@ -76,14 +86,23 @@ void chrg_roll_nor_thread_entry (void *data)
//rt_kprintf("Nor[%d].%d\r\n", pNOR->idx, pSW->id);
}
}
idx++;
}
ret = rt_mb_recv(pTN->mb, (rt_uint32_t *)&pMB_R, 100); // 超时 100ms
if ((RT_EOK == ret)&&(RT_NULL != pMB_R)) {
// todo mail data
crc = calc_crc8(pMB_R->payload, pMB_R->length-1);
if (crc == pMB_R->payload[pMB_R->length-1]) {
if (1 == manu) {
rt_mutex_take(pTHR->mutex, RT_WAITING_FOREVER);
pNOR->manual = 0;
rt_mutex_release(pTHR->mutex);
} else {
// todo
}
}
if (RT_NULL != pMB_R->payload) {
rt_free(pMB_R->payload);
@@ -96,11 +115,41 @@ void chrg_roll_nor_thread_entry (void *data)
}
rt_thread_mdelay(50); // 间隔 50ms
} else if (RT_ETIMEOUT == ret) {
rt_mutex_take(pTHR->mutex, RT_WAITING_FOREVER);
pNOR->manual = 0;
rt_mutex_release(pTHR->mutex);
}
}
}
#if 1
static int north_send(rt_uint8_t argc, char **argv)
{
struct chrg_north_t *pNOR = &chrgnorth;
int ch = 0;
if (2 != argc) {
rt_kprintf("help : %s [0-3]\r\n", argv[0]);
return -1;
}
ch = (rt_uint8_t)atoi(argv[1]);
if ((ch < 0)||(ch >= TOTAL_NOR_CHS)) {
rt_kprintf("help : %s [0-3]\r\n", argv[0]);
return -1;
}
nor_ch = (rt_uint8_t)ch;
pNOR->manual = 1;
return 0;
}
MSH_CMD_EXPORT(north_send, north send test);
#endif
@@ -6,9 +6,6 @@
#define THR_NAME_ROLL_NOR "thr.rollnor"
#define ROLL_NOR_EVT_RECVED (1<<0) // 收到北向数据
extern void chrg_roll_nor_thread_entry (void *data);
+76 -26
View File
@@ -1,22 +1,17 @@
#include <stdlib.h>
#include <rtthread.h>
#include "chrg_thread.h"
#include "chrg_roll_sou.h"
#include "chrg_switch.h"
#include "chrg_eload.h"
#include "chrg_utils.h"
#define LOG_TAG "chrg.rollsou"
#include <rtdbg.h>
void chrg_roll_sou_evt_send (void)
{
struct chrg_thread_t *pTHR = &chrgthr[IDX_THR_ROLL_SOU];
if (RT_NULL != pTHR->ev) {
rt_event_send(pTHR->ev, ROLL_SOU_EVT_RECVED);
}
}
rt_uint8_t sou_ch = IDX_SOU_CH1;
rt_uint8_t sou_pt = MB_R_PART1;
void chrg_roll_sou_thread_entry (void *data)
{
@@ -26,7 +21,7 @@ void chrg_roll_sou_thread_entry (void *data)
return ;
}
rt_uint8_t idx = 0;
rt_uint8_t index = 0, idx = 0, part = 0, pt = 0, manu = 0;
rt_err_t ret = RT_EOK;
struct chrg_south_t *pSOU = &chrgsouth;
struct chrg_thread_t *pTS = &chrgthr[IDX_THR_SOUTH];
@@ -34,30 +29,48 @@ void chrg_roll_sou_thread_entry (void *data)
while (1) {
rt_mutex_take(pTHR->mutex, RT_WAITING_FOREVER);
pSOU->idx = idx%(TOTAL_CHS+TOTAL_SOU_CHS);
manu = pSOU->manual;
rt_mutex_release(pTHR->mutex);
if (pSOU->idx < TOTAL_SOU_CHS) {
if (0 == pSOU->enable[pSOU->idx]) {
idx++;
if (1 == manu) {
chrg_south_switch((eIDX_SOU_CH)sou_ch);
chrg_eload_refresh(ID_ELOAD, sou_pt);
} else { // 轮巡4个通道,每个通道3条读取命令
part = index%(TOTAL_SOU_CHS*TOTAL_MB_R); // [0, 11]
idx = part/TOTAL_MB_R; // [0, 3]
pt = part%TOTAL_MB_R;
if (0 == pSOU->enable[idx]) {
pSOU->idx = (eIDX_SOU_CH)idx;
index++;
rt_thread_mdelay(10);
continue;
} else {
pSOU->idx = (eIDX_SOU_CH)pSOU->idx;
chrg_switch_south(pSOU->idx);
//rt_kprintf("Sou[%d].%d\r\n", pSOU->idx, pSOU->id);
}
if (idx != (rt_uint8_t)pSOU->idx) {
pSOU->idx = (eIDX_SOU_CH)idx;
chrg_south_switch(pSOU->idx);
}
idx++;
chrg_eload_refresh(ID_ELOAD, pt);
}
ret = rt_mb_recv(pTS->mb, (rt_uint32_t *)&pMB_R, 100); // 超时 100ms
index++;
}
ret = rt_mb_recv(pTS->mb, (rt_uint32_t *)&pMB_R, 200); // 超时 200ms
if ((RT_EOK == ret)&&(RT_NULL != pMB_R)) {
// todo mail data
if (0 == mb_crc16(pMB_R->payload, pMB_R->length)) {
if (1 == manu) {
rt_mutex_take(pTHR->mutex, RT_WAITING_FOREVER);
pSOU->manual = 0;
rt_mutex_release(pTHR->mutex);
} else {
chrg_eload_parse(idx, pt, pMB_R->payload, pMB_R->length);
}
} else {
LOG_E("crc failed.");
}
if (RT_NULL != pMB_R->payload) {
rt_free(pMB_R->payload);
@@ -70,11 +83,48 @@ void chrg_roll_sou_thread_entry (void *data)
}
rt_thread_mdelay(50); // 间隔 50ms
} else if (RT_ETIMEOUT == ret) {
rt_mutex_take(pTHR->mutex, RT_WAITING_FOREVER);
pSOU->manual = 0;
rt_mutex_release(pTHR->mutex);
}
}
}
#if 1
static int south_send(rt_uint8_t argc, char **argv)
{
struct chrg_south_t *pSOU = &chrgsouth;
int ch = 0, pt = 0;
if (3 != argc) {
rt_kprintf("help : %s [0-3] [0-2]\r\n", argv[0]);
return -1;
}
ch = (rt_uint8_t)atoi(argv[1]);
if ((ch < 0)||(ch >= TOTAL_SOU_CHS)) {
rt_kprintf("help : %s [0-3] [0-2]\r\n", argv[0]);
return -1;
}
pt = (rt_uint8_t)atoi(argv[2]);
if ((pt < 0)||(pt >= TOTAL_MB_R)) {
rt_kprintf("help : %s [0-3] [0-2]\r\n", argv[0]);
return -1;
}
sou_ch = (rt_uint8_t)ch;
sou_pt = (rt_uint8_t)pt;
pSOU->manual = 1;
return 0;
}
MSH_CMD_EXPORT(south_send, south send test);
#endif
@@ -6,14 +6,10 @@
#define THR_NAME_ROLL_SOU "thr.rollsou"
#define ROLL_SOU_EVT_RECVED (1<<0) // 收到南向数据
extern void chrg_roll_sou_evt_send (void);
extern void chrg_roll_sou_thread_entry (void *data);
#endif
+257 -11
View File
@@ -1,22 +1,26 @@
#include <stdlib.h>
#include <rtthread.h>
#include "chrg_gpio.h"
#include "chrg_thread.h"
#include "chrg_south.h"
#include "chrg_roll_sou.h"
#include "chrg_switch.h"
#include "chrg_utils.h"
#define LOG_TAG "chrg.sou"
#define DBG_LEVEL DBG_LOG
#include <rtdbg.h>
#define MB_ACK_HEAD_SIZE 3 // modbus 响应头3字节
struct chrg_south_t chrgsouth = {
.devname = DEV_NAME_SOUTH,
.tty = RT_NULL,
.rx_len = 0,
.rb = RT_NULL,
.enable = {1, 1, 1, 1},
.idx = IDX_SOU_CH1,
.sw[IDX_SOU_CH1] = {
/*.sw[IDX_SOU_CH1] = {
.id = ID_ELOAD,
},
.sw[IDX_SOU_CH2] = {
@@ -27,10 +31,77 @@ struct chrg_south_t chrgsouth = {
},
.sw[IDX_SOU_CH4] = {
.id = ID_ELOAD,
},
},*/
};
// 南向1级选通
static int chrg_south_switch_lv1 (eIDX_CH ch)
{
if (ch >= 2) {
return -1;
}
return chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV1_A].base,
chrgios[IDX_GPO_SOU_SW_LV1_B].base, ch);
}
// 南向2级左半
static int chrg_south_switch_lv2_1 (eIDX_CH ch)
{
int ret = -1;
if (IDX_CH1 == ch) {
ret = chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV2_A1].base,
chrgios[IDX_GPO_SOU_SW_LV2_B1].base, IDX_CH3);
} else if (IDX_CH2 == ch) {
ret = chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV2_A1].base,
chrgios[IDX_GPO_SOU_SW_LV2_B1].base, IDX_CH1);
}
return ret;
}
// 南向2级右半
static int chrg_south_switch_lv2_2 (eIDX_CH ch)
{
int ret = -1;
if (IDX_CH1 == ch) {
ret = chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV2_A2].base,
chrgios[IDX_GPO_SOU_SW_LV2_B2].base, IDX_CH3);
} else if (IDX_CH2 == ch) {
ret = chrg_switch_ch(chrgios[IDX_GPO_SOU_SW_LV2_A2].base,
chrgios[IDX_GPO_SOU_SW_LV2_B2].base, IDX_CH1);
} else {
return -1;
}
return ret;
}
// 南向通道选择
int chrg_south_switch (eIDX_SOU_CH ch)
{
int ret = -1;
if (ch >= TOTAL_SOU_CHS) {
return -1;
}
// 1级/2级通道顺序反向
if ((IDX_SOU_CH1 == ch)||(IDX_SOU_CH2 == ch)) {
ret = chrg_south_switch_lv1(IDX_CH2);
ret |= chrg_south_switch_lv2_2((eIDX_CH)ch);
} else if ((IDX_SOU_CH3 == ch)||(IDX_SOU_CH4 == ch)) {
ret = chrg_south_switch_lv1(IDX_CH1);
ret |= chrg_south_switch_lv2_1((eIDX_CH)(ch-IDX_SOU_CH3));
} else {
return -1;
}
return ret;
}
int chrg_south_send (rt_uint8_t *data, rt_size_t length)
{
rt_ssize_t ret = -1;
@@ -43,6 +114,158 @@ int chrg_south_send (rt_uint8_t *data, rt_size_t length)
return ret;
}
// 读取 modbus 前3个字节。2个(设置)或3个字节(查询)
static int chrg_south_frame_head (struct rt_ringbuffer *rb, rt_uint8_t *head, eIDX_ID id)
{
int i = 0;
rt_uint8_t data = 0, stage = 0, rd = 0;
rt_size_t ret = 0;
rt_size_t len_rb = 0; // ring数据长度
if (RT_NULL == rb) {
return -1;
}
len_rb = rt_ringbuffer_data_len(rb);
if (len_rb < MB_ACK_HEAD_SIZE) { // 帧头3字节
return -1;
}
for (i = 0; i < len_rb - 2; i++) { // 找头三个字节 [地址, 功能码, 长度/无]
ret = rt_ringbuffer_getchar(rb, &data);
if (0 == ret) {
continue;
}
switch (stage) {
case 0:
head[0] = data;
if (data != id) { // 地址不符
stage = 0;
continue;
}
stage = 1;
break;
case 1:
head[1] = data;
if (MB_REGISTER_RD == data) { // 读寄存器 应答
stage = 2;
rd = 1;
} else if (MB_REGISTER_WR == data) { // 写单个寄存器 应答
stage = 2;
} else {
stage = 0;
}
break;
case 2:
head[2] = data;
if (1 == rd) {
if ((data == 0)||(data > 80)||(data%2 != 0)) { // 大于40个寄存器
stage = 0;
} else {
return data+5;
}
} else {
return 8; // 原命令返回
}
break;
default:
break;
}
}
return -1;
}
static int chrg_south_pickup_frame (struct rt_ringbuffer *rb,
struct pickup_info_t *pFrame)
{
int cnt = 0;
rt_size_t len_rb = 0;
if ((RT_NULL == rb)||(RT_NULL == pFrame)) {
return -1;
}
do {
if (0 == pFrame->findhead) {
pFrame->len_msg = chrg_south_frame_head(rb, pFrame->head, ID_ELOAD);
if (pFrame->len_msg > 0) {
pFrame->pMB = (struct mb_msg_t *)rt_malloc(sizeof(struct mb_msg_t));
if (RT_NULL == pFrame->pMB) {
LOG_E("malloc mb failed.");
return -2;
}
pFrame->pMB->length = pFrame->len_msg;
if (pFrame->pMB->length >= SIZE_BUF_TTY) {
rt_free(pFrame->pMB);
pFrame->pMB = RT_NULL;
LOG_E("too long msg.");
return -3;
}
pFrame->pMB->payload = (rt_uint8_t *)rt_malloc(pFrame->len_msg);
if (RT_NULL == pFrame->pMB->payload) {
LOG_E("malloc buf failed.");
return -4;
}
rt_memcpy(pFrame->pMB->payload, pFrame->head, MB_ACK_HEAD_SIZE);
len_rb = rt_ringbuffer_data_len(rb);
if (len_rb >= pFrame->len_msg - MB_ACK_HEAD_SIZE) {
rt_ringbuffer_get(rb, &pFrame->pMB->payload[MB_ACK_HEAD_SIZE],
pFrame->len_msg - MB_ACK_HEAD_SIZE);
chrg_thread_mb_send(IDX_THR_SOUTH, pFrame->pMB);
pFrame->length = 0;
pFrame->len_msg = 0;
cnt++;
} else {
rt_ringbuffer_get(rb, &pFrame->pMB->payload[MB_ACK_HEAD_SIZE], len_rb);
pFrame->length = MB_ACK_HEAD_SIZE + len_rb;
pFrame->findhead = 1;
pFrame->last_tick = rt_tick_get();
break;
}
}
} else {
len_rb = rt_ringbuffer_data_len(rb);
int len_need = pFrame->len_msg - MB_ACK_HEAD_SIZE;
if (len_rb >= len_need) {
rt_ringbuffer_get(rb, &pFrame->pMB->payload[pFrame->length], len_need);
chrg_thread_mb_send(IDX_THR_SOUTH, pFrame->pMB);
pFrame->length = 0;
pFrame->findhead = 0;
pFrame->len_msg = 0;
cnt++;
} else {
rt_ringbuffer_get(rb, &pFrame->pMB->payload[pFrame->length], len_rb);
pFrame->length += len_rb;
pFrame->last_tick = rt_tick_get();
break;
}
}
len_rb = rt_ringbuffer_data_len(rb);
} while (len_rb >= MB_ACK_HEAD_SIZE);
return cnt;
}
void chrg_south_thread_entry (void *data)
{
struct chrg_thread_t *pTHR = (struct chrg_thread_t *)data;
@@ -55,6 +278,8 @@ void chrg_south_thread_entry (void *data)
struct chrg_tty_t *pTTY = RT_NULL;
struct chrg_south_t *pSOU = &chrgsouth;
chrg_south_switch(IDX_SOU_CH1);
pTTY = chrg_tty_create(pSOU->devname, BAUD_RATE_115200, 0, -1, 1);
if (RT_NULL == pTTY) {
LOG_E("tty can't create.");
@@ -69,6 +294,12 @@ void chrg_south_thread_entry (void *data)
pSOU->tty = pTTY;
pSOU->rb = rt_ringbuffer_create(SIZE_BUF_TTY*2);
if (RT_NULL == pSOU->rb) {
LOG_E("create rb '%s' failed.", pSOU->devname);
return ;
}
while (1) {
rt_memset(pSOU->rx_buf, 0, sizeof(pSOU->rx_buf));
len = chrg_tty_recv(pTTY, pSOU->rx_buf, sizeof(pSOU->rx_buf));
@@ -77,25 +308,40 @@ void chrg_south_thread_entry (void *data)
continue;
}
// pick data & update sw
rt_ringbuffer_put(pSOU->rb, pSOU->rx_buf, len);
if (1 == pSOU->frame.findhead) {
if (rt_tick_get() >= pSOU->frame.last_tick + 100) { // 100ms
pSOU->frame.findhead = 0; // reset
//LOG_E("timeo\r\n");
}
}
//chrg_thread_mb_send(IDX_THR_NORTH, pFrame->pMB);
chrg_south_pickup_frame(pSOU->rb, &pSOU->frame);
}
}
#if 1
static int south_send(rt_uint8_t argc, char **argv)
static int south_ch(rt_uint8_t argc, char **argv)
{
return source_get_vc(5000, 1000);
//return chrg_south_send("1234567890abcdef", 16);
int ret = 0;
if (2 != argc) {
rt_kprintf("help : %s [0-3]\r\n", argv[0]);
return -1;
}
ret = chrg_south_switch((eIDX_SOU_CH)atoi(argv[1]));
return ret;
}
MSH_CMD_EXPORT(south_send, south send test);
MSH_CMD_EXPORT(south_ch, south channel select);
#endif
+22 -3
View File
@@ -3,26 +3,45 @@
#include <rtthread.h>
#include "chrg_def.h"
#include "chrg_tty.h"
#include "chrg_switch.h"
#include "chrg_eload.h"
#define THR_NAME_SOUTH "thr.sou"
#define DEV_NAME_SOUTH "uart6"
// 南向选择 组合
typedef enum {
IDX_SOU_CH1 = IDX_CH1, // U25_J18
IDX_SOU_CH2 = IDX_CH2, // U25_J16
IDX_SOU_CH3 = IDX_CH3, // U24_J14
IDX_SOU_CH4 = IDX_CH4, // U24_J12
TOTAL_SOU_CHS
} eIDX_SOU_CH;
struct chrg_south_t {
const char *devname;
struct chrg_tty_t *tty;
rt_uint16_t rx_len;
struct rt_ringbuffer *rb;
struct pickup_info_t frame;
rt_uint8_t rx_buf[SIZE_BUF_TTY];
rt_uint8_t enable[TOTAL_SOU_CHS]; // 通路使能
rt_uint8_t manual; // 手动插入命令
eIDX_SOU_CH idx; // 当前通路
struct chrg_switch_t sw[TOTAL_SOU_CHS];
eIDX_MB_PART part;
struct chrg_eload_t eload[TOTAL_SOU_CHS]; // 负载
};
extern struct chrg_south_t chrgsouth;
// 南向通道选择
extern int chrg_south_switch (eIDX_SOU_CH ch);
extern int chrg_south_send (rt_uint8_t *data, rt_size_t length);
extern void chrg_south_thread_entry (void *data);
+1 -1
View File
@@ -111,7 +111,7 @@ rt_err_t chrg_thread_mb_send (eIDX_THRS idx, void *data)
rt_err_t ret = RT_EOK;
if (idx >= TOTAL_THRS) {
return RT_ERROR;
return -RT_ERROR;
}
struct chrg_thread_t *pTHR = &chrgthr[idx];
+18
View File
@@ -3,6 +3,15 @@
#include <rtthread.h>
// 4路选通
typedef enum {
IDX_CH1 = 0, // 通路1
IDX_CH2, // 通路2
IDX_CH3, // 通路3
IDX_CH4, // 通路4
TOTAL_CHS
} eIDX_CH;
typedef enum {
ID_SINK = 0x01, // SINK 的 ID 为 1, 波特率 200K
@@ -44,6 +53,15 @@ struct mb_msg_t {
rt_uint8_t *payload; // 数据区
};
struct pickup_info_t {
rt_tick_t last_tick; // 前次收数据时刻
rt_uint16_t length; // 已提取数据字节数
rt_uint8_t findhead; // 找到帧头
rt_uint8_t head[8]; // 帧头填充区
int len_msg; // 数据长度
struct mb_msg_t *pMB; // 邮件
};
#endif
+101
View File
@@ -0,0 +1,101 @@
#include <rtthread.h>
#include "chrg_south.h"
#include "chrg_eload.h"
#include "chrg_utils.h"
int chrg_eload_read_regs (rt_uint8_t addr, rt_uint16_t reg, rt_uint16_t len)
{
rt_uint8_t buf[8] = {0};
rt_uint16_t crc = 0;
buf[0] = addr;
buf[1] = MB_REGISTER_RD;
u16_to_u8v(reg, &buf[2]);
u16_to_u8v(len, &buf[4]);
crc = mb_crc16(buf, 6);
u16_to_u8v(crc, &buf[6]);
return chrg_south_send(buf, 8);
}
int chrg_eload_write_reg (rt_uint8_t addr, rt_uint16_t reg, rt_uint16_t value)
{
rt_uint8_t buf[8] = {0};
rt_uint16_t crc = 0;
buf[0] = addr;
buf[1] = MB_REGISTER_WR;
u16_to_u8v(reg, &buf[2]);
u16_to_u8v(value, &buf[4]);
crc = mb_crc16(buf, 6);
u16_to_u8v(crc, &buf[6]);
return chrg_south_send(buf, 8);
}
int chrg_eload_refresh (rt_uint8_t addr, rt_uint8_t part)
{
int ret = 0;
if (0 == part) {
chrg_eload_read_regs(addr, REG_TEMPERATUE, SIZE_P1_RD); // reg 112~123
} else if (1 == part) {
chrg_eload_read_regs(addr, REG_STA1, SIZE_P2_RD); // reg 0~39
} else if (2 == part) {
chrg_eload_read_regs(addr, REG_LIMIT_VOL, SIZE_P3_RD); // reg 40~63
}
return ret;
}
int chrg_eload_parse (rt_uint8_t idx, rt_uint8_t pt, rt_uint8_t *data, rt_uint16_t len)
{
if (idx >= TOTAL_SOU_CHS) {
return -1;
}
struct chrg_eload_t *pLOAD = &chrgsouth.eload[idx];
switch (pt) {
case MB_R_PART1: {
if ((SIZE_P1_RD*2+5) != len) {
return -1;
}
struct eload_p1_t *pP1 = (struct eload_p1_t *)&data[3];
}
break;
case MB_R_PART2: {
if ((SIZE_P2_RD*2+5) != len) {
return -1;
}
struct eload_p2_t *pP2 = (struct eload_p2_t *)&data[3];
}
break;
case MB_R_PART3: {
if ((SIZE_P3_RD*2+5) != len) {
return -1;
}
struct eload_p3_t *pP3 = (struct eload_p3_t *)&data[3];
}
break;
default:
break;
}
return 0;
}
+163
View File
@@ -0,0 +1,163 @@
#ifndef __CHRG_ELOAD_H__
#define __CHRG_ELOAD_H__
#include <rtthread.h>
#define MB_REGISTER_RD (0x03) // 读寄存器
#define MB_REGISTER_WR (0x06) // 写寄存器
#define REG_STA1 (0x00) // R 16bit 工作状态1
#define STA1_CHARGING (0x00) // 预充电中
#define STA1_READY (0x01) // 就绪/停止
#define STA1_RUNNING (0x02) // 运行
#define STA1_FAULT (0x03) // 故障
#define REG_STA2 (0x01) // R 16bit 工作状态2
#define STA2_PRE_REL_CLOSE (1<<0) // 预充继电器闭合
#define STA2_MAIN_REL_CLOSE (1<<1) // 主继电器闭合
#define REG_FAULT1 (0x02) // R 16bit 故障状态1
#define FAULT1_LOW_IN_VOL (1<<0) // 输入欠压
#define FAULT1_OVER_IN_VOL (1<<1) // 输入过压
#define FAULT1_OVER_IN_CUR (1<<2) // 输入过流
#define FAULT1_OVER_OUT_VOL (1<<3) // 输出过压
#define FAULT1_OVER_OUT_CUR (1<<4) // 输出过流
#define REG_FAULT2 (0x03) // R 16bit 故障状态2
#define FALUT2_FLASH (1<<0) // 存储异常
#define REG_ELOAD (0x04) // RW 16bit 源载指令 默认负载
#define ELOAD_SOURCE (0x01) // 电源
#define ELOAD_LOAD (0x02) // 负载
#define REG_WORK (0x1E) // W 16bit 工作指令
#define WORK_START (0x01) // 启动
#define WORK_STOP (0x02) // 停止
#define WORK_RESET (0x03) // 故障复位
#define WORK_SAVE (0xAA) // 存储数据到FLASH
#define WORK_RESTORE (0xBB) // 恢复默认参数
#define REG_MODE (0x1F) // RW 16bit 工作模式
#define MODE_CONSTANT_VOLTAGE (0x01) // 恒压
#define MODE_CONSTANT_CURRENT (0x02) // 恒流
#define MODE_OPEN_LOOP (0x03) // 开环
#define MODE_CONSTANT_POWER (0x04) // 恒功率
#define MODE_CONSTANT_RESISTANCE (0x05) // 恒阻
#define REG_VOLTAGE (0x20) // RW 32bit 电压 0.001V (0~60V) 默认5V
#define REG_CURRENT (0x22) // RW 32bit 电流 0.001A (0~60A) 默认1A
#define REG_POWER (0x24) // RW 32bit 功率 0.01W (0~600W)
#define REG_RESISTANCE (0x26) // RW 16bit 电阻 0.001R
#define REG_LIMIT_VOL (0x28) // RW 32bit 电压限值 0.001V (0~60V) 默认48V
#define REG_LIMIT_VUR (0x2A) // RW 32bit 电流限值 0.001A (0~60A) 默认10A
#define REG_ADJUST_VOL_K (0x2C) // RWP 16bit 电压矫正K 0~65535 默认4096
#define REG_ADJUST_VOL_B (0x2D) // RWP 16bit 电压矫正B 0~65535 默认0
#define REG_ADJUST_CUR_K (0x2E) // RWP 16bit 电流矫正K 0~65535 默认4096
#define REG_ADJUST_CUR_B (0x2F) // RWP 16bit 电流矫正B 0~65535 默认0
#define REG_VOL_LOOP_KP (0x30) // RWP float 电压环KP 0.001~100 默认0.1
#define REG_VOL_LOOP_KI (0x32) // RWP float 电压环KI 0.001~100 默认0.01
#define REG_CUR_LOOP_KP (0x34) // RWP float 电流环KP 0.001~100 默认0.1
#define REG_CUR_LOOP_KI (0x36) // RWP float 电流环KI 0.001~100 默认0.01
#define REG_POWER_LOOP_KP (0x38) // RWP float 功率环KP 0.001~100 默认0.1
#define REG_POWER_LOOP_KI (0x3A) // RWP float 功率环KI 0.001~100 默认0.01
#define REG_RESIS_LOOP_KP (0x3C) // RWP float 恒阻环KP 0.001~100 默认0.1
#define REG_RESIS_LOOP_KI (0x3E) // RWP float 恒阻环KI 0.001~100 默认0.01
#define REG_TEMPERATUE (0x70) // RWP 16bit 读取温度 0.01C (0~100C)
#define REG_TEMP_PROTECT (0x71) // RWP 16bit 温度保护值 0.01C (60~100C) 默认90C
#define REG_ADDRESS (0x7A) // RWP 16bit 从机地址
#define REG_VERSION (0x7B) // R 16bit 版本号 0~0xFFFF
typedef enum {
MB_R_PART1 = 0, // 寄存器分段1
MB_R_PART2, // 寄存器分段2
MB_R_PART3, // 寄存器分段3
TOTAL_MB_R
} eIDX_MB_PART;
#define SIZE_P1_RD 12 // 读12个寄存器
#define SIZE_P2_RD 40 // 读40个寄存器
#define SIZE_P3_RD 24 // 读24个寄存器
struct eload_p1_t {
rt_uint16_t temperature; // reg112
rt_uint16_t temp_protect; // reg113
rt_uint16_t reserv[8];
rt_uint16_t addr; // reg122
rt_uint16_t version; // reg123
};
struct eload_p2_t {
rt_uint16_t status1; // reg0
rt_uint16_t status2; // reg1
rt_uint16_t fault1; // reg2
rt_uint16_t fault2; // reg3
rt_uint16_t eload; // reg4
rt_uint16_t reserv1[25];
rt_uint16_t work_cmd; // reg30
rt_uint16_t work_mode; // reg31
rt_uint32_t voltage; // reg32-33
rt_uint32_t current; // reg34-35
rt_uint32_t power; // reg36-37
rt_uint16_t resistance; // reg38
rt_uint16_t reserv2;
};
struct eload_p3_t {
rt_uint32_t limit_vol; // reg40-41
rt_uint32_t limit_cur; // reg42-43
rt_uint16_t adj_vol_k; // reg44
rt_uint16_t adj_vol_b; // reg45
rt_uint16_t adj_cur_k; // reg46
rt_uint16_t adj_cur_b; // reg47
rt_uint32_t loop_vol_kp; // reg48-49 float
rt_uint32_t loop_vol_ki; // reg50-51 float
rt_uint32_t loop_cur_kp; // reg52-53 float
rt_uint32_t loop_cur_ki; // reg54-55 float
rt_uint32_t loop_pwr_kp; // reg56-57 float
rt_uint32_t loop_pwr_ki; // reg58-59 float
rt_uint32_t loop_resis_kp; // reg60-61 float
rt_uint32_t loop_resis_ki; // reg62-63 float
};
struct chrg_eload_t {
rt_uint16_t status1; // 工作状态1
rt_uint16_t status2; // 工作状态2
rt_uint16_t falut1; // 故障状态1
rt_uint16_t falut2; // 故障状态2
};
extern int chrg_eload_read_regs (rt_uint8_t addr, rt_uint16_t reg, rt_uint16_t len);
extern int chrg_eload_write_reg (rt_uint8_t addr, rt_uint16_t reg, rt_uint16_t value);
extern int chrg_eload_refresh (rt_uint8_t addr, rt_uint8_t part);
extern int chrg_eload_parse (rt_uint8_t idx, rt_uint8_t pt, rt_uint8_t *data, rt_uint16_t len);
#endif
@@ -3,11 +3,10 @@
#include <rtthread.h>
#include "chrg_north.h"
#include "chrg_south.h"
#include "chrg_pkg.h"
#include "chrg_north_pkg.h"
#include "chrg_utils.h"
int chrg_pkg_encode (eIDX_ID id, rt_uint8_t cmd, rt_uint8_t *data_in,
int chrg_north_pkg_encode (eIDX_ID id, rt_uint8_t cmd, rt_uint8_t *data_in,
rt_uint8_t len_in, rt_uint8_t *data_out, rt_uint16_t *len_out)
{
if (RT_NULL == data_out) {
@@ -24,7 +23,7 @@ int chrg_pkg_encode (eIDX_ID id, rt_uint8_t cmd, rt_uint8_t *data_in,
data_out[3] = cmd;
if (len_in > 0) {
memcpy(&data_out[4], data_in, len_in);
rt_memcpy(&data_out[4], data_in, len_in);
}
data_out[len_in+4] = calc_crc8(data_out, len_in+4);
@@ -35,7 +34,7 @@ int chrg_pkg_encode (eIDX_ID id, rt_uint8_t cmd, rt_uint8_t *data_in,
}
int chrg_pkg_decode (rt_uint8_t *data, rt_uint16_t length, struct chrg_switch_t *pSW)
int chrg_north_pkg_decode (rt_uint8_t *data, rt_uint16_t length, struct chrg_switch_t *pSW)
{
if ((RT_NULL == data)||(RT_NULL == pSW)||(length < 5)) {
return -1;
@@ -120,27 +119,6 @@ int chrg_pkg_decode (rt_uint8_t *data, rt_uint16_t length, struct chrg_switch_t
return 0;
}
int chrg_pkg_send (eIDX_TTY idx, rt_uint8_t *data, rt_uint16_t len)
{
rt_ssize_t ret = -1;
struct chrg_tty_t *pTTY = RT_NULL;
switch (idx) {
case IDX_TTY_NORTH:
pTTY = chrgnorth.tty;
break;
case IDX_TTY_SOUTH:
pTTY = chrgsouth.tty;
break;
default:
return -1;
}
if ((RT_NULL != pTTY)&&(RT_NULL != pTTY->dev)) {
ret = rt_device_write(pTTY->dev, 0, data, len);
}
return ret;
}
@@ -0,0 +1,19 @@
#ifndef __CHRG_PKG_H__
#define __CHRG_PKG_H__
#include <rtthread.h>
#include "chrg_tty.h"
#include "chrg_def.h"
#include "chrg_north.h"
extern int chrg_north_pkg_encode (eIDX_ID id, rt_uint8_t cmd, rt_uint8_t *data_in,
rt_uint8_t len_in, rt_uint8_t *data_out, rt_uint16_t *len_out);
extern int chrg_north_pkg_decode (rt_uint8_t *data, rt_uint16_t length, struct chrg_switch_t *pSW);
#endif
-19
View File
@@ -1,19 +0,0 @@
#ifndef __CHRG_PKG_H__
#define __CHRG_PKG_H__
#include <rtthread.h>
#include "chrg_tty.h"
#include "chrg_def.h"
#include "chrg_switch.h"
extern int chrg_pkg_encode (eIDX_ID id, rt_uint8_t cmd, rt_uint8_t *data_in,
rt_uint8_t len_in, rt_uint8_t *data_out, rt_uint16_t *len_out);
extern int chrg_pkg_decode (rt_uint8_t *data, rt_uint16_t length, struct chrg_switch_t *pSW);
extern int chrg_pkg_send (eIDX_TTY idx, rt_uint8_t *data, rt_uint16_t len);
#endif
+5 -5
View File
@@ -3,7 +3,7 @@
#include "chrg_source.h"
#include "chrg_north.h"
#include "chrg_pkg.h"
#include "chrg_north_pkg.h"
#include "chrg_utils.h"
@@ -19,7 +19,7 @@ int source_get_vc (rt_uint16_t vol, rt_uint16_t cur)
data[4] = 0x00;
data[5] = 0x00;
chrg_pkg_encode(ID_SOURCE, SRC_CMD_GET_VOLTAGE, data, 6, frame, &len);
chrg_north_pkg_encode(ID_SOURCE, SRC_CMD_GET_VOLTAGE, data, 6, frame, &len);
return chrg_north_send(frame, len);
}
@@ -29,7 +29,7 @@ int source_get_pd (void)
rt_uint16_t len = 0;
rt_uint8_t frame[16] = {0};
chrg_pkg_encode(ID_SOURCE, SRC_CMD_GET_PROTOCOL, RT_NULL, 0, frame, &len);
chrg_north_pkg_encode(ID_SOURCE, SRC_CMD_GET_PROTOCOL, RT_NULL, 0, frame, &len);
return chrg_north_send(frame, len);
}
@@ -42,7 +42,7 @@ int source_set_cc_lvl (rt_uint8_t lvl)
data[0] = lvl;
chrg_pkg_encode(ID_SOURCE, SRC_CMD_SET_CC_LEVEL, data, 1, frame, &len);
chrg_north_pkg_encode(ID_SOURCE, SRC_CMD_SET_CC_LEVEL, data, 1, frame, &len);
return chrg_north_send(frame, len);
}
@@ -62,7 +62,7 @@ int source_set_pd (rt_uint8_t pro, rt_uint8_t src, rt_uint8_t pps,
u16_to_u8v(vmin, &data[5]);
u16_to_u8v(max_cur, &data[7]);
chrg_pkg_encode(ID_SOURCE, SRC_CMD_SET_CC_LEVEL, data, 9, frame, &len);
chrg_north_pkg_encode(ID_SOURCE, SRC_CMD_SET_CC_LEVEL, data, 9, frame, &len);
return chrg_north_send(frame, len);
}
+220 -216
View File
@@ -10,7 +10,6 @@
<TargetName>chrg</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>6160000::V6.16::ARMCLANG</pCCUsed>
<uAC6>1</uAC6>
<TargetOption>
<TargetCommonOption>
@@ -337,9 +336,9 @@
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define>STM32F405xx, __CLK_TCK=RT_TICK_PER_SECOND, __STDC_LIMIT_MACROS, RT_USING_LIBC, USE_HAL_DRIVER, __RTTHREAD__, RT_USING_ARMLIBC</Define>
<Define>RT_USING_LIBC, __CLK_TCK=RT_TICK_PER_SECOND, RT_USING_ARMLIBC, __RTTHREAD__, __STDC_LIMIT_MACROS, USE_HAL_DRIVER, STM32F405xx</Define>
<Undefine></Undefine>
<IncludePath>..\..\rt-thread\components\libc\posix\ipc;..\..\rt-thread\components\drivers\smp_call;board\CubeMX_Config\Inc;..\..\rt-thread\libcpu\arm\cortex-m4;..\..\rt-thread\components\libc\posix\io\poll;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;..\..\rt-thread\components\libc\compilers\common\include;board\ports;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\libs\cmsis-core\Include;..\..\rt-thread\components\finsh;..\..\libs\stm32f4\STM32F4_HAL\Inc;..\..\rt-thread\components\libc\compilers\common\extension;applications\thread;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_flash;..\..\rt-thread\components\drivers\include;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;..\..\rt-thread\components\drivers\include;applications;..\..\rt-thread\components\drivers\phy;applications\bsp;..\..\rt-thread\components\drivers\include;board;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\components\libc\posix\io\eventfd;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;..\..\rt-thread\components\legacy\usb\usbdevice;..\..\rt-thread\components\fal\inc;..\..\rt-thread\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\io\epoll;.;..\..\rt-thread\libcpu\arm\common;applications\utils;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\rt-thread\components\drivers\include</IncludePath>
<IncludePath>..\..\rt-thread\components\finsh;applications\bsp;..\..\libs\cmsis-core\Include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;..\..\rt-thread\components\libc\posix\ipc;..\..\libs\stm32f4\STM32F4_HAL\Inc;..\..\rt-thread\components\legacy\usb\usbdevice;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\components\drivers\include;board\CubeMX_Config\Inc;..\..\rt-thread\components\libc\compilers\common\extension;..\..\rt-thread\components\drivers\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_flash;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;..\..\rt-thread\components\drivers\phy;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\rt-thread\components\libc\posix\io\poll;applications\utils;..\..\rt-thread\components\fal\inc;..\..\rt-thread\components\libc\compilers\common\include;..\..\rt-thread\components\libc\posix\io\eventfd;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\smp_call;..\..\rt-thread\libcpu\arm\common;..\..\rt-thread\components\drivers\include;applications;.;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;board;applications\thread;..\..\rt-thread\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\io\epoll;board\ports;..\..\rt-thread\libcpu\arm\cortex-m4</IncludePath>
</VariousControls>
</Cads>
<Aads>
@@ -393,21 +392,6 @@
<Group>
<GroupName>Applications/bsp</GroupName>
<Files>
<File>
<FileName>chrg_led.c</FileName>
<FileType>1</FileType>
<FilePath>applications\bsp\chrg_led.c</FilePath>
</File>
<File>
<FileName>chrg_wdt.c</FileName>
<FileType>1</FileType>
<FilePath>applications\bsp\chrg_wdt.c</FilePath>
</File>
<File>
<FileName>chrg_switch.c</FileName>
<FileType>1</FileType>
<FilePath>applications\bsp\chrg_switch.c</FilePath>
</File>
<File>
<FileName>chrg_vcom.c</FileName>
<FileType>1</FileType>
@@ -418,6 +402,26 @@
<FileType>1</FileType>
<FilePath>applications\bsp\chrg_gpio.c</FilePath>
</File>
<File>
<FileName>chrg_tty.c</FileName>
<FileType>1</FileType>
<FilePath>applications\bsp\chrg_tty.c</FilePath>
</File>
<File>
<FileName>chrg_switch.c</FileName>
<FileType>1</FileType>
<FilePath>applications\bsp\chrg_switch.c</FilePath>
</File>
<File>
<FileName>chrg_led.c</FileName>
<FileType>1</FileType>
<FilePath>applications\bsp\chrg_led.c</FilePath>
</File>
<File>
<FileName>chrg_wdt.c</FileName>
<FileType>1</FileType>
<FilePath>applications\bsp\chrg_wdt.c</FilePath>
</File>
<File>
<FileName>chrg_clk.c</FileName>
<FileType>1</FileType>
@@ -429,45 +433,20 @@
<FilePath>applications\bsp\chrg_tmr.c</FilePath>
</File>
<File>
<FileName>chrg_tty.c</FileName>
<FileName>chrg_fal.c</FileName>
<FileType>1</FileType>
<FilePath>applications\bsp\chrg_tty.c</FilePath>
<FilePath>applications\bsp\chrg_fal.c</FilePath>
</File>
<File>
<FileName>chrg_rel.c</FileName>
<FileType>1</FileType>
<FilePath>applications\bsp\chrg_rel.c</FilePath>
</File>
<File>
<FileName>chrg_fal.c</FileName>
<FileType>1</FileType>
<FilePath>applications\bsp\chrg_fal.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>Applications/thread</GroupName>
<Files>
<File>
<FileName>chrg_south.c</FileName>
<FileType>1</FileType>
<FilePath>applications\thread\chrg_south.c</FilePath>
</File>
<File>
<FileName>chrg_roll_nor.c</FileName>
<FileType>1</FileType>
<FilePath>applications\thread\chrg_roll_nor.c</FilePath>
</File>
<File>
<FileName>chrg_comm.c</FileName>
<FileType>1</FileType>
<FilePath>applications\thread\chrg_comm.c</FilePath>
</File>
<File>
<FileName>chrg_thread.c</FileName>
<FileType>1</FileType>
<FilePath>applications\thread\chrg_thread.c</FilePath>
</File>
<File>
<FileName>chrg_roll_sou.c</FileName>
<FileType>1</FileType>
@@ -478,31 +457,56 @@
<FileType>1</FileType>
<FilePath>applications\thread\chrg_lcd.c</FilePath>
</File>
<File>
<FileName>chrg_comm.c</FileName>
<FileType>1</FileType>
<FilePath>applications\thread\chrg_comm.c</FilePath>
</File>
<File>
<FileName>chrg_roll_nor.c</FileName>
<FileType>1</FileType>
<FilePath>applications\thread\chrg_roll_nor.c</FilePath>
</File>
<File>
<FileName>chrg_north.c</FileName>
<FileType>1</FileType>
<FilePath>applications\thread\chrg_north.c</FilePath>
</File>
<File>
<FileName>chrg_south.c</FileName>
<FileType>1</FileType>
<FilePath>applications\thread\chrg_south.c</FilePath>
</File>
<File>
<FileName>chrg_thread.c</FileName>
<FileType>1</FileType>
<FilePath>applications\thread\chrg_thread.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>Applications/utils</GroupName>
<Files>
<File>
<FileName>chrg_sink.c</FileName>
<FileType>1</FileType>
<FilePath>applications\utils\chrg_sink.c</FilePath>
</File>
<File>
<FileName>chrg_pkg.c</FileName>
<FileType>1</FileType>
<FilePath>applications\utils\chrg_pkg.c</FilePath>
</File>
<File>
<FileName>chrg_utils.c</FileName>
<FileType>1</FileType>
<FilePath>applications\utils\chrg_utils.c</FilePath>
</File>
<File>
<FileName>chrg_north_pkg.c</FileName>
<FileType>1</FileType>
<FilePath>applications\utils\chrg_north_pkg.c</FilePath>
</File>
<File>
<FileName>chrg_eload.c</FileName>
<FileType>1</FileType>
<FilePath>applications\utils\chrg_eload.c</FilePath>
</File>
<File>
<FileName>chrg_sink.c</FileName>
<FileType>1</FileType>
<FilePath>applications\utils\chrg_sink.c</FilePath>
</File>
<File>
<FileName>chrg_source.c</FileName>
<FileType>1</FileType>
@@ -608,7 +612,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -664,7 +668,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -720,7 +724,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -776,7 +780,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -832,7 +836,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -888,7 +892,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -944,7 +948,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1000,7 +1004,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1056,7 +1060,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1112,7 +1116,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1168,7 +1172,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1224,7 +1228,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1280,7 +1284,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1336,7 +1340,7 @@
<MiscControls> </MiscControls>
<Define>__RT_IPC_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1398,30 +1402,40 @@
<GroupName>Fal</GroupName>
<Files>
<File>
<FileName>fal.c</FileName>
<FileName>fal_flash.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\rt-thread\components\fal\src\fal.c</FilePath>
<FilePath>..\..\rt-thread\components\fal\src\fal_flash.c</FilePath>
</File>
<File>
<FileName>fal_rtt.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\rt-thread\components\fal\src\fal_rtt.c</FilePath>
</File>
<File>
<FileName>fal_flash.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\rt-thread\components\fal\src\fal_flash.c</FilePath>
</File>
<File>
<FileName>fal_partition.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\rt-thread\components\fal\src\fal_partition.c</FilePath>
</File>
<File>
<FileName>fal.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\rt-thread\components\fal\src\fal.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>Finsh</GroupName>
<Files>
<File>
<FileName>msh_parse.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\rt-thread\components\finsh\msh_parse.c</FilePath>
</File>
<File>
<FileName>shell.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\rt-thread\components\finsh\shell.c</FilePath>
</File>
<File>
<FileName>cmd.c</FileName>
<FileType>1</FileType>
@@ -1432,16 +1446,6 @@
<FileType>1</FileType>
<FilePath>..\..\rt-thread\components\finsh\msh.c</FilePath>
</File>
<File>
<FileName>shell.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\rt-thread\components\finsh\shell.c</FilePath>
</File>
<File>
<FileName>msh_parse.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\rt-thread\components\finsh\msh_parse.c</FilePath>
</File>
</Files>
</Group>
<Group>
@@ -1497,7 +1501,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1553,7 +1557,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1609,7 +1613,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1665,7 +1669,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1721,7 +1725,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1777,7 +1781,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1833,7 +1837,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1889,7 +1893,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -1945,7 +1949,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -2001,7 +2005,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -2057,7 +2061,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -2113,7 +2117,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -2169,7 +2173,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -2225,7 +2229,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -2281,7 +2285,7 @@
<MiscControls> </MiscControls>
<Define>__RT_KERNEL_SOURCE__</Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
<IncludePath> </IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
@@ -2292,15 +2296,20 @@
<Group>
<GroupName>klibc</GroupName>
<Files>
<File>
<FileName>kstring.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\rt-thread\src\klibc\kstring.c</FilePath>
</File>
<File>
<FileName>rt_vsnprintf_tiny.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\rt-thread\src\klibc\rt_vsnprintf_tiny.c</FilePath>
</File>
<File>
<FileName>kstring.c</FileName>
<FileName>kstdio.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\rt-thread\src\klibc\kstring.c</FilePath>
<FilePath>..\..\rt-thread\src\klibc\kstdio.c</FilePath>
</File>
<File>
<FileName>rt_vsscanf.c</FileName>
@@ -2312,11 +2321,6 @@
<FileType>1</FileType>
<FilePath>..\..\rt-thread\src\klibc\kerrno.c</FilePath>
</File>
<File>
<FileName>kstdio.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\rt-thread\src\klibc\kstdio.c</FilePath>
</File>
</Files>
</Group>
<Group>
@@ -2387,151 +2391,151 @@
<Group>
<GroupName>STM32F4-HAL</GroupName>
<Files>
<File>
<FileName>stm32f4xx_hal_cryp.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_cortex.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cortex.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_gpio.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_gpio.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_dma_ex.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma_ex.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_usart.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_usart.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_flash_ramfunc.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ramfunc.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_iwdg.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_iwdg.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_cec.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cec.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_ll_usb.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_ll_usb.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_flash_ex.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ex.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_hcd.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_hcd.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_uart.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_uart.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_flash.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_pwr_ex.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_ex.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_wwdg.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_wwdg.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_crc.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_crc.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_pwr.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_pccard.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pccard.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_tim.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_pcd_ex.c</FileName>
<FileName>stm32f4xx_hal_iwdg.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd_ex.c</FilePath>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_iwdg.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_dma.c</FileName>
<FileName>stm32f4xx_hal_cryp_ex.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma.c</FilePath>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp_ex.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_pcd.c</FileName>
<FileName>stm32f4xx_hal_flash_ramfunc.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd.c</FilePath>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ramfunc.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_rng.c</FileName>
<FileName>stm32f4xx_hal_usart.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c</FilePath>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_usart.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_rcc_ex.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc_ex.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_lptim.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_lptim.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_rcc.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_cortex.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cortex.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_pwr.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_hcd.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_hcd.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_cryp.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_pwr_ex.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_ex.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_ll_usb.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_ll_usb.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_cec.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cec.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_lptim.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_lptim.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_wwdg.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_wwdg.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_dma_ex.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma_ex.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_flash.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_rng.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_pcd.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_crc.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_crc.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_dma.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_pccard.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pccard.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_pcd_ex.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd_ex.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_uart.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_uart.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_gpio.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_gpio.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_tim_ex.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim_ex.c</FilePath>
</File>
<File>
<FileName>stm32f4xx_hal_cryp_ex.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp_ex.c</FilePath>
</File>
</Files>
</Group>
</Groups>