Esempio n. 1
0
// =========== Public Methods ==================================================
void batSetup(void) {

#if defined(__IMAGEPROC1)
    ConfigINT0(RISING_EDGE_INT & EXT_INT_ENABLE & EXT_INT_PRI_7);
#elif defined(__IMAGEPROC2)
    ConfigINT2(RISING_EDGE_INT & EXT_INT_ENABLE & EXT_INT_PRI_7);
#endif

}
Esempio n. 2
0
void Int0Init( void )
{
    int i;
    for( i = 0; i < MAX_INT0_CALLBACK; i++ ) {
        int0Callbacks[i].callback = NULL;
    }
	CNPU2=0x80;	//pin#16 pull-up CN23
    CloseINT0();
	ConfigINT0(INT_ENABLE | FALLING_EDGE_INT | INT_PRI_7);
}
Esempio n. 3
0
static void InitializeSystem(void)
{
    AD1PCFG = 0xFFFF;   
    SYSTEMConfigPerformance(80000000);
    UserInit();
    USBDeviceInit();	// Initializes USB module SFRs and firmware
    			// variables to known states.
    ConfigINT0(EXT_INT_PRI_6 | RISING_EDGE_INT | EXT_INT_ENABLE);
    
    mPMPOpen(PMP_CONTROL, PMP_MODE, PMP_PORT, PMP_INT);
    PMPSetAddress(0x4000);
}
Esempio n. 4
0
void SetupInterrupts(void)
{
    #if defined(__IMAGEPROC2)

        ConfigINT2(RISING_EDGE_INT & EXT_INT_ENABLE & EXT_INT_PRI_7); // Battery Supervisor

    #elif defined(__IMAGEPROC1)

        ConfigINT0(RISING_EDGE_INT & EXT_INT_ENABLE & EXT_INT_PRI_7); // Battery Supervisor

    #endif
    ConfigIntTimer1(T1_INT_PRIOR_4 & T1_INT_OFF);
    ConfigIntTimer2(T2_INT_PRIOR_4 & T2_INT_OFF);
}
Esempio n. 5
0
/**
 * Record a trace, this is a blocking function.
 * Use the ext interupt 0 and 1.
 * Use the timer 1.
 */
uchar* recordTrace(int *size) {
    uchar charIndex = 0;
    uchar charBuffer;

    uint state = STATE_BEGINING;

    uchar i = 0;
    uchar t0 = (uchar) 0x00;
    uint tmpEtu = NO_ETU_CHANGE;
    uchar protocol;
    uchar convention;

    convention = CONVENTION_DIRECTE;
    protocol = PROTOCOL_T0;

    initialiseInterupt();

    if(!waitForIO())
    {
        reInit();
        return NULL;
    }

    /* Configure the interupt on IO to answer on each falling edge*/
    ConfigINT2(EXT_INT_ENABLE | FALLING_EDGE_INT | EXT_INT_PRI_1);

    /* Configure the warm reset to trigger on falling edge*/
    ConfigINT1(EXT_INT_ENABLE | FALLING_EDGE_INT | EXT_INT_PRI_1);

    while( (STATE_TERMINATED != state))
    {
        state = getState();
        if( (isData() > 0) && dataIndex < DATA_SIZE)
        {
            charBuffer = 0x00;
            for(charIndex = 0 ; charIndex < 8 ; charIndex++ )
            {
                if(CONVENTION_INVERSE == convention)
                {
                    charBuffer ^= (getAcq() << (7-charIndex));
                }
                else if(CONVENTION_DIRECTE == convention)
                {
                    charBuffer ^= (getAcq() << charIndex);
                }
            }
            if(CONVENTION_INVERSE == convention)
            {
                charBuffer = 0xff ^ charBuffer;
            }
            dataArray[dataIndex] = charBuffer;

            dataIndex++;
            clearFlag();

            if(STATE_TS == state)
            {
                if((uchar) 0x3b == charBuffer)
                {
                    convention = CONVENTION_DIRECTE;
                }

                /* 0x03 is the way the byte 3f will be read with the tool
                 * For information, by default the Direct convention is used
                 * so we don't see directly the byte 3F but the byte 3f coded
                 * in direct convention = 0x03 */
                if((uchar) 0x03 == charBuffer)
                {
                    convention = CONVENTION_INVERSE;
                    dataArray[dataIndex-1] = 0x3f;
                }

                setState(STATE_T0);
            }
            else if(STATE_T0 == state)
            {
                t0 = charBuffer;
                setState(STATE_ATR);
            } /*Then we treats TAx, TBx, TCx, TDx,... and finaly hist bytes */
            else if(0 < (t0 & 0x10) )
            {
                t0 = t0 ^ 0x10;
                /* It's a TAx */
                if(0 == i) /* It's Ta1*/
                {
                    /*Configuring the new ATR value*/
                    tmpEtu = computeEtu(charBuffer);
                }
            }
            else if(0 < (t0 & 0x20) )
            {
                /*It's a TBx*/
                t0 = t0 ^ 0x20;
            }
            else if(0 < (t0 & 0x40) )
            {
                /*It's a TCx*/
                t0 = t0 ^ 0x40;
            }
            else if(0 < (t0 & 0x80) )
            {
                /*It's a TDx*/
                t0 = t0 ^ 0x80;
                /* t0 is only compose of the historical bytes We verify if
                 the TD bytes implies other bytes*/
                t0 ^= (charBuffer & 0xf0);
                i++;

                /* We also verify if it's a T=1 protocol */
                if( ((uchar) 0x01) == ((uchar) charBuffer ^ 0x01) )
                {
                    /*It's a t=1 card set the value to T=1*/
                    protocol = PROTOCOL_T1;
                }

            }
            else if(0 < (t0 & 0x0F))
            {
                /* This is historical bytes */
                t0--;
                if(t0 == 0)
                {
                    if(PROTOCOL_T1 == protocol)
                    {
                        setState(STATE_ATR_CRC);
                    }
                    else
                    {
                        setState(STATE_PROCESSING);
                        fixEtu(tmpEtu);
                    }
                }
            }
            else if(STATE_ATR_CRC == state) {
                setState(STATE_PROCESSING);
                fixEtu(tmpEtu);
            }
        }/*end of if(isData() > 0 )*/
        else if(STATE_RESET == getState()) {
            charIndex = 0;
            convention = CONVENTION_DIRECTE;
            warmAtrOffset = dataIndex;
            t0 = 0x00;
            setState(STATE_BEGINING);
        }
        if( !isData() && !PIN_VCC )
        {
            setState(STATE_TERMINATED);
        }
        if(dataIndex >= DATA_SIZE )
        {
#ifdef DEBUG
            sendDataBuffer("Array overflow\n");
#endif
            setState(STATE_TERMINATED);
        }
    }//End of while

    /* Stop the interupt on IO */
    ConfigINT0(EXT_INT_DISABLE);

    /* Stop the warm reset */
    ConfigINT1(EXT_INT_DISABLE);

#ifdef DEBUG
    sendDataBuffer("Trace recorded : \n");
#endif

    /* End of debug information */
    *size = dataIndex;
    reInit();
    return dataArray;
}