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:
- 37:c9b96afec535
- Parent:
- 35:74a546766adb
- Child:
- 38:a0753c2a4497
--- a/main.cpp Mon Sep 17 20:16:33 2018 +0000 +++ b/main.cpp Tue Sep 18 06:40:34 2018 +0000 @@ -25,6 +25,7 @@ DigitalOut pomp_OFF(PA_12); // pomp off DigitalOut heater_OFF(PA_15); // heater off +unsigned int epprom_value = 0; float temp[5] = { 85,85,85,85,85 // initial temperature @@ -76,6 +77,8 @@ void pb_hit_interrupt (void) { + //writeEEPROMWord(0, 666 ); + epprom_value++; pc.printf("Button pressed\r\n"); }; @@ -110,10 +113,12 @@ if ( a[2]=='\0') { //pc.printf(a); - pc.printf("OK\r\n"); + pc.printf("RAM=%u FLASH=%u OK\r\n", epprom_value, readEEPROMWord(0)); } else { pc.printf("Wrong AT command\r\n"); }; + + //readEEPROMWord(0x01); } else { pc.printf("Wrong request\r\n"); }; @@ -161,6 +166,13 @@ pc.printf("Temp %3.1f|%3.1f|%3.1f|%3.1f|%3.1f\r\n", temp[0], temp[1], temp[2], temp[3], temp[4] ); pc.printf("======================================="); + if (readEEPROMWord(0)!=epprom_value) { + enableEEPROMWriting(); + writeEEPROMWord(0,epprom_value); + disableEEPROMWriting(); + }; + + __enable_irq(); myled = 1; // turn the LED off @@ -172,8 +184,10 @@ int main() { confSysClock(); //Configure system clock (72MHz HSE clock, 48MHz USB clock) - - wd.Configure(5.0); + + epprom_value = readEEPROMWord(0); + + wd.Configure(10.0); PinDetect pb(PA_11); pb.mode(PullUp); @@ -207,7 +221,7 @@ queue.call( start_temp ); queue.call_every(100, at_command); - queue.call_every(1000, check_temp); + queue.call_every(2000, check_temp); // Start queue queue.dispatch();