EMIR - Ekvitermní mikroprocesorová regulace https://code.google.com/p/emir/ https://code.google.com/p/emir/wiki/DesignV3
Dependencies: ConfigFile DS1307 OneWire SDFileSystem USBDeviceLite mbed-rtos mbed
Diff: src/main.cpp
- Revision:
- 3:ede67e9b60eb
- Child:
- 4:9065e9ccb078
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main.cpp Tue May 06 19:21:27 2014 +0000 @@ -0,0 +1,63 @@ +#include "mbed.h" +#include "rtos.h" +#include "SDFileSystem.h" +#include "sensor.h" +#include "comm.h" + +Serial pc(MBED_UARTUSB); + +SDFileSystem sd(MBED_SPI0, "sd"); + +DigitalOut ledR(LED_RED, 1); +DigitalOut ledG(LED_GREEN, 1); +//DigitalOut ledB(LED_BLUE, 1); + +DigitalOut OUT1(D2, 0); +DigitalOut OUT2(D3, 0); +DigitalOut OUT3(D4, 0); +DigitalOut OUT4(D5, 0); + +DigitalIn IN1(D8, PullUp); +DigitalIn IN2(D9, PullUp); + +extern "C" void HardFault_Handler() +{ + mbed_die(); +} + +int main(void) +{ + pc.printf("Starting threads... "); + Thread sensor(sensor_thread, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); + Thread comm(comm_thread, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); + pc.printf("done\n"); + + FILE *fp = fopen("/sd/sdtest2.txt", "w"); + if (fp == NULL) { + pc.printf("Could not open file for write\n"); + } else { + pc.printf("Writing... "); + fprintf(fp, "Hello fun SD Card World!\nOK!\n"); + pc.printf("closing... "); + fclose(fp); + } + pc.printf("done\n"); + + OUT1 = 1; + OUT2 = 1; + OUT3 = 1; + OUT4 = 1; + wait(1.0); + OUT1 = 0; + OUT2 = 0; + OUT3 = 0; + OUT4 = 0; + + while (1) + { + ledG = !ledG; + Thread::wait(200); + } + +} +