fm_ccjy/Core/Inc/main.h

290 lines
8.3 KiB
C
Raw Blame History

/* 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"
#include "stm32f4xx_ll_adc.h"
#include "stm32f4xx_ll_dma.h"
#include "stm32f4xx_ll_rcc.h"
#include "stm32f4xx_ll_bus.h"
#include "stm32f4xx_ll_system.h"
#include "stm32f4xx_ll_exti.h"
#include "stm32f4xx_ll_cortex.h"
#include "stm32f4xx_ll_utils.h"
#include "stm32f4xx_ll_pwr.h"
#include "stm32f4xx_ll_spi.h"
#include "stm32f4xx_ll_tim.h"
#include "stm32f4xx_ll_usart.h"
#include "stm32f4xx_ll_gpio.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stm32f4xx_it.h"
#include <stdbool.h>
#include "adc.h"
#include "spi.h"
#include "tim.h"
#include "usart.h"
#include "gpio.h"
#include "Modbus.h"
#include "ads1256.h"
#include "hc165.h"
#include "hc595.h"
#include "dac7311.h"
#include "ms5803.h"
#include "laser.h"
#include "mf.h"
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
extern char step_cnt;
extern uint16_t press_array1[10];
extern uint16_t press_array2[10];
extern uint16_t press_array3[10];
extern uint32_t press_array1_sum;
extern uint32_t press_array2_sum;
extern uint32_t press_array3_sum;
extern int a1,a2,a3;
/* 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(uint32_t nus);
void delay_ms(uint16_t nms);
void delay_tick(uint32_t ticks);
extern int OVER_TIMES;
//#define OVER_TIMES 24
/* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/
#define SPI1_NSS4_Pin LL_GPIO_PIN_2
#define SPI1_NSS4_GPIO_Port GPIOE
#define SPI1_NSS3_Pin LL_GPIO_PIN_3
#define SPI1_NSS3_GPIO_Port GPIOE
#define SPI1_NSS2_Pin LL_GPIO_PIN_4
#define SPI1_NSS2_GPIO_Port GPIOE
#define SPI1_NSS1_Pin LL_GPIO_PIN_5
#define SPI1_NSS1_GPIO_Port GPIOE
#define SENSOR_SELECT_Pin LL_GPIO_PIN_6
#define SENSOR_SELECT_GPIO_Port GPIOE
#define PC13_SPI8_Pin LL_GPIO_PIN_13
#define PC13_SPI8_GPIO_Port GPIOC
#define PC14_SPI8_Pin LL_GPIO_PIN_14
#define PC14_SPI8_GPIO_Port GPIOC
#define PC15_SPI8_Pin LL_GPIO_PIN_15
#define PC15_SPI8_GPIO_Port GPIOC
#define HC165_DAT_Pin LL_GPIO_PIN_0
#define HC165_DAT_GPIO_Port GPIOC
#define HC165_INH_Pin LL_GPIO_PIN_1
#define HC165_INH_GPIO_Port GPIOC
#define HC165_LD_Pin LL_GPIO_PIN_2
#define HC165_LD_GPIO_Port GPIOC
#define HC165_CLK_Pin LL_GPIO_PIN_3
#define HC165_CLK_GPIO_Port GPIOC
#define ADC_IN0_AO1_Pin LL_GPIO_PIN_0
#define ADC_IN0_AO1_GPIO_Port GPIOA
#define ADC_IN1_A02_Pin LL_GPIO_PIN_1
#define ADC_IN1_A02_GPIO_Port GPIOA
#define ADC_IN2_RT_Pin LL_GPIO_PIN_2
#define ADC_IN2_RT_GPIO_Port GPIOA
#define PA3_SPI8_Pin LL_GPIO_PIN_3
#define PA3_SPI8_GPIO_Port GPIOA
#define PA4_SPI8_Pin LL_GPIO_PIN_4
#define PA4_SPI8_GPIO_Port GPIOA
#define HC595_SER_Pin LL_GPIO_PIN_4
#define HC595_SER_GPIO_Port GPIOC
#define HC595_OE_Pin LL_GPIO_PIN_5
#define HC595_OE_GPIO_Port GPIOC
#define HC595_RCLK_Pin LL_GPIO_PIN_0
#define HC595_RCLK_GPIO_Port GPIOB
#define HC595_SRCLK_Pin LL_GPIO_PIN_1
#define HC595_SRCLK_GPIO_Port GPIOB
#define HC595_SRCLR_Pin LL_GPIO_PIN_2
#define HC595_SRCLR_GPIO_Port GPIOB
#define DO1_Pin LL_GPIO_PIN_7
#define DO1_GPIO_Port GPIOE
#define DO2_Pin LL_GPIO_PIN_8
#define DO2_GPIO_Port GPIOE
#define DO3_Pin LL_GPIO_PIN_9
#define DO3_GPIO_Port GPIOE
#define DO4_Pin LL_GPIO_PIN_10
#define DO4_GPIO_Port GPIOE
#define DO5_Pin LL_GPIO_PIN_11
#define DO5_GPIO_Port GPIOE
#define DO6_Pin LL_GPIO_PIN_12
#define DO6_GPIO_Port GPIOE
#define DO7_Pin LL_GPIO_PIN_13
#define DO7_GPIO_Port GPIOE
#define DO8_Pin LL_GPIO_PIN_14
#define DO8_GPIO_Port GPIOE
#define PE15_SPI7_Pin LL_GPIO_PIN_15
#define PE15_SPI7_GPIO_Port GPIOE
#define PB10_SPI7_Pin LL_GPIO_PIN_10
#define PB10_SPI7_GPIO_Port GPIOB
#define PB11_SPI7_Pin LL_GPIO_PIN_11
#define PB11_SPI7_GPIO_Port GPIOB
#define AO1_SPI5_MOSI_Pin LL_GPIO_PIN_11
#define AO1_SPI5_MOSI_GPIO_Port GPIOD
#define AO1_SPI5_SCK_Pin LL_GPIO_PIN_12
#define AO1_SPI5_SCK_GPIO_Port GPIOD
#define AO1_SPI5_NSS_Pin LL_GPIO_PIN_13
#define AO1_SPI5_NSS_GPIO_Port GPIOD
#define PD14_SPI7_Pin LL_GPIO_PIN_14
#define PD14_SPI7_GPIO_Port GPIOD
#define PD15_SPI7_Pin LL_GPIO_PIN_15
#define PD15_SPI7_GPIO_Port GPIOD
#define AO2_SPI6_MOSI_Pin LL_GPIO_PIN_8
#define AO2_SPI6_MOSI_GPIO_Port GPIOC
#define AO2_SPI6_SCK_Pin LL_GPIO_PIN_9
#define AO2_SPI6_SCK_GPIO_Port GPIOC
#define AO2_SPI6_NSS_Pin LL_GPIO_PIN_8
#define AO2_SPI6_NSS_GPIO_Port GPIOA
#define SWDIO_Pin LL_GPIO_PIN_13
#define SWDIO_GPIO_Port GPIOA
#define SWCLK_Pin LL_GPIO_PIN_14
#define SWCLK_GPIO_Port GPIOA
#define ADS1256_DRDY_Pin LL_GPIO_PIN_0
#define ADS1256_DRDY_GPIO_Port GPIOD
#define ADS1256_PDWN_Pin LL_GPIO_PIN_1
#define ADS1256_PDWN_GPIO_Port GPIOD
#define CH395Q_RST_Pin LL_GPIO_PIN_2
#define CH395Q_RST_GPIO_Port GPIOD
#define CH395Q_INT_Pin LL_GPIO_PIN_3
#define CH395Q_INT_GPIO_Port GPIOD
#define CH395Q_RSTI_Pin LL_GPIO_PIN_4
#define CH395Q_RSTI_GPIO_Port GPIOD
#define SPI1_NSS8_Pin LL_GPIO_PIN_7
#define SPI1_NSS8_GPIO_Port GPIOD
#define SPI1_NSS7_Pin LL_GPIO_PIN_3
#define SPI1_NSS7_GPIO_Port GPIOB
#define SPI1_NSS6_Pin LL_GPIO_PIN_4
#define SPI1_NSS6_GPIO_Port GPIOB
#define SPI1_NSS5_Pin LL_GPIO_PIN_5
#define SPI1_NSS5_GPIO_Port GPIOB
#define ENCODER_A_Pin LL_GPIO_PIN_6
#define ENCODER_A_GPIO_Port GPIOB
#define ENCODER_B_Pin LL_GPIO_PIN_7
#define ENCODER_B_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */
extern int flow_state;
#define osel_memset _memset
#define osel_memcmp _memcmp
#define osel_memcpy memcpyL
#define osel_memcpyr memcpyR
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)
void delay_init(uint16_t sysclk);
/* USER CODE END Private defines */
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H */