12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #pragma once
- /* Standard C headers */
- #include <inttypes.h>
- #include <stdarg.h>
- #include <stdbool.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- /* Arduino headers */
- #include <Arduino.h>
- #include <FreeRTOS.h>
- /* ESP-IDF headers */
- #include <sdkconfig.h>
- #include <esp_err.h>
- #include <esp_event.h>
- #include <esp_log.h>
- #ifdef __cplusplus
- # define extern_c extern "C"
- # define EXTERN_C(...) extern "C" { __VA_ARGS__ }
- #else
- # define extern_c extern
- # define EXTERN_C(...) __VA_ARGS__
- #endif
- #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
- #ifndef MODULE
- # define MODULE ""
- #endif
- #if DEBUG
- # define CMSG(...) printf(__VA_ARGS__)
- #else
- # define CMSG(...) ((void)0)
- #endif
- #define MSG(...) CMSG(MODULE ": " __VA_ARGS__)
- /*
- * Common types for callbacks
- */
- typedef void *token_t;
- typedef int (*read_func_t)(token_t token, void *buf, size_t len);
- typedef int (*write_func_t)(token_t token, const void *buf, size_t len);
- /*
- * Sleep thread...
- */
- static inline void suspend(void)
- {
- vTaskSuspend(NULL);
- }
- /*
- * Reboot system
- */
- extern_c void reboot_now(void);
- extern_c int reboot_delayed(void);
|