fix south ch

This commit is contained in:
wmano
2025-09-24 21:47:15 +08:00
parent b7a2df5583
commit 21158288ac
6 changed files with 20 additions and 81 deletions
-9
View File
@@ -44,15 +44,6 @@ struct chrg_intr_t chrgintr[TOTAL_INTR] = {
.pulse = PIN_IRQ_MODE_FALLING,
.value = PIN_LOW,
.delay = 0,
},
[IDX_INTR_KEY] = {
.name = NAME_INTR_KEY,
.index = IDX_INTR_KEY,
.pin = PIN_INTR_KEY,
.mode = PIN_MODE_INPUT_PULLUP,
.pulse = PIN_IRQ_MODE_RISING,
.value = PIN_LOW,
.delay = 0,
}
};
+2 -5
View File
@@ -10,20 +10,17 @@
#define NAME_INTR_I2C2 "i2c2irq"
#define NAME_INTR_I2C3 "i2c3irq"
#define NAME_INTR_I2C4 "i2c4irq"
#define NAME_INTR_KEY "keyirq"
#define PIN_INTR_I2C1 GET_PIN(C, 8) //GET_PIN(C, 1)
#define PIN_INTR_I2C2 GET_PIN(C, 9) //GET_PIN(A, 1)
#define PIN_INTR_I2C1 GET_PIN(C, 1)
#define PIN_INTR_I2C2 GET_PIN(A, 1)
#define PIN_INTR_I2C3 GET_PIN(A, 7)
#define PIN_INTR_I2C4 GET_PIN(B, 13)
#define PIN_INTR_KEY GET_PIN(A, 0) //GET_PIN(B, 6)
typedef enum {
IDX_INTR_I2C1 = 0, // 0
IDX_INTR_I2C2, // 1
IDX_INTR_I2C3, // 2
IDX_INTR_I2C4, // 3
IDX_INTR_KEY, // 4
TOTAL_INTR
} eIDX_INTR;
+3
View File
@@ -127,6 +127,9 @@ static int chrg_switch_init (void)
chrg_switch_north_pins_init();
chrg_switch_south_pins_init();
chrg_switch_north(IDX_CH_0);
chrg_switch_south(IDX_SOUTH_0);
return 0;
}
+1 -1
View File
@@ -29,7 +29,7 @@ typedef enum {
#define TTY_SW_DLY_US 0 // 发送引脚控制切换延时
#endif
#define SIZE_BUF_TTY 128
#define SIZE_BUF_TTY 256
#define TTY_TX_COMP_TMO_MAX (3 * RT_TICK_PER_SECOND) // 最大DMA传输完成超时
#define TTY_BYTE_TMO_MIN 2 // 最小字节超时
+8 -32
View File
@@ -1,4 +1,4 @@
#include <string.h>
#include <rtthread.h>
#include "chrg_north.h"
@@ -38,54 +38,30 @@ static void chrg_north_thread_entry (void *data)
return ;
}
//rt_uint8_t crc8 = 0;
//rt_size_t len_mq = 0, len_get = 0, len_msg = 0;
struct chrg_tty_t *pTTY = pNOR->tty;
//struct mq_msg_t msg;
int len = 0;
struct chrg_tty_t *pTTY = pNOR->tty;
chrg_tty_set_recv_tmo(pTTY, 200);
chrg_tty_set_recv_tmo(pTTY, 100);
if (chrg_tty_connect(pTTY) != RT_EOK) {
chrg_tty_destory(pTTY);
return;
}
while (1) {
memset(pNOR->rx_buf, 0, sizeof(pNOR->rx_buf));
len = chrg_tty_recv(pTTY, pNOR->rx_buf, sizeof(pNOR->rx_buf));
if (len > 0) {
chrg_tty_send(pTTY, pNOR->rx_buf, len);
}
/*
rt_memset(&msg, 0, sizeof(struct mq_msg_t));
len_mq = rt_mq_recv(pTTY->mq, &msg, sizeof(struct mq_msg_t), RT_WAITING_FOREVER);
if (len_mq <= 0) {
if (len <= 0) {
rt_thread_mdelay(1);
continue;
}
len_get = rt_device_read(msg.dev, 0, &pNOR->rx_buf[0], 1);
if (1 != len_get) {
continue;
}
pNOR->rx_len = 1;
rt_kprintf("%s\r\n", (char *)pNOR->rx_buf);
chrg_tty_send(pTTY, pNOR->rx_buf, len);
len_msg = rt_device_read(msg.dev, 0, &pNOR->rx_buf[1], len_get-1);
if (len_msg <= 0) {
continue;
}
pNOR->rx_len += len_msg;
if (len_msg == len_get-1) {
crc8 = calc_crc8(pNOR->rx_buf, len_msg);
if (crc8 == pNOR->rx_buf[len_msg]) {
pNOR->rx_len = 0;
}
}
*/
}
}
+6 -34
View File
@@ -37,13 +37,10 @@ static void chrg_south_thread_entry (void *data)
return ;
}
//rt_uint8_t crc8 = 0;
//rt_size_t len_mq = 0, len_get = 0, len_msg = 0;
struct chrg_tty_t *pTTY = pSOU->tty;
//struct mq_msg_t msg;
int len = 0;
struct chrg_tty_t *pTTY = pSOU->tty;
chrg_tty_set_recv_tmo(pTTY, 200);
chrg_tty_set_recv_tmo(pTTY, 100);
if (chrg_tty_connect(pTTY) != RT_EOK) {
chrg_tty_destory(pTTY);
return;
@@ -51,40 +48,15 @@ static void chrg_south_thread_entry (void *data)
while (1) {
len = chrg_tty_recv(pTTY, pSOU->rx_buf, sizeof(pSOU->rx_buf));
if (len > 0) {
chrg_tty_send(pTTY, pSOU->rx_buf, len);
}
/*
rt_memset(&msg, 0, sizeof(struct mq_msg_t));
len_mq = rt_mq_recv(pTTY->mq, &msg, sizeof(struct mq_msg_t), RT_WAITING_FOREVER);
if (len_mq <= 0) {
if (len <= 0) {
rt_thread_mdelay(1);
continue;
}
len_get = rt_device_read(msg.dev, 0, &pSOU->rx_buf[0], 1);
if (1 != len_get) {
continue;
}
rt_kprintf("%s\r\n", (char *)pSOU->rx_buf);
chrg_tty_send(pTTY, pSOU->rx_buf, len);
pSOU->rx_len = 1;
len_msg = rt_device_read(msg.dev, 0, &pSOU->rx_buf[1], len_get-1);
if (len_msg <= 0) {
continue;
}
pSOU->rx_len += len_msg;
if (len_msg == len_get-1) {
crc8 = calc_crc8(pSOU->rx_buf, len_msg);
if (crc8 == pSOU->rx_buf[len_msg]) {
pSOU->rx_len = 0;
}
}
*/
}
}