Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:1b9f706b8abc, committed 2014-10-05
- Comitter:
- wbeaumont
- Date:
- Sun Oct 05 17:12:21 2014 +0000
- Parent:
- 0:e252ae2774e8
- Child:
- 2:2b886cea4fcb
- Commit message:
- dummy init functions added, version class added
Changed in this revision
| adt7320.cpp | Show annotated file Show diff for this revision Revisions of this file |
| adt7320.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/adt7320.cpp Thu Oct 02 19:25:55 2014 +0000
+++ b/adt7320.cpp Sun Oct 05 17:12:21 2014 +0000
@@ -4,7 +4,14 @@
#define CS_ACTIVE 1
#define CS_DEACTIVE 0
-adt7320::adt7320(SWSPI *spiinterface ,DigitalOut* chipselect ){
+#define ADT7320_SRC_VER "1.13"
+
+
+
+
+adt7320::adt7320(SWSPI *spiinterface ,DigitalOut* chipselect )
+:getVersion( ADT7320_HDR_VER ,ADT7320_SRC_VER , __TIME__, __DATE__)
+{
spi=spiinterface;
cs=chipselect;
}
@@ -38,6 +45,18 @@
}
+
+void adt7320::setR08( u8 reg, u8 datain){
+ set_spi_mode(16);
+ u16 data=0x0000;
+ u16 cmd = (u16) format_cmd(reg,false);
+ cmd = cmd <<8;
+ data= datain | cmd;
+ cs->write(CS_ACTIVE);
+ data= spi->write(data);
+ cs->write(CS_DEACTIVE);
+}
+
u16 adt7320::getR16( u8 reg){
set_spi_mode(24);
u32 data=0x0000FFFF;
@@ -50,6 +69,18 @@
return (u16)(0x0000FFFF &data);
}
+void adt7320::setR16( u8 reg,u16 datain){
+ set_spi_mode(24);
+ u32 data=0x00000000;
+ u32 cmd =(u32) format_cmd(reg,false);
+ cmd = cmd <<16;
+ data= datain | cmd;
+ cs->write(CS_ACTIVE);
+ data= spi->write(data);
+ cs->write(CS_DEACTIVE);
+}
+
+
u8 adt7320::getId(){
return getR08(0x03);
@@ -59,7 +90,20 @@
return getR16(0x04);
}
+void adt7320::set_TcritSP(u16 tcrit){
+
+ setR16(0x04,tcrit );
+}
+
+
+
u16 adt7320::get_T(){
return getR16(0x02);
}
+
+ void adt7320::init1(){}
+ void adt7320::init2(){}
+
+
+
--- a/adt7320.h Thu Oct 02 19:25:55 2014 +0000
+++ b/adt7320.h Sun Oct 05 17:12:21 2014 +0000
@@ -7,26 +7,39 @@
*/
#include "solid_sctrl_def.h"
+#include "getVersion.h"
#include "SWSPI.h"
-class adt7320 {
+#define ADT7320_HDR_VER "1.13"
+
+class adt7320 : public getVersion{
void set_spi_mode(u8 nrbyte);
-u8 format_cmd( u8 reg, bool rw);
-SWSPI* spi;
-DigitalOut* cs;
+
+private:
+ SWSPI* spi;
+ DigitalOut* cs;
+ u8 format_cmd( u8 reg, bool rw);
+ u8 getR08( u8 addr);
+ void setR08( u8 addr, u8 datain);
+ u16 getR16( u8 addr);
+ void setR16( u8 addr, u16 datain);
+
public:
adt7320(SWSPI *spiinterface ,DigitalOut* chipselect );
- float getTemperature(){return -280;};
- u8 getR08( u8 addr);
- u16 getR16( u8 addr);
+ float getTemperature(){return -280;}; // to be implenented
u8 getId();
u16 get_TcritSP();
+ void set_TcritSP(u16 tcrit);
u16 get_T(); // get the temperature register
-
+ u16 get_hdr_ver();// returns the hdr version nr
+ u16 get_src_ver();// returns the src version nr
+ void init1();
+ void init2();
+
};