Skip to content

Commit 6912fa8

Browse files
committed
fix: define LED_BUILTIN to allow build
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 70fe697 commit 6912fa8

File tree

2 files changed

+42
-38
lines changed

2 files changed

+42
-38
lines changed

examples/NonReg/SPI_loop/SPI_loop.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
*/
2020
#include "SPI.h"
2121

22+
#ifndef LED_BUILTIN
23+
#define LED_BUILTIN PNUM_NOT_DEFINED
24+
#warning "LED_BUILTIN is not defined."
25+
#endif
26+
2227
#define MOSI_PIN PIN_SPI_MOSI
2328
#define MISO_PIN PIN_SPI_MISO
2429
#define SCK_PIN PIN_SPI_SCK

examples/NonReg/SerialLoop/SerialLoop.ino

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
#include "utils.h"
1414

1515
/*
16-
* 1 - Connect Rx/Tx of the desired Serial
17-
* 2 - Define UART_TEST_INSTANCE
18-
* ! Ensure Serial feature is enabled thanks 'U(S)ART support menu'!
19-
* 3 - Optionnal: comment unwanted speed in serialSpeed array.
20-
*/
16+
1 - Connect Rx/Tx of the desired Serial
17+
2 - Define UART_TEST_INSTANCE
18+
! Ensure Serial feature is enabled thanks 'U(S)ART support menu'!
19+
3 - Optionnal: comment unwanted speed in serialSpeed array.
20+
*/
2121
#define SERIAL_PORT_TESTED SerialTest
22-
#if defined(SERIAL_UART_INSTANCE) && (SERIAL_UART_INSTANCE != 1)
22+
#if defined(SERIAL_UART_INSTANCE) && (SERIAL_UART_INSTANCE != 1) && defined(USART1_BASE)
2323
#define UART_TEST_INSTANCE USART1
24-
#elif defined(USART2_BASE)
24+
#elif defined(SERIAL_UART_INSTANCE) && (SERIAL_UART_INSTANCE != 2) && defined(USART2_BASE)
2525
#define UART_TEST_INSTANCE USART2
2626
#else
2727
#define UART_TEST_INSTANCE LPUART1
@@ -40,23 +40,23 @@ struct serialTest_s {
4040

4141
static serialTest serialConfig[] = {
4242
#ifdef UART_WORDLENGTH_7B
43-
DECL_CONFIG(SERIAL_7N1),
44-
DECL_CONFIG(SERIAL_7N2),
45-
DECL_CONFIG(SERIAL_6E1),
46-
DECL_CONFIG(SERIAL_6E2),
47-
DECL_CONFIG(SERIAL_6O1),
48-
DECL_CONFIG(SERIAL_6O2),
43+
DECL_CONFIG(SERIAL_7N1),
44+
DECL_CONFIG(SERIAL_7N2),
45+
DECL_CONFIG(SERIAL_6E1),
46+
DECL_CONFIG(SERIAL_6E2),
47+
DECL_CONFIG(SERIAL_6O1),
48+
DECL_CONFIG(SERIAL_6O2),
4949
#endif
50-
DECL_CONFIG(SERIAL_8N1),
51-
DECL_CONFIG(SERIAL_8N2),
52-
DECL_CONFIG(SERIAL_7E1),
53-
DECL_CONFIG(SERIAL_8E1),
54-
DECL_CONFIG(SERIAL_7E2),
55-
DECL_CONFIG(SERIAL_7O1),
56-
DECL_CONFIG(SERIAL_8O1),
57-
DECL_CONFIG(SERIAL_7O2),
58-
DECL_CONFIG(SERIAL_8O2),
59-
DECL_CONFIG(SERIAL_8E2)
50+
DECL_CONFIG(SERIAL_8N1),
51+
DECL_CONFIG(SERIAL_8N2),
52+
DECL_CONFIG(SERIAL_7E1),
53+
DECL_CONFIG(SERIAL_8E1),
54+
DECL_CONFIG(SERIAL_7E2),
55+
DECL_CONFIG(SERIAL_7O1),
56+
DECL_CONFIG(SERIAL_8O1),
57+
DECL_CONFIG(SERIAL_7O2),
58+
DECL_CONFIG(SERIAL_8O2),
59+
DECL_CONFIG(SERIAL_8E2)
6060
};
6161

6262
static uint32_t serialSpeed[] = {
@@ -79,14 +79,14 @@ static uint32_t serialSpeed[] = {
7979

8080
static uint32_t start_time = 0;
8181
static uint32_t configCur = 0;
82-
static uint32_t configNb = sizeof(serialConfig)/sizeof(serialTest);
83-
static uint32_t speedNb = sizeof(serialSpeed)/sizeof(uint32_t);
82+
static uint32_t configNb = sizeof(serialConfig) / sizeof(serialTest);
83+
static uint32_t speedNb = sizeof(serialSpeed) / sizeof(uint32_t);
8484
static uint32_t nbTestOK = 0;
8585
static uint32_t nbTestKO = 0;
8686

8787
uint32_t dataMask(uint32_t config) {
8888
uint32_t databits = 0;
89-
switch(config & 0x07) {
89+
switch (config & 0x07) {
9090
case 0x02:
9191
databits = 6;
9292
break;
@@ -108,32 +108,32 @@ void test_uart(int val)
108108
int recval = 0;
109109
SERIAL_PORT_TESTED.write(val);
110110
delay(10);
111-
while(SERIAL_PORT_TESTED.available()){
111+
while (SERIAL_PORT_TESTED.available()) {
112112
recval = SERIAL_PORT_TESTED.read();
113113
}
114-
if(val == recval) {
114+
if (val == recval) {
115115
nbTestOK++;
116116
}
117117
else {
118118
SERIAL_PORT_MONITOR.print("Send: 0x");
119-
SERIAL_PORT_MONITOR.print(val,HEX);
119+
SERIAL_PORT_MONITOR.print(val, HEX);
120120
SERIAL_PORT_MONITOR.print("\tReceived: 0x");
121-
SERIAL_PORT_MONITOR.print(recval,HEX);
121+
SERIAL_PORT_MONITOR.print(recval, HEX);
122122
SERIAL_PORT_MONITOR.println(" --> KO <--");
123123
nbTestKO++;
124124
}
125125
}
126126

127127
void setup() {
128128
SERIAL_PORT_MONITOR.begin(115200);
129-
while(!SERIAL_PORT_MONITOR);
129+
while (!SERIAL_PORT_MONITOR);
130130
SERIAL_PORT_MONITOR.print("SerialLoop test on ");
131131
SERIAL_PORT_MONITOR.println(XSTR(SERIAL_PORT_TESTED));
132132
SERIAL_PORT_MONITOR.print(configNb);
133133
SERIAL_PORT_MONITOR.println(" configs to test.");
134134
SERIAL_PORT_MONITOR.print(speedNb);
135135
SERIAL_PORT_MONITOR.println(" speed to test.");
136-
start_time=millis();
136+
start_time = millis();
137137
}
138138

139139
void loop() {
@@ -147,7 +147,7 @@ void loop() {
147147
SERIAL_PORT_MONITOR.print("Test duration (ms): ");
148148
SERIAL_PORT_MONITOR.print(millis() - start_time);
149149

150-
while(1); // End test
150+
while (1); // End test
151151
}
152152

153153
SERIAL_PORT_MONITOR.println("########################");
@@ -156,19 +156,18 @@ void loop() {
156156
SERIAL_PORT_MONITOR.print(" (0x");
157157
SERIAL_PORT_MONITOR.print(serialConfig[configCur].config, HEX);
158158
SERIAL_PORT_MONITOR.println(")");
159-
for (uint32_t s=0; s<speedNb; s++) {
159+
for (uint32_t s = 0; s < speedNb; s++) {
160160
SERIAL_PORT_MONITOR.print("Test at ");
161161
SERIAL_PORT_MONITOR.print(serialSpeed[s]);
162162
SERIAL_PORT_MONITOR.println(" baud");
163-
SERIAL_PORT_TESTED.begin(serialSpeed[s],serialConfig[configCur].config);
163+
SERIAL_PORT_TESTED.begin(serialSpeed[s], serialConfig[configCur].config);
164164
mask = dataMask(serialConfig[configCur].config);
165-
for (uint32_t i=0; i<=(0xFF&mask); i++)
165+
for (uint32_t i = 0; i <= (0xFF & mask); i++)
166166
{
167-
test_uart(i&mask);
167+
test_uart(i & mask);
168168
}
169169
SERIAL_PORT_TESTED.end();
170170
}
171171
SERIAL_PORT_MONITOR.println("End.");
172172
configCur++;
173173
}
174-

0 commit comments

Comments
 (0)