This program does *not* run correctly if declarations are left in.

Dependencies:   mbed-rtos mbed

Committer:
justgary
Date:
Thu Feb 02 23:36:37 2017 +0000
Revision:
0:e4945b97d9aa
This program does *not* run properly if declarations are left in.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
justgary 0:e4945b97d9aa 1 #include "mbed.h"
justgary 0:e4945b97d9aa 2 #include "rtos.h"
justgary 0:e4945b97d9aa 3
justgary 0:e4945b97d9aa 4 Serial pc(USBTX, USBRX);
justgary 0:e4945b97d9aa 5
justgary 0:e4945b97d9aa 6 DigitalOut redled(LED_RED);
justgary 0:e4945b97d9aa 7 DigitalOut greled(LED_GREEN);
justgary 0:e4945b97d9aa 8 DigitalOut bluled(LED_BLUE);
justgary 0:e4945b97d9aa 9 DigitalOut useled(LED_USER);
justgary 0:e4945b97d9aa 10
justgary 0:e4945b97d9aa 11 InterruptIn irq_data(P2_14); // <--- Leave this line, blink_thread() won't run
justgary 0:e4945b97d9aa 12
justgary 0:e4945b97d9aa 13 SPI spi_data(P10_14, P10_15, P10_12, P10_13); // SPI0 // <--- Leave these two lines, nothing runs
justgary 0:e4945b97d9aa 14 RawSerial uart_data(P8_14, P8_15); // UART4 // <-'
justgary 0:e4945b97d9aa 15
justgary 0:e4945b97d9aa 16
justgary 0:e4945b97d9aa 17 Thread h_task1_thread (osPriorityRealtime, 20480L, NULL);
justgary 0:e4945b97d9aa 18 Thread h_task2_thread (osPriorityHigh, 20480L, NULL);
justgary 0:e4945b97d9aa 19 Thread h_task3_thread (osPriorityNormal, 20480L, NULL);
justgary 0:e4945b97d9aa 20 Thread h_task4_thread (osPriorityLow, 20480L, NULL);
justgary 0:e4945b97d9aa 21 Thread h_blink_thread (osPriorityNormal, 20480L, NULL);
justgary 0:e4945b97d9aa 22
justgary 0:e4945b97d9aa 23 void blink_thread () {
justgary 0:e4945b97d9aa 24 useled = 1;
justgary 0:e4945b97d9aa 25 while (true) {
justgary 0:e4945b97d9aa 26 Thread::signal_wait(0x1);
justgary 0:e4945b97d9aa 27 useled = !useled;
justgary 0:e4945b97d9aa 28 }
justgary 0:e4945b97d9aa 29 }
justgary 0:e4945b97d9aa 30
justgary 0:e4945b97d9aa 31 int main() {
justgary 0:e4945b97d9aa 32 h_blink_thread.start(blink_thread);
justgary 0:e4945b97d9aa 33
justgary 0:e4945b97d9aa 34 while(1) {
justgary 0:e4945b97d9aa 35 bluled = 1;
justgary 0:e4945b97d9aa 36 wait(0.2);
justgary 0:e4945b97d9aa 37 bluled = 0;
justgary 0:e4945b97d9aa 38 wait(0.2);
justgary 0:e4945b97d9aa 39 h_blink_thread.signal_set(0x1);
justgary 0:e4945b97d9aa 40 }
justgary 0:e4945b97d9aa 41 }