Proj 324 Final

Fork of ELEC351_Group_T by Plymouth ELEC351 Group T

Committer:
thomasmorris
Date:
Sat Dec 30 20:55:48 2017 +0000
Revision:
23:3c85d7f657a2
Working on Serial Comms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thomasmorris 23:3c85d7f657a2 1 #ifndef SETUP_HPP //Known as header guards
thomasmorris 23:3c85d7f657a2 2 #define SETUP_HPP
thomasmorris 23:3c85d7f657a2 3
thomasmorris 23:3c85d7f657a2 4
thomasmorris 23:3c85d7f657a2 5
thomasmorris 23:3c85d7f657a2 6 #include "sample_hardware.hpp"
thomasmorris 23:3c85d7f657a2 7 #include "Networkbits.hpp"
thomasmorris 23:3c85d7f657a2 8 #include "rtos.h"
thomasmorris 23:3c85d7f657a2 9 #include "LED.hpp"
thomasmorris 23:3c85d7f657a2 10 #include "DATA.hpp"
thomasmorris 23:3c85d7f657a2 11 #include "LCD.hpp"
thomasmorris 23:3c85d7f657a2 12 #define SerialTime 1
thomasmorris 23:3c85d7f657a2 13 #define NotSerialTime 0
thomasmorris 23:3c85d7f657a2 14 #define SamplingTime 1
thomasmorris 23:3c85d7f657a2 15 #define NotSamplingTime 0
thomasmorris 23:3c85d7f657a2 16 #define Print_Time_to_LCD 1
thomasmorris 23:3c85d7f657a2 17 #define Dont_Print_Time_to_LCD 0
thomasmorris 23:3c85d7f657a2 18 #define TimerInterval 1 //This is in seconds
thomasmorris 23:3c85d7f657a2 19 #define Serail_Enter_Check_Interval 0.1 //100 ms
thomasmorris 23:3c85d7f657a2 20 #define EDGE_RISEN 1
thomasmorris 23:3c85d7f657a2 21 #define EDGE_FALLEN 0
thomasmorris 23:3c85d7f657a2 22 #define mailsize 5
thomasmorris 23:3c85d7f657a2 23 #define SERIAL_COMMS 1
thomasmorris 23:3c85d7f657a2 24 #define NotSERIAL_COMMS 0
thomasmorris 23:3c85d7f657a2 25 #include <iostream>
thomasmorris 23:3c85d7f657a2 26 #include <SERIAL.hpp>
thomasmorris 23:3c85d7f657a2 27 Serial pc(USBTX, USBRX);
thomasmorris 23:3c85d7f657a2 28 //SW1+SW2 are declared as interrupt ins in sample hardware.cpp
thomasmorris 23:3c85d7f657a2 29
thomasmorris 23:3c85d7f657a2 30
thomasmorris 23:3c85d7f657a2 31 //Thread IDs
thomasmorris 23:3c85d7f657a2 32 osThreadId idMain;
thomasmorris 23:3c85d7f657a2 33 osThreadId id1;
thomasmorris 23:3c85d7f657a2 34 osThreadId id2;
thomasmorris 23:3c85d7f657a2 35 osThreadId id3;
thomasmorris 23:3c85d7f657a2 36 osThreadId id4;
thomasmorris 23:3c85d7f657a2 37
thomasmorris 23:3c85d7f657a2 38
thomasmorris 23:3c85d7f657a2 39 Timeout sw1TimeOut;//Used to prevent switch bounce
thomasmorris 23:3c85d7f657a2 40
thomasmorris 23:3c85d7f657a2 41 LED Red_led(PE_15);
thomasmorris 23:3c85d7f657a2 42 LED Yellow_led(PB_10);
thomasmorris 23:3c85d7f657a2 43 LED Green_led(PB_11);
thomasmorris 23:3c85d7f657a2 44
thomasmorris 23:3c85d7f657a2 45 LCD LCD(D8,D9,D4,A0,A1,A2,A3,D7,D6,D3,D1); //Declare the LCD class
thomasmorris 23:3c85d7f657a2 46 char LCD_buffer [50];
thomasmorris 23:3c85d7f657a2 47 int LCD_sprintf;
thomasmorris 23:3c85d7f657a2 48
thomasmorris 23:3c85d7f657a2 49 //Tickers
thomasmorris 23:3c85d7f657a2 50
thomasmorris 23:3c85d7f657a2 51 Ticker Sample_timer;
thomasmorris 23:3c85d7f657a2 52 Ticker Serial_timer;
thomasmorris 23:3c85d7f657a2 53 //Threads
thomasmorris 23:3c85d7f657a2 54 Thread t1;
thomasmorris 23:3c85d7f657a2 55 Thread t2;
thomasmorris 23:3c85d7f657a2 56 Thread t3;
thomasmorris 23:3c85d7f657a2 57 Thread t4;
thomasmorris 23:3c85d7f657a2 58 Thread t5;
thomasmorris 23:3c85d7f657a2 59 Thread t6;
thomasmorris 23:3c85d7f657a2 60
thomasmorris 23:3c85d7f657a2 61
thomasmorris 23:3c85d7f657a2 62 double temp = 0;
thomasmorris 23:3c85d7f657a2 63 double pressure = 0;
thomasmorris 23:3c85d7f657a2 64 double lux = 0;
thomasmorris 23:3c85d7f657a2 65 string buffer_time = 0;
thomasmorris 23:3c85d7f657a2 66
thomasmorris 23:3c85d7f657a2 67 char buffer[32];
thomasmorris 23:3c85d7f657a2 68 char scom_time_buffer[32];
thomasmorris 23:3c85d7f657a2 69 char msel_time_buffer[32];
thomasmorris 23:3c85d7f657a2 70
thomasmorris 23:3c85d7f657a2 71 void SW1FallingEdge();
thomasmorris 23:3c85d7f657a2 72 void SW1TimeOutHandler();
thomasmorris 23:3c85d7f657a2 73
thomasmorris 23:3c85d7f657a2 74 string Serial_Enter_Check;
thomasmorris 23:3c85d7f657a2 75 string Serial_Input;
thomasmorris 23:3c85d7f657a2 76
thomasmorris 23:3c85d7f657a2 77 Mutex lock1;//Mutex Locks
thomasmorris 23:3c85d7f657a2 78 Mutex lock2;
thomasmorris 23:3c85d7f657a2 79
thomasmorris 23:3c85d7f657a2 80 using namespace std;
thomasmorris 23:3c85d7f657a2 81
thomasmorris 23:3c85d7f657a2 82 int mode = 0;
thomasmorris 23:3c85d7f657a2 83
thomasmorris 23:3c85d7f657a2 84 Mail<DATA, mailsize> mail_box; //Mail Queue, Type DATA, Capacity mailsize(defined above), name mail_box
thomasmorris 23:3c85d7f657a2 85
thomasmorris 23:3c85d7f657a2 86 void Serial_Comms();
thomasmorris 23:3c85d7f657a2 87 void Serial_Comms_set();
thomasmorris 23:3c85d7f657a2 88
thomasmorris 23:3c85d7f657a2 89 #endif
thomasmorris 23:3c85d7f657a2 90