stm32f4xx_dcmi.c
Go to the documentation of this file.
1 
85 /* Includes ------------------------------------------------------------------*/
86 #include "stm32f4xx_dcmi.h"
87 #include "stm32f4xx_rcc.h"
88 
98 /* Private typedef -----------------------------------------------------------*/
99 /* Private define ------------------------------------------------------------*/
100 /* Private macro -------------------------------------------------------------*/
101 /* Private variables ---------------------------------------------------------*/
102 /* Private function prototypes -----------------------------------------------*/
103 /* Private functions ---------------------------------------------------------*/
104 
126 void DCMI_DeInit(void)
127 {
128  DCMI->CR = 0x0;
129  DCMI->IER = 0x0;
130  DCMI->ICR = 0x1F;
131  DCMI->ESCR = 0x0;
132  DCMI->ESUR = 0x0;
133  DCMI->CWSTRTR = 0x0;
134  DCMI->CWSIZER = 0x0;
135 }
136 
143 void DCMI_Init(DCMI_InitTypeDef* DCMI_InitStruct)
144 {
145  uint32_t temp = 0x0;
146 
147  /* Check the parameters */
149  assert_param(IS_DCMI_SYNCHRO(DCMI_InitStruct->DCMI_SynchroMode));
155 
156  /* The DCMI configuration registers should be programmed correctly before
157  enabling the CR_ENABLE Bit and the CR_CAPTURE Bit */
158  DCMI->CR &= ~(DCMI_CR_ENABLE | DCMI_CR_CAPTURE);
159 
160  /* Reset the old DCMI configuration */
161  temp = DCMI->CR;
162 
163  temp &= ~((uint32_t)DCMI_CR_CM | DCMI_CR_ESS | DCMI_CR_PCKPOL |
166 
167  /* Sets the new configuration of the DCMI peripheral */
168  temp |= ((uint32_t)DCMI_InitStruct->DCMI_CaptureMode |
169  DCMI_InitStruct->DCMI_SynchroMode |
170  DCMI_InitStruct->DCMI_PCKPolarity |
171  DCMI_InitStruct->DCMI_VSPolarity |
172  DCMI_InitStruct->DCMI_HSPolarity |
173  DCMI_InitStruct->DCMI_CaptureRate |
174  DCMI_InitStruct->DCMI_ExtendedDataMode);
175 
176  DCMI->CR = temp;
177 }
178 
185 void DCMI_StructInit(DCMI_InitTypeDef* DCMI_InitStruct)
186 {
187  /* Set the default configuration */
189  DCMI_InitStruct->DCMI_SynchroMode = DCMI_SynchroMode_Hardware;
190  DCMI_InitStruct->DCMI_PCKPolarity = DCMI_PCKPolarity_Falling;
191  DCMI_InitStruct->DCMI_VSPolarity = DCMI_VSPolarity_Low;
192  DCMI_InitStruct->DCMI_HSPolarity = DCMI_HSPolarity_Low;
193  DCMI_InitStruct->DCMI_CaptureRate = DCMI_CaptureRate_All_Frame;
195 }
196 
205 void DCMI_CROPConfig(DCMI_CROPInitTypeDef* DCMI_CROPInitStruct)
206 {
207  /* Sets the CROP window coordinates */
208  DCMI->CWSTRTR = (uint32_t)((uint32_t)DCMI_CROPInitStruct->DCMI_HorizontalOffsetCount |
209  ((uint32_t)DCMI_CROPInitStruct->DCMI_VerticalStartLine << 16));
210 
211  /* Sets the CROP window size */
212  DCMI->CWSIZER = (uint32_t)(DCMI_CROPInitStruct->DCMI_CaptureCount |
213  ((uint32_t)DCMI_CROPInitStruct->DCMI_VerticalLineCount << 16));
214 }
215 
224 {
225  /* Check the parameters */
227 
228  if (NewState != DISABLE)
229  {
230  /* Enable the DCMI Crop feature */
231  DCMI->CR |= (uint32_t)DCMI_CR_CROP;
232  }
233  else
234  {
235  /* Disable the DCMI Crop feature */
236  DCMI->CR &= ~(uint32_t)DCMI_CR_CROP;
237  }
238 }
239 
247 {
248  DCMI->ESCR = (uint32_t)(DCMI_CodesInitStruct->DCMI_FrameStartCode |
249  ((uint32_t)DCMI_CodesInitStruct->DCMI_LineStartCode << 8)|
250  ((uint32_t)DCMI_CodesInitStruct->DCMI_LineEndCode << 16)|
251  ((uint32_t)DCMI_CodesInitStruct->DCMI_FrameEndCode << 24));
252 }
253 
262 {
263  /* Check the parameters */
265 
266  if (NewState != DISABLE)
267  {
268  /* Enable the DCMI JPEG format */
269  DCMI->CR |= (uint32_t)DCMI_CR_JPEG;
270  }
271  else
272  {
273  /* Disable the DCMI JPEG format */
274  DCMI->CR &= ~(uint32_t)DCMI_CR_JPEG;
275  }
276 }
299 void DCMI_Cmd(FunctionalState NewState)
300 {
301  /* Check the parameters */
303 
304  if (NewState != DISABLE)
305  {
306  /* Enable the DCMI by setting ENABLE bit */
307  DCMI->CR |= (uint32_t)DCMI_CR_ENABLE;
308  }
309  else
310  {
311  /* Disable the DCMI by clearing ENABLE bit */
312  DCMI->CR &= ~(uint32_t)DCMI_CR_ENABLE;
313  }
314 }
315 
323 {
324  /* Check the parameters */
326 
327  if (NewState != DISABLE)
328  {
329  /* Enable the DCMI Capture */
330  DCMI->CR |= (uint32_t)DCMI_CR_CAPTURE;
331  }
332  else
333  {
334  /* Disable the DCMI Capture */
335  DCMI->CR &= ~(uint32_t)DCMI_CR_CAPTURE;
336  }
337 }
338 
344 uint32_t DCMI_ReadData(void)
345 {
346  return DCMI->DR;
347 }
377 void DCMI_ITConfig(uint16_t DCMI_IT, FunctionalState NewState)
378 {
379  /* Check the parameters */
382 
383  if (NewState != DISABLE)
384  {
385  /* Enable the Interrupt sources */
386  DCMI->IER |= DCMI_IT;
387  }
388  else
389  {
390  /* Disable the Interrupt sources */
391  DCMI->IER &= (uint16_t)(~DCMI_IT);
392  }
393 }
394 
414 FlagStatus DCMI_GetFlagStatus(uint16_t DCMI_FLAG)
415 {
416  FlagStatus bitstatus = RESET;
417  uint32_t dcmireg, tempreg = 0;
418 
419  /* Check the parameters */
420  assert_param(IS_DCMI_GET_FLAG(DCMI_FLAG));
421 
422  /* Get the DCMI register index */
423  dcmireg = (((uint16_t)DCMI_FLAG) >> 12);
424 
425  if (dcmireg == 0x00) /* The FLAG is in RISR register */
426  {
427  tempreg= DCMI->RISR;
428  }
429  else if (dcmireg == 0x02) /* The FLAG is in SR register */
430  {
431  tempreg = DCMI->SR;
432  }
433  else /* The FLAG is in MISR register */
434  {
435  tempreg = DCMI->MISR;
436  }
437 
438  if ((tempreg & DCMI_FLAG) != (uint16_t)RESET )
439  {
440  bitstatus = SET;
441  }
442  else
443  {
444  bitstatus = RESET;
445  }
446  /* Return the DCMI_FLAG status */
447  return bitstatus;
448 }
449 
461 void DCMI_ClearFlag(uint16_t DCMI_FLAG)
462 {
463  /* Check the parameters */
464  assert_param(IS_DCMI_CLEAR_FLAG(DCMI_FLAG));
465 
466  /* Clear the flag by writing in the ICR register 1 in the corresponding
467  Flag position*/
468 
469  DCMI->ICR = DCMI_FLAG;
470 }
471 
483 ITStatus DCMI_GetITStatus(uint16_t DCMI_IT)
484 {
485  ITStatus bitstatus = RESET;
486  uint32_t itstatus = 0;
487 
488  /* Check the parameters */
489  assert_param(IS_DCMI_GET_IT(DCMI_IT));
490 
491  itstatus = DCMI->MISR & DCMI_IT; /* Only masked interrupts are checked */
492 
493  if ((itstatus != (uint16_t)RESET))
494  {
495  bitstatus = SET;
496  }
497  else
498  {
499  bitstatus = RESET;
500  }
501  return bitstatus;
502 }
503 
515 void DCMI_ClearITPendingBit(uint16_t DCMI_IT)
516 {
517  /* Clear the interrupt pending Bit by writing in the ICR register 1 in the
518  corresponding pending Bit position*/
519 
520  DCMI->ICR = DCMI_IT;
521 }
538 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
FlagStatus
Definition: stm32f4xx.h:706
DCMI Init structure definition.
#define DCMI_CR_CROP
Definition: stm32f4xx.h:4029
uint16_t DCMI_PCKPolarity
#define DCMI_CR_HSPOL
Definition: stm32f4xx.h:4033
FunctionalState
Definition: stm32f4xx.h:708
void DCMI_CROPConfig(DCMI_CROPInitTypeDef *DCMI_CROPInitStruct)
Initializes the DCMI peripheral CROP mode according to the specified parameters in the DCMI_CROPInitS...
#define DCMI_CR_CM
Definition: stm32f4xx.h:4028
uint16_t DCMI_HSPolarity
#define IS_DCMI_HSPOLARITY(POLARITY)
#define DCMI_CR_ESS
Definition: stm32f4xx.h:4031
#define DCMI_CR_FCRC_1
Definition: stm32f4xx.h:4036
#define IS_DCMI_SYNCHRO(MODE)
DCMI CROP Init structure definition.
#define DCMI_ExtendedDataMode_8b
uint16_t DCMI_SynchroMode
uint16_t DCMI_CaptureRate
uint16_t DCMI_ExtendedDataMode
void assert_param(int val)
uint32_t DCMI_ReadData(void)
Reads the data stored in the DR register.
#define DCMI_CaptureRate_All_Frame
#define DCMI_CR_FCRC_0
Definition: stm32f4xx.h:4035
#define IS_FUNCTIONAL_STATE(STATE)
Definition: stm32f4xx.h:709
void DCMI_Cmd(FunctionalState NewState)
Enables or disables the DCMI interface.
void DCMI_Init(DCMI_InitTypeDef *DCMI_InitStruct)
Initializes the DCMI according to the specified parameters in the DCMI_InitStruct.
uint16_t DCMI_HorizontalOffsetCount
#define DCMI_VSPolarity_Low
#define IS_DCMI_VSPOLARITY(POLARITY)
#define DCMI_CR_EDM_0
Definition: stm32f4xx.h:4037
#define DCMI_CR_EDM_1
Definition: stm32f4xx.h:4038
Definition: stm32f4xx.h:706
#define DCMI_CR_CAPTURE
Definition: stm32f4xx.h:4027
enum FlagStatus ITStatus
#define IS_DCMI_CONFIG_IT(IT)
#define DCMI_CR_VSPOL
Definition: stm32f4xx.h:4034
#define DCMI_CR_PCKPOL
Definition: stm32f4xx.h:4032
#define IS_DCMI_CAPTURE_RATE(RATE)
void DCMI_SetEmbeddedSynchroCodes(DCMI_CodesInitTypeDef *DCMI_CodesInitStruct)
Sets the embedded synchronization codes.
#define DCMI_SynchroMode_Hardware
#define IS_DCMI_EXTENDED_DATA(DATA)
static volatile int16_t temp
Definition: drv_mpu6050.c:278
void DCMI_CaptureCmd(FunctionalState NewState)
Enables or disables the DCMI Capture.
DCMI Embedded Synchronisation CODE Init structure definition.
uint16_t DCMI_VerticalStartLine
#define DCMI_CR_JPEG
Definition: stm32f4xx.h:4030
#define IS_DCMI_CLEAR_FLAG(FLAG)
void DCMI_DeInit(void)
Deinitializes the DCMI registers to their default reset values.
#define DCMI_PCKPolarity_Falling
#define DCMI_HSPolarity_Low
void DCMI_StructInit(DCMI_InitTypeDef *DCMI_InitStruct)
Fills each DCMI_InitStruct member with its default value.
This file contains all the functions prototypes for the DCMI firmware library.
void DCMI_ClearITPendingBit(uint16_t DCMI_IT)
Clears the DCMI&#39;s interrupt pending bits.
#define IS_DCMI_GET_IT(IT)
uint16_t DCMI_VerticalLineCount
void DCMI_ITConfig(uint16_t DCMI_IT, FunctionalState NewState)
Enables or disables the DCMI interface interrupts.
#define DCMI
Definition: stm32f4xx.h:2144
uint16_t DCMI_VSPolarity
#define IS_DCMI_GET_FLAG(FLAG)
#define IS_DCMI_PCKPOLARITY(POLARITY)
#define DCMI_CR_ENABLE
Definition: stm32f4xx.h:4040
#define IS_DCMI_CAPTURE_MODE(MODE)
uint16_t DCMI_CaptureMode
ITStatus DCMI_GetITStatus(uint16_t DCMI_IT)
Checks whether the DCMI interrupt has occurred or not.
void DCMI_ClearFlag(uint16_t DCMI_FLAG)
Clears the DCMI&#39;s pending flags.
void DCMI_CROPCmd(FunctionalState NewState)
Enables or disables the DCMI Crop feature.
void DCMI_JPEGCmd(FunctionalState NewState)
Enables or disables the DCMI JPEG format.
FlagStatus DCMI_GetFlagStatus(uint16_t DCMI_FLAG)
Checks whether the DCMI interface flag is set or not.
#define DCMI_CaptureMode_Continuous


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:49