api-hal-version.c 994 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <api-hal-version.h>
  2. #include <stm32wbxx.h>
  3. typedef struct {
  4. uint8_t version;
  5. uint8_t target;
  6. uint8_t body;
  7. uint8_t connect;
  8. uint32_t timestamp;
  9. char name[8];
  10. } ApiHalVersionOTP;
  11. bool api_hal_version_do_i_belong_here() {
  12. return api_hal_version_get_hw_target() == 5;
  13. }
  14. const uint8_t api_hal_version_get_hw_version() {
  15. return ((ApiHalVersionOTP*)OTP_AREA_BASE)->version;
  16. }
  17. const uint8_t api_hal_version_get_hw_target() {
  18. return ((ApiHalVersionOTP*)OTP_AREA_BASE)->target;
  19. }
  20. const uint8_t api_hal_version_get_hw_body() {
  21. return ((ApiHalVersionOTP*)OTP_AREA_BASE)->body;
  22. }
  23. const uint8_t api_hal_version_get_hw_connect() {
  24. return ((ApiHalVersionOTP*)OTP_AREA_BASE)->connect;
  25. }
  26. const uint32_t api_hal_version_get_hw_timestamp() {
  27. return ((ApiHalVersionOTP*)OTP_AREA_BASE)->timestamp;
  28. }
  29. const char * api_hal_version_get_name_ptr() {
  30. char * name = ((ApiHalVersionOTP*)OTP_AREA_BASE)->name;
  31. return *name == 0xFFU ? NULL : name;
  32. }