2016-10-12 15:51:17 -04: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 13:18:17 -04:00
|
|
|
#include <alloca.h>
|
|
|
|
|
2016-10-12 12:42:55 -04:00
|
|
|
// Include Zephyr's autoconf.h, which should be made first by Zephyr makefiles
|
|
|
|
#include "autoconf.h"
|
|
|
|
|
2016-07-22 13:18:17 -04: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)
|
|
|
|
|
2016-08-24 16:13:11 -04:00
|
|
|
#define MICROPY_STACK_CHECK (1)
|
2016-07-22 13:18:17 -04:00
|
|
|
#define MICROPY_ENABLE_GC (1)
|
|
|
|
#define MICROPY_HELPER_REPL (1)
|
|
|
|
#define MICROPY_REPL_AUTO_INDENT (1)
|
|
|
|
#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)
|
|
|
|
#define MICROPY_PY_BUILTINS_SLICE (0)
|
|
|
|
#define MICROPY_PY_ARRAY (0)
|
|
|
|
#define MICROPY_PY_COLLECTIONS (0)
|
|
|
|
#define MICROPY_PY_CMATH (0)
|
|
|
|
#define MICROPY_PY_IO (0)
|
2016-08-24 16:13:11 -04: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 17:22:42 -04:00
|
|
|
#define MICROPY_PY_MACHINE (1)
|
2016-10-28 14:38:52 -04:00
|
|
|
#define MICROPY_MODULE_WEAK_LINKS (1)
|
2016-07-22 13:18:17 -04:00
|
|
|
#define MICROPY_PY_STRUCT (0)
|
2016-10-22 13:15:26 -04:00
|
|
|
#define MICROPY_PY_UTIME (1)
|
|
|
|
#define MICROPY_PY_UTIME_MP_HAL (1)
|
2016-07-22 13:18:17 -04: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)
|
2016-10-26 11:26:58 -04:00
|
|
|
|
|
|
|
#ifdef CONFIG_BOARD
|
|
|
|
#define MICROPY_HW_BOARD_NAME "zephyr-" CONFIG_BOARD
|
|
|
|
#else
|
2016-07-22 13:18:17 -04:00
|
|
|
#define MICROPY_HW_BOARD_NAME "zephyr-generic"
|
2016-10-26 11:26:58 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SOC
|
|
|
|
#define MICROPY_HW_MCU_NAME CONFIG_SOC
|
|
|
|
#else
|
2016-07-22 13:18:17 -04:00
|
|
|
#define MICROPY_HW_MCU_NAME "unknown-cpu"
|
2016-10-26 11:26:58 -04:00
|
|
|
#endif
|
|
|
|
|
2016-09-17 14:15:58 -04:00
|
|
|
#define MICROPY_MODULE_FROZEN_STR (1)
|
2016-07-22 13:18:17 -04:00
|
|
|
|
|
|
|
typedef int mp_int_t; // must be pointer size
|
|
|
|
typedef unsigned mp_uint_t; // must be pointer size
|
|
|
|
|
|
|
|
typedef void *machine_ptr_t; // must be of pointer size
|
|
|
|
typedef const void *machine_const_ptr_t; // must be of pointer size
|
|
|
|
typedef long mp_off_t;
|
|
|
|
|
|
|
|
#define BYTES_PER_WORD (sizeof(mp_int_t))
|
|
|
|
|
|
|
|
#define MP_STATE_PORT MP_STATE_VM
|
|
|
|
|
|
|
|
#define MICROPY_PORT_ROOT_POINTERS \
|
2016-09-29 13:24:56 -04:00
|
|
|
mp_obj_t mp_kbd_exception; \
|
2016-07-22 13:18:17 -04:00
|
|
|
const char *readline_hist[8];
|
|
|
|
|
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 17:22:42 -04:00
|
|
|
extern const struct _mp_obj_module_t mp_module_machine;
|
2016-10-22 13:15:26 -04:00
|
|
|
extern const struct _mp_obj_module_t mp_module_time;
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
#define MICROPY_PORT_BUILTIN_MODULES \
|
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 17:22:42 -04:00
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_machine), (mp_obj_t)&mp_module_machine }, \
|
2016-10-22 13:15:26 -04:00
|
|
|
MICROPY_PY_UTIME_DEF \
|
|
|
|
|
2016-10-28 14:38:52 -04:00
|
|
|
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), MP_ROM_PTR(&mp_module_time) }, \
|
|
|
|
|
2016-09-24 16:20:59 -04:00
|
|
|
// extra built in names to add to the global namespace
|
|
|
|
#define MICROPY_PORT_BUILTINS \
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_help), (mp_obj_t)&mp_builtin_help_obj }, \
|
|
|
|
|