Skip to content

Commit b4848cf

Browse files
committed
platform/avr: add reset to bootloader and reset functions
Signed-off-by: Rafael Silva <[email protected]>
1 parent 35caf4b commit b4848cf

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/platform/avr/boot.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* SPDX-License-Identifier: MIT
3+
* SPDX-FileCopyrightText: 2022 Rafael Silva <[email protected]>
4+
*/
5+
6+
#include <avr/wdt.h>
7+
8+
// Assuming the Caterina bootloader that comes with the 32u4
9+
uint16_t bootKey = 0x7777;
10+
volatile uint16_t *const bootKeyPtr = (volatile uint16_t *) 0x0800;
11+
12+
void reset()
13+
{
14+
wdt_enable(WDTO_15MS);
15+
for (;;) {
16+
}
17+
}
18+
19+
void bootloader()
20+
{
21+
*bootKeyPtr = bootKey;
22+
23+
reset();
24+
}

src/platform/avr/boot.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* SPDX-License-Identifier: MIT
3+
* SPDX-FileCopyrightText: 2022 Rafael Silva <[email protected]>
4+
*/
5+
6+
void reset() __attribute__((noreturn));
7+
void bootloader() __attribute__((noreturn));
8+
;

0 commit comments

Comments
 (0)