ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
dfu.cpp
Go to the documentation of this file.
1#include "dfu.h"
2
3#ifdef USE_NRF52_DFU
4
5#include "esphome/core/log.h"
7
8namespace esphome {
9namespace nrf52 {
10
11static const char *const TAG = "dfu";
12
13static const uint32_t DFU_DBL_RESET_MAGIC = 0x5A1AD5; // SALADS
14
16 this->reset_pin_->setup();
17#if defined(CONFIG_CDC_ACM_DTE_RATE_CALLBACK_SUPPORT)
18 zephyr::global_cdc_acm->add_on_rate_callback([this](const device *, uint32_t rate) {
19 if (rate == 1200) {
20 volatile uint32_t *dbl_reset_mem = (volatile uint32_t *) 0x20007F7C;
21 (*dbl_reset_mem) = DFU_DBL_RESET_MAGIC;
22 this->reset_pin_->digital_write(true);
23 }
24 });
25#endif
26}
27
29 ESP_LOGCONFIG(TAG, "DFU:");
30 LOG_PIN(" RESET Pin: ", this->reset_pin_);
31}
32
33} // namespace nrf52
34} // namespace esphome
35
36#endif
virtual void setup()=0
virtual void digital_write(bool value)=0
void add_on_rate_callback(F &&callback)
Definition cdc_acm.h:14
CdcAcm * global_cdc_acm
Definition cdc_acm.cpp:26
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
static void uint32_t