roll south mb
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user