diff --git a/ports/litex/common-hal/os/__init__.c b/ports/litex/common-hal/os/__init__.c new file mode 100644 index 000000000000..578f3e8c63c2 --- /dev/null +++ b/ports/litex/common-hal/os/__init__.c @@ -0,0 +1,61 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Sean Cross + * + * 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 "genhdr/mpversion.h" +#include "py/mpconfig.h" +#include "py/objstr.h" +#include "py/objtuple.h" +#include "py/qstr.h" + +STATIC const qstr os_uname_info_fields[] = { + MP_QSTR_sysname, MP_QSTR_nodename, + MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine +}; +STATIC const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "litex"); +STATIC const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "litex"); +STATIC const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); +STATIC const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); +STATIC const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); + + +STATIC MP_DEFINE_ATTRTUPLE( + os_uname_info_obj, + os_uname_info_fields, + 5, + (mp_obj_t)&os_uname_info_sysname_obj, + (mp_obj_t)&os_uname_info_nodename_obj, + (mp_obj_t)&os_uname_info_release_obj, + (mp_obj_t)&os_uname_info_version_obj, + (mp_obj_t)&os_uname_info_machine_obj +); + +mp_obj_t common_hal_os_uname(void) { + return (mp_obj_t)&os_uname_info_obj; +} + +bool common_hal_os_urandom(uint8_t* buffer, uint32_t length) { + return false; +} diff --git a/ports/litex/mpconfigport.h b/ports/litex/mpconfigport.h index cfa3eb5c7459..fcf9d3b73b4d 100644 --- a/ports/litex/mpconfigport.h +++ b/ports/litex/mpconfigport.h @@ -28,9 +28,12 @@ #ifndef FPGA_MPCONFIGPORT_H__ #define FPGA_MPCONFIGPORT_H__ -#define MICROPY_PY_UJSON (0) #define CIRCUITPY_INTERNAL_NVM_SIZE (0) #define MICROPY_NLR_THUMB (0) +#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1) +#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) +#define MICROPY_PY_UBINASCII (1) +#define MICROPY_PY_UJSON (1) #include "py/circuitpy_mpconfig.h" diff --git a/ports/litex/mpconfigport.mk b/ports/litex/mpconfigport.mk index 47e2b1abc8f2..0a82f416194e 100644 --- a/ports/litex/mpconfigport.mk +++ b/ports/litex/mpconfigport.mk @@ -12,20 +12,20 @@ USB_SERIAL_NUMBER_LENGTH = 30 # Longints can be implemented as mpz, as longlong, or not LONGINT_IMPL = MPZ -#Reduced feature set for early port -CIRCUITPY_MINIMAL_BUILD = 1 +CIRCUITPY_ANALOGIO = 0 +CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_AUDIOIO = 0 +CIRCUITPY_BITBANGIO = 0 +CIRCUITPY_BOARD = 0 +CIRCUITPY_BUSIO = 0 +CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_FREQUENCYIO = 0 +CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_NVM = 0 +CIRCUITPY_PULSEIO = 0 +CIRCUITPY_ROTARYIO = 0 +CIRCUITPY_RTC = 0 -# CIRCUITPY_BOARD = 1 -# CIRCUITPY_DIGITALIO = 1 -# CIRCUITPY_ANALOGIO = 1 -# CIRCUITPY_MICROCONTROLLER = 1 -# CIRCUITPY_BUSIO = 1 -# CIRCUITPY_PULSEIO = 1 -# CIRCUITPY_OS = 1 -# CIRCUITPY_STORAGE = 1 -# CIRCUITPY_RANDOM = 1 +# Enable USB support CIRCUITPY_USB_HID = 1 CIRCUITPY_USB_MIDI = 1 - -#ifeq ($(MCU_SUB_VARIANT), stm32f412zx) -#endif diff --git a/ports/litex/mphalport.c b/ports/litex/mphalport.c index 005a65aac4ac..0b8f01298574 100644 --- a/ports/litex/mphalport.c +++ b/ports/litex/mphalport.c @@ -60,6 +60,10 @@ void mp_hal_delay_ms(mp_uint_t delay) { } } +void mp_hal_delay_us(mp_uint_t delay) { + mp_hal_delay_ms(delay / 1000); +} + extern void SysTick_Handler(void); __attribute__((section(".ramtext")))