Refactored few peripheral tests like DigitalInOut, InteruptIn

Checked refactoring progress on LPC11U24
pull/900/head
Przemek Wirkus 2015-01-28 10:08:03 +00:00
parent b45d190b5d
commit 812a1c3000
6 changed files with 43 additions and 16 deletions

View File

@ -41,20 +41,24 @@ DigitalIn in(p25);
#endif #endif
int main() int main() {
{ TEST_TIMEOUT(10);
TEST_HOSTTEST(default_auto);
TEST_DESCRIPTION(DigitalIn DigitalOut);
TEST_START("MBED_A5");
out = 0; out = 0;
wait(0.1); wait(0.1);
if (in != 0) { if (in != 0) {
printf("ERROR: in != 0\n"); printf("ERROR: in != 0\n");
notify_completion(false); TEST_RESULT(false);
} }
out = 1; out = 1;
wait(0.1); wait(0.1);
if (in != 1) { if (in != 1) {
printf("ERROR: in != 1\n"); printf("ERROR: in != 1\n");
notify_completion(false); TEST_RESULT(false);
} }
notify_completion(true); TEST_RESULT(true);
} }

View File

@ -44,6 +44,11 @@ DigitalInOut d2(p25);
int main() int main()
{ {
TEST_TIMEOUT(10);
TEST_HOSTTEST(default_auto);
TEST_DESCRIPTION(DigitalInOut);
TEST_START("MBED_A6");
bool check = true; bool check = true;
d1.output(); d1.output();
@ -76,5 +81,5 @@ int main()
check = false; check = false;
} }
notify_completion(check); TEST_RESULT(check);
} }

View File

@ -32,13 +32,17 @@ TMP102 temperature(I2C_SDA, I2C_SCL, 0x90);
TMP102 temperature(p28, p27, 0x90); TMP102 temperature(p28, p27, 0x90);
#endif #endif
int main() int main() {
{ TEST_TIMEOUT(10);
TEST_HOSTTEST(default_auto);
TEST_DESCRIPTION(DigitalIn DigitalOut);
TEST_START("MBED_A4");
float t = temperature.read(); float t = temperature.read();
printf("TMP102: Temperature: %f\n\r", t); printf("TMP102: Temperature: %f\n\r", t);
// In our test environment (ARM office) we should get a temperature within // In our test environment (ARM office) we should get a temperature within
// the range ]15, 30[C // the range ]15, 30[C
bool result = (t > 15.0) && (t < 30.0); bool result = (t > 15.0) && (t < 30.0);
notify_completion(result); TEST_RESULT(result);
} }

View File

@ -87,6 +87,11 @@ void flipper() {
} }
int main() { int main() {
TEST_TIMEOUT(20);
TEST_HOSTTEST(default_auto);
TEST_DESCRIPTION(InterruptIn);
TEST_START("MBED_A7");
IN_OUT_CLEAR; IN_OUT_CLEAR;
//Test falling edges first //Test falling edges first
in.rise(NULL); in.rise(NULL);
@ -95,7 +100,7 @@ int main() {
if(checks != 5) { if(checks != 5) {
printf("MBED: falling edges test failed: %d\r\n",checks); printf("MBED: falling edges test failed: %d\r\n",checks);
notify_completion(false); TEST_RESULT(false);
} }
//Now test rising edges //Now test rising edges
@ -105,7 +110,7 @@ int main() {
if (checks != 10) { if (checks != 10) {
printf("MBED: raising edges test failed: %d\r\n", checks); printf("MBED: raising edges test failed: %d\r\n", checks);
notify_completion(false); TEST_RESULT(false);
} }
//Now test switch off edge detection //Now test switch off edge detection
@ -115,7 +120,7 @@ int main() {
if (checks != 10) { if (checks != 10) {
printf("MBED: edge detection switch off test failed: %d\r\n", checks); printf("MBED: edge detection switch off test failed: %d\r\n", checks);
notify_completion(false); TEST_RESULT(false);
} }
//Finally test both //Finally test both
@ -125,9 +130,8 @@ int main() {
if (checks != 20) { if (checks != 20) {
printf("MBED: Simultaneous rising and falling edges failed: %d\r\n", checks); printf("MBED: Simultaneous rising and falling edges failed: %d\r\n", checks);
notify_completion(false); TEST_RESULT(false);
} }
notify_completion(true); TEST_RESULT(true);
return 0;
} }

View File

@ -91,6 +91,11 @@ PortInOut port1(PORT_1, MASK_1);
PortInOut port2(PORT_2, MASK_2); PortInOut port2(PORT_2, MASK_2);
int main() { int main() {
TEST_TIMEOUT(20);
TEST_HOSTTEST(default_auto);
TEST_DESCRIPTION(PortInOut);
TEST_START("MBED_A11");
bool check = true; bool check = true;
port1.output(); port1.output();
@ -111,5 +116,5 @@ int main() {
port2 = 0; wait(0.1); port2 = 0; wait(0.1);
if (port1 != 0) check = false; if (port1 != 0) check = false;
notify_completion(check); TEST_RESULT(check);
} }

View File

@ -91,6 +91,11 @@ PortOut port_out(PORT_1, MASK_1);
PortIn port_in (PORT_2, MASK_2); PortIn port_in (PORT_2, MASK_2);
int main() { int main() {
TEST_TIMEOUT(20);
TEST_HOSTTEST(default_auto);
TEST_DESCRIPTION(PortOut PortIn);
TEST_START("MBED_A10");
port_out = MASK_1; port_out = MASK_1;
wait(0.1); wait(0.1);
int value = port_in.read(); int value = port_in.read();