Skip to content

Commit 4cd370e

Browse files
committed
Merge remote-tracking branch 'adafruit/main' into add-os-utime-function
2 parents 987030e + 14c9028 commit 4cd370e

File tree

23 files changed

+89
-50
lines changed

23 files changed

+89
-50
lines changed

locale/circuitpython.pot

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ msgstr ""
6060
msgid "%%c requires int or char"
6161
msgstr ""
6262

63+
#: main.c
64+
#, c-format
65+
msgid "%02X"
66+
msgstr ""
67+
6368
#: shared-bindings/rgbmatrix/RGBMatrix.c
6469
#, c-format
6570
msgid ""
@@ -2077,6 +2082,10 @@ msgstr ""
20772082
msgid "UART write"
20782083
msgstr ""
20792084

2085+
#: main.c
2086+
msgid "UID:"
2087+
msgstr ""
2088+
20802089
#: shared-module/usb_hid/Device.c
20812090
msgid "USB busy"
20822091
msgstr ""

main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,9 +779,9 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
779779
#if CIRCUITPY_MICROCONTROLLER && COMMON_HAL_MCU_PROCESSOR_UID_LENGTH > 0
780780
uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH];
781781
common_hal_mcu_processor_get_uid(raw_id);
782-
mp_printf(&mp_plat_print, "UID:");
783-
for (uint8_t i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) {
784-
mp_printf(&mp_plat_print, "%02X", raw_id[i]);
782+
mp_cprintf(&mp_plat_print, translate("UID:"));
783+
for (size_t i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) {
784+
mp_cprintf(&mp_plat_print, translate("%02X"), raw_id[i]);
785785
}
786786
mp_printf(&mp_plat_print, "\n");
787787
port_boot_info();

ports/atmel-samd/common-hal/busio/I2C.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
125125
// exact cutoff, but no frequency well under 100kHz is available)
126126
if ((frequency < 95000) ||
127127
(i2c_m_sync_set_baudrate(&self->i2c_desc, 0, frequency / 1000) != ERR_NONE)) {
128-
reset_pin_number(sda->number);
129-
reset_pin_number(scl->number);
130128
common_hal_busio_i2c_deinit(self);
131129
mp_arg_error_invalid(MP_QSTR_frequency);
132130
}

ports/espressif/common-hal/wifi/Radio.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void common_hal_wifi_radio_set_mac_address_ap(wifi_radio_obj_t *self, const uint
165165
esp_wifi_set_mac(ESP_IF_WIFI_AP, mac);
166166
}
167167

168-
mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self) {
168+
mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self, uint8_t start_channel, uint8_t stop_channel) {
169169
if (self->current_scan != NULL) {
170170
mp_raise_RuntimeError(translate("Already scanning for wifi networks"));
171171
}
@@ -177,9 +177,12 @@ mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self) {
177177
wifi_scannednetworks_obj_t *scan = m_new_obj(wifi_scannednetworks_obj_t);
178178
scan->base.type = &wifi_scannednetworks_type;
179179
self->current_scan = scan;
180-
scan->start_channel = 1;
181-
scan->end_channel = 11;
180+
scan->current_channel_index = 0;
181+
scan->start_channel = start_channel;
182+
scan->end_channel = stop_channel;
182183
scan->radio_event_group = self->event_group_handle;
184+
scan->done = false;
185+
scan->channel_scan_in_progress = false;
183186
wifi_scannednetworks_scan_next_channel(scan);
184187
return scan;
185188
}

ports/espressif/common-hal/wifi/ScannedNetworks.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self)
7272
return mp_const_none;
7373
}
7474
// If we are scanning, wait and then load them.
75-
if (self->scanning) {
75+
if (self->channel_scan_in_progress) {
7676
// We may have to scan more than one channel to get a result.
7777
while (!self->done) {
7878
if (!wifi_scannednetworks_wait_for_scan(self)) {
@@ -81,7 +81,7 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self)
8181
}
8282

8383
esp_wifi_scan_get_ap_num(&self->total_results);
84-
self->scanning = false;
84+
self->channel_scan_in_progress = false;
8585
if (self->total_results > 0) {
8686
break;
8787
}
@@ -112,7 +112,7 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self)
112112
}
113113
}
114114
esp_wifi_scan_get_ap_records(&self->total_results, self->results);
115-
self->scanning = false;
115+
self->channel_scan_in_progress = false;
116116
}
117117

118118
wifi_network_obj_t *entry = m_new_obj(wifi_network_obj_t);
@@ -132,40 +132,49 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self)
132132
}
133133

134134
// We don't do a linear scan so that we look at a variety of spectrum up front.
135-
static uint8_t scan_pattern[] = {6, 1, 11, 3, 9, 13, 2, 4, 8, 12, 5, 7, 10, 14};
135+
static uint8_t scan_pattern[] = {6, 1, 11, 3, 9, 13, 2, 4, 8, 12, 5, 7, 10, 14, 0};
136136

137137
void wifi_scannednetworks_scan_next_channel(wifi_scannednetworks_obj_t *self) {
138-
uint8_t next_channel = sizeof(scan_pattern);
138+
// There is no channel 0, so use that as a flag to indicate we've run out of channels to scan.
139+
uint8_t next_channel = 0;
139140
while (self->current_channel_index < sizeof(scan_pattern)) {
140141
next_channel = scan_pattern[self->current_channel_index];
141142
self->current_channel_index++;
143+
// Scan only channels that are in the specified range.
142144
if (self->start_channel <= next_channel && next_channel <= self->end_channel) {
143145
break;
144146
}
145147
}
146148
wifi_scan_config_t config = { 0 };
147149
config.channel = next_channel;
148-
if (next_channel == sizeof(scan_pattern)) {
150+
if (next_channel == 0) {
149151
wifi_scannednetworks_done(self);
150152
} else {
151153
esp_err_t result = esp_wifi_scan_start(&config, false);
152154
if (result != ESP_OK) {
153155
wifi_scannednetworks_done(self);
154156
} else {
155-
self->scanning = true;
157+
self->channel_scan_in_progress = true;
156158
}
157159
}
158160
}
159161

160162
void wifi_scannednetworks_deinit(wifi_scannednetworks_obj_t *self) {
161163
// if a scan is active, make sure and clean up the idf's buffer of results.
162-
if (self->scanning) {
164+
if (self->channel_scan_in_progress) {
163165
esp_wifi_scan_stop();
164166
if (wifi_scannednetworks_wait_for_scan(self)) {
165-
// Ignore the number of records since we're throwing them away.
166-
uint16_t number = 0;
167-
esp_wifi_scan_get_ap_records(&number, NULL);
168-
self->scanning = false;
167+
// Discard the scanned records, one at a time, to avoid memory leaks.
168+
uint16_t number;
169+
do {
170+
number = 1;
171+
wifi_ap_record_t record;
172+
esp_wifi_scan_get_ap_records(&number, &record);
173+
} while (number > 0);
174+
// TODO: available in ESP-IDF v5.0; do instead of the above.
175+
// Discard scan results.
176+
// esp_wifi_clear_ap_list();
177+
self->channel_scan_in_progress = false;
169178
}
170179
}
171180
wifi_scannednetworks_done(self);

ports/espressif/common-hal/wifi/ScannedNetworks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ typedef struct {
5353
uint8_t end_channel; // Inclusive
5454

5555
bool done;
56-
bool scanning;
56+
bool channel_scan_in_progress;
5757
} wifi_scannednetworks_obj_t;
5858

5959
void wifi_scannednetworks_scan_next_channel(wifi_scannednetworks_obj_t *self);

ports/espressif/common-hal/wifi/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void common_hal_wifi_init(bool user_initiated) {
172172
// Even though we just called esp_netif_create_default_wifi_sta,
173173
// station mode isn't actually ready for use until esp_wifi_set_mode()
174174
// is called and the configuration is loaded via esp_wifi_set_config().
175-
// Set both convienence flags to false so it's not forgotten.
175+
// Set both convenience flags to false so it's not forgotten.
176176
self->sta_mode = 0;
177177
self->ap_mode = 0;
178178

ports/espressif/esp-idf

Submodule esp-idf updated 724 files

ports/raspberrypi/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ INC_CYW43 := \
6565
-isystem sdk/src/rp2_common/pico_cyw43_arch/include/ \
6666
-isystem sdk/src/rp2_common/pico_lwip/include/ \
6767

68-
CFLAGS_CYW43 := -DCYW43_LWIP=1 -DPICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1 -DCYW43_USE_SPI -DIGNORE_GPIO25 -DIGNORE_GPIO23 -DCYW43_LOGIC_DEBUG=0
68+
CFLAGS_CYW43 := -DCYW43_LWIP=1 -DPICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1 -DCYW43_USE_SPI -DIGNORE_GPIO25 -DIGNORE_GPIO23 -DIGNORE_GPIO24 -DCYW43_LOGIC_DEBUG=0
6969
SRC_SDK_CYW43 := \
7070
src/common/pico_sync/sem.c \
7171
src/rp2_common/cyw43_driver/cyw43_bus_pio_spi.c \

ports/raspberrypi/boards/raspberry_pi_pico_w/pins.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,10 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
2828
{ MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) },
2929

3030
{ MP_ROM_QSTR(MP_QSTR_SMPS_MODE), MP_ROM_PTR(&pin_CYW1) },
31-
{ MP_ROM_QSTR(MP_QSTR_GP23), MP_ROM_PTR(&pin_CYW1) },
32-
33-
{ MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO24) },
34-
{ MP_ROM_QSTR(MP_QSTR_GP24), MP_ROM_PTR(&pin_GPIO24) },
3531

3632
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_CYW0) },
37-
{ MP_ROM_QSTR(MP_QSTR_CYW0), MP_ROM_PTR(&pin_CYW0) },
33+
34+
{ MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_CYW2) },
3835

3936
{ MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) },
4037
{ MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) },
@@ -47,8 +44,5 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
4744
{ MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) },
4845
{ MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) },
4946
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) },
50-
51-
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) },
52-
{ MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO29) },
5347
};
5448
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

0 commit comments

Comments
 (0)