490 lines
18 KiB
C
490 lines
18 KiB
C
#include "usr_bsp_uart.h"
|
|
#include <cpu.h>
|
|
#include <os.h>
|
|
#include <os_cpu.h>
|
|
#include <bsp_int.h>
|
|
#include <bsp_sys.h>
|
|
#include <lib_def.h>
|
|
#include "usr_bsp_sys.h"
|
|
|
|
#define UART0_RECV_CACHE_MAX 256
|
|
#define UART1_RECV_CACHE_MAX 256
|
|
#define UART2_RECV_CACHE_MAX 256
|
|
#define UART3_RECV_CACHE_MAX 256
|
|
#define UART4_RECV_CACHE_MAX 256
|
|
#define UART5_RECV_CACHE_MAX 256
|
|
#define UART6_RECV_CACHE_MAX 256
|
|
#define UART7_RECV_CACHE_MAX 256
|
|
|
|
/* 静态全局变量定义 */
|
|
static uint8_t usr_uart0_recv_space[UART0_RECV_CACHE_MAX] = {0};
|
|
static uint32_t uart0_recv_local = 0;
|
|
static uint32_t uart0_recv_temp = 0;
|
|
|
|
static uint8_t usr_uart1_recv_space[UART1_RECV_CACHE_MAX] = {0};
|
|
static uint32_t uart1_recv_local = 0;
|
|
static uint32_t uart1_recv_temp = 0;
|
|
|
|
static uint8_t usr_uart2_recv_space[UART2_RECV_CACHE_MAX] = {0};
|
|
static uint32_t uart2_recv_local = 0;
|
|
static uint32_t uart2_recv_temp = 0;
|
|
|
|
static uint8_t usr_uart3_recv_space[UART3_RECV_CACHE_MAX] = {0};
|
|
static uint32_t uart3_recv_local = 0;
|
|
static uint32_t uart3_recv_temp = 0;
|
|
|
|
static uint8_t usr_uart4_recv_space[UART4_RECV_CACHE_MAX] = {0};
|
|
static uint32_t uart4_recv_local = 0;
|
|
static uint32_t uart4_recv_temp = 0;
|
|
|
|
static uint8_t usr_uart5_recv_space[UART5_RECV_CACHE_MAX] = {0};
|
|
static uint32_t uart5_recv_local = 0;
|
|
static uint32_t uart5_recv_temp = 0;
|
|
|
|
static uint8_t usr_uart6_recv_space[UART6_RECV_CACHE_MAX] = {0};
|
|
static uint32_t uart6_recv_local = 0;
|
|
static uint32_t uart6_recv_temp = 0;
|
|
|
|
static uint8_t usr_uart7_recv_space[UART7_RECV_CACHE_MAX] = {0};
|
|
static uint32_t uart7_recv_local = 0;
|
|
static uint32_t uart7_recv_temp = 0;
|
|
|
|
static void usr_bsp_uart0_IntHandler(void);
|
|
static void usr_bsp_uart1_IntHandler(void);
|
|
static void usr_bsp_uart2_IntHandler(void);
|
|
static void usr_bsp_uart3_IntHandler(void);
|
|
static void usr_bsp_uart4_IntHandler(void);
|
|
static void usr_bsp_uart5_IntHandler(void);
|
|
static void usr_bsp_uart6_IntHandler(void);
|
|
static void usr_bsp_uart7_IntHandler(void);
|
|
|
|
/* UART初始化
|
|
* 参数
|
|
* uart_id(串口ID): USR_UART_ID_0
|
|
* USR_UART_ID_1
|
|
* USR_UART_ID_2
|
|
* USR_UART_ID_3
|
|
* USR_UART_ID_4
|
|
* USR_UART_ID_5
|
|
* USR_UART_ID_6
|
|
* USR_UART_ID_7
|
|
* bandrate(波特率): USR_UART_BANDRATE_9600
|
|
* USR_UART_BANDRATE_14400
|
|
* USR_UART_BANDRATE_19200
|
|
* USR_UART_BANDRATE_38400
|
|
* USR_UART_BANDRATE_56000
|
|
* USR_UART_BANDRATE_57600
|
|
* USR_UART_BANDRATE_115200
|
|
* databit(数据位): USR_UART_DATABIT_8
|
|
* USR_UART_DATABIT_7
|
|
* USR_UART_DATABIT_6
|
|
* USR_UART_DATABIT_5
|
|
* stopbit(停止位): USR_UART_STOPBIT_ONE
|
|
* USR_UART_STOPBIT_TWO
|
|
* checkbit(校验位): USR_UART_CHECKBIT_NONE
|
|
* USR_UART_CHECKBIT_EVEN
|
|
* USR_UART_CHECKBIT_ODD
|
|
* 返回值:
|
|
* 0: 表示成功
|
|
* -1:表示失败
|
|
*/
|
|
int8_t usr_bsp_uart_init(uint8_t uart_id, uint32_t bandrate, uint8_t databit, uint8_t stopbit, uint8_t checkbit)
|
|
{
|
|
if (uart_id == USR_UART0) {
|
|
SysCtlPeripheralEnable(USR_UART0_SYSCTL);
|
|
SysCtlPeripheralEnable(USR_UART0_GPIO_SYSCTL);
|
|
GPIOPinConfigure(USR_URAT0_GPIO_RX);
|
|
GPIOPinConfigure(USR_UART0_GPIO_TX);
|
|
GPIOPinTypeUART(USR_UART0_GPIO_BASE, USR_URAT0_GPIO_RX_PIN | USR_UART0_GPIO_TX_PIN);
|
|
UARTConfigSetExpClk(USR_UART0_BASE, usr_bsp_get_sysclock(), bandrate, (databit | stopbit | checkbit));
|
|
/* 加入系统中断函数 */
|
|
BSP_IntVectSet((CPU_INT08U)USR_BSP_INT_ID_UART0, (CPU_FNCT_VOID)usr_bsp_uart0_IntHandler);
|
|
BSP_IntEn(USR_BSP_INT_ID_UART0);
|
|
/* 开启硬件中断 */
|
|
IntEnable(USR_INT_UART0);
|
|
IntPrioritySet(USR_INT_UART0, 3 << 5); // 设置中断优先级
|
|
UARTIntEnable(USR_UART0_BASE, UART_INT_RX | UART_INT_RT);
|
|
} else if (uart_id == USR_UART1) {
|
|
SysCtlPeripheralEnable(USR_UART1_SYSCTL);
|
|
SysCtlPeripheralEnable(USR_UART1_GPIO_SYSCTL);
|
|
GPIOPinConfigure(USR_URAT1_GPIO_RX);
|
|
GPIOPinConfigure(USR_UART1_GPIO_TX);
|
|
GPIOPinTypeUART(USR_UART1_GPIO_BASE, USR_URAT1_GPIO_RX_PIN | USR_UART1_GPIO_TX_PIN);
|
|
UARTConfigSetExpClk(USR_UART1_BASE, usr_bsp_get_sysclock(), bandrate, (databit | stopbit | checkbit));
|
|
/* 加入系统中断函数 */
|
|
BSP_IntVectSet((CPU_INT08U)USR_BSP_INT_ID_UART1, (CPU_FNCT_VOID)usr_bsp_uart1_IntHandler);
|
|
BSP_IntEn(USR_BSP_INT_ID_UART1);
|
|
/* 开启硬件中断 */
|
|
IntEnable(USR_INT_UART1);
|
|
IntPrioritySet(USR_INT_UART1, 3 << 5); // 设置中断优先级
|
|
UARTIntEnable(USR_UART1_BASE, UART_INT_RX | UART_INT_RT);
|
|
} else if (uart_id == USR_UART2) {
|
|
SysCtlPeripheralEnable(USR_UART2_SYSCTL);
|
|
SysCtlPeripheralEnable(USR_UART2_GPIO_SYSCTL);
|
|
GPIOPinConfigure(USR_URAT2_GPIO_RX);
|
|
GPIOPinConfigure(USR_UART2_GPIO_TX);
|
|
GPIOPinTypeUART(USR_UART2_GPIO_BASE, USR_URAT2_GPIO_RX_PIN | USR_UART2_GPIO_TX_PIN);
|
|
UARTConfigSetExpClk(USR_UART2_BASE, usr_bsp_get_sysclock(), bandrate, (databit | stopbit | checkbit));
|
|
/* 加入系统中断函数 */
|
|
BSP_IntVectSet((CPU_INT08U)USR_BSP_INT_ID_UART2, (CPU_FNCT_VOID)usr_bsp_uart2_IntHandler);
|
|
BSP_IntEn(USR_BSP_INT_ID_UART2);
|
|
/* 开启硬件中断 */
|
|
IntEnable(USR_INT_UART2);
|
|
IntPrioritySet(USR_INT_UART2, 3 << 5); // 设置中断优先级
|
|
UARTIntEnable(USR_UART2_BASE, UART_INT_RX | UART_INT_RT);
|
|
} else if (uart_id == USR_UART3) {
|
|
SysCtlPeripheralEnable(USR_UART3_SYSCTL);
|
|
SysCtlPeripheralEnable(USR_UART3_GPIO_SYSCTL);
|
|
GPIOPinConfigure(USR_URAT3_GPIO_RX);
|
|
GPIOPinConfigure(USR_UART3_GPIO_TX);
|
|
GPIOPinTypeUART(USR_UART3_GPIO_BASE, USR_URAT3_GPIO_RX_PIN | USR_UART3_GPIO_TX_PIN);
|
|
UARTConfigSetExpClk(USR_UART3_BASE, usr_bsp_get_sysclock(), bandrate, (databit | stopbit | checkbit));
|
|
/* 加入系统中断函数 */
|
|
BSP_IntVectSet((CPU_INT08U)USR_BSP_INT_ID_UART3, (CPU_FNCT_VOID)usr_bsp_uart3_IntHandler);
|
|
BSP_IntEn(USR_BSP_INT_ID_UART3);
|
|
/* 开启硬件中断 */
|
|
IntEnable(USR_INT_UART3);
|
|
IntPrioritySet(USR_INT_UART3, 3 << 5); // 设置中断优先级
|
|
UARTIntEnable(USR_UART3_BASE, UART_INT_RX | UART_INT_RT);
|
|
} else if (uart_id == USR_UART4) {
|
|
SysCtlPeripheralEnable(USR_UART4_SYSCTL);
|
|
SysCtlPeripheralEnable(USR_UART4_GPIO_SYSCTL);
|
|
GPIOPinConfigure(USR_URAT4_GPIO_RX);
|
|
GPIOPinConfigure(USR_UART4_GPIO_TX);
|
|
GPIOPinTypeUART(USR_UART4_GPIO_BASE, USR_URAT4_GPIO_RX_PIN | USR_UART4_GPIO_TX_PIN);
|
|
UARTConfigSetExpClk(USR_UART4_BASE, usr_bsp_get_sysclock(), bandrate, (databit | stopbit | checkbit));
|
|
/* 加入系统中断函数 */
|
|
BSP_IntVectSet((CPU_INT08U)USR_BSP_INT_ID_UART4, (CPU_FNCT_VOID)usr_bsp_uart4_IntHandler);
|
|
BSP_IntEn(USR_BSP_INT_ID_UART4);
|
|
/* 开启硬件中断 */
|
|
IntEnable(USR_INT_UART4);
|
|
IntPrioritySet(USR_INT_UART4, 3 << 5); // 设置中断优先级
|
|
UARTIntEnable(USR_UART4_BASE, UART_INT_RX | UART_INT_RT);
|
|
} else if (uart_id == USR_UART5) {
|
|
SysCtlPeripheralEnable(USR_UART5_SYSCTL);
|
|
SysCtlPeripheralEnable(USR_UART5_GPIO_SYSCTL);
|
|
GPIOPinConfigure(USR_URAT5_GPIO_RX);
|
|
GPIOPinConfigure(USR_UART5_GPIO_TX);
|
|
GPIOPinTypeUART(USR_UART5_GPIO_BASE, USR_URAT5_GPIO_RX_PIN | USR_UART5_GPIO_TX_PIN);
|
|
UARTConfigSetExpClk(USR_UART5_BASE, usr_bsp_get_sysclock(), bandrate, (databit | stopbit | checkbit));
|
|
/* 加入系统中断函数 */
|
|
BSP_IntVectSet((CPU_INT08U)USR_BSP_INT_ID_UART5, (CPU_FNCT_VOID)usr_bsp_uart5_IntHandler);
|
|
BSP_IntEn(USR_BSP_INT_ID_UART5);
|
|
/* 开启硬件中断 */
|
|
IntEnable(USR_INT_UART5);
|
|
IntPrioritySet(USR_INT_UART5, 3 << 5); // 设置中断优先级
|
|
UARTIntEnable(USR_UART5_BASE, UART_INT_RX | UART_INT_RT);
|
|
} else if (uart_id == USR_UART6) {
|
|
SysCtlPeripheralEnable(USR_UART6_SYSCTL);
|
|
SysCtlPeripheralEnable(USR_UART6_GPIO_SYSCTL);
|
|
GPIOPinConfigure(USR_URAT6_GPIO_RX);
|
|
GPIOPinConfigure(USR_UART6_GPIO_TX);
|
|
GPIOPinTypeUART(USR_UART6_GPIO_BASE, USR_URAT6_GPIO_RX_PIN | USR_UART6_GPIO_TX_PIN);
|
|
UARTConfigSetExpClk(USR_UART6_BASE, usr_bsp_get_sysclock(), bandrate, (databit | stopbit | checkbit));
|
|
/* 加入系统中断函数 */
|
|
BSP_IntVectSet((CPU_INT08U)USR_BSP_INT_ID_UART6, (CPU_FNCT_VOID)usr_bsp_uart6_IntHandler);
|
|
BSP_IntEn(USR_BSP_INT_ID_UART6);
|
|
/* 开启硬件中断 */
|
|
IntEnable(USR_INT_UART6);
|
|
IntPrioritySet(USR_INT_UART6, 3 << 5); // 设置中断优先级
|
|
UARTIntEnable(USR_UART6_BASE, UART_INT_RX | UART_INT_RT);
|
|
} else if (uart_id == USR_UART7) {
|
|
SysCtlPeripheralEnable(USR_UART7_SYSCTL);
|
|
SysCtlPeripheralEnable(USR_UART7_GPIO_SYSCTL);
|
|
GPIOPinConfigure(USR_URAT7_GPIO_RX);
|
|
GPIOPinConfigure(USR_UART7_GPIO_TX);
|
|
GPIOPinTypeUART(USR_UART7_GPIO_BASE, USR_URAT7_GPIO_RX_PIN | USR_UART7_GPIO_TX_PIN);
|
|
UARTConfigSetExpClk(USR_UART7_BASE, usr_bsp_get_sysclock(), bandrate, (databit | stopbit | checkbit));
|
|
/* 加入系统中断函数 */
|
|
BSP_IntVectSet((CPU_INT08U)USR_BSP_INT_ID_UART7, (CPU_FNCT_VOID)usr_bsp_uart7_IntHandler);
|
|
BSP_IntEn(USR_BSP_INT_ID_UART7);
|
|
/* 开启硬件中断 */
|
|
IntEnable(USR_INT_UART7);
|
|
IntPrioritySet(USR_INT_UART7, 3 << 5); // 设置中断优先级
|
|
UARTIntEnable(USR_UART7_BASE, UART_INT_RX | UART_INT_RT);
|
|
} else {
|
|
return -1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/* 串口发送函数
|
|
* 返回值:
|
|
* 0: 成功
|
|
* -1: 失败
|
|
*/
|
|
int8_t usr_bsp_uart_send(uint8_t uart_id, uint8_t *data, uint32_t data_len)
|
|
{
|
|
uint32_t i = 0;
|
|
CPU_SR_ALLOC();
|
|
OS_ENTER_CRITICAL();
|
|
if (uart_id == USR_UART0) {
|
|
for (; i < data_len; i++) {
|
|
UARTCharPut(UART0_BASE, data[i]);
|
|
}
|
|
while (UARTBusy(UART0_BASE)) {
|
|
//OSTimeDly(1);
|
|
}
|
|
} else if (uart_id == USR_UART1) {
|
|
for (; i < data_len; i++) {
|
|
UARTCharPut(UART1_BASE, data[i]);
|
|
}
|
|
while (UARTBusy(UART1_BASE)) {
|
|
//OSTimeDly(1);
|
|
}
|
|
} else if (uart_id == USR_UART2) {
|
|
for (; i < data_len; i++) {
|
|
UARTCharPut(UART2_BASE, data[i]);
|
|
}
|
|
while (UARTBusy(UART2_BASE)) {
|
|
//OSTimeDly(1);
|
|
}
|
|
} else if (uart_id == USR_UART3) {
|
|
for (; i < data_len; i++) {
|
|
UARTCharPut(UART3_BASE, data[i]);
|
|
}
|
|
while (UARTBusy(UART3_BASE)) {
|
|
//OSTimeDly(1);
|
|
}
|
|
} else if (uart_id == USR_UART4) {
|
|
for (; i < data_len; i++) {
|
|
UARTCharPut(UART4_BASE, data[i]);
|
|
}
|
|
while (UARTBusy(UART4_BASE)) {
|
|
//OSTimeDly(1);
|
|
}
|
|
} else if (uart_id == USR_UART5) {
|
|
for (; i < data_len; i++) {
|
|
UARTCharPut(UART5_BASE, data[i]);
|
|
}
|
|
while (UARTBusy(UART5_BASE)) {
|
|
//OSTimeDly(1);
|
|
}
|
|
} else if (uart_id == USR_UART6) {
|
|
for (; i < data_len; i++) {
|
|
UARTCharPut(UART6_BASE, data[i]);
|
|
}
|
|
while (UARTBusy(UART6_BASE)) {
|
|
//OSTimeDly(1);
|
|
}
|
|
} else if (uart_id == USR_UART7) {
|
|
for (; i < data_len; i++) {
|
|
UARTCharPut(UART7_BASE, data[i]);
|
|
}
|
|
while (UARTBusy(UART7_BASE)) {
|
|
//OSTimeDly(1);
|
|
}
|
|
} else {
|
|
OS_EXIT_CRITICAL();
|
|
return -1;
|
|
}
|
|
OS_EXIT_CRITICAL();
|
|
return 0;
|
|
}
|
|
|
|
/* 接收信息 */
|
|
uint32_t usr_bsp_uart_get_info(uint8_t uart_id, uint8_t *info, uint32_t info_len)
|
|
{
|
|
uint32_t i = 0;
|
|
CPU_SR_ALLOC();
|
|
OS_ENTER_CRITICAL();
|
|
switch (uart_id) {
|
|
case USR_UART0:
|
|
for (i = 0; i < info_len; i++) {
|
|
if (uart0_recv_temp == uart0_recv_local) {
|
|
break;
|
|
}
|
|
info[i] = usr_uart0_recv_space[uart0_recv_temp];
|
|
uart0_recv_temp++;
|
|
uart0_recv_temp = uart0_recv_temp % UART0_RECV_CACHE_MAX;
|
|
}
|
|
break;
|
|
case USR_UART1:
|
|
for (i = 0; i < info_len; i++) {
|
|
if (uart1_recv_temp == uart1_recv_local) {
|
|
break;
|
|
}
|
|
info[i] = usr_uart1_recv_space[uart1_recv_temp];
|
|
uart1_recv_temp++;
|
|
uart1_recv_temp = uart1_recv_temp % UART1_RECV_CACHE_MAX;
|
|
}
|
|
break;
|
|
case USR_UART2:
|
|
for (i = 0; i < info_len; i++) {
|
|
if (uart2_recv_temp == uart2_recv_local) {
|
|
break;
|
|
}
|
|
info[i] = usr_uart2_recv_space[uart2_recv_temp];
|
|
uart2_recv_temp++;
|
|
uart2_recv_temp = uart2_recv_temp % UART2_RECV_CACHE_MAX;
|
|
}
|
|
break;
|
|
case USR_UART3:
|
|
for (i = 0; i < info_len; i++) {
|
|
if (uart3_recv_temp == uart3_recv_local) {
|
|
break;
|
|
}
|
|
info[i] = usr_uart3_recv_space[uart3_recv_temp];
|
|
uart3_recv_temp++;
|
|
uart3_recv_temp = uart3_recv_temp % UART3_RECV_CACHE_MAX;
|
|
}
|
|
break;
|
|
case USR_UART4:
|
|
for (i = 0; i < info_len; i++) {
|
|
if (uart4_recv_temp == uart4_recv_local) {
|
|
break;
|
|
}
|
|
info[i] = usr_uart4_recv_space[uart4_recv_temp];
|
|
uart4_recv_temp++;
|
|
uart4_recv_temp = uart4_recv_temp % UART4_RECV_CACHE_MAX;
|
|
}
|
|
break;
|
|
case USR_UART5:
|
|
for (i = 0; i < info_len; i++) {
|
|
if (uart5_recv_temp == uart5_recv_local) {
|
|
break;
|
|
}
|
|
info[i] = usr_uart5_recv_space[uart5_recv_temp];
|
|
uart5_recv_temp++;
|
|
uart5_recv_temp = uart5_recv_temp % UART5_RECV_CACHE_MAX;
|
|
}
|
|
break;
|
|
case USR_UART6:
|
|
for (i = 0; i < info_len; i++) {
|
|
if (uart6_recv_temp == uart6_recv_local) {
|
|
break;
|
|
}
|
|
info[i] = usr_uart6_recv_space[uart6_recv_temp];
|
|
uart6_recv_temp++;
|
|
uart6_recv_temp = uart6_recv_temp % UART6_RECV_CACHE_MAX;
|
|
}
|
|
break;
|
|
case USR_UART7:
|
|
for (i = 0; i < info_len; i++) {
|
|
if (uart7_recv_temp == uart7_recv_local) {
|
|
break;
|
|
}
|
|
info[i] = usr_uart7_recv_space[uart7_recv_temp];
|
|
uart7_recv_temp++;
|
|
uart7_recv_temp = uart7_recv_temp % UART7_RECV_CACHE_MAX;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
OS_EXIT_CRITICAL();
|
|
return i;
|
|
}
|
|
|
|
static void usr_bsp_uart0_IntHandler(void)
|
|
{
|
|
uint32_t ui32Status;
|
|
ui32Status = UARTIntStatus(UART0_BASE, true);
|
|
UARTIntClear(UART0_BASE, ui32Status);
|
|
OSIntEnter(); // 进入中断
|
|
while (UARTCharsAvail(UART0_BASE)) {
|
|
usr_uart0_recv_space[uart0_recv_local] = (uint8_t)UARTCharGetNonBlocking(UART0_BASE);
|
|
uart0_recv_local++;
|
|
uart0_recv_local = uart0_recv_local % UART0_RECV_CACHE_MAX;
|
|
}
|
|
OSIntExit(); // 退出中断
|
|
}
|
|
|
|
static void usr_bsp_uart1_IntHandler(void)
|
|
{
|
|
uint32_t ui32Status;
|
|
ui32Status = UARTIntStatus(UART1_BASE, true);
|
|
UARTIntClear(UART1_BASE, ui32Status);
|
|
OSIntEnter(); // 进入中断
|
|
while (UARTCharsAvail(UART1_BASE)) {
|
|
usr_uart1_recv_space[uart1_recv_local] = (uint8_t)UARTCharGetNonBlocking(UART1_BASE);
|
|
uart1_recv_local++;
|
|
uart1_recv_local = uart1_recv_local % UART1_RECV_CACHE_MAX;
|
|
}
|
|
OSIntExit(); // 退出中断
|
|
}
|
|
|
|
static void usr_bsp_uart2_IntHandler(void)
|
|
{
|
|
uint32_t ui32Status;
|
|
ui32Status = UARTIntStatus(UART2_BASE, true);
|
|
UARTIntClear(UART2_BASE, ui32Status);
|
|
OSIntEnter(); // 进入中断
|
|
while (UARTCharsAvail(UART2_BASE)) {
|
|
usr_uart2_recv_space[uart2_recv_local] = (uint8_t)UARTCharGetNonBlocking(UART2_BASE);
|
|
uart2_recv_local++;
|
|
uart2_recv_local = uart2_recv_local % UART2_RECV_CACHE_MAX;
|
|
}
|
|
OSIntExit(); // 退出中断
|
|
}
|
|
|
|
static void usr_bsp_uart3_IntHandler(void)
|
|
{
|
|
uint32_t ui32Status;
|
|
ui32Status = UARTIntStatus(UART3_BASE, true);
|
|
UARTIntClear(UART3_BASE, ui32Status);
|
|
OSIntEnter(); // 进入中断
|
|
while (UARTCharsAvail(UART3_BASE)) {
|
|
usr_uart3_recv_space[uart3_recv_local] = (uint8_t)UARTCharGetNonBlocking(UART3_BASE);
|
|
uart3_recv_local++;
|
|
uart3_recv_local = uart3_recv_local % UART3_RECV_CACHE_MAX;
|
|
}
|
|
OSIntExit(); // 退出中断
|
|
}
|
|
|
|
static void usr_bsp_uart4_IntHandler(void)
|
|
{
|
|
uint32_t ui32Status;
|
|
ui32Status = UARTIntStatus(UART4_BASE, true);
|
|
UARTIntClear(UART4_BASE, ui32Status);
|
|
OSIntEnter(); // 进入中断
|
|
while (UARTCharsAvail(UART4_BASE)) {
|
|
usr_uart4_recv_space[uart4_recv_local] = (uint8_t)UARTCharGetNonBlocking(UART4_BASE);
|
|
uart4_recv_local++;
|
|
uart4_recv_local = uart4_recv_local % UART4_RECV_CACHE_MAX;
|
|
}
|
|
OSIntExit(); // 退出中断
|
|
}
|
|
|
|
static void usr_bsp_uart5_IntHandler(void)
|
|
{
|
|
uint32_t ui32Status;
|
|
ui32Status = UARTIntStatus(UART5_BASE, true);
|
|
UARTIntClear(UART5_BASE, ui32Status);
|
|
OSIntEnter(); // 进入中断
|
|
while (UARTCharsAvail(UART5_BASE)) {
|
|
usr_uart5_recv_space[uart5_recv_local] = (uint8_t)UARTCharGetNonBlocking(UART5_BASE);
|
|
uart5_recv_local++;
|
|
uart5_recv_local = uart5_recv_local % UART5_RECV_CACHE_MAX;
|
|
}
|
|
OSIntExit(); // 退出中断
|
|
}
|
|
|
|
static void usr_bsp_uart6_IntHandler(void)
|
|
{
|
|
uint32_t ui32Status;
|
|
ui32Status = UARTIntStatus(UART6_BASE, true);
|
|
UARTIntClear(UART6_BASE, ui32Status);
|
|
OSIntEnter(); // 进入中断
|
|
while (UARTCharsAvail(UART6_BASE)) {
|
|
usr_uart6_recv_space[uart6_recv_local] = (uint8_t)UARTCharGetNonBlocking(UART6_BASE);
|
|
uart6_recv_local++;
|
|
uart6_recv_local = uart6_recv_local % UART6_RECV_CACHE_MAX;
|
|
}
|
|
OSIntExit(); // 退出中断
|
|
}
|
|
|
|
static void usr_bsp_uart7_IntHandler(void)
|
|
{
|
|
uint32_t ui32Status;
|
|
ui32Status = UARTIntStatus(UART7_BASE, true);
|
|
UARTIntClear(UART7_BASE, ui32Status);
|
|
OSIntEnter(); // 进入中断
|
|
while (UARTCharsAvail(UART7_BASE)) {
|
|
usr_uart7_recv_space[uart7_recv_local] = (uint8_t)UARTCharGetNonBlocking(UART7_BASE);
|
|
uart7_recv_local++;
|
|
uart7_recv_local = uart7_recv_local % UART7_RECV_CACHE_MAX;
|
|
}
|
|
OSIntExit(); // 退出中断
|
|
}
|