Fixed Logic issues with the load.c file.
This commit is contained in:
parent
ac6b93b49e
commit
01e4c43481
|
@ -7,12 +7,12 @@
|
||||||
void Load_HandleLoadPortA(uint8_t adc_pin, uint8_t out_pin)
|
void Load_HandleLoadPortA(uint8_t adc_pin, uint8_t out_pin)
|
||||||
{
|
{
|
||||||
ADC_Init(adc_pin);
|
ADC_Init(adc_pin);
|
||||||
ADC_Enable(adc_pin);
|
ADC_Enable();
|
||||||
|
ADC_SetPin(adc_pin);
|
||||||
uint16_t val = ADC_ReadValue(adc_pin);
|
uint16_t val = ADC_ReadValue(adc_pin);
|
||||||
val = ADC_ReadValue(adc_pin);
|
|
||||||
|
|
||||||
ADC_Disable();
|
ADC_Disable();
|
||||||
if(val > 527 || val < 1000){
|
if(val > 527 && val < 1000){
|
||||||
RegEdit_SetBit((void *) &PORTA.DIR, out_pin);
|
RegEdit_SetBit((void *) &PORTA.DIR, out_pin);
|
||||||
RegEdit_SetBit((void *) &PORTA.OUT, out_pin);
|
RegEdit_SetBit((void *) &PORTA.OUT, out_pin);
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,12 @@ void Load_HandleLoadPortA(uint8_t adc_pin, uint8_t out_pin)
|
||||||
void Load_HandleLoadPortB(uint8_t adc_pin, uint8_t out_pin)
|
void Load_HandleLoadPortB(uint8_t adc_pin, uint8_t out_pin)
|
||||||
{
|
{
|
||||||
ADC_Init(adc_pin);
|
ADC_Init(adc_pin);
|
||||||
ADC_Enable(adc_pin);
|
ADC_Enable();
|
||||||
|
ADC_SetPin(adc_pin);
|
||||||
uint16_t val = ADC_ReadValue(adc_pin);
|
uint16_t val = ADC_ReadValue(adc_pin);
|
||||||
val = ADC_ReadValue(adc_pin);
|
|
||||||
|
|
||||||
ADC_Disable();
|
ADC_Disable();
|
||||||
if(val > 527 || val < 1000){
|
if(val > 527 && val < 1000){
|
||||||
RegEdit_SetBit((void *) &PORTB.DIR, out_pin);
|
RegEdit_SetBit((void *) &PORTB.DIR, out_pin);
|
||||||
RegEdit_SetBit((void *) &PORTB.OUT, out_pin);
|
RegEdit_SetBit((void *) &PORTB.OUT, out_pin);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue