浏览代码

Fix analogReadAveraging with ADC1

teensy4-core
PaulStoffregen 7 年前
父节点
当前提交
392c93cb87
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. +12
    -0
      teensy3/analog.c

+ 12
- 0
teensy3/analog.c 查看文件

@@ -347,15 +347,27 @@ void analogReadAveraging(unsigned int num)
} else if (num <= 4) {
num = 4;
ADC0_SC3 = ADC_SC3_AVGE + ADC_SC3_AVGS(0);
#ifdef HAS_KINETIS_ADC1
ADC1_SC3 = ADC_SC3_AVGE + ADC_SC3_AVGS(0);
#endif
} else if (num <= 8) {
num = 8;
ADC0_SC3 = ADC_SC3_AVGE + ADC_SC3_AVGS(1);
#ifdef HAS_KINETIS_ADC1
ADC1_SC3 = ADC_SC3_AVGE + ADC_SC3_AVGS(1);
#endif
} else if (num <= 16) {
num = 16;
ADC0_SC3 = ADC_SC3_AVGE + ADC_SC3_AVGS(2);
#ifdef HAS_KINETIS_ADC1
ADC1_SC3 = ADC_SC3_AVGE + ADC_SC3_AVGS(2);
#endif
} else {
num = 32;
ADC0_SC3 = ADC_SC3_AVGE + ADC_SC3_AVGS(3);
#ifdef HAS_KINETIS_ADC1
ADC1_SC3 = ADC_SC3_AVGE + ADC_SC3_AVGS(3);
#endif
}
analog_num_average = num;
}

正在加载...
取消
保存