Skip to content

Commit a2e36e8

Browse files
authored
Merge pull request #2469 from particle-iot/fix/p2-servo-tone
[tests] Fix broken tone and servo tests for p2 platform, also EEPROM_03 for all.
2 parents fe90a9b + 3fae3a9 commit a2e36e8

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

user/tests/wiring/no_fixture/eeprom.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,18 @@ test(EEPROM_02_ReadWriteSucceedsForAllAddressWithInRange) {
7373

7474
test(EEPROM_03_ReadWriteFailsForAnyAddressOutOfRange) {
7575
int EEPROM_SIZE = EEPROM.length();
76-
uint16_t address = 0;
77-
uint8_t base = (uint8_t)rand();
76+
int EEPROM_INC = 10;
77+
uint16_t address = EEPROM_SIZE;
78+
uint8_t base = rand() % (255 - EEPROM_INC - 1); // do not allow data to equal 255, which is what EEPROM.read(invalid_address) returns
7879
uint8_t data = base;
7980

8081
// when
81-
for(address=EEPROM_SIZE, data=base; address < EEPROM_SIZE+10; address++, data++)
82+
for(address=EEPROM_SIZE, data=base; address < EEPROM_SIZE + EEPROM_INC; address++, data++)
8283
{
8384
EEPROM.write(address, data);
8485
}
8586
// then
86-
for(address=EEPROM_SIZE, data=base; address < EEPROM_SIZE+10; address++, data++)
87+
for(address=EEPROM_SIZE, data=base; address < EEPROM_SIZE + EEPROM_INC; address++, data++)
8788
{
8889
assertNotEqual(EEPROM.read(address), data);
8990
}

user/tests/wiring/no_fixture_long_running/servo.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
#include "unit-test/unit-test.h"
2929

3030
#if HAL_PLATFORM_GEN == 3
31-
#if PLATFORM_ID == PLATFORM_ESOMX
32-
static const pin_t pin = D0, pin2 = D1;
31+
#if PLATFORM_ID == PLATFORM_P2 || PLATFORM_ID == PLATFORM_ESOMX
32+
static const hal_pin_t pin = D1, pin2 = D8;
3333
#else
34-
static const pin_t pin = A0, pin2 = A1;
34+
static const hal_pin_t pin = A0, pin2 = A1;
3535
#endif
3636
#else
3737
#error "Unsupported platform"
@@ -40,9 +40,9 @@ static const pin_t pin = A0, pin2 = A1;
4040
test(SERVO_01_CannotAttachWhenPinSelectedIsNotTimerChannel) {
4141
#if HAL_PLATFORM_NRF52840
4242
# if PLATFORM_ID == PLATFORM_TRACKER
43-
pin_t pin = BTN;
43+
hal_pin_t pin = BTN;
4444
#elif PLATFORM_ID == PLATFORM_ESOMX
45-
pin_t pin = A0;
45+
hal_pin_t pin = A0;
4646
# else
4747
hal_pin_t pin = D0;
4848
# endif

user/tests/wiring/no_fixture_long_running/tone.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,20 @@
2727
#include "tone_hal.h"
2828
#include "unit-test/unit-test.h"
2929

30-
#if PLATFORM_ID == PLATFORM_ESOMX
31-
static const pin_t pin = D1;//pin under test
30+
#if PLATFORM_ID == PLATFORM_P2
31+
static const hal_pin_t pin = D1;//pin under test
32+
#elif PLATFORM_ID == PLATFORM_ESOMX
33+
static const hal_pin_t pin = A3;//pin under test
3234
#else
33-
static const pin_t pin = A1;//pin under test
35+
static const hal_pin_t pin = A1;//pin under test
3436
#endif
3537

3638
test(TONE_01_NoGenerateWhenPinSelectedIsNotTimerChannel) {
3739
#if HAL_PLATFORM_NRF52840
3840
# if PLATFORM_ID == PLATFORM_TRACKER
39-
pin_t pin = BTN;
41+
hal_pin_t pin = BTN;
4042
# elif PLATFORM_ID == PLATFORM_ESOMX
41-
pin_t pin = A0;
43+
hal_pin_t pin = A0;
4244
# else
4345
hal_pin_t pin = D0;
4446
# endif

0 commit comments

Comments
 (0)