Skip to content

Commit 302cdad

Browse files
committed
m5x camera working
1 parent ed0cc92 commit 302cdad

File tree

4 files changed

+71
-34
lines changed

4 files changed

+71
-34
lines changed

ports/espressif/boards/m5stack_timer_camera_x/board.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@
3333

3434
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
3535
if (pin_number == 33) {
36-
// Turn on BAT_HOLD by default, so that the board does not power off.
36+
/*
37+
* Turn on BAT_HOLD by default,
38+
* so that the board does not power off
39+
* when usb is disconnected or
40+
* the power button is released.
41+
*/
3742
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
3843
gpio_set_level(pin_number, true);
3944
return true;
4045
}
41-
4246
return false;
4347
}
4448

ports/espressif/boards/m5stack_timer_camera_x/mpconfigboard.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,20 @@
2929

3030
#define MICROPY_HW_LED_STATUS (&pin_GPIO2)
3131

32-
#define CIRCUITPY_BOARD_I2C (2)
32+
#define CIRCUITPY_BOARD_I2C (3)
3333
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO13, .sda = &pin_GPIO4}, \
34-
{.scl = &pin_GPIO14, .sda = &pin_GPIO12}}
34+
{.scl = &pin_GPIO14, .sda = &pin_GPIO12}, \
35+
{.scl = &pin_GPIO23, .sda = &pin_GPIO25}}
36+
37+
// Ext. Port
38+
// BM8563
39+
// Camera sensor
3540

3641
// UART pins attached to the USB-serial converter chip
3742
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
3843
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3)
3944

4045
#define CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP (1)
4146

42-
#define DEFAULT_RESERVED_PSRAM (1048576)
47+
// espcamera.FrameSize.QXGA, half a megabyte result image.jpeg
48+
#define DEFAULT_RESERVED_PSRAM (1572864)

ports/espressif/boards/m5stack_timer_camera_x/pins.c

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22
#include "shared-bindings/board/__init__.h"
33
#include "shared-module/displayio/__init__.h"
44

5-
CIRCUITPY_BOARD_BUS_SINGLETON(bm8563_i2c, i2c, 1)
5+
CIRCUITPY_BOARD_BUS_SINGLETON(bm8563_i2c, i2c, 1) // RTC
6+
CIRCUITPY_BOARD_BUS_SINGLETON(sscb_i2c, i2c, 2) // Camera sensor
67

78
STATIC const mp_rom_obj_tuple_t camera_data_tuple = {
9+
// The order matters.
10+
// They must be ordered from low to high (Y2, Y3 .. Y9).
11+
12+
// Do not include any of the control pins in here.
813
{&mp_type_tuple},
914
8,
1015
{
11-
MP_ROM_PTR(&pin_GPIO19),
12-
MP_ROM_PTR(&pin_GPIO36),
13-
MP_ROM_PTR(&pin_GPIO18),
14-
MP_ROM_PTR(&pin_GPIO39),
15-
MP_ROM_PTR(&pin_GPIO5),
16-
MP_ROM_PTR(&pin_GPIO34),
17-
MP_ROM_PTR(&pin_GPIO35),
18-
MP_ROM_PTR(&pin_GPIO32)
16+
MP_ROM_PTR(&pin_GPIO32), // Y2
17+
MP_ROM_PTR(&pin_GPIO35), // Y3
18+
MP_ROM_PTR(&pin_GPIO34), // Y4
19+
MP_ROM_PTR(&pin_GPIO5), // Y5
20+
MP_ROM_PTR(&pin_GPIO39), // Y6
21+
MP_ROM_PTR(&pin_GPIO18), // Y7
22+
MP_ROM_PTR(&pin_GPIO36), // Y8
23+
MP_ROM_PTR(&pin_GPIO19) // Y9
1924
}
2025
};
2126

@@ -24,41 +29,59 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
2429

2530
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO2) },
2631

27-
// Connector, the label says G V SDA/G4 SCL/G13
32+
// "Ext. Port", the label says [G, V, SDA/G4, SCL/G13]
2833
{ MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_GPIO4) },
2934
{ MP_ROM_QSTR(MP_QSTR_G13), MP_ROM_PTR(&pin_GPIO13) },
3035
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) },
3136
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO13) },
3237
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
3338

34-
// Battery pins, no alternative names as they cannot be used for anything else.
39+
/* Battery
40+
*
41+
* No alternative names as they are not broken out
42+
* and cannot be used for anything else.
43+
*/
3544
{ MP_ROM_QSTR(MP_QSTR_BAT_HOLD), MP_ROM_PTR(&pin_GPIO33) },
3645
{ MP_ROM_QSTR(MP_QSTR_BAT_ADC), MP_ROM_PTR(&pin_GPIO38) },
3746

38-
// BM8563 I2C bus, no alternative names as they cannot be used for anything else.
47+
/* BM8563 I2C bus
48+
*
49+
* No alternative names as they are not broken out
50+
* and cannot be used for anything else.
51+
*/
3952
{ MP_ROM_QSTR(MP_QSTR_BM8563_SCL), MP_ROM_PTR(&pin_GPIO14) },
4053
{ MP_ROM_QSTR(MP_QSTR_BM8563_SDA), MP_ROM_PTR(&pin_GPIO12) },
4154
{ MP_ROM_QSTR(MP_QSTR_BM8563_I2C), MP_ROM_PTR(&board_bm8563_i2c_obj) },
4255

43-
// Camera pins
44-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_VSYNC), MP_ROM_PTR(&pin_GPIO22) },
45-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_HREF), MP_ROM_PTR(&pin_GPIO26) },
46-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_PCLK), MP_ROM_PTR(&pin_GPIO21) },
47-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_XCLK), MP_ROM_PTR(&pin_GPIO27) }, // xclk_freq_hz = 20000000
48-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_RESET), MP_ROM_PTR(&pin_GPIO15) },
56+
// Camera control
57+
{ MP_ROM_QSTR(MP_QSTR_VSYNC), MP_ROM_PTR(&pin_GPIO22) },
58+
{ MP_ROM_QSTR(MP_QSTR_HREF), MP_ROM_PTR(&pin_GPIO26) },
59+
{ MP_ROM_QSTR(MP_QSTR_PCLK), MP_ROM_PTR(&pin_GPIO21) },
60+
{ MP_ROM_QSTR(MP_QSTR_XCLK), MP_ROM_PTR(&pin_GPIO27) }, // xclk_freq_hz = 20000000
61+
{ MP_ROM_QSTR(MP_QSTR_RESET), MP_ROM_PTR(&pin_GPIO15) },
4962

50-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_SSCB_SDA), MP_ROM_PTR(&pin_GPIO25) },
51-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_SSCB_SCL), MP_ROM_PTR(&pin_GPIO23) },
63+
// Camera sensor I2C bus
64+
{ MP_ROM_QSTR(MP_QSTR_SSCB_SDA), MP_ROM_PTR(&pin_GPIO25) },
65+
{ MP_ROM_QSTR(MP_QSTR_SSCB_SCL), MP_ROM_PTR(&pin_GPIO23) },
66+
{ MP_ROM_QSTR(MP_QSTR_SSCB_I2C), MP_ROM_PTR(&board_sscb_i2c_obj) },
5267

53-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA), MP_ROM_PTR(&camera_data_tuple) },
68+
/*
69+
* Camera data
70+
*
71+
* We don't really need to individually name each one,
72+
* but they look cool in the tuple listing if we do.
73+
*
74+
* These are also not broken out.
75+
*/
76+
{ MP_ROM_QSTR(MP_QSTR_D), MP_ROM_PTR(&camera_data_tuple) },
5477

55-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA7), MP_ROM_PTR(&pin_GPIO19) },
56-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA6), MP_ROM_PTR(&pin_GPIO36) },
57-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA5), MP_ROM_PTR(&pin_GPIO18) },
58-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA4), MP_ROM_PTR(&pin_GPIO39) },
59-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA3), MP_ROM_PTR(&pin_GPIO5) },
60-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA2), MP_ROM_PTR(&pin_GPIO34) },
61-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA1), MP_ROM_PTR(&pin_GPIO35) },
62-
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA0), MP_ROM_PTR(&pin_GPIO32) }
78+
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO19) },
79+
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO36) },
80+
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO18) },
81+
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO39) },
82+
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) },
83+
{ MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO34) },
84+
{ MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO35) },
85+
{ MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO32) }
6386
};
6487
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

ports/espressif/boards/m5stack_timer_camera_x/sdkconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
# ESP32-D0WDQ6-V3 (revision 3)
12
CONFIG_ESP32_SPIRAM_SUPPORT=y
23
CONFIG_ESP32_ECO3_CACHE_LOCK_FIX=y
34
CONFIG_ESP32_REV_MIN_3=y
45

6+
# PSRAM
57
CONFIG_D0WD_PSRAM_CLK_IO=17
68
CONFIG_D0WD_PSRAM_CS_IO=16
79

@@ -15,8 +17,10 @@ CONFIG_SPIRAM_BOOT_INIT=y
1517
CONFIG_SPIRAM_USE_MEMMAP=y
1618
CONFIG_SPIRAM_MEMTEST=y
1719

20+
# Hostname
1821
CONFIG_LWIP_LOCAL_HOSTNAME="M5StackTimerX"
1922

23+
# Camera
2024
CONFIG_OV3660_SUPPORT=y
2125
CONFIG_GC_SENSOR_SUBSAMPLE_MODE=y
2226
CONFIG_CAMERA_CORE0=y

0 commit comments

Comments
 (0)