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.
Dependents: proyectoprueba3 proyectoRTOS proyectoRTOS2 proyectoRTOS ... more
max6675.cpp
00001 00002 #include "max6675.h" 00003 00004 max6675::max6675(PinName miso, PinName sclk, PinName cs) : 00005 max(NC, miso, sclk), _cs(cs) 00006 { 00007 max.format(16,1); // set 16 bit SPI format 00008 max.frequency(400000); 00009 } 00010 00011 float max6675::gettemp(int cf) 00012 { 00013 float temp = 0; 00014 int tempByte= 0; 00015 00016 _cs = 0; 00017 wait_us(1); // wait to stablize 00018 tempByte = max.write(0); 00019 wait_us(1); // wait to finish 00020 _cs = 1; 00021 00022 if (tempByte & (1<<2)) { // faulty or no sensor connected 00023 return -99; 00024 } else { 00025 temp = (tempByte)/32.0f; 00026 } 00027 if(cf) { 00028 temp = (temp*9.0f/5.0f) + 32.0f; // Convert value to ˚F 00029 } 00030 return temp; 00031 }
Generated on Thu Jul 21 2022 20:18:13 by
1.7.2