2016-10-12 20:51:17 +01:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-07-22 18:18:17 +01:00
|
|
|
#include <alloca.h>
|
|
|
|
|
2016-10-12 17:42:55 +01:00
|
|
|
// Include Zephyr's autoconf.h, which should be made first by Zephyr makefiles
|
|
|
|
#include "autoconf.h"
|
2017-03-25 21:32:51 +00:00
|
|
|
// Included here to get basic Zephyr environment (macros, etc.)
|
|
|
|
#include <zephyr.h>
|
2021-06-14 22:57:29 +01:00
|
|
|
#include <drivers/spi.h>
|
2016-10-12 17:42:55 +01:00
|
|
|
|
2016-11-04 16:09:39 +00:00
|
|
|
// Usually passed from Makefile
|
|
|
|
#ifndef MICROPY_HEAP_SIZE
|
|
|
|
#define MICROPY_HEAP_SIZE (16 * 1024)
|
|
|
|
#endif
|
|
|
|
|
2017-05-02 21:33:16 +01:00
|
|
|
#define MICROPY_ENABLE_SOURCE_LINE (1)
|
2016-08-24 21:13:11 +01:00
|
|
|
#define MICROPY_STACK_CHECK (1)
|
2016-07-22 18:18:17 +01:00
|
|
|
#define MICROPY_ENABLE_GC (1)
|
|
|
|
#define MICROPY_HELPER_REPL (1)
|
|
|
|
#define MICROPY_REPL_AUTO_INDENT (1)
|
2016-12-15 22:07:28 +00:00
|
|
|
#define MICROPY_KBD_EXCEPTION (1)
|
2016-07-22 18:18:17 +01:00
|
|
|
#define MICROPY_CPYTHON_COMPAT (0)
|
|
|
|
#define MICROPY_PY_ASYNC_AWAIT (0)
|
|
|
|
#define MICROPY_PY_ATTRTUPLE (0)
|
|
|
|
#define MICROPY_PY_BUILTINS_ENUMERATE (0)
|
|
|
|
#define MICROPY_PY_BUILTINS_FILTER (0)
|
|
|
|
#define MICROPY_PY_BUILTINS_MIN_MAX (0)
|
|
|
|
#define MICROPY_PY_BUILTINS_PROPERTY (0)
|
|
|
|
#define MICROPY_PY_BUILTINS_RANGE_ATTRS (0)
|
|
|
|
#define MICROPY_PY_BUILTINS_REVERSED (0)
|
|
|
|
#define MICROPY_PY_BUILTINS_SET (0)
|
2018-08-05 21:56:19 +01:00
|
|
|
#define MICROPY_PY_BUILTINS_STR_COUNT (0)
|
2021-04-25 13:30:19 +01:00
|
|
|
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
|
2017-01-21 23:31:02 +00:00
|
|
|
#define MICROPY_PY_BUILTINS_HELP (1)
|
|
|
|
#define MICROPY_PY_BUILTINS_HELP_TEXT zephyr_help_text
|
2016-07-22 18:18:17 +01:00
|
|
|
#define MICROPY_PY_ARRAY (0)
|
|
|
|
#define MICROPY_PY_COLLECTIONS (0)
|
|
|
|
#define MICROPY_PY_CMATH (0)
|
|
|
|
#define MICROPY_PY_IO (0)
|
2016-08-24 21:13:11 +01:00
|
|
|
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
|
zephyr: Initial implementation of machine.Pin.
The integration with Zephyr is fairly clean but as MicroPython Hardware API
requires pin ID to be a single value, but Zephyr operates GPIO in terms of
ports and pins, not just pins, a "hierarchical" ID is required, using tuple
of (port, pin). Port is a string, effectively a device name of a GPIO port,
per Zephyr conventions these are "GPIO_0", "GPIO_1", etc.; pin is integer
number of pin with the port (supposed to be in range 0-31).
Example of pin initialization:
pin = Pin(("GPIO_1", 21), Pin.OUT)
(an LED on FRDM-K64F's Port B, Pin 21).
There is support for in/out pins and pull up/pull down but currently
there is no interrupt support.
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2016-09-28 22:22:42 +01:00
|
|
|
#define MICROPY_PY_MACHINE (1)
|
2019-03-18 13:54:08 +00:00
|
|
|
#define MICROPY_PY_MACHINE_I2C (1)
|
2021-06-14 22:57:29 +01:00
|
|
|
#define MICROPY_PY_MACHINE_SPI (1)
|
|
|
|
#define MICROPY_PY_MACHINE_SPI_MSB (SPI_TRANSFER_MSB)
|
|
|
|
#define MICROPY_PY_MACHINE_SPI_LSB (SPI_TRANSFER_LSB)
|
2017-04-08 12:27:36 +01:00
|
|
|
#define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new
|
2016-10-28 19:38:52 +01:00
|
|
|
#define MICROPY_MODULE_WEAK_LINKS (1)
|
2016-07-22 18:18:17 +01:00
|
|
|
#define MICROPY_PY_STRUCT (0)
|
2017-03-30 22:06:31 +01:00
|
|
|
#ifdef CONFIG_NETWORKING
|
|
|
|
// If we have networking, we likely want errno comfort
|
|
|
|
#define MICROPY_PY_UERRNO (1)
|
|
|
|
#define MICROPY_PY_USOCKET (1)
|
|
|
|
#endif
|
2021-04-25 13:30:19 +01:00
|
|
|
#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
|
2017-05-08 17:28:38 +01:00
|
|
|
#define MICROPY_PY_UBINASCII (1)
|
|
|
|
#define MICROPY_PY_UHASHLIB (1)
|
2022-03-03 06:59:30 +00:00
|
|
|
#define MICROPY_PY_UOS_ZEPHYR (1)
|
2016-10-22 18:15:26 +01:00
|
|
|
#define MICROPY_PY_UTIME (1)
|
|
|
|
#define MICROPY_PY_UTIME_MP_HAL (1)
|
2017-03-08 07:53:10 +00:00
|
|
|
#define MICROPY_PY_ZEPHYR (1)
|
2018-01-16 14:29:54 +00:00
|
|
|
#define MICROPY_PY_ZSENSOR (1)
|
2016-07-22 18:18:17 +01:00
|
|
|
#define MICROPY_PY_SYS_MODULES (0)
|
|
|
|
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_LONGLONG)
|
|
|
|
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
|
|
|
|
#define MICROPY_PY_BUILTINS_COMPLEX (0)
|
2020-06-14 07:22:56 +01:00
|
|
|
#define MICROPY_ENABLE_SCHEDULER (1)
|
2019-12-19 21:52:33 +00:00
|
|
|
#define MICROPY_VFS (1)
|
|
|
|
#define MICROPY_READER_VFS (MICROPY_VFS)
|
2016-10-26 16:26:58 +01:00
|
|
|
|
2019-12-19 22:00:00 +00:00
|
|
|
// 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)
|
|
|
|
|
2016-11-04 15:56:04 +00:00
|
|
|
// Saving extra crumbs to make sure binary fits in 128K
|
|
|
|
#define MICROPY_COMP_CONST_FOLDING (0)
|
|
|
|
#define MICROPY_COMP_CONST (0)
|
|
|
|
#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (0)
|
|
|
|
|
2021-04-25 13:28:55 +01:00
|
|
|
void mp_hal_signal_event(void);
|
|
|
|
#define MICROPY_SCHED_HOOK_SCHEDULED mp_hal_signal_event()
|
|
|
|
|
2017-06-08 15:58:13 +01:00
|
|
|
#define MICROPY_PY_SYS_PLATFORM "zephyr"
|
|
|
|
|
2016-10-26 16:26:58 +01:00
|
|
|
#ifdef CONFIG_BOARD
|
|
|
|
#define MICROPY_HW_BOARD_NAME "zephyr-" CONFIG_BOARD
|
|
|
|
#else
|
2016-07-22 18:18:17 +01:00
|
|
|
#define MICROPY_HW_BOARD_NAME "zephyr-generic"
|
2016-10-26 16:26:58 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SOC
|
|
|
|
#define MICROPY_HW_MCU_NAME CONFIG_SOC
|
|
|
|
#else
|
2016-07-22 18:18:17 +01:00
|
|
|
#define MICROPY_HW_MCU_NAME "unknown-cpu"
|
2016-10-26 16:26:58 +01:00
|
|
|
#endif
|
|
|
|
|
2020-10-18 20:54:38 +01:00
|
|
|
#define MICROPY_MODULE_FROZEN_STR (0)
|
2016-07-22 18:18:17 +01:00
|
|
|
|
|
|
|
typedef int mp_int_t; // must be pointer size
|
|
|
|
typedef unsigned mp_uint_t; // must be pointer size
|
|
|
|
typedef long mp_off_t;
|
|
|
|
|
|
|
|
#define MP_STATE_PORT MP_STATE_VM
|
|
|
|
|
|
|
|
#define MICROPY_PORT_ROOT_POINTERS \
|
2020-06-14 07:22:56 +01:00
|
|
|
const char *readline_hist[8]; \
|
2021-04-25 13:30:19 +01:00
|
|
|
void *machine_pin_irq_list; /* Linked list of pin irq objects */ \
|
|
|
|
struct _mp_bluetooth_zephyr_root_pointers_t *bluetooth_zephyr_root_pointers;
|
2016-07-22 18:18:17 +01:00
|
|
|
|
2016-10-22 18:15:26 +01:00
|
|
|
extern const struct _mp_obj_module_t mp_module_time;
|
2019-12-19 21:52:33 +00:00
|
|
|
extern const struct _mp_obj_module_t mp_module_uos;
|
2017-03-30 22:06:31 +01:00
|
|
|
extern const struct _mp_obj_module_t mp_module_usocket;
|
2017-03-08 07:53:10 +00:00
|
|
|
extern const struct _mp_obj_module_t mp_module_zephyr;
|
2018-01-16 14:29:54 +00:00
|
|
|
extern const struct _mp_obj_module_t mp_module_zsensor;
|
2016-10-22 18:15:26 +01:00
|
|
|
|
2022-03-03 06:59:30 +00:00
|
|
|
#if MICROPY_PY_UOS_ZEPHYR
|
2019-12-19 21:52:33 +00:00
|
|
|
#define MICROPY_PY_UOS_DEF { MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_uos) },
|
|
|
|
#else
|
|
|
|
#define MICROPY_PY_UOS_DEF
|
|
|
|
#endif
|
|
|
|
|
2017-04-07 22:38:51 +01:00
|
|
|
#if MICROPY_PY_USOCKET
|
|
|
|
#define MICROPY_PY_USOCKET_DEF { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_usocket) },
|
|
|
|
#else
|
|
|
|
#define MICROPY_PY_USOCKET_DEF
|
|
|
|
#endif
|
|
|
|
|
2016-10-22 18:15:26 +01:00
|
|
|
#if MICROPY_PY_UTIME
|
|
|
|
#define MICROPY_PY_UTIME_DEF { MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_time) },
|
|
|
|
#else
|
|
|
|
#define MICROPY_PY_UTIME_DEF
|
|
|
|
#endif
|
|
|
|
|
2017-03-08 07:53:10 +00:00
|
|
|
#if MICROPY_PY_ZEPHYR
|
|
|
|
#define MICROPY_PY_ZEPHYR_DEF { MP_ROM_QSTR(MP_QSTR_zephyr), MP_ROM_PTR(&mp_module_zephyr) },
|
|
|
|
#else
|
|
|
|
#define MICROPY_PY_ZEPHYR_DEF
|
|
|
|
#endif
|
|
|
|
|
2018-01-16 14:29:54 +00:00
|
|
|
#if MICROPY_PY_ZSENSOR
|
|
|
|
#define MICROPY_PY_ZSENSOR_DEF { MP_ROM_QSTR(MP_QSTR_zsensor), MP_ROM_PTR(&mp_module_zsensor) },
|
|
|
|
#else
|
|
|
|
#define MICROPY_PY_ZSENSOR_DEF
|
|
|
|
#endif
|
|
|
|
|
2016-10-22 18:15:26 +01:00
|
|
|
#define MICROPY_PORT_BUILTIN_MODULES \
|
2019-12-19 21:52:33 +00:00
|
|
|
MICROPY_PY_UOS_DEF \
|
2017-04-07 22:38:51 +01:00
|
|
|
MICROPY_PY_USOCKET_DEF \
|
2016-10-22 18:15:26 +01:00
|
|
|
MICROPY_PY_UTIME_DEF \
|
2017-03-08 07:53:10 +00:00
|
|
|
MICROPY_PY_ZEPHYR_DEF \
|
2018-01-16 14:29:54 +00:00
|
|
|
MICROPY_PY_ZSENSOR_DEF \
|
2016-10-22 18:15:26 +01:00
|
|
|
|
2016-09-24 21:20:59 +01:00
|
|
|
// extra built in names to add to the global namespace
|
|
|
|
#define MICROPY_PORT_BUILTINS \
|
2019-12-19 21:52:33 +00:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },
|
2020-06-14 07:22:56 +01:00
|
|
|
|
|
|
|
#define MICROPY_BEGIN_ATOMIC_SECTION irq_lock
|
|
|
|
#define MICROPY_END_ATOMIC_SECTION irq_unlock
|