/* ################################################################### ** Filename : main.c ** Processor : S32K1xx ** Abstract : ** Main module. ** This module contains user's application code. ** Settings : ** Contents : ** No public methods ** ** ###################################################################*/ /*! ** @file main.c ** @version 01.00 ** @brief ** Main module. ** This module contains user's application code. */ /*! ** @addtogroup main_module main module documentation ** @{ */ /* MODULE main */ /* Including necessary module. Cpu.h contains other modules needed for compiling.*/ #include "Cpu.h" #define BSWT0_TASK_PRIORITY ( tskIDLE_PRIORITY ) #define BSWT0_TASK_STACK_SIZE (3*configMINIMAL_STACK_SIZE) #define TIMER_10MS_TIMER_PERIOD_MS ( 10UL / portTICK_PERIOD_MS ) volatile int exit_code = 0; static TimerHandle_t xTimer10ms = NULL; void rtos_init( void ) { /*Disable the interrupt as soon as possible*/ DISABLE_INTERRUPTS(); /*Initialize and configure clocks*/ CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT); CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT); /*configures the pins with the options provided in the given structure.g_pin_mux_InitConfigArr*/ PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr); /* * Set systick interrupt priority * As FreeRTOS is using systick which need to have highest priority * */ INT_SYS_SetPriority(SysTick_IRQn, 0);/**< Cortex-M4 System Tick Interrupt */ /*Initialize Internal Storage Flash*/ IFls_Init(); } static void BswTask0( void *pvParameters ) { taskENTER_CRITICAL(); vTaskDelay(1500); taskEXIT_CRITICAL(); // Code continue... } static void prvTimer10ms_cb( TimerHandle_t xTimer ) { /// ... } void rtos_start( void ) { /* Create Tasks. */ xTaskCreate( BswTask0, "BswT0", BSWT0_TASK_STACK_SIZE, NULL, BSWT0_TASK_PRIORITY, &handlers[BSW0_TASK]/*NULL*/ ); xTimer10ms = xTimerCreate( "Timer10ms", /* A text name, purely to help debugging. */ TIMER_10MS_TIMER_PERIOD_MS, /* The timer period, in this case 10ms. */ pdTRUE, /* This is a one shot timer, so xAutoReload is set to pdFALSE. */ ( void * ) 0, /* The ID is not used, so can be set to anything. */ prvTimer10ms_cb /* The callback function */ ); /* Start the tasks and timer running. */ vTaskStartScheduler(); /* If all is well, the scheduler will now be running, and the following line will never be reached. If the following line does execute, then there was insufficient FreeRTOS heap memory available for the idle and/or timer tasks to be created. See the memory management section on the FreeRTOS web site for more details. */ for( ;; ); } #define PEX_RTOS_INIT rtos_init #define PEX_RTOS_START rtos_start /*! \brief The main function for the project. \details The startup initialization sequence is the following: * - startup asm routine * - main() */ int main(void) { /* Write your local variable definition here */ /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ #ifdef PEX_RTOS_INIT PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */ #endif /*** End of Processor Expert internal initialization. ***/ /* Write your code here */ /* For example: for(;;) { } */ /*** Don't write any code pass this line, or it will be deleted during code generation. ***/ /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/ #ifdef PEX_RTOS_START PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */ #endif /*** End of RTOS startup code. ***/ /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/ for(;;) { if(exit_code != 0) { break; } } return exit_code; /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/ } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/ /* END main */ /*! ** @} */ /* ** ################################################################### ** ** This file was created by Processor Expert 10.1 [05.21] ** for the NXP S32K series of microcontrollers. ** ** ################################################################### */