⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deviceinfo.c

📁 ebd9307开发板wince bsp源码,包括cs8900,lcd,nand,serial,touch,usb,gpio,wd等驱动
💻 C
字号:
//**********************************************************************
//                                                                      
// Filename: deviceinfo.c
//                                                                      
// Description: Gets the device information from the eeprom or the
//              or the header file.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Use of this source code is subject to the terms of the Cirrus end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to 
// use this source code. For a copy of the EULA, please see the 
// EULA.RTF on your install media.
//
// Copyright(c) Cirrus Logic Corporation 2005, All Rights Reserved                       
//                                                                      
//**********************************************************************
#include <windows.h>
#include <options.h>
#include <drv_glob.h>


//****************************************************************************
// itoa10
//****************************************************************************
// Converts a number base 10 to a string.
//
// n - Number to convert.
// s - String.
//
void itoa10
(
    int n,
    char s[]
)
{
    int i = 0; 

    // Get absolute value of number
    unsigned int val = (unsigned int)((n < 0) ? -n : n);

    // Extract digits in reverse order
    do {
        s[i++] = (val % 10) + '0';
    } while (val /= 10);

    // Add sign if number negative
    if (n < 0) s[i++] = '-';

    s[i--] = '\0';

    // Reverse string
    for (n = 0; n < i; n++, i--) 
    {
        char swap = s[n];
        s[n] = s[i];
        s[i] = swap;
    }
}

//****************************************************************************
// UpperDWFromMAC
//****************************************************************************
// Get the upper dword from the mac address.
// 
//
static DWORD UpperDWFromMAC(EDBG_ADDR * pAddr)
{
    DWORD ret;

    //
    // The WORDs in wMAC field are in net order, so we need to do some
    // serious shifting around.
    // A hex ethernet address of 12 34 56 78 9a bc is stored in wMAC array as
    // wMAC[0] = 3412, wMAC[1] = 7856, wMAC[2] = bc9a.
    // The 4 byte return value should look like 0x00123456
    //
    ret = (pAddr->wMAC[0] & 0x00ff) << 16;
    ret |= pAddr->wMAC[0] & 0xff00;
    ret |= pAddr->wMAC[1] & 0x00ff;
    return ret;
}

//****************************************************************************
// Create a device name from the MAC address.
//****************************************************************************
// pMyAddr          - Ethernet MAC address 
// szBuf            - Returned name
//
void CreateDeviceName
(
    EDBG_ADDR *pMyAddr, 
    char    *szDeviceName
)
{
    DWORD dwUpperMAC;

        dwUpperMAC = UpperDWFromMAC(pMyAddr);
        strcpy(szDeviceName,EBOOT_PLATFORM_STRING);
        szDeviceName += strlen(szDeviceName);    
        itoa10(((pMyAddr->wMAC[2]>>8) | ((pMyAddr->wMAC[2] & 0x00ff) << 8)), szDeviceName);
}

//****************************************************************************
// GetDeviceMacAddress
//****************************************************************************
// pusMACAddress        - Pointer to the Returned MAC Address for the CS8950.
// pusDefaultMACAddress - Default MAC Address.
//
void GetDeviceMacAddress
(
    USHORT         * pusMACAddress,
    USHORT         * pusDefaultMACAddress
)
{
    //
    // We need to do this since the board does not have a MAC address.
    // Lets use the same mac address as eboot.
    //
    memcpy(pusMACAddress, pusDefaultMACAddress, 6 );
}


//****************************************************************************
// GetPlatformString
//****************************************************************************
//  szPlatformString - Returns the platform string.
// 
//
void GetPlatformString
(
    char *szPlatformString       
)
{
    //
    // Create device name based on Ethernet address.
    //
    memcpy(szPlatformString, EBOOT_PLATFORM_STRING, sizeof(EBOOT_PLATFORM_STRING));
}




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -