forked from xuos/xiuos
add usart3 connect
This commit is contained in:
parent
1dffac3f88
commit
814a742260
|
@ -60,6 +60,8 @@ static uint32_t _SysTick_Config(uint32_t ticks)
|
|||
|
||||
extern RxBuffer2;
|
||||
extern uint16_t UART_ReceiveData(USART_TypeDef* USARTx);
|
||||
extern void UART_SendData(USART_TypeDef* USARTx, uint16_t Data);
|
||||
|
||||
void InitBoardHardware()
|
||||
{
|
||||
_SysTick_Config(SystemCoreClock / TICK_PER_SECOND);
|
||||
|
@ -78,10 +80,22 @@ void InitBoardHardware()
|
|||
|
||||
KPrintf("board init done.\n");
|
||||
KPrintf("start okernel...\n");
|
||||
// while (1) {
|
||||
// uint32_t ans = (uint32_t)UART_ReceiveData(USART3);
|
||||
// KPrintf("%d\n", ans);
|
||||
// for (int i = 0; i < 10000; i++)
|
||||
// ;
|
||||
// }
|
||||
|
||||
uint16_t ans = 0;
|
||||
uint16_t recv_data = 0;
|
||||
uint16_t send_data = 0;
|
||||
int cnt = 0;
|
||||
while (1) {
|
||||
|
||||
recv_data = UART_ReceiveData(USART3);
|
||||
|
||||
if (recv_data < 58 && recv_data > 47) {
|
||||
ans = recv_data;
|
||||
|
||||
KPrintf("recv data: %d\n", ans - 48);
|
||||
}
|
||||
send_data = ans + 17;
|
||||
KPrintf("send data: %d\n", send_data);
|
||||
UART_SendData(USART3, send_data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,6 +177,17 @@ static const struct SerialDataCfg data_cfg_init = {
|
|||
.serial_timeout = WAITING_FOREVER,
|
||||
};
|
||||
|
||||
static const struct SerialDataCfg data_cfg_init_uart3 = {
|
||||
.serial_baud_rate = BAUD_RATE_115200,
|
||||
.serial_data_bits = DATA_BITS_8,
|
||||
.serial_stop_bits = STOP_BITS_1,
|
||||
.serial_parity_mode = PARITY_NONE,
|
||||
.serial_bit_order = BIT_ORDER_LSB,
|
||||
.serial_invert_mode = NRZ_NORMAL,
|
||||
.serial_buffer_size = SERIAL_RB_BUFSZ,
|
||||
.serial_timeout = WAITING_FOREVER,
|
||||
};
|
||||
|
||||
/*manage the serial device operations*/
|
||||
static const struct SerialDrvDone drv_done = {
|
||||
.init = SerialInit,
|
||||
|
@ -259,7 +270,12 @@ void USART1_IRQHandler(void)
|
|||
|
||||
uint16_t UART_ReceiveData(USART_TypeDef* USARTx)
|
||||
{
|
||||
return (uint16_t)(USARTx->DATAR);
|
||||
return (uint16_t)(USARTx->DATAR & (uint16_t)0x01FF);
|
||||
}
|
||||
|
||||
void UART_SendData(USART_TypeDef* USARTx, uint16_t Data)
|
||||
{
|
||||
USARTx->DATAR = (Data & (uint16_t)0x01FF);
|
||||
}
|
||||
|
||||
#ifdef BSP_USING_UART2
|
||||
|
|
Loading…
Reference in New Issue