/* proj_cm33_ns/main.c - Hello World Example */
/*******************************************************************************
* File Name : main.c
*
* Description : This source file contains the main routine for non-secure
* application in the CM33 CPU
*
* Related Document : See README.md
*
********************************************************************************
/*******************************************************************************
* Header Files
*******************************************************************************/
#include "cybsp.h"
#include "retarget_io_init.h"
/*******************************************************************************
* Macros
*******************************************************************************/
#define BLINKY_LED_DELAY_MSEC (1000U)
/* The timeout value in microseconds used to wait for CM55 core to be booted */
#define CM55_BOOT_WAIT_TIME_USEC (10U)
/* App boot address for CM55 project */
#define CM55_APP_BOOT_ADDR (CYMEM_CM33_0_m55_nvm_START + \
CYBSP_MCUBOOT_HEADER_SIZE)
/*******************************************************************************
* Function Name: main
********************************************************************************
* Summary:
* This is the main function of the CM33 non-secure application.
*
* It initializes the device and board peripherals. It also initializes the
* retarget-io middleware to be used with the debug UART port using which
* "Hello World!" is printed on the debug UART. The LED pin is initialized with
* default configurations. The CM55 core is enabled and then the programs enters
* an infinite while loop which toggles the LED1 with a frequency of 1 Hz.
*
* Parameters:
* none
*
* Return:
* int
*
*******************************************************************************/
int main(void)
{
cy_rslt_t result = CY_RSLT_SUCCESS;
/* Initialize the device and board peripherals. */
result = cybsp_init();
/* Board initialization failed. Stop program execution. */
if (CY_RSLT_SUCCESS != result)
{
handle_app_error();
}
/* Enable global interrupts */
__enable_irq();
/* Initialize retarget-io middleware */
init_retarget_io();
/* \x1b[2J\x1b[;H - ANSI ESC sequence for clear screen. */
printf("\x1b[2J\x1b[;H");
printf("****************** "
"PSOC Edge MCU: Hello world "
"****************** \r\n\n");
printf("Hello World!\r\n\n");
printf("For more projects, "
"visit our code examples repositories:\r\n\n");
printf("https://github.com/Infineon/"
"Code-Examples-for-ModusToolbox-Software\r\n\n");
/* Enable CM55. */
/* CM55_APP_BOOT_ADDR must be updated if CM55 memory layout is changed.*/
Cy_SysEnableCM55(MXCM55, CM55_APP_BOOT_ADDR, CM55_BOOT_WAIT_TIME_USEC);
for(;;)
{
Cy_GPIO_Inv(CYBSP_USER_LED1_PORT, CYBSP_USER_LED1_PIN); // Toggle the LED1
Cy_SysLib_Delay(BLINKY_LED_DELAY_MSEC); // Delay for 1 second
}
}
/* [] END OF FILE */
#define BLINKY_LED_DELAY_MSEC (1000U)
for(;;)
{
Cy_GPIO_Inv(CYBSP_USER_LED1_PORT, CYBSP_USER_LED1_PIN); // Toggle the LED1
Cy_SysLib_Delay(BLINKY_LED_DELAY_MSEC); // Delay for 1 second
}