mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-12 13:48:33 +00: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:
@@ -68,8 +68,7 @@ static void event_loop() {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
portapack::init();
|
||||
|
||||
if( portapack::init() ) {
|
||||
portapack::display.init();
|
||||
|
||||
sdcStart(&SDCD1, nullptr);
|
||||
@@ -84,6 +83,8 @@ int main(void) {
|
||||
sdcStop(&SDCD1);
|
||||
|
||||
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 */
|
||||
|
Reference in New Issue
Block a user