Improve HW version detect code. Funtionally equivalent
This commit is contained in:
parent
ab5fd6433e
commit
ad3de6e6b7
@ -34,7 +34,8 @@
|
||||
enum hw_revision get_pcb_hardware_version(void)
|
||||
{
|
||||
uint8_t current_pin;
|
||||
uint16_t port_bitmask = 0U;
|
||||
uint16_t port_bitmask = 0U; /* Use uint16_t because a port can have 16 IOs max. */
|
||||
const uint16_t highest_bit_mask = (1 << (HW_REV_DETECT_PIN_HIGH - HW_REV_DETECT_PIN_LOW));
|
||||
static enum hw_revision revision = HW_REV_NOT_DETECTED;
|
||||
|
||||
/* If the revision has been previously detected,
|
||||
@ -57,7 +58,7 @@ enum hw_revision get_pcb_hardware_version(void)
|
||||
*/
|
||||
for (current_pin = HW_REV_DETECT_PIN_LOW; current_pin <= HW_REV_DETECT_PIN_HIGH; current_pin++) {
|
||||
port_bitmask >>= 1;
|
||||
port_bitmask |= (HW_REV_DETECT_GPIO->IDR & (1 << current_pin)) ? 0x0 : 0x80;
|
||||
port_bitmask |= (HW_REV_DETECT_GPIO->IDR & (1 << current_pin)) ? 0x0 : highest_bit_mask;
|
||||
}
|
||||
|
||||
/* Resolve the read in bitmask to a hardware version */
|
||||
|
Loading…
Reference in New Issue
Block a user