|
27 | 27 | #ifndef __NRF52_HAL |
28 | 28 | #define __NRF52_HAL |
29 | 29 |
|
30 | | -#include "py/mpconfig.h" |
| 30 | +#include <stdbool.h> |
| 31 | +#include <stdint.h> |
| 32 | + |
| 33 | +#include "hal_gpio.h" |
| 34 | +#include "lib/utils/interrupt_char.h" |
| 35 | +#include "nrf.h" |
31 | 36 | #include NRF5_HAL_H |
32 | 37 | #include "pin.h" |
33 | | -#include "hal_gpio.h" |
34 | | - |
35 | | -#include "lib/oofatfs/ff.h" |
36 | | - |
37 | | -typedef enum |
38 | | -{ |
39 | | - HAL_OK = 0x00, |
40 | | - HAL_ERROR = 0x01, |
41 | | - HAL_BUSY = 0x02, |
42 | | - HAL_TIMEOUT = 0x03 |
43 | | -} HAL_StatusTypeDef; |
| 38 | +#include "py/mpconfig.h" |
44 | 39 |
|
45 | | -extern FIL* boot_output_file; |
| 40 | +extern volatile uint64_t ticks_ms; |
46 | 41 |
|
47 | | -static inline uint32_t hal_tick_fake(void) { |
48 | | - return 0; |
| 42 | +static inline mp_uint_t mp_hal_ticks_ms(void) { |
| 43 | + return ticks_ms; |
49 | 44 | } |
50 | 45 |
|
51 | | -#define mp_hal_ticks_ms hal_tick_fake // TODO: implement. Right now, return 0 always |
52 | | - |
53 | | -extern const unsigned char mp_hal_status_to_errno_table[4]; |
54 | | - |
55 | | -NORETURN void mp_hal_raise(HAL_StatusTypeDef status); |
56 | | -void mp_hal_set_interrupt_char(int c); // -1 to disable |
57 | | - |
58 | 46 | int mp_hal_stdin_rx_chr(void); |
59 | 47 | void mp_hal_stdout_tx_str(const char *str); |
60 | 48 | bool mp_hal_stdin_any(void); |
61 | 49 |
|
62 | | -#define mp_hal_pin_obj_t const pin_obj_t* |
63 | | -#define mp_hal_get_pin_obj(o) pin_find(o) |
64 | | -#define mp_hal_pin_high(p) hal_gpio_pin_high(p) |
65 | | -#define mp_hal_pin_low(p) hal_gpio_pin_low(p) |
66 | | -#define mp_hal_pin_read(p) hal_gpio_pin_read(p) |
67 | | -#define mp_hal_pin_write(p, v) do { if (v) { mp_hal_pin_high(p); } else { mp_hal_pin_low(p); } } while (0) |
68 | | -#define mp_hal_pin_od_low(p) mp_hal_pin_low(p) |
69 | | -#define mp_hal_pin_od_high(p) mp_hal_pin_high(p) |
70 | | -#define mp_hal_pin_open_drain(p) hal_gpio_cfg_pin(p->port, p->pin, HAL_GPIO_MODE_INPUT, HAL_GPIO_PULL_DISABLED) |
71 | | - |
72 | | - |
73 | | -// TODO: empty implementation for now. Used by machine_spi.c:69 |
74 | | -#define mp_hal_delay_us_fast(p) |
75 | | -#define mp_hal_ticks_us() (0) |
76 | | -#define mp_hal_ticks_cpu() (0) |
77 | | - |
78 | 50 | #endif |
79 | 51 |
|
0 commit comments