PSoC 6 Peripheral Driver Library

General Description

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 a 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_SetDescriptor (DMAC_Type *base, uint32_t channel, cy_stc_dmac_descriptor_t const *descriptor)
 Sets a descriptor as current for the specified DMACchannel. 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 DMACchannel. 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_GetCurrentSrcAddress (DMAC_Type *base, uint32_t channel)
 Returns the source address being used for the current transfer. More...
 
__STATIC_INLINE void * Cy_DMAC_Channel_GetCurrentDstAddress (DMAC_Type *base, uint32_t channel)
 Returns the destination address being used for the current transfer. More...
 
__STATIC_INLINE uint32_t Cy_DMAC_Channel_GetCurrentXloopIndex (DMAC_Type const *base, uint32_t channel)
 Returns the current transfer X-loop index. More...
 
__STATIC_INLINE uint32_t Cy_DMAC_Channel_GetCurrentYloopIndex (DMAC_Type const *base, uint32_t channel)
 Returns the current transfer X-loop index. More...
 
__STATIC_INLINE cy_stc_dmac_descriptor_tCy_DMAC_Channel_GetCurrentDescriptor (DMAC_Type const *base, uint32_t channel)
 Returns the descriptor that is active in the channel. More...
 
__STATIC_INLINE uint32_t Cy_DMAC_Channel_GetInterruptStatus (DMAC_Type const *base, uint32_t channel)
 Returns the interrupt status of the specified channel. More...
 
__STATIC_INLINE void Cy_DMAC_Channel_ClearInterrupt (DMAC_Type *base, uint32_t channel, uint32_t interrupt)
 Clears the interrupt status of the specified channel. More...
 
__STATIC_INLINE void Cy_DMAC_Channel_SetInterrupt (DMAC_Type *base, uint32_t channel, uint32_t interrupt)
 Sets the interrupt for the specified channel. More...
 
__STATIC_INLINE uint32_t Cy_DMAC_Channel_GetInterruptMask (DMAC_Type const *base, uint32_t channel)
 Returns the interrupt mask value of the specified channel. More...
 
__STATIC_INLINE void Cy_DMAC_Channel_SetInterruptMask (DMAC_Type *base, uint32_t channel, uint32_t interrupt)
 Sets an interrupt mask value for the specified channel. More...
 
__STATIC_INLINE uint32_t Cy_DMAC_Channel_GetInterruptStatusMasked (DMAC_Type const *base, uint32_t channel)
 Returns the logical AND of the corresponding INTR and INTR_MASK fields in a single-load operation. More...
 

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 a descriptor and other parameters.

Parameters
baseThe pointer to the hardware DMAC block.
channelA 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 a 1D descriptor */
#define DATACNT (8UL)
cy_stc_dmac_descriptor_t nextDescriptor;
uint32_t src[DATACNT];
uint32_t dst[DATACNT];
{
.interruptType = CY_DMAC_DESCR,
.triggerOutType = CY_DMAC_DESCR,
.channelState = CY_DMAC_CHANNEL_ENABLED,
.triggerInType = CY_DMAC_DESCR,
.dataSize = CY_DMAC_WORD,
.srcTransferSize = CY_DMAC_TRANSFER_SIZE_WORD,
.dstTransferSize = CY_DMAC_TRANSFER_SIZE_WORD,
.descriptorType = CY_DMAC_1D_TRANSFER,
.srcAddress = &src,
.dstAddress = &dst,
.srcXincrement = 1U,
.dstXincrement = 1U,
.xCount = DATACNT,
.srcYincrement = 0U,
.dstYincrement = 0U,
.yCount = 1UL,
.nextDescriptor = &nextDescriptor,
};
if (CY_DMAC_SUCCESS != Cy_DMAC_Descriptor_Init(&descriptor, &descriptor_cfg))
{
/* Insert error handling */
}
/* Scenario: Setup and enable the DMAC channel 0 */
channelConfig.enable = false;
channelConfig.bufferable = false;
if (CY_DMAC_SUCCESS != Cy_DMAC_Channel_Init(DMAC, 0UL, &channelConfig))
{
/* Insert error handling */
}
Cy_DMAC_Channel_SetDescriptor(DMAC, 0UL, &descriptor);
Cy_DMAC_Channel_SetPriority(DMAC, 0UL, 3UL);

◆ 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.
channelA channel number.
Function Usage
/* Scenario: Disable the DMAC channel 0 if it's priority equals 3 */
if (3UL == Cy_DMAC_Channel_GetPriority(DMAC, 0UL))
{
if (0UL != Cy_DMAC_GetActiveChannel(DMAC))
{
/* if needed (if there is only channel used) the whole block can be disabled */
}
}

◆ Cy_DMAC_Channel_SetDescriptor()

__STATIC_INLINE void Cy_DMAC_Channel_SetDescriptor ( DMAC_Type *  base,
uint32_t  channel,
cy_stc_dmac_descriptor_t const *  descriptor 
)

Sets a descriptor as current for the specified DMACchannel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
descriptorThis is the descriptor to be associated with the channel.
Function Usage
/* Scenario: Initialize a 1D descriptor */
#define DATACNT (8UL)
cy_stc_dmac_descriptor_t nextDescriptor;
uint32_t src[DATACNT];
uint32_t dst[DATACNT];
{
.interruptType = CY_DMAC_DESCR,
.triggerOutType = CY_DMAC_DESCR,
.channelState = CY_DMAC_CHANNEL_ENABLED,
.triggerInType = CY_DMAC_DESCR,
.dataSize = CY_DMAC_WORD,
.srcTransferSize = CY_DMAC_TRANSFER_SIZE_WORD,
.dstTransferSize = CY_DMAC_TRANSFER_SIZE_WORD,
.descriptorType = CY_DMAC_1D_TRANSFER,
.srcAddress = &src,
.dstAddress = &dst,
.srcXincrement = 1U,
.dstXincrement = 1U,
.xCount = DATACNT,
.srcYincrement = 0U,
.dstYincrement = 0U,
.yCount = 1UL,
.nextDescriptor = &nextDescriptor,
};
if (CY_DMAC_SUCCESS != Cy_DMAC_Descriptor_Init(&descriptor, &descriptor_cfg))
{
/* Insert error handling */
}
/* Scenario: Setup and enable the DMAC channel 0 */
channelConfig.enable = false;
channelConfig.bufferable = false;
if (CY_DMAC_SUCCESS != Cy_DMAC_Channel_Init(DMAC, 0UL, &channelConfig))
{
/* Insert error handling */
}
Cy_DMAC_Channel_SetDescriptor(DMAC, 0UL, &descriptor);
Cy_DMAC_Channel_SetPriority(DMAC, 0UL, 3UL);

◆ 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 a 1D descriptor */
#define DATACNT (8UL)
cy_stc_dmac_descriptor_t nextDescriptor;
uint32_t src[DATACNT];
uint32_t dst[DATACNT];
{
.interruptType = CY_DMAC_DESCR,
.triggerOutType = CY_DMAC_DESCR,
.channelState = CY_DMAC_CHANNEL_ENABLED,
.triggerInType = CY_DMAC_DESCR,
.dataSize = CY_DMAC_WORD,
.srcTransferSize = CY_DMAC_TRANSFER_SIZE_WORD,
.dstTransferSize = CY_DMAC_TRANSFER_SIZE_WORD,
.descriptorType = CY_DMAC_1D_TRANSFER,
.srcAddress = &src,
.dstAddress = &dst,
.srcXincrement = 1U,
.dstXincrement = 1U,
.xCount = DATACNT,
.srcYincrement = 0U,
.dstYincrement = 0U,
.yCount = 1UL,
.nextDescriptor = &nextDescriptor,
};
if (CY_DMAC_SUCCESS != Cy_DMAC_Descriptor_Init(&descriptor, &descriptor_cfg))
{
/* Insert error handling */
}
/* Scenario: Setup and enable the DMAC channel 0 */
channelConfig.enable = false;
channelConfig.bufferable = false;
if (CY_DMAC_SUCCESS != Cy_DMAC_Channel_Init(DMAC, 0UL, &channelConfig))
{
/* Insert error handling */
}
Cy_DMAC_Channel_SetDescriptor(DMAC, 0UL, &descriptor);
Cy_DMAC_Channel_SetPriority(DMAC, 0UL, 3UL);

◆ Cy_DMAC_Channel_Disable()

__STATIC_INLINE void Cy_DMAC_Channel_Disable ( DMAC_Type *  base,
uint32_t  channel 
)

Disables a DMACchannel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
Function Usage
/* Scenario: Disable the DMAC channel 0 if it's priority equals 3 */
if (3UL == Cy_DMAC_Channel_GetPriority(DMAC, 0UL))
{
if (0UL != Cy_DMAC_GetActiveChannel(DMAC))
{
/* if needed (if there is only channel used) the whole block can be disabled */
}
}

◆ 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.
Function Usage
/* Scenario: Initialize a 1D descriptor */
#define DATACNT (8UL)
cy_stc_dmac_descriptor_t nextDescriptor;
uint32_t src[DATACNT];
uint32_t dst[DATACNT];
{
.interruptType = CY_DMAC_DESCR,
.triggerOutType = CY_DMAC_DESCR,
.channelState = CY_DMAC_CHANNEL_ENABLED,
.triggerInType = CY_DMAC_DESCR,
.dataSize = CY_DMAC_WORD,
.srcTransferSize = CY_DMAC_TRANSFER_SIZE_WORD,
.dstTransferSize = CY_DMAC_TRANSFER_SIZE_WORD,
.descriptorType = CY_DMAC_1D_TRANSFER,
.srcAddress = &src,
.dstAddress = &dst,
.srcXincrement = 1U,
.dstXincrement = 1U,
.xCount = DATACNT,
.srcYincrement = 0U,
.dstYincrement = 0U,
.yCount = 1UL,
.nextDescriptor = &nextDescriptor,
};
if (CY_DMAC_SUCCESS != Cy_DMAC_Descriptor_Init(&descriptor, &descriptor_cfg))
{
/* Insert error handling */
}
/* Scenario: Setup and enable the DMAC channel 0 */
channelConfig.enable = false;
channelConfig.bufferable = false;
if (CY_DMAC_SUCCESS != Cy_DMAC_Channel_Init(DMAC, 0UL, &channelConfig))
{
/* Insert error handling */
}
Cy_DMAC_Channel_SetDescriptor(DMAC, 0UL, &descriptor);
Cy_DMAC_Channel_SetPriority(DMAC, 0UL, 3UL);

◆ 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 the DMAC channel 0 if it's priority equals 3 */
if (3UL == Cy_DMAC_Channel_GetPriority(DMAC, 0UL))
{
if (0UL != Cy_DMAC_GetActiveChannel(DMAC))
{
/* if needed (if there is only channel used) the whole block can be disabled */
}
}

◆ Cy_DMAC_Channel_GetCurrentSrcAddress()

__STATIC_INLINE void * Cy_DMAC_Channel_GetCurrentSrcAddress ( DMAC_Type *  base,
uint32_t  channel 
)

Returns the source address being used for the current transfer.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
Returns
Returns the pointer to the source of transfer.
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_Channel_GetCurrentSrcAddress(DMAC, 0UL)) &&
((void*) dst != Cy_DMAC_Channel_GetCurrentDstAddress(DMAC, 0UL)))
{
/* Read the dst/modify the src arrays content here */
}

◆ Cy_DMAC_Channel_GetCurrentDstAddress()

__STATIC_INLINE void * Cy_DMAC_Channel_GetCurrentDstAddress ( DMAC_Type *  base,
uint32_t  channel 
)

Returns the destination address being used for the current transfer.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
Returns
Returns the pointer to the destination of transfer.
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_Channel_GetCurrentSrcAddress(DMAC, 0UL)) &&
((void*) dst != Cy_DMAC_Channel_GetCurrentDstAddress(DMAC, 0UL)))
{
/* Read the dst/modify the src arrays content here */
}

◆ Cy_DMAC_Channel_GetCurrentXloopIndex()

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

Returns the current transfer X-loop index.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
Returns
Returns the current transfer X-loop 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 x = 7;
uint32_t y = 8;
if (((void*) src == Cy_DMAC_Channel_GetCurrentSrcAddress(DMAC, 0UL)) &&
{
/* Modify the src arrays content here */
}

◆ Cy_DMAC_Channel_GetCurrentYloopIndex()

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

Returns the current transfer X-loop index.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
Returns
Returns the current transfer X-loop 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 x = 7;
uint32_t y = 8;
if (((void*) src == Cy_DMAC_Channel_GetCurrentSrcAddress(DMAC, 0UL)) &&
{
/* Modify the src arrays content here */
}

◆ Cy_DMAC_Channel_GetCurrentDescriptor()

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

Returns the descriptor that is active in the channel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
Returns
The pointer to the descriptor associated with the channel.
Function Usage
/* Scenario: Disable a descriptor */
if (&descriptor != Cy_DMAC_Channel_GetCurrentDescriptor(DMAC, 0UL)) /* Make sure it is not in use */
{
}

◆ Cy_DMAC_Channel_GetInterruptStatus()

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

Returns the interrupt status of the specified channel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
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 */
if (CY_DMAC_INTR_MASK == Cy_DMAC_Channel_GetInterruptStatus (DMAC, 0UL))
{
/* The DMAC channel 0 interrupt is pending */
}

◆ Cy_DMAC_Channel_ClearInterrupt()

__STATIC_INLINE void Cy_DMAC_Channel_ClearInterrupt ( DMAC_Type *  base,
uint32_t  channel,
uint32_t  interrupt 
)

Clears the interrupt status of the specified channel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
interruptThe interrupt mask, see Interrupt Masks.
Function Usage
/* Scenario: Inside the interrupt service routine for DMAC channel 0: */
uint32_t interrupt = Cy_DMAC_Channel_GetInterruptStatusMasked(DMAC, 0UL);
if (CY_DMAC_INTR_COMPLETION == interrupt)
{
/* Insert completion interrupt handling */
}
/* Check for other interrupts */
/* Clear interrupts */
Cy_DMAC_Channel_ClearInterrupt(DMAC, 0UL, interrupt);

◆ Cy_DMAC_Channel_SetInterrupt()

__STATIC_INLINE void Cy_DMAC_Channel_SetInterrupt ( DMAC_Type *  base,
uint32_t  channel,
uint32_t  interrupt 
)

Sets the interrupt for the specified channel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
interruptThe interrupt mask. See Interrupt Masks.
Function Usage
/* Scenario: Enable interrupts for channel 0 */
Cy_DMAC_Channel_SetInterruptMask (DMAC, 0UL, CY_DMAC_INTR_MASK);
/* Scenario: Test the interrupt for channel 0 */
/* Now the interrupt should occur (if it is enabled, of course) */
/* Scenario: Disable interrupts for DMAC channel 0 if it is enabled */
if (CY_DMAC_INTR_MASK == Cy_DMAC_Channel_GetInterruptMask(DMAC, 0UL))
{
}

◆ Cy_DMAC_Channel_GetInterruptMask()

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

Returns the interrupt mask value of the specified channel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
Returns
The interrupt mask value. See Interrupt Masks.
Function Usage
/* Scenario: Enable interrupts for channel 0 */
Cy_DMAC_Channel_SetInterruptMask (DMAC, 0UL, CY_DMAC_INTR_MASK);
/* Scenario: Test the interrupt for channel 0 */
/* Now the interrupt should occur (if it is enabled, of course) */
/* Scenario: Disable interrupts for DMAC channel 0 if it is enabled */
if (CY_DMAC_INTR_MASK == Cy_DMAC_Channel_GetInterruptMask(DMAC, 0UL))
{
}

◆ Cy_DMAC_Channel_SetInterruptMask()

__STATIC_INLINE void Cy_DMAC_Channel_SetInterruptMask ( DMAC_Type *  base,
uint32_t  channel,
uint32_t  interrupt 
)

Sets an interrupt mask value for the specified channel.

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
interruptThe interrupt mask, see Interrupt Masks.
Function Usage
/* Scenario: Enable interrupts for channel 0 */
Cy_DMAC_Channel_SetInterruptMask (DMAC, 0UL, CY_DMAC_INTR_MASK);
/* Scenario: Test the interrupt for channel 0 */
/* Now the interrupt should occur (if it is enabled, of course) */
/* Scenario: Disable interrupts for DMAC channel 0 if it is enabled */
if (CY_DMAC_INTR_MASK == Cy_DMAC_Channel_GetInterruptMask(DMAC, 0UL))
{
}

◆ Cy_DMAC_Channel_GetInterruptStatusMasked()

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

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

Parameters
baseThe pointer to the hardware DMAC block.
channelThe channel number.
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_Channel_GetInterruptStatusMasked(DMAC, 0UL);
if (CY_DMAC_INTR_COMPLETION == interrupt)
{
/* Insert completion interrupt handling */
}
/* Check for other interrupts */
/* Clear interrupts */
Cy_DMAC_Channel_ClearInterrupt(DMAC, 0UL, interrupt);