Index: App/Common.h =================================================================== diff -u -r29f1ba03faefd982327916590818a260a3e4aa48 -r8ba82119080b77f804fa2b3edadd11422f57371b --- App/Common.h (.../Common.h) (revision 29f1ba03faefd982327916590818a260a3e4aa48) +++ App/Common.h (.../Common.h) (revision 8ba82119080b77f804fa2b3edadd11422f57371b) @@ -21,8 +21,10 @@ // ********** build switches ********** -#define RM46_EVAL_BOARD_TARGET 1 -#define SIMULATE_UI 1 +#ifndef _VECTORCAST_ + #define RM46_EVAL_BOARD_TARGET 1 + #define SIMULATE_UI 1 +#endif // ********** public definitions ********** @@ -66,7 +68,15 @@ // **** VectorCAST Definitions **** #ifdef _VECTORCAST_ -#define _enable_IRQ() + + #define _enable_IRQ() + #define _disable_IRQ() + #define _enable_FIQ() +#pragma WEAK(can1LowLevelInterrupt) + void can1LowLevelInterrupt(void) {} +#pragma WEAK(can1HighLevelInterrupt) + void can1HighLevelInterrupt(void) {} + #endif #endif Index: App/Drivers/CPLD.c =================================================================== diff -u -r29f1ba03faefd982327916590818a260a3e4aa48 -r8ba82119080b77f804fa2b3edadd11422f57371b --- App/Drivers/CPLD.c (.../CPLD.c) (revision 29f1ba03faefd982327916590818a260a3e4aa48) +++ App/Drivers/CPLD.c (.../CPLD.c) (revision 8ba82119080b77f804fa2b3edadd11422f57371b) @@ -102,11 +102,6 @@ CLR_GREEN(); CLR_RED(); CLR_BLUE(); - - // initialize the associated s/w modules - initAlarmLamp(); - initButtons(); - initWatchdogMgmt(); } /************************************************************************* Index: App/Drivers/CPLD.h =================================================================== diff -u -r29f1ba03faefd982327916590818a260a3e4aa48 -r8ba82119080b77f804fa2b3edadd11422f57371b --- App/Drivers/CPLD.h (.../CPLD.h) (revision 29f1ba03faefd982327916590818a260a3e4aa48) +++ App/Drivers/CPLD.h (.../CPLD.h) (revision 8ba82119080b77f804fa2b3edadd11422f57371b) @@ -10,7 +10,7 @@ * @date 20-Sep-2019 * @author S. Nash * - * @brief header file for CPLD driver . + * @brief header file for CPLD driver. * **************************************************************************/ Index: App/Services/CommBuffers.c =================================================================== diff -u -ra87b6b9e253c6c0fcc84bca6f5de71959ce18bcc -r8ba82119080b77f804fa2b3edadd11422f57371b --- App/Services/CommBuffers.c (.../CommBuffers.c) (revision a87b6b9e253c6c0fcc84bca6f5de71959ce18bcc) +++ App/Services/CommBuffers.c (.../CommBuffers.c) (revision 8ba82119080b77f804fa2b3edadd11422f57371b) @@ -56,7 +56,7 @@ for ( b = 0; b < NUM_OF_COMM_BUFFERS; b++ ) { activeDoubleBuffer[b] = 0; - for ( d = 0; d < 2; d++ ) + for ( d = 0; d < DOUBLE_BUFFERS; d++ ) { commBufferByteCount[b][d] = 0; for ( i = 0; i < COMM_BUFFER_LENGTH; i++ ) Index: App/Services/Timers.c =================================================================== diff -u -r9aec79f151c686b730888c98f70f53ad958fe9b5 -r8ba82119080b77f804fa2b3edadd11422f57371b --- App/Services/Timers.c (.../Timers.c) (revision 9aec79f151c686b730888c98f70f53ad958fe9b5) +++ App/Services/Timers.c (.../Timers.c) (revision 8ba82119080b77f804fa2b3edadd11422f57371b) @@ -14,7 +14,6 @@ * **************************************************************************/ -#include "Common.h" #include "Timers.h" // ********** private definitions ********** Index: App/Services/WatchdogMgmt.c =================================================================== diff -u -r29f1ba03faefd982327916590818a260a3e4aa48 -r8ba82119080b77f804fa2b3edadd11422f57371b --- App/Services/WatchdogMgmt.c (.../WatchdogMgmt.c) (revision 29f1ba03faefd982327916590818a260a3e4aa48) +++ App/Services/WatchdogMgmt.c (.../WatchdogMgmt.c) (revision 8ba82119080b77f804fa2b3edadd11422f57371b) @@ -60,7 +60,7 @@ void initWatchdogMgmt( void ) { watchdogExpired = FALSE; - lastWatchdogPetTime = getMSTimerCount(); + lastWatchdogPetTime = 0; watchdogSelfTestState = WATCHDOG_SELF_TEST_STATE_START; watchdogSelfTestTimerCount = 0; resetWDTaskCheckIns(); Index: App/Tasks/TaskGeneral.c =================================================================== diff -u -ra87b6b9e253c6c0fcc84bca6f5de71959ce18bcc -r8ba82119080b77f804fa2b3edadd11422f57371b --- App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision a87b6b9e253c6c0fcc84bca6f5de71959ce18bcc) +++ App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 8ba82119080b77f804fa2b3edadd11422f57371b) @@ -43,6 +43,18 @@ *************************************************************************/ void taskGeneral( void ) { + // check in with watchdog manager + checkInWithWatchdogMgmt( TASK_GENERAL ); // do this first to keep timing consistent with watchdog management + + // manage data received from other sub-systems + execSystemCommRx(); + + // run operation mode state machine + execOperationModes(); + + // control alarm lamp + execAlarmLamp(); + #ifdef RM46_EVAL_BOARD_TARGET if ( getUserButtonState() == PIN_SIGNAL_LOW ) { @@ -59,18 +71,6 @@ } #endif - // check in with watchdog manager - checkInWithWatchdogMgmt( TASK_GENERAL ); // do this first to keep timing consistent with watchdog management - - // manage data received from other sub-systems - execSystemCommRx(); - - // run operation mode state machine - execOperationModes(); - - // control alarm lamp - execAlarmLamp(); - // manage data to be transmitted to other sub-systems execSystemCommTx(); Index: source/notification.c =================================================================== diff -u -r29f1ba03faefd982327916590818a260a3e4aa48 -r8ba82119080b77f804fa2b3edadd11422f57371b --- source/notification.c (.../notification.c) (revision 29f1ba03faefd982327916590818a260a3e4aa48) +++ source/notification.c (.../notification.c) (revision 8ba82119080b77f804fa2b3edadd11422f57371b) @@ -59,7 +59,6 @@ #include "sys_dma.h" /* USER CODE BEGIN (0) */ -#include "SystemComm.h" /* USER CODE END */ #pragma WEAK(esmGroup1Notification) void esmGroup1Notification(uint32 channel) @@ -132,7 +131,6 @@ { /* enter user code between the USER CODE BEGIN and USER CODE END. */ /* USER CODE BEGIN (15) */ - handleCANMsgInterrupt( (CAN_MESSAGE_BOX_T)messageBox ); /* USER CODE END */ } 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 */