From 7e0e6fcdca953d9505d190ab99e2d31c56927db0 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 3 Oct 2023 15:03:59 -0400 Subject: [PATCH] Metro M4 now compiles --- extmod/moduselect.c | 9 +++++++-- ports/atmel-samd/common-hal/i2ctarget/I2CTarget.h | 2 -- py/obj.h | 4 ++++ shared-bindings/_bleio/CharacteristicBuffer.c | 2 +- shared-bindings/_bleio/ScanResults.c | 3 +-- shared-bindings/_bleio/UUID.c | 2 +- shared-bindings/_bleio/__init__.h | 15 +++++++-------- shared-bindings/_pixelmap/PixelMap.c | 8 ++++---- .../adafruit_bus_device/i2c_device/I2CDevice.c | 2 +- shared-bindings/audiomp3/MP3Decoder.c | 2 +- shared-bindings/i2ctarget/I2CTarget.c | 13 +++++++------ shared-bindings/keypad/EventQueue.c | 2 +- shared-bindings/keypad/Keys.c | 2 +- shared-bindings/rgbmatrix/RGBMatrix.c | 2 +- shared-bindings/vectorio/VectorShape.c | 2 +- shared-module/getpass/__init__.c | 2 +- shared-module/msgpack/__init__.c | 4 ++-- 17 files changed, 41 insertions(+), 35 deletions(-) diff --git a/extmod/moduselect.c b/extmod/moduselect.c index 14f9ffb661..a1513835b2 100644 --- a/extmod/moduselect.c +++ b/extmod/moduselect.c @@ -171,7 +171,8 @@ STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) { mp_map_deinit(&poll_map); return mp_obj_new_tuple(3, list_array); } - MICROPY_EVENT_POLL_HOOK + // CIRCUITPY + RUN_BACKGROUND_TASKS; } } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_select_select_obj, 3, 4, select_select); @@ -250,7 +251,11 @@ STATIC mp_uint_t poll_poll_internal(uint n_args, const mp_obj_t *args) { if (n_ready > 0 || (timeout != (mp_uint_t)-1 && mp_hal_ticks_ms() - start_tick >= timeout)) { break; } - MICROPY_EVENT_POLL_HOOK + // CIRCUITPY + RUN_BACKGROUND_TASKS; + if (mp_hal_is_interrupted()) { + return 0; + } } return n_ready; diff --git a/ports/atmel-samd/common-hal/i2ctarget/I2CTarget.h b/ports/atmel-samd/common-hal/i2ctarget/I2CTarget.h index 471abbb0bf..894961ab7b 100644 --- a/ports/atmel-samd/common-hal/i2ctarget/I2CTarget.h +++ b/ports/atmel-samd/common-hal/i2ctarget/I2CTarget.h @@ -23,8 +23,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SAMD_PENDSV_H -#define MICROPY_INCLUDED_SAMD_PENDSV_H #ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_I2C_TARGET_H #define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_I2C_TARGET_H diff --git a/py/obj.h b/py/obj.h index 2576f87cf1..789e05b884 100644 --- a/py/obj.h +++ b/py/obj.h @@ -898,6 +898,10 @@ extern const mp_obj_type_t mp_type_UnicodeError; extern const mp_obj_type_t mp_type_ValueError; extern const mp_obj_type_t mp_type_ViperTypeError; extern const mp_obj_type_t mp_type_ZeroDivisionError; +#if CIRCUITPY_ALARM +extern const mp_obj_type_t mp_type_DeepSleepRequest; +#endif + // Constant objects, globally accessible: None, False, True // These should always be accessed via the below macros. diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c index d95972d263..474a07f7b9 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.c +++ b/shared-bindings/_bleio/CharacteristicBuffer.c @@ -228,6 +228,6 @@ MP_DEFINE_CONST_OBJ_TYPE( MP_TYPE_FLAG_ITER_IS_ITERNEXT, make_new, bleio_characteristic_buffer_make_new, locals_dict, &bleio_characteristic_buffer_locals_dict, - iternext, mp_stream_unbuffered_iter, + iter, mp_stream_unbuffered_iter, protocol, &characteristic_buffer_stream_p ); diff --git a/shared-bindings/_bleio/ScanResults.c b/shared-bindings/_bleio/ScanResults.c index 028c066168..81d4e66bce 100644 --- a/shared-bindings/_bleio/ScanResults.c +++ b/shared-bindings/_bleio/ScanResults.c @@ -63,6 +63,5 @@ MP_DEFINE_CONST_OBJ_TYPE( bleio_scanresults_type, MP_QSTR_ScanResults, MP_TYPE_FLAG_ITER_IS_ITERNEXT, - getiter, mp_identity_getiter, - iternext, scanresults_iternext + iter, scanresults_iternext ); diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c index 3469982458..c177e096f5 100644 --- a/shared-bindings/_bleio/UUID.c +++ b/shared-bindings/_bleio/UUID.c @@ -288,5 +288,5 @@ MP_DEFINE_CONST_OBJ_TYPE( make_new, bleio_uuid_make_new, locals_dict, &bleio_uuid_locals_dict, unary_op, bleio_uuid_unary_op, - binary_op, bleio_uuid_binary_op, + binary_op, bleio_uuid_binary_op ); diff --git a/shared-bindings/_bleio/__init__.h b/shared-bindings/_bleio/__init__.h index f34df306b7..1a917793eb 100644 --- a/shared-bindings/_bleio/__init__.h +++ b/shared-bindings/_bleio/__init__.h @@ -29,6 +29,7 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO___INIT___H #define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO___INIT___H +#include "py/obj.h" #include "py/objlist.h" #include "shared-bindings/_bleio/Adapter.h" @@ -41,14 +42,12 @@ extern bleio_adapter_obj_t common_hal_bleio_adapter_obj; void bleio_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); #define MP_DEFINE_BLEIO_EXCEPTION(exc_name, base_name) \ - const mp_obj_type_t mp_type_bleio_##exc_name = { \ - { &mp_type_type }, \ - .name = MP_QSTR_##exc_name, \ - .print = bleio_exception_print, \ - .make_new = mp_obj_exception_make_new, \ - .attr = mp_obj_exception_attr, \ - .parent = &mp_type_##base_name, \ - }; + MP_DEFINE_CONST_OBJ_TYPE(mp_type_bleio_##exc_name, MP_QSTR_##exc_name, MP_TYPE_FLAG_NONE, \ + make_new, mp_obj_exception_make_new, \ + print, bleio_exception_print, \ + attr, mp_obj_exception_attr, \ + parent, &mp_type_##base_name \ + ); extern const mp_obj_type_t mp_type_bleio_BluetoothError; extern const mp_obj_type_t mp_type_bleio_RoleError; diff --git a/shared-bindings/_pixelmap/PixelMap.c b/shared-bindings/_pixelmap/PixelMap.c index 618135f995..4d06fe64fa 100644 --- a/shared-bindings/_pixelmap/PixelMap.c +++ b/shared-bindings/_pixelmap/PixelMap.c @@ -259,8 +259,8 @@ MP_DEFINE_CONST_OBJ_TYPE( pixelmap_pixelmap_type, MP_QSTR_PixelMap, MP_TYPE_FLAG_NONE, - .locals_dict, &pixelmap_pixelmap_locals_dict, - .make_new, pixelmap_pixelmap_make_new, - .subscr, pixelmap_pixelmap_subscr, - .unary_op, pixelmap_pixelmap_unary_op + locals_dict, &pixelmap_pixelmap_locals_dict, + make_new, pixelmap_pixelmap_make_new, + subscr, pixelmap_pixelmap_subscr, + unary_op, pixelmap_pixelmap_unary_op ); diff --git a/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c index c0380871fa..0da8c48fcf 100644 --- a/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c @@ -289,5 +289,5 @@ MP_DEFINE_CONST_OBJ_TYPE( MP_QSTR_I2CDevice, MP_TYPE_FLAG_NONE, make_new, adafruit_bus_device_i2cdevice_make_new, - locals_dict = &adafruit_bus_device_i2cdevice_locals_dict + locals_dict, &adafruit_bus_device_i2cdevice_locals_dict ); diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 160b415ad1..1acab44a61 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -289,5 +289,5 @@ MP_DEFINE_CONST_OBJ_TYPE( MP_TYPE_FLAG_NONE, make_new, audiomp3_mp3file_make_new, locals_dict, &audiomp3_mp3file_locals_dict, - .protocol, &audiomp3_mp3file_proto + protocol, &audiomp3_mp3file_proto ); diff --git a/shared-bindings/i2ctarget/I2CTarget.c b/shared-bindings/i2ctarget/I2CTarget.c index c7866813ea..79d234c5dc 100644 --- a/shared-bindings/i2ctarget/I2CTarget.c +++ b/shared-bindings/i2ctarget/I2CTarget.c @@ -214,12 +214,13 @@ STATIC const mp_rom_map_elem_t i2ctarget_i2c_target_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(i2ctarget_i2c_target_locals_dict, i2ctarget_i2c_target_locals_dict_table); -const mp_obj_type_t i2ctarget_i2c_target_type = { - { &mp_type_type }, - .name = MP_QSTR_I2CTarget, - .make_new = i2ctarget_i2c_target_make_new, - .locals_dict = (mp_obj_dict_t *)&i2ctarget_i2c_target_locals_dict, -}; +MP_DEFINE_CONST_OBJ_TYPE( + i2ctarget_i2c_target_type, + MP_QSTR_I2CTarget, + MP_TYPE_FLAG_NONE, + make_new, i2ctarget_i2c_target_make_new, + locals_dict, &i2ctarget_i2c_target_locals_dict + ); //| class I2CTargetRequest: //| def __init__( diff --git a/shared-bindings/keypad/EventQueue.c b/shared-bindings/keypad/EventQueue.c index 596c141b41..9293f8390b 100644 --- a/shared-bindings/keypad/EventQueue.c +++ b/shared-bindings/keypad/EventQueue.c @@ -167,7 +167,7 @@ STATIC const mp_stream_p_t eventqueue_p = { MP_DEFINE_CONST_OBJ_TYPE( keypad_eventqueue_type, - P_QSTR_EventQueue, + MP_QSTR_EventQueue, MP_TYPE_FLAG_NONE, unary_op, keypad_eventqueue_unary_op, #if MICROPY_PY_USELECT diff --git a/shared-bindings/keypad/Keys.c b/shared-bindings/keypad/Keys.c index 6b9f394a08..94fe3dba02 100644 --- a/shared-bindings/keypad/Keys.c +++ b/shared-bindings/keypad/Keys.c @@ -173,7 +173,7 @@ MP_DEFINE_CONST_OBJ_TYPE( keypad_keys_type, MP_QSTR_Keys, MP_TYPE_FLAG_NONE, - .make_new = keypad_keys_make_new + make_new, keypad_keys_make_new #if CIRCUITPY_KEYPAD_KEYS , locals_dict, &keypad_keys_locals_dict #endif diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index 6ea601f1e0..d9277ad443 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -428,5 +428,5 @@ MP_DEFINE_CONST_OBJ_TYPE( locals_dict, &rgbmatrix_rgbmatrix_locals_dict, make_new, rgbmatrix_rgbmatrix_make_new, buffer, rgbmatrix_rgbmatrix_get_buffer, - protocol = &rgbmatrix_rgbmatrix_proto + protocol, &rgbmatrix_rgbmatrix_proto ); diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index fb91f487b3..bf2a1d772d 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -245,5 +245,5 @@ MP_DEFINE_CONST_OBJ_TYPE( vectorio_vector_shape_type, MP_QSTR_VectorShape, MP_TYPE_FLAG_NONE, - locals_dict = &vectorio_vector_shape_locals_dict + locals_dict, &vectorio_vector_shape_locals_dict ); diff --git a/shared-module/getpass/__init__.c b/shared-module/getpass/__init__.c index 8f16d75b53..72469a686f 100644 --- a/shared-module/getpass/__init__.c +++ b/shared-module/getpass/__init__.c @@ -57,5 +57,5 @@ mp_obj_t shared_module_getpass_getpass(const char *prompt, mp_print_t *print) { } } - return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); + return mp_obj_new_str_from_vstr(&vstr); } diff --git a/shared-module/msgpack/__init__.c b/shared-module/msgpack/__init__.c index 6425ae8496..aac38607cb 100644 --- a/shared-module/msgpack/__init__.c +++ b/shared-module/msgpack/__init__.c @@ -375,7 +375,7 @@ STATIC mp_obj_t unpack_bytes(msgpack_stream_t *s, size_t size) { size -= n; p += n; } - return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); + return mp_obj_new_bytes_from_vstr(&vstr); } STATIC mp_obj_t unpack_ext(msgpack_stream_t *s, size_t size, mp_obj_t ext_hook) { @@ -474,7 +474,7 @@ STATIC mp_obj_t unpack(msgpack_stream_t *s, mp_obj_t ext_hook, bool use_list) { vstr_init_len(&vstr, size); byte *p = (byte *)vstr.buf; read(s, p, size); - return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); + return mp_obj_new_str_from_vstr(&vstr); } case 0xde: case 0xdf: {