Skip to content

Commit a62bdf2

Browse files
committed
ci: restore the default bareMinimum sketch
Signed-off-by: Aymane Bahssain <aymane.bahssain@st.com>
1 parent 44484e2 commit a62bdf2

File tree

2 files changed

+91
-12
lines changed

2 files changed

+91
-12
lines changed

CI/build/examples/BareMinimum/BareMinimum.ino

Lines changed: 87 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,46 @@
44
* and can not be executed.
55
*/
66

7+
#include <EEPROM.h>
8+
#ifndef STM32MP1xx
9+
#include <IWatchdog.h>
10+
#endif
11+
#ifdef TIMER_SERVO
12+
#include <Servo.h>
13+
#endif
714
#include <SPI.h>
815
#include <SoftwareSerial.h>
916
#include <Wire.h>
1017

18+
#include <CMSIS_DSP.h>
19+
/* ----------------------------------------------------------------------
20+
Defines each of the tests performed
21+
------------------------------------------------------------------- */
22+
#define MAX_BLOCKSIZE 2
23+
#define DELTA (0.0001f)
24+
/* ----------------------------------------------------------------------
25+
Test input data for Floating point sin_cos example for 32-blockSize
26+
Generated by the MATLAB randn() function
27+
------------------------------------------------------------------- */
28+
const float32_t testInput_f32[MAX_BLOCKSIZE] = {
29+
-1.244916875853235400, -4.793533929171324800
30+
};
31+
const float32_t testRefOutput_f32 = 1.000000000;
32+
/* ----------------------------------------------------------------------
33+
Declare Global variables
34+
------------------------------------------------------------------- */
35+
uint32_t blockSize = 2;
36+
float32_t testOutput;
37+
float32_t cosOutput;
38+
float32_t sinOutput;
39+
float32_t cosSquareOutput;
40+
float32_t sinSquareOutput;
41+
/* ----------------------------------------------------------------------
42+
Max magnitude FFT Bin test
43+
------------------------------------------------------------------- */
44+
arm_status status;
45+
/* CMSIS_DSP */
46+
1147
#ifndef USER_BTN
1248
#define USER_BTN 2
1349
#endif
@@ -28,6 +64,9 @@
2864
HardwareSerial Serial(PIN_SERIAL_RX, PIN_SERIAL_TX);
2965
#endif
3066

67+
#ifdef TIMER_SERVO
68+
Servo servo;
69+
#endif
3170
SoftwareSerial swSerial(10, 11);
3271

3372
void setup() {
@@ -40,15 +79,35 @@ void setup() {
4079
while (!Serial) {};
4180

4281
swSerial.begin(4800);
43-
swSerial.println("X");
44-
delay(20);
45-
while (swSerial.available()) {
46-
int c = swSerial.read();
47-
Serial.print("swSerial read: ");
48-
Serial.println((char)c);
82+
swSerial.write("x");
83+
if (!swSerial.isListening()) {
84+
swSerial.listen();
85+
if (swSerial.available()) {
86+
swSerial.read();
87+
}
4988
}
5089
swSerial.end();
5190

91+
// EEPROM
92+
byte value = EEPROM.read(0x01);
93+
EEPROM.write(EEPROM.length() - 1, value);
94+
95+
#ifndef STM32MP1xx
96+
// IWDG
97+
if (!IWatchdog.isReset(true)) {
98+
IWatchdog.begin(10000000);
99+
IWatchdog.isEnabled();
100+
}
101+
IWatchdog.reload();
102+
#endif
103+
104+
#ifdef TIMER_SERVO
105+
// Servo
106+
servo.attach(3, 900, 2100);
107+
servo.write(1500);
108+
servo.detach();
109+
#endif
110+
52111
// SPI
53112
SPISettings settings(SPI_SPEED_CLOCK_DEFAULT, MSBFIRST, SPI_MODE0);
54113
SPI.setMISO(PIN_SPI_MISO);
@@ -60,6 +119,7 @@ void setup() {
60119
SPI.endTransaction();
61120
SPI.transfer(1);
62121
SPI.end();
122+
63123
// Wire
64124
Wire.setSCL(PIN_WIRE_SCL);
65125
Wire.setSDA(digitalPinToPinName(PIN_WIRE_SDA));
@@ -72,6 +132,27 @@ void setup() {
72132
Wire.requestFrom(2, 1);
73133
Wire.end();
74134

135+
// CMSIS DSP
136+
float32_t diff;
137+
for (uint32_t i = 0; i < blockSize; i++) {
138+
cosOutput = arm_cos_f32(testInput_f32[i]);
139+
sinOutput = arm_sin_f32(testInput_f32[i]);
140+
arm_mult_f32(&cosOutput, &cosOutput, &cosSquareOutput, 1);
141+
arm_mult_f32(&sinOutput, &sinOutput, &sinSquareOutput, 1);
142+
arm_add_f32(&cosSquareOutput, &sinSquareOutput, &testOutput, 1);
143+
/* absolute value of difference between ref and test */
144+
diff = fabsf(testRefOutput_f32 - testOutput);
145+
/* Comparison of sin_cos value with reference */
146+
status = (diff > DELTA) ? ARM_MATH_TEST_FAILURE : ARM_MATH_SUCCESS;
147+
if (status == ARM_MATH_TEST_FAILURE) {
148+
break;
149+
}
150+
}
151+
if (status != ARM_MATH_SUCCESS) {
152+
Serial.printf("FAILURE\n");
153+
} else {
154+
Serial.printf("SUCCESS\n");
155+
}
75156
}
76157

77158
void loop() {
@@ -90,5 +171,3 @@ void receiveEvent(int) {
90171
void requestEvent() {
91172
Wire.write("x");
92173
}
93-
94-

CI/build/examples/BareMinimum/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ build_sketch(TARGET "BareMinimum"
4242
SOURCES
4343
BareMinimum.ino
4444
DEPENDS
45-
# CMSIS_DSP
46-
# EEPROM
47-
# IWatchdog
48-
# Servo
45+
CMSIS_DSP
46+
EEPROM
47+
IWatchdog
48+
Servo
4949
SoftwareSerial
5050
SPI
5151
Wire

0 commit comments

Comments
 (0)