| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- /*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2017 Armink (armink.ztl@gmail.com)
- *
- * 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 <rtthread.h>
- #include <stdint.h>
- #include <libc/libc_errno.h>
- // options to control how MicroPython is built
- // You can disable the built-in MicroPython compiler by setting the following
- // config option to 0. If you do this then you won't get a REPL prompt, but you
- // will still be able to execute pre-compiled scripts, compiled with mpy-cross.
- #define MICROPY_ENABLE_COMPILER (1)
- #if defined(PKG_MICROPYTHON_HEAP_SIZE)
- #define MICROPY_HEAP_SIZE PKG_MICROPYTHON_HEAP_SIZE
- #else
- #define MICROPY_HEAP_SIZE (8 * 1024)
- #endif
- #define MICROPY_STACK_CHECK (1)
- #define MICROPY_QSTR_BYTES_IN_HASH (1)
- #define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool
- #define MICROPY_ALLOC_PATH_MAX (256)
- #define MICROPY_ALLOC_PARSE_CHUNK_INIT (16)
- #define MICROPY_EMIT_X64 (0)
- #define MICROPY_EMIT_THUMB (0)
- #define MICROPY_EMIT_INLINE_THUMB (0)
- #define MICROPY_COMP_MODULE_CONST (0)
- #define MICROPY_COMP_CONST (0)
- #define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (0)
- #define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
- #define MICROPY_MEM_STATS (0)
- #define MICROPY_DEBUG_PRINTERS (0)
- #define MICROPY_ENABLE_GC (1)
- #define MICROPY_ENABLE_FINALISER (1)
- #define MICROPY_GC_ALLOC_THRESHOLD (0)
- #define MICROPY_REPL_EVENT_DRIVEN (0)
- #define MICROPY_REPL_AUTO_INDENT (1)
- #define MICROPY_KBD_EXCEPTION (1)
- #define MICROPY_HELPER_REPL (1)
- #define MICROPY_HELPER_LEXER_UNIX (0)
- #define MICROPY_ENABLE_SOURCE_LINE (0)
- #define MICROPY_ENABLE_DOC_STRING (0)
- #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
- #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (0)
- #define MICROPY_PY_ASYNC_AWAIT (0)
- // control over Python builtins
- #define MICROPY_PY_FUNCTION_ATTRS (1)
- #define MICROPY_PY_BUILTINS_STR_UNICODE (1)
- #define MICROPY_PY_BUILTINS_STR_CENTER (1)
- #define MICROPY_PY_BUILTINS_STR_PARTITION (1)
- #define MICROPY_PY_BUILTINS_STR_SPLITLINES (1)
- #define MICROPY_PY_BUILTINS_BYTEARRAY (1)
- #define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
- #define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
- #define MICROPY_PY_ALL_SPECIAL_METHODS (1)
- #define MICROPY_PY_BUILTINS_COMPILE (1)
- #define MICROPY_PY_BUILTINS_EXECFILE (1)
- #define MICROPY_PY_BUILTINS_INPUT (1)
- #define MICROPY_PY_BUILTINS_POW3 (1)
- #define MICROPY_PY_BUILTINS_ENUMERATE (1)
- #define MICROPY_PY_BUILTINS_FILTER (1)
- #define MICROPY_PY_BUILTINS_FROZENSET (1)
- #define MICROPY_PY_BUILTINS_REVERSED (1)
- #define MICROPY_PY_BUILTINS_SET (1)
- #define MICROPY_PY_BUILTINS_HELP (1)
- #define MICROPY_PY_BUILTINS_HELP_TEXT rtthread_help_text
- #define MICROPY_PY_BUILTINS_HELP_MODULES (1)
- #define MICROPY_PY_BUILTINS_SLICE (1)
- #define MICROPY_PY_BUILTINS_PROPERTY (1)
- #define MICROPY_PY_BUILTINS_MIN_MAX (1)
- #define MICROPY_PY___FILE__ (1)
- #define MICROPY_PY_GC (1)
- #define MICROPY_PY_ARRAY (1)
- #define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)
- #define MICROPY_PY_ATTRTUPLE (1)
- #define MICROPY_PY_COLLECTIONS (1)
- #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1)
- #define MICROPY_PY_MATH (1)
- #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (1)
- #define MICROPY_PY_CMATH (1)
- #define MICROPY_PY_IO (1)
- #define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
- #define MICROPY_STREAMS_NON_BLOCK (1)
- #define MICROPY_MODULE_WEAK_LINKS (1)
- #define MICROPY_CAN_OVERRIDE_BUILTINS (1)
- #define MICROPY_USE_INTERNAL_ERRNO (1)
- #define MICROPY_PY_STRUCT (0)
- #define MICROPY_PY_RTTHREAD (1)
- #define MICROPY_PY_SYS (0)
- #define MICROPY_MODULE_FROZEN_MPY (1)
- #define MICROPY_CPYTHON_COMPAT (0)
- #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
- #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
- // extended modules
- #define MICROPY_PY_UCTYPES (1)
- #define MICROPY_PY_UZLIB (0)
- #define MICROPY_PY_UJSON (1)
- #define MICROPY_PY_URE (0)
- #define MICROPY_PY_UHEAPQ (1)
- #define MICROPY_PY_UHASHLIB (0)
- #define MICROPY_PY_UBINASCII (1)
- #define MICROPY_PY_UTIME (1)
- #define MICROPY_PY_UTIME_MP_HAL (1)
- #define MICROPY_PY_UTIMEQ (1)
- #define MICROPY_PY_URANDOM (1)
- #define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
- #define MICROPY_PY_MACHINE (1)
- #define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new
- #if defined(__CC_ARM)
- //TODO
- #elif defined(__ICCARM__)
- //#include <sys/types.h>
- #define MICROPY_NO_ALLOCA 1
- #define NORETURN __noreturn
- #define MP_WEAK __weak
- #define MP_NOINLINE
- #define MP_ALWAYSINLINE
- #define MP_LIKELY(x) x
- #define MP_UNLIKELY(x) x
- #elif defined(__GNUC__)
- // We need to provide a declaration/definition of alloca()
- #include <alloca.h>
- #else
- #error "not supported compiler"
- #endif /* defined(__CC_ARM) */
- // type definitions for the specific machine
- #define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))
- // This port is intended to be 32-bit, but unfortunately, int32_t for
- // different targets may be defined in different ways - either as int
- // or as long. This requires different printf formatting specifiers
- // to print such value. So, we avoid int32_t and use int directly.
- #define UINT_FMT "%u"
- #define INT_FMT "%d"
- 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_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
- // 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) },
- #define MICROPY_HW_BOARD_NAME "RT-Thread Board"
- #define MICROPY_HW_MCU_NAME "stm32f4"
- #ifdef __linux__
- #define MICROPY_MIN_USE_STDOUT (1)
- #endif
- #ifdef __thumb__
- #define MICROPY_MIN_USE_CORTEX_CPU (1)
- #define MICROPY_MIN_USE_STM32_MCU (1)
- #endif
- #define MP_STATE_PORT MP_STATE_VM
- #define MICROPY_PORT_ROOT_POINTERS const char *readline_hist[8];
- extern const struct _mp_obj_module_t pyb_module;
- extern const struct _mp_obj_module_t mp_module_rtthread;
- extern const struct _mp_obj_module_t mp_module_time;
- extern const struct _mp_obj_module_t mp_module_machine;
- #if MICROPY_PY_RTTHREAD
- #define MICROPY_PY_RTTHREAD_DEF { MP_ROM_QSTR(MP_QSTR_rtthread), MP_ROM_PTR(&mp_module_rtthread) },
- #else
- #define MICROPY_PY_RTTHREAD_DEF
- #endif
- #define MICROPY_PORT_BUILTIN_MODULES \
- { MP_ROM_QSTR(MP_QSTR_machine), MP_ROM_PTR(&mp_module_machine) }, \
- { MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, \
- MICROPY_PY_RTTHREAD_DEF \
- #define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
- { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&mp_module_time) }, \
- #define MP_RTT_NOT_IMPL_PRINT rt_kprintf("Not implement on %s:%ld, Please add for your board!\n", __FILE__, __FUNCTION__)
|