Skip to content

Commit c00467a

Browse files
authored
Change reset pin of Portenta boards for clashing with Portenta Carriers and Shields (#15)
* change reset pin for portenta h7 and disable the reset procedure for machine control * change reset pin for portenta c33 to 0
1 parent 2352608 commit c00467a

File tree

6 files changed

+57
-3
lines changed

6 files changed

+57
-3
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,23 @@ 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
38+
* `Arduino Portenta C33`: short the pin 0 to GND until the led turns off
3739
* Other boards: short the pin 2 to GND until the led turns off
40+
* `Portenta Machine Control`: currently the reset procedure is not available
41+
42+
### More on the reconfiguration pin
43+
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.
44+
45+
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.
46+
47+
### Change the reconfiguration pin
48+
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.
49+
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/
50+
51+
### Disable the reconfiguration feature
52+
In order to disable the reconfiguration procedure, use this function in the sketch `NetworkConfigurator.setReconfigurePin(DISABLE_PIN)`
53+
3854

3955
## Configurator Agents
4056
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
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 C33: short the pin 0 to GND until the led turns off
26+
* - Portenta Machine Control: the reset is not available
2427
* - Other boards: short the pin 2 to GND until the led turns off
2528
*
2629
* In this sketch the BLE and Serial interfaces are always enabled and ready for accepting

src/ANetworkConfigurator_Config.h

Lines changed: 4 additions & 2 deletions
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
@@ -108,7 +110,7 @@
108110
#if defined(ARDUINO_PORTENTA_C33)
109111
#define NETWORK_CONFIGURATOR_COMPATIBLE 1
110112
#define ZERO_TOUCH_ENABLED 1
111-
#define PIN_RECONFIGURE 2
113+
#define PIN_RECONFIGURE 0
112114
#define LED_RECONFIGURE LEDG
113115
#define BOARD_HAS_RGB
114116
#define GREEN_LED LEDG

src/Arduino_NetworkConfigurator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ 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 C33: short the pin 0 to GND until the led turns off
127+
* - Portenta Machine Control: the reset is not available
125128
* - Other boards: short the pin 2 to GND until the led turns off
126129
*/
127130

src/Arduino_NetworkConfigurator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ 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 C33: short the pin 0 to GND until the led turns off
63+
* - Portenta Machine Control: the reset is not available
6164
* - Other boards: short the pin 2 to GND until the led turns off
6265
*
6366
*/

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)