-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refresh app + update Memfault SDK to 1.11.4
- Loading branch information
Showing
25 changed files
with
1,258 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,49 @@ | ||
list(APPEND | ||
COMPONENT_SRCS | ||
cmd_app.c | ||
cmd_system.c | ||
console_example_main.c | ||
button.c | ||
led.c | ||
main.c | ||
) | ||
|
||
if (CONFIG_APP_MEMFAULT_TRANSPORT_HTTP) | ||
list(APPEND COMPONENT_SRCS app_memfault_transport_http.c) | ||
elseif(CONFIG_APP_MEMFAULT_TRANSPORT_MQTT) | ||
list(APPEND COMPONENT_SRCS app_memfault_transport_mqtt.c) | ||
endif() | ||
|
||
# the 'cmd_wifi.c' implementation is different for ESP-IDF v5+ | ||
if("${IDF_VERSION_MAJOR}" VERSION_GREATER_EQUAL 5) | ||
if (CONFIG_MEMFAULT) | ||
list(APPEND | ||
COMPONENT_SRCS | ||
cmd_wifi.c | ||
cmd_app.c | ||
cmd_system.c | ||
ota_session_metrics.c | ||
) | ||
else() | ||
list(APPEND | ||
COMPONENT_SRCS | ||
cmd_wifi_legacy.c | ||
) | ||
endif() | ||
|
||
# include settings.c only on idf >= 4 | ||
if("${IDF_VERSION_MAJOR}" VERSION_GREATER_EQUAL 4) | ||
list(APPEND | ||
COMPONENT_SRCS | ||
settings.c | ||
if (CONFIG_APP_MEMFAULT_TRANSPORT_HTTP) | ||
list(APPEND COMPONENT_SRCS app_memfault_transport_http.c) | ||
elseif(CONFIG_APP_MEMFAULT_TRANSPORT_MQTT) | ||
list(APPEND COMPONENT_SRCS app_memfault_transport_mqtt.c) | ||
endif() | ||
|
||
# the 'cmd_wifi.c' implementation is different for ESP-IDF v5+ | ||
if("${IDF_VERSION_MAJOR}" VERSION_GREATER_EQUAL 5) | ||
list(APPEND | ||
COMPONENT_SRCS | ||
cmd_wifi.c | ||
) | ||
else() | ||
list(APPEND | ||
COMPONENT_SRCS | ||
cmd_wifi_legacy.c | ||
) | ||
endif() | ||
|
||
# include settings.c only on idf >= 4 | ||
if("${IDF_VERSION_MAJOR}" VERSION_GREATER_EQUAL 4) | ||
list(APPEND | ||
COMPONENT_SRCS | ||
settings.c | ||
) | ||
endif() | ||
|
||
set(COMPONENT_ADD_INCLUDEDIRS | ||
. | ||
config | ||
) | ||
endif() | ||
|
||
set(COMPONENT_ADD_INCLUDEDIRS | ||
. | ||
memfault | ||
) | ||
|
||
register_component() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
//! @file | ||
//! | ||
//! Copyright (c) Memfault, Inc. | ||
//! See License.txt for details | ||
//! | ||
//! Button setup and handling | ||
|
||
#include "button.h" | ||
|
||
#include "driver/gpio.h" | ||
#include "esp_attr.h" | ||
#include "esp_log.h" | ||
#include "esp_system.h" | ||
|
||
static const char *TAG = "button"; | ||
|
||
static void IRAM_ATTR prv_gpio_isr_handler(void *arg) { | ||
uint32_t gpio_num = (uint32_t)arg; | ||
|
||
// dereference a null point to trigger a crash | ||
volatile uint32_t *ptr = NULL; | ||
*ptr = gpio_num; | ||
} | ||
|
||
// The flex glitch filter is only available on 5.1. Skip it for earlier SDKs. | ||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) | ||
#include "driver/gpio_filter.h" | ||
static void prv_button_glitch_filter_enable(void) { | ||
#if SOC_GPIO_FLEX_GLITCH_FILTER_NUM > 0 | ||
gpio_glitch_filter_handle_t filter; | ||
gpio_flex_glitch_filter_config_t filter_cfg = { | ||
.clk_src = GLITCH_FILTER_CLK_SRC_DEFAULT, | ||
.gpio_num = CONFIG_BUTTON_GPIO, | ||
.window_thres_ns = 500, | ||
.window_width_ns = 500, | ||
}; | ||
esp_err_t err = gpio_new_flex_glitch_filter(&filter_cfg, &filter); | ||
if (err != ESP_OK) { | ||
ESP_LOGE(TAG, "Failed to create glitch filter: %s", esp_err_to_name(err)); | ||
return; | ||
} | ||
|
||
err = gpio_glitch_filter_enable(filter); | ||
if (err != ESP_OK) { | ||
ESP_LOGE(TAG, "Failed to enable glitch filter: %s", esp_err_to_name(err)); | ||
return; | ||
} | ||
#endif | ||
} | ||
#else // ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) | ||
static void prv_button_glitch_filter_enable(void) { | ||
// No-op | ||
} | ||
#endif // ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) | ||
|
||
void button_setup(void) { | ||
// configure the button as an input | ||
gpio_config_t io_conf = { | ||
.intr_type = GPIO_INTR_NEGEDGE, | ||
.mode = GPIO_MODE_INPUT, | ||
.pin_bit_mask = 1ULL << CONFIG_BUTTON_GPIO, | ||
.pull_down_en = GPIO_PULLDOWN_DISABLE, | ||
.pull_up_en = GPIO_PULLUP_ENABLE, | ||
}; | ||
esp_err_t err = gpio_config(&io_conf); | ||
if (err != ESP_OK) { | ||
ESP_LOGE(TAG, "Failed to configure button: %s", esp_err_to_name(err)); | ||
return; | ||
} | ||
|
||
prv_button_glitch_filter_enable(); | ||
|
||
// install gpio isr service | ||
err = gpio_install_isr_service(0); | ||
if (err != ESP_OK) { | ||
ESP_LOGE(TAG, "Failed to install gpio isr service: %s", esp_err_to_name(err)); | ||
return; | ||
} | ||
|
||
// install isr handler for specific gpio pin | ||
err = gpio_isr_handler_add(CONFIG_BUTTON_GPIO, prv_gpio_isr_handler, (void *)CONFIG_BUTTON_GPIO); | ||
if (err != ESP_OK) { | ||
ESP_LOGE(TAG, "Failed to add isr handler for button: %s", esp_err_to_name(err)); | ||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//! @file | ||
//! | ||
//! Copyright (c) Memfault, Inc. | ||
//! See License.txt for details | ||
//! | ||
//! Button setup and handling | ||
|
||
#pragma once | ||
|
||
void button_setup(void); |
Oops, something went wrong.