Skip to content

Commit

Permalink
Add gpio and sigmadelta test
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz committed Oct 26, 2023
1 parent 4029b71 commit 86fd9bb
Showing 1 changed file with 43 additions and 19 deletions.
62 changes: 43 additions & 19 deletions tests/periman/periman.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
*/

#include <unity.h>
#include "HardwareSerial.h"
#include "Wire.h"

/* Global variables */

String last_test = "";

/* Utility functions */

extern int8_t uart_get_RxPin(uint8_t uart_num);
extern int8_t uart_get_TxPin(uint8_t uart_num);

/* Unity functions */

// This function is automatically called by unity before each test is run
Expand All @@ -38,30 +32,54 @@ void tearDown(void) {
/* Test functions */
/* These functions must only init the peripheral on the same pins and update "last_test" */

#if SOC_I2C_SUPPORTED
void i2c_test(void) {
last_test = "I2C";
Wire.begin(SOC_RX0, SOC_TX0);
void gpio_test(void) {
pinMode(SOC_RX0, INPUT);
pinMode(SOC_TX0, INPUT);
last_test = "GPIO";
}

#if SOC_SDM_SUPPORTED
void sigmadelta_test(void) {
if (!sigmaDeltaAttach(SOC_RX0, 312500)) {
TEST_FAIL_MESSAGE("SigmaDelta init failed");
}
if (!sigmaDeltaAttach(SOC_TX0, 312500)) {
TEST_FAIL_MESSAGE("SigmaDelta init failed");
}
last_test = "SigmaDelta";
}
#endif

#if SOC_LEDC_SUPPORTED
void ledc_test(void) {
if (!ledcAttach(SOC_RX0, 5000, 12)) {
TEST_FAIL_MESSAGE("LEDC init failed");
}
if (!ledcAttach(SOC_TX0, 5000, 12)) {
TEST_FAIL_MESSAGE("LEDC init failed");
}
last_test = "LEDC";
}
#endif

#if SOC_RMT_SUPPORTED
void rmt_test(void) {
last_test = "RMT";
if (!rmtInit(SOC_RX0, RMT_TX_MODE, RMT_MEM_NUM_BLOCKS_1, 10000000)) {
TEST_FAIL_MESSAGE("RMT init failed");
}
if (!rmtInit(SOC_TX0, RMT_TX_MODE, RMT_MEM_NUM_BLOCKS_1, 10000000)) {
TEST_FAIL_MESSAGE("RMT init failed");
}
last_test = "RMT";
}
#endif

#if SOC_LEDC_SUPPORTED
void ledc_test(void) {
last_test = "LEDC";
ledcAttach(SOC_RX0, 5000, 12);
ledcAttach(SOC_TX0, 5000, 12);
#if SOC_I2C_SUPPORTED
void i2c_test(void) {
if (!Wire.begin(SOC_RX0, SOC_TX0)) {
TEST_FAIL_MESSAGE("I2C init failed");
}
last_test = "I2C";
}
#endif

Expand All @@ -73,16 +91,22 @@ void setup() {

UNITY_BEGIN();

#if SOC_I2C_SUPPORTED
RUN_TEST(i2c_test);
RUN_TEST(gpio_test);

#if SOC_SDM_SUPPORTED
RUN_TEST(sigmadelta_test);
#endif

#if SOC_LEDC_SUPPORTED
RUN_TEST(ledc_test);
#endif

#if SOC_RMT_SUPPORTED
RUN_TEST(rmt_test);
//RUN_TEST(rmt_test);
#endif

#if SOC_I2C_SUPPORTED
RUN_TEST(i2c_test);
#endif

UNITY_END();
Expand Down

0 comments on commit 86fd9bb

Please sign in to comment.