Skip to content

Commit f42cf8a

Browse files
committed
giga: sync overlay with mbed pin order
fixes arduino#7
1 parent 2ba2f14 commit f42cf8a

File tree

4 files changed

+99
-15
lines changed

4 files changed

+99
-15
lines changed

Diff for: loader/boards/arduino_giga_r1_m7.overlay

+23-15
Original file line numberDiff line numberDiff line change
@@ -382,29 +382,37 @@
382382
<&gpiob 12 0>,
383383
<&gpiod 3 0>,
384384

385-
<&gpiob 6 0>, /* SDA1 */
386-
<&gpioh 12 0>,
387-
388-
<&gpioc 4 0>,
385+
<&gpioc 4 0>, /* A0 */
389386
<&gpioc 5 0>,
390387
<&gpiob 0 0>,
391388
<&gpiob 1 0>,
392389
<&gpioc 3 0>,
393390
<&gpioc 2 0>,
394-
<&gpioc 0 0>, /* A6 */
395-
<&gpioa 0 0>,
396-
<&gpioz 0 0>, /* analog only */
397-
<&gpioz 1 0>, /* analog only */
398-
<&gpioz 2 0>, /* analog only */
399-
<&gpioz 3 0>, /* analog only */
400-
<&gpioa 4 0>,
401-
<&gpioa 5 0>,
402-
<&gpiob 5 0>, /* CAN RX */
403-
<&gpiob 13 0>, /* CAN TX */
391+
<&gpioc 0 0>,
392+
<&gpioa 0 0>, /* A7 */
393+
<&gpioa 4 0>, /* A12 */
394+
<&gpioa 5 0>, /* A13 */
404395

405396
<&gpioi 12 GPIO_ACTIVE_LOW>,
406397
<&gpioj 13 GPIO_ACTIVE_LOW>,
407-
<&gpioe 3 GPIO_ACTIVE_LOW>;
398+
<&gpioe 3 GPIO_ACTIVE_LOW>,
399+
400+
<&gpiog 9 0>, /* SPI1 MISO */
401+
<&gpiod 7 0>, /* SPI1 MOSI */
402+
<&gpiob 3 0>, /* SPI1 SCK */
403+
404+
<&gpioa 15 0>, /* USB HOST ENABLE */
405+
406+
<&gpiob 5 0>, /* CAN RX */
407+
<&gpiob 13 0>, /* CAN TX */
408+
409+
<&gpiob 6 0>, /* SDA1 */
410+
<&gpioh 12 0>,
411+
412+
<&gpioz 0 0>, /* analog only A8 */
413+
<&gpioz 1 0>, /* analog only A9 */
414+
<&gpioz 2 0>, /* analog only A10 */
415+
<&gpioz 3 0>; /* analog only A11 */
408416

409417
builtin-led-gpios = <&gpioi 12 GPIO_ACTIVE_LOW>,
410418
<&gpioj 13 GPIO_ACTIVE_LOW>,

Diff for: variants/arduino_giga_r1_m7/pure_analog_pins.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "pure_analog_pins.h"
2+
3+
#undef A8
4+
#undef A9
5+
#undef A10
6+
#undef A11
7+
8+
PureAnalogPin A8_PURE(0);
9+
PureAnalogPin A9_PURE(1);
10+
PureAnalogPin A10_PURE(2);
11+
PureAnalogPin A11_PURE(3);
12+
13+
int getAnalogReadResolution();
14+
15+
int analogRead(PureAnalogPin pin) {
16+
return ::analogRead(A8 + pin.get());
17+
}

Diff for: variants/arduino_giga_r1_m7/pure_analog_pins.h

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#ifndef _PURE_ANALOG_PINS_
2+
#define _PURE_ANALOG_PINS_
3+
4+
/******************************************************************************
5+
* INCLUDE
6+
******************************************************************************/
7+
8+
#include "Arduino.h"
9+
10+
/******************************************************************************
11+
* PREPROCESSOR-MAGIC
12+
******************************************************************************/
13+
14+
#define PURE_ANALOG_AS_DIGITAL_ATTRIBUTE __attribute__ ((error("Can't use pins A8-A11 as digital")))
15+
16+
/******************************************************************************
17+
* TYPEDEF
18+
******************************************************************************/
19+
20+
class PureAnalogPin {
21+
public:
22+
PureAnalogPin(int _pin) : pin(_pin) {};
23+
int get() {
24+
return pin;
25+
};
26+
bool operator== (PureAnalogPin const & other) const {
27+
return pin == other.pin;
28+
}
29+
//operator int() = delete;
30+
__attribute__ ((error("Change me to a #define"))) operator int();
31+
private:
32+
int pin;
33+
};
34+
35+
extern PureAnalogPin A8_PURE;
36+
extern PureAnalogPin A9_PURE;
37+
extern PureAnalogPin A10_PURE;
38+
extern PureAnalogPin A11_PURE;
39+
40+
#define A8 A8_PURE
41+
#define A9 A9_PURE
42+
#define A10 A10_PURE
43+
#define A11 A11_PURE
44+
45+
/******************************************************************************
46+
* FUNCTION DECLARATION
47+
******************************************************************************/
48+
49+
void PURE_ANALOG_AS_DIGITAL_ATTRIBUTE pinMode (PureAnalogPin pin, PinMode mode);
50+
PinStatus PURE_ANALOG_AS_DIGITAL_ATTRIBUTE digitalRead (PureAnalogPin pin);
51+
void PURE_ANALOG_AS_DIGITAL_ATTRIBUTE digitalWrite(PureAnalogPin pin, PinStatus value);
52+
int analogRead (PureAnalogPin pin);
53+
void PURE_ANALOG_AS_DIGITAL_ATTRIBUTE analogWrite (PureAnalogPin pin, int value);
54+
55+
#undef PURE_ANALOG_AS_DIGITAL_ATTRIBUTE
56+
57+
#endif /* _PURE_ANALOG_PINS_ */

Diff for: variants/arduino_giga_r1_m7/variant.h

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#include "pure_analog_pins.h"
8+
79
// TODO: correctly handle these legacy defines
810
#define MOSI 0
911
#define MISO 0

0 commit comments

Comments
 (0)