Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
dma_api.h
00001 #ifndef MBED_DMA_API_H 00002 #define MBED_DMA_API_H 00003 00004 00005 00006 #include "device.h" 00007 #include "platform.h" 00008 #include <stdbool.h> 00009 00010 00011 00012 #ifdef __cplusplus 00013 extern "C" { 00014 #endif 00015 00016 //Declare number of DMA channels available. Defined in the dma_api.c 00017 extern int _channel_num ; 00018 00019 00020 typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState; 00021 00022 00023 //DMA transfer type 00024 typedef enum { 00025 M2M = 0x00, 00026 M2P = 0x01, 00027 P2M = 0x02, 00028 P2P = 0x03 00029 } TransferType; 00030 00031 00032 00033 // DMA Trigger type. 00034 // To be done: trigger type should be able to caculated automatically according to source/destination address 00035 typedef enum { 00036 ALWAYS , 00037 _SSP0_TX, 00038 _SSP0_RX, 00039 _SSP1_TX, 00040 _SSP1_RX, 00041 _ADC, 00042 _I2S0, 00043 _I2S1, 00044 _DAC, 00045 _UART0_TX, 00046 _UART0_RX, 00047 _UART1_TX, 00048 _UART1_RX, 00049 _UART2_TX, 00050 _UART2_RX, 00051 _UART3_TX, 00052 _UART3_RX, 00053 _MATCH0_0, 00054 _MATCH0_1, 00055 _MATCH1_0, 00056 _MATCH1_1, 00057 _MATCH2_0, 00058 _MATCH2_1, 00059 _MATCH3_0, 00060 _MATCH3_1 00061 } TriggerType; 00062 00063 //define DMA interrupt type: ERR, generated when err happens; FINISH, generated when transfer finish 00064 typedef enum {ERR, FINISH} DMA_IT; 00065 00066 // declear DMA IRQ. The real IRQ number will be defined in per platform file dma_api.c 00067 extern IRQn_Type _DMA_IRQ; 00068 00069 00070 // Forward declaration 00071 // DMA Init structures definition. It is used to describe DMA configurable features. 00072 00073 typedef struct DMA_InitTypeDef DMA_InitTypeDef; 00074 00075 typedef struct LLI 00076 { 00077 uint32_t LLI_src; 00078 uint32_t LLI_dst; 00079 uint32_t LLI_next; 00080 uint32_t LLI_control; // Only care about transfer size, as other charactors will be same as initial transfer 00081 }LLI; 00082 00083 void DMA_destination(DMA_InitTypeDef* DMA_InitStruct, const uint32_t dst, unsigned int width, bool inc); 00084 void DMA_source(DMA_InitTypeDef* DMA_InitStruct, const uint32_t src, unsigned int width, bool inc); 00085 void DMA_trigger_source(DMA_InitTypeDef* DMA_InitStruct, TriggerType trig); 00086 void DMA_trigger_destination(DMA_InitTypeDef* DMA_InitStruct, TriggerType trig); 00087 00088 /** 00089 * @brief Initializes the DMAy Channelx according to the specified parameters 00090 * in the DMA_InitStruct. 00091 * @param channel. The chosen channel number. 00092 * @param DMA_InitStruct: pointer to a DMA_InitTypeDef structure that contains 00093 * the configuration information for the specified DMA Channel. 00094 * @retval None 00095 */ 00096 void DMA_init(int channel, DMA_InitTypeDef* DMA_InitStruct); 00097 00098 void DMA_start(int channel, DMA_InitTypeDef* DMA_InitStruct, unsigned int lengh); 00099 //void DMA_next(DMA_InitTypeDef* DMA_InitStruct, LLI* list); 00100 void DMA_next(DMA_InitTypeDef* DMA_InitStruct, const uint32_t src, const uint32_t dst, uint32_t size); // The input size has to smaller than 4096bytes. 00101 /** 00102 * @brief Check whether channel is active or not 00103 * @param channel. The channel number. 00104 * @retval 0 or 1 00105 */ 00106 bool DMA_channel_active(int channel); 00107 00108 00109 00110 /** 00111 * @brief Reset the DMA channel to default reset value 00112 * @param channel. The chosen channel number 00113 * @retval None 00114 */ 00115 void DMA_reset(int channel); 00116 00117 00118 /** 00119 * @brief Allocate a struct pointer point to DMA_InitTypeDef type memory space. Fills each DMA_InitStruct member with its default value. 00120 * @param None 00121 * @retval a pointer point to a DMA_InitTypeDef structure. 00122 */ 00123 DMA_InitTypeDef* DMA_struct_create(void); 00124 00125 00126 00127 /** 00128 * @brief Delete the memory allocated for the DMA_InitTypeDef structure 00129 * @param A pointer point to a DMA_InitTypeDef structure 00130 * @retval None 00131 */ 00132 void DMA_struct_delete(DMA_InitTypeDef* ptr); 00133 00134 00135 typedef void (*func_ptr)(); 00136 00137 00138 00139 void DMA_IRQ_handler(void); 00140 void DMA_IRQ_attach(int channel, int status, func_ptr ptr); 00141 void DMA_IRQ_detach(int channel); 00142 00143 #ifdef __cplusplus 00144 } 00145 #endif 00146 00147 #endif
Generated on Sat Jul 16 2022 23:21:49 by
1.7.2