File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -280,8 +280,15 @@ int main(void)
280
280
pCdc = (P_USB_CDC )usb_init ();
281
281
#endif
282
282
DEBUG_PIN_LOW ;
283
+
284
+ // output on D13 (PA.17)
285
+ LED_PORT .PINCFG [LED_PIN ].reg &= ~ (uint8_t )(PORT_PINCFG_INEN );
286
+ LED_PORT .DIRSET .reg = (uint32_t )(1 << LED_PIN );
287
+
283
288
/* Wait for a complete enum on usb or a '#' char on serial line */
284
289
while (1 ) {
290
+ pulse_led (1 ); // while we're waiting, blink the D13
291
+
285
292
#if SAM_BA_INTERFACE == SAM_BA_USBCDC_ONLY || SAM_BA_INTERFACE == SAM_BA_BOTH_INTERFACES
286
293
if (pCdc -> IsConfigured (pCdc ) != 0 ) {
287
294
main_b_cdc_enable = true;
@@ -309,3 +316,28 @@ int main(void)
309
316
#endif
310
317
}
311
318
}
319
+
320
+
321
+ // We'll have the D13 LED slowly pulse on and off with bitbang PWM
322
+ // for a nice 'hey we're in bootload mode' indication! -ada
323
+ static uint8_t pulse_tick = 0 ;
324
+ static int8_t pulse_dir = 1 ;
325
+ static int16_t pulse_pwm ;
326
+ void pulse_led (int8_t speed ) {
327
+ // blink D13
328
+ pulse_tick ++ ;
329
+ if (pulse_tick == 0 ) {
330
+ pulse_pwm += pulse_dir * speed ;
331
+ if (pulse_pwm > 255 ) {
332
+ pulse_pwm = 255 ;
333
+ pulse_dir = -1 ;
334
+ }
335
+ if (pulse_pwm < 0 ) {
336
+ pulse_pwm = 0 ;
337
+ pulse_dir = +1 ;
338
+ }
339
+ LED_ON ;
340
+ }
341
+ if (pulse_tick == pulse_pwm )
342
+ LED_OFF ;
343
+ }
Original file line number Diff line number Diff line change 29
29
30
30
#pragma once
31
31
32
+ // Gently pulse the D13 LED
33
+ #define LED_PIN 17
34
+ #define PORTA PORT->Group[0]
35
+ #define LED_PORT PORTA
36
+
37
+ #define LED_ON LED_PORT.OUTSET.reg = (uint32_t)(1 << LED_PIN);
38
+ #define LED_OFF LED_PORT.OUTCLR.reg = (uint32_t)(1 << LED_PIN);
32
39
/*
33
40
* If BOOT_DOUBLE_TAP_ADDRESS is defined the bootloader is started by
34
41
* quickly tapping two times on the reset button.
Original file line number Diff line number Diff line change @@ -201,6 +201,7 @@ void put_uint32(uint32_t n) {
201
201
202
202
void sam_ba_monitor_loop (void )
203
203
{
204
+ pulse_led (3 );
204
205
length = ptr_monitor_if -> getdata (data , SIZEBUFMAX );
205
206
ptr = data ;
206
207
for (i = 0 ; i < length ; i ++ , ptr ++ )
You can’t perform that action at this time.
0 commit comments