Rodkin
2019-04-06 23:32nrf51802接收串口数据,导致系统重启
5用nrf51802作为数据透传模块,当上位MCU发送串口数据,导致nrf51802系统重启
void UART0_IRQHandler(void)
{
// Handle reception
if (NRF_UART0->EVENTS_RXDRDY != 0)
{
uint32_t err_code;
// Clear UART RX event flag
NRF_UART0->EVENTS_RXDRDY = 0;
// Write received byte to FIFO
err_code = app_fifo_put(&m_rx_fifo, (uint8_t)NRF_UART0->RXD);
if (err_code != NRF_SUCCESS)
{
app_uart_evt_t app_uart_event;
app_uart_event.evt_type = APP_UART_FIFO_ERROR;
app_uart_event.data.error_code = err_code;
m_event_handler(&app_uart_event);
}
// Notify that new data is available if this was first byte put in the buffer.
else if (FIFO_LENGTH(m_rx_fifo) == 1)
{
app_uart_evt_t app_uart_event;
app_uart_event.evt_type = APP_UART_DATA_READY;
m_event_handler(&app_uart_event);
}
else
{
// Do nothing, only send event if first byte was added or overflow in FIFO occurred.
}
}
// Handle transmission.
if (NRF_UART0->EVENTS_TXDRDY != 0)
{
// Clear UART TX event flag.
NRF_UART0->EVENTS_TXDRDY = 0;
on_uart_event(ON_TX_READY);
}
// Handle errors.
if (NRF_UART0->EVENTS_ERROR != 0)
{
uint32_t error_source;
app_uart_evt_t app_uart_event;
// Clear UART ERROR event flag.
NRF_UART0->EVENTS_ERROR = 0;
// Clear error source.
error_source = NRF_UART0->ERRORSRC;
NRF_UART0->ERRORSRC = error_source;
app_uart_event.evt_type = APP_UART_COMMUNICATION_ERROR;
app_uart_event.data.error_communication = error_source;
m_event_handler(&app_uart_event);
}
}
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- 使用web-bluetooth 连接设备 一直获取不到服务
- javascript
- chrome
- 1个回答
- 如何访问http客户端响应正文全局[关闭]
- http
- 1个回答
- 使用config.toml文件部署Golang应用(api)
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 1个回答
- ttyusb / uart在传输过程中发送“ USB”
- usb
- uart
- 1个回答
- PHP exec不运行程序
- exec
- raspbian
- php
- 1个回答
换一换