STM32L4xx_HAL_Driver  1.14.0
stm32l4xx_hal_dma_ex.c
Go to the documentation of this file.
1 
49 /* Includes ------------------------------------------------------------------*/
50 #include "stm32l4xx_hal.h"
51 
52 #if defined(DMAMUX1)
53 
63 #ifdef HAL_DMA_MODULE_ENABLED
64 
65 /* Private typedef -----------------------------------------------------------*/
66 /* Private define ------------------------------------------------------------*/
67 /* Private macro -------------------------------------------------------------*/
68 /* Private variables ---------------------------------------------------------*/
69 /* Private Constants ---------------------------------------------------------*/
70 /* Private function prototypes -----------------------------------------------*/
71 /* Private functions ---------------------------------------------------------*/
72 
73 
105 {
106  /* Check the parameters */
107  assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
108 
109  assert_param(IS_DMAMUX_SYNC_SIGNAL_ID(pSyncConfig->SyncSignalID));
110 
111  assert_param(IS_DMAMUX_SYNC_POLARITY(pSyncConfig-> SyncPolarity));
112  assert_param(IS_DMAMUX_SYNC_STATE(pSyncConfig->SyncEnable));
113  assert_param(IS_DMAMUX_SYNC_EVENT(pSyncConfig->EventEnable));
114  assert_param(IS_DMAMUX_SYNC_REQUEST_NUMBER(pSyncConfig->RequestNumber));
115 
116  /*Check if the DMA state is ready */
117  if(hdma->State == HAL_DMA_STATE_READY)
118  {
119  /* Process Locked */
120  __HAL_LOCK(hdma);
121 
122  /* Set the new synchronization parameters (and keep the request ID filled during the Init)*/
123  MODIFY_REG( hdma->DMAmuxChannel->CCR, \
124  (~DMAMUX_CxCR_DMAREQ_ID) , \
125  ((pSyncConfig->SyncSignalID) << DMAMUX_CxCR_SYNC_ID_Pos) | ((pSyncConfig->RequestNumber - 1U) << DMAMUX_CxCR_NBREQ_Pos) | \
126  pSyncConfig->SyncPolarity | ((uint32_t)pSyncConfig->SyncEnable << DMAMUX_CxCR_SE_Pos) | \
127  ((uint32_t)pSyncConfig->EventEnable << DMAMUX_CxCR_EGE_Pos));
128 
129  /* Process UnLocked */
130  __HAL_UNLOCK(hdma);
131 
132  return HAL_OK;
133  }
134  else
135  {
136  /*DMA State not Ready*/
137  return HAL_ERROR;
138  }
139 }
140 
151 {
152  /* Check the parameters */
153  assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
154 
155  assert_param(IS_DMAMUX_REQUEST_GEN_SIGNAL_ID(pRequestGeneratorConfig->SignalID));
156 
157  assert_param(IS_DMAMUX_REQUEST_GEN_POLARITY(pRequestGeneratorConfig->Polarity));
158  assert_param(IS_DMAMUX_REQUEST_GEN_REQUEST_NUMBER(pRequestGeneratorConfig->RequestNumber));
159 
160  /* check if the DMA state is ready
161  and DMA is using a DMAMUX request generator block
162  */
163  if((hdma->State == HAL_DMA_STATE_READY) && (hdma->DMAmuxRequestGen != 0U))
164  {
165  /* Process Locked */
166  __HAL_LOCK(hdma);
167 
168  /* Set the request generator new parameters */
169  hdma->DMAmuxRequestGen->RGCR = pRequestGeneratorConfig->SignalID | \
170  ((pRequestGeneratorConfig->RequestNumber - 1U) << DMAMUX_RGxCR_GNBREQ_Pos)| \
171  pRequestGeneratorConfig->Polarity;
172  /* Process UnLocked */
173  __HAL_UNLOCK(hdma);
174 
175  return HAL_OK;
176  }
177  else
178  {
179  return HAL_ERROR;
180  }
181 }
182 
190 {
191  /* Check the parameters */
192  assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
193 
194  /* check if the DMA state is ready
195  and DMA is using a DMAMUX request generator block
196  */
197  if((hdma->State != HAL_DMA_STATE_RESET) && (hdma->DMAmuxRequestGen != 0))
198  {
199 
200  /* Enable the request generator*/
201  hdma->DMAmuxRequestGen->RGCR |= DMAMUX_RGxCR_GE;
202 
203  return HAL_OK;
204  }
205  else
206  {
207  return HAL_ERROR;
208  }
209 }
210 
218 {
219  /* Check the parameters */
220  assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
221 
222  /* check if the DMA state is ready
223  and DMA is using a DMAMUX request generator block
224  */
225  if((hdma->State != HAL_DMA_STATE_RESET) && (hdma->DMAmuxRequestGen != 0))
226  {
227 
228  /* Disable the request generator*/
229  hdma->DMAmuxRequestGen->RGCR &= ~DMAMUX_RGxCR_GE;
230 
231  return HAL_OK;
232  }
233  else
234  {
235  return HAL_ERROR;
236  }
237 }
238 
246 {
247  /* Check for DMAMUX Synchronization overrun */
248  if((hdma->DMAmuxChannelStatus->CSR & hdma->DMAmuxChannelStatusMask) != 0U)
249  {
250  /* Disable the synchro overrun interrupt */
251  hdma->DMAmuxChannel->CCR &= ~DMAMUX_CxCR_SOIE;
252 
253  /* Clear the DMAMUX synchro overrun flag */
254  hdma->DMAmuxChannelStatus->CFR = hdma->DMAmuxChannelStatusMask;
255 
256  /* Update error code */
257  hdma->ErrorCode |= HAL_DMA_ERROR_SYNC;
258 
259  if(hdma->XferErrorCallback != NULL)
260  {
261  /* Transfer error callback */
262  hdma->XferErrorCallback(hdma);
263  }
264  }
265 
266  if(hdma->DMAmuxRequestGen != 0)
267  {
268  /* if using a DMAMUX request generator block Check for DMAMUX request generator overrun */
269  if((hdma->DMAmuxRequestGenStatus->RGSR & hdma->DMAmuxRequestGenStatusMask) != 0U)
270  {
271  /* Disable the request gen overrun interrupt */
272  hdma->DMAmuxRequestGen->RGCR &= ~DMAMUX_RGxCR_OIE;
273 
274  /* Clear the DMAMUX request generator overrun flag */
276 
277  /* Update error code */
278  hdma->ErrorCode |= HAL_DMA_ERROR_REQGEN;
279 
280  if(hdma->XferErrorCallback != NULL)
281  {
282  /* Transfer error callback */
283  hdma->XferErrorCallback(hdma);
284  }
285  }
286  }
287 }
288 
297 #endif /* HAL_DMA_MODULE_ENABLED */
298 
307 #endif /* DMAMUX1 */
308 
309 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
HAL_StatusTypeDef HAL_DMAEx_EnableMuxRequestGenerator(DMA_HandleTypeDef *hdma)
Enable the DMAMUX request generator block used by the given DMA channel (instance).
HAL_StatusTypeDef HAL_DMAEx_ConfigMuxRequestGenerator(DMA_HandleTypeDef *hdma, HAL_DMA_MuxRequestGeneratorConfigTypeDef *pRequestGeneratorConfig)
Configure the DMAMUX request generator block used by the given DMA channel (instance).
DMA handle Structure definition.
DMAMUX_RequestGenStatus_TypeDef * DMAmuxRequestGenStatus
This file contains all the functions prototypes for the HAL module driver.
DMAMUX_RequestGen_TypeDef * DMAmuxRequestGen
HAL_StatusTypeDef HAL_DMAEx_DisableMuxRequestGenerator(DMA_HandleTypeDef *hdma)
Disable the DMAMUX request generator block used by the given DMA channel (instance).
DMA_Channel_TypeDef * Instance
void(* XferErrorCallback)(struct __DMA_HandleTypeDef *hdma)
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
void HAL_DMAEx_MUX_IRQHandler(DMA_HandleTypeDef *hdma)
Handles DMAMUX interrupt request.
__IO HAL_DMA_StateTypeDef State
DMAMUX_Channel_TypeDef * DMAmuxChannel
return HAL_OK
uint32_t DMAmuxRequestGenStatusMask
HAL DMAMUX request generator parameters structure definition.
HAL_StatusTypeDef HAL_DMAEx_ConfigMuxSync(DMA_HandleTypeDef *hdma, HAL_DMA_MuxSyncConfigTypeDef *pSyncConfig)
Configure the DMAMUX synchronization parameters for a given DMA channel (instance).
DMAMUX_ChannelStatus_TypeDef * DMAmuxChannelStatus
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
HAL DMA Synchro definition.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))