mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Init: Boot to HackRF mode if PortaPack CPLD not found.
Worst case, customers can always pull off the PortaPack to get back to a working HackRF.
This commit is contained in:
parent
b3c21c3762
commit
748e5a4f5f
@ -68,22 +68,23 @@ static void event_loop() {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
portapack::init();
|
||||
if( portapack::init() ) {
|
||||
portapack::display.init();
|
||||
|
||||
portapack::display.init();
|
||||
sdcStart(&SDCD1, nullptr);
|
||||
|
||||
sdcStart(&SDCD1, nullptr);
|
||||
controls_init();
|
||||
lcd_frame_sync_configure();
|
||||
rtc_interrupt_enable();
|
||||
|
||||
controls_init();
|
||||
lcd_frame_sync_configure();
|
||||
rtc_interrupt_enable();
|
||||
event_loop();
|
||||
|
||||
event_loop();
|
||||
sdcDisconnect(&SDCD1);
|
||||
sdcStop(&SDCD1);
|
||||
|
||||
sdcDisconnect(&SDCD1);
|
||||
sdcStop(&SDCD1);
|
||||
portapack::shutdown();
|
||||
}
|
||||
|
||||
portapack::shutdown();
|
||||
m4_init(portapack::spi_flash::image_tag_hackrf, portapack::memory::map::m4_code_hackrf);
|
||||
m0_halt();
|
||||
|
||||
|
@ -148,7 +148,20 @@ static const portapack::cpld::Config& portapack_cpld_config() {
|
||||
;
|
||||
}
|
||||
|
||||
void init() {
|
||||
static void shutdown_base() {
|
||||
clock_manager.shutdown();
|
||||
|
||||
power.shutdown();
|
||||
// TODO: Wait a bit for supplies to discharge?
|
||||
|
||||
chSysDisable();
|
||||
|
||||
systick_stop();
|
||||
|
||||
hackrf::one::reset();
|
||||
}
|
||||
|
||||
bool init() {
|
||||
for(const auto& pin : pins) {
|
||||
pin.init();
|
||||
}
|
||||
@ -190,7 +203,8 @@ void init() {
|
||||
clock_manager.run_at_full_speed();
|
||||
|
||||
if( !portapack::cpld::update_if_necessary(portapack_cpld_config()) ) {
|
||||
chSysHalt();
|
||||
shutdown_base();
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !hackrf::cpld::load_sram() ) {
|
||||
@ -210,6 +224,8 @@ void init() {
|
||||
|
||||
LPC_CREG->DMAMUX = portapack::gpdma_mux;
|
||||
gpdma::controller.enable();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void shutdown() {
|
||||
@ -222,16 +238,7 @@ void shutdown() {
|
||||
|
||||
hackrf::cpld::init_from_eeprom();
|
||||
|
||||
clock_manager.shutdown();
|
||||
|
||||
power.shutdown();
|
||||
// TODO: Wait a bit for supplies to discharge?
|
||||
|
||||
chSysDisable();
|
||||
|
||||
systick_stop();
|
||||
|
||||
hackrf::one::reset();
|
||||
shutdown_base();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
@ -49,7 +49,7 @@ extern ReceiverModel receiver_model;
|
||||
|
||||
extern TemperatureLogger temperature_logger;
|
||||
|
||||
void init();
|
||||
bool init();
|
||||
void shutdown();
|
||||
|
||||
} /* namespace portapack */
|
||||
|
Loading…
Reference in New Issue
Block a user