STM32L4xx_HAL_Driver  1.14.0
Initialization and Configuration functions

Initialization and Configuration functions. More...

Functions

HAL_StatusTypeDef HAL_DCMI_Init (DCMI_HandleTypeDef *hdcmi)
 Initialize the DCMI according to the specified parameters in the DCMI_InitTypeDef and create the associated handle. More...
 
HAL_StatusTypeDef HAL_DCMI_DeInit (DCMI_HandleTypeDef *hdcmi)
 De-initialize the DCMI peripheral, reset control registers to their default values. More...
 
void HAL_DCMI_MspInit (DCMI_HandleTypeDef *hdcmi)
 Initialize the DCMI MSP. More...
 
void HAL_DCMI_MspDeInit (DCMI_HandleTypeDef *hdcmi)
 De-initialize the DCMI MSP. More...
 
HAL_StatusTypeDef HAL_DCMI_RegisterCallback (DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID, pDCMI_CallbackTypeDef pCallback)
 DCMI Callback registering. More...
 
HAL_StatusTypeDef HAL_DCMI_UnRegisterCallback (DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID)
 DCMI Callback Unregistering. More...
 

Detailed Description

Initialization and Configuration functions.

 ===============================================================================
                ##### Initialization and Configuration functions #####
 ===============================================================================
    [..]  This section provides functions allowing to:
      (+) Initialize and configure the DCMI
      (+) De-initialize the DCMI

Function Documentation

◆ HAL_DCMI_DeInit()

HAL_StatusTypeDef HAL_DCMI_DeInit ( DCMI_HandleTypeDef hdcmi)

De-initialize the DCMI peripheral, reset control registers to their default values.

Parameters
hdcmipointer to a DCMI_HandleTypeDef structure that contains the configuration information for DCMI.
Return values
HALstatus

Definition at line 345 of file stm32l4xx_hal_dcmi.c.

346 {
347  /* Before aborting any DCMI transfer, check
348  first whether or not DCMI clock is enabled */
349  if (__HAL_RCC_DCMI_IS_CLK_ENABLED())
350  {
351  if (HAL_DCMI_Stop(hdcmi) != HAL_OK)
352  {
353  /* Issue when stopping DCMI IP */
354  return HAL_ERROR;
355  }
356  }
357 
358  /* Reset DCMI control register */
359  hdcmi->Instance->CR = 0;
360 
361 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
362  if(hdcmi->MspDeInitCallback == NULL)
363  {
365  }
366  /* De-Initialize the low level hardware (MSP) */
367  hdcmi->MspDeInitCallback(hdcmi);
368 #else
369  /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
370  HAL_DCMI_MspDeInit(hdcmi);
371 #endif /* (USE_HAL_DCMI_REGISTER_CALLBACKS) */
372 
373  /* Update error code */
374  hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;
375 
376  /* Initialize the DCMI state*/
377  hdcmi->State = HAL_DCMI_STATE_RESET;
378 
379  /* Release Lock */
380  __HAL_UNLOCK(hdcmi);
381 
382  return HAL_OK;
383 }
HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef *hdcmi)
Disable DCMI capture in DMA mode.
void(* MspDeInitCallback)(struct __DCMI_HandleTypeDef *hdcmi)
__IO HAL_DCMI_StateTypeDef State
__HAL_UNLOCK(hrtc)
return HAL_OK
void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef *hdcmi)
De-initialize the DCMI MSP.

◆ HAL_DCMI_Init()

HAL_StatusTypeDef HAL_DCMI_Init ( DCMI_HandleTypeDef hdcmi)

Initialize the DCMI according to the specified parameters in the DCMI_InitTypeDef and create the associated handle.

Parameters
hdcmipointer to a DCMI_HandleTypeDef structure that contains the configuration information for DCMI.
Note
By default, all interruptions are enabled (line end, frame end, overrun, VSYNC and embedded synchronization error interrupts).
Return values
HALstatus

Definition at line 237 of file stm32l4xx_hal_dcmi.c.

238 {
239  /* Check the DCMI peripheral state */
240  if(hdcmi == NULL)
241  {
242  return HAL_ERROR;
243  }
244 
245  /* Check function parameters */
246  assert_param(IS_DCMI_ALL_INSTANCE(hdcmi->Instance));
247  assert_param(IS_DCMI_SYNCHRO(hdcmi->Init.SynchroMode));
248  assert_param(IS_DCMI_PCKPOLARITY(hdcmi->Init.PCKPolarity));
249  assert_param(IS_DCMI_VSPOLARITY(hdcmi->Init.VSPolarity));
250  assert_param(IS_DCMI_HSPOLARITY(hdcmi->Init.HSPolarity));
251  assert_param(IS_DCMI_CAPTURE_RATE(hdcmi->Init.CaptureRate));
252  assert_param(IS_DCMI_EXTENDED_DATA(hdcmi->Init.ExtendedDataMode));
253  assert_param(IS_DCMI_MODE_JPEG(hdcmi->Init.JPEGMode));
254 
255  assert_param(IS_DCMI_BYTE_SELECT_MODE(hdcmi->Init.ByteSelectMode));
256  assert_param(IS_DCMI_BYTE_SELECT_START(hdcmi->Init.ByteSelectStart));
257  assert_param(IS_DCMI_LINE_SELECT_MODE(hdcmi->Init.LineSelectMode));
258  assert_param(IS_DCMI_LINE_SELECT_START(hdcmi->Init.LineSelectStart));
259 
260  if(hdcmi->State == HAL_DCMI_STATE_RESET)
261  {
262  /* Allocate lock resource and initialize it */
263  hdcmi->Lock = HAL_UNLOCKED;
264 
265  /* Init the DCMI Callback settings */
266 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
267  hdcmi->FrameEventCallback = HAL_DCMI_FrameEventCallback; /* Legacy weak FrameEventCallback */
268  hdcmi->VsyncEventCallback = HAL_DCMI_VsyncEventCallback; /* Legacy weak VsyncEventCallback */
269  hdcmi->LineEventCallback = HAL_DCMI_LineEventCallback; /* Legacy weak LineEventCallback */
270  hdcmi->ErrorCallback = HAL_DCMI_ErrorCallback; /* Legacy weak ErrorCallback */
271 
272  if(hdcmi->MspInitCallback == NULL)
273  {
274  /* Legacy weak MspInit Callback */
276  }
277  /* Initialize the low level hardware (MSP) */
278  hdcmi->MspInitCallback(hdcmi);
279 #else
280  /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
281  HAL_DCMI_MspInit(hdcmi);
282 #endif /* (USE_HAL_DCMI_REGISTER_CALLBACKS) */
283  }
284 
285  /* Change the DCMI state */
286  hdcmi->State = HAL_DCMI_STATE_BUSY;
287 
288  /* Disable DCMI IP before setting the configuration register */
289  __HAL_DCMI_DISABLE(hdcmi);
290 
291  if (hdcmi->Init.ExtendedDataMode != DCMI_EXTEND_DATA_8B)
292  {
293  /* Byte select mode must be programmed to the reset value if the extended mode
294  is not set to 8-bit data capture on every pixel clock */
295  hdcmi->Init.ByteSelectMode = DCMI_BSM_ALL;
296  }
297 
298  /* Set DCMI parameters */
299  hdcmi->Instance->CR &= ~(DCMI_CR_PCKPOL | DCMI_CR_HSPOL | DCMI_CR_VSPOL | DCMI_CR_EDM_0 |\
300  DCMI_CR_EDM_1 | DCMI_CR_FCRC_0 | DCMI_CR_FCRC_1 | DCMI_CR_JPEG |\
301  DCMI_CR_ESS | DCMI_CR_BSM_0 | DCMI_CR_BSM_1 | DCMI_CR_OEBS |\
302  DCMI_CR_LSM | DCMI_CR_OELS);
303 
304  hdcmi->Instance->CR |= (uint32_t)(hdcmi->Init.SynchroMode | hdcmi->Init.CaptureRate |\
305  hdcmi->Init.VSPolarity | hdcmi->Init.HSPolarity |\
306  hdcmi->Init.PCKPolarity | hdcmi->Init.ExtendedDataMode |\
307  hdcmi->Init.JPEGMode | hdcmi->Init.ByteSelectMode |\
308  hdcmi->Init.ByteSelectStart | hdcmi->Init.LineSelectMode |\
309  hdcmi->Init.LineSelectStart);
310 
311  if(hdcmi->Init.SynchroMode == DCMI_SYNCHRO_EMBEDDED)
312  {
313  hdcmi->Instance->ESCR = (((uint32_t)hdcmi->Init.SynchroCode.FrameStartCode) |\
314  ((uint32_t)hdcmi->Init.SynchroCode.LineStartCode << DCMI_ESCR_LSC_Pos)|\
315  ((uint32_t)hdcmi->Init.SynchroCode.LineEndCode << DCMI_ESCR_LEC_Pos) |\
316  ((uint32_t)hdcmi->Init.SynchroCode.FrameEndCode << DCMI_ESCR_FEC_Pos));
317  }
318 
319  /* By default, enable all interrupts. The user may disable the unwanted ones
320  in resorting to __HAL_DCMI_DISABLE_IT() macro before invoking HAL_DCMI_Start_DMA().
321  Enabled interruptions are
322  - end of line
323  - end of frame
324  - data reception overrun
325  - frame synchronization signal VSYNC
326  - synchronization error */
327  __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_FRAME|DCMI_IT_OVR|DCMI_IT_ERR|DCMI_IT_VSYNC|DCMI_IT_LINE);
328 
329  /* Update error code */
330  hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;
331 
332  /* Initialize the DCMI state*/
333  hdcmi->State = HAL_DCMI_STATE_READY;
334 
335  return HAL_OK;
336 }
void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi)
Frame Event callback.
void(* MspInitCallback)(struct __DCMI_HandleTypeDef *hdcmi)
void(* ErrorCallback)(struct __DCMI_HandleTypeDef *hdcmi)
void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi)
Error DCMI callback.
void HAL_DCMI_MspInit(DCMI_HandleTypeDef *hdcmi)
Initialize the DCMI MSP.
void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi)
Line Event callback.
void(* FrameEventCallback)(struct __DCMI_HandleTypeDef *hdcmi)
__IO HAL_DCMI_StateTypeDef State
DCMI_CodesInitTypeDef SynchroCode
void(* LineEventCallback)(struct __DCMI_HandleTypeDef *hdcmi)
void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi)
VSYNC Event callback.
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
void(* VsyncEventCallback)(struct __DCMI_HandleTypeDef *hdcmi)

◆ HAL_DCMI_MspDeInit()

__weak void HAL_DCMI_MspDeInit ( DCMI_HandleTypeDef hdcmi)

De-initialize the DCMI MSP.

Parameters
hdcmipointer to a DCMI_HandleTypeDef structure that contains the configuration information for DCMI.
Return values
None

Definition at line 407 of file stm32l4xx_hal_dcmi.c.

408 {
409  /* Prevent unused argument(s) compilation warning */
410  UNUSED(hdcmi);
411 
412  /* NOTE : This function should not be modified; when the callback is needed,
413  the HAL_DCMI_MspDeInit() callback can be implemented in the user file
414  */
415 }

◆ HAL_DCMI_MspInit()

__weak void HAL_DCMI_MspInit ( DCMI_HandleTypeDef hdcmi)

Initialize the DCMI MSP.

Parameters
hdcmipointer to a DCMI_HandleTypeDef structure that contains the configuration information for DCMI.
Return values
None

Definition at line 391 of file stm32l4xx_hal_dcmi.c.

392 {
393  /* Prevent unused argument(s) compilation warning */
394  UNUSED(hdcmi);
395 
396  /* NOTE : This function should not be modified; when the callback is needed,
397  the HAL_DCMI_MspInit() callback can be implemented in the user file
398  */
399 }

◆ HAL_DCMI_RegisterCallback()

HAL_StatusTypeDef HAL_DCMI_RegisterCallback ( DCMI_HandleTypeDef hdcmi,
HAL_DCMI_CallbackIDTypeDef  CallbackID,
pDCMI_CallbackTypeDef  pCallback 
)

DCMI Callback registering.

Parameters
hdcmidcmi handle
CallbackIDdcmi Callback ID
hdcmipointer to dcmi Callback function
Return values
status

Definition at line 1072 of file stm32l4xx_hal_dcmi.c.

1073 {
1074  HAL_StatusTypeDef status = HAL_OK;
1075 
1076  if(pCallback == NULL)
1077  {
1078  /* update the error code */
1079  hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
1080  /* update return status */
1081  status = HAL_ERROR;
1082  }
1083  else
1084  {
1085  if(hdcmi->State == HAL_DCMI_STATE_READY)
1086  {
1087  switch (CallbackID)
1088  {
1090  hdcmi->FrameEventCallback = pCallback;
1091  break;
1092 
1094  hdcmi->VsyncEventCallback = pCallback;
1095  break;
1096 
1098  hdcmi->LineEventCallback = pCallback;
1099  break;
1100 
1101  case HAL_DCMI_ERROR_CB_ID :
1102  hdcmi->ErrorCallback = pCallback;
1103  break;
1104 
1105  case HAL_DCMI_MSPINIT_CB_ID :
1106  hdcmi->MspInitCallback = pCallback;
1107  break;
1108 
1110  hdcmi->MspDeInitCallback = pCallback;
1111  break;
1112 
1113  default :
1114  /* Return error status */
1115  status = HAL_ERROR;
1116  break;
1117  }
1118  }
1119  else if(hdcmi->State == HAL_DCMI_STATE_RESET)
1120  {
1121  switch (CallbackID)
1122  {
1123  case HAL_DCMI_MSPINIT_CB_ID :
1124  hdcmi->MspInitCallback = pCallback;
1125  break;
1126 
1128  hdcmi->MspDeInitCallback = pCallback;
1129  break;
1130 
1131  default :
1132  /* update the error code */
1133  hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
1134  /* update return status */
1135  status = HAL_ERROR;
1136  break;
1137  }
1138  }
1139  else
1140  {
1141  /* update the error code */
1142  hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
1143  /* update return status */
1144  status = HAL_ERROR;
1145  }
1146  }
1147 
1148  return status;
1149 }
void(* MspInitCallback)(struct __DCMI_HandleTypeDef *hdcmi)
void(* MspDeInitCallback)(struct __DCMI_HandleTypeDef *hdcmi)
void(* ErrorCallback)(struct __DCMI_HandleTypeDef *hdcmi)
void(* FrameEventCallback)(struct __DCMI_HandleTypeDef *hdcmi)
__IO HAL_DCMI_StateTypeDef State
void(* LineEventCallback)(struct __DCMI_HandleTypeDef *hdcmi)
return HAL_OK
void(* VsyncEventCallback)(struct __DCMI_HandleTypeDef *hdcmi)

◆ HAL_DCMI_UnRegisterCallback()

HAL_StatusTypeDef HAL_DCMI_UnRegisterCallback ( DCMI_HandleTypeDef hdcmi,
HAL_DCMI_CallbackIDTypeDef  CallbackID 
)

DCMI Callback Unregistering.

Parameters
hdcmidcmi handle
CallbackIDdcmi Callback ID
Return values
status

Definition at line 1157 of file stm32l4xx_hal_dcmi.c.

1158 {
1159  HAL_StatusTypeDef status = HAL_OK;
1160 
1161  if(hdcmi->State == HAL_DCMI_STATE_READY)
1162  {
1163  switch (CallbackID)
1164  {
1166  hdcmi->FrameEventCallback = HAL_DCMI_FrameEventCallback; /* Legacy weak FrameEventCallback */
1167  break;
1168 
1170  hdcmi->VsyncEventCallback = HAL_DCMI_VsyncEventCallback; /* Legacy weak VsyncEventCallback */
1171  break;
1172 
1174  hdcmi->LineEventCallback = HAL_DCMI_LineEventCallback; /* Legacy weak LineEventCallback */
1175  break;
1176 
1177  case HAL_DCMI_ERROR_CB_ID :
1178  hdcmi->ErrorCallback = HAL_DCMI_ErrorCallback; /* Legacy weak ErrorCallback */
1179  break;
1180 
1181  case HAL_DCMI_MSPINIT_CB_ID :
1183  break;
1184 
1187  break;
1188 
1189  default :
1190  /* update the error code */
1191  hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
1192  /* update return status */
1193  status = HAL_ERROR;
1194  break;
1195  }
1196  }
1197  else if(hdcmi->State == HAL_DCMI_STATE_RESET)
1198  {
1199  switch (CallbackID)
1200  {
1201  case HAL_DCMI_MSPINIT_CB_ID :
1203  break;
1204 
1207  break;
1208 
1209  default :
1210  /* update the error code */
1211  hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
1212  /* update return status */
1213  status = HAL_ERROR;
1214  break;
1215  }
1216  }
1217  else
1218  {
1219  /* update the error code */
1220  hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
1221  /* update return status */
1222  status = HAL_ERROR;
1223  }
1224 
1225  return status;
1226 }
void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi)
Frame Event callback.
void(* MspInitCallback)(struct __DCMI_HandleTypeDef *hdcmi)
void(* MspDeInitCallback)(struct __DCMI_HandleTypeDef *hdcmi)
void(* ErrorCallback)(struct __DCMI_HandleTypeDef *hdcmi)
void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi)
Error DCMI callback.
void HAL_DCMI_MspInit(DCMI_HandleTypeDef *hdcmi)
Initialize the DCMI MSP.
void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi)
Line Event callback.
void(* FrameEventCallback)(struct __DCMI_HandleTypeDef *hdcmi)
__IO HAL_DCMI_StateTypeDef State
void(* LineEventCallback)(struct __DCMI_HandleTypeDef *hdcmi)
void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi)
VSYNC Event callback.
return HAL_OK
void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef *hdcmi)
De-initialize the DCMI MSP.
void(* VsyncEventCallback)(struct __DCMI_HandleTypeDef *hdcmi)