Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit 291acc8

Browse files
Merge branch 'master' into master
2 parents 29642fe + a9845d2 commit 291acc8

File tree

15 files changed

+329
-115
lines changed

15 files changed

+329
-115
lines changed

Diff for: .github/workflows/check-arduino.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
steps:
1818
- name: Checkout repository
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2020

2121
- name: Arduino Lint
2222
uses: arduino/arduino-lint-action@v1

Diff for: .github/workflows/compile-examples.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
steps:
3636
- name: Checkout repository
37-
uses: actions/checkout@v3
37+
uses: actions/checkout@v4
3838

3939
- name: Compile example sketches
4040
uses: arduino/compile-sketches@v1

Diff for: .github/workflows/spell-check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
steps:
1818
- name: Checkout repository
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2020

2121
- name: Spell check
2222
uses: codespell-project/actions-codespell@master

Diff for: .github/workflows/sync-labels.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ jobs:
2727

2828
steps:
2929
- name: Checkout repository
30-
uses: actions/checkout@v3
30+
uses: actions/checkout@v4
3131

3232
- name: Download JSON schema for labels configuration file
3333
id: download-schema
34-
uses: carlosperate/download-file-action@v1
34+
uses: carlosperate/download-file-action@v2
3535
with:
3636
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json
3737
location: ${{ runner.temp }}/label-configuration-schema
@@ -65,7 +65,7 @@ jobs:
6565

6666
steps:
6767
- name: Download
68-
uses: carlosperate/download-file-action@v1
68+
uses: carlosperate/download-file-action@v2
6969
with:
7070
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }}
7171

@@ -105,7 +105,7 @@ jobs:
105105
echo "::set-output name=flag::--dry-run"
106106
107107
- name: Checkout repository
108-
uses: actions/checkout@v3
108+
uses: actions/checkout@v4
109109

110110
- name: Download configuration files artifact
111111
uses: actions/download-artifact@v3
@@ -114,7 +114,7 @@ jobs:
114114
path: ${{ env.CONFIGURATIONS_FOLDER }}
115115

116116
- name: Remove unneeded artifact
117-
uses: geekyeggo/delete-artifact@v1
117+
uses: geekyeggo/delete-artifact@v2
118118
with:
119119
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
120120

Diff for: examples/Digital_programmable/CombinedIOExpander/CombinedIOExpander.ino

+25-38
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ void loop() {
5353

5454
Serial.println();
5555
// Write the status value to On to all the Output Pins
56-
setAll(SWITCH_ON);
56+
digital_programmables.writeAll(SWITCH_ON_ALL);
5757

5858
// Reads from all Input Pins
5959
readAll();
6060
delay(1000);
6161

6262
// Write the status value to Off all to all the Output Pins
63-
setAll(SWITCH_OFF);
63+
digital_programmables.writeAll(SWITCH_OFF_ALL);
6464

6565
// Reads from all Input Pins
6666
readAll();
@@ -69,43 +69,30 @@ void loop() {
6969

7070
}
7171

72-
void setAll(PinStatus status) {
73-
// Write the status value to each Pin
74-
digital_programmables.set(IO_WRITE_CH_PIN_00, status);
75-
digital_programmables.set(IO_WRITE_CH_PIN_01, status);
76-
digital_programmables.set(IO_WRITE_CH_PIN_02, status);
77-
digital_programmables.set(IO_WRITE_CH_PIN_03, status);
78-
digital_programmables.set(IO_WRITE_CH_PIN_04, status);
79-
digital_programmables.set(IO_WRITE_CH_PIN_05, status);
80-
digital_programmables.set(IO_WRITE_CH_PIN_06, status);
81-
digital_programmables.set(IO_WRITE_CH_PIN_07, status);
82-
digital_programmables.set(IO_WRITE_CH_PIN_08, status);
83-
digital_programmables.set(IO_WRITE_CH_PIN_09, status);
84-
digital_programmables.set(IO_WRITE_CH_PIN_10, status);
85-
digital_programmables.set(IO_WRITE_CH_PIN_11, status);
86-
}
8772

8873
void readAll() {
89-
// Reads from input pins. This API returns -1 if you try to read from a write channel.
90-
Serial.println("IO Pin 00: " + String(digital_programmables.read(IO_READ_CH_PIN_00)));
91-
Serial.println("IO Pin 01: " + String(digital_programmables.read(IO_READ_CH_PIN_01)));
92-
Serial.println("IO Pin 02: " + String(digital_programmables.read(IO_READ_CH_PIN_02)));
93-
Serial.println("IO Pin 03: " + String(digital_programmables.read(IO_READ_CH_PIN_03)));
94-
Serial.println("IO Pin 04: " + String(digital_programmables.read(IO_READ_CH_PIN_04)));
95-
Serial.println("IO Pin 05: " + String(digital_programmables.read(IO_READ_CH_PIN_05)));
96-
Serial.println("IO Pin 06: " + String(digital_programmables.read(IO_READ_CH_PIN_06)));
97-
Serial.println("IO Pin 07: " + String(digital_programmables.read(IO_READ_CH_PIN_07)));
98-
Serial.println("IO Pin 08: " + String(digital_programmables.read(IO_READ_CH_PIN_08)));
99-
Serial.println("IO Pin 09: " + String(digital_programmables.read(IO_READ_CH_PIN_09)));
100-
Serial.println("IO Pin 10: " + String(digital_programmables.read(IO_READ_CH_PIN_10)));
101-
Serial.println("IO Pin 11: " + String(digital_programmables.read(IO_READ_CH_PIN_11)));
74+
uint32_t inputs = digital_programmables.readAll();
75+
Serial.println("CH00: " + String((inputs & (1 << IO_READ_CH_PIN_00)) >> IO_READ_CH_PIN_00));
76+
Serial.println("CH01: " + String((inputs & (1 << IO_READ_CH_PIN_01)) >> IO_READ_CH_PIN_01));
77+
Serial.println("CH02: " + String((inputs & (1 << IO_READ_CH_PIN_02)) >> IO_READ_CH_PIN_02));
78+
Serial.println("CH03: " + String((inputs & (1 << IO_READ_CH_PIN_03)) >> IO_READ_CH_PIN_03));
79+
Serial.println("CH04: " + String((inputs & (1 << IO_READ_CH_PIN_04)) >> IO_READ_CH_PIN_04));
80+
Serial.println("CH05: " + String((inputs & (1 << IO_READ_CH_PIN_05)) >> IO_READ_CH_PIN_05));
81+
Serial.println("CH06: " + String((inputs & (1 << IO_READ_CH_PIN_06)) >> IO_READ_CH_PIN_06));
82+
Serial.println("CH07: " + String((inputs & (1 << IO_READ_CH_PIN_07)) >> IO_READ_CH_PIN_07));
83+
Serial.println("CH08: " + String((inputs & (1 << IO_READ_CH_PIN_08)) >> IO_READ_CH_PIN_08));
84+
Serial.println("CH09: " + String((inputs & (1 << IO_READ_CH_PIN_09)) >> IO_READ_CH_PIN_09));
85+
Serial.println("CH10: " + String((inputs & (1 << IO_READ_CH_PIN_10)) >> IO_READ_CH_PIN_10));
86+
Serial.println("CH11: " + String((inputs & (1 << IO_READ_CH_PIN_11)) >> IO_READ_CH_PIN_11));
87+
Serial.println();
88+
inputs = digital_inputs.readAll();
89+
Serial.println("CH00: " + String((inputs & (1 << DIN_READ_CH_PIN_00)) >> DIN_READ_CH_PIN_00));
90+
Serial.println("CH01: " + String((inputs & (1 << DIN_READ_CH_PIN_01)) >> DIN_READ_CH_PIN_01));
91+
Serial.println("CH02: " + String((inputs & (1 << DIN_READ_CH_PIN_02)) >> DIN_READ_CH_PIN_02));
92+
Serial.println("CH03: " + String((inputs & (1 << DIN_READ_CH_PIN_03)) >> DIN_READ_CH_PIN_03));
93+
Serial.println("CH04: " + String((inputs & (1 << DIN_READ_CH_PIN_04)) >> DIN_READ_CH_PIN_04));
94+
Serial.println("CH05: " + String((inputs & (1 << DIN_READ_CH_PIN_05)) >> DIN_READ_CH_PIN_05));
95+
Serial.println("CH06: " + String((inputs & (1 << DIN_READ_CH_PIN_06)) >> DIN_READ_CH_PIN_06));
96+
Serial.println("CH07: " + String((inputs & (1 << DIN_READ_CH_PIN_07)) >> DIN_READ_CH_PIN_07));
10297
Serial.println();
103-
Serial.println("DIN Pin 00: " + String(digital_inputs.read(DIN_READ_CH_PIN_00)));
104-
Serial.println("DIN Pin 01: " + String(digital_inputs.read(DIN_READ_CH_PIN_01)));
105-
Serial.println("DIN Pin 02: " + String(digital_inputs.read(DIN_READ_CH_PIN_02)));
106-
Serial.println("DIN Pin 03: " + String(digital_inputs.read(DIN_READ_CH_PIN_03)));
107-
Serial.println("DIN Pin 04: " + String(digital_inputs.read(DIN_READ_CH_PIN_04)));
108-
Serial.println("DIN Pin 05: " + String(digital_inputs.read(DIN_READ_CH_PIN_05)));
109-
Serial.println("DIN Pin 06: " + String(digital_inputs.read(DIN_READ_CH_PIN_06)));
110-
Serial.println("DIN Pin 07: " + String(digital_inputs.read(DIN_READ_CH_PIN_07)));
11198
}

Diff for: examples/Digital_programmable/Digital_input/Digital_input.ino

+10-9
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void setup() {
2828
}
2929

3030
void loop() {
31-
//Reads and Prints all channels and
31+
//Reads and Prints all channels (in a single operation)
3232
readAll();
3333

3434
//Read one-by-one each channel and print them one-by-one
@@ -62,13 +62,14 @@ void loop() {
6262
}
6363

6464
uint8_t readAll() {
65-
Serial.println("CH00: " + String(digital_inputs.read(DIN_READ_CH_PIN_00)));
66-
Serial.println("CH01: " + String(digital_inputs.read(DIN_READ_CH_PIN_01)));
67-
Serial.println("CH02: " + String(digital_inputs.read(DIN_READ_CH_PIN_02)));
68-
Serial.println("CH03: " + String(digital_inputs.read(DIN_READ_CH_PIN_03)));
69-
Serial.println("CH04: " + String(digital_inputs.read(DIN_READ_CH_PIN_04)));
70-
Serial.println("CH05: " + String(digital_inputs.read(DIN_READ_CH_PIN_05)));
71-
Serial.println("CH06: " + String(digital_inputs.read(DIN_READ_CH_PIN_06)));
72-
Serial.println("CH07: " + String(digital_inputs.read(DIN_READ_CH_PIN_07)));
65+
uint32_t inputs = digital_inputs.readAll();
66+
Serial.println("CH00: " + String((inputs & (1 << DIN_READ_CH_PIN_00)) >> DIN_READ_CH_PIN_00));
67+
Serial.println("CH01: " + String((inputs & (1 << DIN_READ_CH_PIN_01)) >> DIN_READ_CH_PIN_01));
68+
Serial.println("CH02: " + String((inputs & (1 << DIN_READ_CH_PIN_02)) >> DIN_READ_CH_PIN_02));
69+
Serial.println("CH03: " + String((inputs & (1 << DIN_READ_CH_PIN_03)) >> DIN_READ_CH_PIN_03));
70+
Serial.println("CH04: " + String((inputs & (1 << DIN_READ_CH_PIN_04)) >> DIN_READ_CH_PIN_04));
71+
Serial.println("CH05: " + String((inputs & (1 << DIN_READ_CH_PIN_05)) >> DIN_READ_CH_PIN_05));
72+
Serial.println("CH06: " + String((inputs & (1 << DIN_READ_CH_PIN_06)) >> DIN_READ_CH_PIN_06));
73+
Serial.println("CH07: " + String((inputs & (1 << DIN_READ_CH_PIN_07)) >> DIN_READ_CH_PIN_07));
7374
Serial.println();
7475
}

Diff for: examples/Digital_programmable/GPIO_programmable/GPIO_programmable.ino

+28-33
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
This example code is in the public domain.
1414
*/
15-
15+
1616
#include <Arduino_MachineControl.h>
1717
#include "Wire.h"
1818
using namespace machinecontrol;
@@ -42,52 +42,47 @@ void loop() {
4242
digital_programmables.set(IO_WRITE_CH_PIN_03, SWITCH_OFF);
4343
delay(1000);
4444

45+
Serial.println();
46+
// Sets all the status Pins Values to On in one single operation
47+
uint32_t status = ON_VALUE_PIN_10 | ON_VALUE_PIN_08 | ON_VALUE_PIN_06 | ON_VALUE_PIN_04 | ON_VALUE_PIN_02 | ON_VALUE_PIN_00;
48+
digital_programmables.writeAll(status);
49+
delay(1000);
50+
51+
// Toggles the actual status values of all digital programmables Pins
52+
digital_programmables.toggle();
53+
delay(1000);
54+
4555
Serial.println();
4656
// Write the status value to On to all the Output Pins
47-
setAll(SWITCH_ON);
57+
digital_programmables.writeAll(SWITCH_ON_ALL);
4858

4959
// Reads from all Input Pins
5060
readAll();
5161
delay(1000);
5262

5363
// Write the status value to Off all to all the Output Pins
54-
setAll(SWITCH_OFF);
64+
digital_programmables.writeAll(SWITCH_OFF_ALL);
5565

5666
// Reads from all Input Pins
5767
readAll();
5868
Serial.println();
5969
delay(1000);
60-
6170
}
6271

63-
void setAll(PinStatus status) {
64-
// Write the status value to each Pin
65-
digital_programmables.set(IO_WRITE_CH_PIN_00, status);
66-
digital_programmables.set(IO_WRITE_CH_PIN_01, status);
67-
digital_programmables.set(IO_WRITE_CH_PIN_02, status);
68-
digital_programmables.set(IO_WRITE_CH_PIN_03, status);
69-
digital_programmables.set(IO_WRITE_CH_PIN_04, status);
70-
digital_programmables.set(IO_WRITE_CH_PIN_05, status);
71-
digital_programmables.set(IO_WRITE_CH_PIN_06, status);
72-
digital_programmables.set(IO_WRITE_CH_PIN_07, status);
73-
digital_programmables.set(IO_WRITE_CH_PIN_08, status);
74-
digital_programmables.set(IO_WRITE_CH_PIN_09, status);
75-
digital_programmables.set(IO_WRITE_CH_PIN_10, status);
76-
digital_programmables.set(IO_WRITE_CH_PIN_11, status);
72+
uint8_t readAll() {
73+
uint32_t inputs = digital_programmables.readAll();
74+
Serial.println("CH00: " + String((inputs & (1 << IO_READ_CH_PIN_00)) >> IO_READ_CH_PIN_00));
75+
Serial.println("CH01: " + String((inputs & (1 << IO_READ_CH_PIN_01)) >> IO_READ_CH_PIN_01));
76+
Serial.println("CH02: " + String((inputs & (1 << IO_READ_CH_PIN_02)) >> IO_READ_CH_PIN_02));
77+
Serial.println("CH03: " + String((inputs & (1 << IO_READ_CH_PIN_03)) >> IO_READ_CH_PIN_03));
78+
Serial.println("CH04: " + String((inputs & (1 << IO_READ_CH_PIN_04)) >> IO_READ_CH_PIN_04));
79+
Serial.println("CH05: " + String((inputs & (1 << IO_READ_CH_PIN_05)) >> IO_READ_CH_PIN_05));
80+
Serial.println("CH06: " + String((inputs & (1 << IO_READ_CH_PIN_06)) >> IO_READ_CH_PIN_06));
81+
Serial.println("CH07: " + String((inputs & (1 << IO_READ_CH_PIN_07)) >> IO_READ_CH_PIN_07));
82+
Serial.println("CH08: " + String((inputs & (1 << IO_READ_CH_PIN_08)) >> IO_READ_CH_PIN_08));
83+
Serial.println("CH09: " + String((inputs & (1 << IO_READ_CH_PIN_09)) >> IO_READ_CH_PIN_09));
84+
Serial.println("CH10: " + String((inputs & (1 << IO_READ_CH_PIN_10)) >> IO_READ_CH_PIN_10));
85+
Serial.println("CH11: " + String((inputs & (1 << IO_READ_CH_PIN_11)) >> IO_READ_CH_PIN_11));
86+
Serial.println();
7787
}
7888

79-
void readAll() {
80-
// Reads from input pins. This API returns -1 if you try to read from a write channel.
81-
Serial.println("Pin 00: " + String(digital_programmables.read(IO_READ_CH_PIN_00)));
82-
Serial.println("Pin 01: " + String(digital_programmables.read(IO_READ_CH_PIN_01)));
83-
Serial.println("Pin 02: " + String(digital_programmables.read(IO_READ_CH_PIN_02)));
84-
Serial.println("Pin 03: " + String(digital_programmables.read(IO_READ_CH_PIN_03)));
85-
Serial.println("Pin 04: " + String(digital_programmables.read(IO_READ_CH_PIN_04)));
86-
Serial.println("Pin 05: " + String(digital_programmables.read(IO_READ_CH_PIN_05)));
87-
Serial.println("Pin 06: " + String(digital_programmables.read(IO_READ_CH_PIN_06)));
88-
Serial.println("Pin 07: " + String(digital_programmables.read(IO_READ_CH_PIN_07)));
89-
Serial.println("Pin 08: " + String(digital_programmables.read(IO_READ_CH_PIN_08)));
90-
Serial.println("Pin 09: " + String(digital_programmables.read(IO_READ_CH_PIN_09)));
91-
Serial.println("Pin 10: " + String(digital_programmables.read(IO_READ_CH_PIN_10)));
92-
Serial.println("Pin 11: " + String(digital_programmables.read(IO_READ_CH_PIN_11)));
93-
}

Diff for: library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Arduino_MachineControl
2-
version=1.1.0
2+
version=1.1.1
33
author=Arduino
44
maintainer=Arduino <[email protected]>
55
sentence=Arduino Library for Portenta Machine Control - PMC

Diff for: src/Arduino_MachineControl.h

+33-9
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@
99
#include "utility/RTC/PCF8563T.h"
1010
#include "utility/RTC/PCF8563T.h"
1111

12-
#include "Arduino.h"
13-
#include "pinDefinitions.h"
14-
#include "mbed.h"
12+
#include <Arduino.h>
13+
#include <pinDefinitions.h>
14+
#include <mbed.h>
15+
16+
#if __has_include("portenta_info.h")
17+
#include "portenta_info.h"
18+
#define TRY_REV2_RECOGNITION
19+
uint8_t* boardInfo();
20+
#define PMC_R2_SKU (24 << 8 | 3)
21+
#endif
1522

1623
namespace machinecontrol {
1724

@@ -28,6 +35,26 @@ class RTDClass {
2835
* @param channel (0-2)
2936
*/
3037
void selectChannel(int channel) {
38+
39+
#ifdef TRY_REV2_RECOGNITION
40+
// check if OTP data is present AND the board is mounted on a r2 carrier
41+
auto info = (PortentaBoardInfo*)boardInfo();
42+
if (info->magic == 0xB5 && info->carrier == PMC_R2_SKU) {
43+
// reverse channels 0 and 2
44+
switch (channel) {
45+
case 0:
46+
channel = 2;
47+
break;
48+
case 2:
49+
channel = 0;
50+
break;
51+
default:
52+
break;
53+
}
54+
}
55+
#endif
56+
#undef TRY_REV2_RECOGNITION
57+
3158
for (int i=0; i<3; i++) {
3259
ch_sel[i] = (i == channel ? 1 : 0);
3360
}
@@ -74,9 +101,6 @@ class RTDClass {
74101

75102
extern RTDClass temp_probes;
76103

77-
static mbed::CAN _can(PB_8, PH_13);
78-
79-
80104
/**
81105
* The COMMClass is used to initialize the CAN and RS485 LEDs and
82106
* establish the power mode of the CAN bus.
@@ -124,10 +148,10 @@ class COMMClass {
124148
can_disable = 1;
125149
}
126150

127-
UART _UART4_ = arduino::UART(PA_0, PI_9, NC, NC);
128-
mbed::CAN& can = _can;
151+
arduino::UART _UART4_ {PA_0, PI_9, NC, NC};
152+
mbed::CAN can {PB_8, PH_13};
129153

130-
RS485Class rs485 = RS485Class(_UART4_, PinNameToIndex(PA_0), PinNameToIndex(PI_13), PinNameToIndex(PI_10));
154+
RS485Class rs485 {_UART4_, PinNameToIndex(PA_0), PinNameToIndex(PI_13), PinNameToIndex(PI_10)};
131155

132156
void rs485Enable(bool enable) { digitalWrite(PinNameToIndex(PG_9), enable ? HIGH : LOW); }
133157
void rs485ModeRS232(bool enable) { digitalWrite(PinNameToIndex(PA_10), enable ? LOW : HIGH); }

Diff for: src/utility/RTC/PCF8563T.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ uint8_t PCF8563TClass::getMonths() {
172172
* @return byte with Day(s) value
173173
*/
174174
uint8_t PCF8563TClass::getDays() {
175-
uint8_t days = readByte(PCF8563T_DAYS_REG);
175+
uint8_t days = readByte(PCF8563T_DAYS_REG) & 0x3F;
176176
return (days & 0x0F) + ((days >> 4)*10);
177177
}
178178

0 commit comments

Comments
 (0)