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¶
Detailed Description¶
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¶
function ~MAX11300Driver¶
function Init¶
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¶
function ReadAnalogPinRaw¶
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¶
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¶
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¶
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¶
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¶
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¶
Call this to stop the auto updating, but complete the current update.
function VoltsTo12BitUint¶
Parameters:
- volts the voltage to convert
- range the MAX11300Types::DacVoltageRange to constrain to
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¶
Parameters:
- value the 12 bit value to convert
- range the MAX11300Types::AdcVoltageRange to constrain to
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