#include "hal_data.h" FSP_CPP_HEADER void R_BSP_WarmStart(bsp_warm_start_event_t event); FSP_CPP_FOOTER void sci_out(unsigned char c); void sci_out_str(char *c); /*******************************************************************************************************************//** * 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 */ //SCI9ポート設定(TX:P109, RX:P110) R_PMISC->PWPR_b.B0WI = 0; R_PMISC->PWPR_b.PFSWE = 1; R_PFS->PORT[1].PIN[9].PmnPFS_b.PMR = 0; R_PFS->PORT[1].PIN[10].PmnPFS_b.PMR = 0; R_PFS->PORT[1].PIN[9].PmnPFS_b.PSEL = 0x5; R_PFS->PORT[1].PIN[10].PmnPFS_b.PSEL = 0x5; R_PFS->PORT[1].PIN[9].PmnPFS_b.PMR = 1; R_PFS->PORT[1].PIN[10].PmnPFS_b.PMR = 1; R_PMISC->PWPR_b.PFSWE = 0; R_PMISC->PWPR_b.B0WI = 1; //SCI9スタンバイ解除 R_SYSTEM->PRCR = 0xA502; R_MSTP->MSTPCRB_b.MSTPB22 = 0; R_SYSTEM->PRCR = 0xA500; //SCI9初期設定 R_SCI9->SMR = 0x00; R_SCI9->SCR = 0x00; R_SCI9->SEMR = 0x40; R_SCI9->BRR = 0x0C; //115,200bps(err=0.16%) ABCS = 0、BDGM = 1; //SCI9_RXI 割り込みベクタ R_ICU->IELSR_b[4].IELS = 0x1E; //送信許可,受信許可,受信割り込み許可 R_SCI9->SCR = 0x70; sci_out_str("\r\nSCI Receive polling test program\r\n"); while (1) { if (R_ICU->IELSR_b[4].IR == 1) { //受信データあり R_ICU->IELSR_b[4].IR = 0; //割り込みフラグクリア sci_out(R_SCI9->RDR); //受信データはエコーバックさせる } } #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, &IOPORT_CFG_NAME); } } #if BSP_TZ_SECURE_BUILD FSP_CPP_HEADER 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 () { } FSP_CPP_FOOTER #endif void sci_out(unsigned char c) { R_SCI9->TDR = c; while ((R_SCI9->SSR & 0x04) != 0x04); } void sci_out_str(char *c) { while (*c != '\0') { sci_out((unsigned char)*c); c++; } }