我是个新手,在学GCC,现在想把C51里的程序移植到WINAVR里,我用的是WINAVR 20050214。如有一个这样的程序,
#include <avr/io.h>
#undef GLOBAL_EXT
#include "SysCnfg.h"
#include "BasicTyp.H"
#include "usb100.h"
#include "Common.h"
#include "Hal4Sys.h"
#include "Hal4d12.h"
#include "mainloop.h"
#include "chap_9.h"
/*
//*************************************************************************
// Public Data
//*************************************************************************
*/
/* bit Flags
STRUC_EXT BITFLAGS BDATA_SEG bFlags;
/* MCU Timer bit flags
BIT_EXT MCUBF_Timer;
INT8_EXT Hal4Sys_ClockTicks;
/* D12 bit flags
BIT_EXT D12BF_SetupOverwritten;
BIT_EXT D12BF_Configuration;
//USB
// DefaultControlPipe Finite State Machine [One-Hot]
INT8_EXT BDATA_SEG DCPFSMstate;
BIT_EXT DCPFSM_SetupProc;
BIT_EXT DCPFSM_DataIn;
BIT_EXT DCPFSM_DataOut;
BIT_EXT DCPFSM_COhandshake;
BIT_EXT DCPFSM_CIhandshake;
BIT_EXT DCPFSM_Stall;
// DCP FSM
// SETUP Stage -> SETUP Proc -> DATA OUT Stage -> CONTROL OUT Handshake -> STATUS Stage -> IDLE
// SETUP Stage -> SETUP Proc -> CONTROL OUT Handshake -> STATUS Stage -> IDLE
// SETUP Stage -> SETUP Proc -> DATA IN Stage-> CONTROL IN Handshake ->STATUS Stage -> IDLE
//
// USB Device Request
STRUC_EXT DEVICE_REQUEST DCPDeviceRequest;
INT8_EXT UsbReq_Recipient;
INT8_EXT UsbReq_Type;
INT8_EXT UsbReq_Request;
BIT_EXT REQBF_DCPRequest_dir;
BIT_EXT REQBF_StallDCPRequest;
BIT_EXT REQBF_DCPRequest_EPdir;
// Default Control Pipe Tansfer DCPXfer
INT8_EXT BDATA_SEG Xfer_Space;
BIT_EXT DCPXfer_atMCUCODE;
BIT_EXT DCPXfer_atMCURAM;
BIT_EXT DCPXfer_atEEROM;
BIT_EXT DCPXfer_atATA;
INT16_EXT DCPXfer_wResidue;
INT8_EXT * DCPXfer_pData;
// Bulk-Only TP Finite State Machine [One-Hot]
INT8_EXT BDATA_SEG BOTFSMstate;
BIT_EXT BOTFSM_CBWProc;
BIT_EXT BOTFSM_DataIn;
BIT_EXT BOTFSM_DataOut;
BIT_EXT BOTFSM_CSWProc;
BIT_EXT BOTFSM_CSW;
BIT_EXT BOTFSM_IDLE;
BIT_EXT BOTFSM_Stall;
// BOT FSM
// IDLE Stage -> CBW -> CBW Proc -> DATA OUT Stage -> CSW Proc -> CSW Stage -> IDLE
// IDLE Stage -> CBW -> CBW Proc -> DATA IN Stage -> CSW Proc -> CSW Stage -> IDLE
// STALL Stage -> IDLE
//
BIT_EXT BOTBF_StallAtBulkOut;
BIT_EXT BOTBF_StallAtBulkIn;
BIT_EXT BOTXfer_atRAM;
BIT_EXT BOTXfer_atATA;
BIT_EXT BOTXfer_atROM;
/*
//*************************************************************************
// Public temp var
//*************************************************************************
*/
/*// Public temp var
STRUC_EXT FLEXI_INT32 tempvars4UsbReq;
INT8_EXT BDATA_SEG FlexByte;
BIT_EXT FlexByte_b0 ;
BIT_EXT FlexByte_b1;
BIT_EXT FlexByte_b2;
BIT_EXT FlexByte_b3;
BIT_EXT FlexByte_b4;
BIT_EXT FlexByte_b5;
BIT_EXT FlexByte_b6;
BIT_EXT FlexByte_b7;
*/
/*
//*************************************************************************
// Private temp var
//*************************************************************************
*/
/*
//*************************************************************************
// USB Device Descriptor
//*************************************************************************
*/
//设备描述符
code USB_DEVICE_DESCRIPTOR DeviceDescr
{
sizeof(USB_DEVICE_DESCRIPTOR); // 设备描述符长度
USB_DEVICE_DESCRIPTOR_TYPE; // 设备描述符类型=01
/*SWAP(0x0100);*/ // 协议版本
0; // 测试设备类型
0; // 设备子类
0; // 设备协议
EP0_PACKET_SIZE; // 端点0最大数据包大小,=10H
/*SWAP(0x0693),
SWAP(0x0003),
SWAP(0x0100),*/ // 设备系列号
STR_INDEX_MANUFACTURER; // 厂商描述符字符串索引,=01H
STR_INDEX_PRODUCT; // 产品描述符字符串索引,=02H
STR_INDEX_SERIALNUMBER; // 设序列号字符串索引,=03H
1; // 可能备置数
};
#define NUM_ENDPOINTS 2 //定义除主控端点外的端点数
#define CONFIG_DESCRIPTOR_LENGTH (sizeof(USB_CONFIGURATION_DESCRIPTOR) + sizeof(USB_INTERFACE_DESCRIPTOR) + (NUM_ENDPOINTS * sizeof(USB_ENDPOINT_DESCRIPTOR)))
//设备配置描述符
code USB_CONFIGURATION_DESCRIPTOR ConfigDescr =
{
sizeof(USB_CONFIGURATION_DESCRIPTOR),
USB_CONFIGURATION_DESCRIPTOR_TYPE, // 类型,=02H
SWAP(CONFIG_DESCRIPTOR_LENGTH), // 返回整个数据长度。包括该配置所返回的所有描述符(配置、接口、端点和类型或供应商)=20H
1, // 配置所支持的接口数
1, // 作为Set Configuration 的一个参数选择配置值
0, //STR_INDEX_CONFIGURATION, // 用于描述该配置字符串描述符的索引
0x80, // 配置特性:总线供电
0x32 // zero power consumption
};
谢谢啦,麻烦各位大侠了~~
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
//设备描述符
code USB_DEVICE_DESCRIPTOR DeviceDescr
改成了const USB_DEVICE_DESCRIPTOR DeviceDescr
但是/* bit Flags
STRUC_EXT BITFLAGS BDATA_SEG bFlags; 以及以下的都不知道怎么改
请达人帮忙下啊
一周热门 更多>