Skip to content

Commit 941c4b5

Browse files
authored
Merge branch 'adafruit:main' into main
2 parents bf751be + ed5591c commit 941c4b5

48 files changed

Lines changed: 757 additions & 99 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
[submodule "ports/espressif/esp-idf"]
144144
path = ports/espressif/esp-idf
145145
url = https://github.com/adafruit/esp-idf.git
146-
branch = circuitpython-v5.1.3
146+
branch = circuitpython-v5.2.2
147147
[submodule "ports/espressif/esp-protocols"]
148148
path = ports/espressif/esp-protocols
149149
url = https://github.com/espressif/esp-protocols.git

devices/ble_hci/common-hal/_bleio/__init__.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ bool vm_used_ble;
3737
// }
3838
// }
3939

40+
void common_hal_bleio_init(void) {
41+
}
42+
4043
void bleio_user_reset() {
4144
// HCI doesn't support the BLE workflow so just do a full reset.
4245
bleio_reset();

locale/circuitpython.pot

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ msgstr ""
113113
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
114114
#: ports/raspberrypi/common-hal/usb_host/Port.c
115115
#: shared-bindings/digitalio/DigitalInOut.c
116-
#: shared-bindings/microcontroller/Pin.c
116+
#: shared-bindings/microcontroller/Pin.c shared-module/max3421e/Max3421E.c
117117
msgid "%q in use"
118118
msgstr ""
119119

@@ -1114,10 +1114,12 @@ msgstr ""
11141114
msgid "Input/output error"
11151115
msgstr ""
11161116

1117+
#: ports/espressif/common-hal/_bleio/__init__.c
11171118
#: ports/nordic/common-hal/_bleio/__init__.c
11181119
msgid "Insufficient authentication"
11191120
msgstr ""
11201121

1122+
#: ports/espressif/common-hal/_bleio/__init__.c
11211123
#: ports/nordic/common-hal/_bleio/__init__.c
11221124
msgid "Insufficient encryption"
11231125
msgstr ""
@@ -1154,6 +1156,7 @@ msgstr ""
11541156
#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c
11551157
#: ports/atmel-samd/common-hal/countio/Counter.c
11561158
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
1159+
#: ports/atmel-samd/common-hal/max3421e/Max3421E.c
11571160
#: ports/atmel-samd/common-hal/ps2io/Ps2.c
11581161
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
11591162
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
@@ -1285,6 +1288,10 @@ msgstr ""
12851288
msgid "MAC address was invalid"
12861289
msgstr ""
12871290

1291+
#: ports/espressif/common-hal/_bleio/Characteristic.c
1292+
msgid "MITM security not supported"
1293+
msgstr ""
1294+
12881295
#: shared-bindings/is31fl3741/IS31FL3741.c
12891296
msgid "Mapping must be a tuple"
12901297
msgstr ""
@@ -2139,6 +2146,7 @@ msgstr ""
21392146
msgid "Unknown BLE error: %d"
21402147
msgstr ""
21412148

2149+
#: ports/espressif/common-hal/max3421e/Max3421E.c
21422150
#: ports/raspberrypi/common-hal/wifi/__init__.c
21432151
#, c-format
21442152
msgid "Unknown error code %d"
@@ -3810,7 +3818,7 @@ msgstr ""
38103818
msgid "pop from empty %q"
38113819
msgstr ""
38123820

3813-
#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c
3821+
#: shared-bindings/socketpool/Socket.c
38143822
msgid "port must be >= 0"
38153823
msgstr ""
38163824

main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,10 +1006,6 @@ int __attribute__((used)) main(void) {
10061006
supervisor_status_bar_init();
10071007
#endif
10081008

1009-
#if CIRCUITPY_BLEIO
1010-
// Early init so that a reset press can cause BLE public advertising.
1011-
supervisor_bluetooth_init();
1012-
#endif
10131009

10141010
#if !INTERNAL_FLASH_FILESYSTEM
10151011
// Set up anything that might need to get done before we try to use SPI flash
@@ -1027,6 +1023,12 @@ int __attribute__((used)) main(void) {
10271023
set_safe_mode(SAFE_MODE_NO_CIRCUITPY);
10281024
}
10291025

1026+
#if CIRCUITPY_BLEIO
1027+
// Early init so that a reset press can cause BLE public advertising. Need the filesystem to
1028+
// read settings.toml.
1029+
supervisor_bluetooth_init();
1030+
#endif
1031+
10301032
#if CIRCUITPY_ALARM
10311033
// Record which alarm woke us up, if any.
10321034
// common_hal_alarm_record_wake_alarm() should return a static, non-heap object

ports/espressif/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,13 @@ LDFLAGS += \
229229
-Tesp32c6.rom.newlib.ld \
230230
-Tesp32c6.rom.coexist.ld \
231231
-Tesp32c6.rom.heap.ld \
232+
-Tesp32c6.rom.systimer.ld \
232233
-Tesp32c6.rom.wdt.ld
233234
else ifeq ($(IDF_TARGET),esp32h2)
234235
LDFLAGS += \
235236
-Tesp32h2.rom.heap.ld \
236237
-Tesp32h2.rom.newlib.ld \
238+
-Tesp32h2.rom.systimer.ld \
237239
-Tesp32h2.rom.wdt.ld
238240
else ifeq ($(IDF_TARGET),esp32s2)
239241
LDFLAGS += \

ports/espressif/boards/adafruit_feather_esp32c6_4mbflash_nopsram/mpconfigboard.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#define MICROPY_HW_BOARD_NAME "Adafruit Feather ESP32-C6 4MB Flash No PSRAM"
1212
#define MICROPY_HW_MCU_NAME "ESP32C6"
1313

14-
#define MICROPY_HW_NEOPIXEL (&pin_GPIO9)
14+
// Don't use the neopixel for status because we can't use it at the same time as
15+
// the boot button.
16+
// #define MICROPY_HW_NEOPIXEL (&pin_GPIO9)
1517

1618
#define MICROPY_HW_LED_STATUS (&pin_GPIO15)
1719

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "supervisor/board.h"
8+
#include "mpconfigboard.h"
9+
#include "shared-bindings/busio/SPI.h"
10+
#include "shared-bindings/fourwire/FourWire.h"
11+
#include "shared-bindings/microcontroller/Pin.h"
12+
#include "shared-module/displayio/__init__.h"
13+
#include "shared-bindings/board/__init__.h"
14+
#include "supervisor/shared/board.h"
15+
16+
#include "shared-module/displayio/mipi_constants.h"
17+
#include "components/driver/gpio/include/driver/gpio.h"
18+
#include "components/hal/include/hal/gpio_hal.h"
19+
#include "common-hal/microcontroller/Pin.h"
20+
21+
#define DELAY 0x80
22+
23+
// ST7789
24+
uint8_t display_init_sequence[] = {
25+
0x01, 0 | DELAY, 0x96, // _SWRESET and Delay 150ms
26+
0x11, 0 | DELAY, 0xFF, // _SLPOUT and Delay 500ms
27+
0x3A, 0x81, 0x55, 0x0A, // _COLMOD and Delay 10ms
28+
0x36, 0x01, 0x08, // _MADCTL (BGR)
29+
0x21, 0 | DELAY, 0x0A, // _INVON Hack and Delay 10ms
30+
0x13, 0 | DELAY, 0x0A, // _NORON and Delay 10ms
31+
0x36, 0x01, 0xA0, // _MADCTL (Landscape)
32+
0xE0, 0x0E, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x32, 0x44,
33+
0x42, 0x06, 0x0E, 0x12, 0x14, 0x17, // gamma-curve positive
34+
0xE1, 0x0E, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x31, 0x54,
35+
0x47, 0x0E, 0x1C, 0x17, 0x1B, 0x1E, // gamma-curve negative
36+
0x29, 0 | DELAY, 0xFF, // _DISPON and Delay 500ms
37+
};
38+
39+
static void display_init(void) {
40+
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
41+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
42+
bus->base.type = &fourwire_fourwire_type;
43+
44+
common_hal_fourwire_fourwire_construct(
45+
bus,
46+
spi,
47+
&pin_GPIO2, // TFT_DC
48+
&pin_GPIO15, // TFT_CS
49+
NULL, // TFT_RST
50+
26600000, // Baudrate
51+
0, // Polarity
52+
0 // Phase
53+
);
54+
55+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
56+
display->base.type = &busdisplay_busdisplay_type;
57+
58+
common_hal_busdisplay_busdisplay_construct(display,
59+
bus,
60+
320, // Width
61+
240, // Height
62+
0, // column start
63+
0, // row start
64+
0, // rotation
65+
16, // Color depth
66+
false, // Grayscale
67+
false, // pixels in a byte share a row. Only valid for depths < 8
68+
1, // bytes per cell. Only valid for depths < 8
69+
false, // reverse_pixels_in_byte. Only valid for depths < 8
70+
true, // reverse_pixels_in_word
71+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
72+
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
73+
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
74+
display_init_sequence,
75+
sizeof(display_init_sequence),
76+
&pin_GPIO27, // backlight pin
77+
NO_BRIGHTNESS_COMMAND,
78+
1.0f, // brightness
79+
false, // single_byte_bounds
80+
false, // data_as_commands
81+
true, // auto_refresh
82+
60, // native_frames_per_second
83+
true, // backlight_on_high
84+
false, // SH1107_addressing
85+
50000); // backlight pwm frequency
86+
}
87+
88+
void board_init(void) {
89+
display_init();
90+
}
91+
92+
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
93+
// Pull the speaker pin low to reduce noise on reset
94+
if (pin_number == 26) {
95+
// Turn on audio
96+
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
97+
gpio_set_level(pin_number, false);
98+
return true;
99+
}
100+
return false;
101+
}
102+
103+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2022 Dan Halbert for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
// Micropython setup
10+
11+
#define MICROPY_HW_BOARD_NAME "sunton_esp32_2432S032C"
12+
#define MICROPY_HW_MCU_NAME "ESP32"
13+
#define MICROPY_HW_LED_STATUS (&pin_GPIO16)
14+
#define MICROPY_HW_LED_STATUS_INVERTED (1)
15+
16+
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
17+
18+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO21)
19+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO22)
20+
21+
#define CIRCUITPY_BOARD_SPI (2)
22+
#define CIRCUITPY_BOARD_SPI_PIN { \
23+
{.clock = &pin_GPIO14, .mosi = &pin_GPIO13, .miso = &pin_GPIO12}, /*LCD*/ \
24+
{.clock = &pin_GPIO18, .mosi = &pin_GPIO23, .miso = &pin_GPIO19}, /*SD*/ \
25+
}
26+
27+
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
28+
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CIRCUITPY_CREATOR_ID = 0x19991000
2+
CIRCUITPY_CREATION_ID = 0x00AA032C
3+
4+
IDF_TARGET = esp32
5+
6+
CIRCUITPY_ESP_FLASH_MODE = qio
7+
CIRCUITPY_ESP_FLASH_FREQ = 40m
8+
CIRCUITPY_ESP_FLASH_SIZE = 4MB
9+
10+
CIRCUITPY_ESPCAMERA = 0
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "shared-bindings/board/__init__.h"
8+
#include "shared-module/displayio/__init__.h"
9+
10+
CIRCUITPY_BOARD_BUS_SINGLETON(lcd_spi, spi, 0)
11+
CIRCUITPY_BOARD_BUS_SINGLETON(sd_spi, spi, 1)
12+
13+
static const mp_rom_map_elem_t board_module_globals_table[] = {
14+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
15+
16+
// Boot button
17+
{ MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) },
18+
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) },
19+
20+
// RGB LED
21+
{ MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_GPIO16) },
22+
{ MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_GPIO4) },
23+
{ MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_GPIO17) },
24+
25+
// CDS Light sensor (Not present on all boards)
26+
{ MP_ROM_QSTR(MP_QSTR_LDR), MP_ROM_PTR(&pin_GPIO34) },
27+
28+
// Speaker pin
29+
{ MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO26) },
30+
31+
// User available GPIOs:
32+
// P3 pin 1 and CN1 pin 2, shared with touch-interrupt and SDA
33+
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },
34+
// P3 pin 2 and CN1 pin 3, shared with SCL
35+
{ MP_ROM_QSTR(MP_QSTR_IO22), MP_ROM_PTR(&pin_GPIO22) },
36+
// P3 pin 3, input only
37+
{ MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) },
38+
39+
// I2C
40+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO21) },
41+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO22) },
42+
43+
// TF card slot (SPI)
44+
{ MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO23) },
45+
{ MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO19) },
46+
{ MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO18) },
47+
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO5) },
48+
49+
// ST7789 (SPI)
50+
{ MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO13) },
51+
{ MP_ROM_QSTR(MP_QSTR_LCD_MISO), MP_ROM_PTR(&pin_GPIO12) },
52+
{ MP_ROM_QSTR(MP_QSTR_LCD_SCK), MP_ROM_PTR(&pin_GPIO14) },
53+
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO15) },
54+
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO2) },
55+
{ MP_ROM_QSTR(MP_QSTR_LCD_BCKL), MP_ROM_PTR(&pin_GPIO27) },
56+
57+
// GT911 (I2C)
58+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_SDA), MP_ROM_PTR(&pin_GPIO33) },
59+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_SCL), MP_ROM_PTR(&pin_GPIO32) },
60+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_RST), MP_ROM_PTR(&pin_GPIO25) },
61+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_INT), MP_ROM_PTR(&pin_GPIO21) },
62+
63+
// objects
64+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
65+
{ MP_ROM_QSTR(MP_QSTR_LCD_SPI), MP_ROM_PTR(&board_lcd_spi_obj) },
66+
{ MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_sd_spi_obj) },
67+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
68+
69+
};
70+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

0 commit comments

Comments
 (0)