STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
STAR_MCP3201.cpp
Go to the documentation of this file.
1#include "STAR_MCP3201.h"
2
3STAR_MCP3201::STAR_MCP3201(uint8_t cs_pin, SPIClass* spi)
4 : _cs(cs_pin), _spi(spi) {}
5
7 _spi->beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
9 uint8_t hi = _spi->transfer(0);
10 uint8_t lo = _spi->transfer(0);
12 _spi->endTransaction();
13
14 // Mask out the 2 don't-care bits and the null bit from byte 0,
15 // then combine with byte 1 after stripping the repeated LSB.
16 return (uint16_t)((hi & 0x1F) << 7) | (uint16_t)(lo >> 1);
17}
#define HIGH
Definition Arduino.h:19
#define LOW
Definition Arduino.h:20
void digitalWrite(int, int)
Definition Arduino.h:48
uint16_t read()
SPIClass * _spi
STAR_MCP3201(uint8_t cs_pin, SPIClass *spi)