void main(void) { // Stash board info from the bootloader before we let anything touch // the SFRs. // g_board_frequency = BOARD_FREQUENCY_REG; g_board_bl_version = BOARD_BL_VERSION_REG; // try to load parameters; set them to defaults if that fails. // this is done before hardware_init() to get the serial speed // XXX default parameter selection should be based on board info // if (!param_load()) param_default(); // setup boolean features feature_mavlink_framing = param_get(PARAM_MAVLINK)?true:false; feature_opportunistic_resend = param_get(PARAM_OPPRESEND)?true:false; feature_golay = param_get(PARAM_ECC)?true:false; feature_rtscts = param_get(PARAM_RTSCTS)?true:false; // Do hardware initialisation. hardware_init(); // do radio initialisation radio_init(); // turn on the receiver if (!radio_receiver_on()) { panic("failed to enable receiver"); } tdm_serial_loop(); }
static void at_ampersand(void) { switch (at_cmd[3]) { case 'F': param_default(); at_ok(); break; case 'W': param_save(); at_ok(); break; case 'U': if (!strcmp(at_cmd + 4, "PDATE")) { // force a flash error volatile char x = *(__code volatile char *)0xfc00; for (;;) ; } at_error(); break; case 'P': tdm_change_phase(); break; case 'T': // enable test modes if (!strcmp(at_cmd + 4, "")) { // disable all tests at_testmode = 0; } else if (!strcmp(at_cmd + 4, "=RSSI")) { // display RSSI stats at_testmode ^= AT_TEST_RSSI; } else if (!strcmp(at_cmd + 4, "=TDM")) { // display TDM debug at_testmode ^= AT_TEST_TDM; } else { at_error(); } break; default: at_error(); break; } }
/**==========================================================================**\ ** M A IN \**==========================================================================**/ int main ( int argc, char *argv[] ) { param_t param ; npc_t *npc = NULL ; ProgramName = *argv++ ; --argc ; param_default( ¶m ); while( argv[0] && argv[1] && argv[0][0]=='-' ) { switch( argv[0][1] ) { case 'n': param.seedNumber= argv[1]; break; case 'm': param.maxDigits = atoi( argv[1] ); break; case 'b': param.baseNumber= atoi( argv[1] ); break; case 'a': param.savePeriod= atoi( argv[1] ); break; case 'i': strupdate(&(param.loadFile), argv[1] ); break; case 'o': strupdate(&(param.saveFile), argv[1] ); break; case 'v': param.help |= PARAM_VERSION ; param_usage( ¶m ) ; default : fprintf( stderr, "unknown option: '%c'\n" ); param_usage( ¶m ); } param.numParams ++ ; argc -= 2 ; argv += 2 ; } param_verify( ¶m ); if( (npc = npc_new( param.maxDigits )) == NULL ) { fprintf( stderr, "err npc_new\n" ); return( 0 ); } npc->base = param.baseNumber ; if( param.loadFile ) { if( !npc_loadFile( npc, param.loadFile ) ) return( 0 ); } else { if( !npc_string_ingest( npc, param.seedNumber ) ) { fprintf( stderr, "err loading seedNumber\n" ); return( 0 ); } else npc->origSeed = atoi( param.seedNumber ) ; } copywrite() ; npc_loop( npc ) ; printf( "\n" "Progress: %%%6.2f Digits: %7d Its: %8d Secs: %6u\n" , 100. * npc->numDigits / npc->maxDigits , npc->numDigits , npc->iterates , npc->timeMark - npc->timeInit ) ; if( param.saveFile ) npc_saveFile( npc, param.saveFile ) ; return 0; }