mpconfigport.h 4.38 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * This file is part of the Micro Python project, http://micropython.org/
 *
 * The MIT License (MIT)
 *
 * Copyright (c) 2013, 2014 Damien P. George
 *
 * 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.
 */

27
28
// options to control how Micro Python is built

29
#define MICROPY_ALLOC_PATH_MAX      (128)
30
31
32
#define MICROPY_EMIT_THUMB          (1)
#define MICROPY_EMIT_INLINE_THUMB   (1)
#define MICROPY_ENABLE_GC           (1)
33
#define MICROPY_ENABLE_FINALISER    (1)
34
#define MICROPY_HELPER_REPL         (1)
35
#define MICROPY_ENABLE_SOURCE_LINE  (1)
36
37
#define MICROPY_LONGINT_IMPL        (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_FLOAT_IMPL          (MICROPY_FLOAT_IMPL_FLOAT)
38
#define MICROPY_OPT_COMPUTED_GOTO   (1)
39
40
41
42
43
44
/* Enable FatFS LFNs
    0: Disable LFN feature.
    1: Enable LFN with static working buffer on the BSS. Always NOT reentrant.
    2: Enable LFN with dynamic working buffer on the STACK.
    3: Enable LFN with dynamic working buffer on the HEAP.
*/
45
46
#define MICROPY_ENABLE_LFN          (1)
#define MICROPY_LFN_CODE_PAGE       (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
47
#define MICROPY_PY_BUILTINS_STR_UNICODE (0)
48
#define MICROPY_PY_BUILTINS_FROZENSET (1)
49
50
51
#define MICROPY_PY_SYS_EXIT         (1)
#define MICROPY_PY_SYS_STDFILES     (1)
#define MICROPY_PY_CMATH            (1)
52
53
#define MICROPY_PY_IO               (1)
#define MICROPY_PY_IO_FILEIO        (1)
54
55

// extra built in names to add to the global namespace
Damien George's avatar
Damien George committed
56
extern const struct _mp_obj_fun_native_t mp_builtin_help_obj;
57
extern const struct _mp_obj_fun_native_t mp_builtin_input_obj;
58
extern const struct _mp_obj_fun_native_t mp_builtin_open_obj;
59
#define MICROPY_PORT_BUILTINS \
60
61
62
    { MP_OBJ_NEW_QSTR(MP_QSTR_help), (mp_obj_t)&mp_builtin_help_obj }, \
    { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
    { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
63

64
65
66
// extra built in modules to add to the list of known ones
extern const struct _mp_obj_module_t os_module;
extern const struct _mp_obj_module_t pyb_module;
67
extern const struct _mp_obj_module_t stm_module;
68
extern const struct _mp_obj_module_t time_module;
69
#define MICROPY_PORT_BUILTIN_MODULES \
70
71
    { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, \
    { MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \
72
    { MP_OBJ_NEW_QSTR(MP_QSTR_stm), (mp_obj_t)&stm_module }, \
73
    { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \
74

75
// extra constants
76
#define MICROPY_PORT_CONSTANTS \
77
78
79
    { MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \
    { MP_OBJ_NEW_QSTR(MP_QSTR_stm), (mp_obj_t)&stm_module }, \

80
81
82
83
// type definitions for the specific machine

#define BYTES_PER_WORD (4)

84
85
#define UINT_FMT "%u"
#define INT_FMT "%d"
86

87
88
typedef int machine_int_t; // must be pointer size
typedef unsigned int machine_uint_t; // must be pointer size
89
90
91
92
93
94
95
96
97
98
99
typedef void *machine_ptr_t; // must be of pointer size
typedef const void *machine_const_ptr_t; // must be of pointer size

// There is no classical C heap in bare-metal ports, only Python
// garbage-collected heap. For completeness, emulate C heap via
// GC heap. Note that MicroPython core never uses malloc() and friends,
// so these defines are mostly to help extension module writers.
#define malloc gc_alloc
#define free gc_free
#define realloc gc_realloc

100
101
#define USE_DEVICE_MODE
//#define USE_HOST_MODE
102

103
// board specific definitions
104
#include "mpconfigboard.h"
105
106
107

// We need to provide a declaration/definition of alloca()
#include <alloca.h>