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.
max6675_2.cpp
00001 00002 #include <mbed.h> 00003 #include "max6675_2.h" 00004 00005 max6675_2::max6675_2(SPI& _spi_2, PinName _ncs_2) : spi_2(_spi_2), ncs_2(_ncs_2) { 00006 00007 } 00008 00009 float max6675_2::read_temp_2() { 00010 short value_2 = 0; 00011 float temp_2 = 0; 00012 00013 uint8_t highByte_2=0; 00014 uint8_t lowByte_2=0; 00015 00016 select_2(); 00017 wait(.25); //This delay is needed else it does'nt seem to update the temp 00018 00019 highByte_2 = spi_2.write(0); 00020 lowByte_2 = spi_2.write(0); 00021 deselect_2(); 00022 00023 00024 if (lowByte_2 & (1<<2)) { 00025 error("No Probe"); 00026 } else { 00027 value_2 = (highByte_2 << 5 | lowByte_2>>3); 00028 } 00029 00030 temp_2 = (value_2*0.25); // Multiply the value by 0.25 to get temp in ˚C or 00031 // * (9.0/5.0)) + 32.0; // Convert value to ˚F (ensure proper floats!) 00032 00033 return temp_2; 00034 } 00035 00036 void max6675_2::select_2() { 00037 ncs_2 = 0; 00038 } 00039 00040 void max6675_2::deselect_2() { 00041 ncs_2 = 1; 00042 }
Generated on Wed Jul 13 2022 08:50:51 by
