#include "hal_data.h"
/* Application error */
#define APP_ASSERT(a)   \
{                       \
    if ((a))            \
    {                   \
        /* Break */     \
        __BKPT(0);      \
    }                   \
}
/* Callback function */
void coolTimerCallback(timer_callback_args_t *p_args)
{
    /* TODO: add your own code here */
    FSP_PARAMETER_NOT_USED(p_args);
    static bsp_io_level_t level = BSP_IO_LEVEL_LOW;
    R_IOPORT_PinWrite (&g_ioport_ctrl, LED1, level);
    level = (level) ? BSP_IO_LEVEL_LOW : BSP_IO_LEVEL_HIGH;
}

/*******************************************************************************************************************//**
 * 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 */
    fsp_err_t status;
    status=R_GPT_Open(&coolTimer_ctrl, &coolTimer_cfg);
    APP_ASSERT(status);
    status = R_GPT_Start (&coolTimer_ctrl);
    APP_ASSERT(status);
    while (1)
    { /* Wait for interrupt */
        __WFI(); /* Increment counter */
    }
#if BSP_TZ_SECURE_BUILD
    /* Enter non-secure code */
    R_BSP_NonSecureEnter();
#endif
}

#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
