fixed up ADC code + tests to make them pass
This commit is contained in:
parent
5f547dd844
commit
a92cdead2e
|
@ -47,17 +47,12 @@ void ADC_Init(uint8_t pin_num)
|
||||||
(void *) (&PORTA.PIN0CTRL)+pin_num,
|
(void *) (&PORTA.PIN0CTRL)+pin_num,
|
||||||
PORT_ISC_INPUT_DISABLE_gc
|
PORT_ISC_INPUT_DISABLE_gc
|
||||||
);
|
);
|
||||||
/*
|
|
||||||
RegEdit_OR_Num(
|
|
||||||
(void *) (&PORTA.PIN0CTRL)+pin_num,
|
|
||||||
PORT_ISC_INPUT_DISABLE_gc
|
|
||||||
);*/
|
|
||||||
|
|
||||||
//Ensure we use full 10bit resolution
|
//Ensure we use full 10bit resolution
|
||||||
RegEdit_ClearBit((void *) &ADC0.CTRLA, 2);
|
//RegEdit_ClearBit((void *) &ADC0.CTRLA, 2);
|
||||||
|
|
||||||
//Use VDD as our voltage refernce.
|
//Use VDD as our voltage refernce.
|
||||||
RegEdit_SetBit((void *) &ADC0.CTRLC, 4);
|
//RegEdit_SetBit((void *) &ADC0.CTRLC, 4);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,21 +52,10 @@ TEST(test_ADC, ADC_InitPortAPin7UsesCorrectRegisters)
|
||||||
|
|
||||||
//Set the ISC(input sense config) to disable digital input
|
//Set the ISC(input sense config) to disable digital input
|
||||||
//buffering and reduce the noise on ADC usage.
|
//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")
|
mock().expectOneCall("RegEdit_SetBit")
|
||||||
.withPointerParameter("reg", (void *) &ADC0.CTRLC)
|
.withPointerParameter("reg", (void *) &PORTA.PIN7CTRL)
|
||||||
.withUnsignedIntParameter("bit_num", 4);
|
.withUnsignedIntParameter("bit_num", PORT_ISC_INPUT_DISABLE_gc);
|
||||||
|
|
||||||
|
|
||||||
ADC_Init(7);
|
ADC_Init(7);
|
||||||
}
|
}
|
||||||
|
@ -85,20 +74,9 @@ TEST(test_ADC, ADC_InitPortAPin0UsesCorrectRegisters)
|
||||||
|
|
||||||
//Set the ISC(input sense config) to disable digital input
|
//Set the ISC(input sense config) to disable digital input
|
||||||
//buffering and reduce the noise on ADC usage.
|
//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")
|
mock().expectOneCall("RegEdit_SetBit")
|
||||||
.withPointerParameter("reg", (void *) &ADC0.CTRLC)
|
.withPointerParameter("reg", (void *) &PORTA.PIN0CTRL)
|
||||||
.withUnsignedIntParameter("bit_num", 4);
|
.withUnsignedIntParameter("bit_num", PORT_ISC_INPUT_DISABLE_gc);
|
||||||
|
|
||||||
ADC_Init(0);
|
ADC_Init(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue