fixed up ADC code + tests to make them pass

This commit is contained in:
jakeg00dwin 2024-07-27 09:06:23 -07:00
parent 5f547dd844
commit a92cdead2e
2 changed files with 7 additions and 34 deletions

View File

@ -47,17 +47,12 @@ void ADC_Init(uint8_t pin_num)
(void *) (&PORTA.PIN0CTRL)+pin_num,
PORT_ISC_INPUT_DISABLE_gc
);
/*
RegEdit_OR_Num(
(void *) (&PORTA.PIN0CTRL)+pin_num,
PORT_ISC_INPUT_DISABLE_gc
);*/
//Ensure we use full 10bit resolution
RegEdit_ClearBit((void *) &ADC0.CTRLA, 2);
//RegEdit_ClearBit((void *) &ADC0.CTRLA, 2);
//Use VDD as our voltage refernce.
RegEdit_SetBit((void *) &ADC0.CTRLC, 4);
//RegEdit_SetBit((void *) &ADC0.CTRLC, 4);
}

View File

@ -52,21 +52,10 @@ TEST(test_ADC, ADC_InitPortAPin7UsesCorrectRegisters)
//Set the ISC(input sense config) to disable digital input
//buffering and reduce the noise on ADC usage.
mock().expectOneCall("RegEdit_OR_Num")
.withPointerParameter("reg", (void *) &PORTA.PIN7CTRL)
.withUnsignedIntParameter("num", 0x4);
//check that the resolusion is selected
mock().expectOneCall("RegEdit_ClearBit")
.withPointerParameter("reg", (void *) &ADC0.CTRLA)
.withUnsignedIntParameter("bit_num", 2);
//check for the seleceted refernce voltage
//we leave the adc prescaler alone mostly.
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &ADC0.CTRLC)
.withUnsignedIntParameter("bit_num", 4);
.withPointerParameter("reg", (void *) &PORTA.PIN7CTRL)
.withUnsignedIntParameter("bit_num", PORT_ISC_INPUT_DISABLE_gc);
ADC_Init(7);
}
@ -85,20 +74,9 @@ TEST(test_ADC, ADC_InitPortAPin0UsesCorrectRegisters)
//Set the ISC(input sense config) to disable digital input
//buffering and reduce the noise on ADC usage.
mock().expectOneCall("RegEdit_OR_Num")
.withPointerParameter("reg", (void *) &PORTA.PIN0CTRL)
.withUnsignedIntParameter("num", 0x4);
//check that the resolusion is selected
mock().expectOneCall("RegEdit_ClearBit")
.withPointerParameter("reg", (void *) &ADC0.CTRLA)
.withUnsignedIntParameter("bit_num", 2);
//check for the seleceted refernce voltage
//we leave the adc prescaler alone mostly.
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &ADC0.CTRLC)
.withUnsignedIntParameter("bit_num", 4);
.withPointerParameter("reg", (void *) &PORTA.PIN0CTRL)
.withUnsignedIntParameter("bit_num", PORT_ISC_INPUT_DISABLE_gc);
ADC_Init(0);
}