/**
|
******************************************************************************
|
* @file xl_ewm.c
|
* @author kirk ,xu.wang
|
* @version 4.5.2
|
* @date Fri Mar 26 17:29:12 2021
|
* @brief This file provide function about EWM firmware program
|
******************************************************************************
|
* @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.
|
*
|
* <h2><center>© COPYRIGHT 2019 Chipways</center></h2>
|
******************************************************************************
|
*/
|
#if defined(__cplusplus)
|
extern "C" {
|
#endif /* __cplusplus */
|
|
/* Includes ---------------------------------------------------------------*/
|
#include "xl_ewm.h"
|
/** @addtogroup XL6600_StdPeriph_Driver
|
* @{
|
*/
|
|
/** @defgroup EWM EWM Module
|
* @brief EWM Driver Modules Library
|
* @{
|
*/
|
|
/* Private typedef -----------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
/* Private macro -------------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
/* Private functions ---------------------------------------------------------*/
|
|
|
/** @defgroup EWM_Private_Functions
|
* @{
|
*/
|
|
/**
|
* @brief ³õʼ»¯EWM
|
* @param EWMx:ÉèÖÃEWMÍâÉè
|
* @param EWM_InitStruct:ÉèÖÃEWM³õʼ»¯²ÎÊý½á¹¹Ìå
|
* @retval None
|
*/
|
void EWM_Init(EWM_Type* EWMx,const EWM_InitTypeDef* EWM_InitStruct)
|
{
|
uint8_t temp;
|
|
EWMx->CMPH = EWM_InitStruct->EWM_CMPHValue;
|
EWMx->CMPL = EWM_InitStruct->EWM_CMPLValue;
|
EWMx->CLKDIV = EWM_InitStruct->EWM_Clock_Div;
|
|
temp = (uint8_t)EWMx->CTRL;
|
|
temp |= (uint8_t)((EWM_InitStruct->EWM_ClockSource << EWM_CTRL_CLK_SEL_SHIFT) | \
|
(EWM_InitStruct->EWM_ResetIntEnable << EWM_CTRL_INTREN_OUT_SHIFT) | \
|
(EWM_InitStruct->EWM_CMPLIntEnable << EWM_CTRL_INTREN_CMPL_SHIFT) | \
|
(EWM_InitStruct->EWM_InputEnable << EWM_CTRL_INEN_SHIFT) | \
|
(EWM_InitStruct->EWM_InputLevel << EWM_CTRL_ASSIN_SHIFT) | \
|
(EWM_InitStruct->EWM_Enable));
|
EWMx->CTRL = (uint32_t)temp;
|
}
|
|
/**
|
* @brief EWMË¢ÐÂServer
|
* @param EWMx:ÉèÖÃEWMÍâÉè
|
* @param nCount£¬Ê±¼äÖÜÆÚ
|
* @retval ÖжÏ״̬
|
*/
|
void EWM_UpdateServ(EWM_Type *EWMx)
|
{
|
EWMx->SERV = 0xB4;
|
EWMx->SERV = 0x2C;
|
}
|
/**
|
* @brief EWMµÃµ½ÖжÏ״̬
|
* @param EWMx:ÉèÖÃEWMÍâÉè
|
* @param EWM_InterruptStatusType:ÉèÖÃEWMÖжÏÀàÐÍ
|
* @retval ÖжÏ״̬
|
*/
|
uint8_t EWM_GetInterruptStatus(const EWM_Type *EWMx)
|
{
|
return (uint8_t) EWMx->INTR_STATE;
|
}
|
|
/**
|
* @brief EWMÇå³ýÖжϱêÖ¾
|
* @param EWMx:ÉèÖÃEWMÍâÉè
|
* @param EWM_InterruptStatusType:EWMÖжÏÀàÐÍ
|
* Õâ¸ö²ÎÊý¿ÉÒÔÈ¡ÏÂÃæµÄÖµ:
|
* @arg EWM_CMPL_INT_STATUS: CMPLÖжÏ״̬
|
* @arg EWM_RESET_INT_STATUS: ¸´Î»ÖжÏ״̬
|
* @arg EWM_LTCMPL_INT_STATUS: ¼ÆÊýÆ÷δµ½´ïCMPLÖжÏ״̬
|
* @arg EWM_GTCMPH_INT_STATUS: ¼ÆÊýÆ÷´ïµ½CMPHÖжÏ״̬
|
* @arg EWM_OUT15CLOCK_INT_STATUS: ûÓÐÔÚ15¸öÖÜÆÚÄÚÍê³ÉË¢ÐÂÖжÏ״̬
|
* @arg EWM_EXTERNAL_INT_STATUS: ÍⲿÐźŷ¢Éú·×ªÖжÏ״̬
|
* @arg EWM_CLEAR_ALL_INT: CMPLÖжÏ״̬
|
* @retval None
|
*/
|
void EWM_ClearInterruptStatus(EWM_Type *EWMx,uint8_t EWM_InterruptStatusType)
|
{
|
EWMx->INTR_STATE |= (uint32_t)EWM_InterruptStatusType;
|
}
|
|
/**
|
* @}
|
*/
|
|
/**
|
* @}
|
*/
|
|
/**
|
* @}
|
*/
|
#ifdef __cplusplus
|
}
|
#endif /* __cplusplus */
|