From d808884b976ec0f7343230af268ff69f3acaf53e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Thu, 24 Aug 2023 01:17:39 +0900 Subject: [PATCH] FuriHal: explicitly pull display pins at early init stage, move PUPD config to early stage (#3004) Co-authored-by: hedger --- .../targets/f18/furi_hal/furi_hal_resources.c | 29 +++++++------------ .../targets/f7/furi_hal/furi_hal_resources.c | 29 +++++++------------ 2 files changed, 20 insertions(+), 38 deletions(-) diff --git a/firmware/targets/f18/furi_hal/furi_hal_resources.c b/firmware/targets/f18/furi_hal/furi_hal_resources.c index f28f98b0..63da03e0 100644 --- a/firmware/targets/f18/furi_hal/furi_hal_resources.c +++ b/firmware/targets/f18/furi_hal/furi_hal_resources.c @@ -128,19 +128,22 @@ void furi_hal_resources_init_early() { furi_hal_resources_init_input_pins(GpioModeInput); + // Explicit, surviving reset, pulls + LL_PWR_EnablePUPDCfg(); + LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_A, LL_PWR_GPIO_BIT_8); // gpio_vibro + LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_8); // gpio_speaker + // SD Card stepdown control furi_hal_gpio_write(&gpio_periph_power, 1); furi_hal_gpio_init(&gpio_periph_power, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); // Display pins - furi_hal_gpio_write(&gpio_display_rst_n, 1); + furi_hal_gpio_write(&gpio_display_rst_n, 0); furi_hal_gpio_init_simple(&gpio_display_rst_n, GpioModeOutputPushPull); - furi_hal_gpio_init(&gpio_display_di, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); - - // Pullup display reset pin for shutdown - SET_BIT(PWR->PUCRB, gpio_display_rst_n.pin); - CLEAR_BIT(PWR->PDCRB, gpio_display_rst_n.pin); - SET_BIT(PWR->CR3, PWR_CR3_APC); + LL_PWR_EnableGPIOPullUp(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_0); // gpio_display_rst_n + furi_hal_gpio_write(&gpio_display_di, 0); + furi_hal_gpio_init_simple(&gpio_display_di, GpioModeOutputPushPull); + LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_1); // gpio_display_di // Hard reset USB furi_hal_gpio_write(&gpio_usb_dm, 1); @@ -182,18 +185,6 @@ void furi_hal_resources_init() { // Button pins furi_hal_resources_init_input_pins(GpioModeInterruptRiseFall); - // Explicit pulls pins - LL_PWR_EnablePUPDCfg(); - LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_8); // gpio_speaker - LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_A, LL_PWR_GPIO_BIT_8); // gpio_vibro - - // Display pins - furi_hal_gpio_init(&gpio_display_rst_n, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); - furi_hal_gpio_write(&gpio_display_rst_n, 0); - - furi_hal_gpio_init(&gpio_display_di, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); - furi_hal_gpio_write(&gpio_display_di, 0); - // SD pins furi_hal_gpio_init(&gpio_sdcard_cd, GpioModeInput, GpioPullNo, GpioSpeedLow); furi_hal_gpio_write(&gpio_sdcard_cd, 0); diff --git a/firmware/targets/f7/furi_hal/furi_hal_resources.c b/firmware/targets/f7/furi_hal/furi_hal_resources.c index 34b26b83..4d52960d 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_resources.c +++ b/firmware/targets/f7/furi_hal/furi_hal_resources.c @@ -117,19 +117,23 @@ void furi_hal_resources_init_early() { furi_hal_resources_init_input_pins(GpioModeInput); + // Explicit, surviving reset, pulls + LL_PWR_EnablePUPDCfg(); + LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_A, LL_PWR_GPIO_BIT_8); // gpio_vibro + LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_8); // gpio_speaker + LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_9); // gpio_infrared_tx + // SD Card stepdown control furi_hal_gpio_write(&gpio_periph_power, 1); furi_hal_gpio_init(&gpio_periph_power, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); // Display pins - furi_hal_gpio_write(&gpio_display_rst_n, 1); + furi_hal_gpio_write(&gpio_display_rst_n, 0); furi_hal_gpio_init_simple(&gpio_display_rst_n, GpioModeOutputPushPull); + LL_PWR_EnableGPIOPullUp(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_0); // gpio_display_rst_n + furi_hal_gpio_write(&gpio_display_di, 0); furi_hal_gpio_init_simple(&gpio_display_di, GpioModeOutputPushPull); - - // Alternative pull configuration for shutdown - SET_BIT(PWR->PUCRB, DISPLAY_RST_Pin); - CLEAR_BIT(PWR->PDCRB, DISPLAY_RST_Pin); - SET_BIT(PWR->CR3, PWR_CR3_APC); + LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_1); // gpio_display_di // Hard reset USB furi_hal_gpio_write(&gpio_usb_dm, 1); @@ -171,19 +175,6 @@ void furi_hal_resources_init() { // Button pins furi_hal_resources_init_input_pins(GpioModeInterruptRiseFall); - // Explicit, surviving reset, pulls - LL_PWR_EnablePUPDCfg(); - LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_9); // gpio_infrared_tx - LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_8); // gpio_speaker - LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_A, LL_PWR_GPIO_BIT_8); // gpio_vibro - - // Display pins - furi_hal_gpio_init(&gpio_display_rst_n, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); - furi_hal_gpio_write(&gpio_display_rst_n, 0); - - furi_hal_gpio_init(&gpio_display_di, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); - furi_hal_gpio_write(&gpio_display_di, 0); - // SD pins furi_hal_gpio_init(&gpio_sdcard_cd, GpioModeInput, GpioPullNo, GpioSpeedLow); furi_hal_gpio_write(&gpio_sdcard_cd, 0);