Skip to content

Commit

Permalink
Update ADCSetup.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Bexin3 authored Jan 25, 2023
1 parent 6948701 commit 69ba265
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/ADCSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ int16_t anv = 0;

void ADC0Setup(bool DacRef, int Res, int Samp, int ADCClk, int ADCDiv, int BaseV, bool Freerun, bool PreDiv) {

/* genericClockSetup(ADCClk, ADCDiv); //Sets up ADC clock and divides it
genericClockSetup(ADCClk, ADCDiv); //Sets up ADC clock and divides it
AttachClock(ADCClk, 0x1E);

if (DacRef) {
DACSetup(BaseV); //Setup DAC if needed
};
*/

ADC0->CALIB.reg = ADC_CALIB_BIASCOMP(0x7) | ADC_CALIB_BIASREFBUF(0x7);

if (DacRef) {
ADC0->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC1_Val;
} else {
ADC0->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC2_Val;
};



Expand Down Expand Up @@ -118,16 +122,20 @@ return(anv); //Write it down

void ADC1Setup(bool DacRef, int Res, int Samp, int ADCClk, int ADCDiv, int BaseV, bool Freerun, bool PreDiv) {

/* genericClockSetup(ADCClk, ADCDiv); //Sets up ADC clock and divides it
genericClockSetup(ADCClk, ADCDiv); //Sets up ADC clock and divides it
AttachClock(ADCClk, 0x1E);

if (DacRef) {
DACSetup(BaseV); //Setup DAC if needed
};
*/

ADC1->CALIB.reg = ADC_CALIB_BIASCOMP(0x7) | ADC_CALIB_BIASREFBUF(0x7);

ADC1->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC1_Val;
if (DacRef) {
ADC0->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC1_Val;
} else {
ADC0->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC2_Val;
};



Expand Down

0 comments on commit 69ba265

Please sign in to comment.