mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 19:50:30 +01:00
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_c2_c5_c6) (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (bigendian) (push) Has been cancelled
qemu port / build_and_test_arm (sabrelite) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_hardfp) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_softfp) (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
qemu port / build_and_test_rv64 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / longlong (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / gil_enabled (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / repr_b (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Adds the ability to use PSRAM and non-contiguous memory.
Example usage, add this to dts overlay:
/ {
heap_psram {
compatible = "micropython,heap";
size = <DT_SIZE_M(4)>;
memory-region = <&psram>;
};
heap_sram1 {
compatible = "micropython,heap";
size = <DT_SIZE_K(140)>;
memory-region = <&sram1>;
};
};
Signed-off-by: Vdragon <mail@massdriver.space>
191 lines
6.6 KiB
C
191 lines
6.6 KiB
C
/*
|
|
* This file is part of the MicroPython project, http://micropython.org/
|
|
*
|
|
* The MIT License (MIT)
|
|
*
|
|
* Copyright (c) 2016 Linaro Limited
|
|
*
|
|
* 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 <alloca.h>
|
|
|
|
// Include Zephyr's autoconf.h, which should be made first by Zephyr makefiles
|
|
#include <zephyr/autoconf.h>
|
|
// Included here to get basic Zephyr environment (macros, etc.)
|
|
#include <zephyr/kernel.h>
|
|
#include <zephyr/drivers/spi.h>
|
|
|
|
// Use the basic configuration level to get a balance between size and features.
|
|
#ifndef MICROPY_CONFIG_ROM_LEVEL
|
|
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES)
|
|
#endif
|
|
|
|
// Usually passed from Makefile
|
|
#ifndef MICROPY_HEAP_SIZE
|
|
#define MICROPY_HEAP_SIZE (16 * 1024)
|
|
#endif
|
|
|
|
// We can't guarantee object layout of nlr code so use long jump by default.
|
|
#define MICROPY_NLR_THUMB_USE_LONG_JUMP (1)
|
|
|
|
#define MICROPY_PERSISTENT_CODE_LOAD (1)
|
|
#define MICROPY_ENABLE_SOURCE_LINE (1)
|
|
#define MICROPY_STACK_CHECK (1)
|
|
#define MICROPY_STACK_CHECK_MARGIN (512)
|
|
#define MICROPY_STACK_SIZE_HARD_IRQ (CONFIG_ISR_STACK_SIZE)
|
|
#define MICROPY_ENABLE_GC (1)
|
|
#define MICROPY_ENABLE_FINALISER (MICROPY_VFS)
|
|
#define MICROPY_HELPER_REPL (1)
|
|
#define MICROPY_REPL_AUTO_INDENT (1)
|
|
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
|
|
#define MICROPY_KBD_EXCEPTION (1)
|
|
#define MICROPY_PY_BUILTINS_BYTES_HEX (1)
|
|
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
|
|
#define MICROPY_PY_BUILTINS_HELP (1)
|
|
#define MICROPY_PY_BUILTINS_HELP_TEXT zephyr_help_text
|
|
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)
|
|
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
|
|
#define MICROPY_PY_MACHINE (1)
|
|
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/zephyr/modmachine.c"
|
|
#define MICROPY_PY_MACHINE_I2C (1)
|
|
#ifdef CONFIG_I2C_TARGET
|
|
#define MICROPY_PY_MACHINE_I2C_TARGET (1)
|
|
#define MICROPY_PY_MACHINE_I2C_TARGET_INCLUDEFILE "ports/zephyr/machine_i2c_target.c"
|
|
#define MICROPY_PY_MACHINE_I2C_TARGET_MAX (1)
|
|
#define MICROPY_PY_MACHINE_I2C_TARGET_HARD_IRQ (1)
|
|
#endif
|
|
#define MICROPY_PY_MACHINE_SOFTI2C (1)
|
|
#define MICROPY_PY_MACHINE_SPI (1)
|
|
#define MICROPY_PY_MACHINE_SPI_MSB (SPI_TRANSFER_MSB)
|
|
#define MICROPY_PY_MACHINE_SPI_LSB (SPI_TRANSFER_LSB)
|
|
#define MICROPY_PY_MACHINE_SOFTSPI (1)
|
|
#define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new
|
|
#define MICROPY_PY_MACHINE_UART (1)
|
|
#define MICROPY_PY_MACHINE_UART_INCLUDEFILE "ports/zephyr/machine_uart.c"
|
|
#ifdef CONFIG_WATCHDOG
|
|
#define MICROPY_PY_MACHINE_WDT (1)
|
|
#define MICROPY_PY_MACHINE_WDT_INCLUDEFILE "ports/zephyr/machine_wdt.c"
|
|
#endif
|
|
#define MICROPY_PY_MACHINE_PWM (1)
|
|
#define MICROPY_PY_MACHINE_PWM_INCLUDEFILE "ports/zephyr/machine_pwm.c"
|
|
#if defined(CONFIG_NETWORKING) || defined(CONFIG_FILE_SYSTEM)
|
|
#define MICROPY_PY_ERRNO (1)
|
|
#endif
|
|
#ifdef CONFIG_NETWORKING
|
|
#define MICROPY_PY_SOCKET (1)
|
|
#endif
|
|
#ifdef CONFIG_BT
|
|
#define MICROPY_PY_BLUETOOTH (1)
|
|
#ifdef CONFIG_BT_CENTRAL
|
|
#define MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE (1)
|
|
#endif
|
|
#define MICROPY_PY_BLUETOOTH_ENABLE_GATT_CLIENT (0)
|
|
#endif
|
|
#define MICROPY_PY_BINASCII (1)
|
|
#define MICROPY_PY_HASHLIB (1)
|
|
#define MICROPY_PY_OS (1)
|
|
#define MICROPY_PY_TIME_TIME_TIME_NS (1)
|
|
#define MICROPY_PY_TIME_INCLUDEFILE "ports/zephyr/modtime.c"
|
|
#define MICROPY_PY_ZEPHYR (1)
|
|
#define MICROPY_PY_ZSENSOR (1)
|
|
#define MICROPY_PY_SYS_MAXSIZE (1)
|
|
#define MICROPY_PY_SYS_STDFILES (1)
|
|
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
|
|
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
|
|
#define MICROPY_PY_BUILTINS_COMPLEX (0)
|
|
#define MICROPY_ENABLE_SCHEDULER (1)
|
|
#define MICROPY_VFS (1)
|
|
#define MICROPY_READER_VFS (MICROPY_VFS)
|
|
|
|
// fatfs configuration used in ffconf.h
|
|
#define MICROPY_FATFS_ENABLE_LFN (1)
|
|
#define MICROPY_FATFS_LFN_CODE_PAGE 437 /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
|
|
#define MICROPY_FATFS_USE_LABEL (1)
|
|
#define MICROPY_FATFS_RPATH (2)
|
|
#define MICROPY_FATFS_NORTC (1)
|
|
|
|
// When CONFIG_THREAD_CUSTOM_DATA is enabled, MICROPY_PY_THREAD is enabled automatically
|
|
#ifdef CONFIG_THREAD_CUSTOM_DATA
|
|
#define MICROPY_PY_THREAD (1)
|
|
#define MICROPY_PY_THREAD_GIL (1)
|
|
#define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32)
|
|
#endif
|
|
|
|
void mp_hal_signal_event(void);
|
|
#define MICROPY_SCHED_HOOK_SCHEDULED mp_hal_signal_event()
|
|
|
|
#define MICROPY_PY_SYS_PLATFORM "zephyr"
|
|
|
|
#ifdef CONFIG_BOARD
|
|
#define MICROPY_HW_BOARD_NAME "zephyr-" CONFIG_BOARD
|
|
#else
|
|
#define MICROPY_HW_BOARD_NAME "zephyr-generic"
|
|
#endif
|
|
|
|
#ifdef CONFIG_SOC
|
|
#define MICROPY_HW_MCU_NAME CONFIG_SOC
|
|
#else
|
|
#define MICROPY_HW_MCU_NAME "unknown-cpu"
|
|
#endif
|
|
|
|
#ifdef CONFIG_ADC
|
|
#define MICROPY_PY_MACHINE_ADC (1)
|
|
#define MICROPY_PY_MACHINE_ADC_INCLUDEFILE "ports/zephyr/machine_adc.c"
|
|
#define MICROPY_PY_MACHINE_ADC_READ (1)
|
|
#define MICROPY_PY_MACHINE_ADC_READ_UV (1)
|
|
#endif
|
|
|
|
#if DT_HAS_COMPAT_STATUS_OKAY(micropython_heap)
|
|
#define MICROPY_GC_SPLIT_HEAP (1)
|
|
#endif
|
|
|
|
typedef long mp_off_t;
|
|
|
|
#define MP_STATE_PORT MP_STATE_VM
|
|
|
|
#define MP_SSIZE_MAX (0x7fffffff)
|
|
|
|
// extra built in names to add to the global namespace
|
|
#define MICROPY_PORT_BUILTINS \
|
|
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },
|
|
|
|
#if MICROPY_PY_THREAD
|
|
#define MICROPY_EVENT_POLL_HOOK \
|
|
do { \
|
|
extern void mp_handle_pending(bool); \
|
|
mp_handle_pending(true); \
|
|
MP_THREAD_GIL_EXIT(); \
|
|
k_msleep(1); \
|
|
MP_THREAD_GIL_ENTER(); \
|
|
} while (0);
|
|
#else
|
|
#define MICROPY_EVENT_POLL_HOOK \
|
|
do { \
|
|
extern void mp_handle_pending(bool); \
|
|
mp_handle_pending(true); \
|
|
k_msleep(1); \
|
|
} while (0);
|
|
#endif
|
|
|
|
// Compatibility switches
|
|
|
|
#ifdef CONFIG_NEWLIB_LIBC
|
|
#define MICROPY_PY_MATH_POW_FIX_NAN (1)
|
|
#endif
|