updated `Load_HandleLoadPortA()` function to pass new tests.

This commit is contained in:
jakeg00dwin 2024-09-23 12:49:18 -07:00
parent 31e225bacf
commit e03a78a17b
1 changed files with 8 additions and 3 deletions

View File

@ -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;
}
}