Class MCP3X0X

Inheritance Relationships

Derived Types

Class Documentation

class MCP3X0X

Abstract base class for all MCP adc devices.

Subclassed by iplo::MCP3002, iplo::MCP3004, iplo::MCP3008, iplo::MCP3202, iplo::MCP3204, iplo::MCP3208

Public Functions

explicit MCP3X0X(SPI &spi)

Construct a new MCP3X0X object.

Parameters:

spiSPI bus handle.

std::int16_t analogRead(std::uint8_t channel)

Read value from the specified channel in single mode.

Parameters:

channel – Device channel number.

Returns:

Read value from the channel.

std::int16_t differentialRead(std::uint8_t channel)

Read value from the specified channel in differential mode.

Parameters:

channel – Device channel number.

Returns:

Final value from differential channels.

std::int16_t deltaRead(std::uint8_t channel)

Read.

Parameters:

channel – Device channel number.

Returns:

Subtraction of two channels value.

std::uint8_t channels()

Return number of channels in the MCP ADC IC.

Returns:

Number of channels.

Protected Functions

virtual std::uint8_t buildRequest(std::uint8_t channel, bool single, std::uint8_t *data) = 0

Pure virtual method for building device request. To be implemented in all derivative class.

std::int16_t readAnalogValue(std::uint8_t channel, bool single)

Read raw analog value from the device.

Parameters:
  • channel – Channel number to read from

  • single – Identifier whether reading should be on single mode or differential mode.

Returns:

Raw read value from the device.

Protected Attributes

std::uint8_t _channels = {}

Number of channels in the IC.

std::int16_t _maxValue = {}

Maximal possible value on the IC. Corresponds to the device resolution

SPI &_spi

SPI bus handle