Пример #1
0
/**
 * \brief   Disables Cache. The levels/type of Cache to be disabled
 *          is passed as parameter.
 *
 * \param   disFlag   Caches to be disabled.
 *            'disFlag' can take one of the below values. \n
 *                CACHE_ICACHE - To disable Instruction Cache \n
 *                CACHE_DCACHE - To disable Data/Unified Cache \n
 *                CACHE_ALL - To disable all levels of Cache
 *
 * \return  None.
 *
 * \Note    Disabling Data Cache disables Unified cache also, if present.
 **/
void CacheDisable(unsigned int disFlag)
{
    if(disFlag & CACHE_ICACHE)
    {
        CP15ICacheDisable();
        CP15ICacheFlush();
    }

    /* Here D Cache Disabling disables Unified cache also */
    if(disFlag & CACHE_DCACHE)
    {
        CP15DCacheDisable();

        /* For Cortex A8, L2EN has to be disabled for L2 Cache */
        if(PRIMARY_PART_CORTEX_A8 == CP15MainIdPrimPartNumGet())
        {
            CP15AuxControlFeatureDisable(CORTEX_A8_L2EN);
        }
    }
}
Пример #2
0
/**
 * \brief   Enables Cache. The levels/type of Cache to be enabled
 *          is passed as parameter.
 *
 * \param   enFlag   Caches to be enabled.
 *            'enFlag' can take one of the below values. \n
 *                CACHE_ICACHE - To enable Instruction Cache \n
 *                CACHE_DCACHE - To enable Data/Unified Cache \n
 *                CACHE_ALL - To enable all levels of Cache
 *
 * \return  None.
 *
 * \Note    Enabling Data Cache enables Unified cache also, if present.
 **/
void CacheEnable(unsigned int enFlag)
{
    if(enFlag & CACHE_ICACHE)
    {
        CP15ICacheFlush();
        CP15ICacheEnable();
    }

    if(enFlag & CACHE_DCACHE)
    {
        /* For Cortex A8, L2EN has to be enabled for L2 Cache */
        if(PRIMARY_PART_CORTEX_A8 == CP15MainIdPrimPartNumGet())
        {
            CP15AuxControlFeatureEnable(CORTEX_A8_L2EN);
        }

        CP15DCacheFlush();
        CP15DCacheEnable();
    }
}
Пример #3
0
/**
 * \brief   This API invalidates the entire I-Cache
 *
 * \param   None
 *
 * \return  None.
 *
 **/
void CacheInstInvalidateAll(void)
{
    CP15ICacheFlush();
}
Пример #4
0
/*
** Main function. The application starts here.
*/
int main(void)
{
    unsigned int index;
    unsigned int j;

    int result = 0;

    /*
    ** Sets up Section page tables. This is only first level
    ** page table, each page is of size 1MB
    */
    for(index = 0; index < (4*1024); index++)
    {
         /* Set the cacheable memory attributes */
         if((index >= 0x800 && index < 0x880) || (index == 0x403))
         {
              pageTable[index] = (index << 20) | CACHEABLE_TLB_ATTR;
         }

         /* Set the non-cacheable memory attributes */
         else
         {
              pageTable[index] = (index << 20) | NORM_TLB_ATTR;
         }
    }


    /* Invalidate the TLB, pipeline */
    CP15TlbInvalidate();
    CP15BranchPredictorInvalidate();

    CP15BranchPredictionEnable();

    CP15DomainAccessClientSet();

    /* Set TTB0 value. We use only TTB0 here (N = 0) */
    CP15Ttb0Set(((unsigned int )pageTable) | RGN_L2_WBWA);

    /* Enables MMU */
    CP15MMUEnable();

    /* Flush and enable Instruction Cache */
    CP15ICacheFlush();
    CP15ICacheEnable();

    PeripheralsSetUp();

    /* Initialize the ARM Interrupt Controller */
    IntAINTCInit();

    /* Register the ISRs */  
    Timer2IntRegister();
    Timer4IntRegister();
    EnetIntRegister();
    RtcIntRegister();
    HSMMCSDIntRegister();
    IntRegister(127, dummyIsr);

    IntMasterIRQEnable();

    /* Enable system interrupts */
    IntSystemEnable(SYS_INT_RTCINT);
    IntPrioritySet(SYS_INT_RTCINT, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_3PGSWTXINT0);
    IntPrioritySet(SYS_INT_3PGSWTXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_3PGSWRXINT0);
    IntPrioritySet(SYS_INT_3PGSWRXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_TINT2);
    IntPrioritySet(SYS_INT_TINT2, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_TINT4);
    IntPrioritySet(SYS_INT_TINT4, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_MMCSD0INT);
    IntPrioritySet(SYS_INT_MMCSD0INT, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_EDMACOMPINT);
    IntPrioritySet(SYS_INT_EDMACOMPINT, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(127);
    IntPrioritySet(127, 0, AINTC_HOSTINT_ROUTE_IRQ);

    RtcInit();
    UARTStdioInit();
    HSMMCSDContolInit();
    DelayTimerSetup();

    Timer2Config();
    Timer4Config();
    LedIfConfig();

    Timer2IntEnable();
    Timer4IntEnable();
    RtcSecIntEnable();

    InitI2C();

    Timer4Start(); 

    // Read config from files
    HSMMCSDCardAccessSetup();

    configRead();

    LedOn( USER_LED_1 );
    for( j = 0; j < 1000000; ++j );
    LedOff( USER_LED_1 );
    LedOn( USER_LED_2 );
    for( j = 0; j < 1000000; ++j );
    LedOff( USER_LED_2 );
    LedOn( USER_LED_3 );
    for( j = 0; j < 1000000; ++j );
    LedOff( USER_LED_3 );
    LedOn( USER_LED_4 );
    for( j = 0; j < 1000000; ++j );
    LedOff( USER_LED_4 );

    // TEMP
    //i2cTest();

    /*
    ** Loop for ever. Necessary actions shall be taken
    ** after detecting the click.
    */
    while( 1 )
    {
        EnetStatusCheckNUpdate();

        if( runCommand )
        {
            // Command blink
            LedOn( USER_LED_1 );

            if( runData[ runIndex + 1 ] == 'D' )
            {
                if( runData[ runIndex + 2 ] == 'S' )
                {
                    UARTPuts( "** DAC SET\n\r", -1 );

                    if( runData[ runIndex + 3 ] == 'A' )
                    {
                        i2cDAC_Set( 0,
                          runData[ runIndex + 4 ], runData[ runIndex + 5 ] );
                    }
                    if( runData[ runIndex + 6 ] == 'B' )
                    {
                        i2cDAC_Set( 1,
                          runData[ runIndex + 7 ], runData[ runIndex + 8 ] );
                    }
                    if( runData[ runIndex + 9 ] == 'C' )
                    {
                        i2cDAC_Set( 2,
                          runData[ runIndex + 10 ], runData[ runIndex + 11 ] );
                    }
                    if( runData[ runIndex + 12 ] == 'D' )
                    {
                        i2cDAC_Set( 3,
                          runData[ runIndex + 13 ], runData[ runIndex + 14 ] );
                    }
                }
                else if( runData[ runIndex + 2 ] == 'G' )
                {
                    UARTPuts( "** DAC GET\n\r", -1 );

                    uartData[ 0 ] = 15;
                    uartData[ 1 ] = 'D';
                    uartData[ 2 ] = 'G';

                    uartData[ 3 ] = 'A';
                    i2cDAC_Get( 0, &uartData[ 4 ] );

                    uartData[ 6 ] = 'B';
                    i2cDAC_Get( 1, &uartData[ 7 ] );

                    uartData[ 9 ] = 'C';
                    i2cDAC_Get( 2, &uartData[ 10 ] );

                    uartData[ 12 ] = 'D';
                    i2cDAC_Get( 3, &uartData[ 13 ] );

                    net_ext_send( uartData, 15 );
                }
            }
            else if( runData[ runIndex + 1 ] == 'G' )
            {
                if( runData[ runIndex + 2 ] == 'S' )
                {
                    if( runData[ runIndex + 3 ] == 0 ) // Off
                    {
                        UARTPuts( "** GPIO OFF\n\r", -1 );
                        i2cGPIO_Off( 0, 1 << runData[ runIndex + 4 ] );
                    }
                    else if( runData[ runIndex + 3 ] == 1 ) // On
                    {
                        UARTPuts( "** GPIO ON\n\r", -1 );
                        i2cGPIO_On( 0, 1 << runData[ runIndex + 4 ] );
                    }
                }
                else if( runData[ runIndex + 2 ] == 'G' )
                {
                    UARTPuts( "** GPIO GET\n\r", -1 );

                    uartData[ 0 ] = 5;
                    uartData[ 1 ] = 'G';
                    uartData[ 2 ] = 'G';

                    i2cGPIO_Get( &uartData[ 3 ] );

                    net_ext_send( uartData, 5 );
                }
            }
            else if( runData[ runIndex + 1 ] == 'U' )
            {
                UARTPuts( "** UART\n\r", -1 );
                i2cUART_Send( &(runData[ runIndex + 2 ]), 6 );
            }

            runCommand -= runData[ runIndex + 0 ];

            if( runCommand > 0 )
            {
                runIndex += runData[ runIndex + 0 ];
            }
            else
            {
                runIndex = 0;
            }

            LedOff( USER_LED_1 );
        }

        result = i2cUART_Recv( &( uartData[ 2 ] ), 30 );

        if( result > 0 )
        {
            UARTPuts( "** UART Recv: ", -1 );

            for( index = 0; index < result; ++index )
            {
                UARTPutHexNum( uartData[ index + 2 ] );
                UARTPutc( ' ' );
            }

            UARTPutc( '\n' );
            UARTPutc( '\r' );

            // Return the stage position info to the GUI
            if( uartData[ 3 ] == 0x0A ||
                uartData[ 3 ] == 0x3C )
            {
                uartData[ 0 ] = result + 2;
                uartData[ 1 ] = 'U';

                net_ext_send( uartData, result + 2 );
            }
        }
    }
}