Added code and tests for tracking the setup() function usage
This commit is contained in:
parent
8a49ca42a7
commit
b41fe4a9fc
|
@ -13,10 +13,13 @@
|
||||||
uint16_t fake_data[FAKESIZE];
|
uint16_t fake_data[FAKESIZE];
|
||||||
int fake_index = 0;
|
int fake_index = 0;
|
||||||
|
|
||||||
|
static bool is_setup = false;
|
||||||
|
|
||||||
|
|
||||||
void ADC_Setup(void)
|
void ADC_Setup(void)
|
||||||
{
|
{
|
||||||
|
is_setup = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ADC_Init(uint8_t pin_num)
|
void ADC_Init(uint8_t pin_num)
|
||||||
|
@ -68,3 +71,9 @@ int MockADC_GetIndex(void)
|
||||||
{
|
{
|
||||||
return fake_index;
|
return fake_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool MockADC_IsSetup(void)
|
||||||
|
{
|
||||||
|
return is_setup;
|
||||||
|
}
|
||||||
|
|
|
@ -24,5 +24,6 @@ extern uint16_t (*ADC_ReadValue)(uint8_t pin_num);
|
||||||
void MockADC_PushValue(uint16_t value);
|
void MockADC_PushValue(uint16_t value);
|
||||||
void MockADC_ZeroIndex(void);
|
void MockADC_ZeroIndex(void);
|
||||||
int MockADC_GetIndex(void);
|
int MockADC_GetIndex(void);
|
||||||
|
bool MockADC_IsSetup(void);
|
||||||
|
|
||||||
#endif //MOCKADC_H
|
#endif //MOCKADC_H
|
||||||
|
|
|
@ -63,20 +63,11 @@ void ADC_Init(uint8_t pin_num)
|
||||||
//Disable input buffer
|
//Disable input buffer
|
||||||
//We do some kinda nasty address addition but it saves
|
//We do some kinda nasty address addition but it saves
|
||||||
//memory and means we don't need a switch statment.
|
//memory and means we don't need a switch statment.
|
||||||
//PORT_ISC_INPUT_DISABLE_gc
|
|
||||||
RegEdit_SetBit(
|
RegEdit_SetBit(
|
||||||
(void *) (&PORTA.PIN0CTRL)+pin_num,
|
(void *) (&PORTA.PIN0CTRL)+pin_num,
|
||||||
PORT_ISC_INPUT_DISABLE_gc
|
PORT_ISC_INPUT_DISABLE_gc
|
||||||
);
|
);
|
||||||
|
|
||||||
//Ensure we use full 10bit resolution
|
|
||||||
//RegEdit_ClearBit((void *) &ADC0.CTRLA, 2);
|
|
||||||
|
|
||||||
//Use VDD as our voltage refernce.
|
|
||||||
//RegEdit_SetBit((void *) &ADC0.CTRLC, 4);
|
|
||||||
|
|
||||||
//We setup the ADC to take 32 samples.
|
|
||||||
//RegEdit_OR_Num((void *) &ADC0.CTRLB, 0x5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -84,3 +84,12 @@ TEST(test_MockADC, MockADC_PushValueDoesntOverflowArray)
|
||||||
CHECK_TRUE(MockADC_GetIndex() <= 255);
|
CHECK_TRUE(MockADC_GetIndex() <= 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(test_MockADC, MockADC_SetupSetsGlobal)
|
||||||
|
{
|
||||||
|
CHECK_FALSE(MockADC_IsSetup());
|
||||||
|
|
||||||
|
ADC_Setup();
|
||||||
|
|
||||||
|
CHECK_TRUE(MockADC_IsSetup());
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue