/* * max31865.c * * Created: 13.9.2019 12:34:48 * Author : strakos.p */ // Includes #include "max31865.h" // Constant macro #define DDR(x) (*(&x - 1)) // address of data direction register of port x #if defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) /* on ATmega64/128 PINF is on port 0x00 and not 0x60 */ #define PIN(x) ( &PORTF==&(x) ? _SFR_IO8(0x00) : (*(&x - 2)) ) #else #define PIN(x) (*(&x - 2)) // address of input register of port x #endif // Reading data from SPI char max_spi_read(char addr){ CS_PORT &= ~_BV(CS_PIN); // CS_LOW - activate slave SPDR = addr; // register address to read while(!(SPSR & (1<> 1)); if (datatype == 'r') return RTD; // Basic temperature calculation, the accuracy for temperatures // between -75°C - 100°C is max +-1.5°C temperature = ( (long)10*RTD >> 5) - 2560; // RTD / 32 - 256 if (datatype == 't') return temperature; } // return 1000 if not conversion available else return 1000; }