Index: firmware/App/Services/CommBuffers.c =================================================================== diff -u -rc74c1d99a011dd0fb7f98f183faecda675221fce -radea34db9066bdc0dbb20f49bdf66c9331a7037c --- firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision c74c1d99a011dd0fb7f98f183faecda675221fce) +++ firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision adea34db9066bdc0dbb20f49bdf66c9331a7037c) @@ -11,17 +11,17 @@ // ********** private definitions ********** -#define MAX_NUM_OF_CAN_BYTES ( SW_UPDATE_FLASH_BUFFER_SIZE + CAN_MESSAGE_PAYLOAD_SIZE ) ///< Maximum number of CAN bytes. +#define UPDATE_PACKET_SIZE_BYTES ( SW_UPDATE_FLASH_BUFFER_SIZE + CAN_MESSAGE_PAYLOAD_SIZE ) ///< Software update packet size in bytes. -// ********** private data ********** - /// Software update buffer structure typedef struct { U32 SWUpdateFrameCount; ///< Software update frame count. - U08 SWUpdateBuffer[ MAX_NUM_OF_CAN_BYTES ]; ///< Software update buffer. + U08 SWUpdateBuffer[ UPDATE_PACKET_SIZE_BYTES ]; ///< Software update buffer. } SW_UPDATE_BUFFER_T; +// ********** private data ********** + static SW_UPDATE_BUFFER_T SWUpdateBuffer[ NUM_OF_SW_UPDATE_MBOXES ]; ///< Software update buffer array. // ********** private function prototypes ******** @@ -47,7 +47,6 @@ * @brief * The addToCommBuffer function adds data of specified length to a given * communication buffer. - * @note This function will add to the active side of the double buffer. * @note This function is thread safe. IRQ interrupts are disabled during * buffer operations. * @details Inputs: SWUpdateBuffer[] @@ -67,7 +66,7 @@ U32 currentFrameCount = SWUpdateBuffer[ mailBox ].SWUpdateFrameCount; // Check if the number of bytes is less than the allowed bytes in the mailbox buffer. - if ( ( currentFrameCount * CAN_MESSAGE_PAYLOAD_SIZE ) <= MAX_NUM_OF_CAN_BYTES ) + if ( ( currentFrameCount * CAN_MESSAGE_PAYLOAD_SIZE ) <= UPDATE_PACKET_SIZE_BYTES ) { U32 currentBufferIndex = currentFrameCount * len; @@ -89,7 +88,6 @@ * The getFromCommBuffer function fills a given byte array with a specified * number of bytes from a given buffer and returns the number of bytes * retrieved from the buffer. - * @note This function will draw from the inactive side of the double buffer * and, if needed, switch double buffers to draw the rest of the requested data. * @note This function is thread safe. IRQ interrupts are disabled during buffer * operations. @@ -104,7 +102,7 @@ { BOOL status = FALSE; - if ( ( mailBox < NUM_OF_SW_UPDATE_MBOXES ) && ( len <= MAX_NUM_OF_CAN_BYTES ) ) + if ( ( mailBox < NUM_OF_SW_UPDATE_MBOXES ) && ( len <= UPDATE_PACKET_SIZE_BYTES ) ) { _disable_IRQ(); memcpy( data, SWUpdateBuffer[ mailBox ].SWUpdateBuffer, len ); @@ -118,8 +116,7 @@ /*********************************************************************//** * @brief * The getNumberOfBytesInBuffer function determines how many bytes - * are currently contained in a given comm buffer. Both sides of the - * double buffers are considered for this. + * are currently contained in a given comm buffer. * @details Inputs: SWUpdateBuffer[] * @details Outputs: none * @param mailbox ID of buffer to get byte count for