From 5d9ddd4c1d8bdf4ac87fb69d5425b00677d038c8 Mon Sep 17 00:00:00 2001 From: Kampi Date: Mon, 20 Mar 2023 19:41:43 +0100 Subject: [PATCH 1/2] bugfix: Change namespace variable to nvs_namespace (C++ compatibility) Closes https://github.com/espressif/esp-idf/pull/11028 --- examples/system/ulp_fsm/ulp/main/ulp_example_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/system/ulp_fsm/ulp/main/ulp_example_main.c b/examples/system/ulp_fsm/ulp/main/ulp_example_main.c index 1607e7b077..d3717e06a2 100644 --- a/examples/system/ulp_fsm/ulp/main/ulp_example_main.c +++ b/examples/system/ulp_fsm/ulp/main/ulp_example_main.c @@ -98,12 +98,12 @@ static void init_ulp_program(void) static void update_pulse_count(void) { - const char* namespace = "plusecnt"; + const char* nvs_namespace = "plusecnt"; const char* count_key = "count"; ESP_ERROR_CHECK( nvs_flash_init() ); nvs_handle_t handle; - ESP_ERROR_CHECK( nvs_open(namespace, NVS_READWRITE, &handle)); + ESP_ERROR_CHECK( nvs_open(nvs_namespace, NVS_READWRITE, &handle)); uint32_t pulse_count = 0; esp_err_t err = nvs_get_u32(handle, count_key, &pulse_count); assert(err == ESP_OK || err == ESP_ERR_NVS_NOT_FOUND); From 9757e62bd12e8b29ab1fca6d895da2270738baae Mon Sep 17 00:00:00 2001 From: Jakob Hasse Date: Fri, 24 Mar 2023 11:38:34 +0800 Subject: [PATCH 2/2] bugfix: made C code C++ compatible --- examples/system/ulp_fsm/ulp/main/ulp_example_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/system/ulp_fsm/ulp/main/ulp_example_main.c b/examples/system/ulp_fsm/ulp/main/ulp_example_main.c index d3717e06a2..602f77ddd1 100644 --- a/examples/system/ulp_fsm/ulp/main/ulp_example_main.c +++ b/examples/system/ulp_fsm/ulp/main/ulp_example_main.c @@ -107,18 +107,18 @@ static void update_pulse_count(void) uint32_t pulse_count = 0; esp_err_t err = nvs_get_u32(handle, count_key, &pulse_count); assert(err == ESP_OK || err == ESP_ERR_NVS_NOT_FOUND); - printf("Read pulse count from NVS: %5"PRIu32"\n", pulse_count); + printf("Read pulse count from NVS: %5" PRIu32"\n", pulse_count); /* ULP program counts signal edges, convert that to the number of pulses */ uint32_t pulse_count_from_ulp = (ulp_edge_count & UINT16_MAX) / 2; /* In case of an odd number of edges, keep one until next time */ ulp_edge_count = ulp_edge_count % 2; - printf("Pulse count from ULP: %5"PRIu32"\n", pulse_count_from_ulp); + printf("Pulse count from ULP: %5" PRIu32"\n", pulse_count_from_ulp); /* Save the new pulse count to NVS */ pulse_count += pulse_count_from_ulp; ESP_ERROR_CHECK(nvs_set_u32(handle, count_key, pulse_count)); ESP_ERROR_CHECK(nvs_commit(handle)); nvs_close(handle); - printf("Wrote updated pulse count to NVS: %5"PRIu32"\n", pulse_count); + printf("Wrote updated pulse count to NVS: %5" PRIu32"\n", pulse_count); }