Generic class to support (almost) any chip of the SPI-based MicroChip ADC chips family (MCP3001-2-4-8, MCP3201-2-4-8, MCP3301-2-4).
More...
|
| SPIDevice () INLINE=default |
| Create a new SPIDevice ; this sets up the CS pin for later use during transfers.
|
|
void | start_transfer () |
| Start an SPI transfer to this device. More...
|
|
void | end_transfer () INLINE |
| End the current SPI ransfer tot hsi device. More...
|
|
| AbstractSPIDevice (const AbstractSPIDevice &)=delete |
|
AbstractSPIDevice & | operator= (const AbstractSPIDevice &)=delete |
|
uint8_t | transfer (uint8_t data) |
| Transfer one byte to the currently selected SPI slave device through MOSI pin, and get the byte returned by the device through MISO pin. More...
|
|
void | transfer (uint8_t *data, uint16_t size) |
| Transfer an array of payload data to the currently selected SPI slave device through MOSI pin, and get all data bytes simultaneously received from that device through MISO pin. More...
|
|
void | transfer (const uint8_t *data, uint16_t size) |
| Transfer an array of payload data to the currently selected SPI slave device through MOSI pin; any data bytes simultaneously received from that device through MISO pin are lost. More...
|
|
void | transfer (uint8_t *data, uint16_t size, uint8_t sent) |
| Transfer the provided byte sent several times to the currently selected SPI slave device through MOSI pin, and get all data bytes simultaneously received from that device through MISO pin. More...
|
|
void | transfer (uint16_t size, uint8_t sent) |
| Transfer the provided byte sent several times to the currently selected SPI slave device through MOSI pin; any data bytes simultaneously received from that device through MISO pin are lost. More...
|
|
template<
board::DigitalPin CS, typename CHANNEL_, uint16_t MASK, uint8_t RSHIFT, typename TYPE_ = uint16_t>
class devices::mcp3x0x::MCP3x0x< CS, CHANNEL_, MASK, RSHIFT, TYPE_ >
Generic class to support (almost) any chip of the SPI-based MicroChip ADC chips family (MCP3001-2-4-8, MCP3201-2-4-8, MCP3301-2-4).
You would never directly use this class in your programs but rather use class aliases with the proper template parameter values.
- Template Parameters
-
CS | the output pin used for Chip Selection of the MCP chip on the SPI bus. |
CHANNEL_ | an enum class type defining all possible analog input channels handled by the device; this is used as an argument in read_channel() ; it must be castable to a uint8_t or uint16_t that will be used as the first or two first bytes in the transmission to the chip. |
MASK | the mask to use on the 2 bytes received from the chip to get the analog value read; this mask shall match the number of bits returned by the chip. |
RSHIFT | the number of bits to shift right on the analog value read by the chip; some MCP devices actually return values that are not right-aligned; for these devices you need a non-0 RSHIFT . |
TYPE_ | the analog output type, typically uint16_t , or int16_t for some devices. |
- See also
- MCP3008
-
MCP3208
-
MCP3304
Definition at line 67 of file mcp3x0x.h.