Skip to content

Commit

Permalink
Add mega ccm driver support
Browse files Browse the repository at this point in the history
Signed-off-by: Lee Jackson <[email protected]>
  • Loading branch information
Lee Jackson committed Nov 12, 2024
1 parent 0054ab7 commit 05e3050
Show file tree
Hide file tree
Showing 11 changed files with 548 additions and 4 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET ST
sensors/sc101iot.c
sensors/sc030iot.c
sensors/sc031gs.c
sensors/mega_ccm.c
)

list(APPEND priv_include_dirs
Expand Down
7 changes: 7 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ menu "Camera configuration"
Enable this option if you want to use the SC031GS.
Disable this option to save memory.

config MEGA_CCM_SUPPORT
bool "Support MEGA CCM 5MP"
default y
help
Enable this option if you want to use the MEGA CCM.
Disable this option to save memory.

choice SCCB_HARDWARE_I2C_PORT
bool "I2C peripheral to use for SCCB"
default SCCB_HARDWARE_I2C_PORT1
Expand Down
6 changes: 6 additions & 0 deletions driver/esp_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
#if CONFIG_SC031GS_SUPPORT
#include "sc031gs.h"
#endif
#if CONFIG_MEGA_CCM_SUPPORT
#include "mega_ccm.h"
#endif

#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
#include "esp32-hal-log.h"
Expand Down Expand Up @@ -143,6 +146,9 @@ static const sensor_func_t g_sensors[] = {
#if CONFIG_SC031GS_SUPPORT
{sc031gs_detect, sc031gs_init},
#endif
#if CONFIG_MEGA_CCM_SUPPORT
{mega_ccm_detect, mega_ccm_init},
#endif
};

static esp_err_t camera_probe(const camera_config_t *config, camera_model_t *out_camera_model)
Expand Down
6 changes: 6 additions & 0 deletions driver/include/sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef enum {
SC101IOT_PID = 0xda4a,
SC030IOT_PID = 0x9a46,
SC031GS_PID = 0x0031,
MEGA_CCM_PID =0x039E,
} camera_pid_t;

typedef enum {
Expand All @@ -48,6 +49,7 @@ typedef enum {
CAMERA_SC101IOT,
CAMERA_SC030IOT,
CAMERA_SC031GS,
CAMERA_MEGA_CCM,
CAMERA_MODEL_MAX,
CAMERA_NONE,
} camera_model_t;
Expand All @@ -67,6 +69,7 @@ typedef enum {
SC101IOT_SCCB_ADDR = 0x68,// 0xd0 >> 1
SC030IOT_SCCB_ADDR = 0x68,// 0xd0 >> 1
SC031GS_SCCB_ADDR = 0x30,
MEGA_CCM_SCCB_ADDR = 0x1F, // 0x3E >> 1
} camera_sccb_addr_t;

typedef enum {
Expand All @@ -84,10 +87,12 @@ typedef enum {
typedef enum {
FRAMESIZE_96X96, // 96x96
FRAMESIZE_QQVGA, // 160x120
FRAMESIZE_128X128, // 128x128
FRAMESIZE_QCIF, // 176x144
FRAMESIZE_HQVGA, // 240x176
FRAMESIZE_240X240, // 240x240
FRAMESIZE_QVGA, // 320x240
FRAMESIZE_320X320, // 320x320
FRAMESIZE_CIF, // 400x296
FRAMESIZE_HVGA, // 480x320
FRAMESIZE_VGA, // 640x480
Expand All @@ -106,6 +111,7 @@ typedef enum {
FRAMESIZE_WQXGA, // 2560x1600
FRAMESIZE_P_FHD, // 1080x1920
FRAMESIZE_QSXGA, // 2560x1920
FRAMESIZE_5MP, // 2592x1944
FRAMESIZE_INVALID
} framesize_t;

Expand Down
4 changes: 4 additions & 0 deletions driver/sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ const camera_sensor_info_t camera_sensor[CAMERA_MODEL_MAX] = {
{CAMERA_SC101IOT, "SC101IOT", SC101IOT_SCCB_ADDR, SC101IOT_PID, FRAMESIZE_HD, false},
{CAMERA_SC030IOT, "SC030IOT", SC030IOT_SCCB_ADDR, SC030IOT_PID, FRAMESIZE_VGA, false},
{CAMERA_SC031GS, "SC031GS", SC031GS_SCCB_ADDR, SC031GS_PID, FRAMESIZE_VGA, false},
{CAMERA_MEGA_CCM, "MEGA_CCM", MEGA_CCM_SCCB_ADDR, MEGA_CCM_PID, FRAMESIZE_5MP, true},
};

const resolution_info_t resolution[FRAMESIZE_INVALID] = {
{ 96, 96, ASPECT_RATIO_1X1 }, /* 96x96 */
{ 128, 128, ASPECT_RATIO_1X1 }, /* 128x128 */
{ 160, 120, ASPECT_RATIO_4X3 }, /* QQVGA */
{ 176, 144, ASPECT_RATIO_5X4 }, /* QCIF */
{ 240, 176, ASPECT_RATIO_4X3 }, /* HQVGA */
{ 240, 240, ASPECT_RATIO_1X1 }, /* 240x240 */
{ 320, 240, ASPECT_RATIO_4X3 }, /* QVGA */
{ 320, 320, ASPECT_RATIO_1X1 }, /* 320x320 */
{ 400, 296, ASPECT_RATIO_4X3 }, /* CIF */
{ 480, 320, ASPECT_RATIO_3X2 }, /* HVGA */
{ 640, 480, ASPECT_RATIO_4X3 }, /* VGA */
Expand All @@ -44,6 +47,7 @@ const resolution_info_t resolution[FRAMESIZE_INVALID] = {
{ 2560, 1600, ASPECT_RATIO_16X10 }, /* WQXGA */
{ 1088, 1920, ASPECT_RATIO_9X16 }, /* Portrait FHD */
{ 2560, 1920, ASPECT_RATIO_4X3 }, /* QSXGA */
{ 2592, 1944, ASPECT_RATIO_4X3 }, /* 5MP */
};

camera_sensor_info_t *esp_camera_sensor_get_info(sensor_id_t *id)
Expand Down
2 changes: 1 addition & 1 deletion examples/camera_example/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
idf_component_register(SRCS take_picture.c
PRIV_INCLUDE_DIRS .
PRIV_REQUIRES nvs_flash)
PRIV_REQUIRES nvs_flash esp_psram)
26 changes: 23 additions & 3 deletions examples/camera_example/main/take_picture.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// 1. Board setup (Uncomment):
// #define BOARD_WROVER_KIT
// #define BOARD_ESP32CAM_AITHINKER
// #define BOARD_WROVER_KIT 1
#define BOARD_ESP32S3CAM

/**
* 2. Kconfig setup
Expand Down Expand Up @@ -45,7 +47,7 @@

#include "esp_camera.h"

#define BOARD_WROVER_KIT 1


// WROVER-KIT PIN Map
#ifdef BOARD_WROVER_KIT
Expand Down Expand Up @@ -93,6 +95,24 @@

#endif

#ifdef BOARD_ESP32S3CAM
#define CAM_PIN_PWDN 38
#define CAM_PIN_RESET -1
#define CAM_PIN_VSYNC 6
#define CAM_PIN_HREF 7
#define CAM_PIN_PCLK 13
#define CAM_PIN_XCLK 15
#define CAM_PIN_SIOD 4
#define CAM_PIN_SIOC 5
#define CAM_PIN_D0 11
#define CAM_PIN_D1 9
#define CAM_PIN_D2 8
#define CAM_PIN_D3 10
#define CAM_PIN_D4 12
#define CAM_PIN_D5 18
#define CAM_PIN_D6 17
#define CAM_PIN_D7 16
#endif
static const char *TAG = "example:take_picture";

#if ESP_CAMERA_SUPPORTED
Expand Down Expand Up @@ -120,8 +140,8 @@ static camera_config_t camera_config = {
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,

.pixel_format = PIXFORMAT_RGB565, //YUV422,GRAYSCALE,RGB565,JPEG
.frame_size = FRAMESIZE_QVGA, //QQVGA-UXGA, For ESP32, do not use sizes above QVGA when not JPEG. The performance of the ESP32-S series has improved a lot, but JPEG mode always gives better frame rates.
.pixel_format = PIXFORMAT_JPEG, //YUV422,GRAYSCALE,RGB565,JPEG
.frame_size = FRAMESIZE_HD, //QQVGA-UXGA, For ESP32, do not use sizes above QVGA when not JPEG. The performance of the ESP32-S series has improved a lot, but JPEG mode always gives better frame rates.

.jpeg_quality = 12, //0-63, for OV series camera sensors, lower number means higher quality
.fb_count = 1, //When jpeg mode is used, if fb_count more than one, the driver will work in continuous mode.
Expand Down
Loading

0 comments on commit 05e3050

Please sign in to comment.