This repository has been archived on 2025-01-02. You can view files and clone it, but cannot push or open issues or pull requests.
torsion/User/system/bsp/bsp.h

55 lines
1.8 KiB
C
Raw Permalink 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.

#ifndef __BSP_H__
#define __BSP_H__
#include "gpios.h"
#include "adcs.h"
#include "dacs.h"
#include "pwms.h"
#include "uarts.h"
#include "eeprom.h"
// #include "spis.h"
#include "i2cs.h"
/***
* @brief 启用定时器时钟。
* @param {TIMx} TIMx定时器外设寄存器地址。
* @return {void}
* @note: 此函数应在定时器相关初始化函数之后调用,以启用定时器的时钟。
*/
#define ENABLE_TIM(TIMx) \
do \
{ \
LL_TIM_EnableCounter(TIMx); \
LL_TIM_EnableIT_UPDATE(TIMx); \
} while (__LINE__ == -1);
#define WATCHDOG_RESET() LL_IWDG_ReloadCounter(IWDG)
/**
* @brief Clears the flags of a DMA channel
* @param DMAX DMAx register base
* @param CHx DMA channel number
* @param Flag a boolean variable that indicates if the transfer is complete
* @note This function should be called within the interrupt service routine of the DMA channel
*/
#define DMA_ClEAR_FLAG(DMAX, CHx, Flag) \
do \
{ \
if (LL_DMA_IsActiveFlag_TC##CHx(DMAX)) \
{ \
LL_DMA_ClearFlag_TC##CHx(DMAX); \
LL_DMA_ClearFlag_GI##CHx(DMAX); \
Flag = TRUE; \
} \
if (LL_DMA_IsActiveFlag_TE##CHx(DMAX)) \
{ \
LL_DMA_ClearFlag_TE##CHx(DMAX); \
} \
if (LL_DMA_IsActiveFlag_GI##CHx(DMAX)) \
{ \
LL_DMA_ClearFlag_GI##CHx(DMAX); \
} \
} while (__LINE__ == -1)
#endif // __BSP_H__