Index: RTC.c =================================================================== diff -u -rf7c61d2d14b40cfbbd2fa8e0968a1f972a39e4e0 -r0f1d0c443daee3e30ae823711e85f3410bbf49fe --- RTC.c (.../RTC.c) (revision f7c61d2d14b40cfbbd2fa8e0968a1f972a39e4e0) +++ RTC.c (.../RTC.c) (revision 0f1d0c443daee3e30ae823711e85f3410bbf49fe) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2021 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file RTC.c * * @author (last) Sean Nash -* @date (last) 13-Aug-2020 +* @date (last) 01-Oct-2020 * * @author (original) Dara Navaei * @date (original) 11-Jan-2020 @@ -230,9 +230,8 @@ /*********************************************************************//** * @brief * The initRTC initializes the RTC module. - * @details - * Inputs: RTCSelfTestState, RTCSelfTestState - * Outputs: RTCSelfTestState, RTCSelfTestState + * @details Inputs: RTCSelfTestState, RTCSelfTestState + * @details Outputs: RTCSelfTestState, RTCSelfTestState * @return none *************************************************************************/ void initRTC( void ) @@ -245,9 +244,8 @@ * @brief * The setRTCTimestamp gets the timestamp values from caller, converts them * into BCD format and inserts them into the txBuffer to be written into the RTC. - * @details - * Inputs: RTCNewTimestampStruct, hasWriteToRTCRequested, isTimestampBufferReady - * Outputs: RTCNewTimestampStruct, hasWriteToRTCRequested, isTimestampBufferReady + * @details Inputs: RTCNewTimestampStruct, hasWriteToRTCRequested, isTimestampBufferReady + * @details Outputs: RTCNewTimestampStruct, hasWriteToRTCRequested, isTimestampBufferReady * @param secs seconds * @param mins minutes * @param hours hours @@ -303,9 +301,8 @@ /*********************************************************************//** * @brief * The execRTCSelfTest runs the RTC POST during the self-test. - * @details - * Inputs: RTCSelfTestState - * Outputs: RTCSelfTestState, alarm if invalid state was called + * @details Inputs: RTCSelfTestState + * @details Outputs: RTCSelfTestState, alarm if invalid state was called * @return RTCSelfTestResult the result of self-test *************************************************************************/ SELF_TEST_STATUS_T execRTCSelfTest( void ) @@ -360,9 +357,8 @@ /*********************************************************************//** * @brief * The execRTC function executes a signle pass of the RTC monitor state machine. - * @details - * Inputs: RTCExecState - * Outputs: RTCExecState, alarm if invalid state was called + * @details Inputs: RTCExecState + * @details Outputs: RTCExecState, alarm if invalid state was called * @return none *************************************************************************/ void execRTC( void ) @@ -419,9 +415,8 @@ /*********************************************************************//** * @brief * The getRTCTimestamp returns the current time in epoch format. - * @details - * Inputs: lastEpochTime - * Outputs: none + * @details Inputs: lastEpochTime + * @details Outputs: none * @return lastEpochTime the time in epoch as a U32 *************************************************************************/ U32 getRTCTimestamp( void ) @@ -435,10 +430,9 @@ * will check input address and length to make sure they are within the * range. If everything is fine, it will prepare the txBuffer and set the * RAM status to busy. - * @details - * Inputs: RTCRAMStatus, RTCRAMState, hasWriteToRAMRequested, RAMBufferLength, + * @details Inputs: RTCRAMStatus, RTCRAMState, hasWriteToRAMRequested, RAMBufferLength, * prepRAMBuffer, txBuffer - * Outputs: RTCRAMStatus, RTCRAMState, hasWriteToRAMRequested, RAMBufferLength, + * @details Outputs: RTCRAMStatus, RTCRAMState, hasWriteToRAMRequested, RAMBufferLength, * prepRAMBuffer, txBuffer * @param address address of the RTC RAM to write to * @param data address of the data buffer to be written to RAM @@ -490,10 +484,9 @@ * will check input address and length to make sure they are within the * range. If everything is fine, it will prepare the txBuffer and set the * RAM status to busy. - * @details - * Inputs: RTCRAMStatus, RTCRAMState, hasReadFromRAMRequested, RAMBufferLength, + * @details Inputs: RTCRAMStatus, RTCRAMState, hasReadFromRAMRequested, RAMBufferLength, * prepRAMBuffer, txBuffer - * Outputs: RTCRAMStatus, RTCRAMState, hasReadFromRAMRequested, RAMBufferLength, + * @details Outputs: RTCRAMStatus, RTCRAMState, hasReadFromRAMRequested, RAMBufferLength, * prepRAMBuffer, txBuffer * @param address address of the RTC RAM to read data from * @param length length of data to be read from RAM @@ -540,9 +533,8 @@ /*********************************************************************//** * @brief * The getRTCRAMState returns the RAM state. - * @details - * Inputs: RTCRAMState - * Outputs: none + * @details Inputs: RTCRAMState + * @details Outputs: none * @return RTC RAM state *************************************************************************/ RTC_RAM_STATE_T getRTCRAMState( void ) @@ -554,9 +546,8 @@ * @brief * The getRTCRAMStatus returns the RAM status. If the RAM status is complete * it will set the RAM status to Idle and the RAM state to Ready. - * @details - * Inputs: RTCRAMStatus, RTCRAMState - * Outputs: RTCRAMStatus, RTCRAMState + * @details Inputs: RTCRAMStatus, RTCRAMState + * @details Outputs: RTCRAMStatus, RTCRAMState * @return RTC RAM status *************************************************************************/ RTC_RAM_STATUS_T getRTCRAMStatus( void ) @@ -574,9 +565,8 @@ * @brief * The getDataFromRAM populates the provided external buffer with the data * in the specified address in the RTC RAM. - * @details - * Inputs: RAMBuffer - * Outputs: none + * @details Inputs: RAMBuffer + * @details Outputs: none * @param externalBuffer address of the external buffer to copy data into * @param length length of data to be copied into buffer * @return none @@ -610,10 +600,9 @@ * If it was not called for the first time, it will wait to the buffer * to be transmitted and then it will populate the provided receive buffer * If the transaction failed, it will try 3 time before it fails. - * @details - * Inputs : isRTCServiceOnEntry, RTCServiceState, numberOfFailedRTCTransfers, + * @details Inputs: isRTCServiceOnEntry, RTCServiceState, numberOfFailedRTCTransfers, * previousTransferLength - * Outputs: isRTCServiceOnEntry, RTCServiceState, numberOfFailedRTCTransfers, + * @details Outputs: isRTCServiceOnEntry, RTCServiceState, numberOfFailedRTCTransfers, * previousTransferLength * @return TRUE if RTC operation was successful *************************************************************************/ @@ -695,9 +684,8 @@ * The isRTCFunctional checks whether the RTC is still functional by checking * the bits in the first 3 control registers. The function ignore the clear * flags. - * @details - * Inputs: rxBuffer - * Outputs: alarm if any of the control registers are at fault + * @details Inputs: rxBuffer + * @details Outputs: alarm if any of the control registers are at fault * @return TRUE if the control registers are normal *************************************************************************/ static BOOL isRTCFunctional( void ) @@ -755,9 +743,8 @@ /*********************************************************************//** * @brief * The convertBCD2Decimal converts the BCD values to decimal. - * @details - * Inputs: none - * Outputs: none + * @details Inputs: none + * @details Outputs: none * @param bcd the number in bcd * @return number is decimal a U08 *************************************************************************/ @@ -785,9 +772,8 @@ /*********************************************************************//** * @brief * The convertDecimal2BCD converts the decimal values to BCD. - * @details - * Inputs: none - * Outputs: none + * @details Inputs: none + * @details Outputs: none * @param decimal number if decimal * @return number in bcd as a U08 *************************************************************************/ @@ -812,9 +798,8 @@ /*********************************************************************//** * @brief * The convertTime2Epoch converts the time into epoch (seconds from Jan 1 1970). - * @details - * Inputs: RTCTimestampStruct - * Outputs: none + * @details Inputs: RTCTimestampStruct + * @details Outputs: none * @return time in epoch as a U32 *************************************************************************/ static U32 convertTime2Epoch( void ) @@ -851,9 +836,8 @@ * @brief * The updateReadTimestampStruct function updates the time structure * after every read. - * @details - * Inputs: RTCTimestampStruct - * Outputs: RTCTimestampStruct + * @details Inputs: RTCTimestampStruct + * @details Outputs: RTCTimestampStruct * @return none *************************************************************************/ static void updateReadTimestampStruct( void ) @@ -871,9 +855,8 @@ * @brief * The setMibSPIBufferLength sets the MibSPI buffer length prior to every * RTC transaction. - * @details - * Inputs: none - * Outputs: none + * @details Inputs: none + * @details Outputs: none * @param length length of data transfer in bytes * @return TRUE if the buffer length was set successfully *************************************************************************/ @@ -943,9 +926,8 @@ /*********************************************************************//** * @brief * The prepBufferForReadCommand sets the txBuffer for a read. - * @details - * Inputs: txBuffer - * Outputs: txBuffer + * @details Inputs: txBuffer + * @details Outputs: txBuffer * @param length length of buffer to read * @return none *************************************************************************/ @@ -964,9 +946,8 @@ * @brief * The handleExecWaitForPostState checks whether POST has completed and what * was the result of the POST test. It will either go to Idle of Fault. - * @details - * Inputs: RTCSelfTestState - * Outputs: none + * @details Inputs: RTCSelfTestState + * @details Outputs: none * @return next state *************************************************************************/ static RTC_EXEC_STATE_T handleExecWaitForPostState( void ) @@ -986,10 +967,9 @@ * The handleExecIdleState checks whether read or write to RTC or RAM has * been requested. If none of them have been requested, it will increment the * timer. - * @details - * Inputs: nohasWriteToRTCRequested, hasWriteToRAMRequested, + * @details Inputs: nohasWriteToRTCRequested, hasWriteToRAMRequested, * hasReadFromRAMRequested, timeCounter - * Outputs: timeCounter + * @details Outputs: timeCounter * @return next state *************************************************************************/ static RTC_EXEC_STATE_T handleExecIdleState( void ) @@ -1024,10 +1004,9 @@ /*********************************************************************//** * @brief * The handleExecWriteState writes timestamp to RTC. - * @details - * Inputs: isTimestampBufferReady, txBuffer, hasWriteToRTCRequested, + * @details Inputs: isTimestampBufferReady, txBuffer, hasWriteToRTCRequested, * timeCounter, RTCServiceState - * Outputs: isTimestampBufferReady, txBuffer, hasWriteToRTCRequested, + * @details Outputs: isTimestampBufferReady, txBuffer, hasWriteToRTCRequested, * timeCounter, alarm if any RTC RAM operations occurred * @return next state *************************************************************************/ @@ -1072,10 +1051,9 @@ /*********************************************************************//** * @brief * The handleExecPrepRAMState prepares the RAM for read or write. - * @details - * Inputs: RTCServiceState, hasWriteToRAMRequested, hasReadFromRAMRequested, + * @details Inputs: RTCServiceState, hasWriteToRAMRequested, hasReadFromRAMRequested, * prepRAMBuffer, RAMBuffer - * Outputs: alarm if any RTC RAM operations error occurred + * @details Outputs: alarm if any RTC RAM operations error occurred * @return next state *************************************************************************/ static RTC_EXEC_STATE_T handleExecPrepRAMState( void ) @@ -1106,10 +1084,9 @@ /*********************************************************************//** * @brief * The handleExecWriteToRAMState writes to RAM. - * @details - * Inputs: RTCServiceState, hasWriteToRAMRequested, RTCRAMStatus, txBuffer, + * @details Inputs: RTCServiceState, hasWriteToRAMRequested, RTCRAMStatus, txBuffer, * RAMBuffer, RAMBufferLength - * Outputs: hasWriteToRAMRequested, RTCRAMStatus, alarm if any RTC RAM + * @details Outputs: hasWriteToRAMRequested, RTCRAMStatus, alarm if any RTC RAM * operations errors occurred * @return next state *************************************************************************/ @@ -1138,10 +1115,9 @@ /*********************************************************************//** * @brief * The handleExecReadFromRAMState read from RAM. - * @details - * Inputs: RTCServiceState, hasReadFromRAMRequested, RTCRAMStatus, txBuffer, + * @details Inputs: RTCServiceState, hasReadFromRAMRequested, RTCRAMStatus, txBuffer, * RAMBuffer, RAMBufferLength - * Outputs: hasReadFromRAMRequested, RTCRAMStatus, alarm if any RTC RAM + * @details Outputs: hasReadFromRAMRequested, RTCRAMStatus, alarm if any RTC RAM * operations errors occurred * @return next state *************************************************************************/ @@ -1172,9 +1148,8 @@ * The handleExecReadState reads timestamp from RTC. The function calls * other functions to update the time structure and convert the latest time * to epoch. - * @details - * Inputs: RTCServiceState, lastEpochTime, timeCounter, txBuffer, rxBuffer - * Outputs: lastEpochTime, timeCounter, alarm if any RTC operations error + * @details Inputs: RTCServiceState, lastEpochTime, timeCounter, txBuffer, rxBuffer + * @details Outputs: lastEpochTime, timeCounter, alarm if any RTC operations error * occurred * @return next state *************************************************************************/ @@ -1208,9 +1183,8 @@ * @brief * The handleSelfTestStart calls another function to prepare the txBuffer * for a read and sets the state to control registers. - * @details - * Inputs: RTCSelfTestResult - * Outputs: RTCSelfTestResult + * @details Inputs: RTCSelfTestResult + * @details Outputs: RTCSelfTestResult * @return next state *************************************************************************/ static RTC_SELF_TEST_STATE_T handleSelfTestStart( void ) @@ -1229,10 +1203,9 @@ * another function to check whether RTC is function or not. If the RTC is * functional, it will update the RTCPreviousSecond variable and sets the * state machine to the next state. - * @details - * Inputs: RTCServiceState, txBuffer, rxBuffer, RTCPreviousSecond, + * @details Inputs: RTCServiceState, txBuffer, rxBuffer, RTCPreviousSecond, * RTCSelfTestResult - * Outputs: RTCPreviousSecond, RTCSelfTestResult + * @details Outputs: RTCPreviousSecond, RTCSelfTestResult * @return next state *************************************************************************/ static RTC_SELF_TEST_STATE_T handleSelfTestCheckCtrlRegs( void ) @@ -1268,10 +1241,9 @@ * The handleSelfTestWaitForFirstSecond continuously reads the RTC and compares * latest second from RTC to the previous second and if it has changed, it will * start the timer and set the state machine to the next state. - * @details - * Inputs: RTCServiceState, txBuffer, rxBuffer, RTCCurrentSecond, RTCSelfTestTimer, + * @details Inputs: RTCServiceState, txBuffer, rxBuffer, RTCCurrentSecond, RTCSelfTestTimer, * RTCPreviousSecond - * Outputs: RTCCurrentSecond, RTCSelfTestTimer, RTCPreviousSecond + * @details Outputs: RTCCurrentSecond, RTCSelfTestTimer, RTCPreviousSecond * @return next state *************************************************************************/ static RTC_SELF_TEST_STATE_T handleSelfTestWaitForFirstSecond( void ) @@ -1313,9 +1285,8 @@ * The handleSelfTestWaitForSecondSecond continuously reads the RTC and compares * latest second from RTC to the previous second and if it has changed, it will * set the state machine to the next state. - * @details - * Inputs: RTCServiceState, txBuffer, rxBuffer, RTCCurrentSecond - * Outputs: RTCCurrentSecond + * @details Inputs: RTCServiceState, txBuffer, rxBuffer, RTCCurrentSecond + * @details Outputs: RTCCurrentSecond * @return next state *************************************************************************/ static RTC_SELF_TEST_STATE_T handleSelfTestWaitForSecondSecond( void ) @@ -1355,8 +1326,7 @@ * within the specified time tolerance. It will call another function to check * whether one second has elapsed. If the time has elapsed, how much time has * passed since the last second that was read from RTC. - * @details - * Inputs: RTCSelfTestTimer, RTCSelfTestResult + * @details Inputs: RTCSelfTestTimer, RTCSelfTestResult * Outputs : RTCSelfTestTimer, RTCSelfTestResult, alarm if RTC time accuracy * test failed * @return Next state