native: Fixes an hw version issue with some older BMP.

The BMP with hardware version 4 and newer, use option bytes instead of
physical GPIO to encode the hardware version. In some older BMP there is
a chance that the user option byte is set to 255 (0x00FF pattern). This
can throw off the hardware version detection routine.
This commit is contained in:
Piotr Esden-Tempski 2022-03-15 19:05:53 -07:00
parent bcba3ee4a9
commit e82d4f2eda
1 changed files with 4 additions and 3 deletions

View File

@ -80,12 +80,13 @@ int platform_hwversion(void)
/* Check if the hwversion is set in the user option byte. */ /* Check if the hwversion is set in the user option byte. */
if (hwversion == -1) { if (hwversion == -1) {
if (BMP_HWVERSION_BYTE != 0xFFFF) { if ((BMP_HWVERSION_BYTE != 0xFFFF) &&
(BMP_HWVERSION_BYTE != 0x00FF)) {
/* Check if the data is valid. /* Check if the data is valid.
* When valid it should only have values 4 and higher. * When valid it should only have values 4 and higher.
*/ */
if ((BMP_HWVERSION_BYTE >> 8) != if (((BMP_HWVERSION_BYTE >> 8) !=
(~BMP_HWVERSION_BYTE & 0xFF) || (~BMP_HWVERSION_BYTE & 0xFF)) ||
((BMP_HWVERSION_BYTE & 0xFF) < 4)) { ((BMP_HWVERSION_BYTE & 0xFF) < 4)) {
return -2; return -2;
} else { } else {