static void initialize() { CLOCK_StopTimer(); tx_power = Model.tx_power; phase = initialize_rx_tx_addr(); telemetry_setup_state = CFLIE_TELEM_SETUP_STATE_INIT; packet_counter = 0; int delay = cflie_init(); memset(&Telemetry, 0, sizeof(Telemetry)); TELEMETRY_SetType(TELEM_DSM); dbgprintf("cflie init\n"); if (phase == CFLIE_INIT_SEARCH) { PROTOCOL_SetBindState(0xFFFFFFFF); } CLOCK_StartTimer(delay, cflie_callback); }
void PROTO_Stubs(int idx) { if (! idx) return; CLOCK_StartTimer(); spi_disable(); spi_set_bidirectional_receive_only_mode(); spi_read(); spi_set_unidirectional_mode(); TELEMETRY_SetUpdated(); TELEMETRY_SetType(); UART_Stop(); rcc_peripheral_disable_clock(); _usleep(); MCU_SerialNumber(); USB_Disable(); PROTO_CS_HI(); PROTO_CS_LO(); MUSIC_Beep(); rand32(); }
void PROTOCOL_Load(int no_dlg) { (void)no_dlg; #ifdef ENABLE_MODULAR FATFS ModuleFAT; FILE *fh; if(! PROTOCOL_HasModule(Model.protocol)) { *loaded_protocol = 0; return; } if(*loaded_protocol == Model.protocol) return; char file[25]; strcpy(file, "protocol/"); if (Model.protocol > PROTOCOL_COUNT) { *loaded_protocol = 0; return; } else { strcat(file, Protocols[Model.protocol].name); } file[17] = '\0'; //truncate filename to 8 characters strcat(file, ".mod"); memset(&ModuleFAT, 0, sizeof(ModuleFAT)); finit(&ModuleFAT, "protocol"); fh = fopen2(&ModuleFAT, file, "r"); //printf("Loading %s: %08lx\n", file, fh); if(! fh) { if(! no_dlg) { sprintf(tempstring, "Misisng protocol:\n%s", file); PAGE_ShowWarning(NULL, tempstring); } return; } setbuf(fh, 0); fread(loaded_protocol, 1, 4 * 1024, fh); fclose(fh); if ((unsigned long)&_data_loadaddr != *loaded_protocol) { if(! no_dlg) { sprintf(tempstring, "Protocol Mismatch:\n%08x\n%08x", (unsigned long)&_data_loadaddr, *loaded_protocol); PAGE_ShowWarning(NULL, tempstring); } *loaded_protocol = 0; return; } //printf("Updated %d (%d) bytes: Data: %08lx %08lx %08lx\n", size, len, *loaded_protocol, *(loaded_protocol+1), *(loaded_protocol+2)); //We use the same file for multiple protocols, so we need to manually set this here *loaded_protocol = Model.protocol; #else if(! PROTOCOL_HasModule(Model.protocol)) { PROTO_Cmds = NULL; printf("Module is not defined!\n"); return; } PROTO_Cmds = Protocols[Model.protocol].cmd; #endif PROTOCOL_SetSwitch(get_module(Model.protocol)); if (PROTOCOL_GetTelemetryState() != PROTO_TELEM_UNSUPPORTED) { memset(&Telemetry, 0, sizeof(Telemetry)); TELEMETRY_SetType(PROTOCOL_GetTelemetryType()); } CurrentProtocolChannelMap = PROTOCOL_GetChannelMap(); }