STM32F103C8T6_WIFI_Heating_system

Dependencies:   mbed mbed-STM32F103C8T6 eeprom_flash Watchdog PinDetect DS1820

  1. Bluepill STM32F103C8T6 Heating system
    1. _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)

Committer:
andrewklmn
Date:
Mon Sep 10 17:39:16 2018 +0000
Revision:
12:187e02ab447f
Parent:
10:4b88be251088
Child:
14:d954558361b9
hetaing system for korovnik

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hudakz 5:3c3ef17a17a6 1 #include "stm32f103c8t6.h"
hudakz 0:ab218237069e 2 #include "mbed.h"
andrewklmn 12:187e02ab447f 3
andrewklmn 12:187e02ab447f 4 Serial pc(PA_2, PA_3);
andrewklmn 12:187e02ab447f 5
andrewklmn 12:187e02ab447f 6 char a[128] = ""; // RX command buffer
andrewklmn 12:187e02ab447f 7 char i = 0; // RX char pointer
andrewklmn 12:187e02ab447f 8 char recieved = 0;
andrewklmn 12:187e02ab447f 9
andrewklmn 12:187e02ab447f 10 // This function is called when a character goes into the RX buffer.
andrewklmn 12:187e02ab447f 11 void rxCallback() {
andrewklmn 12:187e02ab447f 12 char c;
andrewklmn 12:187e02ab447f 13 if (recieved == 0){ // skip if command was already received
andrewklmn 12:187e02ab447f 14 c = pc.getc();
andrewklmn 12:187e02ab447f 15 if ( c == 0x0d || c == 0x0a ) {
andrewklmn 12:187e02ab447f 16 recieved = 1;
andrewklmn 12:187e02ab447f 17 } else {
andrewklmn 12:187e02ab447f 18 if (i==16){ // max length of command from SERIAL
andrewklmn 12:187e02ab447f 19 a[0] = c;
andrewklmn 12:187e02ab447f 20 a[1] = '\0';
andrewklmn 12:187e02ab447f 21 i = 0;
andrewklmn 12:187e02ab447f 22 } else {
andrewklmn 12:187e02ab447f 23 a[i] = c;
andrewklmn 12:187e02ab447f 24 i++;
andrewklmn 12:187e02ab447f 25 a[i] = '\0';
andrewklmn 12:187e02ab447f 26 };
andrewklmn 12:187e02ab447f 27 };
andrewklmn 12:187e02ab447f 28 };
andrewklmn 12:187e02ab447f 29 };
andrewklmn 12:187e02ab447f 30
hudakz 10:4b88be251088 31
hudakz 0:ab218237069e 32 int main() {
andrewklmn 12:187e02ab447f 33
hudakz 10:4b88be251088 34 confSysClock(); //Configure system clock (72MHz HSE clock, 48MHz USB clock)
andrewklmn 12:187e02ab447f 35 DigitalOut myled(LED1);
hudakz 10:4b88be251088 36
andrewklmn 12:187e02ab447f 37 pc.attach(&rxCallback, Serial::RxIrq);
andrewklmn 12:187e02ab447f 38 pc.baud(115200);
andrewklmn 12:187e02ab447f 39 pc.printf("Hello world!\r\n");
hudakz 10:4b88be251088 40
hudakz 0:ab218237069e 41 while(1) {
hudakz 5:3c3ef17a17a6 42 // The on-board LED is connected, via a resistor, to +3.3V (not to GND).
hudakz 3:c6a589f444b9 43 // So to turn the LED on or off we have to set it to 0 or 1 respectively
hudakz 7:accb2c83a007 44 myled = 0; // turn the LED on
andrewklmn 12:187e02ab447f 45 wait_ms(50); // 200 millisecond
andrewklmn 12:187e02ab447f 46 myled = 1; // turn the LED off
andrewklmn 12:187e02ab447f 47 wait_ms(50); // 1000 millisecond
andrewklmn 12:187e02ab447f 48 myled = 0; // turn the LED on
andrewklmn 12:187e02ab447f 49 wait_ms(50); // 200 millisecond
andrewklmn 12:187e02ab447f 50 myled = 1; // turn the LED off
andrewklmn 12:187e02ab447f 51 wait_ms(50); // 1000 millisecond
andrewklmn 12:187e02ab447f 52 myled = 0; // turn the LED on
andrewklmn 12:187e02ab447f 53 wait_ms(50); // 200 millisecond
hudakz 7:accb2c83a007 54 myled = 1; // turn the LED off
hudakz 10:4b88be251088 55 wait_ms(1000); // 1000 millisecond
andrewklmn 12:187e02ab447f 56 if (recieved == 1) {
andrewklmn 12:187e02ab447f 57 // command was recieved
andrewklmn 12:187e02ab447f 58 pc.printf(a);
andrewklmn 12:187e02ab447f 59
andrewklmn 12:187e02ab447f 60 // ready for new command
andrewklmn 12:187e02ab447f 61 a[0] = '\0';
andrewklmn 12:187e02ab447f 62 i = 0;
andrewklmn 12:187e02ab447f 63 recieved = 0;
andrewklmn 12:187e02ab447f 64 };
hudakz 0:ab218237069e 65 }
hudakz 0:ab218237069e 66 }
hudakz 8:f1432e9af6c8 67