/* ------------------------------------------------------------------------ *
 *                                                                          *
 *  _FLASH_getId( )                                                         *
 *                                                                          *
 *      Get IDs                                                             *
 *                                                                          *
 * ------------------------------------------------------------------------ */
Uint16 _FLASH_getId( Uint16* id)
{
    Uint32 addr = FLASH_BASE;

    volatile Uint16* addr16  = ( Uint16* )addr;
    volatile Uint16* pmfgid  = ( Uint16* )addr;
    volatile Uint16* pdevid1 = ( Uint16* )( addr + 0x1 );

    FLASH_CTL555 = FLASH_RESET;
    USBSTK5515_waitusec(10);

    /* Configure to read manufacturer ID */
    FLASH_CTL555 = FLASH_CMD_AA;
    FLASH_CTL2AA = FLASH_CMD_55;
    FLASH_CTL555 = FLASH_ID;

    /* Insert small delay for device to respond */
    USBSTK5515_waitusec(10);

    *id++ = *pmfgid;          // Read MFG_ID
    *id++ = *pdevid1;         // Read DEV_ID

    *addr16 = FLASH_RESET;
    return 0;
}
コード例 #2
0
ファイル: uled_test.c プロジェクト: mpigsley/C5515
/* ------------------------------------------------------------------------ *
 *                                                                          *
 *  uled_test( )                                                            *
 *     User LED tests toggles each of the four user LEDs 6 times            *                                             
 *                                                                          *
 * ------------------------------------------------------------------------ */
Int16 uled_test( )
{
    Int16 i, j;
    
    printf("    User LED tests toggles each of the four user LEDs 6 times\n");
 	SYS_EXBUSSEL = 0x6000;  // Enable user LEDs on external bus
    USBSTK5515_ULED_init( );

    /* Running LED test */
    for ( j = 0 ; j < 6 ; j++ )
    {
        for ( i = 0 ; i < 4 ; i++ )
        {
            if ( USBSTK5515_ULED_on( i ) )  // Turn on user LED i
                return 1;
            USBSTK5515_waitusec( 50000 );
        }
        
        for ( i = 0 ; i < 4 ; i++ )
        {
            if ( USBSTK5515_ULED_off( i ) ) // Turn off user LED i
                return 2;
            USBSTK5515_waitusec( 50000 );
        }
    }
    USBSTK5515_ULED_setall( 0x00 );

    return 0;
}
コード例 #3
0
ファイル: usbstk5515_i2c.c プロジェクト: dervish77/adgf
/* ------------------------------------------------------------------------ *
 *                                                                          *
 *  _I2C_read( i2c_addr, data, len )                                        *
 *                                                                          *
 *      I2C read in Master mode                                             *
 *                                                                          *
 *      i2c_addr    <- I2C slave address                                    *
 *      data        <- I2C data ptr                                         *
 *      len         <- # of bytes to write                                  *
 *                                                                          *
 *      Returns:    0: PASS                                                 *
 *                 -1: FAIL Timeout                                         *
 *                                                                          *
 * ------------------------------------------------------------------------ */
Int16 USBSTK5515_I2C_read( Uint16 i2c_addr, Uint8* data, Uint16 len )
{
    Int32 timeout, i;

    I2C_CNT = len;                    // Set length
    I2C_SAR = i2c_addr;               // Set I2C slave address
    I2C_MDR = MDR_STT                 // Set for Master Read
              | MDR_MST
              | MDR_IRS
              | MDR_FREE;

    USBSTK5515_wait( 10 );            // Short delay

    for ( i = 0 ; i < len ; i++ )
    {
        timeout = i2c_timeout;

        //Wait for Rx Ready 
        do
        {
            if ( timeout-- < 0 )
            {
                USBSTK5515_I2C_reset( );
                return -1;
            }
        } while ( ( I2C_STR & STR_RRDY ) == 0 );// Wait for Rx Ready

        data[i] = I2C_DRR;            // Read
    }

    I2C_MDR |= MDR_STP;               // Generate STOP

	USBSTK5515_waitusec(10);
    return 0;
}
コード例 #4
0
ファイル: usbstk5515_i2c.c プロジェクト: dervish77/adgf
/* ------------------------------------------------------------------------ *
 *                                                                          *
 *  _I2C_write( i2c_addr, data, len )                                       *
 *                                                                          *
 *      I2C write in Master mode                                            *
 *                                                                          *
 *      i2c_addr    <- I2C slave address                                    *
 *      data        <- I2C data ptr                                         *
 *      len         <- # of bytes to write                                  *
 *                                                                          *
 * ------------------------------------------------------------------------ */
Int16 USBSTK5515_I2C_write( Uint16 i2c_addr, Uint8* data, Uint16 len )
{
    Int16 timeout, i;

		//I2C_IER = 0x0000;
        I2C_CNT = len;                    // Set length
        I2C_SAR = i2c_addr;               // Set I2C slave address
        I2C_MDR = MDR_STT                 // Set for Master Write
                  | MDR_TRX
                  | MDR_MST
                  | MDR_IRS
                  | MDR_FREE;

        USBSTK5515_wait(100);              // Short delay

        for ( i = 0 ; i < len ; i++ )
        {
           I2C_DXR = data[i];            // Write
            timeout = 0x510;             // I2C_timeout = 1ms;
            USBSTK5515_GPIO_setOutput( 17, 1);
            do
            {
                if ( timeout-- < 0  )
                {
                	USBSTK5515_GPIO_setOutput( 17, 0);
                    USBSTK5515_I2C_reset( );
                    return -1;
                }
            } while ( ( I2C_STR & STR_XRDY ) == 0 );// Wait for Tx Ready
        }

        I2C_MDR |= MDR_STP;             // Generate STOP

		USBSTK5515_waitusec(1000);

        return 0;

}