mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-12 15:42:52 +00:00
feat(cam): add cam sensor handle and deinit api
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
static const char *TAG = "sensor_init";
|
||||
|
||||
void example_sensor_init(example_sensor_config_t *sensor_config, i2c_master_bus_handle_t *out_i2c_bus_handle)
|
||||
void example_sensor_init(example_sensor_config_t *sensor_config, example_sensor_handle_t *out_sensor_handle)
|
||||
{
|
||||
esp_err_t ret = ESP_FAIL;
|
||||
|
||||
@@ -95,6 +95,12 @@ void example_sensor_init(example_sensor_config_t *sensor_config, i2c_master_bus_
|
||||
ESP_LOGE(TAG, "Start stream fail");
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
*out_i2c_bus_handle = i2c_bus_handle;
|
||||
out_sensor_handle->i2c_bus_handle = i2c_bus_handle;
|
||||
out_sensor_handle->sccb_handle = cam_config.sccb_handle;
|
||||
}
|
||||
|
||||
void example_sensor_deinit(example_sensor_handle_t sensor_handle)
|
||||
{
|
||||
ESP_ERROR_CHECK(esp_sccb_del_i2c_io(sensor_handle.sccb_handle));
|
||||
ESP_ERROR_CHECK(i2c_del_master_bus(sensor_handle.i2c_bus_handle));
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -13,6 +13,14 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Handle of SCCB interface and sensor
|
||||
*/
|
||||
typedef struct {
|
||||
esp_sccb_io_handle_t sccb_handle; /*!< SCCB io handle that created by `sccb_new_i2c_io` */
|
||||
i2c_master_bus_handle_t i2c_bus_handle; /*!< I2C bus handle that created by `i2c_new_master_bus` */
|
||||
} example_sensor_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration of SCCB interface and sensor
|
||||
*/
|
||||
@@ -28,9 +36,16 @@ typedef struct {
|
||||
* @brief SCCB Interface and Sensor Init
|
||||
*
|
||||
* @param[in] sensor_config Camera sensor configuration
|
||||
* @param[out] out_i2c_bus_handle I2C bus handle
|
||||
* @param[out] out_sensor_handle Camera sensor handle
|
||||
*/
|
||||
void example_sensor_init(example_sensor_config_t *sensor_config, i2c_master_bus_handle_t *out_i2c_bus_handle);
|
||||
void example_sensor_init(example_sensor_config_t *sensor_config, example_sensor_handle_t *out_sensor_handle);
|
||||
|
||||
/**
|
||||
* @brief SCCB Interface and Sensor Deinit
|
||||
*
|
||||
* @param[in] out_sensor_handle Camera sensor handle
|
||||
*/
|
||||
void example_sensor_deinit(example_sensor_handle_t sensor_handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user