Beispiel #1
0
/*
** Perform file operations on MMCSD
*/
static void ActionMMCSD(void)
{
    pmFlag = FALSE;
    rtcSetFlag = FALSE;
    tmrClick = FALSE;
    tmrFlag  = FALSE;
    LedOff();

    if(TRUE == HSMMCSDCardPresentStat())
    {
        sdCardAccessFlag = TRUE;
    }
    else
    {
        sdCardAccessFlag = FALSE;
        ConsoleUtilsPrintf("\n\rSD card not present. Please insert an"
                           " SD card and try again! \n\r");
    }

    /*
    ** Check for SD Card
    */
    if(TRUE == sdCardAccessFlag)
    {
         HSMMCSDCardAccessSetup();
    }

    pageIndex = MENU_IDX_SD;
    UpdateUartConsoleHelp();
}
Beispiel #2
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 );
            }
        }
    }
}