File tree Expand file tree Collapse file tree 2 files changed +31
-9
lines changed
Expand file tree Collapse file tree 2 files changed +31
-9
lines changed Original file line number Diff line number Diff line change 1- #include "pico.h"
2- #include "pico/time.h"
3- #include "pico/bootrom.h"
1+ extern " C" {
2+ #include " pico.h"
3+ #include " pico/time.h"
4+ #include " pico/bootrom.h"
5+ }
46
57// Allow user override of the LED mask
68#ifndef USB_BOOT_LED_ACTIVITY_MASK
@@ -17,14 +19,14 @@ static const uint32_t magic_token[] = {
1719static uint32_t __uninitialized_ram (magic_location)[count_of(magic_token)];
1820
1921// run at initialization time
20- static void __attribute__(( constructor )) boot_double_tap_check () {
22+ static void boot_double_tap_check () {
2123 for (uint i = 0 ; i < count_of (magic_token); i++) {
2224 if (magic_location[i] != magic_token[i]) {
2325 // Arm for 100 ms then disarm and continue booting
2426 for (i = 0 ; i < count_of (magic_token); i++) {
2527 magic_location[i] = magic_token[i];
2628 }
27- busy_wait_us (100000 );
29+ busy_wait_us (500000 );
2830 magic_location[0 ] = 0 ;
2931 return ;
3032 }
@@ -34,4 +36,13 @@ static void __attribute__((constructor)) boot_double_tap_check() {
3436 reset_usb_boot (USB_BOOT_LED_ACTIVITY_MASK, 0 );
3537}
3638
39+ class DoubleTap {
40+ public:
41+ DoubleTap () {
42+ boot_double_tap_check ();
43+ }
44+ };
45+
46+ DoubleTap dt __attribute__ ((init_priority (101 )));
47+
3748#endif
Original file line number Diff line number Diff line change 1- #include "pico.h"
2- #include "pico/time.h"
3- #include "pico/bootrom.h"
1+ extern " C" {
2+ #include " pico.h"
3+ #include " pico/time.h"
4+ #include " pico/bootrom.h"
5+ }
46
57// Allow user override of the LED mask
68#ifndef USB_BOOT_LED_ACTIVITY_MASK
@@ -17,7 +19,7 @@ static const uint32_t magic_token[] = {
1719static uint32_t __uninitialized_ram (magic_location)[count_of(magic_token)];
1820
1921// run at initialization time
20- static void __attribute__(( constructor )) boot_double_tap_check () {
22+ static void boot_double_tap_check () {
2123 for (uint i = 0 ; i < count_of (magic_token); i++) {
2224 if (magic_location[i] != magic_token[i]) {
2325 // Arm for 100 ms then disarm and continue booting
@@ -34,4 +36,13 @@ static void __attribute__((constructor)) boot_double_tap_check() {
3436 reset_usb_boot (USB_BOOT_LED_ACTIVITY_MASK, 0 );
3537}
3638
39+ class DoubleTap {
40+ public:
41+ DoubleTap () {
42+ boot_double_tap_check ();
43+ }
44+ };
45+
46+ DoubleTap dt __attribute__ ((init_priority (101 )));
47+
3748#endif
You can’t perform that action at this time.
0 commit comments