ADC Multiplexer#

Soft Driver#

Defined in namespace hal::soft

#include <libhal-soft/adc_mux.hpp>

class adc_multiplexer#

A driver for an ADC multiplexer that manages and reads ADC mux pins. This driver is intended to be used with multiplexers that use digital signals. An ADC multiplexer can be used to expand the number of input channels of an ADC.

Public Functions

adc_multiplexer(std::span<output_pin*> p_signal_pins, hal::adc &p_source_pin, hal::steady_clock &p_clock)#

Constructs a new adc_multiplexer object.

Parameters:
  • p_signal_pins – A span of the output signal pins used to determine the channel on the mux.

  • p_source_pin – The output adc pin of the multiplexer.

  • p_clock – A steady clock used for delaying 500ns to give time to the mux to have an updated signal.

Throws:

hal::argument_out_of_domain – - if p_signal_pins has 1 or 0 pins. This is considered an unsupported use case of this driver.

float read_channel(std::uint16_t p_mux_port)#

Reads a channel on the mux.

Parameters:

p_mux_port – The port to be read. If an out of bounds port number is passed, an error-typed result is returned.

Throws:

hal::argument_out_of_domain – - if p_mux_port is greater than the value returned from get_max_channel().

Returns:

float - adc sample from the selected channel.

int get_max_channel()#

Gets the highest capacity channel held by the ADC mux object. This is calculated based off of how many source pins are available.

Returns:

the maximum channel number for this mux (2^n states, where n is number of source pins).

group AdcMux

Functions

adc_mux_pin make_adc(adc_multiplexer &p_multiplexer, std::uint8_t p_channel)#

Returns an ADC pin from the multiplexer.

Parameters:
  • p_multiplexer – the adc multiplexer with the desire adc channel pin

  • p_channel – The channel number of the pin

Throws:

hal::argument_out_of_domain – - if p_channel greater than the available number of channels in the multiplexer.

Returns:

A newly constructed ADC multiplexer pin.

class adc_mux_pin : public hal::adc#
#include <adc_mux.hpp>

A class that represents a multiplexer pin for ADC.