libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
daisy_patch_sm.h
Go to the documentation of this file.
1#pragma once
2
3#include "daisy.h"
4
5namespace daisy
6{
7namespace patch_sm
8{
18 enum
19 {
20 CV_1 = 0,
33 };
34
36 enum
37 {
41 };
42
43
53 {
54 public:
56 enum class PinBank
57 {
58 A,
59 B,
60 C,
61 D
62 };
63
66
68 void Init();
69
72
75
80
85
87 void StopAudio();
88
92 void SetAudioBlockSize(size_t size);
93
98 void SetAudioSampleRate(float sr);
99
101
104
107
110
115 void StartAdc();
116
118 void StopAdc();
119
122
127
134
136 float GetAdcValue(int idx);
137
146 Pin GetPin(const PinBank bank, const int idx);
147
157 void StartDac(DacHandle::DacCallback callback = nullptr);
158
162 void StopDac();
163
172 void WriteCvOut(const int channel, float voltage);
173
178 inline void Delay(uint32_t milliseconds)
179 {
180 System::Delay(milliseconds);
181 }
182
184 inline uint32_t GetRandomValue() { return Random::GetValue(); }
185
187 inline float GetRandomFloat(float min = 0.f, float max = 1.f)
188 {
189 return Random::GetFloat(min, max);
190 }
191
192 void SetLed(bool state);
193
196 template <typename... VA>
197 static void Print(const char* format, VA... va)
198 {
199 Log::Print(format, va...);
200 }
201
204 template <typename... VA>
205 static void PrintLine(const char* format, VA... va)
206 {
207 Log::PrintLine(format, va...);
208 }
209
212 static void StartLog(bool wait_for_pc = false)
213 {
214 Log::StartLog(wait_for_pc);
215 }
216
228
241 bool ValidateQSPI(bool quick = true);
242
252
258
259
263 constexpr static Pin A1 = Pin(PORTX, 0);
264 constexpr static Pin A2 = Pin(PORTA, 1);
265 constexpr static Pin A3 = Pin(PORTA, 0);
266 constexpr static Pin A4 = Pin(PORTX, 0);
267 constexpr static Pin A5 = Pin(PORTX, 0);
268 constexpr static Pin A6 = Pin(PORTX, 0);
269 constexpr static Pin A7 = Pin(PORTX, 0);
270 constexpr static Pin A8 = Pin(PORTB, 14);
271 constexpr static Pin A9 = Pin(PORTB, 15);
272 constexpr static Pin A10 = Pin(PORTX, 0);
274 constexpr static Pin B1 = Pin(PORTX, 0);
275 constexpr static Pin B2 = Pin(PORTX, 0);
276 constexpr static Pin B3 = Pin(PORTX, 0);
277 constexpr static Pin B4 = Pin(PORTX, 0);
278 constexpr static Pin B5 = Pin(PORTC, 14);
279 constexpr static Pin B6 = Pin(PORTC, 13);
280 constexpr static Pin B7 = Pin(PORTB, 8);
281 constexpr static Pin B8 = Pin(PORTB, 9);
282 constexpr static Pin B9 = Pin(PORTG, 14);
283 constexpr static Pin B10 = Pin(PORTG, 13);
285 constexpr static Pin C1 = Pin(PORTA, 5);
286 constexpr static Pin C2 = Pin(PORTA, 7);
287 constexpr static Pin C3 = Pin(PORTA, 2);
288 constexpr static Pin C4 = Pin(PORTA, 6);
289 constexpr static Pin C5 = Pin(PORTA, 3);
290 constexpr static Pin C6 = Pin(PORTB, 1);
291 constexpr static Pin C7 = Pin(PORTC, 4);
292 constexpr static Pin C8 = Pin(PORTC, 0);
293 constexpr static Pin C9 = Pin(PORTC, 1);
294 constexpr static Pin C10 = Pin(PORTA, 4);
296 constexpr static Pin D1 = Pin(PORTB, 4);
297 constexpr static Pin D2 = Pin(PORTC, 11);
298 constexpr static Pin D3 = Pin(PORTC, 10);
299 constexpr static Pin D4 = Pin(PORTC, 9);
300 constexpr static Pin D5 = Pin(PORTC, 8);
301 constexpr static Pin D6 = Pin(PORTC, 12);
302 constexpr static Pin D7 = Pin(PORTD, 2);
303 constexpr static Pin D8 = Pin(PORTC, 2);
304 constexpr static Pin D9 = Pin(PORTC, 3);
305 constexpr static Pin D10 = Pin(PORTD, 3);
306 class Impl;
307
308 private:
310
311 float callback_rate_;
312
314 Impl* pimpl_;
315 };
316} // namespace patch_sm
317
318} // namespace daisy
Definition sdram.h:84
Interface for initializing and using the USB Peripherals on the daisy.
Definition usb.h:19
Handler for analog to digital conversion.
Definition adc.h:91
Hardware Interface for control inputs Primarily designed for ADC input controls such as potentiomet...
Definition ctrl.h:18
Audio Engine Handle.
Definition audio.h:23
void(* AudioCallback)(InputBuffer in, OutputBuffer out, size_t size)
Definition audio.h:65
void(* InterleavingAudioCallback)(InterleavingInputBuffer in, InterleavingOutputBuffer out, size_t size)
Definition audio.h:83
DAC handle for Built-in DAC Peripheral.
Definition dac.h:22
void(* DacCallback)(uint16_t **out, size_t size)
Definition dac.h:96
General Purpose I/O control.
Definition gpio.h:22
Generic Class for handling gate inputs through GPIO.
Definition gatein.h:15
Interface for simple USB logging.
Definition logger.h:72
static void StartLog(bool wait_for_pc=false)
static void Print(const char *format,...)
static void PrintLine(const char *format,...)
Definition codec_pcm3060.h:20
Definition qspi.h:32
static float GetFloat(float min=0.f, float max=1.f)
static uint32_t GetValue()
Definition system.h:19
static void Delay(uint32_t delay_ms)
Board support file for DaisyPatchSM hardware.
Definition daisy_patch_sm.h:53
void StartAudio(AudioHandle::InterleavingAudioCallback cb)
void Delay(uint32_t milliseconds)
Definition daisy_patch_sm.h:178
static constexpr Pin C5
Definition daisy_patch_sm.h:289
static constexpr Pin C8
Definition daisy_patch_sm.h:292
Pcm3060 codec
Definition daisy_patch_sm.h:250
static constexpr Pin C1
Definition daisy_patch_sm.h:285
static constexpr Pin D8
Definition daisy_patch_sm.h:303
static constexpr Pin C3
Definition daisy_patch_sm.h:287
void SetAudioSampleRate(SaiHandle::Config::SampleRate sample_rate)
static constexpr Pin B1
Definition daisy_patch_sm.h:274
UsbHandle usb
Definition daisy_patch_sm.h:249
AudioHandle audio
Definition daisy_patch_sm.h:247
static constexpr Pin D10
Definition daisy_patch_sm.h:305
static constexpr Pin B5
Definition daisy_patch_sm.h:278
static constexpr Pin A10
Definition daisy_patch_sm.h:272
static void Print(const char *format, VA... va)
Definition daisy_patch_sm.h:197
static constexpr Pin B4
Definition daisy_patch_sm.h:277
static constexpr Pin A3
Definition daisy_patch_sm.h:265
void SetAudioBlockSize(size_t size)
static constexpr Pin D3
Definition daisy_patch_sm.h:298
static constexpr Pin B6
Definition daisy_patch_sm.h:279
PinBank
Definition daisy_patch_sm.h:57
GateIn gate_in_1
Definition daisy_patch_sm.h:256
void ChangeAudioCallback(AudioHandle::AudioCallback cb)
static constexpr Pin B10
Definition daisy_patch_sm.h:283
static constexpr Pin C2
Definition daisy_patch_sm.h:286
GPIO gate_out_2
Definition daisy_patch_sm.h:257
void ChangeAudioCallback(AudioHandle::InterleavingAudioCallback cb)
AnalogControl controls[ADC_LAST]
Definition daisy_patch_sm.h:255
static constexpr Pin A1
Definition daisy_patch_sm.h:263
void SetAudioSampleRate(float sr)
GPIO user_led
Definition daisy_patch_sm.h:254
static constexpr Pin B9
Definition daisy_patch_sm.h:282
static constexpr Pin C10
Definition daisy_patch_sm.h:294
void StartDac(DacHandle::DacCallback callback=nullptr)
static constexpr Pin C7
Definition daisy_patch_sm.h:291
SdramHandle sdram
Definition daisy_patch_sm.h:245
static constexpr Pin A4
Definition daisy_patch_sm.h:266
DacHandle dac
Definition daisy_patch_sm.h:251
float GetRandomFloat(float min=0.f, float max=1.f)
Definition daisy_patch_sm.h:187
bool ValidateQSPI(bool quick=true)
Tests the QSPI for validity This will wipe contents of QSPI when testing.
static void StartLog(bool wait_for_pc=false)
Definition daisy_patch_sm.h:212
void WriteCvOut(const int channel, float voltage)
static constexpr Pin D6
Definition daisy_patch_sm.h:301
AdcHandle adc
Definition daisy_patch_sm.h:248
static constexpr Pin B8
Definition daisy_patch_sm.h:281
Pin GetPin(const PinBank bank, const int idx)
static constexpr Pin D1
Definition daisy_patch_sm.h:296
static constexpr Pin C4
Definition daisy_patch_sm.h:288
static constexpr Pin D2
Definition daisy_patch_sm.h:297
DaisyPatchSM()
Definition daisy_patch_sm.h:64
GPIO gate_out_1
Definition daisy_patch_sm.h:257
static constexpr Pin B7
Definition daisy_patch_sm.h:280
static constexpr Pin A2
Definition daisy_patch_sm.h:264
static constexpr Pin C6
Definition daisy_patch_sm.h:290
void StartAudio(AudioHandle::AudioCallback cb)
static constexpr Pin D9
Definition daisy_patch_sm.h:304
static constexpr Pin B3
Definition daisy_patch_sm.h:276
static constexpr Pin D7
Definition daisy_patch_sm.h:302
static constexpr Pin A7
Definition daisy_patch_sm.h:269
~DaisyPatchSM()
Definition daisy_patch_sm.h:65
static constexpr Pin A5
Definition daisy_patch_sm.h:267
uint32_t GetRandomValue()
Definition daisy_patch_sm.h:184
static constexpr Pin A9
Definition daisy_patch_sm.h:271
GateIn gate_in_2
Definition daisy_patch_sm.h:256
bool ValidateSDRAM()
Tests entirety of SDRAM for validity This will wipe contents of SDRAM when testing.
void ProcessAllControls()
Definition daisy_patch_sm.h:129
static constexpr Pin D4
Definition daisy_patch_sm.h:299
static constexpr Pin A6
Definition daisy_patch_sm.h:268
static constexpr Pin D5
Definition daisy_patch_sm.h:300
System system
Definition daisy_patch_sm.h:244
static constexpr Pin C9
Definition daisy_patch_sm.h:293
QSPIHandle qspi
Definition daisy_patch_sm.h:246
static constexpr Pin B2
Definition daisy_patch_sm.h:275
static void PrintLine(const char *format, VA... va)
Definition daisy_patch_sm.h:205
static constexpr Pin A8
Definition daisy_patch_sm.h:270
@ CV_OUT_BOTH
Definition daisy_patch_sm.h:38
@ CV_OUT_1
Definition daisy_patch_sm.h:39
@ CV_OUT_2
Definition daisy_patch_sm.h:40
@ CV_1
Definition daisy_patch_sm.h:20
@ CV_7
Definition daisy_patch_sm.h:26
@ CV_6
Definition daisy_patch_sm.h:25
@ ADC_9
Definition daisy_patch_sm.h:28
@ CV_3
Definition daisy_patch_sm.h:22
@ ADC_12
Definition daisy_patch_sm.h:31
@ CV_4
Definition daisy_patch_sm.h:23
@ CV_5
Definition daisy_patch_sm.h:24
@ ADC_10
Definition daisy_patch_sm.h:29
@ ADC_LAST
Definition daisy_patch_sm.h:32
@ ADC_11
Definition daisy_patch_sm.h:30
@ CV_8
Definition daisy_patch_sm.h:27
@ CV_2
Definition daisy_patch_sm.h:21
Hardware defines and helpers for daisy field platform.
Definition index.h:2
@ PORTX
Definition daisy_core.h:188
@ PORTA
Definition daisy_core.h:177
@ PORTB
Definition daisy_core.h:178
@ PORTC
Definition daisy_core.h:179
@ PORTD
Definition daisy_core.h:180
@ PORTG
Definition daisy_core.h:183
representation of hardware port/pin combination
Definition daisy_core.h:193
SampleRate
Definition sai.h:58