interface for the temperature sensor chip adt7320, with sw SPI interface

Dependents:   SPItest sscm

Committer:
wbeaumont
Date:
Wed Oct 22 10:30:04 2014 +0000
Revision:
3:49638acbc5d4
Parent:
2:2b886cea4fcb
Child:
4:ee71e7bca786
added getTemperature implementation ( get back results in degree C , float)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wbeaumont 0:e252ae2774e8 1 #ifndef ADT7320_H
wbeaumont 0:e252ae2774e8 2 #define ADT7320_H
wbeaumont 0:e252ae2774e8 3
wbeaumont 0:e252ae2774e8 4 /*
wbeaumont 3:49638acbc5d4 5 * class to read the adt7320 temperature sensor via SPI
wbeaumont 3:49638acbc5d4 6 *
wbeaumont 3:49638acbc5d4 7 * v1.20 implemented float temperature readout
wbeaumont 3:49638acbc5d4 8 *
wbeaumont 3:49638acbc5d4 9 * W. Beaumont
wbeaumont 3:49638acbc5d4 10 * (C) 2014 Universiteit Antwerpen
wbeaumont 3:49638acbc5d4 11 */
wbeaumont 0:e252ae2774e8 12
wbeaumont 0:e252ae2774e8 13 #include "solid_sctrl_def.h"
wbeaumont 1:1b9f706b8abc 14 #include "getVersion.h"
wbeaumont 0:e252ae2774e8 15 #include "SWSPI.h"
wbeaumont 0:e252ae2774e8 16
wbeaumont 3:49638acbc5d4 17 #define ADT7320_HDR_VER "1.20"
wbeaumont 1:1b9f706b8abc 18
wbeaumont 1:1b9f706b8abc 19 class adt7320 : public getVersion{
wbeaumont 0:e252ae2774e8 20
wbeaumont 0:e252ae2774e8 21 void set_spi_mode(u8 nrbyte);
wbeaumont 1:1b9f706b8abc 22
wbeaumont 1:1b9f706b8abc 23 private:
wbeaumont 1:1b9f706b8abc 24 SWSPI* spi;
wbeaumont 1:1b9f706b8abc 25 DigitalOut* cs;
wbeaumont 0:e252ae2774e8 26
wbeaumont 1:1b9f706b8abc 27 u8 format_cmd( u8 reg, bool rw);
wbeaumont 1:1b9f706b8abc 28 u8 getR08( u8 addr);
wbeaumont 1:1b9f706b8abc 29 void setR08( u8 addr, u8 datain);
wbeaumont 1:1b9f706b8abc 30 u16 getR16( u8 addr);
wbeaumont 1:1b9f706b8abc 31 void setR16( u8 addr, u16 datain);
wbeaumont 3:49638acbc5d4 32 u8 Tmode ;
wbeaumont 1:1b9f706b8abc 33
wbeaumont 0:e252ae2774e8 34 public:
wbeaumont 0:e252ae2774e8 35
wbeaumont 0:e252ae2774e8 36 adt7320(SWSPI *spiinterface ,DigitalOut* chipselect );
wbeaumont 3:49638acbc5d4 37 float getTemperature();
wbeaumont 0:e252ae2774e8 38 u8 getId();
wbeaumont 0:e252ae2774e8 39 u16 get_TcritSP();
wbeaumont 1:1b9f706b8abc 40 void set_TcritSP(u16 tcrit);
wbeaumont 0:e252ae2774e8 41 u16 get_T(); // get the temperature register
wbeaumont 1:1b9f706b8abc 42 u16 get_hdr_ver();// returns the hdr version nr
wbeaumont 1:1b9f706b8abc 43 u16 get_src_ver();// returns the src version nr
wbeaumont 1:1b9f706b8abc 44 void init1();
wbeaumont 1:1b9f706b8abc 45 void init2();
wbeaumont 2:2b886cea4fcb 46 void serial_line_rst();
wbeaumont 1:1b9f706b8abc 47
wbeaumont 0:e252ae2774e8 48 };
wbeaumont 0:e252ae2774e8 49
wbeaumont 0:e252ae2774e8 50
wbeaumont 0:e252ae2774e8 51
wbeaumont 0:e252ae2774e8 52
wbeaumont 0:e252ae2774e8 53 #endif