Skip to content

daisy::MAX11300Driver

Module: LIBDAISY / DEVICE / MAX11300

Device Driver for the MAX11300 20 port ADC/DAC/GPIO device. More...

#include <max11300.h>

Public Classes

Name
struct Config

Public Functions

Name
MAX11300Driver()
~MAX11300Driver()
MAX11300Types::Result Init(Config config, MAX11300Types::DmaBuffer * dma_buffer)
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 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 DisablePin(size_t device_index, Pin pin)
uint16_t ReadAnalogPinRaw(size_t device_index, MAX11300Types::Pin pin) const
float ReadAnalogPinVolts(size_t device_index, MAX11300Types::Pin pin) const
void WriteAnalogPinRaw(size_t device_index, MAX11300Types::Pin pin, uint16_t raw_value)
void WriteAnalogPinVolts(size_t device_index, MAX11300Types::Pin pin, float voltage)
bool ReadDigitalPin(size_t device_index, MAX11300Types::Pin pin) const
void WriteDigitalPin(size_t device_index, MAX11300Types::Pin pin, bool value)
MAX11300Types::Result Start(MAX11300Types::UpdateCompleteCallbackFunctionPtr complete_callback =nullptr, void * complete_callback_context =nullptr)
void Stop()
uint16_t VoltsTo12BitUint(float volts, MAX11300Types::DacVoltageRange range)
float TwelveBitUintToVolts(uint16_t value, MAX11300Types::AdcVoltageRange range)

Detailed Description

template <typename Transport ,
size_t num_devices>
class daisy::MAX11300Driver;

Device Driver for the MAX11300 20 port ADC/DAC/GPIO device.

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 MAX11300Driver

inline MAX11300Driver()

function ~MAX11300Driver

inline ~MAX11300Driver()

function Init

inline MAX11300Types::Result Init(
    Config config,
    MAX11300Types::DmaBuffer * dma_buffer
)

Parameters:

  • config - The MAX11300 configuration
  • dma_buffer a buffer in DMA-accessible memory. Allocate it like this: MAX11300DmaBuffer DMA_BUFFER_MEM_SECTION myBuffer;

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.


function ConfigurePinAsDigitalRead

inline MAX11300Types::Result ConfigurePinAsDigitalRead(
    size_t device_index,
    MAX11300Types::Pin pin,
    float threshold_voltage
)

function ConfigurePinAsDigitalWrite

inline MAX11300Types::Result ConfigurePinAsDigitalWrite(
    size_t device_index,
    MAX11300Types::Pin pin,
    float output_voltage
)

function ConfigurePinAsAnalogRead

inline MAX11300Types::Result ConfigurePinAsAnalogRead(
    size_t device_index,
    MAX11300Types::Pin pin,
    MAX11300Types::AdcVoltageRange range
)

function ConfigurePinAsAnalogWrite

inline MAX11300Types::Result ConfigurePinAsAnalogWrite(
    size_t device_index,
    MAX11300Types::Pin pin,
    MAX11300Types::DacVoltageRange range
)

function DisablePin

inline MAX11300Types::Result DisablePin(
    size_t device_index,
    Pin pin
)

function ReadAnalogPinRaw

inline uint16_t ReadAnalogPinRaw(
    size_t device_index,
    MAX11300Types::Pin pin
) const

Parameters:

  • pin - The pin of which to read the value

Return: - The raw, 12 bit value of the given ANALOG_IN (ADC) pin.

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


function ReadAnalogPinVolts

inline float ReadAnalogPinVolts(
    size_t device_index,
    MAX11300Types::Pin pin
) const

Parameters:

  • pin - The pin of which to read the voltage

Return: - The value of the given ANALOG_IN (ADC) pin in volts

Read the value of a given ADC pin in volts.

*note this read is local, call MAX11300::Start() to sync with the MAX11300


function WriteAnalogPinRaw

inline void WriteAnalogPinRaw(
    size_t device_index,
    MAX11300Types::Pin pin,
    uint16_t raw_value
)

Parameters:

  • pin - The pin of which to write the value
  • raw_value - the 12-bit code to write to the given Pin

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


function WriteAnalogPinVolts

inline void WriteAnalogPinVolts(
    size_t device_index,
    MAX11300Types::Pin pin,
    float voltage
)

Parameters:

  • pin - The pin of which to write the voltage
  • voltage - Target 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


function ReadDigitalPin

inline bool ReadDigitalPin(
    size_t device_index,
    MAX11300Types::Pin pin
) const

Parameters:

  • pin - The pin of which to read the value

Return: - The boolean state of the pin

Read the state of a GPI pin

*note this read is local, call MAX11300::Start() to sync with the MAX11300


function WriteDigitalPin

inline void WriteDigitalPin(
    size_t device_index,
    MAX11300Types::Pin pin,
    bool value
)

Parameters:

  • pin - The pin of which to write the value
  • value - the boolean state to write

Write a digital state to the given GPO pin

*note this write is local, call MAX11300::Start() to sync with the MAX11300


function Start

inline MAX11300Types::Result Start(
    MAX11300Types::UpdateCompleteCallbackFunctionPtr complete_callback =nullptr,
    void * complete_callback_context =nullptr
)

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

See: Stop()

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().


function Stop

inline void Stop()

Call this to stop the auto updating, but complete the current update.


function VoltsTo12BitUint

static inline uint16_t VoltsTo12BitUint(
    float volts,
    MAX11300Types::DacVoltageRange range
)

Parameters:

Return: the voltage as 12 bit unsigned integer

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.


function TwelveBitUintToVolts

static inline float TwelveBitUintToVolts(
    uint16_t value,
    MAX11300Types::AdcVoltageRange range
)

Parameters:

Return: the value as a float voltage constrained to the given voltage 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.

---

Updated on 2024-01-03 at 19:41:01 +0000