예제 #1
0
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();

    dbgprintf("cflie init\n");
    if (phase == CFLIE_INIT_SEARCH) {
        PROTOCOL_SetBindState(0xFFFFFFFF);
    }
    CLOCK_StartTimer(delay, cflie_callback);
}
예제 #2
0
// Generate id and hopping freq
static void CORONA_init()
{
#ifdef CORONA_FORCE_ID
    // Example of ID and channels taken from dumps
    switch (Model.proto_opts[PROTO_OPTS_FORMAT]) {
    case FORMAT_V1:
      memcpy((void *)rx_tx_addr,(void *)"\x1F\xFE\x6C\x35",CORONA_ADDRESS_LENGTH);
      memcpy((void *)hopping_frequency,(void *)"\x17\x0D\x03\x49",CORONA_RF_NUM_CHANNELS+1);
      break;
    case FORMAT_V2:
      memcpy((void *)rx_tx_addr,(void *)"\xFE\xFE\x02\xFB",CORONA_ADDRESS_LENGTH);
      memcpy((void *)hopping_frequency,(void *)"\x14\x3D\x35",CORONA_RF_NUM_CHANNELS);
      break;
    case FORMAT_FDV3:
      memcpy((void *)rx_tx_addr,(void *)"\x02\xfa\x38\x38",CORONA_ADDRESS_LENGTH);
      memcpy((void *)hopping_frequency,(void *)"\x71\xb9\x30",CORONA_RF_NUM_CHANNELS);
      break;
    }
#else
    // From dumps channels are anything between 0x00 and 0xC5 on V1.
    // But 0x00 and 0xB8 should be avoided on V2 since they are used for bind.
    // Below code make sure channels are between 0x02 and 0xA0, spaced with
    // a minimum of 2 and not ordered (RX only use the 1st channel unless there is an issue).
    // Extra hopping frequency used for Flydream V3 id packets
    initialize_rx_tx_addr();
    u8 order = rx_tx_addr[3] & 0x03;
    for (u8 i=0; i < CORONA_RF_NUM_CHANNELS+1; i++)
        hopping_frequency[i^order] = 2+rx_tx_addr[3-i]%39+(i<<5)+(i<<3);

    if (Model.proto_opts[PROTO_OPTS_FORMAT] != FORMAT_FDV3) {
        // ID looks random but on the 15 V1 dumps they all show the same odd/even rule
        if (rx_tx_addr[3] & 0x01) { // If [3] is odd then [0] is odd and [2] is even 
            rx_tx_addr[0] |= 0x01;
            rx_tx_addr[2] &= 0xFE;
        } else {                    // If [3] is even then [0] is even and [2] is odd 
            rx_tx_addr[0] &= 0xFE;
            rx_tx_addr[2] |= 0x01;
        }
        rx_tx_addr[1] = 0xFE;       // Always FE in the dumps of V1 and V2
    } else {
        rx_tx_addr[1] = 0xFA;       // Always FA for Flydream V3
        rx_tx_addr[3] = hopping_frequency[CORONA_RF_NUM_CHANNELS]; // channel used for id/freq packets
    }
#endif
}