m5x camera working

This commit is contained in:
Bill Sideris 2023-05-18 21:39:59 +03:00
parent ed0cc9295f
commit 302cdad4ca
No known key found for this signature in database
GPG Key ID: 1BEF1BCEBA58EA33
4 changed files with 71 additions and 34 deletions

View File

@ -33,12 +33,16 @@
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
if (pin_number == 33) {
// Turn on BAT_HOLD by default, so that the board does not power off.
/*
* Turn on BAT_HOLD by default,
* so that the board does not power off
* when usb is disconnected or
* the power button is released.
*/
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
return true;
}
return false;
}

View File

@ -29,9 +29,14 @@
#define MICROPY_HW_LED_STATUS (&pin_GPIO2)
#define CIRCUITPY_BOARD_I2C (2)
#define CIRCUITPY_BOARD_I2C (3)
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO13, .sda = &pin_GPIO4}, \
{.scl = &pin_GPIO14, .sda = &pin_GPIO12}}
{.scl = &pin_GPIO14, .sda = &pin_GPIO12}, \
{.scl = &pin_GPIO23, .sda = &pin_GPIO25}}
// Ext. Port
// BM8563
// Camera sensor
// UART pins attached to the USB-serial converter chip
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
@ -39,4 +44,5 @@
#define CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP (1)
#define DEFAULT_RESERVED_PSRAM (1048576)
// espcamera.FrameSize.QXGA, half a megabyte result image.jpeg
#define DEFAULT_RESERVED_PSRAM (1572864)

View File

@ -2,20 +2,25 @@
#include "shared-bindings/board/__init__.h"
#include "shared-module/displayio/__init__.h"
CIRCUITPY_BOARD_BUS_SINGLETON(bm8563_i2c, i2c, 1)
CIRCUITPY_BOARD_BUS_SINGLETON(bm8563_i2c, i2c, 1) // RTC
CIRCUITPY_BOARD_BUS_SINGLETON(sscb_i2c, i2c, 2) // Camera sensor
STATIC const mp_rom_obj_tuple_t camera_data_tuple = {
// The order matters.
// They must be ordered from low to high (Y2, Y3 .. Y9).
// Do not include any of the control pins in here.
{&mp_type_tuple},
8,
{
MP_ROM_PTR(&pin_GPIO19),
MP_ROM_PTR(&pin_GPIO36),
MP_ROM_PTR(&pin_GPIO18),
MP_ROM_PTR(&pin_GPIO39),
MP_ROM_PTR(&pin_GPIO5),
MP_ROM_PTR(&pin_GPIO34),
MP_ROM_PTR(&pin_GPIO35),
MP_ROM_PTR(&pin_GPIO32)
MP_ROM_PTR(&pin_GPIO32), // Y2
MP_ROM_PTR(&pin_GPIO35), // Y3
MP_ROM_PTR(&pin_GPIO34), // Y4
MP_ROM_PTR(&pin_GPIO5), // Y5
MP_ROM_PTR(&pin_GPIO39), // Y6
MP_ROM_PTR(&pin_GPIO18), // Y7
MP_ROM_PTR(&pin_GPIO36), // Y8
MP_ROM_PTR(&pin_GPIO19) // Y9
}
};
@ -24,41 +29,59 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO2) },
// Connector, the label says G V SDA/G4 SCL/G13
// "Ext. Port", the label says [G, V, SDA/G4, SCL/G13]
{ MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_G13), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
// Battery pins, no alternative names as they cannot be used for anything else.
/* Battery
*
* No alternative names as they are not broken out
* and cannot be used for anything else.
*/
{ MP_ROM_QSTR(MP_QSTR_BAT_HOLD), MP_ROM_PTR(&pin_GPIO33) },
{ MP_ROM_QSTR(MP_QSTR_BAT_ADC), MP_ROM_PTR(&pin_GPIO38) },
// BM8563 I2C bus, no alternative names as they cannot be used for anything else.
/* BM8563 I2C bus
*
* No alternative names as they are not broken out
* and cannot be used for anything else.
*/
{ MP_ROM_QSTR(MP_QSTR_BM8563_SCL), MP_ROM_PTR(&pin_GPIO14) },
{ MP_ROM_QSTR(MP_QSTR_BM8563_SDA), MP_ROM_PTR(&pin_GPIO12) },
{ MP_ROM_QSTR(MP_QSTR_BM8563_I2C), MP_ROM_PTR(&board_bm8563_i2c_obj) },
// Camera pins
{ MP_ROM_QSTR(MP_QSTR_CAMERA_VSYNC), MP_ROM_PTR(&pin_GPIO22) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_HREF), MP_ROM_PTR(&pin_GPIO26) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_PCLK), MP_ROM_PTR(&pin_GPIO21) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_XCLK), MP_ROM_PTR(&pin_GPIO27) }, // xclk_freq_hz = 20000000
{ MP_ROM_QSTR(MP_QSTR_CAMERA_RESET), MP_ROM_PTR(&pin_GPIO15) },
// Camera control
{ MP_ROM_QSTR(MP_QSTR_VSYNC), MP_ROM_PTR(&pin_GPIO22) },
{ MP_ROM_QSTR(MP_QSTR_HREF), MP_ROM_PTR(&pin_GPIO26) },
{ MP_ROM_QSTR(MP_QSTR_PCLK), MP_ROM_PTR(&pin_GPIO21) },
{ MP_ROM_QSTR(MP_QSTR_XCLK), MP_ROM_PTR(&pin_GPIO27) }, // xclk_freq_hz = 20000000
{ MP_ROM_QSTR(MP_QSTR_RESET), MP_ROM_PTR(&pin_GPIO15) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_SSCB_SDA), MP_ROM_PTR(&pin_GPIO25) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_SSCB_SCL), MP_ROM_PTR(&pin_GPIO23) },
// Camera sensor I2C bus
{ MP_ROM_QSTR(MP_QSTR_SSCB_SDA), MP_ROM_PTR(&pin_GPIO25) },
{ MP_ROM_QSTR(MP_QSTR_SSCB_SCL), MP_ROM_PTR(&pin_GPIO23) },
{ MP_ROM_QSTR(MP_QSTR_SSCB_I2C), MP_ROM_PTR(&board_sscb_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA), MP_ROM_PTR(&camera_data_tuple) },
/*
* Camera data
*
* We don't really need to individually name each one,
* but they look cool in the tuple listing if we do.
*
* These are also not broken out.
*/
{ MP_ROM_QSTR(MP_QSTR_D), MP_ROM_PTR(&camera_data_tuple) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA7), MP_ROM_PTR(&pin_GPIO19) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA6), MP_ROM_PTR(&pin_GPIO36) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA5), MP_ROM_PTR(&pin_GPIO18) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA4), MP_ROM_PTR(&pin_GPIO39) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA3), MP_ROM_PTR(&pin_GPIO5) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA2), MP_ROM_PTR(&pin_GPIO34) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA1), MP_ROM_PTR(&pin_GPIO35) },
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA0), MP_ROM_PTR(&pin_GPIO32) }
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO19) },
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO36) },
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO18) },
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO39) },
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) },
{ MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO34) },
{ MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO35) },
{ MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO32) }
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

View File

@ -1,7 +1,9 @@
# ESP32-D0WDQ6-V3 (revision 3)
CONFIG_ESP32_SPIRAM_SUPPORT=y
CONFIG_ESP32_ECO3_CACHE_LOCK_FIX=y
CONFIG_ESP32_REV_MIN_3=y
# PSRAM
CONFIG_D0WD_PSRAM_CLK_IO=17
CONFIG_D0WD_PSRAM_CS_IO=16
@ -15,8 +17,10 @@ CONFIG_SPIRAM_BOOT_INIT=y
CONFIG_SPIRAM_USE_MEMMAP=y
CONFIG_SPIRAM_MEMTEST=y
# Hostname
CONFIG_LWIP_LOCAL_HOSTNAME="M5StackTimerX"
# Camera
CONFIG_OV3660_SUPPORT=y
CONFIG_GC_SENSOR_SUBSAMPLE_MODE=y
CONFIG_CAMERA_CORE0=y