add sink source
This commit is contained in:
@@ -7,13 +7,26 @@
|
||||
#define DBG_LEVEL DBG_LOG
|
||||
#include <rtdbg.h>
|
||||
|
||||
struct chrg_north_t chrgnor = {
|
||||
struct chrg_north_t chrgnorth = {
|
||||
.name = THR_NAME_NORTH,
|
||||
.tid = RT_NULL,
|
||||
.tty = RT_NULL,
|
||||
.rx_len = 0,
|
||||
};
|
||||
|
||||
|
||||
int chrg_north_send (rt_uint8_t *data, rt_size_t length)
|
||||
{
|
||||
rt_ssize_t ret = -1;
|
||||
struct chrg_tty_t *pTTY = chrgnorth.tty;
|
||||
|
||||
if ((RT_NULL != pTTY)&&(RT_NULL != pTTY->dev)) {
|
||||
ret = rt_device_write(pTTY->dev, 0, data, length);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void chrg_north_thread_entry (void *data)
|
||||
{
|
||||
rt_err_t ret = RT_EOK;
|
||||
@@ -49,7 +62,7 @@ static void chrg_north_thread_entry (void *data)
|
||||
static int chrg_north_init (void)
|
||||
{
|
||||
rt_err_t ret;
|
||||
struct chrg_north_t *pNOR = &chrgnor;
|
||||
struct chrg_north_t *pNOR = &chrgnorth;
|
||||
|
||||
pNOR->tty = &chrgtty[IDX_TTY_NORTH];
|
||||
rt_memset(pNOR->rx_buf, 0, SIZE_BUF_UART);
|
||||
@@ -77,15 +90,7 @@ 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;
|
||||
return chrg_north_send("1234567890abcdef", 16);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
#define __CHRG_NORTH_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "chrg_tty.h"
|
||||
#include "chrg_switch.h"
|
||||
|
||||
|
||||
#define THR_NAME_NORTH "thr_nor"
|
||||
|
||||
@@ -14,9 +17,13 @@ struct chrg_north_t {
|
||||
struct chrg_tty_t *tty;
|
||||
rt_uint16_t rx_len;
|
||||
rt_uint8_t rx_buf[SIZE_BUF_UART];
|
||||
|
||||
struct chrg_switch_t sw[TOTAL_CHS];
|
||||
};
|
||||
|
||||
extern struct chrg_north_t chrgnor;
|
||||
extern struct chrg_north_t chrgnorth;
|
||||
|
||||
extern int chrg_north_send (rt_uint8_t *data, rt_size_t length);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define DBG_LEVEL DBG_LOG
|
||||
#include <rtdbg.h>
|
||||
|
||||
struct chrg_south_t chrgsou = {
|
||||
struct chrg_south_t chrgsouth = {
|
||||
.name = THR_NAME_SOUTH,
|
||||
.tid = RT_NULL,
|
||||
.tty = RT_NULL,
|
||||
@@ -49,7 +49,7 @@ static void chrg_south_thread_entry (void *data)
|
||||
static int chrg_south_init (void)
|
||||
{
|
||||
rt_err_t ret;
|
||||
struct chrg_south_t *pSOU = &chrgsou;
|
||||
struct chrg_south_t *pSOU = &chrgsouth;
|
||||
|
||||
pSOU->tty = &chrgtty[IDX_TTY_NORTH];
|
||||
rt_memset(pSOU->rx_buf, 0, SIZE_BUF_UART);
|
||||
@@ -77,7 +77,7 @@ 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_south_t *pSOU = &chrgsouth;
|
||||
struct chrg_tty_t *pTTY = pSOU->tty;
|
||||
|
||||
if (RT_NULL != pTTY->dev) {
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
#define __CHRG_SOUTH_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "chrg_tty.h"
|
||||
#include "chrg_switch.h"
|
||||
|
||||
#define THR_NAME_SOUTH "thr_sou"
|
||||
|
||||
@@ -14,9 +16,11 @@ struct chrg_south_t {
|
||||
struct chrg_tty_t *tty;
|
||||
rt_uint16_t rx_len;
|
||||
rt_uint8_t rx_buf[SIZE_BUF_UART];
|
||||
|
||||
struct chrg_switch_t sw[TOTAL_SOUTH_CHS];
|
||||
};
|
||||
|
||||
extern struct chrg_south_t chrgsou;
|
||||
extern struct chrg_south_t chrgsouth;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user