Settable times

This commit is contained in:
wantong
2024-01-25 13:43:24 +08:00
parent b478a0087d
commit f5b2c8f817
113 changed files with 6352 additions and 7210 deletions

View File

@ -35,7 +35,7 @@ extern "C" {
extern UART_HandleTypeDef huart1;
/* USER CODE BEGIN Private defines */
#define USART_REC_LEN 200 /* 定义最大接收200字节数据 */
#define USART_REC_LEN 200 /* 定义<EFBFBD><EFBFBD>?大接<E5A4A7><E68EA5>?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]; /* 串口缓冲 */
extern uint16_t g_usart_rx_sta; /* 串口接收状 */
extern uint8_t g_usart_rx_buf[USART_REC_LEN]; /* 串口缓冲<EFBFBD><EFBFBD>? */
extern uint16_t g_usart_rx_sta; /* 串口接收状<EFBFBD>?? */
extern uint8_t g_rx_buffer[RXBUFFERSIZE]; /* HAL库USART接收Buffer */

View File

@ -143,7 +143,6 @@ int main(void)
MX_TIM1_Init();
MX_TIM2_Init();
MX_USART1_UART_Init();
RetargetInit(&huart1);
MX_TIM12_Init();
MX_ADC1_Init();
MX_TIM3_Init();
@ -196,6 +195,7 @@ int main(void)
{
temp16_2[i]+=adc_ans[i];
}
if (index%Average_Number==0)
{
for(int i=0;i<512;i++)

View File

@ -54,7 +54,7 @@ void MX_TIM1_Init(void)
/* USER CODE END TIM1_Init 1 */
htim1.Instance = TIM1;
htim1.Init.Prescaler = 16;
htim1.Init.Prescaler = 24-1;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 65535;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
@ -112,7 +112,7 @@ void MX_TIM2_Init(void)
/* USER CODE END TIM2_Init 1 */
htim2.Instance = TIM2;
htim2.Init.Prescaler = 16;
htim2.Init.Prescaler = 24-1;
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
htim2.Init.Period = 100;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
@ -157,7 +157,7 @@ void MX_TIM3_Init(void)
/* USER CODE END TIM3_Init 1 */
htim3.Instance = TIM3;
htim3.Init.Prescaler = 16;
htim3.Init.Prescaler = 24-1;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 65535;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
@ -213,7 +213,7 @@ void MX_TIM12_Init(void)
/* USER CODE END TIM12_Init 1 */
htim12.Instance = TIM12;
htim12.Init.Prescaler = 16;
htim12.Init.Prescaler = 24-1;
htim12.Init.CounterMode = TIM_COUNTERMODE_UP;
htim12.Init.Period = 65535;
htim12.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;

View File

@ -21,13 +21,13 @@
#include "usart.h"
/* USER CODE BEGIN 0 */
/* 接收缓冲, 大USART_REC_LEN个字. */
/* 接收缓冲, <EFBFBD><EFBFBD>?大USART_REC_LEN个字<EFBFBD><EFBFBD>?. */
uint8_t g_usart_rx_buf[USART_REC_LEN];
/* 接收状
* bit15 接收完成标志
* bit14 接收0x0d
* bit13~0 接收到的有效字节数目
/* 接收状<EFBFBD>??
* bit15<EFBFBD><EFBFBD>? 接收完成标志
* bit14<EFBFBD><EFBFBD>? 接收<EFBFBD><EFBFBD>?0x0d
* bit13~0<EFBFBD><EFBFBD>? 接收到的有效字节数目
*/
uint16_t g_usart_rx_sta = 0;
/* HAL库使用的串口接收缓冲 */
@ -52,7 +52,7 @@ void MX_USART1_UART_Init(void)
/* USER CODE END USART1_Init 1 */
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.BaudRate = 921600;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
@ -81,7 +81,7 @@ void MX_USART1_UART_Init(void)
/* USER CODE BEGIN USART1_Init 2 */
HAL_UART_Receive_IT(&huart1, (uint8_t *)g_rx_buffer, RXBUFFERSIZE);
/* USER CODE END USART1_Init 2 */
/* USER CODE END USART1_Init 2 */
}
@ -179,19 +179,19 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
/* USER CODE BEGIN 1 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if(huart->Instance == USART1) /* 如果是串1 */
if(huart->Instance == USART1) /* 如果是串<EFBFBD><EFBFBD>?1 */
{
if((g_usart_rx_sta & 0x8000) == 0) /* 接收未完 */
if((g_usart_rx_sta & 0x8000) == 0) /* 接收未完<EFBFBD><EFBFBD>? */
{
if(g_usart_rx_sta & 0x4000) /* 接收到了0x0d */
{
if(g_rx_buffer[0] != 0x0a)
{
g_usart_rx_sta = 0; /* 接收错误,重新开始 */
g_usart_rx_sta = 0; /* 接收错误,重新<EFBFBD><EFBFBD>?<3F><>? */
}
else
{
g_usart_rx_sta |= 0x8000; /* 接收完成 */
g_usart_rx_sta |= 0x8000; /* 接收完成<EFBFBD><EFBFBD>? */
}
}
else /* 还没收到0X0D */
@ -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; /* 接收数据错误,重新开始接收 */
g_usart_rx_sta = 0; /* 接收数据错误,重新<EFBFBD><EFBFBD>?始接<E5A78B><E68EA5>? */
}
}
}