Skip to content

Commit

Permalink
Fixed GPIO outputs inadvertent activation during bootup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Павел authored and Павел committed May 24, 2021
1 parent 2f93ba8 commit ac49eb7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Firmware-vscode/gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ void gpio_init()
gpioOK = gpio_port.begin();
if (!gpioOK) return;
gpio_port.setClock(400000);
gpio_write_all(mem_get_gpio()); //Set output values first, since default value for output register is "all ON"
uint8_t current_pin = 0;
for (uint8_t i = 0; i < arraySize(gpio_map); i++)
for (uint8_t i = 0; i < arraySize(gpio_map); i++) //Only then set pin modes so that they can actually become outputs
{
uint8_t state = i % 2 == 0 ? OUTPUT : INPUT;
for (uint8_t j = 0; j < gpio_map[i]; j++)
Expand Down
6 changes: 5 additions & 1 deletion Firmware-vscode/mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ void mem_save()
mem_save_array_b(ee_cooler_enable, enableCooler, arraySize(ee_cooler_enable));
}

uint16_t mem_get_gpio()
{
return eeprom_read_word(&ee_gpio);
}

void mem_load()
{
Setpoint = eeprom_read_float(&ee_setpoint);
Expand All @@ -97,7 +102,6 @@ void mem_load()
distillExtraPower = eeprom_read_float(&ee_distillation_bias);
distillTempWindow = eeprom_read_float(&ee_distillation_window);
rampStepLimit = eeprom_read_float(&ee_ramp_step);
gpio_write_all(eeprom_read_word(&ee_gpio));
cjc = eeprom_read_byte(&ee_cjc);
mem_load_array_b(ee_cooler_enable, enableCooler, arraySize(ee_cooler_enable));
}
Expand Down
1 change: 1 addition & 0 deletions Firmware-vscode/thermo.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ void mem_set_first_run();
void mem_save();
void mem_load();
void mem_save_persistent();
uint16_t mem_get_gpio();

#pragma endregion

Expand Down

0 comments on commit ac49eb7

Please sign in to comment.