Delta / Mbed OS Delta_BLE_LEDBlinker

Fork of BLE_LEDBlinker by Bluetooth Low Energy

Committer:
tsungta
Date:
Fri Dec 09 10:10:14 2016 +0000
Revision:
13:75f95a5cf9c1
Parent:
12:f0ffc006e62d
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tsungta 12:f0ffc006e62d 1 #ifdef MBED_CONF_RTOS_PRESENT
tsungta 12:f0ffc006e62d 2 #include "EventLoop.h"
tsungta 12:f0ffc006e62d 3
tsungta 12:f0ffc006e62d 4 #include "events.h"
tsungta 12:f0ffc006e62d 5 #include "rtos.h"
tsungta 12:f0ffc006e62d 6 #include "mbed.h"
tsungta 12:f0ffc006e62d 7
tsungta 12:f0ffc006e62d 8
tsungta 12:f0ffc006e62d 9 EventLoop::EventLoop(
tsungta 12:f0ffc006e62d 10 osPriority priority,
tsungta 12:f0ffc006e62d 11 unsigned event_size,
tsungta 12:f0ffc006e62d 12 unsigned char *event_pointer,
tsungta 12:f0ffc006e62d 13 uint32_t stack_size,
tsungta 12:f0ffc006e62d 14 unsigned char *stack_pointer)
tsungta 12:f0ffc006e62d 15 : EventQueue(event_size, event_pointer)
tsungta 12:f0ffc006e62d 16 , _thread(priority, stack_size, stack_pointer)
tsungta 12:f0ffc006e62d 17 , _running(false) {
tsungta 12:f0ffc006e62d 18 }
tsungta 12:f0ffc006e62d 19
tsungta 12:f0ffc006e62d 20 EventLoop::~EventLoop() {
tsungta 12:f0ffc006e62d 21 stop();
tsungta 12:f0ffc006e62d 22 }
tsungta 12:f0ffc006e62d 23
tsungta 12:f0ffc006e62d 24 static void run(EventLoop *loop) {
tsungta 12:f0ffc006e62d 25 loop->dispatch();
tsungta 12:f0ffc006e62d 26 }
tsungta 12:f0ffc006e62d 27
tsungta 12:f0ffc006e62d 28 osStatus EventLoop::start() {
tsungta 12:f0ffc006e62d 29 if (_running) {
tsungta 12:f0ffc006e62d 30 return osOK;
tsungta 12:f0ffc006e62d 31 }
tsungta 12:f0ffc006e62d 32
tsungta 12:f0ffc006e62d 33 osStatus status = _thread.start(this, run);
tsungta 12:f0ffc006e62d 34 _running = (status == osOK);
tsungta 12:f0ffc006e62d 35 return status;
tsungta 12:f0ffc006e62d 36 }
tsungta 12:f0ffc006e62d 37
tsungta 12:f0ffc006e62d 38 osStatus EventLoop::stop() {
tsungta 12:f0ffc006e62d 39 if (!_running) {
tsungta 12:f0ffc006e62d 40 return osOK;
tsungta 12:f0ffc006e62d 41 }
tsungta 12:f0ffc006e62d 42
tsungta 12:f0ffc006e62d 43 break_();
tsungta 12:f0ffc006e62d 44 osStatus status = _thread.join();
tsungta 12:f0ffc006e62d 45 _running = false;
tsungta 12:f0ffc006e62d 46 return status;
tsungta 12:f0ffc006e62d 47 }
tsungta 12:f0ffc006e62d 48
tsungta 12:f0ffc006e62d 49 #endif
tsungta 12:f0ffc006e62d 50