1
1
/* Peripheral Manager test
2
- *
3
- * This test is using Serial to check if the peripheral manager is able to
4
- * attach and detach peripherals correctly on shared pins.
5
- * Make sure that the peripheral names contain only letters, numbers and underscores.
6
- *
7
- * This test skips the following peripherals:
8
- * - USB: USB is not able to be detached
9
- * - SDMMC: SDMMC requires a card to be mounted before the pins are attached
10
- * - ETH: ETH requires a ethernet port to be connected before the pins are attached
11
- */
2
+
3
+ This test is using Serial to check if the peripheral manager is able to
4
+ attach and detach peripherals correctly on shared pins.
5
+ Make sure that the peripheral names contain only letters, numbers and underscores.
6
+
7
+ This test skips the following peripherals:
8
+ - USB: USB is not able to be detached
9
+ - SDMMC: SDMMC requires a card to be mounted before the pins are attached
10
+ - ETH: ETH requires a ethernet port to be connected before the pins are attached
11
+ */
12
12
13
13
#if SOC_I2S_SUPPORTED
14
14
#include " ESP_I2S.h"
@@ -62,7 +62,7 @@ void onReceive_cb(void) {
62
62
63
63
// This function is called by before each test is run
64
64
void setup_test (String test_name, int8_t rx_pin = UART1_RX_DEFAULT, int8_t tx_pin = UART1_TX_DEFAULT) {
65
- log_v (" Setting up %s test" , test_name.c_str ());
65
+ log_i (" Setting up %s test" , test_name.c_str ());
66
66
67
67
current_test = test_name;
68
68
uart1_rx_pin = rx_pin;
@@ -74,12 +74,12 @@ void setup_test(String test_name, int8_t rx_pin = UART1_RX_DEFAULT, int8_t tx_pi
74
74
Serial1.setPins (uart1_rx_pin, uart1_tx_pin);
75
75
uart_internal_loopback (1 , true );
76
76
delay (100 );
77
- log_v (" Running %s test" , test_name.c_str ());
77
+ log_i (" Running %s test" , test_name.c_str ());
78
78
}
79
79
80
80
// This function is called after each test is run
81
81
void teardown_test (void ) {
82
- log_v (" Tearing down %s test" , current_test.c_str ());
82
+ log_i (" Tearing down %s test" , current_test.c_str ());
83
83
if (test_executed) {
84
84
pinMode (uart1_rx_pin, INPUT_PULLUP);
85
85
pinMode (uart1_tx_pin, OUTPUT);
@@ -96,13 +96,15 @@ void teardown_test(void) {
96
96
Serial1.println (" test: This should be printed" );
97
97
Serial1.flush ();
98
98
99
- log_v (" Finished %s test" , current_test.c_str ());
99
+ log_i (" Finished %s test" , current_test.c_str ());
100
+ Serial.println (" =========================================================================================" );
101
+ delay (2000 );
100
102
}
101
103
102
104
/* Test functions */
103
105
/* These functions must call "setup_test" and "teardown_test" and set "test_executed" to true
104
- * if the test is executed
105
- */
106
+ if the test is executed
107
+ */
106
108
107
109
void gpio_test (void ) {
108
110
setup_test (" GPIO" );
@@ -130,7 +132,7 @@ void sigmadelta_test(void) {
130
132
131
133
void adc_oneshot_test (void ) {
132
134
#if !SOC_ADC_SUPPORTED
133
- setup_test (" ADC_Oneshot" );
135
+ setup_test (" ADC_Oneshot - NO ADC Support " );
134
136
#else
135
137
setup_test (" ADC_Oneshot" , ADC1_DEFAULT, ADC2_DEFAULT);
136
138
test_executed = true ;
@@ -151,8 +153,8 @@ void ARDUINO_ISR_ATTR adcComplete() {
151
153
#endif
152
154
153
155
void adc_continuous_test (void ) {
154
- #if !SOC_ADC_SUPPORTED
155
- setup_test (" ADC_Continuous" );
156
+ #if !SOC_ADC_SUPPORTED || CONFIG_IDF_TARGET_ESP32P4
157
+ setup_test (" ADC_Continuous - NO ADC Support " );
156
158
#else
157
159
setup_test (" ADC_Continuous" , ADC1_DEFAULT, ADC2_DEFAULT);
158
160
test_executed = true ;
@@ -166,8 +168,10 @@ void adc_continuous_test(void) {
166
168
analogContinuous (adc_pins, adc_pins_count, 6 , 20000 , &adcComplete);
167
169
analogContinuousStart ();
168
170
171
+ Serial.println ();
169
172
while (adc_coversion_done == false ) {
170
- delay (1 );
173
+ Serial.print (" ." );
174
+ delay (500 );
171
175
}
172
176
173
177
if (!analogContinuousRead (&result, 0 )) {
@@ -226,12 +230,13 @@ void i2s_test(void) {
226
230
I2SClass i2s;
227
231
228
232
i2s.setPins (uart1_rx_pin, uart1_tx_pin, -1 );
233
+
229
234
i2s.setTimeout (1000 );
230
235
if (!i2s.begin (I2S_MODE_STD, 16000 , I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO)) {
231
- Serial.println (" I2S init failed" );
232
236
}
233
237
#endif
234
238
teardown_test ();
239
+ delay (500 ); Serial.println (" Exting I2S driver..." ); delay (500 );
235
240
}
236
241
237
242
void i2c_test (void ) {
@@ -282,17 +287,31 @@ void setup() {
282
287
Serial1.onReceive (onReceive_cb);
283
288
uart_internal_loopback (1 , true );
284
289
290
+ Serial.println (" starting gpio_test()" );
285
291
gpio_test ();
292
+ Serial.println (" starting sigmadelta_test()" );
286
293
sigmadelta_test ();
294
+ Serial.println (" starting ledc_test()" );
287
295
ledc_test ();
296
+ Serial.println (" starting rmt_test()" );
288
297
rmt_test ();
289
- i2s_test ();
290
- i2c_test ();
298
+ Serial.println (" \t ==>starting i2s_test()" );
299
+ i2s_test (); // apos esta linha temos um [E][esp32-hal-periman.c:122] perimanSetPinBus(): Invalid pin: 255
300
+ Serial.println (" \t ==>Back to setup()" );
301
+ Serial.println (" \t ==>starting spi_test()" );
291
302
spi_test ();
303
+ Serial.println (" \t ==>starting i2c_test()" );
304
+ i2c_test ();
305
+ Serial.println (" \t ==>ended i2c_test()" );
306
+ Serial.println (" starting adc_oneshot_test()" );
292
307
adc_oneshot_test ();
308
+ Serial.println (" starting adc_continuous_test()" );
293
309
adc_continuous_test ();
310
+ Serial.println (" starting dac_test()" );
294
311
dac_test ();
312
+ Serial.println (" starting touch_test()" );
295
313
touch_test ();
314
+ Serial.println (" starting gpio_test()" );
296
315
297
316
// Print to Serial1 to avoid buffering issues
298
317
Serial1.println (" Peripheral Manager test done" );
0 commit comments