mirror of https://github.com/ARMmbed/mbed-os.git
RTOS_8 ISR handling for queue put/get functionality added to test suite
parent
e35fd00101
commit
b6fadb4e11
|
@ -1,34 +1,53 @@
|
|||
#include "mbed.h"
|
||||
#include "test_env.h"
|
||||
#include "rtos.h"
|
||||
|
||||
Queue<uint32_t, 5> queue;
|
||||
#define QUEUE_SIZE 5
|
||||
#define THREAD_DELAY 250
|
||||
#define QUEUE_PUT_ISR_VALUE 128
|
||||
#define QUEUE_PUT_THREAD_VALUE 127
|
||||
|
||||
Queue<uint32_t, QUEUE_SIZE> queue;
|
||||
|
||||
DigitalOut myled(LED1);
|
||||
|
||||
void queue_isr() {
|
||||
queue.put((uint32_t*)2);
|
||||
|
||||
queue.put((uint32_t*)QUEUE_PUT_ISR_VALUE);
|
||||
myled = !myled;
|
||||
}
|
||||
|
||||
void queue_thread(void const *argument) {
|
||||
while (true) {
|
||||
queue.put((uint32_t*)1);
|
||||
Thread::wait(1000);
|
||||
queue.put((uint32_t*)QUEUE_PUT_THREAD_VALUE);
|
||||
Thread::wait(THREAD_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
int main (void) {
|
||||
Thread thread(queue_thread);
|
||||
|
||||
Ticker ticker;
|
||||
ticker.attach(queue_isr, 1.0);
|
||||
|
||||
int isr_puts_counter = 0;
|
||||
bool result = true;
|
||||
|
||||
while (true) {
|
||||
osEvent evt = queue.get();
|
||||
if (evt.status != osEventMessage) {
|
||||
printf("queue->get() returned %02x status\n\r", evt.status);
|
||||
printf("QUEUE_GET: Status(0x%02X) ... [FAIL]\r\n", evt.status);
|
||||
result = false;
|
||||
break;
|
||||
} else {
|
||||
printf("queue->get() returned %d\n\r", evt.value.v);
|
||||
printf("QUEUE_GET: Value(%u) ... [OK]\r\n", evt.value.v);
|
||||
if (evt.value.v == QUEUE_PUT_ISR_VALUE) {
|
||||
isr_puts_counter++;
|
||||
}
|
||||
if (isr_puts_counter >= QUEUE_SIZE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notify_completion(result);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -548,9 +548,10 @@ TESTS = [
|
|||
"host_test": "wait_us_auto"
|
||||
},
|
||||
{
|
||||
"id": "RTOS_8", "description": "ISR",
|
||||
"id": "RTOS_8", "description": "ISR (Queue)",
|
||||
"source_dir": join(TEST_DIR, "rtos", "mbed", "isr"),
|
||||
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES],
|
||||
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB],
|
||||
"automated": True,
|
||||
},
|
||||
{
|
||||
"id": "RTOS_9", "description": "SD File write-read",
|
||||
|
@ -608,6 +609,7 @@ TESTS = [
|
|||
"source_dir": join(TEST_DIR, "net", "protocols", "HTTPClient_HelloWorld"),
|
||||
"dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB],
|
||||
"automated": True,
|
||||
"duration": 15,
|
||||
"peripherals": ["ethernet"],
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue