//#############################################################################
// FILE: usbhostenum.c
// TITLE: Device enumeration code for the USB host library
//#############################################################################
// $TI Release: F2837xS Support Library v210 $
// $Release Date: Tue Nov 1 15:35:23 CDT 2016 $
// $Copyright:
// Copyright (C) 2014-2016 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the
// distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/debug.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/usb.h"
#include "driverlib/rtos_bindings.h"
#include "usblib/usblib.h"
#include "usblib/usblibpriv.h"
#include "usblib/host/usbhost.h"
#include "usblib/host/usbhostpriv.h"
#include "usblib/host/usbhhub.h"
#ifdef INCLUDE_DEBUG_OUTPUT
#include "utils/uartstdio.h"
#define DEBUG_OUTPUT UARTprintf
#else
#define DEBUG_OUTPUT while(0)((int32_t (*)(char *, ...))0)
#endif
//*****************************************************************************
//
//! \addtogroup usblib_hcd
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// External prototypes.
//
//*****************************************************************************
extern tUSBMode g_iUSBMode;
extern void OTGDeviceDisconnect(uint32_t ui32Index);
//*****************************************************************************
//
// Internal function prototypes.
//
//*****************************************************************************
static void USBHCDEP0StateTx(void);
static void USBHCDEnumHandler(void);
static void USBHCDClearFeature(uint32_t ui32DevAddress, uint32_t ui32Endpoint,
uint32_t ui32Feature);
//*****************************************************************************
//
// Automatic power enable.
//
//*****************************************************************************
#define USB_HOST_PWREN_AUTO 0x00000002
//*****************************************************************************
//
// Flags used to signal between the interrupt handler and USBHCDMain().
//
//*****************************************************************************
#define INT_EVENT_VBUS_ERR 0x01
#define INT_EVENT_CONNECT 0x02
#define INT_EVENT_DISCONNECT 0x04
#define INT_EVENT_POWER_FAULT 0x08
#define INT_EVENT_SOF 0x10
#define INT_EVENT_ENUM 0x20
//*****************************************************************************
//
// Flags used with the tUSBHostDevice.ui32Flags structure member.
//
//*****************************************************************************
#define USBHDEV_FLAG_NOTIFYINT 0x00000001
#define USBHDEV_FLAG_ALLOCATED 0x80000000
//*****************************************************************************
//
// This holds the current power configuration that is used when USBHCDInit()
// is called.
//
//*****************************************************************************
static uint32_t g_ui32PowerConfig = USBHCD_VBUS_AUTO_HIGH;
//*****************************************************************************
//
// The states for endpoint 0 during enumeration.
//
//*****************************************************************************
typedef enum
{
//
// The USB device is waiting on a request from the host controller on
// endpoint 0.
//
eEP0StateIdle,
//
// Setup packet is expecting data IN.
//
eEP0StateSetupIN,
//
// Setup packet is sending data OUT.
//
eEP0StateSetupOUT,
//
// The USB device is receiving data from the device due to an SETUP IN
// request.
//
eEP0StateRx,
//
// The USB device has completed the IN or OUT request and is now waiting
// for the host to acknowledge the end of the IN/OUT transaction. This
// is the status phase for a USB control transaction.
//
eEP0StateStatus,
//
// This state is for when a response only has a status phase and no
// data phase.
//
eEP0StateStatusIN,
//
// This endpoint has signaled a stall condition and is waiting for the
// stall to be acknowledged by the host controller.
//
eEP0StateStall,
//
// An error has occurred on endpoint 0.
//
eEP0StateError
}
tEP0State;
//*****************************************************************************
//
// This structure holds the full state for the device enumeration.
//
//*****************************************************************************
typedef struct
{
//
// This is the pointer to the current data being sent out or received
// on endpoint 0.
//
uint8_t *pui8Data;
//
// This is the number of bytes that remain to be sent from or received
// into the g_DeviceState.pEP0Data data buffer.
//
volatile uint32_t ui32BytesRemaining;
//
// The amount of data being sent/received due to a request.
//
uint32_t ui32DataSize;
//
// This is the current device address in use by endpoint 0.
//
uint32_t ui32DevAddress;
//
// The maximum packet size for the device responding to the setup packet.
//
uint32_t ui32MaxPacketSize;
//
// The host controller's state.
//
tEP0State iState;
}
tHostState;
//*****************************************************************************
//
// This variable holds the current state of endpoint 0.
//
//*****************************************************************************
static volatile tHostState g_sUSBHEP0State =
{
0, // pui8Data
0, // ui32BytesRemaining
0, // ui32DataSize
0, // ui32DevAddress
0, // ui32MaxPacketSize
eEP0StateIdle // iState
};
//******
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
usb_dev_serial_cpu1_cpy8.4us.zip_F2837xS_dsp_uart_upward492 (187个子文件)
F2837xS_CodeStartBranch.asm 3KB
F2837xS_usDelay.asm 2KB
usbhostenum.c 184KB
usb.c 128KB
usbdcdc.c 104KB
usbdenum.c 96KB
F2837xS_DefaultISR.c 57KB
ustdlib.c 53KB
usbhhub.c 45KB
usbbuffer.c 42KB
uart.c 40KB
usbmode.c 37KB
usb_dev_serial.c 35KB
F2837xS_SysCtrl.c 29KB
sysctl.c 28KB
usbdcdesc.c 25KB
usbringbuf0.c 23KB
usbringbuf.c 22KB
F2837xS_GlobalVariableDefs.c 21KB
usbdconfig.c 21KB
usbdesc.c 19KB
F2837xS_PieVect.c 15KB
F2837xS_Gpio.c 15KB
usbdma.c 12KB
interrupt.c 11KB
usbtick.c 8KB
systick.c 8KB
usb_serial_structs.c 7KB
usb_hal.c 4KB
usbdhandler.c 4KB
F2837xS_CpuTimers.c 4KB
F2837xS_PieCtrl.c 2KB
.ccsproject 451B
TMS320F28377S.ccxml 1KB
F2837xS_Headers_nonBIOS.cmd 13KB
2837xS_Generic_FLASH_lnk.cmd 5KB
2837xS_RAM_lnk_cpu1_USB.cmd 4KB
.cproject 36KB
usb_dev_serial.d 14KB
usb_dev_serial.d 14KB
usbdenum.d 12KB
usb_hal.d 11KB
usb_hal.d 11KB
systick.d 10KB
systick.d 10KB
interrupt.d 10KB
interrupt.d 10KB
sysctl.d 10KB
sysctl.d 10KB
F2837xS_DefaultISR.d 10KB
F2837xS_DefaultISR.d 10KB
F2837xS_CpuTimers.d 10KB
F2837xS_CpuTimers.d 10KB
F2837xS_PieCtrl.d 10KB
F2837xS_SysCtrl.d 10KB
F2837xS_PieVect.d 10KB
F2837xS_SysCtrl.d 10KB
F2837xS_PieCtrl.d 10KB
F2837xS_PieVect.d 10KB
F2837xS_Gpio.d 9KB
F2837xS_Gpio.d 9KB
F2837xS_GlobalVariableDefs.d 7KB
F2837xS_GlobalVariableDefs.d 7KB
usbmode.d 3KB
usbmode.d 3KB
usbhostenum.d 3KB
usbhostenum.d 3KB
usbdenum.d 3KB
usbdcdc.d 3KB
usbdcdc.d 3KB
usbdma.d 2KB
usbdma.d 2KB
usbhhub.d 2KB
usbhhub.d 2KB
usbdhandler.d 2KB
usbdhandler.d 2KB
usb_serial_structs.d 2KB
usb_serial_structs.d 2KB
usbdconfig.d 2KB
usbdconfig.d 2KB
usbdcdesc.d 2KB
usbdcdesc.d 2KB
usb.d 1KB
usb.d 1KB
uart.d 1KB
uart.d 1KB
usbbuffer.d 1KB
usbringbuf0.d 989B
usbringbuf0.d 989B
usbbuffer.d 967B
usbtick.d 949B
usbtick.d 949B
ustdlib.d 792B
ustdlib.d 792B
usbdesc.d 577B
usbdesc.d 577B
usb_serial_structs.h 1KB
usblib.lib 676KB
makefile 6KB
makefile 6KB
共 187 条
- 1
- 2
资源评论
JaniceLu
- 粉丝: 79
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功