shuchu
This commit is contained in:
@ -54,7 +54,7 @@ void Error_Handler(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
void change(int j);
|
||||
void data_shift(int j);
|
||||
void data_shift(int j,int k);
|
||||
void removeTopAndBottomN(uint16_t arr[], int n);
|
||||
uint16_t calculateMean(uint16_t *data, int size);
|
||||
|
||||
|
@ -97,9 +97,12 @@ int enc2;
|
||||
uint8_t buf[2900];
|
||||
uint8_t buf1[29]={0X0A,0X0A,0X0A,0X0A,0X0A,0X0A,0X0A,0X0A};
|
||||
int adc_array_size= 1520;
|
||||
int average_value=0;
|
||||
int average_value[100][400];
|
||||
int enc3[100][400];
|
||||
uint16_t adc_array[1520];
|
||||
uint16_t ev_co[1520];
|
||||
int measure_f=0;
|
||||
int track_array[400];
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
@ -156,7 +159,7 @@ int main(void)
|
||||
// USBD_Start(&hUsbDeviceHS);
|
||||
|
||||
// HAL_PCD_MspInit(&hpcd_USB_OTG_HS);
|
||||
int re_value=0;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -171,30 +174,46 @@ int main(void)
|
||||
/* USER CODE BEGIN 3 */
|
||||
|
||||
|
||||
|
||||
|
||||
for(int j=0;j<100;j++){
|
||||
|
||||
measure_f=0;
|
||||
enc1 = __HAL_TIM_GET_COUNTER(&htim2);//<2F><>ȡ<EFBFBD><C8A1>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ֵ
|
||||
if(enc0==6000)
|
||||
{
|
||||
enc0=enc1;
|
||||
}
|
||||
|
||||
enc2 = enc1;
|
||||
|
||||
while(abs(enc2-enc1)==0)
|
||||
|
||||
while(abs(enc2-enc1)==0)
|
||||
{
|
||||
average_value=adc_get_result(ADC_CHANNEL_11);
|
||||
enc2 = __HAL_TIM_GET_COUNTER(&htim2);//<2F><>ȡ<EFBFBD><C8A1>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ֵ
|
||||
data_shift(0);
|
||||
CDC_Transmit_HS(buf, 8);
|
||||
|
||||
average_value[j][measure_f]=adc_get_result(ADC_CHANNEL_11);
|
||||
enc3[j][measure_f] = __HAL_TIM_GET_COUNTER(&htim2);//<2F><>ȡ<EFBFBD><C8A1>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ֵ
|
||||
enc2=enc3[j][measure_f];
|
||||
measure_f++;
|
||||
if(measure_f>300)
|
||||
{
|
||||
measure_f=300;
|
||||
}
|
||||
|
||||
}
|
||||
if(enc2-enc0>1000)
|
||||
track_array[j]=measure_f;
|
||||
}
|
||||
for(int k=0;k<100;k++){
|
||||
for(int i=0;i<8*track_array[k];i+=8)
|
||||
{
|
||||
HAL_Delay(5000);
|
||||
HAL_Delay(5000);
|
||||
enc0=6000;
|
||||
CDC_Transmit_HS(buf1, 8);
|
||||
|
||||
data_shift(i,k);
|
||||
|
||||
}
|
||||
CDC_Transmit_HS(buf, 8*track_array[k]);
|
||||
}
|
||||
|
||||
|
||||
// if(enc2-enc0>1000)
|
||||
// {
|
||||
//// HAL_Delay(5000);
|
||||
//// HAL_Delay(5000);
|
||||
//// enc0=6000;
|
||||
//// CDC_Transmit_HS(buf1, 8);
|
||||
// }
|
||||
|
||||
}
|
||||
/* USER CODE END 3 */
|
||||
@ -287,16 +306,16 @@ void PeriphCommonClock_Config(void)
|
||||
|
||||
/* USER CODE BEGIN 4 */
|
||||
|
||||
void data_shift(int j)
|
||||
void data_shift(int j,int k)
|
||||
{
|
||||
buf[j] = (uint8_t)(average_value & 0xFF);
|
||||
buf[j+1] = (uint8_t)((average_value >> 8) & 0xFF);
|
||||
buf[j] = (uint8_t)(average_value[k][(j+1)/8] & 0xFF);
|
||||
buf[j+1] = (uint8_t)((average_value[k][(j+1)/8] >> 8) & 0xFF);
|
||||
buf[j+7] = 0xFF;
|
||||
buf[j+6] = 0x0D;
|
||||
buf[j+2] = (uint8_t)(enc2 & 0xFF);
|
||||
buf[j+3] = (uint8_t)((enc2 >> 8) & 0xFF);
|
||||
buf[j+4] = (uint8_t)((enc2 >> 16) & 0xFF);
|
||||
buf[j+5] = (uint8_t)((enc2 >> 24) & 0xFF);
|
||||
buf[j+2] = (uint8_t)(enc3[k][(j+1)/8] & 0xFF);
|
||||
buf[j+3] = (uint8_t)((enc3[k][(j+1)/8] >> 8) & 0xFF);
|
||||
buf[j+4] = (uint8_t)((enc3[k][(j+1)/8] >> 16) & 0xFF);
|
||||
buf[j+5] = (uint8_t)((enc3[k][(j+1)/8] >> 24) & 0xFF);
|
||||
|
||||
}
|
||||
void removeTopAndBottomN(uint16_t arr[], int n) {
|
||||
|
File diff suppressed because one or more lines are too long
@ -157,34 +157,130 @@
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>174</LineNumber>
|
||||
<LineNumber>189</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134257128</Address>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\USB_HS_PHY\../Core/Src/main.c\174</Expression>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>174</LineNumber>
|
||||
<LineNumber>190</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134257212</Address>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\\../Core/Src/main.c\174</Expression>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>2</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>195</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>3</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>193</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>4</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>188</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>5</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>191</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>6</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>192</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>7</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>194</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
@ -196,32 +292,17 @@
|
||||
<Ww>
|
||||
<count>1</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>k</ItemText>
|
||||
<ItemText>enc2,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>2</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>ev_co[ac]</ItemText>
|
||||
<ItemText>enc1,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>i</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>4</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>re_value</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>5</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>enc2,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>6</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>enc1,0x0A</ItemText>
|
||||
<ItemText>measure_f,0x0A</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<Tracepoint>
|
||||
|
Reference in New Issue
Block a user