Buffer working with LCD, Serial and SD Card

Dependencies:   BMP280

Fork of Thread_Communication by BDG

Committer:
dnonoo
Date:
Fri Dec 29 17:50:30 2017 +0000
Revision:
8:ab6322afa341
Parent:
7:f017a37bcf1b
Buffer(Mutex) with LCD (Mail Queue), Serial and SD Card (Mutex Locks)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
benparkes 0:cb3a5c15b01e 1 #include "LCD.h"
benparkes 0:cb3a5c15b01e 2 #include "BMP280.h"
dnonoo 8:ab6322afa341 3 #include "SDBlockDevice.h"
dnonoo 8:ab6322afa341 4 #include "FATFileSystem.h"
benparkes 0:cb3a5c15b01e 5
dnonoo 7:f017a37bcf1b 6 #define ENTER_KEY 1
dnonoo 7:f017a37bcf1b 7 #define MAX_SAMPLES 120
dnonoo 7:f017a37bcf1b 8 #define SENSOR_UPDATE 1
dnonoo 7:f017a37bcf1b 9 #define DATA_READY 1
dnonoo 7:f017a37bcf1b 10 #define SAMPLING_PERIOD 10
dnonoo 7:f017a37bcf1b 11 #define ON 1
dnonoo 7:f017a37bcf1b 12 #define OFF 0
dnonoo 7:f017a37bcf1b 13
benparkes 0:cb3a5c15b01e 14 extern LCD lcd;
benparkes 0:cb3a5c15b01e 15 extern BMP280 sensor;
dnonoo 8:ab6322afa341 16 extern SDBlockDevice sd (PB_5, D12, D13, D10);
benparkes 0:cb3a5c15b01e 17
benparkes 0:cb3a5c15b01e 18 /* External LEDs as Open Drain */
dnonoo 7:f017a37bcf1b 19 extern DigitalOut Red_ext (PE_15);
dnonoo 7:f017a37bcf1b 20 extern DigitalOut Yellow_ext (PB_10);
dnonoo 7:f017a37bcf1b 21 extern DigitalOut Green_ext (PB_11);
benparkes 0:cb3a5c15b01e 22
benparkes 0:cb3a5c15b01e 23 /* Configure On-board LEDS */
dnonoo 7:f017a37bcf1b 24 extern DigitalOut Green_int (LED1);
dnonoo 7:f017a37bcf1b 25 extern DigitalOut Blue_int (LED2);
dnonoo 7:f017a37bcf1b 26 extern DigitalOut Red_int (LED3);
benparkes 0:cb3a5c15b01e 27
benparkes 0:cb3a5c15b01e 28 /* Configure Digital In Switches */
dnonoo 7:f017a37bcf1b 29 extern DigitalIn SW_L (PE_12);
dnonoo 7:f017a37bcf1b 30 extern DigitalIn SW_R (PE_14);
dnonoo 8:ab6322afa341 31 //extern DigitalIn SW_B (USER_BUTTON); //defined as interrupt now for SD
benparkes 0:cb3a5c15b01e 32 /* Configure Analogue Pins */
benparkes 0:cb3a5c15b01e 33 /* Analogue IN */
dnonoo 7:f017a37bcf1b 34 extern AnalogIn LDR_In (PA_0);
benparkes 0:cb3a5c15b01e 35
benparkes 0:cb3a5c15b01e 36 /* Congfigure Serial interface */
dnonoo 7:f017a37bcf1b 37 Serial pc(USBTX, USBRX);
dnonoo 7:f017a37bcf1b 38
dnonoo 7:f017a37bcf1b 39 /* Mail */
dnonoo 7:f017a37bcf1b 40 typedef struct {
dnonoo 7:f017a37bcf1b 41 float LDR_Value;
dnonoo 7:f017a37bcf1b 42 float temp_Value;
dnonoo 7:f017a37bcf1b 43 float press_Value;
dnonoo 7:f017a37bcf1b 44 } mail_t;
dnonoo 7:f017a37bcf1b 45
dnonoo 7:f017a37bcf1b 46 Mail<mail_t, 16> mail_box;
dnonoo 7:f017a37bcf1b 47
dnonoo 7:f017a37bcf1b 48 //data FIFO buffer
dnonoo 7:f017a37bcf1b 49 char data_buffer[MAX_SAMPLES][64];
dnonoo 7:f017a37bcf1b 50 int sample_h = 0;
dnonoo 7:f017a37bcf1b 51 int sample_t = 0;
dnonoo 7:f017a37bcf1b 52 int data_h = 0;
dnonoo 7:f017a37bcf1b 53 int data_t = 0;
dnonoo 7:f017a37bcf1b 54 struct tm * sample_epoch;
dnonoo 7:f017a37bcf1b 55
dnonoo 7:f017a37bcf1b 56
dnonoo 7:f017a37bcf1b 57 //Serial_CMD
dnonoo 7:f017a37bcf1b 58 volatile int rx_in=0;
dnonoo 7:f017a37bcf1b 59 char rx_buffer[32];
dnonoo 7:f017a37bcf1b 60 time_t raw_time = time(NULL);
dnonoo 7:f017a37bcf1b 61 char serial_buffer[80];
dnonoo 7:f017a37bcf1b 62
dnonoo 7:f017a37bcf1b 63 extern void POST();