Skip to content

Commit 544998b

Browse files
committed
Allow access to RGB LED as well as A4-A7 via classic Arduino APIs for Arduino Nano RP2040 Connect.
1 parent 2e04815 commit 544998b

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

src/utility/nano_rp2040_support.cpp

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
This file is part of the WiFiNINA library.
3+
Copyright (c) 2021 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#ifdef ARDUINO_NANO_RP2040_CONNECT
21+
22+
/******************************************************************************
23+
* INCLUDE
24+
******************************************************************************/
25+
26+
#include "nina_pins.h" /* variants/NANO_RP2040_CONNECT/ninaPins.h */
27+
#include "wifi_drv.h"
28+
29+
/******************************************************************************
30+
* FUNCTION DEFINITION
31+
******************************************************************************/
32+
33+
void pinMode(NinaPin pin, PinMode mode)
34+
{
35+
WiFiDrv::wifiDriverInit();
36+
Serial.print(__FUNCTION__);
37+
Serial.print(": pin = ");
38+
Serial.print(pin);
39+
Serial.print(", mode = ");
40+
Serial.println(mode);
41+
WiFiDrv::pinMode(static_cast<uint8_t>(pin), static_cast<uint8_t>(mode));
42+
}
43+
44+
PinStatus digitalRead(NinaPin pin)
45+
{
46+
WiFiDrv::wifiDriverInit();
47+
return WiFiDrv::digitalRead(static_cast<uint8_t>(pin));
48+
}
49+
50+
void digitalWrite(NinaPin pin, PinStatus value)
51+
{
52+
WiFiDrv::wifiDriverInit();
53+
Serial.print(__FUNCTION__);
54+
Serial.print(": pin = ");
55+
Serial.print(pin);
56+
Serial.print(", value = ");
57+
Serial.println(value);
58+
WiFiDrv::digitalWrite(static_cast<uint8_t>(pin), static_cast<uint8_t>(value));
59+
}
60+
61+
int analogRead(NinaPin pin)
62+
{
63+
WiFiDrv::wifiDriverInit();
64+
return WiFiDrv::analogRead(static_cast<uint8_t>(pin));
65+
}
66+
67+
void analogWrite(NinaPin pin, int value)
68+
{
69+
WiFiDrv::wifiDriverInit();
70+
WiFiDrv::analogWrite(static_cast<uint8_t>(pin), static_cast<uint8_t>(value));
71+
}
72+
73+
#endif /* ARDUINO_NANO_RP2040_CONNECT */

src/utility/wifi_drv.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,11 @@ void WiFiDrv::pinMode(uint8_t pin, uint8_t mode)
10601060
SpiDrv::spiSlaveDeselect();
10611061
}
10621062

1063+
PinStatus WiFiDrv::digitalRead(uint8_t pin)
1064+
{
1065+
#warning "This needs to be implemented!!!"
1066+
}
1067+
10631068
void WiFiDrv::digitalWrite(uint8_t pin, uint8_t value)
10641069
{
10651070
WAIT_FOR_SLAVE_SELECT();
@@ -1087,6 +1092,11 @@ void WiFiDrv::digitalWrite(uint8_t pin, uint8_t value)
10871092
SpiDrv::spiSlaveDeselect();
10881093
}
10891094

1095+
int WiFiDrv::analogRead(uint8_t pin)
1096+
{
1097+
#warning "This needs to be implemented!!!"
1098+
}
1099+
10901100
void WiFiDrv::analogWrite(uint8_t pin, uint8_t value)
10911101
{
10921102
WAIT_FOR_SLAVE_SELECT();

src/utility/wifi_drv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ class WiFiDrv
290290
static void debug(uint8_t on);
291291
static float getTemperature();
292292
static void pinMode(uint8_t pin, uint8_t mode);
293+
static PinStatus digitalRead(uint8_t pin);
293294
static void digitalWrite(uint8_t pin, uint8_t value);
295+
static int analogRead(uint8_t pin);
294296
static void analogWrite(uint8_t pin, uint8_t value);
295297

296298
static int8_t downloadFile(const char* url, uint8_t url_len, const char *filename, uint8_t filename_len);

0 commit comments

Comments
 (0)