Exemplo n.º 1
0
//*****************************************************************************
//
// This function implements the "readid" command.  It reads a the ID block from
// the I2C EEPROM on the daughter board and displays the contents.
//
//*****************************************************************************
int
Cmd_readid(int argc, char *argv[])
{
    tBoolean bRetcode;
    tDaughterIDInfo sInfo;

    //
    // Read a byte from the flash device.
    //
    bRetcode = EEPROMReadPolled((unsigned char *)&sInfo, 0,
                                sizeof(tDaughterIDInfo));

    if(bRetcode)
    {
        UARTprintf("\nDaughter Board ID Block\n");
        UARTprintf(  "-----------------------\n\n");
        UARTprintf("Marker:       %c%c (0x%02x, 0x%02x)\n", sInfo.pucMarker[0],
                   sInfo.pucMarker[1], sInfo.pucMarker[0], sInfo.pucMarker[1]);
        UARTprintf("Length:       %d bytes\n", sInfo.ucLength);
        UARTprintf("Version:      %d\n", sInfo.ucVersion);
        UARTprintf("BoardID:      %d (0x%04x)\n", sInfo.usBoardID,
                   sInfo.usBoardID);
        UARTprintf("BoardRev:     %d\n", sInfo.ucBoardRev);
        UARTprintf("EPI Mode:     0x%02x\n", sInfo.ucEPIMode);
        UARTprintf("EPI Pins:     0x%08x\n", sInfo.ulEPIPins);
        UARTprintf("Addr Map:     0x%02x\n", sInfo.ucAddrMap);
        UARTprintf("Rate 0:       %dnS\n", sInfo.usRate0nS);
        UARTprintf("Rate 1:       %dnS\n", sInfo.usRate1nS);
        UARTprintf("Max Wait:     %d cycles\n", sInfo.ucMaxWait);
        UARTprintf("Config:       0x%08x\n", sInfo.ulConfigFlags);
        UARTprintf("Read Access:  %dnS\n", sInfo.ucReadAccTime);
        UARTprintf("Write Access: %dnS\n", sInfo.ucWriteAccTime);
        UARTprintf("Read Cycle    %dnS\n", sInfo.usReadCycleTime);
        UARTprintf("Write Cycle:  %dnS\n", sInfo.usWriteCycleTime);
        UARTprintf("Columns:      %d\n", sInfo.usNumColumns);
        UARTprintf("Rows:         %d\n", sInfo.usNumRows);
        UARTprintf("Refresh:      %dmS\n", sInfo.ucRefreshInterval);
        UARTprintf("Frame count:  %d\n", sInfo.ucFrameCount);
        if(sInfo.pucName[0])
        {
            unsigned long ulLoop;
            unsigned long ulIndex;
            unsigned char ucChar;

            UARTprintf("Name:         %c", sInfo.pucName[0]);

            ulIndex = offsetof(tDaughterIDInfo, pucName) + 1;
            ulLoop = (unsigned long)sInfo.ucLength - ulIndex;

            //
            // Read and display the remaining characters in the name string.
            //
            while(ulLoop)
            {
                //
                // Get the next character from the name string.
                //
                bRetcode = EEPROMReadPolled(&ucChar, ulIndex, 1);

                if(bRetcode && ucChar)
                {
                    UARTprintf("%c", ucChar);
                }
                else
                {
                    break;
                }

                ulLoop--;
                ulIndex++;
            }
             UARTprintf("\n");
        }
    }
    else
    {
        UARTprintf("Error reading ID block from daughter board!\n");
    }

    return(COMMAND_OK);
}
Exemplo n.º 2
0
//*****************************************************************************
//
// Determines which daughter board is currently attached to the lm3s9b96
// development board and returns the daughter board's information block as
//
// This function determines which of the possible daughter boards are
// attached to the lm3s9b96.  It recognizes Flash/SRAM and FPGA daughter
// boards, each of which contains an I2C device which may be queried to
// identify the board.  In cases where the SDRAM daughter board is attached,
// this function will return \b NONE and the determination of whether or not
// the board is present is left to function SDRAMInit() in extram.c.
//
// \return Returns \b DAUGHTER_FPGA if the FPGA daugher is detected, \b
// DAUGHTER_SRAM_FLASH if the SRAM and flash board is detected and \b
// DAUGHTER_NONE if not board could be identified (covering the cases where
// either no board or the SDRAM board is attached).
//
//*****************************************************************************
static tDaughterBoard
DaughterBoardTypeGet(tDaughterIDInfo *psInfo)
{
    tBoolean bRetcode;

    //
    // Enable the I2C controller used to interface to the daughter board ID
    // EEPROM (if present).
    //
    SysCtlPeripheralEnable(ID_I2C_PERIPH);

    //
    // Configure the I2C SCL and SDA pins for I2C operation.
    //
    GPIOPinTypeI2C(ID_I2CSCL_GPIO_PORT, ID_I2CSCL_PIN | ID_I2CSDA_PIN);

    //
    // Initialize the I2C master.
    //
    I2CMasterInitExpClk(ID_I2C_MASTER_BASE, SysCtlClockGet(), 0);

    //
    // Read the ID information from the I2C EEPROM.
    //
    bRetcode = EEPROMReadPolled((unsigned char *)psInfo, 0,
                                sizeof(tDaughterIDInfo));

    //
    // Did we read the ID information successfully?
    //
    if(bRetcode)
    {
        //
        // Yes.  Check that the structure marker is what we expect.
        //
        if((psInfo->pucMarker[0] == 'I') && (psInfo->pucMarker[1] == 'D'))
        {
            //
            // Marker is fine.
            //
            switch(psInfo->usBoardID)
            {
                //
                // Is this a daughter board we know about already?
                //
                case DAUGHTER_SRAM_FLASH:
                {
                    //
                    // Yes - return the board ID.
                    //
                    return((tDaughterBoard)psInfo->usBoardID);
                }

                //
                // This is a daughter board that we don't know about.
                //
                default:
                {
                    return(DAUGHTER_UNKNOWN);
                }
            }
        }
    }

    //
    // We experienced an error reading the ID EEPROM or read no valid info
    // structure from the device.  This likely indicates that no daughter
    // board is present.  Set the return structure to configure the system
    // assuming that the default (SDRAM) daughter board is present.
    //
    psInfo->usBoardID = (unsigned short)DAUGHTER_NONE;
    psInfo->ulEPIPins = EPI_PINS_SDRAM;
    psInfo->ucEPIMode = EPI_MODE_SDRAM;
    psInfo->ulConfigFlags = (EPI_SDRAM_FULL_POWER | EPI_SDRAM_SIZE_64MBIT);
    psInfo->ucAddrMap = (EPI_ADDR_RAM_SIZE_256MB | EPI_ADDR_RAM_BASE_6);
    psInfo->usRate0nS = 20;
    psInfo->usRate1nS = 20;
    psInfo->ucRefreshInterval = 64;
    psInfo->usNumRows = 4096;
    return(DAUGHTER_NONE);
}
Exemplo n.º 3
0
//*****************************************************************************
//
// This function implements the "read" command.  It reads a block of bytes from
// a given location in the I2C flash part on the daughter board.
//
//*****************************************************************************
int
Cmd_read(int argc, char *argv[])
{
    const char *pcPos;
    tBoolean bRetcode;
    unsigned long ulAddr, ulCount, ulLoop, ulLoop2;
    unsigned char ucData;

    //
    // Were we passed the correct number of parameters?
    //
    if(argc < 3)
    {
        return(COMMAND_TOO_FEW_ARGS);
    }

    if(argc > 3)
    {
        return(CMDLINE_TOO_MANY_ARGS);
    }

    //
    // Get the parameters.
    //
    ulAddr  = ustrtoul(argv[1], &pcPos, 0);
    ulCount = ustrtoul(argv[2], &pcPos, 0);

    //
    // Make sure the start address is valid.
    //
    if(ulAddr >= 128)
    {
        UARTprintf("Error: Address must be between 0 and 127.\n");
        return(COMMAND_INVALID_ARG);
    }

    //
    // Make sure the end address is valid.
    //
    if((ulAddr + ulCount) > 128)
    {
        UARTprintf("Error: End address must be < 128\n");
        return(COMMAND_INVALID_ARG);
    }

    //
    // Loop through the requested range in steps of 8 bytes.  This double loop
    // is purely to allow us to format the output a bit more cleanly.
    //
     for(ulLoop = (ulAddr & 0xF8); ulLoop < (((ulAddr + ulCount) + 7) & 0xF8);
        ulLoop += 8)
    {
        //
        // Show the address we are currently reading.
        //
        UARTprintf("\n0x%02x: ", ulLoop);

        //
        // Now loop through the individual bytes in this 8 byte block.
        //
        for(ulLoop2 = ulLoop;
           (ulLoop2 < (ulLoop + 8)) && (ulLoop2 < (ulAddr + ulCount));
           ulLoop2++)
        {
            //
            // Are we inside the requested range?  If not, just print a
            // placemarker.
            //
            if(ulLoop2 < ulAddr)
            {
                UARTprintf("   ");
            }
            else
            {
                //
                // We are inside the requested address range so read the value
                // and output it.
                //
                bRetcode = EEPROMReadPolled(&ucData, ulLoop2, 1);

                //
                // Did we read the EEPROM correctly?
                //
                if(bRetcode)
                {
                    UARTprintf("%02x ", ucData);
                }
                else
                {
                    UARTprintf("\nError reading byte from address 0x%02x!\n",
                               ulLoop2);
                    return(COMMAND_OK);
                }
            }
        }
    }

    //
    // Tell the command line processor that we processed the command
    // successfully.
    //
    return(COMMAND_OK);
}