hversion.h 892 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef HW_VERSION_H_
  2. #define HW_VERSION_H_
  3. #include <stdio.h>
  4. #include "hdef.h"
  5. #include "htime.h"
  6. #define VERSION_MAJOR 1
  7. #define VERSION_MINOR 18
  8. #define VERSION_MICRO 5
  9. #define VERSION_PATCH 1
  10. #define VERSION_STRING STRINGIFY(VERSION_MAJOR) "." \
  11. STRINGIFY(VERSION_MINOR) "." \
  12. STRINGIFY(VERSION_MICRO) "." \
  13. STRINGIFY(VERSION_PATCH)
  14. #define VERSION_HEX (VERSION_MAJOR << 24) | (VERSION_MINOR << 16) | (VERSION_MICRO << 8) | VERSION_PATCH
  15. inline const char* get_static_version() {
  16. return VERSION_STRING;
  17. }
  18. inline const char* get_compile_version() {
  19. static char version[64];
  20. static datetime_t dt = get_compile_datetime();
  21. snprintf(version, sizeof(version), "%d.%02d.%02d.%02d",
  22. VERSION_MAJOR, dt.year%100, dt.month, dt.day);
  23. return version;
  24. }
  25. #endif // HW_VERSION_H_