2023-03-26 16:42:00 +02:00
|
|
|
#include <mission/tcs/max1227.h>
|
2022-02-22 13:39:04 +01:00
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
void max1227::prepareExternallyClockedSingleChannelRead(uint8_t *spiBuf, uint8_t channel,
|
|
|
|
size_t &sz) {
|
|
|
|
spiBuf[0] = buildConvByte(ScanModes::N_ONCE, channel, false);
|
|
|
|
spiBuf[1] = 0x00;
|
|
|
|
spiBuf[2] = 0x00;
|
|
|
|
sz = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
void max1227::prepareExternallyClockedRead0ToN(uint8_t *spiBuf, uint8_t n, size_t &sz) {
|
|
|
|
for (uint8_t idx = 0; idx <= n; idx++) {
|
|
|
|
spiBuf[idx * 2] = buildConvByte(ScanModes::N_ONCE, idx, false);
|
|
|
|
spiBuf[idx * 2 + 1] = 0x00;
|
|
|
|
}
|
|
|
|
spiBuf[(n + 1) * 2] = 0x00;
|
|
|
|
sz += (n + 1) * 2 + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void max1227::prepareExternallyClockedTemperatureRead(uint8_t *spiBuf, size_t &sz) {
|
|
|
|
spiBuf[0] = buildConvByte(ScanModes::N_ONCE, 0, true);
|
|
|
|
std::memset(spiBuf + 1, 0, 24);
|
|
|
|
sz += 25;
|
|
|
|
}
|
|
|
|
|
2022-06-10 10:39:43 +02:00
|
|
|
float max1227::getTemperature(uint16_t raw) {
|
2022-06-17 08:31:36 +02:00
|
|
|
float temp = static_cast<float>((-2048 * (raw >> 11)) + (raw & 0x7FF)) * 0.125;
|
|
|
|
return temp;
|
2022-06-10 10:39:43 +02:00
|
|
|
}
|