添加Dma_Send.c文件
This commit is contained in:
15
R_PINGCHANG/Core/Inc/Dma_Send.h
Normal file
15
R_PINGCHANG/Core/Inc/Dma_Send.h
Normal file
@ -0,0 +1,15 @@
|
||||
//
|
||||
// Created by zhu on 2024/2/4.
|
||||
//
|
||||
|
||||
#ifndef S15909_H750_DMA_SEND_H
|
||||
#define S15909_H750_DMA_SEND_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "string.h"
|
||||
#include "dma.h"
|
||||
#include "usart.h"
|
||||
|
||||
|
||||
void DMA_Send();
|
||||
#endif //S15909_H750_DMA_SEND_H
|
67
R_PINGCHANG/Core/Src/Dma_Send.c
Normal file
67
R_PINGCHANG/Core/Src/Dma_Send.c
Normal file
@ -0,0 +1,67 @@
|
||||
//
|
||||
// Created by zhu on 2024/2/4.
|
||||
//
|
||||
|
||||
#include "Dma_Send.h"
|
||||
static uint8_t temp[1040];
|
||||
static uint16_t temp16[512];
|
||||
static uint32_t temp16_2[512];
|
||||
|
||||
int Average_Number=50;
|
||||
volatile int mul_int_max = 0;
|
||||
volatile int G_Clk_Rise_Number = 0;
|
||||
volatile int G_Hamamatsu_Trigger_Rise_Number_U8 = 0;
|
||||
volatile int G_Hamamatsu_Trigger_Rise_Number=0;
|
||||
|
||||
|
||||
int index_count = 0;
|
||||
int needreset1=0;
|
||||
int needreset2=1;
|
||||
int thisneedtransfor=1;
|
||||
void DMA_Send(){
|
||||
if(G_Clk_Rise_Number>=2080)
|
||||
{
|
||||
needreset1=1;
|
||||
}
|
||||
if(G_Hamamatsu_Trigger_Rise_Number>=512&&thisneedtransfor)
|
||||
{
|
||||
thisneedtransfor=0;
|
||||
for(int i=0;i<512;i++)
|
||||
{
|
||||
temp16_2[i]+=adc_ans[i];
|
||||
}
|
||||
|
||||
if (index_count%Average_Number==0)
|
||||
{
|
||||
for(int i=0;i<512;i++)
|
||||
{
|
||||
temp16[i]=temp16_2[i]/Average_Number;
|
||||
temp16_2[i]=0;
|
||||
}
|
||||
temp[0]=0xff;
|
||||
temp[1]=0xff;
|
||||
/**** 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++;
|
||||
}
|
||||
if(mul_int>mul_int_max)
|
||||
{
|
||||
mul_int=0;
|
||||
}
|
||||
if(needreset1==1&&needreset2==1)
|
||||
{
|
||||
__disable_irq();
|
||||
mul_int++;
|
||||
G_Clk_Rise_Number=0;
|
||||
G_Hamamatsu_Trigger_Rise_Number_U8=0;
|
||||
G_Hamamatsu_Trigger_Rise_Number=0;
|
||||
__enable_irq();
|
||||
needreset1=0;
|
||||
needreset2=0;
|
||||
thisneedtransfor=1;
|
||||
}
|
||||
|
||||
}
|
@ -27,37 +27,14 @@
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "retarget.h"
|
||||
#include "string.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"
|
||||
#include <stdbool.h>
|
||||
///**
|
||||
// * <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20>ض<EFBFBD><D8B6><EFBFBD>c<EFBFBD>⺯<EFBFBD><E2BAAF>printf<74><66>DEBUG_USARTx
|
||||
// * <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||||
// * <20><> <20><> ֵ: <20><>
|
||||
// * ˵ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// */
|
||||
//int fputc(int ch, FILE *f)
|
||||
//{
|
||||
// HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xffff);
|
||||
// return ch;
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20>ض<EFBFBD><D8B6><EFBFBD>c<EFBFBD>⺯<EFBFBD><E2BAAF>getchar,scanf<6E><66>DEBUG_USARTx
|
||||
// * <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||||
// * <20><> <20><> ֵ: <20><>
|
||||
// * ˵ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// */
|
||||
//int fgetc(FILE *f)
|
||||
//{
|
||||
// uint8_t ch = 0;
|
||||
// HAL_UART_Receive(&huart1, &ch, 1, 0xffff);
|
||||
// return ch;
|
||||
//}
|
||||
#include "Dma_Send.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@ -79,11 +56,7 @@
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
int Average_Number=50;
|
||||
volatile int mul_int_max = 0;
|
||||
volatile int G_Clk_Rise_Number = 0;
|
||||
volatile int G_Hamamatsu_Trigger_Rise_Number_U8 = 0;
|
||||
volatile int G_Hamamatsu_Trigger_Rise_Number=0;
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
@ -154,72 +127,16 @@ int main(void)
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
|
||||
static uint8_t temp[1040];
|
||||
static uint16_t temp16[512];
|
||||
static uint32_t temp16_2[512];
|
||||
|
||||
int index=0;
|
||||
int needreset1=0;
|
||||
int needreset2=1;
|
||||
int thisneedtransfor=1;
|
||||
|
||||
while (1)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
// SerialDataProcess();
|
||||
SerialDataProcess();
|
||||
if(Printf_Flag== true){
|
||||
Judge();
|
||||
Printf_Flag = false;
|
||||
}
|
||||
// if(G_Clk_Rise_Number>=2080)
|
||||
// {
|
||||
// needreset1=1;
|
||||
// }
|
||||
// if(G_Hamamatsu_Trigger_Rise_Number>=512&&thisneedtransfor)
|
||||
// {
|
||||
// thisneedtransfor=0;
|
||||
// for(int i=0;i<512;i++)
|
||||
// {
|
||||
// temp16_2[i]+=adc_ans[i];
|
||||
// }
|
||||
//
|
||||
// if (index%Average_Number==0)
|
||||
// {
|
||||
// for(int i=0;i<512;i++)
|
||||
// {
|
||||
// temp16[i]=temp16_2[i]/Average_Number;
|
||||
// temp16_2[i]=0;
|
||||
// }
|
||||
// temp[0]=0xff;
|
||||
// temp[1]=0xff;
|
||||
// /**** 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++;
|
||||
// }
|
||||
// if(mul_int>mul_int_max)
|
||||
// {
|
||||
// mul_int=0;
|
||||
// }
|
||||
// if(needreset1==1&&needreset2==1)
|
||||
// {
|
||||
// __disable_irq();
|
||||
// mul_int++;
|
||||
// G_Clk_Rise_Number=0;
|
||||
// G_Hamamatsu_Trigger_Rise_Number_U8=0;
|
||||
// G_Hamamatsu_Trigger_Rise_Number=0;
|
||||
// __enable_irq();
|
||||
// needreset1=0;
|
||||
// needreset2=0;
|
||||
// thisneedtransfor=1;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
SerialDataProcess();
|
||||
if(Printf_Flag== true){
|
||||
Judge();
|
||||
Printf_Flag = false;
|
||||
}
|
||||
DMA_Send();
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
|
Reference in New Issue
Block a user