test(wokwi): Add I2C Master test and enable GPIO and PSRAM tests (#10848)
* test(wokwi): Enable PSRAM test * fix(tests): Add missing diagram for ESP32-P4 * test(wokwi): Enable GPIO test * test(wokwi): Add I2C master test * fix(tests): Add missing requirement and improve logging * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
parent
eec2af3d35
commit
978b441cd4
15 changed files with 488 additions and 8 deletions
8
.github/scripts/tests_run.sh
vendored
8
.github/scripts/tests_run.sh
vendored
|
|
@ -48,10 +48,10 @@ function run_test {
|
|||
return 0
|
||||
fi
|
||||
|
||||
local right_target
|
||||
right_target=$(grep -E "^CONFIG_IDF_TARGET=\"$target\"$" "$sdkconfig_path")
|
||||
if [ -z "$right_target" ]; then
|
||||
printf "\033[91mError: Sketch %s compiled for different target\n\033[0m\n" "$sketchname"
|
||||
local compiled_target
|
||||
compiled_target=$(grep -E "CONFIG_IDF_TARGET=" "$sdkconfig_path" | cut -d'"' -f2)
|
||||
if [ "$compiled_target" != "$target" ]; then
|
||||
printf "\033[91mError: Sketch %s compiled for %s, expected %s\033[0m\n" "$sketchname" "$compiled_target" "$target"
|
||||
printf "\n\n\n"
|
||||
return 1
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -5,3 +5,4 @@ pytest-embedded-serial-esp==1.12.0
|
|||
pytest-embedded-arduino==1.12.0
|
||||
pytest-embedded-wokwi==1.12.0
|
||||
pytest-embedded-qemu==1.12.0
|
||||
esptool==4.8.1
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"platforms": {
|
||||
"hardware": false,
|
||||
"qemu": false,
|
||||
"wokwi": false
|
||||
"qemu": false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
28
tests/validation/gpio/diagram.esp32p4.json
Normal file
28
tests/validation/gpio/diagram.esp32p4.json
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"version": 1,
|
||||
"author": "lucasssvaz",
|
||||
"editor": "wokwi",
|
||||
"parts": [
|
||||
{
|
||||
"type": "board-esp32-p4-function-ev",
|
||||
"id": "esp32",
|
||||
"top": -66.32,
|
||||
"left": -277.63,
|
||||
"attrs": {}
|
||||
},
|
||||
{
|
||||
"type": "wokwi-pushbutton",
|
||||
"id": "btn1",
|
||||
"top": -128.2,
|
||||
"left": -19.2,
|
||||
"attrs": { "color": "green", "bounce": "1" }
|
||||
}
|
||||
],
|
||||
"connections": [
|
||||
[ "esp32:38", "$serialMonitor:TX", "", [] ],
|
||||
[ "esp32:37", "$serialMonitor:RX", "", [] ],
|
||||
[ "btn1:2.r", "esp32:GND.3", "black", [ "h19.4", "v29" ] ],
|
||||
[ "esp32:0", "btn1:1.l", "blue", [ "h-48", "v-67.2" ] ]
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
||||
9
tests/validation/i2c_master/ci.json
Normal file
9
tests/validation/i2c_master/ci.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"platforms": {
|
||||
"hardware": false,
|
||||
"qemu": false
|
||||
},
|
||||
"requires": [
|
||||
"CONFIG_SOC_I2C_SUPPORTED=y"
|
||||
]
|
||||
}
|
||||
24
tests/validation/i2c_master/diagram.esp32.json
Normal file
24
tests/validation/i2c_master/diagram.esp32.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": 1,
|
||||
"author": "lucasssvaz",
|
||||
"editor": "wokwi",
|
||||
"parts": [
|
||||
{
|
||||
"type": "board-esp32-devkit-c-v4",
|
||||
"id": "esp32",
|
||||
"top": -57.6,
|
||||
"left": -177.56,
|
||||
"attrs": {}
|
||||
},
|
||||
{ "type": "wokwi-ds1307", "id": "rtc1", "top": -43.8, "left": -19.1, "attrs": {} }
|
||||
],
|
||||
"connections": [
|
||||
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
|
||||
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
|
||||
[ "esp32:22", "rtc1:SCL", "green", [ "h38.4", "v-9.6" ] ],
|
||||
[ "esp32:21", "rtc1:SDA", "blue", [ "h48", "v-28.8", "h19.2" ] ],
|
||||
[ "esp32:GND.2", "rtc1:GND", "black", [ "v0" ] ],
|
||||
[ "rtc1:5V", "esp32:5V", "red", [ "h-28.8", "v-67.6", "h-172.8", "v230.4" ] ]
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
||||
25
tests/validation/i2c_master/diagram.esp32c3.json
Normal file
25
tests/validation/i2c_master/diagram.esp32c3.json
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"version": 1,
|
||||
"author": "lucasssvaz",
|
||||
"editor": "wokwi",
|
||||
"parts": [
|
||||
{
|
||||
"type": "board-esp32-c3-devkitm-1",
|
||||
"id": "esp32",
|
||||
"top": -57.6,
|
||||
"left": -177.56,
|
||||
"attrs": {}
|
||||
},
|
||||
{ "type": "wokwi-ds1307", "id": "rtc1", "top": -43.8, "left": -19.1, "attrs": {} }
|
||||
],
|
||||
"connections": [
|
||||
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
|
||||
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
|
||||
[ "rtc1:5V", "esp32:5V", "red", [ "h-28.8", "v-67.6", "h-172.8", "v230.4" ] ],
|
||||
[ "esp32:5V.1", "rtc1:5V", "red", [ "h-18.22", "v-144.3", "h153.6", "v48" ] ],
|
||||
[ "esp32:GND.10", "rtc1:GND", "black", [ "h56.16", "v9.3" ] ],
|
||||
[ "esp32:8", "rtc1:SDA", "green", [ "h17.76", "v-19.5" ] ],
|
||||
[ "esp32:9", "rtc1:SCL", "blue", [ "h0" ] ]
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
||||
26
tests/validation/i2c_master/diagram.esp32c6.json
Normal file
26
tests/validation/i2c_master/diagram.esp32c6.json
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"version": 1,
|
||||
"author": "lucasssvaz",
|
||||
"editor": "wokwi",
|
||||
"parts": [
|
||||
{
|
||||
"type": "board-esp32-c6-devkitc-1",
|
||||
"id": "esp32",
|
||||
"top": -57.6,
|
||||
"left": -177.56,
|
||||
"attrs": {}
|
||||
},
|
||||
{ "type": "wokwi-ds1307", "id": "rtc1", "top": -43.8, "left": -19.1, "attrs": {} }
|
||||
],
|
||||
"connections": [
|
||||
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
|
||||
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
|
||||
[ "rtc1:5V", "esp32:5V", "red", [ "h-28.8", "v-67.6", "h-172.8", "v230.4" ] ],
|
||||
[ "esp32:5V.1", "rtc1:5V", "red", [ "h-18.22", "v-144.3", "h153.6", "v48" ] ],
|
||||
[ "esp32:GND.10", "rtc1:GND", "black", [ "h56.16", "v9.3" ] ],
|
||||
[ "esp32:23", "rtc1:SDA", "green", [ "h17.38", "v-23.51" ] ],
|
||||
[ "esp32:GND.4", "rtc1:GND", "black", [ "h55.78", "v-4.31" ] ],
|
||||
[ "esp32:22", "rtc1:SCL", "blue", [ "h26.98", "v-23.51" ] ]
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
||||
24
tests/validation/i2c_master/diagram.esp32h2.json
Normal file
24
tests/validation/i2c_master/diagram.esp32h2.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": 1,
|
||||
"author": "lucasssvaz",
|
||||
"editor": "wokwi",
|
||||
"parts": [
|
||||
{
|
||||
"type": "board-esp32-h2-devkitm-1",
|
||||
"id": "esp32",
|
||||
"top": -57.6,
|
||||
"left": -177.56,
|
||||
"attrs": {}
|
||||
},
|
||||
{ "type": "wokwi-ds1307", "id": "rtc1", "top": -43.8, "left": -19.1, "attrs": {} }
|
||||
],
|
||||
"connections": [
|
||||
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
|
||||
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
|
||||
[ "esp32:GND.6", "rtc1:GND", "black", [ "h0" ] ],
|
||||
[ "esp32:5V", "rtc1:5V", "red", [ "h-29.14", "v-160.97", "h172.8", "v48" ] ],
|
||||
[ "esp32:12", "rtc1:SDA", "green", [ "h36.58", "v-36.17" ] ],
|
||||
[ "esp32:22", "rtc1:SCL", "blue", [ "v-7.37", "h46.18", "v-38.4" ] ]
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
||||
24
tests/validation/i2c_master/diagram.esp32p4.json
Normal file
24
tests/validation/i2c_master/diagram.esp32p4.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": 1,
|
||||
"author": "lucasssvaz",
|
||||
"editor": "wokwi",
|
||||
"parts": [
|
||||
{
|
||||
"type": "board-esp32-p4-function-ev",
|
||||
"id": "esp32",
|
||||
"top": -57.6,
|
||||
"left": -177.56,
|
||||
"attrs": {}
|
||||
},
|
||||
{ "type": "wokwi-ds1307", "id": "rtc1", "top": -197.4, "left": 57.7, "attrs": {} }
|
||||
],
|
||||
"connections": [
|
||||
[ "esp32:38", "$serialMonitor:TX", "", [] ],
|
||||
[ "esp32:37", "$serialMonitor:RX", "", [] ],
|
||||
[ "esp32:5V.1", "rtc1:5V", "red", [ "v0" ] ],
|
||||
[ "esp32:GND.1", "rtc1:GND", "black", [ "v-133.52", "h5.53" ] ],
|
||||
[ "esp32:7", "rtc1:SDA", "green", [ "v0" ] ],
|
||||
[ "esp32:8", "rtc1:SCL", "blue", [ "h15.13", "v-114.12" ] ]
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
||||
24
tests/validation/i2c_master/diagram.esp32s2.json
Normal file
24
tests/validation/i2c_master/diagram.esp32s2.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": 1,
|
||||
"author": "lucasssvaz",
|
||||
"editor": "wokwi",
|
||||
"parts": [
|
||||
{
|
||||
"type": "board-esp32-s2-devkitm-1",
|
||||
"id": "esp32",
|
||||
"top": -57.6,
|
||||
"left": -177.56,
|
||||
"attrs": {}
|
||||
},
|
||||
{ "type": "wokwi-ds1307", "id": "rtc1", "top": -43.8, "left": -19.1, "attrs": {} }
|
||||
],
|
||||
"connections": [
|
||||
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
|
||||
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
|
||||
[ "esp32:GND.2", "rtc1:GND", "black", [ "v0" ] ],
|
||||
[ "rtc1:5V", "esp32:5V", "red", [ "h-28.8", "v-67.6", "h-172.8", "v230.4" ] ],
|
||||
[ "esp32:8", "rtc1:SDA", "green", [ "h-19.47", "v-119.51", "h144", "v57.6" ] ],
|
||||
[ "esp32:9", "rtc1:SCL", "blue", [ "h-29.07", "v-138.71", "h144", "v76.8" ] ]
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
||||
24
tests/validation/i2c_master/diagram.esp32s3.json
Normal file
24
tests/validation/i2c_master/diagram.esp32s3.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": 1,
|
||||
"author": "lucasssvaz",
|
||||
"editor": "wokwi",
|
||||
"parts": [
|
||||
{
|
||||
"type": "board-esp32-s3-devkitc-1",
|
||||
"id": "esp32",
|
||||
"top": -57.6,
|
||||
"left": -177.56,
|
||||
"attrs": {}
|
||||
},
|
||||
{ "type": "wokwi-ds1307", "id": "rtc1", "top": -43.8, "left": -19.1, "attrs": {} }
|
||||
],
|
||||
"connections": [
|
||||
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
|
||||
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
|
||||
[ "esp32:GND.2", "rtc1:GND", "black", [ "v0" ] ],
|
||||
[ "rtc1:5V", "esp32:5V", "red", [ "h-28.8", "v-67.6", "h-172.8", "v230.4" ] ],
|
||||
[ "esp32:8", "rtc1:SDA", "green", [ "h-19.47", "v-119.51", "h144", "v32.93", "h38.35" ] ],
|
||||
[ "esp32:9", "rtc1:SCL", "blue", [ "h-29.07", "v-138.71", "h144", "v32.93", "h47.95" ] ]
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
||||
271
tests/validation/i2c_master/i2c_master.ino
Normal file
271
tests/validation/i2c_master/i2c_master.ino
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
/*
|
||||
I2C Master Test for
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <unity.h>
|
||||
#include <Wire.h>
|
||||
|
||||
/* DS1307 functions */
|
||||
|
||||
const uint8_t DS1307_ADDR = 0x68;
|
||||
const uint8_t start_sec = 1;
|
||||
const uint8_t start_min = 2;
|
||||
const uint8_t start_hour = 3;
|
||||
const uint8_t start_day = 4;
|
||||
const uint8_t start_month = 5;
|
||||
const uint16_t start_year = 2020;
|
||||
|
||||
static uint8_t read_sec = 0;
|
||||
static uint8_t read_min = 0;
|
||||
static uint8_t read_hour = 0;
|
||||
static uint8_t read_day = 0;
|
||||
static uint8_t read_month = 0;
|
||||
static uint16_t read_year = 0;
|
||||
static int peek_data = -1;
|
||||
|
||||
const auto BCD2DEC = [](uint8_t num) -> uint8_t {
|
||||
return ((num / 16 * 10) + (num % 16));
|
||||
};
|
||||
|
||||
const auto DEC2BCD = [](uint8_t num) -> uint8_t {
|
||||
return ((num / 10 * 16) + (num % 10));
|
||||
};
|
||||
|
||||
void reset_read_values() {
|
||||
read_sec = 0;
|
||||
read_min = 0;
|
||||
read_hour = 0;
|
||||
read_day = 0;
|
||||
read_month = 0;
|
||||
read_year = 0;
|
||||
}
|
||||
|
||||
void ds1307_start(void) {
|
||||
uint8_t sec;
|
||||
|
||||
//Get seconds
|
||||
Wire.beginTransmission(DS1307_ADDR);
|
||||
Wire.write(0x00);
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom(DS1307_ADDR, 1);
|
||||
sec = Wire.read() & 0x7F; //Seconds without halt bit
|
||||
|
||||
//Set seconds and start clock
|
||||
Wire.beginTransmission(DS1307_ADDR);
|
||||
Wire.write(0x00);
|
||||
Wire.write(sec);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
void ds1307_stop(void) {
|
||||
uint8_t sec;
|
||||
|
||||
//Get seconds
|
||||
Wire.beginTransmission(DS1307_ADDR);
|
||||
Wire.write(0x00);
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom(DS1307_ADDR, 1);
|
||||
sec = Wire.read() | 0x80; //Seconds with halt bit
|
||||
|
||||
//Set seconds and halt clock
|
||||
Wire.beginTransmission(DS1307_ADDR);
|
||||
Wire.write(0x00);
|
||||
Wire.write(sec);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
void ds1307_get_time(uint8_t *sec, uint8_t *min, uint8_t *hour, uint8_t *day, uint8_t *month, uint16_t *year) {
|
||||
//Get time
|
||||
Wire.beginTransmission(DS1307_ADDR);
|
||||
Wire.write(0x00);
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom(DS1307_ADDR, 7);
|
||||
|
||||
TEST_ASSERT_EQUAL(7, Wire.available());
|
||||
|
||||
if (peek_data == -1 && Wire.peek() != -1) {
|
||||
peek_data = Wire.peek();
|
||||
}
|
||||
|
||||
*sec = BCD2DEC(Wire.read() & 0x7F); //Seconds without halt bit
|
||||
*min = BCD2DEC(Wire.read());
|
||||
*hour = BCD2DEC(Wire.read() & 0x3F);
|
||||
Wire.read(); //Ignore day of week
|
||||
*day = BCD2DEC(Wire.read());
|
||||
*month = BCD2DEC(Wire.read());
|
||||
*year = BCD2DEC(Wire.read()) + 2000;
|
||||
}
|
||||
|
||||
void ds1307_set_time(uint8_t sec, uint8_t min, uint8_t hour, uint8_t day, uint8_t month, uint16_t year) {
|
||||
Wire.beginTransmission(DS1307_ADDR);
|
||||
Wire.write(0x00);
|
||||
Wire.write(DEC2BCD(sec));
|
||||
Wire.write(DEC2BCD(min));
|
||||
Wire.write(DEC2BCD(hour));
|
||||
Wire.write(DEC2BCD(0)); //Ignore day of week
|
||||
Wire.write(DEC2BCD(day));
|
||||
Wire.write(DEC2BCD(month));
|
||||
Wire.write(DEC2BCD(year - 2000));
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
/* Unity functions */
|
||||
|
||||
// This function is automatically called by unity before each test is run
|
||||
void setUp(void) {
|
||||
reset_read_values();
|
||||
Wire.begin();
|
||||
}
|
||||
|
||||
// This function is automatically called by unity after each test is run
|
||||
void tearDown(void) {
|
||||
//Reset time
|
||||
ds1307_set_time(start_sec, start_min, start_hour, start_day, start_month, start_year);
|
||||
|
||||
Wire.end();
|
||||
}
|
||||
|
||||
void rtc_set_time() {
|
||||
//Set time
|
||||
ds1307_set_time(start_sec, start_min, start_hour, start_day, start_month, start_year);
|
||||
|
||||
//Get time
|
||||
ds1307_get_time(&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year);
|
||||
|
||||
//Check time
|
||||
TEST_ASSERT_EQUAL(start_sec, read_sec);
|
||||
TEST_ASSERT_EQUAL(start_min, read_min);
|
||||
TEST_ASSERT_EQUAL(start_hour, read_hour);
|
||||
TEST_ASSERT_EQUAL(start_day, read_day);
|
||||
TEST_ASSERT_EQUAL(start_month, read_month);
|
||||
TEST_ASSERT_EQUAL(start_year, read_year);
|
||||
}
|
||||
|
||||
void rtc_run_clock() {
|
||||
uint8_t old_sec = 0;
|
||||
|
||||
//Run clock for 5 seconds
|
||||
ds1307_start();
|
||||
delay(5000);
|
||||
ds1307_stop();
|
||||
|
||||
//Get time
|
||||
ds1307_get_time(&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year);
|
||||
|
||||
//Check time
|
||||
TEST_ASSERT_UINT8_WITHIN(2, start_sec + 5, read_sec);
|
||||
TEST_ASSERT_EQUAL(start_min, read_min);
|
||||
TEST_ASSERT_EQUAL(start_hour, read_hour);
|
||||
TEST_ASSERT_EQUAL(start_day, read_day);
|
||||
TEST_ASSERT_EQUAL(start_month, read_month);
|
||||
TEST_ASSERT_EQUAL(start_year, read_year);
|
||||
|
||||
old_sec = read_sec;
|
||||
reset_read_values();
|
||||
|
||||
//Get time again to check that clock is stopped
|
||||
delay(2000);
|
||||
ds1307_get_time(&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year);
|
||||
|
||||
//Check time
|
||||
TEST_ASSERT_EQUAL(old_sec, read_sec);
|
||||
TEST_ASSERT_EQUAL(start_min, read_min);
|
||||
TEST_ASSERT_EQUAL(start_hour, read_hour);
|
||||
TEST_ASSERT_EQUAL(start_day, read_day);
|
||||
TEST_ASSERT_EQUAL(start_month, read_month);
|
||||
TEST_ASSERT_EQUAL(start_year, read_year);
|
||||
}
|
||||
|
||||
void change_clock() {
|
||||
//Get time
|
||||
ds1307_get_time(&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year);
|
||||
|
||||
//Check time
|
||||
TEST_ASSERT_EQUAL(start_sec, read_sec);
|
||||
TEST_ASSERT_EQUAL(start_min, read_min);
|
||||
TEST_ASSERT_EQUAL(start_hour, read_hour);
|
||||
TEST_ASSERT_EQUAL(start_day, read_day);
|
||||
TEST_ASSERT_EQUAL(start_month, read_month);
|
||||
TEST_ASSERT_EQUAL(start_year, read_year);
|
||||
|
||||
Wire.setClock(400000);
|
||||
reset_read_values();
|
||||
|
||||
TEST_ASSERT_EQUAL(400000, Wire.getClock());
|
||||
|
||||
//Get time
|
||||
ds1307_get_time(&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year);
|
||||
|
||||
//Check time
|
||||
TEST_ASSERT_EQUAL(start_sec, read_sec);
|
||||
TEST_ASSERT_EQUAL(start_min, read_min);
|
||||
TEST_ASSERT_EQUAL(start_hour, read_hour);
|
||||
TEST_ASSERT_EQUAL(start_day, read_day);
|
||||
TEST_ASSERT_EQUAL(start_month, read_month);
|
||||
TEST_ASSERT_EQUAL(start_year, read_year);
|
||||
}
|
||||
|
||||
void swap_pins() {
|
||||
Wire.setPins(SCL, SDA);
|
||||
Wire.begin();
|
||||
//Set time
|
||||
ds1307_set_time(start_sec, start_min, start_hour, start_day, start_month, start_year);
|
||||
|
||||
//Get time
|
||||
ds1307_get_time(&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year);
|
||||
|
||||
//Check time
|
||||
TEST_ASSERT_EQUAL(start_sec, read_sec);
|
||||
TEST_ASSERT_EQUAL(start_min, read_min);
|
||||
TEST_ASSERT_EQUAL(start_hour, read_hour);
|
||||
TEST_ASSERT_EQUAL(start_day, read_day);
|
||||
TEST_ASSERT_EQUAL(start_month, read_month);
|
||||
TEST_ASSERT_EQUAL(start_year, read_year);
|
||||
|
||||
Wire.setPins(SDA, SCL);
|
||||
}
|
||||
|
||||
void test_api() {
|
||||
int integer_ret;
|
||||
|
||||
// Set Buffer Size
|
||||
integer_ret = Wire.setBufferSize(32);
|
||||
TEST_ASSERT_EQUAL(32, integer_ret);
|
||||
integer_ret = Wire.setBufferSize(I2C_BUFFER_LENGTH);
|
||||
TEST_ASSERT_EQUAL(I2C_BUFFER_LENGTH, integer_ret);
|
||||
|
||||
// Set TimeOut
|
||||
Wire.setTimeOut(100);
|
||||
TEST_ASSERT_EQUAL(100, Wire.getTimeOut());
|
||||
|
||||
// Check if buffer can be peeked
|
||||
TEST_ASSERT_GREATER_THAN(-1, peek_data);
|
||||
|
||||
Wire.flush();
|
||||
}
|
||||
|
||||
/* Main */
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
delay(10);
|
||||
}
|
||||
|
||||
log_d("Starting I2C Master");
|
||||
Wire.begin();
|
||||
|
||||
log_d("Starting tests");
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(rtc_set_time);
|
||||
RUN_TEST(rtc_run_clock);
|
||||
RUN_TEST(change_clock);
|
||||
RUN_TEST(swap_pins);
|
||||
RUN_TEST(test_api);
|
||||
UNITY_END();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
2
tests/validation/i2c_master/test_i2c_master.py
Normal file
2
tests/validation/i2c_master/test_i2c_master.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
def test_i2c_master(dut):
|
||||
dut.expect_unity_test_output(timeout=240)
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"platforms": {
|
||||
"qemu": false,
|
||||
"wokwi": false
|
||||
"qemu": false
|
||||
},
|
||||
"requires": [
|
||||
"CONFIG_SPIRAM=y"
|
||||
|
|
|
|||
Loading…
Reference in a new issue