summaryrefslogtreecommitdiff
path: root/bsp/essemi/es8p508x/libraries/Library/Include/lib_wdt.h
blob: 45ad9d4287f11fb2f37f953be51490ba812e97bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/***************************************************************
 *Copyright (C), 2017, Shanghai Eastsoft Microelectronics Co., Ltd
 *�����  lib_wdt.c
 *��  �ߣ�  Liut
 *��  ����  V1.00
 *��  �ڣ�  2017/02/04
 *��  ����  ���Ź�ģ��⺯��
 *��  ע��  ������ ES8P508xоƬ
 ����������ѧϰ����ʾʹ�ã����û�ֱ�����ô����������ķ��ջ������е��κη������Ρ�
 ***************************************************************/
#ifndef __LIBWDT_H__
#define __LIBWDT_H__

#include "system_ES8P508x.h"
#include "ES8P508x.h"
#include "type.h"

/* WDTʱ��ѡ�� */
typedef enum
{
    WDT_CLOCK_PCLK = 0x0,   //PCLK
    WDT_CLOCK_WDT  = 0x1,   //WDTʱ��Դ��32kHz
} WDT_TYPE_CLKS;

/* ��ʼ���ṹ�� */
typedef struct
{
    uint32_t WDT_Tms;       //��ʱʱ�䣬��λms 
    TYPE_FUNCEN WDT_IE;     //�ж�ʹ��
    TYPE_FUNCEN WDT_Rst;    //��λʹ��
    WDT_TYPE_CLKS WDT_Clock;//ʱ��ѡ��
} IWDT_InitStruType;

typedef enum
{
    WDT_WIN_25 = 0x0,   //25%�����ڽ�ֹι����������ι��������λ
    WDT_WIN_50 = 0x1,   //50%�����ڽ�ֹι����������ι��������λ
    WDT_WIN_75 = 0x2,   //75%�����ڽ�ֹι����������ι��������λ
    WDT_WIN_100 = 0x3,  //����ֹι����ι����ʹ���Ź�����������
} WDT_TYPE_WIN;

/* ��ʼ���ṹ�� */
typedef struct
{
    uint32_t WDT_Tms;       //��ʱʱ�䣬��λms 
    TYPE_FUNCEN WDT_IE;     //�ж�ʹ��
    TYPE_FUNCEN WDT_Rst;    //��λʹ��
    WDT_TYPE_CLKS WDT_Clock;//ʱ��ѡ��
    WDT_TYPE_WIN WDT_Win;   //��ֹι������
} WWDT_InitStruType;

#define IWDT_RegUnLock()     (IWDT->LOCK.Word = 0x1ACCE551)
#define IWDT_RegLock()       (IWDT->LOCK.Word = 0x0)

#define IWDT_Enable()        {IWDT_RegUnLock();IWDT->CON.EN = 1;IWDT_RegLock();}
#define IWDT_Disable()       {IWDT_RegUnLock();IWDT->CON.EN = 0;IWDT_RegLock();}

#define IWDT_Clear()         {IWDT_RegUnLock();IWDT->INTCLR.INTCLR = 0;IWDT_RegLock();}

#define IWDT_ITEnable()      {IWDT_RegUnLock();IWDT->CON.IE = 1;IWDT_RegLock();}
#define IWDT_ITDisable()     {IWDT_RegUnLock();IWDT->CON.IE = 0;IWDT_RegLock();}

#define IWDT_RstEnable()     {IWDT_RegUnLock();IWDT->CON.RSTEN = 1;IWDT_RegLock();}
#define IWDT_RstDisable()    {IWDT_RegUnLock();IWDT->CON.RSTEN = 0;IWDT_RegLock();}

#define IWDT_CLOCK_PCLK()    {IWDT_RegUnLock();IWDT->CON.CLKS = 0;IWDT_RegLock();}
#define IWDT_CLOCK_WDT()     {IWDT_RegUnLock();IWDT->CON.CLKS = 1;IWDT_RegLock();}

#define WWDT_RegUnLock()     (WWDT->LOCK.Word = 0x1ACCE551)
#define WWDT_RegLock()       (WWDT->LOCK.Word = 0x0)

#define WWDT_Enable()        {WWDT_RegUnLock();WWDT->CON.EN = 1;WWDT_RegLock();}
#define WWDT_Disable()       {WWDT_RegUnLock();WWDT->CON.EN = 0;WWDT_RegLock();}

#define WWDT_Clear()         {WWDT_RegUnLock();WWDT->INTCLR.INTCLR = 0;WWDT_RegLock();}

#define WWDT_ITEnable()      {WWDT_RegUnLock();WWDT->CON.IE = 1;WWDT_RegLock();}
#define WWDT_ITDisable()     {WWDT_RegUnLock();WWDT->CON.IE = 0;WWDT_RegLock();}

#define WWDT_RstEnable()     {WWDT_RegUnLock();WWDT->CON.RSTEN = 1;WWDT_RegLock();}
#define WWDT_RstDisable()    {WWDT_RegUnLock();WWDT->CON.RSTEN = 0;WWDT_RegLock();}

#define WWDT_CLOCK_PCLK()    {WWDT_RegUnLock();WWDT->CON.CLKS = 0;WWDT_RegLock();}
#define WWDT_CLOCK_WDT()     {WWDT_RegUnLock();WWDT->CON.CLKS = 1;WWDT_RegLock();}

void IWDT_Init(IWDT_InitStruType *IWDT_InitStruct);
void IWDT_SetReloadValue(uint32_t Value);
uint32_t IWDT_GetValue(void);
FlagStatus IWDT_GetFlagStatus(void);
FlagStatus IWDT_GetITStatus(void);
void WWDT_Init(WWDT_InitStruType *WDT_InitStruct);
void WWDT_SetReloadValue(uint32_t Value);
uint32_t WWDT_GetValue(void);
FlagStatus WWDT_GetFlagStatus(void);
FlagStatus WWDT_GetITStatus(void);

#endif

/*************************END OF FILE**********************/