Files
BR_YKC/Core/User/Global/global.h
2026-05-21 12:19:01 +08:00

115 lines
5.1 KiB
C

/**
******************************************************************************
* @file User\Global\global.h
* @author 路淮
* @version v0.1
* @date 2026-05-21
* @brief 全局头文件
******************************************************************************
*/
#ifndef __GLOBAL_H
#define __GLOBAL_H
/* Private includes ----------------------------------------------------------*/
/* C 语言标准库 */
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <stdarg.h>
#include <stdbool.h>
#include <time.h>
/* CubeMX生成 */
#include "main.h"
// #include "iwdg.h"
#include "usart.h"
#include "gpio.h"
/* freeRTOS 相关 */
#include "cmsis_os.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
#include "event_groups.h"
#include "stream_buffer.h"
#include "timers.h"
/* Os */
#include "os_task.h"
#include "os_queue.h"
#include "os_semaphore.h"
/* GL */
#include "g_runtime.h"
#include "server_to_charger.h"
#include "g_dcpile.h"
/* driver */
#include "cJSON.h"
#include "server_common.h"
#include "charger_to_server.h"
#include "drv_usart.h"
/* macro ------------------------------------------------------------------------------------------------*/
#define ON 1
#define OFF 0
#define TRUE 1
#define FALSE 0
#define PI 3.1415926f
/*- I/O 输出-*/
#define AIR724_RESET() \
do \
{ \
HAL_GPIO_WritePin(AIR724_REWST_GPIO_Port, AIR724_REWST_Pin, GPIO_PIN_SET); \
uint32_t i = 60000000; \
while (i--) \
__nop; \
HAL_GPIO_WritePin(AIR724_REWST_GPIO_Port, AIR724_REWST_Pin, GPIO_PIN_RESET); \
} while (0) /* System Run Led */
#define RS485_EN(x) \
do \
{ \
x ? HAL_GPIO_WritePin(RS485_EN_GPIO_Port, RS485_EN_Pin, GPIO_PIN_SET) : HAL_GPIO_WritePin(RS485_EN_GPIO_Port, RS485_EN_Pin, GPIO_PIN_RESET); \
} while (0) /* RS485 EN Led */
#define System_Mode_Led(x) \
do \
{ \
x ? HAL_GPIO_WritePin(System_Mode_Led_GPIO_Port, System_Mode_Led_Pin, GPIO_PIN_SET) : HAL_GPIO_WritePin(System_Mode_Led_GPIO_Port, System_Mode_Led_Pin, GPIO_PIN_RESET); \
} while (0) /* System Run Led */
#define System_Mode_Led_Toggle() HAL_GPIO_TogglePin(System_Mode_Led_GPIO_Port, System_Mode_Led_Pin)
#define System_Run_Led(x) \
do \
{ \
x ? HAL_GPIO_WritePin(System_Run_Led_GPIO_Port, System_Run_Led_Pin, GPIO_PIN_SET) : HAL_GPIO_WritePin(System_Run_Led_GPIO_Port, System_Run_Led_Pin, GPIO_PIN_RESET); \
} while (0) /* System Run Led */
#define System_Run_Led_Toggle() HAL_GPIO_TogglePin(System_Run_Led_GPIO_Port, System_Run_Led_Pin) /* System Run Led */
#define YT8512_RST(x) \
do \
{ \
x ? HAL_GPIO_WritePin(YT8512_RST_GPIO_Port, YT8512_RST_Pin, GPIO_PIN_SET) : HAL_GPIO_WritePin(YT8512_RST_GPIO_Port, YT8512_RST_Pin, GPIO_PIN_RESET); \
} while (0) /* System Run Led */
/*- I/O 输入-*/
#define get_sys_time_msec() HAL_GetTick()
#define CONSTRAIN(x, max, min) (x > max ? max : (x < min ? min : x))
#endif /* __GLOBAL_H */