firmware-teensy: default to none of the outputs selected

main^2
EmaMaker 2021-06-14 15:50:52 +02:00
parent db15c6e8ce
commit 1cd615ca77
2 changed files with 9 additions and 1 deletions

View File

@ -38,6 +38,7 @@ void generateSine(float);
void generateSquare(float, int);
void generateWave(float, int*, int);
void noSelect();
void selectDAC0();
void selectDAC1();

View File

@ -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);
}