Comment functions

This commit is contained in:
Mario Hüttel 2021-10-23 21:18:32 +02:00
parent 56872086fa
commit 288b19c4fc
1 changed files with 7 additions and 1 deletions

View File

@ -33,6 +33,9 @@ enum hw_revision get_pcb_hardware_version(void)
uint16_t port_bitmask = 0U;
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)
return revision;
@ -45,12 +48,15 @@ enum hw_revision get_pcb_hardware_version(void)
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++) {
port_bitmask >>= 1;
port_bitmask |= (HW_REV_DETECT_GPIO->IDR & (1 << current_pin)) ? 0x0 : 0x80;
}
/* Resolve the read in bitmask to a hardware version */
switch (port_bitmask) {
case 0U:
revision = HW_REV_V1_2;