2014-01-06 08:20:11 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2017-06-30 08:22:17 +01:00
|
|
|
// options to control how MicroPython is built
|
2014-01-06 08:20:11 +00:00
|
|
|
|
2014-06-16 06:33:14 +01:00
|
|
|
#define MICROPY_ALLOC_PATH_MAX (128)
|
2014-01-06 08:20:11 +00:00
|
|
|
#define MICROPY_EMIT_THUMB (1)
|
|
|
|
#define MICROPY_EMIT_INLINE_THUMB (1)
|
2014-01-07 17:49:42 +00:00
|
|
|
#define MICROPY_ENABLE_GC (1)
|
2014-06-16 06:33:14 +01:00
|
|
|
#define MICROPY_ENABLE_FINALISER (1)
|
2015-01-09 00:10:55 +00:00
|
|
|
#define MICROPY_STACK_CHECK (1)
|
2014-05-21 20:32:59 +01:00
|
|
|
#define MICROPY_HELPER_REPL (1)
|
2019-12-25 07:27:38 +00:00
|
|
|
#define MICROPY_REPL_INFO (1)
|
2014-06-16 06:33:14 +01:00
|
|
|
#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)
|
|
|
|
|
2017-06-01 06:43:20 +01:00
|
|
|
#define MICROPY_PY_BUILTINS_INPUT (1)
|
2017-01-21 23:24:30 +00:00
|
|
|
#define MICROPY_PY_BUILTINS_HELP (1)
|
|
|
|
#define MICROPY_PY_BUILTINS_HELP_TEXT teensy_help_text
|
|
|
|
|
2014-06-16 06:33:14 +01:00
|
|
|
#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)
|
|
|
|
|
2014-08-20 21:21:11 +01:00
|
|
|
#define MICROPY_TIMER_REG (0)
|
|
|
|
#define MICROPY_REG (MICROPY_TIMER_REG)
|
|
|
|
|
|
|
|
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
|
|
|
|
#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0)
|
|
|
|
|
2014-06-16 06:33:14 +01:00
|
|
|
// extra built in names to add to the global namespace
|
|
|
|
#define MICROPY_PORT_BUILTINS \
|
|
|
|
|
|
|
|
// 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 \
|
2017-08-21 12:34:23 +01:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, \
|
2014-06-16 06:33:14 +01:00
|
|
|
|
|
|
|
// extra constants
|
|
|
|
#define MICROPY_PORT_CONSTANTS \
|
2017-08-21 12:34:23 +01:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, \
|
2014-01-06 08:20:11 +00:00
|
|
|
|
2015-01-07 23:38:50 +00:00
|
|
|
#define MP_STATE_PORT MP_STATE_VM
|
|
|
|
|
|
|
|
#define MICROPY_PORT_ROOT_POINTERS \
|
|
|
|
const char *readline_hist[8]; \
|
|
|
|
mp_obj_t pin_class_mapper; \
|
|
|
|
mp_obj_t pin_class_map_dict; \
|
|
|
|
struct _pyb_uart_obj_t *pyb_stdio_uart; \
|
|
|
|
|
2014-01-06 08:20:11 +00:00
|
|
|
// type definitions for the specific machine
|
|
|
|
|
2014-06-16 06:33:14 +01:00
|
|
|
#define UINT_FMT "%u"
|
|
|
|
#define INT_FMT "%d"
|
|
|
|
|
2014-07-03 13:25:24 +01:00
|
|
|
typedef int32_t mp_int_t; // must be pointer size
|
|
|
|
typedef unsigned int mp_uint_t; // must be pointer size
|
2014-11-16 22:16:14 +00:00
|
|
|
typedef long mp_off_t;
|
2014-01-06 08:20:11 +00:00
|
|
|
|
2015-04-09 23:56:15 +01:00
|
|
|
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
|
|
|
|
|
2014-08-25 13:24:33 +01:00
|
|
|
// We have inlined IRQ functions for efficiency (they are generally
|
|
|
|
// 1 machine instruction).
|
|
|
|
//
|
|
|
|
// Note on IRQ state: you should not need to know the specific
|
|
|
|
// value of the state variable, but rather just pass the return
|
|
|
|
// value from disable_irq back to enable_irq. If you really need
|
|
|
|
// to know the machine-specific values, see irq.h.
|
|
|
|
|
|
|
|
#ifndef __disable_irq
|
2020-02-27 04:36:53 +00:00
|
|
|
#define __disable_irq() __asm__ volatile ("CPSID i");
|
2014-08-25 13:24:33 +01:00
|
|
|
#endif
|
|
|
|
|
2020-03-26 13:35:04 +00:00
|
|
|
__attribute__((always_inline)) static inline uint32_t __get_PRIMASK(void) {
|
2014-08-25 13:24:33 +01:00
|
|
|
uint32_t result;
|
|
|
|
__asm volatile ("MRS %0, primask" : "=r" (result));
|
2020-02-27 04:36:53 +00:00
|
|
|
return result;
|
2014-08-25 13:24:33 +01:00
|
|
|
}
|
|
|
|
|
2020-03-26 13:35:04 +00:00
|
|
|
__attribute__((always_inline)) static inline void __set_PRIMASK(uint32_t priMask) {
|
2014-08-25 13:24:33 +01:00
|
|
|
__asm volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
|
|
|
|
}
|
|
|
|
|
2020-03-26 13:35:04 +00:00
|
|
|
__attribute__((always_inline)) static inline void enable_irq(mp_uint_t state) {
|
2014-08-25 13:24:33 +01:00
|
|
|
__set_PRIMASK(state);
|
|
|
|
}
|
|
|
|
|
2020-03-26 13:35:04 +00:00
|
|
|
__attribute__((always_inline)) static inline mp_uint_t disable_irq(void) {
|
2014-08-25 13:24:33 +01:00
|
|
|
mp_uint_t state = __get_PRIMASK();
|
|
|
|
__disable_irq();
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
|
|
|
|
#define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state)
|
2014-08-24 20:21:12 +01:00
|
|
|
|
2014-06-16 06:33:14 +01:00
|
|
|
// 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"
|
2014-07-15 06:19:27 +01:00
|
|
|
#define MICROPY_HW_MCU_NAME "MK20DX256"
|
2014-06-16 06:33:14 +01:00
|
|
|
|
|
|
|
#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)
|
|
|
|
|
2015-10-30 23:03:58 +00:00
|
|
|
#define MICROPY_MPHALPORT_H "teensy_hal.h"
|
2014-07-02 13:42:37 +01:00
|
|
|
#define MICROPY_PIN_DEFS_PORT_H "pin_defs_teensy.h"
|