mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
127 lines
5.2 KiB
C
127 lines
5.2 KiB
C
/******************************************************************************************************************************************
|
||
* <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: SWM320_wdt.c
|
||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: SWM320<32><30>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD>WDT<44><54><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
* <20><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>: http://www.synwit.com.cn/e/tool/gbook/?bid=1
|
||
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
||
* <20>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD>: V1.1.0 2017<31><37>10<31><30>25<32><35>
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼:
|
||
*
|
||
*
|
||
*******************************************************************************************************************************************
|
||
* @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 "SWM320.h"
|
||
#include "SWM320_wdt.h"
|
||
|
||
|
||
/******************************************************************************************************************************************
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: WDT_Init()
|
||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: WDT<44><54><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʼ<EFBFBD><CABC>
|
||
* <20><> <20><>: WDT_TypeDef * WDTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õĿ<C3B5><C4BF>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>WDT
|
||
* uint32_t peroid ȡֵ0--4294967295<39><35><EFBFBD><EFBFBD>λΪ<CEBB><CEAA>Ƭ<EFBFBD><C6AC>ϵͳʱ<CDB3><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
* uint32_t mode WDT_MODE_RESET <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ WDT_MODE_INTERRUPT <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
||
* <20><> <20><>: <20><>
|
||
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>λʹ<CEBB><CAB9>ʱ<EFBFBD>жϲ<D0B6><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>ʱоƬֱ<C6AC>Ӹ<EFBFBD>λ<EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><DEB7><EFBFBD>Ӧ<EFBFBD>ж<EFBFBD>
|
||
******************************************************************************************************************************************/
|
||
void WDT_Init(WDT_TypeDef * WDTx, uint32_t peroid, uint32_t mode)
|
||
{
|
||
SYS->CLKEN |= (0x01 << SYS_CLKEN_WDT_Pos);
|
||
|
||
WDT_Stop(WDTx); //<2F><><EFBFBD><EFBFBD>ǰ<EFBFBD>ȹر<C8B9>
|
||
|
||
WDTx->LOAD = peroid;
|
||
|
||
if(mode == WDT_MODE_RESET)
|
||
{
|
||
NVIC_DisableIRQ(WDT_IRQn);
|
||
|
||
WDTx->CR |= (1 << WDT_CR_RSTEN_Pos);
|
||
}
|
||
else //mode == WDT_MODE_INTERRUPT
|
||
{
|
||
NVIC_EnableIRQ(WDT_IRQn);
|
||
|
||
WDTx->CR &= ~(1 << WDT_CR_RSTEN_Pos);
|
||
}
|
||
}
|
||
|
||
/******************************************************************************************************************************************
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: WDT_Start()
|
||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>WDT<44><54><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ
|
||
* <20><> <20><>: WDT_TypeDef * WDTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õĿ<C3B5><C4BF>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>WDT
|
||
* <20><> <20><>: <20><>
|
||
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||
******************************************************************************************************************************************/
|
||
void WDT_Start(WDT_TypeDef * WDTx)
|
||
{
|
||
WDTx->CR |= (0x01 << WDT_CR_EN_Pos);
|
||
}
|
||
|
||
/******************************************************************************************************************************************
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: WDT_Stop()
|
||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09>ر<EFBFBD>ָ<EFBFBD><D6B8>WDT<44><54>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>ʱ
|
||
* <20><> <20><>: WDT_TypeDef * WDTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õĿ<C3B5><C4BF>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>WDT
|
||
* <20><> <20><>: <20><>
|
||
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||
******************************************************************************************************************************************/
|
||
void WDT_Stop(WDT_TypeDef * WDTx)
|
||
{
|
||
WDTx->CR &= ~(0x01 << WDT_CR_EN_Pos);
|
||
}
|
||
|
||
/******************************************************************************************************************************************
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: WDT_Feed()
|
||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: ι<><CEB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD>װ<EFBFBD><D7B0>ֵ<EFBFBD><D6B5>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ
|
||
* <20><> <20><>: WDT_TypeDef * WDTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õĿ<C3B5><C4BF>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>WDT
|
||
* <20><> <20><>: <20><>
|
||
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||
******************************************************************************************************************************************/
|
||
void WDT_Feed(WDT_TypeDef * WDTx)
|
||
{
|
||
WDTx->FEED = 0x55;
|
||
}
|
||
|
||
/******************************************************************************************************************************************
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: WDT_GetValue()
|
||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><>ȡָ<C8A1><D6B8><EFBFBD><EFBFBD><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ĵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ʱֵ
|
||
* <20><> <20><>: WDT_TypeDef * WDTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õĿ<C3B5><C4BF>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>WDT
|
||
* <20><> <20><>: int32_t <09><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ
|
||
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||
******************************************************************************************************************************************/
|
||
int32_t WDT_GetValue(WDT_TypeDef * WDTx)
|
||
{
|
||
return WDTx->VALUE;
|
||
}
|
||
|
||
/******************************************************************************************************************************************
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: WDT_INTClr()
|
||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09>жϱ<D0B6>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
|
||
* <20><> <20><>: WDT_TypeDef * WDTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õĿ<C3B5><C4BF>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>WDT
|
||
* <20><> <20><>: <20><>
|
||
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||
******************************************************************************************************************************************/
|
||
void WDT_INTClr(WDT_TypeDef * WDTx)
|
||
{
|
||
WDTx->IF = 1;
|
||
}
|
||
|
||
/******************************************************************************************************************************************
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: WDT_INTStat()
|
||
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09>ж<EFBFBD>״̬<D7B4><CCAC>ѯ
|
||
* <20><> <20><>: WDT_TypeDef * WDTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õĿ<C3B5><C4BF>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>WDT
|
||
* <20><> <20><>: int32_t 1 <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD> 0 δ<><CEB4><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
|
||
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||
******************************************************************************************************************************************/
|
||
uint32_t WDT_INTStat(WDT_TypeDef * WDTx)
|
||
{
|
||
return WDTx->IF;
|
||
}
|