ELEC351 SUBMISSION - Same as on the DLE

/media/uploads/Luka_Danilovic/elec_315_prototype_assembly.jpg

Committer:
Luka_Danilovic
Date:
Wed Jan 10 09:49:43 2018 +0000
Revision:
0:c66224a27cf8
ELEC351 SUBMISSION - SAme as on the DLE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Luka_Danilovic 0:c66224a27cf8 1 #ifndef __samplingMaster__ //Inclusion safeguards
Luka_Danilovic 0:c66224a27cf8 2 #define __samplingMaster__
Luka_Danilovic 0:c66224a27cf8 3
Luka_Danilovic 0:c66224a27cf8 4
Luka_Danilovic 0:c66224a27cf8 5 typedef struct __attribute__ ((packed)) { // Store one after another
Luka_Danilovic 0:c66224a27cf8 6
Luka_Danilovic 0:c66224a27cf8 7 float temp; // Temperature
Luka_Danilovic 0:c66224a27cf8 8 float pres; // Presure
Luka_Danilovic 0:c66224a27cf8 9 float ligt; // Light level
Luka_Danilovic 0:c66224a27cf8 10
Luka_Danilovic 0:c66224a27cf8 11 } TDS_sensorData; // Type Def Struct _ sensor Data
Luka_Danilovic 0:c66224a27cf8 12
Luka_Danilovic 0:c66224a27cf8 13
Luka_Danilovic 0:c66224a27cf8 14 /* Spec said that we are not allowed to use any third party code unless it is
Luka_Danilovic 0:c66224a27cf8 15 from ARM or STmicroelectronics, so I wrote my own driver for sampling BMP280 &
Luka_Danilovic 0:c66224a27cf8 16 ADC in succesion. Ths code for MPB280 was inspired by the BMP280 Datasheet:
Luka_Danilovic 0:c66224a27cf8 17 [https://cdn-shop.adafruit.com/datasheets/BST-BMP280-DS001-11.pdf]
Luka_Danilovic 0:c66224a27cf8 18 and BMP280 mbed library by "charlie":
Luka_Danilovic 0:c66224a27cf8 19 [https://os.mbed.com/users/charly/code/BMP280/] */
Luka_Danilovic 0:c66224a27cf8 20
Luka_Danilovic 0:c66224a27cf8 21
Luka_Danilovic 0:c66224a27cf8 22
Luka_Danilovic 0:c66224a27cf8 23
Luka_Danilovic 0:c66224a27cf8 24 /* BMP280 register addresses and values */
Luka_Danilovic 0:c66224a27cf8 25 #define I2C_adr 0xEE
Luka_Danilovic 0:c66224a27cf8 26 #define CONTROL_REGISTER 0xF4
Luka_Danilovic 0:c66224a27cf8 27 #define Tsb_IIR_REGISTER 0xF5
Luka_Danilovic 0:c66224a27cf8 28 #define PRES_ADDRESS_VAL 0xF7
Luka_Danilovic 0:c66224a27cf8 29 #define TEMP_ADDRESS_VAL 0xFA
Luka_Danilovic 0:c66224a27cf8 30 #define DIG_Tn_REGISTERS 0x88
Luka_Danilovic 0:c66224a27cf8 31 #define DIG_Pn_REGISTERS 0x8E
Luka_Danilovic 0:c66224a27cf8 32 #define PREAS_UPER_LIMIT 0x80000000
Luka_Danilovic 0:c66224a27cf8 33
Luka_Danilovic 0:c66224a27cf8 34
Luka_Danilovic 0:c66224a27cf8 35 class C_sensorData // Class _ sensor Data
Luka_Danilovic 0:c66224a27cf8 36 {
Luka_Danilovic 0:c66224a27cf8 37 private:
Luka_Danilovic 0:c66224a27cf8 38 PinName ADC_pin;
Luka_Danilovic 0:c66224a27cf8 39 PinName SDI_pin;
Luka_Danilovic 0:c66224a27cf8 40 PinName SCK_pin;
Luka_Danilovic 0:c66224a27cf8 41 char inst[18]; // Instruction/Data array
Luka_Danilovic 0:c66224a27cf8 42 uint16_t T1Trim; // Unsigned int of 16 bits for temperature trim
Luka_Danilovic 0:c66224a27cf8 43 int16_t T2Trim, T3Trim; // Signed ints of 16 bits for temperature trim
Luka_Danilovic 0:c66224a27cf8 44 uint16_t P1Trim; // Unsigned int of 16 bits for pressure trim
Luka_Danilovic 0:c66224a27cf8 45 int16_t P2Trim, P3Trim, P4Trim, P5Trim, P6Trim, P7Trim, P8Trim, P9Trim; /*
Luka_Danilovic 0:c66224a27cf8 46 Signed ints of 16 bits for temperature trim */
Luka_Danilovic 0:c66224a27cf8 47 int32_t tempT, tempA, tempB;// Temporary working variables
Luka_Danilovic 0:c66224a27cf8 48 uint32_t tempP; // Temporary working variables
Luka_Danilovic 0:c66224a27cf8 49
Luka_Danilovic 0:c66224a27cf8 50 public:
Luka_Danilovic 0:c66224a27cf8 51 C_sensorData();
Luka_Danilovic 0:c66224a27cf8 52 TDS_sensorData read();
Luka_Danilovic 0:c66224a27cf8 53 };
Luka_Danilovic 0:c66224a27cf8 54
Luka_Danilovic 0:c66224a27cf8 55 #endif