实现采样模式,待调试

This commit is contained in:
zhan-min 2020-10-30 22:00:03 +08:00
parent 36b0cf6772
commit b308d544ca
4 changed files with 1790 additions and 1783 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -34,9 +34,9 @@ uint8_t TimePerDivOderNbr = sizeof(TimePerDiv_Group)/sizeof(TimePerDiv_Group[0]
int8_t TimePerDivOder = 0;//当前每格间隔时间的序号
//可设置项
int8_t TriggerValue = 0; //代号0触发阀值
int8_t TriggerMode = 0; //代号1触发模式0下降沿触发1上升沿触发
int8_t SamplingMode = 0; //代号2采样模式0自动1普通2单次
int8_t TriggerValue = 0; //代号0触发阀值
int8_t TriggerMode = 0; //代号1触发模式0下降沿触发1上升沿触发
int8_t SamplingMode = 0; //代号2采样模式0自动1普通2单次
uint16_t TimePerDiv = 1; //代号3每格代表的时间间隔
//要显示的信息
@ -84,11 +84,12 @@ static void Setting_do(uint8_t CurSetItem, int8_t Operation)
}
case 3:
{
TimePerDiv += Operation;
TimePerDivOder += Operation;
if(TimePerDivOder < 0)
TimePerDivOder = 0;
if(TimePerDivOder > TimePerDivOderNbr-1)
TimePerDivOder = TimePerDivOderNbr-1;
TimePerDiv = TimePerDiv_Group[TimePerDivOder];
break;
}
default :
@ -97,7 +98,7 @@ static void Setting_do(uint8_t CurSetItem, int8_t Operation)
rt_kprintf("TriggerValue: %d\n",TriggerValue);
rt_kprintf("TriggerMode: %d\n",TriggerMode);
rt_kprintf("Sampling_mode: %d\n",SamplingMode);
rt_kprintf("TimePerDiv_Oder: %d\n",TimePerDivOder);
rt_kprintf("TimePerDiv: %d\n",TimePerDiv);
rt_kprintf("\n");
}
@ -119,7 +120,7 @@ void Setting_Inf_Update(uint8_t CurSetItem)
sprintf(dispBuff,"SamplingMode: %d", SamplingMode);
ILI9341_DispString_EN(210, (((sFONT *)LCD_GetFont())->Height)*2, dispBuff);
sprintf(dispBuff,"TimePerDiv: %d", TimePerDiv_Group[TimePerDivOder]);
sprintf(dispBuff,"TimePerDiv: %d", TimePerDiv);
ILI9341_DispString_EN(210, (((sFONT *)LCD_GetFont())->Height)*3, dispBuff);
}
@ -218,6 +219,8 @@ void Setting(void* parameter)
break;
}
}
else
break;
}
LED2_OFF;//退出设置状态
}
@ -274,9 +277,9 @@ void Run(void)
if (KeyScan_thread != RT_NULL)
rt_thread_startup(KeyScan_thread);
GetWave_thread = /* 线程控制块指针 */
rt_thread_create( "GetWave", /* 线程名字 */
Get_Wave_Data, /* 线程入口函数 */
GetWave_thread = /* 线程控制块指针 */
rt_thread_create( "GetWave", /* 线程名字 */
Get_Wave_Data, /* 线程入口函数 */
RT_NULL, /* 线程入口函数参数 */
512, /* 线程栈大小 */
3, /* 线程的优先级 */
@ -284,9 +287,9 @@ void Run(void)
if (GetWave_thread != RT_NULL)
rt_thread_startup(GetWave_thread);
PlotWave_thread = /* 线程控制块指针 */
rt_thread_create( "PlotWave", /* 线程名字 */
PlotWave, /* 线程入口函数 */
PlotWave_thread = /* 线程控制块指针 */
rt_thread_create( "PlotWave", /* 线程名字 */
PlotWave, /* 线程入口函数 */
RT_NULL, /* 线程入口函数参数 */
512, /* 线程栈大小 */
3, /* 线程的优先级 */

View File

@ -153,23 +153,25 @@ FlagStatus Get_Trigger_Status(void)
void Get_Wave_Data(void* parameter)
{
uint16_t ADC_SampleCount=0;
uint16_t ADC_SampleCount = 0;
uint8_t flag = 1;//波形数据采集完成标志位
while(1)
{
ADC_SampleCount=0;
while(Get_Trigger_Status() == RESET);
if(SamplingMode == 1)//普通采样模式需判断触发条件SamplingMode=0为自动采样模式不需要判断触发条件
while(Get_Trigger_Status() == RESET);
while(ADC_SampleCount < ADCx_1_SampleNbr)
{
while(ADC_GetITStatus(ADCx_1, ADC_IT_EOC) != SET);
ADC_ConvertedValue[ADC_SampleCount] = ADC_GetConversionValue(ADCx_1);
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
Delay_us( TimePerDiv*1000/50 -7 );
Delay_us( TimePerDiv*1000/50 -7 );//采样间隔时间
ADC_SampleCount++;
}
rt_mq_send(getwave_status_queue, &flag, sizeof(flag));
while(SamplingMode != 2);//单次采样模式
}
}