This program is a part of Lab Assignment to introduce mbedRTOS feature. It has four threads.
Dependencies: 4DGL-uLCD-SE wave_player_appbd
Fork of rtos_mutex by
This program is a part of a ECE4180 Lab3. It uses four threads. Main thread is for counting the RTC time and printing to uLCD. Anohter thread is for playing short tone, next is for displaying image in uLCD from the unformatted SD card. Next thread control the RBG led. All these threads utilize bluetooth serial UART command received and function accordingly. Bluetooth App from adafruit is used as an assistance to send command.
Parts used: mBED LPC1768 uLCD Display + SD Card Adafruit Bluetooth Audio Amp + Speaker
main.cpp@1:0f886ffbe0c1, 2012-07-13 (annotated)
- Committer:
- emilmont
- Date:
- Fri Jul 13 10:34:00 2012 +0000
- Revision:
- 1:0f886ffbe0c1
- Parent:
- 0:9325f4cd8c1e
- Child:
- 5:384d6cef11d4
First implementation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 1:0f886ffbe0c1 | 1 | #include "mbed.h" |
emilmont | 1:0f886ffbe0c1 | 2 | #include "rtos.h" |
emilmont | 1:0f886ffbe0c1 | 3 | |
emilmont | 1:0f886ffbe0c1 | 4 | Mutex stdio_mutex; |
emilmont | 1:0f886ffbe0c1 | 5 | |
emilmont | 1:0f886ffbe0c1 | 6 | void notify(const char* name, int state) { |
emilmont | 1:0f886ffbe0c1 | 7 | stdio_mutex.lock(); |
emilmont | 1:0f886ffbe0c1 | 8 | printf("%s: %d\n\r", name, state); |
emilmont | 1:0f886ffbe0c1 | 9 | stdio_mutex.unlock(); |
emilmont | 1:0f886ffbe0c1 | 10 | } |
emilmont | 1:0f886ffbe0c1 | 11 | |
emilmont | 1:0f886ffbe0c1 | 12 | void test_thread(void const *args) { |
emilmont | 1:0f886ffbe0c1 | 13 | while (true) { |
emilmont | 1:0f886ffbe0c1 | 14 | notify((const char*)args, 0); Thread::wait(1000); |
emilmont | 1:0f886ffbe0c1 | 15 | notify((const char*)args, 1); Thread::wait(1000); |
emilmont | 1:0f886ffbe0c1 | 16 | } |
emilmont | 1:0f886ffbe0c1 | 17 | } |
emilmont | 1:0f886ffbe0c1 | 18 | |
emilmont | 1:0f886ffbe0c1 | 19 | int main() { |
emilmont | 1:0f886ffbe0c1 | 20 | Thread t2(test_thread, (void *)"Th 2"); |
emilmont | 1:0f886ffbe0c1 | 21 | Thread t3(test_thread, (void *)"Th 3"); |
emilmont | 1:0f886ffbe0c1 | 22 | |
emilmont | 1:0f886ffbe0c1 | 23 | test_thread((void *)"Th 1"); |
emilmont | 1:0f886ffbe0c1 | 24 | } |