MTB CAT1 Peripheral driver library
FIFO buffer control Functions

General Description

Functions

__STATIC_INLINE void Cy_SAR_FifoRead (const SAR_Type *base, cy_stc_sar_fifo_read_t *readStruct)
 Reads FIFO word-by-word. More...
 
__STATIC_INLINE uint32_t Cy_SAR_FifoGetDataCount (const SAR_Type *base)
 Returns a number of non-empty FIFO cells. More...
 
__STATIC_INLINE void Cy_SAR_FifoSetLevel (const SAR_Type *base, uint32_t level)
 Sets the FIFO trigger level which specifies how many samples FIFO should contain in order to generate trigger event. More...
 
__STATIC_INLINE void Cy_SAR_ClearFifoInterrupt (const SAR_Type *base, uint32_t intrMask)
 Clear the FIFO interrupt. More...
 
__STATIC_INLINE void Cy_SAR_SetFifoInterrupt (const SAR_Type *base, uint32_t intrMask)
 Trigger an interrupt with software. More...
 
__STATIC_INLINE void Cy_SAR_SetFifoInterruptMask (const SAR_Type *base, uint32_t intrMask)
 Enable which interrupts can trigger the CPU interrupt controller. More...
 
__STATIC_INLINE uint32_t Cy_SAR_GetFifoInterruptStatus (const SAR_Type *base)
 Return the interrupt register status. More...
 
__STATIC_INLINE uint32_t Cy_SAR_GetFifoInterruptMask (const SAR_Type *base)
 Return which interrupts can trigger the CPU interrupt controller as configured by Cy_SAR_SetFifoInterruptMask. More...
 
__STATIC_INLINE uint32_t Cy_SAR_GetFifoInterruptStatusMasked (const SAR_Type *base)
 Return the bitwise AND between the interrupt request and mask registers. More...
 

Function Documentation

◆ Cy_SAR_FifoRead()

__STATIC_INLINE void Cy_SAR_FifoRead ( const SAR_Type base,
cy_stc_sar_fifo_read_t readStruct 
)

Reads FIFO word-by-word.

Returns
Subsequent data sample
Function Usage
/* Scenario: Collect channel data from the FIFO */
#define FIFO_DEPTH (64UL)
#define CHAN_NUM (16UL)
{
.chanId = true, /* fifoRead.channel will contain channel number */
.chainToNext = false, /* No FIFO chaining */
.clrTrIntrOnRead = false, /* Interrupt is cleared by interrupt handler */
.level = FIFO_DEPTH, /* FIFO depth is 64 if no chaining */
.trOut = false /* Interrupt is used to get fifo data */
};
config.fifoCfgPtr = &fifoConfig;
(void) Cy_SAR_Init(SAR_HW, &config); /* Initialize SAR with FIFO */
Cy_SAR_Enable(SAR_HW); /* FIFO is enabled with SAR if fifoCfgPtr is not NULL */
/* Then, for example in the interrupt handler: */
uint16_t sarResults[CHAN_NUM][FIFO_DEPTH];
uint32_t numSamples = Cy_SAR_FifoGetDataCount(SAR_HW);
for (uint32_t i = 0; i < numSamples; i++)
{
Cy_SAR_FifoRead(SAR_HW, &fifoRead);
sarResults[fifoRead.channel][i] = fifoRead.value;
}
/* Scenario: FIFO is no more needed - reinitialize SAR without FIFO */
Cy_SAR_Disable(SAR_HW); /* FIFO is disabled with SAR */
config.fifoCfgPtr = NULL;
(void) Cy_SAR_Init(SAR_HW, &config);
Cy_SAR_Enable(SAR_HW); /* Now FIFO is not enabled with SAR if fifoCfgPtr = NULL */

◆ Cy_SAR_FifoGetDataCount()

__STATIC_INLINE uint32_t Cy_SAR_FifoGetDataCount ( const SAR_Type base)

Returns a number of non-empty FIFO cells.

Returns
Number of FIFO samples.
Function Usage
/* Scenario: Collect channel data from the FIFO */
#define FIFO_DEPTH (64UL)
#define CHAN_NUM (16UL)
{
.chanId = true, /* fifoRead.channel will contain channel number */
.chainToNext = false, /* No FIFO chaining */
.clrTrIntrOnRead = false, /* Interrupt is cleared by interrupt handler */
.level = FIFO_DEPTH, /* FIFO depth is 64 if no chaining */
.trOut = false /* Interrupt is used to get fifo data */
};
config.fifoCfgPtr = &fifoConfig;
(void) Cy_SAR_Init(SAR_HW, &config); /* Initialize SAR with FIFO */
Cy_SAR_Enable(SAR_HW); /* FIFO is enabled with SAR if fifoCfgPtr is not NULL */
/* Then, for example in the interrupt handler: */
uint16_t sarResults[CHAN_NUM][FIFO_DEPTH];
uint32_t numSamples = Cy_SAR_FifoGetDataCount(SAR_HW);
for (uint32_t i = 0; i < numSamples; i++)
{
Cy_SAR_FifoRead(SAR_HW, &fifoRead);
sarResults[fifoRead.channel][i] = fifoRead.value;
}
/* Scenario: FIFO is no more needed - reinitialize SAR without FIFO */
Cy_SAR_Disable(SAR_HW); /* FIFO is disabled with SAR */
config.fifoCfgPtr = NULL;
(void) Cy_SAR_Init(SAR_HW, &config);
Cy_SAR_Enable(SAR_HW); /* Now FIFO is not enabled with SAR if fifoCfgPtr = NULL */

◆ Cy_SAR_FifoSetLevel()

__STATIC_INLINE void Cy_SAR_FifoSetLevel ( const SAR_Type base,
uint32_t  level 
)

Sets the FIFO trigger level which specifies how many samples FIFO should contain in order to generate trigger event.

Parameters
basePointer to structure describing registers
levelThe FIFO trigger level to be set. Range: 1..256.
Returns
None

◆ Cy_SAR_ClearFifoInterrupt()

__STATIC_INLINE void Cy_SAR_ClearFifoInterrupt ( const SAR_Type base,
uint32_t  intrMask 
)

Clear the FIFO interrupt.

The interrupt must be cleared with this function so that the hardware can set subsequent interrupts and those interrupts can be forwarded to the interrupt controller, if enabled.

Parameters
basePointer to structure describing registers
intrMaskThe mask of interrupts to clear. Typically this will be the value returned from Cy_SAR_GetFifoInterruptStatus. Alternately, select one or more values from Interrupt Masks and "OR" them together.
Returns
None

◆ Cy_SAR_SetFifoInterrupt()

__STATIC_INLINE void Cy_SAR_SetFifoInterrupt ( const SAR_Type base,
uint32_t  intrMask 
)

Trigger an interrupt with software.

Parameters
basePointer to structure describing registers
intrMaskThe mask of interrupts to set. Select one or more values from Interrupt Masks and "OR" them together.
Returns
None

◆ Cy_SAR_SetFifoInterruptMask()

__STATIC_INLINE void Cy_SAR_SetFifoInterruptMask ( const SAR_Type base,
uint32_t  intrMask 
)

Enable which interrupts can trigger the CPU interrupt controller.

Parameters
basePointer to structure describing registers
intrMaskThe mask of interrupts. Select one or more values from Interrupt Masks and "OR" them together:
Returns
None

◆ Cy_SAR_GetFifoInterruptStatus()

__STATIC_INLINE uint32_t Cy_SAR_GetFifoInterruptStatus ( const SAR_Type base)

Return the interrupt register status.

Parameters
basePointer to structure describing registers
Returns
Interrupt status Interrupt Masks.

◆ Cy_SAR_GetFifoInterruptMask()

__STATIC_INLINE uint32_t Cy_SAR_GetFifoInterruptMask ( const SAR_Type base)

Return which interrupts can trigger the CPU interrupt controller as configured by Cy_SAR_SetFifoInterruptMask.

Parameters
basePointer to structure describing registers
Returns
Interrupt mask. Compare this value with masks in Interrupt Masks.

◆ Cy_SAR_GetFifoInterruptStatusMasked()

__STATIC_INLINE uint32_t Cy_SAR_GetFifoInterruptStatusMasked ( const SAR_Type base)

Return the bitwise AND between the interrupt request and mask registers.

See Cy_SAR_GetFifoInterruptStatus and Cy_SAR_GetFifoInterruptMask.

Parameters
basePointer to structure describing registers
Returns
Bitwise AND of the interrupt request and mask registers Interrupt Masks.