SCCB configured externally

This commit is contained in:
apiesse
2020-05-14 11:31:45 +02:00
parent 528c97a872
commit d109e5cc19
4 changed files with 24 additions and 23 deletions

View File

@ -959,7 +959,7 @@ esp_err_t camera_probe(const camera_config_t* config, camera_model_t* out_camera
camera_enable_out_clock(config);
ESP_LOGD(TAG, "Initializing SSCB");
SCCB_Init(config->pin_sscb_sda, config->pin_sscb_scl);
SCCB_Init(config->pin_sccb_sda, config->pin_sccb_scl, config->sccb_external);
if(config->pin_pwdn >= 0) {
ESP_LOGD(TAG, "Resetting camera by power down line");
@ -968,7 +968,7 @@ esp_err_t camera_probe(const camera_config_t* config, camera_model_t* out_camera
conf.mode = GPIO_MODE_OUTPUT;
gpio_config(&conf);
// carefull, logic is inverted compared to reset pin
// careful, logic is inverted compared to reset pin
gpio_set_level(config->pin_pwdn, 1);
vTaskDelay(10 / portTICK_PERIOD_MS);
gpio_set_level(config->pin_pwdn, 0);

View File

@ -18,8 +18,8 @@
.pin_pwdn = PIN_PWDN,
.pin_reset = PIN_RESET,
.pin_xclk = PIN_XCLK,
.pin_sscb_sda = PIN_SIOD,
.pin_sscb_scl = PIN_SIOC,
.pin_sccb_sda = PIN_SIOD,
.pin_sccb_scl = PIN_SIOC,
.pin_d7 = PIN_D7,
.pin_d6 = PIN_D6,
.pin_d5 = PIN_D5,
@ -81,8 +81,8 @@ typedef struct {
int pin_pwdn; /*!< GPIO pin for camera power down line */
int pin_reset; /*!< GPIO pin for camera reset line */
int pin_xclk; /*!< GPIO pin for camera XCLK line */
int pin_sscb_sda; /*!< GPIO pin for camera SDA line */
int pin_sscb_scl; /*!< GPIO pin for camera SCL line */
int pin_sccb_sda; /*!< GPIO pin for camera SDA line */
int pin_sccb_scl; /*!< GPIO pin for camera SCL line */
int pin_d7; /*!< GPIO pin for camera D7 line */
int pin_d6; /*!< GPIO pin for camera D6 line */
int pin_d5; /*!< GPIO pin for camera D5 line */
@ -105,6 +105,8 @@ typedef struct {
int jpeg_quality; /*!< Quality of JPEG output. 0-63 lower means higher quality */
size_t fb_count; /*!< Number of frame buffers to be allocated. If more than one, then each frame will be acquired (double speed) */
int sccb_external; /*!< Hardware SCCB interface configured externally */
} camera_config_t;
/**

View File

@ -9,8 +9,8 @@
#ifndef __SCCB_H__
#define __SCCB_H__
#include <stdint.h>
int SCCB_Init(int pin_sda, int pin_scl);
uint8_t SCCB_Probe();
int SCCB_Init(int pin_sda, int pin_scl, int external);
uint8_t SCCB_Probe(void);
uint8_t SCCB_Read(uint8_t slv_addr, uint8_t reg);
uint8_t SCCB_Write(uint8_t slv_addr, uint8_t reg, uint8_t data);
uint8_t SCCB_Read16(uint8_t slv_addr, uint16_t reg);

View File

@ -19,8 +19,6 @@
static const char* TAG = "sccb";
#endif
//#undef CONFIG_SCCB_HARDWARE_I2C
#define LITTLETOBIG(x) ((x<<8)|(x>>8))
#ifdef CONFIG_SCCB_HARDWARE_I2C
@ -43,11 +41,11 @@ static uint8_t ESP_SLAVE_ADDR = 0x3c;
#include "twi.h"
#endif
int SCCB_Init(int pin_sda, int pin_scl)
int SCCB_Init(int pin_sda, int pin_scl, int external)
{
ESP_LOGI(TAG, "pin_sda %d pin_scl %d\n", pin_sda, pin_scl);
ESP_LOGI(TAG, "pin_sda %d pin_scl %d external %d \n", pin_sda, pin_scl, external);
#ifdef CONFIG_SCCB_HARDWARE_I2C
//log_i("SCCB_Init start");
if (external == 0) {
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = pin_sda;
@ -58,13 +56,14 @@ int SCCB_Init(int pin_sda, int pin_scl)
i2c_param_config(SCCB_I2C_PORT, &conf);
i2c_driver_install(SCCB_I2C_PORT, conf.mode, 0, 0, 0);
}
#else
twi_init(pin_sda, pin_scl);
#endif
return 0;
}
uint8_t SCCB_Probe()
uint8_t SCCB_Probe(void)
{
#ifdef CONFIG_SCCB_HARDWARE_I2C
uint8_t slave_addr = 0x0;