HAL DCMI functions

Initialization and de-initialization functions

group DCMI_Exported_Functions_Group1

A set of functions allowing to initialize and deinitialize the DCMI peripheral :

  • HAL_DCMI_Init() : Initialize the HAL DCMI handle and associate it to a given DCMI peripheral instance.

  • HAL_DCMI_DeInit() : De-initialize the HAL DCMI handle and stop/abort any ongoing capture process.

Functions

hal_status_t HAL_DCMI_Init ( hal_dcmi_handle_t * hdcmi , hal_dcmi_t instance )

Initialize the HAL DCMI handle and associate it to a given DCMI peripheral instance.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter when hdcmi pointer is NULL

  • HAL_OK – DCMI is successfully initialized

void HAL_DCMI_DeInit ( hal_dcmi_handle_t * hdcmi )

De-initialize the HAL DCMI handle and stop/abort any ongoing capture process.

Parameters :

hdcmi – Pointer to a hal_dcmi_handle_t structure

PARALLEL Configuration functions

group DCMI_Exported_Functions_Group2

A set of functions allowing to configure the DCMI peripheral:

Functions

hal_status_t HAL_DCMI_PARALLEL_SetConfig ( hal_dcmi_handle_t * hdcmi , const hal_dcmi_parallel_config_t * p_config )

Configure the DCMI according to the specified parameters.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter when p_config pointer is NULL

  • HAL_OK – DCMI is successfully configured

void HAL_DCMI_PARALLEL_GetConfig ( const hal_dcmi_handle_t * hdcmi , hal_dcmi_parallel_config_t * p_config )

Retrieve the DCMI configuration.

Parameters :
hal_status_t HAL_DCMI_PARALLEL_SetSyncMode ( hal_dcmi_handle_t * hdcmi , hal_dcmi_sync_mode_t mode )

Set synchronization mode.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter when incompatible sync mode with other parameters

  • HAL_OK – DCMI synchro mode is successfully configured

hal_dcmi_sync_mode_t HAL_DCMI_PARALLEL_GetSyncMode ( const hal_dcmi_handle_t * hdcmi )

Get synchronization mode.

Parameters :

hdcmi – Pointer to a hal_dcmi_handle_t structure

Return values :
  • HAL_DCMI_SYNC_HARDWARE – Hardware synchronization mode

  • HAL_DCMI_SYNC_EMBEDDED – Embedded synchronization mode

hal_status_t HAL_DCMI_PARALLEL_SetEmbSyncCode ( hal_dcmi_handle_t * hdcmi , const hal_dcmi_parallel_emb_sync_config_t * p_config )

Set embedded synchronization code (frame start/end , line start/end).

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter when p_config pointer is NULL

  • HAL_OK – DCMI delimiter code is successfully configured

void HAL_DCMI_PARALLEL_GetEmbSyncCode ( const hal_dcmi_handle_t * hdcmi , hal_dcmi_parallel_emb_sync_config_t * p_config )

Get embedded synchronization code.

Parameters :
hal_status_t HAL_DCMI_PARALLEL_SetEmbSyncMask ( hal_dcmi_handle_t * hdcmi , const hal_dcmi_parallel_emb_sync_config_t * p_config )

Set embedded synchronization delimiters masks (Frame start/end masks values, Line start/end masks values).

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter when p_config pointer is NULL

  • HAL_OK – DCMI delimiter mask is successfully configured

void HAL_DCMI_PARALLEL_GetEmbSyncMask ( const hal_dcmi_handle_t * hdcmi , hal_dcmi_parallel_emb_sync_config_t * p_config )

Get embedded synchronization delimiters unmasks.

Parameters :

PIPE configuration functions

group DCMI_Exported_Functions_Group3

A set of functions allowing to configure the DCMI pipe peripheral:

Functions

hal_status_t HAL_DCMI_SetConfigPipe ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe , const hal_dcmi_pipe_config_t * p_config )

Configure the frames to be captured.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter when p_config pointer is NULL

  • HAL_OK – DCMI frame capture rate is successfully configured

void HAL_DCMI_GetConfigPipe ( const hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe , hal_dcmi_pipe_config_t * p_config )

Get the frame capture config.

Parameters :
hal_status_t HAL_DCMI_SetPipeBytesDecimation ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe , hal_dcmi_byte_decimation_mode_t byte_decimation_mode )

Set the bytes decimation.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter when incompatible bytes decimation mode with data width

  • HAL_OK – DCMI horizontal resolution is successfully configured

hal_dcmi_byte_decimation_mode_t HAL_DCMI_GetPipeBytesDecimation ( const hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

Get the bytes decimation.

Parameters :
Return values :
  • HAL_DCMI_BYTE_CAPTURE_ALL – All received data captured

  • HAL_DCMI_BYTE_CAPTURE_1BYTE_OUT_2_ODD – One byte out of 2 odd parts captured

  • HAL_DCMI_BYTE_CAPTURE_1BYTE_OUT_2_EVEN – One byte out of 2 even parts captured

  • HAL_DCMI_BYTE_CAPTURE_1BYTE_OUT_4_ODD – One byte out of 4 odd parts captured

  • HAL_DCMI_BYTE_CAPTURE_1BYTE_OUT_4_EVEN – One byte out of 4 even parts captured

  • HAL_DCMI_BYTE_CAPTURE_2BYTE_OUT_4_ODD – Two byte out of 4 odd parts captured

  • HAL_DCMI_BYTE_CAPTURE_2BYTE_OUT_4_EVEN – Two byte out of 4 even parts captured

hal_status_t HAL_DCMI_SetPipeLinesDecimation ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe , hal_dcmi_line_decimation_mode_t line_decimation_mode )

Set the lines decimation.

Parameters :
Return values :

HAL_OK – DCMI vertical resolution is successfully configured

hal_dcmi_line_decimation_mode_t HAL_DCMI_GetPipeLinesDecimation ( const hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

Get the lines decimation.

Parameters :
Return values :
  • HAL_DCMI_LINE_CAPTURE_ALL – All received data captured

  • HAL_DCMI_LINE_CAPTURE_1LINE_OUT_2_ODD – One line out of 2 odd parts captured

  • HAL_DCMI_LINE_CAPTURE_1LINE_OUT_2_EVEN – One line out of 2 even parts captured

hal_status_t HAL_DCMI_SetConfigPipeCrop ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe , const hal_dcmi_crop_config_t * p_config )

Configure the DCMI CROP coordinate.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter when p_config pointer is NULL

  • HAL_OK – DCMI crop coordinate is successfully configured

void HAL_DCMI_GetConfigPipeCrop ( const hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe , hal_dcmi_crop_config_t * p_config )

Get the DCMI CROP coordinate.

Parameters :
hal_status_t HAL_DCMI_EnablePipeCrop ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

Enable the Crop feature.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter when the API is called while the DCMI is configured in JPEG format that does not support crop feature

  • HAL_OK – DCMI crop feature is successfully enabled

hal_status_t HAL_DCMI_DisablePipeCrop ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

Disable the Crop feature.

Parameters :
Return values :

HAL_OK – DCMI crop feature is successfully disabled

hal_dcmi_crop_status_t HAL_DCMI_IsEnabledPipeCrop ( const hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

Check the status of DCMI Crop feature.

Parameters :
Return values :
  • HAL_DCMI_CROP_DISABLED – The full image is captured

  • HAL_DCMI_CROP_ENABLED – Specify window is captured

Input and Output operation functions

group DCMI_Exported_Functions_Group4

A set of functions allowing to manage the DCMI data transfers:

Functions

hal_status_t HAL_DCMI_StartPipe_DMA ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe , hal_dcmi_capture_t capture , uint32_t dest_addr , uint32_t size_byte )

Start the DCMI capture using the DMA by enabling the required interrupts.

Note

The required interrupts are: Frame, Vsync, Overrun and Error sync. The optional interrupt (line) is enabled by default.

Parameters :
  • hdcmi – Pointer to a hal_dcmi_handle_t structure

  • pipe – Value from hal_dcmi_pipe_t enumeration

  • capture – DCMI capture mode snapshot or continuous grab This parameter can be a value of hal_dcmi_capture_t enumeration

  • dest_addr – The destination memory Buffer address (LCD Frame buffer)

  • size_byte – The length of capture to be transferred

Return values :
  • HAL_ERROR – The transfer mode parameter is linked-list linear or the DMA channel state is active

  • HAL_BUSY – If USE_HAL_CHECK_PROCESS_STATE is set to “1” and the current pipe state is not IDLE

  • HAL_OK – The DMA channel peripheral transfer is successfully started

hal_status_t HAL_DCMI_StartPipe_DMA_Opt ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe , hal_dcmi_capture_t capture , uint32_t dest_addr , uint32_t size_byte , uint32_t interrupts )

Start the DCMI capture using the DMA by enabling the required interrupts (Frame, Vsync, Overrun and Error) and by offering the user a parameter to enable if needed the optional interrupt (line).

Parameters :
  • hdcmi – Pointer to a hal_dcmi_handle_t structure

  • pipe – Value from hal_dcmi_pipe_t enumeration

  • capture – DCMI capture mode snapshot or continuous grab This parameter can be a value of hal_dcmi_capture_t enumeration

  • dest_addr – The destination memory Buffer address (LCD Frame buffer)

  • size_byte – The length of capture to be transferred

  • interrupts – DCMI Optional Interrupts This parameter can be a value of DCMI Optional Interrupts group

Return values :
  • HAL_ERROR – The transfer mode parameter is linked-list linear or the DMA channel state is active

  • HAL_BUSY – If USE_HAL_CHECK_PROCESS_STATE is set to “1” and the current pipe state is not IDLE

  • HAL_OK – The DMA channel peripheral transfer is successfully started

hal_status_t HAL_DCMI_StopPipe_DMA ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

Stop the DCMI capture.

Parameters :
Return values :

HAL_OK – The DMA channel peripheral transfer is successfully stopped

hal_status_t HAL_DCMI_SuspendPipe ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

Suspend DCMI capture.

Parameters :
Return values :
  • HAL_ERROR – The DCMI capture bit not cleared

  • HAL_OK – The DCMI capture is successfully suspended

hal_status_t HAL_DCMI_ResumePipe ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

Resume DCMI capture.

Parameters :
Return values :
  • HAL_BUSY – If USE_HAL_CHECK_PROCESS_STATE is set to “1” and the current pipe state is not SUSPEND

  • HAL_OK – The DCMI capture is successfully resumed

IRQHandler and Register callbacks functions

group DCMI_Exported_Functions_Group5

A set of function to handle the DCMI interruptions :

Functions

void HAL_DCMI_IRQHandler ( hal_dcmi_handle_t * hdcmi )

Handles DCMI interrupt request.

Parameters :

hdcmi – Pointer to a hal_dcmi_handle_t structure

hal_status_t HAL_DCMI_RegisterPipeStopCallback ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe , hal_dcmi_pipe_cb_t p_callback )

Register the DCMI Pipe Stop callback to be used instead of the weak HAL_DCMI_PipeStopCallback() predefined callback.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter return when callback pointer is NULL

  • HAL_OK – DCMI pipe stop callback is successfully stored

hal_status_t HAL_DCMI_RegisterPipeFrameEventCallback ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe , hal_dcmi_pipe_cb_t p_callback )

Register the DCMI Pipe Frame event callback to be used instead of the weak HAL_DCMI_PipeFrameEventCallback() predefined callback.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter return when callback pointer is NULL

  • HAL_OK – DCMI pipe frame event callback is successfully stored

hal_status_t HAL_DCMI_RegisterPipeVsyncEventCallback ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe , hal_dcmi_pipe_cb_t p_callback )

Register the DCMI Pipe Vsync event callback to be used instead of the weak HAL_DCMI_PipeVsyncEventCallback() predefined callback.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter return when callback pointer is NULL

  • HAL_OK – DCMI pipe Vsync event callback is successfully stored

hal_status_t HAL_DCMI_RegisterPipeLineEventCallback ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe , hal_dcmi_pipe_cb_t p_callback )

Register the DCMI Pipe Line event callback to be used instead of the weak HAL_DCMI_PipeLineEventCallback() predefined callback.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter return when callback pointer is NULL

  • HAL_OK – DCMI pipe line event callback is successfully stored

hal_status_t HAL_DCMI_RegisterPipeErrorCallback ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe , hal_dcmi_pipe_cb_t p_callback )

Register the DCMI Pipe error callback to be used instead of the weak HAL_DCMI_PipeErrorCallback() predefined callback.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter return when callback pointer is NULL

  • HAL_OK – DCMI pipe error callback is successfully stored

hal_status_t HAL_DCMI_RegisterErrorCallback ( hal_dcmi_handle_t * hdcmi , hal_dcmi_cb_t p_callback )

Register the DCMI Error callback to be used instead of the weak HAL_DCMI_ErrorCallback() predefined callback.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter return when callback pointer is NULL

  • HAL_OK – DCMI error callback is successfully stored

callbacks functions

group DCMI_Exported_Functions_Group6

A set of Weak functions (or default Callbacks functions if USE_HAL_DCMI_REGISTER_CALLBACKS is set to 1) which are used to asynchronously inform the application. The HAL DCMI driver provides these callbacks as weak empty functions. When needed these functions are to be implemented in the user file:

Functions

void HAL_DCMI_PipeStopCallback ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

DCMI Pipe stop callback.

Parameters :
void HAL_DCMI_PipeFrameEventCallback ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

DCMI Pipe frame event callback.

Parameters :
void HAL_DCMI_PipeVsyncEventCallback ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

DCMI Pipe Vsync event callback.

Parameters :
void HAL_DCMI_PipeLineEventCallback ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

DCMI Pipe line event callback.

Parameters :
void HAL_DCMI_PipeErrorCallback ( hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

DCMI Pipe error callback.

Parameters :
void HAL_DCMI_ErrorCallback ( hal_dcmi_handle_t * hdcmi )

DCMI error callback.

Parameters :

hdcmi – Pointer to a hal_dcmi_handle_t structure

Peripheral State and Error functions

group DCMI_Exported_Functions_Group8

This subsection provides functions allowing to

Functions

hal_dcmi_state_t HAL_DCMI_GetState ( const hal_dcmi_handle_t * hdcmi )

Return the DCMI state.

Parameters :

hdcmi – Pointer to a hal_dcmi_handle_t structure

Return values :

hal_dcmi_state_t – DCMI global state

hal_dcmi_pipe_state_t HAL_DCMI_GetPipeState ( const hal_dcmi_handle_t * hdcmi , hal_dcmi_pipe_t pipe )

Return the DCMI pipe state.

Parameters :
Return values :

hal_dcmi_pipe_state_t – DCMI pipe state

uint32_t HAL_DCMI_GetLastErrorCodes ( const hal_dcmi_handle_t * hdcmi )

Return the DCMI error code.

Parameters :

hdcmi – Pointer to a hal_dcmi_handle_t structure

Return values :

uint32_t – Error code value which can be a combination of:

Set/Get user data

group DCMI_Exported_Functions_Group9

A set of functions allowing to manage a user data pointer stored to the DCMI handle:

Functions

void HAL_DCMI_SetUserData ( hal_dcmi_handle_t * hdcmi , const void * p_user_data )

Set the user data pointer into the handle.

Parameters :
const void * HAL_DCMI_GetUserData ( const hal_dcmi_handle_t * hdcmi )

Get the user data pointer from the handle.

Parameters :

hdcmi – Pointer to a hal_dcmi_handle_t structure

Return values :

Pointer – to the user data.

Interrupt and Flag management

group DCMI_Exported_Functions_Group10

Functions

uint32_t HAL_DCMI_IsActiveFlag ( const hal_dcmi_handle_t * hdcmi , uint32_t flag )

Check whether or not the specified DCMI flag is set.

Parameters :
Return values :

The – state of DCMI flag (0 or 1)

void HAL_DCMI_ClearFlag ( hal_dcmi_handle_t * hdcmi , uint32_t flag )

Clear the specified DCMI flags.

Parameters :
void HAL_DCMI_EnableIT ( hal_dcmi_handle_t * hdcmi , uint32_t interrupt )

Enable the specified DCMI interrupts.

Parameters :
void HAL_DCMI_DisableIT ( hal_dcmi_handle_t * hdcmi , uint32_t interrupt )

Disable the specified DCMI interrupts.

Parameters :
uint32_t HAL_DCMI_IsEnabledIT ( const hal_dcmi_handle_t * hdcmi , uint32_t interrupt )

Check whether or not the specified DCMI interrupt is set.

Parameters :
Return values :

The – state of DCMI interrupt (0 or 1)

uint32_t HAL_HAL_DCMI_IsActiveMaskedFlag ( const hal_dcmi_handle_t * hdcmi , uint32_t flag )

Check whether or not the specified DCMI flag masked with interrupt is set.

Parameters :
Return values :

The – state of DCMI flag masked with interrupt (0 or 1)

uint32_t HAL_HAL_DCMI_ReadMaskedFlag ( const hal_dcmi_handle_t * hdcmi , uint32_t flag )

Read which DCMI flags masked with interrupt are active.

Parameters :
Return values :

Which – DCMI flags masked with interrupt are active