Skip to content

Commit 6c90841

Browse files
committed
Add more test cases
1 parent 19be86b commit 6c90841

File tree

14 files changed

+404
-1
lines changed

14 files changed

+404
-1
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
/CMakeLists.txt.user*
21
/playground
2+
3+
CMakeLists.txt.user*
4+

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@ This project would not have been possible without all the previous hard work
9393
I took good inspiration from it, especially when it comes to making CMake's initial
9494
compiler detection accept Arduinos very special binary layout.
9595

96+
## Third-Party Code
97+
98+
This project's test suites uses example code from third parties:
99+
100+
* [DigitalPotControl](tests/DigitalPotControl/DigitalPotControl.ino)
101+
by _Heather Dewey-Hagborg_ and _Tom Igoe_.
102+
* [EchoString](tests/EchoString/EchoString.ino)
103+
by unknown author: This example code is in the public domain.
104+
* [LinkStatus](tests/LinkStatus/LinkStatus.ino)
105+
by _Cristian Maglie_: This example code is in the public domain.
106+
* [TFTBitmapLogo](tests/TFTBitmapLogo/TFTBitmapLogo.ino)
107+
by _Enrico Gueli_: This example code is in the public domain.
108+
* [TwoPortReceive](tests/TwoPortReceive/TwoPortReceive.ino)
109+
by _Mikal Hart_ and _Tom Igoe_: this example code is in the public domain.
110+
96111
<!-- The following are the link reference definitions used in this document -->
97112

98113
[arduino-avr]: https://github.com/arduino/ArduinoCore-avr

tests/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,21 @@ function(arduino_cli_toolchain_add_test NAME)
7676
endforeach()
7777
endfunction()
7878

79+
# ======================================================================================================================
80+
# the actual tests
81+
# ======================================================================================================================
82+
83+
# A very minimal sketch without any additional dependencies
7984
arduino_cli_toolchain_add_test(CMakeBlink)
85+
86+
# Some sketches from Arduino examples that use one single core library
87+
arduino_cli_toolchain_add_test(DigitalPotControl SKIP attiny43) # some pins are mising for attiny43
88+
arduino_cli_toolchain_add_test(TwoPortReceive SKIP nano_33_iot nodemcu-32s) # no SoftwareSerial for samd and esp32
89+
90+
# Some sketches from Arduino examples that use core libraries which depend on other core libraries
91+
arduino_cli_toolchain_add_test(EchoString)
92+
arduino_cli_toolchain_add_test(LinkStatus)
93+
arduino_cli_toolchain_add_test(TFTBitmapLogo)
94+
95+
# TBD: A sketch which uses multiple independent libraries
96+
# TDB: A sketch with complex directory structure: multiple .ino files, multiple .cpp files, src folder
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.19)
2+
project(DigitalPotControl LANGUAGES CXX)
3+
add_executable(DigitalPotControl DigitalPotControl.ino)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
Digital Pot Control
3+
4+
This example controls an Analog Devices AD5206 digital potentiometer.
5+
The AD5206 has 6 potentiometer channels. Each channel's pins are labeled
6+
A - connect this to voltage
7+
W - this is the pot's wiper, which changes when you set it
8+
B - connect this to ground.
9+
10+
The AD5206 is SPI-compatible,and to command it, you send two bytes,
11+
one with the channel number (0 - 5) and one with the resistance value for the
12+
channel (0 - 255).
13+
14+
The circuit:
15+
* All A pins of AD5206 connected to +5V
16+
* All B pins of AD5206 connected to ground
17+
* An LED and a 220-ohm resistor in series connected from each W pin to ground
18+
* CS - to digital pin 10 (SS pin)
19+
* SDI - to digital pin 11 (MOSI pin)
20+
* CLK - to digital pin 13 (SCK pin)
21+
22+
created 10 Aug 2010
23+
by Tom Igoe
24+
25+
Thanks to Heather Dewey-Hagborg for the original tutorial, 2005
26+
27+
*/
28+
29+
30+
// include the SPI library:
31+
#include <SPI.h>
32+
33+
34+
// set pin 10 as the slave select for the digital pot:
35+
const int slaveSelectPin = 10;
36+
37+
void setup() {
38+
// set the slaveSelectPin as an output:
39+
pinMode(slaveSelectPin, OUTPUT);
40+
// initialize SPI:
41+
SPI.begin();
42+
}
43+
44+
void loop() {
45+
// go through the six channels of the digital pot:
46+
for (int channel = 0; channel < 6; channel++) {
47+
// change the resistance on this channel from min to max:
48+
for (int level = 0; level < 255; level++) {
49+
digitalPotWrite(channel, level);
50+
delay(10);
51+
}
52+
// wait a second at the top:
53+
delay(100);
54+
// change the resistance on this channel from max to min:
55+
for (int level = 0; level < 255; level++) {
56+
digitalPotWrite(channel, 255 - level);
57+
delay(10);
58+
}
59+
}
60+
61+
}
62+
63+
void digitalPotWrite(int address, int value) {
64+
// take the SS pin low to select the chip:
65+
digitalWrite(slaveSelectPin, LOW);
66+
delay(100);
67+
// send in the address and value via SPI:
68+
SPI.transfer(address);
69+
SPI.transfer(value);
70+
delay(100);
71+
// take the SS pin high to de-select the chip:
72+
digitalWrite(slaveSelectPin, HIGH);
73+
}

tests/EchoString/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.19)
2+
project(EchoString LANGUAGES CXX)
3+
add_executable(EchoString EchoString.ino)

tests/EchoString/EchoString.ino

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Firmata is a generic protocol for communicating with microcontrollers
3+
* from software on a host computer. It is intended to work with
4+
* any host computer software package.
5+
*
6+
* To download a host software package, please click on the following link
7+
* to open the list of Firmata client libraries in your default browser.
8+
*
9+
* https://github.com/firmata/arduino#firmata-client-libraries
10+
*/
11+
12+
/* This sketch accepts strings and raw sysex messages and echos them back.
13+
*
14+
* This example code is in the public domain.
15+
*/
16+
#include <Firmata.h>
17+
18+
void stringCallback(char *myString)
19+
{
20+
Firmata.sendString(myString);
21+
}
22+
23+
24+
void sysexCallback(byte command, byte argc, byte *argv)
25+
{
26+
Firmata.sendSysex(command, argc, argv);
27+
}
28+
29+
void setup()
30+
{
31+
Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION);
32+
Firmata.attach(STRING_DATA, stringCallback);
33+
Firmata.attach(START_SYSEX, sysexCallback);
34+
Firmata.begin(57600);
35+
}
36+
37+
void loop()
38+
{
39+
while (Firmata.available()) {
40+
Firmata.processInput();
41+
}
42+
}
43+
44+

tests/LinkStatus/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.19)
2+
project(LinkStatus LANGUAGES CXX)
3+
add_executable(LinkStatus LinkStatus.ino)

tests/LinkStatus/LinkStatus.ino

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
Link Status
3+
4+
This sketch prints the Ethernet link status. When the
5+
Ethernet cable is connected the link status should go to "ON".
6+
NOTE: Only WIZnet W5200 and W5500 are capable of reporting
7+
the link status. W5100 will report "Unknown".
8+
Hardware:
9+
- Ethernet shield or equivalent board/shield with WIZnet W5200/W5500
10+
Written by Cristian Maglie
11+
This example is public domain.
12+
*/
13+
14+
#include <SPI.h>
15+
#include <Ethernet.h>
16+
17+
void setup() {
18+
// You can use Ethernet.init(pin) to configure the CS pin
19+
//Ethernet.init(10); // Most Arduino shields
20+
//Ethernet.init(5); // MKR ETH Shield
21+
//Ethernet.init(0); // Teensy 2.0
22+
//Ethernet.init(20); // Teensy++ 2.0
23+
//Ethernet.init(15); // ESP8266 with Adafruit FeatherWing Ethernet
24+
//Ethernet.init(33); // ESP32 with Adafruit FeatherWing Ethernet
25+
26+
Serial.begin(9600);
27+
}
28+
29+
void loop() {
30+
auto link = Ethernet.linkStatus();
31+
Serial.print("Link status: ");
32+
switch (link) {
33+
case Unknown:
34+
Serial.println("Unknown");
35+
break;
36+
case LinkON:
37+
Serial.println("ON");
38+
break;
39+
case LinkOFF:
40+
Serial.println("OFF");
41+
break;
42+
}
43+
delay(1000);
44+
}

tests/TFTBitmapLogo/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.19)
2+
project(TFTBitmapLogo LANGUAGES CXX)
3+
add_executable(TFTBitmapLogo TFTBitmapLogo.ino)

0 commit comments

Comments
 (0)