211 lines
5.8 KiB
C
211 lines
5.8 KiB
C
/* USER CODE BEGIN Header */
|
||
/**
|
||
******************************************************************************
|
||
* @file : main.h
|
||
* @brief : Header for main.c file.
|
||
* This file contains the common defines of the application.
|
||
******************************************************************************
|
||
* @attention
|
||
*
|
||
* Copyright (c) 2024 STMicroelectronics.
|
||
* All rights reserved.
|
||
*
|
||
* This software is licensed under terms that can be found in the LICENSE file
|
||
* in the root directory of this software component.
|
||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||
*
|
||
******************************************************************************
|
||
*/
|
||
/* USER CODE END Header */
|
||
|
||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||
#ifndef __MAIN_H
|
||
#define __MAIN_H
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
/* Includes ------------------------------------------------------------------*/
|
||
#include "stm32f4xx_hal.h"
|
||
|
||
/* Private includes ----------------------------------------------------------*/
|
||
/* USER CODE BEGIN Includes */
|
||
|
||
/* USER CODE END Includes */
|
||
|
||
/* Exported types ------------------------------------------------------------*/
|
||
/* USER CODE BEGIN ET */
|
||
|
||
/* USER CODE END ET */
|
||
|
||
/* Exported constants --------------------------------------------------------*/
|
||
/* USER CODE BEGIN EC */
|
||
|
||
/* USER CODE END EC */
|
||
|
||
/* Exported macro ------------------------------------------------------------*/
|
||
/* USER CODE BEGIN EM */
|
||
|
||
/* USER CODE END EM */
|
||
|
||
/* Exported functions prototypes ---------------------------------------------*/
|
||
void Error_Handler(void);
|
||
|
||
/* USER CODE BEGIN EFP */
|
||
void delay_us(__IO uint32_t delay);
|
||
void delay_ms(__IO uint32_t delay);
|
||
void delay_tick(uint32_t ticks);
|
||
/* USER CODE END EFP */
|
||
|
||
/* Private defines -----------------------------------------------------------*/
|
||
#define AO2_MOSI_Pin GPIO_PIN_2
|
||
#define AO2_MOSI_GPIO_Port GPIOE
|
||
#define AO2_SCK_Pin GPIO_PIN_3
|
||
#define AO2_SCK_GPIO_Port GPIOE
|
||
#define AO2_NSS_Pin GPIO_PIN_4
|
||
#define AO2_NSS_GPIO_Port GPIOE
|
||
#define PWRCTRL_Pin GPIO_PIN_5
|
||
#define PWRCTRL_GPIO_Port GPIOE
|
||
#define CHARGING_Pin GPIO_PIN_13
|
||
#define CHARGING_GPIO_Port GPIOC
|
||
#define DI1_Pin GPIO_PIN_0
|
||
#define DI1_GPIO_Port GPIOC
|
||
#define DI2_Pin GPIO_PIN_1
|
||
#define DI2_GPIO_Port GPIOC
|
||
#define AO1FB_Pin GPIO_PIN_2
|
||
#define AO1FB_GPIO_Port GPIOC
|
||
#define AO2FB_Pin GPIO_PIN_3
|
||
#define AO2FB_GPIO_Port GPIOC
|
||
#define AI_Pin GPIO_PIN_2
|
||
#define AI_GPIO_Port GPIOA
|
||
#define BATTERY_Pin GPIO_PIN_4
|
||
#define BATTERY_GPIO_Port GPIOA
|
||
#define SPI1_NSS1_Pin GPIO_PIN_4
|
||
#define SPI1_NSS1_GPIO_Port GPIOC
|
||
#define SPI1_NSS2_Pin GPIO_PIN_5
|
||
#define SPI1_NSS2_GPIO_Port GPIOC
|
||
#define SPI1_NSS3_Pin GPIO_PIN_0
|
||
#define SPI1_NSS3_GPIO_Port GPIOB
|
||
#define LED_Pin GPIO_PIN_14
|
||
#define LED_GPIO_Port GPIOE
|
||
#define BUZZER_Pin GPIO_PIN_15
|
||
#define BUZZER_GPIO_Port GPIOE
|
||
#define HP303S_NSS_Pin GPIO_PIN_11
|
||
#define HP303S_NSS_GPIO_Port GPIOD
|
||
#define HP303S_SCK_Pin GPIO_PIN_12
|
||
#define HP303S_SCK_GPIO_Port GPIOD
|
||
#define HP303S_MOSI_Pin GPIO_PIN_13
|
||
#define HP303S_MOSI_GPIO_Port GPIOD
|
||
#define HP303S_MISO_Pin GPIO_PIN_14
|
||
#define HP303S_MISO_GPIO_Port GPIOD
|
||
#define SPI3_NSS_Pin GPIO_PIN_15
|
||
#define SPI3_NSS_GPIO_Port GPIOA
|
||
#define CH395Q_INT_Pin GPIO_PIN_0
|
||
#define CH395Q_INT_GPIO_Port GPIOD
|
||
#define CH395Q_RSTI_Pin GPIO_PIN_1
|
||
#define CH395Q_RSTI_GPIO_Port GPIOD
|
||
#define CH395Q_RST_Pin GPIO_PIN_2
|
||
#define CH395Q_RST_GPIO_Port GPIOD
|
||
#define HART_CD_Pin GPIO_PIN_3
|
||
#define HART_CD_GPIO_Port GPIOD
|
||
#define USART2_RTS_Pin GPIO_PIN_4
|
||
#define USART2_RTS_GPIO_Port GPIOD
|
||
#define HART_RST_Pin GPIO_PIN_7
|
||
#define HART_RST_GPIO_Port GPIOD
|
||
#define DO_Pin GPIO_PIN_4
|
||
#define DO_GPIO_Port GPIOB
|
||
#define AO1_MOSI_Pin GPIO_PIN_9
|
||
#define AO1_MOSI_GPIO_Port GPIOB
|
||
#define AO1_SCK_Pin GPIO_PIN_0
|
||
#define AO1_SCK_GPIO_Port GPIOE
|
||
#define AO1_NSS_Pin GPIO_PIN_1
|
||
#define AO1_NSS_GPIO_Port GPIOE
|
||
|
||
/* USER CODE BEGIN Private defines */
|
||
#define osel_memset _memset
|
||
#define osel_memcmp _memcmp
|
||
#define osel_memcpy memcpyL
|
||
#define osel_memcpyr memcpyR
|
||
|
||
extern float ao1_offsets;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
extern float ao2_offsets;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
extern int16_t current_offsets[4];//<2F><><EFBFBD><EFBFBD>Уֵ
|
||
extern int16_t pressure_offsets[4];//<2F><>ѹУֵ
|
||
|
||
extern int cnt_update;
|
||
extern int net_status;
|
||
|
||
static inline void _memset(uint8_t *dst, uint8_t value, uint16_t size)
|
||
{
|
||
while (size--)
|
||
{
|
||
*dst++ = value;
|
||
}
|
||
}
|
||
|
||
static inline int8_t _memcmp(const uint8_t *dst, const uint8_t *src, uint16_t size)
|
||
{
|
||
while (size--)
|
||
{
|
||
if (*dst++ != *src++)
|
||
{
|
||
return -1;
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
static inline void memcpyL(uint8_t *dst, const uint8_t *src, uint16_t size)
|
||
{
|
||
while (size--)
|
||
{
|
||
*dst++ = *src++;
|
||
}
|
||
}
|
||
|
||
static inline void memcpyR(uint8_t *dst, const uint8_t *src, uint16_t size)
|
||
{
|
||
dst = dst + (size - 1);
|
||
while (size--)
|
||
{
|
||
*dst-- = *src++;
|
||
}
|
||
}
|
||
|
||
// <20>Ƚ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||
#define IsEqual(arr1, arr2, n) ({ \
|
||
int _equal = 1; \
|
||
for (int _i = 0; _i < n; _i++) \
|
||
{ \
|
||
if (arr1[_i] != arr2[_i]) \
|
||
{ \
|
||
_equal = 0; \
|
||
break; \
|
||
} \
|
||
} \
|
||
_equal; \
|
||
})
|
||
|
||
// ASSIC<49><43>ת<EFBFBD><D7AA>Ϊ16<31><36><EFBFBD><EFBFBD>
|
||
#define CHAR_TO_NUM(c, num) \
|
||
do \
|
||
{ \
|
||
if ((c) >= '0' && (c) <= '9') \
|
||
{ \
|
||
(num) = (c) - '0'; \
|
||
} \
|
||
else \
|
||
{ \
|
||
num = 0; \
|
||
} \
|
||
} while (0)
|
||
/* USER CODE END Private defines */
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif /* __MAIN_H */
|