140 #define TRANSFER_IT_ENABLE_MASK (uint32_t)(DMA_SxCR_TCIE | DMA_SxCR_HTIE | \
141 DMA_SxCR_TEIE | DMA_SxCR_DMEIE)
143 #define DMA_Stream0_IT_MASK (uint32_t)(DMA_LISR_FEIF0 | DMA_LISR_DMEIF0 | \
144 DMA_LISR_TEIF0 | DMA_LISR_HTIF0 | \
147 #define DMA_Stream1_IT_MASK (uint32_t)(DMA_Stream0_IT_MASK << 6)
148 #define DMA_Stream2_IT_MASK (uint32_t)(DMA_Stream0_IT_MASK << 16)
149 #define DMA_Stream3_IT_MASK (uint32_t)(DMA_Stream0_IT_MASK << 22)
150 #define DMA_Stream4_IT_MASK (uint32_t)(DMA_Stream0_IT_MASK | (uint32_t)0x20000000)
151 #define DMA_Stream5_IT_MASK (uint32_t)(DMA_Stream1_IT_MASK | (uint32_t)0x20000000)
152 #define DMA_Stream6_IT_MASK (uint32_t)(DMA_Stream2_IT_MASK | (uint32_t)0x20000000)
153 #define DMA_Stream7_IT_MASK (uint32_t)(DMA_Stream3_IT_MASK | (uint32_t)0x20000000)
154 #define TRANSFER_IT_MASK (uint32_t)0x0F3C0F3C
155 #define HIGH_ISR_MASK (uint32_t)0x20000000
156 #define RESERVED_MASK (uint32_t)0x0F7D0F7D
199 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
202 DMAy_Streamx->CR &= ~((uint32_t)DMA_SxCR_EN);
205 DMAy_Streamx->CR = 0;
208 DMAy_Streamx->NDTR = 0;
211 DMAy_Streamx->PAR = 0;
214 DMAy_Streamx->M0AR = 0;
217 DMAy_Streamx->M1AR = 0;
220 DMAy_Streamx->FCR = (uint32_t)0x00000021;
223 if (DMAy_Streamx == DMA1_Stream0)
226 DMA1->LIFCR = DMA_Stream0_IT_MASK;
228 else if (DMAy_Streamx == DMA1_Stream1)
231 DMA1->LIFCR = DMA_Stream1_IT_MASK;
233 else if (DMAy_Streamx == DMA1_Stream2)
236 DMA1->LIFCR = DMA_Stream2_IT_MASK;
238 else if (DMAy_Streamx == DMA1_Stream3)
241 DMA1->LIFCR = DMA_Stream3_IT_MASK;
243 else if (DMAy_Streamx == DMA1_Stream4)
246 DMA1->HIFCR = DMA_Stream4_IT_MASK;
248 else if (DMAy_Streamx == DMA1_Stream5)
251 DMA1->HIFCR = DMA_Stream5_IT_MASK;
253 else if (DMAy_Streamx == DMA1_Stream6)
256 DMA1->HIFCR = (uint32_t)DMA_Stream6_IT_MASK;
258 else if (DMAy_Streamx == DMA1_Stream7)
261 DMA1->HIFCR = DMA_Stream7_IT_MASK;
263 else if (DMAy_Streamx == DMA2_Stream0)
266 DMA2->LIFCR = DMA_Stream0_IT_MASK;
268 else if (DMAy_Streamx == DMA2_Stream1)
271 DMA2->LIFCR = DMA_Stream1_IT_MASK;
273 else if (DMAy_Streamx == DMA2_Stream2)
276 DMA2->LIFCR = DMA_Stream2_IT_MASK;
278 else if (DMAy_Streamx == DMA2_Stream3)
281 DMA2->LIFCR = DMA_Stream3_IT_MASK;
283 else if (DMAy_Streamx == DMA2_Stream4)
286 DMA2->HIFCR = DMA_Stream4_IT_MASK;
288 else if (DMAy_Streamx == DMA2_Stream5)
291 DMA2->HIFCR = DMA_Stream5_IT_MASK;
293 else if (DMAy_Streamx == DMA2_Stream6)
296 DMA2->HIFCR = DMA_Stream6_IT_MASK;
300 if (DMAy_Streamx == DMA2_Stream7)
303 DMA2->HIFCR = DMA_Stream7_IT_MASK;
324 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
325 assert_param(IS_DMA_CHANNEL(DMA_InitStruct->
DMA_Channel));
326 assert_param(IS_DMA_DIRECTION(DMA_InitStruct->
DMA_DIR));
329 assert_param(IS_DMA_MEMORY_INC_STATE(DMA_InitStruct->
DMA_MemoryInc));
332 assert_param(IS_DMA_MODE(DMA_InitStruct->
DMA_Mode));
333 assert_param(IS_DMA_PRIORITY(DMA_InitStruct->
DMA_Priority));
334 assert_param(IS_DMA_FIFO_MODE_STATE(DMA_InitStruct->
DMA_FIFOMode));
341 tmpreg = DMAy_Streamx->CR;
344 tmpreg &= ((uint32_t)~(DMA_SxCR_CHSEL | DMA_SxCR_MBURST | DMA_SxCR_PBURST | \
345 DMA_SxCR_PL | DMA_SxCR_MSIZE | DMA_SxCR_PSIZE | \
346 DMA_SxCR_MINC | DMA_SxCR_PINC | DMA_SxCR_CIRC | \
367 DMAy_Streamx->CR = tmpreg;
371 tmpreg = DMAy_Streamx->FCR;
374 tmpreg &= (uint32_t)~(DMA_SxFCR_DMDIS | DMA_SxFCR_FTH);
382 DMAy_Streamx->FCR = tmpreg;
416 DMA_InitStruct->
DMA_DIR = DMA_DIR_PeripheralToMemory;
434 DMA_InitStruct->
DMA_Mode = DMA_Mode_Normal;
478 void DMA_Cmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState)
481 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
482 assert_param(IS_FUNCTIONAL_STATE(NewState));
484 if (NewState != DISABLE)
487 DMAy_Streamx->CR |= (uint32_t)DMA_SxCR_EN;
492 DMAy_Streamx->CR &= ~(uint32_t)DMA_SxCR_EN;
517 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
518 assert_param(IS_DMA_PINCOS_SIZE(DMA_Pincos));
521 if(DMA_Pincos != DMA_PINCOS_Psize)
524 DMAy_Streamx->CR |= (uint32_t)DMA_SxCR_PINCOS;
529 DMAy_Streamx->CR &= ~(uint32_t)DMA_SxCR_PINCOS;
553 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
554 assert_param(IS_DMA_FLOW_CTRL(DMA_FlowCtrl));
557 if(DMA_FlowCtrl != DMA_FlowCtrl_Memory)
560 DMAy_Streamx->CR |= (uint32_t)DMA_SxCR_PFCTRL;
565 DMAy_Streamx->CR &= ~(uint32_t)DMA_SxCR_PFCTRL;
635 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
638 DMAy_Streamx->NDTR = (uint16_t)Counter;
650 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
653 return ((uint16_t)(DMAy_Streamx->NDTR));
731 uint32_t DMA_CurrentMemory)
734 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
735 assert_param(IS_DMA_CURRENT_MEM(DMA_CurrentMemory));
737 if (DMA_CurrentMemory != DMA_Memory_0)
740 DMAy_Streamx->CR |= (uint32_t)(DMA_SxCR_CT);
745 DMAy_Streamx->CR &= ~(uint32_t)(DMA_SxCR_CT);
749 DMAy_Streamx->M1AR = Memory1BaseAddr;
764 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
765 assert_param(IS_FUNCTIONAL_STATE(NewState));
768 if (NewState != DISABLE)
771 DMAy_Streamx->CR |= (uint32_t)DMA_SxCR_DBM;
776 DMAy_Streamx->CR &= ~(uint32_t)DMA_SxCR_DBM;
803 uint32_t DMA_MemoryTarget)
806 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
807 assert_param(IS_DMA_CURRENT_MEM(DMA_MemoryTarget));
810 if (DMA_MemoryTarget != DMA_Memory_0)
813 DMAy_Streamx->M1AR = MemoryBaseAddr;
818 DMAy_Streamx->M0AR = MemoryBaseAddr;
833 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
836 if ((DMAy_Streamx->CR & DMA_SxCR_CT) != 0)
945 FunctionalState state = DISABLE;
948 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
950 if ((DMAy_Streamx->CR & (uint32_t)DMA_SxCR_EN) != 0)
982 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
985 tmpreg = (uint32_t)((DMAy_Streamx->FCR & DMA_SxFCR_FS));
1006 FlagStatus bitstatus = RESET;
1008 uint32_t tmpreg = 0;
1011 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
1012 assert_param(IS_DMA_GET_FLAG(DMA_FLAG));
1015 if (DMAy_Streamx < DMA2_Stream0)
1027 if ((DMA_FLAG & HIGH_ISR_MASK) != (uint32_t)RESET)
1030 tmpreg = DMAy->HISR;
1035 tmpreg = DMAy->LISR;
1039 tmpreg &= (uint32_t)RESERVED_MASK;
1042 if ((tmpreg & DMA_FLAG) != (uint32_t)RESET)
1076 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
1077 assert_param(IS_DMA_CLEAR_FLAG(DMA_FLAG));
1080 if (DMAy_Streamx < DMA2_Stream0)
1092 if ((DMA_FLAG & HIGH_ISR_MASK) != (uint32_t)RESET)
1095 DMAy->HIFCR = (uint32_t)(DMA_FLAG & RESERVED_MASK);
1100 DMAy->LIFCR = (uint32_t)(DMA_FLAG & RESERVED_MASK);
1118 void DMA_ITConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState)
1121 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
1122 assert_param(IS_DMA_CONFIG_IT(DMA_IT));
1123 assert_param(IS_FUNCTIONAL_STATE(NewState));
1126 if ((DMA_IT & DMA_IT_FE) != 0)
1128 if (NewState != DISABLE)
1131 DMAy_Streamx->FCR |= (uint32_t)DMA_IT_FE;
1136 DMAy_Streamx->FCR &= ~(uint32_t)DMA_IT_FE;
1141 if (DMA_IT != DMA_IT_FE)
1143 if (NewState != DISABLE)
1146 DMAy_Streamx->CR |= (uint32_t)(DMA_IT & TRANSFER_IT_ENABLE_MASK);
1151 DMAy_Streamx->CR &= ~(uint32_t)(DMA_IT & TRANSFER_IT_ENABLE_MASK);
1172 ITStatus bitstatus = RESET;
1174 uint32_t tmpreg = 0, enablestatus = 0;
1177 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
1178 assert_param(IS_DMA_GET_IT(DMA_IT));
1181 if (DMAy_Streamx < DMA2_Stream0)
1193 if ((DMA_IT & TRANSFER_IT_MASK) != (uint32_t)RESET)
1196 tmpreg = (uint32_t)((DMA_IT >> 11) & TRANSFER_IT_ENABLE_MASK);
1199 enablestatus = (uint32_t)(DMAy_Streamx->CR & tmpreg);
1204 enablestatus = (uint32_t)(DMAy_Streamx->FCR & DMA_IT_FE);
1208 if ((DMA_IT & HIGH_ISR_MASK) != (uint32_t)RESET)
1211 tmpreg = DMAy->HISR ;
1216 tmpreg = DMAy->LISR ;
1220 tmpreg &= (uint32_t)RESERVED_MASK;
1223 if (((tmpreg & DMA_IT) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET))
1257 assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
1258 assert_param(IS_DMA_CLEAR_IT(DMA_IT));
1261 if (DMAy_Streamx < DMA2_Stream0)
1273 if ((DMA_IT & HIGH_ISR_MASK) != (uint32_t)RESET)
1276 DMAy->HIFCR = (uint32_t)(DMA_IT & RESERVED_MASK);
1281 DMAy->LIFCR = (uint32_t)(DMA_IT & RESERVED_MASK);
This file contains all the functions prototypes for the RCC firmware library.
FunctionalState DMA_GetCmdStatus(DMA_Stream_TypeDef *DMAy_Streamx)
Returns the status of EN bit for the specified DMAy Streamx.
ITStatus DMA_GetITStatus(DMA_Stream_TypeDef *DMAy_Streamx, uint32_t DMA_IT)
Checks whether the specified DMAy Streamx interrupt has occurred or not.
uint32_t DMA_PeripheralBurst
uint32_t DMA_PeripheralDataSize
uint32_t DMA_PeripheralBaseAddr
void DMA_DoubleBufferModeCmd(DMA_Stream_TypeDef *DMAy_Streamx, FunctionalState NewState)
Enables or disables the double buffer mode for the selected DMA stream.
FlagStatus DMA_GetFlagStatus(DMA_Stream_TypeDef *DMAy_Streamx, uint32_t DMA_FLAG)
Checks whether the specified DMAy Streamx flag is set or not.
void DMA_PeriphIncOffsetSizeConfig(DMA_Stream_TypeDef *DMAy_Streamx, uint32_t DMA_Pincos)
Configures, when the PINC (Peripheral Increment address mode) bit is set, if the peripheral address s...
uint32_t DMA_GetCurrentMemoryTarget(DMA_Stream_TypeDef *DMAy_Streamx)
Returns the current memory target used by double buffer transfer.
void DMA_StructInit(DMA_InitTypeDef *DMA_InitStruct)
Fills each DMA_InitStruct member with its default value.
void DMA_ITConfig(DMA_Stream_TypeDef *DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState)
Enables or disables the specified DMAy Streamx interrupts.
void DMA_Init(DMA_Stream_TypeDef *DMAy_Streamx, DMA_InitTypeDef *DMA_InitStruct)
Initializes the DMAy Streamx according to the specified parameters in the DMA_InitStruct structure...
void DMA_SetCurrDataCounter(DMA_Stream_TypeDef *DMAy_Streamx, uint16_t Counter)
Writes the number of data units to be transferred on the DMAy Streamx.
void DMA_MemoryTargetConfig(DMA_Stream_TypeDef *DMAy_Streamx, uint32_t MemoryBaseAddr, uint32_t DMA_MemoryTarget)
Configures the Memory address for the next buffer transfer in double buffer mode (for dynamic use)...
uint32_t DMA_MemoryDataSize
DMA Init structure definition.
uint32_t DMA_PeripheralInc
This file contains all the functions prototypes for the DMA firmware library.
void DMA_DoubleBufferModeConfig(DMA_Stream_TypeDef *DMAy_Streamx, uint32_t Memory1BaseAddr, uint32_t DMA_CurrentMemory)
Configures, when the DMAy Streamx is disabled, the double buffer mode and the current memory target...
void DMA_ClearFlag(DMA_Stream_TypeDef *DMAy_Streamx, uint32_t DMA_FLAG)
Clears the DMAy Streamx's pending flags.
uint32_t DMA_GetFIFOStatus(DMA_Stream_TypeDef *DMAy_Streamx)
Returns the current DMAy Streamx FIFO filled level.
void DMA_FlowControllerConfig(DMA_Stream_TypeDef *DMAy_Streamx, uint32_t DMA_FlowCtrl)
Configures, when the DMAy Streamx is disabled, the flow controller for the next transactions (Periphe...
void DMA_Cmd(DMA_Stream_TypeDef *DMAy_Streamx, FunctionalState NewState)
Enables or disables the specified DMAy Streamx.
uint32_t DMA_FIFOThreshold
void DMA_DeInit(DMA_Stream_TypeDef *DMAy_Streamx)
Deinitialize the DMAy Streamx registers to their default reset values.
uint16_t DMA_GetCurrDataCounter(DMA_Stream_TypeDef *DMAy_Streamx)
Returns the number of remaining data units in the current DMAy Streamx transfer.
void DMA_ClearITPendingBit(DMA_Stream_TypeDef *DMAy_Streamx, uint32_t DMA_IT)
Clears the DMAy Streamx's interrupt pending bits.
uint32_t DMA_Memory0BaseAddr