Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the Micro Python project, http://micropython.org/ |
| 3 | * |
| 4 | * The MIT License (MIT) |
| 5 | * |
| 6 | * Copyright (c) 2013, 2014 Damien P. George |
| 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | * of this software and associated documentation files (the "Software"), to deal |
| 10 | * in the Software without restriction, including without limitation the rights |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | * copies of the Software, and to permit persons to whom the Software is |
| 13 | * furnished to do so, subject to the following conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice shall be included in |
| 16 | * all copies or substantial portions of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | * THE SOFTWARE. |
| 25 | */ |
| 26 | |
Dave Hylands | f14b92b | 2014-03-12 18:06:26 -0700 | [diff] [blame] | 27 | // options to control how Micro Python is built |
| 28 | |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 29 | #define MICROPY_ALLOC_PATH_MAX (128) |
Dave Hylands | f14b92b | 2014-03-12 18:06:26 -0700 | [diff] [blame] | 30 | #define MICROPY_EMIT_THUMB (1) |
| 31 | #define MICROPY_EMIT_INLINE_THUMB (1) |
| 32 | #define MICROPY_ENABLE_GC (1) |
Damien George | 12bab72 | 2014-04-05 20:35:48 +0100 | [diff] [blame] | 33 | #define MICROPY_ENABLE_FINALISER (1) |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 34 | #define MICROPY_HELPER_REPL (1) |
Damien George | 73496fb | 2014-04-13 14:51:56 +0100 | [diff] [blame] | 35 | #define MICROPY_ENABLE_SOURCE_LINE (1) |
Damien George | f92a0d4 | 2014-05-11 17:27:31 +0100 | [diff] [blame] | 36 | #define MICROPY_ENABLE_FROZENSET (1) |
Dave Hylands | f14b92b | 2014-03-12 18:06:26 -0700 | [diff] [blame] | 37 | #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) |
| 38 | #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 39 | #define MICROPY_OPT_COMPUTED_GOTO (1) |
Dave Hylands | f14b92b | 2014-03-12 18:06:26 -0700 | [diff] [blame] | 40 | /* Enable FatFS LFNs |
| 41 | 0: Disable LFN feature. |
| 42 | 1: Enable LFN with static working buffer on the BSS. Always NOT reentrant. |
| 43 | 2: Enable LFN with dynamic working buffer on the STACK. |
| 44 | 3: Enable LFN with dynamic working buffer on the HEAP. |
| 45 | */ |
Damien George | b92d3e1 | 2014-03-17 14:04:19 +0000 | [diff] [blame] | 46 | #define MICROPY_ENABLE_LFN (1) |
| 47 | #define MICROPY_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */ |
Damien George | 89755ae | 2014-05-11 17:35:43 +0100 | [diff] [blame] | 48 | #define MICROPY_MOD_SYS_EXIT (1) |
Damien George | 86a0304 | 2014-04-13 19:00:56 +0100 | [diff] [blame] | 49 | #define MICROPY_MOD_SYS_STDFILES (1) |
Damien George | 93e51b5 | 2014-05-03 18:40:50 +0100 | [diff] [blame] | 50 | #define MICROPY_ENABLE_MOD_CMATH (1) |
Damien George | b92d3e1 | 2014-03-17 14:04:19 +0000 | [diff] [blame] | 51 | |
| 52 | // extra built in names to add to the global namespace |
Damien George | 5fd2ebb | 2014-03-24 11:27:56 +0000 | [diff] [blame] | 53 | extern const struct _mp_obj_fun_native_t mp_builtin_help_obj; |
Damien George | 02fa035 | 2014-03-22 23:53:50 +0000 | [diff] [blame] | 54 | extern const struct _mp_obj_fun_native_t mp_builtin_input_obj; |
Damien George | b92d3e1 | 2014-03-17 14:04:19 +0000 | [diff] [blame] | 55 | extern const struct _mp_obj_fun_native_t mp_builtin_open_obj; |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 56 | #define MICROPY_PORT_BUILTINS \ |
Damien George | 7efc5b3 | 2014-04-05 22:36:42 +0100 | [diff] [blame] | 57 | { MP_OBJ_NEW_QSTR(MP_QSTR_help), (mp_obj_t)&mp_builtin_help_obj }, \ |
| 58 | { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \ |
| 59 | { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, |
Dave Hylands | f14b92b | 2014-03-12 18:06:26 -0700 | [diff] [blame] | 60 | |
Damien George | caac542 | 2014-03-25 14:18:18 +0000 | [diff] [blame] | 61 | // extra built in modules to add to the list of known ones |
| 62 | extern const struct _mp_obj_module_t os_module; |
| 63 | extern const struct _mp_obj_module_t pyb_module; |
Damien George | 3f48984 | 2014-04-10 22:46:40 +0100 | [diff] [blame] | 64 | extern const struct _mp_obj_module_t stm_module; |
Damien George | caac542 | 2014-03-25 14:18:18 +0000 | [diff] [blame] | 65 | extern const struct _mp_obj_module_t time_module; |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 66 | #define MICROPY_PORT_BUILTIN_MODULES \ |
Damien George | 7efc5b3 | 2014-04-05 22:36:42 +0100 | [diff] [blame] | 67 | { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, \ |
| 68 | { MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \ |
Damien George | 3f48984 | 2014-04-10 22:46:40 +0100 | [diff] [blame] | 69 | { MP_OBJ_NEW_QSTR(MP_QSTR_stm), (mp_obj_t)&stm_module }, \ |
Damien George | 7efc5b3 | 2014-04-05 22:36:42 +0100 | [diff] [blame] | 70 | { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \ |
Damien George | caac542 | 2014-03-25 14:18:18 +0000 | [diff] [blame] | 71 | |
Damien George | 3f48984 | 2014-04-10 22:46:40 +0100 | [diff] [blame] | 72 | // extra constants |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 73 | #define MICROPY_PORT_CONSTANTS \ |
Damien George | 3f48984 | 2014-04-10 22:46:40 +0100 | [diff] [blame] | 74 | { MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \ |
| 75 | { MP_OBJ_NEW_QSTR(MP_QSTR_stm), (mp_obj_t)&stm_module }, \ |
| 76 | |
Dave Hylands | f14b92b | 2014-03-12 18:06:26 -0700 | [diff] [blame] | 77 | // type definitions for the specific machine |
| 78 | |
| 79 | #define BYTES_PER_WORD (4) |
| 80 | |
Damien George | 5874c1c | 2014-05-03 13:24:21 +0100 | [diff] [blame] | 81 | #define UINT_FMT "%u" |
| 82 | #define INT_FMT "%d" |
Dave Hylands | f14b92b | 2014-03-12 18:06:26 -0700 | [diff] [blame] | 83 | |
Damien George | 5874c1c | 2014-05-03 13:24:21 +0100 | [diff] [blame] | 84 | typedef int machine_int_t; // must be pointer size |
| 85 | typedef unsigned int machine_uint_t; // must be pointer size |
Dave Hylands | f14b92b | 2014-03-12 18:06:26 -0700 | [diff] [blame] | 86 | typedef void *machine_ptr_t; // must be of pointer size |
| 87 | typedef const void *machine_const_ptr_t; // must be of pointer size |
| 88 | |
| 89 | // There is no classical C heap in bare-metal ports, only Python |
| 90 | // garbage-collected heap. For completeness, emulate C heap via |
| 91 | // GC heap. Note that MicroPython core never uses malloc() and friends, |
| 92 | // so these defines are mostly to help extension module writers. |
| 93 | #define malloc gc_alloc |
| 94 | #define free gc_free |
| 95 | #define realloc gc_realloc |
| 96 | |
Dave Hylands | 0a64c92 | 2014-03-14 00:51:26 -0700 | [diff] [blame] | 97 | #define USE_DEVICE_MODE |
| 98 | //#define USE_HOST_MODE |
| 99 | |
| 100 | // board specific definitions |
| 101 | #include "mpconfigboard.h" |