/**************************************************************************//** * @file lppdma.h * @version V1.00 * @brief M2L31 series LPPDMA driver header file * * SPDX-License-Identifier: Apache-2.0 * @copyright (C) 2023 Nuvoton Technology Corp. All rights reserved. *****************************************************************************/ #ifndef __LPPDMA_H__ #define __LPPDMA_H__ #ifdef __cplusplus extern "C" { #endif /** @addtogroup Standard_Driver Standard Driver @{ */ /** @addtogroup LPPDMA_Driver LPPDMA Driver @{ */ /** @addtogroup LPPDMA_EXPORTED_CONSTANTS LPPDMA Exported Constants @{ */ #define LPPDMA_CH_MAX 4UL /*!< Specify Maximum Channels of LPPDMA \hideinitializer */ /*---------------------------------------------------------------------------------------------------------*/ /* Operation Mode Constant Definitions */ /*---------------------------------------------------------------------------------------------------------*/ #define LPPDMA_OP_STOP 0x00000000UL /*!INTSTS)) /** * @brief Get Transfer Done Interrupt Status * * @param[in] lppdma The pointer of the specified LPPDMA module * * @return None * * @details Get the transfer done Interrupt status. * \hideinitializer */ #define LPPDMA_GET_TD_STS(lppdma) ((uint32_t)(lppdma->TDSTS)) /** * @brief Clear Transfer Done Interrupt Status * * @param[in] lppdma The pointer of the specified LPPDMA module * * @param[in] u32Mask The channel mask * * @return None * * @details Clear the transfer done Interrupt status. * \hideinitializer */ #define LPPDMA_CLR_TD_FLAG(lppdma,u32Mask) ((uint32_t)(lppdma->TDSTS = (u32Mask))) /** * @brief Get Target Abort Interrupt Status * * @param[in] lppdma The pointer of the specified LPPDMA module * * @return None * * @details Get the target abort Interrupt status. * \hideinitializer */ #define LPPDMA_GET_ABORT_STS(lppdma) ((uint32_t)(lppdma->ABTSTS)) /** * @brief Clear Target Abort Interrupt Status * * @param[in] lppdma The pointer of the specified LPPDMA module * * @param[in] u32Mask The channel mask * * @return None * * @details Clear the target abort Interrupt status. * \hideinitializer */ #define LPPDMA_CLR_ABORT_FLAG(lppdma,u32Mask) ((uint32_t)(lppdma->ABTSTS = (u32Mask))) /** * @brief Get Alignment Interrupt Status * * @param[in] lppdma The pointer of the specified LPPDMA module * * @return None * * @details Get Alignment Interrupt status. * \hideinitializer */ #define LPPDMA_GET_ALIGN_STS(lppdma) ((uint32_t)(lppdma->ALIGN)) /** * @brief Clear Alignment Interrupt Status * * @param[in] lppdma The pointer of the specified LPPDMA module * @param[in] u32Mask The channel mask * * @return None * * @details Clear the Alignment Interrupt status. * \hideinitializer */ #define LPPDMA_CLR_ALIGN_FLAG(lppdma,u32Mask) ((uint32_t)(lppdma->ALIGN = (u32Mask))) /** * @brief Check Channel Status * * @param[in] lppdma The pointer of the specified LPPDMA module * @param[in] u32Ch The selected channel * * @retval 0 Idle state * @retval 1 Busy state * * @details Check the selected channel is busy or not. * \hideinitializer */ #define LPPDMA_IS_CH_BUSY(lppdma,u32Ch) ((uint32_t)(lppdma->TRGSTS & (1UL << (u32Ch)))? 1 : 0) /** * @brief Set Source Address * * @param[in] lppdma The pointer of the specified LPPDMA module * @param[in] u32Ch The selected channel * @param[in] u32Addr The selected address * * @return None * * @details This macro set the selected channel source address. * \hideinitializer */ #define LPPDMA_SET_SRC_ADDR(lppdma,u32Ch, u32Addr) ((uint32_t)(lppdma->LPDSCT[(u32Ch)].SA = (u32Addr))) /** * @brief Set Destination Address * * @param[in] lppdma The pointer of the specified LPPDMA module * @param[in] u32Ch The selected channel * @param[in] u32Addr The selected address * * @return None * * @details This macro set the selected channel destination address. * \hideinitializer */ #define LPPDMA_SET_DST_ADDR(lppdma,u32Ch, u32Addr) ((uint32_t)(lppdma->LPDSCT[(u32Ch)].DA = (u32Addr))) /** * @brief Set Transfer Count * * @param[in] lppdma The pointer of the specified LPPDMA module * @param[in] u32Ch The selected channel * @param[in] u32TransCount Transfer Count * * @return None * * @details This macro set the selected channel transfer count. * \hideinitializer */ #define LPPDMA_SET_TRANS_CNT(lppdma,u32Ch, u32TransCount) ((uint32_t)(lppdma->LPDSCT[(u32Ch)].CTL=(lppdma->LPDSCT[(u32Ch)].CTL&~LPPDMA_DSCT_CTL_TXCNT_Msk)|(((u32TransCount)-1UL) << LPPDMA_DSCT_CTL_TXCNT_Pos))) /** * @brief Set Scatter-gather descriptor Address * * @param[in] lppdma The pointer of the specified LPPDMA 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. * \hideinitializer */ #define LPPDMA_SET_SCATTER_DESC(lppdma,u32Ch, u32Addr) ((uint32_t)(lppdma->LPDSCT[(u32Ch)].NEXT = (u32Addr) - (lppdma->SCATBA))) /** * @brief Stop the channel * * @param[in] lppdma The pointer of the specified LPPDMA module * * @param[in] u32Ch The selected channel * * @return None * * @details This macro stop the selected channel. * \hideinitializer */ #define LPPDMA_STOP(lppdma,u32Ch) ((uint32_t)(lppdma->PAUSE = (1UL << (u32Ch)))) /** * @brief Pause the channel * * @param[in] lppdma The pointer of the specified LPPDMA module * * @param[in] u32Ch The selected channel * * @return None * * @details This macro pause the selected channel. * \hideinitializer */ #define LPPDMA_PAUSE(lppdma,u32Ch) ((uint32_t)(lppdma->PAUSE = (1UL << (u32Ch)))) /*---------------------------------------------------------------------------------------------------------*/ /* Define PDMA functions prototype */ /*---------------------------------------------------------------------------------------------------------*/ void LPPDMA_Open(LPPDMA_T * lppdma,uint32_t u32Mask); void LPPDMA_Close(LPPDMA_T * lppdma); void LPPDMA_SetTransferCnt(LPPDMA_T * lppdma,uint32_t u32Ch, uint32_t u32Width, uint32_t u32TransCount); void LPPDMA_SetTransferAddr(LPPDMA_T * lppdma,uint32_t u32Ch, uint32_t u32SrcAddr, uint32_t u32SrcCtrl, uint32_t u32DstAddr, uint32_t u32DstCtrl); void LPPDMA_SetTransferMode(LPPDMA_T * lppdma,uint32_t u32Ch, uint32_t u32Peripheral, uint32_t u32ScatterEn, uint32_t u32DescAddr); void LPPDMA_SetBurstType(LPPDMA_T * lppdma,uint32_t u32Ch, uint32_t u32BurstType, uint32_t u32BurstSize); void LPPDMA_Trigger(LPPDMA_T * lppdma,uint32_t u32Ch); void LPPDMA_EnableInt(LPPDMA_T * lppdma,uint32_t u32Ch, uint32_t u32Mask); void LPPDMA_DisableInt(LPPDMA_T * lppdma,uint32_t u32Ch, uint32_t u32Mask); /*@}*/ /* end of group LPPDMA_EXPORTED_FUNCTIONS */ /*@}*/ /* end of group LPPDMA_Driver */ /*@}*/ /* end of group Standard_Driver */ #ifdef __cplusplus } #endif #endif /* __LPPDMA_H__ */ /*** (C) COPYRIGHT 2023 Nuvoton Technology Corp. ***/