updated `Load_HandleLoadPortA()` function to pass new tests.
This commit is contained in:
parent
31e225bacf
commit
e03a78a17b
|
@ -60,14 +60,19 @@ static uint16_t sample_adc(uint8_t adc_pin)
|
|||
void Load_HandleLoadPortA(uint8_t adc_pin, uint8_t out_pin)
|
||||
{
|
||||
uint16_t val = sample_adc(adc_pin);
|
||||
|
||||
if(is_valid_load(val) && !porta_disabled[adc_pin]){
|
||||
if(porta_disabled[adc_pin]){
|
||||
RegEdit_ClearBit((void *) &PORTA.OUT, out_pin);
|
||||
}
|
||||
else if(!is_valid_load(val)){
|
||||
RegEdit_ClearBit((void *) &PORTA.OUT, out_pin);
|
||||
porta_disabled[adc_pin] = true;
|
||||
}
|
||||
else if(is_below_target(val)){
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue