mirror of
https://github.com/tsl0922/EPD-nRF5.git
synced 2025-12-05 15:32:48 +08:00
fix wdt reset on scheduler
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "nrf_pwr_mgmt.h"
|
||||
#include "app_scheduler.h"
|
||||
#include "EPD_service.h"
|
||||
#include "main.h"
|
||||
#include "nrf_log.h"
|
||||
|
||||
#if defined(S112)
|
||||
@@ -31,11 +32,6 @@
|
||||
#define EPD_CFG_DEFAULT {0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x03, 0x09, 0x03}
|
||||
#endif
|
||||
|
||||
// defined in main.c
|
||||
extern uint32_t timestamp(void);
|
||||
extern void set_timestamp(uint32_t timestamp);
|
||||
extern void sleep_mode_enter(void);
|
||||
|
||||
static void epd_gui_update(void * p_event_data, uint16_t event_size)
|
||||
{
|
||||
epd_gui_update_event_t *event = (epd_gui_update_event_t *)p_event_data;
|
||||
@@ -54,6 +50,8 @@ static void epd_gui_update(void * p_event_data, uint16_t event_size)
|
||||
DrawGUI(&data, epd->drv->write_image, p_epd->display_mode);
|
||||
epd->drv->refresh();
|
||||
EPD_GPIO_Uninit();
|
||||
|
||||
app_feed_wdt();
|
||||
}
|
||||
|
||||
/**@brief Function for handling the @ref BLE_GAP_EVT_CONNECTED event from the S110 SoftDevice.
|
||||
|
||||
@@ -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>..\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>
|
||||
<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>
|
||||
|
||||
@@ -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>..\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>
|
||||
|
||||
@@ -85,7 +85,8 @@ INC_FOLDERS += \
|
||||
$(SDK_ROOT)/external/segger_rtt \
|
||||
$(SDK_ROOT) \
|
||||
$(PROJ_DIR)/EPD \
|
||||
$(PROJ_DIR)/GUI
|
||||
$(PROJ_DIR)/GUI \
|
||||
$(PROJ_DIR)
|
||||
|
||||
# Libraries common to all targets
|
||||
LIB_FILES += \
|
||||
|
||||
@@ -119,7 +119,8 @@ INC_FOLDERS += \
|
||||
$(SDK_ROOT)/modules/nrfx/hal \
|
||||
$(SDK_ROOT) \
|
||||
$(PROJ_DIR)/EPD \
|
||||
$(PROJ_DIR)/GUI
|
||||
$(PROJ_DIR)/GUI \
|
||||
$(PROJ_DIR)
|
||||
|
||||
# Libraries common to all targets
|
||||
LIB_FILES += \
|
||||
|
||||
51
main.c
51
main.c
@@ -39,6 +39,7 @@
|
||||
#include "nrf_drv_wdt.h"
|
||||
#include "nrf_pwr_mgmt.h"
|
||||
#include "EPD_service.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "nrf_log.h"
|
||||
#include "nrf_log_ctrl.h"
|
||||
@@ -115,6 +116,30 @@ void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name)
|
||||
app_error_handler(DEAD_BEEF, line_num, p_file_name);
|
||||
}
|
||||
|
||||
// return current timestamp
|
||||
uint32_t timestamp(void)
|
||||
{
|
||||
return m_timestamp;
|
||||
}
|
||||
|
||||
// set the timestamp
|
||||
void set_timestamp(uint32_t timestamp)
|
||||
{
|
||||
app_timer_stop(m_clock_timer_id);
|
||||
m_timestamp = timestamp;
|
||||
app_timer_start(m_clock_timer_id, CLOCK_TIMER_INTERVAL, NULL);
|
||||
}
|
||||
|
||||
// reload the wdt channel
|
||||
void app_feed_wdt(void)
|
||||
{
|
||||
if (m_timestamp - m_wdt_last_feed_time >= 30) {
|
||||
NRF_LOG_DEBUG("Feed WDT\n");
|
||||
nrf_drv_wdt_channel_feed(m_wdt_channel_id);
|
||||
m_wdt_last_feed_time = m_timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(S112)
|
||||
static void buttonless_dfu_sdh_state_observer(nrf_sdh_state_evt_t state, void * p_context)
|
||||
{
|
||||
@@ -674,19 +699,6 @@ static void advertising_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
// return current timestamp
|
||||
uint32_t timestamp(void)
|
||||
{
|
||||
return m_timestamp;
|
||||
}
|
||||
|
||||
void set_timestamp(uint32_t timestamp)
|
||||
{
|
||||
app_timer_stop(m_clock_timer_id);
|
||||
m_timestamp = timestamp;
|
||||
app_timer_start(m_clock_timer_id, CLOCK_TIMER_INTERVAL, NULL);
|
||||
}
|
||||
|
||||
/**@brief Function for initializing the nrf log module.
|
||||
*/
|
||||
static void log_init(void)
|
||||
@@ -714,11 +726,7 @@ static void power_management_init(void)
|
||||
*/
|
||||
static void idle_state_handle(void)
|
||||
{
|
||||
if (m_timestamp - m_wdt_last_feed_time >= 30) {
|
||||
NRF_LOG_DEBUG("Feed WDT\n");
|
||||
nrf_drv_wdt_channel_feed(m_wdt_channel_id);
|
||||
m_wdt_last_feed_time = m_timestamp;
|
||||
}
|
||||
app_feed_wdt();
|
||||
|
||||
if (NRF_LOG_PROCESS() == false)
|
||||
nrf_pwr_mgmt_run();
|
||||
@@ -730,6 +738,8 @@ static void idle_state_handle(void)
|
||||
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
|
||||
NRF_LOG_ERROR("WDT Rest!\r\n");
|
||||
NRF_LOG_FINAL_FLUSH();
|
||||
}
|
||||
|
||||
/**@brief Function for application main entry.
|
||||
@@ -738,6 +748,11 @@ int main(void)
|
||||
{
|
||||
log_init();
|
||||
|
||||
if (nrf_power_resetreas_get() & NRF_POWER_RESETREAS_DOG_MASK) {
|
||||
NRF_LOG_DEBUG("!!!reset from WDT!!!\n");
|
||||
nrf_power_resetreas_clear(NRF_POWER_RESETREAS_DOG_MASK);
|
||||
}
|
||||
|
||||
NRF_LOG_DEBUG("init..\n");
|
||||
|
||||
// Configure WDT.
|
||||
|
||||
Reference in New Issue
Block a user