DCL Floating Point Data Logging Structures

Module: Digital Control Library (DCL)

More…

Types

Name

typedef _DCL_VOLATILE struct

DCL_FDLOG
Defines the data logger strcture for 32-bit float.

Functions

Name

_DCL_CODE_ACCESS void

DCL_setLogIndex(DCL_FDLOG * buf, uint32_t idx)
Sets index of the current pointer (zero-indexed)

_DCL_CODE_ACCESS void

DCL_deleteLog(DCL_FDLOG * buf)
Resets all structure pointers to null value.

_DCL_CODE_ACCESS void

DCL_resetLog(DCL_FDLOG * buf)
Resets the data index pointer to start of buffer.

_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.

_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.

_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.

_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.

_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.

Defines

Name

FDLOG_DEFAULTS
Default initialization of DCL_FDLOG.

DCL_getLogSize(buf)
Obtain the total size of buffer.

DCL_getLogIndex(buf)
Index of the current pointer (zero-indexed)

DCL_getLogRemain(buf)
Remaining space left from indexed pointer to end of buffer.

DCL_clearLog(buf)
Clears the buffer contents by writing 0 to all elements and resets the data index pointer to the start of the buffer.

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:

function DCL_deleteLog

_DCL_CODE_ACCESS void DCL_deleteLog(
    DCL_FDLOG * buf
)

Resets all structure pointers to null value.

Parameters:

function DCL_resetLog

_DCL_CODE_ACCESS void DCL_resetLog(
    DCL_FDLOG * buf
)

Resets the data index pointer to start of buffer.

Parameters:

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:

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:

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:

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:

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.