Files
BR_YKC/Core/User/Global/global.h

121 lines
5.4 KiB
C

/**
******************************************************************************
* @file user\global\global.h
* @author liangky
* @version v0.1
* @date 2023-10-11
* @brief Briefly describe the function of your function
******************************************************************************
*/
#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"
/* 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"
/* _hal */
#include "_hal_usart.h"
/* driver */
#include "cJSON.h"
#include "server_common.h"
#include "charger_to_server.h"
/* macro ------------------------------------------------------------------------------------------------*/
#define ON 1
#define OFF 0
#define TRUE 1
#define FALSE 0
#define PI 3.1415926f
#define SOFTWARE_VERSION "JSBRv1.2" // 软件版本
#define YKC_VERSION 0x10 // YKC 协议版本 v1.6
#define NET_CONN_TYPE 0 // 0: 4G, 1: LAN
#define DEBUG 1 // 调试模式
#define YKC_SERVER_IP "121.43.69.62" // YKC 服务器 IP 地址
#define YKC_SERVER_PORT 8767 // YKC 服务器端口号
/*- 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 */