forked from xuos/xiuos
support e220 for xidatong on nuttx
This commit is contained in:
parent
88ef0ad96c
commit
5873feb442
|
@ -37,6 +37,30 @@ endif
|
||||||
|
|
||||||
if ADD_NUTTX_FETURES
|
if ADD_NUTTX_FETURES
|
||||||
|
|
||||||
|
config ADAPTER_E220_M0_PATH
|
||||||
|
string "E220 M0 pin device"
|
||||||
|
default "/dev/gpout0"
|
||||||
|
|
||||||
|
config ADAPTER_E220_M1_PATH
|
||||||
|
string "E220 M1 pin device"
|
||||||
|
default "/dev/gpout1"
|
||||||
|
|
||||||
|
config ADAPTER_E220_DRIVER_EXTUART
|
||||||
|
bool "Using extra uart to support lora"
|
||||||
|
default y
|
||||||
|
|
||||||
|
config ADAPTER_E220_DRIVER
|
||||||
|
string "E220 device uart driver path"
|
||||||
|
default "/dev/ttyS3"
|
||||||
|
depends on !ADAPTER_E220_DRIVER_EXTUART
|
||||||
|
|
||||||
|
if ADAPTER_E220_DRIVER_EXTUART
|
||||||
|
config ADAPTER_E220_DRIVER
|
||||||
|
string "E220 device extra uart driver path"
|
||||||
|
default "/dev/extuart_dev3"
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ADD_RTTHREAD_FETURES
|
if ADD_RTTHREAD_FETURES
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
SRC_FILES := e220.c
|
include $(KERNEL_ROOT)/.config
|
||||||
|
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||||
|
include $(APPDIR)/Make.defs
|
||||||
|
CSRCS += e220.c
|
||||||
|
include $(APPDIR)/Application.mk
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||||
|
SRC_FILES := e220.c
|
||||||
include $(KERNEL_ROOT)/compiler.mk
|
include $(KERNEL_ROOT)/compiler.mk
|
||||||
|
|
||||||
|
endif
|
|
@ -21,7 +21,7 @@
|
||||||
#include <adapter.h>
|
#include <adapter.h>
|
||||||
|
|
||||||
#define E220_GATEWAY_ADDRESS 0xFFFF
|
#define E220_GATEWAY_ADDRESS 0xFFFF
|
||||||
#define E220_CHANNEL 0x04
|
#define E220_CHANNEL 0x05
|
||||||
|
|
||||||
#ifdef AS_LORA_GATEWAY_ROLE
|
#ifdef AS_LORA_GATEWAY_ROLE
|
||||||
#define E220_ADDRESS E220_GATEWAY_ADDRESS
|
#define E220_ADDRESS E220_GATEWAY_ADDRESS
|
||||||
|
@ -46,6 +46,60 @@ enum E220LoraMode
|
||||||
* @param mode Lora working mode
|
* @param mode Lora working mode
|
||||||
* @return NULL
|
* @return NULL
|
||||||
*/
|
*/
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
static void E220LoraModeConfig(enum E220LoraMode mode)
|
||||||
|
{
|
||||||
|
int m0_fd, m1_fd;
|
||||||
|
|
||||||
|
//delay 1s , wait AUX ready
|
||||||
|
PrivTaskDelay(1000);
|
||||||
|
m0_fd = PrivOpen(ADAPTER_E220_M0_PATH, O_RDWR);
|
||||||
|
if (m0_fd < 0) {
|
||||||
|
printf("open %s error\n", ADAPTER_E220_M0_PATH);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m1_fd = PrivOpen(ADAPTER_E220_M1_PATH, O_RDWR);
|
||||||
|
if (m1_fd < 0) {
|
||||||
|
printf("open %s error\n", ADAPTER_E220_M1_PATH);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Both M0 and M1 GPIO are outputs mode, set M0 and M1 high or low
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case DATA_TRANSFER_MODE:
|
||||||
|
PrivIoctl(m1_fd, GPIOC_WRITE, (unsigned long)GPIO_LOW);
|
||||||
|
PrivIoctl(m0_fd, GPIOC_WRITE, (unsigned long)GPIO_LOW);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WOR_SEND_MODE:
|
||||||
|
PrivIoctl(m1_fd, GPIOC_WRITE, (unsigned long)GPIO_LOW);
|
||||||
|
PrivIoctl(m0_fd, GPIOC_WRITE, (unsigned long)GPIO_HIGH);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WOR_RECEIVE_MODE:
|
||||||
|
PrivIoctl(m1_fd, GPIOC_WRITE, (unsigned long)GPIO_HIGH);
|
||||||
|
|
||||||
|
PrivIoctl(m0_fd, GPIOC_WRITE,(unsigned long)GPIO_LOW);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONFIGURE_MODE_MODE:
|
||||||
|
PrivIoctl(m1_fd, GPIOC_WRITE, (unsigned long)GPIO_HIGH);
|
||||||
|
PrivIoctl(m0_fd, GPIOC_WRITE, (unsigned long)GPIO_HIGH);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrivClose(m0_fd);
|
||||||
|
PrivClose(m1_fd);
|
||||||
|
|
||||||
|
//delay 20ms , wait mode switch done
|
||||||
|
PrivTaskDelay(20);
|
||||||
|
}
|
||||||
|
#else
|
||||||
static void E220LoraModeConfig(enum E220LoraMode mode)
|
static void E220LoraModeConfig(enum E220LoraMode mode)
|
||||||
{
|
{
|
||||||
//delay 1s , wait AUX ready
|
//delay 1s , wait AUX ready
|
||||||
|
@ -126,6 +180,7 @@ static void E220LoraModeConfig(enum E220LoraMode mode)
|
||||||
//delay 20ms , wait mode switch done
|
//delay 20ms , wait mode switch done
|
||||||
PrivTaskDelay(20);
|
PrivTaskDelay(20);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: Switch baud rate to register bit
|
* @description: Switch baud rate to register bit
|
||||||
|
@ -263,6 +318,25 @@ static int E220GetRegisterParam(uint8 *buf)
|
||||||
* @param adapter - Lora device pointer
|
* @param adapter - Lora device pointer
|
||||||
* @return success: 0, failure: -1
|
* @return success: 0, failure: -1
|
||||||
*/
|
*/
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
static int E220Open(struct Adapter *adapter)
|
||||||
|
{
|
||||||
|
/*step1: open e220 uart port*/
|
||||||
|
adapter->fd = PrivOpen(ADAPTER_E220_DRIVER, O_RDWR);
|
||||||
|
if (adapter->fd < 0) {
|
||||||
|
printf("E220Open get uart %s fd error\n", ADAPTER_E220_DRIVER);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrivIoctl(adapter->fd, OPE_INT, (unsigned long)BAUD_RATE_9600);
|
||||||
|
E220SetRegisterParam(adapter, E220_ADDRESS, E220_CHANNEL, E220_UART_BAUD_RATE);
|
||||||
|
PrivIoctl(adapter->fd, OPE_INT, (unsigned long)E220_UART_BAUD_RATE);
|
||||||
|
|
||||||
|
ADAPTER_DEBUG("E220Open done\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
static int E220Open(struct Adapter *adapter)
|
static int E220Open(struct Adapter *adapter)
|
||||||
{
|
{
|
||||||
/*step1: open e220 uart port*/
|
/*step1: open e220 uart port*/
|
||||||
|
@ -316,6 +390,7 @@ static int E220Open(struct Adapter *adapter)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: Close E220 uart function
|
* @description: Close E220 uart function
|
||||||
|
@ -520,6 +595,7 @@ static void LoraRead(void *parameter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ADD_XIZI_FETURES
|
||||||
static void LoraTest(void)
|
static void LoraTest(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -554,3 +630,40 @@ static void LoraSend(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
||||||
LoraSend, LoraSend, lora send message);
|
LoraSend, LoraSend, lora send message);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
void E220LoraReceive(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
pthread_t thread;
|
||||||
|
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
|
||||||
|
attr.priority = 80;
|
||||||
|
attr.stacksize = 2048;
|
||||||
|
|
||||||
|
LoraOpen();
|
||||||
|
|
||||||
|
ret = PrivTaskCreate(&thread, &attr, (void*)LoraRead, NULL);
|
||||||
|
if (ret < 0) {
|
||||||
|
printf("task lora read create failed, status=%d\n", ret);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void E220LoraSend(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct Adapter *adapter = AdapterDeviceFindByName(ADAPTER_LORA_NAME);
|
||||||
|
if (NULL == adapter) {
|
||||||
|
printf("LoraRead find lora adapter error\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc == 2) {
|
||||||
|
char Msg[256] = {0};
|
||||||
|
strncpy(Msg, argv[1], 256);
|
||||||
|
|
||||||
|
E220Open(adapter);
|
||||||
|
E220Send(adapter, Msg, strlen(Msg));
|
||||||
|
E220Close(adapter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -33,11 +33,11 @@ static uint8_t ReadCH438Data(uint8_t addr);
|
||||||
static void WriteCH438Data(uint8_t addr, uint8_t dat);
|
static void WriteCH438Data(uint8_t addr, uint8_t dat);
|
||||||
static void WriteCH438Block(uint8_t mAddr, uint8_t mLen, char *mBuf);
|
static void WriteCH438Block(uint8_t mAddr, uint8_t mLen, char *mBuf);
|
||||||
static void Ch438UartSend(uint8_t ext_uart_no, char *Data, uint16_t Num);
|
static void Ch438UartSend(uint8_t ext_uart_no, char *Data, uint16_t Num);
|
||||||
uint8_t CH438UARTRcv(uint8_t ext_uart_no, char* buf);
|
uint8_t CH438UARTRcv(uint8_t ext_uart_no, char *buf, size_t size);
|
||||||
static void ImxrtCH438Init(void);
|
static void ImxrtCH438Init(void);
|
||||||
static void CH438PortInit(uint8_t ext_uart_no, uint32_t baud_rate);
|
static void CH438PortInit(uint8_t ext_uart_no, uint32_t baud_rate);
|
||||||
static int ImxrtCh438WriteData(uint8_t ext_uart_no, char *write_buffer, size_t size);
|
static int ImxrtCh438WriteData(uint8_t ext_uart_no, char *write_buffer, size_t size);
|
||||||
static size_t ImxrtCh438ReadData(uint8_t ext_uart_no);
|
static size_t ImxrtCh438ReadData(uint8_t ext_uart_no, size_t size);
|
||||||
static void Ch438InitDefault(void);
|
static void Ch438InitDefault(void);
|
||||||
|
|
||||||
static int ch438_open(FAR struct file *filep);
|
static int ch438_open(FAR struct file *filep);
|
||||||
|
@ -60,6 +60,7 @@ struct ch438_dev_s
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/*mutex of corresponding port*/
|
||||||
static pthread_mutex_t mutex[CH438PORTNUM] =
|
static pthread_mutex_t mutex[CH438PORTNUM] =
|
||||||
{
|
{
|
||||||
PTHREAD_MUTEX_INITIALIZER,
|
PTHREAD_MUTEX_INITIALIZER,
|
||||||
|
@ -71,6 +72,8 @@ static pthread_mutex_t mutex[CH438PORTNUM] =
|
||||||
PTHREAD_MUTEX_INITIALIZER,
|
PTHREAD_MUTEX_INITIALIZER,
|
||||||
PTHREAD_MUTEX_INITIALIZER
|
PTHREAD_MUTEX_INITIALIZER
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Condition variable of corresponding port */
|
||||||
static pthread_cond_t cond[CH438PORTNUM] =
|
static pthread_cond_t cond[CH438PORTNUM] =
|
||||||
{
|
{
|
||||||
PTHREAD_COND_INITIALIZER,
|
PTHREAD_COND_INITIALIZER,
|
||||||
|
@ -83,16 +86,26 @@ static pthread_cond_t cond[CH438PORTNUM] =
|
||||||
PTHREAD_COND_INITIALIZER
|
PTHREAD_COND_INITIALIZER
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* there is data available on the corresponding port */
|
||||||
static volatile bool done[CH438PORTNUM] = {false,false,false,false,false,false,false,false};
|
static volatile bool done[CH438PORTNUM] = {false,false,false,false,false,false,false,false};
|
||||||
|
|
||||||
|
/* Eight port data buffer */
|
||||||
static char buff[CH438PORTNUM][CH438_BUFFSIZE];
|
static char buff[CH438PORTNUM][CH438_BUFFSIZE];
|
||||||
static uint8_t buff_ptr[CH438PORTNUM];
|
|
||||||
static uint8_t Interruptnum[CH438PORTNUM] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,}; /* SSR寄存器中断号对应值 */
|
|
||||||
static uint8_t offsetadd[CH438PORTNUM] = {0x00,0x10,0x20,0x30,0x08,0x18,0x28,0x38,}; /* 串口号的偏移地址 */
|
|
||||||
|
|
||||||
|
/* the value of interrupt number of SSR register */
|
||||||
|
static uint8_t Interruptnum[CH438PORTNUM] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,};
|
||||||
|
|
||||||
|
/* Offset address of serial port number */
|
||||||
|
static uint8_t offsetadd[CH438PORTNUM] = {0x00,0x10,0x20,0x30,0x08,0x18,0x28,0x38,};
|
||||||
|
|
||||||
|
/* Interrupt register status global variable */
|
||||||
static uint8_t gInterruptStatus;
|
static uint8_t gInterruptStatus;
|
||||||
|
|
||||||
|
|
||||||
|
/* port open status global variable */
|
||||||
static volatile bool g_ch438open[CH438PORTNUM] = {false,false,false,false,false,false,false,false};
|
static volatile bool g_ch438open[CH438PORTNUM] = {false,false,false,false,false,false,false,false};
|
||||||
|
|
||||||
|
/* Ch438 POSIX interface */
|
||||||
static const struct file_operations g_ch438fops =
|
static const struct file_operations g_ch438fops =
|
||||||
{
|
{
|
||||||
ch438_open,
|
ch438_open,
|
||||||
|
@ -307,7 +320,7 @@ static void Ch438UartSend(uint8_t ext_uart_no, char *Data, uint16_t Num)
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
while((ReadCH438Data(REG_LSR_ADDR) & BIT_LSR_TEMT) == 0); /* 等待数据发送完毕,THR,TSR全空 */
|
while((ReadCH438Data(REG_LSR_ADDR) & BIT_LSR_TEMT) == 0); /* wait for sending data done, THR and TSR is NULL */
|
||||||
if(Num <= 128)
|
if(Num <= 128)
|
||||||
{
|
{
|
||||||
WriteCH438Block(REG_THR_ADDR, Num, Data);
|
WriteCH438Block(REG_THR_ADDR, Num, Data);
|
||||||
|
@ -329,28 +342,38 @@ static void Ch438UartSend(uint8_t ext_uart_no, char *Data, uint16_t Num)
|
||||||
* Disable FIFO mode for ch438 serial port to receive multi byte data
|
* Disable FIFO mode for ch438 serial port to receive multi byte data
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
uint8_t CH438UARTRcv(uint8_t ext_uart_no, char* buf)
|
uint8_t CH438UARTRcv(uint8_t ext_uart_no, char *buf, size_t size)
|
||||||
{
|
{
|
||||||
uint8_t RcvNum = 0;
|
uint8_t rcv_num = 0;
|
||||||
uint8_t dat = 0;
|
uint8_t dat = 0;
|
||||||
uint8_t REG_LSR_ADDR,REG_RBR_ADDR;
|
uint8_t REG_LSR_ADDR,REG_RBR_ADDR;
|
||||||
|
char *read_buffer;
|
||||||
|
size_t buffer_index = 0;
|
||||||
|
|
||||||
|
read_buffer = buf;
|
||||||
|
|
||||||
REG_LSR_ADDR = offsetadd[ext_uart_no] | REG_LSR0_ADDR;
|
REG_LSR_ADDR = offsetadd[ext_uart_no] | REG_LSR0_ADDR;
|
||||||
REG_RBR_ADDR = offsetadd[ext_uart_no] | REG_RBR0_ADDR;
|
REG_RBR_ADDR = offsetadd[ext_uart_no] | REG_RBR0_ADDR;
|
||||||
|
|
||||||
/* Wait for the data to be ready */
|
/* Wait for the data to be ready */
|
||||||
while ((ReadCH438Data(REG_LSR_ADDR) & BIT_LSR_DATARDY) == 0);
|
while ((ReadCH438Data(REG_LSR_ADDR) & BIT_LSR_DATARDY) == 0);
|
||||||
while((ReadCH438Data(REG_LSR_ADDR) & BIT_LSR_DATARDY) == 0x01)
|
|
||||||
|
while (((ReadCH438Data(REG_LSR_ADDR) & BIT_LSR_DATARDY) == 0x01) && (size != 0))
|
||||||
{
|
{
|
||||||
dat = ReadCH438Data(REG_RBR_ADDR);
|
dat = ReadCH438Data(REG_RBR_ADDR);
|
||||||
buff[ext_uart_no][buff_ptr[ext_uart_no]] = dat;
|
*read_buffer = dat;
|
||||||
|
read_buffer++;
|
||||||
buff_ptr[ext_uart_no] = buff_ptr[ext_uart_no] + 1;
|
buffer_index++;
|
||||||
if(buff_ptr[ext_uart_no] == 256)
|
if (255 == buffer_index) {
|
||||||
buff_ptr[ext_uart_no] = 0;
|
buffer_index = 0;
|
||||||
RcvNum = RcvNum + 1;
|
read_buffer = buf;
|
||||||
}
|
}
|
||||||
return RcvNum;
|
|
||||||
|
++rcv_num;
|
||||||
|
--size;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rcv_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -477,7 +500,7 @@ static int ImxrtCh438WriteData(uint8_t ext_uart_no, char *write_buffer, size_t s
|
||||||
Ch438UartSend(ext_uart_no, write_buffer, write_len);
|
Ch438UartSend(ext_uart_no, write_buffer, write_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -487,7 +510,7 @@ static int ImxrtCh438WriteData(uint8_t ext_uart_no, char *write_buffer, size_t s
|
||||||
* Read data from ch438 port
|
* Read data from ch438 port
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static size_t ImxrtCh438ReadData(uint8_t ext_uart_no)
|
static size_t ImxrtCh438ReadData(uint8_t ext_uart_no, size_t size)
|
||||||
{
|
{
|
||||||
size_t RevLen = 0;
|
size_t RevLen = 0;
|
||||||
uint8_t InterruptStatus;
|
uint8_t InterruptStatus;
|
||||||
|
@ -503,33 +526,30 @@ static size_t ImxrtCh438ReadData(uint8_t ext_uart_no)
|
||||||
REG_IIR_ADDR = offsetadd[ext_uart_no] | REG_IIR0_ADDR;
|
REG_IIR_ADDR = offsetadd[ext_uart_no] | REG_IIR0_ADDR;
|
||||||
REG_LSR_ADDR = offsetadd[ext_uart_no] | REG_LSR0_ADDR;
|
REG_LSR_ADDR = offsetadd[ext_uart_no] | REG_LSR0_ADDR;
|
||||||
REG_MSR_ADDR = offsetadd[ext_uart_no] | REG_MSR0_ADDR;
|
REG_MSR_ADDR = offsetadd[ext_uart_no] | REG_MSR0_ADDR;
|
||||||
InterruptStatus = ReadCH438Data(REG_IIR_ADDR) & 0x0f; /* 读串口的中断状态 */
|
/* Read the interrupt status of the serial port */
|
||||||
|
InterruptStatus = ReadCH438Data(REG_IIR_ADDR) & 0x0f;
|
||||||
ch438info("InterruptStatus is %d\n", InterruptStatus);
|
ch438info("InterruptStatus is %d\n", InterruptStatus);
|
||||||
|
|
||||||
switch(InterruptStatus)
|
switch(InterruptStatus)
|
||||||
{
|
{
|
||||||
case INT_NOINT: /* 没有中断 */
|
case INT_NOINT: /* no interrupt */
|
||||||
break;
|
break;
|
||||||
case INT_THR_EMPTY: /* THR空中断 */
|
case INT_THR_EMPTY: /* the transmit hold register is not interrupted */
|
||||||
break;
|
break;
|
||||||
case INT_RCV_OVERTIME: /* 接收超时中断,收到数据后一般是触发这个 。在收到一帧数据后4个数据时间没有后续的数据时触发*/
|
case INT_RCV_OVERTIME: /* receive data timeout interrupt */
|
||||||
case INT_RCV_SUCCESS: /* 接收数据可用中断。这是一个数据帧超过缓存了才发生,否则一般是前面的超时中断。处理过程同上面的超时中断 */
|
case INT_RCV_SUCCESS: /* receive data available interrupt */
|
||||||
RevLen = CH438UARTRcv(ext_uart_no, buff[ext_uart_no]);
|
RevLen = CH438UARTRcv(ext_uart_no, buff[ext_uart_no], size);
|
||||||
buff_ptr[ext_uart_no] = 0;
|
|
||||||
break;
|
break;
|
||||||
|
case INT_RCV_LINES: /* receive line status interrupt */
|
||||||
case INT_RCV_LINES: /* 接收线路状态中断 */
|
|
||||||
ReadCH438Data(REG_LSR_ADDR);
|
ReadCH438Data(REG_LSR_ADDR);
|
||||||
break;
|
break;
|
||||||
case INT_MODEM_CHANGE: /* MODEM输入变化中断 */
|
case INT_MODEM_CHANGE: /* modem input change interrupt */
|
||||||
ReadCH438Data(REG_MSR_ADDR);
|
ReadCH438Data(REG_MSR_ADDR);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
done[ext_uart_no] = false;
|
done[ext_uart_no] = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&mutex[ext_uart_no]);
|
pthread_mutex_unlock(&mutex[ext_uart_no]);
|
||||||
|
|
||||||
|
@ -663,7 +683,7 @@ static ssize_t ch438_read(FAR struct file *filep, FAR char *buffer, size_t bufle
|
||||||
|
|
||||||
DEBUGASSERT(port >= 0 && port < CH438PORTNUM);
|
DEBUGASSERT(port >= 0 && port < CH438PORTNUM);
|
||||||
|
|
||||||
length = ImxrtCh438ReadData(port);
|
length = ImxrtCh438ReadData(port, buflen);
|
||||||
memcpy(buffer, buff[port], length);
|
memcpy(buffer, buff[port], length);
|
||||||
|
|
||||||
if(length > buflen)
|
if(length > buflen)
|
||||||
|
|
Loading…
Reference in New Issue