DCL Floating Point Data Logging Structures
Module: Digital Control Library (DCL)
Types
Name |
|
|---|---|
typedef _DCL_VOLATILE struct |
DCL_FDLOG |
Functions
Name |
|
|---|---|
_DCL_CODE_ACCESS void |
DCL_setLogIndex(DCL_FDLOG * buf, uint32_t idx) |
_DCL_CODE_ACCESS void |
DCL_deleteLog(DCL_FDLOG * buf) |
_DCL_CODE_ACCESS void |
DCL_resetLog(DCL_FDLOG * buf) |
_DCL_CODE_ACCESS void |
DCL_fillLog(DCL_FDLOG * buf, float32_t data) |
_DCL_CODE_ACCESS void |
DCL_initLog(DCL_FDLOG * buf, float32_t * addr, uint32_t size) |
DCL_writeLog(DCL_FDLOG * buf, float32_t data) |
|
DCL_readLog(DCL_FDLOG * buf) |
|
_DCL_CODE_ACCESS void |
DCL_copyLog(DCL_FDLOG * src, DCL_FDLOG * dst) |
Defines
Name |
|
|---|---|
FDLOG_DEFAULTS |
|
DCL_getLogSize(buf) |
|
DCL_getLogIndex(buf) |
|
DCL_getLogRemain(buf) |
|
DCL_clearLog(buf) |
Detailed Description
Defines a 32-bit floating-point data logger strcture and related functions.
The FDLOG structure describes a continuous memory block which is characterized by its start index pointer, current index pointer, and size of the buffer.
Overfilling the data logger would result in a warp-around in a similar fashion as circular buffers.
An example of initialization and use is shown below:
uint32_t fdlog_size = 400;
#pragma DATA_SECTION(r_Array, "DataLogSection") //Not necessary but helpful for debugging
float32_t r_Array[fdlog_size];
DCL_FDLOG rBuf;
DCL_initLog(&rBuf, r_Array, fdlog_size);
DCL_clearLog(&rBuf);
DCL_writeFDLOG(&rBuf, some_results);
output = readFDLOG(&rBuf);
Types Documentation
typedef DCL_FDLOG
typedef _DCL_VOLATILE struct DCL_FDLOG;
Defines the data logger strcture for 32-bit float.
Functions Documentation
function DCL_setLogIndex
_DCL_CODE_ACCESS void DCL_setLogIndex(
DCL_FDLOG * buf,
uint32_t idx
)
Sets index of the current pointer (zero-indexed)
Parameters:
buf Pointer to DCL_FDLOG
idx Index number
function DCL_deleteLog
_DCL_CODE_ACCESS void DCL_deleteLog(
DCL_FDLOG * buf
)
Resets all structure pointers to null value.
Parameters:
buf The DCL_FDLOG structure
function DCL_resetLog
_DCL_CODE_ACCESS void DCL_resetLog(
DCL_FDLOG * buf
)
Resets the data index pointer to start of buffer.
Parameters:
buf The DCL_FDLOG structure
function DCL_fillLog
_DCL_CODE_ACCESS void DCL_fillLog(
DCL_FDLOG * buf,
float32_t data
)
Fills the buffer with a given data value and resets the data index pointer to the start of the buffer.
Parameters:
buf The DCL_FDLOG structure
data The fill data value
function DCL_initLog
_DCL_CODE_ACCESS void DCL_initLog(
DCL_FDLOG * buf,
float32_t * addr,
uint32_t size
)
Assigns the buffer pointers to a memory block or array and sets the data index pointer to the first address.
Parameters:
buf The DCL_FDLOG structure
addr The start address of the memory block
size The length of the memory block in 32-bit words
function DCL_writeLog
_DCL_CODE_ACCESSfloat32_t DCL_writeLog(
DCL_FDLOG * buf,
float32_t data
)
Writes a data point into the buffer and advances the indexing pointer, wrapping if necessary. Returns the over-written data value for delay line or FIFO implementation.
Parameters:
buf The DCL_FDLOG structure
data The input data value
Return: The over-written data value
function DCL_readLog
_DCL_CODE_ACCESSfloat32_t DCL_readLog(
DCL_FDLOG * buf
)
Reads a data point from the buffer and then advances the indexing pointer, wrapping if necessary.
Parameters:
buf The DCL_FDLOG structure
Return: The indexed data value
function DCL_copyLog
_DCL_CODE_ACCESS void DCL_copyLog(
DCL_FDLOG * src,
DCL_FDLOG * dst
)
Copies the contents of one log (src) into another (dst). Both logs must have the same size.
Parameters:
Macros Documentation
define FDLOG_DEFAULTS
#define FDLOG_DEFAULTS {0x0, 0x0, 0x0, 0}
Default initialization of DCL_FDLOG.
define DCL_getLogSize
#define DCL_getLogSize(
buf
)
((buf)->size)
Obtain the total size of buffer.
Parameters:
buf Pointer to DCL_FDLOG
Return: uint32_t size
define DCL_getLogIndex
#define DCL_getLogIndex(
buf
)
((uint32_t)((buf)->dptr - (buf)->fptr))
Index of the current pointer (zero-indexed)
Parameters:
buf Pointer to DCL_FDLOG
Return: uint32_t index
define DCL_getLogRemain
#define DCL_getLogRemain(
buf
)
((int32_t)((buf)->lptr - (buf)->dptr))
Remaining space left from indexed pointer to end of buffer.
Parameters:
buf Pointer to DCL_FDLOG
Return: int32_t remain
define DCL_clearLog
#define DCL_clearLog(
buf
)
DCL_fillLog(buf, 0.0f)
Clears the buffer contents by writing 0 to all elements and resets the data index pointer to the start of the buffer.