mirror of
https://github.com/esphome/esphome.git
synced 2025-10-25 05:03:52 +01:00
fix clang-format
This commit is contained in:
@@ -302,8 +302,8 @@ float ADCSensor::sample() {
|
|||||||
// With internal reference, single-ended input (grounded negative input) and a gain of 1/6, the input range will be:
|
// With internal reference, single-ended input (grounded negative input) and a gain of 1/6, the input range will be:
|
||||||
// Input range = (0.6 V)/(1/6) = 3.6 V
|
// Input range = (0.6 V)/(1/6) = 3.6 V
|
||||||
|
|
||||||
uint32_t raw = analogRead(this->pin_->get_pin()); // NOLINT
|
uint32_t raw = analogRead(this->pin_->get_pin()); // NOLINT
|
||||||
if(output_raw_) {
|
if (output_raw_) {
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
// default 10-bit resolution
|
// default 10-bit resolution
|
||||||
|
|||||||
@@ -12,20 +12,17 @@
|
|||||||
// - on Android you may need change the MANUFACTURER_ID to Nordic
|
// - on Android you may need change the MANUFACTURER_ID to Nordic
|
||||||
// - on iOS you may need to change the MANUFACTURER_ID to Apple.
|
// - on iOS you may need to change the MANUFACTURER_ID to Apple.
|
||||||
// You will also need to "Add Other Beacon, then enter Major, Minor that you set in the sketch
|
// You will also need to "Add Other Beacon, then enter Major, Minor that you set in the sketch
|
||||||
#define MANUFACTURER_ID 0x0059
|
#define MANUFACTURER_ID 0x0059
|
||||||
|
|
||||||
// "nRF Connect" app can be used to detect beacon
|
// "nRF Connect" app can be used to detect beacon
|
||||||
uint8_t beaconUuid[16] = {
|
uint8_t beaconUuid[16] = {0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78,
|
||||||
0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78,
|
0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0};
|
||||||
0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0
|
|
||||||
};
|
|
||||||
|
|
||||||
// A valid Beacon packet consists of the following information:
|
// A valid Beacon packet consists of the following information:
|
||||||
// UUID, Major, Minor, RSSI @ 1M
|
// UUID, Major, Minor, RSSI @ 1M
|
||||||
BLEBeacon beacon(beaconUuid, 1, 2, -54);
|
BLEBeacon beacon(beaconUuid, 1, 2, -54);
|
||||||
|
|
||||||
void startAdv(void)
|
void startAdv(void) {
|
||||||
{
|
|
||||||
// Advertising packet
|
// Advertising packet
|
||||||
// Set the beacon payload using the BLEBeacon class populated
|
// Set the beacon payload using the BLEBeacon class populated
|
||||||
// earlier in this example
|
// earlier in this example
|
||||||
@@ -34,35 +31,34 @@ void startAdv(void)
|
|||||||
// Secondary Scan Response packet (optional)
|
// Secondary Scan Response packet (optional)
|
||||||
// Since there is no room for 'Name' in Advertising packet
|
// Since there is no room for 'Name' in Advertising packet
|
||||||
Bluefruit.ScanResponse.addName();
|
Bluefruit.ScanResponse.addName();
|
||||||
|
|
||||||
/* Start Advertising
|
/* Start Advertising
|
||||||
* - Enable auto advertising if disconnected
|
* - Enable auto advertising if disconnected
|
||||||
* - Timeout for fast mode is 30 seconds
|
* - Timeout for fast mode is 30 seconds
|
||||||
* - Start(timeout) with timeout = 0 will advertise forever (until connected)
|
* - Start(timeout) with timeout = 0 will advertise forever (until connected)
|
||||||
*
|
*
|
||||||
* Apple Beacon specs
|
* Apple Beacon specs
|
||||||
* - Type: Non-connectable, scannable, undirected
|
* - Type: Non-connectable, scannable, undirected
|
||||||
* - Fixed interval: 100 ms -> fast = slow = 100 ms
|
* - Fixed interval: 100 ms -> fast = slow = 100 ms
|
||||||
*/
|
*/
|
||||||
Bluefruit.Advertising.setType(BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED);
|
Bluefruit.Advertising.setType(BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED);
|
||||||
Bluefruit.Advertising.restartOnDisconnect(true);
|
Bluefruit.Advertising.restartOnDisconnect(true);
|
||||||
Bluefruit.Advertising.setInterval(160, 160); // in unit of 0.625 ms
|
Bluefruit.Advertising.setInterval(160, 160); // in unit of 0.625 ms
|
||||||
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
||||||
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
|
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace ble {
|
namespace ble {
|
||||||
|
|
||||||
void Beacon::loop() {
|
void Beacon::loop() {}
|
||||||
}
|
|
||||||
|
|
||||||
void Beacon::setup(){
|
void Beacon::setup() {
|
||||||
Bluefruit.begin();
|
Bluefruit.begin();
|
||||||
|
|
||||||
// off Blue LED for lowest power consumption
|
// off Blue LED for lowest power consumption
|
||||||
Bluefruit.autoConnLed(false);
|
Bluefruit.autoConnLed(false);
|
||||||
Bluefruit.setTxPower(0); // Check bluefruit.h for supported values
|
Bluefruit.setTxPower(0); // Check bluefruit.h for supported values
|
||||||
Bluefruit.setName("ESPHome");
|
Bluefruit.setName("ESPHome");
|
||||||
|
|
||||||
// Manufacturer ID is required for Manufacturer Specific Data
|
// Manufacturer ID is required for Manufacturer Specific Data
|
||||||
@@ -72,5 +68,5 @@ void Beacon::setup(){
|
|||||||
startAdv();
|
startAdv();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dfu
|
} // namespace ble
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace ble {
|
namespace ble {
|
||||||
class Beacon : public Component {
|
class Beacon : public Component {
|
||||||
void loop() override;
|
void loop() override;
|
||||||
void setup() override;
|
void setup() override;
|
||||||
};
|
};
|
||||||
}
|
} // namespace ble
|
||||||
}
|
} // namespace esphome
|
||||||
|
|||||||
@@ -54,39 +54,39 @@ static uint32_t get_free_heap() {
|
|||||||
#elif defined(USE_LIBRETINY)
|
#elif defined(USE_LIBRETINY)
|
||||||
return lt_heap_get_free();
|
return lt_heap_get_free();
|
||||||
#elif defined(USE_NRF52)
|
#elif defined(USE_NRF52)
|
||||||
//TODO
|
// TODO
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_NRF52) && defined(USE_ARDUINO)
|
#if defined(USE_NRF52) && defined(USE_ARDUINO)
|
||||||
static std::string nrf52_get_reset_reason_name(){
|
static std::string nrf52_get_reset_reason_name() {
|
||||||
uint32_t rr = readResetReason();
|
uint32_t rr = readResetReason();
|
||||||
if (rr & POWER_RESETREAS_VBUS_Msk){
|
if (rr & POWER_RESETREAS_VBUS_Msk) {
|
||||||
return "VBUS";
|
return "VBUS";
|
||||||
}
|
}
|
||||||
if (rr & POWER_RESETREAS_NFC_Msk){
|
if (rr & POWER_RESETREAS_NFC_Msk) {
|
||||||
return "NFC";
|
return "NFC";
|
||||||
}
|
}
|
||||||
if (rr & POWER_RESETREAS_DIF_Msk){
|
if (rr & POWER_RESETREAS_DIF_Msk) {
|
||||||
return "DIF";
|
return "DIF";
|
||||||
}
|
}
|
||||||
if (rr & POWER_RESETREAS_LPCOMP_Msk){
|
if (rr & POWER_RESETREAS_LPCOMP_Msk) {
|
||||||
return "LPCOMP";
|
return "LPCOMP";
|
||||||
}
|
}
|
||||||
if (rr & POWER_RESETREAS_OFF_Msk){
|
if (rr & POWER_RESETREAS_OFF_Msk) {
|
||||||
return "OFF";
|
return "OFF";
|
||||||
}
|
}
|
||||||
if (rr & POWER_RESETREAS_LOCKUP_Msk){
|
if (rr & POWER_RESETREAS_LOCKUP_Msk) {
|
||||||
return "LOCKUP";
|
return "LOCKUP";
|
||||||
}
|
}
|
||||||
if (rr & POWER_RESETREAS_SREQ_Msk){
|
if (rr & POWER_RESETREAS_SREQ_Msk) {
|
||||||
return "SREQ";
|
return "SREQ";
|
||||||
}
|
}
|
||||||
if (rr & POWER_RESETREAS_DOG_Msk){
|
if (rr & POWER_RESETREAS_DOG_Msk) {
|
||||||
return "DOG";
|
return "DOG";
|
||||||
}
|
}
|
||||||
if (rr & POWER_RESETREAS_RESETPIN_Msk){
|
if (rr & POWER_RESETREAS_RESETPIN_Msk) {
|
||||||
return "RESETPIN";
|
return "RESETPIN";
|
||||||
}
|
}
|
||||||
return "NONE";
|
return "NONE";
|
||||||
@@ -415,10 +415,13 @@ void DebugComponent::dump_config() {
|
|||||||
#endif // USE_LIBRETINY
|
#endif // USE_LIBRETINY
|
||||||
|
|
||||||
#if defined(USE_NRF52) && defined(USE_ARDUINO)
|
#if defined(USE_NRF52) && defined(USE_ARDUINO)
|
||||||
//TODO fixme
|
// TODO fixme
|
||||||
ESP_LOGD(TAG, "bootloader version %lu.%lu.%lu", (bootloaderVersion >> 16) & 0xFF, (bootloaderVersion >> 8) & 0xFF, bootloaderVersion & 0xFF);
|
ESP_LOGD(TAG, "bootloader version %lu.%lu.%lu", (bootloaderVersion >> 16) & 0xFF, (bootloaderVersion >> 8) & 0xFF,
|
||||||
ESP_LOGD(TAG, "MBR bootloader addr 0x%08lx, UICR bootloader addr 0x%08lx", (*((uint32_t *)MBR_BOOTLOADER_ADDR)), NRF_UICR->NRFFW[0]);
|
bootloaderVersion & 0xFF);
|
||||||
ESP_LOGD(TAG, "MBR param page addr 0x%08lx, UICR param page addr 0x%08lx", (*((uint32_t *) MBR_PARAM_PAGE_ADDR)), NRF_UICR->NRFFW[1]);
|
ESP_LOGD(TAG, "MBR bootloader addr 0x%08lx, UICR bootloader addr 0x%08lx", (*((uint32_t *) MBR_BOOTLOADER_ADDR)),
|
||||||
|
NRF_UICR->NRFFW[0]);
|
||||||
|
ESP_LOGD(TAG, "MBR param page addr 0x%08lx, UICR param page addr 0x%08lx", (*((uint32_t *) MBR_PARAM_PAGE_ADDR)),
|
||||||
|
NRF_UICR->NRFFW[1]);
|
||||||
reset_reason = nrf52_get_reset_reason_name();
|
reset_reason = nrf52_get_reset_reason_name();
|
||||||
ESP_LOGD(TAG, "Reset Reason: %s", reset_reason.c_str());
|
ESP_LOGD(TAG, "Reset Reason: %s", reset_reason.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,33 +8,31 @@
|
|||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace deep_sleep {
|
namespace deep_sleep {
|
||||||
|
|
||||||
#define DFU_MAGIC_SKIP 0x6d
|
#define DFU_MAGIC_SKIP 0x6d
|
||||||
|
|
||||||
static const char *const TAG = "deep_sleep.nrf52";
|
static const char *const TAG = "deep_sleep.nrf52";
|
||||||
|
|
||||||
void Nrf52DeepSleepBackend::begin_sleep(const optional<uint64_t>& sleep_duration) {
|
void Nrf52DeepSleepBackend::begin_sleep(const optional<uint64_t> &sleep_duration) {
|
||||||
// RTC works only during System On
|
// RTC works only during System On
|
||||||
if (sleep_duration.has_value())
|
if (sleep_duration.has_value()) {
|
||||||
{
|
|
||||||
// TinyUSBDevice.detach();
|
// TinyUSBDevice.detach();
|
||||||
// TODO deinit USB
|
// TODO deinit USB
|
||||||
// TOOD and the rest of peripherals
|
// TOOD and the rest of peripherals
|
||||||
uint32_t start_time = millis();
|
uint32_t start_time = millis();
|
||||||
portSUPPRESS_TICKS_AND_SLEEP(ms2tick(*sleep_duration/1000));
|
portSUPPRESS_TICKS_AND_SLEEP(ms2tick(*sleep_duration / 1000));
|
||||||
last_sleep_duration_ = millis() - start_time;
|
last_sleep_duration_ = millis() - start_time;
|
||||||
// TinyUSBDevice.attach();
|
// TinyUSBDevice.attach();
|
||||||
} else {
|
} else {
|
||||||
NRF_POWER->GPREGRET = DFU_MAGIC_SKIP;
|
NRF_POWER->GPREGRET = DFU_MAGIC_SKIP;
|
||||||
// Enter System OFF.
|
// Enter System OFF.
|
||||||
#ifdef SOFTDEVICE_PRESENT
|
#ifdef SOFTDEVICE_PRESENT
|
||||||
uint8_t sd_en = 0;
|
uint8_t sd_en = 0;
|
||||||
(void) sd_softdevice_is_enabled(&sd_en);
|
(void) sd_softdevice_is_enabled(&sd_en);
|
||||||
if (sd_en)
|
if (sd_en) {
|
||||||
{
|
uint32_t ret_code = sd_power_system_off();
|
||||||
uint32_t ret_code = sd_power_system_off();
|
assert((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_SOFTDEVICE_NOT_ENABLED));
|
||||||
assert((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_SOFTDEVICE_NOT_ENABLED));
|
}
|
||||||
}
|
#endif // SOFTDEVICE_PRESENT
|
||||||
#endif // SOFTDEVICE_PRESENT
|
|
||||||
nrf_power_system_off(NRF_POWER);
|
nrf_power_system_off(NRF_POWER);
|
||||||
// it should never reach here...
|
// it should never reach here...
|
||||||
}
|
}
|
||||||
@@ -42,7 +40,7 @@ void Nrf52DeepSleepBackend::begin_sleep(const optional<uint64_t>& sleep_duration
|
|||||||
|
|
||||||
void Nrf52DeepSleepBackend::dump_config() {
|
void Nrf52DeepSleepBackend::dump_config() {
|
||||||
if (last_sleep_duration_.has_value()) {
|
if (last_sleep_duration_.has_value()) {
|
||||||
ESP_LOGD(TAG, "Last sleep duration: %lu ms", *last_sleep_duration_ );
|
ESP_LOGD(TAG, "Last sleep duration: %lu ms", *last_sleep_duration_);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "Last sleep duration: unknown");
|
ESP_LOGD(TAG, "Last sleep duration: unknown");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ namespace deep_sleep {
|
|||||||
|
|
||||||
class Nrf52DeepSleepBackend {
|
class Nrf52DeepSleepBackend {
|
||||||
public:
|
public:
|
||||||
void begin_sleep(const optional<uint64_t>& sleep_duration);
|
void begin_sleep(const optional<uint64_t> &sleep_duration);
|
||||||
void dump_config();
|
void dump_config();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
optional<uint32_t> last_sleep_duration_;
|
optional<uint32_t> last_sleep_duration_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -37,8 +37,7 @@ optional<uint32_t> DeepSleepComponent::get_run_duration_() const {
|
|||||||
return this->run_duration_;
|
return this->run_duration_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeepSleepComponent::setup_deep_sleep_()
|
void DeepSleepComponent::setup_deep_sleep_() {
|
||||||
{
|
|
||||||
this->next_enter_deep_sleep_ = false;
|
this->next_enter_deep_sleep_ = false;
|
||||||
const optional<uint32_t> run_duration = get_run_duration_();
|
const optional<uint32_t> run_duration = get_run_duration_();
|
||||||
if (run_duration.has_value()) {
|
if (run_duration.has_value()) {
|
||||||
@@ -153,7 +152,7 @@ void DeepSleepComponent::begin_sleep(bool manual) {
|
|||||||
esp_sleep_enable_touchpad_wakeup();
|
esp_sleep_enable_touchpad_wakeup();
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||||
}
|
}
|
||||||
#endif // USE_ESP32_VARIANT_ESP32C3
|
#endif // USE_ESP32_VARIANT_ESP32C3
|
||||||
#ifdef USE_ESP32_VARIANT_ESP32C3
|
#ifdef USE_ESP32_VARIANT_ESP32C3
|
||||||
if (this->sleep_duration_.has_value())
|
if (this->sleep_duration_.has_value())
|
||||||
esp_sleep_enable_timer_wakeup(*this->sleep_duration_);
|
esp_sleep_enable_timer_wakeup(*this->sleep_duration_);
|
||||||
@@ -165,9 +164,9 @@ void DeepSleepComponent::begin_sleep(bool manual) {
|
|||||||
esp_deep_sleep_enable_gpio_wakeup(1 << this->wakeup_pin_->get_pin(),
|
esp_deep_sleep_enable_gpio_wakeup(1 << this->wakeup_pin_->get_pin(),
|
||||||
static_cast<esp_deepsleep_gpio_wake_up_mode_t>(level));
|
static_cast<esp_deepsleep_gpio_wake_up_mode_t>(level));
|
||||||
}
|
}
|
||||||
#endif // USE_ESP32_VARIANT_ESP32C3
|
#endif // USE_ESP32_VARIANT_ESP32C3
|
||||||
esp_deep_sleep_start();
|
esp_deep_sleep_start();
|
||||||
#endif // USE_ESP32
|
#endif // USE_ESP32
|
||||||
|
|
||||||
#ifdef USE_ESP8266
|
#ifdef USE_ESP8266
|
||||||
ESP.deepSleep(*this->sleep_duration_); // NOLINT(readability-static-accessed-through-instance)
|
ESP.deepSleep(*this->sleep_duration_); // NOLINT(readability-static-accessed-through-instance)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ uint32_t *dbl_reset_mem = ((uint32_t *) DFU_DBL_RESET_MEM);
|
|||||||
|
|
||||||
const struct device *cdc_dev[] = {DT_FOREACH_STATUS_OKAY(zephyr_cdc_acm_uart, DEVICE_AND_COMMA)};
|
const struct device *cdc_dev[] = {DT_FOREACH_STATUS_OKAY(zephyr_cdc_acm_uart, DEVICE_AND_COMMA)};
|
||||||
|
|
||||||
static void cdc_dte_rate_callback(const struct device *, uint32_t rate){
|
static void cdc_dte_rate_callback(const struct device *, uint32_t rate) {
|
||||||
if (rate == 1200) {
|
if (rate == 1200) {
|
||||||
goto_dfu = true;
|
goto_dfu = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,5 +19,5 @@ class DeviceFirmwareUpdate : public Component {
|
|||||||
output::BinaryOutput *reset_output_;
|
output::BinaryOutput *reset_output_;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
}
|
} // namespace dfu
|
||||||
}
|
} // namespace esphome
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ void Logger::write_header_(int level, const char *tag, int line) {
|
|||||||
this->printf_to_buffer_("%s[%s][%s:%03u]: ", color, letter, tag, line);
|
this->printf_to_buffer_("%s[%s][%s:%03u]: ", color, letter, tag, line);
|
||||||
#ifdef USE_ARDUINO
|
#ifdef USE_ARDUINO
|
||||||
} else {
|
} else {
|
||||||
this->printf_to_buffer_("%s[%s][%s:%03u]%s[%s]%s: ", color, letter, tag, line, ESPHOME_LOG_BOLD(ESPHOME_LOG_COLOR_RED), pcTaskGetName(current_task), color);
|
this->printf_to_buffer_("%s[%s][%s:%03u]%s[%s]%s: ", color, letter, tag, line,
|
||||||
|
ESPHOME_LOG_BOLD(ESPHOME_LOG_COLOR_RED), pcTaskGetName(current_task), color);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -152,17 +153,17 @@ Logger::Logger(uint32_t baud_rate, size_t tx_buffer_size) : baud_rate_(baud_rate
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_USB_CDC
|
#ifdef USE_USB_CDC
|
||||||
# ifndef USE_ZEPHYR
|
#ifndef USE_ZEPHYR
|
||||||
void Logger::loop() {
|
void Logger::loop() {
|
||||||
#ifdef USE_ARDUINO
|
#ifdef USE_ARDUINO
|
||||||
if (this->uart_ != UART_SELECTION_USB_CDC) {
|
if (this->uart_ != UART_SELECTION_USB_CDC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
static bool opened = false;
|
static bool opened = false;
|
||||||
if (opened == Serial){
|
if (opened == Serial) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(false == opened){
|
if (false == opened) {
|
||||||
App.schedule_dump_config();
|
App.schedule_dump_config();
|
||||||
}
|
}
|
||||||
opened = !opened;
|
opened = !opened;
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ class Logger : public Component {
|
|||||||
#elif defined(USE_ESP_IDF)
|
#elif defined(USE_ESP_IDF)
|
||||||
uart_port_t uart_num_;
|
uart_port_t uart_num_;
|
||||||
#elif defined(USE_ZEPHYR)
|
#elif defined(USE_ZEPHYR)
|
||||||
const device * uart_dev_{nullptr};
|
const device *uart_dev_{nullptr};
|
||||||
#endif
|
#endif
|
||||||
struct LogLevelOverride {
|
struct LogLevelOverride {
|
||||||
std::string tag;
|
std::string tag;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#ifdef USE_NRF52
|
#ifdef USE_NRF52
|
||||||
#ifdef USE_ARDUINO
|
#ifdef USE_ARDUINO
|
||||||
#include <Adafruit_TinyUSB.h> // for Serial
|
#include <Adafruit_TinyUSB.h> // for Serial
|
||||||
#endif
|
#endif
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace logger {
|
namespace logger {
|
||||||
|
|
||||||
|
|
||||||
static const char *const TAG = "logger";
|
static const char *const TAG = "logger";
|
||||||
|
|
||||||
#ifdef USE_ZEPHYR
|
#ifdef USE_ZEPHYR
|
||||||
@@ -28,11 +27,11 @@ void Logger::loop() {
|
|||||||
uart_line_ctrl_get(uart_dev_, UART_LINE_CTRL_DTR, &dtr);
|
uart_line_ctrl_get(uart_dev_, UART_LINE_CTRL_DTR, &dtr);
|
||||||
|
|
||||||
/* Poll if the DTR flag was set, optional */
|
/* Poll if the DTR flag was set, optional */
|
||||||
if(opened == dtr) {
|
if (opened == dtr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(false == opened){
|
if (false == opened) {
|
||||||
App.schedule_dump_config();
|
App.schedule_dump_config();
|
||||||
}
|
}
|
||||||
opened = !opened;
|
opened = !opened;
|
||||||
@@ -59,10 +58,10 @@ void Logger::pre_setup() {
|
|||||||
uart_dev = DEVICE_DT_GET_OR_NULL(DT_NODELABEL(uart0));
|
uart_dev = DEVICE_DT_GET_OR_NULL(DT_NODELABEL(uart0));
|
||||||
break;
|
break;
|
||||||
case UART_SELECTION_USB_CDC:
|
case UART_SELECTION_USB_CDC:
|
||||||
uart_dev = DEVICE_DT_GET_OR_NULL(DT_NODELABEL(cdc_acm_uart0));
|
uart_dev = DEVICE_DT_GET_OR_NULL(DT_NODELABEL(cdc_acm_uart0));
|
||||||
if(device_is_ready(uart_dev)) {
|
if (device_is_ready(uart_dev)) {
|
||||||
usb_enable(NULL);
|
usb_enable(NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!device_is_ready(uart_dev)) {
|
if (!device_is_ready(uart_dev)) {
|
||||||
@@ -78,10 +77,10 @@ void Logger::pre_setup() {
|
|||||||
|
|
||||||
#ifdef USE_ZEPHYR
|
#ifdef USE_ZEPHYR
|
||||||
void HOT Logger::write_msg_(const char *msg) {
|
void HOT Logger::write_msg_(const char *msg) {
|
||||||
if(nullptr == uart_dev_) {
|
if (nullptr == uart_dev_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while(*msg) {
|
while (*msg) {
|
||||||
uart_poll_out(uart_dev_, *msg);
|
uart_poll_out(uart_dev_, *msg);
|
||||||
++msg;
|
++msg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,11 @@ uint32_t millis() { return ::millis(); }
|
|||||||
void delay(uint32_t ms) { ::delay(ms); }
|
void delay(uint32_t ms) { ::delay(ms); }
|
||||||
uint32_t micros() { return ::micros(); }
|
uint32_t micros() { return ::micros(); }
|
||||||
|
|
||||||
struct nrf5x_wdt_obj
|
struct nrf5x_wdt_obj {
|
||||||
{
|
nrfx_wdt_t wdt;
|
||||||
nrfx_wdt_t wdt;
|
nrfx_wdt_channel_id ch;
|
||||||
nrfx_wdt_channel_id ch;
|
|
||||||
};
|
};
|
||||||
//TODO what value for watchdog?
|
// TODO what value for watchdog?
|
||||||
static nrfx_wdt_config_t nrf5x_wdt_cfg = NRFX_WDT_DEFAULT_CONFIG;
|
static nrfx_wdt_config_t nrf5x_wdt_cfg = NRFX_WDT_DEFAULT_CONFIG;
|
||||||
|
|
||||||
static struct nrf5x_wdt_obj nrf5x_wdt = {
|
static struct nrf5x_wdt_obj nrf5x_wdt = {
|
||||||
@@ -23,39 +22,33 @@ static struct nrf5x_wdt_obj nrf5x_wdt = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void arch_init() {
|
void arch_init() {
|
||||||
//Configure WDT.
|
// Configure WDT.
|
||||||
nrf5x_wdt_cfg.behaviour = NRF_WDT_BEHAVIOUR_PAUSE_SLEEP_HALT;
|
nrf5x_wdt_cfg.behaviour = NRF_WDT_BEHAVIOUR_PAUSE_SLEEP_HALT;
|
||||||
nrfx_wdt_init(&nrf5x_wdt.wdt, &nrf5x_wdt_cfg, nullptr);
|
nrfx_wdt_init(&nrf5x_wdt.wdt, &nrf5x_wdt_cfg, nullptr);
|
||||||
nrfx_wdt_channel_alloc(&nrf5x_wdt.wdt, &nrf5x_wdt.ch);
|
nrfx_wdt_channel_alloc(&nrf5x_wdt.wdt, &nrf5x_wdt.ch);
|
||||||
nrfx_wdt_enable(&nrf5x_wdt.wdt);
|
nrfx_wdt_enable(&nrf5x_wdt.wdt);
|
||||||
|
|
||||||
nRFCrypto.begin();
|
|
||||||
// Init random seed
|
|
||||||
union seedParts {
|
|
||||||
uint32_t seed32;
|
|
||||||
uint8_t seed8[4];
|
|
||||||
} seed;
|
|
||||||
nRFCrypto.Random.generate(seed.seed8, sizeof(seed.seed8));
|
|
||||||
randomSeed(seed.seed32);
|
|
||||||
|
|
||||||
|
nRFCrypto.begin();
|
||||||
|
// Init random seed
|
||||||
|
union seedParts {
|
||||||
|
uint32_t seed32;
|
||||||
|
uint8_t seed8[4];
|
||||||
|
} seed;
|
||||||
|
nRFCrypto.Random.generate(seed.seed8, sizeof(seed.seed8));
|
||||||
|
randomSeed(seed.seed32);
|
||||||
}
|
}
|
||||||
void arch_feed_wdt() {
|
void arch_feed_wdt() { nrfx_wdt_feed(&nrf5x_wdt.wdt); }
|
||||||
nrfx_wdt_feed(&nrf5x_wdt.wdt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void arch_restart() {
|
void arch_restart() { NVIC_SystemReset(); }
|
||||||
NVIC_SystemReset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void nrf52GetMacAddr(uint8_t *mac)
|
void nrf52GetMacAddr(uint8_t *mac) {
|
||||||
{
|
const uint8_t *src = (const uint8_t *) NRF_FICR->DEVICEADDR;
|
||||||
const uint8_t *src = (const uint8_t *)NRF_FICR->DEVICEADDR;
|
mac[5] = src[0];
|
||||||
mac[5] = src[0];
|
mac[4] = src[1];
|
||||||
mac[4] = src[1];
|
mac[3] = src[2];
|
||||||
mac[3] = src[2];
|
mac[2] = src[3];
|
||||||
mac[2] = src[3];
|
mac[1] = src[4];
|
||||||
mac[1] = src[4];
|
mac[0] = src[5] | 0xc0; // MSB high two bits get set elsewhere in the bluetooth stack
|
||||||
mac[0] = src[5] | 0xc0; // MSB high two bits get set elsewhere in the bluetooth stack
|
|
||||||
}
|
}
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
||||||
|
|||||||
@@ -11,25 +11,24 @@ void delay(uint32_t ms) { ::k_msleep(ms); }
|
|||||||
uint32_t micros() { return k_ticks_to_us_floor32(k_uptime_ticks()); }
|
uint32_t micros() { return k_ticks_to_us_floor32(k_uptime_ticks()); }
|
||||||
|
|
||||||
void arch_init() {
|
void arch_init() {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
void arch_feed_wdt() {
|
void arch_feed_wdt() {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void arch_restart() {
|
void arch_restart() {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void nrf52GetMacAddr(uint8_t *mac)
|
void nrf52GetMacAddr(uint8_t *mac) {
|
||||||
{
|
const uint8_t *src = (const uint8_t *) NRF_FICR->DEVICEADDR;
|
||||||
const uint8_t *src = (const uint8_t *)NRF_FICR->DEVICEADDR;
|
mac[5] = src[0];
|
||||||
mac[5] = src[0];
|
mac[4] = src[1];
|
||||||
mac[4] = src[1];
|
mac[3] = src[2];
|
||||||
mac[3] = src[2];
|
mac[2] = src[3];
|
||||||
mac[2] = src[3];
|
mac[1] = src[4];
|
||||||
mac[1] = src[4];
|
mac[0] = src[5] | 0xc0; // MSB high two bits get set elsewhere in the bluetooth stack
|
||||||
mac[0] = src[5] | 0xc0; // MSB high two bits get set elsewhere in the bluetooth stack
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
@@ -37,13 +36,13 @@ void nrf52GetMacAddr(uint8_t *mac)
|
|||||||
void setup();
|
void setup();
|
||||||
void loop();
|
void loop();
|
||||||
|
|
||||||
int main(){
|
int main() {
|
||||||
setup();
|
setup();
|
||||||
while(1) {
|
while (1) {
|
||||||
loop();
|
loop();
|
||||||
esphome::yield();
|
esphome::yield();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class NRF52GPIOPin : public InternalGPIOPin {
|
|||||||
bool inverted_;
|
bool inverted_;
|
||||||
gpio::Flags flags_;
|
gpio::Flags flags_;
|
||||||
#ifdef USE_ZEPHYR
|
#ifdef USE_ZEPHYR
|
||||||
const device * gpio_ = nullptr;
|
const device *gpio_ = nullptr;
|
||||||
bool value_ = false;
|
bool value_ = false;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,17 +13,14 @@ namespace nrf52 {
|
|||||||
static const char *const TAG = "nrf52";
|
static const char *const TAG = "nrf52";
|
||||||
|
|
||||||
static int IRAM_ATTR flags_to_mode(gpio::Flags flags, uint8_t pin) {
|
static int IRAM_ATTR flags_to_mode(gpio::Flags flags, uint8_t pin) {
|
||||||
// For nRF52 extra modes are available.
|
// For nRF52 extra modes are available.
|
||||||
// Standard drive is typically 2mA (min 1mA) '0' sink (low) or '1' source (high). High drive (VDD > 2.7V) is typically 10mA low, 9mA high (min 6mA)
|
// Standard drive is typically 2mA (min 1mA) '0' sink (low) or '1' source (high). High drive (VDD > 2.7V) is typically
|
||||||
// OUTPUT_S0S1 Standard '0', standard '1' same as OUTPUT
|
// 10mA low, 9mA high (min 6mA) OUTPUT_S0S1 Standard '0', standard '1' same as OUTPUT OUTPUT_H0S1 High drive '0',
|
||||||
// OUTPUT_H0S1 High drive '0', standard '1'
|
// standard '1' OUTPUT_S0H1 Standard '0', high drive '1' OUTPUT_H0H1 High drive '0', high 'drive '1'' OUTPUT_D0S1
|
||||||
// OUTPUT_S0H1 Standard '0', high drive '1'
|
// Disconnect '0' standard '1' (normally used for wired-or connections) OUTPUT_D0H1 Disconnect '0', high drive '1'
|
||||||
// OUTPUT_H0H1 High drive '0', high 'drive '1''
|
// (normally used for wired-or connections) OUTPUT_S0D1 Standard '0'. disconnect '1' (normally used for wired-and
|
||||||
// OUTPUT_D0S1 Disconnect '0' standard '1' (normally used for wired-or connections)
|
// connections) OUTPUT_H0D1 High drive '0', disconnect '1' (normally used for wired-and connections) NOTE P0.27 should
|
||||||
// OUTPUT_D0H1 Disconnect '0', high drive '1' (normally used for wired-or connections)
|
// be only low (standard) drive, low frequency
|
||||||
// OUTPUT_S0D1 Standard '0'. disconnect '1' (normally used for wired-and connections)
|
|
||||||
// OUTPUT_H0D1 High drive '0', disconnect '1' (normally used for wired-and connections)
|
|
||||||
// NOTE P0.27 should be only low (standard) drive, low frequency
|
|
||||||
if (flags == gpio::FLAG_INPUT) { // NOLINT(bugprone-branch-clone)
|
if (flags == gpio::FLAG_INPUT) { // NOLINT(bugprone-branch-clone)
|
||||||
return INPUT;
|
return INPUT;
|
||||||
} else if (flags == gpio::FLAG_OUTPUT) {
|
} else if (flags == gpio::FLAG_OUTPUT) {
|
||||||
@@ -33,7 +30,7 @@ static int IRAM_ATTR flags_to_mode(gpio::Flags flags, uint8_t pin) {
|
|||||||
} else if (flags == (gpio::FLAG_INPUT | gpio::FLAG_PULLDOWN)) {
|
} else if (flags == (gpio::FLAG_INPUT | gpio::FLAG_PULLDOWN)) {
|
||||||
return INPUT_PULLDOWN;
|
return INPUT_PULLDOWN;
|
||||||
} else if (flags == (gpio::FLAG_OUTPUT | gpio::FLAG_OPEN_DRAIN)) {
|
} else if (flags == (gpio::FLAG_OUTPUT | gpio::FLAG_OPEN_DRAIN)) {
|
||||||
return OUTPUT_S0D1;
|
return OUTPUT_S0D1;
|
||||||
} else {
|
} else {
|
||||||
return INPUT;
|
return INPUT;
|
||||||
}
|
}
|
||||||
@@ -44,13 +41,11 @@ struct ISRPinArg {
|
|||||||
bool inverted;
|
bool inverted;
|
||||||
};
|
};
|
||||||
|
|
||||||
//TODO implement
|
// TODO implement
|
||||||
//TODO test
|
// TODO test
|
||||||
void (*irq_cb)(void *);
|
void (*irq_cb)(void *);
|
||||||
void* irq_arg;
|
void *irq_arg;
|
||||||
static void pin_irq(void){
|
static void pin_irq(void) { irq_cb(irq_arg); }
|
||||||
irq_cb(irq_arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
ISRInternalGPIOPin NRF52GPIOPin::to_isr() const {
|
ISRInternalGPIOPin NRF52GPIOPin::to_isr() const {
|
||||||
auto *arg = new ISRPinArg{}; // NOLINT(cppcoreguidelines-owning-memory)
|
auto *arg = new ISRPinArg{}; // NOLINT(cppcoreguidelines-owning-memory)
|
||||||
@@ -82,9 +77,7 @@ void NRF52GPIOPin::attach_interrupt(void (*func)(void *), void *arg, gpio::Inter
|
|||||||
|
|
||||||
void NRF52GPIOPin::setup() { pin_mode(flags_); }
|
void NRF52GPIOPin::setup() { pin_mode(flags_); }
|
||||||
|
|
||||||
void NRF52GPIOPin::pin_mode(gpio::Flags flags) {
|
void NRF52GPIOPin::pin_mode(gpio::Flags flags) { pinMode(pin_, flags_to_mode(flags, pin_)); }
|
||||||
pinMode(pin_, flags_to_mode(flags, pin_));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string NRF52GPIOPin::dump_summary() const {
|
std::string NRF52GPIOPin::dump_summary() const {
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
@@ -92,15 +85,9 @@ std::string NRF52GPIOPin::dump_summary() const {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NRF52GPIOPin::digital_read() {
|
bool NRF52GPIOPin::digital_read() { return bool(digitalRead(pin_)) != inverted_; }
|
||||||
return bool(digitalRead(pin_)) != inverted_;
|
void NRF52GPIOPin::digital_write(bool value) { digitalWrite(pin_, value != inverted_ ? 1 : 0); }
|
||||||
}
|
void NRF52GPIOPin::detach_interrupt() const { detachInterrupt(pin_); }
|
||||||
void NRF52GPIOPin::digital_write(bool value) {
|
|
||||||
digitalWrite(pin_, value != inverted_ ? 1 : 0);
|
|
||||||
}
|
|
||||||
void NRF52GPIOPin::detach_interrupt() const {
|
|
||||||
detachInterrupt(pin_);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace nrf52
|
} // namespace nrf52
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ static int flags_to_mode(gpio::Flags flags, uint8_t pin, bool inverted, bool val
|
|||||||
}
|
}
|
||||||
if (flags & gpio::FLAG_OUTPUT) {
|
if (flags & gpio::FLAG_OUTPUT) {
|
||||||
ret |= GPIO_OUTPUT;
|
ret |= GPIO_OUTPUT;
|
||||||
if(value != inverted){
|
if (value != inverted) {
|
||||||
ret |= GPIO_OUTPUT_INIT_HIGH;
|
ret |= GPIO_OUTPUT_INIT_HIGH;
|
||||||
} else {
|
} else {
|
||||||
ret |= GPIO_OUTPUT_INIT_LOW;
|
ret |= GPIO_OUTPUT_INIT_LOW;
|
||||||
@@ -51,18 +51,18 @@ void NRF52GPIOPin::attach_interrupt(void (*func)(void *), void *arg, gpio::Inter
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NRF52GPIOPin::setup() {
|
void NRF52GPIOPin::setup() {
|
||||||
const struct device * gpio = nullptr;
|
const struct device *gpio = nullptr;
|
||||||
if(pin_ < 32) {
|
if (pin_ < 32) {
|
||||||
#define GPIO0 DT_NODELABEL(gpio0)
|
#define GPIO0 DT_NODELABEL(gpio0)
|
||||||
#if DT_NODE_HAS_STATUS(GPIO0, okay)
|
#if DT_NODE_HAS_STATUS(GPIO0, okay)
|
||||||
gpio = DEVICE_DT_GET(GPIO0);
|
gpio = DEVICE_DT_GET(GPIO0);
|
||||||
#else
|
#else
|
||||||
#error "gpio0 is disabled"
|
#error "gpio0 is disabled"
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#define GPIO1 DT_NODELABEL(gpio1)
|
#define GPIO1 DT_NODELABEL(gpio1)
|
||||||
#if DT_NODE_HAS_STATUS(GPIO1, okay)
|
#if DT_NODE_HAS_STATUS(GPIO1, okay)
|
||||||
gpio = DEVICE_DT_GET(GPIO1);
|
gpio = DEVICE_DT_GET(GPIO1);
|
||||||
#else
|
#else
|
||||||
#error "gpio1 is disabled"
|
#error "gpio1 is disabled"
|
||||||
#endif
|
#endif
|
||||||
@@ -77,7 +77,7 @@ void NRF52GPIOPin::setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NRF52GPIOPin::pin_mode(gpio::Flags flags) {
|
void NRF52GPIOPin::pin_mode(gpio::Flags flags) {
|
||||||
if(nullptr == gpio_) {
|
if (nullptr == gpio_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gpio_pin_configure(gpio_, pin_, flags_to_mode(flags, pin_, inverted_, value_));
|
gpio_pin_configure(gpio_, pin_, flags_to_mode(flags, pin_, inverted_, value_));
|
||||||
@@ -90,7 +90,7 @@ std::string NRF52GPIOPin::dump_summary() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool NRF52GPIOPin::digital_read() {
|
bool NRF52GPIOPin::digital_read() {
|
||||||
if(nullptr == gpio_) {
|
if (nullptr == gpio_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return bool(gpio_pin_get(gpio_, pin_) != inverted_);
|
return bool(gpio_pin_get(gpio_, pin_) != inverted_);
|
||||||
@@ -100,10 +100,10 @@ void NRF52GPIOPin::digital_write(bool value) {
|
|||||||
// make sure that value is not ignored since it can be inverted e.g. on switch side
|
// make sure that value is not ignored since it can be inverted e.g. on switch side
|
||||||
// that way init state should be correct
|
// that way init state should be correct
|
||||||
value_ = value;
|
value_ = value;
|
||||||
if(nullptr == gpio_) {
|
if (nullptr == gpio_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gpio_pin_set(gpio_, pin_, value != inverted_ ? 1 : 0 );
|
gpio_pin_set(gpio_, pin_, value != inverted_ ? 1 : 0);
|
||||||
}
|
}
|
||||||
void NRF52GPIOPin::detach_interrupt() const {
|
void NRF52GPIOPin::detach_interrupt() const {
|
||||||
// TODO
|
// TODO
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
#include "variant.h"
|
#include "variant.h"
|
||||||
|
|
||||||
const uint32_t g_ADigitalPinMap[] =
|
const uint32_t g_ADigitalPinMap[] = {
|
||||||
{
|
// P0
|
||||||
// P0
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
|
||||||
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ,
|
31,
|
||||||
8 , 9 , 10, 11, 12, 13, 14, 15,
|
|
||||||
16, 17, 18, 19, 20, 21, 22, 23,
|
|
||||||
24, 25, 26, 27, 28, 29, 30, 31,
|
|
||||||
|
|
||||||
// P1
|
|
||||||
32, 33, 34, 35, 36, 37, 38, 39,
|
|
||||||
40, 41, 42, 43, 44, 45, 46, 47
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// P1
|
||||||
|
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47};
|
||||||
|
|||||||
@@ -2,15 +2,14 @@
|
|||||||
|
|
||||||
#include "WVariant.h"
|
#include "WVariant.h"
|
||||||
|
|
||||||
#define PINS_COUNT (48)
|
#define PINS_COUNT (48)
|
||||||
#define LED_BUILTIN (64)
|
#define LED_BUILTIN (64)
|
||||||
#if PINS_COUNT > LED_BUILTIN
|
#if PINS_COUNT > LED_BUILTIN
|
||||||
#error LED_BUILTIN should be bigger than PINS_COUNT. To ignore settings.
|
#error LED_BUILTIN should be bigger than PINS_COUNT. To ignore settings.
|
||||||
#endif
|
#endif
|
||||||
#define LED_BLUE (LED_BUILTIN)
|
#define LED_BLUE (LED_BUILTIN)
|
||||||
// TODO other are also needed?
|
// TODO other are also needed?
|
||||||
#define USE_LFXO // Board uses 32khz crystal for LF
|
#define USE_LFXO // Board uses 32khz crystal for LF
|
||||||
#define LED_STATE_ON (1)
|
#define LED_STATE_ON (1)
|
||||||
#define PIN_SERIAL1_RX (33) // P1.01
|
#define PIN_SERIAL1_RX (33) // P1.01
|
||||||
#define PIN_SERIAL1_TX (34) // P1.02
|
#define PIN_SERIAL1_TX (34) // P1.02
|
||||||
|
|
||||||
|
|||||||
@@ -12,30 +12,30 @@ class NRF52Preferences : public ESPPreferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ESPPreferenceObject make_preference(size_t length, uint32_t type) override {
|
ESPPreferenceObject make_preference(size_t length, uint32_t type) override {
|
||||||
//TODO
|
// TODO
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sync() override {
|
bool sync() override {
|
||||||
//TODO
|
// TODO
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool reset() override {
|
bool reset() override {
|
||||||
// TODO
|
// TODO
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected:
|
// protected:
|
||||||
// uint8_t *eeprom_sector_;
|
// uint8_t *eeprom_sector_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void setup_preferences() {
|
void setup_preferences() {
|
||||||
auto *prefs = new NRF52Preferences(); // NOLINT(cppcoreguidelines-owning-memory)
|
auto *prefs = new NRF52Preferences(); // NOLINT(cppcoreguidelines-owning-memory)
|
||||||
global_preferences = prefs;
|
global_preferences = prefs;
|
||||||
}
|
}
|
||||||
//TODO
|
// TODO
|
||||||
// void preferences_prevent_write(bool prevent) { s_prevent_write = prevent; }
|
// void preferences_prevent_write(bool prevent) { s_prevent_write = prevent; }
|
||||||
|
|
||||||
} // namespace nrf52
|
} // namespace nrf52
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ namespace esphome {
|
|||||||
namespace nrf52 {
|
namespace nrf52 {
|
||||||
|
|
||||||
void setup_preferences();
|
void setup_preferences();
|
||||||
//TODO
|
// TODO
|
||||||
// void preferences_prevent_write(bool prevent);
|
// void preferences_prevent_write(bool prevent);
|
||||||
|
|
||||||
} // namespace nrf52
|
} // namespace nrf52
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ bool random_bytes(uint8_t *data, size_t len) {
|
|||||||
#ifdef USE_ARDUINO
|
#ifdef USE_ARDUINO
|
||||||
return nRFCrypto.Random.generate(data, len);
|
return nRFCrypto.Random.generate(data, len);
|
||||||
#elif USE_ZEPHYR
|
#elif USE_ZEPHYR
|
||||||
//TODO
|
// TODO
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#error "No random source available for this configuration."
|
#error "No random source available for this configuration."
|
||||||
@@ -531,7 +531,7 @@ Mutex::Mutex() {}
|
|||||||
void Mutex::lock() {}
|
void Mutex::lock() {}
|
||||||
bool Mutex::try_lock() { return true; }
|
bool Mutex::try_lock() { return true; }
|
||||||
void Mutex::unlock() {}
|
void Mutex::unlock() {}
|
||||||
//TODO
|
// TODO
|
||||||
#elif defined(USE_ESP32) || defined(USE_LIBRETINY) /*|| defined(USE_NRF52)*/
|
#elif defined(USE_ESP32) || defined(USE_LIBRETINY) /*|| defined(USE_NRF52)*/
|
||||||
Mutex::Mutex() { handle_ = xSemaphoreCreateMutex(); }
|
Mutex::Mutex() { handle_ = xSemaphoreCreateMutex(); }
|
||||||
void Mutex::lock() { xSemaphoreTake(this->handle_, portMAX_DELAY); }
|
void Mutex::lock() { xSemaphoreTake(this->handle_, portMAX_DELAY); }
|
||||||
|
|||||||
@@ -551,7 +551,7 @@ class Mutex {
|
|||||||
Mutex &operator=(const Mutex &) = delete;
|
Mutex &operator=(const Mutex &) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//TODO
|
// TODO
|
||||||
#if defined(USE_ESP32) || defined(USE_LIBRETINY) /*|| defined(USE_NRF52)*/
|
#if defined(USE_ESP32) || defined(USE_LIBRETINY) /*|| defined(USE_NRF52)*/
|
||||||
SemaphoreHandle_t handle_;
|
SemaphoreHandle_t handle_;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user