Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BMP280
Sampling.h
- Committer:
- mwthewsey
- Date:
- 2018-01-06
- Revision:
- 9:ac5673cca703
- Parent:
- 8:dbb57b4d5ba4
- Child:
- 10:261f2b69c4c7
- Child:
- 15:e61297f9bae9
File content as of revision 9:ac5673cca703:
#ifndef __Sampling__ #define __Sampling__ #include "mbed.h" #include "BMP280.h" #include "rtos.h" #define BUFFERSIZE 8 //Thread Sync Tools extern Mutex tempReadingsLock; extern Mutex presReadingsLock; extern Mutex LDRReadingsLock; extern Mutex timeReadingsLock; //Buffers extern float tempReadings[BUFFERSIZE]; extern float presReadings[BUFFERSIZE]; extern float LDRReadings[BUFFERSIZE]; extern float timeReadings[BUFFERSIZE]; extern unsigned short currentIndex; //Position in the buffer of the newest sample extern unsigned short nextIndex; //Position in the buffer where the next sample needs to be writen to extern unsigned short oldestIndex; //Position in the buffer of the oldest sample extern bool firstSample; //Used to indicate this is the first sample to be taken. used in IncrementIndex func extern Thread t1; //Sample Enviromental Sensor extern Thread t2; //Sample LDR Sensor extern Ticker sampleRate; extern Timeout SampleLEDTimeout; extern BMP280 sensor; extern AnalogIn LDRSensor; //Input pin for LDR extern DigitalOut SamplingLED; //Onboard LED showing when a sample happens /*These can be deleted I think extern float fLatestTemp; extern float fLatestLDR; extern float fLatestPres; */ extern bool NewEnvSample; //Is there new data from the envirom sensor to output? extern bool NewLDRSample; //Is there new data from the LDR to output? void SampleTimerISR(void); //Called by ticker. Calls the sample funcs of each device by flagging the threads void ConfigThreadsAndIR(void); //Setup Interrupts and Threads void ThreadSampleEnvSensor(void); //when flagged by interrupt will capture a sample then calls the addtobufferfuncs void AddTempSample(float temp); //Producer function void AddPresSample(float pres); //Producer Function void ThreadSampleLDR(void); //When flagged by interrupt will read time and LDR value. void AddLDRSample(float LDR); //Poducer Function void AddTimeSample(/*Whatever time*/); //Producer Function void IncrementIndex(void); //Called after samples are added. Increments the index and moves the oldest //along if necessary void FlipSamplingLED(void); //Called by timeout, turns of LED unsigned short IndexIncrement(unsigned short thisIndex); //Incrementing the index with respect for the buffersize #endif