Plymouth ELEC351 Group T
/
ELEC351_Group_T
FINAL PROJECT isn't it
Fork of ELEC351 by
SETUP.hpp@38:8d86e0d8a816, 2018-01-07 (annotated)
- Committer:
- thomasmorris
- Date:
- Sun Jan 07 21:08:34 2018 +0000
- Revision:
- 38:8d86e0d8a816
- Parent:
- 37:7c4d7f206039
- Child:
- 39:5c499989d2b9
FIFO work in progress
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomasmorris | 25:36699ed589ab | 1 | #ifndef _SETUP_HPP_ //Known as header guards |
thomasmorris | 25:36699ed589ab | 2 | #define _SETUP_HPP_ |
thomasmorris | 25:36699ed589ab | 3 | |
thomasmorris | 25:36699ed589ab | 4 | #include "sample_hardware.hpp" |
thomasmorris | 35:26b0a9b55d82 | 5 | //#include "Networkbits.hpp" |
thomasmorris | 25:36699ed589ab | 6 | #include "rtos.h" |
thomasmorris | 25:36699ed589ab | 7 | #include "LED.hpp" |
thomasmorris | 25:36699ed589ab | 8 | #include "DATA.hpp" |
thomasmorris | 25:36699ed589ab | 9 | #include "LCD.hpp" |
thomasmorris | 25:36699ed589ab | 10 | #include "SERIAL.hpp" |
thomasmorris | 30:4cde05cc7c4f | 11 | #include "TIME.hpp" |
thomasmorris | 38:8d86e0d8a816 | 12 | |
thomasmorris | 38:8d86e0d8a816 | 13 | |
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 TimerInterval 2 //This is in seconds |
thomasmorris | 35:26b0a9b55d82 | 21 | #define Default_Mode_Toggle_Time 3000 |
thomasmorris | 25:36699ed589ab | 22 | #define EDGE_RISEN 1 |
thomasmorris | 25:36699ed589ab | 23 | #define EDGE_FALLEN 0 |
thomasmorris | 38:8d86e0d8a816 | 24 | #include <iostream> |
thomasmorris | 25:36699ed589ab | 25 | #define mailsize 5 |
thomasmorris | 38:8d86e0d8a816 | 26 | |
thomasmorris | 38:8d86e0d8a816 | 27 | DATA Data_Active; |
thomasmorris | 38:8d86e0d8a816 | 28 | DATA Data_Buffer[mailsize]; |
thomasmorris | 38:8d86e0d8a816 | 29 | int Data_Buffer_Write_Pointer; |
thomasmorris | 38:8d86e0d8a816 | 30 | int Write_To_Data_Buffer(DATA Data_Store, int Write_Pointer); |
thomasmorris | 37:7c4d7f206039 | 31 | |
thomasmorris | 37:7c4d7f206039 | 32 | LCD LCD(D8,D9,D4,A0,A1,A2,A3,D7,D6,D3,D1); |
thomasmorris | 37:7c4d7f206039 | 33 | |
thomasmorris | 25:36699ed589ab | 34 | Serial pc(USBTX, USBRX); |
thomasmorris | 25:36699ed589ab | 35 | //SW1+SW2 are declared as interrupt ins in sample hardware.cpp |
thomasmorris | 25:36699ed589ab | 36 | //Forward Declarations |
thomasmorris | 25:36699ed589ab | 37 | |
thomasmorris | 25:36699ed589ab | 38 | void Serial_Comms(); |
chills | 26:78f5e454e59f | 39 | void Sample_signal_set(); |
chills | 26:78f5e454e59f | 40 | void Console_Output_ISR(); |
thomasmorris | 37:7c4d7f206039 | 41 | void Serial_Comms_Data_Get(); |
thomasmorris | 25:36699ed589ab | 42 | |
thomasmorris | 25:36699ed589ab | 43 | float Sample_Rate; |
thomasmorris | 25:36699ed589ab | 44 | //Thread IDs |
thomasmorris | 25:36699ed589ab | 45 | osThreadId idMain; |
thomasmorris | 25:36699ed589ab | 46 | osThreadId id1; |
thomasmorris | 25:36699ed589ab | 47 | osThreadId id2; |
thomasmorris | 25:36699ed589ab | 48 | osThreadId id3; |
thomasmorris | 25:36699ed589ab | 49 | osThreadId id4; |
thomasmorris | 25:36699ed589ab | 50 | osThreadId id5; |
thomasmorris | 25:36699ed589ab | 51 | |
thomasmorris | 25:36699ed589ab | 52 | |
thomasmorris | 25:36699ed589ab | 53 | Timeout sw1TimeOut;//Used to prevent switch bounce |
thomasmorris | 30:4cde05cc7c4f | 54 | Timeout sw2TimeOut;//Used to prevent switch bounce |
thomasmorris | 25:36699ed589ab | 55 | |
thomasmorris | 25:36699ed589ab | 56 | LED Red_led(PE_15); |
thomasmorris | 25:36699ed589ab | 57 | LED Yellow_led(PB_10); |
thomasmorris | 25:36699ed589ab | 58 | LED Green_led(PB_11); |
thomasmorris | 25:36699ed589ab | 59 | |
thomasmorris | 25:36699ed589ab | 60 | char LCD_buffer [50]; |
thomasmorris | 25:36699ed589ab | 61 | int LCD_sprintf; |
thomasmorris | 25:36699ed589ab | 62 | |
thomasmorris | 25:36699ed589ab | 63 | //Tickers |
thomasmorris | 25:36699ed589ab | 64 | |
chills | 26:78f5e454e59f | 65 | Ticker Sampling_Timer; |
chills | 26:78f5e454e59f | 66 | Ticker Console_Output_Timer; |
thomasmorris | 25:36699ed589ab | 67 | |
thomasmorris | 25:36699ed589ab | 68 | //Threads |
thomasmorris | 29:64b1f95a807c | 69 | |
thomasmorris | 29:64b1f95a807c | 70 | Thread t1(osPriorityRealtime); //Sampler Set to a higher priority cos nick wants it |
thomasmorris | 25:36699ed589ab | 71 | Thread t2; |
thomasmorris | 25:36699ed589ab | 72 | Thread t3; |
thomasmorris | 25:36699ed589ab | 73 | Thread t4; |
thomasmorris | 25:36699ed589ab | 74 | Thread t5; |
thomasmorris | 25:36699ed589ab | 75 | |
chills | 34:c0b8705f183d | 76 | int Log_Value = 0; |
thomasmorris | 25:36699ed589ab | 77 | double temp = 0; |
thomasmorris | 25:36699ed589ab | 78 | double pressure = 0; |
thomasmorris | 25:36699ed589ab | 79 | double lux = 0; |
thomasmorris | 25:36699ed589ab | 80 | string buffer_time = 0; |
thomasmorris | 25:36699ed589ab | 81 | |
thomasmorris | 25:36699ed589ab | 82 | char buffer[32]; |
thomasmorris | 25:36699ed589ab | 83 | char scom_time_buffer[32]; |
thomasmorris | 25:36699ed589ab | 84 | char msel_time_buffer[32]; |
thomasmorris | 25:36699ed589ab | 85 | |
thomasmorris | 25:36699ed589ab | 86 | void SW1FallingEdge(); |
thomasmorris | 25:36699ed589ab | 87 | void SW1TimeOutHandler(); |
chills | 26:78f5e454e59f | 88 | void Sampling_ISR(); |
chills | 26:78f5e454e59f | 89 | void Console_Output_ISR(); |
thomasmorris | 30:4cde05cc7c4f | 90 | void SW1RisingEdge(); |
thomasmorris | 30:4cde05cc7c4f | 91 | void SW2RisingEdge(); |
thomasmorris | 25:36699ed589ab | 92 | |
thomasmorris | 37:7c4d7f206039 | 93 | |
thomasmorris | 38:8d86e0d8a816 | 94 | //DATA Data_Active; |
thomasmorris | 25:36699ed589ab | 95 | |
thomasmorris | 25:36699ed589ab | 96 | using namespace std; |
thomasmorris | 25:36699ed589ab | 97 | |
thomasmorris | 25:36699ed589ab | 98 | int mode = 0; |
thomasmorris | 25:36699ed589ab | 99 | |
thomasmorris | 29:64b1f95a807c | 100 | //DigitalIn onBoardSwitch(USER_BUTTON); |
thomasmorris | 25:36699ed589ab | 101 | #endif |