Compare commits
No commits in common. "ea7341d6c8a6cc71165d5bb3e115a7516d1c1339" and "73e99fc3b97bbb4a07f324f7275c4aef6d266d6e" have entirely different histories.
ea7341d6c8
...
73e99fc3b9
2 changed files with 2 additions and 21 deletions
|
|
@ -22,18 +22,6 @@
|
|||
#include "MockRegEdit.h"
|
||||
#endif
|
||||
|
||||
//These two arrays allow us to track the A and B ports to know when
|
||||
//one has been disabled before.
|
||||
static bool porta_disabled[8] = {0};
|
||||
static bool portb_disabled[8] = {0};
|
||||
|
||||
static bool valid_load(uint16_t val)
|
||||
{
|
||||
if(val > 527 && val < 1000) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Load_HandleLoadPortA(uint8_t adc_pin, uint8_t out_pin)
|
||||
|
|
@ -44,13 +32,12 @@ void Load_HandleLoadPortA(uint8_t adc_pin, uint8_t out_pin)
|
|||
uint16_t val = ADC_ReadValue(adc_pin);
|
||||
|
||||
ADC_Disable();
|
||||
if(valid_load(val) && !porta_disabled[adc_pin]){
|
||||
if(val > 527 && val < 1000){
|
||||
RegEdit_SetBit((void *) &PORTA.DIR, out_pin);
|
||||
RegEdit_SetBit((void *) &PORTA.OUT, out_pin);
|
||||
}
|
||||
else{
|
||||
RegEdit_ClearBit((void *) &PORTA.OUT, out_pin);
|
||||
porta_disabled[adc_pin] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -62,12 +49,11 @@ void Load_HandleLoadPortB(uint8_t adc_pin, uint8_t out_pin)
|
|||
uint16_t val = ADC_ReadValue(adc_pin);
|
||||
|
||||
ADC_Disable();
|
||||
if(valid_load(val) && !portb_disabled[adc_pin]){
|
||||
if(val > 527 && val < 1000){
|
||||
RegEdit_SetBit((void *) &PORTB.DIR, out_pin);
|
||||
RegEdit_SetBit((void *) &PORTB.OUT, out_pin);
|
||||
}
|
||||
else{
|
||||
RegEdit_ClearBit((void *) &PORTB.OUT, out_pin);
|
||||
portb_disabled[adc_pin] = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,15 +47,10 @@ TEST(test_load, PortAHandlerSuccess)
|
|||
mock().expectOneCall("ADC_Enable");
|
||||
mock().expectOneCall("ADC_ReadValue_Impl")
|
||||
.withUnsignedIntParameter("pin_num", 4);
|
||||
|
||||
mock().expectOneCall("ADC_Disable");
|
||||
|
||||
mock().expectOneCall("RegEdit_ClearBit")
|
||||
.withPointerParameter("reg", (void *) &PORTA.OUT)
|
||||
.withUnsignedIntParameter("bit_num", 7);
|
||||
|
||||
Load_HandleLoadPortA(4, 7);
|
||||
}
|
||||
|
||||
|
||||
//Need to setup a one-shot or way for it to only enable once.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue