mpconfigport.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #include <stdint.h>
  2. // options to control how MicroPython is built
  3. #define MICROPY_ALLOC_PATH_MAX (128)
  4. #define MICROPY_EMIT_THUMB (1)
  5. #define MICROPY_EMIT_INLINE_THUMB (1)
  6. #define MICROPY_ENABLE_GC (1)
  7. #define MICROPY_ENABLE_FINALISER (1)
  8. #define MICROPY_STACK_CHECK (1)
  9. #define MICROPY_HELPER_REPL (1)
  10. #define MICROPY_ENABLE_SOURCE_LINE (1)
  11. #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
  12. #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
  13. #define MICROPY_OPT_COMPUTED_GOTO (1)
  14. #define MICROPY_PY_BUILTINS_INPUT (1)
  15. #define MICROPY_PY_BUILTINS_HELP (1)
  16. #define MICROPY_PY_BUILTINS_HELP_TEXT teensy_help_text
  17. #define MICROPY_PY_IO (0)
  18. #define MICROPY_PY_FROZENSET (1)
  19. #define MICROPY_PY_SYS_EXIT (1)
  20. #define MICROPY_PY_SYS_STDFILES (1)
  21. #define MICROPY_PY_CMATH (1)
  22. #define MICROPY_TIMER_REG (0)
  23. #define MICROPY_REG (MICROPY_TIMER_REG)
  24. #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
  25. #define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0)
  26. // extra built in names to add to the global namespace
  27. #define MICROPY_PORT_BUILTINS \
  28. // extra built in modules to add to the list of known ones
  29. extern const struct _mp_obj_module_t os_module;
  30. extern const struct _mp_obj_module_t pyb_module;
  31. extern const struct _mp_obj_module_t time_module;
  32. #define MICROPY_PORT_BUILTIN_MODULES \
  33. { MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, \
  34. // extra constants
  35. #define MICROPY_PORT_CONSTANTS \
  36. { MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, \
  37. #define MP_STATE_PORT MP_STATE_VM
  38. #define MICROPY_PORT_ROOT_POINTERS \
  39. const char *readline_hist[8]; \
  40. mp_obj_t pin_class_mapper; \
  41. mp_obj_t pin_class_map_dict; \
  42. struct _pyb_uart_obj_t *pyb_stdio_uart; \
  43. // type definitions for the specific machine
  44. #define UINT_FMT "%u"
  45. #define INT_FMT "%d"
  46. typedef int32_t mp_int_t; // must be pointer size
  47. typedef unsigned int mp_uint_t; // must be pointer size
  48. typedef long mp_off_t;
  49. #define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
  50. // We have inlined IRQ functions for efficiency (they are generally
  51. // 1 machine instruction).
  52. //
  53. // Note on IRQ state: you should not need to know the specific
  54. // value of the state variable, but rather just pass the return
  55. // value from disable_irq back to enable_irq. If you really need
  56. // to know the machine-specific values, see irq.h.
  57. #ifndef __disable_irq
  58. #define __disable_irq() __asm__ volatile("CPSID i");
  59. #endif
  60. __attribute__(( always_inline )) static inline uint32_t __get_PRIMASK(void) {
  61. uint32_t result;
  62. __asm volatile ("MRS %0, primask" : "=r" (result));
  63. return(result);
  64. }
  65. __attribute__(( always_inline )) static inline void __set_PRIMASK(uint32_t priMask) {
  66. __asm volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
  67. }
  68. __attribute__(( always_inline )) static inline void enable_irq(mp_uint_t state) {
  69. __set_PRIMASK(state);
  70. }
  71. __attribute__(( always_inline )) static inline mp_uint_t disable_irq(void) {
  72. mp_uint_t state = __get_PRIMASK();
  73. __disable_irq();
  74. return state;
  75. }
  76. #define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
  77. #define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state)
  78. // We need to provide a declaration/definition of alloca()
  79. #include <alloca.h>
  80. // The following would be from a board specific file, if one existed
  81. #define MICROPY_HW_BOARD_NAME "Teensy-3.1"
  82. #define MICROPY_HW_MCU_NAME "MK20DX256"
  83. #define MICROPY_HW_HAS_SWITCH (0)
  84. #define MICROPY_HW_HAS_SDCARD (0)
  85. #define MICROPY_HW_HAS_MMA7660 (0)
  86. #define MICROPY_HW_HAS_LIS3DSH (0)
  87. #define MICROPY_HW_HAS_LCD (0)
  88. #define MICROPY_HW_ENABLE_RNG (0)
  89. #define MICROPY_HW_ENABLE_RTC (0)
  90. #define MICROPY_HW_ENABLE_TIMER (0)
  91. #define MICROPY_HW_ENABLE_SERVO (0)
  92. #define MICROPY_HW_ENABLE_DAC (0)
  93. #define MICROPY_HW_ENABLE_I2C1 (0)
  94. #define MICROPY_HW_ENABLE_SPI1 (0)
  95. #define MICROPY_HW_ENABLE_SPI3 (0)
  96. #define MICROPY_HW_ENABLE_CC3K (0)
  97. #define MICROPY_HW_LED1 (pin_C5)
  98. #define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
  99. #define MICROPY_HW_LED_ON(pin) (pin->gpio->PSOR = pin->pin_mask)
  100. #define MICROPY_HW_LED_OFF(pin) (pin->gpio->PCOR = pin->pin_mask)
  101. #if 0
  102. // SD card detect switch
  103. #define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)
  104. #define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
  105. #define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
  106. #endif
  107. #define MICROPY_MATH_SQRT_ASM (1)
  108. #define MICROPY_MPHALPORT_H "teensy_hal.h"
  109. #define MICROPY_PIN_DEFS_PORT_H "pin_defs_teensy.h"