summaryrefslogtreecommitdiffstatshomepage
path: root/teensy/mpconfigport.h
diff options
context:
space:
mode:
authorDave Hylands <dhylands@gmail.com>2014-06-15 22:33:14 -0700
committerDave Hylands <dhylands@gmail.com>2014-06-15 22:48:05 -0700
commit4f1b7fec9f103c92de40875e9a06b7decc4923f4 (patch)
treed9e0f1b0e7dd290a728c065960500ecf30967997 /teensy/mpconfigport.h
parent2547928148aefcf163953057979e14f46bef1170 (diff)
downloadmicropython-4f1b7fec9f103c92de40875e9a06b7decc4923f4.tar.gz
micropython-4f1b7fec9f103c92de40875e9a06b7decc4923f4.zip
Updated teensy to build.
Refactored some stmhal files which are shared with teensy.
Diffstat (limited to 'teensy/mpconfigport.h')
-rw-r--r--teensy/mpconfigport.h88
1 files changed, 85 insertions, 3 deletions
diff --git a/teensy/mpconfigport.h b/teensy/mpconfigport.h
index f7c66d8874..417335cfcb 100644
--- a/teensy/mpconfigport.h
+++ b/teensy/mpconfigport.h
@@ -2,20 +2,102 @@
// options to control how Micro Python is built
+#define MICROPY_ALLOC_PATH_MAX (128)
#define MICROPY_EMIT_THUMB (1)
#define MICROPY_EMIT_INLINE_THUMB (1)
#define MICROPY_ENABLE_GC (1)
+#define MICROPY_ENABLE_FINALISER (1)
#define MICROPY_HELPER_REPL (1)
#define MICROPY_PY_BUILTINS_FLOAT (1)
+#define MICROPY_ENABLE_SOURCE_LINE (1)
+#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
+#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
+#define MICROPY_OPT_COMPUTED_GOTO (1)
+
+#define MICROPY_PY_IO (0)
+#define MICROPY_PY_FROZENSET (1)
+#define MICROPY_PY_SYS_EXIT (1)
+#define MICROPY_PY_SYS_STDFILES (1)
+#define MICROPY_PY_CMATH (1)
+
+// extra built in names to add to the global namespace
+extern const struct _mp_obj_fun_native_t mp_builtin_help_obj;
+extern const struct _mp_obj_fun_native_t mp_builtin_input_obj;
+extern const struct _mp_obj_fun_native_t mp_builtin_open_obj;
+#define MICROPY_PORT_BUILTINS \
+ { 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 }, \
+
+// 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;
+extern const struct _mp_obj_module_t time_module;
+#define MICROPY_PORT_BUILTIN_MODULES \
+ { MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \
+
+// extra constants
+#define MICROPY_PORT_CONSTANTS \
+ { MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \
// type definitions for the specific machine
#define BYTES_PER_WORD (4)
+#define UINT_FMT "%u"
+#define INT_FMT "%d"
+
typedef int32_t machine_int_t; // must be pointer size
-typedef uint32_t machine_uint_t; // must be pointer size
+typedef unsigned int machine_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 float machine_float_t;
-machine_float_t machine_sqrt(machine_float_t x);
+// 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
+
+// We need to provide a declaration/definition of alloca()
+#include <alloca.h>
+
+// The following would be from a board specific file, if one existed
+
+#define MICROPY_HW_BOARD_NAME "Teensy-3.1"
+
+#define MICROPY_HW_HAS_SWITCH (0)
+#define MICROPY_HW_HAS_SDCARD (0)
+#define MICROPY_HW_HAS_MMA7660 (0)
+#define MICROPY_HW_HAS_LIS3DSH (0)
+#define MICROPY_HW_HAS_LCD (0)
+#define MICROPY_HW_ENABLE_RNG (0)
+#define MICROPY_HW_ENABLE_RTC (0)
+#define MICROPY_HW_ENABLE_TIMER (0)
+#define MICROPY_HW_ENABLE_SERVO (0)
+#define MICROPY_HW_ENABLE_DAC (0)
+#define MICROPY_HW_ENABLE_I2C1 (0)
+#define MICROPY_HW_ENABLE_SPI1 (0)
+#define MICROPY_HW_ENABLE_SPI3 (0)
+#define MICROPY_HW_ENABLE_CC3K (0)
+
+#define MICROPY_HW_LED1 (pin_C5)
+#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
+#define MICROPY_HW_LED_ON(pin) (pin->gpio->PSOR = pin->pin_mask)
+#define MICROPY_HW_LED_OFF(pin) (pin->gpio->PCOR = pin->pin_mask)
+
+#if 0
+// SD card detect switch
+#define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)
+#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
+#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
+#endif
+
+#define MICROPY_MATH_SQRT_ASM (1)
+
+#define HAL_H "teensy_hal.h"
+#define PIN_DEFS_PORT_H "pin_defs_teensy.h"
+
+#define GPIO_read_pin(gpio, pin) (((gpio)->PDIR >> (pin)) & 1)
+#define GPIO_set_pin(gpio, pin_mask) (((gpio)->PSOR) = (pin_mask))
+#define GPIO_clear_pin(gpio, pin_mask) (((gpio)->PCOR) = (pin_mask))