Block Functions

group group_dmac_block_functions

Functions

__STATIC_INLINE void Cy_DMAC_Enable (DMAC_Type *base)

Enables the DMACblock.

Function Usage

    
    /* Scenario: Initialize a 1D descriptor */
    #define DATACNT (8UL)
    cy_stc_dmac_descriptor_t descriptor;
    cy_stc_dmac_descriptor_t nextDescriptor;
    uint32_t src[DATACNT];
    uint32_t dst[DATACNT];
    
    cy_stc_dmac_descriptor_config_t descriptor_cfg = 
    {
        .retrigger = CY_DMAC_RETRIG_IM,
        .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 */
    cy_stc_dmac_channel_config_t channelConfig;
    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(DMAC, 0UL);
    
    Cy_DMAC_Enable(DMAC);
    

Parameters
  • base: The pointer to the hardware DMAC block.

__STATIC_INLINE void Cy_DMAC_Disable (DMAC_Type *base)

Disables the DMACblock.

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))
        {
            Cy_DMAC_Channel_Disable(DMAC, 0UL);
            Cy_DMAC_Channel_DeInit(DMAC, 0UL);

            /* if needed (if there is only channel used) the whole block can be disabled */
            Cy_DMAC_Disable(DMAC);
        }
    }
    

Parameters
  • base: The pointer to the hardware DMAC block.

__STATIC_INLINE uint32_t Cy_DMAC_GetActiveChannel (DMAC_Type const *base)

Returns the status of the active/pending channels of the DMACblock.

Return

Returns a bit-field with all of the currently active/pending channels in the DMAC block.

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))
        {
            Cy_DMAC_Channel_Disable(DMAC, 0UL);
            Cy_DMAC_Channel_DeInit(DMAC, 0UL);

            /* if needed (if there is only channel used) the whole block can be disabled */
            Cy_DMAC_Disable(DMAC);
        }
    }
    

Parameters
  • base: The pointer to the hardware DMAC block.