iSensor-SPI-Buffer buffer implementation
More...
#include "reg.h"
#include "buffer.h"
#include "stm32f3xx_hal.h"
iSensor-SPI-Buffer buffer implementation
Copyright (c) Analog Devices Inc, 2020 All Rights Reserved.
- Date
- 3/19/2020
- Author
- A. Nolan (alex..nosp@m.nola.nosp@m.n@ana.nosp@m.log..nosp@m.com)
◆ __attribute__()
static uint8_t buf [BUF_SIZE] __attribute__ |
( |
(aligned(32)) |
| ) |
|
|
static |
The buffer storage (aligned to allow word-wise retrieval of buffer data)
◆ Buffer_Add_Element()
uint8_t* Buffer_Add_Element |
( |
| ) |
|
Add an element to the buffer.
- Returns
- Pointer to the new element added to the buffer
New elements always get added to the head of the buffer, in both buffer modes. If the buffer is full and ReplaceOldest is set to true, then the head continues moving through the buffer memory. If replace oldest is set to false, the head stays still when the buffer data structure reaches capacity.
◆ Buffer_Can_Add_Element()
uint32_t Buffer_Can_Add_Element |
( |
| ) |
|
Checks if an element can be added to the buffer.
- Returns
- 0 if no element can be added to the buffer, 1 otherwise
The return value depends on the replace oldest setting and buffer count
◆ Buffer_Reset()
Clears the buffer data structure.
- Returns
- void
This function resets the buffer to its default state. All stored buffer entries are discarded. The buffer control registers (buffer length, buffer config) are both validated to ensure the buffer is initialized to a valid state.
◆ Buffer_Take_Element()
uint8_t* Buffer_Take_Element |
( |
| ) |
|
Take a single element from the buffer.
- Returns
- Pointer to the element retrieved from the buffer
In FIFO mode (queue) this function takes from the tail and moves the tail pointer down. This function is called from the main loop when a buffer dequeue is requested. As such, the ISRs are disabled for the duration of this function execution to prevent issues with g_bufCount being inadvertently changed
◆ buf_head
volatile uint32_t buf_head = 0 |
|
static |
Index within buffer array for buffer head
◆ buf_increment
uint32_t buf_increment = 64 |
|
static |
Increment per buffer entry. This is buffer length + 4, padded to multiple of 4
◆ buf_lastEntryIndex
uint32_t buf_lastEntryIndex |
|
static |
Position at which buffer needs to wrap around
◆ buf_maxCount
Buffer max count (determined once when buffer is initialized)
◆ buf_replaceOldest
uint32_t buf_replaceOldest = 0 |
|
static |
Buffer full setting (0 -> stop adding, Not 0 -> replace oldest)
◆ buf_tail
volatile uint32_t buf_tail = 0 |
|
static |
Index within buffer array for buffer tail
◆ g_bufCount
Number of elements currently stored in the buffer. Global scope
◆ g_bufLastRegIndex
uint32_t g_bufLastRegIndex |
Index for the last buffer output register. This is based on buffer size. Global scope
◆ g_bufNumWords32
Number of 32-bit words per buffer entry. Global scope