Skip to content

Commit 601c814

Browse files
committed
minimal: Allow to compile without defining MICROPY_HAL_H.
1 parent ccf45a4 commit 601c814

6 files changed

Lines changed: 15 additions & 9 deletions

File tree

lib/mp-readline/readline.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030

3131
#include "py/mpstate.h"
3232
#include "readline.h"
33+
#ifdef MICROPY_HAL_H
3334
#include MICROPY_HAL_H
35+
#endif
3436

3537
#if 0 // print debugging info
3638
#define DEBUG_PRINT (1)

minimal/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "py/pfenv.h"
1010
#include "py/gc.h"
1111
#include "pyexec.h"
12-
#include "pybstdio.h"
1312

1413
void do_str(const char *src) {
1514
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);

minimal/mpconfigport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ extern const struct _mp_obj_fun_builtin_t mp_builtin_open_obj;
6565
#include <alloca.h>
6666

6767
#define HAL_GetTick() 0
68+
int mp_hal_stdin_rx_chr(void);
69+
void mp_hal_stdout_tx_str(const char *str);
70+
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len);
71+
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len);
6872

6973
static inline void mp_hal_set_interrupt_char(char c) {}
7074

minimal/uart_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
// Receive single character
9-
int stdin_rx_chr(void) {
9+
int mp_hal_stdin_rx_chr(void) {
1010
unsigned char c = 0;
1111
#if MICROPY_MIN_USE_STDOUT
1212
int r = read(0, &c, 1);
@@ -16,7 +16,7 @@ int stdin_rx_chr(void) {
1616
}
1717

1818
// Send string of given length
19-
void stdout_tx_strn(const char *str, mp_uint_t len) {
19+
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
2020
#if MICROPY_MIN_USE_STDOUT
2121
int r = write(1, str, len);
2222
(void)r;

minimal/uart_extra.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <string.h>
22
#include <unistd.h>
33
#include "py/mpconfig.h"
4-
#include "pybstdio.h"
54

65
/*
76
* Extra UART functions
@@ -11,16 +10,16 @@
1110

1211
// Send "cooked" string of length, where every occurance of
1312
// LF character is replaced with CR LF.
14-
void stdout_tx_strn_cooked(const char *str, mp_uint_t len) {
13+
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len) {
1514
while (len--) {
1615
if (*str == '\n') {
17-
stdout_tx_strn("\r", 1);
16+
mp_hal_stdout_tx_strn("\r", 1);
1817
}
19-
stdout_tx_strn(str++, 1);
18+
mp_hal_stdout_tx_strn(str++, 1);
2019
}
2120
}
2221

2322
// Send zero-terminated string
24-
void stdout_tx_str(const char *str) {
25-
stdout_tx_strn(str, strlen(str));
23+
void mp_hal_stdout_tx_str(const char *str) {
24+
mp_hal_stdout_tx_strn(str, strlen(str));
2625
}

stmhal/printf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030

3131
#include "py/obj.h"
3232
#include "py/pfenv.h"
33+
#ifdef MICROPY_HAL_H
3334
#include MICROPY_HAL_H
35+
#endif
3436

3537
#if MICROPY_PY_BUILTINS_FLOAT
3638
#include "py/formatfloat.h"

0 commit comments

Comments
 (0)