sysctl: fix logic error/hang around spi poweroff

This commit is contained in:
Lukas F. Hartmann 2024-05-06 17:26:12 +02:00
parent 63cdf45cd2
commit 2e0c09b641
No known key found for this signature in database
GPG Key ID: 376511EB67AD7BAF
1 changed files with 14 additions and 10 deletions

View File

@ -650,7 +650,11 @@ void max_dump() {
}
}
void init_spi_client();
void turn_som_power_on() {
init_spi_client();
// latch
gpio_put(PIN_PWREN_LATCH, 1);
@ -662,10 +666,10 @@ void turn_som_power_on() {
gpio_put(PIN_3V3_ENABLE, 1);
sleep_ms(10);
gpio_put(PIN_SOM_MOSI, 1);
/*gpio_put(PIN_SOM_MOSI, 1);
gpio_put(PIN_SOM_SS0, 1);
gpio_put(PIN_SOM_SCK, 1);
gpio_put(PIN_SOM_MISO, 1);
gpio_put(PIN_SOM_MISO, 1);*/
gpio_put(PIN_5V_ENABLE, 1);
@ -690,14 +694,16 @@ void turn_som_power_on() {
}
void turn_som_power_off() {
init_spi_client();
// latch
gpio_put(PIN_PWREN_LATCH, 1);
// FIXME spi test
gpio_put(PIN_SOM_MOSI, 0);
/*gpio_put(PIN_SOM_MOSI, 0);
gpio_put(PIN_SOM_SS0, 0);
gpio_put(PIN_SOM_SCK, 0);
gpio_put(PIN_SOM_MISO, 0);
gpio_put(PIN_SOM_MISO, 0);*/
gpio_put(PIN_LED_B, 0);
@ -1008,13 +1014,9 @@ void handle_spi_commands() {
// toggle system power and/or reset imx
if (spi_arg1 == 1) {
turn_som_power_off();
init_spi_client();
return;
}
if (spi_arg1 == 2) {
turn_som_power_on();
init_spi_client();
return;
}
if (spi_arg1 == 3) {
// TODO
@ -1085,7 +1087,9 @@ void handle_spi_commands() {
// that we read above for unknown reasons
init_spi_client();
if (som_is_powered) {
spi_write_blocking(spi1, spi_buf, SPI_BUF_LEN);
}
spi_cmd_state = ST_EXPECT_MAGIC;
spi_command = 0;