diff --git a/src/ADC/ADC.c b/src/ADC/ADC.c index e0f558c..0893392 100644 --- a/src/ADC/ADC.c +++ b/src/ADC/ADC.c @@ -77,7 +77,7 @@ void ADC_Init(uint8_t adc_chan) { void ADC_Enable(void) { // Set the enable bit in the CTRLA register - // RegEdit_SetBit((void *)&ADC0.CTRLA, 0); + RegEdit_SetBit((void *)&ADCSRA, ADEN); } void ADC_Disable() { diff --git a/tests/ADC/test_ADC.cpp b/tests/ADC/test_ADC.cpp index 69ddd19..2308ed3 100644 --- a/tests/ADC/test_ADC.cpp +++ b/tests/ADC/test_ADC.cpp @@ -119,46 +119,18 @@ TEST(test_ADC, ADC_InitPortbWorksWithValidChannels) } } -TEST(test_ADC, ADC_InitPortAPin0UsesCorrectRegisters) -{ - /* - //Check for setting the direction to input. - mock().expectOneCall("RegEdit_ClearBit") - .withPointerParameter("reg", (void *) &PORTA.DIR) - .withUnsignedIntParameter("bit_num", 0); - - //Check that the pullup is off - mock().expectOneCall("RegEdit_ClearBit") - .withPointerParameter("reg", (void *) &PORTA.OUT) - .withUnsignedIntParameter("bit_num", 0); - - //Set the ISC(input sense config) to disable digital input - //buffering and reduce the noise on ADC usage. - mock().expectOneCall("RegEdit_SetBit") - .withPointerParameter("reg", (void *) &PORTA.PIN0CTRL) - .withUnsignedIntParameter("bit_num", PORT_ISC_INPUT_DISABLE_gc); - - */ - //ADC_Init(0); -} - -TEST(test_ADC, ADC_InitDoesNothingOnHighPinNumbers) -{ - //mock().expectNoCall("RegEdit_SetBit"); - //ADC_Init(8); -} TEST(test_ADC, ADC_EnablePasses) { - /* - mock().expectOneCall("RegEdit_SetBit") - .withPointerParameter("reg", (void *) &ADC0.CTRLA) - .withUnsignedIntParameter("bit_num", 0); - */ - //ADC_Enable(); + mock().expectOneCall("RegEdit_SetBit") + .withPointerParameter("reg", (void *) &ADCSRA) + .withUnsignedIntParameter("bit_num", ADEN); + + ADC_Enable(); } + TEST(test_ADC, ADC_DisablePasses) { /* @@ -169,6 +141,7 @@ TEST(test_ADC, ADC_DisablePasses) //ADC_Disable(); } + TEST(test_ADC, ADC_SetPinSetsRightRegisters) { /*