1 /* 2 * Copyright 2019-2023 NXP 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef FSL_SMARTDMA_H_ 9 #define FSL_SMARTDMA_H_ 10 11 #include "fsl_common.h" 12 13 #if defined(MIMXRT533S_SERIES) || defined(MIMXRT555S_SERIES) || defined(MIMXRT595S_cm33_SERIES) 14 #include "fsl_smartdma_rt500.h" 15 #elif defined(MCXN546_cm33_core0_SERIES) || defined(MCXN546_cm33_core1_SERIES) || \ 16 defined(MCXN547_cm33_core0_SERIES) || defined(MCXN547_cm33_core1_SERIES) || defined(MCXN946_cm33_core0_SERIES) || \ 17 defined(MCXN946_cm33_core1_SERIES) || defined(MCXN947_cm33_core0_SERIES) || defined(MCXN947_cm33_core1_SERIES) || \ 18 defined(MCXN236_SERIES) || defined(MCXN235_SERIES) 19 #include "fsl_smartdma_mcxn.h" 20 #else 21 #error "Device not supported" 22 #endif 23 24 /*! 25 * @addtogroup smartdma 26 * @{ 27 */ 28 29 /******************************************************************************* 30 * Definitions 31 ******************************************************************************/ 32 33 /*! @name Driver version */ 34 /*@{*/ 35 /*! @brief SMARTDMA driver version */ 36 #define FSL_SMARTDMA_DRIVER_VERSION (MAKE_VERSION(2, 9, 1)) 37 /*@}*/ 38 39 /*! @brief Callback function prototype for the smartdma driver. */ 40 typedef void (*smartdma_callback_t)(void *param); 41 42 /******************************************************************************* 43 * APIs 44 ******************************************************************************/ 45 46 #if defined(__cplusplus) 47 extern "C" { 48 #endif /* __cplusplus */ 49 50 /*! 51 * @brief Initialize the SMARTDMA. 52 * 53 * @param apiMemAddr The address firmware will be copied to. 54 * @param firmware The firmware to use. 55 * @param firmwareSizeByte Size of firmware. 56 * @deprecated Do not use this function. It has been superceded by 57 * @ref SMARTDMA_InitWithoutFirmware and @ref SMARTDMA_InstallFirmware. 58 */ 59 void SMARTDMA_Init(uint32_t apiMemAddr, const void *firmware, uint32_t firmwareSizeByte); 60 61 /*! 62 * @brief Initialize the SMARTDMA. 63 * 64 * This function is similar with @ref SMARTDMA_Init, the difference is this function 65 * does not install the firmware, the firmware could be installed using 66 * @ref SMARTDMA_InstallFirmware. 67 */ 68 void SMARTDMA_InitWithoutFirmware(void); 69 70 /*! 71 * @brief Install the firmware. 72 * 73 * @param apiMemAddr The address firmware will be copied to. 74 * @param firmware The firmware to use. 75 * @param firmwareSizeByte Size of firmware. 76 * @note Only call this function when SMARTDMA is not busy. 77 */ 78 void SMARTDMA_InstallFirmware(uint32_t apiMemAddr, const void *firmware, uint32_t firmwareSizeByte); 79 80 /*! 81 * @brief Install the complete callback function. 82 * 83 * @param callback The callback called when smartdma program finished. 84 * @param param Parameter for the callback. 85 * @note Only call this function when SMARTDMA is not busy. 86 */ 87 void SMARTDMA_InstallCallback(smartdma_callback_t callback, void *param); 88 89 /*! 90 * @brief Boot the SMARTDMA to run program. 91 * 92 * @param apiIndex Index of the API to call. 93 * @param pParam Pointer to the parameter allocated by caller. 94 * @param mask Value set to register SMARTDMA->ARM2EZH[0:1]. 95 * @note Only call this function when SMARTDMA is not busy. 96 * @note The memory *pParam shall not be freed before the SMARTDMA function finished. 97 */ 98 void SMARTDMA_Boot(uint32_t apiIndex, void *pParam, uint8_t mask); 99 100 /*! 101 * @brief Copy SMARTDMA params and Boot to run program. 102 * 103 * This function is similar with @ref SMARTDMA_Boot, the only difference 104 * is, this function copies the *pParam to a local variable, upper layer 105 * can free the pParam's memory before the SMARTDMA execution finished, 106 * for example, upper layer can define the param as a local variable. 107 * 108 * @param apiIndex Index of the API to call. 109 * @param pParam Pointer to the parameter. 110 * @param mask Value set to SMARTDMA_ARM2SMARTDMA[0:1]. 111 * @note Only call this function when SMARTDMA is not busy. 112 */ 113 void SMARTDMA_Boot1(uint32_t apiIndex, const smartdma_param_t *pParam, uint8_t mask); 114 115 /*! 116 * @brief Deinitialize the SMARTDMA. 117 */ 118 void SMARTDMA_Deinit(void); 119 120 /*! 121 * @brief Reset the SMARTDMA. 122 */ 123 void SMARTDMA_Reset(void); 124 125 /*! 126 * @brief SMARTDMA IRQ. 127 */ 128 void SMARTDMA_HandleIRQ(void); 129 130 #if defined(__cplusplus) 131 } 132 #endif 133 134 /* @} */ 135 136 #endif /* FSL_SMARTDMA_H_ */ 137