File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
variants/arduino_portenta_h7 Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,32 @@ void digitalWrite(PinName pinNumber, PinStatus status) {
3939}
4040
4141
42+ PinStatus digitalRead (PinName pinNumber) {
43+ return (gpio_pin_get (arduino_ports[pinNumber >> 4 ].port , pinNumber & 0xf ) == 1 ) ? HIGH : LOW;
44+ }
45+
46+ int analogRead (PinName pinNumber) {
47+ // Not sure what to do here, does anyone do something like:
48+ // analogRead(PA_0c); or analogRead(PC2_ALT0)?
49+ // first pass only support ones on pins.
50+ int pin_index = PinNameToIndex (pinNumber);
51+ if (pin_index != -1 ) {
52+ return analogRead (pin_index);
53+ }
54+ return -1 ;
55+ }
56+
57+
58+ void analogWrite (PinName pinNumber, int value) {
59+ // first pass only support ones on pins.
60+ int pin_index = PinNameToIndex (pinNumber);
61+ if (pin_index != -1 ) {
62+ analogWrite (pin_index, value);
63+ }
64+ }
65+
66+
67+
4268int PinNameToIndex (PinName P) {
4369 for (size_t i = 0 ; i < ARRAY_SIZE (arduino_pins); i++) {
4470 if ((arduino_ports[P >> 4 ].port == arduino_pins[i].port ) && ((P & 0xf ) == arduino_pins[i].pin )) {
Original file line number Diff line number Diff line change @@ -302,6 +302,9 @@ void pinMode(PinName pinNumber, PinMode mode);
302302void digitalWrite (PinName pinNumber , PinStatus status );
303303int PinNameToIndex (PinName P );
304304PinName digitalPinToPinName (pin_size_t P );
305+ PinStatus digitalRead (PinName pinNumber );
306+ int analogRead (PinName pinNumber );
307+ void analogWrite (PinName pinNumber , int value );
305308
306309#endif
307310
You can’t perform that action at this time.
0 commit comments