STM32F103C8T6_WIFI_Heating_system
Dependencies: mbed mbed-STM32F103C8T6 eeprom_flash Watchdog PinDetect DS1820
- Bluepill STM32F103C8T6 Heating system
- _This project is core part of bigger heating system project!_
Features
- Reading temperature from four DS18B20 sensors
- Making a decision about switching on/off heater and pomp
- Executing simple user commands from UART
- Storing state parameters to program memory (EEPROM emulation)
Diff: main.cpp
- Revision:
- 14:d954558361b9
- Parent:
- 12:187e02ab447f
- Child:
- 15:721546347507
--- a/main.cpp Mon Sep 10 18:01:39 2018 +0000 +++ b/main.cpp Mon Sep 10 21:21:19 2018 +0000 @@ -5,13 +5,13 @@ char a[128] = ""; // RX command buffer char i = 0; // RX char pointer -char recieved = 0; +static char recieved = 0; // This function is called when a character goes into the RX buffer. void rxCallback() { char c; + c = pc.getc(); if (recieved == 0){ // skip if command was already received - c = pc.getc(); if ( c == 0x0d || c == 0x0a ) { recieved = 1; } else { @@ -24,7 +24,7 @@ i++; a[i] = '\0'; }; - }; + }; }; }; @@ -35,7 +35,7 @@ DigitalOut myled(LED1); pc.attach(&rxCallback, Serial::RxIrq); - pc.baud(115200); + pc.baud(9600); pc.printf("Hello world!\r\n"); while(1) { @@ -54,14 +54,16 @@ myled = 1; // turn the LED off wait_ms(1000); // 1000 millisecond if (recieved == 1) { + // command was recieved pc.printf(a); // ready for new command + recieved = 0; a[0] = '\0'; i = 0; - recieved = 0; - }; + }; + } } \ No newline at end of file