MAX31855 Cold-Junction Compensated Thermocouple-to-Digital Converter

Files at this revision

API Documentation at this revision

Comitter:
mederic
Date:
Wed Jul 29 13:11:30 2015 +0000
Parent:
1:aa96d283eead
Commit message:
read spi 8bit mode (to be complient with all platform)

Changed in this revision

MAX31855.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/MAX31855.cpp	Wed Jul 29 12:28:35 2015 +0000
+++ b/MAX31855.cpp	Wed Jul 29 13:11:30 2015 +0000
@@ -6,14 +6,14 @@
 MAX31855::MAX31855(PinName mosi, PinName miso, PinName sck, PinName ncs) :_spi(mosi,miso,sck), _ncs(ncs)
 {
     _ncs = 1;   //CS high
-    _spi.format(16,0);
+    _spi.format(8,0);
     _spi.frequency(1000000);
 }
 
 MAX31855::MAX31855(SPI& spi, PinName ncs) :_spi(spi), _ncs(ncs)
 {
     _ncs = 1;   //CS high
-    _spi.format(16,0);
+    _spi.format(8,0);
     _spi.frequency(1000000);
 }
 
@@ -67,8 +67,8 @@
 void MAX31855::read(void)
 {
     _ncs = 0;
-    unsigned short high = _spi.write(0);
-    unsigned short  low = _spi.write(0);
+    unsigned short high = ((_spi.write(0)<<8)&0xff00) + ((_spi.write(0)&0x00ff));
+    unsigned short  low = ((_spi.write(0)<<8)&0xff00) + ((_spi.write(0)&0x00ff));
     _ncs = 1;
     
     _t = (high>>2)/4.0;