File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -86,5 +86,9 @@ You must reflect this change in several places:
8686Hopefully step three will not be needed in the future when I find a better
8787way 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
Original file line number Diff line number Diff 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+
164179void 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
You can’t perform that action at this time.
0 commit comments