📄 usb_var.c
字号:
/**************** (c) 1998 STMicroelectronics **********************
PROJECT : USB - ST7
COMPILER : ST7 HICROSS C (HIWARE)
MODULE : usb_var.c
VERSION : V 1.1
CREATION DATE : 25/05/98
AUTHOR : / MICROCONTROLLER DIVISION / ST Rousset
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
DESCRIPTION : ST7263 USB variables.
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
MODIFICATIONS :
Rev 1.1 23/09/98
-Added :
#include "usb_var.h"
-Removed : (already declared in usb_var.h)
struct endpoint
{
Byte Rx[8];
Byte Tx[8];
};
-Moved:
Byte bmUsbState;to be under #pragma DATA_SEG SHORT MY_RAM0 and not
#pragma DATA_SEG DEFAULT (not coherent with usb_var.h definition).
******************************************************************************/
#include "hidef.h"
#include "condcomp.h"
#include "usb_var.h"
#pragma DATA_SEG SHORT MY_RAM0
Byte bmUsbState;
/* This bit bit-mapped SW register describes the current Remote Wake up / Go Suspend /
Start of Frame / Device enumerated.
It is written when one of those events occur.
--------------------------------------------------------------------------------
| Bit7 | Bit6 | Bit5 | Bit4 | Bit3 | Bit2 | Bit1 | Bit0 |
--------------------------------------------------------------------------------
| - | - | - | - | Enumerated | SOF | Go Suspend | Remote Wakeup |
--------------------------------------------------------------------------------
*/
Byte bmUsbIntFlag;
/* This bit-mapped SW register describes the current interrupt status.
It is written when a USB interrupt occurs.
When a bit = 1, the corresponding interrupt has occured.
--------------------------------------------------------
| Bit7 | Bit6 | Bit5 | Bit4 | Bit3 | Bit2 | Bit1 | Bit0 |
--------------------------------------------------------
| SUSP | DOVR | CTR | ERR | IOVR | ESUSP| RESET| SOF |
--------------------------------------------------------
*/
Byte UsbCtrStatus;
/*This SW register specifies the current Control Transfer transaction stages.
------------------------------------------------------------------
| Phase name | Value | Description |
------------------------------------------------------------------
| DATA_STAGE_IN | 0x01 | Control Transfer with IN data phase |
| | | |
| DATA_STAGE_OUT | 0x02 | Control Transfer with OUT data phase |
| | | |
| LAST_OUT_TRANS | 0x04 | The Status Stage(IN) must be performed |
| | | |
| LAST_IN_TRANS | 0x08 | The Status Stage(OUT) must be performed|
| | | |
| NO_MORE_DATA | 0x10 | No more data to send during Data Stage |
| | | |
| NO_DATA_STAGE | 0x20 | No-Data Control Transfer |
| | | |
| ADDRESS2SET | 0x40 | Device address must be written |
| | | after completion of Status Stage |
------------------------------------------------------------------
*/
Byte UsbImr; // This byte specifies the Interrupt Mask value to write in the Interrupt Mask
// register.
Byte UsbbmRequestType; // This byte specifies the bmRequestType value of the last USB Device Request
// received by the device (see USB spec. version 1.0).
Byte UsbbRequest; // This byte specifies the bRequest value of the last USB Device Request
// received by the device (see USB spec. version 1.0).
Byte UsbwValue[2];
/* This array specifies the wValue value of the last USB Device Request
received by the device (see USB spec. version 1.0).
UsbwValue[0] = lower byte
UsbwValue[1] = higher byte
*/
Byte UsbwIndex[2];
/* This array specifies the wIndex value of the last USB Device Request
received by the device (see USB spec. version 1.0).
UsbwIndex[0] = lower byte
UsbwIndex[1] = higher byte
*/
unsigned int CurrentUsbbLength; // This byte specifies the current number of bytes to transmit
// during the Control Transfer Data Stage.
unsigned int CurrentDescAddPointer; // This byte specifies the current pointer position
// of the transmited Descsriptor during the enumeration.
Byte UsbDataTrDir;
/* This byte specifies the packet identifier (PID) of the last USB packet
received by the device (see USB spec. version 1.0).
------------------------------------------------------------------------
| Token PID | Value | Description |
------------------------------------------------------------------------
| TP_OUT | 0x00 | Address + endpoint number in host -> function |
| | | transaction |
| | | |
| TP_IN | 0x80 | Address + endpoint number in function -> host |
| | | transaction |
| | | |
| TP_SETUP | 0xC0 | Address + endpoint number in function -> host |
| | | transaction for setup to a control endpoint |
| | | |
------------------------------------------------------------------------
*/
Byte UsbEndpNumber; // This byte specifies the endpoint address of endpoint addressed
// during the last USB packet received by the device
// (see USB spec. version 1.0).
Byte InterfaceValue; // Interface Value
Byte ConfigurationValue; // USB Device Configuration Value
Byte InterfacebmAttributes; // bmAttributes value of Interface Descriptor
#pragma DATA_SEG DMA_CTRL // The USB dma buffers must start at an 0xXX00 address (0x200 for instance)
struct endpoint Endpoint0; // Endpoint buffers
#ifdef USE_ENDPOINT1
#pragma DATA_SEG DMA_IN1
Byte Endpoint1[8];
#endif
#ifdef USE_ENDPOINT2
#pragma DATA_SEG DMA_IN2
Byte Endpoint2[8];
#endif
#pragma DATA_SEG DEFAULT
Byte DeviceStatusInfo;
/* This array specifies the status value of the specified
recipient (see USB spec. version 1.0).
For a device:
DeviceStatusInfo
--------------------------------------------------------
| Bit7 | Bit6 | Bit5 | Bit4 | Bit3 | Bit2 | Bit1 | Bit0 |
--------------------------------------------------------
| - | - | - | - | - | - |Remote| Self |
| | | | | | |Wakeup|Power.|
--------------------------------------------------------
*/
Byte Endpoint0StatusInfo;
#ifdef USE_ENDPOINT1
Byte Endpoint1StatusInfo;
#endif
#ifdef USE_ENDPOINT2
Byte Endpoint2StatusInfo;
#endif
/*
For an endpoint:
EndpointXStatusInfo
--------------------------------------------------------
| Bit7 | Bit6 | Bit5 | Bit4 | Bit3 | Bit2 | Bit1 | Bit0 |
--------------------------------------------------------
| - | - | - | - | - | - | - | Halt |
--------------------------------------------------------
*/
Byte Protocol;
Byte Idle;
#pragma DATA_SEG DEFAULT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -