Merge pull request #3627 from adafruit/6.0.x
Merge 6.0.x bugfixes to main
This commit is contained in:
commit
144eb131ae
4
main.c
4
main.c
@ -234,10 +234,12 @@ void cleanup_after_vm(supervisor_allocation* heap) {
|
|||||||
common_hal_canio_reset();
|
common_hal_canio_reset();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
reset_port();
|
// reset_board_busses() first because it may release pins from the never_reset state, so that
|
||||||
|
// reset_port() can reset them.
|
||||||
#if CIRCUITPY_BOARD
|
#if CIRCUITPY_BOARD
|
||||||
reset_board_busses();
|
reset_board_busses();
|
||||||
#endif
|
#endif
|
||||||
|
reset_port();
|
||||||
reset_board();
|
reset_board();
|
||||||
reset_status_led();
|
reset_status_led();
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
|
|||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_BUSY), MP_ROM_PTR(&pin_PA22) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_BUSY), MP_ROM_PTR(&pin_PA22) },
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RESET), MP_ROM_PTR(&pin_PA21) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RESET), MP_ROM_PTR(&pin_PA21) },
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RTS), MP_ROM_PTR(&pin_PA18) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RTS), MP_ROM_PTR(&pin_PA18) },
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_PA12) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_PA13) },
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_PA13) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_PA12) },
|
||||||
|
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCL),MP_ROM_PTR(&pin_PB30) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCL),MP_ROM_PTR(&pin_PB30) },
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDA),MP_ROM_PTR(&pin_PB31) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDA),MP_ROM_PTR(&pin_PB31) },
|
||||||
|
@ -28,6 +28,12 @@
|
|||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
|
|
||||||
#include "shared-bindings/board/__init__.h"
|
#include "shared-bindings/board/__init__.h"
|
||||||
|
#if BOARD_I2C
|
||||||
|
#include "shared-bindings/busio/I2C.h"
|
||||||
|
#endif
|
||||||
|
#if BOARD_SPI
|
||||||
|
#include "shared-bindings/busio/SPI.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
//| """Board specific pin names
|
//| """Board specific pin names
|
||||||
//|
|
//|
|
||||||
@ -45,7 +51,7 @@
|
|||||||
#if BOARD_I2C
|
#if BOARD_I2C
|
||||||
mp_obj_t board_i2c(void) {
|
mp_obj_t board_i2c(void) {
|
||||||
mp_obj_t singleton = common_hal_board_get_i2c();
|
mp_obj_t singleton = common_hal_board_get_i2c();
|
||||||
if (singleton != NULL) {
|
if (singleton != NULL && !common_hal_busio_i2c_deinited(singleton)) {
|
||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
assert_pin_free(DEFAULT_I2C_BUS_SDA);
|
assert_pin_free(DEFAULT_I2C_BUS_SDA);
|
||||||
@ -69,7 +75,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c);
|
|||||||
#if BOARD_SPI
|
#if BOARD_SPI
|
||||||
mp_obj_t board_spi(void) {
|
mp_obj_t board_spi(void) {
|
||||||
mp_obj_t singleton = common_hal_board_get_spi();
|
mp_obj_t singleton = common_hal_board_get_spi();
|
||||||
if (singleton != NULL) {
|
if (singleton != NULL && !common_hal_busio_spi_deinited(singleton)) {
|
||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
assert_pin_free(DEFAULT_SPI_BUS_SCK);
|
assert_pin_free(DEFAULT_SPI_BUS_SCK);
|
||||||
|
@ -55,9 +55,8 @@ mp_obj_t common_hal_board_get_i2c(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t common_hal_board_create_i2c(void) {
|
mp_obj_t common_hal_board_create_i2c(void) {
|
||||||
if (i2c_singleton != NULL) {
|
// All callers have either already verified this or come so early that it can't be otherwise.
|
||||||
return i2c_singleton;
|
assert(i2c_singleton == NULL || common_hal_busio_i2c_deinited(i2c_singleton));
|
||||||
}
|
|
||||||
busio_i2c_obj_t *self = &i2c_obj;
|
busio_i2c_obj_t *self = &i2c_obj;
|
||||||
self->base.type = &busio_i2c_type;
|
self->base.type = &busio_i2c_type;
|
||||||
|
|
||||||
@ -79,9 +78,8 @@ mp_obj_t common_hal_board_get_spi(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t common_hal_board_create_spi(void) {
|
mp_obj_t common_hal_board_create_spi(void) {
|
||||||
if (spi_singleton != NULL) {
|
// All callers have either already verified this or come so early that it can't be otherwise.
|
||||||
return spi_singleton;
|
assert(spi_singleton == NULL || common_hal_busio_spi_deinited(spi_singleton));
|
||||||
}
|
|
||||||
busio_spi_obj_t *self = &spi_obj;
|
busio_spi_obj_t *self = &spi_obj;
|
||||||
self->base.type = &busio_spi_type;
|
self->base.type = &busio_spi_type;
|
||||||
|
|
||||||
@ -139,14 +137,17 @@ void reset_board_busses(void) {
|
|||||||
bool display_using_i2c = false;
|
bool display_using_i2c = false;
|
||||||
#if CIRCUITPY_DISPLAYIO
|
#if CIRCUITPY_DISPLAYIO
|
||||||
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
|
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
|
||||||
if (displays[i].i2cdisplay_bus.bus == i2c_singleton) {
|
if (displays[i].bus_base.type == &displayio_i2cdisplay_type && displays[i].i2cdisplay_bus.bus == i2c_singleton) {
|
||||||
display_using_i2c = true;
|
display_using_i2c = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!display_using_i2c) {
|
if (i2c_singleton != NULL) {
|
||||||
i2c_singleton = NULL;
|
if (!display_using_i2c) {
|
||||||
|
common_hal_busio_i2c_deinit(i2c_singleton);
|
||||||
|
i2c_singleton = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if BOARD_SPI
|
#if BOARD_SPI
|
||||||
@ -169,9 +170,10 @@ void reset_board_busses(void) {
|
|||||||
// make sure SPI lock is not held over a soft reset
|
// make sure SPI lock is not held over a soft reset
|
||||||
if (spi_singleton != NULL) {
|
if (spi_singleton != NULL) {
|
||||||
common_hal_busio_spi_unlock(spi_singleton);
|
common_hal_busio_spi_unlock(spi_singleton);
|
||||||
}
|
if (!display_using_spi) {
|
||||||
if (!display_using_spi) {
|
common_hal_busio_spi_deinit(spi_singleton);
|
||||||
spi_singleton = NULL;
|
spi_singleton = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if BOARD_UART
|
#if BOARD_UART
|
||||||
|
@ -47,5 +47,4 @@ char serial_read(void);
|
|||||||
bool serial_bytes_available(void);
|
bool serial_bytes_available(void);
|
||||||
bool serial_connected(void);
|
bool serial_connected(void);
|
||||||
|
|
||||||
extern volatile bool _serial_connected;
|
|
||||||
#endif // MICROPY_INCLUDED_SUPERVISOR_SERIAL_H
|
#endif // MICROPY_INCLUDED_SUPERVISOR_SERIAL_H
|
||||||
|
@ -47,8 +47,6 @@ busio_uart_obj_t debug_uart;
|
|||||||
byte buf_array[64];
|
byte buf_array[64];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
volatile bool _serial_connected;
|
|
||||||
|
|
||||||
void serial_early_init(void) {
|
void serial_early_init(void) {
|
||||||
#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
|
#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
|
||||||
debug_uart.base.type = &busio_uart_type;
|
debug_uart.base.type = &busio_uart_type;
|
||||||
@ -71,7 +69,9 @@ bool serial_connected(void) {
|
|||||||
#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
|
#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
return _serial_connected;
|
// True if DTR is asserted, and the USB connection is up.
|
||||||
|
// tud_cdc_get_line_state(): bit 0 is DTR, bit 1 is RTS
|
||||||
|
return (tud_cdc_get_line_state() & 1) && tud_ready();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,6 @@ void tud_umount_cb(void) {
|
|||||||
// remote_wakeup_en : if host allows us to perform remote wakeup
|
// remote_wakeup_en : if host allows us to perform remote wakeup
|
||||||
// USB Specs: Within 7ms, device must draw an average current less than 2.5 mA from bus
|
// USB Specs: Within 7ms, device must draw an average current less than 2.5 mA from bus
|
||||||
void tud_suspend_cb(bool remote_wakeup_en) {
|
void tud_suspend_cb(bool remote_wakeup_en) {
|
||||||
_serial_connected = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoked when usb bus is resumed
|
// Invoked when usb bus is resumed
|
||||||
@ -128,8 +127,6 @@ void tud_resume_cb(void) {
|
|||||||
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) {
|
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) {
|
||||||
(void) itf; // interface ID, not used
|
(void) itf; // interface ID, not used
|
||||||
|
|
||||||
_serial_connected = dtr;
|
|
||||||
|
|
||||||
// DTR = false is counted as disconnected
|
// DTR = false is counted as disconnected
|
||||||
if ( !dtr )
|
if ( !dtr )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user