Time: 17:33 Date: 10/12/2017 Description: Task 1,7,8 Currently Functioning
Dependencies: BME280 BMP280 TextLCD
Working Repository
SETUP.hpp@42:ae1640bca2e1, 2018-01-08 (annotated)
- Committer:
- thomasmorris
- Date:
- Mon Jan 08 15:38:53 2018 +0000
- Revision:
- 42:ae1640bca2e1
- Parent:
- 41:859b5e1e3d9a
- Child:
- 45:875f7e18a386
Edit me
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomasmorris | 41:859b5e1e3d9a | 1 | #ifndef _SETUP_HPP_ //SETUP header guard |
thomasmorris | 25:36699ed589ab | 2 | #define _SETUP_HPP_ |
thomasmorris | 41:859b5e1e3d9a | 3 | //File includes |
thomasmorris | 25:36699ed589ab | 4 | #include "sample_hardware.hpp" |
thomasmorris | 25:36699ed589ab | 5 | #include "rtos.h" |
thomasmorris | 25:36699ed589ab | 6 | #include "LED.hpp" |
thomasmorris | 25:36699ed589ab | 7 | #include "DATA.hpp" |
thomasmorris | 25:36699ed589ab | 8 | #include "LCD.hpp" |
thomasmorris | 25:36699ed589ab | 9 | #include "SERIAL.hpp" |
thomasmorris | 30:4cde05cc7c4f | 10 | #include "TIME.hpp" |
thomasmorris | 41:859b5e1e3d9a | 11 | #include <iostream> |
thomasmorris | 38:8d86e0d8a816 | 12 | |
thomasmorris | 41:859b5e1e3d9a | 13 | //Signal definitions |
thomasmorris | 28:09b5c46c8afd | 14 | #define SerialCommsTime 1 |
thomasmorris | 29:64b1f95a807c | 15 | #define NotSerialCommsTime 0 |
thomasmorris | 25:36699ed589ab | 16 | #define SamplingTime 1 |
thomasmorris | 25:36699ed589ab | 17 | #define NotSamplingTime 0 |
thomasmorris | 25:36699ed589ab | 18 | #define Print_Time_to_LCD 1 |
thomasmorris | 25:36699ed589ab | 19 | #define Dont_Print_Time_to_LCD 0 |
thomasmorris | 25:36699ed589ab | 20 | #define EDGE_RISEN 1 |
thomasmorris | 25:36699ed589ab | 21 | #define EDGE_FALLEN 0 |
thomasmorris | 41:859b5e1e3d9a | 22 | #define SD_Data_Ready 1 |
thomasmorris | 41:859b5e1e3d9a | 23 | #define No_SD_Data_Ready 0 |
thomasmorris | 38:8d86e0d8a816 | 24 | |
thomasmorris | 41:859b5e1e3d9a | 25 | //Time definitions |
thomasmorris | 42:ae1640bca2e1 | 26 | #define TimerInterval 1 //This is in seconds |
thomasmorris | 41:859b5e1e3d9a | 27 | #define Default_Mode_Toggle_Time 3000 |
thomasmorris | 41:859b5e1e3d9a | 28 | #define NetworkWait 5000 |
thomasmorris | 41:859b5e1e3d9a | 29 | |
thomasmorris | 41:859b5e1e3d9a | 30 | //Definition of Data buffer size (120 in specification) |
thomasmorris | 42:ae1640bca2e1 | 31 | #define mailsize 20 |
thomasmorris | 41:859b5e1e3d9a | 32 | |
thomasmorris | 41:859b5e1e3d9a | 33 | DATA Data_Active;//Current data sample |
thomasmorris | 41:859b5e1e3d9a | 34 | DATA Data_Buffer[mailsize];//Data buffer |
thomasmorris | 38:8d86e0d8a816 | 35 | int Data_Buffer_Write_Pointer; |
thomasmorris | 38:8d86e0d8a816 | 36 | int Write_To_Data_Buffer(DATA Data_Store, int Write_Pointer); |
thomasmorris | 39:5c499989d2b9 | 37 | int Write_Pointer = 0; |
thomasmorris | 37:7c4d7f206039 | 38 | |
thomasmorris | 41:859b5e1e3d9a | 39 | LCD LCD(D8,D9,D4,A0,A1,A2,A3,D7,D6,D3,D1);//LCD object creation via constructor |
thomasmorris | 37:7c4d7f206039 | 40 | |
thomasmorris | 41:859b5e1e3d9a | 41 | Serial pc(USBTX, USBRX);//Define serial namespace so the serial comms can be printed to |
thomasmorris | 41:859b5e1e3d9a | 42 | |
thomasmorris | 41:859b5e1e3d9a | 43 | //Forward Declarations of functions |
thomasmorris | 25:36699ed589ab | 44 | |
thomasmorris | 25:36699ed589ab | 45 | void Serial_Comms(); |
chills | 26:78f5e454e59f | 46 | void Sample_signal_set(); |
chills | 26:78f5e454e59f | 47 | void Console_Output_ISR(); |
thomasmorris | 41:859b5e1e3d9a | 48 | void Serial_Comms_Data_Get(); |
thomasmorris | 41:859b5e1e3d9a | 49 | void Sampling_ISR(); |
thomasmorris | 41:859b5e1e3d9a | 50 | void Console_Output_ISR(); |
thomasmorris | 41:859b5e1e3d9a | 51 | //Declarations of Varialbes |
thomasmorris | 25:36699ed589ab | 52 | |
thomasmorris | 25:36699ed589ab | 53 | float Sample_Rate; |
thomasmorris | 41:859b5e1e3d9a | 54 | int mode = 0;//Used to switch modes in serial comms |
thomasmorris | 41:859b5e1e3d9a | 55 | char LCD_buffer [50]; |
thomasmorris | 41:859b5e1e3d9a | 56 | int LCD_sprintf; |
thomasmorris | 41:859b5e1e3d9a | 57 | int Log_Value = 0; |
thomasmorris | 41:859b5e1e3d9a | 58 | double temp = 0; |
thomasmorris | 41:859b5e1e3d9a | 59 | double pressure = 0; |
thomasmorris | 41:859b5e1e3d9a | 60 | double lux = 0; |
thomasmorris | 41:859b5e1e3d9a | 61 | string buffer_time = 0; |
thomasmorris | 41:859b5e1e3d9a | 62 | char buffer[32]; |
thomasmorris | 41:859b5e1e3d9a | 63 | char scom_time_buffer[32]; |
thomasmorris | 41:859b5e1e3d9a | 64 | char msel_time_buffer[32]; |
thomasmorris | 41:859b5e1e3d9a | 65 | |
thomasmorris | 25:36699ed589ab | 66 | //Thread IDs |
thomasmorris | 25:36699ed589ab | 67 | osThreadId idMain; |
thomasmorris | 25:36699ed589ab | 68 | osThreadId id1; |
thomasmorris | 25:36699ed589ab | 69 | osThreadId id2; |
thomasmorris | 25:36699ed589ab | 70 | osThreadId id3; |
thomasmorris | 25:36699ed589ab | 71 | osThreadId id4; |
thomasmorris | 25:36699ed589ab | 72 | osThreadId id5; |
thomasmorris | 25:36699ed589ab | 73 | |
thomasmorris | 41:859b5e1e3d9a | 74 | //Time out Declarations |
thomasmorris | 25:36699ed589ab | 75 | Timeout sw1TimeOut;//Used to prevent switch bounce |
thomasmorris | 30:4cde05cc7c4f | 76 | Timeout sw2TimeOut;//Used to prevent switch bounce |
thomasmorris | 25:36699ed589ab | 77 | |
thomasmorris | 41:859b5e1e3d9a | 78 | //LED object constructors |
thomasmorris | 25:36699ed589ab | 79 | LED Red_led(PE_15); |
thomasmorris | 25:36699ed589ab | 80 | LED Yellow_led(PB_10); |
thomasmorris | 25:36699ed589ab | 81 | LED Green_led(PB_11); |
thomasmorris | 25:36699ed589ab | 82 | |
thomasmorris | 25:36699ed589ab | 83 | //Tickers |
thomasmorris | 41:859b5e1e3d9a | 84 | Ticker Sampling_Timer;//Controls Sampling |
thomasmorris | 41:859b5e1e3d9a | 85 | Ticker Console_Output_Timer;//Controls Serial comms |
thomasmorris | 25:36699ed589ab | 86 | |
thomasmorris | 25:36699ed589ab | 87 | //Threads |
thomasmorris | 41:859b5e1e3d9a | 88 | Thread t1(osPriorityRealtime); //Sampler Set to a highest priority |
thomasmorris | 25:36699ed589ab | 89 | Thread t2; |
thomasmorris | 25:36699ed589ab | 90 | Thread t3; |
thomasmorris | 25:36699ed589ab | 91 | Thread t4; |
thomasmorris | 25:36699ed589ab | 92 | Thread t5; |
thomasmorris | 25:36699ed589ab | 93 | |
thomasmorris | 25:36699ed589ab | 94 | |
thomasmorris | 41:859b5e1e3d9a | 95 | using namespace std;//Set default namespace enables use of iostream with serial comms |
thomasmorris | 25:36699ed589ab | 96 | #endif |