增加触发机制,待调试
This commit is contained in:
parent
d95123fe48
commit
d04f31f543
File diff suppressed because it is too large
Load Diff
|
@ -106,8 +106,8 @@
|
||||||
<MDIClientArea>
|
<MDIClientArea>
|
||||||
<RegID>0</RegID>
|
<RegID>0</RegID>
|
||||||
<MDITabState>
|
<MDITabState>
|
||||||
<Len>502</Len>
|
<Len>589</Len>
|
||||||
<Data>01000000040000000100000001000000010000000100000000000000020000000000000001000000010000000000000028000000280000000100000005000000010000000100000024453A5C7A6D5C656D6265645C6F7363696C6C6F73636F70655C557365725C6D61696E2E6300000000066D61696E2E6300000000C5D4F200FFFFFFFF27453A5C7A6D5C656D6265645C6F7363696C6C6F73636F70655C557365725C4F53435C4F53432E6300000000054F53432E6300000000FFDC7800FFFFFFFF27453A5C7A6D5C656D6265645C6F7363696C6C6F73636F70655C557365725C4F53435C4F53432E6800000000054F53432E6800000000BECEA100FFFFFFFF2C453A5C7A6D5C656D6265645C6F7363696C6C6F73636F70655C557365725C73746D3332663130785F69742E63000000000E73746D3332663130785F69742E6300000000F0A0A100FFFFFFFF2B453A5C7A6D5C656D6265645C6F7363696C6C6F73636F70655C557365725C6164635C6273705F6164632E6300000000096273705F6164632E6300000000BCA8E100FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD500010000000000000002000000F3000000660000008007000016030000</Data>
|
<Data>01000000040000000100000001000000010000000100000000000000020000000000000001000000010000000000000028000000280000000100000006000000010000000100000026453A5C7A6D5C656D62656465645C6F7363696C6C6F73636F70655C557365725C6D61696E2E6300000000066D61696E2E6300000000C5D4F200FFFFFFFF29453A5C7A6D5C656D62656465645C6F7363696C6C6F73636F70655C557365725C4F53435C4F53432E6300000000054F53432E6300000000FFDC7800FFFFFFFF29453A5C7A6D5C656D62656465645C6F7363696C6C6F73636F70655C557365725C4F53435C4F53432E6800000000054F53432E6800000000BCA8E100FFFFFFFF2D453A5C7A6D5C656D62656465645C6F7363696C6C6F73636F70655C557365725C6164635C6273705F6164632E6300000000096273705F6164632E6300000000F0A0A100FFFFFFFF2D453A5C7A6D5C656D62656465645C6F7363696C6C6F73636F70655C557365725C6164635C6273705F6164632E6800000000096273705F6164632E6800000000BCA8E100FFFFFFFF36453A5C7A6D5C656D62656465645C6F7363696C6C6F73636F70655C4C69627261726965735C434D5349535C73746D3332663130782E68000000000B73746D3332663130782E68000000009CC1B600FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD500010000000000000002000000F3000000660000008007000016030000</Data>
|
||||||
</MDITabState>
|
</MDITabState>
|
||||||
</MDIClientArea>
|
</MDIClientArea>
|
||||||
<ViewEx>
|
<ViewEx>
|
||||||
|
@ -1871,35 +1871,44 @@
|
||||||
<Doc>
|
<Doc>
|
||||||
<Name>..\User\OSC\OSC.c</Name>
|
<Name>..\User\OSC\OSC.c</Name>
|
||||||
<ColumnNumber>0</ColumnNumber>
|
<ColumnNumber>0</ColumnNumber>
|
||||||
<TopLine>255</TopLine>
|
<TopLine>28</TopLine>
|
||||||
<CurrentLine>263</CurrentLine>
|
<CurrentLine>42</CurrentLine>
|
||||||
<Folding>1</Folding>
|
<Folding>1</Folding>
|
||||||
<ContractedFolders></ContractedFolders>
|
<ContractedFolders></ContractedFolders>
|
||||||
<PaneID>0</PaneID>
|
<PaneID>0</PaneID>
|
||||||
</Doc>
|
</Doc>
|
||||||
<Doc>
|
<Doc>
|
||||||
<Name>..\User\OSC\OSC.h</Name>
|
<Name>..\User\OSC\OSC.h</Name>
|
||||||
<ColumnNumber>50</ColumnNumber>
|
<ColumnNumber>4</ColumnNumber>
|
||||||
<TopLine>1</TopLine>
|
<TopLine>1</TopLine>
|
||||||
<CurrentLine>21</CurrentLine>
|
<CurrentLine>11</CurrentLine>
|
||||||
<Folding>1</Folding>
|
|
||||||
<ContractedFolders></ContractedFolders>
|
|
||||||
<PaneID>0</PaneID>
|
|
||||||
</Doc>
|
|
||||||
<Doc>
|
|
||||||
<Name>..\User\stm32f10x_it.c</Name>
|
|
||||||
<ColumnNumber>50</ColumnNumber>
|
|
||||||
<TopLine>70</TopLine>
|
|
||||||
<CurrentLine>96</CurrentLine>
|
|
||||||
<Folding>1</Folding>
|
<Folding>1</Folding>
|
||||||
<ContractedFolders></ContractedFolders>
|
<ContractedFolders></ContractedFolders>
|
||||||
<PaneID>0</PaneID>
|
<PaneID>0</PaneID>
|
||||||
</Doc>
|
</Doc>
|
||||||
<Doc>
|
<Doc>
|
||||||
<Name>..\User\adc\bsp_adc.c</Name>
|
<Name>..\User\adc\bsp_adc.c</Name>
|
||||||
<ColumnNumber>0</ColumnNumber>
|
<ColumnNumber>32</ColumnNumber>
|
||||||
<TopLine>160</TopLine>
|
<TopLine>154</TopLine>
|
||||||
<CurrentLine>191</CurrentLine>
|
<CurrentLine>181</CurrentLine>
|
||||||
|
<Folding>1</Folding>
|
||||||
|
<ContractedFolders></ContractedFolders>
|
||||||
|
<PaneID>0</PaneID>
|
||||||
|
</Doc>
|
||||||
|
<Doc>
|
||||||
|
<Name>..\User\adc\bsp_adc.h</Name>
|
||||||
|
<ColumnNumber>13</ColumnNumber>
|
||||||
|
<TopLine>15</TopLine>
|
||||||
|
<CurrentLine>47</CurrentLine>
|
||||||
|
<Folding>1</Folding>
|
||||||
|
<ContractedFolders></ContractedFolders>
|
||||||
|
<PaneID>0</PaneID>
|
||||||
|
</Doc>
|
||||||
|
<Doc>
|
||||||
|
<Name>..\Libraries\CMSIS\stm32f10x.h</Name>
|
||||||
|
<ColumnNumber>44</ColumnNumber>
|
||||||
|
<TopLine>506</TopLine>
|
||||||
|
<CurrentLine>519</CurrentLine>
|
||||||
<Folding>1</Folding>
|
<Folding>1</Folding>
|
||||||
<ContractedFolders></ContractedFolders>
|
<ContractedFolders></ContractedFolders>
|
||||||
<PaneID>0</PaneID>
|
<PaneID>0</PaneID>
|
||||||
|
|
|
@ -671,7 +671,7 @@
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>DOC</GroupName>
|
<GroupName>DOC</GroupName>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<TargetCommonOption>
|
<TargetCommonOption>
|
||||||
<Device>STM32F103VE</Device>
|
<Device>STM32F103VE</Device>
|
||||||
<Vendor>STMicroelectronics</Vendor>
|
<Vendor>STMicroelectronics</Vendor>
|
||||||
<PackID>Keil.STM32F1xx_DFP.2.0.0</PackID>
|
<PackID>Keil.STM32F1xx_DFP.2.1.0</PackID>
|
||||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||||
<Cpu>IRAM(0x20000000,0x10000) IROM(0x08000000,0x80000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
|
<Cpu>IRAM(0x20000000,0x10000) IROM(0x08000000,0x80000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
|
||||||
<FlashUtilSpec></FlashUtilSpec>
|
<FlashUtilSpec></FlashUtilSpec>
|
||||||
|
|
|
@ -23,10 +23,10 @@ rt_mq_t getwave_status_queue = RT_NULL;//
|
||||||
rt_mq_t key_scan_queue = RT_NULL;//键盘扫描开始标志
|
rt_mq_t key_scan_queue = RT_NULL;//键盘扫描开始标志
|
||||||
|
|
||||||
/* 定义线程控制块 */
|
/* 定义线程控制块 */
|
||||||
static rt_thread_t Setting_thread = RT_NULL;
|
rt_thread_t Setting_thread = RT_NULL;
|
||||||
static rt_thread_t GetWave_thread = RT_NULL;
|
rt_thread_t GetWave_thread = RT_NULL;
|
||||||
static rt_thread_t PlotWave_thread = RT_NULL;
|
rt_thread_t PlotWave_thread = RT_NULL;
|
||||||
static rt_thread_t KeyScan_thread = RT_NULL;
|
rt_thread_t KeyScan_thread = RT_NULL;
|
||||||
|
|
||||||
|
|
||||||
uint16_t TimePerDiv_Group[] = {2, 5, 10, 20, 50, 100, 200, 500};
|
uint16_t TimePerDiv_Group[] = {2, 5, 10, 20, 50, 100, 200, 500};
|
||||||
|
@ -35,13 +35,14 @@ int8_t TimePerDivOder = 0;//
|
||||||
|
|
||||||
//可设置项
|
//可设置项
|
||||||
int8_t TriggerValue = 0; //代号0,触发阀值
|
int8_t TriggerValue = 0; //代号0,触发阀值
|
||||||
int8_t TriggerType = 0; //代号1,触发类型,0:自动,1:单次,2:普通
|
int8_t RangeMode = 0; //代号1,量程模式,0:自动,1:手动
|
||||||
int8_t TriggerMode = 0; //代号2,触发模式,0:下降沿触发,1:上升沿触发
|
int8_t TriggerMode = 0; //代号2,触发模式,0:下降沿触发,1:上升沿触发,2:上升沿下降沿触发
|
||||||
int8_t SamplingMode = 0; //代号3,采样模式,0:自动,1:普通,2:单次
|
int8_t SamplingMode = 0; //代号3,采样模式,0:自动,1:普通,2:单次
|
||||||
uint16_t TimePerDiv = 1; //代号4,每格代表的时间间隔
|
uint16_t TimePerDiv = 1; //代号4,每格代表的时间间隔
|
||||||
|
|
||||||
//要显示的信息
|
//要显示的信息
|
||||||
__IO uint16_t ADC_ConvertedValue[ADCx_1_SampleNbr] = {0};//ADC采集数据
|
__IO uint16_t ADC_ConvertedValue[ADCx_1_SampleNbr] = {0};//ADC采集数据
|
||||||
|
FlagStatus StopSample = RESET;//停止采样标志
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,11 +68,11 @@ static void Setting_do(uint8_t CurSetItem, int8_t Operation)
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
TriggerType += Operation;
|
RangeMode += Operation;
|
||||||
if(TriggerType < 0)
|
if(RangeMode < 0)
|
||||||
TriggerType = 0;
|
RangeMode = 0;
|
||||||
if(TriggerType > 2)
|
if(RangeMode > 1)
|
||||||
TriggerType = 2;
|
RangeMode = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -79,8 +80,8 @@ static void Setting_do(uint8_t CurSetItem, int8_t Operation)
|
||||||
TriggerMode += Operation;
|
TriggerMode += Operation;
|
||||||
if(TriggerMode < 0)
|
if(TriggerMode < 0)
|
||||||
TriggerMode = 0;
|
TriggerMode = 0;
|
||||||
if(TriggerMode > 1)
|
if(TriggerMode > 2)
|
||||||
TriggerMode = 1;
|
TriggerMode = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -106,7 +107,7 @@ static void Setting_do(uint8_t CurSetItem, int8_t Operation)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rt_kprintf("TriggerValue: %d\n",TriggerValue);
|
rt_kprintf("TriggerValue: %d\n",TriggerValue);
|
||||||
rt_kprintf("TriggerType: %d\n",TriggerType);
|
rt_kprintf("RangeMode: %d\n",RangeMode);
|
||||||
rt_kprintf("TriggerMode: %d\n",TriggerMode);
|
rt_kprintf("TriggerMode: %d\n",TriggerMode);
|
||||||
rt_kprintf("Sampling_mode: %d\n",SamplingMode);
|
rt_kprintf("Sampling_mode: %d\n",SamplingMode);
|
||||||
rt_kprintf("TimePerDiv: %d\n",TimePerDiv);
|
rt_kprintf("TimePerDiv: %d\n",TimePerDiv);
|
||||||
|
@ -125,7 +126,7 @@ void Setting_Inf_Update(uint8_t CurSetItem)
|
||||||
sprintf(dispBuff,"TV: %d", TriggerValue);
|
sprintf(dispBuff,"TV: %d", TriggerValue);
|
||||||
ILI9341_DispString_EN(230, (((sFONT *)LCD_GetFont())->Height)*0, dispBuff);
|
ILI9341_DispString_EN(230, (((sFONT *)LCD_GetFont())->Height)*0, dispBuff);
|
||||||
|
|
||||||
sprintf(dispBuff,"TT: %d", TriggerType);
|
sprintf(dispBuff,"RD: %d", RangeMode);
|
||||||
ILI9341_DispString_EN(230, (((sFONT *)LCD_GetFont())->Height)*1, dispBuff);
|
ILI9341_DispString_EN(230, (((sFONT *)LCD_GetFont())->Height)*1, dispBuff);
|
||||||
|
|
||||||
sprintf(dispBuff,"TM: %d", TriggerMode);
|
sprintf(dispBuff,"TM: %d", TriggerMode);
|
||||||
|
@ -307,7 +308,7 @@ void Run(void)
|
||||||
|
|
||||||
GetWave_thread = /* 线程控制块指针 */
|
GetWave_thread = /* 线程控制块指针 */
|
||||||
rt_thread_create( "GetWave", /* 线程名字 */
|
rt_thread_create( "GetWave", /* 线程名字 */
|
||||||
Get_Wave_Data, /* 线程入口函数 */
|
Get_Wave, /* 线程入口函数 */
|
||||||
RT_NULL, /* 线程入口函数参数 */
|
RT_NULL, /* 线程入口函数参数 */
|
||||||
512, /* 线程栈大小 */
|
512, /* 线程栈大小 */
|
||||||
3, /* 线程的优先级 */
|
3, /* 线程的优先级 */
|
||||||
|
|
|
@ -8,9 +8,12 @@
|
||||||
extern rt_mq_t setting_data_queue;
|
extern rt_mq_t setting_data_queue;
|
||||||
extern rt_mq_t getwave_status_queue;
|
extern rt_mq_t getwave_status_queue;
|
||||||
|
|
||||||
|
//线程
|
||||||
|
extern rt_thread_t GetWave_thread;
|
||||||
|
|
||||||
//可设置项
|
//可设置项
|
||||||
extern uint16_t TimePerDiv;//每格代表的时间间隔
|
extern uint16_t TimePerDiv;//每格代表的时间间隔
|
||||||
extern int8_t TriggerType;
|
extern int8_t RangeMode;//量程模式,0:自动,1:手动
|
||||||
extern int8_t TriggerMode;//触发模式,0:下降沿触发,1:上升沿触发
|
extern int8_t TriggerMode;//触发模式,0:下降沿触发,1:上升沿触发
|
||||||
extern int8_t TriggerValue;//触发阀值
|
extern int8_t TriggerValue;//触发阀值
|
||||||
extern int8_t SamplingMode;//采样模式,0:自动,1:普通,2:单次
|
extern int8_t SamplingMode;//采样模式,0:自动,1:普通,2:单次
|
||||||
|
@ -21,7 +24,7 @@ extern __IO uint16_t ADC_ConvertedValue[];//ADC
|
||||||
extern uint16_t TimePerDiv_Group[];
|
extern uint16_t TimePerDiv_Group[];
|
||||||
extern uint8_t TimePerDivOderNbr;
|
extern uint8_t TimePerDivOderNbr;
|
||||||
extern int8_t TimePerDivOder;//当前每格间隔时间的序号
|
extern int8_t TimePerDivOder;//当前每格间隔时间的序号
|
||||||
|
extern FlagStatus StopSample;//停止采样标志
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,10 @@ FlagStatus Get_Trigger_Status(void)
|
||||||
{
|
{
|
||||||
uint16_t d0, d1;
|
uint16_t d0, d1;
|
||||||
|
|
||||||
|
if(SamplingMode == 0)
|
||||||
|
return SET;
|
||||||
|
else if((SamplingMode == 1) || (SamplingMode == 2))
|
||||||
|
{
|
||||||
while(ADC_GetITStatus(ADCx_1, ADC_IT_EOC) == RESET);
|
while(ADC_GetITStatus(ADCx_1, ADC_IT_EOC) == RESET);
|
||||||
d0 = ADC_GetConversionValue(ADCx_1);
|
d0 = ADC_GetConversionValue(ADCx_1);
|
||||||
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
|
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
|
||||||
|
@ -137,42 +141,46 @@ FlagStatus Get_Trigger_Status(void)
|
||||||
d1 = ADC_GetConversionValue(ADCx_1);
|
d1 = ADC_GetConversionValue(ADCx_1);
|
||||||
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
|
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
|
||||||
|
|
||||||
if(TriggerMode == 1)
|
if(TriggerMode == 0)
|
||||||
{
|
{
|
||||||
if(d1 - d0 > TriggerValue)
|
if((d0 - d1 > 0) && (d1 == TriggerValue))//应该可能大概需要改成区间判断,先这样吧
|
||||||
return SET;
|
return SET;
|
||||||
}
|
}
|
||||||
else if(TriggerMode == 0)
|
else if(TriggerMode == 1)
|
||||||
{
|
{
|
||||||
if(d0 - d1 > TriggerValue)
|
if((d1 - d0 > 0) && (d1 == TriggerValue))
|
||||||
return SET;
|
return SET;
|
||||||
}
|
}
|
||||||
|
else if(TriggerMode == 2)
|
||||||
|
{
|
||||||
|
if(d1 == TriggerValue)
|
||||||
|
return SET;
|
||||||
|
}
|
||||||
|
}
|
||||||
return RESET;
|
return RESET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Get_Wave_Data(void* parameter)
|
|
||||||
|
void Get_Wave(void* parameter)
|
||||||
{
|
{
|
||||||
uint16_t ADC_SampleCount = 0;
|
|
||||||
uint8_t flag = 1;//波形数据采集完成标志位
|
uint8_t flag = 1;//波形数据采集完成标志位
|
||||||
|
uint16_t ADC_SampleCount = 0;
|
||||||
|
|
||||||
while(1)
|
while(ADC_GetITStatus(ADCx_1, ADC_IT_EOC) != SET);
|
||||||
{
|
|
||||||
ADC_SampleCount=0;
|
|
||||||
if(SamplingMode == 1)//普通采样模式需判断触发条件,SamplingMode=0为自动采样模式,不需要判断触发条件
|
|
||||||
while(Get_Trigger_Status() == RESET);
|
|
||||||
|
|
||||||
while(ADC_SampleCount < ADCx_1_SampleNbr)
|
while(ADC_SampleCount < ADCx_1_SampleNbr)
|
||||||
{
|
{
|
||||||
while(ADC_GetITStatus(ADCx_1, ADC_IT_EOC) != SET);
|
|
||||||
ADC_ConvertedValue[ADC_SampleCount] = ADC_GetConversionValue(ADCx_1);
|
ADC_ConvertedValue[ADC_SampleCount] = ADC_GetConversionValue(ADCx_1);
|
||||||
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
|
ADC_ClearITPendingBit(ADCx_1, ADC_IT_EOC);
|
||||||
Delay_us( TimePerDiv*1000/50 -7 );//采样间隔时间
|
Delay_us( TimePerDiv*1000/50 -7 );//采样间隔时间
|
||||||
ADC_SampleCount++;
|
ADC_SampleCount++;
|
||||||
}
|
}
|
||||||
rt_mq_send(getwave_status_queue, &flag, sizeof(flag));
|
if(SamplingMode == 2)
|
||||||
while(SamplingMode != 2);//单次采样模式
|
{
|
||||||
|
StopSample = SET;
|
||||||
|
rt_thread_suspend(GetWave_thread);
|
||||||
}
|
}
|
||||||
|
rt_mq_send(getwave_status_queue, &flag, sizeof(flag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -201,3 +209,4 @@ uint16_t Get_Y_Data(void)
|
||||||
return YData;
|
return YData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
|
|
||||||
void ADCx_Init(void);
|
void ADCx_Init(void);
|
||||||
void Get_Wave_Data(void* parameter);
|
void Get_Wave(void* parameter);
|
||||||
uint16_t Get_X_Data(void);
|
uint16_t Get_X_Data(void);
|
||||||
uint16_t Get_Y_Data(void);
|
uint16_t Get_Y_Data(void);
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ void rt_hw_board_init()
|
||||||
sprintf(dispBuff,"TV: %d", TriggerValue);
|
sprintf(dispBuff,"TV: %d", TriggerValue);
|
||||||
ILI9341_DispString_EN(230, (((sFONT *)LCD_GetFont())->Height)*0, dispBuff);
|
ILI9341_DispString_EN(230, (((sFONT *)LCD_GetFont())->Height)*0, dispBuff);
|
||||||
|
|
||||||
sprintf(dispBuff,"TT: %d", TriggerType);
|
sprintf(dispBuff,"RD: %d", RangeMode);
|
||||||
ILI9341_DispString_EN(230, (((sFONT *)LCD_GetFont())->Height)*1, dispBuff);
|
ILI9341_DispString_EN(230, (((sFONT *)LCD_GetFont())->Height)*1, dispBuff);
|
||||||
|
|
||||||
sprintf(dispBuff,"TM: %d", TriggerMode);
|
sprintf(dispBuff,"TM: %d", TriggerMode);
|
||||||
|
|
Loading…
Reference in New Issue