all: Add py/mphal.h and use it in all ports.

py/mphal.h contains declarations for generic mp_hal_XXX functions, such
as stdio and delay/ticks, which ports should provide definitions for.  A
port will also provide mphalport.h with further HAL declarations.
crypto-aes
Damien George 7 years ago committed by Paul Sokolovsky
parent 0bd3f3291d
commit 731f359292
  1. 1
      bare-arm/mphalport.h
  2. 1
      cc3200/bootmgr/main.c
  3. 2
      cc3200/fatfs/src/drivers/sd_diskio.c
  4. 1
      cc3200/fatfs/src/drivers/sflash_diskio.c
  5. 1
      cc3200/ftp/ftp.c
  6. 1
      cc3200/ftp/updater.c
  7. 10
      cc3200/hal/cc3200_hal.c
  8. 7
      cc3200/hal/cc3200_hal.h
  9. 2
      cc3200/main.c
  10. 2
      cc3200/misc/FreeRTOSHooks.c
  11. 2
      cc3200/misc/mperror.c
  12. 1
      cc3200/misc/mpirq.c
  13. 2
      cc3200/misc/mpsystick.c
  14. 2
      cc3200/mods/modmachine.c
  15. 2
      cc3200/mods/modnetwork.c
  16. 1
      cc3200/mods/modubinascii.c
  17. 1
      cc3200/mods/modusocket.c
  18. 1
      cc3200/mods/modussl.c
  19. 2
      cc3200/mods/modutime.c
  20. 1
      cc3200/mods/modwipy.c
  21. 2
      cc3200/mods/modwlan.c
  22. 1
      cc3200/mods/pybadc.c
  23. 2
      cc3200/mods/pybi2c.c
  24. 1
      cc3200/mods/pybpin.c
  25. 1
      cc3200/mods/pybrtc.c
  26. 1
      cc3200/mods/pybsd.c
  27. 2
      cc3200/mods/pybsleep.c
  28. 1
      cc3200/mods/pybspi.c
  29. 2
      cc3200/mods/pybtimer.c
  30. 2
      cc3200/mods/pybuart.c
  31. 2
      cc3200/mods/pybwdt.c
  32. 3
      cc3200/mpconfigport.h
  33. 2
      cc3200/mptask.c
  34. 2
      cc3200/serverstask.c
  35. 2
      cc3200/telnet/telnet.c
  36. 1
      cc3200/util/gccollect.c
  37. 6
      esp8266/esp_mphal.h
  38. 2
      esp8266/main.c
  39. 1
      esp8266/modesp.c
  40. 2
      esp8266/modpyb.c
  41. 1
      esp8266/modpybadc.c
  42. 1
      esp8266/modpybrtc.c
  43. 2
      esp8266/modutime.c
  44. 3
      esp8266/mpconfigport.h
  45. 4
      lib/mp-readline/readline.c
  46. 9
      minimal/mpconfigport.h
  47. 2
      minimal/mphalport.h
  48. 1
      minimal/uart_extra.c
  49. 4
      pic16bit/main.c
  50. 8
      pic16bit/modpyb.c
  51. 3
      pic16bit/mpconfigport.h
  52. 10
      pic16bit/pic16bit_mphal.c
  53. 9
      pic16bit/pic16bit_mphal.h
  54. 61
      py/mphal.h
  55. 1
      py/mpprint.c
  56. 1
      qemu-arm/mphalport.h
  57. 2
      stmhal/Makefile
  58. 3
      stmhal/adc.c
  59. 2
      stmhal/boards/stm32f4xx_prefix.c
  60. 2
      stmhal/can.c
  61. 2
      stmhal/extint.c
  62. 2
      stmhal/i2c.c
  63. 3
      stmhal/irq.c
  64. 3
      stmhal/led.c
  65. 2
      stmhal/main.c
  66. 2
      stmhal/modmachine.c
  67. 2
      stmhal/modnwwiznet5k.c
  68. 2
      stmhal/moduselect.c
  69. 2
      stmhal/mpconfigport.h
  70. 6
      stmhal/mphalport.c
  71. 9
      stmhal/mphalport.h
  72. 2
      stmhal/pin.c
  73. 1
      stmhal/pin_defs_stmhal.c
  74. 2
      stmhal/pin_named_pins.c
  75. 4
      stmhal/printf.c
  76. 2
      stmhal/pybstdio.c
  77. 4
      stmhal/pyexec.c
  78. 2
      stmhal/spi.c
  79. 2
      stmhal/stm32_it.c
  80. 1
      stmhal/timer.c
  81. 2
      stmhal/uart.c
  82. 2
      stmhal/usbd_desc.c
  83. 2
      stmhal/usrsw.c
  84. 2
      teensy/led.c
  85. 2
      teensy/main.c
  86. 3
      teensy/modpyb.c
  87. 3
      teensy/mpconfigport.h
  88. 2
      teensy/pin_defs_teensy.c
  89. 10
      teensy/teensy_hal.c
  90. 7
      teensy/teensy_hal.h
  91. 2
      teensy/timer.c
  92. 1
      teensy/uart.c
  93. 2
      unix/input.c
  94. 2
      unix/main.c
  95. 2
      unix/mpconfigport.h
  96. 4
      unix/unix_mphal.c
  97. 8
      unix/unix_mphal.h
  98. 2
      windows/mpconfigport.h
  99. 6
      windows/windows_mphal.c
  100. 1
      windows/windows_mphal.h

@ -0,0 +1 @@
// empty file

@ -30,7 +30,6 @@
#include "std.h"
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "hw_ints.h"
#include "hw_types.h"
#include "hw_gpio.h"

@ -38,7 +38,7 @@
#include <stdbool.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/mphal.h"
#include "hw_types.h"
#include "hw_memmap.h"
#include "hw_ints.h"

@ -3,7 +3,6 @@
#include "std.h"
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "simplelink.h"
#include "diskio.h"

@ -29,7 +29,6 @@
#include "std.h"
#include "py/mpstate.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"

@ -28,7 +28,6 @@
#include <stdbool.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "simplelink.h"
#include "flc.h"

@ -34,7 +34,7 @@
#include "py/mpstate.h"
#include MICROPY_HAL_H
#include "py/mphal.h"
#include "py/runtime.h"
#include "py/objstr.h"
#include "inc/hw_types.h"
@ -104,11 +104,11 @@ void HAL_IncrementTick(void) {
HAL_tickCount++;
}
uint32_t mp_hal_ticks_ms(void) {
mp_uint_t mp_hal_ticks_ms(void) {
return HAL_tickCount;
}
void mp_hal_delay_ms(uint32_t delay) {
void mp_hal_delay_ms(mp_uint_t delay) {
// only if we are not within interrupt context and interrupts are enabled
if ((HAL_NVIC_INT_CTRL_REG & HAL_VECTACTIVE_MASK) == 0 && query_irq() == IRQ_STATE_ENABLED) {
#ifdef USE_FREERTOS
@ -140,7 +140,7 @@ void mp_hal_stdout_tx_str(const char *str) {
mp_hal_stdout_tx_strn(str, strlen(str));
}
void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
void mp_hal_stdout_tx_strn(const char *str, size_t len) {
if (MP_STATE_PORT(os_term_dup_obj)) {
if (MP_OBJ_IS_TYPE(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
uart_tx_strn(MP_STATE_PORT(os_term_dup_obj)->stream_o, str, len);
@ -153,7 +153,7 @@ void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
telnet_tx_strn(str, len);
}
void mp_hal_stdout_tx_strn_cooked (const char *str, uint32_t len) {
void mp_hal_stdout_tx_strn_cooked (const char *str, size_t len) {
int32_t nslen = 0;
const char *_str = str;

@ -62,14 +62,7 @@
extern void HAL_SystemInit (void);
extern void HAL_SystemDeInit (void);
extern void HAL_IncrementTick(void);
extern uint32_t mp_hal_ticks_ms(void);
extern void mp_hal_delay_ms(uint32_t delay);
extern NORETURN void mp_hal_raise(int errno);
extern void mp_hal_set_interrupt_char (int c);
int mp_hal_stdin_rx_chr(void);
void mp_hal_stdout_tx_str(const char *str);
void mp_hal_stdout_tx_strn(const char *str, uint32_t len);
void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
#endif /* CC3200_LAUNCHXL_HAL_CC3200_HAL_H_ */

@ -29,7 +29,7 @@
#include <ctype.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/mphal.h"
#include "mptask.h"
#include "simplelink.h"
#include "pybwdt.h"

@ -29,7 +29,7 @@
#include <string.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/mphal.h"
#include "py/obj.h"
#include "inc/hw_memmap.h"
#include "pybuart.h"

@ -30,9 +30,9 @@
#include <string.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/runtime.h"
#include "py/mphal.h"
#include "hw_ints.h"
#include "hw_types.h"
#include "hw_gpio.h"

@ -27,7 +27,6 @@
#include "std.h"
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/runtime.h"
#include "py/gc.h"

@ -26,8 +26,8 @@
*/
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/mphal.h"
#include "mpsystick.h"
#include "systick.h"
#include "inc/hw_types.h"

@ -30,7 +30,7 @@
#include "py/mpstate.h"
#include "py/runtime.h"
#include MICROPY_HAL_H
#include "py/mphal.h"
#include "irq.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"

@ -28,10 +28,10 @@
#include <std.h>
#include "py/mpstate.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/mphal.h"
#include "modnetwork.h"
#include "mpexception.h"
#include "serverstask.h"

@ -26,7 +26,6 @@
*/
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/binary.h"

@ -30,7 +30,6 @@
#include "simplelink.h"
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/objstr.h"
#include "py/runtime.h"

@ -29,7 +29,6 @@
#include "simplelink.h"
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/objstr.h"
#include "py/runtime.h"

@ -29,10 +29,10 @@
#include <string.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/nlr.h"
#include "py/obj.h"
#include "py/smallint.h"
#include "py/mphal.h"
#include "timeutils.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"

@ -1,5 +1,4 @@
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/runtime.h"
#include "mperror.h"

@ -30,10 +30,10 @@
#include "simplelink.h"
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/objstr.h"
#include "py/runtime.h"
#include "py/mphal.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"

@ -29,7 +29,6 @@
#include <string.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/binary.h"

@ -29,8 +29,8 @@
#include <string.h>
#include "py/mpstate.h"
#include MICROPY_HAL_H
#include "py/runtime.h"
#include "py/mphal.h"
#include "bufhelper.h"
#include "inc/hw_types.h"
#include "inc/hw_i2c.h"

@ -30,7 +30,6 @@
#include <string.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/runtime.h"
#include "py/gc.h"

@ -28,7 +28,6 @@
#include <std.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/runtime.h"
#include "inc/hw_types.h"

@ -25,7 +25,6 @@
*/
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/runtime.h"
#include "inc/hw_types.h"

@ -28,8 +28,8 @@
#include <string.h>
#include "py/mpstate.h"
#include MICROPY_HAL_H
#include "py/runtime.h"
#include "py/mphal.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "inc/hw_nvic.h"

@ -29,7 +29,6 @@
#include <string.h>
#include "py/mpstate.h"
#include MICROPY_HAL_H
#include "py/runtime.h"
#include "bufhelper.h"
#include "inc/hw_types.h"

@ -30,11 +30,11 @@
#include <string.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/gc.h"
#include "py/mphal.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"

@ -31,11 +31,11 @@
#include <string.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/runtime.h"
#include "py/objlist.h"
#include "py/stream.h"
#include "py/mphal.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"

@ -27,9 +27,9 @@
#include <stdint.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/runtime.h"
#include "py/mphal.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "inc/hw_ints.h"

@ -180,7 +180,6 @@ typedef void *machine_ptr_t; // must be of pointer size
typedef const void *machine_const_ptr_t; // must be of pointer size
typedef long mp_off_t;
void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
@ -204,7 +203,7 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
// Include board specific configuration
#include "mpconfigboard.h"
#define MICROPY_HAL_H "cc3200_hal.h"
#define MICROPY_MPHALPORT_H "cc3200_hal.h"
#define MICROPY_PORT_HAS_TELNET (1)
#define MICROPY_PORT_HAS_FTP (1)
#define MICROPY_PY_SYS_PLATFORM "WiPy"

@ -28,10 +28,10 @@
#include <stdint.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/runtime.h"
#include "py/gc.h"
#include "py/mphal.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"

@ -28,9 +28,9 @@
#include <string.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/misc.h"
#include "py/nlr.h"
#include "py/mphal.h"
#include "serverstask.h"
#include "simplelink.h"
#include "debug.h"

@ -27,8 +27,8 @@
#include <stdint.h>
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/mphal.h"
#include "telnet.h"
#include "simplelink.h"
#include "modnetwork.h"

@ -32,7 +32,6 @@
#include "py/gc.h"
#include "gccollect.h"
#include "gchelper.h"
#include MICROPY_HAL_H
/******************************************************************************
DECLARE PRIVATE DATA

@ -32,13 +32,7 @@ void ets_isr_mask(unsigned);
void mp_hal_init(void);
void mp_hal_feed_watchdog(void);
int mp_hal_stdin_rx_chr(void);
void mp_hal_stdout_tx_str(const char *str);
void mp_hal_stdout_tx_strn(const char *str, uint32_t len);
void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
uint32_t mp_hal_ticks_ms(void);
void mp_hal_delay_ms(uint32_t delay);
void mp_hal_delay_us(uint32_t);
void mp_hal_set_interrupt_char(int c);
uint32_t mp_hal_get_cpu_freq(void);

@ -33,10 +33,10 @@
#include "py/runtime.h"
#include "py/stackctrl.h"
#include "py/frozenmod.h"
#include "py/mphal.h"
#include "py/gc.h"
#include "pyexec.h"
#include "gccollect.h"
#include MICROPY_HAL_H
#include "user_interface.h"
STATIC char heap[16384];

@ -32,7 +32,6 @@
#include "py/obj.h"
#include "py/gc.h"
#include "py/runtime.h"
#include MICROPY_HAL_H
#include "netutils.h"
#include "queue.h"
#include "user_interface.h"

@ -29,9 +29,9 @@
#include "py/nlr.h"
#include "py/obj.h"
#include "py/gc.h"
#include "py/mphal.h"
#include "gccollect.h"
#include "pyexec.h"
#include MICROPY_HAL_H
#include "user_interface.h"
#include "modpyb.h"

@ -30,7 +30,6 @@
#include "py/nlr.h"
#include "py/obj.h"
#include "py/runtime.h"
#include MICROPY_HAL_H
#include "user_interface.h"
const mp_obj_type_t pyb_adc_type;

@ -30,7 +30,6 @@
#include "py/nlr.h"
#include "py/obj.h"
#include "py/runtime.h"
#include MICROPY_HAL_H
#include "timeutils.h"
#include "user_interface.h"
#include "modpyb.h"

@ -32,7 +32,7 @@
#include "py/obj.h"
#include "py/gc.h"
#include "py/runtime.h"
#include MICROPY_HAL_H
#include "py/mphal.h"
#include "modpyb.h"
#include "modpybrtc.h"
#include "timeutils.h"

@ -54,7 +54,6 @@ typedef void *machine_ptr_t; // must be of pointer size
typedef const void *machine_const_ptr_t; // must be of pointer size
typedef long mp_off_t;
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len);
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
// extra built in names to add to the global namespace
@ -94,7 +93,7 @@ extern const struct _mp_obj_module_t uos_module;
// board specifics
#define MICROPY_HAL_H "esp_mphal.h"
#define MICROPY_MPHALPORT_H "esp_mphal.h"
#define MICROPY_HW_BOARD_NAME "ESP module"
#define MICROPY_HW_MCU_NAME "ESP8266"
#define MICROPY_PY_SYS_PLATFORM "ESP8266"

@ -30,10 +30,8 @@
#include "py/mpstate.h"
#include "py/repl.h"
#include "py/mphal.h"
#include "readline.h"
#ifdef MICROPY_HAL_H
#include MICROPY_HAL_H
#endif
#if 0 // print debugging info
#define DEBUG_PRINT (1)

@ -65,7 +65,6 @@ typedef void *machine_ptr_t; // must be of pointer size
typedef const void *machine_const_ptr_t; // must be of pointer size
typedef long mp_off_t;
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len);
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
// extra built in names to add to the global namespace
@ -76,14 +75,6 @@ extern const struct _mp_obj_fun_builtin_t mp_builtin_open_obj;
// We need to provide a declaration/definition of alloca()
#include <alloca.h>
#define mp_hal_ticks_ms() 0
int mp_hal_stdin_rx_chr(void);
void mp_hal_stdout_tx_str(const char *str);
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len);
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len);
static inline void mp_hal_set_interrupt_char(char c) {}
#define MICROPY_HW_BOARD_NAME "minimal"
#define MICROPY_HW_MCU_NAME "unknown-cpu"

@ -0,0 +1,2 @@
static inline mp_uint_t mp_hal_ticks_ms(void) { return 0; }
static inline void mp_hal_set_interrupt_char(char c) {}

@ -1,6 +1,7 @@
#include <string.h>
#include <unistd.h>
#include "py/mpconfig.h"
#include "py/mphal.h"
/*
* Extra UART functions

@ -32,9 +32,9 @@
#include "py/compile.h"
#include "py/runtime.h"
#include "py/gc.h"
#include "py/mphal.h"
#include "pyexec.h"
#include "readline.h"
#include MICROPY_HAL_H
#include "board.h"
#include "modpyb.h"
@ -59,7 +59,7 @@ soft_reset:
led_state(1, 0);
led_state(2, 0);
led_state(3, 1);
mp_hal_milli_delay(150);
mp_hal_delay_ms(150);
led_state(3, 0);
// init MicroPython runtime

@ -27,17 +27,17 @@
#include <stdio.h>
#include "py/obj.h"
#include MICROPY_HAL_H
#include "py/mphal.h"
#include "modpyb.h"
STATIC mp_obj_t pyb_millis(void) {
return MP_OBJ_NEW_SMALL_INT(mp_hal_get_milliseconds());
return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms());
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_millis_obj, pyb_millis);
STATIC mp_obj_t pyb_elapsed_millis(mp_obj_t start) {
uint32_t startMillis = mp_obj_get_int(start);
uint32_t currMillis = mp_hal_get_milliseconds();
uint32_t currMillis = mp_hal_ticks_ms();
return MP_OBJ_NEW_SMALL_INT((currMillis - startMillis) & 0x1fff);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_elapsed_millis_obj, pyb_elapsed_millis);
@ -45,7 +45,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_elapsed_millis_obj, pyb_elapsed_millis);
STATIC mp_obj_t pyb_delay(mp_obj_t ms_in) {
mp_int_t ms = mp_obj_get_int(ms_in);
if (ms >= 0) {
mp_hal_milli_delay(ms);
mp_hal_delay_ms(ms);
}
return mp_const_none;
}

@ -86,7 +86,6 @@ typedef void *machine_ptr_t; // must be pointer size
typedef const void *machine_const_ptr_t; // must be pointer size
typedef int mp_off_t;
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len);
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
// extra builtin names to add to the global namespace
@ -108,6 +107,6 @@ extern const struct _mp_obj_module_t pyb_module;
char *readline_hist[8]; \
mp_obj_t keyboard_interrupt_obj; \
#define MICROPY_HAL_H "pic16bit_mphal.h"
#define MICROPY_MPHALPORT_H "pic16bit_mphal.h"
#define MICROPY_HW_BOARD_NAME "dsPICSK"
#define MICROPY_HW_MCU_NAME "dsPIC33"

@ -25,7 +25,7 @@
*/
#include <string.h>
#include "pic16bit_mphal.h"
#include "py/mphal.h"
#include "board.h"
static int interrupt_char;
@ -34,12 +34,12 @@ void mp_hal_init(void) {
MP_STATE_PORT(keyboard_interrupt_obj) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
}
mp_uint_t mp_hal_get_milliseconds(void) {
mp_uint_t mp_hal_ticks_ms(void) {
// TODO
return 0;
}
void mp_hal_milli_delay(mp_uint_t ms) {
void mp_hal_delay_ms(mp_uint_t ms) {
// tuned for fixed CPU frequency
for (int i = ms; i > 0; i--) {
for (volatile int j = 0; j < 5000; j++) {
@ -63,13 +63,13 @@ void mp_hal_stdout_tx_str(const char *str) {
mp_hal_stdout_tx_strn(str, strlen(str));
}
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
void mp_hal_stdout_tx_strn(const char *str, size_t len) {
for (; len > 0; --len) {
uart_tx_char(*str++);
}
}
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len) {
void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
for (; len > 0; --len) {
if (*str == '\n') {
uart_tx_char('\r');

@ -26,19 +26,10 @@
#ifndef __MICROPY_INCLUDED_PIC16BIT_PIC16BIT_MPHAL_H__
#define __MICROPY_INCLUDED_PIC16BIT_PIC16BIT_MPHAL_H__
#define HAL_GetTick mp_hal_get_milliseconds
#include "py/mpstate.h"
void mp_hal_init(void);
mp_uint_t mp_hal_get_milliseconds(void);
void mp_hal_milli_delay(mp_uint_t ms);
void mp_hal_set_interrupt_char(int c);
int mp_hal_stdin_rx_chr(void);
void mp_hal_stdout_tx_str(const char *str);
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len);
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len);
#endif // __MICROPY_INCLUDED_PIC16BIT_PIC16BIT_MPHAL_H__

@ -0,0 +1,61 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2015 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.
*/
#ifndef __MICROPY_INCLUDED_PY_MPHAL_H__
#define __MICROPY_INCLUDED_PY_MPHAL_H__
#include "py/mpconfig.h"
#ifdef MICROPY_MPHALPORT_H
#include MICROPY_MPHALPORT_H
#else
#include <mphalport.h>
#endif
#ifndef mp_hal_stdin_rx_chr
int mp_hal_stdin_rx_chr(void);
#endif
#ifndef mp_hal_stdout_tx_str
void mp_hal_stdout_tx_str(const char *str);
#endif
#ifndef mp_hal_stdout_tx_strn
void mp_hal_stdout_tx_strn(const char *str, size_t len);
#endif
#ifndef mp_hal_stdout_tx_strn_cooked
void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len);
#endif
#ifndef mp_hal_delay_ms
void mp_hal_delay_ms(mp_uint_t ms);
#endif
#ifndef mp_hal_ticks_ms
mp_uint_t mp_hal_ticks_ms(void);
#endif
#endif // __MICROPY_INCLUDED_PY_MPHAL_H__

@ -30,6 +30,7 @@
#include <stdio.h>
#include <string.h>
#include "py/mphal.h"
#include "py/mpprint.h"
#include "py/obj.h"
#include "py/objint.h"

@ -0,0 +1 @@
// empty file

@ -113,7 +113,7 @@ SRC_C = \
usbd_desc.c \
usbd_cdc_interface.c \
usbd_msc_storage.c \
mphal.c \
mphalport.c \
irq.c \
pendsv.c \
systick.c \

@ -25,16 +25,15 @@
*/
#include <stdio.h>
#include STM32_HAL_H
#include <string.h>
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/binary.h"
#include "py/mphal.h"
#include "adc.h"
#include "pin.h"
#include "genhdr/pins.h"
#include "mphal.h"
#include "timer.h"
/// \moduleref pyb

@ -3,8 +3,8 @@
#include <stdio.h>
#include "py/obj.h"
#include "py/mphal.h"
#include "pin.h"
#include MICROPY_HAL_H
#define AF(af_idx, af_fn, af_unit, af_type, af_ptr) \
{ \

@ -33,10 +33,10 @@
#include "py/objtuple.h"
#include "py/runtime.h"
#include "py/gc.h"
#include "py/mphal.h"
#include "bufhelper.h"
#include "can.h"
#include "pybioctl.h"
#include MICROPY_HAL_H
#if MICROPY_HW_ENABLE_CAN

@ -31,7 +31,7 @@
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/gc.h"
#include MICROPY_HAL_H
#include "py/mphal.h"
#include "pin.h"
#include "extint.h"

@ -29,13 +29,13 @@
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/mphal.h"
#include "irq.h"
#include "pin.h"
#include "genhdr/pins.h"
#include "bufhelper.h"
#include "dma.h"
#include "i2c.h"
#include MICROPY_HAL_H
#if !defined(MICROPY_HW_I2C_BAUDRATE_DEFAULT)
#define MICROPY_HW_I2C_BAUDRATE_DEFAULT 400000

@ -26,10 +26,9 @@
#include "py/nlr.h"
#include "py/obj.h"
#include "py/mphal.h"
#include "irq.h"
#include MICROPY_HAL_H
/// \moduleref pyb
/// \function wfi()

@ -25,15 +25,14 @@
*/
#include <stdio.h>
#include STM32_HAL_H
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/mphal.h"
#include "timer.h"
#include "led.h"
#include "pin.h"
#include "genhdr/pins.h"
#include "mphal.h"
#if defined(MICROPY_HW_LED1)

@ -34,6 +34,7 @@
#include "py/runtime.h"
#include "py/stackctrl.h"
#include "py/gc.h"
#include "py/mphal.h"
#include "lib/fatfs/ff.h"
@ -60,7 +61,6 @@
#include "dac.h"
#include "can.h"
#include "modnetwork.h"
#include MICROPY_HAL_H
void SystemClock_Config(void);

@ -29,6 +29,7 @@
#include "modmachine.h"
#include "py/gc.h"
#include "py/runtime.h"
#include "py/mphal.h"
#include "lib/fatfs/ff.h"
#include "lib/fatfs/diskio.h"
#include "gccollect.h"
@ -38,7 +39,6 @@
#include "pin.h"
#include "timer.h"
#include "usb.h"
#include MICROPY_HAL_H
// machine.info([dump_alloc_table])
// Print out lots of information about the board.

@ -32,12 +32,12 @@
#include "py/nlr.h"
#include "py/objlist.h"
#include "py/runtime.h"
#include "py/mphal.h"
#include "netutils.h"
#include "modnetwork.h"
#include "pin.h"
#include "genhdr/pins.h"
#include "spi.h"
#include MICROPY_HAL_H
#include "ethernet/wizchip_conf.h"
#include "ethernet/socket.h"

@ -30,8 +30,8 @@
#include "py/nlr.h"
#include "py/obj.h"
#include "py/objlist.h"
#include "py/mphal.h"
#include "pybioctl.h"
#include MICROPY_HAL_H
/// \module select - Provides select function to wait for events on a stream
///

@ -199,7 +199,6 @@ typedef void *machine_ptr_t; // must be of pointer size
typedef const void *machine_const_ptr_t; // must be of pointer size
typedef long mp_off_t;
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len);
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
// We have inlined IRQ functions for efficiency (they are generally
@ -242,7 +241,6 @@ static inline mp_uint_t disable_irq(void) {
// We need to provide a declaration/definition of alloca()
#include <alloca.h>
#define MICROPY_HAL_H "mphal.h"
#define MICROPY_PIN_DEFS_PORT_H "pin_defs_stmhal.h"
#endif // __INCLUDED_MPCONFIGPORT_H

@ -2,9 +2,9 @@
#include <string.h>
#include "py/mpstate.h"
#include "py/mphal.h"
#include "usb.h"
#include "uart.h"
#include "mphal.h"
// this table converts from HAL_StatusTypeDef to POSIX errno
const byte mp_hal_status_to_errno_table[4] = {
@ -48,7 +48,7 @@ void mp_hal_stdout_tx_str(const char *str) {
mp_hal_stdout_tx_strn(str, strlen(str));
}
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
void mp_hal_stdout_tx_strn(const char *str, size_t len) {
if (MP_STATE_PORT(pyb_stdio_uart) != NULL) {
uart_tx_strn(MP_STATE_PORT(pyb_stdio_uart), str, len);
}
@ -60,7 +60,7 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
}
}
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len) {
void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
// send stdout to UART and USB CDC VCP
if (MP_STATE_PORT(pyb_stdio_uart) != NULL) {
uart_tx_strn_cooked(MP_STATE_PORT(pyb_stdio_uart), str, len);

@ -8,7 +8,7 @@
#elif defined(MCU_SERIES_F7)
#define MP_HAL_UNIQUE_ID_ADDRESS (0x1ff0f420)
#else
#error mphal.h: Unrecognized MCU_SERIES
#error mphalport.h: Unrecognized MCU_SERIES
#endif
// Basic GPIO functions
@ -24,15 +24,10 @@
void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio);
extern const byte mp_hal_status_to_errno_table[4];
extern const unsigned char mp_hal_status_to_errno_table[4];
NORETURN void mp_hal_raise(HAL_StatusTypeDef status);
void mp_hal_set_interrupt_char(int c); // -1 to disable
int mp_hal_stdin_rx_chr(void);
void mp_hal_stdout_tx_str(const char *str);
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len);
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len);
#define mp_hal_delay_ms HAL_Delay
#define mp_hal_ticks_ms HAL_GetTick

@ -30,7 +30,7 @@
#include "py/nlr.h"
#include "py/runtime.h"
#include MICROPY_HAL_H
#include "py/mphal.h"
#include "pin.h"
/// \moduleref pyb

@ -1,6 +1,5 @@
#include "py/obj.h"
#include "pin.h"
#include MICROPY_HAL_H
// Returns the pin mode. This value returned by this macro should be one of:
// GPIO_MODE_INPUT, GPIO_MODE_OUTPUT_PP, GPIO_MODE_OUTPUT_OD,

@ -28,7 +28,7 @@
#include <string.h>
#include "py/runtime.h"
#include MICROPY_HAL_H
#include "py/mphal.h"
#include "pin.h"
STATIC void pin_named_pins_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {