CAT2 Peripheral Driver Library

Functions

__STATIC_INLINE void Cy_DMAC_Enable (DMAC_Type *base)
 Enables the DMAC block. More...
 
__STATIC_INLINE void Cy_DMAC_Disable (DMAC_Type *base)
 Disables the DMAC block. More...
 
__STATIC_INLINE uint32_t Cy_DMAC_GetActiveChannel (DMAC_Type const *base)
 Returns the status of the active/pending channels of the DMAC block. More...
 
__STATIC_INLINE void * Cy_DMAC_GetActiveSrcAddress (DMAC_Type const *base)
 Returns the source address of the active descriptor. More...
 
__STATIC_INLINE void * Cy_DMAC_GetActiveDstAddress (DMAC_Type const *base)
 Returns the destination address of the active descriptor. More...
 
__STATIC_INLINE uint32_t Cy_DMAC_GetCurrentIndex (DMAC_Type const *base)
 Returns the current transfer index. More...
 
__STATIC_INLINE uint32_t Cy_DMAC_GetInterruptStatus (DMAC_Type const *base)
 Returns the interrupt(s) status. More...
 
__STATIC_INLINE uint32_t Cy_DMAC_GetInterruptStatusMasked (DMAC_Type const *base)
 Returns the logical AND of the corresponding INTR and INTR_MASK registers in a single-load operation. More...
 
__STATIC_INLINE uint32_t Cy_DMAC_GetInterruptMask (DMAC_Type const *base)
 Returns the interrupt mask value. More...
 
__STATIC_INLINE void Cy_DMAC_SetInterruptMask (DMAC_Type *base, uint32_t interrupt)
 Sets an interrupt mask value for the specified channel. More...
 
__STATIC_INLINE void Cy_DMAC_SetInterrupt (DMAC_Type *base, uint32_t interrupt)
 Sets the specified interrupt(s). More...
 
__STATIC_INLINE void Cy_DMAC_ClearInterrupt (DMAC_Type *base, uint32_t interrupt)
 Clears the specified interrupt(s). More...
 

Detailed Description

Function Documentation

◆ Cy_DMAC_Enable()

__STATIC_INLINE void Cy_DMAC_Enable ( DMAC_Type base)

Enables the DMAC block.

Parameters
baseThe pointer to the hardware DMAC block.
Function Usage
/* Scenario: Initialize the single ping descriptor */
#define DATA_CNT (8U)
#define CHANN_NUM (0U)
uint32_t src[DATA_CNT];
uint32_t dst[DATA_CNT];
/* Descriptor ping configuration structure */
cy_stc_dmac_descriptor_config_t descriptorPingCfg =
{
.srcAddress = src,
.dstAddress = dst,
.dataCount = DATA_CNT,
.dataSize = CY_DMAC_WORD,
.srcTransferSize = CY_DMAC_TRANSFER_SIZE_WORD,
.srcAddrIncrement = true,
.dstTransferSize = CY_DMAC_TRANSFER_SIZE_WORD,
.dstAddrIncrement = true,
.retrigger = CY_DMAC_RETRIG_IM,
.cpltState = false,
.interrupt = false,
.preemptable = false,
.flipping = false,
.triggerType = CY_DMAC_SINGLE_DESCR
};
/* Channel configuration structure */
{
.priority = 3U,
.enable = false,
};
/* Initialize the ping descriptor for channel 0 */
if (CY_DMAC_SUCCESS != Cy_DMAC_Descriptor_Init(DMAC, CHANN_NUM, CY_DMAC_DESCRIPTOR_PING, &descriptorPingCfg))
{
/* Insert error handling */
}
/* Scenario: Setup and enable DMAC channel 0 */
if (CY_DMAC_SUCCESS != Cy_DMAC_Channel_Init(DMAC, CHANN_NUM, &channelConfig))
{
/* Insert error handling */
}

◆ Cy_DMAC_Disable()

__STATIC_INLINE void Cy_DMAC_Disable ( DMAC_Type base)

Disables the DMAC block.

Parameters
baseThe pointer to the hardware DMAC block.
Function Usage
/* Scenario: Disable DMAC channel 0 if its priority equals 3 */
#define CHANN_NUM (0U)
if (3U == Cy_DMAC_Channel_GetPriority(DMAC, CHANN_NUM))
{
if (CHANN_NUM != Cy_DMAC_GetActiveChannel(DMAC))
{
Cy_DMAC_Channel_Disable(DMAC, CHANN_NUM);
Cy_DMAC_Channel_DeInit(DMAC, CHANN_NUM);
/* if needed (if there is only one channel used) the whole block can be disabled */
}
}
/* Scenario: Higher priority for the DMAC channel 0 if its priority equals 2 */
if (3U == Cy_DMAC_Channel_GetPriority(DMAC, CHANN_NUM))
{
if (CHANN_NUM != Cy_DMAC_GetActiveChannel(DMAC))
{
Cy_DMAC_Channel_SetPriority(DMAC, CHANN_NUM, 1U);
}
}

◆ Cy_DMAC_GetActiveChannel()

__STATIC_INLINE uint32_t Cy_DMAC_GetActiveChannel ( DMAC_Type const *  base)

Returns the status of the active/pending channels of the DMAC block.

Parameters
baseThe pointer to the hardware DMAC block.
Returns
Returns a bit-field with all of the currently active/pending channels in the DMAC block.
Function Usage
/* Scenario: Disable DMAC channel 0 if its priority equals 3 */
#define CHANN_NUM (0U)
if (3U == Cy_DMAC_Channel_GetPriority(DMAC, CHANN_NUM))
{
if (CHANN_NUM != Cy_DMAC_GetActiveChannel(DMAC))
{
Cy_DMAC_Channel_Disable(DMAC, CHANN_NUM);
Cy_DMAC_Channel_DeInit(DMAC, CHANN_NUM);
/* if needed (if there is only one channel used) the whole block can be disabled */
}
}
/* Scenario: Higher priority for the DMAC channel 0 if its priority equals 2 */
if (3U == Cy_DMAC_Channel_GetPriority(DMAC, CHANN_NUM))
{
if (CHANN_NUM != Cy_DMAC_GetActiveChannel(DMAC))
{
Cy_DMAC_Channel_SetPriority(DMAC, CHANN_NUM, 1U);
}
}

◆ Cy_DMAC_GetActiveSrcAddress()

__STATIC_INLINE void * Cy_DMAC_GetActiveSrcAddress ( DMAC_Type const *  base)

Returns the source address of the active descriptor.

Parameters
baseThe pointer to the hardware DMAC block.
Returns
The source address value of the DMAC block.
Function Usage
/* Scenario: Make sure the arrays are not in use before reading/modifying */
uint32_t src[16];
uint32_t dst[16];
if (((void *) src != Cy_DMAC_GetActiveSrcAddress(DMAC)) &&
((void *) dst != Cy_DMAC_GetActiveDstAddress(DMAC)))
{
/* Read the dst/modify the src arrays content here */
}

◆ Cy_DMAC_GetActiveDstAddress()

__STATIC_INLINE void * Cy_DMAC_GetActiveDstAddress ( DMAC_Type const *  base)

Returns the destination address of the active descriptor.

Parameters
baseThe pointer to the hardware DMAC block.
Returns
The destination address value of the DMAC block.
Function Usage
/* Scenario: Make sure the arrays are not in use before reading/modifying */
uint32_t src[16];
uint32_t dst[16];
if (((void *) src != Cy_DMAC_GetActiveSrcAddress(DMAC)) &&
((void *) dst != Cy_DMAC_GetActiveDstAddress(DMAC)))
{
/* Read the dst/modify the src arrays content here */
}

◆ Cy_DMAC_GetCurrentIndex()

__STATIC_INLINE uint32_t Cy_DMAC_GetCurrentIndex ( DMAC_Type const *  base)

Returns the current transfer index.

Parameters
baseThe pointer to the hardware DMAC block.
Returns
The current transfer index.
Function Usage
/* Scenario: Make sure the current indexes are greater than a desired
* data source item before modifying.
*/
uint32_t src[16][16];
uint32_t idx = 7;
if (((void *) src == Cy_DMAC_GetActiveSrcAddress(DMAC)) &&
(idx < Cy_DMAC_GetCurrentIndex(DMAC)))
{
/* Modify the src arrays content here */
}

◆ Cy_DMAC_GetInterruptStatus()

__STATIC_INLINE uint32_t Cy_DMAC_GetInterruptStatus ( DMAC_Type const *  base)

Returns the interrupt(s) status.

Parameters
baseThe pointer to the hardware DMAC block.
Returns
The interrupt status, see Interrupt Masks.
Function Usage
/* Scenario: Need to check the interrupt status regardless of whether it is enabled (masked) or not */
{
/* The DMAC channel 0 interrupt is pending */
}

◆ Cy_DMAC_GetInterruptStatusMasked()

__STATIC_INLINE uint32_t Cy_DMAC_GetInterruptStatusMasked ( DMAC_Type const *  base)

Returns the logical AND of the corresponding INTR and INTR_MASK registers in a single-load operation.

Parameters
baseThe pointer to the hardware DMAC block.
Returns
The masked interrupt status. See Interrupt Masks.
Function Usage
/* Scenario: Inside the interrupt service routine for DMAC channel 0 */
uint32_t interrupt = Cy_DMAC_GetInterruptStatusMasked(DMAC);
if ((interrupt & CY_DMAC_INTR_CHAN_0) > 0U)
{
/* Insert interrupt handling for channel 0 */
}
else if ((interrupt & CY_DMAC_INTR_CHAN_1) > 0U)
{
/* Insert interrupt handling for channel 1 */
}
/* Clear interrupts */
Cy_DMAC_ClearInterrupt(DMAC, interrupt);

◆ Cy_DMAC_GetInterruptMask()

__STATIC_INLINE uint32_t Cy_DMAC_GetInterruptMask ( DMAC_Type const *  base)

Returns the interrupt mask value.

Parameters
baseThe pointer to the hardware DMAC block.
Returns
The interrupt mask value. See Interrupt Masks.
Function Usage
/* Scenario: Enable interrupts for channels 0 and 3 */
Cy_DMAC_SetInterruptMask(DMAC,(CY_DMAC_INTR_CHAN_0 | CY_DMAC_INTR_CHAN_3));
/* Scenario: Test the interrupt for channel 0 */
Cy_DMAC_SetInterrupt(DMAC, CY_DMAC_INTR_CHAN_0);
/* An interrupt occur (if it is enabled) */
/* Scenario: Disable interrupts for DMAC channel 0 if it is enabled */
if ((Cy_DMAC_GetInterruptMask(DMAC) & CY_DMAC_INTR_CHAN_0) > 0U)
{
Cy_DMAC_SetInterruptMask(DMAC, (Cy_DMAC_GetInterruptMask(DMAC) & ~CY_DMAC_INTR_CHAN_0));
}

◆ Cy_DMAC_SetInterruptMask()

__STATIC_INLINE void Cy_DMAC_SetInterruptMask ( DMAC_Type base,
uint32_t  interrupt 
)

Sets an interrupt mask value for the specified channel.

Parameters
baseThe pointer to the hardware DMAC block.
interruptThe interrupt mask, see Interrupt Masks.
Function Usage
/* Scenario: Enable interrupts for channels 0 and 3 */
Cy_DMAC_SetInterruptMask(DMAC,(CY_DMAC_INTR_CHAN_0 | CY_DMAC_INTR_CHAN_3));
/* Scenario: Test the interrupt for channel 0 */
Cy_DMAC_SetInterrupt(DMAC, CY_DMAC_INTR_CHAN_0);
/* An interrupt occur (if it is enabled) */
/* Scenario: Disable interrupts for DMAC channel 0 if it is enabled */
if ((Cy_DMAC_GetInterruptMask(DMAC) & CY_DMAC_INTR_CHAN_0) > 0U)
{
Cy_DMAC_SetInterruptMask(DMAC, (Cy_DMAC_GetInterruptMask(DMAC) & ~CY_DMAC_INTR_CHAN_0));
}

◆ Cy_DMAC_SetInterrupt()

__STATIC_INLINE void Cy_DMAC_SetInterrupt ( DMAC_Type base,
uint32_t  interrupt 
)

Sets the specified interrupt(s).

Parameters
baseThe pointer to the hardware DMAC block.
interruptThe interrupt mask. See Interrupt Masks.
Function Usage
/* Scenario: Enable interrupts for channels 0 and 3 */
Cy_DMAC_SetInterruptMask(DMAC,(CY_DMAC_INTR_CHAN_0 | CY_DMAC_INTR_CHAN_3));
/* Scenario: Test the interrupt for channel 0 */
Cy_DMAC_SetInterrupt(DMAC, CY_DMAC_INTR_CHAN_0);
/* An interrupt occur (if it is enabled) */
/* Scenario: Disable interrupts for DMAC channel 0 if it is enabled */
if ((Cy_DMAC_GetInterruptMask(DMAC) & CY_DMAC_INTR_CHAN_0) > 0U)
{
Cy_DMAC_SetInterruptMask(DMAC, (Cy_DMAC_GetInterruptMask(DMAC) & ~CY_DMAC_INTR_CHAN_0));
}

◆ Cy_DMAC_ClearInterrupt()

__STATIC_INLINE void Cy_DMAC_ClearInterrupt ( DMAC_Type base,
uint32_t  interrupt 
)

Clears the specified interrupt(s).

Parameters
baseThe pointer to the hardware DMAC block.
interruptThe interrupt mask, see Interrupt Masks.
Function Usage
/* Scenario: Inside the interrupt service routine for DMAC channel 0 */
uint32_t interrupt = Cy_DMAC_GetInterruptStatusMasked(DMAC);
if ((interrupt & CY_DMAC_INTR_CHAN_0) > 0U)
{
/* Insert interrupt handling for channel 0 */
}
else if ((interrupt & CY_DMAC_INTR_CHAN_1) > 0U)
{
/* Insert interrupt handling for channel 1 */
}
/* Clear interrupts */
Cy_DMAC_ClearInterrupt(DMAC, interrupt);