samd/mpconfigport: Restructure to use ROM feature levels.

Changes are:
- Set the feature level for each MCU: CORE features for SAMD21, and EXTRA
  features for SAMD51.
- Remove all definitions that are included in the core feature level.
- Keep the default settings for feature level and float, to make the choice
  obvious.
This commit is contained in:
robert-hh 2022-06-15 15:16:07 +02:00 committed by Damien George
parent a415752173
commit 929dfc66a3
4 changed files with 33 additions and 38 deletions

View File

@ -161,6 +161,7 @@ SRC_QSTR += \
shared/readline/readline.c \
extmod/uos_dupterm.c \
shared/runtime/mpirq.c \
shared/runtime/sys_stdio_mphal.c \
SRC_QSTR += $(SRC_MOD) $(SRC_CXX)

View File

@ -1,16 +1,24 @@
// Deinitions common to all SAMD21 boards
#include "samd21.h"
#define MICROPY_HW_FLASH_STORAGE_BASE (0x30000)
#define MICROPY_HW_FLASH_STORAGE_BYTES (0xFFFF)
#define VFS_BLOCK_SIZE_BYTES (1536) // 24x 64B flash pages;
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES)
#define MICROPY_HW_UART_TXBUF (1)
// MicroPython emitters
#define MICROPY_EMIT_THUMB (0)
#define MICROPY_EMIT_INLINE_THUMB (0)
#define CPU_FREQ (48000000)
#define APB_FREQ (48000000)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
#define IRQ_PRI_PENDSV ((1 << __NVIC_PRIO_BITS) - 1)
#define MICROPY_HW_FLASH_STORAGE_BASE (0x30000)
#define MICROPY_HW_FLASH_STORAGE_BYTES (0xFFFF)
#define VFS_BLOCK_SIZE_BYTES (1536) // 24x 64B flash pages;
#define MICROPY_HW_UART_TXBUF (1)
#define CPU_FREQ (48000000)
#define APB_FREQ (48000000)
#define IRQ_PRI_PENDSV ((1 << __NVIC_PRIO_BITS) - 1)
static inline uint32_t raise_irq_pri(uint32_t pri) {
(void)pri;

View File

@ -1,10 +1,17 @@
// Deinitions common to all SAMD51 boards
#include "samd51.h"
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES)
// MicroPython emitters
#define MICROPY_EMIT_THUMB (1)
#define MICROPY_EMIT_INLINE_THUMB (1)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
#define MICROPY_PY_BUILTINS_COMPLEX (0)
#define MICROPY_PY_MATH (0)
#define MICROPY_PY_CMATH (0)
#define MICROPY_PY_UOS_URANDOM (1)
#define MICROPY_PY_URANDOM_SEED_INIT_FUNC (trng_random_u32())
unsigned long trng_random_u32(void);
@ -15,18 +22,18 @@ unsigned long trng_random_u32(void);
// samd_flash.c flash parameters
// Build a 128k Flash storage at top. 512k-128k=384k=0x60000
// 512*1024= 0x80000 minus 128*1024= 0x20000 = 0x60000
#define MICROPY_HW_FLASH_STORAGE_BASE (0x60000)
#define MICROPY_HW_FLASH_STORAGE_BYTES (0x1FFFF)
#define VFS_BLOCK_SIZE_BYTES (1536) //
#define MICROPY_HW_FLASH_STORAGE_BASE (0x60000)
#define MICROPY_HW_FLASH_STORAGE_BYTES (0x1FFFF)
#define VFS_BLOCK_SIZE_BYTES (1536) //
#define MICROPY_HW_UART_TXBUF (1)
#define MICROPY_HW_UART_TXBUF (1)
#define CPU_FREQ (120000000)
#define APB_FREQ (48000000)
#define DPLLx_REF_FREQ (32768)
#define CPU_FREQ (120000000)
#define APB_FREQ (48000000)
#define DPLLx_REF_FREQ (32768)
#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003)
#define IRQ_PRI_PENDSV NVIC_EncodePriority(NVIC_PRIORITYGROUP_4, 7, 0)
#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003)
#define IRQ_PRI_PENDSV NVIC_EncodePriority(NVIC_PRIORITYGROUP_4, 7, 0)
static inline uint32_t raise_irq_pri(uint32_t pri) {
uint32_t basepri = __get_BASEPRI();

View File

@ -40,8 +40,6 @@
// MicroPython emitters
#define MICROPY_PERSISTENT_CODE_LOAD (1)
#define MICROPY_EMIT_THUMB (0)
#define MICROPY_EMIT_INLINE_THUMB (0)
// Compiler configuration
#define MICROPY_COMP_CONST (1)
@ -56,33 +54,18 @@
#define MICROPY_ENABLE_SOURCE_LINE (1)
#define MICROPY_STREAMS_NON_BLOCK (1)
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
#define MICROPY_CPYTHON_COMPAT (0)
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
#define MICROPY_PY_BUILTINS_HELP (1)
#define MICROPY_PY_BUILTINS_HELP_TEXT samd_help_text
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
#define MICROPY_ENABLE_SCHEDULER (1)
// fixes sys/usys import issue
#define MICROPY_MODULE_WEAK_LINKS (1)
// Control over Python builtins
#define MICROPY_PY_ASYNC_AWAIT (0)
#define MICROPY_PY_BUILTINS_BYTES_HEX (1)
#define MICROPY_PY_BUILTINS_STR_COUNT (0)
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
#define MICROPY_PY_BUILTINS_SET (0)
#define MICROPY_PY_BUILTINS_FROZENSET (0)
#define MICROPY_PY_BUILTINS_PROPERTY (0)
#define MICROPY_PY_BUILTINS_ENUMERATE (1)
#define MICROPY_PY_BUILTINS_FILTER (0)
#define MICROPY_PY_BUILTINS_REVERSED (0)
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1)
#define MICROPY_PY_BUILTINS_MIN_MAX (1)
#define MICROPY_PY_BUILTINS_INPUT (1)
#define MICROPY_PY___FILE__ (0)
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)
#define MICROPY_PY_ATTRTUPLE (1)
#define MICROPY_PY_COLLECTIONS (0)
#define MICROPY_PY_SYS (1)
#define MICROPY_PY_SYS_PLATFORM "samd"
#define MICROPY_PY_SYS_EXIT (1)
@ -118,10 +101,6 @@
#define MICROPY_PY_MACHINE_PWM_DUTY_U16_NS (1)
#define MICROPY_PY_MACHINE_PWM_INCLUDEFILE "ports/samd/machine_pwm.c"
// Use VfsLfs's types for fileio/textio
#define mp_type_fileio mp_type_vfs_lfs1_fileio
#define mp_type_textio mp_type_vfs_lfs1_textio
#define MP_STATE_PORT MP_STATE_VM
// Miscellaneous settings