Skip to content
This repository was archived by the owner on Jan 1, 2019. It is now read-only.

Commit 731f359

Browse files
dpgeorgepfalcon
authored andcommitted
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.
1 parent 0bd3f32 commit 731f359

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+156
-174
lines changed

bare-arm/mphalport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// empty file

cc3200/bootmgr/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "std.h"
3131

3232
#include "py/mpconfig.h"
33-
#include MICROPY_HAL_H
3433
#include "hw_ints.h"
3534
#include "hw_types.h"
3635
#include "hw_gpio.h"

cc3200/fatfs/src/drivers/sd_diskio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include <stdbool.h>
3939

4040
#include "py/mpconfig.h"
41-
#include MICROPY_HAL_H
41+
#include "py/mphal.h"
4242
#include "hw_types.h"
4343
#include "hw_memmap.h"
4444
#include "hw_ints.h"

cc3200/fatfs/src/drivers/sflash_diskio.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "std.h"
44

55
#include "py/mpconfig.h"
6-
#include MICROPY_HAL_H
76
#include "py/obj.h"
87
#include "simplelink.h"
98
#include "diskio.h"

cc3200/ftp/ftp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "std.h"
3030

3131
#include "py/mpstate.h"
32-
#include MICROPY_HAL_H
3332
#include "py/obj.h"
3433
#include "inc/hw_types.h"
3534
#include "inc/hw_ints.h"

cc3200/ftp/updater.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <stdbool.h>
2929

3030
#include "py/mpconfig.h"
31-
#include MICROPY_HAL_H
3231
#include "py/obj.h"
3332
#include "simplelink.h"
3433
#include "flc.h"

cc3200/hal/cc3200_hal.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535

3636
#include "py/mpstate.h"
37-
#include MICROPY_HAL_H
37+
#include "py/mphal.h"
3838
#include "py/runtime.h"
3939
#include "py/objstr.h"
4040
#include "inc/hw_types.h"
@@ -104,11 +104,11 @@ void HAL_IncrementTick(void) {
104104
HAL_tickCount++;
105105
}
106106

107-
uint32_t mp_hal_ticks_ms(void) {
107+
mp_uint_t mp_hal_ticks_ms(void) {
108108
return HAL_tickCount;
109109
}
110110

111-
void mp_hal_delay_ms(uint32_t delay) {
111+
void mp_hal_delay_ms(mp_uint_t delay) {
112112
// only if we are not within interrupt context and interrupts are enabled
113113
if ((HAL_NVIC_INT_CTRL_REG & HAL_VECTACTIVE_MASK) == 0 && query_irq() == IRQ_STATE_ENABLED) {
114114
#ifdef USE_FREERTOS
@@ -140,7 +140,7 @@ void mp_hal_stdout_tx_str(const char *str) {
140140
mp_hal_stdout_tx_strn(str, strlen(str));
141141
}
142142

143-
void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
143+
void mp_hal_stdout_tx_strn(const char *str, size_t len) {
144144
if (MP_STATE_PORT(os_term_dup_obj)) {
145145
if (MP_OBJ_IS_TYPE(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
146146
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) {
153153
telnet_tx_strn(str, len);
154154
}
155155

156-
void mp_hal_stdout_tx_strn_cooked (const char *str, uint32_t len) {
156+
void mp_hal_stdout_tx_strn_cooked (const char *str, size_t len) {
157157
int32_t nslen = 0;
158158
const char *_str = str;
159159

cc3200/hal/cc3200_hal.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,7 @@
6262
extern void HAL_SystemInit (void);
6363
extern void HAL_SystemDeInit (void);
6464
extern void HAL_IncrementTick(void);
65-
extern uint32_t mp_hal_ticks_ms(void);
66-
extern void mp_hal_delay_ms(uint32_t delay);
6765
extern NORETURN void mp_hal_raise(int errno);
6866
extern void mp_hal_set_interrupt_char (int c);
6967

70-
int mp_hal_stdin_rx_chr(void);
71-
void mp_hal_stdout_tx_str(const char *str);
72-
void mp_hal_stdout_tx_strn(const char *str, uint32_t len);
73-
void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
74-
7568
#endif /* CC3200_LAUNCHXL_HAL_CC3200_HAL_H_ */

cc3200/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <ctype.h>
3030

3131
#include "py/mpconfig.h"
32-
#include MICROPY_HAL_H
32+
#include "py/mphal.h"
3333
#include "mptask.h"
3434
#include "simplelink.h"
3535
#include "pybwdt.h"

cc3200/misc/FreeRTOSHooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <string.h>
3030

3131
#include "py/mpconfig.h"
32-
#include MICROPY_HAL_H
32+
#include "py/mphal.h"
3333
#include "py/obj.h"
3434
#include "inc/hw_memmap.h"
3535
#include "pybuart.h"

cc3200/misc/mperror.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
#include <string.h>
3131

3232
#include "py/mpconfig.h"
33-
#include MICROPY_HAL_H
3433
#include "py/obj.h"
3534
#include "py/runtime.h"
35+
#include "py/mphal.h"
3636
#include "hw_ints.h"
3737
#include "hw_types.h"
3838
#include "hw_gpio.h"

cc3200/misc/mpirq.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "std.h"
2828

2929
#include "py/mpconfig.h"
30-
#include MICROPY_HAL_H
3130
#include "py/obj.h"
3231
#include "py/runtime.h"
3332
#include "py/gc.h"

cc3200/misc/mpsystick.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
*/
2727

2828
#include "py/mpconfig.h"
29-
#include MICROPY_HAL_H
3029
#include "py/obj.h"
30+
#include "py/mphal.h"
3131
#include "mpsystick.h"
3232
#include "systick.h"
3333
#include "inc/hw_types.h"

cc3200/mods/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include "py/mpstate.h"
3232
#include "py/runtime.h"
33-
#include MICROPY_HAL_H
33+
#include "py/mphal.h"
3434
#include "irq.h"
3535
#include "inc/hw_types.h"
3636
#include "inc/hw_gpio.h"

cc3200/mods/modnetwork.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
#include <std.h>
2929

3030
#include "py/mpstate.h"
31-
#include MICROPY_HAL_H
3231
#include "py/obj.h"
3332
#include "py/nlr.h"
3433
#include "py/runtime.h"
34+
#include "py/mphal.h"
3535
#include "modnetwork.h"
3636
#include "mpexception.h"
3737
#include "serverstask.h"

cc3200/mods/modubinascii.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
*/
2727

2828
#include "py/mpconfig.h"
29-
#include MICROPY_HAL_H
3029
#include "py/nlr.h"
3130
#include "py/runtime.h"
3231
#include "py/binary.h"

cc3200/mods/modusocket.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
#include "simplelink.h"
3232
#include "py/mpconfig.h"
33-
#include MICROPY_HAL_H
3433
#include "py/obj.h"
3534
#include "py/objstr.h"
3635
#include "py/runtime.h"

cc3200/mods/modussl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
#include "simplelink.h"
3131
#include "py/mpconfig.h"
32-
#include MICROPY_HAL_H
3332
#include "py/obj.h"
3433
#include "py/objstr.h"
3534
#include "py/runtime.h"

cc3200/mods/modutime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
#include <string.h>
3030

3131
#include "py/mpconfig.h"
32-
#include MICROPY_HAL_H
3332
#include "py/nlr.h"
3433
#include "py/obj.h"
3534
#include "py/smallint.h"
35+
#include "py/mphal.h"
3636
#include "timeutils.h"
3737
#include "inc/hw_types.h"
3838
#include "inc/hw_ints.h"

cc3200/mods/modwipy.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "py/mpconfig.h"
2-
#include MICROPY_HAL_H
32
#include "py/obj.h"
43
#include "py/runtime.h"
54
#include "mperror.h"

cc3200/mods/modwlan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030

3131
#include "simplelink.h"
3232
#include "py/mpconfig.h"
33-
#include MICROPY_HAL_H
3433
#include "py/obj.h"
3534
#include "py/objstr.h"
3635
#include "py/runtime.h"
36+
#include "py/mphal.h"
3737
#include "inc/hw_types.h"
3838
#include "inc/hw_ints.h"
3939
#include "inc/hw_memmap.h"

cc3200/mods/pybadc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <string.h>
3030

3131
#include "py/mpconfig.h"
32-
#include MICROPY_HAL_H
3332
#include "py/nlr.h"
3433
#include "py/runtime.h"
3534
#include "py/binary.h"

cc3200/mods/pybi2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#include <string.h>
3030

3131
#include "py/mpstate.h"
32-
#include MICROPY_HAL_H
3332
#include "py/runtime.h"
33+
#include "py/mphal.h"
3434
#include "bufhelper.h"
3535
#include "inc/hw_types.h"
3636
#include "inc/hw_i2c.h"

cc3200/mods/pybpin.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <string.h>
3131

3232
#include "py/mpconfig.h"
33-
#include MICROPY_HAL_H
3433
#include "py/obj.h"
3534
#include "py/runtime.h"
3635
#include "py/gc.h"

cc3200/mods/pybrtc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <std.h>
2929

3030
#include "py/mpconfig.h"
31-
#include MICROPY_HAL_H
3231
#include "py/obj.h"
3332
#include "py/runtime.h"
3433
#include "inc/hw_types.h"

cc3200/mods/pybsd.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
*/
2626

2727
#include "py/mpconfig.h"
28-
#include MICROPY_HAL_H
2928
#include "py/obj.h"
3029
#include "py/runtime.h"
3130
#include "inc/hw_types.h"

cc3200/mods/pybsleep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
#include <string.h>
2929

3030
#include "py/mpstate.h"
31-
#include MICROPY_HAL_H
3231
#include "py/runtime.h"
32+
#include "py/mphal.h"
3333
#include "inc/hw_types.h"
3434
#include "inc/hw_ints.h"
3535
#include "inc/hw_nvic.h"

cc3200/mods/pybspi.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <string.h>
3030

3131
#include "py/mpstate.h"
32-
#include MICROPY_HAL_H
3332
#include "py/runtime.h"
3433
#include "bufhelper.h"
3534
#include "inc/hw_types.h"

cc3200/mods/pybtimer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
#include <string.h>
3131

3232
#include "py/mpconfig.h"
33-
#include MICROPY_HAL_H
3433
#include "py/obj.h"
3534
#include "py/nlr.h"
3635
#include "py/runtime.h"
3736
#include "py/gc.h"
37+
#include "py/mphal.h"
3838
#include "inc/hw_types.h"
3939
#include "inc/hw_ints.h"
4040
#include "inc/hw_memmap.h"

cc3200/mods/pybuart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
#include <string.h>
3232

3333
#include "py/mpconfig.h"
34-
#include MICROPY_HAL_H
3534
#include "py/obj.h"
3635
#include "py/runtime.h"
3736
#include "py/objlist.h"
3837
#include "py/stream.h"
38+
#include "py/mphal.h"
3939
#include "inc/hw_types.h"
4040
#include "inc/hw_ints.h"
4141
#include "inc/hw_memmap.h"

cc3200/mods/pybwdt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
#include <stdint.h>
2828

2929
#include "py/mpconfig.h"
30-
#include MICROPY_HAL_H
3130
#include "py/obj.h"
3231
#include "py/runtime.h"
32+
#include "py/mphal.h"
3333
#include "inc/hw_types.h"
3434
#include "inc/hw_gpio.h"
3535
#include "inc/hw_ints.h"

cc3200/mpconfigport.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ typedef void *machine_ptr_t; // must be of pointer size
180180
typedef const void *machine_const_ptr_t; // must be of pointer size
181181
typedef long mp_off_t;
182182

183-
void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
184183
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
185184

186185
#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
@@ -204,7 +203,7 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
204203
// Include board specific configuration
205204
#include "mpconfigboard.h"
206205

207-
#define MICROPY_HAL_H "cc3200_hal.h"
206+
#define MICROPY_MPHALPORT_H "cc3200_hal.h"
208207
#define MICROPY_PORT_HAS_TELNET (1)
209208
#define MICROPY_PORT_HAS_FTP (1)
210209
#define MICROPY_PY_SYS_PLATFORM "WiPy"

cc3200/mptask.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
#include <stdint.h>
2929

3030
#include "py/mpconfig.h"
31-
#include MICROPY_HAL_H
3231
#include "py/obj.h"
3332
#include "py/runtime.h"
3433
#include "py/gc.h"
34+
#include "py/mphal.h"
3535
#include "inc/hw_memmap.h"
3636
#include "inc/hw_types.h"
3737
#include "inc/hw_ints.h"

cc3200/serverstask.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
#include <string.h>
2929

3030
#include "py/mpconfig.h"
31-
#include MICROPY_HAL_H
3231
#include "py/misc.h"
3332
#include "py/nlr.h"
33+
#include "py/mphal.h"
3434
#include "serverstask.h"
3535
#include "simplelink.h"
3636
#include "debug.h"

cc3200/telnet/telnet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#include <stdint.h>
2828

2929
#include "py/mpconfig.h"
30-
#include MICROPY_HAL_H
3130
#include "py/obj.h"
31+
#include "py/mphal.h"
3232
#include "telnet.h"
3333
#include "simplelink.h"
3434
#include "modnetwork.h"

cc3200/util/gccollect.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "py/gc.h"
3333
#include "gccollect.h"
3434
#include "gchelper.h"
35-
#include MICROPY_HAL_H
3635

3736
/******************************************************************************
3837
DECLARE PRIVATE DATA

esp8266/esp_mphal.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,7 @@ void ets_isr_mask(unsigned);
3232

3333
void mp_hal_init(void);
3434
void mp_hal_feed_watchdog(void);
35-
int mp_hal_stdin_rx_chr(void);
36-
void mp_hal_stdout_tx_str(const char *str);
37-
void mp_hal_stdout_tx_strn(const char *str, uint32_t len);
38-
void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
3935

40-
uint32_t mp_hal_ticks_ms(void);
41-
void mp_hal_delay_ms(uint32_t delay);
4236
void mp_hal_delay_us(uint32_t);
4337
void mp_hal_set_interrupt_char(int c);
4438
uint32_t mp_hal_get_cpu_freq(void);

0 commit comments

Comments
 (0)