diff --git a/modules/time/fsw/inc/cfe_time_internal_cfg.h b/modules/time/fsw/inc/cfe_time_internal_cfg.h index 27c4efe66..4ada83b76 100644 --- a/modules/time/fsw/inc/cfe_time_internal_cfg.h +++ b/modules/time/fsw/inc/cfe_time_internal_cfg.h @@ -55,6 +55,26 @@ #define CFE_PLATFORM_TIME_CFG_CLIENT CFE_PLATFORM_TIME_CFGVAL(CFG_CLIENT) #define DEFAULT_CFE_PLATFORM_TIME_CFG_CLIENT false +/** +** \cfetimecfg Disable Local 1Hz task +** +** \par Description: +** This configuration parameter selects whether the Time task creates a +** local 1hz task to drive the 1hz state machine, or if it relies +** on an external app like the cFS Scheduler to send the 1hz state +** machine packet. This option can support specific Time mission use +** cases. +** +** \par Limits +** If set to false, the Time module will create the OSAL timer and local +** 1Hz task that drives the Time 1Hz state machine (default). +** If set to true, the Time module will exclude the OSAL timer, local 1Hz ISR +** (callback) and the Local 1Hz task. An external source such as the scheduler +** will have to send the packet to drive the 1hz state machine. +*/ +#define CFE_PLATFORM_TIME_CFG_DISABLE_LOCAL_1HZ CFE_PLATFORM_TIME_CFGVAL(CFG_DISABLE_LOCAL_1HZ) +#define DEFAULT_CFE_PLATFORM_TIME_CFG_DISABLE_LOCAL_1HZ false + /** ** \cfetimecfg Local MET or Virtual MET Selection for Time Servers ** diff --git a/modules/time/fsw/src/cfe_time_task.c b/modules/time/fsw/src/cfe_time_task.c index 20a249290..97431d9d8 100644 --- a/modules/time/fsw/src/cfe_time_task.c +++ b/modules/time/fsw/src/cfe_time_task.c @@ -162,16 +162,6 @@ static int32 CFE_TIME_TaskInit_CreateResources(const char *LogFunction) return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } - OsStatus = OS_BinSemCreate(&CFE_TIME_Global.LocalSemaphore, - CFE_TIME_SEM_ONEHZ_NAME, - CFE_TIME_SEM_VALUE, - CFE_TIME_SEM_OPTIONS); - if (OsStatus != OS_SUCCESS) - { - CFE_ES_WriteToSysLog("%s: Error creating local semaphore:RC=%ld\n", LogFunction, (long)OsStatus); - return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; - } - Status = CFE_ES_CreateChildTask(&CFE_TIME_Global.ToneTaskID, CFE_TIME_TASK_TONE_NAME, CFE_TIME_Tone1HzTask, @@ -185,6 +175,17 @@ static int32 CFE_TIME_TaskInit_CreateResources(const char *LogFunction) return Status; } +#if (CFE_PLATFORM_TIME_CFG_DISABLE_LOCAL_1HZ == false) + OsStatus = OS_BinSemCreate(&CFE_TIME_Global.LocalSemaphore, + CFE_TIME_SEM_ONEHZ_NAME, + CFE_TIME_SEM_VALUE, + CFE_TIME_SEM_OPTIONS); + if (OsStatus != OS_SUCCESS) + { + CFE_ES_WriteToSysLog("%s: Error creating local semaphore:RC=%ld\n", LogFunction, (long)OsStatus); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } + Status = CFE_ES_CreateChildTask(&CFE_TIME_Global.LocalTaskID, CFE_TIME_TASK_ONEHZ_NAME, CFE_TIME_Local1HzTask, @@ -197,6 +198,7 @@ static int32 CFE_TIME_TaskInit_CreateResources(const char *LogFunction) CFE_ES_WriteToSysLog("%s: Error creating local 1Hz child task:RC=0x%08X\n", LogFunction, (unsigned int)Status); return Status; } +#endif return CFE_SUCCESS; } @@ -314,6 +316,7 @@ static int32 CFE_TIME_TaskInit_SendInitEvent(const char *LogFunction) return CFE_SUCCESS; } +#if (CFE_PLATFORM_TIME_CFG_DISABLE_LOCAL_1HZ == false) /*---------------------------------------------------------------- * * Local helper function @@ -353,6 +356,7 @@ static void CFE_TIME_TaskInit_Setup1HzTimer(const char *LogFunction) CFE_ES_WriteToSysLog("%s: 1Hz OS_TimerSet failed:RC=%ld\n", LogFunction, (long)OsStatus); } } +#endif /*---------------------------------------------------------------- * @@ -389,7 +393,9 @@ int32 CFE_TIME_TaskInit(void) OS_SelectTone(CFE_TIME_Global.ClockSignal); #endif +#if (CFE_PLATFORM_TIME_CFG_DISABLE_LOCAL_1HZ == false) CFE_TIME_TaskInit_Setup1HzTimer(__func__); +#endif return CFE_SUCCESS; } diff --git a/modules/time/fsw/src/cfe_time_tone.c b/modules/time/fsw/src/cfe_time_tone.c index 12b96d4fe..247281c28 100644 --- a/modules/time/fsw/src/cfe_time_tone.c +++ b/modules/time/fsw/src/cfe_time_tone.c @@ -943,17 +943,6 @@ void CFE_TIME_ToneUpdate(void) } } -/*---------------------------------------------------------------- - * - * Application-scope internal function - * See description in header file for argument/return detail - * - *-----------------------------------------------------------------*/ -void CFE_TIME_Local1HzTimerCallback(osal_id_t TimerId, void *Arg) -{ - CFE_TIME_Local1HzISR(); -} - /*---------------------------------------------------------------- * * Application-scope internal function @@ -1130,6 +1119,15 @@ void CFE_TIME_Local1HzStateMachine(void) /* Start Performance Monitoring */ CFE_ES_PerfLogEntry(CFE_MISSION_TIME_LOCAL1HZISR_PERF_ID); + /* + ** Send "info" event if we just started flywheel mode... + */ + if (CFE_TIME_Global.AutoStartFly) + { + CFE_TIME_Global.AutoStartFly = false; + CFE_EVS_SendEvent(CFE_TIME_FLY_ON_EID, CFE_EVS_EventType_INFORMATION, "Start FLYWHEEL"); + } + /* Zero out the Reference variable because we pass it into * a function before using it * */ @@ -1241,10 +1239,24 @@ void CFE_TIME_Local1HzISR(void) { CFE_TIME_Global.LocalIntCounter++; +#if (CFE_PLATFORM_TIME_CFG_DISABLE_LOCAL_1HZ == false) /* ** Enable 1Hz task (we can't send a SB message from here)... */ OS_BinSemGive(CFE_TIME_Global.LocalSemaphore); +#endif +} + +#if (CFE_PLATFORM_TIME_CFG_DISABLE_LOCAL_1HZ == false) +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in header file for argument/return detail + * + *-----------------------------------------------------------------*/ +void CFE_TIME_Local1HzTimerCallback(osal_id_t TimerId, void *Arg) +{ + CFE_TIME_Local1HzISR(); } /*---------------------------------------------------------------- @@ -1274,16 +1286,6 @@ void CFE_TIME_Local1HzTask(void) /* Start Performance Monitoring */ CFE_ES_PerfLogEntry(CFE_MISSION_TIME_LOCAL1HZTASK_PERF_ID); - /* - ** Send "info" event if we just started flywheel mode... - */ - if (CFE_TIME_Global.AutoStartFly) - { - CFE_TIME_Global.AutoStartFly = false; - - CFE_EVS_SendEvent(CFE_TIME_FLY_ON_EID, CFE_EVS_EventType_INFORMATION, "Start FLYWHEEL"); - } - /* ** Send 1Hz timing packet... ** This used to be optional in previous CFE versions, but it is now required @@ -1302,6 +1304,7 @@ void CFE_TIME_Local1HzTask(void) ** error in the creation of the semaphore. */ } +#endif /*---------------------------------------------------------------- * diff --git a/modules/time/ut-coverage/time_UT.c b/modules/time/ut-coverage/time_UT.c index 40e9c94d1..e75db5ee7 100644 --- a/modules/time/ut-coverage/time_UT.c +++ b/modules/time/ut-coverage/time_UT.c @@ -2378,7 +2378,9 @@ void Test_Tone(void) */ void Test_1Hz(void) { - uint16 Arg; +#if (CFE_PLATFORM_TIME_CFG_DISABLE_LOCAL_1HZ == false) + uint16 Arg; +#endif uint16 i; uint32 delSec = 3; CFE_TIME_SysTime_t time1; @@ -2490,6 +2492,7 @@ void Test_1Hz(void) CFE_TIME_Tone1HzISR(); UtAssert_INT32_EQ(ut_time_CallbackCalled, 3); +#if (CFE_PLATFORM_TIME_CFG_DISABLE_LOCAL_1HZ == false) /* Test the local 1Hz ISR */ UT_InitData(); CFE_TIME_Global.LocalIntCounter = 1; @@ -2506,6 +2509,7 @@ void Test_1Hz(void) UT_SetDeferredRetcode(UT_KEY(OS_BinSemTake), 2, OS_ERROR); CFE_TIME_Local1HzTask(); UtAssert_UINT32_EQ(CFE_TIME_Global.LocalTaskCounter, 1); +#endif /* Test the tone 1Hz task where the binary semaphore take fails on the * second call @@ -2545,6 +2549,7 @@ void Test_1Hz(void) CFE_TIME_Tone1HzISR(); UtAssert_BOOL_FALSE(CFE_TIME_Global.IsToneGood); +#if (CFE_PLATFORM_TIME_CFG_DISABLE_LOCAL_1HZ == false) /* Test local 1Hz interrupt when enough time has elapsed (subseconds) since * receiving a time update to automatically change the state to flywheel */ @@ -2576,6 +2581,7 @@ void Test_1Hz(void) UtAssert_INT32_EQ(RefState->ClockFlyState, CFE_TIME_FlywheelState_NO_FLY); /* Test the local 1Hz task where auto start flywheel is disabled */ + /* APC - need to relocate this test */ UT_InitData(); CFE_TIME_Global.LocalTaskCounter = 0; CFE_TIME_Global.AutoStartFly = false; @@ -2596,6 +2602,7 @@ void Test_1Hz(void) UT_SetBSP_Time(0, 0); CFE_TIME_Local1HzTimerCallback(OS_ObjectIdFromInteger(123), &Arg); UtAssert_UINT32_EQ(CFE_TIME_Global.LocalIntCounter, 2); +#endif } /*