2014-07-02 08:42:37 -04:00
|
|
|
// We use the ST Cube HAL library for most hardware peripherals
|
2015-07-28 11:36:26 -04:00
|
|
|
#include STM32_HAL_H
|
2014-07-02 08:42:37 -04:00
|
|
|
|
2015-10-29 12:03:10 -04:00
|
|
|
// The unique id address differs per MCU. Ideally this define should
|
|
|
|
// go in some MCU-specific header, but for now it lives here.
|
|
|
|
#if defined(MCU_SERIES_F4)
|
|
|
|
#define MP_HAL_UNIQUE_ID_ADDRESS (0x1fff7a10)
|
|
|
|
#elif defined(MCU_SERIES_F7)
|
|
|
|
#define MP_HAL_UNIQUE_ID_ADDRESS (0x1ff0f420)
|
|
|
|
#else
|
|
|
|
#error mphal.h: Unrecognized MCU_SERIES
|
|
|
|
#endif
|
|
|
|
|
2014-07-02 08:42:37 -04:00
|
|
|
// Basic GPIO functions
|
|
|
|
#define GPIO_read_pin(gpio, pin) (((gpio)->IDR >> (pin)) & 1)
|
2015-08-03 18:07:20 -04:00
|
|
|
#if defined(MCU_SERIES_F7)
|
2015-07-28 14:13:33 -04:00
|
|
|
#define GPIO_set_pin(gpio, pin_mask) (((gpio)->BSRR) = (pin_mask))
|
|
|
|
#define GPIO_clear_pin(gpio, pin_mask) (((gpio)->BSRR) = ((pin_mask) << 16))
|
|
|
|
#else
|
2014-07-02 08:42:37 -04:00
|
|
|
#define GPIO_set_pin(gpio, pin_mask) (((gpio)->BSRRL) = (pin_mask))
|
|
|
|
#define GPIO_clear_pin(gpio, pin_mask) (((gpio)->BSRRH) = (pin_mask))
|
2015-07-28 14:13:33 -04:00
|
|
|
#endif
|
2014-07-22 10:57:36 -04:00
|
|
|
#define GPIO_read_output_pin(gpio, pin) (((gpio)->ODR >> (pin)) & 1)
|
2014-10-23 09:25:32 -04:00
|
|
|
|
2015-08-02 19:05:16 -04:00
|
|
|
void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio);
|
|
|
|
|
2014-10-23 09:25:32 -04:00
|
|
|
extern const byte mp_hal_status_to_errno_table[4];
|
|
|
|
|
|
|
|
NORETURN void mp_hal_raise(HAL_StatusTypeDef status);
|
2014-11-27 11:58:31 -05:00
|
|
|
void mp_hal_set_interrupt_char(int c); // -1 to disable
|
2015-02-13 10:04:53 -05:00
|
|
|
|
|
|
|
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, mp_uint_t len);
|
|
|
|
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len);
|
2015-10-27 16:31:42 -04:00
|
|
|
|
|
|
|
#define mp_hal_delay_ms HAL_Delay
|
|
|
|
#define mp_hal_ticks_ms HAL_GetTick
|