From 1cd615ca77c5ab46c7b140a46e45885ae70c06b6 Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Mon, 14 Jun 2021 15:50:52 +0200 Subject: [PATCH] firmware-teensy: default to none of the outputs selected --- Firmware/Teensy/include/waves.h | 1 + Firmware/Teensy/src/waves.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Firmware/Teensy/include/waves.h b/Firmware/Teensy/include/waves.h index c605b91..e4e7fc8 100644 --- a/Firmware/Teensy/include/waves.h +++ b/Firmware/Teensy/include/waves.h @@ -38,6 +38,7 @@ void generateSine(float); void generateSquare(float, int); void generateWave(float, int*, int); +void noSelect(); void selectDAC0(); void selectDAC1(); diff --git a/Firmware/Teensy/src/waves.cpp b/Firmware/Teensy/src/waves.cpp index dfb7811..65db6c4 100644 --- a/Firmware/Teensy/src/waves.cpp +++ b/Firmware/Teensy/src/waves.cpp @@ -24,6 +24,8 @@ void setupWaves(){ SIM_SCGC2 |= SIM_SCGC2_DAC1; DAC1_C0 = DAC_C0_DACEN | DAC_C0_DACRFS; + noSelect(); + //This one can be calculated only once calculateSineLookup(); } @@ -73,6 +75,11 @@ void selectDAC1(){ digitalWriteFast(DAC1_SEL, HIGH); } +void noSelect(){ + digitalWriteFast(DAC0_SEL, LOW); + digitalWriteFast(DAC1_SEL, LOW); +} + //Write the DAC with using some parts of framework's Arduino.h, for higher speeds // Use FASTRUN to run code in RAM typedef int16_t __attribute__((__may_alias__)) aliased_int16_t; @@ -107,7 +114,7 @@ FASTRUN void generateSine(float frequency){ } FASTRUN void generateSquare(float frequency, int duty){ - startGenerating(); + selectDAC1(); calculateSquareLookup(duty); generateWave(frequency, SQUARE_LUT, 1); } \ No newline at end of file