开发平台:MDK
下载器:板载jlink
开发板:FPB-RA4E1
目地:串口打印
1、原理图:
使用的是通道9,IO口是P109,P110.
2、配置:
先打开FSP Smart Configurator,全部配置好后,再关掉,回来KEIL中。
3、核心代码:
- 打印EA4E1
- memset(g_temp_buffer, RESET_VALUE, DATA_LENGTH);
- b_valid_data = false;
- Delay(0x05FFFFF);
- /* Application is being run on Serial terminal hence transmitting error message to the same */
- err = uart_print_user_msg((uint8_t *)"\r\RA4E1\r\n");
- Delay(0x05FFFFF);
- if (FSP_SUCCESS != err)
- {
- APP_ERR_PRINT ("\r\n ** UART WRITE FAILED ** \r\n");
- return err;
- }
- 初始化:
- fsp_err_t err = FSP_SUCCESS;
- /* Initialize UART channel with baud rate 115200 */
- err = R_SCI_UART_Open (&g_uart_ctrl, &g_uart_cfg);
- if (FSP_SUCCESS != err)
- {
- APP_ERR_PRINT ("\r\n** R_SCI_UART_Open API failed **\r\n");
- }
- return err;
- 回调:
- /* Logged the event in global variable */
- g_uart_event = (uint8_t)p_args->event;
- /* Reset g_temp_buffer index if it exceeds than buffer size */
- if(DATA_LENGTH == g_counter_var)
- {
- g_counter_var = RESET_VALUE;
- }
- if(UART_EVENT_RX_CHAR == p_args->event)
- {
- switch (p_args->data)
- {
- /* If Enter is pressed by user, set flag to process the data */
- case CARRIAGE_ASCII:
- {
- g_counter_var = RESET_VALUE;
- g_data_received_flag = true;
- break;
- }
- /* Read all data provided by user until enter button is pressed */
- default:
- {
- g_temp_buffer[g_counter_var++] = (uint8_t ) p_args->data;
- break;
- }
- }
5、输出结果: