MCP3xxx-series ADC driver using SPI communication for the Parallax Propeller. Compatible with the following devices:
More...
#include <PropWare/sensor/analog/mcp3xxx.h>
|
enum | Channel {
Channel::CHANNEL_0,
Channel::CHANNEL_1,
Channel::CHANNEL_2,
Channel::CHANNEL_3,
Channel::CHANNEL_4,
Channel::CHANNEL_5,
Channel::CHANNEL_6,
Channel::CHANNEL_7
} |
|
enum | ChannelDiff {
ChannelDiff::DIFF_0_1,
ChannelDiff::DIFF_1_0,
ChannelDiff::DIFF_2_3,
ChannelDiff::DIFF_3_2,
ChannelDiff::DIFF_4_5,
ChannelDiff::DIFF_5_4,
ChannelDiff::DIFF_6_7,
ChannelDiff::DIFF_7_6
} |
|
enum | PartNumber {
PartNumber::MCP300x = 11,
PartNumber::MCP320x = 13,
PartNumber::MCP330x = 14
} |
|
MCP3xxx-series ADC driver using SPI communication for the Parallax Propeller. Compatible with the following devices:
- MCP3002
- MCP3004
- MCP3008
- MCP3202
- MCP3204
- MCP3208
- MCP3302
- MCP3304
- MCP3308
- Note
- MCP3xxx chips uses SPI mode 2 and shifts data MSB first
- Examples
- MCP3xxx_Demo.cpp.
Definition at line 49 of file mcp3xxx.h.
◆ Channel
Single-ended channels
Enumerator |
---|
CHANNEL_0 | Channel 0
|
CHANNEL_1 | Channel 1
|
CHANNEL_2 | Channel 2
|
CHANNEL_3 | Channel 3
|
CHANNEL_4 | Channel 4 (MCP3008 only)
|
CHANNEL_5 | Channel 5 (MCP3008 only)
|
CHANNEL_6 | Channel 6 (MCP3008 only)
|
CHANNEL_7 | Channel 7 (MCP3008 only)
|
Definition at line 52 of file mcp3xxx.h.
◆ ChannelDiff
Pseudo-differential pair channels
Enumerator |
---|
DIFF_0_1 | CH0+, CH1-
|
DIFF_1_0 | CH1+, CH0-
|
DIFF_2_3 | CH2+, CH3-
|
DIFF_3_2 | CH3+, CH2-
|
DIFF_4_5 | CH4+, CH5- (MCP3008 only)
|
DIFF_5_4 | CH5+, CH4- (MCP3008 only)
|
DIFF_6_7 | CH6+, CH7- (MCP3008 only)
|
DIFF_7_6 | CH7+, CH6- (MCP3008 only)
|
Definition at line 64 of file mcp3xxx.h.
◆ PartNumber
The part number determines the width of the data transfer
Enumerator |
---|
MCP300x | 10-bit ADC, includes MCP3002, MCP3004 and MCP3008
|
MCP320x | 12-bit ADC, includes MCP3202, MCP3204 and MCP3208
|
MCP330x | 13-bit ADC, includes MCP3302, MCP3304 and MCP3308
|
Definition at line 76 of file mcp3xxx.h.
◆ MCP3xxx()
Construction requires an instance of the SPI module; the SPI module does not need to be started.
- Parameters
-
[in] | spi | Constructed SPI module |
[in] | cs | Pin mask used for chip select |
[in] | partNumber | Determine bit-width of the ADC channels |
[in] | alwaysSetSPIMode | Should every invocation of read or read_diff set the SPI mode. Setting to true is only necessary when multiple devices are connected to the same SPI bus and use different SPI modes |
Definition at line 93 of file mcp3xxx.h.
◆ always_set_spi_mode()
void PropWare::MCP3xxx::always_set_spi_mode |
( |
const bool |
alwaysSetMode | ) |
|
Choose whether to always set the SPI mode and bitmode before reading or writing to the ADC; Useful when multiple devices are connected to the SPI bus.
- Parameters
-
[in] | alwaysSetMode | For any non-zero value, the SPI modes will always be set before a read or write routine |
Definition at line 113 of file mcp3xxx.h.
◆ read()
Read a specific channel's data in single-ended mode.
- Parameters
-
[in] | channel | One of MCP_CHANNEL_x , where x is a number 0 through 3 (or 0 through 7 for the MCP3008); Selects the channel to be read |
- Returns
- Returns 0 upon success, error code otherwise
Definition at line 124 of file mcp3xxx.h.
◆ read_diff()
Read a specific axis's data in differential mode.
- Parameters
-
[in] | channels | One of DIFF_x _y , where x is a number 0 through 3 (or 0 through 7 for the MCP3008) and y is x + (x + 1)%2 (See above defined enum or datasheet for details) |
- Returns
- Returns 0 upon success, error code otherwise
Definition at line 155 of file mcp3xxx.h.
The documentation for this class was generated from the following file: