12345678910111213141516171819202122232425262728293031323334353637 |
- #ifndef KBF_ASSERT_H
- #define KBF_ASSERT_H
- #include <freertos/FreeRTOS.h>
- #include <freertos/task.h>
- #include <esp_err.h>
- #ifndef CHECK
- #define CHECK(x) do { \
- esp_err_t __err = (x); \
- if (__err != ESP_OK) { \
- ESP_LOGE("CHECK", "error check failed\n" \
- "\tat %s, line %d, in %s\n" \
- "\t\tline:\t%s\n\t\terror:\t%d (%s)", \
- __FILE__, __LINE__, __ASSERT_FUNC, #x, \
- __err, esp_err_to_name(__err)); \
- ESP_LOGE("CHECK", "aborting in 30 seconds..."); \
- vTaskDelay(30000 / portTICK_PERIOD_MS); \
- abort(); \
- } \
- } while (0)
- #else
- #error CHECK macro already defined
- #endif
- #ifndef ABORT
- #define ABORT(msg) do { \
- ESP_LOGE("ABORT", msg); \
- ESP_LOGE("ABORT", "aborting in 30 seconds..."); \
- vTaskDelay(30000 / portTICK_PERIOD_MS); \
- abort(); \
- } while (0)
- #else
- #error ABORT macro already defined
- #endif
- #endif
|