2019-02-15 00:28:20 -05:00
|
|
|
/*
|
|
|
|
* This file is part of the MicroPython project, http://micropython.org/
|
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2019 Dan Halbert for Adafruit Industries
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-08-19 23:24:04 -04:00
|
|
|
|
2016-08-23 20:36:29 -04:00
|
|
|
#ifndef __INCLUDED_MPCONFIGPORT_H
|
|
|
|
#define __INCLUDED_MPCONFIGPORT_H
|
|
|
|
|
2019-02-15 00:28:20 -05:00
|
|
|
// Definitions for which SAMD chip we're using.
|
2017-09-22 21:05:51 -04:00
|
|
|
#include "include/sam.h"
|
|
|
|
|
2019-12-10 22:39:44 -05:00
|
|
|
// Definitions that control circuitpy_mpconfig.h:
|
2019-12-06 15:18:20 -05:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-12-10 22:39:44 -05:00
|
|
|
#ifdef SAMD21
|
2019-10-20 23:50:12 -04:00
|
|
|
|
|
|
|
// HMCRAMC0_SIZE is defined in the ASF4 include files for each SAMD21 chip.
|
|
|
|
#define RAM_SIZE HMCRAMC0_SIZE
|
|
|
|
#define BOOTLOADER_SIZE (8*1024)
|
2018-10-07 13:51:24 -04:00
|
|
|
#define CIRCUITPY_MCU_FAMILY samd21
|
2017-10-10 14:36:00 -04:00
|
|
|
#define MICROPY_PY_SYS_PLATFORM "Atmel SAMD21"
|
2018-10-19 21:46:22 -04:00
|
|
|
#define SPI_FLASH_MAX_BAUDRATE 8000000
|
2018-10-07 14:43:39 -04:00
|
|
|
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0)
|
|
|
|
#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0)
|
|
|
|
#define MICROPY_PY_FUNCTION_ATTRS (0)
|
2019-02-15 09:52:45 -05:00
|
|
|
// MICROPY_PY_UJSON depends on MICROPY_PY_IO
|
2018-10-07 14:43:39 -04:00
|
|
|
#define MICROPY_PY_IO (0)
|
2020-05-19 14:43:57 -04:00
|
|
|
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
|
2019-02-15 09:52:45 -05:00
|
|
|
#define MICROPY_PY_UJSON (0)
|
2018-11-12 10:17:07 -05:00
|
|
|
#define MICROPY_PY_UERRNO_LIST \
|
|
|
|
X(EPERM) \
|
|
|
|
X(ENOENT) \
|
|
|
|
X(EIO) \
|
|
|
|
X(EAGAIN) \
|
|
|
|
X(ENOMEM) \
|
|
|
|
X(EACCES) \
|
|
|
|
X(EEXIST) \
|
|
|
|
X(ENODEV) \
|
|
|
|
X(EISDIR) \
|
|
|
|
X(EINVAL) \
|
|
|
|
|
2019-10-20 23:50:12 -04:00
|
|
|
#endif // SAMD21
|
2017-09-22 21:05:51 -04:00
|
|
|
|
2019-12-06 15:18:20 -05:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2020-06-18 15:13:59 -04:00
|
|
|
#ifdef SAM_D5X_E5X
|
2019-10-20 23:50:12 -04:00
|
|
|
|
2020-06-18 15:13:59 -04:00
|
|
|
// HSRAM_SIZE is defined in the ASF4 include files for each SAM_D5X_E5X chip.
|
2019-10-20 23:50:12 -04:00
|
|
|
#define RAM_SIZE HSRAM_SIZE
|
|
|
|
#define BOOTLOADER_SIZE (16*1024)
|
2018-10-07 13:51:24 -04:00
|
|
|
#define CIRCUITPY_MCU_FAMILY samd51
|
2020-06-18 15:13:59 -04:00
|
|
|
#ifdef SAMD51
|
2017-10-10 14:36:00 -04:00
|
|
|
#define MICROPY_PY_SYS_PLATFORM "MicroChip SAMD51"
|
2020-06-18 15:13:59 -04:00
|
|
|
#elif defined(SAME54)
|
|
|
|
#define MICROPY_PY_SYS_PLATFORM "MicroChip SAME54"
|
|
|
|
#endif
|
2018-10-19 21:46:22 -04:00
|
|
|
#define SPI_FLASH_MAX_BAUDRATE 24000000
|
2018-10-07 14:43:39 -04:00
|
|
|
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1)
|
|
|
|
#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1)
|
|
|
|
#define MICROPY_PY_FUNCTION_ATTRS (1)
|
2019-12-06 15:18:20 -05:00
|
|
|
// MICROPY_PY_UJSON depends on MICROPY_PY_IO
|
2018-10-07 14:43:39 -04:00
|
|
|
#define MICROPY_PY_IO (1)
|
2019-02-15 09:52:45 -05:00
|
|
|
#define MICROPY_PY_UJSON (1)
|
2018-11-12 10:17:07 -05:00
|
|
|
// MICROPY_PY_UERRNO_LIST - Use the default
|
2019-10-20 23:50:12 -04:00
|
|
|
|
2020-06-18 15:13:59 -04:00
|
|
|
#endif // SAM_D5X_E5X
|
2018-05-21 23:58:03 -04:00
|
|
|
|
2019-12-06 15:18:20 -05:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// This also includes mpconfigboard.h.
|
|
|
|
#include "py/circuitpy_mpconfig.h"
|
|
|
|
|
2019-12-10 22:39:44 -05:00
|
|
|
// Definitions that can be overridden by mpconfigboard.h:
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifdef SAMD21
|
|
|
|
|
|
|
|
#if INTERNAL_FLASH_FILESYSTEM
|
|
|
|
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (64*1024)
|
|
|
|
#else
|
|
|
|
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CIRCUITPY_INTERNAL_NVM_SIZE
|
|
|
|
#define CIRCUITPY_INTERNAL_NVM_SIZE (256)
|
|
|
|
#endif
|
|
|
|
|
2019-12-16 17:17:13 -05:00
|
|
|
#ifndef CIRCUITPY_DEFAULT_STACK_SIZE
|
2020-07-27 21:50:36 -04:00
|
|
|
#define CIRCUITPY_DEFAULT_STACK_SIZE 3584
|
2019-12-16 17:17:13 -05:00
|
|
|
#endif
|
|
|
|
|
2020-07-08 14:59:00 -04:00
|
|
|
#ifndef SAMD21_BOD33_LEVEL
|
|
|
|
// Set brownout detection to ~2.7V. Default from factory is 1.7V,
|
|
|
|
// which is too low for proper operation of external SPI flash chips
|
|
|
|
// (they are 2.7-3.6V).
|
|
|
|
#define SAMD21_BOD33_LEVEL (39)
|
2020-07-08 13:59:53 -04:00
|
|
|
// 2.77V with hysteresis off. Table 37.20 in datasheet.
|
|
|
|
#endif
|
|
|
|
|
2020-02-13 17:41:05 -05:00
|
|
|
// Smallest unit of flash that can be erased.
|
|
|
|
#define FLASH_ERASE_SIZE NVMCTRL_ROW_SIZE
|
|
|
|
|
2019-12-10 22:39:44 -05:00
|
|
|
#endif // SAMD21
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2020-06-18 15:13:59 -04:00
|
|
|
#ifdef SAM_D5X_E5X
|
2019-12-10 22:39:44 -05:00
|
|
|
|
|
|
|
#ifndef CIRCUITPY_INTERNAL_NVM_SIZE
|
|
|
|
#define CIRCUITPY_INTERNAL_NVM_SIZE (8192)
|
|
|
|
#endif
|
|
|
|
|
2019-12-16 17:17:13 -05:00
|
|
|
#ifndef CIRCUITPY_DEFAULT_STACK_SIZE
|
|
|
|
#define CIRCUITPY_DEFAULT_STACK_SIZE (24*1024)
|
|
|
|
#endif
|
|
|
|
|
2020-07-08 14:59:00 -04:00
|
|
|
#ifndef SAMD5x_E5x_BOD33_LEVEL
|
|
|
|
// Set brownout detection to ~2.7V. Default from factory is 1.7V,
|
|
|
|
// which is too low for proper operation of external SPI flash chips
|
|
|
|
// (they are 2.7-3.6V).
|
|
|
|
#define SAMD5x_E5x_BOD33_LEVEL (200)
|
2020-07-08 13:59:53 -04:00
|
|
|
// 2.7V: 1.5V + LEVEL * 6mV.
|
|
|
|
#endif
|
|
|
|
|
2020-02-13 17:41:05 -05:00
|
|
|
// Smallest unit of flash that can be erased.
|
|
|
|
#define FLASH_ERASE_SIZE NVMCTRL_BLOCK_SIZE
|
|
|
|
|
2019-12-10 22:39:44 -05:00
|
|
|
// If CIRCUITPY is internal, use half of flash for it.
|
|
|
|
#if INTERNAL_FLASH_FILESYSTEM
|
|
|
|
#ifndef CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE
|
|
|
|
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (FLASH_SIZE/2)
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0)
|
|
|
|
#endif
|
|
|
|
|
2020-06-18 15:13:59 -04:00
|
|
|
#endif // SAM_D5X_E5X
|
2019-12-10 22:39:44 -05:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-12-06 15:18:20 -05:00
|
|
|
#ifndef CALIBRATE_CRYSTALLESS
|
|
|
|
#define CALIBRATE_CRYSTALLESS (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef BOARD_HAS_CRYSTAL
|
|
|
|
#define BOARD_HAS_CRYSTAL (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// if CALIBRATE_CRYSTALLESS is requested, make room for storing
|
|
|
|
// calibration data generated from external USB.
|
|
|
|
#ifndef CIRCUITPY_INTERNAL_CONFIG_SIZE
|
|
|
|
#if CALIBRATE_CRYSTALLESS
|
|
|
|
#define CIRCUITPY_INTERNAL_CONFIG_SIZE (NVMCTRL_ROW_SIZE) // 256
|
|
|
|
#else
|
|
|
|
#define CIRCUITPY_INTERNAL_CONFIG_SIZE (0)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2019-10-28 18:15:02 -04:00
|
|
|
// Flash layout, starting at 0x00000000
|
|
|
|
//
|
2019-12-12 14:57:23 -05:00
|
|
|
// - bootloader (8 or 16kB)
|
|
|
|
// - firmware
|
|
|
|
// - internal CIRCUITPY flash filesystem (optional)
|
|
|
|
// - internal config, used to store crystalless clock calibration info (optional)
|
|
|
|
// - microntroller.nvm (optional)
|
2019-10-28 18:15:02 -04:00
|
|
|
|
2019-12-05 22:45:53 -05:00
|
|
|
// Define these regions starting up from the bottom of flash:
|
2019-10-28 18:15:02 -04:00
|
|
|
|
2019-12-05 22:45:53 -05:00
|
|
|
#define BOOTLOADER_START_ADDR (0x00000000)
|
|
|
|
|
|
|
|
#define CIRCUITPY_FIRMWARE_START_ADDR (BOOTLOADER_START_ADDR + BOOTLOADER_SIZE)
|
|
|
|
|
|
|
|
// Define these regions start down from the top of flash:
|
2019-10-28 18:15:02 -04:00
|
|
|
|
2019-12-05 22:45:53 -05:00
|
|
|
#define CIRCUITPY_INTERNAL_NVM_START_ADDR \
|
2019-12-10 17:57:17 -05:00
|
|
|
(FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE)
|
2019-12-05 22:45:53 -05:00
|
|
|
|
|
|
|
#define CIRCUITPY_INTERNAL_CONFIG_START_ADDR \
|
|
|
|
(CIRCUITPY_INTERNAL_NVM_START_ADDR - CIRCUITPY_INTERNAL_CONFIG_SIZE)
|
|
|
|
|
2019-12-10 17:57:17 -05:00
|
|
|
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR \
|
|
|
|
(CIRCUITPY_INTERNAL_CONFIG_START_ADDR - CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE)
|
|
|
|
|
2019-12-05 22:45:53 -05:00
|
|
|
// The firmware space is the space left over between the fixed lower and upper regions.
|
|
|
|
#define CIRCUITPY_FIRMWARE_SIZE \
|
2019-12-10 17:57:17 -05:00
|
|
|
(CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR - CIRCUITPY_FIRMWARE_START_ADDR)
|
|
|
|
|
|
|
|
#if BOOTLOADER_START_ADDR % FLASH_PAGE_SIZE != 0
|
|
|
|
#error BOOTLOADER_START_ADDR must be on a flash page boundary.
|
|
|
|
#endif
|
|
|
|
|
2020-02-13 17:41:05 -05:00
|
|
|
#if CIRCUITPY_INTERNAL_NVM_START_ADDR % FLASH_ERASE_SIZE != 0
|
|
|
|
#error CIRCUITPY_INTERNAL_NVM_START_ADDR must be on a flash erase (row or block) boundary.
|
2019-12-10 17:57:17 -05:00
|
|
|
#endif
|
2020-02-13 17:41:05 -05:00
|
|
|
#if CIRCUITPY_INTERNAL_NVM_SIZE % FLASH_ERASE_SIZE != 0
|
|
|
|
#error CIRCUITPY_INTERNAL_NVM_SIZE must be a multiple of FLASH_ERASE_SIZE.
|
2019-12-10 17:57:17 -05:00
|
|
|
#endif
|
|
|
|
|
2020-02-13 17:41:05 -05:00
|
|
|
#if CIRCUITPY_INTERNAL_CONFIG_START_ADDR % FLASH_ERASE_SIZE != 0
|
|
|
|
#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be on a flash erase (row or block) boundary.
|
2019-12-10 17:57:17 -05:00
|
|
|
#endif
|
2020-02-13 17:41:05 -05:00
|
|
|
#if CIRCUITPY_INTERNAL_CONFIG_SIZE % FLASH_ERASE_SIZE != 0
|
|
|
|
#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be a multiple of FLASH_ERASE_SIZE.
|
2019-12-10 17:57:17 -05:00
|
|
|
#endif
|
|
|
|
|
2020-02-13 17:41:05 -05:00
|
|
|
#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR % FLASH_ERASE_SIZE != 0
|
|
|
|
#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be on a flash erase (row or block) boundary.
|
2019-12-10 17:57:17 -05:00
|
|
|
#endif
|
2020-02-13 17:41:05 -05:00
|
|
|
#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE % FLASH_ERASE_SIZE != 0
|
|
|
|
#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be a multiple of FLASH_ERASE_SIZE.
|
2019-12-10 17:57:17 -05:00
|
|
|
#endif
|
2019-12-05 22:45:53 -05:00
|
|
|
|
|
|
|
#if CIRCUITPY_FIRMWARE_SIZE < 0
|
|
|
|
#error No space left in flash for firmware after specifying other regions!
|
2018-05-21 23:58:03 -04:00
|
|
|
#endif
|
2019-10-28 18:15:02 -04:00
|
|
|
|
2019-02-15 00:28:20 -05:00
|
|
|
// Turning off audioio, audiobusio, and touchio as necessary
|
|
|
|
// due to limitations of chips is handled in mpconfigboard.mk
|
2016-08-19 23:24:04 -04:00
|
|
|
|
2018-06-15 19:16:21 -04:00
|
|
|
#include "peripherals/samd/dma.h"
|
2018-03-12 19:09:13 -04:00
|
|
|
|
2016-08-19 23:24:04 -04:00
|
|
|
#define MICROPY_PORT_ROOT_POINTERS \
|
2019-02-15 00:28:20 -05:00
|
|
|
CIRCUITPY_COMMON_ROOT_POINTERS \
|
2019-02-21 00:19:31 -05:00
|
|
|
mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT];
|
2017-05-12 19:45:38 -04:00
|
|
|
|
2016-08-23 20:36:29 -04:00
|
|
|
#endif // __INCLUDED_MPCONFIGPORT_H
|