A library to interface to the MCP3208 SPI-based ADC from Microchip. This chip provides eight analogue inputs, providing converted 12-bit values via SPI.
Dependents: Nucleo_MCP3208_Test Nucleo_MCP3208_Ticker_Test BBMv2_eps ref_BBMv2_eps ... more
MCP3208 Class Reference
Class for interfacing to the MCP3208 SPI-based ADC. More...
#include <mcp3208.h>
Public Member Functions | |
MCP3208 (SPI bus, PinName cs) | |
Create an MCP3208 object. | |
float | read_input (int channel) |
Read from a single-ended input. | |
float | read_diff_input (int channel, Polarity polarity) |
Read from a pair of differential inputs. |
Detailed Description
Class for interfacing to the MCP3208 SPI-based ADC.
This class will also allow interfacing to the MCP3204, but only four inputs are provided by that chip, as opposed to the eight of the MCP3208.
Definition at line 28 of file mcp3208.h.
Constructor & Destructor Documentation
MCP3208 | ( | SPI | bus, |
PinName | cs | ||
) |
Create an MCP3208 object.
- Parameters:
-
bus An SPI bus object. cs The name of a pin to use as the chip select.
Definition at line 9 of file mcp3208.cpp.
Member Function Documentation
float read_diff_input | ( | int | channel, |
Polarity | polarity | ||
) |
Read from a pair of differential inputs.
In differential mode, the channels are referred to as 0 to 3, with polarity set in a separate parameter. This avoids the user having to set the polarity as part of the channel number or having channel numbers increase by two (i.e. the channels being 0, 2, 4, and 6).
- Parameters:
-
channel The channel number to read from. polarity The polarity of the differential signal. returns The sampled value as a float between 0.0 and 1.0.
Definition at line 42 of file mcp3208.cpp.
float read_input | ( | int | channel ) |
Read from a single-ended input.
- Parameters:
-
channel The channel number to read from. returns The sampled value as a float between 0.0 and 1.0.
Definition at line 22 of file mcp3208.cpp.
Generated on Mon Jul 18 2022 21:57:39 by
![doxygen](doxygen.png)