Contains necessary classes and functions for ELEC351

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers samplingMaster.hpp Source File

samplingMaster.hpp

00001 #ifndef __samplingMaster__ //Inclusion safeguards
00002 #define __samplingMaster__
00003 
00004 
00005 typedef struct __attribute__ ((packed)) { // Store one after another
00006 
00007     float temp;     // Temperature
00008     float pres;     // Presure
00009     float ligt;     // Light level
00010 
00011 } TDS_sensorData;   // Type Def Struct _ sensor Data
00012 
00013 
00014 /* Spec said that we are not allowed to use any third party code unless it is
00015 from ARM or STmicroelectronics, so I wrote my own driver for sampling BMP280 &
00016 ADC in succesion. Ths code for MPB280 was inspired by the BMP280 Datasheet: 
00017 [https://cdn-shop.adafruit.com/datasheets/BST-BMP280-DS001-11.pdf]
00018 and BMP280 mbed library by "charlie": 
00019 [https://os.mbed.com/users/charly/code/BMP280/] */
00020 
00021 
00022 
00023 
00024 /* BMP280 register addresses and values */
00025 #define I2C_adr 0xEE
00026 #define CONTROL_REGISTER 0xF4
00027 #define Tsb_IIR_REGISTER 0xF5
00028 #define PRES_ADDRESS_VAL 0xF7
00029 #define TEMP_ADDRESS_VAL 0xFA
00030 #define DIG_Tn_REGISTERS 0x88
00031 #define DIG_Pn_REGISTERS 0x8E
00032 #define PREAS_UPER_LIMIT 0x80000000
00033 
00034 
00035 class C_sensorData              // Class _ sensor Data 
00036 {
00037     private: 
00038     PinName  ADC_pin;
00039     PinName  SDI_pin;
00040     PinName  SCK_pin;
00041     char     inst[18];          // Instruction/Data array
00042     uint16_t T1Trim;            // Unsigned int of 16 bits for temperature trim
00043     int16_t  T2Trim, T3Trim;    // Signed ints of 16 bits for temperature trim
00044     uint16_t P1Trim;            // Unsigned int of 16 bits for pressure trim
00045     int16_t  P2Trim, P3Trim, P4Trim, P5Trim, P6Trim, P7Trim, P8Trim, P9Trim; /* 
00046     Signed ints of 16 bits for temperature trim */
00047     int32_t  tempT, tempA, tempB;// Temporary working variables
00048     uint32_t tempP;              // Temporary working variables
00049     
00050     public:
00051     C_sensorData();
00052     TDS_sensorData read();
00053 };
00054 
00055 #endif