增加注释

This commit is contained in:
王绪洁 2025-02-28 11:32:13 +08:00
parent c5774f328e
commit 10a92ef376
6 changed files with 72 additions and 50 deletions

View File

@ -82,9 +82,9 @@ uint8_t send_data_flag_cmd = 0;
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
@ -121,17 +121,18 @@ int main(void)
MX_TIM1_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
// HAL_GPIO_WritePin(DO_EN_GPIO_Port, DO_EN_Pin, GPIO_PIN_SET); // DO输出使能
/*配置各串口的DMA接收*/
// start
HAL_UARTEx_ReceiveToIdle_DMA(&huart4, lcd_uart4.rx_data_temp, ARRAY_LEN(lcd_uart4.rx_data_temp));
HAL_UARTEx_ReceiveToIdle_DMA(&huart6, ble1_uart6.rx_data_temp, ARRAY_LEN(ble1_uart6.rx_data_temp));
HAL_UARTEx_ReceiveToIdle_DMA(&huart3, ble2_uart3.rx_data_temp, ARRAY_LEN(ble2_uart3.rx_data_temp));
HAL_UARTEx_ReceiveToIdle_DMA(&huart5, hart1_uart5.rx_data_temp, ARRAY_LEN(hart1_uart5.rx_data_temp));
HAL_UARTEx_ReceiveToIdle_DMA(&huart2, hart2_uart2.rx_data_temp, ARRAY_LEN(hart2_uart2.rx_data_temp));
HAL_UARTEx_ReceiveToIdle_DMA(&huart1, usb_uart1.rx_data_temp, ARRAY_LEN(usb_uart1.rx_data_temp));
hart_ht1200m_reset(); // 初始化HT1200M模块
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); // PWM输出用于驱动HT1200M模块
HAL_TIM_Encoder_Start(&htim1, TIM_CHANNEL_ALL);
// end
hart_ht1200m_reset(); // 初始化HT1200M模块
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); // PWM输出用于驱动HT1200M模块
HAL_TIM_Encoder_Start(&htim1, TIM_CHANNEL_ALL); // 旋转编码器输入,用于检测旋转编码器状态
/* USER CODE END 2 */
/* Call init function for freertos objects (in freertos.c) */
@ -152,22 +153,22 @@ int main(void)
}
/**
* @brief System Clock Configuration
* @retval None
*/
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
*/
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
@ -182,9 +183,8 @@ void SystemClock_Config(void)
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
@ -283,19 +283,20 @@ void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
/* USER CODE END 4 */
/**
* @brief Period elapsed callback in non blocking mode
* @note This function is called when TIM4 interrupt took place, inside
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
* a global variable "uwTick" used as application time base.
* @param htim : TIM handle
* @retval None
*/
* @brief Period elapsed callback in non blocking mode
* @note This function is called when TIM4 interrupt took place, inside
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
* a global variable "uwTick" used as application time base.
* @param htim : TIM handle
* @retval None
*/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
/* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */
if (htim->Instance == TIM4) {
if (htim->Instance == TIM4)
{
HAL_IncTick();
}
/* USER CODE BEGIN Callback 1 */
@ -304,9 +305,9 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
}
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
@ -318,14 +319,14 @@ void Error_Handler(void)
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */

View File

@ -25,6 +25,15 @@ void communication_exception(uint8_t *tx_data, const uint8_t *const rx_data, com
tx_data[6] = FRAME_TAIL; // 帧尾
}
/**
* @brief AI数据并封装成通信帧
*
* AI通道获取模拟数据
*
* @param ai_data communication_ai_t结构体的指针AI通道信息
* @param tx_data uint8_t数组的指针
* @param rx_data const uint8_t数组的指针
*/
void communication_get_ai(communication_ai_t *ai_data, uint8_t *tx_data, const uint8_t *const rx_data)
{
float32_u analog_data;

View File

@ -89,13 +89,6 @@ void TCP_Client_Init(void)
client_pcb = tcp_new();
IP4_ADDR(&server_ip, DEST_IP_ADDR0, DEST_IP_ADDR1, DEST_IP_ADDR2, DEST_IP_ADDR3); // 磁甜IP華硊
// printf("IP 地址为: %d.%d.%d.%d\n",
// ip4_addr1(&server_ip),
// ip4_addr2(&server_ip),
// ip4_addr3(&server_ip),
// ip4_addr4(&server_ip));
// printf("客户端开始连接!\n");
// 羲宎蟀諉
tcp_connect(client_pcb, &server_ip, TCP_CLIENT_PORT, client_connected);
ip_set_option(client_pcb, SOF_KEEPALIVE);

View File

@ -220,6 +220,7 @@ typedef enum
} ad7124_registers_addr_e; // 寄存器地址
typedef enum
{
AD7124_SIZE_1 = 1,
AD7124_SIZE_2 = 2,
AD7124_SIZE_3 = 3,

View File

@ -1,5 +1,16 @@
#include "ht1200m.h"
/**
* @brief hart_ht1200m模块
*
* hart_ht1200m模块RTS引脚实现
*
*
* 1. HART1和HART2的复位引脚置高电平
* 2. 10
* 3. HART1和HART2的复位引脚置低电平
* 4. HART1和HART2的RTS引脚设置为接收状态
*/
extern void hart_ht1200m_reset(void)
{
HART1_RESET_ON;

View File

@ -4,19 +4,26 @@
extern ip4_addr_t ipaddr;
uint8_t ip_addr[24] = {0};
/**
* @brief UART向LCD屏幕绘制IP地址
*
* UART接口向LCD屏幕发送IP地址便
*
* @note UART接口LCD屏幕已经正确连接到UART接口
*/
void uart_lcd_draw_ipaddr(void)
{
ip_addr[0] = 0xEE;
// 串口发送的固定值为串口屏指令指定的帧头帧尾
ip_addr[0] = 0xEE; // 帧头
ip_addr[1] = 0xB1;
ip_addr[2] = 0x10;
ip_addr[3] = 0x00;
ip_addr[4] = 0x00;
ip_addr[5] = 0x00;
ip_addr[6] = 0x03;
ip_addr[2] = 0x10; // 命令码,此处为文本控件文本设置指令
ip_addr[3] = 0x00; // 画面ID高位地址
ip_addr[4] = 0x00; // 画面ID低位地址
ip_addr[5] = 0x00; // 控件ID高位地址
ip_addr[6] = 0x03; // 控件ID低位地址
char *ip_addr_str = ipaddr_ntoa(&ipaddr);
MEMCPY(ip_addr + 7, (uint8_t *)ip_addr_str, strlen(ip_addr_str));
ip_addr[7 + strlen(ip_addr_str)] = 0xFF;
ip_addr[7 + strlen(ip_addr_str)] = 0xFF; // 帧尾,下列都为帧尾
ip_addr[8 + strlen(ip_addr_str)] = 0xFC;
ip_addr[9 + strlen(ip_addr_str)] = 0xFF;
ip_addr[10 + strlen(ip_addr_str)] = 0xFF;