11template<
int chainlength>
13 static constexpr uint8_t BITS = 19;
14 static constexpr uint8_t TOTALBITS = BITS*chainlength;
16 static constexpr uint8_t BYTES = (TOTALBITS+7) / 8;
35 : SPI::Device(bus,
cs, {SPI::Mode::M2, SPI::FirstBit::MSB}) { }
63 for (
int i = 0, n=0; i < chainlength; ++i, n+=BITS) {
64 chain[i].COF = bs.range<
decltype(sensor::COF)>(n + 14, n + 15);
68 chain[i].POS = bs.range<
decltype(sensor::POS)>(n + 1, n + 13);
Wrapper class for simple digital input/output pin.
Definition gpio.h:13
Class describing a chain of AS5145 Hall sensors.
Definition AS5145.h:12
void sense()
request measurement of sensor data
Definition AS5145.h:48
void callback(const SPI::Request rq) override
is called as soon as requested data arrived over wire
Definition AS5145.h:61
AS5145(Sink< SPI::Request > &bus, DIO cs)
Constructor.
Definition AS5145.h:34
int16_t getVal(int i=0)
Definition AS5145.h:41
Wrapper for extracting bitwise data from a stream of bytes.
Definition bitstream.h:12
generic SPI device wrapper.
Definition spi.h:22
DIO cs
GPIO chipselect line.
Definition spi.h:25
struct defining an SPI request.
Definition spi.h:54
Buffer< uint8_t > data
transfer data
Definition spi.h:56
@ MISO
Master in, Slave out.
Definition spi.h:59
generic object sink, i.e.
Definition streams.h:15
void trypush(T &&t)
use this if you don't care if it's going to be successful. data gets discarded if sink is full.
Definition streams.h:28