added new max1227 helper functions
This commit is contained in:
parent
ae4d1e6db3
commit
49decb8e9a
@ -1,5 +1,7 @@
|
|||||||
#include "max1227.h"
|
#include "max1227.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
uint8_t max1227::buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp) {
|
uint8_t max1227::buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp) {
|
||||||
return (1 << 7) | (channel << 3) | (scanMode << 1) | readTemp;
|
return (1 << 7) | (channel << 3) | (scanMode << 1) | readTemp;
|
||||||
}
|
}
|
||||||
@ -26,3 +28,11 @@ void max1227::prepareExternallyClockedRead0ToN(uint8_t *spiBuf, uint8_t n, size_
|
|||||||
spiBuf[(n + 1) * 2] = 0x00;
|
spiBuf[(n + 1) * 2] = 0x00;
|
||||||
sz = (n + 1) * 2 + 1;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
float max1227::getTemperature(int16_t temp) { return static_cast<float>(temp) * 0.125; }
|
||||||
|
@ -63,6 +63,16 @@ void prepareExternallyClockedSingleChannelRead(uint8_t* spiBuf, uint8_t channel,
|
|||||||
*/
|
*/
|
||||||
void prepareExternallyClockedRead0ToN(uint8_t* spiBuf, uint8_t n, size_t& sz);
|
void prepareExternallyClockedRead0ToN(uint8_t* spiBuf, uint8_t n, size_t& sz);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare an externally clocked temperature read. 25 bytes have to be sent
|
||||||
|
* and the raw temperature value will appear on the last 2 bytes of the reply.
|
||||||
|
* @param spiBuf
|
||||||
|
* @param sz
|
||||||
|
*/
|
||||||
|
void prepareExternallyClockedTemperatureRead(uint8_t* spiBuf, size_t& sz);
|
||||||
|
|
||||||
|
float getTemperature(int16_t temp);
|
||||||
|
|
||||||
} // namespace max1227
|
} // namespace max1227
|
||||||
|
|
||||||
#endif /* MISSION_DEVICES_MAX1227_H_ */
|
#endif /* MISSION_DEVICES_MAX1227_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user