Skip to content

Commit

Permalink
all: Add py/mphal.h and use it in all ports.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dpgeorge authored and pfalcon committed Oct 31, 2015
1 parent 0bd3f32 commit 731f359
Show file tree
Hide file tree
Showing 100 changed files with 156 additions and 174 deletions.
1 change: 1 addition & 0 deletions bare-arm/mphalport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty file
1 change: 0 additions & 1 deletion cc3200/bootmgr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/fatfs/src/drivers/sd_diskio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion cc3200/fatfs/src/drivers/sflash_diskio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion cc3200/ftp/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion cc3200/ftp/updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions cc3200/hal/cc3200_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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;

Expand Down
7 changes: 0 additions & 7 deletions cc3200/hal/cc3200_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
2 changes: 1 addition & 1 deletion cc3200/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/misc/FreeRTOSHooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/misc/mperror.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion cc3200/misc/mpirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/misc/mpsystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/mods/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/mods/modnetwork.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion cc3200/mods/modubinascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*/

#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/binary.h"
Expand Down
1 change: 0 additions & 1 deletion cc3200/mods/modusocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion cc3200/mods/modussl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/mods/modutime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion cc3200/mods/modwipy.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "py/runtime.h"
#include "mperror.h"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/mods/modwlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion cc3200/mods/pybadc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/mods/pybi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion cc3200/mods/pybpin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion cc3200/mods/pybrtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion cc3200/mods/pybsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/mods/pybsleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion cc3200/mods/pybspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/mods/pybtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/mods/pybuart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/mods/pybwdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions cc3200/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/mptask.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/serverstask.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cc3200/telnet/telnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion cc3200/util/gccollect.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "py/gc.h"
#include "gccollect.h"
#include "gchelper.h"
#include MICROPY_HAL_H

/******************************************************************************
DECLARE PRIVATE DATA
Expand Down
6 changes: 0 additions & 6 deletions esp8266/esp_mphal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 731f359

Please sign in to comment.