wangj@microvast.com.cn

Blinking_LED_S32DS

Blog Post created by wangj@microvast.com.cn on May 8, 2017

/* ###################################################################
** Filename : main.c
** Processor : S32K144_100
** 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 needed modules to compile this module/procedure */
#include "Cpu.h"
#include "pin_mux.h"
#include "clockMan1.h"

volatile int exit_code = 0;
/* User includes (#include below this line is not maintained by Processor Expert) */

/*!
\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 */
uint32_t cycles;
uint8_t color;
/*** 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 */
CLOCK_SYS_Init(g_clockManConfigsArr,FSL_CLOCK_MANAGER_CONFIG_CNT,g_clockManCallbacksArr,FSL_CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0,CLOCK_MANAGER_POLICY_FORCIBLE);

GPIO_HAL_SetPins(PTD,(1 << 15));
GPIO_HAL_SetPins(PTD,(1 << 16));
GPIO_HAL_SetPins(PTD,(1 << 0));

PINS_DRV_Init(NUM_OF_CONFIGURED_PINS,g_pin_mux_InitConfigArr);

GPIO_HAL_SetPinsDirection(PTD, ((1 << 15) | (1 << 16) | (1 << 0)));


GPIO_HAL_ClearPins(PTD,(1 << 15)); /* RED LED ON */
GPIO_HAL_SetPins(PTD,(1 << 15));
GPIO_HAL_ClearPins(PTD,(1 << 16)); /* GREEN LED ON */
GPIO_HAL_SetPins(PTD,(1 << 16));
GPIO_HAL_ClearPins(PTD,(1 << 0)); /* BLUE LED ON */
GPIO_HAL_SetPins(PTD,(1 << 0));

for(;;) {
cycles = 3600000;
while(cycles--);

asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");

switch(color){
case 0:
GPIO_HAL_ClearPins(PTD,(1 << 15));
GPIO_HAL_SetPins(PTD,(1 << 16));
GPIO_HAL_SetPins(PTD,(1 << 0));
break;
case 1:
GPIO_HAL_SetPins(PTD,(1 << 15));
GPIO_HAL_ClearPins(PTD,(1 << 16));
GPIO_HAL_SetPins(PTD,(1 << 0));
break;
case 2:
GPIO_HAL_SetPins(PTD,(1 << 15));
GPIO_HAL_SetPins(PTD,(1 << 16));
GPIO_HAL_ClearPins(PTD,(1 << 0));
color = 255;
break;
default:
GPIO_HAL_SetPins(PTD,(1 << 15));
GPIO_HAL_SetPins(PTD,(1 << 16));
GPIO_HAL_SetPins(PTD,(1 << 0));
color = 255;
break;
}
++color;
// GPIO_HAL_TogglePins(PTD, ((1 << 15) | (1 << 16)));
}
/* 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 Freescale S32K series of microcontrollers.
**
** ###################################################################
*/

Outcomes