File tree Expand file tree Collapse file tree 5 files changed +61
-2
lines changed Expand file tree Collapse file tree 5 files changed +61
-2
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,16 @@ class RP2040 {
363
363
return (uint32_t )rr;
364
364
}
365
365
366
+ bool isPicoW () {
367
+ #if !defined(ARDUINO_RASPBERRY_PI_PICO_W)
368
+ return false ;
369
+ #else
370
+ extern bool __isPicoW;
371
+ return __isPicoW;
372
+ #endif
373
+ }
374
+
375
+
366
376
private:
367
377
static void _SystickHandler () {
368
378
rp2040._epoch += 1LL << 24 ;
Original file line number Diff line number Diff line change @@ -75,6 +75,15 @@ Returns the total heap that was available to this program at compile time (i.e.
75
75
the Pico RAM size minus things like the ``.data `` and ``.bss `` sections and other
76
76
overhead).
77
77
78
+ Hardware Identification
79
+ -----------------------
80
+
81
+ bool isPicoW()
82
+ ~~~~~~~~~~~~~~
83
+ Returns the core's best guess if this code is running on a Raspberry Pi Pico W.
84
+ This would let you, possibly, use the same UF2 for Pico and PicoW by simply not
85
+ doing any WiFi calls.
86
+
78
87
Bootloader
79
88
----------
80
89
Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ restartCore1 KEYWORD2
44
44
reboot KEYWORD2
45
45
restart KEYWORD2
46
46
47
+ isPicoW KEYWORD2
48
+
47
49
getChipID KEYWORD2
48
50
49
51
hwrand32 KEYWORD2
Original file line number Diff line number Diff line change 19
19
*/
20
20
21
21
#include < pico/cyw43_arch.h>
22
+ #include " hardware/resets.h"
23
+ #include " hardware/gpio.h"
24
+ #include " hardware/adc.h"
22
25
23
26
#ifndef WIFICC
24
27
#define WIFICC CYW43_COUNTRY_WORLDWIDE
25
28
#endif
26
29
30
+ // Taken from https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf
31
+ // also discussion in https://github.com/earlephilhower/arduino-pico/issues/849
32
+ static bool CheckPicoW () {
33
+ adc_init ();
34
+ auto dir = gpio_get_dir (29 );
35
+ auto fnc = gpio_get_function (29 );
36
+ adc_gpio_init (29 );
37
+ adc_select_input (3 );
38
+ auto adc29 = adc_read ();
39
+ gpio_set_function (29 , fnc);
40
+ gpio_set_dir (29 , dir);
41
+
42
+ dir = gpio_get_dir (25 );
43
+ fnc = gpio_get_function (25 );
44
+ gpio_init (25 );
45
+ gpio_set_dir (25 , GPIO_IN);
46
+ auto gp25 = gpio_get (25 );
47
+ gpio_set_function (25 , fnc);
48
+ gpio_set_dir (25 , dir);
49
+
50
+ if (gp25) {
51
+ return true ; // Can't tell, so assume yes
52
+ } else if (adc29 < 200 ) {
53
+ return true ; // PicoW
54
+ } else {
55
+ return false ;
56
+ }
57
+ }
58
+
59
+ bool __isPicoW = true ;
60
+
27
61
extern " C" void initVariant () {
28
- cyw43_arch_init_with_country (WIFICC);
62
+ __isPicoW = CheckPicoW ();
63
+ if (__isPicoW) {
64
+ cyw43_arch_init_with_country (WIFICC);
65
+ }
29
66
}
Original file line number Diff line number Diff line change 3
3
// Pin definitions taken from:
4
4
// https://datasheets.raspberrypi.org/pico/pico-datasheet.pdf
5
5
6
+ extern bool __isPicoW ;
6
7
7
8
// LEDs
8
- #define PIN_LED (32u)
9
+ #define PIN_LED (__isPicoW ? 32u : 25u )
9
10
10
11
// Serial
11
12
#define PIN_SERIAL1_TX (0u)
You can’t perform that action at this time.
0 commit comments