Merge branch 'master' of https://github.com/EmaMaker/SignalGenerator-Teensy
commit
664d0c80cc
|
@ -38,6 +38,7 @@ void generateSine(float);
|
||||||
void generateSquare(float, int);
|
void generateSquare(float, int);
|
||||||
void generateWave(float, int*, int);
|
void generateWave(float, int*, int);
|
||||||
|
|
||||||
|
void noSelect();
|
||||||
void selectDAC0();
|
void selectDAC0();
|
||||||
void selectDAC1();
|
void selectDAC1();
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ void setupWaves(){
|
||||||
SIM_SCGC2 |= SIM_SCGC2_DAC1;
|
SIM_SCGC2 |= SIM_SCGC2_DAC1;
|
||||||
DAC1_C0 = DAC_C0_DACEN | DAC_C0_DACRFS;
|
DAC1_C0 = DAC_C0_DACEN | DAC_C0_DACRFS;
|
||||||
|
|
||||||
|
noSelect();
|
||||||
|
|
||||||
//This one can be calculated only once
|
//This one can be calculated only once
|
||||||
calculateSineLookup();
|
calculateSineLookup();
|
||||||
}
|
}
|
||||||
|
@ -73,6 +75,11 @@ void selectDAC1(){
|
||||||
digitalWriteFast(DAC1_SEL, HIGH);
|
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
|
//Write the DAC with using some parts of framework's Arduino.h, for higher speeds
|
||||||
// Use FASTRUN to run code in RAM
|
// Use FASTRUN to run code in RAM
|
||||||
typedef int16_t __attribute__((__may_alias__)) aliased_int16_t;
|
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){
|
FASTRUN void generateSquare(float frequency, int duty){
|
||||||
startGenerating();
|
selectDAC1();
|
||||||
calculateSquareLookup(duty);
|
calculateSquareLookup(duty);
|
||||||
generateWave(frequency, SQUARE_LUT, 1);
|
generateWave(frequency, SQUARE_LUT, 1);
|
||||||
}
|
}
|
Loading…
Reference in New Issue