Thread 中讨论的其他器件:SysConfig
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好、Asutosh、
确保在 SysConfig 中创建新的 ADC 实例并调用 ADC_init。 您可以按照 TI 驱动程序运行时 API 和 TI 驱动程序示例进行 进一步参考。
此致、
Ryan
我看到过它、它运行良好。
#include
#include
/* POSIX 头文件*/
#include
/*驱动程序头文件*/
#include
#include
/*驱动程序配置*/
#include "ti_drivers_config.h"
/* ADC 采样数*/
#define ADC_SAMPLE_COUNT (10)
#define THREADSTACKSIZE (768)
/* ADC 转换结果变量*/
uint16_t adcValue0;
uint32_t adcValue0MicroVolt;
uint16_t adcValue1[ADC_SAMPLE_COUNT];
uint32_t adcValue1MicroVol[ADC_SAMPLE_COUNT];
静态 Display_Handle 显示;
/*
*==== threadFxn0 ====
*打开 ADC 实例并从单次转换中获取采样结果。
*
void *线程 Fxn0 (void * arg0)
{
ADC_Handle ADC;
ADC_Params 参数;
int_fast16_t res;
ADC_PARAMS_INIT (params);
ADC = ADC_open (CONFIG_ADC_0、params);
if (ADC == NULL){
Display_printf (display、0、0、"Error initializing CONFIG_ADC_0\n");
while (1);
}
/*阻塞模式转换*/
RES = ADC_convert (ADC、&adcValue0);
if (res == ADC_STATUS_SUCCESS){
adcValue0MicroVolt = adc_convertRawToMicroVolts (adc、adcValue0);
display_printf (display、0、0、"CONFIG_ADC_0原始结果:%d\n"、adcValue0);
Display_printf (display、0、0、"CONFIG_ADC_0转换结果:%d uV\n"、
adcValue0MicroVolt);
}
否则{
display_printf (display、0、0、"CONFIG_ADC_0 convert failed\n");
}
ADC_Close (ADC);
返回(空);
}
/*
*==== mainThread ====
*
void * mainThread (void * arg0)
{
pthread_t thread0;
pthread_attr_t atttrs;
struct sched_param primParam;
int retc;
int detachState;
/*调用驱动程序初始化函数*/
adc_init();
display_init();
/*打开输出的显示屏*/
Display = Display_open (Display_Type_UART、NULL);
if (display =NULL){
/*无法打开显示驱动程序*/
while (1);
}
display_printf (display、0、0、"启动 acdsinglechChannel 示例\n");
/*创建应用程序线程*/
pthread_attr_init (atttrs);
detachState = pthread_create_detached;
/*设置优先级和堆栈大小属性*/
retc = pthread_attr_setdetachstate (&attrs、detachState);
如果(retc!= 0){
/* pthread_attr_setdetachstate()失败*/
while (1);
}
retc |= pthread_attr_setstacksize (&attrs、THREADSTACKSIZE);
如果(retc!= 0){
/* pthread_attr_setstacksize()失败*/
while (1);
}
/*创建 threadFxn0线程*/
priParam.sched_priority = 1;
pthread_attr_setschedparam (&attrs、&priParam);
retc = pthread_create (&thread0、&attrs、threadFxn0、NULL);
如果(retc!= 0){
/* pthread_create()失败*/
while (1);
}
返回(空);
}
您好、 Ryan、
感谢您的最佳支持。
我在另 一个线程中资助的相同问题、通过相同的解决方案解决。
再次感谢 Ryan 和 TI 团队。
此致、
Ashutosh Singh。