From a6e2ac208e29051828f531eb9a8514fa6e236b1c Mon Sep 17 00:00:00 2001 From: apiesse Date: Thu, 5 Mar 2020 17:30:21 +0100 Subject: [PATCH 1/3] Hardware I2C0/I2C1 for sccb communication --- Kconfig | 13 ++++++++++--- driver/sccb.c | 11 +++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Kconfig b/Kconfig index 8d3af00..06a90b5 100755 --- a/Kconfig +++ b/Kconfig @@ -21,13 +21,20 @@ config OV3660_SUPPORT Enable this option if you want to use the OV3360. Disable this option to safe memory. -config SCCB_HARDWARE_I2C - bool "Use hardware I2C1 for SCCB" - default y +choice SCCB_HARDWARE_I2C + bool "Use hardware I2C0/I2C1 for SCCB" + default SCCB_HARDWARE_I2C1 help Enable this option if you want to use hardware I2C to control the camera. Disable this option to use software I2C. + config SCCB_HARDWARE_I2C0 + bool "I2C0" + config SCCB_HARDWARE_I2C1 + bool "I2C1" + +endchoice + choice CAMERA_TASK_PINNED_TO_CORE bool "Camera task pinned to core" default CAMERA_CORE0 diff --git a/driver/sccb.c b/driver/sccb.c index 48e53fc..bbff837 100755 --- a/driver/sccb.c +++ b/driver/sccb.c @@ -19,6 +19,13 @@ static const char* TAG = "sccb"; #endif +#ifdef CONFIG_SCCB_HARDWARE_I2C0 + #define CONFIG_SCCB_HARDWARE_I2C +#endif +#ifdef CONFIG_SCCB_HARDWARE_I2C1 + #define CONFIG_SCCB_HARDWARE_I2C +#endif + #define LITTLETOBIG(x) ((x<<8)|(x>>8)) #ifdef CONFIG_SCCB_HARDWARE_I2C @@ -31,7 +38,11 @@ static const char* TAG = "sccb"; #define ACK_CHECK_DIS 0x0 /*!< I2C master will not check ack from slave */ #define ACK_VAL 0x0 /*!< I2C ack value */ #define NACK_VAL 0x1 /*!< I2C nack value */ +#if CONFIG_SCCB_HARDWARE_I2C1 const int SCCB_I2C_PORT = 1; +#else +const int SCCB_I2C_PORT = 0; +#endif static uint8_t ESP_SLAVE_ADDR = 0x3c; #else #include "twi.h" From c38999847b759fa0f127021fbfa4ec07306d7de1 Mon Sep 17 00:00:00 2001 From: apiesse Date: Fri, 6 Mar 2020 09:20:47 +0100 Subject: [PATCH 2/3] update Kconfig to remove the need of some of the ifdef stuff in the sccb.c file and show the setting only when hardware is selected --- Kconfig | 15 ++++++++++----- driver/sccb.c | 9 +-------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Kconfig b/Kconfig index 06a90b5..d03d30e 100755 --- a/Kconfig +++ b/Kconfig @@ -21,16 +21,21 @@ config OV3660_SUPPORT Enable this option if you want to use the OV3360. Disable this option to safe memory. -choice SCCB_HARDWARE_I2C - bool "Use hardware I2C0/I2C1 for SCCB" - default SCCB_HARDWARE_I2C1 +config SCCB_HARDWARE_I2C + bool "Use hardware I2C for SCCB" + default y help Enable this option if you want to use hardware I2C to control the camera. Disable this option to use software I2C. + +choice SCCB_HARDWARE_I2C_PORT + bool "I2C peripheral to use for SCCB" + depends on SCCB_HARDWARE_I2C + default SCCB_HARDWARE_I2C1 - config SCCB_HARDWARE_I2C0 + config SCCB_HARDWARE_I2C_PORT0 bool "I2C0" - config SCCB_HARDWARE_I2C1 + config SCCB_HARDWARE_I2C_PORT1 bool "I2C1" endchoice diff --git a/driver/sccb.c b/driver/sccb.c index bbff837..aa57abc 100755 --- a/driver/sccb.c +++ b/driver/sccb.c @@ -19,13 +19,6 @@ static const char* TAG = "sccb"; #endif -#ifdef CONFIG_SCCB_HARDWARE_I2C0 - #define CONFIG_SCCB_HARDWARE_I2C -#endif -#ifdef CONFIG_SCCB_HARDWARE_I2C1 - #define CONFIG_SCCB_HARDWARE_I2C -#endif - #define LITTLETOBIG(x) ((x<<8)|(x>>8)) #ifdef CONFIG_SCCB_HARDWARE_I2C @@ -38,7 +31,7 @@ static const char* TAG = "sccb"; #define ACK_CHECK_DIS 0x0 /*!< I2C master will not check ack from slave */ #define ACK_VAL 0x0 /*!< I2C ack value */ #define NACK_VAL 0x1 /*!< I2C nack value */ -#if CONFIG_SCCB_HARDWARE_I2C1 +#if CONFIG_SCCB_HARDWARE_I2C_PORT1 const int SCCB_I2C_PORT = 1; #else const int SCCB_I2C_PORT = 0; From 0f835fe230e63b13ee254daa2b79ddee715322aa Mon Sep 17 00:00:00 2001 From: apiesse Date: Fri, 6 Mar 2020 09:31:36 +0100 Subject: [PATCH 3/3] fixed type in Kconfig --- Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kconfig b/Kconfig index d03d30e..207c307 100755 --- a/Kconfig +++ b/Kconfig @@ -31,7 +31,7 @@ config SCCB_HARDWARE_I2C choice SCCB_HARDWARE_I2C_PORT bool "I2C peripheral to use for SCCB" depends on SCCB_HARDWARE_I2C - default SCCB_HARDWARE_I2C1 + default SCCB_HARDWARE_I2C_PORT1 config SCCB_HARDWARE_I2C_PORT0 bool "I2C0"