110VCGQ/project/110VCGQV5/user/Inc/user.h
2023-07-12 15:15:16 +08:00

75 lines
2.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* user.h
*
* Created on: 2023年6月25日
* Author: wyf
*/
#ifndef USER_INC_USER_H_
#define USER_INC_USER_H_
#include "stm32g0xx_hal.h"
#include "main.h"
#include "adc.h"
#include "dma.h"
#include "iwdg.h"
#include "tim.h"
#include "usart.h"
#include "gpio.h"
#include "string.h"
#include "math.h"
#include "stdlib.h"
#include "user_stick.h"
#define ENABLE_INT() __set_PRIMASK(0) /* 使能全局中断 */
#define DISABLE_INT() __set_PRIMASK(1) /* 禁止全局中断 */
extern DMA_HandleTypeDef hdma_adc;
extern ADC_HandleTypeDef hadc1;
extern TIM_HandleTypeDef htim14;
extern DMA_HandleTypeDef hdma_usart1_rx;
extern DMA_HandleTypeDef hdma_usart1_tx;
extern UART_HandleTypeDef huart1;
#define FLASHmotor_runtime 0x08007000
#define FLASH485_ADDR 0x08007800 //存放485地址的地址
#define BUFF_LEN 128
#define ADCBUFF_LEN 250
extern volatile uint8_t usart_count; //串口接收数据个数
extern uint8_t RxBuff[BUFF_LEN] ; //串口接收缓冲区
extern uint8_t TXBuff[BUFF_LEN] ; //串口发送缓冲区
extern uint8_t uBuff[BUFF_LEN] ; //用户缓冲区
extern volatile int8_t polarity ,adc_state; //电场极性,投退状态
extern volatile uint8_t electric_flag ; //外加的反向电场极限0为负1为正
extern volatile uint8_t motor_state ; //电机状态,1为正常, 0不正常
extern volatile uint16_t RS485ADDR ;
extern uint16_t RegularConvData_Tab[ADCBUFF_LEN] ; //ADC采集原始数据
extern volatile int16_t adc_max; //最终峰峰值和
extern volatile int16_t adc_positive , adc_negative; //加外加电场后的adc值
extern volatile uint16_t estimate_value ; //投退判断的差值
extern volatile uint16_t pwm_pulse ; //pwm波脉宽
extern volatile int16_t adcValue_factor; //adc测量值得修正系数*10
extern volatile int16_t adcValue_addnum ; //adc测量值的加减系数
extern volatile int16_t motor_runtime; //电机运行时间
extern uint32_t current_addr; //记录当前电机运行时间的
void user_init(void);
void user_main(void);
void ADC_MAX(void);
void Usart_Receive(void);
uint16_t crc16_modbus(uint8_t *data, uint16_t length);
void MODBUS_03H(void);
void send_ack(uint8_t a);
void MODBUS_06H(void);
uint8_t writeflash(void);
uint8_t write_flash(void);
uint8_t write_runtime(void);
#endif /* USER_INC_USER_H_ */