Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
d573f6f6
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d573f6f6
编写于
11月 10, 2021
作者:
1
192.168.1.134
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add iwdg driver
上级
85da2247
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
143 addition
and
19 deletion
+143
-19
bsp/n32g452xx/Libraries/rt_drivers/drv_wdt.c
bsp/n32g452xx/Libraries/rt_drivers/drv_wdt.c
+128
-0
bsp/n32g452xx/n32g452xx-mini-system/.config
bsp/n32g452xx/n32g452xx-mini-system/.config
+8
-15
bsp/n32g452xx/n32g452xx-mini-system/board/Kconfig
bsp/n32g452xx/n32g452xx-mini-system/board/Kconfig
+6
-1
bsp/n32g452xx/n32g452xx-mini-system/rtconfig.h
bsp/n32g452xx/n32g452xx-mini-system/rtconfig.h
+1
-3
未找到文件。
bsp/n32g452xx/Libraries/rt_drivers/drv_wdt.c
0 → 100644
浏览文件 @
d573f6f6
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-01-22 shelton first version
* 2021-11-10 breo.com porting to n32
*/
#include <board.h>
#include <drivers/watchdog.h>
#ifdef RT_USING_WDT
#ifdef BSP_USING_WDT
#define LSI_VALUE 40000
//#define DRV_DEBUG
#define LOG_TAG "drv.wdt"
#include <drv_log.h>
struct
n32_wdt_obj
{
IWDG_Module
*
instance
;
rt_uint32_t
Prescaler
;
rt_uint32_t
Reload
;
rt_uint16_t
is_start
;
};
static
struct
n32_wdt_obj
n32_wdt
;
static
struct
rt_watchdog_ops
ops
;
static
rt_watchdog_t
watchdog
;
static
rt_err_t
wdt_init
(
rt_watchdog_t
*
wdt
)
{
return
RT_EOK
;
}
static
rt_err_t
wdt_control
(
rt_watchdog_t
*
wdt
,
int
cmd
,
void
*
arg
)
{
switch
(
cmd
)
{
/* feed the watchdog */
case
RT_DEVICE_CTRL_WDT_KEEPALIVE
:
IWDG_ReloadKey
();
break
;
/* set watchdog timeout */
case
RT_DEVICE_CTRL_WDT_SET_TIMEOUT
:
#if defined(LSI_VALUE)
if
(
LSI_VALUE
)
{
n32_wdt
.
Reload
=
(
*
((
rt_uint32_t
*
)
arg
))
*
LSI_VALUE
/
256
;
}
else
{
LOG_E
(
"Please define the value of LSI_VALUE!"
);
}
if
(
n32_wdt
.
Reload
>
0xFFF
)
{
LOG_E
(
"wdg set timeout parameter too large, please less than %ds"
,
0xFFF
*
256
/
LSI_VALUE
);
return
-
RT_EINVAL
;
}
#else
#error "Please define the value of LSI_VALUE!"
#endif
if
(
n32_wdt
.
is_start
)
{
IWDG_WriteConfig
(
IWDG_WRITE_ENABLE
);
IWDG_SetPrescalerDiv
(
n32_wdt
.
Prescaler
);
IWDG_CntReload
(
n32_wdt
.
Reload
);
IWDG_WriteConfig
(
IWDG_WRITE_DISABLE
);
IWDG_Enable
();
}
break
;
case
RT_DEVICE_CTRL_WDT_GET_TIMEOUT
:
#if defined(LSI_VALUE)
if
(
LSI_VALUE
)
{
(
*
((
rt_uint32_t
*
)
arg
))
=
n32_wdt
.
Reload
*
256
/
LSI_VALUE
;
}
else
{
LOG_E
(
"Please define the value of LSI_VALUE!"
);
}
#else
#error "Please define the value of LSI_VALUE!"
#endif
break
;
case
RT_DEVICE_CTRL_WDT_START
:
IWDG_WriteConfig
(
IWDG_WRITE_ENABLE
);
IWDG_SetPrescalerDiv
(
n32_wdt
.
Prescaler
);
IWDG_CntReload
(
n32_wdt
.
Reload
);
IWDG_WriteConfig
(
IWDG_WRITE_DISABLE
);
IWDG_Enable
();
n32_wdt
.
is_start
=
1
;
break
;
default:
LOG_W
(
"This command is not supported."
);
return
-
RT_ERROR
;
}
return
RT_EOK
;
}
int
rt_hw_wdt_init
(
void
)
{
n32_wdt
.
instance
=
IWDG
;
n32_wdt
.
Prescaler
=
IWDG_PRESCALER_DIV256
;
n32_wdt
.
Reload
=
0x00000FFF
;
n32_wdt
.
is_start
=
0
;
ops
.
init
=
&
wdt_init
;
ops
.
control
=
&
wdt_control
;
watchdog
.
ops
=
&
ops
;
/* register watchdog device */
if
(
rt_hw_watchdog_register
(
&
watchdog
,
"wdt"
,
RT_DEVICE_FLAG_DEACTIVATE
,
RT_NULL
)
!=
RT_EOK
)
{
LOG_E
(
"wdt device register failed."
);
return
-
RT_ERROR
;
}
LOG_D
(
"wdt device register success."
);
return
RT_EOK
;
}
INIT_BOARD_EXPORT
(
rt_hw_wdt_init
);
#endif
/* BSP_USING_WDT */
#endif
/* RT_USING_WDT */
bsp/n32g452xx/n32g452xx-mini-system/.config
浏览文件 @
d573f6f6
...
...
@@ -7,6 +7,7 @@
# RT-Thread Kernel
#
CONFIG_RT_NAME_MAX
=
8
# CONFIG_RT_USING_BIG_ENDIAN is not set
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set
# CONFIG_RT_USING_SMP is not set
CONFIG_RT_ALIGN_SIZE
=
4
...
...
@@ -142,7 +143,7 @@ CONFIG_RT_USING_PWM=y
# CONFIG_RT_USING_RTC is not set
# CONFIG_RT_USING_SDIO is not set
# CONFIG_RT_USING_SPI is not set
# CONFIG_RT_USING_WDT is not set
CONFIG_RT_USING_WDT
=
y
# CONFIG_RT_USING_AUDIO is not set
# CONFIG_RT_USING_SENSOR is not set
# CONFIG_RT_USING_TOUCH is not set
...
...
@@ -154,6 +155,7 @@ CONFIG_RT_USING_PWM=y
#
# Using USB
#
# CONFIG_RT_USING_USB is not set
# CONFIG_RT_USING_USB_HOST is not set
# CONFIG_RT_USING_USB_DEVICE is not set
...
...
@@ -161,10 +163,11 @@ CONFIG_RT_USING_PWM=y
# POSIX layer and C standard library
#
CONFIG_RT_USING_LIBC
=
y
# CONFIG_RT_USING_PTHREADS is not set
CONFIG_RT_LIBC_USING_TIME
=
y
# CONFIG_RT_LIBC_USING_FILEIO is not set
# CONFIG_RT_USING_MODULE is not set
CONFIG_RT_LIBC_DEFAULT_TIMEZONE
=
8
# CONFIG_RT_USING_PTHREADS is not set
#
# Network
...
...
@@ -201,6 +204,7 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
# CONFIG_RT_USING_RYM is not set
# CONFIG_RT_USING_ULOG is not set
# CONFIG_RT_USING_UTEST is not set
# CONFIG_RT_USING_VAR_EXPORT is not set
# CONFIG_RT_USING_RT_LINK is not set
#
...
...
@@ -297,10 +301,6 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
# CONFIG_PKG_USING_AGILE_FTP is not set
# CONFIG_PKG_USING_EMBEDDEDPROTO is not set
# CONFIG_PKG_USING_RT_LINK_HW is not set
# CONFIG_PKG_USING_LORA_PKT_FWD is not set
# CONFIG_PKG_USING_LORA_GW_DRIVER_LIB is not set
# CONFIG_PKG_USING_LORA_PKT_SNIFFER is not set
# CONFIG_PKG_USING_HM is not set
#
# security packages
...
...
@@ -334,13 +334,6 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
# CONFIG_PKG_USING_NUEMWIN is not set
# CONFIG_PKG_USING_MP3PLAYER is not set
# CONFIG_PKG_USING_TINYJPEG is not set
# CONFIG_PKG_USING_UGUI is not set
#
# U8G2: a monochrome graphic library
#
# CONFIG_PKG_USING_U8G2_OFFICIAL is not set
# CONFIG_PKG_USING_U8G2 is not set
#
# tools packages
...
...
@@ -449,6 +442,7 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
# CONFIG_PKG_USING_AS7341 is not set
# CONFIG_PKG_USING_STM32_SDIO is not set
# CONFIG_PKG_USING_ICM20608 is not set
# CONFIG_PKG_USING_U8G2 is not set
# CONFIG_PKG_USING_BUTTON is not set
# CONFIG_PKG_USING_PCF8574 is not set
# CONFIG_PKG_USING_SX12XX is not set
...
...
@@ -510,8 +504,6 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
# CONFIG_PKG_USING_MCP23008 is not set
# CONFIG_PKG_USING_BLUETRUM_SDK is not set
# CONFIG_PKG_USING_MISAKA_AT24CXX is not set
# CONFIG_PKG_USING_MISAKA_RGB_BLING is not set
# CONFIG_PKG_USING_BL_MCU_SDK is not set
#
# AI packages
...
...
@@ -594,6 +586,7 @@ CONFIG_SOC_N32G452XX=y
#
CONFIG_RT_USING_GPIO
=
y
# CONFIG_BSP_USING_ON_CHIP_FLASH is not set
# CONFIG_BSP_USING_WDT is not set
CONFIG_BSP_USING_UART
=
y
CONFIG_BSP_USING_UART1
=
y
# CONFIG_BSP_USING_UART2 is not set
...
...
bsp/n32g452xx/n32g452xx-mini-system/board/Kconfig
浏览文件 @
d573f6f6
...
...
@@ -26,7 +26,12 @@ menu "On-chip Peripheral Drivers"
config BSP_USING_ON_CHIP_FLASH
bool "Enable on-chip FLASH"
default n
default n
config BSP_USING_WDT
bool "Enable Watchdog Timer"
select RT_USING_WDT
default n
menuconfig BSP_USING_UART
bool "Enable UART"
...
...
bsp/n32g452xx/n32g452xx-mini-system/rtconfig.h
浏览文件 @
d573f6f6
...
...
@@ -85,6 +85,7 @@
#define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_PIN
#define RT_USING_PWM
#define RT_USING_WDT
/* Using USB */
...
...
@@ -143,9 +144,6 @@
/* multimedia packages */
/* U8G2: a monochrome graphic library */
/* tools packages */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录