Skip to content

Commit 5c4f921

Browse files
authored
Merge pull request #4444 from mysterywolf/wdg
[ab32vg1] 增加看门狗溢出时间宏定义
2 parents ca80560 + eb894e8 commit 5c4f921

File tree

3 files changed

+49
-18
lines changed

3 files changed

+49
-18
lines changed

bsp/bluetrum/ab32vg1-ab-prougen/board/board.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
#define BOARD_H__
1313

1414
#include <rtthread.h>
15-
#include "ab32vgx.h"
16-
#include "drv_gpio.h"
15+
#include <ab32vgx.h>
16+
#ifdef RT_USING_PIN
17+
#include <drv_gpio.h>
18+
#endif
19+
#ifdef RT_USING_WDT
20+
#include <drv_wdt.h>
21+
#endif
22+
1723

1824
#endif

bsp/bluetrum/libraries/hal_drivers/drv_wdt.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#ifdef RT_USING_WDT
1414

15+
#include <drv_wdt.h>
16+
1517
// #define DRV_DEBUG
1618
#define LOG_TAG "drv.wdt"
1719
#include <drv_log.h>
@@ -49,35 +51,35 @@ static rt_err_t wdt_control(rt_watchdog_t *wdt, int cmd, void *arg)
4951

5052
switch (*((rt_uint32_t *)arg))
5153
{
52-
case 0:
54+
case AB32_WDT_TIMEOUT_1MS:
5355
LOG_I("The watchdog timeout is set to 1ms");
5456
tmp |= (0xa << 24) | (0x00 << 20);
5557
break;
56-
case 1:
58+
case AB32_WDT_TIMEOUT_256MS:
5759
LOG_I("The watchdog timeout is set to 256ms");
5860
tmp |= (0xa << 24) | (0x01 << 20);
5961
break;
60-
case 2:
62+
case AB32_WDT_TIMEOUT_512MS:
6163
LOG_I("The watchdog timeout is set to 512ms");
6264
tmp |= (0xa << 24) | (0x02 << 20);
6365
break;
64-
case 3:
66+
case AB32_WDT_TIMEOUT_1024MS:
6567
LOG_I("The watchdog timeout is set to 1024ms");
6668
tmp |= (0xa << 24) | (0x03 << 20);
6769
break;
68-
case 4:
70+
case AB32_WDT_TIMEOUT_2048MS:
6971
LOG_I("The watchdog timeout is set to 2048ms");
7072
tmp |= (0xa << 24) | (0x04 << 20);
7173
break;
72-
case 5:
74+
case AB32_WDT_TIMEOUT_4096MS:
7375
LOG_I("The watchdog timeout is set to 4096ms");
7476
tmp |= (0xa << 24) | (0x05 << 20);
7577
break;
76-
case 6:
78+
case AB32_WDT_TIMEOUT_8192MS:
7779
LOG_I("The watchdog timeout is set to 8192ms");
7880
tmp |= (0xa << 24) | (0x06 << 20);
7981
break;
80-
case 7:
82+
case AB32_WDT_TIMEOUT_16384MS:
8183
LOG_I("The watchdog timeout is set to 16384ms");
8284
tmp |= (0xa << 24) | (0x07 << 20);
8385
break;
@@ -92,28 +94,28 @@ static rt_err_t wdt_control(rt_watchdog_t *wdt, int cmd, void *arg)
9294
case RT_DEVICE_CTRL_WDT_GET_TIMEOUT:
9395
switch ((WDTCON >> 20) & 0x7)
9496
{
95-
case 0:
97+
case AB32_WDT_TIMEOUT_1MS:
9698
LOG_D("The watchdog timeout is set to 1ms");
9799
break;
98-
case 1:
100+
case AB32_WDT_TIMEOUT_256MS:
99101
LOG_D("The watchdog timeout is set to 256ms");
100102
break;
101-
case 2:
103+
case AB32_WDT_TIMEOUT_512MS:
102104
LOG_D("The watchdog timeout is set to 512ms");
103105
break;
104-
case 3:
106+
case AB32_WDT_TIMEOUT_1024MS:
105107
LOG_D("The watchdog timeout is set to 1024ms");
106108
break;
107-
case 4:
109+
case AB32_WDT_TIMEOUT_2048MS:
108110
LOG_D("The watchdog timeout is set to 2048ms");
109111
break;
110-
case 5:
112+
case AB32_WDT_TIMEOUT_4096MS:
111113
LOG_D("The watchdog timeout is set to 4096ms");
112114
break;
113-
case 6:
115+
case AB32_WDT_TIMEOUT_8192MS:
114116
LOG_D("The watchdog timeout is set to 8192ms");
115117
break;
116-
case 7:
118+
case AB32_WDT_TIMEOUT_16384MS:
117119
LOG_D("The watchdog timeout is set to 16384ms");
118120
break;
119121
default:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2020-2021, Bluetrum Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-03-11 Meco Man first version
9+
*/
10+
11+
#ifndef DRV_WDT_H__
12+
#define DRV_WDT_H__
13+
14+
#define AB32_WDT_TIMEOUT_1MS 0
15+
#define AB32_WDT_TIMEOUT_256MS 1
16+
#define AB32_WDT_TIMEOUT_512MS 2
17+
#define AB32_WDT_TIMEOUT_1024MS 3
18+
#define AB32_WDT_TIMEOUT_2048MS 4
19+
#define AB32_WDT_TIMEOUT_4096MS 5
20+
#define AB32_WDT_TIMEOUT_8192MS 6
21+
#define AB32_WDT_TIMEOUT_16384MS 7
22+
23+
#endif

0 commit comments

Comments
 (0)