CAT2 Peripheral Driver Library

Functions

cy_en_dmac_status_t Cy_DMAC_Channel_Init (DMAC_Type *base, uint32_t channel, cy_stc_dmac_channel_config_t const *config)
 Initializes the DMAC channel with an active descriptor and other parameters. More...
 
void Cy_DMAC_Channel_DeInit (DMAC_Type *base, uint32_t channel)
 Clears the content of registers corresponding to the channel. More...
 
__STATIC_INLINE void Cy_DMAC_Channel_Enable (DMAC_Type *base, uint32_t channel)
 Enables a DMAC channel. More...
 
__STATIC_INLINE void Cy_DMAC_Channel_Disable (DMAC_Type *base, uint32_t channel)
 Disables a DMAC channel. More...
 
__STATIC_INLINE void Cy_DMAC_Channel_SetPriority (DMAC_Type *base, uint32_t channel, uint32_t priority)
 The function is used to set a priority for the DMAC channel. More...
 
__STATIC_INLINE uint32_t Cy_DMAC_Channel_GetPriority (DMAC_Type const *base, uint32_t channel)
 Returns the priority of the DMAC channel. More...
 
__STATIC_INLINE void Cy_DMAC_Channel_SetCurrentDescriptor (DMAC_Type *base, uint32_t channel, cy_en_dmac_descriptor_t descriptor)
 Sets a descriptor as current for the specified DMAC channel. More...
 
__STATIC_INLINE cy_en_dmac_descriptor_t Cy_DMAC_Channel_GetCurrentDescriptor (DMAC_Type const *base, uint32_t channel)
 Returns the descriptor, which is active in the channel at the moment. More...
 

Detailed Description

Function Documentation

◆ Cy_DMAC_Channel_Init()

cy_en_dmac_status_t Cy_DMAC_Channel_Init ( DMAC_Type base,
uint32_t  channel,
cy_stc_dmac_channel_config_t const *  config 
)

Initializes the DMAC channel with an active descriptor and other parameters.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
configThe structure that has the initialization information for the channel.
Returns
The status /ref cy_en_dmac_status_t.
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_Channel_DeInit()

void Cy_DMAC_Channel_DeInit ( DMAC_Type base,
uint32_t  channel 
)

Clears the content of registers corresponding to the channel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
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_Channel_Enable()

__STATIC_INLINE void Cy_DMAC_Channel_Enable ( DMAC_Type base,
uint32_t  channel 
)

Enables a DMAC channel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
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_Channel_Disable()

__STATIC_INLINE void Cy_DMAC_Channel_Disable ( DMAC_Type base,
uint32_t  channel 
)

Disables a DMAC channel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
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_Channel_SetPriority()

__STATIC_INLINE void Cy_DMAC_Channel_SetPriority ( DMAC_Type base,
uint32_t  channel,
uint32_t  priority 
)

The function is used to set a priority for the DMAC channel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
priorityThe priority to be set for the DMAC channel. The allowed values are 0,1,2,3, with "0" representing the highest priority and "3" representing the lowest priority
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_Channel_GetPriority()

__STATIC_INLINE uint32_t Cy_DMAC_Channel_GetPriority ( DMAC_Type const *  base,
uint32_t  channel 
)

Returns the priority of the DMAC channel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
Returns
The priority of the channel.
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_Channel_SetCurrentDescriptor()

__STATIC_INLINE void Cy_DMAC_Channel_SetCurrentDescriptor ( DMAC_Type base,
uint32_t  channel,
cy_en_dmac_descriptor_t  descriptor 
)

Sets a descriptor as current for the specified DMAC channel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
descriptorThe descriptor to be associated with the channel.
Function Usage
/* Scenario: Set the ping descriptor as active for the channel and validate if it was invalidated before */
#define CHANN_NUM (0U)
{
/* Validate the descriptor */
}

◆ Cy_DMAC_Channel_GetCurrentDescriptor()

__STATIC_INLINE cy_en_dmac_descriptor_t Cy_DMAC_Channel_GetCurrentDescriptor ( DMAC_Type const *  base,
uint32_t  channel 
)

Returns the descriptor, which is active in the channel at the moment.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
Returns
The active descriptor.
Function Usage
/* Scenario: Invalidate the pong descriptor for channel 0 */
#define CHANN_NUM (0U)
if (CHANN_NUM != Cy_DMAC_GetActiveChannel(DMAC))
{
/* Make sure it is not in use */
{
}
}