File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change 2525 */
2626
2727#include "py/mphal.h"
28+ #include "py/stream.h"
2829#include "shared/runtime/semihosting_arm.h"
2930#include "uart.h"
3031
3132// UART is better behaved with redirection under qemu-system-arm, so prefer that for stdio.
3233#define USE_UART (1)
3334#define USE_SEMIHOSTING (0)
3435
36+ uintptr_t ticks_ms (void );
37+ uintptr_t ticks_us (void );
38+
3539uintptr_t mp_hal_stdio_poll (uintptr_t poll_flags ) {
36- // Not implemented.
40+ #if USE_UART
41+ if ((poll_flags & MP_STREAM_POLL_RD ) && uart_rx_any ()) {
42+ return MP_STREAM_POLL_RD ;
43+ }
44+ #endif
3745 return 0 ;
3846}
3947
@@ -64,3 +72,27 @@ mp_uint_t mp_hal_stdout_tx_strn(const char *str, size_t len) {
6472 #endif
6573 return len ;
6674}
75+
76+ mp_uint_t mp_hal_ticks_ms (void ) {
77+ return ticks_ms ();
78+ }
79+
80+ mp_uint_t mp_hal_ticks_us (void ) {
81+ return ticks_us ();
82+ }
83+
84+ void mp_hal_delay_ms (mp_uint_t ms ) {
85+ mp_uint_t start = mp_hal_ticks_ms ();
86+ while (mp_hal_ticks_ms () - start < ms ) {
87+ }
88+ }
89+
90+ void mp_hal_delay_us (mp_uint_t us ) {
91+ mp_uint_t start = mp_hal_ticks_us ();
92+ while (mp_hal_ticks_us () - start < us ) {
93+ }
94+ }
95+
96+ mp_uint_t mp_hal_ticks_cpu (void ) {
97+ return 0 ;
98+ }
You can’t perform that action at this time.
0 commit comments