1、 return FIFO_FLAG;BYTE FIFO_WR_CHECK(BYTE num)/后4位表示Ready位,前四位表示Len0位的状态是否有被设置 MISC|=0X02;void Read_FIFO(BYTE *Fifo_Addr,BYTE Fifo_Size,BYTE *buffer) int i=0; MISC|=0x01; for(i=0;idata_start0)/请求的数据超出ROM数据 data_count=buffer6;0x40!=0)/是控制指令 if(data_count=0) Send_Hand_Shake(); /开始真正的control_read if(bF
2、lag_RD_HTable=0)/Read Low Byte bFlag_RD_HTable=1; bufferi=(BYTE )*rom_dataptr;/取其低位 i+; data_count-;/全局变量,要发送的总长度 if(data_count8;/取其高位 rom_dataptr+;/将ROM指针前移 if(bufferi=0x3f) if(i+1=8) /填充完毕,结束循环,开始向FIFO发送数据 if(Check_Real_Cmd()=TRUE) return; if(FIFO_WR_CHECK(0)&0xff=0) continue; Write_FIFO(Fifo_0_Ad
3、dr,0x02,buffer); / SetAddress(): 重新设定Endpoint地址函数void SetAddress(BYTE *buffer) BYTE Dev_Addr; Dev_Addr=buffer2/FIFO_OUT3,FIFO_WVALUEL SIES|=0x01;/主机从设备读操作后将更新在AWR中的地址,否则为0则立即更新 Dev_Addr& USB_AWR=Dev_Addr;/ SetConfiguration(): 设置配置函数void SetConfiguration(BYTE *buffer,BYTE *USB_Configuration) USVC|=0x
4、80; PGA_CTRL|=0x80; *USB_Configuration=buffer2;/FIFO_WVALUEL STALL&=0x00;/设置好以上的寄存器/ ClearFeature(): 清徐Feature函数void ClearFeature(BYTE *buffer) BYTE temp; temp=buffer2;/FIFO_wValueL if(temp=0x01) STALL0|=0x01;/SendStall0();void ClearFeature_Endpoint(BYTE *buffer) temp=buffer4;/FIFO_wIndexL if(bFlag_
5、SetConfiguration_Ready=TRUE);/表明已经配置过了 temp=GetPipeBit(temp);/获取对应位 temp=temp;/取反 STALL=temp&STALL;/与STALL寄存器相与,将需要的位置0/ SetFeature(): 设置Feature函数/ 包括Endpoint部分void SetFeature(BYTE *buffer) BYTE FIFO_wValueL=buffer2; BYTE FIFO_wValueH=buffer3; if(FIFO_wValueH=0x00) if(FIFO_wValueL=0x01) else if(FIFO
6、_wValueH=0X81 0010 0000B if(temp&STALL=TRUE)/要检测的位置1 buffer0=1; else buffer0=0; buffer1=0;/ GetConfiguration(): 设置配置的函数 void GetConfiguration(BYTE *buffer,BYTE USB_Configuration) BYTE FIFO_SendLen; buffer0=USB_Configuration; FIFO_SendLen=0x01;=0)/Fifo Ready/ GetInterface(): 获取Interface接口的函数 void Get
7、Interface(BYTE USB_Interface_Alt,BYTE *buffer) buffer0=USB_Interface_Alt; Write_FIFO(Fifo_0_Addr,FIFO_SendLen,buffer)/ SetReport(): 设置Report的函数 BYTE SetReport(BYTE *buffer) BYTE nCmdIndex1; if(FIFO_wValueH=0x02)/set_output_report if(buffer4!=0x03)/check interface STALL|=0x01;/ENPOINT0 Error if(buffe
8、r6!=0x08)/FIFO_wLengthL,check length nCmdIndex1=0x21; return nCmdIndex1;/返回命令索引号/ SetCur(): 设置当前信息的函数 / 包括VolumeControl,MuteControlvoid SetCur(BYTE *buffer)/;21 01 if(buffer3=0x01)/MUTE_CONTROL MuteControl(); else if(buffer3=0x02)/VOLUME_CONTROL VolumeControl();BYTE MuteControl(BYTE *buffer) /21 01
9、00 01,if have more feature , the state must be modify! if(buffer5=0x02)/FIFO_wIndexH,MuteControl_SetSpeaker(); nCmdIndex1=0x18; else if(buffer5=0x06)/MuteControl_SetMic(); nCmdIndex1=0x19;BYTE VolumeControl(BYTE *buffer) if(buffer5=0x02)/FIFO_wIndexH,VolumeControl_SetSpeaker() nCmdIndex1=0x28; else ifbuffer5=0x06) nCmdIndex1=0x29;/ GetMin(): 获取各种最小信息的函数 / 包括GetMin_SetSpeaker,GetMin_SetMicvoid GetMin(BYTE *buffer) if(buffer5=0x02)/FIFO_wIndex
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1