libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
daisy::patch_sm::DaisyPatchSM Class Reference

Board support file for DaisyPatchSM hardware. More...

Detailed Description

Board support file for DaisyPatchSM hardware.

Author
shensley

Daisy Patch SM is a complete Eurorack module DSP engine. Based on the Daisy Seed, with circuits added for interfacing directly with eurorack modular synthesizers.

#include <daisy_patch_sm.h>

Public Types

enum class  PinBank { A , B , C , D }
 

Public Member Functions

 DaisyPatchSM ()
 
 ~DaisyPatchSM ()
 
void Init ()
 
void StartAudio (AudioHandle::AudioCallback cb)
 
void StartAudio (AudioHandle::InterleavingAudioCallback cb)
 
void ChangeAudioCallback (AudioHandle::AudioCallback cb)
 
void ChangeAudioCallback (AudioHandle::InterleavingAudioCallback cb)
 
void StopAudio ()
 
void SetAudioBlockSize (size_t size)
 
void SetAudioSampleRate (float sr)
 
void SetAudioSampleRate (SaiHandle::Config::SampleRate sample_rate)
 
size_t AudioBlockSize ()
 
float AudioSampleRate ()
 
float AudioCallbackRate ()
 
void StartAdc ()
 
void StopAdc ()
 
void ProcessAnalogControls ()
 
void ProcessDigitalControls ()
 
void ProcessAllControls ()
 
float GetAdcValue (int idx)
 
dsy_gpio_pin GetPin (const PinBank bank, const int idx)
 
void StartDac (DacHandle::DacCallback callback=nullptr)
 
void StopDac ()
 
void WriteCvOut (const int channel, float voltage)
 
void Delay (uint32_t milliseconds)
 
uint32_t GetRandomValue ()
 
float GetRandomFloat (float min=0.f, float max=1.f)
 
void SetLed (bool state)
 
bool ValidateSDRAM ()
 Tests entirety of SDRAM for validity This will wipe contents of SDRAM when testing.
 
bool ValidateQSPI (bool quick=true)
 Tests the QSPI for validity This will wipe contents of QSPI when testing.
 

Static Public Member Functions

template<typename... VA>
static void Print (const char *format, VA... va)
 
template<typename... VA>
static void PrintLine (const char *format, VA... va)
 
static void StartLog (bool wait_for_pc=false)
 

Public Attributes

System system
 
SdramHandle sdram
 
QSPIHandle qspi
 
AudioHandle audio
 
AdcHandle adc
 
UsbHandle usb
 
Pcm3060 codec
 
DacHandle dac
 
dsy_gpio user_led
 
AnalogControl controls [ADC_LAST]
 
GateIn gate_in_1
 
GateIn gate_in_2
 
dsy_gpio gate_out_1
 
dsy_gpio gate_out_2
 

Static Public Attributes

static constexpr Pin A1 = Pin(PORTX, 0)
 
static constexpr Pin A2 = Pin(PORTA, 1)
 
static constexpr Pin A3 = Pin(PORTA, 0)
 
static constexpr Pin A4 = Pin(PORTX, 0)
 
static constexpr Pin A5 = Pin(PORTX, 0)
 
static constexpr Pin A6 = Pin(PORTX, 0)
 
static constexpr Pin A7 = Pin(PORTX, 0)
 
static constexpr Pin A8 = Pin(PORTB, 14)
 
static constexpr Pin A9 = Pin(PORTB, 15)
 
static constexpr Pin A10 = Pin(PORTX, 0)
 
static constexpr Pin B1 = Pin(PORTX, 0)
 
static constexpr Pin B2 = Pin(PORTX, 0)
 
static constexpr Pin B3 = Pin(PORTX, 0)
 
static constexpr Pin B4 = Pin(PORTX, 0)
 
static constexpr Pin B5 = Pin(PORTC, 14)
 
static constexpr Pin B6 = Pin(PORTC, 13)
 
static constexpr Pin B7 = Pin(PORTB, 8)
 
static constexpr Pin B8 = Pin(PORTB, 9)
 
static constexpr Pin B9 = Pin(PORTG, 14)
 
static constexpr Pin B10 = Pin(PORTG, 13)
 
static constexpr Pin C1 = Pin(PORTA, 5)
 
static constexpr Pin C2 = Pin(PORTA, 7)
 
static constexpr Pin C3 = Pin(PORTA, 2)
 
static constexpr Pin C4 = Pin(PORTA, 6)
 
static constexpr Pin C5 = Pin(PORTA, 3)
 
static constexpr Pin C6 = Pin(PORTB, 1)
 
static constexpr Pin C7 = Pin(PORTC, 4)
 
static constexpr Pin C8 = Pin(PORTC, 0)
 
static constexpr Pin C9 = Pin(PORTC, 1)
 
static constexpr Pin C10 = Pin(PORTA, 4)
 
static constexpr Pin D1 = Pin(PORTB, 4)
 
static constexpr Pin D2 = Pin(PORTC, 11)
 
static constexpr Pin D3 = Pin(PORTC, 10)
 
static constexpr Pin D4 = Pin(PORTC, 9)
 
static constexpr Pin D5 = Pin(PORTC, 8)
 
static constexpr Pin D6 = Pin(PORTC, 12)
 
static constexpr Pin D7 = Pin(PORTD, 2)
 
static constexpr Pin D8 = Pin(PORTC, 2)
 
static constexpr Pin D9 = Pin(PORTC, 3)
 
static constexpr Pin D10 = Pin(PORTD, 3)
 

Member Enumeration Documentation

◆ PinBank

Helper for mapping pins, and accessing them using the GetPin function

Enumerator

Constructor & Destructor Documentation

◆ DaisyPatchSM()

daisy::patch_sm::DaisyPatchSM::DaisyPatchSM ( )
inline

◆ ~DaisyPatchSM()

daisy::patch_sm::DaisyPatchSM::~DaisyPatchSM ( )
inline

Member Function Documentation

◆ AudioBlockSize()

size_t daisy::patch_sm::DaisyPatchSM::AudioBlockSize ( )

Returns the number of samples processed in an audio callback

◆ AudioCallbackRate()

float daisy::patch_sm::DaisyPatchSM::AudioCallbackRate ( )

Returns the rate at which the audio callback will be called in Hz

◆ AudioSampleRate()

float daisy::patch_sm::DaisyPatchSM::AudioSampleRate ( )

Returns the audio engine's samplerate in Hz

◆ ChangeAudioCallback() [1/2]

void daisy::patch_sm::DaisyPatchSM::ChangeAudioCallback ( AudioHandle::AudioCallback  cb)

Changes the callback that is executing. This may cause clicks if done while audio is processing.

◆ ChangeAudioCallback() [2/2]

void daisy::patch_sm::DaisyPatchSM::ChangeAudioCallback ( AudioHandle::InterleavingAudioCallback  cb)

Changes the callback that is executing. This may cause clicks if done while audio is processing.

◆ Delay()

void daisy::patch_sm::DaisyPatchSM::Delay ( uint32_t  milliseconds)
inline

Here are some wrappers around libDaisy Static functions to provide simpler syntax to those who prefer it. Delays for a specified number of milliseconds

◆ GetAdcValue()

float daisy::patch_sm::DaisyPatchSM::GetAdcValue ( int  idx)

Returns the current value for one of the ADCs

◆ GetPin()

dsy_gpio_pin daisy::patch_sm::DaisyPatchSM::GetPin ( const PinBank  bank,
const int  idx 
)

Returns the STM32 port/pin combo for the desired pin (or an invalid pin for HW only pins)

Macros at top of file can be used in place of separate arguments (i.e. GetPin(A4), etc.)

Parameters
bankshould be one of the PinBank options above
idxpin number between 1 and 10 for each of the pins on each header.
Deprecated:
please use the Pin definitions in daisy::patch_sm instead

◆ GetRandomFloat()

float daisy::patch_sm::DaisyPatchSM::GetRandomFloat ( float  min = 0.f,
float  max = 1.f 
)
inline

Gets a random floating point value between the specified minimum, and maxmimum

◆ GetRandomValue()

uint32_t daisy::patch_sm::DaisyPatchSM::GetRandomValue ( )
inline

Gets a random 32-bit value

◆ Init()

void daisy::patch_sm::DaisyPatchSM::Init ( )

Initializes the memories, and core peripherals for the Daisy Patch SM

◆ Print()

template<typename... VA>
static void daisy::patch_sm::DaisyPatchSM::Print ( const char format,
VA...  va 
)
inlinestatic

Print formatted debug log message

◆ PrintLine()

template<typename... VA>
static void daisy::patch_sm::DaisyPatchSM::PrintLine ( const char format,
VA...  va 
)
inlinestatic

Print formatted debug log message with automatic line termination

◆ ProcessAllControls()

void daisy::patch_sm::DaisyPatchSM::ProcessAllControls ( )
inline

Does both of the above

◆ ProcessAnalogControls()

void daisy::patch_sm::DaisyPatchSM::ProcessAnalogControls ( )

Reads and filters all of the analog control inputs

◆ ProcessDigitalControls()

void daisy::patch_sm::DaisyPatchSM::ProcessDigitalControls ( )

Reads and debounces any of the digital control inputs This does nothing on this board at this time.

◆ SetAudioBlockSize()

void daisy::patch_sm::DaisyPatchSM::SetAudioBlockSize ( size_t  size)

Sets the number of samples processed in an audio callback. This will only take effect on the next invocation of StartAudio

◆ SetAudioSampleRate() [1/2]

void daisy::patch_sm::DaisyPatchSM::SetAudioSampleRate ( float  sr)

Sets the samplerate for the audio engine This will set it to the closest valid samplerate. Options being: 8kHz, 16kHz, 32kHz, 48kHz, and 96kHz

◆ SetAudioSampleRate() [2/2]

void daisy::patch_sm::DaisyPatchSM::SetAudioSampleRate ( SaiHandle::Config::SampleRate  sample_rate)

◆ SetLed()

void daisy::patch_sm::DaisyPatchSM::SetLed ( bool  state)

◆ StartAdc()

void daisy::patch_sm::DaisyPatchSM::StartAdc ( )

Starts the Control ADCs

This is started automatically when Init() is called.

◆ StartAudio() [1/2]

void daisy::patch_sm::DaisyPatchSM::StartAudio ( AudioHandle::AudioCallback  cb)

Starts a non-interleaving audio callback

◆ StartAudio() [2/2]

void daisy::patch_sm::DaisyPatchSM::StartAudio ( AudioHandle::InterleavingAudioCallback  cb)

Starts an interleaving audio callback

◆ StartDac()

void daisy::patch_sm::DaisyPatchSM::StartDac ( DacHandle::DacCallback  callback = nullptr)

Starts the DAC for the CV Outputs

By default this starts by running the internal callback at 48kHz, which will update the values based on the SetCvOut function.

This is started automatically when Init() is called.

◆ StartLog()

static void daisy::patch_sm::DaisyPatchSM::StartLog ( bool  wait_for_pc = false)
inlinestatic

Start the logging session. Optionally wait for terminal connection before proceeding.

◆ StopAdc()

void daisy::patch_sm::DaisyPatchSM::StopAdc ( )

Stops the Control ADCs

◆ StopAudio()

void daisy::patch_sm::DaisyPatchSM::StopAudio ( )

Stops the transmission of audio.

◆ StopDac()

void daisy::patch_sm::DaisyPatchSM::StopDac ( )

Stop the DAC from updating. This will suspend the CV Outputs from changing

◆ ValidateQSPI()

bool daisy::patch_sm::DaisyPatchSM::ValidateQSPI ( bool  quick = true)

Tests the QSPI for validity This will wipe contents of QSPI when testing.

Note
If called with quick = false, this will erase all memory the "quick" test starts 0x400000 bytes into the memory and test 16kB of data
Parameters
quickif this is true the test will only test a small piece of the QSPI checking the entire 8MB can take roughly over a minute.
Return values
returnstrue if SDRAM is okay, otherwise false

◆ ValidateSDRAM()

bool daisy::patch_sm::DaisyPatchSM::ValidateSDRAM ( )

Tests entirety of SDRAM for validity This will wipe contents of SDRAM when testing.

Note
If using the SDRAM for the default bss, or heap, and using constructors as initializers do not call this function. Otherwise, it could overwrite changes performed by constructors.
Return values
returnstrue if SDRAM is okay, otherwise false

◆ WriteCvOut()

void daisy::patch_sm::DaisyPatchSM::WriteCvOut ( const int  channel,
float  voltage 
)

Sets specified DAC channel to the target voltage. This may not be 100% accurate without calibration.

Todo:
Add Calibration to CV Outputs
Parameters
channeldesired channel to update. 0 is both, otherwise 1 or 2 are valid.
voltagevalue in Volts that you'd like to write to the DAC. The valid range is 0-5V.

Member Data Documentation

◆ A1

constexpr Pin daisy::patch_sm::DaisyPatchSM::A1 = Pin(PORTX, 0)
staticconstexpr

Pin Accessors for the DaisyPatchSM hardware Used for initializing various GPIO, etc. A1 - -12V Power Input

◆ A10

constexpr Pin daisy::patch_sm::DaisyPatchSM::A10 = Pin(PORTX, 0)
staticconstexpr

A10 - +3V3 Power Out

◆ A2

constexpr Pin daisy::patch_sm::DaisyPatchSM::A2 = Pin(PORTA, 1)
staticconstexpr

A2 - UART1 Rx

◆ A3

constexpr Pin daisy::patch_sm::DaisyPatchSM::A3 = Pin(PORTA, 0)
staticconstexpr

A3 - UART1 Tx

◆ A4

constexpr Pin daisy::patch_sm::DaisyPatchSM::A4 = Pin(PORTX, 0)
staticconstexpr

A4 - GND

◆ A5

constexpr Pin daisy::patch_sm::DaisyPatchSM::A5 = Pin(PORTX, 0)
staticconstexpr

A5 - +12V Power Input

◆ A6

constexpr Pin daisy::patch_sm::DaisyPatchSM::A6 = Pin(PORTX, 0)
staticconstexpr

A6 - +5V Power Output

◆ A7

constexpr Pin daisy::patch_sm::DaisyPatchSM::A7 = Pin(PORTX, 0)
staticconstexpr

A7 - GND

◆ A8

constexpr Pin daisy::patch_sm::DaisyPatchSM::A8 = Pin(PORTB, 14)
staticconstexpr

A8 - USB DM

◆ A9

constexpr Pin daisy::patch_sm::DaisyPatchSM::A9 = Pin(PORTB, 15)
staticconstexpr

A9 - USB DP

◆ adc

AdcHandle daisy::patch_sm::DaisyPatchSM::adc

◆ audio

AudioHandle daisy::patch_sm::DaisyPatchSM::audio

◆ B1

constexpr Pin daisy::patch_sm::DaisyPatchSM::B1 = Pin(PORTX, 0)
staticconstexpr

B1 - Audio Out Right

◆ B10

constexpr Pin daisy::patch_sm::DaisyPatchSM::B10 = Pin(PORTG, 13)
staticconstexpr

B10 - GATE IN 1

◆ B2

constexpr Pin daisy::patch_sm::DaisyPatchSM::B2 = Pin(PORTX, 0)
staticconstexpr

B2 - Audio Out Left

◆ B3

constexpr Pin daisy::patch_sm::DaisyPatchSM::B3 = Pin(PORTX, 0)
staticconstexpr

B3 - Audio In Right

◆ B4

constexpr Pin daisy::patch_sm::DaisyPatchSM::B4 = Pin(PORTX, 0)
staticconstexpr

B4 - Audio In Left

◆ B5

constexpr Pin daisy::patch_sm::DaisyPatchSM::B5 = Pin(PORTC, 14)
staticconstexpr

B5 - GATE OUT 1

◆ B6

constexpr Pin daisy::patch_sm::DaisyPatchSM::B6 = Pin(PORTC, 13)
staticconstexpr

B6 - GATE OUT 2

◆ B7

constexpr Pin daisy::patch_sm::DaisyPatchSM::B7 = Pin(PORTB, 8)
staticconstexpr

B7 - I2C1 SCL

◆ B8

constexpr Pin daisy::patch_sm::DaisyPatchSM::B8 = Pin(PORTB, 9)
staticconstexpr

B8 - I2C1 SDA

◆ B9

constexpr Pin daisy::patch_sm::DaisyPatchSM::B9 = Pin(PORTG, 14)
staticconstexpr

B9 - GATE IN 2

◆ C1

constexpr Pin daisy::patch_sm::DaisyPatchSM::C1 = Pin(PORTA, 5)
staticconstexpr

C1 - CV Out 2

◆ C10

constexpr Pin daisy::patch_sm::DaisyPatchSM::C10 = Pin(PORTA, 4)
staticconstexpr

C10 - CV Out 1

◆ C2

constexpr Pin daisy::patch_sm::DaisyPatchSM::C2 = Pin(PORTA, 7)
staticconstexpr

C2 - CV In 4

◆ C3

constexpr Pin daisy::patch_sm::DaisyPatchSM::C3 = Pin(PORTA, 2)
staticconstexpr

C3 - CV In 3

◆ C4

constexpr Pin daisy::patch_sm::DaisyPatchSM::C4 = Pin(PORTA, 6)
staticconstexpr

C4 - CV In 2

◆ C5

constexpr Pin daisy::patch_sm::DaisyPatchSM::C5 = Pin(PORTA, 3)
staticconstexpr

C5 - CV In 1

◆ C6

constexpr Pin daisy::patch_sm::DaisyPatchSM::C6 = Pin(PORTB, 1)
staticconstexpr

C6 - CV In 5

◆ C7

constexpr Pin daisy::patch_sm::DaisyPatchSM::C7 = Pin(PORTC, 4)
staticconstexpr

C7 - CV In 6

◆ C8

constexpr Pin daisy::patch_sm::DaisyPatchSM::C8 = Pin(PORTC, 0)
staticconstexpr

C8 - CV In 7

◆ C9

constexpr Pin daisy::patch_sm::DaisyPatchSM::C9 = Pin(PORTC, 1)
staticconstexpr

C9 - CV In 8

◆ codec

Pcm3060 daisy::patch_sm::DaisyPatchSM::codec

◆ controls

AnalogControl daisy::patch_sm::DaisyPatchSM::controls[ADC_LAST]

◆ D1

constexpr Pin daisy::patch_sm::DaisyPatchSM::D1 = Pin(PORTB, 4)
staticconstexpr

D1 - SPI2 CS

◆ D10

constexpr Pin daisy::patch_sm::DaisyPatchSM::D10 = Pin(PORTD, 3)
staticconstexpr

D10 - SPI2 SCK

◆ D2

constexpr Pin daisy::patch_sm::DaisyPatchSM::D2 = Pin(PORTC, 11)
staticconstexpr

D2 - SDMMC D3

◆ D3

constexpr Pin daisy::patch_sm::DaisyPatchSM::D3 = Pin(PORTC, 10)
staticconstexpr

D3 - SDMMC D2

◆ D4

constexpr Pin daisy::patch_sm::DaisyPatchSM::D4 = Pin(PORTC, 9)
staticconstexpr

D4 - SDMMC D1

◆ D5

constexpr Pin daisy::patch_sm::DaisyPatchSM::D5 = Pin(PORTC, 8)
staticconstexpr

D5 - SDMMC D0

◆ D6

constexpr Pin daisy::patch_sm::DaisyPatchSM::D6 = Pin(PORTC, 12)
staticconstexpr

D6 - SDMMC CK

◆ D7

constexpr Pin daisy::patch_sm::DaisyPatchSM::D7 = Pin(PORTD, 2)
staticconstexpr

D7 - SDMMC CMD

◆ D8

constexpr Pin daisy::patch_sm::DaisyPatchSM::D8 = Pin(PORTC, 2)
staticconstexpr

D8 - SPI2 MISO

◆ D9

constexpr Pin daisy::patch_sm::DaisyPatchSM::D9 = Pin(PORTC, 3)
staticconstexpr

D9 - SPI2 MOSI

◆ dac

DacHandle daisy::patch_sm::DaisyPatchSM::dac

◆ gate_in_1

GateIn daisy::patch_sm::DaisyPatchSM::gate_in_1

◆ gate_in_2

GateIn daisy::patch_sm::DaisyPatchSM::gate_in_2

◆ gate_out_1

dsy_gpio daisy::patch_sm::DaisyPatchSM::gate_out_1

◆ gate_out_2

dsy_gpio daisy::patch_sm::DaisyPatchSM::gate_out_2

◆ qspi

QSPIHandle daisy::patch_sm::DaisyPatchSM::qspi

◆ sdram

SdramHandle daisy::patch_sm::DaisyPatchSM::sdram

◆ system

System daisy::patch_sm::DaisyPatchSM::system

Direct Access Structs/Classes

◆ usb

UsbHandle daisy::patch_sm::DaisyPatchSM::usb

◆ user_led

dsy_gpio daisy::patch_sm::DaisyPatchSM::user_led

Dedicated Function Pins


The documentation for this class was generated from the following file: