This program module is for create your data buffer.
- Buffer_Init()
- Save_In_Buffer()
- Available_In_Buffer()
- Peek_From_Buffer()
- Read_From_Buffer()
- Increment_Read_Index()
- Clean_Buffer()
- Buffer_Compare()
- _BUFFER_LENGTH
- _NUMBER_OF_OVERFLOW
- Options:
#define _BUFFER_LENGTH 10 #define _NUMBER_OF_OVERFLOW 5
- Parameters:
- _BUFFER_LENGTH : Length of buffer
- _NUMBER_OF_OVERFLOW : Number of overflows
- Example:
Buffer_TypeDef serialDataBuff; Buffer_TypeDef sensorDataBuff; Buffer_Init(&serialDataBuff); Buffer_Init(&sensorDataBuff);
int main(void)
{
int nmbOfData = 0;
Buffer_TypeDef serialDataBuff;
Buffer_TypeDef sensorDataBuff;
Buffer_Init(&serialDataBuff);
Buffer_Init(&sensorDataBuff);
while()
{
Save_In_Buffer(&serialDataBuff, 'a');
Save_In_Buffer(&sensorDataBuff, 15);
nmbOfData = Available_In_Buffer(&serialDataBuff); /* nmbOfData is number of available data in buffer */
if (nmbOfData > 5)
{
Clean_Buffer(&serialDataBuff);
}
}
}
- Linear
- Circular