2022-07-20 16:36:23 -07:00
|
|
|
#pragma once
|
|
|
|
|
2022-09-20 14:50:06 -07:00
|
|
|
#include "hal.h"
|
|
|
|
|
2022-07-20 16:36:23 -07:00
|
|
|
#include "wideband_config.h"
|
|
|
|
#include "thread_controller.h"
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
MAX31855_OK = 0,
|
|
|
|
MAX31855_OPEN_CIRCUIT = 1,
|
|
|
|
MAX31855_SHORT_TO_GND = 2,
|
|
|
|
MAX31855_SHORT_TO_VCC = 3,
|
|
|
|
MAX31855_NO_REPLY = 4,
|
|
|
|
} Max31855State;
|
|
|
|
|
2022-09-20 14:50:06 -07:00
|
|
|
/* livedata: +96/112 offset, size = 16 */
|
|
|
|
struct livedata_egt_s {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
float temperature;
|
|
|
|
float coldJunctionTemperature;
|
|
|
|
uint8_t state;
|
|
|
|
} __attribute__((packed));
|
|
|
|
uint8_t pad[16];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// for all board. in case of no EGT - returns NULL
|
|
|
|
const struct livedata_egt_s * getEgtLiveDataStructAddr(const int ch);
|
|
|
|
|
2022-10-06 11:24:11 -07:00
|
|
|
#if (EGT_CHANNELS > 0)
|
2022-09-20 14:50:06 -07:00
|
|
|
|
|
|
|
#define MAX31855_THREAD_STACK (512)
|
|
|
|
#define MAX31855_THREAD_PRIO (NORMALPRIO + 1)
|
|
|
|
|
2022-07-20 16:36:23 -07:00
|
|
|
class Max31855 {
|
|
|
|
public:
|
|
|
|
Max31855(SPIConfig *spi) {
|
|
|
|
this->spi = spi;
|
|
|
|
}
|
2022-09-20 14:50:06 -07:00
|
|
|
livedata_egt_s livedata;
|
|
|
|
/* do we need float temperatures? */
|
|
|
|
float coldJunctionTemperature;
|
2022-07-20 16:36:23 -07:00
|
|
|
float temperature;
|
|
|
|
int readPacket();
|
|
|
|
private:
|
|
|
|
SPIConfig *spi;
|
|
|
|
int spi_rx(uint32_t *data);
|
|
|
|
};
|
|
|
|
|
|
|
|
class Max31855Thread : public ThreadController<MAX31855_THREAD_STACK> {
|
|
|
|
public:
|
|
|
|
Max31855Thread(Max31855 max31855[EGT_CHANNELS])
|
|
|
|
: ThreadController("egt", MAX31855_THREAD_PRIO)
|
|
|
|
{
|
|
|
|
this->max31855 = max31855;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ThreadTask() override;
|
|
|
|
private:
|
|
|
|
Max31855 *max31855;
|
|
|
|
};
|
|
|
|
|
|
|
|
void StartEgt();
|
|
|
|
Max31855* getEgtDrivers();
|
|
|
|
|
2022-10-06 11:24:11 -07:00
|
|
|
#endif // (EGT_CHANNELS > 0)
|