Skip to content

daisy::patch_sm::DaisyPatchSM

Module: LIBDAISY / BOARDS

Board support file for DaisyPatchSM hardware. More...

#include <daisy_patch_sm.h>

Public Types

Name
enum class PinBank

Public Functions

Name
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.
template <typename... VA>
void
Print(const char * format, VA... va)
template <typename... VA>
void
PrintLine(const char * format, VA... va)
void StartLog(bool wait_for_pc =false)

Public Attributes

Name
System system
SdramHandle sdram
QSPIHandle qspi
AudioHandle audio
AdcHandle adc
UsbHandle usb
Pcm3060 codec
DacHandle dac
dsy_gpio user_led
AnalogControl[ADC_LAST] controls
GateIn gate_in_1
GateIn gate_in_2
dsy_gpio gate_out_1
dsy_gpio gate_out_2
constexpr static Pin A1
constexpr static Pin A2
constexpr static Pin A3
constexpr static Pin A4
constexpr static Pin A5
constexpr static Pin A6
constexpr static Pin A7
constexpr static Pin A8
constexpr static Pin A9
constexpr static Pin A10
constexpr static Pin B1
constexpr static Pin B2
constexpr static Pin B3
constexpr static Pin B4
constexpr static Pin B5
constexpr static Pin B6
constexpr static Pin B7
constexpr static Pin B8
constexpr static Pin B9
constexpr static Pin B10
constexpr static Pin C1
constexpr static Pin C2
constexpr static Pin C3
constexpr static Pin C4
constexpr static Pin C5
constexpr static Pin C6
constexpr static Pin C7
constexpr static Pin C8
constexpr static Pin C9
constexpr static Pin C10
constexpr static Pin D1
constexpr static Pin D2
constexpr static Pin D3
constexpr static Pin D4
constexpr static Pin D5
constexpr static Pin D6
constexpr static Pin D7
constexpr static Pin D8
constexpr static Pin D9
constexpr static Pin D10

Detailed Description

class daisy::patch_sm::DaisyPatchSM;

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.

Public Types Documentation

enum PinBank

Enumerator Value Description
A
B
C
D

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

Public Functions Documentation

function DaisyPatchSM

inline DaisyPatchSM()

function ~DaisyPatchSM

inline ~DaisyPatchSM()

function Init

void Init()

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


function StartAudio

void StartAudio(
    AudioHandle::AudioCallback cb
)

Starts a non-interleaving audio callback


function StartAudio

void StartAudio(
    AudioHandle::InterleavingAudioCallback cb
)

Starts an interleaving audio callback


function ChangeAudioCallback

void ChangeAudioCallback(
    AudioHandle::AudioCallback cb
)

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


function ChangeAudioCallback

void ChangeAudioCallback(
    AudioHandle::InterleavingAudioCallback cb
)

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


function StopAudio

void StopAudio()

Stops the transmission of audio.


function SetAudioBlockSize

void 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


function SetAudioSampleRate

void 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


function SetAudioSampleRate

void SetAudioSampleRate(
    SaiHandle::Config::SampleRate sample_rate
)

function AudioBlockSize

size_t AudioBlockSize()

Returns the number of samples processed in an audio callback


function AudioSampleRate

float AudioSampleRate()

Returns the audio engine's samplerate in Hz


function AudioCallbackRate

float AudioCallbackRate()

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


function StartAdc

void StartAdc()

Starts the Control ADCs

This is started automatically when Init() is called.


function StopAdc

void StopAdc()

Stops the Control ADCs


function ProcessAnalogControls

void ProcessAnalogControls()

Reads and filters all of the analog control inputs


function ProcessDigitalControls

void ProcessDigitalControls()

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


function ProcessAllControls

inline void ProcessAllControls()

Does both of the above


function GetAdcValue

float GetAdcValue(
    int idx
)

Returns the current value for one of the ADCs


function GetPin

dsy_gpio_pin GetPin(
    const PinBank bank,
    const int idx
)

Parameters:

  • bank should be one of the PinBank options above
  • idx pin number between 1 and 10 for each of the pins on each header.

Deprecated:

please use the Pin definitions in daisy::patch_sm instead

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


function StartDac

void 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.


function StopDac

void StopDac()

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


function WriteCvOut

void WriteCvOut(
    const int channel,
    float voltage
)

Parameters:

  • channel desired channel to update. 0 is both, otherwise 1 or 2 are valid.
  • voltage value in Volts that you'd like to write to the DAC. The valid range is 0-5V.

Todo: Add Calibration to CV Outputs

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


function Delay

inline void Delay(
    uint32_t milliseconds
)

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


function GetRandomValue

inline uint32_t GetRandomValue()

Gets a random 32-bit value


function GetRandomFloat

inline float GetRandomFloat(
    float min =0.f,
    float max =1.f
)

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


function SetLed

void SetLed(
    bool state
)

function ValidateSDRAM

bool ValidateSDRAM()

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

Returns:

  • returns true if SDRAM is okay, otherwise false

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.


function ValidateQSPI

bool ValidateQSPI(
    bool quick =true
)

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

Parameters:

  • quick if this is true the test will only test a small piece of the QSPI checking the entire 8MB can take roughly over a minute.

Returns:

  • returns true if SDRAM is okay, otherwise false

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


function Print

template <typename... VA>
static inline void Print(
    const char * format,
    VA... va
)

Print formatted debug log message


function PrintLine

template <typename... VA>
static inline void PrintLine(
    const char * format,
    VA... va
)

Print formatted debug log message with automatic line termination


function StartLog

static inline void StartLog(
    bool wait_for_pc =false
)

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


Public Attributes Documentation

variable system

System system;

Direct Access Structs/Classes

variable sdram

SdramHandle sdram;

variable qspi

QSPIHandle qspi;

variable audio

AudioHandle audio;

variable adc

AdcHandle adc;

variable usb

UsbHandle usb;

variable codec

Pcm3060 codec;

variable dac

DacHandle dac;

variable user_led

dsy_gpio user_led;

Dedicated Function Pins

variable controls

AnalogControl[ADC_LAST] controls;

variable gate_in_1

GateIn gate_in_1;

variable gate_in_2

GateIn gate_in_2;

variable gate_out_1

dsy_gpio gate_out_1;

variable gate_out_2

dsy_gpio gate_out_2;

variable A1

static constexpr static Pin A1 = Pin(PORTX, 0);

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

variable A2

static constexpr static Pin A2 = Pin(PORTA, 1);

A2 - UART1 Rx

variable A3

static constexpr static Pin A3 = Pin(PORTA, 0);

A3 - UART1 Tx

variable A4

static constexpr static Pin A4 = Pin(PORTX, 0);

A4 - GND

variable A5

static constexpr static Pin A5 = Pin(PORTX, 0);

A5 - +12V Power Input

variable A6

static constexpr static Pin A6 = Pin(PORTX, 0);

A6 - +5V Power Output

variable A7

static constexpr static Pin A7 = Pin(PORTX, 0);

A7 - GND

variable A8

static constexpr static Pin A8 = Pin(PORTB, 14);

A8 - USB DM

variable A9

static constexpr static Pin A9 = Pin(PORTB, 15);

A9 - USB DP

variable A10

static constexpr static Pin A10 = Pin(PORTX, 0);

A10 - +3V3 Power Out

variable B1

static constexpr static Pin B1 = Pin(PORTX, 0);

B1 - Audio Out Right

variable B2

static constexpr static Pin B2 = Pin(PORTX, 0);

B2 - Audio Out Left

variable B3

static constexpr static Pin B3 = Pin(PORTX, 0);

B3 - Audio In Right

variable B4

static constexpr static Pin B4 = Pin(PORTX, 0);

B4 - Audio In Left

variable B5

static constexpr static Pin B5 = Pin(PORTC, 14);

B5 - GATE OUT 1

variable B6

static constexpr static Pin B6 = Pin(PORTC, 13);

B6 - GATE OUT 2

variable B7

static constexpr static Pin B7 = Pin(PORTB, 8);

B7 - I2C1 SCL

variable B8

static constexpr static Pin B8 = Pin(PORTB, 9);

B8 - I2C1 SDA

variable B9

static constexpr static Pin B9 = Pin(PORTG, 14);

B9 - GATE IN 2

variable B10

static constexpr static Pin B10 = Pin(PORTG, 13);

B10 - GATE IN 1

variable C1

static constexpr static Pin C1 = Pin(PORTA, 5);

C1 - CV Out 2

variable C2

static constexpr static Pin C2 = Pin(PORTA, 7);

C2 - CV In 4

variable C3

static constexpr static Pin C3 = Pin(PORTA, 2);

C3 - CV In 3

variable C4

static constexpr static Pin C4 = Pin(PORTA, 6);

C4 - CV In 2

variable C5

static constexpr static Pin C5 = Pin(PORTA, 3);

C5 - CV In 1

variable C6

static constexpr static Pin C6 = Pin(PORTB, 1);

C6 - CV In 5

variable C7

static constexpr static Pin C7 = Pin(PORTC, 4);

C7 - CV In 6

variable C8

static constexpr static Pin C8 = Pin(PORTC, 0);

C8 - CV In 7

variable C9

static constexpr static Pin C9 = Pin(PORTC, 1);

C9 - CV In 8

variable C10

static constexpr static Pin C10 = Pin(PORTA, 4);

C10 - CV Out 1

variable D1

static constexpr static Pin D1 = Pin(PORTB, 4);

D1 - SPI2 CS

variable D2

static constexpr static Pin D2 = Pin(PORTC, 11);

D2 - SDMMC D3

variable D3

static constexpr static Pin D3 = Pin(PORTC, 10);

D3 - SDMMC D2

variable D4

static constexpr static Pin D4 = Pin(PORTC, 9);

D4 - SDMMC D1

variable D5

static constexpr static Pin D5 = Pin(PORTC, 8);

D5 - SDMMC D0

variable D6

static constexpr static Pin D6 = Pin(PORTC, 12);

D6 - SDMMC CK

variable D7

static constexpr static Pin D7 = Pin(PORTD, 2);

D7 - SDMMC CMD

variable D8

static constexpr static Pin D8 = Pin(PORTC, 2);

D8 - SPI2 MISO

variable D9

static constexpr static Pin D9 = Pin(PORTC, 3);

D9 - SPI2 MOSI

variable D10

static constexpr static Pin D10 = Pin(PORTD, 3);

D10 - SPI2 SCK


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