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

📄 transceiver.c

📁 Windows CE 6.0 BSP for the Beagle Board.
💻 C
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
//------------------------------------------------------------------------------
//
//  File:  transceiver.c
//
#include <windows.h>
#include <oal.h>
#include <omap2420.h>

//------------------------------------------------------------------------------

#define MODE_CTL1_SET               0x04      
#define MODE_CTL1_CLR               0x05
#define MODE_CTL2_SET               0x12      
#define MODE_CTL2_CLR               0x13
#define OTG_CTL1_SET                0x06      
#define OTG_CTL1_CLR                0x07

#define MODE_CTL1_SPEED             (1 << 0)
#define MODE_CTL2_SPD_SUSP_CTRL     (1 << 1)
#define MODE_CTL2_BI_DI             (1 << 2)
#define OTG_CTL1_DP_PULLUP          (1 << 0)
#define OTG_CTL1_DM_PULLDOWN        (1 << 3)

#define VENDOR_ID                   0x00
#define PRODUCT_ID                  0x02
#define VERSION_ID                  0x14

//------------------------------------------------------------------------------

BOOL InitI2cController();
BOOL WriteUcharI2C( UCHAR reg, UCHAR data );
BOOL ReadUshortI2C( UCHAR reg, USHORT *pData );

//------------------------------------------------------------------------------

BOOL InitOTGTransceiver()
{
    // configure the I2C controller
    if( !InitI2cController() )
        return FALSE;

    // Active power, direct I2C, VP_VM 4 pin mode, full speed
    WriteUcharI2C( MODE_CTL1_CLR, 0xFF );
    OALStall(100000);
    WriteUcharI2C( MODE_CTL1_SET, MODE_CTL1_SPEED );
    OALStall(100000);

    // No power down, speed and suspend by registers, DAT_VP & SE0_VM bi-dir
    WriteUcharI2C( MODE_CTL2_CLR, 0xFF );
    OALStall(100000);

    WriteUcharI2C( MODE_CTL2_SET, MODE_CTL2_SPD_SUSP_CTRL|MODE_CTL2_BI_DI );
    OALStall(100000);

    return TRUE;
}

//------------------------------------------------------------------------------

void ConnectHardware()
{
    // enable D+ pull up and D- pull down
    WriteUcharI2C( OTG_CTL1_SET, OTG_CTL1_DP_PULLUP | OTG_CTL1_DM_PULLDOWN);
}

//------------------------------------------------------------------------------

void DisconnectHardware()
{
    // disable D+ pull up and D- pull down
    WriteUcharI2C( OTG_CTL1_CLR, OTG_CTL1_DP_PULLUP | OTG_CTL1_DM_PULLDOWN);
}

//------------------------------------------------------------------------------

⌨️ 快捷键说明

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