Files
@ f602474ad6c6
Branch filter:
Location: therm-ng/lib/max31856/max31856.c - annotation
f602474ad6c6
1.4 KiB
text/plain
Initial work on max31856 driver, etc
f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 f602474ad6c6 | //
// MAX31856: Driver to configure and read temperature from the MAX31856 thermoouple-to-Digital IC
//
#include "max31856.h"
#include "states.h"
// Private variables
static float temp_latest = 0.0;
static float temp_avg = 0.0;
static SPI_HandleTypeDef* spiport;
// Initialize the MAX31856 driver
void max31856_init(SPI_HandleTypeDef* spi_port, GPIO_TypeDef* cs_port, uint32_t cs_pin, uint32_t sensor_type)
{
// Set SPI port reference
spiport = spi_port;
// Configure the CS pin for output
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Pin = cs_pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(cs_port, &GPIO_InitStruct);
// MAX31856
// - set to continuous conversion mode
// - probably no filtering, we'll do that on this side of things
// - set up to read the typical open/short faults but not the high/low alarms
uint8_t data[] = {0,0,0,0};
HAL_SPI_Transmit(spiport, data, 1, 100);
// sensor type - could we just mask bits off? maybe optimize the enum for this
}
void max31856_process(void)
{
// Read temperature from the MAX31856 (approx 10hz optimally)
uint8_t data[] = {0,0,0,0};
HAL_SPI_Transmit(spiport, data, 1, 100);
}
// Return latest temperature reading (unaveraged, deg C)
float max31856_latest_temp(void)
{
return temp_latest;
}
// Return average temperature reading (deg C)
float max31856_avg_temp(void)
{
return temp_latest;
}
|