api-hal-version.c 825 B

12345678910111213141516171819202122232425262728293031323334
  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. } ApiHalVersionOTP;
  10. bool api_hal_version_do_i_belong_here() {
  11. return api_hal_version_get_hw_target() == 5;
  12. }
  13. const uint8_t api_hal_version_get_hw_version() {
  14. return ((ApiHalVersionOTP*)OTP_AREA_BASE)->version;
  15. }
  16. const uint8_t api_hal_version_get_hw_target() {
  17. return ((ApiHalVersionOTP*)OTP_AREA_BASE)->target;
  18. }
  19. const uint8_t api_hal_version_get_hw_body() {
  20. return ((ApiHalVersionOTP*)OTP_AREA_BASE)->body;
  21. }
  22. const uint8_t api_hal_version_get_hw_connect() {
  23. return ((ApiHalVersionOTP*)OTP_AREA_BASE)->connect;
  24. }
  25. const uint32_t api_hal_version_get_hw_timestamp() {
  26. return ((ApiHalVersionOTP*)OTP_AREA_BASE)->timestamp;
  27. }