This example program utilizes the MAX31856 mbed library available from Maxim Integrated at the following link: https://os.mbed.com/teams/Maxim-Integrated/code/MAX31856/
Fork of MAX31856_example_program by
main.cpp@6:e1200ae7d6a3, 2017-07-31 (annotated)
- Committer:
- DevinAlexander
- Date:
- Mon Jul 31 18:10:24 2017 +0000
- Revision:
- 6:e1200ae7d6a3
- Parent:
- 3:a99a4367c909
- Child:
- 8:8723d0006097
Fixed errors that was causing compilation errors. It was due to some #defines in the mask register options that had extra close parenthesis, and it caused an issue with compilation due to not enough parameters being inputted into the readWriteRgitser
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DevinAlexander | 0:456e9e702d57 | 1 | #include "mbed.h" |
DevinAlexander | 1:b58719a76fc3 | 2 | #include "MAX31856.h" |
DevinAlexander | 1:b58719a76fc3 | 3 | //#include "USBSerial.h" |
DevinAlexander | 1:b58719a76fc3 | 4 | //#include "SDFileSystem.h" |
DevinAlexander | 1:b58719a76fc3 | 5 | |
DevinAlexander | 1:b58719a76fc3 | 6 | |
DevinAlexander | 1:b58719a76fc3 | 7 | /* |
DevinAlexander | 1:b58719a76fc3 | 8 | //---------------------------------------------------------- |
DevinAlexander | 2:296485923589 | 9 | #include "max32630fthr.h" |
DevinAlexander | 1:b58719a76fc3 | 10 | //Define serial ports |
DevinAlexander | 1:b58719a76fc3 | 11 | // Hardware serial port over DAPLink |
DevinAlexander | 1:b58719a76fc3 | 12 | Serial daplink(P2_1, P2_0); |
DevinAlexander | 1:b58719a76fc3 | 13 | // Virtual serial port over USB |
DevinAlexander | 1:b58719a76fc3 | 14 | //USBSerial microUSB; |
DevinAlexander | 1:b58719a76fc3 | 15 | //---------------------------------------------------------- |
DevinAlexander | 1:b58719a76fc3 | 16 | //SPI Interfaces |
DevinAlexander | 1:b58719a76fc3 | 17 | //SPI testSPI(SPIO MOSI,SPIO MISO,SPIO SCK); |
DevinAlexander | 1:b58719a76fc3 | 18 | SPI testSPI(P5_1, P5_2, P5_0); |
DevinAlexander | 1:b58719a76fc3 | 19 | //---------------------------------------------------------- |
DevinAlexander | 1:b58719a76fc3 | 20 | //Define featherboard |
DevinAlexander | 1:b58719a76fc3 | 21 | MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
DevinAlexander | 1:b58719a76fc3 | 22 | //---------------------------------------------------------- |
DevinAlexander | 1:b58719a76fc3 | 23 | //Thermocouples |
DevinAlexander | 1:b58719a76fc3 | 24 | MAX31856 Thermocouple(testSPI, P3_2, CR1_TC_TYPE_K, CR0_FILTER_OUT_60Hz, CR1_AVG_TC_SAMPLES_1, CR0_CONV_MODE_NORMALLY_ON); |
DevinAlexander | 1:b58719a76fc3 | 25 | */ |
DevinAlexander | 1:b58719a76fc3 | 26 | |
DevinAlexander | 1:b58719a76fc3 | 27 | |
DevinAlexander | 1:b58719a76fc3 | 28 | |
DevinAlexander | 1:b58719a76fc3 | 29 | |
DevinAlexander | 1:b58719a76fc3 | 30 | //---------------------------------------------------------- |
DevinAlexander | 1:b58719a76fc3 | 31 | //Define serial ports |
DevinAlexander | 1:b58719a76fc3 | 32 | // Hardware serial port over DAPLink |
DevinAlexander | 1:b58719a76fc3 | 33 | Serial daplink(USBTX, USBRX); |
DevinAlexander | 1:b58719a76fc3 | 34 | |
DevinAlexander | 1:b58719a76fc3 | 35 | //SPI Interfaces |
DevinAlexander | 1:b58719a76fc3 | 36 | //SPI testSPI(SPIO MOSI,SPIO MISO,SPIO SCK); |
DevinAlexander | 1:b58719a76fc3 | 37 | SPI testSPI(P6_1, P6_2, P6_0); |
DevinAlexander | 1:b58719a76fc3 | 38 | //---------------------------------------------------------- |
DevinAlexander | 2:296485923589 | 39 | //------------- |
DevinAlexander | 1:b58719a76fc3 | 40 | //Thermocouples |
DevinAlexander | 3:a99a4367c909 | 41 | MAX31856 Thermocouple(testSPI, P6_3); |
DevinAlexander | 1:b58719a76fc3 | 42 | |
DevinAlexander | 1:b58719a76fc3 | 43 | |
DevinAlexander | 1:b58719a76fc3 | 44 | |
DevinAlexander | 1:b58719a76fc3 | 45 | |
DevinAlexander | 1:b58719a76fc3 | 46 | |
DevinAlexander | 1:b58719a76fc3 | 47 | |
DevinAlexander | 0:456e9e702d57 | 48 | |
DevinAlexander | 0:456e9e702d57 | 49 | DigitalOut led1(LED1); |
DevinAlexander | 1:b58719a76fc3 | 50 | DigitalOut led2(LED2); |
DevinAlexander | 1:b58719a76fc3 | 51 | |
DevinAlexander | 0:456e9e702d57 | 52 | // main() runs in its own thread in the OS |
DevinAlexander | 0:456e9e702d57 | 53 | int main() { |
DevinAlexander | 1:b58719a76fc3 | 54 | float temperature_TC, temperature_CJ; |
DevinAlexander | 0:456e9e702d57 | 55 | while (true) { |
DevinAlexander | 0:456e9e702d57 | 56 | led1 = !led1; |
DevinAlexander | 2:296485923589 | 57 | wait(0.2); |
DevinAlexander | 1:b58719a76fc3 | 58 | temperature_TC=Thermocouple.readTC(); |
DevinAlexander | 2:296485923589 | 59 | temperature_CJ=Thermocouple.readCJ(); |
DevinAlexander | 1:b58719a76fc3 | 60 | daplink.printf("MAX31856 TC = %f Celsius MAX31856 CJ = %f Celsius \n\r",temperature_TC,temperature_CJ); |
DevinAlexander | 1:b58719a76fc3 | 61 | |
DevinAlexander | 1:b58719a76fc3 | 62 | |
DevinAlexander | 0:456e9e702d57 | 63 | } |
DevinAlexander | 0:456e9e702d57 | 64 | } |
DevinAlexander | 0:456e9e702d57 | 65 |