Skip to content

Commit

Permalink
drv/ioport_lpf2: fix incorrect detection on Technic hub
Browse files Browse the repository at this point in the history
It seems that the bootloader on the Technic hub must change the GPIO
pull from the default, so we need to explicitly set it during init.
Otherwise, ID2 is pulled low and devices are incorrectly detected.

Fixes: pybricks/support#230
  • Loading branch information
dlech committed Feb 3, 2021
1 parent 36b3498 commit a4b616f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/pbio/drv/ioport/ioport_lpf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,15 @@ static void init_one(uint8_t ioport) {
pbdrv_gpio_input(&pdata->uart_tx);
pbdrv_gpio_input(&pdata->uart_rx);

// These should be set by default already, but it seems that the bootloader
// on the Technic hub changes these and causes wrong detection if we don't
// make sure pull is disabled.
pbdrv_gpio_set_pull(&pdata->id1, PBDRV_GPIO_PULL_NONE);
pbdrv_gpio_set_pull(&pdata->id2, PBDRV_GPIO_PULL_NONE);
pbdrv_gpio_set_pull(&pdata->uart_buf, PBDRV_GPIO_PULL_NONE);
pbdrv_gpio_set_pull(&pdata->uart_tx, PBDRV_GPIO_PULL_NONE);
pbdrv_gpio_set_pull(&pdata->uart_rx, PBDRV_GPIO_PULL_NONE);

basic_devs[ioport].port = PBDRV_CONFIG_IOPORT_LPF2_FIRST_PORT + ioport;
basic_devs[ioport].ops = &basic_dev_ops;
}
Expand Down

0 comments on commit a4b616f

Please sign in to comment.