This program utilizes the mcr20 Thread Shield on the FRDM-K64F MCU which is a two-part workspace (HVAC Server (RX)/Probe(TX)) to handle low temperature events read at the probe(s) to prevent pipes from freezing.

Dependencies:   DHT fsl_phy_mcr20a fsl_smac mbed-rtos mbed

Fork of mcr20_wireless_uart by NXP

Committer:
cotigac
Date:
Fri Apr 03 05:23:33 2015 +0000
Revision:
18:b02fc0e53df8
Parent:
17:52cfd7db8da3
Child:
19:71b793021c78
Started creating wireless uart demo based on mbed-rtos

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 0:01fb291427ce 1 #include "mbed.h"
cotigac 18:b02fc0e53df8 2 #include "rtos.h"
sam_grove 2:3e7685cfb2a7 3
cotigac 18:b02fc0e53df8 4 DigitalOut led1(LED1);
cotigac 18:b02fc0e53df8 5 InterruptIn sw2(SW2);
cotigac 18:b02fc0e53df8 6 uint32_t button_pressed;
cotigac 18:b02fc0e53df8 7 Thread *thread2;
sam_grove 2:3e7685cfb2a7 8
cotigac 18:b02fc0e53df8 9 void sw2_press(void)
cotigac 18:b02fc0e53df8 10 {
cotigac 18:b02fc0e53df8 11 thread2->signal_set(0x1);
cotigac 18:b02fc0e53df8 12 }
sam_grove 2:3e7685cfb2a7 13
cotigac 18:b02fc0e53df8 14 void led_thread(void const *argument)
cotigac 18:b02fc0e53df8 15 {
cotigac 18:b02fc0e53df8 16 while (true) {
cotigac 18:b02fc0e53df8 17 led1 = !led1;
cotigac 18:b02fc0e53df8 18 Thread::wait(1000);
sam_grove 2:3e7685cfb2a7 19 }
sam_grove 2:3e7685cfb2a7 20 }
sam_grove 2:3e7685cfb2a7 21
cotigac 18:b02fc0e53df8 22 void button_thread(void const *argument)
sam_grove 2:3e7685cfb2a7 23 {
cotigac 18:b02fc0e53df8 24 while (true) {
cotigac 18:b02fc0e53df8 25 Thread::signal_wait(0x1);
cotigac 18:b02fc0e53df8 26 button_pressed++;
cotigac 18:b02fc0e53df8 27 }
sam_grove 2:3e7685cfb2a7 28 }
sam_grove 2:3e7685cfb2a7 29
sam_grove 2:3e7685cfb2a7 30 int main()
sam_grove 2:3e7685cfb2a7 31 {
cotigac 18:b02fc0e53df8 32 Thread thread(led_thread);
cotigac 18:b02fc0e53df8 33 thread2 = new Thread(button_thread);
sam_grove 2:3e7685cfb2a7 34
cotigac 18:b02fc0e53df8 35 button_pressed = 0;
cotigac 18:b02fc0e53df8 36 sw2.fall(&sw2_press);
cotigac 18:b02fc0e53df8 37 while (true) {
cotigac 18:b02fc0e53df8 38 Thread::wait(5000);
cotigac 18:b02fc0e53df8 39 printf("SW2 was pressed (last 5 seconds): %d \r\n", button_pressed);
cotigac 18:b02fc0e53df8 40 fflush(stdout);
cotigac 18:b02fc0e53df8 41 button_pressed = 0;
sam_grove 2:3e7685cfb2a7 42 }
sam_grove 2:3e7685cfb2a7 43 }