#include "hal_data.h"
FSP_CPP_HEADER
void R_BSP_WarmStart(bsp_warm_start_event_t event);
FSP_CPP_FOOTER
#include "led/bsp_led.h"
#include "debug_uart/bsp_debug_uart.h"
#include "key/key.h"
#include "rs485/rs485.h"
/*******************************************************************************************************************//**
* main() is generated by the RA Configuration editor and is used to generate threads if an RTOS is used. This function
* is called by main() when no RTOS is used.
**********************************************************************************************************************/
void hal_entry(void)
{
/* TODO: add your own code here */
IRQ_Init(); //开启按键中断
IO_Init(); // IO初始化
RS485_1_Init(); //RS485-1初始化
Debug_UART1_Init(); // SCI1 UART 调试串口初始化
printf("\r\n 欢迎使用启明2L1开发板。\r\n");
printf("\r\n 野火RS-485通讯实验例程\r\n");
printf("\r\n 实验步骤:\r\n");
printf("\r\n 1.使用导线连接好两个485通讯设备\r\n");
printf("\r\n 2.若使用两个2L1开发板进行实验,给两个开发板都下载本程序即可。\r\n");
printf("\r\n 3.准备好后,按下其中一个开发板的KEY1键,会使用485向外发送0-10的数字 \r\n");
printf("\r\n 4.若开发板的485接收到字节数据,会把数据以16进制形式打印出来。 \r\n");
while(1)
{
/*按键没有按下的时候,使RS485处于接收状态*/
RS485_1_RX;
LED1_OFF;
LED3_ON;
}
#if BSP_TZ_SECURE_BUILD
/* Enter non-secure code */
R_BSP_NonSecureEnter();
#endif
}
/*******************************************************************************************************************//**
* This function is called at various points during the startup process. This implementation uses the event that is
* called right before main() to set up the pins.
*
* @param[in] event Where at in the start up process the code is currently at
**********************************************************************************************************************/
void R_BSP_WarmStart (bsp_warm_start_event_t event)
{
if (BSP_WARM_START_RESET == event)
{
#if BSP_FEATURE_FLASH_LP_VERSION != 0
/* Enable reading from data flash. */
R_FACI_LP->DFLCTL = 1U;
/* Would normally have to wait tDSTOP(6us) for data flash recovery. Placing the enable here, before clock and
* C runtime initialization, should negate the need for a delay since the initialization will typically take more than 6us. */
#endif
}
if (BSP_WARM_START_POST_C == event)
{
/* C runtime environment and system clocks are setup. */
/* Configure pins. */
R_IOPORT_Open(&g_ioport_ctrl, g_ioport.p_cfg);
}
}
#if BSP_TZ_SECURE_BUILD
BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable ();
/* Trustzone Secure Projects require at least one nonsecure callable function in order to build (Remove this if it is not required to build). */
BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable ()
{
}
#endif