/**************************************************************************//** * @file pdma.h * @version V3.00 * @brief M2354 series PDMA driver header file * * @copyright SPDX-License-Identifier: Apache-2.0 * @copyright Copyright (C) 2020 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __PDMA_H__ #define __PDMA_H__ #ifdef __cplusplus extern "C" { #endif /** @addtogroup Standard_Driver Standard Driver @{ */ /** @addtogroup PDMA_Driver PDMA Driver @{ */ /** @addtogroup PDMA_EXPORTED_CONSTANTS PDMA Exported Constants @{ */ #define PDMA_CH_MAX 8UL /*!< Specify Maximum Channels of PDMA \hideinitializer */ /*---------------------------------------------------------------------------------------------------------*/ /* Operation Mode Constant Definitions */ /*---------------------------------------------------------------------------------------------------------*/ #define PDMA_OP_STOP 0x00000000UL /*!INTSTS)) /** * @brief Get Transfer Done Interrupt Status * * @param[in] pdma The pointer of the specified PDMA module * * @return None * * @details Get the transfer done Interrupt status. */ #define PDMA_GET_TD_STS(pdma) ((uint32_t)((pdma)->TDSTS)) /** * @brief Clear Transfer Done Interrupt Status * * @param[in] pdma The pointer of the specified PDMA module * @param[in] u32Mask The channel mask * * @return None * * @details Clear the transfer done Interrupt status. */ #define PDMA_CLR_TD_FLAG(pdma, u32Mask) ((uint32_t)((pdma)->TDSTS = (u32Mask))) /** * @brief Get Target Abort Interrupt Status * * @param[in] pdma The pointer of the specified PDMA module * * @return None * * @details Get the target abort Interrupt status. */ #define PDMA_GET_ABORT_STS(pdma) ((uint32_t)((pdma)->ABTSTS)) /** * @brief Clear Target Abort Interrupt Status * * @param[in] pdma The pointer of the specified PDMA module * @param[in] u32Mask The channel mask * * @return None * * @details Clear the target abort Interrupt status. */ #define PDMA_CLR_ABORT_FLAG(pdma, u32Mask) ((uint32_t)((pdma)->ABTSTS = (u32Mask))) /** * @brief Get PDMA Transfer Alignment Status * * @param[in] pdma The pointer of the specified PDMA module * * @return None * * @details Get the PDMA transfer alignment status. */ #define PDMA_GET_ALIGN_STS(pdma) ((uint32_t)((pdma)->ALIGN)) /** * @brief Clear PDMA Transfer Alignment Interrupt Status * * @param[in] pdma The pointer of the specified PDMA module * @param[in] u32Mask The channel mask * * @return None * * @details Clear the PDMA transfer alignment Interrupt status. */ #define PDMA_CLR_ALIGN_FLAG(pdma, u32Mask) ((uint32_t)((pdma)->ALIGN = (u32Mask))) /** * @brief Clear Timeout Interrupt Status * * @param[in] pdma The pointer of the specified PDMA module * @param[in] u32Ch The selected channel * * @return None * * @details Clear the selected channel timeout interrupt status. * @note This function is only supported in channel 0 and channel 1. */ #define PDMA_CLR_TMOUT_FLAG(pdma, u32Ch) ((uint32_t)((pdma)->INTSTS = (1UL << ((u32Ch) + 8UL)))) /** * @brief Check Channel Status * * @param[in] pdma The pointer of the specified PDMA module * @param[in] u32Ch The selected channel * * @retval 0 Idle state * @retval 1 Busy state * * @details Check the selected channel is busy or not. */ #define PDMA_IS_CH_BUSY(pdma, u32Ch) ((uint32_t)((pdma)->TRGSTS & (1UL << (u32Ch)))? 1 : 0) /** * @brief Set Source Address * * @param[in] pdma The pointer of the specified PDMA module * @param[in] u32Ch The selected channel * @param[in] u32Addr The selected address * * @return None * * @details This macro set the selected channel source address. */ #define PDMA_SET_SRC_ADDR(pdma, u32Ch, u32Addr) ((uint32_t)((pdma)->DSCT[(u32Ch)].SA = (u32Addr))) /** * @brief Set Destination Address * * @param[in] pdma The pointer of the specified PDMA module * @param[in] u32Ch The selected channel * @param[in] u32Addr The selected address * * @return None * * @details This macro set the selected channel destination address. */ #define PDMA_SET_DST_ADDR(pdma, u32Ch, u32Addr) ((uint32_t)((pdma)->DSCT[(u32Ch)].DA = (u32Addr))) /** * @brief Set Transfer Count * * @param[in] pdma The pointer of the specified PDMA module * @param[in] u32Ch The selected channel * @param[in] u32TransCount Transfer Count * * @return None * * @details This macro set the selected channel transfer count. */ #define PDMA_SET_TRANS_CNT(pdma, u32Ch, u32TransCount) ((uint32_t)((pdma)->DSCT[(u32Ch)].CTL=((pdma)->DSCT[(u32Ch)].CTL&~PDMA_DSCT_CTL_TXCNT_Msk)|(((u32TransCount)-1UL) << PDMA_DSCT_CTL_TXCNT_Pos))) /** * @brief Set Scatter-gather descriptor Address * * @param[in] pdma The pointer of the specified PDMA module * @param[in] u32Ch The selected channel * @param[in] u32Addr The descriptor address * * @return None * * @details This macro set the selected channel scatter-gather descriptor address. */ #define PDMA_SET_SCATTER_DESC(pdma, u32Ch, u32Addr) ((uint32_t)((pdma)->DSCT[(u32Ch)].NEXT = (u32Addr) - ((pdma)->SCATBA))) /** * @brief Stop the channel * * @param[in] pdma The pointer of the specified PDMA module * @param[in] u32Ch The selected channel * * @return None * * @details This macro stop the selected channel. */ #define PDMA_STOP(pdma, u32Ch) ((uint32_t)((pdma)->PAUSE = (1UL << (u32Ch)))) /** * @brief Pause the channel * * @param[in] pdma The pointer of the specified PDMA module * @param[in] u32Ch The selected channel * * @return None * * @details This macro pause the selected channel. */ #define PDMA_PAUSE(pdma, u32Ch) ((uint32_t)((pdma)->PAUSE = (1UL << (u32Ch)))) /** * @brief Reset the channel * * @param[in] pdma The pointer of the specified PDMA module * @param[in] u32Ch The selected channel * * @return None * * @details This macro reset the selected channel. */ #define PDMA_RESET(pdma, u32Ch) ((uint32_t)((pdma)->CHRST = (1UL << (u32Ch)))) /*---------------------------------------------------------------------------------------------------------*/ /* Define PWM functions prototype */ /*---------------------------------------------------------------------------------------------------------*/ void PDMA_Open(PDMA_T *pdma, uint32_t u32Mask); void PDMA_Close(PDMA_T *pdma); void PDMA_SetTransferCnt(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32Width, uint32_t u32TransCount); void PDMA_SetStride(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32DestLen, uint32_t u32SrcLen, uint32_t u32TransCount); void PDMA_SetRepeat(PDMA_T * pdma, uint32_t u32Ch, uint32_t u32DestInterval, uint32_t u32SrcInterval, uint32_t u32RepeatCount); void PDMA_SetTransferAddr(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32SrcAddr, uint32_t u32SrcCtrl, uint32_t u32DstAddr, uint32_t u32DstCtrl); void PDMA_SetTransferMode(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32Peripheral, uint32_t u32ScatterEn, uint32_t u32DescAddr); void PDMA_SetBurstType(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32BurstType, uint32_t u32BurstSize); void PDMA_EnableTimeout(PDMA_T *pdma, uint32_t u32Mask); void PDMA_DisableTimeout(PDMA_T *pdma, uint32_t u32Mask); void PDMA_SetTimeOut(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32OnOff, uint32_t u32TimeOutCnt); void PDMA_Trigger(PDMA_T *pdma, uint32_t u32Ch); void PDMA_EnableInt(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32Mask); void PDMA_DisableInt(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32Mask); /**@}*/ /* end of group PDMA_EXPORTED_FUNCTIONS */ /**@}*/ /* end of group PDMA_Driver */ /**@}*/ /* end of group Standard_Driver */ #ifdef __cplusplus } #endif #endif /* __PDMA_H__ */