Index: Accel.c =================================================================== diff -u -rcfa1142455dbcebceda091ae61e5d1f5e889fa6e -r383eddc9d7e0487233d3a774f7d425a71c19e29a --- Accel.c (.../Accel.c) (revision cfa1142455dbcebceda091ae61e5d1f5e889fa6e) +++ Accel.c (.../Accel.c) (revision 383eddc9d7e0487233d3a774f7d425a71c19e29a) @@ -18,7 +18,8 @@ #include #include "Accel.h" -#include "FPGA.h" +#include "FPGA.h" +#include "MessageSupport.h" #include "NVDataMgmt.h" #include "SystemCommMessages.h" #include "TaskPriority.h" @@ -363,18 +364,21 @@ { // publish accelerometer data on interval if ( ++accelDataPublicationTimerCounter >= getPublishAccelDataInterval() ) - { - F32 x = accelAvgVector[ ACCEL_AXIS_X ]; - F32 y = accelAvgVector[ ACCEL_AXIS_Y ]; - F32 z = accelAvgVector[ ACCEL_AXIS_Z ]; - F32 xm = getMaxAccelAxis( ACCEL_AXIS_X ); - F32 ym = getMaxAccelAxis( ACCEL_AXIS_Y ); - F32 zm = getMaxAccelAxis( ACCEL_AXIS_Z ); - F32 xt = accelTilt[ ACCEL_AXIS_X ]; - F32 yt = accelTilt[ ACCEL_AXIS_Y ]; - F32 zt = accelTilt[ ACCEL_AXIS_Z ]; + { + ACCEL_DATA_PAYLOAD_T data; - broadcastAccelData( x, y, z, xm, ym, zm, xt, yt, zt ); + data.x = accelAvgVector[ ACCEL_AXIS_X ]; + data.y = accelAvgVector[ ACCEL_AXIS_Y ]; + data.z = accelAvgVector[ ACCEL_AXIS_Z ]; + data.xMax = getMaxAccelAxis( ACCEL_AXIS_X ); + data.yMax = getMaxAccelAxis( ACCEL_AXIS_Y ); + data.zMax = getMaxAccelAxis( ACCEL_AXIS_Z ); + data.xTilt = accelTilt[ ACCEL_AXIS_X ]; + data.yTilt = accelTilt[ ACCEL_AXIS_Y ]; + data.zTilt = accelTilt[ ACCEL_AXIS_Z ]; + + broadcastData( MSG_ID_DG_ACCELEROMETER_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( ACCEL_DATA_PAYLOAD_T ) ); + // Reset publication timer counter accelDataPublicationTimerCounter = 0; // Reset max axes Index: RTC.c =================================================================== diff -u -rf6f638e2d46b6b4581ac599e38fae339ea478750 -r383eddc9d7e0487233d3a774f7d425a71c19e29a --- RTC.c (.../RTC.c) (revision f6f638e2d46b6b4581ac599e38fae339ea478750) +++ RTC.c (.../RTC.c) (revision 383eddc9d7e0487233d3a774f7d425a71c19e29a) @@ -17,6 +17,7 @@ #include "mibspi.h" #include "FPGA.h" +#include "MessageSupport.h" #include "OperationModes.h" #include "RTC.h" #include "SystemCommMessages.h" @@ -48,7 +49,7 @@ #define RTC_REG_3_BF_MASK 0x0008 ///< Battery status interrupt flag (0x0008) #define RTC_REG_3_BLF_MASK 0x0004 ///< Battery status low flag (0x0004) -#define RTC_START_STOP_CLK_BIT_INDEX 5 ///< RTC start/stop bit index number +#define RTC_STOP_CLK_COMMAND 0x0020 ///< RTC stop clock command. // Indices used to check values read from RTC #define RTC_REG_1_INDEX 1U ///< RTC control register 1 index @@ -232,7 +233,7 @@ static BOOL isRTCFunctional( void ); static U08 convertBCD2Decimal( U08 bcd ); static U08 convertDecimal2BCD( U08 decimal ); -static U32 convertDateTime2Epoch( RTC_TIMESTAMP_T dateTime ); +static U32 convertDateTime2Epoch( RTC_TIMESTAMP_T dateTime ); static BOOL convertEpoch2DateTime( U32 epoch ); #ifdef USE_LIBRARY_TIME_FUNCTIONS static U32 convertTime2Epoch( void ); @@ -312,8 +313,8 @@ } else { - hasWriteToRTCRequested = TRUE; - isTimestampBufferReady = FALSE; + hasWriteToRTCRequested = TRUE; + isTimestampBufferReady = FALSE; RTCNewTimestampStruct.seconds = secs; RTCNewTimestampStruct.minutes = mins; RTCNewTimestampStruct.hours = hours; @@ -1320,14 +1321,18 @@ { if ( isRTCFunctional() ) { + RTC_DATA_T data; + updateReadTimestampStruct(); #ifndef USE_LIBRARY_TIME_FUNCTIONS lastEpochTime = convertDateTime2Epoch( RTCTimestampStruct ); #else lastEpochTime = convertTime2Epoch(); #endif timeCounter = 1; - broadcastRTCEpoch( lastEpochTime ); + data.epochTime = lastEpochTime; + + broadcastData( MSG_ID_RTC_EPOCH, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( RTC_DATA_T ) ); } result = RTC_EXEC_STATE_IDLE; @@ -1502,18 +1507,16 @@ if ( TRUE == isTestingActivated() ) { - // Get the first register - U16 stopClockRegister = rxBuffer[ RTC_REG_1_INDEX ] & MASK_OFF_MSB; - // Set the 5th bit which is the clock run to 1 to be stopped - stopClockRegister = ( 1 << RTC_START_STOP_CLK_BIT_INDEX ) | 1; // Set write request so the exec state machine will set it hasWriteToRTCRequested = TRUE; isTimestampBufferReady = TRUE; // Set the latest time stamp to be written to the RTC since the stop command must be written // to RTC anyways txBuffer[ 0 ] = RTC_WRITE_TO_REG0; - txBuffer[ 1 ] = stopClockRegister; + // Read the RX buffer and get the first register. Mask off the MSB and or it with 0x0020 to set the + // start stop RTC bit to a 1 to stop the RTC clock. + txBuffer[ 1 ] = ( rxBuffer[ RTC_REG_1_INDEX ] & MASK_OFF_MSB ) | RTC_STOP_CLK_COMMAND; txBuffer[ 2 ] = 0x0000; txBuffer[ 3 ] = 0x0000; txBuffer[ 4 ] = convertDecimal2BCD( RTCNewTimestampStruct.seconds ); Index: RTC.h =================================================================== diff -u -rf6f638e2d46b6b4581ac599e38fae339ea478750 -r383eddc9d7e0487233d3a774f7d425a71c19e29a --- RTC.h (.../RTC.h) (revision f6f638e2d46b6b4581ac599e38fae339ea478750) +++ RTC.h (.../RTC.h) (revision 383eddc9d7e0487233d3a774f7d425a71c19e29a) @@ -29,6 +29,8 @@ * @{ */ +// ********** public definitions ********** + /// RTC RAM status enumeration. typedef enum RTC_RAM_STATUS { @@ -49,6 +51,14 @@ } RTC_RAM_STATE_T; +/// Real time clock data structure +typedef struct +{ + U32 epochTime; ///< Epoch time +} RTC_DATA_T; + +// ********** public function prototypes ********** + void initRTC( void ); void execRTC( void );