/** ****************************************************************************** * @file xl_ewm.h * @author software group * @brief This file contains all the functions prototypes for the EWM * firmware library. ****************************************************************************** * @attention * * 2019 by Chipways Communications,Inc. All Rights Reserved. * This software is supplied under the terms of a license * agreement or non-disclosure agreement with Chipways. * Passing on and copying of this document,and communication * of its contents is not permitted without prior written * authorization. * *

© COPYRIGHT 2019 Chipways

****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef XL_EWM_H_ #define XL_EWM_H_ #ifdef __cplusplus extern "C" { #endif /* Includes ---------------------------------------------------------------*/ #include "XL6600.h" /* Register define ------------------------------------------------------------*/ #define EWM_CTRL_CLK_SEL_MASK 0x60u #define EWM_CTRL_CLK_SEL_SHIFT 5 #define EWM_CTRL_INTREN_OUT_MASK 0x10u #define EWM_CTRL_INTREN_OUT_SHIFT 4 #define EWM_CTRL_INTREN_CMPL_MASK 0x08u #define EWM_CTRL_INTREN_CMPL_SHIFT 3 #define EWM_CTRL_INEN_MASK 0x04u #define EWM_CTRL_INEN_SHIFT 2 #define EWM_CTRL_ASSIN_MASK 0x02u #define EWM_CTRL_ASSIN_SHIFT 1 #define EWM_CTRL_ENABLE_MASK 0x01u #define EWM_CTRL_ENABLE_SHIFT 0 #define EWM_SERV_SERV_MASK 0xFFu #define EWM_SERV_SERV_SHIFT 0 #define EWM_CMPL_CMPL_MASK 0xFFFFu #define EWM_CMPL_CMPL_SHIFT 0 #define EWM_CMPH_CMPH_MASK 0xFFFFu #define EWM_CMPH_CMPH_SHIFT 0 #define EWM_CLKDIV_CLK_DIV_MASK 0xFFFFu #define EWM_CLKDIV_CLK_DIV_SHIFT 0 #define EWM_INTR_STATE_RESET_MASK 0x02u #define EWM_INTR_STATE_RESET_SHIFT 1 #define EWM_INTR_STATE_INT_MASK 0x01u #define EWM_INTR_STATE_INT_SHIFT 0 /** EWM - Register Layout Typedef */ typedef struct { __IO uint32_t CTRL; /*!< ¿ØÖƼĴæÆ÷, offset:0x00*/ __IO uint32_t SERV; /*!< ˢмĴæÆ÷, offset:0x04*/ __IO uint32_t CMPL; /*!< ´°¿ÚÉèÖÃÏÂÏ޼ĴæÆ÷, offset:0x08*/ __IO uint32_t CMPH; /*!< ´°¿ÚÉèÖÃÉÏÏ޼ĴæÆ÷, offset:0x0C*/ __IO uint32_t CLKDIV; /*!< ¼ÆÊýʱÖÓ·ÖÆµ¼Ä´æÆ÷, offset:0x0C*/ __IO uint32_t INTR_STATE; /*!< ÖжÏ״̬¼Ä´æÆ÷, offset:0x0C*/ } EWM_Type; extern EWM_Type* EWM; /** @addtogroup XL6600_StdPeriph_Driver * @{ */ /** @addtogroup EWM * @{ */ /* Exported types ------------------------------------------------------------*/ /** * @brief EWM ³õʼ»¯½á¹¹Ì嶨Òå */ typedef struct { uint8_t EWM_ClockSource; /*!< EWMʱÖÓÔ´ */ uint8_t EWM_ResetIntEnable; /*!< EWMÍⲿ¸´Î»ÖжÏʹÄÜ */ uint8_t EWM_CMPLIntEnable; /*!< CMPLÖжÏʹÄÜ */ uint8_t EWM_InputEnable; /*!< EWMÊäÈ빦ÄÜʹÄÜ */ uint8_t EWM_InputLevel; /*!< EWMÊäÈëµçƽ */ uint8_t EWM_Enable; /*!< EWMÄ£¿éʹÄÜ */ uint16_t EWM_CMPHValue; /*!< EWM´°¿ÚÉèÖÃÉÏÏ޼ĴæÆ÷Öµ */ uint16_t EWM_CMPLValue; /*!< EWM´°¿ÚÉèÖÃÏÂÏ޼ĴæÆ÷Öµ */ uint16_t EWM_Clock_Div; /*!< EWMʱÖÓ·ÖÆµÏµÊý */ }EWM_InitTypeDef; /* Exported constants --------------------------------------------------------*/ /** @defgroup EWM_Exported_Constants EWMÄ£¿éʹÓòÎÊý¶¨Òå * @{ */ /** * @defgroup EWM_Clock_Source EWMʱÖÓÔ´¶¨Òå * @{ */ #define EWM_CLK_SEL_PCLK ((uint8_t)0x0) /*!< APBCLK */ #define EWM_CLK_SEL_LPO_CLK ((uint8_t)0x1) /*!< µÍ¹¦ºÄʱÖÓLPO */ #define EWM_CLK_SEL_OSC_CLK ((uint8_t)0x2) /*!< ÍⲿÕñµ´Æ÷OSC */ #define EWM_CLK_SEL_ICS_IRCLK ((uint8_t)0x3) /*!< ÄÚ²¿»ù׼ʱÖÓIRC */ /** * @defgroup EWM_Input_Level EWMÊäÈëµçƽѡÔñ * @{ */ #define EWM_IN_LEVE_H 0x01 /*!< EWMÊäÈëµçƽΪ¸ß */ #define EWM_IN_LEVE_L 0x00 /*!< EWMÊäÈëµçƽΪµÍ */ /** * @defgroup EWM_Interrupt_Status EWMÖжÏ״̬ * @{ */ #define EWM_CMPL_INT_STATUS 0x01 /*!< CMPLÖжÏ״̬ */ #define EWM_RESET_INT_STATUS 0x02 /*!< ¸´Î»ÖжÏ״̬ */ #define EWM_LTCMPL_INT_STATUS 0x04 /*!< ¼ÆÊýÆ÷δµ½´ïCMPLÖжÏ״̬ */ #define EWM_GTCMPH_INT_STATUS 0x08 /*!< ¼ÆÊýÆ÷µ½´ïCMPHÖжÏ״̬ */ #define EWM_OUT15CLOCK_INT_STATUS 0x10 /*!< ûÓÐÔÚ15¸öÖÜÆÚÄÚÍê³ÉË¢ÐÂÖжÏ״̬ */ #define EWM_EXTERNAL_INT_STATUS 0x20 /*!< ÍⲿÐźŷ¢Éú·­×ªÖжÏ״̬ */ #define EWM_CLEAR_ALL_INT 0x3F /*!< Çå³ýËùÓÐÖÐ¶Ï */ /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ void EWM_Init(EWM_Type *EWMx,const EWM_InitTypeDef *EWM_InitStruct); void EWM_UpdateServ(EWM_Type *EWMx); uint8_t EWM_GetInterruptStatus(const EWM_Type *EWMx); void EWM_ClearInterruptStatus(EWM_Type *EWMx,uint8_t EWM_InterruptStatusType); #ifdef __cplusplus } #endif #endif /** * @} */ /** * @} */