Index: RTC.c =================================================================== diff -u -r9994d19d718b4a64426a4dd93b5a33fa55e5e2c4 -r6f87c4d6e2c23308af2524cea6aed41e679ca000 --- RTC.c (.../RTC.c) (revision 9994d19d718b4a64426a4dd93b5a33fa55e5e2c4) +++ RTC.c (.../RTC.c) (revision 6f87c4d6e2c23308af2524cea6aed41e679ca000) @@ -178,37 +178,31 @@ // ********** private data ********** -static RTC_SELF_TEST_STATE_T RTCSelfTestState = RTC_SELF_TEST_STATE_START; ///< Self test variable. -static RTC_GET_DATA_STATE_T RTCServiceState = RTC_SEND_COMMAND; ///< RTC get data variable. -static RTC_EXEC_STATE_T RTCExecState = RTC_EXEC_STATE_WAIT_FOR_POST; ///< RTC exec state variable. -static SELF_TEST_STATUS_T RTCSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; ///< RTC self-test status variable. -static RTC_RAM_STATUS_T RTCRAMStatus = RTC_RAM_STATUS_IDLE; ///< RTC RAM status variable. -static RTC_RAM_STATE_T RTCRAMState = RTC_RAM_STATE_READY; ///< RTC RAM state. +static RTC_SELF_TEST_STATE_T RTCSelfTestState; ///< Self test variable. +static RTC_GET_DATA_STATE_T RTCServiceState; ///< RTC get data variable. +static RTC_EXEC_STATE_T RTCExecState; ///< RTC exec state variable. +static SELF_TEST_STATUS_T RTCSelfTestResult; ///< RTC self-test status variable. +static RTC_RAM_STATUS_T RTCRAMStatus; ///< RTC RAM status variable. +static RTC_RAM_STATE_T RTCRAMState; ///< RTC RAM state. static RTC_TIMESTAMP_T RTCTimestampStruct; ///< Timestamp record - last read from RTC. static RTC_TIMESTAMP_T RTCNewTimestampStruct; ///< New timestamp record that will hold the new time to be written to RTC. - -static U32 RTCSelfTestTimer = 0; ///< Self test timer. -static U32 RTCPreviousSecond = 0; ///< Previous second for self-test comparison. -static U32 RAMBufferLength = 0; ///< RAM buffer length for RAM operations. -static U32 lastEpochTime = 0; ///< Last epoch time. -static U32 previousTransferLength = 0; ///< Previous transfer length. - -static U32 timeCounter = 1; ///< Initial time counter (1). -static U32 numberOfFailedRTCTransfers = 1; ///< Initial number of failed RTC transactions (1). - -static BOOL hasWriteToRTCRequested = FALSE; ///< Flag to request RTC write. -static BOOL hasWriteToRAMRequested = FALSE; ///< Flag to write to RTC RAM. -static BOOL hasReadFromRAMRequested = FALSE; ///< Flag to read from RTC RAM. -static BOOL isRTCServiceOnEntry = FALSE; ///< Flag to check if service is on entry. -static BOOL isTimestampBufferReady = FALSE; ///< Flag to check if the timestamp buffer is ready. - +static U32 RTCSelfTestTimer; ///< Self test timer. +static U32 RTCPreviousSecond; ///< Previous second for self-test comparison. +static U32 RAMBufferLength; ///< RAM buffer length for RAM operations. +static U32 lastEpochTime; ///< Last epoch time. +static U32 previousTransferLength; ///< Previous transfer length. +static U32 timeCounter; ///< Initial time counter (1). +static U32 numberOfFailedRTCTransfers; ///< Initial number of failed RTC transactions (1). +static BOOL hasWriteToRTCRequested; ///< Flag to request RTC write. +static BOOL hasWriteToRAMRequested; ///< Flag to write to RTC RAM. +static BOOL hasReadFromRAMRequested; ///< Flag to read from RTC RAM. +static BOOL isRTCServiceOnEntry; ///< Flag to check if service is on entry. +static BOOL isTimestampBufferReady; ///< Flag to check if the timestamp buffer is ready. static U16 rxBuffer[ MIBSPI_MAX_BUFFER_LENGTH + 1 ]; ///< Buffer to receive data from RTC. static U16 txBuffer[ MIBSPI_MAX_BUFFER_LENGTH + 1 ]; ///< Buffer to transmit data to RTC. - static U16 prepRAMBuffer[ RTC_RAM_PREP_BUFFER_LENGTH ]; ///< Buffer to send prep read/write commands to RTC RAM. static U16 RAMBuffer[ MIBSPI_MAX_BUFFER_LENGTH ]; ///< Buffer to read RTC RAM data. - -static U16 previousFPGATimerCount = 0; ///< Previous FPGA timer count; +static U16 previousFPGATimerCount; ///< Previous FPGA timer count; /// Array of days in each month. Assumes non-leap year. Must adjust days in February if leap year. static U32 daysInMonth[ 12 ] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; @@ -246,8 +240,25 @@ *************************************************************************/ void initRTC( void ) { - RTCSelfTestState = RTC_SELF_TEST_STATE_START; - RTCServiceState = RTC_SEND_COMMAND; + RTCSelfTestState = RTC_SELF_TEST_STATE_START; + RTCServiceState = RTC_SEND_COMMAND; + RTCExecState = RTC_EXEC_STATE_WAIT_FOR_POST; + RTCSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; + RTCRAMStatus = RTC_RAM_STATUS_IDLE; + RTCRAMState = RTC_RAM_STATE_READY; + RTCSelfTestTimer = 0; + RTCPreviousSecond = 0; + RAMBufferLength = 0; + lastEpochTime = 0; + previousTransferLength = 0; + timeCounter = 1; + numberOfFailedRTCTransfers = 1; + hasWriteToRTCRequested = FALSE; + hasWriteToRAMRequested = FALSE; + hasReadFromRAMRequested = FALSE; + isRTCServiceOnEntry = FALSE; + isTimestampBufferReady = FALSE; + previousFPGATimerCount = 0; } /*********************************************************************//** @@ -1321,8 +1332,8 @@ if ( TRUE == isRTCFunctional() ) { U32 RTCCurrentSecond = rxBuffer[ RTC_SECONDS_INDEX ]; - RTCPreviousSecond = RTCCurrentSecond; - result = RTC_SELF_TEST_STATE_WAIT_FOR_FIRST_SECOND; + RTCPreviousSecond = RTCCurrentSecond; + result = RTC_SELF_TEST_STATE_WAIT_FOR_FIRST_SECOND; } else {