sbgECom Library  4.0.1987-stable
C library to interface SBG Systems IMU/AHRS/INS
sbgSplitBuffer.h File Reference

Helper methods used to handle a splittable buffer. More...

#include <sbgCommon.h>

Go to the source code of this file.

Data Structures

struct  _SbgSplitBuffer
 

Typedefs

typedef struct _SbgSplitBuffer SbgSplitBuffer
 

Functions

SBG_INLINE void sbgSplitBufferInitForRead (SbgSplitBuffer *pSplitBuffer, const void *pBuffer, size_t bufferSize, size_t subBufferSize)
 
SBG_INLINE void sbgSplitBufferInitForWrite (SbgSplitBuffer *pSplitBuffer, void *pBuffer, size_t bufferSize, size_t subBufferSize)
 
SBG_INLINE size_t sbgSplitBufferGetSubBufferNbr (const SbgSplitBuffer *pSplitBuffer)
 
SBG_INLINE void * sbgSplitBufferGetSubBuffer (const SbgSplitBuffer *pSplitBuffer, size_t subBufferIdx)
 
SBG_INLINE size_t sbgSplitBufferGetSubBufferOffset (const SbgSplitBuffer *pSplitBuffer, size_t subBufferIdx)
 
SBG_INLINE size_t sbgSplitBufferGetSubBufferSize (const SbgSplitBuffer *pSplitBuffer, size_t subBufferIdx)
 

Detailed Description

Helper methods used to handle a splittable buffer.

Author
SBG Systems
Date
19 November 2013
License

The MIT license

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Typedef Documentation

◆ SbgSplitBuffer

Defines the ECom transfer states

Function Documentation

◆ sbgSplitBufferInitForRead()

SBG_INLINE void sbgSplitBufferInitForRead ( SbgSplitBuffer pSplitBuffer,
const void *  pBuffer,
size_t  bufferSize,
size_t  subBufferSize 
)

Initialize a split buffer for read operations.

Parameters
[in]pSplitBufferPointer to an allocated split buffer instance.
[in]pBufferThe buffer that needs to be split (doesn't take the ownership).
[in]bufferSizeThe total size of the buffer in bytes.
[in]subBufferSizeThe size of each sub buffer in bytes.

References _SbgSplitBuffer::linkedBufferSize, _SbgSplitBuffer::pLinkedBuffer, _SbgSplitBuffer::subBufferNbr, and _SbgSplitBuffer::subBufferSize.

◆ sbgSplitBufferInitForWrite()

SBG_INLINE void sbgSplitBufferInitForWrite ( SbgSplitBuffer pSplitBuffer,
void *  pBuffer,
size_t  bufferSize,
size_t  subBufferSize 
)

Initialize a split buffer for write operations.

Parameters
[in]pSplitBufferPointer to an allocated split buffer instance.
[in]pBufferThe buffer that needs to be split (doesn't take the ownership).
[in]bufferSizeThe total size of the buffer in bytes.
[in]subBufferSizeThe size of each sub buffer in bytes.

References _SbgSplitBuffer::linkedBufferSize, _SbgSplitBuffer::pLinkedBuffer, _SbgSplitBuffer::subBufferNbr, and _SbgSplitBuffer::subBufferSize.

◆ sbgSplitBufferGetSubBufferNbr()

SBG_INLINE size_t sbgSplitBufferGetSubBufferNbr ( const SbgSplitBuffer pSplitBuffer)

Returns the number of sub buffers that compose the whole buffer.

Parameters
[in]pSplitBufferValid pointer to a Split Buffer instance.
Returns
The number of sub buffer the buffer has or 0 if there is an error.

References _SbgSplitBuffer::subBufferNbr.

◆ sbgSplitBufferGetSubBuffer()

SBG_INLINE void* sbgSplitBufferGetSubBuffer ( const SbgSplitBuffer pSplitBuffer,
size_t  subBufferIdx 
)

Get one sub buffer given its index.

Parameters
[in]pSplitBufferValid pointer to a Split Buffer instance.
[in]subBufferIdxIndex of the sub buffer required.
Returns
Pointer to the sub buffer or NULL if the subBuffer index is invalid.

References _SbgSplitBuffer::pLinkedBuffer, and _SbgSplitBuffer::subBufferSize.

◆ sbgSplitBufferGetSubBufferOffset()

SBG_INLINE size_t sbgSplitBufferGetSubBufferOffset ( const SbgSplitBuffer pSplitBuffer,
size_t  subBufferIdx 
)

Return the offset in bytes of a sub buffer from the start of the buffer.

Parameters
[in]pSplitBufferValid pointer to a Split Buffer instance.
[in]subBufferIdxIndex of the sub buffer required.
Returns
Offset to the sub buffer or 0 if the subBuffer index is invalid.

References _SbgSplitBuffer::subBufferSize.

◆ sbgSplitBufferGetSubBufferSize()

SBG_INLINE size_t sbgSplitBufferGetSubBufferSize ( const SbgSplitBuffer pSplitBuffer,
size_t  subBufferIdx 
)

Get the size of a sub buffer given its index.

Parameters
[in]pSplitBufferValid pointer to a Split Buffer instance.
[in]subBufferIdxIndex of the sub buffer required.
Returns
The size of the sub buffer of index subBufferIdx, or 0 if the subBuffer index is invalid.

References _SbgSplitBuffer::linkedBufferSize, _SbgSplitBuffer::subBufferNbr, and _SbgSplitBuffer::subBufferSize.