mirror of
https://github.com/tsl0922/EPD-nRF5.git
synced 2025-12-12 16:38:13 +08:00
add factory reset cmd
This commit is contained in:
@@ -63,11 +63,15 @@ static uint32_t epd_config_load(epd_config_t *cfg)
|
||||
return pstorage_load((uint8_t *)cfg, &m_flash_handle, sizeof(epd_config_t), 0);
|
||||
}
|
||||
|
||||
static uint32_t epd_config_clear(epd_config_t *cfg)
|
||||
{
|
||||
return pstorage_clear(&m_flash_handle, sizeof(epd_config_t));
|
||||
}
|
||||
|
||||
static uint32_t epd_config_save(epd_config_t *cfg)
|
||||
{
|
||||
uint32_t err_code;
|
||||
err_code = pstorage_clear(&m_flash_handle, sizeof(epd_config_t));
|
||||
if (err_code != NRF_SUCCESS)
|
||||
uint32_t err_code;
|
||||
if ((err_code = epd_config_clear(cfg)) != NRF_SUCCESS)
|
||||
{
|
||||
return err_code;
|
||||
}
|
||||
@@ -193,6 +197,11 @@ static void epd_service_process(ble_epd_t * p_epd, uint8_t * p_data, uint16_t le
|
||||
sd_power_system_off();
|
||||
break;
|
||||
|
||||
case EPD_CMD_CFG_ERASE:
|
||||
epd_config_clear(&p_epd->config);
|
||||
NVIC_SystemReset();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -357,6 +366,11 @@ static void epd_config_init(ble_epd_t * p_epd)
|
||||
p_epd->config.driver_id = p_epd->driver->id;
|
||||
save_config = true;
|
||||
}
|
||||
if (p_epd->config.wakeup_pin == 0xFF)
|
||||
{
|
||||
p_epd->config.wakeup_pin = 7;
|
||||
save_config = true;
|
||||
}
|
||||
if (save_config)
|
||||
{
|
||||
epd_config_save(&p_epd->config);
|
||||
|
||||
@@ -54,6 +54,7 @@ enum EPD_CMDS
|
||||
EPD_CMD_SET_CONFIG = 0x90, /**< set full EPD config */
|
||||
EPD_CMD_SYS_RESET = 0x91, /**< MCU reset */
|
||||
EPD_CMD_SYS_SLEEP = 0x92, /**< MCU enter sleep mode */
|
||||
EPD_CMD_CFG_ERASE = 0x99, /**< Erase config and reset */
|
||||
};
|
||||
|
||||
/**< EPD driver IDs. */
|
||||
|
||||
@@ -105,6 +105,7 @@
|
||||
<li><code>90</code>+<code>配置</code>: 写入配置信息(重启生效,格式参考源码 <code>epd_config_t</code>)</li>
|
||||
<li><code>91</code>: 系统重启</li>
|
||||
<li><code>92</code>: 系统睡眠</li>
|
||||
<li><code>99</code>: 恢复默认设置并重启</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user