2020-10-27 14:38:45 -04:00
|
|
|
#include <cstdint>
|
2021-06-26 14:53:32 -04:00
|
|
|
#include <cstdio>
|
2020-10-27 14:38:45 -04:00
|
|
|
#include "BootloaderVersion.h"
|
|
|
|
|
|
|
|
using namespace Pinetime;
|
|
|
|
|
2021-06-26 14:53:32 -04:00
|
|
|
// NOTE : version < 1.0.0 of bootloader does not export its version to the application firmware.
|
2020-10-27 14:38:45 -04:00
|
|
|
|
2021-06-26 14:53:32 -04:00
|
|
|
uint32_t BootloaderVersion::version = 0;
|
|
|
|
char BootloaderVersion::versionString[BootloaderVersion::VERSION_STR_LEN] = "0.0.0";
|
|
|
|
|
2022-06-14 02:48:00 -04:00
|
|
|
uint32_t BootloaderVersion::Major() {
|
2021-06-26 14:53:32 -04:00
|
|
|
return (BootloaderVersion::version >> 16u) & 0xff;
|
2020-10-27 14:38:45 -04:00
|
|
|
}
|
|
|
|
|
2022-06-14 02:48:00 -04:00
|
|
|
uint32_t BootloaderVersion::Minor() {
|
2021-06-26 14:53:32 -04:00
|
|
|
return (BootloaderVersion::version >> 8u) & 0xff;
|
2020-10-27 14:38:45 -04:00
|
|
|
}
|
|
|
|
|
2022-06-14 02:48:00 -04:00
|
|
|
uint32_t BootloaderVersion::Patch() {
|
2021-06-26 14:53:32 -04:00
|
|
|
return BootloaderVersion::version & 0xff;
|
2020-10-27 14:38:45 -04:00
|
|
|
}
|
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
const char* BootloaderVersion::VersionString() {
|
2021-06-26 14:53:32 -04:00
|
|
|
return BootloaderVersion::versionString;
|
|
|
|
}
|
|
|
|
|
2022-06-14 02:48:00 -04:00
|
|
|
bool BootloaderVersion::IsValid() {
|
2021-06-26 14:53:32 -04:00
|
|
|
return BootloaderVersion::version >= 0x00010000;
|
2020-10-27 14:38:45 -04:00
|
|
|
}
|
|
|
|
|
2021-06-26 14:53:32 -04:00
|
|
|
void BootloaderVersion::SetVersion(uint32_t v) {
|
|
|
|
BootloaderVersion::version = v;
|
2022-05-09 11:16:08 -04:00
|
|
|
snprintf(BootloaderVersion::versionString,
|
|
|
|
BootloaderVersion::VERSION_STR_LEN,
|
|
|
|
"%ld.%ld.%ld",
|
|
|
|
BootloaderVersion::Major(),
|
|
|
|
BootloaderVersion::Minor(),
|
|
|
|
BootloaderVersion::Patch());
|
2020-10-27 14:38:45 -04:00
|
|
|
}
|