forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add support for Ai Thinker ESP32-CAM boards #9231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
862fff3
Add support for Ai Thinker ESP32-CAM boards
gitcnd 9f5bce0
Add support for Ai Thinker ESP32-CAM boards
gitcnd 3b35469
Add support for Ai Thinker ESP32-CAM boards
gitcnd 64f4928
Add support for Ai Thinker ESP32-CAM boards
gitcnd 2396f8b
Add support for Ai Thinker ESP32-CAM boards (add IOnn aliases)
gitcnd 24f2e4f
Add support for Ai Thinker ESP32-CAM boards (default flashlight to off)
gitcnd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* This file is part of the MicroPython project, http://micropython.org/ | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2024 Chris Drake, independently providing these changes. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
#include "supervisor/board.h" | ||
|
||
#include "mpconfigboard.h" | ||
#include "shared-bindings/microcontroller/Pin.h" | ||
#include "components/driver/gpio/include/driver/gpio.h" | ||
#include "components/hal/include/hal/gpio_hal.h" | ||
#include "common-hal/microcontroller/Pin.h" | ||
|
||
void board_init(void) { | ||
reset_board(); | ||
} | ||
|
||
bool espressif_board_reset_pin_number(gpio_num_t pin_number) { | ||
// Pull one LED down on reset rather than the default up | ||
if (pin_number == 4) { // This is the flashlight LED - very bright | ||
gpio_config_t cfg = { | ||
.pin_bit_mask = BIT64(pin_number), | ||
.mode = GPIO_MODE_DISABLE, | ||
.pull_up_en = false, | ||
.pull_down_en = true, | ||
.intr_type = GPIO_INTR_DISABLE, | ||
}; | ||
gpio_config(&cfg); | ||
return true; | ||
} | ||
return false; | ||
} |
48 changes: 48 additions & 0 deletions
48
ports/espressif/boards/ai-thinker-esp32-cam/mpconfigboard.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* This file is part of the MicroPython project, http://micropython.org/ | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2024 Chris Drake, independently providing these changes. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
#define MICROPY_HW_BOARD_NAME "Ai Thinker ESP32-CAM" | ||
#define MICROPY_HW_MCU_NAME "ESP32" | ||
|
||
#define MICROPY_HW_LED_STATUS (&pin_GPIO33) | ||
#define MICROPY_HW_LED_STATUS_INVERTED (1) | ||
|
||
|
||
#define CIRCUITPY_BOARD_I2C (2) | ||
/* OV2640 camera I2C pins are GPIO27 and _GPIO26. GPIO12 and GPIO13 are unused unless SD card inserted:- */ | ||
#define CIRCUITPY_BOARD_I2C_PIN { {.scl = &pin_GPIO27, .sda = &pin_GPIO26}, \ | ||
{.scl = &pin_GPIO12, .sda = &pin_GPIO13} } | ||
|
||
// SD_CARD | ||
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO14) | ||
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO15) | ||
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO2) | ||
|
||
// UART pins attached to the USB-serial converter chip | ||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) | ||
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3) | ||
|
||
#define CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP (1) |
19 changes: 19 additions & 0 deletions
19
ports/espressif/boards/ai-thinker-esp32-cam/mpconfigboard.mk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CIRCUITPY_CREATOR_ID = 0x000C303B | ||
CIRCUITPY_CREATION_ID = 0x00320001 | ||
|
||
IDF_TARGET = esp32 | ||
|
||
# This board doesn't have USB by default, it | ||
# instead uses a CH340C USB-to-Serial chip | ||
CIRCUITPY_USB_DEVICE = 0 | ||
CIRCUITPY_ESP_USB_SERIAL_JTAG = 0 | ||
|
||
CIRCUITPY_ESP_FLASH_MODE = qio | ||
CIRCUITPY_ESP_FLASH_FREQ = 80m | ||
CIRCUITPY_ESP_FLASH_SIZE = 4MB | ||
|
||
CIRCUITPY_ESP_PSRAM_SIZE = 8MB | ||
CIRCUITPY_ESP_PSRAM_MODE = qio | ||
CIRCUITPY_ESP_PSRAM_FREQ = 80m | ||
|
||
CIRCUITPY_ESPCAMERA = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#include "py/objtuple.h" | ||
#include "shared-bindings/board/__init__.h" | ||
|
||
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_GPIO5), // Y2 | ||
MP_ROM_PTR(&pin_GPIO18), // Y3 | ||
MP_ROM_PTR(&pin_GPIO19), // Y4 | ||
MP_ROM_PTR(&pin_GPIO21), // Y5 | ||
MP_ROM_PTR(&pin_GPIO36), // Y6 | ||
MP_ROM_PTR(&pin_GPIO39), // Y7 | ||
MP_ROM_PTR(&pin_GPIO34), // Y8 | ||
MP_ROM_PTR(&pin_GPIO35) // Y9 | ||
} | ||
}; | ||
|
||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = { | ||
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS | ||
|
||
// Red LED on the back of the board | ||
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO33) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LED_INVERTED), MP_ROM_PTR(&pin_GPIO33) }, | ||
|
||
// Bright white LED flashlight on the front (be aware that the SD card uses this when in fast mode) | ||
{ MP_ROM_QSTR(MP_QSTR_FLASHLIGHT), MP_ROM_PTR(&pin_GPIO4) }, | ||
|
||
// The second ESP32-CAM-MB button (first is RST) | ||
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, | ||
|
||
// SD Card (fast mode aka SDMMC) | ||
{ MP_ROM_QSTR(MP_QSTR_SDIO_CLK), MP_ROM_PTR(&pin_GPIO14)}, | ||
{ MP_ROM_QSTR(MP_QSTR_SDIO_CMD), MP_ROM_PTR(&pin_GPIO15)}, | ||
{ MP_ROM_QSTR(MP_QSTR_SDIO_D0), MP_ROM_PTR(&pin_GPIO2)}, | ||
{ MP_ROM_QSTR(MP_QSTR_SDIO_D1), MP_ROM_PTR(&pin_GPIO4)}, | ||
{ MP_ROM_QSTR(MP_QSTR_SDIO_D2), MP_ROM_PTR(&pin_GPIO12)}, | ||
{ MP_ROM_QSTR(MP_QSTR_SDIO_D3), MP_ROM_PTR(&pin_GPIO13)}, | ||
|
||
// SD Card (slow mode) | ||
{ MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO14)}, | ||
{ MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO15)}, | ||
{ MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO2)}, | ||
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO13)}, | ||
{ MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_spi_obj) }, | ||
|
||
// Camera data | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA), MP_ROM_PTR(&camera_data_tuple) }, | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA2), MP_ROM_PTR(&pin_GPIO5) }, | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA3), MP_ROM_PTR(&pin_GPIO18) }, | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA4), MP_ROM_PTR(&pin_GPIO19) }, | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA5), MP_ROM_PTR(&pin_GPIO21) }, | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA6), MP_ROM_PTR(&pin_GPIO36) }, | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA7), MP_ROM_PTR(&pin_GPIO39) }, | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA8), MP_ROM_PTR(&pin_GPIO34) }, | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_DATA9), MP_ROM_PTR(&pin_GPIO35) }, | ||
|
||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_HREF), MP_ROM_PTR(&pin_GPIO23) }, | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_PCLK), MP_ROM_PTR(&pin_GPIO22) }, | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_PWDN), MP_ROM_PTR(&pin_GPIO32) }, | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_RESET), NULL }, | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_VSYNC), MP_ROM_PTR(&pin_GPIO25) }, | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_XCLK), MP_ROM_PTR(&pin_GPIO0) }, | ||
|
||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_SIOD), MP_ROM_PTR(&pin_GPIO26) }, // SDA | ||
{ MP_ROM_QSTR(MP_QSTR_CAMERA_SIOC), MP_ROM_PTR(&pin_GPIO27) }, // SCL | ||
|
||
{ MP_ROM_QSTR(MP_QSTR_U0R), MP_ROM_PTR(&pin_GPIO3) }, | ||
{ MP_ROM_QSTR(MP_QSTR_U0T), MP_ROM_PTR(&pin_GPIO1) }, | ||
|
||
{ MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, // the button | ||
{ MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, | ||
{ MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, | ||
{ MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, | ||
|
||
{ MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, | ||
{ MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, | ||
|
||
{ MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, | ||
{ MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, | ||
{ MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, | ||
{ MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, | ||
|
||
{ 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) } | ||
|
||
gitcnd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# Espressif IoT Development Framework Configuration | ||
# | ||
# | ||
# | ||
# Component config | ||
# | ||
# | ||
# Hardware Settings | ||
CONFIG_OV2640_SUPPORT=y |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.