Skip to content

Commit 3499628

Browse files
committed
fix reset pin for nano rp2040 connect
1 parent 875514b commit 3499628

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

examples/NetworkConfiguratorDemo/NetworkConfiguratorDemo.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
* - Arduino Opta: press and hold the user button (BTN_USER) until the led (LED_USER) turns off
2121
* - Arduino MKR WiFi 1010: short the pin 7 to GND until the led turns off
2222
* - Arduino GIGA R1 WiFi: short the pin 7 to GND until the led turns off
23-
* - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off
2423
* - Nicla Vision: short the pin PA_13 to GND until the led turns off
2524
* - Portenta H7: short the pin 0 to GND until the led turns off
2625
* - Portenta C33: short the pin 0 to GND until the led turns off

src/Arduino_NetworkConfigurator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ NetworkConfiguratorStates NetworkConfiguratorClass::update() {
117117
* - Arduino Opta: press and hold the user button (BTN_USER) until the led (LED_USER) turns off
118118
* - Arduino MKR WiFi 1010: short the pin 7 to GND until the led turns off
119119
* - Arduino GIGA R1 WiFi: short the pin 7 to GND until the led turns off
120-
* - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off
121120
* - Nicla Vision: short the pin PA_13 to GND until the led turns off
122121
* - Portenta H7: short the pin 0 to GND until the led turns off
123122
* - Portenta C33: short the pin 0 to GND until the led turns off

src/Arduino_NetworkConfigurator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ enum class NetworkConfiguratorStates { ZERO_TOUCH_CONFIG,
5757
* - Arduino Opta: press and hold the user button (BTN_USER) until the led (LED_USER) turns off
5858
* - Arduino MKR WiFi 1010: short the pin 7 to GND until the led turns off
5959
* - Arduino GIGA R1 WiFi: short the pin 7 to GND until the led turns off
60-
* - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off
6160
* - Nicla Vision: short the pin PA_13 to GND until the led turns off
6261
* - Portenta H7: short the pin 0 to GND until the led turns off
6362
* - Portenta C33: short the pin 0 to GND until the led turns off

src/utility/ResetInput.cpp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ ResetInput::ResetInput() {
4949
_pin = PIN_RECONFIGURE;
5050
#endif
5151
_ledFeedbackPin = LED_RECONFIGURE;
52+
#if defined(ARDUINO_NANO_RP2040_CONNECT)
53+
_ledOn = 1;
54+
_ledOff = 0;
55+
_lastEvent = 0;
56+
#else
57+
_ledOn = LED_ON;
58+
_ledOff = LED_OFF;
59+
#endif
5260
_expired = false;
5361
_startPressed = 0;
5462
_fireEvent = false;
@@ -70,12 +78,15 @@ void ResetInput::begin() {
7078
if(_getPid_() != OPTA_WIFI_PID){
7179
_ledFeedbackPin = GREEN_LED;
7280
}
73-
#else
81+
#elif !defined(ARDUINO_NANO_RP2040_CONNECT)
7482
pinMode(_pin, INPUT_PULLUP);
7583
#endif
7684
pinMode(_ledFeedbackPin, OUTPUT);
77-
digitalWrite(_ledFeedbackPin, LED_OFF);
85+
digitalWrite(_ledFeedbackPin, _ledOff);
7886
attachInterrupt(digitalPinToInterrupt(_pin),_pressedCallback, CHANGE);
87+
#if defined(ARDUINO_NANO_RP2040_CONNECT)
88+
pinMode(_pin, INPUT_PULLUP);
89+
#endif
7990
}
8091

8192
bool ResetInput::isEventFired() {
@@ -84,7 +95,7 @@ bool ResetInput::isEventFired() {
8495
LEDFeedbackClass::getInstance().stop();
8596
#endif
8697
if(micros() - _startPressed > RESET_HOLD_TIME){
87-
digitalWrite(_ledFeedbackPin, LED_OFF);
98+
digitalWrite(_ledFeedbackPin, _ledOff);
8899
_expired = true;
89100
}
90101
}
@@ -106,17 +117,20 @@ void ResetInput::setPin(int pin) {
106117

107118
void ResetInput::_pressedCallback() {
108119
#if defined(ARDUINO_NANO_RP2040_CONNECT)
109-
if(digitalRead(_pin) == HIGH){
110-
#else
111-
if(digitalRead(_pin) == LOW){
120+
if(_lastEvent - micros() < 1000000){
121+
return;
122+
}
123+
_lastEvent = micros();
112124
#endif
125+
126+
if(digitalRead(_pin) == LOW){
113127
#if !defined(ARDUINO_NANO_RP2040_CONNECT) && !defined(ARDUINO_SAMD_MKRWIFI1010)
114128
LEDFeedbackClass::getInstance().stop();
115129
#endif
116130
_startPressed = micros();
117-
digitalWrite(_ledFeedbackPin, LED_ON);
131+
digitalWrite(_ledFeedbackPin, _ledOn);
118132
} else {
119-
digitalWrite(_ledFeedbackPin, LED_OFF);
133+
digitalWrite(_ledFeedbackPin, _ledOff);
120134
if(_startPressed != 0 && _expired){
121135
_fireEvent = true;
122136
}else{

src/utility/ResetInput.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,14 @@ class ResetInput{
6666
static inline ResetInputCallback _pressedCustomCallback;
6767
static inline int _pin;
6868
static inline int _ledFeedbackPin;
69+
static inline int _ledOff;
70+
static inline int _ledOn;
6971
static inline volatile bool _expired;
7072
static inline volatile bool _fireEvent;
7173
static inline volatile uint32_t _startPressed;
74+
#if defined(ARDUINO_NANO_RP2040_CONNECT)
75+
static inline volatile uint32_t _lastEvent;
76+
#endif
7277
/**
7378
* @brief Internal callback function to handle pin press events.
7479
*/

0 commit comments

Comments
 (0)