Comment functions
This commit is contained in:
parent
56872086fa
commit
288b19c4fc
@ -33,6 +33,9 @@ enum hw_revision get_pcb_hardware_version(void)
|
|||||||
uint16_t port_bitmask = 0U;
|
uint16_t port_bitmask = 0U;
|
||||||
static enum hw_revision revision = HW_REV_NOT_DETECTED;
|
static enum hw_revision revision = HW_REV_NOT_DETECTED;
|
||||||
|
|
||||||
|
/* If the revision has been previously detected,
|
||||||
|
* just return it and don't do the whole detection stuff
|
||||||
|
*/
|
||||||
if (revision != HW_REV_NOT_DETECTED)
|
if (revision != HW_REV_NOT_DETECTED)
|
||||||
return revision;
|
return revision;
|
||||||
|
|
||||||
@ -45,12 +48,15 @@ enum hw_revision get_pcb_hardware_version(void)
|
|||||||
HW_REV_DETECT_GPIO->PUPDR |= PULLUP(current_pin);
|
HW_REV_DETECT_GPIO->PUPDR |= PULLUP(current_pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loop again and read in the pin mask */
|
/* Loop again and read in the pin mask.
|
||||||
|
* Because we use GND-Shorts on the pins to detect the version, the pins are read inverted.
|
||||||
|
*/
|
||||||
for (current_pin = HW_REV_DETECT_PIN_LOW; current_pin <= HW_REV_DETECT_PIN_HIGH; current_pin++) {
|
for (current_pin = HW_REV_DETECT_PIN_LOW; current_pin <= HW_REV_DETECT_PIN_HIGH; current_pin++) {
|
||||||
port_bitmask >>= 1;
|
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 : 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Resolve the read in bitmask to a hardware version */
|
||||||
switch (port_bitmask) {
|
switch (port_bitmask) {
|
||||||
case 0U:
|
case 0U:
|
||||||
revision = HW_REV_V1_2;
|
revision = HW_REV_V1_2;
|
||||||
|
Loading…
Reference in New Issue
Block a user