Skip to content

Commit ab555f7

Browse files
committed
H7: Add in Dual pads into pin names
1 parent 438dae9 commit ab555f7

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

variants/arduino_portenta_h7/PinNames.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ void pinMode(PinName pinNumber, PinMode mode) {
1919
return;
2020
}
2121

22+
if (pinNumber & DUAL_PAD) return;
23+
2224
if (mode == INPUT) { // input mode
2325
gpio_pin_configure(arduino_ports[pinNumber >> 4].port, pinNumber & 0xf,
2426
GPIO_INPUT | GPIO_ACTIVE_HIGH);
@@ -35,20 +37,33 @@ void pinMode(PinName pinNumber, PinMode mode) {
3537
}
3638

3739
void digitalWrite(PinName pinNumber, PinStatus status) {
40+
if (pinNumber & DUAL_PAD) return;
3841
gpio_pin_set(arduino_ports[pinNumber >> 4].port, pinNumber & 0xf, status);
3942
}
4043

4144

4245
PinStatus digitalRead(PinName pinNumber) {
46+
if (pinNumber & DUAL_PAD) return LOW;
4347
return (gpio_pin_get(arduino_ports[pinNumber >> 4].port, pinNumber & 0xf) == 1) ? HIGH : LOW;
4448
}
4549

4650
int analogRead(PinName pinNumber) {
4751
// Not sure what to do here, does anyone do something like:
4852
// analogRead(PA_0c); or analogRead(PC2_ALT0)?
4953
// first pass only support ones on pins.
54+
if (pinNumber & DUAL_PAD) {
55+
switch (pinNumber & 0xf) {
56+
case 0: Serial.print("<A0>"); return analogRead(A0);
57+
case 1: Serial.print("<A1>"); return analogRead(A1);
58+
case 2: Serial.print("<A2>"); return analogRead(A2);
59+
case 3: Serial.print("<A3>"); return analogRead(A3);
60+
default: return -1;
61+
}
62+
63+
}
5064
int pin_index = PinNameToIndex(pinNumber);
5165
if (pin_index != -1) {
66+
Serial.write('<'); Serial.print(pin_index); Serial.write('>');
5267
return analogRead(pin_index);
5368
}
5469
return -1;
@@ -57,6 +72,7 @@ int analogRead(PinName pinNumber) {
5772

5873
void analogWrite(PinName pinNumber, int value) {
5974
// first pass only support ones on pins.
75+
if (pinNumber & DUAL_PAD) return;
6076
int pin_index = PinNameToIndex(pinNumber);
6177
if (pin_index != -1) {
6278
analogWrite(pin_index, value);
@@ -66,6 +82,7 @@ void analogWrite(PinName pinNumber, int value) {
6682

6783

6884
int PinNameToIndex(PinName P) {
85+
if (P & DUAL_PAD) return -1;
6986
for (size_t i = 0; i < ARRAY_SIZE(arduino_pins); i++) {
7087
if ((arduino_ports[P >> 4].port == arduino_pins[i].port) && ((P & 0xf) == arduino_pins[i].pin)) {
7188
return i;

variants/arduino_portenta_h7/PinNames.h

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
extern "C" {
77
#endif
88

9+
#define DUAL_PAD 0x800
10+
911
typedef enum {
1012
PA_0 = 0x00,
1113
PA_1 = 0x01,
@@ -176,6 +178,13 @@ typedef enum {
176178
PK_6 = 0xA6,
177179
PK_7 = 0xA7,
178180

181+
// Lets add the Analog only pins, will name them like the schematic, but number like
182+
PA_0C = 0X00 | DUAL_PAD,
183+
PA_1C = 0X01 | DUAL_PAD,
184+
PC_2C = 0X02 | DUAL_PAD,
185+
PC_3C = 0X03 | DUAL_PAD,
186+
187+
179188
WL_REG_ON = PJ_1,
180189
WL_HOST_WAKE = PJ_5,
181190
WL_SDIO_0 = PC_8,

0 commit comments

Comments
 (0)