mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-18 17:23:52 +08:00
clean up flasher
This commit is contained in:
@@ -10,9 +10,14 @@
|
||||
#endif
|
||||
|
||||
#include "libc.h"
|
||||
#include "drivers/spi.h"
|
||||
#include "gpio.h"
|
||||
|
||||
|
||||
void spi_cb_rx(uint8_t *data, int len) {};
|
||||
|
||||
#include "drivers/drivers.h"
|
||||
#include "drivers/spi.h"
|
||||
|
||||
#include "crypto/rsa.h"
|
||||
#include "crypto/sha.h"
|
||||
|
||||
@@ -20,30 +25,23 @@
|
||||
|
||||
#include "spi_flasher.h"
|
||||
|
||||
void spi_cb_rx(uint8_t *data, int len) {};
|
||||
|
||||
void __initialize_hardware_early() {
|
||||
early();
|
||||
|
||||
if (is_entering_bootmode) {
|
||||
spi_flasher();
|
||||
}
|
||||
}
|
||||
|
||||
void fail() {
|
||||
#ifdef PANDA
|
||||
volatile int i;
|
||||
// detect usb host
|
||||
GPIOA->PUPDR |= GPIO_PUPDR_PUPDR11_0;
|
||||
for (i=0;i<PULL_EFFECTIVE_DELAY;i++);
|
||||
int no_usb = GPIOA->IDR & (1 << 11);
|
||||
GPIOA->PUPDR &= ~(GPIO_PUPDR_PUPDR11_0);
|
||||
int no_usb = detect_with_pull(GPIOA, 11, PULL_UP);
|
||||
|
||||
if (no_usb) {
|
||||
// no usb host, go to SPI flasher
|
||||
spi_flasher();
|
||||
} else {
|
||||
// has usb host, go to USB flasher
|
||||
enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC;
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
#else
|
||||
enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC;
|
||||
NVIC_SystemReset();
|
||||
|
||||
@@ -243,6 +243,7 @@ void set_esp_mode(int mode) {
|
||||
set_gpio_output(GPIOC, 5, 0);
|
||||
break;
|
||||
case ESP_ENABLED:
|
||||
// ESP ON
|
||||
set_gpio_output(GPIOC, 14, 1);
|
||||
set_gpio_output(GPIOC, 5, 1);
|
||||
break;
|
||||
@@ -419,12 +420,6 @@ void early() {
|
||||
} else {
|
||||
set_esp_mode(ESP_ENABLED);
|
||||
}
|
||||
|
||||
#ifdef BOOTSTUB
|
||||
if (is_entering_bootmode) {
|
||||
spi_flasher();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user