Exemplo n.º 1
0
Arquivo: ask.c Projeto: 10to7/RFIDler
// h/w clock ASK emulator - initialise data pointers for ISR and start timer 2
// args: clock pulsewidth (NOT period!), data as array of 0/1, repeat
void write_ASK_HW_clock(unsigned int pulse, BYTE *data, unsigned int tpb, unsigned int repeat)
{
    // convert to ticks
    pulse= CONVERT_TO_TICKS(pulse);
    // we only need to tick once per bit
    pulse *= (unsigned long) tpb;

    // point globals at data for ISR
    EMU_ThisBit= *data;
    EMU_Data= data + 1;
    EMU_Reset_Data= data;
    EMU_DataBitRate= 1;
    EMU_SubCarrier_T0= 1;

    EMU_Repeat= repeat;

    // if we're manchester or bi-phase encoding, we want to clock twice as fast so we can toggle on half-bit
    if(RFIDlerConfig.Manchester || RFIDlerConfig.BiPhase)
    {
        pulse /= 2;
        EMU_SubCarrier_T0 *= 2;
        EMU_DataBitRate *= 2;
    }

    // make sure no clock is running
    stop_HW_clock();
    
    // set mode
    EmulationMode= MOD_MODE_ASK_OOK;

    // make sure nobody's using our timer
    CloseTimer3();

    // tri-state on, clock low
    READER_CLOCK_ENABLE_ON();
    CLOCK_COIL= LOW;

    // emulator mode
    COIL_MODE_EMULATOR();

    // this is also a semaphore so the rest of the code knows we're running
    mLED_Emulate_On();

    // start timer - ISR will send data
    OpenTimer3( T3_ON | T3_PS_1_1 | T3_SOURCE_INT, pulse - 1L);
    mT3SetIntPriority(6);
    mT3ClearIntFlag();
    mT3IntEnable(TRUE);
}
Exemplo n.º 2
0
// h/w clock PSK emulator - initialise data pointers for ISR and start timer 2
// args: clock period, data as array of 0/1, fc per bit, sub-carrier ticks, repeat
void write_PSK1_HW_clock(unsigned int period, BYTE *data, unsigned int fcpb, unsigned int c0, unsigned int repeat)
{
    // convert to ticks
    period= CONVERT_TO_TICKS(period);
    // for psk we want a full clock cycle, not a tick
    period *= 2;

    // point globals at data for ISR
    EMU_ThisBit= *data;
    EMU_Data= data + 1;
    EMU_Reset_Data= data;
    EMU_DataBitRate= fcpb;
    EMU_SubCarrier_T0= c0;
    EMU_Repeat= repeat;

    // set mode
    EmulationMode= MOD_MODE_PSK1;

    // make sure no clock is running
    stop_HW_clock();

    // make sure nobody's using our timers
    CloseTimer3();

    // tri-state on, clock low
    READER_CLOCK_ENABLE_ON();
    CLOCK_COIL= LOW;

    // emulator mode
    COIL_MODE_EMULATOR();

    // this is also a semaphore so the rest of the code knows we're running
    mLED_Emulate_On();

    // start timer - ISR will send data
    OpenTimer3( T3_ON | T3_PS_1_1 | T3_SOURCE_INT, period / 2L - 1L);
    mT3SetIntPriority(6);
    mT3ClearIntFlag();
    mT3IntEnable(TRUE);
}
Exemplo n.º 3
0
Arquivo: fsk.c Projeto: 10to7/RFIDler
// h/w clock FSK emulator - initialise data pointers for ISR and start timer 2
// args: clock pulsewidth (NOT period!), data as array of 0/1, T0 sub-carrier ticks, T1 sub-carrier ticks, repeat
void write_FSK_HW_clock(unsigned long pulse, BYTE *data, unsigned int tpb, unsigned int t0, unsigned int t1, unsigned int repeat)
{
    // convert to ticks
    pulse= CONVERT_TO_TICKS(pulse);

    // point globals at data for ISR
    EMU_ThisBit= *data;
    EMU_Data= data + 1;
    EMU_Reset_Data= data;
    EMU_Repeat= repeat;
    EMU_DataBitRate= tpb;
    EMU_SubCarrier_T0= t0;
    EMU_SubCarrier_T1= t1;

    // set mode
    EmulationMode= MOD_MODE_FSK;

    // make sure no clock is running
    stop_HW_clock();

    // make sure nobody's using our timer
    CloseTimer3();

    // emulator mode
    COIL_MODE_EMULATOR();

    // tri-state on, clock low
    READER_CLOCK_ENABLE_ON();
    CLOCK_COIL= LOW;

    // this is also a semaphore so the rest of the code knows we're running
    mLED_Emulate_On();

    // start timer - ISR will send data
    OpenTimer3( T3_ON | T3_PS_1_1 | T3_SOURCE_INT, pulse - 1L);
    mT3SetIntPriority(6);
    mT3ClearIntFlag();
    mT3IntEnable(TRUE);
}