API 参考
本文档列出 esp_video 的初始化 API(esp_video_init 等)。工程集成步骤、设备节点与 open / ioctl 调用顺序见 ESP Video 应用开发指南。各请求代码的参数与示例见 命令介绍。
初始化
Header File
Functions
-
esp_err_t esp_video_init_with_flags(const esp_video_init_config_t *config, uint32_t flags)
Initialize video hardware and software, including I2C, MIPI CSI and so on with flags.
备注
These flags are used to initialize the video hardware and software with specific flags. They can be combined using bitwise OR operation. For example, to initialize MIPI CSI and DVP video devices, you can use: esp_video_init_with_flags(config, ESP_VIDEO_INIT_FLAGS_MIPI_CSI | ESP_VIDEO_INIT_FLAGS_DVP); To initialize all video devices, you can use: esp_video_init_with_flags(config, ESP_VIDEO_INIT_FLAGS_ALL);
- 参数:
config – video hardware configuration
flags – video device flags, which can be a combination of ESP_VIDEO_INIT_FLAGS_XXX
- 返回:
ESP_OK on success
Others if failed
-
esp_err_t esp_video_deinit_with_flags(uint32_t flags)
Deinitialize video hardware and software, including I2C, MIPI CSI and so on with flags.
备注
This function will deinitialize the video hardware and software in the order of JPEG, H.264, MIPI CSI, DVP, SPI, USB UVC, ISP.
- 参数:
flags – video device flags, which can be a combination of ESP_VIDEO_INIT_FLAGS_XXX
- 返回:
ESP_OK on success
Others if failed
-
esp_err_t esp_video_init(const esp_video_init_config_t *config)
Initialize video hardware and software, including I2C, MIPI CSI and so on.
备注
This function will initialize the video hardware and software with all flags. It is equivalent to calling esp_video_init_with_flags(config, ESP_VIDEO_INIT_FLAGS_ALL).
- 参数:
config – video hardware configuration
- 返回:
ESP_OK on success
Others if failed
-
esp_err_t esp_video_deinit(void)
Deinitialize video hardware and software, including I2C, MIPI CSI and so on.
备注
This function will deinitialize the video hardware and software with all flags. It is equivalent to calling esp_video_deinit_with_flags(ESP_VIDEO_INIT_FLAGS_ALL).
- 返回:
ESP_OK on success
Others if failed
Structures
-
struct esp_video_init_sccb_config
SCCB initialization configuration.
Public Members
-
bool init_sccb
true: SCCB I2C is not initialized and esp_video_init function will initialize SCCB I2C with given parameters i2c_config. false: SCCB I2C is initialized and esp_video_init function can use i2c_handle directly
-
uint8_t port
SCCB I2C port
-
gpio_num_t scl_pin
SCCB I2C SCL pin
-
gpio_num_t sda_pin
SCCB I2C SDA pin
-
struct esp_video_init_sccb_config::[anonymous]::[anonymous] i2c_config
SCCB I2C configuration
-
i2c_master_bus_handle_t i2c_handle
SCCB I2C handle
-
uint32_t freq
SCCB I2C frequency
-
bool init_sccb
-
struct esp_video_init_csi_config
MIPI CSI initialization and camera sensor connection configuration.
Public Members
-
esp_video_init_sccb_config_t sccb_config
Camera sensor SCCB configuration
-
gpio_num_t reset_pin
Camera sensor reset pin, if hardware has no reset pin, set reset_pin to be -1
-
gpio_num_t pwdn_pin
Camera sensor power down pin, if hardware has no power down pin, set pwdn_pin to be -1
-
bool dont_init_ldo
If true, MIPI-CSI video device will not initialize the LDO; otherwise, MIPI-CSI video device will initialize the LDO
-
esp_video_init_sccb_config_t sccb_config
-
struct esp_video_init_dvp_config
DVP initialization and camera sensor connection configuration.
Public Members
-
esp_video_init_sccb_config_t sccb_config
Camera sensor SCCB configuration
-
gpio_num_t reset_pin
Camera sensor reset pin, if hardware has no reset pin, set reset_pin to be -1
-
gpio_num_t pwdn_pin
Camera sensor power down pin, if hardware has no power down pin, set pwdn_pin to be -1
-
esp_cam_ctlr_dvp_pin_config_t dvp_pin
DVP pin configuration
-
uint32_t xclk_freq
DVP hardware output clock frequency
-
esp_video_init_sccb_config_t sccb_config
-
struct esp_video_init_spi_config
SPI interface camera sensor connection configuration.
Public Members
-
esp_video_init_sccb_config_t sccb_config
Camera sensor SCCB configuration
-
esp_cam_ctlr_spi_cam_intf_t intf
SPI CAM interface type:
ESP_CAM_CTLR_SPI_CAM_INTF_SPI: SPI interface
ESP_CAM_CTLR_SPI_CAM_INTF_PARLIO: Parallel I/O interface
-
esp_cam_ctlr_spi_cam_io_mode_t io_mode
SPI CAM data I/O mode(SPI interface only supports 1-bit):
ESP_CAM_CTLR_SPI_CAM_IO_MODE_1BIT: data bus 1-bit
ESP_CAM_CTLR_SPI_CAM_IO_MODE_2BIT: data bus 2-bit
-
uint8_t spi_port
SPI port
-
gpio_num_t spi_cs_pin
SPI CS pin
-
gpio_num_t spi_sclk_pin
SPI SCLK pin
-
gpio_num_t spi_data0_io_pin
SPI data0 I/O pin
-
gpio_num_t spi_data1_io_pin
SPI data1 I/O pin (only required when io_mode is ESP_CAM_CTLR_SPI_CAM_IO_MODE_2BIT, set to -1 if not used)
-
gpio_num_t spi_data2_io_pin
SPI data2 I/O pin (only required when io_mode is ESP_CAM_CTLR_SPI_CAM_IO_MODE_4BIT, set to -1 if not used)
-
gpio_num_t spi_data3_io_pin
SPI data3 I/O pin (only required when io_mode is ESP_CAM_CTLR_SPI_CAM_IO_MODE_4BIT, set to -1 if not used)
-
gpio_num_t reset_pin
SPI interface camera sensor reset pin, if hardware has no reset pin, set reset_pin to be -1
-
gpio_num_t pwdn_pin
SPI interface camera sensor power down pin, if hardware has no power down pin, set pwdn_pin to be -1
-
esp_cam_sensor_xclk_source_t xclk_source
Output clock resource for SPI interface camera sensor
-
uint32_t xclk_freq
Output clock frequency for SPI interface camera sensor
-
gpio_num_t xclk_pin
Output clock pin for SPI interface camera sensor
-
ledc_timer_t timer
The timer source of channel
-
ledc_clk_cfg_t clk_cfg
LEDC source clock from ledc_clk_cfg_t
-
ledc_channel_t channel
LEDC channel used for XCLK
-
struct esp_video_init_spi_config::[anonymous] xclk_ledc_cfg
LEDC configuration for XCLK
-
esp_video_init_sccb_config_t sccb_config
-
struct esp_video_init_usb_uvc_config
UVC video device initialization configuration.
Public Members
-
uint8_t uvc_dev_num
USB UVC devices number
-
uint32_t task_stack
USB UVC video device task stack size
USB Host Lib task stack size
-
uint8_t task_priority
USB UVC video device task priority
USB Host Lib task priority
-
int task_affinity
USB UVC video device task affinity, -1 means no affinity
USB Host Lib task affinity, -1 means no affinity
-
struct esp_video_init_usb_uvc_config::[anonymous] uvc
USB UVC video device configuration
-
bool init_usb_host_lib
Init USB Host Lib in esp_video
-
unsigned peripheral_map
Selects the USB peripheral(s) to use.
-
struct esp_video_init_usb_uvc_config::[anonymous] usb
USB Host Lib configuration
-
uint8_t uvc_dev_num
-
struct esp_video_init_jpeg_enc_config
JPEG initialization configuration.
Public Members
-
jpeg_encoder_handle_t enc_handle
JPEG encoder driver handle:
NULL, JPEG video device will create JPEG encoder driver handle by itself
Not null, JPEG video device will use this handle instead of creating JPEG encoder driver handle
-
jpeg_encoder_handle_t enc_handle
-
struct esp_video_init_jpeg_dec_config
JPEG decode initialization configuration.
Public Members
-
jpeg_decoder_handle_t dec_handle
JPEG decoder driver handle:
NULL, JPEG decode video device will create JPEG decoder driver handle by itself
Not null, JPEG decode video device will use this handle instead of creating JPEG decoder driver handle
-
jpeg_decoder_handle_t dec_handle
-
struct esp_video_init_cam_motor_config
Camera motor connection configuration.
Public Members
-
esp_video_init_sccb_config_t sccb_config
Camera motor SCCB configuration
-
gpio_num_t reset_pin
Camera motor reset pin, if hardware has no reset pin, set reset_pin to be -1
-
gpio_num_t pwdn_pin
Camera motor power down pin, if hardware has no power down pin, set pwdn_pin to be -1
-
gpio_num_t signal_pin
Camera motor enable signal pin, if hardware has no signal pin, set signal to be -1
-
esp_video_init_sccb_config_t sccb_config
-
struct esp_video_init_config
Video hardware initialization configuration.
Public Members
-
const esp_video_init_csi_config_t *csi
MIPI CSI initialization configuration
-
const esp_video_init_dvp_config_t *dvp
DVP initialization configuration array
-
const esp_video_init_jpeg_enc_config_t *jpeg_enc
JPEG encoder initialization configuration
-
const esp_video_init_jpeg_enc_config_t *jpeg
JPEG encoder initialization configuration, this is a backward compatibility alias for jpeg_enc
-
const esp_video_init_jpeg_dec_config_t *jpeg_dec
JPEG decode initialization configuration
-
const esp_video_init_cam_motor_config_t *cam_motor
Camera motor initialization configuration
-
const esp_video_init_spi_config_t *spi
SPI initialization configuration
-
const esp_video_init_usb_uvc_config_t *usb_uvc
USB UVC video device initialization configuration
-
const esp_video_init_csi_config_t *csi
Macros
-
ESP_VIDEO_INIT_FLAGS_MIPI_CSI
Video device initialization flags.
备注
These flags are used to initialize the video hardware and software with specific flags. They can be combined using bitwise OR operation. For example, to initialize MIPI CSI and DVP video devices, you can use: esp_video_init_with_flags(config, ESP_VIDEO_INIT_FLAGS_MIPI_CSI | ESP_VIDEO_INIT_FLAGS_DVP); To initialize all video devices, you can use: esp_video_init_with_flags(config, ESP_VIDEO_INIT_FLAGS_ALL);
-
ESP_VIDEO_INIT_FLAGS_DVP
-
ESP_VIDEO_INIT_FLAGS_SPI
-
ESP_VIDEO_INIT_FLAGS_ISP
-
ESP_VIDEO_INIT_FLAGS_USB_UVC
-
ESP_VIDEO_INIT_FLAGS_H264
-
ESP_VIDEO_INIT_FLAGS_JPEG_ENC
-
ESP_VIDEO_INIT_FLAGS_MOTOR
-
ESP_VIDEO_INIT_FLAGS_JPEG_DEC
-
ESP_VIDEO_INIT_FLAGS_ALL
-
ESP_VIDEO_INIT_FLAGS_JPEG
JPEG initialization flags.
备注
This is a backward compatibility.
-
ESP_VIDEO_ENABLE_SCCB_DEVICE
SCCB I2C device initialization flag
Type Definitions
-
typedef struct esp_video_init_sccb_config esp_video_init_sccb_config_t
SCCB initialization configuration.
-
typedef struct esp_video_init_csi_config esp_video_init_csi_config_t
MIPI CSI initialization and camera sensor connection configuration.
-
typedef struct esp_video_init_dvp_config esp_video_init_dvp_config_t
DVP initialization and camera sensor connection configuration.
-
typedef struct esp_video_init_spi_config esp_video_init_spi_config_t
SPI interface camera sensor connection configuration.
-
typedef struct esp_video_init_usb_uvc_config esp_video_init_usb_uvc_config_t
UVC video device initialization configuration.
-
typedef struct esp_video_init_jpeg_enc_config esp_video_init_jpeg_enc_config_t
JPEG initialization configuration.
-
typedef esp_video_init_jpeg_enc_config_t esp_video_init_jpeg_config_t
JPEG initialization configuration.
备注
This is a backward compatibility alias for esp_video_init_jpeg_enc_config_t.
-
typedef struct esp_video_init_jpeg_dec_config esp_video_init_jpeg_dec_config_t
JPEG decode initialization configuration.
-
typedef struct esp_video_init_cam_motor_config esp_video_init_cam_motor_config_t
Camera motor connection configuration.
-
typedef struct esp_video_init_config esp_video_init_config_t
Video hardware initialization configuration.