/** ****************************************************************************** * @file b_u585i_iot02a_camera.h * @author MCD Application Team * @brief This file contains the common defines and functions prototypes for * the b_u585i_iot02a_camera.c driver. ****************************************************************************** * @attention * * Copyright (c) 2021 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef B_U585I_IOT02A_CAMERA_H #define B_U585I_IOT02A_CAMERA_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "b_u585i_iot02a_errno.h" #include "b_u585i_iot02a_conf.h" #include "camera.h" #include "../Components/ov5640/ov5640.h" /** @addtogroup BSP * @{ */ /** @addtogroup B_U585I_IOT02A * @{ */ /** @defgroup B_U585I_IOT02A_CAMERA CAMERA * @{ */ /** @defgroup B_U585I_IOT02A_CAMERA_Exported_Types CAMERA Exported Types * @{ */ typedef struct { uint32_t Resolution; uint32_t PixelFormat; uint32_t LightMode; uint32_t ColorEffect; int32_t Brightness; int32_t Saturation; int32_t Contrast; int32_t HueDegree; uint32_t MirrorFlip; uint32_t Zoom; uint32_t NightMode; uint32_t IsMspCallbacksValid; } CAMERA_Ctx_t; typedef struct { uint32_t Resolution; uint32_t LightMode; uint32_t ColorEffect; uint32_t Brightness; uint32_t Saturation; uint32_t Contrast; uint32_t HueDegree; uint32_t MirrorFlip; uint32_t Zoom; uint32_t NightMode; } CAMERA_Capabilities_t; #if (USE_HAL_DCMI_REGISTER_CALLBACKS > 0) typedef struct { void (* pMspInitCb)(DCMI_HandleTypeDef *); void (* pMspDeInitCb)(DCMI_HandleTypeDef *); } BSP_CAMERA_Cb_t; #endif /* (USE_HAL_DCMI_REGISTER_CALLBACKS > 0) */ /** * @} */ /** @defgroup B_U585I_IOT02A_CAMERA_Exported_Constants CAMERA Exported Constants * @{ */ /* Camera instance number */ #define CAMERA_INSTANCES_NBR 1U #define CAMERA_MODE_CONTINUOUS DCMI_MODE_CONTINUOUS #define CAMERA_MODE_SNAPSHOT DCMI_MODE_SNAPSHOT /* Camera resolutions */ #define CAMERA_R160x120 0U /* QQVGA Resolution */ #define CAMERA_R320x240 1U /* QVGA Resolution */ #define CAMERA_R480x272 2U /* 480x272 Resolution */ #define CAMERA_R640x480 3U /* VGA Resolution */ #define CAMERA_R800x480 4U /* WVGA Resolution */ /* Camera Pixel Format */ #define CAMERA_PF_RGB565 0U /* Pixel Format RGB565 */ #define CAMERA_PF_RGB888 1U /* Pixel Format RGB888 */ #define CAMERA_PF_YUV422 2U /* Pixel Format YUV422 */ /* Brightness */ #define CAMERA_BRIGHTNESS_MIN -4 #define CAMERA_BRIGHTNESS_MAX 4 /* Saturation */ #define CAMERA_SATURATION_MIN -4 #define CAMERA_SATURATION_MAX 4 /* Contrast */ #define CAMERA_CONTRAST_MIN -4 #define CAMERA_CONTRAST_MAX 4 /* Hue Control */ #define CAMERA_HUEDEGREE_MIN -6 #define CAMERA_HUEDEGREE_MAX 5 /* Mirror/Flip */ #define CAMERA_MIRRORFLIP_NONE 0x00U /* Set camera normal mode */ #define CAMERA_MIRRORFLIP_FLIP 0x01U /* Set camera flip config */ #define CAMERA_MIRRORFLIP_MIRROR 0x02U /* Set camera mirror config */ /* Zoom */ #define CAMERA_ZOOM_x8 0x00U /* Set zoom to x8 */ #define CAMERA_ZOOM_x4 0x11U /* Set zoom to x4 */ #define CAMERA_ZOOM_x2 0x22U /* Set zoom to x2 */ #define CAMERA_ZOOM_x1 0x44U /* Set zoom to x1 */ /* Color Effect */ #define CAMERA_COLOR_EFFECT_NONE 0x00U /* No effect */ #define CAMERA_COLOR_EFFECT_BLUE 0x01U /* Blue effect */ #define CAMERA_COLOR_EFFECT_RED 0x02U /* Red effect */ #define CAMERA_COLOR_EFFECT_GREEN 0x04U /* Green effect */ #define CAMERA_COLOR_EFFECT_BW 0x08U /* Black and White effect */ #define CAMERA_COLOR_EFFECT_SEPIA 0x10U /* Sepia effect */ #define CAMERA_COLOR_EFFECT_NEGATIVE 0x20U /* Negative effect */ /* Light Mode */ #define CAMERA_LIGHT_AUTO 0x00U /* Light Mode Auto */ #define CAMERA_LIGHT_SUNNY 0x01U /* Light Mode Sunny */ #define CAMERA_LIGHT_OFFICE 0x02U /* Light Mode Office */ #define CAMERA_LIGHT_HOME 0x04U /* Light Mode Home */ #define CAMERA_LIGHT_CLOUDY 0x08U /* Light Mode Claudy */ /* Night Mode */ #define CAMERA_NIGHT_MODE_SET 0x00U /* Disable night mode */ #define CAMERA_NIGHT_MODE_RESET 0x01U /* Enable night mode */ #define CAMERA_IRQHandler DCMI_PSSI_IRQHandler #define CAMERA_DMA_IRQHandler DMA2_Stream3_IRQHandler #define XSDN_PIN GPIO_PIN_3 #define XSDN_PORT GPIOI #define XSDN_PIN_AF GPIO_AF10_DCMI #define RSTI_PIN GPIO_PIN_2 #define RSTI_PORT GPIOI #define RSTI_PIN_AF GPIO_AF10_DCMI #define CAM_PLUG_PIN GPIO_PIN_1 #define CAM_PLUG_PORT GPIOI #define CAM_PLUG_PIN_AF GPIO_AF10_DCMI #define CAMERA_OV5640_ADDRESS 0x78U /** * @} */ /** @addtogroup B_U585I_IOT02A_CAMERA_Exported_Variables * @{ */ extern void *Camera_CompObj; extern DCMI_HandleTypeDef hcamera_dcmi; extern CAMERA_Ctx_t Camera_Ctx[]; /** * @} */ /** @addtogroup B_U585I_IOT02A_CAMERA_Exported_Functions * @{ */ int32_t BSP_CAMERA_Init(uint32_t Instance, uint32_t Resolution, uint32_t PixelFormat); int32_t BSP_CAMERA_DeInit(uint32_t Instance); #if (USE_HAL_DCMI_REGISTER_CALLBACKS > 0) int32_t BSP_CAMERA_RegisterDefaultMspCallbacks(uint32_t Instance); int32_t BSP_CAMERA_RegisterMspCallbacks(uint32_t Instance, BSP_CAMERA_Cb_t *CallBacks); #endif /* (USE_HAL_DCMI_REGISTER_CALLBACKS > 0) */ int32_t BSP_CAMERA_Start(uint32_t Instance, uint8_t *buff, uint32_t Mode); int32_t BSP_CAMERA_Stop(uint32_t Instance); int32_t BSP_CAMERA_Suspend(uint32_t Instance); int32_t BSP_CAMERA_Resume(uint32_t Instance); int32_t BSP_CAMERA_GetCapabilities(uint32_t Instance, CAMERA_Capabilities_t *Capabilities); int32_t BSP_CAMERA_SetResolution(uint32_t Instance, uint32_t Resolution); int32_t BSP_CAMERA_GetResolution(uint32_t Instance, uint32_t *Resolution); int32_t BSP_CAMERA_SetPixelFormat(uint32_t Instance, uint32_t PixelFormat); int32_t BSP_CAMERA_GetPixelFormat(uint32_t Instance, uint32_t *PixelFormat); int32_t BSP_CAMERA_SetLightMode(uint32_t Instance, uint32_t LightMode); int32_t BSP_CAMERA_GetLightMode(uint32_t Instance, uint32_t *LightMode); int32_t BSP_CAMERA_SetColorEffect(uint32_t Instance, uint32_t ColorEffect); int32_t BSP_CAMERA_GetColorEffect(uint32_t Instance, uint32_t *ColorEffect); int32_t BSP_CAMERA_SetBrightness(uint32_t Instance, int32_t Brightness); int32_t BSP_CAMERA_GetBrightness(uint32_t Instance, int32_t *Brightness); int32_t BSP_CAMERA_SetSaturation(uint32_t Instance, int32_t Saturation); int32_t BSP_CAMERA_GetSaturation(uint32_t Instance, int32_t *Saturation); int32_t BSP_CAMERA_SetContrast(uint32_t Instance, int32_t Contrast); int32_t BSP_CAMERA_GetContrast(uint32_t Instance, int32_t *Contrast); int32_t BSP_CAMERA_SetHueDegree(uint32_t Instance, int32_t HueDegree); int32_t BSP_CAMERA_GetHueDegree(uint32_t Instance, int32_t *HueDegree); int32_t BSP_CAMERA_SetMirrorFlip(uint32_t Instance, uint32_t MirrorFlip); int32_t BSP_CAMERA_GetMirrorFlip(uint32_t Instance, uint32_t *MirrorFlip); int32_t BSP_CAMERA_SetZoom(uint32_t Instance, uint32_t Zoom); int32_t BSP_CAMERA_GetZoom(uint32_t Instance, uint32_t *Zoom); int32_t BSP_CAMERA_EnableNightMode(uint32_t Instance); int32_t BSP_CAMERA_DisableNightMode(uint32_t Instance); int32_t BSP_CAMERA_HwReset(uint32_t Instance); int32_t BSP_CAMERA_PwrDown(uint32_t Instance); void BSP_CAMERA_LineEventCallback(uint32_t Instance); void BSP_CAMERA_FrameEventCallback(uint32_t Instance); void BSP_CAMERA_VsyncEventCallback(uint32_t Instance); void BSP_CAMERA_ErrorCallback(uint32_t Instance); void BSP_CAMERA_IRQHandler(uint32_t Instance); void BSP_CAMERA_DMA_IRQHandler(uint32_t Instance); /* This function can be modified in case the current settings (e.g. DMA stream) need to be changed for specific application needs */ HAL_StatusTypeDef MX_DCMI_Init(DCMI_HandleTypeDef *hdcmi); /** * @} */ /** * @} */ /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* B_U585I_IOT02A_CAMERA_H */