Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FuriHal: explicitly pull display pins at early init stage, move PUPD config to early stage #3004

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions firmware/targets/f18/furi_hal/furi_hal_resources.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
29 changes: 10 additions & 19 deletions firmware/targets/f7/furi_hal/furi_hal_resources.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down