mpconfigport.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * This file is part of the MicroPython project, http://micropython.org/
  3. *
  4. * The MIT License (MIT)
  5. *
  6. * Copyright (c) 2016 Linaro Limited
  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. #include <alloca.h>
  27. // Include Zephyr's autoconf.h, which should be made first by Zephyr makefiles
  28. #include "autoconf.h"
  29. // Included here to get basic Zephyr environment (macros, etc.)
  30. #include <zephyr.h>
  31. // Usually passed from Makefile
  32. #ifndef MICROPY_HEAP_SIZE
  33. #define MICROPY_HEAP_SIZE (16 * 1024)
  34. #endif
  35. #define MICROPY_ENABLE_SOURCE_LINE (1)
  36. #define MICROPY_STACK_CHECK (1)
  37. #define MICROPY_ENABLE_GC (1)
  38. #define MICROPY_HELPER_REPL (1)
  39. #define MICROPY_REPL_AUTO_INDENT (1)
  40. #define MICROPY_KBD_EXCEPTION (1)
  41. #define MICROPY_CPYTHON_COMPAT (0)
  42. #define MICROPY_PY_ASYNC_AWAIT (0)
  43. #define MICROPY_PY_ATTRTUPLE (0)
  44. #define MICROPY_PY_BUILTINS_ENUMERATE (0)
  45. #define MICROPY_PY_BUILTINS_FILTER (0)
  46. #define MICROPY_PY_BUILTINS_MIN_MAX (0)
  47. #define MICROPY_PY_BUILTINS_PROPERTY (0)
  48. #define MICROPY_PY_BUILTINS_RANGE_ATTRS (0)
  49. #define MICROPY_PY_BUILTINS_REVERSED (0)
  50. #define MICROPY_PY_BUILTINS_SET (0)
  51. #define MICROPY_PY_BUILTINS_HELP (1)
  52. #define MICROPY_PY_BUILTINS_HELP_TEXT zephyr_help_text
  53. #define MICROPY_PY_ARRAY (0)
  54. #define MICROPY_PY_COLLECTIONS (0)
  55. #define MICROPY_PY_CMATH (0)
  56. #define MICROPY_PY_IO (0)
  57. #define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
  58. #define MICROPY_PY_MACHINE (1)
  59. #define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new
  60. #define MICROPY_MODULE_WEAK_LINKS (1)
  61. #define MICROPY_PY_STRUCT (0)
  62. #ifdef CONFIG_NETWORKING
  63. // If we have networking, we likely want errno comfort
  64. #define MICROPY_PY_UERRNO (1)
  65. #define MICROPY_PY_USOCKET (1)
  66. #endif
  67. #define MICROPY_PY_UBINASCII (1)
  68. #define MICROPY_PY_UHASHLIB (1)
  69. #define MICROPY_PY_UTIME (1)
  70. #define MICROPY_PY_UTIME_MP_HAL (1)
  71. #define MICROPY_PY_ZEPHYR (1)
  72. #define MICROPY_PY_ZSENSOR (1)
  73. #define MICROPY_PY_SYS_MODULES (0)
  74. #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_LONGLONG)
  75. #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
  76. #define MICROPY_PY_BUILTINS_COMPLEX (0)
  77. // Saving extra crumbs to make sure binary fits in 128K
  78. #define MICROPY_COMP_CONST_FOLDING (0)
  79. #define MICROPY_COMP_CONST (0)
  80. #define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (0)
  81. #define MICROPY_PY_SYS_PLATFORM "zephyr"
  82. #ifdef CONFIG_BOARD
  83. #define MICROPY_HW_BOARD_NAME "zephyr-" CONFIG_BOARD
  84. #else
  85. #define MICROPY_HW_BOARD_NAME "zephyr-generic"
  86. #endif
  87. #ifdef CONFIG_SOC
  88. #define MICROPY_HW_MCU_NAME CONFIG_SOC
  89. #else
  90. #define MICROPY_HW_MCU_NAME "unknown-cpu"
  91. #endif
  92. #define MICROPY_MODULE_FROZEN_STR (1)
  93. typedef int mp_int_t; // must be pointer size
  94. typedef unsigned mp_uint_t; // must be pointer size
  95. typedef long mp_off_t;
  96. #define MP_STATE_PORT MP_STATE_VM
  97. #define MICROPY_PORT_ROOT_POINTERS \
  98. const char *readline_hist[8];
  99. extern const struct _mp_obj_module_t mp_module_machine;
  100. extern const struct _mp_obj_module_t mp_module_time;
  101. extern const struct _mp_obj_module_t mp_module_usocket;
  102. extern const struct _mp_obj_module_t mp_module_zephyr;
  103. extern const struct _mp_obj_module_t mp_module_zsensor;
  104. #if MICROPY_PY_USOCKET
  105. #define MICROPY_PY_USOCKET_DEF { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_usocket) },
  106. #define MICROPY_PY_USOCKET_WEAK_DEF { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&mp_module_usocket) },
  107. #else
  108. #define MICROPY_PY_USOCKET_DEF
  109. #define MICROPY_PY_USOCKET_WEAK_DEF
  110. #endif
  111. #if MICROPY_PY_UTIME
  112. #define MICROPY_PY_UTIME_DEF { MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_time) },
  113. #else
  114. #define MICROPY_PY_UTIME_DEF
  115. #endif
  116. #if MICROPY_PY_ZEPHYR
  117. #define MICROPY_PY_ZEPHYR_DEF { MP_ROM_QSTR(MP_QSTR_zephyr), MP_ROM_PTR(&mp_module_zephyr) },
  118. #else
  119. #define MICROPY_PY_ZEPHYR_DEF
  120. #endif
  121. #if MICROPY_PY_ZSENSOR
  122. #define MICROPY_PY_ZSENSOR_DEF { MP_ROM_QSTR(MP_QSTR_zsensor), MP_ROM_PTR(&mp_module_zsensor) },
  123. #else
  124. #define MICROPY_PY_ZSENSOR_DEF
  125. #endif
  126. #define MICROPY_PORT_BUILTIN_MODULES \
  127. { MP_ROM_QSTR(MP_QSTR_machine), MP_ROM_PTR(&mp_module_machine) }, \
  128. MICROPY_PY_USOCKET_DEF \
  129. MICROPY_PY_UTIME_DEF \
  130. MICROPY_PY_ZEPHYR_DEF \
  131. MICROPY_PY_ZSENSOR_DEF \
  132. #define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
  133. { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&mp_module_time) }, \
  134. MICROPY_PY_USOCKET_WEAK_DEF \
  135. // extra built in names to add to the global namespace
  136. #define MICROPY_PORT_BUILTINS \