Class daisy::MAX11300Driver¶
template <typename Transport, size_t num_devices>
ClassList > daisy > MAX11300Driver
Device Driver for the MAX11300 20 port ADC/DAC/GPIO device. More...
#include <max11300.h>
Classes¶
Type | Name |
---|---|
struct | Config |
Public Functions¶
Type | Name |
---|---|
MAX11300Types::Result | ConfigurePinAsAnalogRead (size_t device_index, MAX11300Types::Pin pin, MAX11300Types::AdcVoltageRange range) |
MAX11300Types::Result | ConfigurePinAsAnalogWrite (size_t device_index, MAX11300Types::Pin pin, MAX11300Types::DacVoltageRange range) |
MAX11300Types::Result | ConfigurePinAsDigitalRead (size_t device_index, MAX11300Types::Pin pin, float threshold_voltage) |
MAX11300Types::Result | ConfigurePinAsDigitalWrite (size_t device_index, MAX11300Types::Pin pin, float output_voltage) |
MAX11300Types::Result | DisablePin (size_t device_index, Pin pin) |
MAX11300Types::Result | Init (Config config, MAX11300Types::DmaBuffer * dma_buffer) |
MAX11300Driver () |
|
uint16_t | ReadAnalogPinRaw (size_t device_index, MAX11300Types::Pin pin) const |
float | ReadAnalogPinVolts (size_t device_index, MAX11300Types::Pin pin) const |
bool | ReadDigitalPin (size_t device_index, MAX11300Types::Pin pin) const |
MAX11300Types::Result | Start (MAX11300Types::UpdateCompleteCallbackFunctionPtr complete_callback=nullptr, void * complete_callback_context=nullptr) |
void | Stop () |
void | WriteAnalogPinRaw (size_t device_index, MAX11300Types::Pin pin, uint16_t raw_value) |
void | WriteAnalogPinVolts (size_t device_index, MAX11300Types::Pin pin, float voltage) |
void | WriteDigitalPin (size_t device_index, MAX11300Types::Pin pin, bool value) |
~MAX11300Driver () |
Public Static Functions¶
Type | Name |
---|---|
float | TwelveBitUintToVolts (uint16_t value, MAX11300Types::AdcVoltageRange range) |
uint16_t | VoltsTo12BitUint (float volts, MAX11300Types::DacVoltageRange range) |
Detailed Description¶
Author:
sam.braam
Date:
Oct. 2021
This is a highly opinionated driver implementation for the MAX11300 DAC/ADC/GPIO device.
This implemetation has been designed for use in the context of Eurorack modular systems. There are a number of features the MAX11300 offers which are not exposed, as well as a number of configuration decisions that were made in order to simplify usage and improve ergonomics, even at the cost of flexibility.
Public Functions Documentation¶
function ConfigurePinAsAnalogRead¶
inline MAX11300Types::Result daisy::MAX11300Driver::ConfigurePinAsAnalogRead (
size_t device_index,
MAX11300Types::Pin pin,
MAX11300Types::AdcVoltageRange range
)
function ConfigurePinAsAnalogWrite¶
inline MAX11300Types::Result daisy::MAX11300Driver::ConfigurePinAsAnalogWrite (
size_t device_index,
MAX11300Types::Pin pin,
MAX11300Types::DacVoltageRange range
)
function ConfigurePinAsDigitalRead¶
inline MAX11300Types::Result daisy::MAX11300Driver::ConfigurePinAsDigitalRead (
size_t device_index,
MAX11300Types::Pin pin,
float threshold_voltage
)
function ConfigurePinAsDigitalWrite¶
inline MAX11300Types::Result daisy::MAX11300Driver::ConfigurePinAsDigitalWrite (
size_t device_index,
MAX11300Types::Pin pin,
float output_voltage
)
function DisablePin¶
function Init¶
inline MAX11300Types::Result daisy::MAX11300Driver::Init (
Config config,
MAX11300Types::DmaBuffer * dma_buffer
)
Initialize the MAX11300
This method verifies SPI connectivity, configures the chip to operate within the scope of this implementation, and intitalizes all pins by default to High-Z mode.
Parameters:
config
- The MAX11300 configurationdma_buffer
a buffer in DMA-accessible memory. Allocate it like this:MAX11300DmaBuffer DMA_BUFFER_MEM_SECTION myBuffer;
function MAX11300Driver¶
function ReadAnalogPinRaw¶
inline uint16_t daisy::MAX11300Driver::ReadAnalogPinRaw (
size_t device_index,
MAX11300Types::Pin pin
) const
Read the raw 12 bit (0-4095) value of a given ANALOG_IN (ADC) pin.
*note this read is local, call MAX11300::Start() to sync with the MAX11300
Parameters:
pin
- The pin of which to read the value
Returns:
- The raw, 12 bit value of the given ANALOG_IN (ADC) pin.
function ReadAnalogPinVolts¶
inline float daisy::MAX11300Driver::ReadAnalogPinVolts (
size_t device_index,
MAX11300Types::Pin pin
) const
Read the value of a given ADC pin in volts.
*note this read is local, call MAX11300::Start() to sync with the MAX11300
Parameters:
pin
- The pin of which to read the voltage
Returns:
- The value of the given ANALOG_IN (ADC) pin in volts
function ReadDigitalPin¶
inline bool daisy::MAX11300Driver::ReadDigitalPin (
size_t device_index,
MAX11300Types::Pin pin
) const
Read the state of a GPI pin
*note this read is local, call MAX11300::Start() to sync with the MAX11300
Parameters:
pin
- The pin of which to read the value
Returns:
- The boolean state of the pin
function Start¶
inline MAX11300Types::Result daisy::MAX11300Driver::Start (
MAX11300Types::UpdateCompleteCallbackFunctionPtr complete_callback=nullptr,
void * complete_callback_context=nullptr
)
Starts to update and synchronize the MAX11300 - This method does the following:
- Write all current ANALOG_OUT (DAC) values to all MAX11300s
- Read all current ANALOG_IN (ADC) values to memory
- Write all GPO states to all MAX11300s
- Read all GPI states to memory
- call the provided callback function when complete (from an interrupt)
- repeat
The driver can be stopped by calling Stop().
See also: Stop()
Parameters:
complete_callback
An optional callback function that's called after each successful update Keep this callback function simple and fast, it's called from an interrupt.complete_callback_context
An optional context pointer provided to the complete_callback
function Stop¶
Call this to stop the auto updating, but complete the current update.
function WriteAnalogPinRaw¶
inline void daisy::MAX11300Driver::WriteAnalogPinRaw (
size_t device_index,
MAX11300Types::Pin pin,
uint16_t raw_value
)
Write a raw 12 bit (0-4095) value to a given ANALOG_OUT (DAC) pin
*note this write is local, call MAX11300::Start() to sync with the MAX11300
Parameters:
pin
- The pin of which to write the valueraw_value
- the 12-bit code to write to the given Pin
function WriteAnalogPinVolts¶
inline void daisy::MAX11300Driver::WriteAnalogPinVolts (
size_t device_index,
MAX11300Types::Pin pin,
float voltage
)
Write a voltage value, within the bounds of the configured volatge range, to a given ANALOG_OUT (DAC) pin.
*note this write is local, call MAX11300::Start() to sync with the MAX11300
Parameters:
pin
- The pin of which to write the voltagevoltage
- Target voltage
function WriteDigitalPin¶
inline void daisy::MAX11300Driver::WriteDigitalPin (
size_t device_index,
MAX11300Types::Pin pin,
bool value
)
Write a digital state to the given GPO pin
*note this write is local, call MAX11300::Start() to sync with the MAX11300
Parameters:
pin
- The pin of which to write the valuevalue
- the boolean state to write
function ~MAX11300Driver¶
Public Static Functions Documentation¶
function TwelveBitUintToVolts¶
static inline float daisy::MAX11300Driver::TwelveBitUintToVolts (
uint16_t value,
MAX11300Types::AdcVoltageRange range
)
A utility funtion for converting the first 12 bits (0-4095) of an unsigned 16 bit integer value, to a voltage (float) value. The voltage value is scaled and bound to the given voltage range.
Parameters:
value
the 12 bit value to convertrange
the MAX11300Types::AdcVoltageRange to constrain to
Returns:
the value as a float voltage constrained to the given voltage range
function VoltsTo12BitUint¶
static inline uint16_t daisy::MAX11300Driver::VoltsTo12BitUint (
float volts,
MAX11300Types::DacVoltageRange range
)
A utility funtion for converting a voltage (float) value, bound to a given voltage range, to the first 12 bits (0-4095) of an unsigned 16 bit integer value.
Parameters:
volts
the voltage to convertrange
the MAX11300Types::DacVoltageRange to constrain to
Returns:
the voltage as 12 bit unsigned integer
The documentation for this class was generated from the following file external-docs/libDaisy/src/dev/max11300.h