Skip to content

Commit b6fadb4

Browse files
committed
RTOS_8 ISR handling for queue put/get functionality added to test suite
1 parent e35fd00 commit b6fadb4

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed
Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,53 @@
11
#include "mbed.h"
2+
#include "test_env.h"
23
#include "rtos.h"
34

4-
Queue<uint32_t, 5> queue;
5+
#define QUEUE_SIZE 5
6+
#define THREAD_DELAY 250
7+
#define QUEUE_PUT_ISR_VALUE 128
8+
#define QUEUE_PUT_THREAD_VALUE 127
9+
10+
Queue<uint32_t, QUEUE_SIZE> queue;
511

612
DigitalOut myled(LED1);
713

814
void queue_isr() {
9-
queue.put((uint32_t*)2);
15+
16+
queue.put((uint32_t*)QUEUE_PUT_ISR_VALUE);
1017
myled = !myled;
1118
}
1219

1320
void queue_thread(void const *argument) {
1421
while (true) {
15-
queue.put((uint32_t*)1);
16-
Thread::wait(1000);
22+
queue.put((uint32_t*)QUEUE_PUT_THREAD_VALUE);
23+
Thread::wait(THREAD_DELAY);
1724
}
1825
}
1926

2027
int main (void) {
2128
Thread thread(queue_thread);
22-
2329
Ticker ticker;
2430
ticker.attach(queue_isr, 1.0);
25-
31+
int isr_puts_counter = 0;
32+
bool result = true;
33+
2634
while (true) {
2735
osEvent evt = queue.get();
2836
if (evt.status != osEventMessage) {
29-
printf("queue->get() returned %02x status\n\r", evt.status);
37+
printf("QUEUE_GET: Status(0x%02X) ... [FAIL]\r\n", evt.status);
38+
result = false;
39+
break;
3040
} else {
31-
printf("queue->get() returned %d\n\r", evt.value.v);
41+
printf("QUEUE_GET: Value(%u) ... [OK]\r\n", evt.value.v);
42+
if (evt.value.v == QUEUE_PUT_ISR_VALUE) {
43+
isr_puts_counter++;
44+
}
45+
if (isr_puts_counter >= QUEUE_SIZE) {
46+
break;
47+
}
3248
}
3349
}
50+
51+
notify_completion(result);
52+
return 0;
3453
}

workspace_tools/tests.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,10 @@
548548
"host_test": "wait_us_auto"
549549
},
550550
{
551-
"id": "RTOS_8", "description": "ISR",
551+
"id": "RTOS_8", "description": "ISR (Queue)",
552552
"source_dir": join(TEST_DIR, "rtos", "mbed", "isr"),
553-
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES],
553+
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB],
554+
"automated": True,
554555
},
555556
{
556557
"id": "RTOS_9", "description": "SD File write-read",
@@ -608,6 +609,7 @@
608609
"source_dir": join(TEST_DIR, "net", "protocols", "HTTPClient_HelloWorld"),
609610
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB],
610611
"automated": True,
612+
"duration": 15,
611613
"peripherals": ["ethernet"],
612614
},
613615
{

0 commit comments

Comments
 (0)