Cleanup FUSB setup

This commit is contained in:
Ben V. Brown
2021-04-08 21:20:25 +10:00
parent 7a437b9265
commit 22c5f6d361
5 changed files with 19 additions and 13 deletions

View File

@@ -127,10 +127,10 @@ bool fusb_setup() {
}
/* Fully reset the FUSB302B */
fusb_write_byte(FUSB_RESET, FUSB_RESET_SW_RES);
osDelay(2);
vTaskDelay(TICKS_10MS);
uint8_t tries = 0;
while (!fusb_read_id()) {
osDelay(10);
vTaskDelay(TICKS_10MS);
tries++;
if (tries > 5) {
return false; // Welp :(
@@ -156,12 +156,12 @@ bool fusb_setup() {
/* Measure CC1 */
fusb_write_byte(FUSB_SWITCHES0, 0x07);
osDelay(10);
vTaskDelay(TICKS_10MS);
uint8_t cc1 = fusb_read_byte(FUSB_STATUS0) & FUSB_STATUS0_BC_LVL;
/* Measure CC2 */
fusb_write_byte(FUSB_SWITCHES0, 0x0B);
osDelay(10);
vTaskDelay(TICKS_10MS);
uint8_t cc2 = fusb_read_byte(FUSB_STATUS0) & FUSB_STATUS0_BC_LVL;
/* Select the correct CC line for BMC signaling; also enable AUTO_CRC */