eive-obsw/mission/devices/max1227.cpp
Robin Mueller c06ef5d6b5
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
added more max1227 tests
2022-02-16 18:56:38 +01:00

29 lines
976 B
C++

#include "max1227.h"
uint8_t max1227::buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp) {
return (1 << 7) | (channel << 3) | (scanMode << 1) | readTemp;
}
uint8_t max1227::buildSetupByte(ClkSel clkSel, RefSel refSel, DiffSel diffSel) {
return (1 << 6) | (clkSel << 4) | (refSel << 2) | diffSel;
}
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;
}
uint8_t max1227::buildResetByte(bool fifoOnly) { return (1 << 4) | (fifoOnly << 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;
}