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.
Dependencies: mbed SDFileSystem
max6675.cpp
- Committer:
- BoostNori
- Date:
- 2020-03-02
- Revision:
- 0:cb620b090bf4
File content as of revision 0:cb620b090bf4:
#include <mbed.h>
#include "max6675.h"
max6675::max6675(SPI& _spi, PinName _ncs) : spi(_spi), ncs(_ncs) {
}
float max6675::read_temp() {
short value = 0;
float temp = 0;
uint8_t highByte=0;
uint8_t lowByte=0;
select();
wait(.25); //This delay is needed else it does'nt seem to update the temp
highByte = spi.write(0);
lowByte = spi.write(0);
deselect();
if (lowByte & (1<<2)) {
error("No Probe");
} else {
value = (highByte << 5 | lowByte>>3);
}
temp = (value*0.25); // Multiply the value by 0.25 to get temp in ˚C or
// * (9.0/5.0)) + 32.0; // Convert value to ˚F (ensure proper floats!)
return temp;
}
void max6675::select() {
ncs = 0;
}
void max6675::deselect() {
ncs = 1;
}