MTB CAT1 Peripheral driver library
Interrupt Functions

General Description

This set of functions are related to SAR interrupts.

Functions

__STATIC_INLINE uint32_t Cy_SAR_GetInterruptStatus (const SAR_Type *base)
 Return the interrupt register status. More...
 
__STATIC_INLINE void Cy_SAR_ClearInterrupt (SAR_Type *base, uint32_t intrMask)
 Clear the interrupt. More...
 
__STATIC_INLINE void Cy_SAR_SetInterrupt (SAR_Type *base, uint32_t intrMask)
 Trigger an interrupt with software. More...
 
__STATIC_INLINE void Cy_SAR_SetInterruptMask (SAR_Type *base, uint32_t intrMask)
 Enable which interrupts can trigger the CPU interrupt controller. More...
 
__STATIC_INLINE uint32_t Cy_SAR_GetInterruptMask (const SAR_Type *base)
 Return which interrupts can trigger the CPU interrupt controller as configured by Cy_SAR_SetInterruptMask. More...
 
__STATIC_INLINE uint32_t Cy_SAR_GetInterruptStatusMasked (const SAR_Type *base)
 Return the bitwise AND between the interrupt request and mask registers. More...
 
__STATIC_INLINE uint32_t Cy_SAR_GetRangeInterruptStatus (const SAR_Type *base)
 Return the range interrupt register status. More...
 
__STATIC_INLINE void Cy_SAR_ClearRangeInterrupt (SAR_Type *base, uint32_t chanMask)
 Clear the range interrupt for the specified channel mask. More...
 
__STATIC_INLINE void Cy_SAR_SetRangeInterrupt (SAR_Type *base, uint32_t chanMask)
 Trigger a range interrupt with software for the specific channel mask. More...
 
__STATIC_INLINE void Cy_SAR_SetRangeInterruptMask (SAR_Type *base, uint32_t chanMask)
 Enable which channels can trigger a range interrupt. More...
 
__STATIC_INLINE uint32_t Cy_SAR_GetRangeInterruptMask (const SAR_Type *base)
 Return which interrupts can trigger a range interrupt as configured by Cy_SAR_SetRangeInterruptMask. More...
 
__STATIC_INLINE uint32_t Cy_SAR_GetRangeInterruptStatusMasked (const SAR_Type *base)
 Return the bitwise AND between the range interrupt request and mask registers. More...
 
__STATIC_INLINE uint32_t Cy_SAR_GetSatInterruptStatus (const SAR_Type *base)
 Return the saturate interrupt register status. More...
 
__STATIC_INLINE void Cy_SAR_ClearSatInterrupt (SAR_Type *base, uint32_t chanMask)
 Clear the saturate interrupt for the specified channel mask. More...
 
__STATIC_INLINE void Cy_SAR_SetSatInterrupt (SAR_Type *base, uint32_t chanMask)
 Trigger a saturate interrupt with software for the specific channel mask. More...
 
__STATIC_INLINE void Cy_SAR_SetSatInterruptMask (SAR_Type *base, uint32_t chanMask)
 Enable which channels can trigger a saturate interrupt. More...
 
__STATIC_INLINE uint32_t Cy_SAR_GetSatInterruptMask (const SAR_Type *base)
 Return which interrupts can trigger a saturate interrupt as configured by Cy_SAR_SetSatInterruptMask. More...
 
__STATIC_INLINE uint32_t Cy_SAR_GetSatInterruptStatusMasked (const SAR_Type *base)
 Return the bitwise AND between the saturate interrupt request and mask registers. More...
 
__STATIC_INLINE uint32_t Cy_SAR_GetInterruptCause (const SAR_Type *base)
 Return the cause of the interrupt. More...
 

Function Documentation

◆ Cy_SAR_GetInterruptStatus()

__STATIC_INLINE uint32_t Cy_SAR_GetInterruptStatus ( const SAR_Type base)

Return the interrupt register status.

Parameters
basePointer to structure describing registers
Returns
Interrupt status
Function Usage
/* ISR function to handle all SAR interrupts.
* This same routine gets called when any of the enabled SAR interrupt sources
* are enabled (EOS, overflow, FW collision, saturation detection, or range detection). */
void SAR_Interrupt(void)
{
uint32_t intr_status = 0u;
/* Read interrupt status register. */
intr_status = Cy_SAR_GetInterruptStatus(SAR_HW);
/* Check what triggered the interrupt. */
if ((intr_status & (uint32_t) CY_SAR_INTR_EOS) == (uint32_t) CY_SAR_INTR_EOS)
{
/* An end of scan occurred, retrieve the ADC result and do something with it here. */
}
/* Check for the saturation detection status, if enabled. */
/* Check for the range detection status, if enabled. */
/* Clear the handled interrupt. */
Cy_SAR_ClearInterrupt(SAR_HW, intr_status);
}

◆ Cy_SAR_ClearInterrupt()

__STATIC_INLINE void Cy_SAR_ClearInterrupt ( SAR_Type base,
uint32_t  intrMask 
)

Clear the 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_GetInterruptStatus. Alternately, select one or more values from Interrupt Masks and "OR" them together.
Returns
None

◆ Cy_SAR_SetInterrupt()

__STATIC_INLINE void Cy_SAR_SetInterrupt ( 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_SetInterruptMask()

__STATIC_INLINE void Cy_SAR_SetInterruptMask ( 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
Function Usage
/* Scenario: Enable the EOS, overflow, and firmware collision interrupt sources.
* Make sure to assign an ISR to handle the SAR interrupts. */
Cy_SAR_SetInterruptMask(SAR_HW, (uint32_t) (CY_SAR_INTR_EOS | CY_SAR_INTR_OVERFLOW | CY_SAR_INTR_FW_COLLISION));

◆ Cy_SAR_GetInterruptMask()

__STATIC_INLINE uint32_t Cy_SAR_GetInterruptMask ( const SAR_Type base)

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

Parameters
basePointer to structure describing registers
Returns
Interrupt mask. Compare this value with masks in Interrupt Masks.
Function Usage
/* Scenario: Check whether a specific interrupt source is enabled. */
uint32_t intrMask;
intrMask = Cy_SAR_GetInterruptMask(SAR_HW);
if ((uint32_t) CY_SAR_INTR_EOS == (intrMask & (uint32_t) CY_SAR_INTR_EOS))
{
/* EOS interrupt was enabled. */
}

◆ Cy_SAR_GetInterruptStatusMasked()

__STATIC_INLINE uint32_t Cy_SAR_GetInterruptStatusMasked ( const SAR_Type base)

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

See Cy_SAR_GetInterruptStatus and Cy_SAR_GetInterruptMask.

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

◆ Cy_SAR_GetRangeInterruptStatus()

__STATIC_INLINE uint32_t Cy_SAR_GetRangeInterruptStatus ( const SAR_Type base)

Return the range interrupt register status.

If the status bit is low for a channel, the channel may not be enabled (Cy_SAR_SetChanMask), range detection is not enabled for the channel (Cy_SAR_SetRangeInterruptMask), or range detection was not triggered for the channel.

Parameters
basePointer to structure describing registers
Returns
The range interrupt status for all channels. Bit 0 is for channel 0, etc.
Function Usage
/* Scenario: Range detection has been enabled for at least one channel.
* Check the range interrupt status in the ISR when an interrupt occurs. */
uint32_t intr_status = 0u;
/* Read the range detection interrupt status register. */
intr_status = Cy_SAR_GetRangeInterruptStatus(SAR_HW);
if (intr_status > 0u)
{
/* One or more channels triggered the range detection interrupt, do something here. */
}
/* Clear the handled range interrupt. */
Cy_SAR_ClearRangeInterrupt(SAR_HW, intr_status);
/* Perform a dummy read of the range interrupt status register for buffered writes. */

◆ Cy_SAR_ClearRangeInterrupt()

__STATIC_INLINE void Cy_SAR_ClearRangeInterrupt ( SAR_Type base,
uint32_t  chanMask 
)

Clear the range interrupt for the specified channel mask.

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

Parameters
basePointer to structure describing registers
chanMaskThe channel mask. Bit 0 is for channel 0, etc. Typically, this is the value returned from Cy_SAR_GetRangeInterruptStatus.
Returns
None

◆ Cy_SAR_SetRangeInterrupt()

__STATIC_INLINE void Cy_SAR_SetRangeInterrupt ( SAR_Type base,
uint32_t  chanMask 
)

Trigger a range interrupt with software for the specific channel mask.

Parameters
basePointer to structure describing registers
chanMaskThe channel mask. Bit 0 is for channel 0, etc.
Returns
None

◆ Cy_SAR_SetRangeInterruptMask()

__STATIC_INLINE void Cy_SAR_SetRangeInterruptMask ( SAR_Type base,
uint32_t  chanMask 
)

Enable which channels can trigger a range interrupt.

Parameters
basePointer to structure describing registers
chanMaskThe channel mask. Bit 0 is for channel 0, etc.
Returns
None
Function Usage
/* Scenario: Enable the range detection interrupt for channel 0 only.
* Make sure to assign an ISR to handle the SAR interrupts. */
uint32_t chanMask = 1UL;
Cy_SAR_SetRangeInterruptMask(SAR_HW, chanMask);

◆ Cy_SAR_GetRangeInterruptMask()

__STATIC_INLINE uint32_t Cy_SAR_GetRangeInterruptMask ( const SAR_Type base)

Return which interrupts can trigger a range interrupt as configured by Cy_SAR_SetRangeInterruptMask.

Parameters
basePointer to structure describing registers
Returns
The range interrupt mask

◆ Cy_SAR_GetRangeInterruptStatusMasked()

__STATIC_INLINE uint32_t Cy_SAR_GetRangeInterruptStatusMasked ( const SAR_Type base)

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

See Cy_SAR_GetRangeInterruptStatus and Cy_SAR_GetRangeInterruptMask.

Parameters
basePointer to structure describing registers
Returns
Bitwise AND between of range interrupt request and mask

◆ Cy_SAR_GetSatInterruptStatus()

__STATIC_INLINE uint32_t Cy_SAR_GetSatInterruptStatus ( const SAR_Type base)

Return the saturate interrupt register status.

If the status bit is low for a channel, the channel may not be enabled (Cy_SAR_SetChanMask), saturation detection is not enabled for the channel (Cy_SAR_SetSatInterruptMask), or saturation detection was not triggered for the channel.

Parameters
basePointer to structure describing registers
Returns
The saturate interrupt status for all channels. Bit 0 is for channel 0, etc.
Function Usage
/* Scenario: Saturation detection has been enabled for at least one channel.
* Check the saturation interrupt status in the ISR when an interrupt occurs. */
uint32_t intr_status = 0u;
/* Read the saturation detection interrupt status register. */
intr_status = Cy_SAR_GetSatInterruptStatus(SAR_HW);
if (intr_status > 0u)
{
/* One or more channel saturated (the sampled value is equal to the
* minimum or maximum, do something here. */
}
/* Clear the handled saturation interrupt. */
Cy_SAR_ClearSatInterrupt(SAR_HW, intr_status);
/* Perform a dummy read of the saturation interrupt status register for buffered writes. */

◆ Cy_SAR_ClearSatInterrupt()

__STATIC_INLINE void Cy_SAR_ClearSatInterrupt ( SAR_Type base,
uint32_t  chanMask 
)

Clear the saturate interrupt for the specified channel mask.

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
chanMaskThe channel mask. Bit 0 is for channel 0, etc. Typically, this is the value returned from Cy_SAR_GetSatInterruptStatus.
Returns
None

◆ Cy_SAR_SetSatInterrupt()

__STATIC_INLINE void Cy_SAR_SetSatInterrupt ( SAR_Type base,
uint32_t  chanMask 
)

Trigger a saturate interrupt with software for the specific channel mask.

Parameters
basePointer to structure describing registers
chanMaskThe channel mask. Bit 0 is for channel 0, etc.
Returns
None

◆ Cy_SAR_SetSatInterruptMask()

__STATIC_INLINE void Cy_SAR_SetSatInterruptMask ( SAR_Type base,
uint32_t  chanMask 
)

Enable which channels can trigger a saturate interrupt.

Parameters
basePointer to structure describing registers
chanMaskThe channel mask. Bit 0 is for channel 0, etc.
Returns
None
Function Usage
/* Scenario: Enable the saturation detection interrupt for all 16 channels.
* Only enabled channels, see Cy_SAR_SetChanMask(), are scanned.
* Make sure to assign an ISR to handle the SAR interrupts. */
uint32_t chanMask = 0xFFFFUL;
Cy_SAR_SetSatInterruptMask(SAR_HW, chanMask);

◆ Cy_SAR_GetSatInterruptMask()

__STATIC_INLINE uint32_t Cy_SAR_GetSatInterruptMask ( const SAR_Type base)

Return which interrupts can trigger a saturate interrupt as configured by Cy_SAR_SetSatInterruptMask.

Parameters
basePointer to structure describing registers
Returns
The saturate interrupt mask. Bit 0 is for channel 0, etc.

◆ Cy_SAR_GetSatInterruptStatusMasked()

__STATIC_INLINE uint32_t Cy_SAR_GetSatInterruptStatusMasked ( const SAR_Type base)

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

See Cy_SAR_GetSatInterruptStatus and Cy_SAR_GetSatInterruptMask.

Parameters
basePointer to structure describing registers
Returns
Bitwise AND of the saturate interrupt request and mask

◆ Cy_SAR_GetInterruptCause()

__STATIC_INLINE uint32_t Cy_SAR_GetInterruptCause ( const SAR_Type base)

Return the cause of the interrupt.

The interrupt routine can be called due to one of the following events:

  • End of scan (EOS)
  • Overflow
  • Firmware collision
  • Saturation detected on one or more channels
  • Range detected on one or more channels
Parameters
basePointer to structure describing registers
Returns
Mask of what caused the interrupt. Compare this value with one of these masks:
  • SAR_INTR_CAUSE_EOS_MASKED_MIR_Msk : EOS caused the interrupt
  • SAR_INTR_CAUSE_OVERFLOW_MASKED_MIR_Msk : Overflow caused the interrupt
  • SAR_INTR_CAUSE_FW_COLLISION_MASKED_MIR_Msk : Firmware collision cause the interrupt
  • SAR_INTR_CAUSE_SATURATE_MASKED_RED_Msk : Saturation detection on one or more channels caused the interrupt
  • SAR_INTR_CAUSE_RANGE_MASKED_RED_Msk : Range detection on one or more channels caused the interrupt