/*********************************************************************************************************************** * Copyright [2020-2022] Renesas Electronics Corporation and/or its affiliates. All Rights Reserved. * * This software and documentation are supplied by Renesas Electronics America Inc. and may only be used with products * of Renesas Electronics Corp. and its affiliates ("Renesas"). No other uses are authorized. Renesas products are * sold pursuant to Renesas terms and conditions of sale. Purchasers are solely responsible for the selection and use * of Renesas products and Renesas assumes no liability. No license, express or implied, to any intellectual property * right is granted by Renesas. This software is protected under all applicable laws, including copyright laws. Renesas * reserves the right to change or discontinue this software and/or this documentation. THE SOFTWARE AND DOCUMENTATION * IS DELIVERED TO YOU "AS IS," AND RENESAS MAKES NO REPRESENTATIONS OR WARRANTIES, AND TO THE FULLEST EXTENT * PERMISSIBLE UNDER APPLICABLE LAW, DISCLAIMS ALL WARRANTIES, WHETHER EXPLICITLY OR IMPLICITLY, INCLUDING WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT, WITH RESPECT TO THE SOFTWARE OR * DOCUMENTATION. RENESAS SHALL HAVE NO LIABILITY ARISING OUT OF ANY SECURITY VULNERABILITY OR BREACH. TO THE MAXIMUM * EXTENT PERMITTED BY LAW, IN NO EVENT WILL RENESAS BE LIABLE TO YOU IN CONNECTION WITH THE SOFTWARE OR DOCUMENTATION * (OR ANY PERSON OR ENTITY CLAIMING RIGHTS DERIVED FROM YOU) FOR ANY LOSS, DAMAGES, OR CLAIMS WHATSOEVER, INCLUDING, * WITHOUT LIMITATION, ANY DIRECT, CONSEQUENTIAL, SPECIAL, INDIRECT, PUNITIVE, OR INCIDENTAL DAMAGES; ANY LOST PROFITS, * OTHER ECONOMIC DAMAGE, PROPERTY DAMAGE, OR PERSONAL INJURY; AND EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY * OF SUCH LOSS, DAMAGES, CLAIMS OR COSTS. **********************************************************************************************************************/ #include "hal_data.h" void R_BSP_WarmStart(bsp_warm_start_event_t event); extern bsp_leds_t g_bsp_leds; /*******************************************************************************************************************//** * @brief Blinky example application * * Blinks all leds at a rate of 1 second using the software delay function provided by the BSP. * **********************************************************************************************************************/ void hal_entry (void) { #if BSP_TZ_SECURE_BUILD /* Enter non-secure code */ R_BSP_NonSecureEnter(); #endif // this is a test /* Define the units to be used with the software delay function */ const bsp_delay_units_t bsp_delay_units = BSP_DELAY_UNITS_MILLISECONDS; /* Set the blink frequency (must be <= bsp_delay_units */ const uint32_t freq_in_hz = 2; /* Calculate the delay in terms of bsp_delay_units */ const uint32_t delay = bsp_delay_units / freq_in_hz; /* LED type structure */ bsp_leds_t leds = g_bsp_leds; /* If this board has no LEDs then trap here */ if (0 == leds.led_count) { while (1) { ; // There are no LEDs on this board } } /* Holds level to set for pins */ bsp_io_level_t pin_level = BSP_IO_LEVEL_LOW; while (1) { /* Enable access to the PFS registers. If using r_ioport module then register protection is automatically * handled. This code uses BSP IO functions to show how it is used. */ R_BSP_PinAccessEnable(); /* Update all board LEDs */ for (uint32_t i = 0; i < leds.led_count; i++) { /* Get pin to toggle */ uint32_t pin = leds.p_leds[i]; /* Write to this pin */ R_BSP_PinWrite((bsp_io_port_pin_t) pin, pin_level); // RESET R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_15, pin_level); // RTS R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_02_PIN_05, pin_level); } /* Protect PFS registers */ R_BSP_PinAccessDisable(); /* Toggle level for next write */ if (BSP_IO_LEVEL_LOW == pin_level) { pin_level = BSP_IO_LEVEL_HIGH; } else { pin_level = BSP_IO_LEVEL_LOW; } /* Delay */ R_BSP_SoftwareDelay(delay, bsp_delay_units); } } /*******************************************************************************************************************//** * 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); } }