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:
Jared Boone 2017-06-13 22:16:00 -07:00
parent b3c21c3762
commit 748e5a4f5f
3 changed files with 31 additions and 23 deletions

View File

@ -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();

View File

@ -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" {

View File

@ -49,7 +49,7 @@ extern ReceiverModel receiver_model;
extern TemperatureLogger temperature_logger;
void init();
bool init();
void shutdown();
} /* namespace portapack */