fix south ch
This commit is contained in:
@@ -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,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 // 最小字节超时
|
||||
|
||||
@@ -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) {
|
||||
if (len <= 0) {
|
||||
rt_thread_mdelay(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
rt_kprintf("%s\r\n", (char *)pNOR->rx_buf);
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
|
||||
len_get = rt_device_read(msg.dev, 0, &pNOR->rx_buf[0], 1);
|
||||
if (1 != len_get) {
|
||||
continue;
|
||||
}
|
||||
|
||||
pNOR->rx_len = 1;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
if (len <= 0) {
|
||||
rt_thread_mdelay(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
rt_kprintf("%s\r\n", (char *)pSOU->rx_buf);
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
|
||||
len_get = rt_device_read(msg.dev, 0, &pSOU->rx_buf[0], 1);
|
||||
if (1 != len_get) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user