common.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #define _GNU_SOURCE 1
  3. #include "compiler.h"
  4. /* Standard C headers */
  5. #include <inttypes.h>
  6. #include <stdarg.h>
  7. #include <stdbool.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. /* Arduino headers */
  12. #include <Arduino.h>
  13. #include <FreeRTOS.h>
  14. /* ESP-IDF headers */
  15. #include <sdkconfig.h>
  16. #include <esp_err.h>
  17. #include <esp_event.h>
  18. #include <esp_log.h>
  19. #include "xmalloc.h"
  20. #ifndef MODULE
  21. # define MODULE ""
  22. #endif
  23. #if DEBUG
  24. # define CMSG(...) printf(__VA_ARGS__)
  25. #else
  26. # define CMSG(...) ((void)0)
  27. #endif
  28. #define MSG(...) CMSG(MODULE ": " __VA_ARGS__)
  29. /*
  30. * Common types for callbacks
  31. */
  32. typedef void *token_t;
  33. typedef int (*read_func_t)(token_t token, void *buf, size_t len);
  34. typedef int (*write_func_t)(token_t token, const void *buf, size_t len);
  35. /*
  36. * Sleep thread...
  37. */
  38. static inline void suspend(void)
  39. {
  40. vTaskSuspend(NULL);
  41. }
  42. /*
  43. * Reboot system
  44. */
  45. extern_c void reboot_now(void);
  46. extern_c int reboot_delayed(void);
  47. /*
  48. * Board version
  49. */
  50. extern_c uint8_t max80_board_version;