Skip to content

Commit

Permalink
[SYS] Fix port LEDs on system that overwrite whole GPIO out register
Browse files Browse the repository at this point in the history
  • Loading branch information
darthcloud committed Nov 3, 2023
1 parent f603757 commit ebd6572
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions main/system/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ static inline void set_power_off(uint32_t state) {
}

static inline void set_port_led(uint32_t index, uint32_t state) {
gpio_set_level(led_list[index], state);
if (state) {
esp_rom_gpio_connect_out_signal(led_list[index], ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + LEDC_CHANNEL_1, 0, 0);
}
else {
esp_rom_gpio_connect_out_signal(led_list[index], ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + LEDC_CHANNEL_2, 0, 0);
}
}

static inline uint32_t get_port_led_pin(uint32_t index) {
Expand Down Expand Up @@ -179,12 +184,6 @@ static void internal_flag_init(void) {
}
}

static void port_led_reset(uint32_t pin) {
if (pin) {
gpio_set_direction(pin, GPIO_MODE_OUTPUT);
}
}

static void port_led_pulse(uint32_t pin) {
if (pin) {
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[pin], PIN_FUNC_GPIO);
Expand Down Expand Up @@ -310,8 +309,6 @@ static void wired_port_hdl(void) {
if (!bt_ready && !err_led_set) {
uint8_t new_led = (device->ids.out_idx < port_cnt) ? get_port_led_pin(device->ids.out_idx) : 0;

port_led_reset(current_pulse_led);

if (bt_hci_get_inquiry()) {
port_led_pulse(new_led);
err_led_set = 1;
Expand Down Expand Up @@ -664,6 +661,9 @@ void sys_mgr_init(uint32_t package) {
gpio_set_level(led_list[i], 0);
io_conf.pin_bit_mask = 1ULL << led_list[i];
gpio_config(&io_conf);
/* Can't use GPIO mode on port LED as some wired driver overwrite whole GPIO port */
/* Use unused LEDC channel 2 to force output low */
esp_rom_gpio_connect_out_signal(led_list[i], ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + LEDC_CHANNEL_2, 0, 0);
}

#ifdef CONFIG_BLUERETRO_HW2
Expand Down

0 comments on commit ebd6572

Please sign in to comment.