Index: source/sys_main.c =================================================================== diff -u -r29f1ba03faefd982327916590818a260a3e4aa48 -r8ba82119080b77f804fa2b3edadd11422f57371b --- source/sys_main.c (.../sys_main.c) (revision 29f1ba03faefd982327916590818a260a3e4aa48) +++ source/sys_main.c (.../sys_main.c) (revision 8ba82119080b77f804fa2b3edadd11422f57371b) @@ -57,6 +57,8 @@ #include "rti.h" #include "Common.h" +#include "AlarmLamp.h" +#include "Buttons.h" #include "CommBuffers.h" #include "CPLD.h" #include "MsgQueues.h" @@ -65,7 +67,9 @@ #include "SystemComm.h" #include "TaskBG.h" #include "Timers.h" +#include "WatchdogMgmt.h" +static void initProcessor( void ); static void initSoftware( void ); static void initHardware( void ); static void initTasks( void ); @@ -86,12 +90,15 @@ { /* USER CODE BEGIN (3) */ - initHardware(); - initSoftware(); - initTasks(); + initProcessor(); // configure processor + initSoftware(); // initialize software modules + initHardware(); // configure external hardware + initTasks(); // setup and start the scheduled tasks - // start task background (will no return) + // start task background (will not return) +#ifndef _VECTORCAST_ taskBackground(); +#endif /* USER CODE END */ @@ -101,31 +108,90 @@ /* USER CODE BEGIN (4) */ +/************************************************************************* + * @brief initProcessor + * The initProcessor function initializes and configures the processor \n + * peripherals. + * @details + * Inputs : none + * Outputs : Processor peripherals initialized and configured. + * @return none + *************************************************************************/ +static void initProcessor( void ) +{ + gioInit(); // configure GPIO pins + mibspiInit(); // re-purposing MIBSPI5 I/O/C pins as GPIO + canInit(); // CAN1 = CAN, re-purposing CAN2 and CAN3 Rx and Tx pins as GPIO +} + +/************************************************************************* + * @brief initSoftware + * The initSoftware function calls all software module initialize functions. + * @details + * Inputs : none + * Outputs : All modules initialized. + * @return none + *************************************************************************/ static void initSoftware( void ) { initTimers(); initSafetyShutdown(); initCPLD(); initOperationModes(); + initAlarmLamp(); + initButtons(); + initWatchdogMgmt(); initCommBuffers(); initMsgQueues(); initSystemComm(); } +/************************************************************************* + * @brief initHardware + * The initHardware function initializes and configures external hardware. + * @details + * Inputs : none + * Outputs : External hardware initialized and configured. + * @return none + *************************************************************************/ static void initHardware( void ) { - gioInit(); - mibspiInit(); // re-purposing MIBSPI5 I/O/C pins as GPIO - canInit(); // CAN1 = CAN, re-purposing CAN2 and CAN3 Rx and Tx pins as GPIO } +/************************************************************************* + * @brief initTasks + * The initTasks function sets up and starts the scheduled tasks. + * @details + * Inputs : none + * Outputs : Scheduled tasks set up and started. + * @return none + *************************************************************************/ static void initTasks( void ) { + // initialize RTI to setup the 3 tasks rtiInit(); rtiEnableNotification( rtiNOTIFICATION_COMPARE0 | rtiNOTIFICATION_COMPARE1 | rtiNOTIFICATION_COMPARE3 ); rtiStartCounter( rtiCOUNTER_BLOCK0 ); + // the timer task (and other comm related interrupts) require FIQ enabled _enable_FIQ(); + // the general and priority tasks require IRQ enabled _enable_IRQ(); } +/************************************************************************* + * @brief canMessageNotification + * The canMessageNotification function handles CAN message notifications. + * @details + * Inputs : none + * Outputs : CAN message notification handled. + * @param node : which CAN controller + * @param messageBox : which message box triggered the message notification + * @return none + *************************************************************************/ +void canMessageNotification(canBASE_t *node, uint32 messageBox) +{ + handleCANMsgInterrupt( (CAN_MESSAGE_BOX_T)messageBox ); +} + + /* USER CODE END */