Gas Pressure Display Updated Power control for Pressure sensor added

Dependencies:   UniGraphic mbed vt100

Committer:
Rhyme
Date:
Fri Feb 16 08:27:50 2018 +0000
Revision:
0:37c8ecde13c2
control PSE530 power via PTC5 (pse530_en)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:37c8ecde13c2 1 #ifndef _LM75B_H_
Rhyme 0:37c8ecde13c2 2 #define _LM75B_H_
Rhyme 0:37c8ecde13c2 3
Rhyme 0:37c8ecde13c2 4 #include "mbed.h"
Rhyme 0:37c8ecde13c2 5
Rhyme 0:37c8ecde13c2 6 /**
Rhyme 0:37c8ecde13c2 7 * NXP LM75B Digital temperature sensor and thermal watchdog
Rhyme 0:37c8ecde13c2 8 *
Rhyme 0:37c8ecde13c2 9 * @code
Rhyme 0:37c8ecde13c2 10 #include "mbed.h"
Rhyme 0:37c8ecde13c2 11 #include "LM75B.h"
Rhyme 0:37c8ecde13c2 12 #define LM75B_I2C_ADDRESS (0x48)
Rhyme 0:37c8ecde13c2 13
Rhyme 0:37c8ecde13c2 14 #if defined (TARGET_KL25Z)
Rhyme 0:37c8ecde13c2 15 #define PIN_SCL PTE1
Rhyme 0:37c8ecde13c2 16 #define PIN_SDA PTE0
Rhyme 0:37c8ecde13c2 17 #elif defined (TARGET_KL46Z)
Rhyme 0:37c8ecde13c2 18 #define PIN_SCL PTE1
Rhyme 0:37c8ecde13c2 19 #define PIN_SDA PTE0
Rhyme 0:37c8ecde13c2 20 #elif defined (TARGET_K64F)
Rhyme 0:37c8ecde13c2 21 #define PIN_SCL PTE24
Rhyme 0:37c8ecde13c2 22 #define PIN_SDA PTE25
Rhyme 0:37c8ecde13c2 23 #elif defined (TARGET_K22F)
Rhyme 0:37c8ecde13c2 24 #define PIN_SCL PTE1
Rhyme 0:37c8ecde13c2 25 #define PIN_SDA PTE0
Rhyme 0:37c8ecde13c2 26 #elif defined (TARGET_KL05Z)
Rhyme 0:37c8ecde13c2 27 #define PIN_SCL PTB3
Rhyme 0:37c8ecde13c2 28 #define PIN_SDA PTB4
Rhyme 0:37c8ecde13c2 29 #elif defined (TARGET_NUCLEO_F411RE)
Rhyme 0:37c8ecde13c2 30 #define PIN_SCL PB_8
Rhyme 0:37c8ecde13c2 31 #define PIN_SDA PB_9
Rhyme 0:37c8ecde13c2 32 #else
Rhyme 0:37c8ecde13c2 33 #error TARGET NOT DEFINED
Rhyme 0:37c8ecde13c2 34 #endif
Rhyme 0:37c8ecde13c2 35
Rhyme 0:37c8ecde13c2 36 int main() {
Rhyme 0:37c8ecde13c2 37 int8_t itemp = 0 ;
Rhyme 0:37c8ecde13c2 38 float ftemp = 0.0 ;
Rhyme 0:37c8ecde13c2 39 LM75B lm75b(PIN_SDA, PIN_SCL, LM75B_I2C_ADDRESS) ;
Rhyme 0:37c8ecde13c2 40
Rhyme 0:37c8ecde13c2 41 while(1) {
Rhyme 0:37c8ecde13c2 42 itemp = lm75b.temp() ;
Rhyme 0:37c8ecde13c2 43 lm75b.getTemp(&ftemp) ;
Rhyme 0:37c8ecde13c2 44 printf("Temp = %d C degree, %.3f C degree\n", itemp, ftemp) ;
Rhyme 0:37c8ecde13c2 45 wait(1) ;
Rhyme 0:37c8ecde13c2 46 }
Rhyme 0:37c8ecde13c2 47 }
Rhyme 0:37c8ecde13c2 48 * @endcode
Rhyme 0:37c8ecde13c2 49 */
Rhyme 0:37c8ecde13c2 50 class LM75B
Rhyme 0:37c8ecde13c2 51 {
Rhyme 0:37c8ecde13c2 52 public:
Rhyme 0:37c8ecde13c2 53 /**
Rhyme 0:37c8ecde13c2 54 * LM75B constructor
Rhyme 0:37c8ecde13c2 55 *
Rhyme 0:37c8ecde13c2 56 * @param i2c pointer to the I2C object
Rhyme 0:37c8ecde13c2 57 * @param addr addr of the I2C peripheral
Rhyme 0:37c8ecde13c2 58 */
Rhyme 0:37c8ecde13c2 59 LM75B(I2C *i2c, int addr);
Rhyme 0:37c8ecde13c2 60
Rhyme 0:37c8ecde13c2 61 /**
Rhyme 0:37c8ecde13c2 62 * LM75B destructor
Rhyme 0:37c8ecde13c2 63 */
Rhyme 0:37c8ecde13c2 64 ~LM75B();
Rhyme 0:37c8ecde13c2 65
Rhyme 0:37c8ecde13c2 66 /**
Rhyme 0:37c8ecde13c2 67 * get temperature as one byte (signed)
Rhyme 0:37c8ecde13c2 68 * @param *temp int8_t returns integer part of the temperature
Rhyme 0:37c8ecde13c2 69 * @return 0: success not-0: failure
Rhyme 0:37c8ecde13c2 70 */
Rhyme 0:37c8ecde13c2 71 int temp(int8_t *temp) ;
Rhyme 0:37c8ecde13c2 72
Rhyme 0:37c8ecde13c2 73 /**
Rhyme 0:37c8ecde13c2 74 * get temperature as 11 bit (float)
Rhyme 0:37c8ecde13c2 75 * @param *temp float returns the temperature as float
Rhyme 0:37c8ecde13c2 76 * @return 0: success not-0: failure
Rhyme 0:37c8ecde13c2 77 */
Rhyme 0:37c8ecde13c2 78 int getTemp(float *temp) ;
Rhyme 0:37c8ecde13c2 79
Rhyme 0:37c8ecde13c2 80 /**
Rhyme 0:37c8ecde13c2 81 * get configuration register
Rhyme 0:37c8ecde13c2 82 * @param ptr_byte uint8_t pointer value for the register
Rhyme 0:37c8ecde13c2 83 * @param *config_data uint8_t value of the config register
Rhyme 0:37c8ecde13c2 84 * @return 0: success non-0: failure
Rhyme 0:37c8ecde13c2 85 */
Rhyme 0:37c8ecde13c2 86 int getConfig(uint8_t ptr_byte, uint8_t *config_data) ;
Rhyme 0:37c8ecde13c2 87
Rhyme 0:37c8ecde13c2 88 /**
Rhyme 0:37c8ecde13c2 89 * set configuration register
Rhyme 0:37c8ecde13c2 90 * @param ptr_byte uint8_t pointer value for the register
Rhyme 0:37c8ecde13c2 91 * @param config_data uint8_t value to set in the config register
Rhyme 0:37c8ecde13c2 92 * @return 0: success non-0: failure
Rhyme 0:37c8ecde13c2 93 */
Rhyme 0:37c8ecde13c2 94 int setConfig(uint8_t ptr_byte, uint8_t config_data) ;
Rhyme 0:37c8ecde13c2 95
Rhyme 0:37c8ecde13c2 96 private:
Rhyme 0:37c8ecde13c2 97 I2C *p_i2c;
Rhyme 0:37c8ecde13c2 98 int m_addr;
Rhyme 0:37c8ecde13c2 99 int readRegs(int addr, uint8_t * data, int len);
Rhyme 0:37c8ecde13c2 100 int writeRegs(uint8_t * data, int len);
Rhyme 0:37c8ecde13c2 101
Rhyme 0:37c8ecde13c2 102 };
Rhyme 0:37c8ecde13c2 103
Rhyme 0:37c8ecde13c2 104 #endif