mirror of
https://github.com/jam422470459/EPD-nRF52-hema213.git
synced 2025-12-07 17:12:48 +08:00
enable wdt support
This commit is contained in:
@@ -340,7 +340,7 @@
|
||||
<MiscControls>--locale=english</MiscControls>
|
||||
<Define>BLE_STACK_SUPPORT_REQD NRF51822 NRF_SD_BLE_API_VERSION=2 S130 NRF51 SOFTDEVICE_PRESENT NRF_DFU_SETTINGS_VERSION=1 SWI_DISABLE0 __HEAP_SIZE=4096 __STACK_SIZE=1200</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\config;..\EPD;..\GUI;..\SDK\12.3.0_d7731ad;..\SDK\12.3.0_d7731ad\components\toolchain;..\SDK\12.3.0_d7731ad\components\toolchain\cmsis\include;..\SDK\12.3.0_d7731ad\components\drivers_nrf\clock;..\SDK\12.3.0_d7731ad\components\drivers_nrf\common;..\SDK\12.3.0_d7731ad\components\drivers_nrf\delay;..\SDK\12.3.0_d7731ad\components\drivers_nrf\gpiote;..\SDK\12.3.0_d7731ad\components\drivers_nrf\hal;..\SDK\12.3.0_d7731ad\components\drivers_nrf\spi_master;..\SDK\12.3.0_d7731ad\components\drivers_nrf\twi_master;..\SDK\12.3.0_d7731ad\external\segger_rtt;..\SDK\12.3.0_d7731ad\components\libraries\bootloader\dfu;..\SDK\12.3.0_d7731ad\components\libraries\crc32;..\SDK\12.3.0_d7731ad\components\libraries\fds;..\SDK\12.3.0_d7731ad\components\libraries\fstorage;..\SDK\12.3.0_d7731ad\components\libraries\experimental_section_vars;..\SDK\12.3.0_d7731ad\components\libraries\log;..\SDK\12.3.0_d7731ad\components\libraries\log\src;..\SDK\12.3.0_d7731ad\components\libraries\pwr_mgmt;..\SDK\12.3.0_d7731ad\components\libraries\scheduler;..\SDK\12.3.0_d7731ad\components\libraries\trace;..\SDK\12.3.0_d7731ad\components\libraries\timer;..\SDK\12.3.0_d7731ad\components\libraries\util;..\SDK\12.3.0_d7731ad\components\ble\common;..\SDK\12.3.0_d7731ad\components\ble\ble_advertising;..\SDK\12.3.0_d7731ad\components\ble\ble_services\ble_dfu;..\SDK\12.3.0_d7731ad\components\softdevice\common\softdevice_handler;..\SDK\12.3.0_d7731ad\components\softdevice\s130\headers;..\SDK\12.3.0_d7731ad\components\softdevice\s130\headers\nrf51</IncludePath>
|
||||
<IncludePath>..\EPD;..\GUI;..\SDK\12.3.0_d7731ad;..\SDK\12.3.0_d7731ad\components\toolchain;..\SDK\12.3.0_d7731ad\components\toolchain\cmsis\include;..\SDK\12.3.0_d7731ad\components\drivers_nrf\clock;..\SDK\12.3.0_d7731ad\components\drivers_nrf\common;..\SDK\12.3.0_d7731ad\components\drivers_nrf\delay;..\SDK\12.3.0_d7731ad\components\drivers_nrf\gpiote;..\SDK\12.3.0_d7731ad\components\drivers_nrf\hal;..\SDK\12.3.0_d7731ad\components\drivers_nrf\spi_master;..\SDK\12.3.0_d7731ad\components\drivers_nrf\twi_master;..\SDK\12.3.0_d7731ad\components\drivers_nrf\wdt;..\SDK\12.3.0_d7731ad\external\segger_rtt;..\SDK\12.3.0_d7731ad\components\libraries\bootloader\dfu;..\SDK\12.3.0_d7731ad\components\libraries\crc32;..\SDK\12.3.0_d7731ad\components\libraries\fds;..\SDK\12.3.0_d7731ad\components\libraries\fstorage;..\SDK\12.3.0_d7731ad\components\libraries\experimental_section_vars;..\SDK\12.3.0_d7731ad\components\libraries\log;..\SDK\12.3.0_d7731ad\components\libraries\log\src;..\SDK\12.3.0_d7731ad\components\libraries\pwr_mgmt;..\SDK\12.3.0_d7731ad\components\libraries\scheduler;..\SDK\12.3.0_d7731ad\components\libraries\trace;..\SDK\12.3.0_d7731ad\components\libraries\timer;..\SDK\12.3.0_d7731ad\components\libraries\util;..\SDK\12.3.0_d7731ad\components\ble\common;..\SDK\12.3.0_d7731ad\components\ble\ble_advertising;..\SDK\12.3.0_d7731ad\components\ble\ble_services\ble_dfu;..\SDK\12.3.0_d7731ad\components\softdevice\common\softdevice_handler;..\SDK\12.3.0_d7731ad\components\softdevice\s130\headers;..\SDK\12.3.0_d7731ad\components\softdevice\s130\headers\nrf51</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@@ -524,6 +524,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\SDK\12.3.0_d7731ad\components\drivers_nrf\spi_master\nrf_drv_spi.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>nrf_drv_wdt.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\SDK\12.3.0_d7731ad\components\drivers_nrf\wdt\nrf_drv_wdt.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
@@ -1156,6 +1161,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\SDK\12.3.0_d7731ad\components\drivers_nrf\spi_master\nrf_drv_spi.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>nrf_drv_wdt.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\SDK\12.3.0_d7731ad\components\drivers_nrf\wdt\nrf_drv_wdt.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
||||
@@ -340,7 +340,7 @@
|
||||
<MiscControls>--locale=english --reduce_paths</MiscControls>
|
||||
<Define>APP_TIMER_V2 APP_TIMER_V2_RTC1_ENABLED CONFIG_GPIO_AS_PINRESET DEVELOP_IN_NRF52840 FLOAT_ABI_SOFT NRF52811_XXAA NRFX_COREDEP_DELAY_US_LOOP_CYCLES=3 NRF_DFU_SVCI_ENABLED NRF_DFU_TRANSPORT_BLE=1 NRF_SD_BLE_API_VERSION=7 S112 SOFTDEVICE_PRESENT __HEAP_SIZE=8192 __STACK_SIZE=2048</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\config;..\EPD;..\GUI;..\SDK\17.1.0_ddde560;..\SDK\17.1.0_ddde560\components\ble\common;..\SDK\17.1.0_ddde560\components\ble\ble_advertising;..\SDK\17.1.0_ddde560\components\ble\nrf_ble_gatt;..\SDK\17.1.0_ddde560\components\ble\ble_services\ble_dfu;..\SDK\17.1.0_ddde560\components\libraries\atomic;..\SDK\17.1.0_ddde560\components\libraries\atomic_fifo;..\SDK\17.1.0_ddde560\components\libraries\atomic_flags;..\SDK\17.1.0_ddde560\components\libraries\balloc;..\SDK\17.1.0_ddde560\components\libraries\bootloader;..\SDK\17.1.0_ddde560\components\libraries\bootloader\ble_dfu;..\SDK\17.1.0_ddde560\components\libraries\bootloader\dfu;..\SDK\17.1.0_ddde560\components\libraries\delay;..\SDK\17.1.0_ddde560\components\libraries\fstorage;..\SDK\17.1.0_ddde560\components\libraries\fds;..\SDK\17.1.0_ddde560\components\libraries\experimental_section_vars;..\SDK\17.1.0_ddde560\components\libraries\log;..\SDK\17.1.0_ddde560\components\libraries\log\src;..\SDK\17.1.0_ddde560\components\libraries\memobj;..\SDK\17.1.0_ddde560\components\libraries\mutex;..\SDK\17.1.0_ddde560\components\libraries\pwr_mgmt;..\SDK\17.1.0_ddde560\components\libraries\ringbuf;..\SDK\17.1.0_ddde560\components\libraries\sortlist;..\SDK\17.1.0_ddde560\components\libraries\scheduler;..\SDK\17.1.0_ddde560\components\libraries\strerror;..\SDK\17.1.0_ddde560\components\libraries\svc;..\SDK\17.1.0_ddde560\components\libraries\timer;..\SDK\17.1.0_ddde560\components\libraries\util;..\SDK\17.1.0_ddde560\components\softdevice\common;..\SDK\17.1.0_ddde560\components\softdevice\s112\headers;..\SDK\17.1.0_ddde560\components\softdevice\s112\headers\nrf52;..\SDK\17.1.0_ddde560\components\toolchain\cmsis\include;..\SDK\17.1.0_ddde560\external\fprintf;..\SDK\17.1.0_ddde560\external\segger_rtt;..\SDK\17.1.0_ddde560\integration\nrfx;..\SDK\17.1.0_ddde560\integration\nrfx\legacy;..\SDK\17.1.0_ddde560\modules\nrfx;..\SDK\17.1.0_ddde560\modules\nrfx\mdk;..\SDK\17.1.0_ddde560\modules\nrfx\drivers\include;..\SDK\17.1.0_ddde560\modules\nrfx\hal</IncludePath>
|
||||
<IncludePath>..\EPD;..\GUI;..\SDK\17.1.0_ddde560;..\SDK\17.1.0_ddde560\components\ble\common;..\SDK\17.1.0_ddde560\components\ble\ble_advertising;..\SDK\17.1.0_ddde560\components\ble\nrf_ble_gatt;..\SDK\17.1.0_ddde560\components\ble\ble_services\ble_dfu;..\SDK\17.1.0_ddde560\components\libraries\atomic;..\SDK\17.1.0_ddde560\components\libraries\atomic_fifo;..\SDK\17.1.0_ddde560\components\libraries\atomic_flags;..\SDK\17.1.0_ddde560\components\libraries\balloc;..\SDK\17.1.0_ddde560\components\libraries\bootloader;..\SDK\17.1.0_ddde560\components\libraries\bootloader\ble_dfu;..\SDK\17.1.0_ddde560\components\libraries\bootloader\dfu;..\SDK\17.1.0_ddde560\components\libraries\delay;..\SDK\17.1.0_ddde560\components\libraries\fstorage;..\SDK\17.1.0_ddde560\components\libraries\fds;..\SDK\17.1.0_ddde560\components\libraries\experimental_section_vars;..\SDK\17.1.0_ddde560\components\libraries\log;..\SDK\17.1.0_ddde560\components\libraries\log\src;..\SDK\17.1.0_ddde560\components\libraries\memobj;..\SDK\17.1.0_ddde560\components\libraries\mutex;..\SDK\17.1.0_ddde560\components\libraries\pwr_mgmt;..\SDK\17.1.0_ddde560\components\libraries\ringbuf;..\SDK\17.1.0_ddde560\components\libraries\sortlist;..\SDK\17.1.0_ddde560\components\libraries\scheduler;..\SDK\17.1.0_ddde560\components\libraries\strerror;..\SDK\17.1.0_ddde560\components\libraries\svc;..\SDK\17.1.0_ddde560\components\libraries\timer;..\SDK\17.1.0_ddde560\components\libraries\util;..\SDK\17.1.0_ddde560\components\softdevice\common;..\SDK\17.1.0_ddde560\components\softdevice\s112\headers;..\SDK\17.1.0_ddde560\components\softdevice\s112\headers\nrf52;..\SDK\17.1.0_ddde560\components\toolchain\cmsis\include;..\SDK\17.1.0_ddde560\external\fprintf;..\SDK\17.1.0_ddde560\external\segger_rtt;..\SDK\17.1.0_ddde560\integration\nrfx;..\SDK\17.1.0_ddde560\integration\nrfx\legacy;..\SDK\17.1.0_ddde560\modules\nrfx;..\SDK\17.1.0_ddde560\modules\nrfx\mdk;..\SDK\17.1.0_ddde560\modules\nrfx\drivers\include;..\SDK\17.1.0_ddde560\modules\nrfx\hal</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@@ -544,6 +544,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\SDK\17.1.0_ddde560\modules\nrfx\drivers\src\nrfx_spim.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>nrfx_wdt.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\SDK\17.1.0_ddde560\modules\nrfx\drivers\src\nrfx_wdt.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
@@ -1296,6 +1301,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\SDK\17.1.0_ddde560\modules\nrfx\drivers\src\nrfx_spim.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>nrfx_wdt.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\SDK\17.1.0_ddde560\modules\nrfx\drivers\src\nrfx_wdt.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
||||
@@ -32,6 +32,7 @@ SRC_FILES += \
|
||||
$(SDK_ROOT)/components/drivers_nrf/clock/nrf_drv_clock.c \
|
||||
$(SDK_ROOT)/components/drivers_nrf/gpiote/nrf_drv_gpiote.c \
|
||||
$(SDK_ROOT)/components/drivers_nrf/spi_master/nrf_drv_spi.c \
|
||||
$(SDK_ROOT)/components/drivers_nrf/wdt/nrf_drv_wdt.c \
|
||||
$(SDK_ROOT)/components/toolchain/gcc/gcc_startup_nrf51.s \
|
||||
$(SDK_ROOT)/components/toolchain/system_nrf51.c \
|
||||
$(SDK_ROOT)/components/softdevice/common/softdevice_handler/softdevice_handler.c \
|
||||
@@ -63,6 +64,7 @@ INC_FOLDERS += \
|
||||
$(SDK_ROOT)/components/drivers_nrf/delay \
|
||||
$(SDK_ROOT)/components/drivers_nrf/gpiote \
|
||||
$(SDK_ROOT)/components/drivers_nrf/spi_master \
|
||||
$(SDK_ROOT)/components/drivers_nrf/wdt \
|
||||
$(SDK_ROOT)/components/libraries/fstorage \
|
||||
$(SDK_ROOT)/components/libraries/experimental_section_vars \
|
||||
$(SDK_ROOT)/components/libraries/bootloader/dfu \
|
||||
|
||||
@@ -59,6 +59,7 @@ SRC_FILES += \
|
||||
$(SDK_ROOT)/modules/nrfx/drivers/src/prs/nrfx_prs.c \
|
||||
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_spi.c \
|
||||
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_spim.c \
|
||||
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_wdt.c \
|
||||
$(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_clock.c \
|
||||
$(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_spi.c \
|
||||
$(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52811.S \
|
||||
|
||||
@@ -2829,7 +2829,7 @@
|
||||
// <e> WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver
|
||||
//==========================================================
|
||||
#ifndef WDT_ENABLED
|
||||
#define WDT_ENABLED 0
|
||||
#define WDT_ENABLED 1
|
||||
#endif
|
||||
#if WDT_ENABLED
|
||||
// <o> WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode
|
||||
@@ -2847,7 +2847,7 @@
|
||||
|
||||
|
||||
#ifndef WDT_CONFIG_RELOAD_VALUE
|
||||
#define WDT_CONFIG_RELOAD_VALUE 2000
|
||||
#define WDT_CONFIG_RELOAD_VALUE 60000
|
||||
#endif
|
||||
|
||||
// <o> WDT_CONFIG_IRQ_PRIORITY - Interrupt priority
|
||||
|
||||
@@ -5369,7 +5369,7 @@
|
||||
// <e> WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer
|
||||
//==========================================================
|
||||
#ifndef WDT_ENABLED
|
||||
#define WDT_ENABLED 0
|
||||
#define WDT_ENABLED 1
|
||||
#endif
|
||||
// <o> WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode
|
||||
|
||||
@@ -5386,7 +5386,7 @@
|
||||
|
||||
|
||||
#ifndef WDT_CONFIG_RELOAD_VALUE
|
||||
#define WDT_CONFIG_RELOAD_VALUE 2000
|
||||
#define WDT_CONFIG_RELOAD_VALUE 60000
|
||||
#endif
|
||||
|
||||
// <o> WDT_CONFIG_IRQ_PRIORITY - Interrupt priority
|
||||
|
||||
21
main.c
21
main.c
@@ -36,6 +36,7 @@
|
||||
#include "app_timer.h"
|
||||
#include "app_scheduler.h"
|
||||
#include "nrf_drv_gpiote.h"
|
||||
#include "nrf_drv_wdt.h"
|
||||
#include "nrf_pwr_mgmt.h"
|
||||
#include "EPD_service.h"
|
||||
|
||||
@@ -95,6 +96,7 @@ static ble_uuid_t m_adv_uuids[] = {{BLE_UUID_EPD_SVC, \
|
||||
BLE_EPD_DEF(m_epd); /**< Structure to identify the EPD Service. */
|
||||
static uint32_t m_timestamp = 1735689600; /**< Current timestamp. */
|
||||
APP_TIMER_DEF(m_clock_timer_id); /**< Clock timer. */
|
||||
static nrf_drv_wdt_channel_id m_wdt_channel_id;
|
||||
|
||||
/**@brief Callback function for asserts in the SoftDevice.
|
||||
*
|
||||
@@ -711,10 +713,23 @@ static void power_management_init(void)
|
||||
*/
|
||||
static void idle_state_handle(void)
|
||||
{
|
||||
if (m_timestamp % 30 == 0) {
|
||||
NRF_LOG_DEBUG("Feed WDT\n");
|
||||
nrf_drv_wdt_channel_feed(m_wdt_channel_id);
|
||||
}
|
||||
|
||||
if (NRF_LOG_PROCESS() == false)
|
||||
nrf_pwr_mgmt_run();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WDT events handler.
|
||||
*/
|
||||
void wdt_event_handler(void)
|
||||
{
|
||||
//NOTE: The max amount of time we can spend in WDT interrupt is two cycles of 32768[Hz] clock - after that, reset occurs
|
||||
}
|
||||
|
||||
/**@brief Function for application main entry.
|
||||
*/
|
||||
int main(void)
|
||||
@@ -723,6 +738,12 @@ int main(void)
|
||||
|
||||
NRF_LOG_DEBUG("init..\n");
|
||||
|
||||
// Configure WDT.
|
||||
nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
|
||||
APP_ERROR_CHECK(nrf_drv_wdt_init(&config, wdt_event_handler));
|
||||
APP_ERROR_CHECK(nrf_drv_wdt_channel_alloc(&m_wdt_channel_id));
|
||||
nrf_drv_wdt_enable();
|
||||
|
||||
timers_init();
|
||||
power_management_init();
|
||||
ble_stack_init();
|
||||
|
||||
Reference in New Issue
Block a user