2018-06-21 03:41:07 -03:00
|
|
|
#pragma once
|
2018-03-28 21:45:13 -03:00
|
|
|
|
|
|
|
#define LED_ACTIVITY 1
|
|
|
|
#define LED_BOOTLOADER 2
|
|
|
|
|
|
|
|
/* board info forwarded from board-specific code to booloader */
|
|
|
|
struct boardinfo {
|
2018-06-21 03:41:07 -03:00
|
|
|
uint32_t board_type;
|
|
|
|
uint32_t board_rev;
|
|
|
|
uint32_t fw_size;
|
2021-06-13 08:52:57 -03:00
|
|
|
uint32_t extf_size;
|
2018-03-28 21:45:13 -03:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
extern struct boardinfo board_info;
|
|
|
|
|
2018-06-25 00:39:22 -03:00
|
|
|
void init_uarts(void);
|
2018-03-28 21:45:13 -03:00
|
|
|
int16_t cin(unsigned timeout_ms);
|
2018-06-24 19:29:54 -03:00
|
|
|
int cin_word(uint32_t *wp, unsigned timeout_ms);
|
2018-03-28 21:45:13 -03:00
|
|
|
void cout(uint8_t *data, uint32_t len);
|
2018-06-25 00:39:22 -03:00
|
|
|
void port_setbaud(uint32_t baudrate);
|
2024-06-13 03:49:50 -03:00
|
|
|
#if defined(BOOTLOADER_FORWARD_OTG2_SERIAL)
|
|
|
|
bool update_otg2_serial_forward(void);
|
|
|
|
#endif
|
2018-03-28 21:45:13 -03:00
|
|
|
void flash_init();
|
|
|
|
|
|
|
|
uint32_t flash_func_read_word(uint32_t offset);
|
2019-02-03 21:42:16 -04:00
|
|
|
bool flash_func_write_word(uint32_t offset, uint32_t v);
|
|
|
|
bool flash_func_write_words(uint32_t offset, uint32_t *v, uint8_t n);
|
2018-03-28 21:45:13 -03:00
|
|
|
uint32_t flash_func_sector_size(uint32_t sector);
|
2023-07-31 03:26:43 -03:00
|
|
|
bool flash_func_is_erased(uint32_t sector);
|
2022-10-06 21:14:38 -03:00
|
|
|
bool flash_func_erase_sector(uint32_t sector, bool force_erase = false);
|
2018-03-28 21:45:13 -03:00
|
|
|
uint32_t flash_func_read_otp(uint32_t idx);
|
|
|
|
uint32_t flash_func_read_sn(uint32_t idx);
|
2018-06-24 19:29:54 -03:00
|
|
|
void flash_set_keep_unlocked(bool);
|
2018-06-24 21:28:40 -03:00
|
|
|
void lock_bl_port(void);
|
2018-03-28 21:45:13 -03:00
|
|
|
|
2020-07-14 18:31:14 -03:00
|
|
|
bool flash_write_flush(void);
|
|
|
|
bool flash_write_buffer(uint32_t address, const uint32_t *v, uint8_t nwords);
|
|
|
|
|
2018-03-28 21:45:13 -03:00
|
|
|
uint32_t get_mcu_id(void);
|
|
|
|
uint32_t get_mcu_desc(uint32_t len, uint8_t *buf);
|
|
|
|
|
2018-06-27 05:46:47 -03:00
|
|
|
uint32_t board_get_rtc_signature(void);
|
|
|
|
void board_set_rtc_signature(uint32_t sig);
|
|
|
|
|
2018-03-28 21:45:13 -03:00
|
|
|
void led_on(unsigned led);
|
|
|
|
void led_off(unsigned led);
|
|
|
|
void led_toggle(unsigned led);
|
|
|
|
|
2024-01-13 01:28:10 -04:00
|
|
|
void thread_sleep_ms(uint32_t ms);
|
|
|
|
|
2023-07-31 01:15:59 -03:00
|
|
|
void custom_startup(void);
|
|
|
|
|
2024-07-23 20:54:15 -03:00
|
|
|
#if defined(STM32H7) && CH_CFG_USE_HEAP
|
2024-01-13 01:28:10 -04:00
|
|
|
void check_ecc_errors(void);
|
2024-07-23 20:54:15 -03:00
|
|
|
#endif
|
2024-01-13 01:28:10 -04:00
|
|
|
|
2019-02-08 01:37:03 -04:00
|
|
|
// printf to debug uart (or USB)
|
2019-02-06 17:11:32 -04:00
|
|
|
extern "C" {
|
2021-08-03 23:44:31 -03:00
|
|
|
void uprintf(const char *fmt, ...) FMT_PRINTF(1,2);
|
2019-02-06 17:11:32 -04:00
|
|
|
}
|
2018-03-28 21:45:13 -03:00
|
|
|
|
|
|
|
// generate a LED sequence forever
|
|
|
|
void led_pulses(uint8_t npulses);
|
|
|
|
|
2018-06-21 03:41:07 -03:00
|
|
|
typedef struct mcu_des_t {
|
|
|
|
uint16_t mcuid;
|
|
|
|
const char *desc;
|
|
|
|
} mcu_des_t;
|
|
|
|
|
|
|
|
typedef struct mcu_rev_t {
|
|
|
|
uint16_t revid;
|
|
|
|
char rev;
|
|
|
|
} mcu_rev_t;
|