STM32_WGY/User/hal_interface.h

57 lines
1.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.

// 本模块为硬件驱动的接口层包括HAL和LL库里相关函数的实现
#ifndef __HAL_INTERFACE_H
#define __HAL_INTERFACE_H
#include "stm32l4xx_hal.h"
#include "type.h"
// 是否允许调试打印输出?
#define PRINT_DEBUG 1
#if PRINT_DEBUG
#define PRINTF printf
#else
#define PRINTF NO_PRINTF
#endif
#define NO_PRINTF(format, ...) {}
// 延时函数
#define GetTickCount() HAL_GetTick()
u32 GetDelayTick(u32 ms);
u8 IsTickOut(u32 OutTick);
void delay_ms(u32 ms);
void delay_us(uint16_t us);
// 实现从Bootloader跳转到App
void JumpToEntry(uint32_t addr);
// 实现从App跳转到Bootloader
void JumpToLoader();
typedef struct USART_Handle
{
USART_TypeDef *Instance;
volatile uint16_t TxXferCount;
volatile uint8_t BusyTx; // 发送忙
volatile uint8_t ITx; // 是否以中断方式发送
uint8_t *pTxBuffPtr;
void (*TxISR)(struct USART_Handle *huart);
void (*RxISR)(struct USART_Handle *huart);
} USART_Handle;
extern USART_Handle huart1, huart2, huart3, hlpuart1;
// 实现串口发送
void UART_Transmit(USART_Handle *uart, uint8_t *buf, uint16_t len);
// 实现以中断方式串口发送
uint8_t UART_Transmit_IT(USART_Handle *huart, uint8_t *pData, uint16_t Size);
// 应用程序的串口中断处理
void APP_USART_IRQHandler(USART_Handle *usart);
// 启动原因代码
extern volatile uint32_t SYS_RSTSTS;
// 读取启动原因代码
void Fetch_ResetFlags();
#endif