rt-thread/bsp/swm341/libraries/SWM341_StdPeriph_Driver/SWM341_iofilt.c

74 lines
3.6 KiB
C
Raw Normal View History

/******************************************************************************************************************************************
* : SWM341_iofilt.c
* : SWM341单片机的IO滤波器功能模块PAD到模块输入间的信号滤波
* : http://www.synwit.com.cn/e/tool/gbook/?bid=1
* :
* : V1.0.0 2016130
* :
*
*
*******************************************************************************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION
* REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, SYNWIT SHALL NOT BE HELD LIABLE
* FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
* OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONN-
* -ECTION WITH THEIR PRODUCTS.
*
* COPYRIGHT 2012 Synwit Technology
*******************************************************************************************************************************************/
#include "SWM341.h"
#include "SWM341_iofilt.h"
static uint32_t Width[2];
/******************************************************************************************************************************************
* : IOFILT_Init()
* : IO滤波器初始化
* : uint32_t IOFILTn 0-1
* uint32_t signal IOFILT0_PB5IOFILT0_PB4...
* uint32_t width width HRC IOFILT_WIDTH_2IOFILT_WIDTH_4...
* :
* :
******************************************************************************************************************************************/
void IOFILT_Init(uint32_t IOFILTn, uint32_t signal, uint32_t width)
{
SYS->CLKSEL &= ~SYS_CLKSEL_IOFILT_Msk;
SYS->CLKSEL |= (0 << SYS_CLKSEL_IOFILT_Pos); //滤波器时钟源HRC
SYS->CLKEN1 |= (1 << SYS_CLKEN1_IOFILT_Pos);
*(&SYS->IOFILT0 + IOFILTn) = (signal << SYS_IOFILT_IOSEL_Pos) |
(0 << SYS_IOFILT_CLKDIV_Pos) |
(width << SYS_IOFILT_TIM_Pos);
Width[IOFILTn] = width;
}
/******************************************************************************************************************************************
* : IOFILT_Open()
* : IO滤波器开启
* : uint32_t IOFILTn 0-1
* :
* :
******************************************************************************************************************************************/
void IOFILT_Open(uint32_t IOFILTn)
{
*(&SYS->IOFILT0 + IOFILTn) |= (Width[IOFILTn] << SYS_IOFILT_TIM_Pos);
}
/******************************************************************************************************************************************
* : IOFILT_Close()
* : IO滤波器关闭PAD上的信号直接进入模块
* : uint32_t IOFILTn 0-1
* :
* :
******************************************************************************************************************************************/
void IOFILT_Close(uint32_t IOFILTn)
{
*(&SYS->IOFILT0 + IOFILTn) &= ~SYS_IOFILT_TIM_Msk;
}