File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -545,11 +545,15 @@ void analogReference(uint8_t mode) {
545545 ctrl = ADC_VREF_CONTROL_AVCC0_AVSS0; break ;
546546 }
547547
548- R_ADC_Close (&adc.ctrl );
548+ if (adc.ctrl .opened ) {
549+ R_ADC_Close (&adc.ctrl );
550+ }
549551 adc.cfg_extend .adc_vref_control = ctrl;
550552 R_ADC_Open (&adc.ctrl , &adc.cfg );
551553
552- R_ADC_Close (&adc1.ctrl );
554+ if (adc1.ctrl .opened ) {
555+ R_ADC_Close (&adc1.ctrl );
556+ }
553557 adc1.cfg_extend .adc_vref_control = ctrl;
554558 R_ADC_Open (&adc1.ctrl , &adc1.cfg );
555559}
@@ -638,13 +642,17 @@ void analogReadResolution(int bits) {
638642 break ;
639643 }
640644
641- R_ADC_Close (&adc.ctrl );
645+ if (adc.ctrl .opened ) {
646+ R_ADC_Close (&adc.ctrl );
647+ }
642648 auto res = R_ADC_Open (&adc.ctrl , &adc.cfg );
643649 if (res != FSP_SUCCESS) {
644650 adc.cfg .resolution = old_read_resolution;
645651 }
646652
647- R_ADC_Close (&adc1.ctrl );
653+ if (adc1.ctrl .opened ) {
654+ R_ADC_Close (&adc1.ctrl );
655+ }
648656 res = R_ADC_Open (&adc1.ctrl , &adc1.cfg );
649657 if (res != FSP_SUCCESS) {
650658 adc1.cfg .resolution = old1_read_resolution;
You can’t perform that action at this time.
0 commit comments