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
Revision 2:0e0131d51df5, committed 2014-04-28
- Comitter:
- alpov
- Date:
- Mon Apr 28 13:10:52 2014 +0000
- Parent:
- 1:ba96f3880cfc
- Child:
- 3:ede67e9b60eb
- Commit message:
- updated libs, testing main devel, removed rtos
Changed in this revision
--- a/DS1307.lib Mon Apr 28 07:48:57 2014 +0000 +++ b/DS1307.lib Mon Apr 28 13:10:52 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/alpov/code/DS1307/#60383faa35a9 +http://mbed.org/users/alpov/code/DS1307/#c5018c71887f
--- a/USBDevice.lib Mon Apr 28 07:48:57 2014 +0000 +++ b/USBDevice.lib Mon Apr 28 13:10:52 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/USBDevice/#5b7d31d9d3f3 +http://mbed.org/users/alpov/code/USBDevice/#c7639faed2eb
--- a/main.cpp Mon Apr 28 07:48:57 2014 +0000 +++ b/main.cpp Mon Apr 28 13:10:52 2014 +0000 @@ -3,13 +3,12 @@ #include "USBSerial.h" #include "DS1307.h" #include "1wire.h" -#include "mbed_debug.h" Serial pc(MBED_UARTUSB); SDFileSystem sd(MBED_SPI0, "sd"); -//USBSerial usb(0x1f00, 0x2012, 0x0001/*, false*/); +USBSerial usb(0x1f00, 0x2012, 0x0001, false); DS1307 rtc(I2C_SDA, I2C_SCL); @@ -28,11 +27,23 @@ DigitalIn IN2(D9, PullUp); +void blik_usb() +{ + if (usb.configured()) + ledG = !ledG; + else + ledG = 1; +} + + int main(void) { Timer t; + Ticker usbstat; char c; + usbstat.attach(&blik_usb, 0.2); + pc.printf("Hello World!\n"); FILE *fp = fopen("/sd/sdtest2.txt", "w"); @@ -56,28 +67,14 @@ OUT3 = 0; OUT4 = 0; - pc.printf("\n\n\n\n*************************************\n"); - pc.printf("* r - reads the clock\n"); - pc.printf("* w - write the clock\n"); - pc.printf("* c - convert temperatures\n"); - pc.printf("* t - search 1wire and list read temperatures\n"); - pc.printf("*************************************\n\n"); - + pc.printf("Entering loop\n"); + while (1) { -// ledR = usb.configured(); - - ledG = 0; - wait(0.2); - ledG = 1; - wait(0.2); -/* - if (usb.configured()) - usb.printf("blik!\n"); -*/ + if (!usb.readable()) continue; + c = usb.getc(); + //pc.printf("USB command received\n"); - if (!pc.readable()) continue; - c = pc.getc(); if (c == 'r') { // perform read t.reset(); @@ -88,24 +85,24 @@ struct tm *now; now = localtime(&m_time); - pc.printf("Current time is %lu, %02d:%02d:%02d, %d.%d.%04d\n", + usb.printf("Current time is %lu, %02d:%02d:%02d, %d.%d.%04d\n", m_time, now->tm_hour, now->tm_min, now->tm_sec, now->tm_mday, now->tm_mon+1, now->tm_year+1900 ); - pc.printf("Internal datetime format is %s\n", asctime(now)); - pc.printf("Read complete, elapsed %uus\n", t.read_us()); + usb.printf("Internal datetime format is %s\n", asctime(now)); + usb.printf("Read complete, elapsed %uus\n", t.read_us()); } else if (c == 'w') { // perform write int date, month, year, hours, minutes, seconds; - pc.printf("Enter the date (date 1..31)\n"); pc.scanf("%d", &date); - pc.printf("Enter the date (month 1..12)\n"); pc.scanf("%d", &month); - pc.printf("Enter the date (year >2000)\n"); pc.scanf("%d", &year); - pc.printf("Enter the time (hours 0..23)\n"); pc.scanf("%d", &hours); - pc.printf("Enter the time (minutes 0..59)\n"); pc.scanf("%d", &minutes); - pc.printf("Enter the time (seconds 0..59)\n"); pc.scanf("%d", &seconds); + usb.printf("Enter the date (date 1..31)\n"); usb.scanf("%d", &date); + usb.printf("Enter the date (month 1..12)\n"); usb.scanf("%d", &month); + usb.printf("Enter the date (year >2000)\n"); usb.scanf("%d", &year); + usb.printf("Enter the time (hours 0..23)\n"); usb.scanf("%d", &hours); + usb.printf("Enter the time (minutes 0..59)\n"); usb.scanf("%d", &minutes); + usb.printf("Enter the time (seconds 0..59)\n"); usb.scanf("%d", &seconds); struct tm now = {seconds, minutes, hours, date, month-1, year-1900}; time_t m_time = mktime(&now); @@ -115,11 +112,11 @@ bool b = rtc.set_time(m_time); t.stop(); - pc.printf("Write complete (UNIX %lu, result %d), elapsed %uus\n", m_time, b, t.read_us()); + usb.printf("Write complete (UNIX %lu, result %d), elapsed %uus\n", m_time, b, t.read_us()); } else if (c == 'c') { ow.ConvertAll(true); - pc.printf("Convert done\n"); + usb.printf("Convert done\n"); } else if (c == 't') { int result, temp; @@ -128,23 +125,24 @@ memset(rom, 0, sizeof(rom)); result = ow.First(rom); while (result == OW_FOUND) { - for (int i = 0; i < 8; i++) pc.printf("%.2X", rom[i]); + for (int i = 0; i < 8; i++) usb.printf("%.2X", rom[i]); t.reset(); t.start(); int b = ow.ReadTemperature(rom, &temp); t.stop(); - if (b) pc.printf(": read failed, code 0x%.4x, elapsed %uus\n", b, t.read_us()); - else pc.printf(": read ok, temperature %.2f'C, elapsed %uus\n", temp / 100., t.read_us()); + if (b) usb.printf(": read failed, code 0x%.4x, elapsed %uus\n", b, t.read_us()); + else usb.printf(": read ok, temperature %.2f'C, elapsed %uus\n", temp / 100., t.read_us()); result = ow.Next(rom); } - pc.printf("Done\n"); + usb.printf("Done\n"); } else { - pc.printf("Syntax error\n"); + usb.printf("Syntax error\n"); } - pc.printf("\n"); + + usb.printf("\n"); } }
--- a/mbed-rtos.lib Mon Apr 28 07:48:57 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#be2573f85b81