Skip to content

Commit 44b85d1

Browse files
committed
Added a specific place for code to check if the bootloader
should run or just jump straight to user code.
1 parent cf0eb64 commit 44b85d1

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

README.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,9 @@ You must reflect this change in several places:
8686
Hopefully step three will not be needed in the future when I find a better
8787
way to implement this part of the code.
8888

89+
If you want the bootloader to only be invoked under certain conditions, e.g.
90+
the presence of USB power then please modify the `want_bootloader` function
91+
in `main.c`
92+
8993

9094

src/main.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,29 @@ void timer1_isr_forward() __naked {
161161
#endif
162162
}
163163

164+
uint8_t want_bootloader() {
165+
// Check if we want to the bootloader to run
166+
// Here is the place to check for things like USB power and jump straight to
167+
// user code under some conditions.
168+
169+
/*
170+
// Check for USB +5V, if not present go straight to user code
171+
PxDIR &= ~y;
172+
if (!Px_y)
173+
return 0;
174+
*/
175+
176+
return 1;
177+
}
178+
164179
void bootloader_main ()
165180
{
166181
__xdata char buff[100];
167182
uint8_t ihx_status;
168183
uint16_t read_start_addr, read_len;
169184

170-
/*
171-
// Check for USB +5V, if not present go straight to user code
172-
PxDIR &= ~y;
173-
if (!Px_y)
185+
if (!want_bootloader())
174186
jump_to_user();
175-
*/
176187

177188
clock_init();
178189

0 commit comments

Comments
 (0)