可以进行积分延时,可以使用任工的上位机进行数据展示
This commit is contained in:
@ -35,7 +35,7 @@ extern "C" {
|
||||
extern UART_HandleTypeDef huart1;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
#define USART_REC_LEN 200 /* 定义<EFBFBD><EFBFBD>?大接<E5A4A7><E68EA5>?200字节数据 */
|
||||
#define USART_REC_LEN 200 /* 定义最大接收200字节数据 */
|
||||
#define USART_EN_RX 1 /* 使能串口接收 */
|
||||
#define RXBUFFERSIZE 1 /* 缓存大小 */
|
||||
|
||||
@ -44,8 +44,8 @@ extern UART_HandleTypeDef huart1;
|
||||
void MX_USART1_UART_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
extern uint8_t g_usart_rx_buf[USART_REC_LEN]; /* 串口缓冲<EFBFBD><EFBFBD>? */
|
||||
extern uint16_t g_usart_rx_sta; /* 串口接收状<EFBFBD>?? */
|
||||
extern uint8_t g_usart_rx_buf[USART_REC_LEN]; /* 串口缓冲区 */
|
||||
extern uint16_t g_usart_rx_sta; /* 串口接收状态 */
|
||||
extern uint8_t g_rx_buffer[RXBUFFERSIZE]; /* HAL库USART接收Buffer */
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ static uint8_t temp[1040];
|
||||
static uint16_t temp16[512];
|
||||
static uint32_t temp16_2[512];
|
||||
|
||||
int Average_Number=50;
|
||||
int Average_Number=20;
|
||||
volatile int mul_int_max = 0;
|
||||
volatile int G_Clk_Rise_Number = 0;
|
||||
volatile int G_Hamamatsu_Trigger_Rise_Number_U8 = 0;
|
||||
@ -21,17 +21,19 @@ int thisneedtransfor=1;
|
||||
void DMA_Send(){
|
||||
if(G_Clk_Rise_Number>=2080)
|
||||
{
|
||||
__disable_irq();
|
||||
needreset1=1;
|
||||
}
|
||||
if(G_Hamamatsu_Trigger_Rise_Number>=512&&thisneedtransfor)
|
||||
{
|
||||
__disable_irq();
|
||||
thisneedtransfor=0;
|
||||
for(int i=0;i<512;i++)
|
||||
{
|
||||
temp16_2[i]+=adc_ans[i];
|
||||
temp16_2[i]+=adc_ans[i];//将采集到的16位数据放在temp16_2中
|
||||
}
|
||||
|
||||
if (index_count%Average_Number==0)
|
||||
if (index_count%Average_Number==0)//如果没有到达50次平均那就接着采集,达到50次之后再取平均值,dma发送
|
||||
{
|
||||
for(int i=0;i<512;i++)
|
||||
{
|
||||
@ -43,9 +45,13 @@ void DMA_Send(){
|
||||
/**** void *memcpy(void *dest, const void *src, size_t n); *****/
|
||||
memcpy(temp+2,temp16,1024);
|
||||
HAL_UART_Transmit_DMA(&huart1,temp,1026);
|
||||
|
||||
}
|
||||
needreset2=1;
|
||||
index_count++;
|
||||
__enable_irq();
|
||||
// RCCdelay_us(2);
|
||||
HAL_Delay(50);
|
||||
}
|
||||
if(mul_int>mul_int_max)
|
||||
{
|
||||
|
@ -5,5 +5,4 @@
|
||||
#include "Get_Parameters.h"
|
||||
float Get_Temperature(){
|
||||
return 1.00;
|
||||
|
||||
}
|
@ -4,8 +4,6 @@
|
||||
#include <stdbool.h>
|
||||
#include "usart.h"
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "cJSON_Test.h"
|
||||
#include "SerialDataProcess.h"
|
||||
#include "Communication_Protocol.h"
|
||||
|
@ -1,9 +1,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cJSON_Test.h"
|
||||
#include "string.h"
|
||||
#include "Store_Information.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdbool.h"
|
||||
struct paramstruct Parameters; //声明结构体对象
|
||||
extern bool Printf_Flag ;
|
||||
@ -14,7 +11,8 @@ void cjson(uint8_t g_usart_json_string[])
|
||||
cJSON *json = cJSON_Parse(json_string);
|
||||
if (json != NULL) {
|
||||
// 获取 JSON 对象中的值
|
||||
cJSON *temperature = cJSON_GetObjectItem(json, "temperature");// char * name 是结构体指针,通过name->valuestring访问结构体中成员的字符串
|
||||
cJSON *temperature = cJSON_GetObjectItem(json, "temperature");
|
||||
// char * name 是结构体指针,通过name->valuestring访问结构体中成员的字符串
|
||||
cJSON *pn = cJSON_GetObjectItem(json, "pn");
|
||||
cJSON *sn = cJSON_GetObjectItem(json, "sn");
|
||||
cJSON *production_date = cJSON_GetObjectItem(json, "production_date");
|
||||
@ -25,13 +23,13 @@ void cjson(uint8_t g_usart_json_string[])
|
||||
if (temperature != NULL && pn != NULL && sn != NULL&& production_date != NULL
|
||||
&& manufacturer != NULL&&Device_Pixel_Length!=NULL&&Set_Integration_Time!=NULL) {
|
||||
// 打印解析结果
|
||||
printf("Temperature: %d\n", temperature->valueint);
|
||||
printf("Pn:%d\n", pn ->valueint);
|
||||
printf("Sn:%d\n", sn ->valueint);
|
||||
printf("Production_date:%d\n", production_date ->valueint);
|
||||
printf("Manufacturer:%d\n", manufacturer ->valueint);
|
||||
printf("Device_Pixel_Length:%d\n", Device_Pixel_Length ->valueint);
|
||||
printf("Set_Integration_Time:%d\n", Set_Integration_Time ->valueint);
|
||||
// printf("Temperature: %d\n", temperature->valueint);
|
||||
// printf("Pn:%d\n", pn ->valueint);
|
||||
// printf("Sn:%d\n", sn ->valueint);
|
||||
// printf("Production_date:%d\n", production_date ->valueint);
|
||||
// printf("Manufacturer:%d\n", manufacturer ->valueint);
|
||||
// printf("Device_Pixel_Length:%d\n", Device_Pixel_Length ->valueint);
|
||||
// printf("Set_Integration_Time:%d\n", Set_Integration_Time ->valueint);
|
||||
|
||||
Parameters.sn = sn ->valueint;
|
||||
Parameters.pn = pn->valueint;
|
||||
|
@ -27,9 +27,7 @@
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "retarget.h"
|
||||
|
||||
#include "SerialDataProcess.h"
|
||||
#include "stdio.h" //<2F><>printf<74><66><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD>
|
||||
#include <stdint.h>
|
||||
#include "Judge.h"
|
||||
#include "cJSON_Test.h"
|
||||
@ -132,11 +130,19 @@ int main(void)
|
||||
while (1)
|
||||
{
|
||||
SerialDataProcess();
|
||||
if(Printf_Flag== true){
|
||||
if(Printf_Flag== true)
|
||||
{
|
||||
Judge();
|
||||
Printf_Flag = false;
|
||||
}
|
||||
DMA_Send();
|
||||
/*
|
||||
|
||||
|
||||
|
||||
55 AA 00 77 00 7B 22 74 65 6D 70 65 72 61 74 75 72 65 22 3A 31 2C 22 70 6E 22 3A 31 2C 22 73 6E 22 3A 31 2C 22 70 72 6F 64 75 63 74 69 6F 6E 5F 64 61 74 65 22 3A 31 2C 22 6D 61 6E 75 66 61 63 74 75 72 65 72 22 3A 31 2C 22 73 65 74 5F 69 6E 74 65 67 72 61 74 69 6F 6E 5F 74 69 6D 65 22 3A 37 2C 22 64 65 76 69 63 65 5F 70 69 78 65 6C 5F 6C 65 6E 67 74 68 22 3A 31 7D 98 CA
|
||||
|
||||
*/
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
|
@ -30,7 +30,7 @@ volatile int mul_int = 0;
|
||||
|
||||
|
||||
uint16_t adc_ans[540]={0};
|
||||
uint8_t adc_ans_u8[2080]={0};
|
||||
//uint8_t adc_ans_u8[2080]={0};
|
||||
/* USER CODE END 0 */
|
||||
|
||||
TIM_HandleTypeDef htim1;
|
||||
@ -510,9 +510,9 @@ void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
|
||||
{
|
||||
adc_ans[G_Hamamatsu_Trigger_Rise_Number]=0xea60;
|
||||
}
|
||||
adc_ans_u8[G_Hamamatsu_Trigger_Rise_Number_U8] = (uint8_t)(adc_ans[G_Hamamatsu_Trigger_Rise_Number] >> 8);//<2F><>8λ
|
||||
adc_ans_u8[G_Hamamatsu_Trigger_Rise_Number_U8+1]=(uint8_t)adc_ans[G_Hamamatsu_Trigger_Rise_Number];
|
||||
G_Hamamatsu_Trigger_Rise_Number_U8=G_Hamamatsu_Trigger_Rise_Number_U8+2;
|
||||
// adc_ans_u8[G_Hamamatsu_Trigger_Rise_Number_U8] = (uint8_t)(adc_ans[G_Hamamatsu_Trigger_Rise_Number] >> 8);//<2F><>8λ
|
||||
// adc_ans_u8[G_Hamamatsu_Trigger_Rise_Number_U8+1]=(uint8_t)adc_ans[G_Hamamatsu_Trigger_Rise_Number];
|
||||
// G_Hamamatsu_Trigger_Rise_Number_U8=G_Hamamatsu_Trigger_Rise_Number_U8+2;
|
||||
G_Hamamatsu_Trigger_Rise_Number++;
|
||||
}
|
||||
}
|
||||
|
@ -21,12 +21,12 @@
|
||||
#include "usart.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
/* 接收缓冲, <EFBFBD>?大USART_REC_LEN个字<EFBFBD>?. */
|
||||
/* 接收缓冲, 最大USART_REC_LEN个字节. */
|
||||
uint8_t g_usart_rx_buf[USART_REC_LEN];
|
||||
|
||||
/* 接收状<E694B6>??
|
||||
* bit15<31>? 接收完成标志
|
||||
* bit14<31>? 接收<EFBFBD>?0x0d
|
||||
* bit14<31>? 接收到0x0d
|
||||
* bit13~0<>? 接收到的有效字节数目
|
||||
*/
|
||||
uint16_t g_usart_rx_sta = 0;
|
||||
@ -52,7 +52,7 @@ void MX_USART1_UART_Init(void)
|
||||
|
||||
/* USER CODE END USART1_Init 1 */
|
||||
huart1.Instance = USART1;
|
||||
huart1.Init.BaudRate = 921600;
|
||||
huart1.Init.BaudRate = 115200;
|
||||
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart1.Init.StopBits = UART_STOPBITS_1;
|
||||
huart1.Init.Parity = UART_PARITY_NONE;
|
||||
@ -187,7 +187,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||||
{
|
||||
if(g_rx_buffer[0] != 0x0a)
|
||||
{
|
||||
g_usart_rx_sta = 0; /* 接收错误,重新<EFBFBD>?<3F>? */
|
||||
g_usart_rx_sta = 0; /* 接收错误,重新接收 */
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -206,7 +206,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||||
g_usart_rx_sta++;
|
||||
if(g_usart_rx_sta > (USART_REC_LEN - 1))
|
||||
{
|
||||
g_usart_rx_sta = 0; /* 接收数据错误,重新<EFBFBD>?始接<E5A78B>? */
|
||||
g_usart_rx_sta = 0; /* 接收数据错误,重新开始接收 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user