forked from PX4/PX4-Bootloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bl.h
66 lines (52 loc) · 1.8 KB
/
bl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Common bootloader definitions.
*/
#pragma once
/*****************************************************************************
* Generic bootloader functions.
*/
/* board info forwarded from board-specific code to booloader */
struct boardinfo {
uint32_t board_type;
uint32_t board_rev;
uint32_t fw_size;
uint32_t systick_mhz; /* systick input clock */
} __attribute__((packed));
extern struct boardinfo board_info;
extern void jump_to_app(void);
extern void bootloader(unsigned timeout);
extern void delay(unsigned msec);
#define BL_WAIT_MAGIC 0x19710317 /* magic number in PWR regs to wait in bootloader */
/* generic timers */
#define NTIMERS 4
#define TIMER_BL_WAIT 0
#define TIMER_CIN 1
#define TIMER_LED 2
#define TIMER_DELAY 3
extern volatile unsigned timer[NTIMERS]; /* each timer decrements every millisecond if > 0 */
/* generic receive buffer for async reads */
extern void buf_put(uint8_t b);
extern int buf_get(void);
/*****************************************************************************
* Chip/board functions.
*/
/* LEDs */
#define LED_ACTIVITY 1
#define LED_BOOTLOADER 2
extern void led_on(unsigned led);
extern void led_off(unsigned led);
extern void led_toggle(unsigned led);
/* flash helpers from main_*.c */
extern uint32_t flash_func_sector_size(unsigned sector);
extern void flash_func_erase_sector(unsigned sector);
extern void flash_func_write_word(uint32_t address, uint32_t word);
extern uint32_t flash_func_read_word(uint32_t address);
extern uint32_t flash_func_read_otp(uint32_t address);
extern uint32_t flash_func_read_sn(uint32_t address);
/*****************************************************************************
* Interface in/output.
*/
extern void cinit(void *config);
extern void cfini(void);
extern int cin(void);
extern void cout(uint8_t *buf, unsigned len);