Contains necessary classes and functions for ELEC351

/media/uploads/Luka_Danilovic/elec_315_prototype_assembly.jpg

Committer:
Luka_Danilovic
Date:
Tue Jan 09 15:47:08 2018 +0000
Revision:
7:92b4783af1d2
Parent:
2:e2b885367ba8
ELEC351 Library; LCD Driver not working due to a bug I could not diagnose. I suspect it is the initialization.

Who changed what in which revision?

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