Skip to content

Commit 1f5ca5a

Browse files
committed
change reset pin for portenta h7 and disable the reset procedure for machine control
1 parent 30febb2 commit 1f5ca5a

File tree

6 files changed

+52
-2
lines changed

6 files changed

+52
-2
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,22 @@ The procedure:
3434
* `Arduino MKR WiFi 1010`: short the pin 7 to GND until the led turns off
3535
* `Arduino GIGA R1 WiFi`: short the pin 7 to GND until the led turns off
3636
* `Arduino Nano RP2040 Connect`: short the pin 2 to 3.3V until the led turns off
37+
* `Arduino Portenta H7`: short the pin 0 to GND until the led turns off
3738
* Other boards: short the pin 2 to GND until the led turns off
39+
* `Portenta Machine Control`: currently the reset procedure is not available
40+
41+
### More on the reconfiguration pin
42+
Internally, the pin indicated in the procedure is set as `INPUT_PULLUP` (except for `Arduino Opta` ) and it's attached to an ISR fired on every change of the pin's status.
43+
44+
In order to be notified when the ISR is fired, it's possible to register a callback function using the function `NetworkConfigurator.addReconfigurePinCallback(callback)`. Please take the example as reference.
45+
46+
### Change the reconfiguration pin
47+
In order to change the default pin for resetting the board, it's possible to use the function `NetworkConfigurator.setReconfigurePin(your_pin)` specifying the new pin.
48+
The pin must be in the list of digital pins usable for interrupts. Please refer to the Arduino documentation for more details: https://docs.arduino.cc/language-reference/en/functions/external-interrupts/attachInterrupt/
49+
50+
### Disable the reconfiguration feature
51+
In order to disable the reconfiguration procedure, use this function in the sketch `NetworkConfigurator.setReconfigurePin(DISABLE_PIN)`
52+
3853

3954
## Configurator Agents
4055
The library provides a set of *Configurator Agents* that added as plug-in to the sketch handle the communication between the Arduino Network Configurator and an external client ([*Arduino IoT App*](https://cloud.arduino.cc/iot-remote-app/) and Arduino IoT Cloud) for configuring the board.

examples/NetworkConfiguratorDemo/NetworkConfiguratorDemo.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
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
2323
* - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off
24+
* - Portenta H7: short the pin 0 to GND until the led turns off
25+
* - Portenta Machine Control: the reset is not available
2426
* - Other boards: short the pin 2 to GND until the led turns off
2527
*
2628
* In this sketch the BLE and Serial interfaces are always enabled and ready for accepting

src/ANetworkConfigurator_Config.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
#if defined(ARDUINO_PORTENTA_H7_M7)
5858
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
5959
#define ZERO_TOUCH_ENABLED 1
60-
#define PIN_RECONFIGURE 2
60+
#define I2C_ADD_DETECT_MACHINE_CONTROL_1 0x23
61+
#define I2C_ADD_DETECT_MACHINE_CONTROL_2 0x22
62+
#define PIN_RECONFIGURE 0
6163
#define LED_RECONFIGURE LED_BUILTIN
6264
#define BOARD_HAS_RGB
6365
#define GREEN_LED LEDG

src/Arduino_NetworkConfigurator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ NetworkConfiguratorStates NetworkConfiguratorClass::update() {
122122
* - Arduino MKR WiFi 1010: short the pin 7 to GND until the led turns off
123123
* - Arduino GIGA R1 WiFi: short the pin 7 to GND until the led turns off
124124
* - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off
125+
* - Portenta H7: short the pin 0 to GND until the led turns off
126+
* - Portenta Machine Control: the reset is not available
125127
* - Other boards: short the pin 2 to GND until the led turns off
126128
*/
127129

src/Arduino_NetworkConfigurator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ enum class NetworkConfiguratorStates { ZERO_TOUCH_CONFIG,
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
6060
* - Arduino Nano RP2040 Connect: short the pin 2 to 3.3V until the led turns off
61+
* - Portenta H7: short the pin 0 to GND until the led turns off
62+
* - Portenta Machine Control: the reset is not available
6163
* - Other boards: short the pin 2 to GND until the led turns off
6264
*
6365
*/

src/utility/ResetInput.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,28 @@
1111
#include "ResetInput.h"
1212
#include "utility/LEDFeedback.h"
1313

14+
#if defined(ARDUINO_PORTENTA_H7_M7)
15+
#include <Wire.h>
16+
17+
18+
bool isPortentaMachineControlAttached() {
19+
Wire.begin();
20+
Wire.beginTransmission(I2C_ADD_DETECT_MACHINE_CONTROL_1);
21+
if (Wire.endTransmission() != 0) {
22+
return false;
23+
}
24+
25+
Wire.beginTransmission(I2C_ADD_DETECT_MACHINE_CONTROL_2);
26+
if (Wire.endTransmission() != 0) {
27+
return false;
28+
}
29+
30+
Wire.end();
31+
return true;
32+
}
33+
34+
#endif
35+
1436
ResetInput &ResetInput::getInstance() {
1537
static ResetInput instance;
1638
return instance;
@@ -25,6 +47,12 @@ ResetInput::ResetInput() {
2547
}
2648

2749
void ResetInput::begin() {
50+
#if defined(ARDUINO_PORTENTA_H7_M7)
51+
if(isPortentaMachineControlAttached()) {
52+
return; // Portenta Machine Control is not supported
53+
}
54+
#endif
55+
2856
if(_pin == DISABLE_PIN){
2957
return;
3058
}
@@ -35,7 +63,6 @@ void ResetInput::begin() {
3563
#endif
3664
pinMode(LED_RECONFIGURE, OUTPUT);
3765
digitalWrite(LED_RECONFIGURE, LED_OFF);
38-
3966
attachInterrupt(digitalPinToInterrupt(_pin),_pressedCallback, CHANGE);
4067
}
4168

0 commit comments

Comments
 (0)