我想开启多个adc。
1、在不使用sce的情况下,必须建立多个线程任务,每个线程任务都开启一个adc任务?
2、那么在使用sce的情况下,也是开启多个任务?
3、使用多个adc的时候,我不想连续测试,又想功耗很低,需要采集的时候才采集,那么我应该用哪个好?
我下面写的程序可行吗?
#include "adc.h"#include <
ti/drivers/ADC.h>ADC_Params params;ADC_Handle adc23,adc24,adc25,adc26,adc27,adc28,adc29,adc30;void ADC_Init(void)[ ADC_init(); ADC_Params_init(¶ms);]uint16_t ADC23_Convert(void)[ int_fast16_t res = 0; uint16_t adcValue = 0; adc23 = ADC_open(CC1310_LAUNCHXL_ADC0, ¶ms); res = ADC_convert(adc23, &adcValue); ADC_close(adc23); if (res == ADC_STATUS_SUCCESS) [ if(adcValue < 1) adcValue=1;//避开0,这样就知道是不是转换成功了 return adcValue; ] else [ return 0; ]]uint16_t ADC24_Convert(void)[ int_fast16_t res = 0; uint16_t adcValue = 0; adc24 = ADC_open(CC1310_LAUNCHXL_ADC1, ¶ms); res = ADC_convert(adc24, &adcValue); ADC_close(adc24); if (res == ADC_STATUS_SUCCESS) [ if(adcValue < 1) adcValue=1;//避开0,这样就知道是不是转换成功了 return adcValue; ] else [ return 0; ]]uint16_t ADC25_Convert(void)[ int_fast16_t res = 0; uint16_t adcValue = 0; adc25 = ADC_open(CC1310_LAUNCHXL_ADC2, ¶ms); res = ADC_convert(adc25, &adcValue); ADC_close(adc25); if (res == ADC_STATUS_SUCCESS) [ if(adcValue < 1) adcValue=1;//避开0,这样就知道是不是转换成功了 return adcValue; ] else [ return 0; ]]uint16_t ADC26_Convert(void)[ int_fast16_t res = 0; uint16_t adcValue = 0; adc26 = ADC_open(CC1310_LAUNCHXL_ADC3, ¶ms); res = ADC_convert(adc26, &adcValue); ADC_close(adc26); if (res == ADC_STATUS_SUCCESS) [ if(adcValue < 1) adcValue=1;//避开0,这样就知道是不是转换成功了 return adcValue; ] else [ return 0; ]]uint16_t ADC27_Convert(void)[ int_fast16_t res = 0; uint16_t adcValue = 0; adc27 = ADC_open(CC1310_LAUNCHXL_ADC4, ¶ms); res = ADC_convert(adc27, &adcValue); ADC_close(adc27); if (res == ADC_STATUS_SUCCESS) [ if(adcValue < 1) adcValue=1;//避开0,这样就知道是不是转换成功了 return adcValue; ] else [ return 0; ]]uint16_t ADC28_Convert(void)[ int_fast16_t res = 0; uint16_t adcValue = 0; adc28 = ADC_open(CC1310_LAUNCHXL_ADC5, ¶ms); res = ADC_convert(adc28, &adcValue); ADC_close(adc28); if (res == ADC_STATUS_SUCCESS) [ if(adcValue < 1) adcValue=1;//避开0,这样就知道是不是转换成功了 return adcValue; ] else [ return 0; ]]uint16_t ADC29_Convert(void)[ int_fast16_t res = 0; uint16_t adcValue = 0; adc29 = ADC_open(CC1310_LAUNCHXL_ADC6, ¶ms); res = ADC_convert(adc29, &adcValue); ADC_close(adc29); if (res == ADC_STATUS_SUCCESS) [ if(adcValue < 1) adcValue=1;//避开0,这样就知道是不是转换成功了 return adcValue; ] else [ return 0; ]]uint16_t ADC30_Convert(void)[ int_fast16_t res = 0; uint16_t adcValue = 0; adc30 = ADC_open(CC1310_LAUNCHXL_ADC7, ¶ms); res = ADC_convert(adc30, &adcValue); ADC_close(adc30); if (res == ADC_STATUS_SUCCESS) [ if(adcValue < 1) adcValue=1;//避开0,这样就知道是不是转换成功了 return adcValue; ] else [ return 0; ]]
0