CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/AP_Bootloader/support.h
Views: 1798
1
#pragma once
2
3
#include <AP_HAL_ChibiOS/AP_HAL_ChibiOS.h>
4
5
#define LED_ACTIVITY 1
6
#define LED_BOOTLOADER 2
7
8
/* board info forwarded from board-specific code to booloader */
9
struct boardinfo {
10
uint32_t board_type;
11
uint32_t board_rev;
12
uint32_t fw_size;
13
uint32_t extf_size;
14
} __attribute__((packed));
15
16
extern struct boardinfo board_info;
17
18
void init_uarts(void);
19
int16_t cin(unsigned timeout_ms);
20
int cin_word(uint32_t *wp, unsigned timeout_ms);
21
void cout(uint8_t *data, uint32_t len);
22
void port_setbaud(uint32_t baudrate);
23
#if defined(BOOTLOADER_FORWARD_OTG2_SERIAL)
24
bool update_otg2_serial_forward(void);
25
#endif
26
void flash_init();
27
28
uint32_t flash_func_read_word(uint32_t offset);
29
bool flash_func_write_word(uint32_t offset, uint32_t v);
30
bool flash_func_write_words(uint32_t offset, uint32_t *v, uint8_t n);
31
uint32_t flash_func_sector_size(uint32_t sector);
32
bool flash_func_is_erased(uint32_t sector);
33
bool flash_func_erase_sector(uint32_t sector, bool force_erase = false);
34
uint32_t flash_func_read_otp(uint32_t idx);
35
uint32_t flash_func_read_sn(uint32_t idx);
36
void flash_set_keep_unlocked(bool);
37
void lock_bl_port(void);
38
39
bool flash_write_flush(void);
40
bool flash_write_buffer(uint32_t address, const uint32_t *v, uint8_t nwords);
41
42
uint32_t get_mcu_id(void);
43
uint32_t get_mcu_desc(uint32_t len, uint8_t *buf);
44
45
uint32_t board_get_rtc_signature(void);
46
void board_set_rtc_signature(uint32_t sig);
47
48
void led_on(unsigned led);
49
void led_off(unsigned led);
50
void led_toggle(unsigned led);
51
52
void thread_sleep_ms(uint32_t ms);
53
void thread_sleep_us(uint32_t us);
54
55
void custom_startup(void);
56
57
#if defined(STM32H7) && CH_CFG_USE_HEAP
58
void check_ecc_errors(void);
59
#endif
60
61
// printf to debug uart (or USB)
62
extern "C" {
63
void uprintf(const char *fmt, ...) FMT_PRINTF(1,2);
64
}
65
66
// generate a LED sequence forever
67
void led_pulses(uint8_t npulses);
68
69
typedef struct mcu_des_t {
70
uint16_t mcuid;
71
const char *desc;
72
} mcu_des_t;
73
74
typedef struct mcu_rev_t {
75
uint16_t revid;
76
char rev;
77
} mcu_rev_t;
78
79