#pragma once #define _GNU_SOURCE 1 #include "compiler.h" /* Standard C headers */ #include #include #include #include #include #include /* Arduino headers */ #include #include /* ESP-IDF headers */ #include #include #include #include #include "xmalloc.h" #ifndef MODULE # define MODULE "" #endif #if DEBUG # define CMSG(...) printf(__VA_ARGS__) #else # define CMSG(...) ((void)0) #endif #define MSG(...) CMSG(MODULE ": " __VA_ARGS__) /* * Hack to deal with the lack of this information in FreeRTOS proper */ #define EVENT_BITS (configUSE_16_BIT_TICKS ? 8 : 24) #define EVENT_ALL_BITS ((1U << EVENT_BITS)-1) /* * 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); } /* * Kill thread; vTaskDelete(NULL) *should* never return... */ static inline no_return exit_task(void) { vTaskDelete(NULL); while (1) { /* vTaskDelete() returned!? */ vTaskSuspend(NULL); } } /* * Reboot system */ extern_c void reboot_now(void); extern_c int reboot_delayed(void); /* * Main MAC address from efuses */ extern_c uint8_t efuse_default_mac[6]; /* * Time sync status */ extern_c volatile bool time_net_sync_status; struct timeval; extern_c void time_net_sync(const struct timeval *tv); extern_c void print_time(const char *msg, const struct timeval *tv);