commit 36da235535db4c1854b54b39624d7f36bf990498 Author: josch Date: Thu Jun 26 09:38:06 2014 +0200 initial commit diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4323eac --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +CC=gcc +CFLAGS=-Wall +LDFLAGS=-lusb -lm + +keenectl: keenectl.o diff --git a/PRG/CAL.LST b/PRG/CAL.LST new file mode 100644 index 0000000..896fd1f --- /dev/null +++ b/PRG/CAL.LST @@ -0,0 +1,114 @@ +文件:CAL.ASM 盛群编译器版本 2.86 页次1 + + + 1 0000 ;8 bit unsigned mul + 2 0000 unbin_mul_8 proc ;data0*data4---->to1to0 + 3 0000 init +Error(A0010) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 3 : 非预期的符号 'init' + 4 0000 0F08 mov a, 08h + 5 0001 0000 mov count0, a +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 5 : 语法错误 + 6 0002 rradd: + 7 0002 0000 rrc to1 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 7 : 语法错误 + 8 0003 0000 rrc data4 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 8 : 语法错误 + 9 0004 380A snz [0ah].0 + 10 0005 2800 R jmp rr1 ;当前data4.0=0,移位 + 11 0006 0F00 mov a, data0 ;当前data4.0=1,移位相加 +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 11 : 未定义的符号 'data0' + 12 0007 0000 addm a, to1 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 12 : 语法错误 + 13 0008 rr1: + 14 0008 0000 sdz count0 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 14 : 语法错误 + 15 0009 2800 R jmp rradd + 16 000A 0000 rrc to1 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 16 : 语法错误 + 17 000B 0000 rrc data4 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 17 : 语法错误 + 18 000C 0F00 mov a, data4 +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 18 : 未定义的符号 'data4' + 19 000D 0000 mov to0, a +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 19 : 语法错误 + 20 000E 0003 ret + 21 000F unbin_mul_8 endp + 22 000F + 23 000F + 24 000F ;8 bit unsigned div + 25 000F unbin_div_8 proc ;data0/data4---->data0(to0)---to1 + 26 000F init +Error(A0010) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 26 : 非预期的符号 'init' + 27 000F 0F08 mov a, 08h ;循环次数8 + 28 0010 0000 mov count0, a +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 28 : 语法错误 + 29 0011 + 30 0011 0000 sz data4 ;除数为0则溢出 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 30 : 语法错误 + 31 0012 2800 R jmp start0 + 32 0013 2800 R jmp over8 + 33 0014 start0: + 34 0014 0000 sz data0 ;被除数为0则结束 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 34 : 语法错误 + 35 0015 2800 R jmp div0 + 36 0016 2800 R jmp dispa + 37 0017 div0: + 38 0017 340A clr [0Ah].0 ;准备左移 + 39 0018 0000 rlc data0 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 39 : 语法错误 + 40 0019 0000 rlc to1 ;左移一位结束 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 40 : 语法错误 + 41 001A 0F00 mov a, to1 ;开始部分余数减除数 +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 41 : 未定义的符号 'to1' + 文件:CAL.ASM 盛群编译器版本 2.86 页次2 + + 42 001B 0A00 sub a, data4 +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 42 : 未定义的符号 'data4' + 43 001C 380A snz [0Ah].0 + 44 001D 2800 R jmp next0 ;不够减则转移 + 45 001E 0000 mov to1, a ;够减则商为1 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 45 : 语法错误 + 46 001F 0000 inc data0 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 46 : 语法错误 + 47 0020 next0: + 48 0020 0000 sdz count0 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 48 : 语法错误 + 49 0021 2800 R jmp div0 + 50 0022 dispa: + 51 0022 0F00 mov a, data0 ;显示商 +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 51 : 未定义的符号 'data0' + 52 0023 0000 mov to0, a +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 52 : 语法错误 + 53 0024 ;; mov a, data4 + 54 0024 ;; mov to1, a + 55 0024 0003 ret + 56 0025 over8: + 57 0025 0003 ret + 58 0026 unbin_div_8 endp + 59 0026 + 60 0026 + 61 0026 ;16 bit unsigned div + 62 0026 unbin_div_16 proc ;data0data1/data4data5---->data1data0(to1to0)---to2to3 + 63 0026 init +Error(A0010) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 63 : 非预期的符号 'init' + 64 0026 0F10 mov a, 10h + 65 0027 0000 mov count0, a +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 65 : 语法错误 + 66 0028 0000 sz data5 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 66 : 语法错误 + 67 0029 2800 R jmp start16 + 68 002A 0000 sz data4 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 68 : 语法错误 + 69 002B 2800 R jmp start16 + 70 002C 2800 R jmp over16 + 71 002D start16: + 72 002D 0000 sz data1 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 72 : 语法错误 + 73 002E 2800 R jmp div16 + 74 002F 0000 sz data0 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM 74 : 语法错误 +Error(A0052) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\CAL.ASM : 错误过多 + + + + 31 Errors \ No newline at end of file diff --git a/PRG/DES.ASM b/PRG/DES.ASM new file mode 100644 index 0000000..f720c4b --- /dev/null +++ b/PRG/DES.ASM @@ -0,0 +1,236 @@ +;==================================================================== +; ROM Size , HT82A821R = 2K , last page = 0700H +; HT82A822R = 4K , last page = 0F00H +; If use HT82A821R +; #defined HT82A821R 1 +; #defined HT82A822R 0 +; If use HT82A822R +; #defined HT82A821R 0 +; #defined HT82A822R 1 +;==================================================================== +; Use ReportID , Report ID 1 = Volume HID control +; Report ID 2 = Transform Other Data +;==================================================================== + +#include ht82a821r.inc +#include const.inc +#define HT82A821R 1 +#define HT82A822R 0 + +IF HT82A821R +Descript .Section at 0700h 'code' +ENDIF + + +IF HT82A822R +Descript .Section at 0F00h 'code' +ENDIF + + + +control_read_table: + device_desc_table: + DW 00112H ;descriptor type (device descriptor) , size of descriptor (18 bytes) + DW 00110H ;USB spec release (ver 1.1) + DW 00000H ;device sub-class , device class + DW 00800H ;maximum packet size , device sub-sub-class + DW 0046DH ;vender ID = 004D9H + DW 03F0EH + DW 03F0AH ;product ID (Sample Device) = 0x2821 + DW 00100H ;product version ID + DW 00201H ;product string index (device show) , manufacturer string index + DW 00100H ;number of configurations + config_desc_table: + DW 00209H ;descriptor type (config descriptor) , size of descriptor + DW 00087H ;total length of descriptor (34 bytes) + DW 00103H ;1 configuration , 3 interface + DW 03F00H ;configuration string index + DW 03FA0H ;configuration attributes (bus supply), Remote Wakeup + DW 03FFAH ;maxpower (500ma) + Interface_Descriptor: + Interface0_descriptor: + standard_audio_control_interface_control: + DW 00409H ;descriptor type (interface descriptor) , size of descriptor (9 bytes) + DW 00000H ;interface alternate setting , interface number (0 base) + DW 00100H ;interface class(01H for audio class) , number of endpoint (1 end point) + DW 00001H ;interface protocol , interface sub-class (audio control) + DW 03F00H ;x , interface string index + class_specific_audio_control_interface_descriptor: + DW 02409H ;descriptor type (CS_INTERFACE) , size of descriptor (9 bytes) + DW 03F01H ;descriptor subtype (Header) + DW 00100H ;audio device class specification release number(1.00) + DW 00028H ;total number of bytes for the class-specific audiocontrol interface descriptor + DW 00101H ;streaming interface number belongs to audio control interface , the number of streaming interface + input_terminal: + DW 0240CH ;descriptor type(CS_INTERFACE) , size of descriptor + DW 00102H ;ID of this terminal(ID=1) , descriptor subtype(INPUT_TERMINAL) + DW 00101H ;terminal type(USB streaming type) + DW 00200H ;number of channel(two channel) , associate with output terminal + DW 00003H ;channel config(Left/Right Front) + DW 00000H ;channelname(unused) , terminal name(unused) + feature_unit: + DW 0240AH ;descriptor type(CS_INTERFACE) , size of descriptor(10 bytes) + DW 00D06H ;UnitID , descriptorSubtype(FEATURE_UNIT) + DW 00101H ;control size(1) , SourceID(input terminal 01) + DW 00003H ;D1(volume)control is enable foe channel 1 , D0(mute) D1(volume) is enable for channel 0 + DW 00000H ;index of this descriptor , D1(volume)control is enable for channel 2 + output_terminal: + DW 02409H ;descriptor type(CS_INTERFACE) , size of descriptor(9 bytes) + DW 00303H ;terminal ID(03) , descriptorsubtype(OUTPUT_TERMINAL) + DW 00301H ;terminal is speaker + DW 00D00H ;sourceID(feature unit ID=0D) , associate terminal + DW 03F00H ;index of this descriptor + Interface1_descriptor: + zero_bw: + DW 00409H ;descriptor type(INTERFACE) , sizoe of descriptor + DW 00001H ;index of ths setting(alternatesetting = 0) , index of this interface + DW 00100H ;interface-class(AUDIO) , number of endpoint(0) + DW 00002H ;interface protocol(unused) , InterfaceSubClass(AUDIO_STREAMING) + DW 03F00H ;index string of this descriptor + audio_streaming: + DW 00409H ;descriptor type(INTERFACE) , size of descriptor + DW 00101H ;index of the setting(alternatesetting = 1) ,index of this interface + DW 00101H ;interface-class(AUDIO) , number of endpoint(1) + DW 00002H ;interface protocol(unused) , InterfaceSubClass(AUDIO_STREAMING) + DW 03F00H ;index string of this descriptor + class_specific_as_interface_desc: + DW 02407H ;descriptor type(CS_INTERFACE) , size of descriptor + DW 00101H ;terminalLink(Input terminal) , descriptor subtype(AS_GENERAL) + DW 03F01H ;interface delay(1) + DW 00001H ;PCM format + format_type_descriptor: + DW 0240BH ;descriptor type(CS_INTERFACE) , size of descriptor + DW 00102H ;FormatType(FORMAT_TYPE_I) , descriptorSubType(FORMAT_TYPE) + DW 00202H ;SubFrameSize(2 byte per slot) , number of channel(2 channels) + DW 00110H ;SamFreqType(support 1 type) , BitSolution(16 bits) + DW 03F80H ;Sample Frequency(48000 Hz) + DW 000BBH ; + end_point_descriptor: + DW 00509H ;descriptor type(END_POINT) , size of descriptor + DW 00902H ;endpoint attributes(adaptive,isochronous) , endpoint2(out direction) + DW 000C0H ;maxPacketSize(192 bytes) + DW 00001H ;Refresh(0) , Interval(1ms) + DW 03F00H ;index string of this descriptor + class_specific_endpoint_descriptor: + DW 02507H ;descriptor type(CS_ENDPOINT) , size of descriptor + DW 00001H ;Attributes(no sampling frequency , no pitch , no maxpackets control) , descriptorType(EP_GENERAL) + DW 03F00H ;LockedDelayUnit(unused) + DW 00000H ;LockDelay(unused) + Interface2_descriptor: + HID_class: + DW 00409H ;INTERFACE descriptor , Size of this descriptor + DW 00002H ;Index of this string , index of this interface + DW 00301H ;HID , 1 endpoint + DW 00000H ;Unused , Non-Boot Device + DW 03F00H ;null string + HID_Desc: + DW 02109H ;HID , Size of this descriptor + DW 00110H ;HID spec rev #1.10 + DW 00100H ;bNumDescriptor , bCountryCode + DW 03F22H ;Report Descriptor + ;==================================================================== + ; Use ReportID , Report ID 1 = Volume HID control + ; Report ID 2 = Transform Other Data + ;==================================================================== + IF UseReportID + DW 00016H ;67 bytes + ELSE + DW 00016H + ENDIF + + HID_end_point_descriptor: + DW 00507H ;Endpoint descriptor , Length of this descriptor + DW 00381H ;Interrupt , Endpoint 1 In direction + DW 00008H ;wMaxPacketSize = 1 Bytes + DW 03F30H ;48ms Interval + end_config_desc_table: + + hid_report_desc_table: +;==================================================================== +; Use ReportID , Report ID 1 = Volume HID control +; Report ID 2 = Transform Other Data +;==================================================================== + ;;vender defined + DW 03F06H ;//Usage Page(Global) + DW 03F00H + DW 03FFFH ;//Usage Page + + DW 00109H ;//Usage(Local 1 bytes) + DW 001A1H ;//collection(Main) + ;input report +;; DW 03F19H +;; DW 03FA6H +;; DW 03F29H ;//Usage(Local) +;; DW 03FACH +;; DW 03F15H ;//Global Logical Minimum +;; DW 03F80H +;; DW 03F25H ;//Global Logical Maximum +;; DW 03F7FH +;; DW 00875H ;//Global Report Size 8 bits +;; DW 00795H ;//Global Report Count 7 (field) +;; DW 00281H ;//Main Input (Data,Variable,Absolute) + ;output + DW 00015H ;//LOGICAL MINIMUM (0) + DW 03F25H + DW 03FffH ;//LOGICAL MAXIMUM (FF) + DW 00019H ;//Usage Min (#) + DW 00129H ;//Usage Max (#) + DW 00895H ;//Report Count(8) + DW 00875H ;//Report Size(8) + DW 00291H ;//OUTPUT: (Data, Array) + DW 03FC0H ;End Collection + end_hid_report_desc_table: + + string_descriptor: + USBStringLanguageDescription: + DW 00304h ; Length , Type (3=string) + DW 00409h ; Language: English , Sub-language: US + + imanufacturer_string: ;Vendor Name + USBStringDescription1: + DW 00310h, 00048h, 0004fh, 0004ch, 00054h, 00045h, 0004bh, 00020h ;HOLTEK + + iproduct_string: ;Product Name + USBStringDescription2: + ;DW 00326h, 00042h, 0002Dh, 0004ch, 00049h, 0004Eh, 0004bh, 00020h ;B-LINK + DW 00055h, 00053h, 00042h, 00020h ;USB + DW 00041h, 00075h, 00064h, 00069h, 0006fh, 00020h, 00020h ;Audio + + isnumber_string: ;Serial Number + USBStringDescription3: + DW 0030Ah, 00038h, 00032h, 00031h, 00052h ;821R + + + + config_desc_length: + DW 00087H + + report_desc_length: + IF UseReportID + DW 00016H + ELSE + DW 00016H + ENDIF + hid_desc_length: + DW 00009H + + + + Public control_read_table + Public device_desc_table + Public config_desc_table + Public end_config_desc_table + Public USBStringLanguageDescription + Public USBStringDescription1 + Public USBStringDescription2 + Public USBStringDescription3 + + Public HID_Desc + Public hid_report_desc_table + Public end_hid_report_desc_table + + + Public config_desc_length + Public hid_desc_length + Public report_desc_length + diff --git a/PRG/DES.LST b/PRG/DES.LST new file mode 100644 index 0000000..4d0d112 --- /dev/null +++ b/PRG/DES.LST @@ -0,0 +1,258 @@ +文件:DES.ASM 盛群编译器版本 2.86 页次1 + + + 1 0000 ;==================================================================== + 2 0000 ; ROM Size , HT82A821R = 2K , last page = 0700H + 3 0000 ; HT82A822R = 4K , last page = 0F00H + 4 0000 ; If use HT82A821R + 5 0000 ; #defined HT82A821R 1 + 6 0000 ; #defined HT82A822R 0 + 7 0000 ; If use HT82A822R + 8 0000 ; #defined HT82A821R 0 + 9 0000 ; #defined HT82A822R 1 + 10 0000 ;==================================================================== + 11 0000 ; Use ReportID , Report ID 1 = Volume HID control + 12 0000 ; Report ID 2 = Transform Other Data + 13 0000 ;==================================================================== + 14 0000 + 15 0000 #include ht82a821r.inc + + + 16 0000 #include const.inc + + + 17 0000 #define HT82A821R 1 + 18 0000 #define HT82A822R 0 + 19 0000 + 20 0000 IF HT82A821R + 21 0000 Descript .Section at 0700h 'code' + 22 0000 ENDIF + 23 0000 + 24 0000 + 25 0000 IF HT82A822R + 26 0000 Descript .Section at 0F00h 'code' + 27 0000 ENDIF + 28 0000 + 29 0000 + 30 0000 + 31 0000 control_read_table: + 32 0000 device_desc_table: + 33 0000 0112 DW 00112H ;descriptor type (device descriptor) , size of descriptor (18 bytes) + 34 0001 0110 DW 00110H ;USB spec release (ver 1.1) + 35 0002 0000 DW 00000H ;device sub-class , device class + 36 0003 0800 DW 00800H ;maximum packet size , device sub-sub-class + 37 0004 046D DW 0046DH ;vender ID = 004D9H + 38 0005 3F0E DW 03F0EH + 39 0006 3F0A DW 03F0AH ;product ID (Sample Device) = 0x2821 + 40 0007 0100 DW 00100H ;product version ID + 41 0008 0201 DW 00201H ;product string index (device show) , manufacturer string index + 42 0009 0100 DW 00100H ;number of configurations + 43 000A config_desc_table: + 44 000A 0209 DW 00209H ;descriptor type (config descriptor) , size of descriptor + 45 000B 0087 DW 00087H ;total length of descriptor (34 bytes) + 46 000C 0103 DW 00103H ;1 configuration , 3 interface + 47 000D 3F00 DW 03F00H ;configuration string index + 48 000E 3FA0 DW 03FA0H ;configuration attributes (bus supply), Remote Wakeup + 49 000F 3FFA DW 03FFAH ;maxpower (500ma) + 50 0010 Interface_Descriptor: + 51 0010 Interface0_descriptor: + 52 0010 standard_audio_control_interface_control: + 53 0010 0409 DW 00409H ;descriptor type (interface descriptor) , size of descriptor (9 bytes) + 54 0011 0000 DW 00000H ;interface alternate setting , interface number (0 base) + 55 0012 0100 DW 00100H ;interface class(01H for audio class) , number of endpoint (1 end point) + 文件:DES.ASM 盛群编译器版本 2.86 页次2 + + 56 0013 0001 DW 00001H ;interface protocol , interface sub-class (audio control) + 57 0014 3F00 DW 03F00H ;x , interface string index + 58 0015 class_specific_audio_control_interface_descriptor: + 59 0015 2409 DW 02409H ;descriptor type (CS_INTERFACE) , size of descriptor (9 bytes) + 60 0016 3F01 DW 03F01H ;descriptor subtype (Header) + 61 0017 0100 DW 00100H ;audio device class specification release number(1.00) + 62 0018 0028 DW 00028H ;total number of bytes for the class-specific audiocontrol interface descriptor + 63 0019 0101 DW 00101H ;streaming interface number belongs to audio control interface , the number of streaming interface + 64 001A input_terminal: + 65 001A 240C DW 0240CH ;descriptor type(CS_INTERFACE) , size of descriptor + 66 001B 0102 DW 00102H ;ID of this terminal(ID=1) , descriptor subtype(INPUT_TERMINAL) + 67 001C 0101 DW 00101H ;terminal type(USB streaming type) + 68 001D 0200 DW 00200H ;number of channel(two channel) , associate with output terminal + 69 001E 0003 DW 00003H ;channel config(Left/Right Front) + 70 001F 0000 DW 00000H ;channelname(unused) , terminal name(unused) + 71 0020 feature_unit: + 72 0020 240A DW 0240AH ;descriptor type(CS_INTERFACE) , size of descriptor(10 bytes) + 73 0021 0D06 DW 00D06H ;UnitID , descriptorSubtype(FEATURE_UNIT) + 74 0022 0101 DW 00101H ;control size(1) , SourceID(input terminal 01) + 75 0023 0003 DW 00003H ;D1(volume)control is enable foe channel 1 , D0(mute) D1(volume) is enable for channel 0 + 76 0024 0000 DW 00000H ;index of this descriptor , D1(volume)control is enable for channel 2 + 77 0025 output_terminal: + 78 0025 2409 DW 02409H ;descriptor type(CS_INTERFACE) , size of descriptor(9 bytes) + 79 0026 0303 DW 00303H ;terminal ID(03) , descriptorsubtype(OUTPUT_TERMINAL) + 80 0027 0301 DW 00301H ;terminal is speaker + 81 0028 0D00 DW 00D00H ;sourceID(feature unit ID=0D) , associate terminal + 82 0029 3F00 DW 03F00H ;index of this descriptor + 83 002A Interface1_descriptor: + 84 002A zero_bw: + 85 002A 0409 DW 00409H ;descriptor type(INTERFACE) , sizoe of descriptor + 86 002B 0001 DW 00001H ;index of ths setting(alternatesetting = 0) , index of this interface + 87 002C 0100 DW 00100H ;interface-class(AUDIO) , number of endpoint(0) + 88 002D 0002 DW 00002H ;interface protocol(unused) , InterfaceSubClass(AUDIO_STREAMING) + 89 002E 3F00 DW 03F00H ;index string of this descriptor + 90 002F audio_streaming: + 91 002F 0409 DW 00409H ;descriptor type(INTERFACE) , size of descriptor + 92 0030 0101 DW 00101H ;index of the setting(alternatesetting = 1) ,index of this interface + 93 0031 0101 DW 00101H ;interface-class(AUDIO) , number of endpoint(1) + 94 0032 0002 DW 00002H ;interface protocol(unused) , InterfaceSubClass(AUDIO_STREAMING) + 95 0033 3F00 DW 03F00H ;index string of this descriptor + 96 0034 class_specific_as_interface_desc: + 97 0034 2407 DW 02407H ;descriptor type(CS_INTERFACE) , size of descriptor + 98 0035 0101 DW 00101H ;terminalLink(Input terminal) , descriptor subtype(AS_GENERAL) + 99 0036 3F01 DW 03F01H ;interface delay(1) + 100 0037 0001 DW 00001H ;PCM format + 101 0038 format_type_descriptor: + 102 0038 240B DW 0240BH ;descriptor type(CS_INTERFACE) , size of descriptor + 103 0039 0102 DW 00102H ;FormatType(FORMAT_TYPE_I) , descriptorSubType(FORMAT_TYPE) + 104 003A 0202 DW 00202H ;SubFrameSize(2 byte per slot) , number of channel(2 channels) + 105 003B 0110 DW 00110H ;SamFreqType(support 1 type) , BitSolution(16 bits) + 106 003C 3F80 DW 03F80H ;Sample Frequency(48000 Hz) + 107 003D 00BB DW 000BBH ; + 108 003E end_point_descriptor: + 109 003E 0509 DW 00509H ;descriptor type(END_POINT) , size of descriptor + 110 003F 0902 DW 00902H ;endpoint attributes(adaptive,isochronous) , endpoint2(out direction) + 111 0040 00C0 DW 000C0H ;maxPacketSize(192 bytes) + 112 0041 0001 DW 00001H ;Refresh(0) , Interval(1ms) + 113 0042 3F00 DW 03F00H ;index string of this descriptor + 114 0043 class_specific_endpoint_descriptor: + 115 0043 2507 DW 02507H ;descriptor type(CS_ENDPOINT) , size of descriptor + 文件:DES.ASM 盛群编译器版本 2.86 页次3 + + 116 0044 0001 DW 00001H ;Attributes(no sampling frequency , no pitch , no maxpackets control) , descriptorType(EP_GENERAL) + 117 0045 3F00 DW 03F00H ;LockedDelayUnit(unused) + 118 0046 0000 DW 00000H ;LockDelay(unused) + 119 0047 Interface2_descriptor: + 120 0047 HID_class: + 121 0047 0409 DW 00409H ;INTERFACE descriptor , Size of this descriptor + 122 0048 0002 DW 00002H ;Index of this string , index of this interface + 123 0049 0301 DW 00301H ;HID , 1 endpoint + 124 004A 0000 DW 00000H ;Unused , Non-Boot Device + 125 004B 3F00 DW 03F00H ;null string + 126 004C HID_Desc: + 127 004C 2109 DW 02109H ;HID , Size of this descriptor + 128 004D 0110 DW 00110H ;HID spec rev #1.10 + 129 004E 0100 DW 00100H ;bNumDescriptor , bCountryCode + 130 004F 3F22 DW 03F22H ;Report Descriptor + 131 0050 ;==================================================================== + 132 0050 ; Use ReportID , Report ID 1 = Volume HID control + 133 0050 ; Report ID 2 = Transform Other Data + 134 0050 ;==================================================================== + 135 0050 IF UseReportID + 136 0050 DW 00016H ;67 bytes + 137 0050 ELSE + 138 0050 0016 DW 00016H + 139 0051 ENDIF + 140 0051 + 141 0051 HID_end_point_descriptor: + 142 0051 0507 DW 00507H ;Endpoint descriptor , Length of this descriptor + 143 0052 0381 DW 00381H ;Interrupt , Endpoint 1 In direction + 144 0053 0008 DW 00008H ;wMaxPacketSize = 1 Bytes + 145 0054 3F30 DW 03F30H ;48ms Interval + 146 0055 end_config_desc_table: + 147 0055 + 148 0055 hid_report_desc_table: + 149 0055 ;==================================================================== + 150 0055 ; Use ReportID , Report ID 1 = Volume HID control + 151 0055 ; Report ID 2 = Transform Other Data + 152 0055 ;==================================================================== + 153 0055 ;;vender defined + 154 0055 3F06 DW 03F06H ;//Usage Page(Global) + 155 0056 3F00 DW 03F00H + 156 0057 3FFF DW 03FFFH ;//Usage Page + 157 0058 + 158 0058 0109 DW 00109H ;//Usage(Local 1 bytes) + 159 0059 01A1 DW 001A1H ;//collection(Main) + 160 005A ;input report + 161 005A ;; DW 03F19H + 162 005A ;; DW 03FA6H + 163 005A ;; DW 03F29H ;//Usage(Local) + 164 005A ;; DW 03FACH + 165 005A ;; DW 03F15H ;//Global Logical Minimum + 166 005A ;; DW 03F80H + 167 005A ;; DW 03F25H ;//Global Logical Maximum + 168 005A ;; DW 03F7FH + 169 005A ;; DW 00875H ;//Global Report Size 8 bits + 170 005A ;; DW 00795H ;//Global Report Count 7 (field) + 171 005A ;; DW 00281H ;//Main Input (Data,Variable,Absolute) + 172 005A ;output + 173 005A 0015 DW 00015H ;//LOGICAL MINIMUM (0) + 174 005B 3F25 DW 03F25H + 175 005C 3FFF DW 03FffH ;//LOGICAL MAXIMUM (FF) + 文件:DES.ASM 盛群编译器版本 2.86 页次4 + + 176 005D 0019 DW 00019H ;//Usage Min (#) + 177 005E 0129 DW 00129H ;//Usage Max (#) + 178 005F 0895 DW 00895H ;//Report Count(8) + 179 0060 0875 DW 00875H ;//Report Size(8) + 180 0061 0291 DW 00291H ;//OUTPUT: (Data, Array) + 181 0062 3FC0 DW 03FC0H ;End Collection + 182 0063 end_hid_report_desc_table: + 183 0063 + 184 0063 string_descriptor: + 185 0063 USBStringLanguageDescription: + 186 0063 0304 DW 00304h ; Length , Type (3=string) + 187 0064 0409 DW 00409h ; Language: English , Sub-language: US + 188 0065 + 189 0065 imanufacturer_string: ;Vendor Name + 190 0065 USBStringDescription1: + 191 0065 0310 0048 DW 00310h, 00048h, 0004fh, 0004ch, 00054h, 00045h, 0004bh, 00020h ;HOLTEK + 004F 004C 0054 0045 004B 0020 + 192 006D + 193 006D iproduct_string: ;Product Name + 194 006D USBStringDescription2: + 195 006D ;DW 00326h, 00042h, 0002Dh, 0004ch, 00049h, 0004Eh, 0004bh, 00020h ;B-LINK + 196 006D 0055 0053 DW 00055h, 00053h, 00042h, 00020h ;USB + 0042 0020 + 197 0071 0041 0075 DW 00041h, 00075h, 00064h, 00069h, 0006fh, 00020h, 00020h ;Audio + 0064 0069 006F 0020 0020 + 198 0078 + 199 0078 isnumber_string: ;Serial Number + 200 0078 USBStringDescription3: + 201 0078 030A 0038 DW 0030Ah, 00038h, 00032h, 00031h, 00052h ;821R + 0032 0031 0052 + 202 007D + 203 007D + 204 007D + 205 007D config_desc_length: + 206 007D 0087 DW 00087H + 207 007E + 208 007E report_desc_length: + 209 007E IF UseReportID + 210 007E DW 00016H + 211 007E ELSE + 212 007E 0016 DW 00016H + 213 007F ENDIF + 214 007F hid_desc_length: + 215 007F 0009 DW 00009H + 216 0080 + 217 0080 + 218 0080 + 219 0080 Public control_read_table + 220 0080 Public device_desc_table + 221 0080 Public config_desc_table + 222 0080 Public end_config_desc_table + 223 0080 Public USBStringLanguageDescription + 224 0080 Public USBStringDescription1 + 225 0080 Public USBStringDescription2 + 226 0080 Public USBStringDescription3 + 227 0080 + 228 0080 Public HID_Desc + 229 0080 Public hid_report_desc_table + 230 0080 Public end_hid_report_desc_table + 231 0080 + 文件:DES.ASM 盛群编译器版本 2.86 页次5 + + 232 0080 + 233 0080 Public config_desc_length + 234 0080 Public hid_desc_length + 235 0080 Public report_desc_length + 236 0080 + + + 0 Errors \ No newline at end of file diff --git a/PRG/DES.OBJ b/PRG/DES.OBJ new file mode 100644 index 0000000..551a665 Binary files /dev/null and b/PRG/DES.OBJ differ diff --git a/PRG/FUNCTION.LST b/PRG/FUNCTION.LST new file mode 100644 index 0000000..f1b5b7f --- /dev/null +++ b/PRG/FUNCTION.LST @@ -0,0 +1,1444 @@ +文件:FUNCTION.ASM 盛群编译器版本 2.86 页次1 + + + 1 0000 ;********************************************************************* + 2 0000 ; Functin Library + 3 0000 ; Author : Ansonku + 4 0000 ; EMail : ansonku@holtek.com.tw + 5 0000 ; Date : 2005/01/11 + 6 0000 ;********************************************************************* + 7 0000 #include ht82a821R.inc + + + 8 0000 #include const.inc + + + 9 0000 ;===================================================================== + 10 0000 ; Descriptor Label + 11 0000 ;===================================================================== + 12 0000 ;2005/11/01 ClearFeature_Endpoint add Send_Hand_Shake + 13 0000 ; + 14 0000 ;2006/02/16 э Sned_Hand_Shake 磷玻ネぃタ盽 stack + 15 0000 ;2006/02/16 э control_read , 磷 descriptor 计┮穦玻ネ拜肈 + 16 0000 ; 璝琌descirptor Ч临Μ in token , ê或 send_hand_shake + 17 0000 ; + 18 0000 ; + 19 0000 ; + 20 0000 ; + 21 0000 + 22 0000 + 23 0000 + 24 0000 + 25 0000 + 26 0000 extern control_read_table:NEAR + 27 0000 extern device_desc_table:NEAR + 28 0000 extern config_desc_table:NEAR + 29 0000 + 30 0000 extern end_config_desc_table:NEAR + 31 0000 extern hid_report_desc_table:NEAR + 32 0000 extern end_hid_report_desc_table:NEAR + 33 0000 + 34 0000 extern USBStringLanguageDescription:NEAR + 35 0000 extern USBStringDescription1:NEAR + 36 0000 extern USBStringDescription2:NEAR + 37 0000 extern USBStringDescription3:NEAR + 38 0000 extern HID_Desc:NEAR + 39 0000 + 40 0000 extern config_desc_length:NEAR + 41 0000 extern hid_desc_length:NEAR + 42 0000 extern report_desc_length:NEAR + 43 0000 + 44 0000 + 45 0000 extern USB_EP0_ISR_END:NEAR + 46 0000 + 47 0000 ;===================================================================== + 48 0000 ; External Variable + 49 0000 ;===================================================================== + 50 0000 extern FIFO_Size:byte + 51 0000 extern FIFO_SendLen:byte + 52 0000 extern FIFO_Type:byte + 53 0000 extern FIFO_Request:byte + 54 0000 extern FIFO_wValueL:byte + 55 0000 extern FIFO_wValueH:byte + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次2 + + 56 0000 extern FIFO_wIndexL:byte + 57 0000 extern FIFO_wIndexH:byte + 58 0000 extern FIFO_wLengthL:byte + 59 0000 extern FIFO_wLengthH:byte + 60 0000 + 61 0000 extern FIFO_Out1:byte + 62 0000 extern FIFO_Out2:byte + 63 0000 extern FIFO_Out3:byte + 64 0000 extern FIFO_Out4:byte + 65 0000 extern FIFO_Out5:byte + 66 0000 extern FIFO_Out6:byte + 67 0000 extern FIFO_Out7:byte + 68 0000 extern FIFO_Out8:byte + 69 0000 + 70 0000 extern USB_Interface:byte + 71 0000 extern USB_Interface_Alt:byte + 72 0000 extern USB_Configuration:byte + 73 0000 + 74 0000 extern FIFO_ADDR:byte + 75 0000 + 76 0000 + 77 0000 + 78 0000 extern Loop_Counter:byte + 79 0000 extern Data_Count:byte + 80 0000 extern Data_Start:byte + 81 0000 + 82 0000 + 83 0000 extern nCmdIndex1:byte + 84 0000 + 85 0000 extern VolumeH_Save:byte + 86 0000 extern VolumeL_Save:byte + 87 0000 extern bFlag_Audio_Mute:bit + 88 0000 ;modify for Remote Wakeup + 89 0000 extern bRmtWakeup :bit + 90 0000 extern b_wakeup :bit + 91 0000 + 92 0000 ;===================================================================== + 93 0000 ; FIFO Status + 94 0000 ;===================================================================== + 95 0000 + 96 0000 ;FIFO + 97 0000 extern FIFO_TEMP:byte + 98 0000 extern bFlag_Real_Cmd:bit + 99 0000 extern bFlag_FIFO_Ready:bit + 100 0000 extern bFlag_FIFO_LEN0:bit + 101 0000 extern bFlag_RD_HTable:bit + 102 0000 extern bFlag_wait_control_out:bit + 103 0000 extern bFlag_SET_ADDRESS:bit + 104 0000 extern bFlag_SCMD:bit + 105 0000 extern bFlag_Enum_Ready:bit + 106 0000 extern bFlag_SetConfiguration_Ready:bit + 107 0000 extern bFlag_SetInterface_Ready:bit + 108 0000 + 109 0000 extern StageOne:NEAR + 110 0000 extern USB_ISR_END:NEAR + 111 0000 ;******************************************************************** + 112 0000 ; USB LIB + 113 0000 ; 1.CHECK FIFOX RD READEY? bFlag_FIFO_Ready = 1:bFlag_FIFO_Ready = 0 + 114 0000 ;******************************************************************** + 115 0000 FIFO0_RD_CHECK: + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次3 + + 116 0000 0722 MOV A,UCC + 117 0001 0D07 OR A,00000111b + 118 0002 0EF8 AND A,11111000b + 119 0003 00A2 MOV UCC,A + 120 0004 + 121 0004 0F00 MOV A,00000000b + 122 0005 2800 R JMP FIFO_CHECK + 123 0006 FIFO1_RD_CHECK: + 124 0006 0722 MOV A,UCC + 125 0007 0D07 OR A,00000111b + 126 0008 0EF9 AND A,11111001b + 127 0009 00A2 MOV UCC,A + 128 000A + 129 000A 0F00 MOV A,00000000b + 130 000B 2800 R JMP FIFO_CHECK + 131 000C FIFO2_RD_CHECK: + 132 000C 0722 MOV A,UCC + 133 000D 0D07 OR A,00000111b + 134 000E 0EFA AND A,11111010b + 135 000F 00A2 MOV UCC,A + 136 0010 + 137 0010 0F00 MOV A,00000000b + 138 0011 2800 R JMP FIFO_CHECK + 139 0012 FIFO3_RD_CHECK: + 140 0012 0722 MOV A,UCC + 141 0013 0D07 OR A,00000111b + 142 0014 0EFB AND A,11111011b + 143 0015 00A2 MOV UCC,A + 144 0016 + 145 0016 0F00 MOV A,00000000b + 146 0017 2800 R JMP FIFO_CHECK + 147 0018 FIFO4_RD_CHECK: + 148 0018 0722 MOV A,UCC + 149 0019 0D07 OR A,00000111b + 150 001A 0EFC AND A,11111100b + 151 001B 00A2 MOV UCC,A + 152 001C + 153 001C 0F00 MOV A,00000000b + 154 001D 2800 R JMP FIFO_CHECK + 155 001E + 156 001E FIFO5_RD_CHECK: + 157 001E 0722 MOV A,UCC + 158 001F 0D07 OR A,00000111b + 159 0020 0EFD AND A,11111101b + 160 0021 00A2 MOV UCC,A + 161 0022 + 162 0022 0F00 MOV A,00000000b + 163 0023 2800 R JMP FIFO_CHECK + 164 0024 ;******************************************************************** + 165 0024 ; USB LIB + 166 0024 ; 1.CHECK FIFOX WR READEY ? bFlag_FIFO_Ready = 1:bFlag_FIFO_Ready = 0 + 167 0024 ;******************************************************************** + 168 0024 + 169 0024 ;LEN0 ready to write?? + 170 0024 LEN0_WR_CHECK: + 171 0024 ;CHECK FIFOX ready to write? + 172 0024 FIFO0_WR_CHECK: + 173 0024 0722 MOV A,UCC + 174 0025 0D07 OR A,00000111b + 175 0026 0EF8 AND A,11111000b + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次4 + + 176 0027 00A2 MOV UCC,A + 177 0028 + 178 0028 0F02 MOV A,00000010b + 179 0029 2800 R JMP FIFO_CHECK + 180 002A FIFO1_WR_CHECK: + 181 002A 0722 MOV A,UCC + 182 002B 0D07 OR A,00000111b + 183 002C 0EF9 AND A,11111001b + 184 002D 00A2 MOV UCC,A + 185 002E + 186 002E 0F02 MOV A,00000010b + 187 002F 2800 R JMP FIFO_CHECK + 188 0030 FIFO2_WR_CHECK: + 189 0030 0722 MOV A,UCC + 190 0031 0D07 OR A,00000111b + 191 0032 0EFA AND A,11111010b + 192 0033 00A2 MOV UCC,A + 193 0034 + 194 0034 0F02 MOV A,00000010b + 195 0035 2800 R JMP FIFO_CHECK + 196 0036 FIFO3_WR_CHECK: + 197 0036 0722 MOV A,UCC + 198 0037 0D07 OR A,00000111b + 199 0038 0EFB AND A,11111011b + 200 0039 00A2 MOV UCC,A + 201 003A + 202 003A 0F02 MOV A,00000010b + 203 003B 2800 R JMP FIFO_CHECK + 204 003C FIFO4_WR_CHECK: + 205 003C 0722 MOV A,UCC + 206 003D 0D07 OR A,00000111b + 207 003E 0EFC AND A,11111100b + 208 003F 00A2 MOV UCC,A + 209 0040 + 210 0040 0F02 MOV A,00000010b + 211 0041 2800 R JMP FIFO_CHECK + 212 0042 + 213 0042 FIFO5_WR_CHECK: + 214 0042 0722 MOV A,UCC + 215 0043 0D07 OR A,00000111b + 216 0044 0EFD AND A,11111101b + 217 0045 00A2 MOV UCC,A + 218 0046 + 219 0046 0F02 MOV A,00000010b + 220 0047 2800 R JMP FIFO_CHECK + 221 0048 + 222 0048 FIFO_CHECK: + 223 0048 0001 clr wdt + 224 0049 0080 E MOV FIFO_TEMP,A + 225 004A 0F26 MOV A,USB_MISC + 226 004B 0083 MOV MP1,A + 227 004C 0702 MOV A,R1 + 228 004D 0EF8 AND A,11111000b + 229 004E 0500 E OR A,FIFO_TEMP + 230 004F 0082 MOV R1,A + 231 0050 2000 R CALL Delay_3us + 232 0051 3002 SET R1.@MISC_REQ ;set request + 233 0052 2000 R CALL Delay_28us + 234 0053 3000 E SET bFlag_FIFO_Ready + 235 0054 3B02 SNZ R1.@MISC_Ready + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次5 + + 236 0055 3400 E CLR bFlag_FIFO_Ready ;if MISC.Ready = 1 -> bFlag_FIFO_Ready = 1 + 237 0056 3000 E SET bFlag_FIFO_LEN0 + 238 0057 3B82 SNZ R1.@MISC_LEN0 + 239 0058 3400 E CLR bFlag_FIFO_LEN0 + 240 0059 + 241 0059 ;;SZ bFlag_FIFO_Ready + 242 0059 3426 clr MISC.@MISC_REQ + 243 005A 0001 clr wdt + 244 005B 0003 RET + 245 005C + 246 005C + 247 005C ReadLen0: + 248 005C 0F28 MOV A,USB_FIFO0 + 249 005D 0083 MOV MP1,A + 250 005E 0702 MOV A,R1 + 251 005F 0000 NOP + 252 0060 2800 R JMP Read_FIFO_END + 253 0061 Read_FIFO0: + 254 0061 0F08 MOV A,USB_FIFO0_SIZE + 255 0062 0080 E MOV FIFO_SIZE,A + 256 0063 0F28 MOV A,USB_FIFO0 + 257 0064 2800 R JMP Read_FIFO + 258 0065 Read_FIFO1: + 259 0065 0F08 MOV A,USB_FIFO1_SIZE + 260 0066 0080 E MOV FIFO_SIZE,A + 261 0067 0F29 MOV A,USB_FIFO1 + 262 0068 2800 R JMP Read_FIFO + 263 0069 Read_FIFO2: + 264 0069 0F08 MOV A,USB_FIFO2_SIZE + 265 006A 0080 E MOV FIFO_SIZE,A + 266 006B 0F2A MOV A,USB_FIFO2 + 267 006C 2800 R JMP Read_FIFO + 268 006D Read_FIFO3: + 269 006D 0F08 MOV A,USB_FIFO3_SIZE + 270 006E 0080 E MOV FIFO_SIZE,A + 271 006F 0F2B MOV A,USB_FIFO3 + 272 0070 2800 R JMP Read_FIFO + 273 0071 Read_FIFO4: + 274 0071 0F08 MOV A,USB_FIFO4_SIZE + 275 0072 0080 E MOV FIFO_SIZE,A + 276 0073 0F2C MOV A,USB_FIFO4 + 277 0074 2800 R JMP Read_FIFO + 278 0075 Read_FIFO5: + 279 0075 0F08 MOV A,USB_FIFO5_SIZE + 280 0076 0080 E MOV FIFO_SIZE,A + 281 0077 0F2D MOV A,USB_FIFO5 + 282 0078 2800 R JMP Read_FIFO + 283 0079 + 284 0079 Read_FIFO: + 285 0079 3026 SET MISC.@MISC_REQ + 286 007A + 287 007A 0080 E MOV FIFO_TEMP,A ;FIFO_TEMP SAVE FIFOX ADDRESS + 288 007B 1F00 E CLR FIFO_SendLen + 289 007C 0F00 E MOV A,OFFSET FIFO_Type + 290 007D 0081 MOV MP0,A + 291 007E Read_FIFO_Loop: + 292 007E 0700 E MOV A,FIFO_TEMP + 293 007F 0083 MOV MP1,A + 294 0080 0702 MOV A,R1 + 295 0081 0080 MOV R0,A + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次6 + + 296 0082 1480 E INC FIFO_SendLen + 297 0083 1481 INC MP0 + 298 0084 0700 E MOV A,FIFO_SIZE + 299 0085 0400 E XOR A,FIFO_SendLen + 300 0086 3D0A SZ Z ;1=FIFO_SIZE=FIFO_SendLen + 301 0087 2800 R JMP Read_FIFO_End + 302 0088 0F26 MOV A,USB_MISC + 303 0089 0083 MOV MP1,A + 304 008A 2000 R CALL Delay_28us + 305 008B 3F02 SZ R1.@MISC_Ready + 306 008C 2800 R JMP Read_FIFO_LOOP + 307 008D 2800 R JMP Read_FIFO_End + 308 008E + 309 008E Send_Hand_Shake: + 310 008E Send_Hand_Shake_wait: + 311 008E ; protect die loop + 312 008E 2000 R call Check_Real_Cmd + 313 008F 3C00 E sz bFlag_Real_Cmd + 314 0090 ;jmp USB_EP0_ISR_END + 315 0090 0003 ret ;modify by 2006-02-16 + 316 0091 + 317 0091 2000 R CALL FIFO0_WR_CHECK + 318 0092 3800 E SNZ bFlag_FIFO_Ready ; acai remark 2007-1-23 + 319 0093 2800 R JMP Send_Hand_Shake_wait + 320 0094 + 321 0094 3026 set MISC.@MISC_REQ + 322 0095 WriteLen0: + 323 0095 Write_FIFO_OK: + 324 0095 Read_FIFO_End: + 325 0095 0F26 MOV A,USB_MISC + 326 0096 0083 MOV MP1,A + 327 0097 0F02 MOV A,(01H SHL @MISC_TX) ;Change TX State + 328 0098 ;CLR INTC0.0 + 329 0098 0482 XORM A,R1 + 330 0099 2000 R CALL Delay_3us + 331 009A 3402 CLR R1.@MISC_REQ + 332 009B ;SET INTC0.0 + 333 009B 0003 RET + 334 009C + 335 009C ;============================================================ + 336 009C ;Function:Write FIFOx from FIFO_OUTx + 337 009C ;============================================================ + 338 009C Write_FIFO0: + 339 009C 0F28 MOV A,USB_FIFO0 + 340 009D 2800 R JMP Write_FIFO + 341 009E Write_FIFO1: + 342 009E 0F29 MOV A,USB_FIFO1 + 343 009F 2800 R JMP Write_FIFO + 344 00A0 Write_FIFO2: + 345 00A0 0F2A MOV A,USB_FIFO2 + 346 00A1 2800 R JMP Write_FIFO + 347 00A2 Write_FIFO3: + 348 00A2 0F2B MOV A,USB_FIFO3 + 349 00A3 2800 R JMP Write_FIFO + 350 00A4 Write_FIFO4: + 351 00A4 0F2C MOV A,USB_FIFO4 + 352 00A5 2800 R JMP Write_FIFO + 353 00A6 Write_FIFO5: + 354 00A6 0F2D MOV A,USB_FIFO5 + 355 00A7 2800 R JMP Write_FIFO + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次7 + + 356 00A8 + 357 00A8 Write_FIFO: + 358 00A8 0001 clr wdt + 359 00A9 3026 SET MISC.@MISC_REQ + 360 00AA + 361 00AA 0080 E MOV FIFO_TEMP,A ;FIFO NO Address + 362 00AB 0F00 E MOV A,OFFSET FIFO_OUT1 + 363 00AC 0081 MOV MP0,A + 364 00AD Write_FIFO_Loop: + 365 00AD 0001 clr wdt + 366 00AE 0700 E MOV A,FIFO_SendLen + 367 00AF 0C00 XOR A,00H + 368 00B0 3D0A SZ Z + 369 00B1 2800 R JMP Write_FIFO_End + 370 00B2 + 371 00B2 0700 E MOV A,FIFO_TEMP + 372 00B3 0083 MOV MP1,A + 373 00B4 0700 MOV A,R0 + 374 00B5 0082 MOV R1,A + 375 00B6 1580 E DEC FIFO_SendLen + 376 00B7 0700 E MOV A,FIFO_SendLen + 377 00B8 0C00 XOR A,00H + 378 00B9 3D0A SZ Z + 379 00BA 2800 R JMP Write_FIFO_End ;FIFO_SendLen=0 肚Ч + 380 00BB 1481 INC MP0 + 381 00BC 0F26 MOV A,USB_MISC + 382 00BD 0083 MOV MP1,A + 383 00BE 2000 R call Delay_28us + 384 00BF 3F02 SZ R1.@MISC_Ready + 385 00C0 2800 R JMP Write_FIFO_Loop + 386 00C1 Write_FIFO_End: + 387 00C1 0001 clr wdt + 388 00C2 2800 R JMP Write_FIFO_OK + 389 00C3 + 390 00C3 + 391 00C3 get_descriptor_length: + 392 00C3 0001 clr wdt + 393 00C4 0700 E MOV A,FIFO_WLENGTHH + 394 00C5 0C00 XOR A,0 + 395 00C6 390A SNZ Z + 396 00C7 2800 R JMP use_actual_length + 397 00C8 0700 E MOV A,FIFO_WLENGTHL + 398 00C9 0C00 XOR A,0 + 399 00CA 3D0A SZ Z + 400 00CB 2800 R JMP use_actual_length + 401 00CC 0700 E MOV A,FIFO_WLENGTHL + 402 00CD 0200 E SUB A,data_count + 403 00CE 3C0A SZ C ;if(FIFO_LENGTHL>data_count) c=1 + 404 00CF 2800 R JMP use_actual_length + 405 00D0 0700 E MOV A,FIFO_WLENGTHL + 406 00D1 0080 E MOV data_count,A + 407 00D2 use_actual_length: + 408 00D2 0003 RET + 409 00D3 ;=============================================================== + 410 00D3 ; Function : Control_read + 411 00D3 ; Purpose : Performs the control read operation as + 412 00D3 ; defined by the USB specification + 413 00D3 ; setup-in-in-in-....-out + 414 00D3 ; data_start:must be set to the descriptors info as an offset + 415 00D3 ; from the beginning of the control read table + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次8 + + 416 00D3 ; data count holds the + 417 00D3 ; data_count:must beset to the size of the descriptor + 418 00D3 ; bFlag_RD_HTable==1 ==> Must be read Hight Bytes + 419 00D3 ; TBLP :Table Index + 420 00D3 ;=============================================================== + 421 00D3 control_read: + 422 00D3 0001 clr wdt + 423 00D4 0700 E MOV A,data_start + 424 00D5 0087 MOV TBLP,A + 425 00D6 control_read_data_stage: + 426 00D6 0001 clr wdt + 427 00D7 0F00 MOV A,00H + 428 00D8 0080 E MOV Loop_Counter,A + 429 00D9 0080 E MOV FIFO_SendLen,A + 430 00DA + 431 00DA + 432 00DA 3EA6 SZ MISC.@MISC_SCMD + 433 00DB 2800 R JMP control_read_status_stage_end + 434 00DC 0001 clr wdt + 435 00DD + 436 00DD 0F00 E MOV A,OFFSET FIFO_TYPE + 437 00DE 0081 MOV MP0,A + 438 00DF + 439 00DF 0700 E MOV A,data_count + 440 00E0 0C00 XOR A,00H + 441 00E1 3D0A SZ Z + 442 00E2 2800 R JMP dma_load_done ;A=00H + 443 00E3 + 444 00E3 dma_load_loop: + 445 00E3 0001 clr wdt + 446 00E4 3800 E SNZ bFlag_RD_HTable + 447 00E5 2800 R JMP Read_Low_Bytes + 448 00E6 Read_High_Bytes: + 449 00E6 0001 clr wdt + 450 00E7 3400 E CLR bFlag_RD_HTable + 451 00E8 1D80 TABRDL R0 + 452 00E9 1487 INC TBLP + 453 00EA 1480 E INC data_start + 454 00EB 0708 MOV A,TBLH + 455 00EC 0E3F AND A,00111111b + 456 00ED 0080 MOV R0,A + 457 00EE 0C3F XOR A,3FH + 458 00EF 3D0A SZ Z + 459 00F0 2800 R JMP dma_load_loop + 460 00F1 + 461 00F1 2800 R JMP Check_Read_Length + 462 00F2 + 463 00F2 Read_Low_Bytes: + 464 00F2 0001 clr wdt + 465 00F3 3000 E SET bFlag_RD_HTable + 466 00F4 1D80 TABRDL R0 + 467 00F5 0700 MOV A,R0 + 468 00F6 Check_Read_Length: + 469 00F6 0001 clr wdt + 470 00F7 1481 INC MP0 + 471 00F8 1480 E INC loop_counter + 472 00F9 1480 E INC FIFO_SendLen + 473 00FA 1580 E DEC data_count + 474 00FB 3D0A SZ Z + 475 00FC 2800 R JMP wait_control_read + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次9 + + 476 00FD 0700 E MOV A,loop_counter + 477 00FE 0C08 XOR A,EP0_FIFO_SIZE + 478 00FF 390A SNZ Z + 479 0100 2800 R JMP dma_load_loop + 480 0101 2800 R jmp wait_control_read + 481 0102 dma_load_done: + 482 0102 0001 clr wdt + 483 0103 ;SZ MISC.@MISC_SCMD + 484 0103 ;JMP control_read_status_stage_end + 485 0103 2000 R CALL Send_Hand_Shake + 486 0104 2800 R jmp control_read_status_stage_end + 487 0105 + 488 0105 wait_control_read: + 489 0105 0001 clr wdt + 490 0106 2000 R call Check_Real_Cmd + 491 0107 3C00 E sz bFlag_Real_Cmd + 492 0108 2800 R jmp control_read_status_stage_end + 493 0109 + 494 0109 0001 clr wdt + 495 010A 2000 R CALL FIFO0_WR_CHECK + 496 010B 3800 E SNZ bFlag_FIFO_Ready + 497 010C 2800 R JMP wait_control_read ;wait FIFO0 Ready + 498 010D 2000 R CALL Write_FIFO0 + 499 010E control_read_status_stage_end: + 500 010E 0001 clr wdt + 501 010F 0000 NOP + 502 0110 0003 RET + 503 0111 + 504 0111 + 505 0111 ;----------------------------------------------------------- + 506 0111 ; Check_Real_Cmd : if have new cmd , set bFlag_Real_Cmd else clr bFlag_Real_Cmd + 507 0111 ;----------------------------------------------------------- + 508 0111 Check_Real_Cmd: + 509 0111 0001 clr wdt + 510 0112 3400 E clr bFlag_Real_Cmd + 511 0113 3EA6 SZ MISC.@MISC_SCMD + 512 0114 3000 E set bFlag_Real_Cmd + 513 0115 3FA6 SZ MISC.@MISC_LEN0 + 514 0116 3000 E set bFlag_Real_Cmd + 515 0117 0003 RET + 516 0118 + 517 0118 ;*************************************************************** + 518 0118 ; USB Stage3 + 519 0118 ; Process the request + 520 0118 ;*************************************************************** + 521 0118 ;Set the device address to the wValue in the SETUP packet at the completion + 522 0118 ;of the current transaction + 523 0118 ;----------------------------------------------------------- + 524 0118 ; Set Address + 525 0118 ;----------------------------------------------------------- + 526 0118 SetAddress: + 527 0118 0001 clr wdt + 528 0119 0700 E MOV A,FIFO_WVALUEL ;save address to FIFO_ADDR + 529 011A 0080 E MOV FIFO_ADDR,A + 530 011B 0080 E MOV FIFO_TEMP,A + 531 011C + 532 011C 0F25 MOV A,USB_SIES + 533 011D 0083 MOV MP1,A + 534 011E 0F01 MOV A,00000001b + 535 011F 0582 ORM A,R1 + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次10 + + 536 0120 1800 E RLA FIFO_TEMP + 537 0121 0EFE AND A,0FEH + 538 0122 0080 E MOV FIFO_TEMP,A + 539 0123 + 540 0123 0F23 MOV A,USB_AWR + 541 0124 0083 MOV MP1,A + 542 0125 0700 E MOV A,FIFO_TEMP + 543 0126 0082 MOV R1,A + 544 0127 0000 NOP + 545 0128 + 546 0128 2000 R CALL Send_Hand_Shake ;send a handshake with host + 547 0129 + 548 0129 3000 E SET bFlag_Set_Address + 549 012A ;;RET ;for test + 550 012A 2800 E JMP USB_EP0_ISR_END + 551 012B + 552 012B ;----------------------------------------------------------- + 553 012B ; Set Configuration + 554 012B ;----------------------------------------------------------- + 555 012B SetConfiguration: + 556 012B 0001 clr wdt + 557 012C 339C set USVC.7 ;unmute + 558 012D + 559 012D 0700 E MOV A,FIFO_WVALUEL + 560 012E 0080 E MOV USB_Configuration,A + 561 012F 1F24 CLR STALL + 562 0130 ;MOV A,USB_STALL + 563 0130 ;MOV MP1,A + 564 0130 ;CLR R1 ;not stall + 565 0130 3000 E set bFlag_SetConfiguration_Ready + 566 0131 SetConfiguration_wait: + 567 0131 2000 R CALL Send_Hand_Shake + 568 0132 2800 E JMP USB_EP0_ISR_END + 569 0133 + 570 0133 ;----------------------------------------------------------- + 571 0133 ; Set Interface + 572 0133 ;----------------------------------------------------------- + 573 0133 SetInterface: + 574 0133 0001 clr wdt + 575 0134 0700 E MOV A,FIFO_WVALUEL + 576 0135 0080 E MOV USB_Interface_Alt,A + 577 0136 0700 E MOV A,FIFO_WINDEXL + 578 0137 0080 E MOV USB_Interface,A + 579 0138 3000 E set bFlag_SetInterface_Ready + 580 0139 3014 set USB_LED_ON + 581 013A SetInterface_wait: + 582 013A 2000 R CALL Send_Hand_Shake + 583 013B 2800 E JMP USB_EP0_ISR_END + 584 013C + 585 013C ;----------------------------------------------------------- + 586 013C ; Get Interface + 587 013C ;----------------------------------------------------------- + 588 013C GetInterface: + 589 013C 0001 clr wdt + 590 013D 0700 E mov A,USB_Interface_Alt + 591 013E 0080 E mov FIFO_OUT1,A + 592 013F + 593 013F 0F01 mov A,01H + 594 0140 0080 E mov FIFO_SendLen,A + 595 0141 + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次11 + + 596 0141 GetInterface_Loop: + 597 0141 0001 clr wdt + 598 0142 2000 R call Check_Real_Cmd + 599 0143 3C00 E sz bFlag_Real_Cmd + 600 0144 2800 R jmp GetInterface_End + 601 0145 0001 clr wdt + 602 0146 2000 R call FIFO0_WR_CHECK + 603 0147 3800 E SNZ bFlag_FIFO_Ready + 604 0148 2800 R JMP GetInterface_Loop + 605 0149 + 606 0149 2000 R CALL Write_FIFO0 + 607 014A + 608 014A GetInterface_End: + 609 014A 2800 E JMP USB_EP0_ISR_END + 610 014B + 611 014B ;----------------------------------------------------------- + 612 014B ; Get Status + 613 014B ; For Get Status (DEVICE,INTERFACE,ENDPOINT) , if self-powered and remote wakeup need to modify + 614 014B ; return 2 bytes (00 00) + 615 014B ;----------------------------------------------------------- + 616 014B GetStatus: + 617 014B 0001 clr wdt + 618 014C 0F02 mov a,02H + 619 014D 0080 E mov FIFO_SendLen,a + 620 014E + 621 014E ;Modify for Remote Wakeup + 622 014E 0F02 mov a,02H + 623 014F 3800 E snz bRmtWakeup + 624 0150 ;------------------------ + 625 0150 0F00 mov a,00H + 626 0151 0080 E mov FIFO_Out1,a + 627 0152 1F00 E clr FIFO_Out2 + 628 0153 + 629 0153 GetStatus_Loop: + 630 0153 0001 clr wdt + 631 0154 2000 R call Check_Real_Cmd + 632 0155 3C00 E sz bFlag_Real_Cmd + 633 0156 2800 R jmp GetStatus_End + 634 0157 0001 clr wdt + 635 0158 + 636 0158 2000 R call FIFO0_WR_CHECK + 637 0159 3800 E SNZ bFlag_FIFO_Ready + 638 015A 2800 R JMP GetStatus_Loop + 639 015B + 640 015B 2000 R CALL Write_FIFO0 + 641 015C + 642 015C GetStatus_End: + 643 015C 2800 E JMP USB_EP0_ISR_END + 644 015D + 645 015D ;----------------------------------------------------------- + 646 015D ; Get Status (Endpoint) + 647 015D ;----------------------------------------------------------- + 648 015D ;----------------------------------------------------------- + 649 015D ; Get Status (Interface) + 650 015D ; return 2 bytes (00 00) + 651 015D ;----------------------------------------------------------- + 652 015D ;Modify for Remote Wakeup + 653 015D GetStatus_Interface: + 654 015D 0001 clr wdt + 655 015E 0F02 mov a,02H + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次12 + + 656 015F 0080 E mov FIFO_SendLen,a + 657 0160 + 658 0160 + 659 0160 0F00 mov a,00H + 660 0161 0080 E mov FIFO_Out1,a + 661 0162 1F00 E clr FIFO_Out2 + 662 0163 + 663 0163 GetStatus_Inerface_Loop: + 664 0163 0001 clr wdt + 665 0164 2000 R call Check_Real_Cmd + 666 0165 3C00 E sz bFlag_Real_Cmd + 667 0166 2800 R jmp GetStatus_End + 668 0167 0001 clr wdt + 669 0168 + 670 0168 2000 R call FIFO0_WR_CHECK + 671 0169 3800 E SNZ bFlag_FIFO_Ready + 672 016A 2800 R JMP GetStatus_Inerface_Loop + 673 016B + 674 016B 2000 R CALL Write_FIFO0 + 675 016C + 676 016C GetStatus_Inerface_Loop_End: + 677 016C 2800 E JMP USB_EP0_ISR_END + 678 016D ;----------------------------------------------------------- + 679 016D ; Get Status (Endpoint) + 680 016D ;----------------------------------------------------------- + 681 016D GetStatus_Endpoint: + 682 016D 0001 clr wdt + 683 016E 0F02 mov a,02H + 684 016F 0080 E mov FIFO_SendLen,a + 685 0170 + 686 0170 0F7F mov a,07FH + 687 0171 0600 E and a,FIFO_wIndexL + 688 0172 + 689 0172 2000 R call GetPipeBit + 690 0173 0080 E mov FIFO_TEMP,a + 691 0174 0724 mov a,STALL + 692 0175 0600 E and a,FIFO_TEMP + 693 0176 0080 E mov FIFO_TEMP,a + 694 0177 + 695 0177 1F00 E clr FIFO_Out1 + 696 0178 1080 E sz FIFO_TEMP + 697 0179 3000 E set FIFO_Out1.0 + 698 017A + 699 017A 1F00 E clr FIFO_Out2 + 700 017B + 701 017B 2800 R jmp GetStatus_Loop + 702 017C + 703 017C + 704 017C GetStatus_Endpoint_End: + 705 017C 2800 E JMP USB_EP0_ISR_END + 706 017D ;----------------------------------------------------------- + 707 017D ; Clear Feature : The HT82A822R return ACK without ERROR + 708 017D ; bmRequest: 00 Device + 709 017D ; 02 EndPoint + 710 017D ; bRequest 01 CLEAR_FEATURE + 711 017D ; wValue 0000 clear ENDPOINT0 HALT + 712 017D ; 0001 clear REMOTE_WAKEUP + 713 017D ; wIndex 0000 + 714 017D ; wLength 0000 + 715 017D ;----------------------------------------------------------- + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次13 + + 716 017D ClearFeature: + 717 017D ;;----2007-01-10 for Vista DTM---- + 718 017D 0700 E mov a,FIFO_wValueL + 719 017E 0C01 xor a,01H + 720 017F 390A snz z + 721 0180 2800 R JMP SendStall0 + 722 0181 ;set b_wakeup + 723 0181 ;clr bRmtWakeup + 724 0181 ;;------------------------------ + 725 0181 0001 clr wdt + 726 0182 ;Modify for Remote Wakeup + 727 0182 3000 E set b_wakeup + 728 0183 3400 E clr bRmtWakeup + 729 0184 ;----------------------- + 730 0184 2000 R CALL Send_Hand_Shake + 731 0185 ClearFeature_Loop: + 732 0185 ClearFeature_End: + 733 0185 2800 E JMP USB_EP0_ISR_END + 734 0186 ;----------------------------------------------------------- + 735 0186 ; Clear Feature (Endpoint) + 736 0186 ;----------------------------------------------------------- + 737 0186 ClearFeature_Endpoint: + 738 0186 0001 clr wdt + 739 0187 + 740 0187 + 741 0187 3800 E snz bFlag_SetConfiguration_Ready + 742 0188 2800 R JMP SendStall0 + 743 0189 + 744 0189 0F7F mov a,07FH + 745 018A 0600 E and a,FIFO_wIndexL + 746 018B + 747 018B 2000 R call GetPipeBit + 748 018C + 749 018C 0080 E mov FIFO_TEMP,a + 750 018D 0180 E CPL FIFO_TEMP + 751 018E 0724 mov a,STALL + 752 018F 0600 E AND a,FIFO_TEMP + 753 0190 00A4 mov STALL,a + 754 0191 + 755 0191 2000 R CALL Send_Hand_Shake + 756 0192 + 757 0192 + 758 0192 ClearFeature_Endpoint_End: + 759 0192 2800 E JMP USB_EP0_ISR_END + 760 0193 + 761 0193 ;----------------------------------------------------------- + 762 0193 ; Set Feature + 763 0193 ;----------------------------------------------------------- + 764 0193 SetFeature: + 765 0193 ;;----2007-01-10 for Vista DTM---- + 766 0193 0700 E mov a,FIFO_wValueH + 767 0194 0C00 xor a,00H + 768 0195 3D0A sz z + 769 0196 2800 R JMP SetFeature_1 + 770 0197 + 771 0197 0700 E mov a,FIFO_wValueH + 772 0198 0A81 sub a,81H ;target-now + 773 0199 380A snz C + 774 019A 2800 R jmp SendStall0 ;<81H + 775 019B ;>=81H + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次14 + + 776 019B 0700 E mov a,FIFO_wValueH + 777 019C 0A84 sub a,84H ;target-now + 778 019D 3C0A sz C + 779 019E 2800 R jmp SendStall0 ;>=84H + 780 019F + 781 019F 0700 E mov a,FIFO_wValueL + 782 01A0 0C00 xor a,00H + 783 01A1 390A snz z + 784 01A2 2800 R JMP SendStall0 + 785 01A3 2800 R jmp SetFeature_2 + 786 01A4 + 787 01A4 SetFeature_1: + 788 01A4 0700 E mov a,FIFO_wValueL + 789 01A5 0C01 xor a,01H + 790 01A6 390A snz z + 791 01A7 2800 R JMP SendStall0 + 792 01A8 + 793 01A8 SetFeature_2: + 794 01A8 + 795 01A8 ;;---------------------------------- + 796 01A8 ;Modify for Remote Wakeup + 797 01A8 3000 E set b_wakeup + 798 01A9 3000 E set bRmtWakeup + 799 01AA ;----------------------- + 800 01AA 2000 R CALL Send_Hand_Shake + 801 01AB SetFeature_Loop: + 802 01AB SetFeature_End: + 803 01AB 2800 E JMP USB_EP0_ISR_END + 804 01AC ;----------------------------------------------------------- + 805 01AC ; Set Feature (Endpoint) + 806 01AC ;----------------------------------------------------------- + 807 01AC SetFeature_Endpoint: + 808 01AC 0001 clr wdt + 809 01AD 3800 E snz bFlag_SetConfiguration_Ready + 810 01AE 2800 R JMP SendStall0 + 811 01AF + 812 01AF 0F7F mov a,07FH + 813 01B0 0600 E and a,FIFO_wIndexL + 814 01B1 + 815 01B1 2000 R call GetPipeBit + 816 01B2 + 817 01B2 0080 E mov FIFO_TEMP,A + 818 01B3 0724 mov a,STALL + 819 01B4 0500 E or a,FIFO_TEMP + 820 01B5 00A4 mov STALL,a + 821 01B6 + 822 01B6 2000 R CALL Send_Hand_Shake + 823 01B7 + 824 01B7 SetFeature_Endpoint_End: + 825 01B7 2800 E JMP USB_EP0_ISR_END + 826 01B8 ;----------------------------------------------------------- + 827 01B8 ; Get Descriptor + 828 01B8 ;----------------------------------------------------------- + 829 01B8 GetDescriptor: + 830 01B8 0001 clr wdt + 831 01B9 3400 E CLR bFlag_RD_HTable + 832 01BA 3400 E CLR bFlag_wait_control_out + 833 01BB + 834 01BB 0700 E MOV A,FIFO_WvalueH ;80 06 00 01 + 835 01BC 0C01 XOR A,device + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次15 + + 836 01BD 3D0A SZ Z + 837 01BE 2800 R JMP GetDeviceDescriptor + 838 01BF + 839 01BF 0700 E MOV A,FIFO_WvalueH ;80 06 00 02 + 840 01C0 0C02 XOR A,configuration + 841 01C1 3D0A SZ Z + 842 01C2 2800 R JMP GetConfigurationDescriptor + 843 01C3 + 844 01C3 0700 E MOV A,FIFO_WvalueH ;80 06 00 03 + 845 01C4 0C03 XOR A,string + 846 01C5 3D0A SZ Z + 847 01C6 2800 R JMP GetStringDescriptor + 848 01C7 + 849 01C7 + 850 01C7 ;------------------------------------------------------ + 851 01C7 ;Then test for HID class Descriptor + 852 01C7 ;------------------------------------------------------ + 853 01C7 + 854 01C7 0700 E MOV A,FIFO_WvalueH ;81 06 00 22 + 855 01C8 0C22 XOR A,report + 856 01C9 3D0A SZ Z + 857 01CA 2800 R JMP GetReportDescriptor + 858 01CB + 859 01CB 0700 E MOV A,FIFO_WvalueH ;81 06 00 21 + 860 01CC 0C21 XOR A,HID + 861 01CD 3D0A SZ Z + 862 01CE 2800 R JMP GetHIDDescriptor + 863 01CF + 864 01CF + 865 01CF + 866 01CF 2800 R JMP SendStall0 ;can't parser + 867 01D0 + 868 01D0 ;----------------------------------------------------------- + 869 01D0 ; GetConfiguration + 870 01D0 ;----------------------------------------------------------- + 871 01D0 GetConfiguration: + 872 01D0 0001 clr wdt + 873 01D1 0F01 mov a,01H + 874 01D2 0080 E mov FIFO_SendLen,a + 875 01D3 + 876 01D3 0700 E mov a,USB_Configuration + 877 01D4 0080 E mov FIFO_OUT1,a + 878 01D5 GetConfiguration_Loop: + 879 01D5 0001 clr wdt + 880 01D6 2000 R call Check_Real_Cmd + 881 01D7 3C00 E sz bFlag_Real_Cmd + 882 01D8 2800 R jmp GetConfiguration_End + 883 01D9 0001 clr wdt + 884 01DA 2000 R call FIFO0_WR_CHECK + 885 01DB 3800 E SNZ bFlag_FIFO_Ready + 886 01DC 2800 R JMP GetConfiguration_Loop + 887 01DD + 888 01DD 2000 R CALL Write_FIFO0 + 889 01DE GetConfiguration_End: + 890 01DE 2800 E JMP USB_EP0_ISR_END + 891 01DF + 892 01DF + 893 01DF + 894 01DF ;------------------------------------------------------ + 895 01DF ;Report + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次16 + + 896 01DF ;------------------------------------------------------ + 897 01DF SetReport: + 898 01DF 0001 clr wdt + 899 01E0 0700 E mov a,FIFO_wValueH + 900 01E1 0C02 xor a,set_output_report + 901 01E2 3D0A sz z + 902 01E3 2800 R jmp SetOutputReport + 903 01E4 + 904 01E4 2800 E JMP USB_EP0_ISR_END + 905 01E5 SetReport_End: + 906 01E5 + 907 01E5 SetOutputReport: + 908 01E5 0001 clr wdt + 909 01E6 ;check interface + 910 01E6 0700 E mov a,FIFO_wIndexL + 911 01E7 0C02 xor a,02H + 912 01E8 390A snz z + 913 01E9 2800 R jmp SendStall0 + 914 01EA ;check length + 915 01EA 0700 E mov a,FIFO_wLengthL + 916 01EB 0C08 xor a,08H + 917 01EC 390A snz z + 918 01ED 2800 R jmp SendStall0 + 919 01EE + 920 01EE 0F21 mov a,21H + 921 01EF 0080 E mov nCmdIndex1,a + 922 01F0 + 923 01F0 + 924 01F0 SetOutputReport_End: + 925 01F0 2800 E JMP USB_EP0_ISR_END + 926 01F1 ;------------------------------------------------------ + 927 01F1 ;Audio class + 928 01F1 ;------------------------------------------------------ + 929 01F1 ;21 01 + 930 01F1 SetCur: + 931 01F1 0001 clr wdt + 932 01F2 0700 E MOV A,FIFO_WVALUEH + 933 01F3 0C01 XOR A,MUTE_CONTROL + 934 01F4 3D0A SZ Z + 935 01F5 2800 R JMP MuteControl + 936 01F6 + 937 01F6 0700 E MOV A,FIFO_WVALUEH + 938 01F7 0C02 XOR A,VOLUME_CONTROL + 939 01F8 3D0A SZ Z + 940 01F9 2800 R JMP VolumeControl + 941 01FA + 942 01FA 2800 R JMP SendStall0 ;can't parser + 943 01FB + 944 01FB ;21 01 00 01 + 945 01FB MuteControl: ;(if have more feature , the state must be modify!!) + 946 01FB 0001 clr wdt + 947 01FC 0F18 mov a,18h + 948 01FD 0080 E mov nCmdIndex1,a + 949 01FE + 950 01FE ;;RET + 951 01FE ;;modify 2005-12-13 + 952 01FE 2800 E jmp USB_EP0_ISR_END + 953 01FF ;21 01 00 02 + 954 01FF VolumeControl: + 955 01FF 0001 clr wdt + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次17 + + 956 0200 0F28 mov a,28h + 957 0201 0080 E mov nCmdIndex1,a + 958 0202 ;;RET + 959 0202 ;;modify 2005-12-13 + 960 0202 2800 E jmp USB_EP0_ISR_END + 961 0203 + 962 0203 ;return D2 00 = -46 db + 963 0203 ;return BC 00 = -32 db (セ E0) + 964 0203 GetMin: + 965 0203 0001 clr wdt + 966 0204 0F00 MOV A,00H + 967 0205 0080 E MOV FIFO_OUT1,A + 968 0206 ;; MOV A,0E0H + 969 0206 0FC8 MOV A,Min_Volume + 970 0207 0080 E MOV FIFO_OUT2,A + 971 0208 0F02 MOV A,02H + 972 0209 0080 E MOV FIFO_SendLen,A + 973 020A GetMin_Loop: + 974 020A 0001 clr wdt + 975 020B 2000 R call Check_Real_Cmd + 976 020C 3C00 E sz bFlag_Real_Cmd + 977 020D 2800 R jmp GetMin_End + 978 020E 0001 clr wdt + 979 020F 2000 R call FIFO0_WR_CHECK + 980 0210 3800 E SNZ bFlag_FIFO_Ready + 981 0211 2800 R JMP GetMin_Loop + 982 0212 + 983 0212 2000 R CALL Write_FIFO0 + 984 0213 GetMin_End: + 985 0213 ;;RET + 986 0213 ;;2005-12-13 modify + 987 0213 2800 E jmp USB_EP0_ISR_END + 988 0214 + 989 0214 + 990 0214 ;return 0x0C00 + 991 0214 GetMax: + 992 0214 0001 clr wdt + 993 0215 0F00 MOV A,00H + 994 0216 0080 E MOV FIFO_OUT1,A + 995 0217 ;; MOV A,0CH + 996 0217 0F00 MOV A,Max_Volume + 997 0218 0080 E MOV FIFO_OUT2,A + 998 0219 0F02 MOV A,02H + 999 021A 0080 E MOV FIFO_SendLen,A +1000 021B GetMax_Loop: +1001 021B 0001 clr wdt +1002 021C 2000 R call Check_Real_Cmd +1003 021D 3C00 E sz bFlag_Real_Cmd +1004 021E 2800 R jmp GetMax_End +1005 021F 0001 clr wdt +1006 0220 +1007 0220 2000 R call FIFO0_WR_CHECK +1008 0221 3800 E SNZ bFlag_FIFO_Ready +1009 0222 2800 R JMP GetMax_Loop +1010 0223 +1011 0223 +1012 0223 2000 R CALL Write_FIFO0 +1013 0224 GetMax_End: +1014 0224 ; RET +1015 0224 ;;2005-12-13 modify + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次18 + +1016 0224 2800 E jmp USB_EP0_ISR_END +1017 0225 +1018 0225 +1019 0225 +1020 0225 +1021 0225 +1022 0225 ;return 0x0100 1db +1023 0225 GetRes: +1024 0225 0001 clr wdt +1025 0226 0F00 MOV A,00H +1026 0227 0080 E MOV FIFO_OUT1,A +1027 0228 0F01 MOV A,01H +1028 0229 0080 E MOV FIFO_OUT2,A +1029 022A 0F02 MOV A,02H +1030 022B 0080 E MOV FIFO_SendLen,A +1031 022C GetRes_Loop: +1032 022C 0001 clr wdt +1033 022D 2000 R call Check_Real_Cmd +1034 022E 3C00 E sz bFlag_Real_Cmd +1035 022F 2800 R jmp GetRes_End +1036 0230 +1037 0230 2000 R call FIFO0_WR_CHECK +1038 0231 3800 E SNZ bFlag_FIFO_Ready +1039 0232 2800 R JMP GetRes_Loop +1040 0233 +1041 0233 2000 R CALL Write_FIFO0 +1042 0234 GetRes_End: +1043 0234 ; RET +1044 0234 ;;2005-12-13 modify +1045 0234 2800 E jmp USB_EP0_ISR_END +1046 0235 +1047 0235 +1048 0235 GetCur: +1049 0235 ;; call Check_Real_Cmd +1050 0235 ;; sz bFlag_Real_Cmd +1051 0235 ;; jmp GetCur_End +1052 0235 ;; +1053 0235 ;; +1054 0235 ;; call FIFO0_WR_CHECK +1055 0235 ;; SNZ bFlag_FIFO_Ready +1056 0235 ;; JMP GetCur +1057 0235 +1058 0235 ;; +1059 0235 ;; MOV A,FIFO_wLengthL +1060 0235 ;; MOV FIFO_SendLen,A +1061 0235 ;; +1062 0235 ;; MOV FIFO_TEMP,A +1063 0235 ;; MOV A,OFFSET FIFO_OUT1 +1064 0235 ;; MOV MP1,A +1065 0235 ;;GetCur_Fill0: +1066 0235 ;; MOV A,00H +1067 0235 ;; MOV R1,A +1068 0235 ;; INC MP1 +1069 0235 ;; DEC FIFO_TEMP +1070 0235 ;; MOV A,00H +1071 0235 ;; XOR A,FIFO_TEMP +1072 0235 ;; SNZ Z +1073 0235 ;; JMP GetCur_Fill0 +1074 0235 ;; CALL Write_FIFO0 +1075 0235 0001 clr wdt + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次19 + +1076 0236 0700 E MOV A,FIFO_wLengthL +1077 0237 0080 E MOV FIFO_SendLen,A +1078 0238 +1079 0238 0F01 MOV A,01H +1080 0239 0400 E XOR A,FIFO_SendLen +1081 023A 3D0A sz z +1082 023B 2800 R jmp GetCur_Mute +1083 023C +1084 023C 0F02 MOV A,02H +1085 023D 0400 E XOR A,FIFO_SendLen +1086 023E 3D0A sz z +1087 023F 2800 R jmp GetCur_Volume +1088 0240 2800 R jmp GetCur_End +1089 0241 +1090 0241 GetCur_Mute: +1091 0241 0001 clr wdt +1092 0242 0F00 MOV A,00H +1093 0243 3C00 E sz bFlag_Audio_Mute +1094 0244 0F01 MOV A,01H +1095 0245 0080 E mov FIFO_OUT1,A +1096 0246 GetCur_Mute_Loop: +1097 0246 0001 clr wdt +1098 0247 2000 R call Check_Real_Cmd +1099 0248 3C00 E sz bFlag_Real_Cmd +1100 0249 2800 R jmp GetCur_End +1101 024A +1102 024A +1103 024A 2000 R call FIFO0_WR_CHECK +1104 024B 3800 E SNZ bFlag_FIFO_Ready +1105 024C 2800 R JMP GetCur_Mute_Loop +1106 024D +1107 024D 2000 R call Write_FIFO0 +1108 024E 2800 R jmp GetCur_End +1109 024F GetCur_Volume: +1110 024F 0001 clr wdt +1111 0250 0700 E MOV A,VolumeH_Save +1112 0251 0080 E mov FIFO_OUT1,A +1113 0252 +1114 0252 0700 E MOV A,VolumeL_Save +1115 0253 0080 E mov FIFO_OUT2,A +1116 0254 GetCur_Volume_Loop: +1117 0254 0001 clr wdt +1118 0255 2000 R call Check_Real_Cmd +1119 0256 3C00 E sz bFlag_Real_Cmd +1120 0257 2800 R jmp GetCur_End +1121 0258 +1122 0258 +1123 0258 2000 R call FIFO0_WR_CHECK +1124 0259 3800 E SNZ bFlag_FIFO_Ready +1125 025A 2800 R JMP GetCur_Volume_Loop +1126 025B +1127 025B 2000 R call Write_FIFO0 +1128 025C 2800 R jmp GetCur_End +1129 025D GetCur_End: +1130 025D ; RET +1131 025D ;;2005-12-13 modify +1132 025D 2800 E jmp USB_EP0_ISR_END +1133 025E +1134 025E ;-------------------------------------------------------------- +1135 025E ; ゼЧΘ + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次20 + +1136 025E SetIdle: +1137 025E 2800 R JMP SendStall0 ;can't parser +1138 025F +1139 025F ;============================================================== +1140 025F ;Standard Get Descriptor routines +1141 025F ; +1142 025F ;Return the device descriptor to the host +1143 025F GetDeviceDescriptor: +1144 025F 0001 clr wdt +1145 0260 0F00 E MOV A,LOW device_desc_table +1146 0261 0087 MOV TBLP,A +1147 0262 1D80 E TABRDL data_count +1148 0263 ;modify 2005-12-02 +1149 0263 2000 R CALL Execute +1150 0264 2800 E jmp USB_EP0_ISR_END +1151 0265 +1152 0265 GetConfigurationDescriptor: +1153 0265 0001 clr wdt +1154 0266 0F00 E MOV A,LOW config_desc_length +1155 0267 0087 MOV TBLP,A +1156 0268 1D80 E TABRDL data_count +1157 0269 0F00 E MOV A,LOW config_desc_table +1158 026A ;modify 2005-12-02 +1159 026A 2000 R call Execute +1160 026B 2800 E jmp USB_EP0_ISR_END +1161 026C ;Not Ready!!!!!!!!! +1162 026C GetStringDescriptor: +1163 026C 0001 clr wdt +1164 026D 0700 E MOV A,FIFO_WVALUEL +1165 026E 0C00 XOR A,00H +1166 026F 3D0A SZ Z +1167 0270 2800 R JMP LanguageString +1168 0271 +1169 0271 0700 E MOV A,FIFO_WVALUEL +1170 0272 0C01 XOR A,01H +1171 0273 3D0A SZ Z +1172 0274 2800 R JMP ManufacturerString +1173 0275 +1174 0275 0700 E MOV A,FIFO_WVALUEL +1175 0276 0C02 XOR A,02H +1176 0277 3D0A SZ Z +1177 0278 2800 R JMP ProductString +1178 0279 +1179 0279 0700 E MOV A,FIFO_WVALUEL +1180 027A 0C03 XOR A,03H +1181 027B 3D0A SZ Z +1182 027C 2800 R JMP SerialNumberString +1183 027D +1184 027D +1185 027D 2800 R JMP SendStall0 ;other no support +1186 027E +1187 027E LanguageString: +1188 027E 0001 clr wdt +1189 027F 0F00 E MOV A,LOW USBStringLanguageDescription +1190 0280 0087 MOV TBLP,A +1191 0281 1D80 E TABRDL data_count +1192 0282 0F00 E MOV A,LOW USBStringLanguageDescription +1193 0283 ;modify 2005-12-02 +1194 0283 2000 R call execute +1195 0284 2800 E jmp USB_EP0_ISR_END + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次21 + +1196 0285 ManufacturerString: +1197 0285 0001 clr wdt +1198 0286 0F00 E MOV A,LOW USBStringDescription1 +1199 0287 0087 MOV TBLP,A +1200 0288 1D80 E TABRDL data_count +1201 0289 0F00 E MOV A,LOW USBStringDescription1 +1202 028A ;modify 2005-12-02 +1203 028A 2000 R call execute +1204 028B 2800 E jmp USB_EP0_ISR_END +1205 028C ProductString: +1206 028C 0001 clr wdt +1207 028D 0F00 E MOV A,LOW USBStringDescription2 +1208 028E 0087 MOV TBLP,A +1209 028F 1D80 E TABRDL data_count +1210 0290 0F00 E MOV A,LOW USBStringDescription2 +1211 0291 ;modify 2005-12-02 +1212 0291 2000 R call execute +1213 0292 2800 E jmp USB_EP0_ISR_END +1214 0293 +1215 0293 +1216 0293 SerialNumberString: +1217 0293 0001 clr wdt +1218 0294 0F00 E MOV A,LOW USBStringDescription3 +1219 0295 0087 MOV TBLP,A +1220 0296 1D80 E TABRDL data_count +1221 0297 0F00 E MOV A,LOW USBStringDescription3 +1222 0298 ;modify 2005-12-02 +1223 0298 2000 R call execute +1224 0299 +1225 0299 2800 E jmp USB_EP0_ISR_END +1226 029A +1227 029A +1228 029A +1229 029A ;-------------------------------------------------- +1230 029A ;HID class Get Descriptor routines +1231 029A ;return the HID descriptor and enable endpoint one +1232 029A ;-------------------------------------------------- +1233 029A GetReportDescriptor: +1234 029A 0001 clr wdt +1235 029B 0F00 E MOV A,LOW report_desc_length +1236 029C 0087 MOV TBLP,A +1237 029D 1D80 E TABRDL data_count ;Report length = Low byte of Report_Size +1238 029E 0F00 E MOV A,LOW hid_report_desc_table +1239 029F 2000 R CALL execute ;send descriptor to host +1240 02A0 ; +1241 02A0 ;Enumeration is complete!! +1242 02A0 ; +1243 02A0 3000 E set bFlag_Enum_Ready ;set Enumeration flag +1244 02A1 ;modify 2005-12-02 +1245 02A1 2800 E jmp USB_EP0_ISR_END +1246 02A2 +1247 02A2 GetHIDDescriptor: +1248 02A2 0001 clr wdt +1249 02A3 0F00 E MOV A,LOW hid_desc_length +1250 02A4 0087 MOV TBLP,A +1251 02A5 1D80 E TABRDL data_count ;Report length = Low byte of Report_Size +1252 02A6 0F00 E MOV A,LOW HID_Desc +1253 02A7 ;modify 2005-12-02 +1254 02A7 2000 R CALL execute ;send descriptor to host +1255 02A8 2800 E jmp USB_EP0_ISR_END + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次22 + +1256 02A9 +1257 02A9 Execute: +1258 02A9 0001 clr wdt +1259 02AA 0080 E MOV data_start,A +1260 02AB 2000 R call get_descriptor_length +1261 02AC 2000 R call control_read +1262 02AD 0003 RET +1263 02AE +1264 02AE ;=============================================================== +1265 02AE SendStall0: +1266 02AE 3024 SET STALL.@STALL_STL0 +1267 02AF 2800 E JMP USB_EP0_ISR_END +1268 02B0 ;return to USB_EP0_ISR +1269 02B0 +1270 02B0 +1271 02B0 +1272 02B0 +1273 02B0 +1274 02B0 +1275 02B0 +1276 02B0 +1277 02B0 +1278 02B0 +1279 02B0 +1280 02B0 +1281 02B0 +1282 02B0 ;*************************************************************** +1283 02B0 ; Delay Test Function +1284 02B0 ; Most instructions Timing is one cycles = 0.33333 us +1285 02B0 ; call , jmp , ret is 2 cycles +1286 02B0 ;*************************************************************** +1287 02B0 +1288 02B0 Delay_28us: +1289 02B0 0F1E mov a,1EH +1290 02B1 Delay_28us_cont: +1291 02B1 0001 clr wdt +1292 02B2 1785 sdz acc +1293 02B3 2800 R jmp Delay_28us_cont +1294 02B4 Delay_3us: +1295 02B4 0001 clr wdt +1296 02B5 0000 NOP +1297 02B6 0000 NOP +1298 02B7 0000 NOP +1299 02B8 0000 NOP +1300 02B9 0001 clr wdt +1301 02BA 0003 ret +1302 02BB +1303 02BB +1304 02BB ;----BEGIN (Get pipe bit) +1305 02BB ;Input : ACC pipe number +1306 02BB ;Output: ACC pip bit (D0:pipe 0, D1:pipe 1...) +1307 02BB GetPipeBit: +1308 02BB 1485 INC ACC +1309 02BC 0080 E MOV FIFO_TEMP,A +1310 02BD 0F80 MOV A,80H +1311 02BE GetPipeBitLoop: +1312 02BE 0001 clr wdt +1313 02BF 1885 RL ACC +1314 02C0 1780 E SDZ FIFO_TEMP +1315 02C1 2800 R JMP GetPipeBitLoop + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次23 + +1316 02C2 0003 RET +1317 02C3 ;----END (Get pipe bit) +1318 02C3 +1319 02C3 +1320 02C3 +1321 02C3 +1322 02C3 Public Control_Read +1323 02C3 Public FIFO0_RD_CHECK +1324 02C3 Public FIFO1_RD_CHECK +1325 02C3 Public FIFO2_RD_CHECK +1326 02C3 Public FIFO3_RD_CHECK +1327 02C3 Public FIFO4_RD_CHECK +1328 02C3 Public FIFO5_RD_CHECK +1329 02C3 Public FIFO0_WR_CHECK +1330 02C3 Public FIFO1_WR_CHECK +1331 02C3 Public FIFO2_WR_CHECK +1332 02C3 Public FIFO3_WR_CHECK +1333 02C3 Public FIFO4_WR_CHECK +1334 02C3 Public FIFO5_WR_CHECK +1335 02C3 Public Read_FIFO0 +1336 02C3 Public Read_FIFO1 +1337 02C3 Public Read_FIFO2 +1338 02C3 Public Read_FIFO3 +1339 02C3 Public Read_FIFO4 +1340 02C3 Public Read_FIFO5 +1341 02C3 Public Write_FIFO0 +1342 02C3 Public Write_FIFO1 +1343 02C3 Public Write_FIFO2 +1344 02C3 Public Write_FIFO3 +1345 02C3 Public Write_FIFO4 +1346 02C3 Public Write_FIFO5 +1347 02C3 Public Send_Hand_Shake +1348 02C3 Public get_descriptor_length +1349 02C3 +1350 02C3 +1351 02C3 +1352 02C3 Public SetAddress +1353 02C3 Public SetConfiguration +1354 02C3 Public SetInterface +1355 02C3 Public GetInterface +1356 02C3 Public GetDescriptor +1357 02C3 Public SetIdle +1358 02C3 Public GetDeviceDescriptor +1359 02C3 Public GetConfigurationDescriptor +1360 02C3 Public GetStringDescriptor +1361 02C3 Public GetStatus +1362 02C3 ;modify for Remote Wakeup +1363 02C3 Public GetStatus_Interface +1364 02C3 ;--------------------------------- +1365 02C3 Public SetFeature +1366 02C3 Public ClearFeature +1367 02C3 Public SetFeature_Endpoint +1368 02C3 Public ClearFeature_Endpoint +1369 02C3 Public GetStatus_Endpoint +1370 02C3 +1371 02C3 Public SetReport +1372 02C3 +1373 02C3 Public Check_Real_Cmd +1374 02C3 +1375 02C3 Public Execute + 文件:FUNCTION.ASM 盛群编译器版本 2.86 页次24 + +1376 02C3 Public SendStall0 +1377 02C3 +1378 02C3 Public GetConfiguration +1379 02C3 +1380 02C3 Public Delay_3us +1381 02C3 +1382 02C3 +1383 02C3 Public SetCur +1384 02C3 Public GetMin +1385 02C3 Public GetMax +1386 02C3 Public GetRes +1387 02C3 Public GetCur +1388 02C3 Public GetPipeBit + + + 0 Errors \ No newline at end of file diff --git a/PRG/FUNCTION.OBJ b/PRG/FUNCTION.OBJ new file mode 100644 index 0000000..057be59 Binary files /dev/null and b/PRG/FUNCTION.OBJ differ diff --git a/PRG/HT82A821R.CV b/PRG/HT82A821R.CV new file mode 100644 index 0000000..68b57b5 Binary files /dev/null and b/PRG/HT82A821R.CV differ diff --git a/PRG/HT82A821R.DBG b/PRG/HT82A821R.DBG new file mode 100644 index 0000000..13a5d6e Binary files /dev/null and b/PRG/HT82A821R.DBG differ diff --git a/PRG/HT82A821R.MAK b/PRG/HT82A821R.MAK new file mode 100644 index 0000000..99270fd --- /dev/null +++ b/PRG/HT82A821R.MAK @@ -0,0 +1,22 @@ +# Generated by HT-IDE3000. DO NOT modify! +E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\DES.OBJ : "E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\DES.ASM" +HASMW32.EXE /NOLOGO @"C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\~ASM17" +E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\FUNCTION.OBJ : "E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\FUNCTION.ASM" +HASMW32.EXE /NOLOGO @"C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\~ASM18" +E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\MACRO.OBJ : "E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\MACRO.ASM" +HASMW32.EXE /NOLOGO @"C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\~ASM19" +E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\MAIN.OBJ : "E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\MAIN.ASM" +HASMW32.EXE /NOLOGO @"C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\~ASM20" +:CheckBreak +E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\HT82A821R.TSK : / +"E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\DES.OBJ" / +"E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\FUNCTION.OBJ" / +"E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\MACRO.OBJ" / +"E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\MAIN.OBJ" +HLINKW32.EXE /NOLOGO @"C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\~LNK21.BAT" +:CheckBreak +HCODGEN32.EXE @"E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\HT82A821R.KKK" +HLOAD32.EXE "E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\HT82A821R.OPT" +:CheckBreak +HLOAD32.EXE "E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\HT82A821R.TSK" +:CheckBreak diff --git a/PRG/HT82A821R.MAP b/PRG/HT82A821R.MAP new file mode 100644 index 0000000..e313ba6 --- /dev/null +++ b/PRG/HT82A821R.MAP @@ -0,0 +1,271 @@ + +盛群连接器 版本7.5 +版权 盛群半导体公司 2002-2003 + +Input Object File: E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\DES.OBJ +Input Object File: E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\FUNCTION.OBJ +Input Object File: E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\MACRO.OBJ +Input Object File: E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\MAIN.OBJ + +Input Library File: C:\HT-IDE3000\LIB\MATH6.LIB + + + Start End Length Class Name + 0000h 0338h 0339h CODE CODE (E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\MAIN.OBJ) + 0339h 05fbh 02c3h CODE OLDMAIN (E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\FUNCTION.OBJ) + 0700h 077fh 0080h CODE DESCRIPT (E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\DES.OBJ) + 0040h 0072h 0033h DATA DATA (E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\MAIN.OBJ) + + + Indepentent Local Sections + + Start End Length Class Name + 0073h 0073h 0000h ILOCAL DELAY (E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\MAIN.OBJ) + + Public Symbols Information + Address Public by Name + 006bh[3] BFLAG_AUDIO_MUTE + 006bh[2] BFLAG_ENUM_READY + 004eh[5] BFLAG_FIFO_LEN0 + 004eh[4] BFLAG_FIFO_READY + 004eh[6] BFLAG_RD_HTABLE + 004eh[3] BFLAG_REAL_CMD + 006bh[1] BFLAG_SCMD + 004eh[1] BFLAG_SETCONFIGURATION_READY + 004eh[2] BFLAG_SETINTERFACE_READY + 006bh[0] BFLAG_SET_ADDRESS + 004eh[7] BFLAG_WAIT_CONTROL_OUT + 006bh[4] BRMTWAKEUP + 006bh[5] B_WAKEUP + 044ah CHECK_REAL_CMD + 04b6h CLEARFEATURE + 04bfh CLEARFEATURE_ENDPOINT + 077dh CONFIG_DESC_LENGTH + 070ah CONFIG_DESC_TABLE + 040ch CONTROL_READ + 0700h CONTROL_READ_TABLE + 0067h DATA_COUNT + 0068h DATA_START + 05edh DELAY_3US + 0700h DEVICE_DESC_TABLE + 0755h END_CONFIG_DESC_TABLE + 0763h END_HID_REPORT_DESC_TABLE + 05e2h EXECUTE + 0339h FIFO0_RD_CHECK + 035dh FIFO0_WR_CHECK + 033fh FIFO1_RD_CHECK + 0363h FIFO1_WR_CHECK + 0345h FIFO2_RD_CHECK + 0369h FIFO2_WR_CHECK + 034bh FIFO3_RD_CHECK + 036fh FIFO3_WR_CHECK + 0351h FIFO4_RD_CHECK + 0375h FIFO4_WR_CHECK + 0357h FIFO5_RD_CHECK + 037bh FIFO5_WR_CHECK + 0065h FIFO_ADDR + 0059h FIFO_OUT1 + 005ah FIFO_OUT2 + 005bh FIFO_OUT3 + 005ch FIFO_OUT4 + 005dh FIFO_OUT5 + 005eh FIFO_OUT6 + 005fh FIFO_OUT7 + 0060h FIFO_OUT8 + 005ah FIFO_REQUEST + 0058h FIFO_SENDLEN + 0057h FIFO_SIZE + 0061h FIFO_TEMP + 0059h FIFO_TYPE + 005eh FIFO_WINDEXH + 005dh FIFO_WINDEXL + 0060h FIFO_WLENGTHH + 005fh FIFO_WLENGTHL + 005ch FIFO_WVALUEH + 005bh FIFO_WVALUEL + 0509h GETCONFIGURATION + 059eh GETCONFIGURATIONDESCRIPTOR + 056eh GETCUR + 04f1h GETDESCRIPTOR + 0598h GETDEVICEDESCRIPTOR + 0475h GETINTERFACE + 054dh GETMAX + 053ch GETMIN + 05f4h GETPIPEBIT + 055eh GETRES + 0484h GETSTATUS + 04a6h GETSTATUS_ENDPOINT + 0496h GETSTATUS_INTERFACE + 05a5h GETSTRINGDESCRIPTOR + 03fch GET_DESCRIPTOR_LENGTH + 074ch HID_DESC + 077fh HID_DESC_LENGTH + 0755h HID_REPORT_DESC_TABLE + 0066h LOOP_COUNTER + 0071h NCMDINDEX1 + 039ah READ_FIFO0 + 039eh READ_FIFO1 + 03a2h READ_FIFO2 + 03a6h READ_FIFO3 + 03aah READ_FIFO4 + 03aeh READ_FIFO5 + 077eh REPORT_DESC_LENGTH + 05e7h SENDSTALL0 + 03c7h SEND_HAND_SHAKE + 0451h SETADDRESS + 0464h SETCONFIGURATION + 052ah SETCUR + 04cch SETFEATURE + 04e5h SETFEATURE_ENDPOINT + 0597h SETIDLE + 046ch SETINTERFACE + 0518h SETREPORT + 011ch STAGEONE + 0765h USBSTRINGDESCRIPTION1 + 076dh USBSTRINGDESCRIPTION2 + 0778h USBSTRINGDESCRIPTION3 + 0763h USBSTRINGLANGUAGEDESCRIPTION + 0064h USB_CONFIGURATION + 010fh USB_EP0_ISR_END + 0062h USB_INTERFACE + 0063h USB_INTERFACE_ALT + 00adh USB_ISR_END + 006fh VOLUMEH_SAVE + 0070h VOLUMEL_SAVE + 03d5h WRITE_FIFO0 + 03d7h WRITE_FIFO1 + 03d9h WRITE_FIFO2 + 03dbh WRITE_FIFO3 + 03ddh WRITE_FIFO4 + 03dfh WRITE_FIFO5 + + Address Public by Value + 0057h FIFO_SIZE + 0058h FIFO_SENDLEN + 0059h FIFO_OUT1 + 0059h FIFO_TYPE + 005ah FIFO_REQUEST + 005ah FIFO_OUT2 + 005bh FIFO_OUT3 + 005bh FIFO_WVALUEL + 005ch FIFO_WVALUEH + 005ch FIFO_OUT4 + 005dh FIFO_OUT5 + 005dh FIFO_WINDEXL + 005eh FIFO_WINDEXH + 005eh FIFO_OUT6 + 005fh FIFO_OUT7 + 005fh FIFO_WLENGTHL + 0060h FIFO_WLENGTHH + 0060h FIFO_OUT8 + 0061h FIFO_TEMP + 0062h USB_INTERFACE + 0063h USB_INTERFACE_ALT + 0064h USB_CONFIGURATION + 0065h FIFO_ADDR + 0066h LOOP_COUNTER + 0067h DATA_COUNT + 0068h DATA_START + 006fh VOLUMEH_SAVE + 0070h VOLUMEL_SAVE + 0071h NCMDINDEX1 + 00adh USB_ISR_END + 010fh USB_EP0_ISR_END + 011ch STAGEONE + 004eh[1] BFLAG_SETCONFIGURATION_READY + 004eh[2] BFLAG_SETINTERFACE_READY + 004eh[3] BFLAG_REAL_CMD + 004eh[4] BFLAG_FIFO_READY + 004eh[5] BFLAG_FIFO_LEN0 + 004eh[6] BFLAG_RD_HTABLE + 004eh[7] BFLAG_WAIT_CONTROL_OUT + 0339h FIFO0_RD_CHECK + 033fh FIFO1_RD_CHECK + 0345h FIFO2_RD_CHECK + 034bh FIFO3_RD_CHECK + 0351h FIFO4_RD_CHECK + 0357h FIFO5_RD_CHECK + 006bh[0] BFLAG_SET_ADDRESS + 006bh[1] BFLAG_SCMD + 006bh[2] BFLAG_ENUM_READY + 006bh[3] BFLAG_AUDIO_MUTE + 006bh[4] BRMTWAKEUP + 035dh FIFO0_WR_CHECK + 006bh[5] B_WAKEUP + 0363h FIFO1_WR_CHECK + 0369h FIFO2_WR_CHECK + 036fh FIFO3_WR_CHECK + 0375h FIFO4_WR_CHECK + 037bh FIFO5_WR_CHECK + 039ah READ_FIFO0 + 039eh READ_FIFO1 + 03a2h READ_FIFO2 + 03a6h READ_FIFO3 + 03aah READ_FIFO4 + 03aeh READ_FIFO5 + 03c7h SEND_HAND_SHAKE + 03d5h WRITE_FIFO0 + 03d7h WRITE_FIFO1 + 03d9h WRITE_FIFO2 + 03dbh WRITE_FIFO3 + 03ddh WRITE_FIFO4 + 03dfh WRITE_FIFO5 + 03fch GET_DESCRIPTOR_LENGTH + 040ch CONTROL_READ + 044ah CHECK_REAL_CMD + 0451h SETADDRESS + 0464h SETCONFIGURATION + 046ch SETINTERFACE + 0475h GETINTERFACE + 0484h GETSTATUS + 0496h GETSTATUS_INTERFACE + 04a6h GETSTATUS_ENDPOINT + 04b6h CLEARFEATURE + 04bfh CLEARFEATURE_ENDPOINT + 04cch SETFEATURE + 04e5h SETFEATURE_ENDPOINT + 04f1h GETDESCRIPTOR + 0509h GETCONFIGURATION + 0518h SETREPORT + 052ah SETCUR + 053ch GETMIN + 054dh GETMAX + 055eh GETRES + 056eh GETCUR + 0597h SETIDLE + 0598h GETDEVICEDESCRIPTOR + 059eh GETCONFIGURATIONDESCRIPTOR + 05a5h GETSTRINGDESCRIPTOR + 05e2h EXECUTE + 05e7h SENDSTALL0 + 05edh DELAY_3US + 05f4h GETPIPEBIT + 0700h CONTROL_READ_TABLE + 0700h DEVICE_DESC_TABLE + 070ah CONFIG_DESC_TABLE + 074ch HID_DESC + 0755h END_CONFIG_DESC_TABLE + 0755h HID_REPORT_DESC_TABLE + 0763h USBSTRINGLANGUAGEDESCRIPTION + 0763h END_HID_REPORT_DESC_TABLE + 0765h USBSTRINGDESCRIPTION1 + 076dh USBSTRINGDESCRIPTION2 + 0778h USBSTRINGDESCRIPTION3 + 077dh CONFIG_DESC_LENGTH + 077eh REPORT_DESC_LENGTH + 077fh HID_DESC_LENGTH + + +ROM Usage Statistics + Size Used Percent + 0800h 067ch 81% + +RAM Usage Statistics + Size Used Percent + 00c0h 0033h 26% + +Call Tree + +HLINK:程序的开始执行点在程序段'CODE'(地址0)。定义在'E:\项目\USB 音频发射\USB Audio(PC)\COD\PRG\MAIN.OBJ' 文件中 + +错误总数:0 警告总数:0 diff --git a/PRG/HT82A821R.OPT b/PRG/HT82A821R.OPT new file mode 100644 index 0000000..a15e199 Binary files /dev/null and b/PRG/HT82A821R.OPT differ diff --git a/PRG/HT82A821R.OTP b/PRG/HT82A821R.OTP new file mode 100644 index 0000000..c304819 Binary files /dev/null and b/PRG/HT82A821R.OTP differ diff --git a/PRG/HT82A821R.PRJ b/PRG/HT82A821R.PRJ new file mode 100644 index 0000000..5fc33f9 Binary files /dev/null and b/PRG/HT82A821R.PRJ differ diff --git a/PRG/HT82A821R.TSK b/PRG/HT82A821R.TSK new file mode 100644 index 0000000..66f58b9 Binary files /dev/null and b/PRG/HT82A821R.TSK differ diff --git a/PRG/HT82A821R.bin b/PRG/HT82A821R.bin new file mode 100644 index 0000000..6e94ebc Binary files /dev/null and b/PRG/HT82A821R.bin differ diff --git a/PRG/HT82A821R.dsw b/PRG/HT82A821R.dsw new file mode 100644 index 0000000..cb01a84 --- /dev/null +++ b/PRG/HT82A821R.dsw @@ -0,0 +1,205 @@ +[BarState-Bar0] +BarID=59392 +XPos=-2 +YPos=-2 +Docking=1 +MRUDockID=59419 +MRUDockLeftPos=-2 +MRUDockTopPos=-2 +MRUDockRightPos=553 +MRUDockBottomPos=30 +MRUFloatStyle=8196 +MRUFloatXPos=-1 +MRUFloatYPos=0 +[BarState-Bar1] +BarID=59393 +[BarState-Bar2] +BarID=59419 +Bars=15 +Bar#0=0 +Bar#1=59392 +Bar#2=0 +Bar#3=65552 +Bar#4=0 +Bar#5=65553 +Bar#6=0 +Bar#7=65555 +Bar#8=0 +Bar#9=65554 +Bar#10=0 +Bar#11=65559 +Bar#12=0 +Bar#13=65551 +Bar#14=0 +[BarState-Bar3] +BarID=59422 +Bars=13 +Bar#0=0 +Bar#1=15 +Bar#2=0 +Bar#3=65552 +Bar#4=0 +Bar#5=65553 +Bar#6=0 +Bar#7=65555 +Bar#8=0 +Bar#9=65554 +Bar#10=0 +Bar#11=124928 +Bar#12=0 +[BarState-Bar4] +BarID=59420 +Bars=14 +Bar#0=0 +Bar#1=65553 +Bar#2=65552 +Bar#3=0 +Bar#4=124928 +Bar#5=0 +Bar#6=65551 +Bar#7=0 +Bar#8=65555 +Bar#9=0 +Bar#10=65554 +Bar#11=0 +Bar#12=65559 +Bar#13=0 +[BarState-Bar5] +BarID=59421 +Bars=15 +Bar#0=0 +Bar#1=19 +Bar#2=0 +Bar#3=16 +Bar#4=0 +Bar#5=17 +Bar#6=0 +Bar#7=18 +Bar#8=0 +Bar#9=23 +Bar#10=0 +Bar#11=65551 +Bar#12=0 +Bar#13=124928 +Bar#14=0 +[BarState-Bar6] +BarID=19 +Visible=0 +XPos=-3 +YPos=-2 +Docking=1 +MRUDockID=0 +MRUDockLeftPos=-3 +MRUDockTopPos=-2 +MRUDockRightPos=97 +MRUDockBottomPos=525 +MRUFloatStyle=8196 +MRUFloatXPos=-1 +MRUFloatYPos=1008 +[BarState-Bar7] +BarID=16 +XPos=-2 +YPos=-2 +Docking=1 +MRUDockID=0 +MRUDockLeftPos=-2 +MRUDockTopPos=-2 +MRUDockRightPos=191 +MRUDockBottomPos=923 +MRUFloatStyle=8196 +MRUFloatXPos=-1 +MRUFloatYPos=-1 +[BarState-Bar8] +BarID=17 +XPos=189 +YPos=-2 +Docking=1 +MRUDockID=59421 +MRUDockLeftPos=189 +MRUDockTopPos=-2 +MRUDockRightPos=383 +MRUDockBottomPos=923 +MRUFloatStyle=8196 +MRUFloatXPos=-1 +MRUFloatYPos=1008 +[BarState-Bar9] +BarID=18 +Visible=0 +XPos=727 +YPos=-2 +Docking=1 +MRUDockID=0 +MRUDockLeftPos=727 +MRUDockTopPos=-2 +MRUDockRightPos=944 +MRUDockBottomPos=775 +MRUFloatStyle=8196 +MRUFloatXPos=-1 +MRUFloatYPos=1008 +[BarState-Bar10] +BarID=15 +Visible=0 +XPos=-2 +YPos=-2 +Docking=1 +MRUDockID=0 +MRUDockLeftPos=0 +MRUDockTopPos=0 +MRUDockRightPos=0 +MRUDockBottomPos=0 +MRUFloatStyle=8196 +MRUFloatXPos=-2147483648 +MRUFloatYPos=0 +[BarState-Bar11] +BarID=23 +Visible=0 +XPos=-2 +YPos=-2 +Docking=1 +MRUDockID=0 +MRUDockLeftPos=-2 +MRUDockTopPos=-2 +MRUDockRightPos=98 +MRUDockBottomPos=923 +MRUFloatStyle=8196 +MRUFloatXPos=-2147483648 +MRUFloatYPos=0 +[BarState-Summary] +Bars=10 +ScreenCX=1680 +ScreenCY=1050 +[SizingBarState-SCBar-19] +sizeHorzCX=100 +sizeHorzCY=150 +sizeVertCX=100 +sizeVertCY=527 +sizeFloatCX=100 +sizeFloatCY=150 +[SizingBarState-SCBar-16] +sizeHorzCX=100 +sizeHorzCY=150 +sizeVertCX=193 +sizeVertCY=925 +sizeFloatCX=100 +sizeFloatCY=150 +[SizingBarState-SCBar-17] +sizeHorzCX=100 +sizeHorzCY=150 +sizeVertCX=194 +sizeVertCY=925 +sizeFloatCX=100 +sizeFloatCY=150 +[SizingBarState-SCBar-18] +sizeHorzCX=100 +sizeHorzCY=150 +sizeVertCX=217 +sizeVertCY=777 +sizeFloatCX=100 +sizeFloatCY=150 +[SizingBarState-SCBar-15] +sizeHorzCX=1684 +sizeHorzCY=150 +sizeVertCX=100 +sizeVertCY=150 +sizeFloatCX=100 +sizeFloatCY=150 diff --git a/PRG/MACRO.LST b/PRG/MACRO.LST new file mode 100644 index 0000000..75f5a3a --- /dev/null +++ b/PRG/MACRO.LST @@ -0,0 +1,404 @@ +文件:MACRO.ASM 盛群编译器版本 2.86 页次1 + + + 1 0000 ;******************************************************************************* + 2 0000 ;* + 3 0000 ;* (c) Copyright 2004, Holtek Semiconductor Inc. + 4 0000 ;* + 5 0000 ;******************************************************************************/ + 6 0000 ;******************************************************************************* + 7 0000 ;MODULE: main.asm + 8 0000 + 9 0000 ;INITIAL: 11/12/2004 + 10 0000 + 11 0000 ;AUTHOR: C351 Ansonku. + 12 0000 + 13 0000 ;NOTE: HT48RB4 16 bit operation + 14 0000 + 15 0000 ;REVISION: First issue + 16 0000 ;******************************************************************************* + 17 0000 ;******************************************************************************* + 18 0000 ; 16 bit ADD with signed + 19 0000 ; use ADD16 XH,XL,YH,YL,ZH,ZL + 20 0000 ; operation + 21 0000 ; XH XL + 22 0000 ; +YH YL + 23 0000 ; -------------- + 24 0000 ; ZH ZL + 25 0000 ;******************************************************************************* + 26 0000 ADD16 MACRO XH,XL,YH,YL,ZH,ZL + 27 0000 MOV A,XL + 28 0000 ADD A,YL + 29 0000 MOV ZL,A + 30 0000 MOV A,XH + 31 0000 ADC A,YH + 32 0000 MOV ZH,A + 33 0000 ENDM + 34 0000 ;******************************************************************************* + 35 0000 ; 16 bit ADD with unsigned + 36 0000 ; use ADD16 XH,XL,YL,ZH,ZL + 37 0000 ; operation + 38 0000 ; XH XL + 39 0000 ; + YL + 40 0000 ; -------------- + 41 0000 ; ZH ZL + 42 0000 ;******************************************************************************* + 43 0000 ADD16U MACRO XH,XL,YL,ZH,ZL + 44 0000 mov a,xh + 45 0000 mov zh,a + 46 0000 MOV A,XL + 47 0000 ADD A,YL + 48 0000 SZ C + 49 0000 INC ZH + 50 0000 MOV ZL,A + 51 0000 ENDM + 52 0000 + 53 0000 + 54 0000 ;******************************************************************************* + 55 0000 ; 16 bit sub with signed + 56 0000 ; use SUB16 XH,XL,YH,YL,ZH,ZL + 57 0000 ; operation + 58 0000 ; XH XL + 59 0000 ; -YH YL + 文件:MACRO.ASM 盛群编译器版本 2.86 页次2 + + 60 0000 ; -------------- + 61 0000 ; ZH ZL + 62 0000 ;******************************************************************************* + 63 0000 SUB16 MACRO XH,XL,YH,YL,ZH,ZL + 64 0000 MOV A,XL + 65 0000 CLR C + 66 0000 SUB A,YL + 67 0000 MOV ZL,A + 68 0000 MOV A,XH + 69 0000 SBC A,YH + 70 0000 MOV ZH,A + 71 0000 + 72 0000 ENDM + 73 0000 + 74 0000 + 75 0000 ;******************************************************************************* + 76 0000 ; 16 bit shift right with signed + 77 0000 ; use RR16 XH,XL,ZH,ZL + 78 0000 ; operation + 79 0000 ;******************************************************************************* + 80 0000 RR16 MACRO XH,XL,ZH,ZL + 81 0000 CLR C + 82 0000 MOV A,XH + 83 0000 AND A,80H + 84 0000 SNZ Z + 85 0000 SET C + 86 0000 RRCA XH + 87 0000 MOV ZH,A + 88 0000 RRCA XL + 89 0000 MOV ZL,A + 90 0000 ENDM + 91 0000 ;******************************************************************************* + 92 0000 ; 16 bit shift left with signed + 93 0000 ; use RL16 XH,XL,ZH,ZL + 94 0000 ; operation + 95 0000 ;******************************************************************************* + 96 0000 RL16 MACRO XH,XL,ZH,ZL + 97 0000 CLR C + 98 0000 SZ XL.7 + 99 0000 SET C + 100 0000 + 101 0000 RLCA XH + 102 0000 MOV ZH,A + 103 0000 CLR C + 104 0000 RLCA XL + 105 0000 MOV ZL,A + 106 0000 ENDM + 107 0000 ;******************************************************************************* + 108 0000 ; 16 bit shift left with signed + 109 0000 ; use RL16N XH,XL,ZH,ZL + 110 0000 ; operation + 111 0000 ;******************************************************************************* + 112 0000 RL16N MACRO XH,XL,ZH,ZL,N + 113 0000 ;MOV A,8 + 114 0000 ;SUB A,N + 115 0000 ;mov a,Xl SHR A + 116 0000 ;mov zh,a + 117 0000 ;mov a,xh SHL N + 118 0000 ;orm a,zh + 119 0000 ENDM + 文件:MACRO.ASM 盛群编译器版本 2.86 页次3 + + 120 0000 ;******************************************************************************* + 121 0000 ; 8 bit multiply with signed + 122 0000 ; use mul8 X,Y,ZH,ZL + 123 0000 ; operation + 124 0000 ;******************************************************************************* + 125 0000 Mul8 MACRO X,Y,ZH,ZL + 126 0000 Local Mul8_End + 127 0000 CLR operator1H ;sum + 128 0000 CLR operator1L + 129 0000 CLR operator2H ;multiply + 130 0000 CLR operator3H ;operator + 131 0000 CLR operator3L + 132 0000 mov A,Y + 133 0000 mov operator2L,A + 134 0000 + 135 0000 SZ X.7 + 136 0000 SET operator2H + 137 0000 Mul16_doloop: + 138 0000 MOV A,6 + 139 0000 MOV Counter3,A + 140 0000 SDZ Counter3 + 141 0000 JMP Mul8_End + 142 0000 SNZ X.Counter3 + 143 0000 jmp Mul18_Next_Bit + 144 0000 RL16 operator2H,operator2L,operator3H,operator3L + 145 0000 ADD16 operator3H,operator3L,operator1H,operaotr1L,operator1H,operator1L + 146 0000 + 147 0000 + 148 0000 Mul18_Next_Bit: + 149 0000 JMP Mul16_doloop + 150 0000 + 151 0000 + 152 0000 Mul8_End: + 153 0000 + 154 0000 + 155 0000 ENDM + 156 0000 + 157 0000 ;******************************************************************************* + 158 0000 ; 8 bit macro + 159 0000 ;******************************************************************************* + 160 0000 ;******************************************************************************* + 161 0000 ; 16 bit ADD with signed + 162 0000 ; use ADD16 X,Y,Z + 163 0000 ; operation + 164 0000 ; X + 165 0000 ; +Y + 166 0000 ; -------------- + 167 0000 ; Z + 168 0000 ;******************************************************************************* + 169 0000 ADD8 MACRO X1,Y1,Z1 + 170 0000 MOV A,X1 + 171 0000 ADD A,Y1 + 172 0000 MOV Z1,A + 173 0000 ENDM + 174 0000 + 175 0000 ;******************************************************************************* + 176 0000 ; 16 bit sub with signed + 177 0000 ; use SUB16 X,Y,Z + 178 0000 ; operation + 179 0000 ; X + 文件:MACRO.ASM 盛群编译器版本 2.86 页次4 + + 180 0000 ; -Y + 181 0000 ; -------------- + 182 0000 ; Z + 183 0000 ;******************************************************************************* + 184 0000 SUB8 MACRO X1,Y1,Z1 + 185 0000 MOV A,X1 + 186 0000 SUB A,Y1 + 187 0000 MOV Z1,A + 188 0000 ENDM + 189 0000 + 190 0000 ;******************************************************************************* + 191 0000 ; 8 bit shift right with signed + 192 0000 ; use RR8 X,Z + 193 0000 ; operation + 194 0000 ;******************************************************************************* + 195 0000 RR8 MACRO X,Y + 196 0000 Local RR8_End,RR8_Modify_FF,RR8_Modify_FF_End + 197 0000 mov a,X + 198 0000 inc acc + 199 0000 SZ Z + 200 0000 jmp RR8_Modify_FF + 201 0000 jmp RR8_Modify_FF_End + 202 0000 RR8_Modify_FF: + 203 0000 clr Y + 204 0000 jmp RR8_End + 205 0000 + 206 0000 RR8_Modify_FF_End: + 207 0000 CLR C + 208 0000 MOV A,X + 209 0000 AND A,80H + 210 0000 SNZ Z + 211 0000 SET C + 212 0000 RRCA X + 213 0000 MOV Y,A + 214 0000 + 215 0000 + 216 0000 + 217 0000 RR8_End: + 218 0000 ENDM + 219 0000 ;******************************************************************************* + 220 0000 ; 8 bit shift left with signed + 221 0000 ; use RL16 X,Z + 222 0000 ; operation + 223 0000 ;******************************************************************************* + 224 0000 RL8 MACRO X,Y + 225 0000 CLR C + 226 0000 RLCA X + 227 0000 MOV Y,A + 228 0000 ENDM + 229 0000 + 230 0000 ;******************************************************************************* + 231 0000 ; 8 bit abs + 232 0000 ; use ABS8 X,Y + 233 0000 ; operation + 234 0000 ;******************************************************************************* + 235 0000 ABS8 MACRO X,Y + 236 0000 Local ABS8_End + 237 0000 + 238 0000 kmov y,x + 239 0000 mov a,x + 文件:MACRO.ASM 盛群编译器版本 2.86 页次5 + + 240 0000 and a,80H + 241 0000 SZ Z + 242 0000 jmp ABS8_End + 243 0000 CPL y + 244 0000 INC y + 245 0000 + 246 0000 ABS8_End: + 247 0000 + 248 0000 ENDM + 249 0000 + 250 0000 + 251 0000 + 252 0000 + 253 0000 + 254 0000 + 255 0000 ;******************************************************************************* + 256 0000 ; kmov + 257 0000 ; use kmov destination,source + 258 0000 ; operation + 259 0000 ;******************************************************************************* + 260 0000 KMOV MACRO mem1,mem2 + 261 0000 mov a,mem2 + 262 0000 mov mem1,a + 263 0000 ENDM + 264 0000 + 265 0000 KOR MACRO mem1,mem2 + 266 0000 mov a,mem2 + 267 0000 orm a,mem1 + 268 0000 ENDM + 269 0000 + 270 0000 + 271 0000 + 272 0000 ;******************************************************************************* + 273 0000 ; make oled column address + 274 0000 ; use oled_make_col_add source,MSB,LSB + 275 0000 ; + 276 0000 ;******************************************************************************* + 277 0000 oled_make_col_add macro mem1,mem2,mem3 + 278 0000 mov a,0FH + 279 0000 AND a,mem1 + 280 0000 mov mem3,a + 281 0000 mov a,70H + 282 0000 and a,mem1 + 283 0000 mov mem2,a + 284 0000 clr c + 285 0000 rrc mem2 + 286 0000 clr c + 287 0000 rrc mem2 + 288 0000 clr c + 289 0000 rrc mem2 + 290 0000 clr c + 291 0000 rrc mem2 + 292 0000 set mem2.4 + 293 0000 + 294 0000 endm + 295 0000 + 296 0000 + 297 0000 + 298 0000 ;*************************************** + 299 0000 + 文件:MACRO.ASM 盛群编译器版本 2.86 页次6 + + 300 0000 XMOV MACRO mem2,mem1 + 301 0000 mov a,mem1 + 302 0000 mov mem2,a + 303 0000 ENDM + 304 0000 ;------------------------------------- + 305 0000 ;;Move ARG2->ARG1(move by bit) + 306 0000 xmov1 MACRO ARG1,ARG2 + 307 0000 LOCAL xmov1_1,xmov1_end + 308 0000 sz ARG2 + 309 0000 jmp xmov1_1 + 310 0000 clr ARG1 + 311 0000 jmp xmov1_end + 312 0000 xmov1_1: + 313 0000 set ARG1 + 314 0000 xmov1_end: + 315 0000 ENDM + 316 0000 ;------------------------------------- + 317 0000 ;;if MEM2=MEM1 =>Skip Next Instruction + 318 0000 EQUJMP MACRO MEM2,MEM1 + 319 0000 MOV A,MEM1 + 320 0000 XOR A,MEM2 + 321 0000 SNZ Z + 322 0000 ENDM + 323 0000 ;;------------------------ + 324 0000 + 325 0000 ;;if MEM2!=MEM1 =>Skip Next Instruction + 326 0000 NEJMP MACRO MEM2,MEM1 + 327 0000 MOV A,MEM1 + 328 0000 XOR A,MEM2 + 329 0000 SZ Z + 330 0000 ENDM + 331 0000 ;;------------------------ + 332 0000 ;;if (REG1==REG2) goto REG3 + 333 0000 JLER MACRO REG1,REG2,REG3 + 334 0000 mov a,REG1 + 335 0000 sub a,REG2 + 336 0000 sz z + 337 0000 jmp REG3 + 338 0000 ENDM + 339 0000 ;********************************************** + 340 0000 ;MACRO: JLNR + 341 0000 ;PURPOSE: REG1 != REG2 goto REG3 + 342 0000 ;********************************************** + 343 0000 JLNR MACRO REG1,REG2,REG3 + 344 0000 mov a,REG1 + 345 0000 sub a,REG2 + 346 0000 snz z + 347 0000 jmp REG3 + 348 0000 ENDM + 349 0000 ;;------------------------ + 350 0000 ;;if MEM2>MEM1 =>Skip Next Instruction + 351 0000 LBRJ MACRO MEM2,MEM1 + 352 0000 MOV A,MEM1 + 353 0000 SUB A,MEM2 + 354 0000 SZ C + 355 0000 ENDM + 356 0000 ;;------------------------ + 357 0000 + 358 0000 ;;if MEM2<=MEM1 =>Skip Next Instruction + 359 0000 LSERJ MACRO MEM2,MEM1 + 文件:MACRO.ASM 盛群编译器版本 2.86 页次7 + + 360 0000 MOV A,MEM1 + 361 0000 SUB A,MEM2 + 362 0000 SNZ C + 363 0000 ENDM + 364 0000 ;;------------------------ + 365 0000 + 366 0000 ;;if MEM2Skip Next Instruction + 367 0000 LSRJ MACRO MEM2,MEM1 + 368 0000 MOV A,MEM2 + 369 0000 SUB A,MEM1 + 370 0000 SZ C + 371 0000 ENDM + 372 0000 ;;------------------------ + 373 0000 + 374 0000 ;;if MEM2>=MEM1 =>Skip Next Instruction + 375 0000 LBERJ MACRO MEM2,MEM1 + 376 0000 MOV A,MEM2 + 377 0000 SUB A,MEM1 + 378 0000 SNZ C + 379 0000 ENDM + 380 0000 ;;------------------------ + 381 0000 + 382 0000 SWAPWORD MACRO DA + 383 0000 EQU (DA>>8)+(DA<<8) + 384 0000 ENDM + 385 0000 ;;------------------------ + 386 0000 + + + 0 Errors \ No newline at end of file diff --git a/PRG/MACRO.OBJ b/PRG/MACRO.OBJ new file mode 100644 index 0000000..8022665 Binary files /dev/null and b/PRG/MACRO.OBJ differ diff --git a/PRG/MAIN.LST b/PRG/MAIN.LST new file mode 100644 index 0000000..4337835 --- /dev/null +++ b/PRG/MAIN.LST @@ -0,0 +1,1885 @@ +文件:MAIN.ASM 盛群编译器版本 2.86 页次1 + + + 1 0000 ;******************************************************************************* + 2 0000 ;* + 3 0000 ;* (c) Copyright 2005, Holtek Semiconductor Inc. + 4 0000 ;* + 5 0000 ;******************************************************************************/ + 6 0000 ;******************************************************************************* + 7 0000 ;MODULE: main.asm + 8 0000 + 9 0000 ;INITIAL: 09/14/2006 + 10 0000 + 11 0000 ;AUTHOR: C351 Ansonku. + 12 0000 + 13 0000 ;NOTE: HT82A821R , HT82A822R Main Function + 14 0000 + 15 0000 ;VERSION: 1.2 + 16 0000 ;Function: + 17 0000 ;key debounced N + 18 0000 ;oled N + 19 0000 ;volume adjust Y + 20 0000 ;2005/05/13 Update Key Debounce + 21 0000 ;2005/05/25 Modify Pop noise + 22 0000 ;2005/06/06 Modify Send_Hand_Shake + 23 0000 ;2005/06/10 耞 token ,安砞笿setup scmd,璶弄8 bytes睲埃scmd籔len0 + 24 0000 ;2005/12/20 USB 瑈祘эノ jmp よΑ implement + 25 0000 ;2005/12/20 盢 suspend 耞э main function い + 26 0000 ;******************************************************************************* + 27 0000 + 28 0000 ;*************************************************************** + 29 0000 ;Include File + 30 0000 ;ht82a822.inc ht82a822r register address defined + 31 0000 ;const.inc user defined + 32 0000 ;macro.asm macro function + 33 0000 ;*************************************************************** + 34 0000 #include ht82a821r.inc + + + 35 0000 #include const.inc + + + 36 0000 #include macro.asm + + + 37 0000 + 38 0000 #define WaitBias 0 + 39 0000 + 40 0000 ;==================================================================== + 41 0000 ;Variable Defined , DATA 眖 40H 秨﹍ + 42 0000 ;==================================================================== + 43 0000 DATA .SECTION AT 40H 'DATA' + 44 0000 #include memory.inc + + + 45 000F ;*************************************************************** + 46 000F ; USB ISR Var (い耞称ノ) + 47 000F ;*************************************************************** + 48 000F 00 isr_usb_acc DB ? + 49 0010 00 isr_usb_status DB ? + 50 0011 00 isr_usb_mp1 DB ? + 51 0012 00 isr_usb_mp0 DB ? + 文件:MAIN.ASM 盛群编译器版本 2.86 页次2 + + 52 0013 00 isr_usb_tblp DB ? + 53 0014 ;*************************************************************** + 54 0014 ; Timer0 ISR Var (い耞称ノ) + 55 0014 ;*************************************************************** + 56 0014 ;;isr_tmr0_acc DB ? + 57 0014 ;;isr_tmr0_status DB ? + 58 0014 ;;isr_tmr0_mp1 DB ? + 59 0014 ;;isr_tmr0_mp0 DB ? + 60 0014 ;;isr_tmr0_tblp DB ? + 61 0014 ;*************************************************************** + 62 0014 ; Timer1 ISR Var (い耞称ノ) + 63 0014 ;*************************************************************** + 64 0014 ;;isr_tmr1_acc DB ? + 65 0014 ;;isr_tmr1_status DB ? + 66 0014 ;;isr_tmr1_mp1 DB ? + 67 0014 ;;isr_tmr1_mp0 DB ? + 68 0014 ;;isr_tmr1_tblp DB ? + 69 0014 + 70 0014 ;*************************************************************** + 71 0014 ; Delay 跑计 + 72 0014 ;*************************************************************** + 73 0014 00 Delay_1 DB ? + 74 0015 00 Delay_2 DB ? + 75 0016 00 Delay_3 DB ? + 76 0017 + 77 0017 ;*************************************************************** + 78 0017 ;USB FIFO Variable + 79 0017 ;USB_Interface : to save usb current interface number + 80 0017 ;USB_Interface_Alt : to save usb current alternate of interface number + 81 0017 ;USB_Configuration : to save USB configuration number + 82 0017 ;FIFO_ADDR : to save USB ADDRESS + 83 0017 ;Loop_Counter , Data_Count , Data_Start : control_read variable + 84 0017 ;*************************************************************** + 85 0017 ;For FIFO Access + 86 0017 00 FIFO_SIZE db ? + 87 0018 00 FIFO_SendLen db ? + 88 0019 FIFO_out1 label byte + 89 0019 00 FIFO_Type db ? + 90 001A FIFO_out2 label byte + 91 001A 00 FIFO_Request db ? + 92 001B FIFO_out3 label byte + 93 001B 00 FIFO_wValueL db ? + 94 001C FIFO_out4 label byte + 95 001C 00 FIFO_wValueH db ? + 96 001D FIFO_out5 label byte + 97 001D 00 FIFO_wIndexL db ? + 98 001E FIFO_out6 label byte + 99 001E 00 FIFO_wIndexH db ? + 100 001F FIFO_out7 label byte + 101 001F 00 FIFO_wLengthL db ? + 102 0020 FIFO_out8 label byte + 103 0020 00 FIFO_wLengthH db ? + 104 0021 + 105 0021 00 FIFO_TEMP db ? + 106 0022 ;************************************************************** + 107 0022 ;USB 篈既 + 108 0022 ; + 109 0022 ; + 110 0022 ;************************************************************** + 111 0022 00 USB_Interface db ? + 文件:MAIN.ASM 盛群编译器版本 2.86 页次3 + + 112 0023 00 USB_Interface_Alt db ? + 113 0024 00 USB_Configuration db ? + 114 0025 ;//save usb address + 115 0025 00 FIFO_ADDR db ? + 116 0026 + 117 0026 00 Loop_Counter db ? + 118 0027 00 Data_Count db ? + 119 0028 00 Data_Start db ? + 120 0029 + 121 0029 ;voice control + 122 0029 00 INC_Counter db ? + 123 002A 00 DEC_Counter db ? + 124 002B + 125 002B + 126 002B ;FIFO + 127 000E bFlag_SetConfiguration_Ready dbit + 128 000E bFlag_SetInterface_Ready dbit + 129 000E bFlag_Real_Cmd dbit + 130 000E bFlag_FIFO_Ready dbit + 131 000E bFlag_FIFO_LEN0 dbit + 132 000E bFlag_RD_HTable dbit + 133 000E bFlag_wait_control_out dbit + 134 002B 00 bFlag_SET_ADDRESS dbit + 135 002B bFlag_SCMD dbit + 136 002B bFlag_Enum_Ready dbit + 137 002C ;Audio + 138 002C 00 PortC_data db ? + 139 002B bFlag_Audio_Mute dbit + 140 002D 00 Volume1 db ? + 141 002E 00 Volume2 db ? + 142 002F + 143 002F ;Mute_Save db ? + 144 002F 00 VolumeH_Save db ? + 145 0030 00 VolumeL_Save db ? + 146 0031 + 147 0031 00 nCmdIndex1 db ? + 148 0032 + 149 0032 + 150 0032 ;************************************************************** + 151 0032 ;Key 篈既 + 152 0032 ; + 153 0032 ; + 154 0032 ;************************************************************** + 155 0032 + 156 0032 ;;Key_Process db ? + 157 0032 ;;Key_CheckIn db ? + 158 0032 ;;Key_Counter db ? + 159 0032 ;;Key_Temp db ? + 160 0032 ;;Key_IncCounter db ? + 161 0032 ;;Key_DecCounter db ? + 162 0032 + 163 0032 ;modify for Remote Wakeup + 164 002B bRmtWakeup dbit + 165 002B b_wakeup dbit + 166 0032 ;modify 2007-06-27 + 167 002B b_forceresumeWakeup dbit + 168 0032 ;modify 2007-07-03 + 169 002B b_forusbRst dbit + 170 0032 00 bFlagTMR1 dbit + 171 0033 + 文件:MAIN.ASM 盛群编译器版本 2.86 页次4 + + 172 0033 ;;*********************************************** + 173 0033 + 174 0033 extern control_read_table:NEAR + 175 0033 extern device_desc_table:NEAR + 176 0033 extern config_desc_table:NEAR + 177 0033 + 178 0033 extern end_config_desc_table:NEAR + 179 0033 extern hid_report_desc_table:NEAR + 180 0033 extern end_hid_report_desc_table:NEAR + 181 0033 + 182 0033 extern USBStringLanguageDescription:NEAR + 183 0033 extern USBStringDescription1:NEAR + 184 0033 extern USBStringDescription2:NEAR + 185 0033 + 186 0033 extern config_desc_length:NEAR + 187 0033 extern report_desc_length:NEAR + 188 0033 ;function + 189 0033 extern Control_Read:NEAR + 190 0033 extern FIFO0_RD_CHECK:NEAR + 191 0033 extern FIFO1_RD_CHECK:NEAR + 192 0033 extern FIFO2_RD_CHECK:NEAR + 193 0033 extern FIFO3_RD_CHECK:NEAR + 194 0033 extern FIFO4_RD_CHECK:NEAR + 195 0033 extern FIFO5_RD_CHECK:NEAR + 196 0033 extern FIFO0_WR_CHECK:NEAR + 197 0033 extern FIFO1_WR_CHECK:NEAR + 198 0033 extern FIFO2_WR_CHECK:NEAR + 199 0033 extern FIFO3_WR_CHECK:NEAR + 200 0033 extern FIFO4_WR_CHECK:NEAR + 201 0033 extern FIFO5_WR_CHECK:NEAR + 202 0033 extern Read_FIFO0:NEAR + 203 0033 extern Read_FIFO1:NEAR + 204 0033 extern Read_FIFO2:NEAR + 205 0033 extern Read_FIFO3:NEAR + 206 0033 extern Read_FIFO4:NEAR + 207 0033 extern Read_FIFO5:NEAR + 208 0033 extern Write_FIFO0:NEAR + 209 0033 extern Write_FIFO1:NEAR + 210 0033 extern Write_FIFO2:NEAR + 211 0033 extern Write_FIFO3:NEAR + 212 0033 extern Write_FIFO4:NEAR + 213 0033 extern Write_FIFO5:NEAR + 214 0033 extern Send_Hand_Shake:NEAR + 215 0033 extern get_descriptor_length:NEAR + 216 0033 + 217 0033 extern SetAddress:NEAR + 218 0033 extern SetConfiguration:NEAR + 219 0033 extern SetInterface:NEAR + 220 0033 extern GetInterface:NEAR + 221 0033 extern GetDescriptor:NEAR + 222 0033 extern SetIdle:NEAR + 223 0033 extern GetDeviceDescriptor:NEAR + 224 0033 extern GetConfigurationDescriptor:NEAR + 225 0033 extern GetStringDescriptor:NEAR + 226 0033 extern GetStatus:NEAR + 227 0033 ;modify for Remote Wakeup + 228 0033 extern GetStatus_Interface:NEAR + 229 0033 ;---------------------------------------------- + 230 0033 extern SetFeature:NEAR + 231 0033 extern ClearFeature:NEAR + 文件:MAIN.ASM 盛群编译器版本 2.86 页次5 + + 232 0033 extern SetReport:NEAR + 233 0033 extern Execute:NEAR + 234 0033 extern SendStall0:NEAR + 235 0033 extern Delay_3us:NEAR + 236 0033 + 237 0033 extern SetFeature_Endpoint:NEAR + 238 0033 extern ClearFeature_Endpoint:NEAR + 239 0033 extern GetStatus_Endpoint:NEAR + 240 0033 + 241 0033 extern Check_Real_Cmd:NEAR + 242 0033 extern GetConfiguration:NEAR + 243 0033 + 244 0033 + 245 0033 ;audio + 246 0033 extern SetCur:NEAR + 247 0033 extern GetMin:NEAR + 248 0033 extern GetMax:NEAR + 249 0033 extern GetRes:NEAR + 250 0033 extern GetCur:NEAR + 251 0033 + 252 0033 extern GetPipeBit:NEAR + 253 0033 ;*************************************************************** + 254 0033 ; MCU Interrupt Table + 255 0033 ;*************************************************************** + 256 0033 + 257 0033 + 258 0000 CODE .section AT 00H 'code' + 259 0000 ORG 00H + 260 0000 2820 jmp Start + 261 0001 ORG 04H + 262 0004 289D jmp USB_ISR + 263 0005 ORG 08H + 264 0008 2898 jmp Timer_0_ISR + 265 0009 ORG 0CH + 266 000C 2899 jmp Timer_1_ISR + 267 000D + 268 000D + 269 000D ;----------------------------------------------------------- + 270 000D ; Start : ORG 20H 磷秨玡 interrupt + 271 000D ;----------------------------------------------------------- + 272 000D ORG 20H + 273 0020 Start: + 274 0020 + 275 0020 2052 call System_Initial + 276 0021 + 277 0021 ;----------------------------------------------------------- + 278 0021 ; Main LOOP Function : + 279 0021 ;----------------------------------------------------------- + 280 0021 Main: + 281 0021 ;----------------------------------------------------------- + 282 0021 ; Check Suspend Function : + 283 0021 ; 材Ω浪琩 suspend 莱璶 delay 1 S 浪琩Ω , 狦 suspend 癟腹临秈 halt + 284 0021 ; 叫浪琩 timer 琌Τ秨币 , 璝Τ莱既闽超 ,  resume 秨币 + 285 0021 ;----------------------------------------------------------- + 286 0021 3820 SNZ USC.@USC_SUSP ;check SUSPEND ? + 287 0022 2841 JMP Main_My_Function + 288 0023 + 289 0023 2205 call wait_about_1s + 290 0024 3820 SNZ USC.@USC_SUSP + 291 0025 2841 JMP Main_My_Function + 文件:MAIN.ASM 盛群编译器版本 2.86 页次6 + + 292 0026 + 293 0026 ToSuspend_again: + 294 0026 0001 clr wdt + 295 0027 ;; clr TMR1C.4 + 296 0027 3414 clr USB_LED_ON + 297 0028 35A2 clr UCC.@UCC_USBCKEN + 298 0029 376B clr b_forceresumeWakeup + 299 002A ;clr b_forusbRst + 300 002A ;----------------------------------------------------------- + 301 002A ; Resume Function : + 302 002A ;  function 璶р halt ぇ玡 timer 篈確 , 秨币 USBCKEN + 303 002A ;----------------------------------------------------------- + 304 002A 0002 HALT + 305 002B ;; set TMR1C.4 + 306 002B 3014 set USB_LED_ON + 307 002C 31A2 set UCC.@UCC_USBCKEN + 308 002D + 309 002D ;modify 2007-06-28 + 310 002D 3023 set AWR.@AWR_WKEN + 311 002E + 312 002E ;sZ b_forusbRst + 313 002E ;JMP Start + 314 002E + 315 002E 3F6B sz b_forceresumeWakeup + 316 002F 2836 jmp RemoteWakeup + 317 0030 + 318 0030 3AEB snz b_wakeup + 319 0031 2835 jmp RemoteWakeup_loop + 320 0032 ;clr b_wakeup + 321 0032 3A6B snz bRmtWakeup ; 浪琩USB device琌Enable RemoteWakeup + 322 0033 2826 jmp ToSuspend_again ; 璝bRmtWakeup=0,玥suspend + 323 0034 366B clr bRmtWakeup + 324 0035 + 325 0035 ;modify for Remote Wakeup + 326 0035 RemoteWakeup_loop: + 327 0035 36EB clr b_wakeup + 328 0036 + 329 0036 + 330 0036 ;sz b_forceresumeWakeup + 331 0036 ;jmp RemoteWakeup + 332 0036 + 333 0036 ;sz USC.@USC_SUSP ; + 334 0036 ;jmp ToSuspend_again ; + 335 0036 ;JMP Main + 336 0036 + 337 0036 RemoteWakeup: + 338 0036 ;modify 2007-06-27 + 339 0036 376B clr b_forceresumeWakeup + 340 0037 30A0 SET USC.@USC_RMWK ; USC.RMWK=1 + 341 0038 0000 nop + 342 0039 0000 nop + 343 003A 0000 nop + 344 003B 0000 nop + 345 003C 0000 nop + 346 003D 0000 nop + 347 003E 34A0 CLR USC.@USC_RMWK ; USC.RMWK=0 + 348 003F ;clr AWR.@AWR_WKEN + 349 003F ;sZ b_forusbRst + 350 003F ;JMP Start + 351 003F + 文件:MAIN.ASM 盛群编译器版本 2.86 页次7 + + 352 003F 3C20 SZ USC.@USC_SUSP ;check SUSPEND ? + 353 0040 2821 JMP Main + 354 0041 + 355 0041 ;----------------------------------------------------- + 356 0041 Main_My_Function: + 357 0041 0001 CLR WDT + 358 0042 38CE SNZ bFlag_SetConfiguration_Ready + 359 0043 2821 JMP main ;;USB Not OK + 360 0044 + 361 0044 ;---------------------------------------------------- + 362 0044 3C4E SZ bIniFMOK + 363 0045 284C JMP L_MyFunction ;;IniFM OK + 364 0046 + 365 0046 0F18 MOV A,cFreqDefL + 366 0047 00C7 MOV mFreqL,A + 367 0048 0F01 MOV A,cFreqDefH + 368 0049 00C8 MOV mFreqH,A + 369 004A 2294 CALL QN8072Init ;;Init QN8072 + 370 004B 304E SET bIniFMOK + 371 004C + 372 004C ;----------------------------------------------------------- + 373 004C ; Here to add your another code !! + 374 004C ;----------------------------------------------------------- + 375 004C L_MyFunction: + 376 004C 0001 clr wdt + 377 004D 0000 NOP + 378 004E 3872 snz bFlagTMR1 + 379 004F ;; jmp Main_End + 380 004F ;; IF UseMediaKey + 381 004F ;; call Key_Debounced + 382 004F ;; ENDIF + 383 004F 21D6 call Run_Volume_Step + 384 0050 + 385 0050 3472 clr bFlagTMR1 + 386 0051 + 387 0051 Main_End: + 388 0051 + 389 0051 2821 JMP Main + 390 0052 + 391 0052 ;*************************************************************** + 392 0052 ; System Initial + 393 0052 ; 1.ram_initial + 394 0052 ; 1.Timer Initial + 395 0052 ; 2.USB Config + 396 0052 ;*************************************************************** + 397 0052 System_Initial: + 398 0052 ;----------------------------------------------------------- + 399 0052 ; Debug + 400 0052 ;----------------------------------------------------------- + 401 0052 + 402 0052 + 403 0052 ;----------------------------------------------------------- + 404 0052 ; Modify Pop Noise + 405 0052 ; 癳い丁非 code  DA + 406 0052 ;----------------------------------------------------------- + 407 0052 0001 clr wdt + 408 0053 0709 mov a,WDTS + 409 0054 00E1 mov FIFO_TEMP,a + 410 0055 + 411 0055 0F57 mov a,01010111b + 文件:MAIN.ASM 盛群编译器版本 2.86 页次8 + + 412 0056 0089 mov WDTS,a + 413 0057 + 414 0057 1F2D clr [02DH] + 415 0058 + 416 0058 + 417 0058 0F80 mov a,80H + 418 0059 00AE mov [02EH],a + 419 005A 0000 nop + 420 005B 0000 nop + 421 005C 31AF set [02FH].3 + 422 005D 0000 nop + 423 005E 0000 nop + 424 005F 35AF clr [02FH].3 + 425 0060 0000 nop + 426 0061 0000 nop + 427 0062 + 428 0062 0761 mov a,FIFO_TEMP + 429 0063 0089 mov WDTS,a + 430 0064 ;----------------------------------------------------------- + 431 0064 ; ˙艼单筿甧ど丁 + 432 0064 ; 代刚莱赣р WaitBias 砞 0 , 獶代刚莱赣р WaitBais 砞 1 + 433 0064 ; Wait Bais and ROUT LOUT Capacity rise about 1.98ms + 434 0064 ; delay time = 255*255*30*3(sdz,jmp) cycle * 0.3333us/cycle = 1.98 ms + 435 0064 ;----------------------------------------------------------- + 436 0064 IF WaitBias + 437 0064 clr pac + 438 0064 + 439 0064 clr FIFO_OUT1 + 440 0064 clr FIFO_OUT2 + 441 0064 clr FIFO_OUT3 + 442 0064 mov a,9 + 443 0064 mov FIFO_OUT3,a + 444 0064 clr pa + 445 0064 + 446 0064 + 447 0064 + 448 0064 System_Initial_Loop: + 449 0064 clr wdt + 450 0064 sdz FIFO_OUT1 + 451 0064 jmp System_Initial_Loop + 452 0064 sdz FIFO_OUT2 + 453 0064 jmp System_Initial_Loop + 454 0064 sdz FIFO_OUT3 + 455 0064 jmp System_Initial_Loop + 456 0064 nop + 457 0064 set pa + 458 0064 clr wdt + 459 0064 ENDIF + 460 0064 ;----------------------------------------------------------- + 461 0064 ; Codec Limit + 462 0064 ;----------------------------------------------------------- + 463 0064 1F2D clr [02DH] + 464 0065 1FAE set [02EH] + 465 0066 + 466 0066 ;----------------------------------------------------------- + 467 0066 ; ram_initial : clear the ram of bank 0 + 468 0066 ;----------------------------------------------------------- + 469 0066 ram_initial: ;clear RAM (040H--0FFH) + 470 0066 0F40 MOV A,040H + 471 0067 0081 MOV MP0,A + 文件:MAIN.ASM 盛群编译器版本 2.86 页次9 + + 472 0068 0FC0 MOV A,192 + 473 0069 ram_initial_next_addr: + 474 0069 0001 clr wdt + 475 006A 1F00 CLR R0 + 476 006B 1481 INC MP0 + 477 006C 1785 SDZ acc + 478 006D 2869 JMP ram_initial_next_addr + 479 006E + 480 006E 374E CLR bFlag_RD_HTable + 481 006F ;----------------------------------------------------------- + 482 006F ; timer_initial : do timer initial + 483 006F ;----------------------------------------------------------- + 484 006F timer_initial: + 485 006F ;; MOV A,80H ; 砞﹚ low  high 牟祇砞ず场璸家Α + 486 006F ;; MOV TMR0C,A ; + 487 006F ;; MOV A,00H ; + 488 006F ;; MOV TMR0L,A + 489 006F ;; MOV A,000H + 490 006F ;; MOV TMR0H,A + 491 006F + 492 006F 0F80 mov a,80H + 493 0070 0091 mov TMR1C,a + 494 0071 0F00 mov a,00H + 495 0072 0090 mov TMR1L,a + 496 0073 008F mov TMR1H,a + 497 0074 + 498 0074 ;----------------------------------------------------------- + 499 0074 ; config_io_port : + 500 0074 ;----------------------------------------------------------- + 501 0074 ;; clr PA + 502 0074 ;----------------------------------------------------------- + 503 0074 ; config_io_port :(USB Audio) + 504 0074 ;----------------------------------------------------------- + 505 0074 3192 SET P_LED + 506 0075 3593 CLR P_LEDC + 507 0076 3092 SET P_SDA + 508 0077 3493 CLR P_SDAC + 509 0078 3012 SET P_SCL + 510 0079 3413 CLR P_SCLC + 511 007A + 512 007A ;;Initial QN8072 Reg0~4 + 513 007A 0F51 MOV A,51H + 514 007B 00C0 MOV mQNReg[0],A + 515 007C 0F18 MOV A,18H + 516 007D 00C1 MOV mQNReg[1],A + 517 007E 0FB9 MOV A,0B9H + 518 007F 00C2 MOV mQNReg[2],A + 519 0080 0F50 MOV A,50H + 520 0081 00C3 MOV mQNReg[3],A + 521 0082 0F58 MOV A,58H + 522 0083 00C4 MOV mQNReg[4],A + 523 0084 + 524 0084 + 525 0084 ;; IF UseMediaKey + 526 0084 ;; kmov pac,Key_Defined + 527 0084 ;; ENDIF + 528 0084 ;; IFE UseMediaKey + 529 0084 ;; kmov pac,00000000b + 530 0084 ;; ENDIF + 531 0084 + 文件:MAIN.ASM 盛群编译器版本 2.86 页次10 + + 532 0084 ;; clr pb + 533 0084 ;; clr pbc ;change to USB Len On + 534 0084 ;;; clr pc ;for volume control + 535 0084 ;; set pcc + 536 0084 ;; clr pd + 537 0084 ;; clr pdc + 538 0084 ;----------------------------------------------------------- + 539 0084 ; config_usb_speaker_register : + 540 0084 ;----------------------------------------------------------- + 541 0084 1F1C clr USVC ;mute & 0db + 542 0085 1F1D clr USF + 543 0086 ;----------------------------------------------------------- + 544 0086 ; reset variable : + 545 0086 ;----------------------------------------------------------- + 546 0086 35EB clr bFlag_Audio_Mute + 547 0087 1F6F clr VolumeH_Save + 548 0088 0FFC mov a,Cur_Volume + 549 0089 00F0 mov VolumeL_Save,a + 550 008A ;----------------------------------------------------------- + 551 008A ; config_usb : do usb config + 552 008A ;----------------------------------------------------------- + 553 008A config_usb: + 554 008A 1F0B CLR INTC0 + 555 008B 308B SET INTC0.@INTC0_EEI ;enable USB + 556 008C 300B SET INTC0.@INTC0_EMI ;Global interrupt + 557 008D + 558 008D 3226 set MISC.@MISC_ISOEN + 559 008E 1F24 clr STALL + 560 008F 3622 clr UCC.@UCC_SUSP2 + 561 0090 + 562 0090 ;SYSCLK + 563 0090 ;set UCC.6 //set to 6 MHz + 564 0090 + 565 0090 31A2 set UCC.@UCC_USBCKEN + 566 0091 0000 nop + 567 0092 3220 set USC.@USC_V33C ;//pc 秨﹍癳 command 筁ㄓ + 568 0093 0001 clr wdt + 569 0094 ;modify for Remote Wakeup + 570 0094 366B clr bRmtWakeup + 571 0095 36EB clr b_wakeup + 572 0096 37EB clr b_forusbRst + 573 0097 ;clr AWR.@AWR_WKEN + 574 0097 0003 RET + 575 0098 + 576 0098 ;*************************************************************** + 577 0098 ; Timer_0_ISR + 578 0098 ; 1.Timer time = 21.2 ms + 579 0098 ; 2.Do this procedure is 3.6ms + 580 0098 ;*************************************************************** + 581 0098 Timer_0_ISR: + 582 0098 ;; clr TMR0C.4 + 583 0098 ;; MOV isr_tmr0_acc,A ;save ACC + 584 0098 ;; MOV A,STATUS + 585 0098 ;; MOV isr_tmr0_status,A ;save status + 586 0098 ;; MOV A,MP1 + 587 0098 ;; MOV isr_tmr0_mp1,A ;save mp1 + 588 0098 ;; MOV A,MP0 + 589 0098 ;; MOV isr_tmr0_mp0,A ;save mp0 + 590 0098 ;; MOV A,TBLP + 591 0098 ;; MOV isr_tmr0_tblp,A ;save TBLP + 文件:MAIN.ASM 盛群编译器版本 2.86 页次11 + + 592 0098 + 593 0098 Timer_0_My_Function: + 594 0098 ;----------------------------------------------------------- + 595 0098 ; Here to add your another code !! + 596 0098 ;----------------------------------------------------------- + 597 0098 ;; NOP + 598 0098 ;; clr wdt + 599 0098 + 600 0098 Timer_0_ISR_END: + 601 0098 ;; MOV A,isr_tmr0_tblp ;restore TBLP + 602 0098 ;; MOV TBLP,A + 603 0098 ;; MOV A,isr_tmr0_mp0 ;restore MP0 + 604 0098 ;; MOV MP0,A + 605 0098 ;; MOV A,isr_tmr0_mp1 ;restore MP1 + 606 0098 ;; MOV MP1,A + 607 0098 ;; MOV A,isr_tmr0_status ;restore STATUS + 608 0098 ;; MOV STATUS,A + 609 0098 ;; MOV A,isr_tmr0_acc ;restore ACC + 610 0098 ;; SET TMR0C.4 ;start timer0 + 611 0098 + 612 0098 0004 RETI + 613 0099 + 614 0099 ;*************************************************************** + 615 0099 ; Timer_1_ISR + 616 0099 ; 1.Timer time = 21.2 ms + 617 0099 ; 2.Do this procedure is 3.6ms + 618 0099 ;*************************************************************** + 619 0099 Timer_1_ISR: + 620 0099 3611 CLR TMR1C.4 + 621 009A + 622 009A + 623 009A ;; MOV isr_tmr1_acc,A ;save ACC + 624 009A ;; MOV A,STATUS + 625 009A ;; MOV isr_tmr1_status,A ;save status + 626 009A ;; MOV A,MP1 + 627 009A ;; MOV isr_tmr1_mp1,A ;save mp1 + 628 009A ;; MOV A,MP0 + 629 009A ;; MOV isr_tmr1_mp0,A ;save mp0 + 630 009A ;; MOV A,TBLP + 631 009A ;; MOV isr_tmr1_tblp,A ;save TBLP + 632 009A ;; clr wdt + 633 009A ;IF UseMediaKey + 634 009A ;call Key_Debounced + 635 009A ;ENDIF + 636 009A ;call Run_Volume_Step + 637 009A 3072 set bFlagTMR1 + 638 009B + 639 009B ;; MOV A,isr_tmr1_tblp ;restore TBLP + 640 009B ;; MOV TBLP,A + 641 009B ;; MOV A,isr_tmr1_mp0 ;restore MP0 + 642 009B ;; MOV MP0,A + 643 009B ;; MOV A,isr_tmr1_mp1 ;restore MP1 + 644 009B ;; MOV MP1,A + 645 009B ;; MOV A,isr_tmr1_status ;restore STATUS + 646 009B ;; MOV STATUS,A + 647 009B ;; MOV A,isr_tmr1_acc ;restore ACC + 648 009B + 649 009B Timer_1_ISR_End: + 650 009B 3211 SET TMR1C.4 + 651 009C 0004 RETI + 文件:MAIN.ASM 盛群编译器版本 2.86 页次12 + + 652 009D + 653 009D ;*************************************************************** + 654 009D ; USB_ISR : USB Interrupt Routine + 655 009D ; 1.Back up every status register + 656 009D ; 2.check which endpoint is interrupt + 657 009D ;*************************************************************** + 658 009D USB_ISR: + 659 009D ;CLR INTC0.@INTC0_EEI ;disable USB interrupt + 660 009D ;SET INTC0.@INTC0_EMI + 661 009D + 662 009D 00CF MOV isr_usb_acc,A ;save ACC + 663 009E 070A MOV A,STATUS + 664 009F 00D0 MOV isr_usb_status,A ;save status + 665 00A0 0703 MOV A,MP1 + 666 00A1 00D1 MOV isr_usb_mp1,A ;save mp1 + 667 00A2 0701 MOV A,MP0 + 668 00A3 00D2 MOV isr_usb_mp0,A ;save mp0 + 669 00A4 0707 MOV A,TBLP + 670 00A5 00D3 MOV isr_usb_tblp,A ;save TBLP + 671 00A6 + 672 00A6 ;modify 2007-07-03 + 673 00A6 3D20 SZ USC.@USC_URST + 674 00A7 33EB SET b_forusbRst + 675 00A8 3520 CLR USC.@USC_URST + 676 00A9 + 677 00A9 ;modify 2007-06-27 + 678 00A9 3DA0 SZ USC.@USC_RESUME + 679 00AA 336B set b_forceresumeWakeup;;JMP RemoteWakeup + 680 00AB + 681 00AB 0001 clr wdt + 682 00AC ;;Check Which FIFO is interrupt + 683 00AC 28B7 JMP Check_Access_FIFO + 684 00AD + 685 00AD + 686 00AD + 687 00AD USB_ISR_END: + 688 00AD 0753 MOV A,isr_usb_tblp ;restore TBLP + 689 00AE 0087 MOV TBLP,A + 690 00AF 0752 MOV A,isr_usb_mp0 ;restore MP0 + 691 00B0 0081 MOV MP0,A + 692 00B1 0751 MOV A,isr_usb_mp1 ;restore MP1 + 693 00B2 0083 MOV MP1,A + 694 00B3 0750 MOV A,isr_usb_status ;restore STATUS + 695 00B4 008A MOV STATUS,A + 696 00B5 074F MOV A,isr_usb_acc ;restore ACC + 697 00B6 + 698 00B6 + 699 00B6 ;CLR INTC0.@INTC0_EMI + 700 00B6 ;SET INTC0.@INTC0_EEI + 701 00B6 + 702 00B6 + 703 00B6 0004 RETI + 704 00B7 + 705 00B7 ;*************************************************************** + 706 00B7 ; USB_EPX_ISR + 707 00B7 ; ぇ玡ㄏノ USR@EP0IF EQU [01BH].0 穦盎代ぃ + 708 00B7 ; эΘ USB_STATUS_CONTROL.@EP0IF + 709 00B7 ;*************************************************************** + 710 00B7 Check_Access_FIFO: + 711 00B7 0001 clr wdt + 文件:MAIN.ASM 盛群编译器版本 2.86 页次13 + + 712 00B8 3C21 SZ USR.@USR_EP0F + 713 00B9 28BF JMP USB_EP0_ISR + 714 00BA 3CA1 SZ USR.@USR_EP1F + 715 00BB 2910 JMP USB_EP1_ISR + 716 00BC 3D21 SZ USR.@USR_EP2F + 717 00BD 2919 JMP USB_EP2_ISR + 718 00BE 28AD JMP USB_ISR_END + 719 00BF + 720 00BF ;----------------------------------------------------- + 721 00BF ;EPNPOINT 0 + 722 00BF ;----------------------------------------------------- + 723 00BF USB_EP0_ISR: + 724 00BF ;CLR USR.@USR_EP0F + 725 00BF + 726 00BF ;;case1 + 727 00BF 3EA6 SZ MISC.@MISC_SCMD ;check setup token + 728 00C0 28CB JMP USB_EP0_SETUP_TOKEN + 729 00C1 + 730 00C1 3FA6 SZ MISC.@MISC_LEN0 ;check out ack token + 731 00C2 28D1 JMP USB_EP0_OUT_ACK_TOKEN + 732 00C3 + 733 00C3 2000 E CALL FIFO0_RD_CHECK + 734 00C4 3E4E SZ bFlag_FIFO_Ready + 735 00C5 28D5 JMP USB_EP0_OUT_TOKEN + 736 00C6 ;clr MISC.@MISC_REQ + 737 00C6 + 738 00C6 2000 E CALL FIFO0_WR_CHECK + 739 00C7 3E4E SZ bFlag_FIFO_Ready + 740 00C8 28CD JMP USB_EP0_IN_TOKEN ;else is in token + 741 00C9 ;clr MISC.@MISC_REQ + 742 00C9 + 743 00C9 ;modify 2007-06-20 + 744 00C9 3421 CLR USR.@USR_EP0F ;Fix OHCI Volume + 745 00CA + 746 00CA 290F JMP USB_EP0_ISR_END + 747 00CB + 748 00CB + 749 00CB ;;case2 + 750 00CB ;; SZ MISC.@MISC_SCMD ;check setup token + 751 00CB ;; JMP USB_EP0_SETUP_TOKEN + 752 00CB ;; + 753 00CB ;; SZ MISC.@MISC_LEN0 ;check out ack token + 754 00CB ;; JMP USB_EP0_OUT_ACK_TOKEN + 755 00CB ;; + 756 00CB ;; CALL FIFO0_RD_CHECK + 757 00CB ;; SZ bFlag_FIFO_Ready + 758 00CB ;; JMP USB_EP0_OUT_TOKEN + 759 00CB ;; ;clr MISC.@MISC_REQ + 760 00CB ;; + 761 00CB ;; CALL FIFO0_WR_CHECK + 762 00CB ;; SZ bFlag_FIFO_Ready + 763 00CB ;; JMP USB_EP0_IN_TOKEN ;else is in token + 764 00CB ;; ;clr MISC.@MISC_REQ + 765 00CB ;; + 766 00CB ;; + 767 00CB ;; JMP USB_EP0_ISR_END + 768 00CB + 769 00CB + 770 00CB ;;case3 + 771 00CB ;; call FIFO0_RD_CHECK + 文件:MAIN.ASM 盛群编译器版本 2.86 页次14 + + 772 00CB ;; sz bFlag_FIFO_Ready + 773 00CB ;; jmp Have_Data_Out + 774 00CB ;; + 775 00CB ;; call FIFO0_WR_CHECK + 776 00CB ;; sz bFlag_FIFO_Ready + 777 00CB ;; jmp USB_EP0_IN_TOKEN + 778 00CB ;; + 779 00CB ;; jmp USB_EP0_ISR_END + 780 00CB ;; + 781 00CB ;;Have_Data_Out: + 782 00CB ;; sz MISC.@MISC_SCMD + 783 00CB ;; jmp USB_EP0_SETUP_TOKEN + 784 00CB ;; sz MISC.@MISC_LEN0 + 785 00CB ;; jmp USB_EP0_OUT_ACK_TOKEN + 786 00CB ;; + 787 00CB ;; jmp USB_EP0_OUT_TOKEN + 788 00CB + 789 00CB + 790 00CB + 791 00CB + 792 00CB + 793 00CB USB_EP0_SETUP_TOKEN: ;PARSE SETUP TOKEN + 794 00CB 0001 clr wdt + 795 00CC 291C JMP StageOne + 796 00CD + 797 00CD USB_EP0_IN_TOKEN: + 798 00CD 0001 clr wdt + 799 00CE ;modify 2007-06-20 + 800 00CE 3421 CLR USR.@USR_EP0F ;Fix OHCI Volume + 801 00CF 2000 E CALL control_read + 802 00D0 290F JMP USB_EP0_ISR_END + 803 00D1 + 804 00D1 USB_EP0_OUT_ACK_TOKEN: + 805 00D1 ;modify 2007-06-20 + 806 00D1 3421 CLR USR.@USR_EP0F ;Fix OHCI Volume + 807 00D2 0001 clr wdt + 808 00D3 37A6 clr MISC.@MISC_LEN0 + 809 00D4 290F JMP USB_EP0_ISR_END + 810 00D5 + 811 00D5 ;-------------------------------------------------------------- + 812 00D5 ; Parser nCmdIndex1 + 813 00D5 ;-------------------------------------------------------------- + 814 00D5 USB_EP0_OUT_TOKEN: + 815 00D5 ;modify 2007-06-20 + 816 00D5 3421 CLR USR.@USR_EP0F ;Fix OHCI Volume + 817 00D6 0001 clr wdt + 818 00D7 1F05 clr acc + 819 00D8 0471 xor a,nCmdIndex1 + 820 00D9 3D0A sz z + 821 00DA 290F jmp USB_EP0_ISR_END + 822 00DB + 823 00DB USB_EP0_OUT_TOKEN_Loop: + 824 00DB 0001 clr wdt + 825 00DC 2000 E CALL Check_Real_Cmd + 826 00DD 3DCE sz bFlag_Real_Cmd + 827 00DE 28F3 jmp USB_EP0_OUT_TOKEN_End + 828 00DF + 829 00DF 0001 clr wdt + 830 00E0 2000 E CALL FIFO0_RD_CHECK + 831 00E1 3A4E SNZ bFlag_FIFO_Ready + 文件:MAIN.ASM 盛群编译器版本 2.86 页次15 + + 832 00E2 28DB JMP USB_EP0_OUT_TOKEN_Loop + 833 00E3 + 834 00E3 2000 E CALL READ_FIFO0 + 835 00E4 0000 NOP + 836 00E5 2000 E CALL Send_Hand_Shake + 837 00E6 + 838 00E6 ;decode command + 839 00E6 ;//parse Cmd , 21 = SetReport Out Data + 840 00E6 0F21 mov a,21H + 841 00E7 0471 xor a,nCmdIndex1 + 842 00E8 3D0A sz z + 843 00E9 29B1 jmp ProcessOutData + 844 00EA + 845 00EA ;//parse Cmd , 18 = Mute Control + 846 00EA 0F18 mov a,18H + 847 00EB 0471 xor a,nCmdIndex1 + 848 00EC 3D0A sz z + 849 00ED 28F5 jmp Implement_Mute + 850 00EE + 851 00EE ;//parse Cmd , 28 = Volume Control + 852 00EE 0F28 mov a,28H + 853 00EF 0471 xor a,nCmdIndex1 + 854 00F0 3D0A sz z + 855 00F1 2909 jmp Implement_Volume + 856 00F2 + 857 00F2 ;//unknow command + 858 00F2 28F3 jmp USB_EP0_OUT_TOKEN_End + 859 00F3 + 860 00F3 USB_EP0_OUT_TOKEN_End: + 861 00F3 1F71 clr nCmdIndex1 + 862 00F4 290F JMP USB_EP0_ISR_END + 863 00F5 + 864 00F5 + 865 00F5 Implement_Mute: + 866 00F5 0001 clr wdt + 867 00F6 3C59 sz FIFO_out1.0 + 868 00F7 379C clr USVC.7 ;mute + 869 00F8 3859 snz FIFO_out1.0 + 870 00F9 339C set USVC.7 ;unmute + 871 00FA + 872 00FA 3C59 sz FIFO_out1.0 + 873 00FB 31EB set bFlag_Audio_Mute ;mute + 874 00FC 3859 snz FIFO_out1.0 + 875 00FD 35EB clr bFlag_Audio_Mute ;unmute + 876 00FE + 877 00FE 3C59 sz FIFO_out1.0 + 878 00FF 3094 set MUTE_LED_ON ;mute + 879 0100 3859 snz FIFO_out1.0 + 880 0101 3494 clr MUTE_LED_ON ;unmute + 881 0102 + 882 0102 + 883 0102 39EB snz bFlag_Audio_Mute + 884 0103 2907 jmp Implement_Mute_1 + 885 0104 + 886 0104 0FC8 mov a,Min_Volume + 887 0105 009C mov USVC,a + 888 0106 + 889 0106 379C clr USVC.7 + 890 0107 + 891 0107 + 文件:MAIN.ASM 盛群编译器版本 2.86 页次16 + + 892 0107 Implement_Mute_1: + 893 0107 0001 clr wdt + 894 0108 ;//kmov Mute_Save,FIFO_out1 + 895 0108 28F3 jmp USB_EP0_OUT_TOKEN_End + 896 0109 + 897 0109 + 898 0109 Implement_Volume: + 899 0109 0001 clr wdt + 900 010A kmov VolumeH_Save,FIFO_out1 + 901 010C kmov VolumeL_Save,FIFO_out2 + 902 010E Implement_Volume_End: + 903 010E 28F3 jmp USB_EP0_OUT_TOKEN_End + 904 010F + 905 010F USB_EP0_ISR_END: + 906 010F ;//CLR USR.@USR_EP0F + 907 010F 28AD JMP USB_ISR_END + 908 0110 ;----------------------------------------------------- + 909 0110 ;EPNPOINT 1 Interrupt + 910 0110 ;----------------------------------------------------- + 911 0110 USB_EP1_ISR: + 912 0110 34A1 CLR USR.@USR_EP1F + 913 0111 384E SNZ bIniFMOK + 914 0112 2918 JMP USB_EP1_ISR_END ;;FM Not initial OK,exit + 915 0113 + 916 0113 ;check the data is in fifo ? + 917 0113 2000 E CALL FIFO1_RD_CHECK + 918 0114 3A4E SNZ bFlag_FIFO_Ready + 919 0115 2918 JMP USB_EP1_ISR_END + 920 0116 2000 E CALL Read_FIFO1 + 921 0117 + 922 0117 + 923 0117 ;;CALL FIFO1_WR_CHECK + 924 0117 ;;SNZ bFlag_FIFO_Ready + 925 0117 ;;JMP USB_EP1_ISR_END + 926 0117 ;;MOV A,00H + 927 0117 ;;MOV FIFO_OUT1,A + 928 0117 ;;MOV A,01H + 929 0117 ;;MOV FIFO_SendLen,A + 930 0117 ;;CALL WRITE_FIFO1 + 931 0117 + 932 0117 22DE CALL QN8027 + 933 0118 + 934 0118 + 935 0118 + 936 0118 USB_EP1_ISR_END: + 937 0118 28AD JMP USB_ISR_END + 938 0119 ;----------------------------------------------------- + 939 0119 ;EPNPOINT 2 Interrupt + 940 0119 ;----------------------------------------------------- + 941 0119 USB_EP2_ISR: + 942 0119 3521 CLR USR.@USR_EP2F + 943 011A ;;SET ET0I ;enable timer0 + 944 011A ;;SET TMR0C.4 ;璓 秨﹍璸计 + 945 011A + 946 011A + 947 011A + 948 011A 3626 clr MISC.@MISC_ISOEN ;闽超 ISO い耞 + 949 011B + 950 011B + 951 011B USB_EP2_ISR_END: + 文件:MAIN.ASM 盛群编译器版本 2.86 页次17 + + 952 011B 28AD JMP USB_ISR_END + 953 011C + 954 011C + 955 011C ;*************************************************************** + 956 011C ; Stage One .... Test bmRequestType + 957 011C ; CALL FIFO_RD_CHECK will return bFlag_FIFO_Ready?(1=Ready,0=not ready) + 958 011C ;*************************************************************** + 959 011C StageOne: + 960 011C 0001 clr wdt + 961 011D 2000 E CALL FIFO0_RD_CHECK + 962 011E 3A4E SNZ bFlag_FIFO_Ready + 963 011F 2948 JMP StageOne_End ; the EP0 FIFO RD is not ready ⊿Τdata秈ㄓ + 964 0120 2000 E CALL Read_FIFO0 ; Read EP0 Command + 965 0121 36A6 clr MISC.@MISC_SCMD + 966 0122 37A6 clr MISC.@MISC_LEN0 + 967 0123 + 968 0123 ;modify 2007-06-20 + 969 0123 3421 CLR USR.@USR_EP0F ;Fix OHCI Volume + 970 0124 + 971 0124 0001 clr wdt + 972 0125 0000 nop + 973 0126 + 974 0126 0759 MOV A,FIFO_TYPE + 975 0127 0C00 XOR A,00H + 976 0128 3D0A SZ Z ;FIFO_TYPE=00H + 977 0129 294A JMP Request_Type00 + 978 012A + 979 012A 0759 MOV A,FIFO_TYPE + 980 012B 0C01 XOR A,01H + 981 012C 3D0A SZ Z ;FIFO_TYPE=01H + 982 012D 2960 JMP Request_Type01 + 983 012E + 984 012E 0759 MOV A,FIFO_TYPE + 985 012F 0C02 XOR A,02H + 986 0130 3D0A SZ Z ;FIFO_TYPE=02H + 987 0131 2966 JMP Request_Type02 + 988 0132 + 989 0132 0759 MOV A,FIFO_TYPE + 990 0133 0C80 XOR A,80H + 991 0134 3D0A SZ Z ;FIFO_TYPE=80H + 992 0135 2970 JMP Request_Type80 + 993 0136 + 994 0136 0759 MOV A,FIFO_TYPE + 995 0137 0C81 XOR A,81H + 996 0138 3D0A SZ Z ;FIFO_TYPE=81H + 997 0139 2980 JMP Request_Type81 + 998 013A + 999 013A 0759 MOV A,FIFO_TYPE +1000 013B 0C82 XOR A,82H +1001 013C 3D0A SZ Z ;FIFO_TYPE=82H +1002 013D 2990 JMP Request_Type82 +1003 013E +1004 013E ;=============================================================== +1005 013E ;HID & Audio +1006 013E ;=============================================================== +1007 013E 0759 MOV A,FIFO_TYPE +1008 013F 0C21 XOR A,21H +1009 0140 3D0A SZ Z +1010 0141 2996 JMP Request_Type21 +1011 0142 + 文件:MAIN.ASM 盛群编译器版本 2.86 页次18 + +1012 0142 ;Volume Control +1013 0142 0001 clr wdt +1014 0143 0759 MOV A,FIFO_TYPE +1015 0144 0CA1 XOR A,0A1H +1016 0145 3D0A SZ Z +1017 0146 29A0 JMP Request_TypeA1 +1018 0147 +1019 0147 2800 E JMP SendStall0 +1020 0148 +1021 0148 +1022 0148 StageOne_End: +1023 0148 ;modify 2007-06-20 +1024 0148 3421 CLR USR.@USR_EP0F ;Fix OHCI Volume +1025 0149 0003 RET +1026 014A +1027 014A +1028 014A ;*************************************************************** +1029 014A ; USB Stage2 +1030 014A ; +1031 014A ;*************************************************************** +1032 014A ;Device to Host with device as recipient +1033 014A ;=============================================================== +1034 014A ;Request_Type00 +1035 014A ;bRequest Function +1036 014A ; 1 Clear Feature +1037 014A ; 3 Set Feature +1038 014A ; 5 Set Address +1039 014A ; 7 not support +1040 014A ; 9 Set Configuration +1041 014A ;=============================================================== +1042 014A ;=============================================================== +1043 014A Request_TYPE00: +1044 014A ;Set the device address to a non-zero value +1045 014A ;Set address +1046 014A 0001 clr wdt +1047 014B 075A MOV A,FIFO_REQUEST +1048 014C 0C05 XOR A,set_address +1049 014D 3D0A SZ Z +1050 014E 2800 E JMP SetAddress +1051 014F +1052 014F ;Set Configuration +1053 014F 075A MOV A,FIFO_REQUEST +1054 0150 0C09 XOR A,set_configuration +1055 0151 390A SNZ Z +1056 0152 2956 JMP Request_TYPE00_NEXT +1057 0153 +1058 0153 318B SET ET1I +1059 0154 3211 SET TMR1C.4 +1060 0155 +1061 0155 2800 E JMP SetConfiguration +1062 0156 +1063 0156 ;Clear Feature +1064 0156 ;The HT82A822R return ACK without ERROR +1065 0156 Request_TYPE00_NEXT: +1066 0156 075A MOV A,FIFO_REQUEST +1067 0157 0C01 XOR A,clear_feature +1068 0158 3D0A SZ Z +1069 0159 2800 E JMP ClearFeature +1070 015A +1071 015A ;Set Feature + 文件:MAIN.ASM 盛群编译器版本 2.86 页次19 + +1072 015A 0001 clr wdt +1073 015B 075A MOV A,FIFO_REQUEST +1074 015C 0C03 XOR A,set_feature +1075 015D 3D0A SZ Z +1076 015E 2800 E JMP SetFeature +1077 015F +1078 015F 2800 E JMP SendStall0 +1079 0160 ;=============================================================== +1080 0160 Request_Type01: +1081 0160 0001 clr wdt +1082 0161 075A MOV A,FIFO_REQUEST +1083 0162 0C0B XOR A,set_interface +1084 0163 3D0A SZ Z +1085 0164 2800 E JMP SetInterface +1086 0165 +1087 0165 2800 E JMP SendStall0 +1088 0166 ;=============================================================== +1089 0166 Request_Type02: +1090 0166 0001 clr wdt +1091 0167 075A MOV A,FIFO_REQUEST +1092 0168 0C01 XOR A,clear_feature +1093 0169 3D0A SZ Z +1094 016A 2800 E JMP ClearFeature_Endpoint +1095 016B +1096 016B 075A MOV A,FIFO_REQUEST +1097 016C 0C03 XOR A,set_feature +1098 016D 3D0A SZ Z +1099 016E 2800 E JMP SetFeature_Endpoint +1100 016F +1101 016F +1102 016F +1103 016F 2800 E JMP SendStall0 +1104 0170 +1105 0170 +1106 0170 +1107 0170 ;=============================================================== +1108 0170 Request_TYPE80: +1109 0170 ;Get Status +1110 0170 ;Get Descriptor 80 06 +1111 0170 0001 clr wdt +1112 0171 075A MOV A,FIFO_REQUEST +1113 0172 0C06 XOR A,get_descriptor +1114 0173 3D0A SZ Z +1115 0174 2800 E JMP GetDescriptor +1116 0175 +1117 0175 ;Get Configuration 80 08 +1118 0175 0001 clr wdt +1119 0176 075A MOV A,FIFO_REQUEST +1120 0177 0C08 XOR A,get_configuration +1121 0178 3D0A SZ Z +1122 0179 2800 E JMP GetConfiguration +1123 017A +1124 017A ;Get Status(DEVICE) 80 00 +1125 017A 0001 clr wdt +1126 017B 075A MOV A,FIFO_REQUEST +1127 017C 0C00 XOR A,get_status +1128 017D 3D0A SZ Z +1129 017E 2800 E JMP GetStatus +1130 017F +1131 017F 2800 E JMP SendStall0 + 文件:MAIN.ASM 盛群编译器版本 2.86 页次20 + +1132 0180 +1133 0180 ;=============================================================== +1134 0180 Request_TYPE81: +1135 0180 ;get status +1136 0180 ;get interface -> not support +1137 0180 ;HID class defines one more request for bmRequestType=81 +1138 0180 ;get HID descriptor +1139 0180 0001 clr wdt +1140 0181 075A MOV A,FIFO_REQUEST +1141 0182 0C06 XOR A,get_descriptor +1142 0183 3D0A SZ Z +1143 0184 2800 E JMP GetDescriptor +1144 0185 +1145 0185 ;Get Interface +1146 0185 0001 clr wdt +1147 0186 075A MOV A,FIFO_REQUEST +1148 0187 0C0A XOR A,get_interface +1149 0188 3D0A SZ Z +1150 0189 2800 E JMP GetInterface +1151 018A +1152 018A ;Get Status(INTERFACE) 81 00 +1153 018A 0001 clr wdt +1154 018B 075A MOV A,FIFO_REQUEST +1155 018C 0C00 XOR A,get_status +1156 018D 3D0A SZ Z +1157 018E 2800 E JMP GetStatus_Interface ;modify for Remote Wakeup +1158 018F +1159 018F 2800 E JMP SendStall0 +1160 0190 ;=============================================================== +1161 0190 Request_TYPE82: +1162 0190 ;get status +1163 0190 ;Get Status(INTERFACE) 82 00 +1164 0190 0001 clr wdt +1165 0191 075A MOV A,FIFO_REQUEST +1166 0192 0C00 XOR A,get_status +1167 0193 3D0A SZ Z +1168 0194 2800 E JMP GetStatus_Endpoint +1169 0195 +1170 0195 2800 E JMP SendStall0 +1171 0196 +1172 0196 ;=============================================================== +1173 0196 ;=============================================================== +1174 0196 ;Now parse HID class Descriptor Types +1175 0196 ;=============================================================== +1176 0196 ;host to device with endpoint as recipient +1177 0196 Request_TYPE21: +1178 0196 0001 clr wdt +1179 0197 ;set report +1180 0197 075A MOV A,FIFO_REQUEST +1181 0198 0C09 XOR A,set_report +1182 0199 3D0A SZ Z +1183 019A 2800 E JMP SetReport +1184 019B +1185 019B ;------------------------------------------------------ +1186 019B ;audio class-specific request code +1187 019B ;------------------------------------------------------ +1188 019B +1189 019B 075A MOV A,FIFO_REQUEST +1190 019C 0C01 XOR A,SET_CUR +1191 019D 3D0A SZ Z + 文件:MAIN.ASM 盛群编译器版本 2.86 页次21 + +1192 019E 2800 E JMP SetCur +1193 019F +1194 019F Request_TYPE21_End: +1195 019F 2800 E JMP SendStall0 +1196 01A0 +1197 01A0 Request_TypeA1: +1198 01A0 075A MOV A,FIFO_REQUEST +1199 01A1 0C82 XOR A,GET_MIN +1200 01A2 3D0A SZ Z +1201 01A3 2800 E JMP GetMin +1202 01A4 +1203 01A4 075A MOV A,FIFO_REQUEST +1204 01A5 0C83 XOR A,GET_MAX +1205 01A6 3D0A SZ Z +1206 01A7 2800 E JMP GetMax +1207 01A8 +1208 01A8 075A MOV A,FIFO_REQUEST +1209 01A9 0C84 XOR A,GET_RES +1210 01AA 3D0A SZ Z +1211 01AB 2800 E JMP GetRes +1212 01AC +1213 01AC 075A MOV A,FIFO_REQUEST +1214 01AD 0C81 XOR A,GET_CUR +1215 01AE 3D0A SZ Z +1216 01AF 2800 E JMP GetCur +1217 01B0 +1218 01B0 +1219 01B0 Request_TYPEA1_End: +1220 01B0 2800 E JMP SendStall0 +1221 01B1 ;=============================================================== +1222 01B1 ProcessOutData: +1223 01B1 3DCE sz bFlag_Real_Cmd +1224 01B2 29B4 jmp ProcessOutData_End +1225 01B3 +1226 01B3 ;; clr wdt +1227 01B3 ;; CALL FIFO0_RD_CHECK +1228 01B3 ;; SNZ bFlag_FIFO_Ready +1229 01B3 ;; JMP ProcessOutData ; the EP0 FIFO RD is not ready ⊿Τdata秈ㄓ +1230 01B3 +1231 01B3 ;; CALL Read_FIFO0 +1232 01B3 22DE CALL QN8027 +1233 01B4 ;; nop +1234 01B4 ;; call FIFO1_WR_CHECK +1235 01B4 ;; snz bFlag_FIFO_Ready +1236 01B4 ;; jmp ProcessOutData_End +1237 01B4 +1238 01B4 ;; call Write_FIFO1 +1239 01B4 +1240 01B4 +1241 01B4 ProcessOutData_End: +1242 01B4 1F71 clr nCmdIndex1 +1243 01B5 290F jmp USB_EP0_ISR_END +1244 01B6 +1245 01B6 +1246 01B6 +1247 01B6 +1248 01B6 Delay_20ms: +1249 01B6 0001 clr wdt +1250 01B7 0F75 mov a,075H +1251 01B8 00D4 mov Delay_1,a + 文件:MAIN.ASM 盛群编译器版本 2.86 页次22 + +1252 01B9 0FFF mov a,0FFH +1253 01BA 00D5 mov Delay_2,a +1254 01BB Delay_20ms_Wait: +1255 01BB 0001 clr wdt +1256 01BC 17D5 SDZ Delay_2 +1257 01BD 29BB JMP Delay_20ms_Wait +1258 01BE 17D4 SDZ Delay_1 +1259 01BF 29BB JMP Delay_20ms_Wait +1260 01C0 0003 RET +1261 01C1 +1262 01C1 Delay_5ms: +1263 01C1 0001 clr wdt +1264 01C2 0F3A mov a,03AH +1265 01C3 00D4 mov Delay_1,a +1266 01C4 0FFF mov a,0FFH +1267 01C5 00D5 mov Delay_2,a +1268 01C6 Delay_5ms_Wait: +1269 01C6 0001 clr wdt +1270 01C7 17D5 SDZ Delay_2 +1271 01C8 29C6 JMP Delay_5ms_Wait +1272 01C9 17D4 SDZ Delay_1 +1273 01CA 29C6 JMP Delay_5ms_Wait +1274 01CB 0003 RET +1275 01CC +1276 01CC +1277 01CC Delay PROC +1278 01CC 0001 clr wdt +1279 01CD 0FFF MOV A,0FFH +1280 01CE 00D4 MOV Delay_1,A +1281 01CF 00D5 MOV Delay_2,A +1282 01D0 +1283 01D0 Wait: +1284 01D0 0001 clr wdt +1285 01D1 17D5 SDZ Delay_2 +1286 01D2 29D0 JMP Wait +1287 01D3 17D4 SDZ Delay_1 +1288 01D4 29D0 JMP Wait +1289 01D5 0003 RET +1290 01D6 +1291 01D6 Delay ENDP +1292 01D6 +1293 01D6 +1294 01D6 +1295 01D6 ;*************************************************************** +1296 01D6 ; Run_Volume_Step Module +1297 01D6 ; Volume1:Target +1298 01D6 ; Volume2:Now +1299 01D6 ;*************************************************************** +1300 01D6 Run_Volume_Step: +1301 01D6 0001 clr wdt +1302 01D7 ;check mute? +1303 01D7 3DEB sz bFlag_Audio_Mute +1304 01D8 2A04 jmp Run_Volume_Step_End +1305 01D9 +1306 01D9 +1307 01D9 0770 mov a,VolumeL_Save +1308 01DA 00ED mov Volume1,a +1309 01DB +1310 01DB ;check Volume1 = 080H ? +1311 01DB 0F80 mov a,80H + 文件:MAIN.ASM 盛群编译器版本 2.86 页次23 + +1312 01DC 046D xor a,Volume1 +1313 01DD 3D0A sz z +1314 01DE 29E0 jmp Run_Volume_Step_Process_Min +1315 01DF 29E2 jmp Run_Volume_Step_1 +1316 01E0 +1317 01E0 Run_Volume_Step_Process_Min: +1318 01E0 0FC8 mov a,Min_Volume +1319 01E1 00ED mov Volume1,a +1320 01E2 +1321 01E2 +1322 01E2 +1323 01E2 Run_Volume_Step_1: +1324 01E2 +1325 01E2 37ED clr Volume1.7 +1326 01E3 +1327 01E3 0F7F mov a,01111111b +1328 01E4 061C and a,USVC +1329 01E5 00EE mov Volume2,a ;Volume2=now Volume1=target +1330 01E6 +1331 01E6 +1332 01E6 076D mov a,Volume1 +1333 01E7 046E xor a,Volume2 +1334 01E8 3D0A sz z +1335 01E9 2A04 jmp Run_Volume_Step_End ;target=now +1336 01EA +1337 01EA 0001 clr wdt +1338 01EB 076D mov a,Volume1 +1339 01EC 026E sub a,Volume2 ;target-now +1340 01ED 3C0A sz C +1341 01EE 29F0 jmp Run_Volume_1 ;>0 +1342 01EF 29F5 jmp Run_Volume_2 ;<0 +1343 01F0 +1344 01F0 Run_Volume_1: +1345 01F0 3B6D snz Volume1.6 +1346 01F1 29FA jmp Run_Volume_Step_Inc +1347 01F2 3B6E snz Volume2.6 +1348 01F3 29FC jmp Run_Volume_Step_Dec +1349 01F4 29FA jmp Run_Volume_Step_Inc +1350 01F5 +1351 01F5 Run_Volume_2: +1352 01F5 3B6E snz Volume2.6 +1353 01F6 29FC jmp Run_Volume_Step_Dec +1354 01F7 3B6D snz Volume1.6 +1355 01F8 29FA jmp Run_Volume_Step_Inc +1356 01F9 29FC jmp Run_Volume_Step_Dec +1357 01FA +1358 01FA +1359 01FA +1360 01FA Run_Volume_Step_Inc: +1361 01FA 14EE INC Volume2 +1362 01FB 29FD jmp Run_Volume_Step_2 +1363 01FC Run_Volume_Step_Dec: +1364 01FC 15EE DEC Volume2 +1365 01FD Run_Volume_Step_2: +1366 01FD 3F9C sz USVC.7 +1367 01FE 33EE set Volume2.7 +1368 01FF 3B9C snz USVC.7 +1369 0200 37EE clr Volume2.7 +1370 0201 kmov USVC,Volume2 +1371 0203 0001 clr wdt + 文件:MAIN.ASM 盛群编译器版本 2.86 页次24 + +1372 0204 Run_Volume_Step_End: +1373 0204 0003 ret +1374 0205 +1375 0205 ;*************************************************************** +1376 0205 ; Key_Debounced Module +1377 0205 ; Key_Defined : 饼盎代 bit +1378 0205 ; Key_Process : 矪瞶筁 叫 set  bit +1379 0205 ; Key_CheckIn : 材Ω盎代惠璶 set  bit +1380 0205 ; Key_Counter : 纗 bit  1 +1381 0205 ; 狦惠璶硈尿笆玥叫づ set Key_Process ( INC,DEC Volume) +1382 0205 ; 狦ぃ惠璶硈尿笆叫 set Key_Process ( Mute,Play,Stop) +1383 0205 ;*************************************************************** +1384 0205 IF UseMediaKey +1385 0205 Key_Debounced: +1386 0205 clr wdt +1387 0205 mov a,VIOP +1388 0205 cpl acc +1389 0205 mov PortC_Data,a +1390 0205 +1391 0205 mov a,Key_Defined +1392 0205 andm a,PortC_Data +1393 0205 sz z +1394 0205 jmp Key_Debounced_ClearReg ;//⊿龄砆 +1395 0205 +1396 0205 +1397 0205 Key_Debounced_Detect_In: +1398 0205 kmov Key_Temp,PortC_Data +1399 0205 clr Key_Counter +1400 0205 Key_Debounced_Detect: +1401 0205 clr C +1402 0205 RRC Key_Temp +1403 0205 sz C +1404 0205 jmp Key_Debounced_Detect_End +1405 0205 inc Key_Counter +1406 0205 mov a,080H +1407 0205 xor a,Key_Temp +1408 0205 sz z +1409 0205 jmp Key_Debounced_Detect_End +1410 0205 jmp Key_Debounced_Detect +1411 0205 Key_Debounced_Detect_End: +1412 0205 mov a,Key_Counter +1413 0205 call GetPipeBit +1414 0205 +1415 0205 xor a,Key_CheckIn +1416 0205 snz z +1417 0205 jmp Key_Debounced_SetCheckIn +1418 0205 +1419 0205 ;check process +1420 0205 mov a,Key_Process +1421 0205 xor a,Key_CheckIn +1422 0205 sz z +1423 0205 jmp Key_Debounced_End +1424 0205 jmp Key_Debounced_Process +1425 0205 +1426 0205 ;璝ぃ惠璶矪瞶叫 jmp Key_Debounced_End +1427 0205 nop +1428 0205 nop +1429 0205 nop +1430 0205 Key_Debounced_Process: +1431 0205 clr wdt + 文件:MAIN.ASM 盛群编译器版本 2.86 页次25 + +1432 0205 mov a,Key_Counter +1433 0205 addm a,pcl +1434 0205 jmp Key_Debounced_Process_WindowsMediaPlayer +1435 0205 jmp Key_Debounced_Process_Mute +1436 0205 jmp Key_Debounced_Process_Dec +1437 0205 jmp Key_Debounced_Process_Inc +1438 0205 jmp Key_Debounced_Process_PlayPause +1439 0205 jmp Key_Debounced_Process_Stop +1440 0205 jmp Key_Debounced_Process_NextTrack +1441 0205 jmp Key_Debounced_Process_PreviousTrack +1442 0205 +1443 0205 Key_Debounced_SetCheckIn: +1444 0205 mov Key_CheckIn,a +1445 0205 clr Key_Process +1446 0205 kmov Key_IncCounter,Const_Counter +1447 0205 kmov Key_DecCounter,Const_Counter +1448 0205 jmp Key_Debounced_End +1449 0205 +1450 0205 Key_Debounced_ClearReg: +1451 0205 clr acc +1452 0205 xor a,Key_CheckIn +1453 0205 sz z +1454 0205 jmp Key_Debounced_End +1455 0205 jmp Key_Debounced_ClearReg_2 +1456 0205 ; clr acc +1457 0205 ; xor a,Key_Process +1458 0205 ; snz z +1459 0205 ; jmp Key_Debounced_ClearReg_2 +1460 0205 ; jmp Key_Debounced_End +1461 0205 +1462 0205 Key_Debounced_ClearReg_2: +1463 0205 clr Key_CheckIn +1464 0205 clr Key_Process +1465 0205 +1466 0205 Key_Debounced_ClearReg_1: +1467 0205 CALL FIFO1_WR_CHECK +1468 0205 SNZ bFlag_FIFO_Ready +1469 0205 JMP Key_Debounced_End +1470 0205 +1471 0205 IF UseReportID +1472 0205 MOV A,01H ;REPORT ID +1473 0205 MOV FIFO_OUT1,A +1474 0205 MOV A,00H +1475 0205 MOV FIFO_OUT2,A +1476 0205 MOV A,02H +1477 0205 MOV FIFO_SendLen,A +1478 0205 ELSE +1479 0205 MOV A,00H +1480 0205 MOV FIFO_OUT1,A +1481 0205 MOV A,01H +1482 0205 MOV FIFO_SendLen,A +1483 0205 ENDIF +1484 0205 CALL WRITE_FIFO1 +1485 0205 ;//write fifo +1486 0205 nop +1487 0205 +1488 0205 +1489 0205 Key_Debounced_My_Function: +1490 0205 ;----------------------------------------------------------- +1491 0205 ; Here to add your another code !! + 文件:MAIN.ASM 盛群编译器版本 2.86 页次26 + +1492 0205 ;----------------------------------------------------------- +1493 0205 nop +1494 0205 +1495 0205 +1496 0205 jmp Key_Debounced_End +1497 0205 +1498 0205 Key_Debounced_End: +1499 0205 clr wdt +1500 0205 ret +1501 0205 ;=========================Process +1502 0205 Key_Debounced_Process_Mute: +1503 0205 clr wdt +1504 0205 CALL FIFO1_WR_CHECK +1505 0205 SNZ bFlag_FIFO_Ready +1506 0205 JMP Key_Debounced_End +1507 0205 +1508 0205 IF UseReportID +1509 0205 MOV A,01H ;REPORT ID +1510 0205 MOV FIFO_OUT1,A +1511 0205 MOV A,08H +1512 0205 MOV FIFO_OUT2,A +1513 0205 MOV A,02H +1514 0205 MOV FIFO_SendLen,A +1515 0205 ELSE +1516 0205 MOV A,08H +1517 0205 MOV FIFO_OUT1,A +1518 0205 MOV A,01H +1519 0205 MOV FIFO_SendLen,A +1520 0205 ENDIF +1521 0205 CALL WRITE_FIFO1 +1522 0205 nop +1523 0205 kmov Key_Process,Key_CheckIn +1524 0205 jmp Key_Debounced_End +1525 0205 Key_Debounced_Process_Dec: +1526 0205 clr wdt +1527 0205 sdz Key_DecCounter +1528 0205 jmp Key_Debounced_End +1529 0205 +1530 0205 CALL FIFO1_WR_CHECK +1531 0205 SNZ bFlag_FIFO_Ready +1532 0205 JMP Key_Debounced_End +1533 0205 IF UseReportID +1534 0205 MOV A,01H ;REPORT ID +1535 0205 MOV FIFO_OUT1,A +1536 0205 MOV A,02H +1537 0205 MOV FIFO_OUT2,A +1538 0205 MOV A,02H +1539 0205 MOV FIFO_SendLen,A +1540 0205 ELSE +1541 0205 MOV A,02H +1542 0205 MOV FIFO_OUT1,A +1543 0205 MOV A,01H +1544 0205 MOV FIFO_SendLen,A +1545 0205 ENDIF +1546 0205 CALL WRITE_FIFO1 +1547 0205 nop +1548 0205 kmov Key_DecCounter,Const_Counter +1549 0205 nop +1550 0205 jmp Key_Debounced_End +1551 0205 + 文件:MAIN.ASM 盛群编译器版本 2.86 页次27 + +1552 0205 Key_Debounced_Process_Inc: +1553 0205 clr wdt +1554 0205 sdz Key_IncCounter +1555 0205 jmp Key_Debounced_End +1556 0205 +1557 0205 CALL FIFO1_WR_CHECK +1558 0205 SNZ bFlag_FIFO_Ready +1559 0205 JMP Key_Debounced_End +1560 0205 IF UseReportID +1561 0205 MOV A,01H ;REPORT ID +1562 0205 MOV FIFO_OUT1,A +1563 0205 MOV A,01H +1564 0205 MOV FIFO_OUT2,A +1565 0205 MOV A,02H +1566 0205 MOV FIFO_SendLen,A +1567 0205 else +1568 0205 MOV A,01H +1569 0205 MOV FIFO_OUT1,A +1570 0205 MOV A,01H +1571 0205 MOV FIFO_SendLen,A +1572 0205 ENDIF +1573 0205 CALL WRITE_FIFO1 +1574 0205 nop +1575 0205 kmov Key_IncCounter,Const_Counter +1576 0205 nop +1577 0205 jmp Key_Debounced_End +1578 0205 +1579 0205 ;=============================================================== +1580 0205 ; User Add Some Key Debounced Code +1581 0205 ;=============================================================== +1582 0205 Key_Debounced_Process_WindowsMediaPlayer: +1583 0205 ;----------------------------------------------------------- +1584 0205 ; Here to add your another code !! +1585 0205 ;----------------------------------------------------------- +1586 0205 clr wdt +1587 0205 CALL FIFO1_WR_CHECK +1588 0205 SNZ bFlag_FIFO_Ready +1589 0205 JMP Key_Debounced_End +1590 0205 +1591 0205 IF UseReportID +1592 0205 MOV A,01H ;REPORT ID +1593 0205 MOV FIFO_OUT1,A +1594 0205 MOV A,04H +1595 0205 MOV FIFO_OUT2,A +1596 0205 MOV A,02H +1597 0205 MOV FIFO_SendLen,A +1598 0205 ELSE +1599 0205 MOV A,04H +1600 0205 MOV FIFO_OUT1,A +1601 0205 MOV A,01H +1602 0205 MOV FIFO_SendLen,A +1603 0205 ENDIF +1604 0205 CALL WRITE_FIFO1 +1605 0205 nop +1606 0205 kmov Key_Process,Key_CheckIn +1607 0205 jmp Key_Debounced_End +1608 0205 +1609 0205 Key_Debounced_Process_PlayPause: +1610 0205 ;----------------------------------------------------------- +1611 0205 ; Here to add your another code !! + 文件:MAIN.ASM 盛群编译器版本 2.86 页次28 + +1612 0205 ;----------------------------------------------------------- +1613 0205 clr wdt +1614 0205 CALL FIFO1_WR_CHECK +1615 0205 SNZ bFlag_FIFO_Ready +1616 0205 JMP Key_Debounced_End +1617 0205 +1618 0205 IF UseReportID +1619 0205 MOV A,01H ;REPORT ID +1620 0205 MOV FIFO_OUT1,A +1621 0205 MOV A,10H +1622 0205 MOV FIFO_OUT2,A +1623 0205 MOV A,02H +1624 0205 MOV FIFO_SendLen,A +1625 0205 ELSE +1626 0205 MOV A,10H +1627 0205 MOV FIFO_OUT1,A +1628 0205 MOV A,01H +1629 0205 MOV FIFO_SendLen,A +1630 0205 ENDIF +1631 0205 CALL WRITE_FIFO1 +1632 0205 nop +1633 0205 kmov Key_Process,Key_CheckIn +1634 0205 +1635 0205 jmp Key_Debounced_End +1636 0205 +1637 0205 Key_Debounced_Process_Stop: +1638 0205 ;----------------------------------------------------------- +1639 0205 ; Here to add your another code !! +1640 0205 ;----------------------------------------------------------- +1641 0205 clr wdt +1642 0205 CALL FIFO1_WR_CHECK +1643 0205 SNZ bFlag_FIFO_Ready +1644 0205 JMP Key_Debounced_End +1645 0205 IF UseReportID +1646 0205 MOV A,01H ;REPORT ID +1647 0205 MOV FIFO_OUT1,A +1648 0205 MOV A,20H +1649 0205 MOV FIFO_OUT2,A +1650 0205 MOV A,02H +1651 0205 MOV FIFO_SendLen,A +1652 0205 ELSE +1653 0205 MOV A,20H +1654 0205 MOV FIFO_OUT1,A +1655 0205 MOV A,01H +1656 0205 MOV FIFO_SendLen,A +1657 0205 ENDIF +1658 0205 CALL WRITE_FIFO1 +1659 0205 nop +1660 0205 kmov Key_Process,Key_CheckIn +1661 0205 +1662 0205 jmp Key_Debounced_End +1663 0205 +1664 0205 Key_Debounced_Process_NextTrack: +1665 0205 ;----------------------------------------------------------- +1666 0205 ; Here to add your another code !! +1667 0205 ;----------------------------------------------------------- +1668 0205 clr wdt +1669 0205 CALL FIFO1_WR_CHECK +1670 0205 SNZ bFlag_FIFO_Ready +1671 0205 JMP Key_Debounced_End + 文件:MAIN.ASM 盛群编译器版本 2.86 页次29 + +1672 0205 IF UseReportID +1673 0205 MOV A,01H ;REPORT ID +1674 0205 MOV FIFO_OUT1,A +1675 0205 MOV A,40H +1676 0205 MOV FIFO_OUT2,A +1677 0205 MOV A,02H +1678 0205 MOV FIFO_SendLen,A +1679 0205 ELSE +1680 0205 MOV A,40H +1681 0205 MOV FIFO_OUT1,A +1682 0205 MOV A,01H +1683 0205 MOV FIFO_SendLen,A +1684 0205 ENDIF +1685 0205 CALL WRITE_FIFO1 +1686 0205 nop +1687 0205 kmov Key_Process,Key_CheckIn +1688 0205 +1689 0205 jmp Key_Debounced_End +1690 0205 +1691 0205 Key_Debounced_Process_PreviousTrack: +1692 0205 ;----------------------------------------------------------- +1693 0205 ; Here to add your another code !! +1694 0205 ;----------------------------------------------------------- +1695 0205 clr wdt +1696 0205 CALL FIFO1_WR_CHECK +1697 0205 SNZ bFlag_FIFO_Ready +1698 0205 JMP Key_Debounced_End +1699 0205 IF UseReportID +1700 0205 MOV A,01H ;REPORT ID +1701 0205 MOV FIFO_OUT1,A +1702 0205 MOV A,80H +1703 0205 MOV FIFO_OUT2,A +1704 0205 MOV A,02H +1705 0205 MOV FIFO_SendLen,A +1706 0205 ELSE +1707 0205 MOV A,80H +1708 0205 MOV FIFO_OUT1,A +1709 0205 MOV A,01H +1710 0205 MOV FIFO_SendLen,A +1711 0205 ENDIF +1712 0205 CALL WRITE_FIFO1 +1713 0205 nop +1714 0205 kmov Key_Process,Key_CheckIn +1715 0205 +1716 0205 jmp Key_Debounced_End +1717 0205 ENDIF +1718 0205 +1719 0205 +1720 0205 wait_about_1s: +1721 0205 ;;;******************************************* +1722 0205 ;;;delay 1S 255*255*3*16*0.3333333=1.04S +1723 0205 ;;;******************************************* +1724 0205 0001 clr wdt +1725 0206 1F54 clr Delay_1 +1726 0207 1F55 clr Delay_2 +1727 0208 kmov Delay_3,16 +1728 020A wait_about_1s_loop: +1729 020A 0001 clr wdt +1730 020B 17D4 sdz Delay_1 +1731 020C 2A0A jmp wait_about_1s_loop + 文件:MAIN.ASM 盛群编译器版本 2.86 页次30 + +1732 020D 17D5 sdz Delay_2 +1733 020E 2A0A jmp wait_about_1s_loop +1734 020F 17D6 sdz Delay_3 +1735 0210 2A0A jmp wait_about_1s_loop +1736 0211 0001 clr wdt +1737 0212 0000 nop +1738 0213 0003 ret +1739 0214 +1740 0214 +1741 0214 +1742 0214 Public FIFO_Size +1743 0214 Public FIFO_SendLen +1744 0214 +1745 0214 Public FIFO_Type +1746 0214 Public FIFO_Request +1747 0214 Public FIFO_wValueL +1748 0214 Public FIFO_wValueH +1749 0214 Public FIFO_wIndexL +1750 0214 Public FIFO_wIndexH +1751 0214 Public FIFO_wLengthL +1752 0214 Public FIFO_wLengthH +1753 0214 +1754 0214 Public FIFO_Out1 +1755 0214 Public FIFO_Out2 +1756 0214 Public FIFO_Out3 +1757 0214 Public FIFO_Out4 +1758 0214 Public FIFO_Out5 +1759 0214 Public FIFO_Out6 +1760 0214 Public FIFO_Out7 +1761 0214 Public FIFO_Out8 +1762 0214 +1763 0214 Public USB_Interface +1764 0214 Public USB_Interface_Alt +1765 0214 Public USB_Configuration +1766 0214 +1767 0214 Public FIFO_ADDR +1768 0214 +1769 0214 +1770 0214 +1771 0214 Public nCmdIndex1 +1772 0214 +1773 0214 +1774 0214 Public Loop_Counter +1775 0214 Public Data_Count +1776 0214 Public Data_Start +1777 0214 Public FIFO_TEMP +1778 0214 Public bFlag_Real_Cmd +1779 0214 Public bFlag_FIFO_Ready +1780 0214 Public bFlag_FIFO_LEN0 +1781 0214 Public bFlag_RD_HTable +1782 0214 Public bFlag_wait_control_out +1783 0214 Public bFlag_SET_ADDRESS +1784 0214 Public bFlag_SCMD +1785 0214 Public bFlag_Enum_Ready +1786 0214 Public bFlag_SetConfiguration_Ready +1787 0214 Public bFlag_SetInterface_Ready +1788 0214 +1789 0214 +1790 0214 Public USB_ISR_END +1791 0214 Public USB_EP0_ISR_END + 文件:MAIN.ASM 盛群编译器版本 2.86 页次31 + +1792 0214 Public StageOne +1793 0214 +1794 0214 +1795 0214 +1796 0214 Public VolumeH_Save +1797 0214 Public VolumeL_Save +1798 0214 Public bFlag_Audio_Mute +1799 0214 ;modify for Remote Wakeup +1800 0214 public bRmtWakeup +1801 0214 public b_wakeup +1802 0214 +1803 0214 ;;----------------------------------------------- +1804 0214 #include QN8027Driver.asm + + +1805 0294 #include QN8072Sub.asm + + +1806 0339 +1807 0339 END + + + 0 Errors \ No newline at end of file diff --git a/PRG/MAIN.OBJ b/PRG/MAIN.OBJ new file mode 100644 index 0000000..cab4e88 Binary files /dev/null and b/PRG/MAIN.OBJ differ diff --git a/PRG/QN8027DRIVER.LST b/PRG/QN8027DRIVER.LST new file mode 100644 index 0000000..1e9eb3f --- /dev/null +++ b/PRG/QN8027DRIVER.LST @@ -0,0 +1,183 @@ +文件:QN8027DRIVER.ASM 盛群编译器版本 2.86 页次1 + + + 1 0000 ;;----------------------------------------------- + 2 0000 ;;function: QN8072_I2C_Read_Data + 3 0000 ;;in: mFMAddr + 4 0000 ;;out: mFMData + 5 0000 ;;description: Read AS6600 data + 6 0000 ;;----------------------------------------------- + 7 0000 QN8072_I2C_Read_Data: + 8 0000 + 9 0000 L_I2CRd_Data_lp: + 10 0000 0001 CLR WDT + 11 0001 + 12 0001 0000 CLR mFMACK +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 12 : 语法错误 + 13 0002 2000 R CALL I2C_START + 14 0003 0F00 MOV A,QN8072_I2C_WRITE_ADDR +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 14 : 未定义的符号 'QN8072_I2C_WRITE_ADDR' + 15 0004 0000 MOV mFMSend,A ;;Set send data +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 15 : 语法错误 + 16 0005 2000 R CALL Write_I2C_Byte ;;Send data + 17 0006 + 18 0006 0F00 MOV A,mFMAddr +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 18 : 未定义的符号 'mFMAddr' + 19 0007 0000 MOV mFMSend,A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 19 : 语法错误 + 20 0008 2000 R CALL Write_I2C_Byte + 21 0009 + 22 0009 0F00 MOV A,mFMACK +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 22 : 未定义的符号 'mFMACK' + 23 000A 0D00 OR A,0 + 24 000B 0000 SNZ Z ;;Z=1,OK +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 24 : 语法错误 + 25 000C 2800 R JMP L_I2CRd_Data_lp + 26 000D ;; + 27 000D L_I2CRd_Data_lp2: + 28 000D 0001 CLR WDT + 29 000E + 30 000E 0000 CLR mFMACK +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 30 : 语法错误 + 31 000F 2000 R CALL I2C_START + 32 0010 + 33 0010 0F00 MOV A,QN8072_I2C_READ_ADDR +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 33 : 未定义的符号 'QN8072_I2C_READ_ADDR' + 34 0011 0000 MOV mFMSend,A ;;Set send data +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 34 : 语法错误 + 35 0012 2000 R CALL Write_I2C_Byte ;;Send data + 36 0013 + 37 0013 0F00 MOV A,mFMACK +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 37 : 未定义的符号 'mFMACK' + 38 0014 0D00 OR A,0 + 39 0015 0000 SNZ Z ;;Z=1,OK +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 39 : 语法错误 + 40 0016 2800 R JMP L_I2CRd_Data_lp2 + 41 0017 + 42 0017 2000 R CALL Read_I2C_Byte + 43 0018 0000 MOV mFMData,A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 43 : 语法错误 + 44 0019 2000 R CALL sendNoAck + 45 001A + 46 001A 2000 R CALL I2C_STOP + 文件:QN8027DRIVER.ASM 盛群编译器版本 2.86 页次2 + + 47 001B 0003 RET + 48 001C + 49 001C ;;----------------------------------------------- + 50 001C ;;function: QN8027_I2C_Write_Data + 51 001C ;;in: mFMAddr,mFMData + 52 001C ;;out: + 53 001C ;;description: Write QN8027 data + 54 001C ;;----------------------------------------------- + 55 001C QN8027_I2C_Write_Data: + 56 001C + 57 001C L_I2CWt_Data_lp: + 58 001C 0001 CLR WDT + 59 001D + 60 001D 0000 CLR mFMACK +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 60 : 语法错误 + 61 001E 2000 R CALL I2C_START + 62 001F 0F00 MOV A,QN8072_I2C_WRITE_ADDR +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 62 : 未定义的符号 'QN8072_I2C_WRITE_ADDR' + 63 0020 0000 MOV mFMSend,A ;;Set send data +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 63 : 语法错误 + 64 0021 2000 R CALL Write_I2C_Byte ;;Send data + 65 0022 + 66 0022 0F00 MOV A,mFMAddr +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 66 : 未定义的符号 'mFMAddr' + 67 0023 0000 MOV mFMSend,A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 67 : 语法错误 + 68 0024 2000 R CALL Write_I2C_Byte + 69 0025 + 70 0025 0F00 MOV A,mFMData +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 70 : 未定义的符号 'mFMData' + 71 0026 0000 MOV mFMSend,A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 71 : 语法错误 + 72 0027 2000 R CALL Write_I2C_Byte + 73 0028 + 74 0028 2000 R CALL I2C_STOP + 75 0029 + 76 0029 0F00 MOV A,mFMACK +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 76 : 未定义的符号 'mFMACK' + 77 002A 0D00 OR A,0 + 78 002B 0000 SNZ Z ;;Z=1,OK +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 78 : 语法错误 + 79 002C 2800 R JMP L_I2CWt_Data_lp + 80 002D + 81 002D 0003 RET + 82 002E + 83 002E ;;----------------------------------------------- + 84 002E ;;function: Delay5us + 85 002E ;;in: NULL + 86 002E ;;out: NULL + 87 002E ;;description: Delay 5us + 88 002E ;;----------------------------------------------- + 89 002E Delay5us: + 90 002E 2800 R JMP $+1 + 91 002F 2800 R JMP $+1 + 92 0030 2800 R JMP $+1 + 93 0031 2800 R JMP $+1 + 94 0032 2800 R JMP $+1 + 95 0033 2800 R JMP $+1 + 96 0034 2800 R JMP $+1 + 97 0035 0000 NOP + 文件:QN8027DRIVER.ASM 盛群编译器版本 2.86 页次3 + + 98 0036 0003 RET + 99 0037 + 100 0037 ;;----------------------------------------------- + 101 0037 ;;function: sendAck + 102 0037 ;;in: NULL + 103 0037 ;;out: NULL + 104 0037 ;;description: Send ACK + 105 0037 ;;----------------------------------------------- + 106 0037 sendAck: + 107 0037 0000 CLR P_SDA ;;0 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 107 : 语法错误 + 108 0038 2000 R CALL Delay5us + 109 0039 + 110 0039 0000 SET P_SCL +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 110 : 语法错误 + 111 003A 2000 R CALL Delay5us + 112 003B 0000 CLR P_SCL +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 112 : 语法错误 + 113 003C 2000 R CALL Delay5us + 114 003D 0003 RET + 115 003E + 116 003E ;;----------------------------------------------- + 117 003E ;;function: sendNoAck + 118 003E ;;in: NULL + 119 003E ;;out: NULL + 120 003E ;;description: Send No ACK + 121 003E ;;----------------------------------------------- + 122 003E sendNoAck: + 123 003E 0000 SET P_SDA ;;1 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 123 : 语法错误 + 124 003F 2000 R CALL Delay5us + 125 0040 + 126 0040 0000 SET P_SCL +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 126 : 语法错误 + 127 0041 2000 R CALL Delay5us + 128 0042 0000 CLR P_SCL +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 128 : 语法错误 + 129 0043 2000 R CALL Delay5us + 130 0044 0003 RET + 131 0045 + 132 0045 ;;----------------------------------------------- + 133 0045 ;;function: Read_I2C_Byte + 134 0045 ;;in: NULL + 135 0045 ;;out: ACC + 136 0045 ;;description: Read data + 137 0045 ;;----------------------------------------------- + 138 0045 Read_I2C_Byte: + 139 0045 0000 CLR mFMSend +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 139 : 语法错误 + 140 0046 0F08 MOV A,8D + 141 0047 0000 MOV mFMCnt,A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM 141 : 语法错误 +Error(A0052) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8027DRIVER.ASM : 错误过多 + + + + 31 Errors \ No newline at end of file diff --git a/PRG/QN8027Driver.asm b/PRG/QN8027Driver.asm new file mode 100644 index 0000000..be4d2b9 --- /dev/null +++ b/PRG/QN8027Driver.asm @@ -0,0 +1,237 @@ +;;----------------------------------------------- +;;function: QN8072_I2C_Read_Data +;;in: mFMAddr +;;out: mFMData +;;description: Read AS6600 data +;;----------------------------------------------- +QN8072_I2C_Read_Data: + +L_I2CRd_Data_lp: + CLR WDT + + CLR mFMACK + CALL I2C_START + MOV A,QN8072_I2C_WRITE_ADDR + MOV mFMSend,A ;;Set send data + CALL Write_I2C_Byte ;;Send data + + MOV A,mFMAddr + MOV mFMSend,A + CALL Write_I2C_Byte + + MOV A,mFMACK + OR A,0 + SNZ Z ;;Z=1,OK + JMP L_I2CRd_Data_lp +;; +L_I2CRd_Data_lp2: + CLR WDT + + CLR mFMACK + CALL I2C_START + + MOV A,QN8072_I2C_READ_ADDR + MOV mFMSend,A ;;Set send data + CALL Write_I2C_Byte ;;Send data + + MOV A,mFMACK + OR A,0 + SNZ Z ;;Z=1,OK + JMP L_I2CRd_Data_lp2 + + CALL Read_I2C_Byte + MOV mFMData,A + CALL sendNoAck + + CALL I2C_STOP + RET + +;;----------------------------------------------- +;;function: QN8027_I2C_Write_Data +;;in: mFMAddr,mFMData +;;out: +;;description: Write QN8027 data +;;----------------------------------------------- +QN8027_I2C_Write_Data: + +L_I2CWt_Data_lp: + CLR WDT + + CLR mFMACK + CALL I2C_START + MOV A,QN8072_I2C_WRITE_ADDR + MOV mFMSend,A ;;Set send data + CALL Write_I2C_Byte ;;Send data + + MOV A,mFMAddr + MOV mFMSend,A + CALL Write_I2C_Byte + + MOV A,mFMData + MOV mFMSend,A + CALL Write_I2C_Byte + + CALL I2C_STOP + + MOV A,mFMACK + OR A,0 + SNZ Z ;;Z=1,OK + JMP L_I2CWt_Data_lp + + RET + +;;----------------------------------------------- +;;function: Delay5us +;;in: NULL +;;out: NULL +;;description: Delay 5us +;;----------------------------------------------- +Delay5us: + JMP $+1 + JMP $+1 + JMP $+1 + JMP $+1 + JMP $+1 + JMP $+1 + JMP $+1 + NOP + RET + +;;----------------------------------------------- +;;function: sendAck +;;in: NULL +;;out: NULL +;;description: Send ACK +;;----------------------------------------------- +sendAck: + CLR P_SDA ;;0 + CALL Delay5us + + SET P_SCL + CALL Delay5us + CLR P_SCL + CALL Delay5us + RET + +;;----------------------------------------------- +;;function: sendNoAck +;;in: NULL +;;out: NULL +;;description: Send No ACK +;;----------------------------------------------- +sendNoAck: + SET P_SDA ;;1 + CALL Delay5us + + SET P_SCL + CALL Delay5us + CLR P_SCL + CALL Delay5us + RET + +;;----------------------------------------------- +;;function: Read_I2C_Byte +;;in: NULL +;;out: ACC +;;description: Read data +;;----------------------------------------------- +Read_I2C_Byte: + CLR mFMSend + MOV A,8D + MOV mFMCnt,A + + SET P_SDAC ;;SDA input +L_ReadI2C_lp: + CLR C + RLC mFMSend + + CLR P_SCL + CALL Delay5us + SET P_SCL + CALL Delay5us + + SZ P_SDA + SET mFMSend.0 ;;save data + + SDZ mFMCnt + JMP L_ReadI2C_lp + + CLR P_SCL + CLR P_SDAC ;;SDA Output + CALL Delay5us + + MOV A,mFMSend + RET + +;;----------------------------------------------- +;;function: Write_I2C_Byte +;;in: mFMSend +;;out: mFMAck +;;description: Write data +;;----------------------------------------------- +Write_I2C_Byte: + MOV A,8D + MOV mFMCnt,A + +L_WriteI2C_lp: + SZ mFMSend.7 + SET P_SDA + SNZ mFMSend.7 + CLR P_SDA + + RLC mFMSend ;;Next bit + + CALL Delay5us + SET P_SCL + CALL Delay5us + CLR P_SCL + + SDZ mFMCnt + JMP L_WriteI2C_lp ;;Send data + + ;;Get ACK + CALL Delay5us + SET P_SDAC ;;SDA input + CALL Delay5us + SET P_SCL + CALL Delay5us + SZ P_SDA + INC mFMACK ;;ACK=1,error + + CLR P_SCL + CALL Delay5us + CLR P_SDAC ;;SDA output + RET + +;;----------------------------------------------- +;;function: I2C_START +;;in: NULL +;;out: NULL +;;description: IIC Start +;;----------------------------------------------- +I2C_START: + SET P_SDA ;;Dat H + CALL Delay5us + SET P_SCL ;;CLK H + CALL Delay5us + CLR P_SDA ;;Dat L + CALL Delay5us + CLR P_SCL ;;CLK L + CALL Delay5us + RET + +;;----------------------------------------------- +;;function: I2C_Stop +;;in: NULL +;;out: NULL +;;description: IIC Stop +;;----------------------------------------------- +I2C_Stop: + CLR P_SDA ;;Dat L + CALL Delay5us + SET P_SCL ;;CLK L + CALL Delay5us + SET P_SDA ;;Dat H + CALL Delay5us + RET + diff --git a/PRG/QN8072SUB.LST b/PRG/QN8072SUB.LST new file mode 100644 index 0000000..fa2f142 --- /dev/null +++ b/PRG/QN8072SUB.LST @@ -0,0 +1,141 @@ +文件:QN8072SUB.ASM 盛群编译器版本 2.86 页次1 + + + 1 0000 ;;----------------------------------------------- + 2 0000 ;;function: QN8072Init + 3 0000 ;;in: mFreqL,mFreqH + 4 0000 ;;out: NULL + 5 0000 ;;description: Initial QN8027 Configer + 6 0000 ;;----------------------------------------------- + 7 0000 QN8072Init: + 8 0000 ;; + 9 0000 0F04 MOV A,04H + 10 0001 0000 MOV mFMAddr,a ;;VGA +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 10 : 语法错误 + 11 0002 0F00 MOV A,mQNReg[4] ;;58H +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 11 : 未定义的符号 'mQNReg' + 12 0003 0000 MOV mFMData,A ;;12M/101/2db/5k +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 12 : 语法错误 + 13 0004 2000 CALL QN8027_I2C_Write_Data +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 13 : 未定义的符号 'QN8027_I2C_Write_Data' + 14 0005 + 15 0005 2000 R CALL Delay20ms + 16 0006 ;; + 17 0006 0F00 MOV A,00H + 18 0007 0000 MOV mFMAddr,a ;;SYSTEM +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 18 : 语法错误 + 19 0008 0F00 MOV A,mQNReg[0] ;;51H +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 19 : 未定义的符号 'mQNReg' + 20 0009 0000 MOV mFMData,A ;;MONO/NO MUTE +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 20 : 语法错误 + 21 000A 2000 CALL QN8027_I2C_Write_Data +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 21 : 未定义的符号 'QN8027_I2C_Write_Data' + 22 000B + 23 000B 2000 R CALL Delay20ms + 24 000C ;; + 25 000C 0000 CLR mQNReg[0].6 +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 25 : 语法错误 + 26 000D 0F00 MOV A,00H + 27 000E 0000 MOV mFMAddr,a ;;SYSTEM +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 27 : 语法错误 + 28 000F 0F00 MOV A,mQNReg[0] ;;51H +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 28 : 未定义的符号 'mQNReg' + 29 0010 0000 MOV mFMData,A ;;MONO/NO MUTE +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 29 : 语法错误 + 30 0011 2000 CALL QN8027_I2C_Write_Data +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 30 : 未定义的符号 'QN8027_I2C_Write_Data' + 31 0012 + 32 0012 0F18 MOV A,18H + 33 0013 0000 MOV mFMAddr,A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 33 : 语法错误 + 34 0014 0FE4 MOV A,0E4H + 35 0015 0000 MOV mFMData,A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 35 : 语法错误 + 36 0016 2000 CALL QN8027_I2C_Write_Data +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 36 : 未定义的符号 'QN8027_I2C_Write_Data' + 37 0017 + 38 0017 0F1B MOV A,1bH + 39 0018 0000 MOV mFMAddr,A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 39 : 语法错误 + 40 0019 0FF0 MOV A,0f0H + 41 001A 0000 MOV mFMData,A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 41 : 语法错误 + 文件:QN8072SUB.ASM 盛群编译器版本 2.86 页次2 + + 42 001B 2000 CALL QN8027_I2C_Write_Data +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 42 : 未定义的符号 'QN8027_I2C_Write_Data' + 43 001C + 44 001C 0000 SET mQNReg[0].5 ;;Enter transmit mode +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 44 : 语法错误 + 45 001D 2000 R CALL QN8072FreqSet ;;Set fre + 46 001E + 47 001E 0F02 MOV A,02H + 48 001F 0000 MOV mFMAddr,A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 48 : 语法错误 + 49 0020 0FE9 MOV A,0e9H + 50 0021 0000 MOV mFMData,A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 50 : 语法错误 + 51 0022 2000 CALL QN8027_I2C_Write_Data +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 51 : 未定义的符号 'QN8027_I2C_Write_Data' + 52 0023 + 53 0023 0F04 MOV A,04H + 54 0024 0000 MOV mFMAddr,A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 54 : 语法错误 + 55 0025 0F42 MOV A,42H + 56 0026 0000 MOV mFMData,A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 56 : 语法错误 + 57 0027 2000 CALL QN8027_I2C_Write_Data +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 57 : 未定义的符号 'QN8027_I2C_Write_Data' + 58 0028 + 59 0028 0003 RET + 60 0029 + 61 0029 ;;----------------------------------------------- + 62 0029 ;;function: QN8072FreqSet + 63 0029 ;;in: mFreqL,mFreqH + 64 0029 ;;out: NULL + 65 0029 ;;description: Set QN8072 Freq + 66 0029 ;; Frf = (76 + 0.05*Channel) -> Channel = (Frf-76)/0.05 + 67 0029 ;;----------------------------------------------- + 68 0029 QN8072FreqSet: + 69 0029 ;; CLR INTC0.@INTC0_EMI ;Global interrupt + 70 0029 ;; CLR data0 + 71 0029 ;; CLR data1 + 72 0029 ;; + 73 0029 ;; MOV A,mFreqL + 74 0029 ;; SUB A,0B0H + 75 0029 ;; MOV data0,A + 76 0029 ;; MOV A,mFreqH + 77 0029 ;; SBC A,1DH + 78 0029 ;; MOV data1,A ;;(Freq - 7600) + 79 0029 ;; + 80 0029 ;; MOV A,05H + 81 0029 ;; MOV data5,A + 82 0029 ;; CLR data4 + 83 0029 ;; CALL unbin_div_16 ;;(Freq - 7600)/5 -> to1to0 + 84 0029 ;; + 85 0029 ;; MOV A,03H + 86 0029 ;; ANDM A,to1 + 87 0029 ;; MOV A,0FCH + 88 0029 ;; ANDM A,mQNReg[0] + 89 0029 ;; MOV A,to1 + 90 0029 ;; ORM A,mQNReg[0] + 91 0029 ;; MOV A,to0 + 92 0029 ;; MOV mQNReg[1],A + 93 0029 ;; + 文件:QN8072SUB.ASM 盛群编译器版本 2.86 页次3 + + 94 0029 + 95 0029 0F00 MOV A,cFreqDefL +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 95 : 未定义的符号 'cFreqDefL' + 96 002A 0000 MOV mQNReg[1],A +Error(A0024) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 96 : 语法错误 + 97 002B 0F00 MOV A,mQNReg[0] +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 97 : 未定义的符号 'mQNReg' + 98 002C 0EFC AND A,0FCH + 99 002D 0D00 OR A,cFreqDefH +Error(A0005) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM 99 : 未定义的符号 'cFreqDefH' +Error(A0052) E:\项目\USB 音频发射\USB AUDIO(PC)\COD\PRG\QN8072SUB.ASM : 错误过多 + + + + 31 Errors \ No newline at end of file diff --git a/PRG/QN8072Sub.asm b/PRG/QN8072Sub.asm new file mode 100644 index 0000000..1216804 --- /dev/null +++ b/PRG/QN8072Sub.asm @@ -0,0 +1,298 @@ +;;----------------------------------------------- +;;function: QN8072Init +;;in: mFreqL,mFreqH +;;out: NULL +;;description: Initial QN8027 Configer +;;----------------------------------------------- +QN8072Init: +;; + MOV A,03H + MOV mFMAddr,a ;;crystal + MOV A,mQNReg[3] ;;50H + MOV mFMData,A ;;digital clock for XTAL1 + CALL QN8027_I2C_Write_Data +;; + MOV A,04H + MOV mFMAddr,a ;;VGA + MOV A,mQNReg[4] ;;58H + MOV mFMData,A ;;12M/101/2db/5k + CALL QN8027_I2C_Write_Data + + CALL Delay20ms +;; + MOV A,00H + MOV mFMAddr,a ;;SYSTEM + MOV A,mQNReg[0] ;;51H + MOV mFMData,A ;;MONO/NO MUTE + CALL QN8027_I2C_Write_Data + + CALL Delay20ms +;; + CLR mQNReg[0].6 + MOV A,00H + MOV mFMAddr,a ;;SYSTEM + MOV A,mQNReg[0] ;;51H + MOV mFMData,A ;;MONO/NO MUTE + CALL QN8027_I2C_Write_Data + + MOV A,18H + MOV mFMAddr,A + MOV A,0E4H + MOV mFMData,A + CALL QN8027_I2C_Write_Data + + MOV A,1bH + MOV mFMAddr,A + MOV A,0f0H + MOV mFMData,A + CALL QN8027_I2C_Write_Data + + SET mQNReg[0].5 ;;Enter transmit mode + CALL QN8072FreqSet ;;Set fre + + MOV A,02H + MOV mFMAddr,A + MOV A,0e9H + MOV mFMData,A + CALL QN8027_I2C_Write_Data + + MOV A,04H + MOV mFMAddr,A + MOV A,42H + MOV mFMData,A + CALL QN8027_I2C_Write_Data + + RET + +;;----------------------------------------------- +;;function: QN8072FreqSet +;;in: mFreqL,mFreqH +;;out: NULL +;;description: Set QN8072 Freq +;; Frf = (76 + 0.05*Channel) -> Channel = (Frf-76)/0.05 +;;----------------------------------------------- +QN8072FreqSet: +;; CLR INTC0.@INTC0_EMI ;Global interrupt +;; CLR data0 +;; CLR data1 +;; +;; MOV A,mFreqL +;; SUB A,0B0H +;; MOV data0,A +;; MOV A,mFreqH +;; SBC A,1DH +;; MOV data1,A ;;(Freq - 7600) +;; +;; MOV A,05H +;; MOV data5,A +;; CLR data4 +;; CALL unbin_div_16 ;;(Freq - 7600)/5 -> to1to0 +;; +;; MOV A,03H +;; ANDM A,to1 +;; MOV A,0FCH +;; ANDM A,mQNReg[0] +;; MOV A,to1 +;; ORM A,mQNReg[0] +;; MOV A,to0 +;; MOV mQNReg[1],A +;; + + MOV A,cFreqDefL + MOV mQNReg[1],A + MOV A,mQNReg[0] + AND A,0FCH + OR A,cFreqDefH + MOV mQNReg[0],A ;;Set define freq + + MOV A,00H + MOV mFMAddr,A + MOV A,mQNReg[0] + MOV mFMData,A + CALL QN8027_I2C_Write_Data + + MOV A,01H + MOV mFMAddr,A + MOV A,mQNReg[1] + MOV mFMData,A + CALL QN8027_I2C_Write_Data + +;; SET INTC0.@INTC0_EMI ;Global interrupt + RET + +;;----------------------------------------------- +;;function: Delay20ms +;;in: NULL +;;out: NULL +;;description: Delay 20ms +;;----------------------------------------------- +Delay20ms: + MOV A,200D + MOV mMK1,A + +L_Dly20ms_1: + MOV A,100D + MOV mMK0,A + CLR WDT + + SDZ mMK0 + JMP $-1 + NOP ;;3*100 = 100us + + SDZ mMK1 + JMP L_Dly20ms_1 + + RET + +;;----------------------------------------------- +;;function: QN8027 +;;in: FIFO_out1~FIFO_out8 +;;out: NULL +;;description: deal QN8027 Data from EP1 +;;----------------------------------------------- +QN8027: + ;;Type check (main or set) + MOV A,cFMUSBType_Main + XOR A,FIFO_out2 + SZ Z + JMP L_FMType_Main ;;Main data + + MOV A,cFMUSBType_Set + XOR A,FIFO_out2 + SZ Z + JMP L_FMType_Set ;;Set data + JMP L_QN8027_end + +;;----------------------------------------------- +L_FMType_Main: + ;;FIFO6 is Key + SZ FIFO_out6.@FMKeyTun + CALL L_FMFun_FMFreSet + + SZ FIFO_out6.@FMKeyOn + CALL L_FMFun_FMWork + + SZ FIFO_out6.@FMKeyOff + CALL L_FMFun_FMIdle + + SZ FIFO_out6.@FMKeyMute + CALL L_FMFun_FMMute + + SZ FIFO_out6.@FMKeyNoMute + CALL L_FMFun_FMNoMute + + ;;FIFO5 is PAC-VALUE(0x10) + SNZ mQNReg[0].5 + JMP L_QN8027_end ;;Idle mode + + MOV A,FIFO_out5 + MOV mFMData,A + MOV A,10H + MOV mFMAddr,A + CALL QN8027_I2C_Write_Data + + ;;In idle and work for PA-ok +;; CALL L_FMFun_FMMute ;;Mute +;; CALL L_FMFun_FMIdle +;; CALL L_FMFun_FMWork +;; SZ FIFO_out6.@FMKeyNoMute +;; CALL L_FMFun_FMNoMute + JMP L_QN8027_end + +;; +L_FMFun_FMNoMute: + CLR mQNReg[0].3 ;;Not mute + JMP $+2 +L_FMFun_FMMute: + SET mQNReg[0].3 + + MOV A,00H + MOV mFMAddr,A + MOV A,mQNReg[0] + MOV mFMData,A + CALL QN8027_I2C_Write_Data ;;Set Mute/No Mute +;; JMP L_QN8027_end + RET + +;; +L_FMFun_FMIdle: + SET P_LED + CLR mQNReg[0].5 ;;Idle mode + JMP $+3 +L_FMFun_FMWork: + CLR P_LED + SET mQNReg[0].5 ;;Work mode + + MOV A,00H + MOV mFMAddr,A + MOV A,mQNReg[0] + MOV mFMData,A + CALL QN8027_I2C_Write_Data ;;Set Idle/Work +;; JMP L_QN8027_end + RET + +;; +L_FMFun_FMFreSet: + ;;FIFO3/4 is Freq + MOV A,FIFO_out4 + MOV mQNReg[1],A + MOV A,0FCH + ANDM A,mQNReg[0] + MOV A,FIFO_out3 + AND A,03H + ORM A,mQNReg[0] + + MOV A,00H + MOV mFMAddr,A + MOV A,mQNReg[0] + MOV mFMData,A + CALL QN8027_I2C_Write_Data + + MOV A,01H + MOV mFMAddr,A + MOV A,mQNReg[1] + MOV mFMData,A + CALL QN8027_I2C_Write_Data +;; JMP L_QN8027_end + RET + +;;----------------------------------------------- +L_FMType_Set: + ;;FIFO_out3 is TX-GAIN + MOV A,mQNReg[4] + AND A,8CH ;;Set GVGA & RIN(GVGA = 000/RIN=11 --> GVGA=101/RIN=11 --> GVGA=000/RIN=10 --> GVGA=101/RIN=0) + OR A,FIFO_out3 + MOV mQNReg[4],A + + MOV A,04H + MOV mFMAddr,A + MOV A,mQNReg[4] + MOV mFMData,A + CALL QN8027_I2C_Write_Data ;;Set TX-GAIN + + ;;Set other + CLR mQNReg[0].4 + SZ FIFO_out4.@FMMono + SET mQNReg[0].4 + + CLR mQNReg[2].7 + SZ FIFO_out4.@FMDeemp + SET mQNReg[2].7 + + MOV A,00H + MOV mFMAddr,A + MOV A,mQNReg[0] + MOV mFMData,A + CALL QN8027_I2C_Write_Data ;;FM Mono + + MOV A,02H + MOV mFMAddr,A + MOV A,mQNReg[2] + MOV mFMData,A + CALL QN8027_I2C_Write_Data ;;FM De-emp + ;;JMP L_QN8027_end + + +L_QN8027_end: + RET + diff --git a/PRG/cal.asm b/PRG/cal.asm new file mode 100644 index 0000000..7fe18c3 --- /dev/null +++ b/PRG/cal.asm @@ -0,0 +1,141 @@ +;8 bit unsigned mul +unbin_mul_8 proc ;data0*data4---->to1to0 + init + mov a, 08h + mov count0, a +rradd: + rrc to1 + rrc data4 + snz [0ah].0 + jmp rr1 ;当前data4.0=0,移位 + mov a, data0 ;当前data4.0=1,移位相加 + addm a, to1 +rr1: + sdz count0 + jmp rradd + rrc to1 + rrc data4 + mov a, data4 + mov to0, a + ret +unbin_mul_8 endp + + +;8 bit unsigned div +unbin_div_8 proc ;data0/data4---->data0(to0)---to1 + init + mov a, 08h ;循环次数8 + mov count0, a + + sz data4 ;除数为0则溢出 + jmp start0 + jmp over8 +start0: + sz data0 ;被除数为0则结束 + jmp div0 + jmp dispa +div0: + clr [0Ah].0 ;准备左移 + rlc data0 + rlc to1 ;左移一位结束 + mov a, to1 ;开始部分余数减除数 + sub a, data4 + snz [0Ah].0 + jmp next0 ;不够减则转移 + mov to1, a ;够减则商为1 + inc data0 +next0: + sdz count0 + jmp div0 +dispa: + mov a, data0 ;显示商 + mov to0, a +;; mov a, data4 +;; mov to1, a + ret +over8: + ret +unbin_div_8 endp + + +;16 bit unsigned div +unbin_div_16 proc ;data0data1/data4data5---->data1data0(to1to0)---to2to3 + init + mov a, 10h + mov count0, a + sz data5 + jmp start16 + sz data4 + jmp start16 + jmp over16 +start16: + sz data1 + jmp div16 + sz data0 + jmp div16 + jmp dispa16 +div16: + clr [0Ah].0 + rlc data0 + rlc data1 + rlc to2 + rlc to3 + mov a, to2 + sub a, data4 + mov com3, a + mov a, to3 + sbc a, data5 + snz [0Ah].0 + jmp next16 + mov to3, a + mov a, com3 + mov to2, a + mov a, 01h + addm a, data0 + mov a, 00h + adcm a, data1 +next16: + sdz count0 + jmp div16 +dispa16: + mov a, data0 + mov to0, a + mov a, data1 + mov to1, a + mov a, 00h + mov to2, a + ret +over16: + ret +unbin_div_16 endp + +;16 bit unsigned mul +unbin_mul_16 proc + init + mov a, 10h ;data0data1*data4data5---->to0to1to2to3 + mov count0, a + clr [0ah].0 +rradd16: + rrc to3 + rrc to2 + rrc data5 + rrc data4 + snz [0ah].0 + jmp rr116 + mov a, data0 + addm a, to2 + mov a, data1 + adcm a, to3 +rr116: + sdz count0 + jmp rradd16 + rrc to3 + rrc to2 + rrc data5 + rrc data4 + mov a, data4 + mov to0, a + mov a, data5 + mov to1, a + ret +unbin_mul_16 endp diff --git a/PRG/const.inc b/PRG/const.inc new file mode 100644 index 0000000..26b1e4f --- /dev/null +++ b/PRG/const.inc @@ -0,0 +1,304 @@ +;**************************************************************** +;Author:Ansonku +;Email:ansonku@holtek.com.tw +;================================================================ +;Update Information +;================================================================ +;2004/09/27 +;define register for usb audio speaker chip +;the usb chip register are all at bank0 +; +;**************************************************************** + + +USB_REG_BANK EQU 0 + + +;R0 EQU [00H] +;MP0 EQU [01H] +;R1 EQU [02H] +;MP1 EQU [03H] + +;ACC EQU [05H] +;PCL EQU [06H] +;TBLP EQU [07H] +;TBLH EQU [08H] + +;STATUS EQU [0AH] +;INTC0 EQU [0BH] + +;TMR0 EQU [0DH] +;TMR0C EQU [0EH] +;TMR1H EQU [0FH] +;TMR1L EQU [10H] +;TMR1C EQU [11H] +;PA EQU [12H] +;PAC EQU [13H] +;PB EQU [14H] +;PBC EQU [15H] +;PC EQU [16H] +;PCC EQU [17H] +;PD EQU [18H] +;PDC EQU [19H] +;PE EQU [1AH] +;PEC EQU [1BH] + +;INTC1 EQU [1EH] + +EP0_FIFO_SIZE EQU 8 + +USB_FIFO0_SIZE EQU 8 +USB_FIFO1_SIZE EQU 8 +USB_FIFO2_SIZE EQU 8 +USB_FIFO3_SIZE EQU 8 +USB_FIFO4_SIZE EQU 8 +USB_FIFO5_SIZE EQU 8 + + + +USB_USC EQU 020H +USB_USR EQU 021H +USB_UCC EQU 022H +USB_AWR EQU 023H +USB_STALL EQU 024H +USB_SIES EQU 025H +USB_MISC EQU 026H +USB_SETIO EQU 027H +USB_FIFO0 EQU 028H +USB_FIFO1 EQU 029H +USB_FIFO2 EQU 02AH +USB_FIFO3 EQU 02BH +USB_FIFO4 EQU 02CH +USB_FIFO5 EQU 02DH + + +;bit position define +@BIT0 EQU 0 +@BIT1 EQU 1 +@BIT2 EQU 2 +@BIT3 EQU 3 +@BIT4 EQU 4 +@BIT5 EQU 5 +@BIT6 EQU 6 +@BIT7 EQU 7 + +;INTC0 +@INTC0_EMI EQU @BIT0 +@INTC0_EEI EQU @BIT1 +@INTC0_ET0I EQU @BIT2 +@INTC0_ET1I EQU @BIT3 +@INTC0_EIF EQU @BIT4 +@INTC0_T0F EQU @BIT5 +@INTC0_T1F EQU @BIT6 + +;INTC1 +@INTC1_EUI EQU @BIT0 +@INTC1_EADI EQU @BIT1 +@INTC1_ESII EQU @BIT2 +@INTC1_USBF EQU @BIT4 +@INTC1_ADF EQU @BIT5 +@INTC1_SIF EQU @BIT6 + +;USC +@USC_SUSP EQU @BIT0 +@USC_RMWK EQU @BIT1 +@USC_URST EQU @BIT2 +@USC_RESUME EQU @BIT3 +@USC_V33C EQU @BIT4 +@USC_URD EQU @BIT7 + +;USR +@USR_EP0F EQU @BIT0 +@USR_EP1F EQU @BIT1 +@USR_EP2F EQU @BIT2 +@USR_EP3F EQU @BIT3 +@USR_EP4F EQU @BIT4 +@USR_EP5F EQU @BIT5 + + +;UCC [20H] +@UCC_EPS0 EQU @BIT0 +@UCC_EPS1 EQU @BIT1 +@UCC_EPS2 EQU @BIT2 +@UCC_USBCKEN EQU @BIT3 +@UCC_SUSP2 EQU @BIT4 +@UCC_SYSCLK EQU @BIT6 +@UCC_UFLS EQU @BIT7 + +;AWR +@AWR_WKEN EQU @BIT0 + +;STALL +@STALL_STL0 EQU @BIT0 +@STALL_STL1 EQU @BIT1 +@STALL_STL2 EQU @BIT2 +@STALL_STL3 EQU @BIT3 +@STALL_STL4 EQU @BIT4 +@STALL_STL5 EQU @BIT5 + +;SIES +@SIES_ASET EQU @BIT0 +@SIES_ERR EQU @BIT1 +@SIES_OUT EQU @BIT2 +@SIES_IN EQU @BIT3 +@SIES_NAK EQU @BIT4 +@SIES_SETUP EQU @BIT5 + +;MISC +@MISC_REQ EQU @BIT0 +@MISC_TX EQU @BIT1 +@MISC_CLEAR EQU @BIT2 +@MISC_ISOEN EQU @BIT4 +@MISC_SCMD EQU @BIT5 +@MISC_READY EQU @BIT6 +@MISC_LEN0 EQU @BIT7 + +;SETIO +@SETIO_DATATG EQU @BIT0 +@SETIO_SETIO1 EQU @BIT1 +@SETIO_SETIO2 EQU @BIT2 +@SETIO_SETIO3 EQU @BIT3 +@SETIO_SETIO4 EQU @BIT4 +@SETIO_SETIO5 EQU @BIT5 + +; +;=================================================== +;Descriptor constant declarations +;=================================================== +;Standard Request Codes +get_status EQU 0 +clear_feature EQU 1 +set_feature EQU 3 +set_address EQU 5 +get_descriptor EQU 6 +set_descriptor EQU 7 +get_configuration EQU 8 +set_configuration EQU 9 +get_interface EQU 10 +set_interface EQU 11 +synch_frame EQU 12 + +;Standard Descriptor types +device EQU 1 +configuration EQU 2 +string EQU 3 +interface EQU 4 +endpoint EQU 5 + +;Standard Feature Selectors +endpoint_stalled EQU 0 +device_remote_wakeup EQU 1 + +;HID class +HID EQU 21H +report EQU 22H +physical EQU 23H + +;calss specific request code from section 7.2 class specific requests +get_report EQU 1 +get_idle EQU 2 +get_protocol EQU 3 +set_report EQU 09 +set_idle EQU 10 +set_protocol EQU 11 + +set_input_report EQU 1 +set_output_report EQU 2 + +;=================================================== +;USB packet constants (debug purposes) +;=================================================== +setup EQU 0B4H +in EQU 096H +out EQU 087H +data0 EQU 0C3H +data1 EQU 0D2H +ack EQU 04BH +nak EQU 04AH +;=================================================== +;USB Audio Class-Specific Request Code +;=================================================== +REQUEST_CODE_UNDEFINED EQU 000H +SET_CUR EQU 001H +GET_CUR EQU 081H +SET_MIN EQU 002H +GET_MIN EQU 082H +SET_MAX EQU 003H +GET_MAX EQU 083H +SET_RES EQU 004H +GET_RES EQU 084H +SET_MEM EQU 005H +GET_MEM EQU 085H +GET_STAT EQU 0FFH + +;Feature Unit Control Selectors +FU_CONTROL_UNDEFINED EQU 000H +MUTE_CONTROL EQU 001H +VOLUME_CONTROL EQU 002H +BASS_CONTROL EQU 003H +MID_CONTROL EQU 004H +TREBLE_CONTROL EQU 005H +GRAPHIC_EQUALIZER_CONTROL EQU 006H +AUTOMATIC_GAIN_CONTROL EQU 007H +DELAY_CONTROL EQU 008H +BASS_BOOST_CONTROL EQU 009H +LOUNDNESS_CONTROL EQU 00AH + + +;//just for HT23RB60 RAM bank +ABank0 EQU 000H +ABank1 EQU 001H +ABank2 EQU 002H +ABank3 EQU 003H +ABank4 EQU 004H +ABank5 EQU 005H +ABank6 EQU 006H +ABank7 EQU 007H +ABank8 EQU 008H +ABank9 EQU 009H +ABankA EQU 00aH +ABankB EQU 00bH +;//just for HT23RB60 ROM bank +OBank0 EQU 000H +OBank1 EQU 020H +OBank2 EQU 040H +OBank3 EQU 060H + + +;for HT16A102B 68k Parallel Mode +OLCD_DATA_PIN EQU PA +C68 EQU PB.0 +RD EQU PB.1 +RW EQU PB.2 +DCOM EQU PB.3 +RES EQU PB.4 + + +;for volume control +Const_Counter EQU 00AH + +VIOP EQU [12H] +@Mute EQU @BIT6 +@Inc EQU @BIT4 +@Dec EQU @BIT5 + +Min_Volume EQU 0C8H +Max_Volume EQU 000H +;//Max_Volume EQU 000H +Cur_Volume EQU 0FCH + + + + +;============================================================= +; IF USE key Debounced Function please set UseMedaiKey = 1 +; Key_Defined represent which bit you want to detect +; For Example : I want to detect PA.0 and PA.1 +; Then I set Key_Defined to 00000011'b = 03H +;============================================================= +#define UseMediaKey 0 +#define UseReportID 0 ;des is changed usereport has problem +Key_Defined EQU 0FFH + +USB_LED_ON EQU PB.0 +MUTE_LED_ON EQU PB.1 diff --git a/PRG/function.asm b/PRG/function.asm new file mode 100644 index 0000000..040e9db --- /dev/null +++ b/PRG/function.asm @@ -0,0 +1,1388 @@ +;********************************************************************* +; Functin Library +; Author : Ansonku +; EMail : ansonku@holtek.com.tw +; Date : 2005/01/11 +;********************************************************************* +#include ht82a821R.inc +#include const.inc +;===================================================================== +; Descriptor Label +;===================================================================== +;2005/11/01 ClearFeature_Endpoint add Send_Hand_Shake +; +;2006/02/16 э Sned_Hand_Shake 磷玻ネぃタ盽 stack +;2006/02/16 э control_read , 磷 descriptor 计┮穦玻ネ拜肈 +; 璝琌descirptor Ч临Μ in token , ê或 send_hand_shake +; +; +; +; + + + + + +extern control_read_table:NEAR +extern device_desc_table:NEAR +extern config_desc_table:NEAR + +extern end_config_desc_table:NEAR +extern hid_report_desc_table:NEAR +extern end_hid_report_desc_table:NEAR + +extern USBStringLanguageDescription:NEAR +extern USBStringDescription1:NEAR +extern USBStringDescription2:NEAR +extern USBStringDescription3:NEAR +extern HID_Desc:NEAR + +extern config_desc_length:NEAR +extern hid_desc_length:NEAR +extern report_desc_length:NEAR + + +extern USB_EP0_ISR_END:NEAR + +;===================================================================== +; External Variable +;===================================================================== +extern FIFO_Size:byte +extern FIFO_SendLen:byte +extern FIFO_Type:byte +extern FIFO_Request:byte +extern FIFO_wValueL:byte +extern FIFO_wValueH:byte +extern FIFO_wIndexL:byte +extern FIFO_wIndexH:byte +extern FIFO_wLengthL:byte +extern FIFO_wLengthH:byte + +extern FIFO_Out1:byte +extern FIFO_Out2:byte +extern FIFO_Out3:byte +extern FIFO_Out4:byte +extern FIFO_Out5:byte +extern FIFO_Out6:byte +extern FIFO_Out7:byte +extern FIFO_Out8:byte + +extern USB_Interface:byte +extern USB_Interface_Alt:byte +extern USB_Configuration:byte + +extern FIFO_ADDR:byte + + + +extern Loop_Counter:byte +extern Data_Count:byte +extern Data_Start:byte + + +extern nCmdIndex1:byte + +extern VolumeH_Save:byte +extern VolumeL_Save:byte +extern bFlag_Audio_Mute:bit +;modify for Remote Wakeup +extern bRmtWakeup :bit +extern b_wakeup :bit + +;===================================================================== +; FIFO Status +;===================================================================== + +;FIFO +extern FIFO_TEMP:byte +extern bFlag_Real_Cmd:bit +extern bFlag_FIFO_Ready:bit +extern bFlag_FIFO_LEN0:bit +extern bFlag_RD_HTable:bit +extern bFlag_wait_control_out:bit +extern bFlag_SET_ADDRESS:bit +extern bFlag_SCMD:bit +extern bFlag_Enum_Ready:bit +extern bFlag_SetConfiguration_Ready:bit +extern bFlag_SetInterface_Ready:bit + +extern StageOne:NEAR +extern USB_ISR_END:NEAR +;******************************************************************** +; USB LIB +; 1.CHECK FIFOX RD READEY? bFlag_FIFO_Ready = 1:bFlag_FIFO_Ready = 0 +;******************************************************************** +FIFO0_RD_CHECK: + MOV A,UCC + OR A,00000111b + AND A,11111000b + MOV UCC,A + + MOV A,00000000b + JMP FIFO_CHECK +FIFO1_RD_CHECK: + MOV A,UCC + OR A,00000111b + AND A,11111001b + MOV UCC,A + + MOV A,00000000b + JMP FIFO_CHECK +FIFO2_RD_CHECK: + MOV A,UCC + OR A,00000111b + AND A,11111010b + MOV UCC,A + + MOV A,00000000b + JMP FIFO_CHECK +FIFO3_RD_CHECK: + MOV A,UCC + OR A,00000111b + AND A,11111011b + MOV UCC,A + + MOV A,00000000b + JMP FIFO_CHECK +FIFO4_RD_CHECK: + MOV A,UCC + OR A,00000111b + AND A,11111100b + MOV UCC,A + + MOV A,00000000b + JMP FIFO_CHECK + +FIFO5_RD_CHECK: + MOV A,UCC + OR A,00000111b + AND A,11111101b + MOV UCC,A + + MOV A,00000000b + JMP FIFO_CHECK +;******************************************************************** +; USB LIB +; 1.CHECK FIFOX WR READEY ? bFlag_FIFO_Ready = 1:bFlag_FIFO_Ready = 0 +;******************************************************************** + +;LEN0 ready to write?? +LEN0_WR_CHECK: +;CHECK FIFOX ready to write? +FIFO0_WR_CHECK: + MOV A,UCC + OR A,00000111b + AND A,11111000b + MOV UCC,A + + MOV A,00000010b + JMP FIFO_CHECK +FIFO1_WR_CHECK: + MOV A,UCC + OR A,00000111b + AND A,11111001b + MOV UCC,A + + MOV A,00000010b + JMP FIFO_CHECK +FIFO2_WR_CHECK: + MOV A,UCC + OR A,00000111b + AND A,11111010b + MOV UCC,A + + MOV A,00000010b + JMP FIFO_CHECK +FIFO3_WR_CHECK: + MOV A,UCC + OR A,00000111b + AND A,11111011b + MOV UCC,A + + MOV A,00000010b + JMP FIFO_CHECK +FIFO4_WR_CHECK: + MOV A,UCC + OR A,00000111b + AND A,11111100b + MOV UCC,A + + MOV A,00000010b + JMP FIFO_CHECK + +FIFO5_WR_CHECK: + MOV A,UCC + OR A,00000111b + AND A,11111101b + MOV UCC,A + + MOV A,00000010b + JMP FIFO_CHECK + +FIFO_CHECK: + clr wdt + MOV FIFO_TEMP,A + MOV A,USB_MISC + MOV MP1,A + MOV A,R1 + AND A,11111000b + OR A,FIFO_TEMP + MOV R1,A + CALL Delay_3us + SET R1.@MISC_REQ ;set request + CALL Delay_28us + SET bFlag_FIFO_Ready + SNZ R1.@MISC_Ready + CLR bFlag_FIFO_Ready ;if MISC.Ready = 1 -> bFlag_FIFO_Ready = 1 + SET bFlag_FIFO_LEN0 + SNZ R1.@MISC_LEN0 + CLR bFlag_FIFO_LEN0 + + ;;SZ bFlag_FIFO_Ready + clr MISC.@MISC_REQ + clr wdt + RET + + +ReadLen0: + MOV A,USB_FIFO0 + MOV MP1,A + MOV A,R1 + NOP + JMP Read_FIFO_END +Read_FIFO0: + MOV A,USB_FIFO0_SIZE + MOV FIFO_SIZE,A + MOV A,USB_FIFO0 + JMP Read_FIFO +Read_FIFO1: + MOV A,USB_FIFO1_SIZE + MOV FIFO_SIZE,A + MOV A,USB_FIFO1 + JMP Read_FIFO +Read_FIFO2: + MOV A,USB_FIFO2_SIZE + MOV FIFO_SIZE,A + MOV A,USB_FIFO2 + JMP Read_FIFO +Read_FIFO3: + MOV A,USB_FIFO3_SIZE + MOV FIFO_SIZE,A + MOV A,USB_FIFO3 + JMP Read_FIFO +Read_FIFO4: + MOV A,USB_FIFO4_SIZE + MOV FIFO_SIZE,A + MOV A,USB_FIFO4 + JMP Read_FIFO +Read_FIFO5: + MOV A,USB_FIFO5_SIZE + MOV FIFO_SIZE,A + MOV A,USB_FIFO5 + JMP Read_FIFO + +Read_FIFO: + SET MISC.@MISC_REQ + + MOV FIFO_TEMP,A ;FIFO_TEMP SAVE FIFOX ADDRESS + CLR FIFO_SendLen + MOV A,OFFSET FIFO_Type + MOV MP0,A +Read_FIFO_Loop: + MOV A,FIFO_TEMP + MOV MP1,A + MOV A,R1 + MOV R0,A + INC FIFO_SendLen + INC MP0 + MOV A,FIFO_SIZE + XOR A,FIFO_SendLen + SZ Z ;1=FIFO_SIZE=FIFO_SendLen + JMP Read_FIFO_End + MOV A,USB_MISC + MOV MP1,A + CALL Delay_28us + SZ R1.@MISC_Ready + JMP Read_FIFO_LOOP + JMP Read_FIFO_End + +Send_Hand_Shake: +Send_Hand_Shake_wait: + ; protect die loop + call Check_Real_Cmd + sz bFlag_Real_Cmd + ;jmp USB_EP0_ISR_END + ret ;modify by 2006-02-16 + + CALL FIFO0_WR_CHECK + SNZ bFlag_FIFO_Ready ; acai remark 2007-1-23 + JMP Send_Hand_Shake_wait + + set MISC.@MISC_REQ +WriteLen0: +Write_FIFO_OK: +Read_FIFO_End: + MOV A,USB_MISC + MOV MP1,A + MOV A,(01H SHL @MISC_TX) ;Change TX State + ;CLR INTC0.0 + XORM A,R1 + CALL Delay_3us + CLR R1.@MISC_REQ + ;SET INTC0.0 + RET + +;============================================================ +;Function:Write FIFOx from FIFO_OUTx +;============================================================ +Write_FIFO0: + MOV A,USB_FIFO0 + JMP Write_FIFO +Write_FIFO1: + MOV A,USB_FIFO1 + JMP Write_FIFO +Write_FIFO2: + MOV A,USB_FIFO2 + JMP Write_FIFO +Write_FIFO3: + MOV A,USB_FIFO3 + JMP Write_FIFO +Write_FIFO4: + MOV A,USB_FIFO4 + JMP Write_FIFO +Write_FIFO5: + MOV A,USB_FIFO5 + JMP Write_FIFO + +Write_FIFO: + clr wdt + SET MISC.@MISC_REQ + + MOV FIFO_TEMP,A ;FIFO NO Address + MOV A,OFFSET FIFO_OUT1 + MOV MP0,A +Write_FIFO_Loop: + clr wdt + MOV A,FIFO_SendLen + XOR A,00H + SZ Z + JMP Write_FIFO_End + + MOV A,FIFO_TEMP + MOV MP1,A + MOV A,R0 + MOV R1,A + DEC FIFO_SendLen + MOV A,FIFO_SendLen + XOR A,00H + SZ Z + JMP Write_FIFO_End ;FIFO_SendLen=0 肚Ч + INC MP0 + MOV A,USB_MISC + MOV MP1,A + call Delay_28us + SZ R1.@MISC_Ready + JMP Write_FIFO_Loop +Write_FIFO_End: + clr wdt + JMP Write_FIFO_OK + + +get_descriptor_length: + clr wdt + MOV A,FIFO_WLENGTHH + XOR A,0 + SNZ Z + JMP use_actual_length + MOV A,FIFO_WLENGTHL + XOR A,0 + SZ Z + JMP use_actual_length + MOV A,FIFO_WLENGTHL + SUB A,data_count + SZ C ;if(FIFO_LENGTHL>data_count) c=1 + JMP use_actual_length + MOV A,FIFO_WLENGTHL + MOV data_count,A +use_actual_length: + RET +;=============================================================== +; Function : Control_read +; Purpose : Performs the control read operation as +; defined by the USB specification +; setup-in-in-in-....-out +; data_start:must be set to the descriptors info as an offset +; from the beginning of the control read table +; data count holds the +; data_count:must beset to the size of the descriptor +; bFlag_RD_HTable==1 ==> Must be read Hight Bytes +; TBLP :Table Index +;=============================================================== +control_read: + clr wdt + MOV A,data_start + MOV TBLP,A +control_read_data_stage: + clr wdt + MOV A,00H + MOV Loop_Counter,A + MOV FIFO_SendLen,A + + + SZ MISC.@MISC_SCMD + JMP control_read_status_stage_end + clr wdt + + MOV A,OFFSET FIFO_TYPE + MOV MP0,A + + MOV A,data_count + XOR A,00H + SZ Z + JMP dma_load_done ;A=00H + +dma_load_loop: + clr wdt + SNZ bFlag_RD_HTable + JMP Read_Low_Bytes +Read_High_Bytes: + clr wdt + CLR bFlag_RD_HTable + TABRDL R0 + INC TBLP + INC data_start + MOV A,TBLH + AND A,00111111b + MOV R0,A + XOR A,3FH + SZ Z + JMP dma_load_loop + + JMP Check_Read_Length + +Read_Low_Bytes: + clr wdt + SET bFlag_RD_HTable + TABRDL R0 + MOV A,R0 +Check_Read_Length: + clr wdt + INC MP0 + INC loop_counter + INC FIFO_SendLen + DEC data_count + SZ Z + JMP wait_control_read + MOV A,loop_counter + XOR A,EP0_FIFO_SIZE + SNZ Z + JMP dma_load_loop + jmp wait_control_read +dma_load_done: + clr wdt + ;SZ MISC.@MISC_SCMD + ;JMP control_read_status_stage_end + CALL Send_Hand_Shake + jmp control_read_status_stage_end + +wait_control_read: + clr wdt + call Check_Real_Cmd + sz bFlag_Real_Cmd + jmp control_read_status_stage_end + + clr wdt + CALL FIFO0_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP wait_control_read ;wait FIFO0 Ready + CALL Write_FIFO0 +control_read_status_stage_end: + clr wdt + NOP + RET + + +;----------------------------------------------------------- +; Check_Real_Cmd : if have new cmd , set bFlag_Real_Cmd else clr bFlag_Real_Cmd +;----------------------------------------------------------- +Check_Real_Cmd: + clr wdt + clr bFlag_Real_Cmd + SZ MISC.@MISC_SCMD + set bFlag_Real_Cmd + SZ MISC.@MISC_LEN0 + set bFlag_Real_Cmd + RET + +;*************************************************************** +; USB Stage3 +; Process the request +;*************************************************************** +;Set the device address to the wValue in the SETUP packet at the completion +;of the current transaction +;----------------------------------------------------------- +; Set Address +;----------------------------------------------------------- +SetAddress: + clr wdt + MOV A,FIFO_WVALUEL ;save address to FIFO_ADDR + MOV FIFO_ADDR,A + MOV FIFO_TEMP,A + + MOV A,USB_SIES + MOV MP1,A + MOV A,00000001b + ORM A,R1 + RLA FIFO_TEMP + AND A,0FEH + MOV FIFO_TEMP,A + + MOV A,USB_AWR + MOV MP1,A + MOV A,FIFO_TEMP + MOV R1,A + NOP + + CALL Send_Hand_Shake ;send a handshake with host + + SET bFlag_Set_Address + ;;RET ;for test + JMP USB_EP0_ISR_END + +;----------------------------------------------------------- +; Set Configuration +;----------------------------------------------------------- +SetConfiguration: + clr wdt + set USVC.7 ;unmute + + MOV A,FIFO_WVALUEL + MOV USB_Configuration,A + CLR STALL + ;MOV A,USB_STALL + ;MOV MP1,A + ;CLR R1 ;not stall + set bFlag_SetConfiguration_Ready +SetConfiguration_wait: + CALL Send_Hand_Shake + JMP USB_EP0_ISR_END + +;----------------------------------------------------------- +; Set Interface +;----------------------------------------------------------- +SetInterface: + clr wdt + MOV A,FIFO_WVALUEL + MOV USB_Interface_Alt,A + MOV A,FIFO_WINDEXL + MOV USB_Interface,A + set bFlag_SetInterface_Ready + set USB_LED_ON +SetInterface_wait: + CALL Send_Hand_Shake + JMP USB_EP0_ISR_END + +;----------------------------------------------------------- +; Get Interface +;----------------------------------------------------------- +GetInterface: + clr wdt + mov A,USB_Interface_Alt + mov FIFO_OUT1,A + + mov A,01H + mov FIFO_SendLen,A + +GetInterface_Loop: + clr wdt + call Check_Real_Cmd + sz bFlag_Real_Cmd + jmp GetInterface_End + clr wdt + call FIFO0_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP GetInterface_Loop + + CALL Write_FIFO0 + +GetInterface_End: + JMP USB_EP0_ISR_END + +;----------------------------------------------------------- +; Get Status +; For Get Status (DEVICE,INTERFACE,ENDPOINT) , if self-powered and remote wakeup need to modify +; return 2 bytes (00 00) +;----------------------------------------------------------- +GetStatus: + clr wdt + mov a,02H + mov FIFO_SendLen,a + + ;Modify for Remote Wakeup + mov a,02H + snz bRmtWakeup + ;------------------------ + mov a,00H + mov FIFO_Out1,a + clr FIFO_Out2 + +GetStatus_Loop: + clr wdt + call Check_Real_Cmd + sz bFlag_Real_Cmd + jmp GetStatus_End + clr wdt + + call FIFO0_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP GetStatus_Loop + + CALL Write_FIFO0 + +GetStatus_End: + JMP USB_EP0_ISR_END + +;----------------------------------------------------------- +; Get Status (Endpoint) +;----------------------------------------------------------- +;----------------------------------------------------------- +; Get Status (Interface) +; return 2 bytes (00 00) +;----------------------------------------------------------- +;Modify for Remote Wakeup +GetStatus_Interface: + clr wdt + mov a,02H + mov FIFO_SendLen,a + + + mov a,00H + mov FIFO_Out1,a + clr FIFO_Out2 + +GetStatus_Inerface_Loop: + clr wdt + call Check_Real_Cmd + sz bFlag_Real_Cmd + jmp GetStatus_End + clr wdt + + call FIFO0_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP GetStatus_Inerface_Loop + + CALL Write_FIFO0 + +GetStatus_Inerface_Loop_End: + JMP USB_EP0_ISR_END +;----------------------------------------------------------- +; Get Status (Endpoint) +;----------------------------------------------------------- +GetStatus_Endpoint: + clr wdt + mov a,02H + mov FIFO_SendLen,a + + mov a,07FH + and a,FIFO_wIndexL + + call GetPipeBit + mov FIFO_TEMP,a + mov a,STALL + and a,FIFO_TEMP + mov FIFO_TEMP,a + + clr FIFO_Out1 + sz FIFO_TEMP + set FIFO_Out1.0 + + clr FIFO_Out2 + + jmp GetStatus_Loop + + +GetStatus_Endpoint_End: + JMP USB_EP0_ISR_END +;----------------------------------------------------------- +; Clear Feature : The HT82A822R return ACK without ERROR +; bmRequest: 00 Device +; 02 EndPoint +; bRequest 01 CLEAR_FEATURE +; wValue 0000 clear ENDPOINT0 HALT +; 0001 clear REMOTE_WAKEUP +; wIndex 0000 +; wLength 0000 +;----------------------------------------------------------- +ClearFeature: +;;----2007-01-10 for Vista DTM---- + mov a,FIFO_wValueL + xor a,01H + snz z + JMP SendStall0 + ;set b_wakeup + ;clr bRmtWakeup +;;------------------------------ + clr wdt + ;Modify for Remote Wakeup + set b_wakeup + clr bRmtWakeup + ;----------------------- + CALL Send_Hand_Shake +ClearFeature_Loop: +ClearFeature_End: + JMP USB_EP0_ISR_END +;----------------------------------------------------------- +; Clear Feature (Endpoint) +;----------------------------------------------------------- +ClearFeature_Endpoint: + clr wdt + + + snz bFlag_SetConfiguration_Ready + JMP SendStall0 + + mov a,07FH + and a,FIFO_wIndexL + + call GetPipeBit + + mov FIFO_TEMP,a + CPL FIFO_TEMP + mov a,STALL + AND a,FIFO_TEMP + mov STALL,a + + CALL Send_Hand_Shake + + +ClearFeature_Endpoint_End: + JMP USB_EP0_ISR_END + +;----------------------------------------------------------- +; Set Feature +;----------------------------------------------------------- +SetFeature: +;;----2007-01-10 for Vista DTM---- + mov a,FIFO_wValueH + xor a,00H + sz z + JMP SetFeature_1 + + mov a,FIFO_wValueH + sub a,81H ;target-now + snz C + jmp SendStall0 ;<81H + ;>=81H + mov a,FIFO_wValueH + sub a,84H ;target-now + sz C + jmp SendStall0 ;>=84H + + mov a,FIFO_wValueL + xor a,00H + snz z + JMP SendStall0 + jmp SetFeature_2 + +SetFeature_1: + mov a,FIFO_wValueL + xor a,01H + snz z + JMP SendStall0 + +SetFeature_2: + +;;---------------------------------- + ;Modify for Remote Wakeup + set b_wakeup + set bRmtWakeup + ;----------------------- + CALL Send_Hand_Shake +SetFeature_Loop: +SetFeature_End: + JMP USB_EP0_ISR_END +;----------------------------------------------------------- +; Set Feature (Endpoint) +;----------------------------------------------------------- +SetFeature_Endpoint: + clr wdt + snz bFlag_SetConfiguration_Ready + JMP SendStall0 + + mov a,07FH + and a,FIFO_wIndexL + + call GetPipeBit + + mov FIFO_TEMP,A + mov a,STALL + or a,FIFO_TEMP + mov STALL,a + + CALL Send_Hand_Shake + +SetFeature_Endpoint_End: + JMP USB_EP0_ISR_END +;----------------------------------------------------------- +; Get Descriptor +;----------------------------------------------------------- +GetDescriptor: + clr wdt + CLR bFlag_RD_HTable + CLR bFlag_wait_control_out + + MOV A,FIFO_WvalueH ;80 06 00 01 + XOR A,device + SZ Z + JMP GetDeviceDescriptor + + MOV A,FIFO_WvalueH ;80 06 00 02 + XOR A,configuration + SZ Z + JMP GetConfigurationDescriptor + + MOV A,FIFO_WvalueH ;80 06 00 03 + XOR A,string + SZ Z + JMP GetStringDescriptor + + + ;------------------------------------------------------ + ;Then test for HID class Descriptor + ;------------------------------------------------------ + + MOV A,FIFO_WvalueH ;81 06 00 22 + XOR A,report + SZ Z + JMP GetReportDescriptor + + MOV A,FIFO_WvalueH ;81 06 00 21 + XOR A,HID + SZ Z + JMP GetHIDDescriptor + + + + JMP SendStall0 ;can't parser + +;----------------------------------------------------------- +; GetConfiguration +;----------------------------------------------------------- +GetConfiguration: + clr wdt + mov a,01H + mov FIFO_SendLen,a + + mov a,USB_Configuration + mov FIFO_OUT1,a +GetConfiguration_Loop: + clr wdt + call Check_Real_Cmd + sz bFlag_Real_Cmd + jmp GetConfiguration_End + clr wdt + call FIFO0_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP GetConfiguration_Loop + + CALL Write_FIFO0 +GetConfiguration_End: + JMP USB_EP0_ISR_END + + + +;------------------------------------------------------ +;Report +;------------------------------------------------------ +SetReport: + clr wdt + mov a,FIFO_wValueH + xor a,set_output_report + sz z + jmp SetOutputReport + + JMP USB_EP0_ISR_END +SetReport_End: + +SetOutputReport: + clr wdt + ;check interface + mov a,FIFO_wIndexL + xor a,02H + snz z + jmp SendStall0 + ;check length + mov a,FIFO_wLengthL + xor a,08H + snz z + jmp SendStall0 + + mov a,21H + mov nCmdIndex1,a + + +SetOutputReport_End: + JMP USB_EP0_ISR_END +;------------------------------------------------------ +;Audio class +;------------------------------------------------------ +;21 01 +SetCur: + clr wdt + MOV A,FIFO_WVALUEH + XOR A,MUTE_CONTROL + SZ Z + JMP MuteControl + + MOV A,FIFO_WVALUEH + XOR A,VOLUME_CONTROL + SZ Z + JMP VolumeControl + + JMP SendStall0 ;can't parser + +;21 01 00 01 +MuteControl: ;(if have more feature , the state must be modify!!) + clr wdt + mov a,18h + mov nCmdIndex1,a + + ;;RET + ;;modify 2005-12-13 + jmp USB_EP0_ISR_END +;21 01 00 02 +VolumeControl: + clr wdt + mov a,28h + mov nCmdIndex1,a + ;;RET + ;;modify 2005-12-13 + jmp USB_EP0_ISR_END + +;return D2 00 = -46 db +;return BC 00 = -32 db (セ E0) +GetMin: + clr wdt + MOV A,00H + MOV FIFO_OUT1,A +;; MOV A,0E0H + MOV A,Min_Volume + MOV FIFO_OUT2,A + MOV A,02H + MOV FIFO_SendLen,A +GetMin_Loop: + clr wdt + call Check_Real_Cmd + sz bFlag_Real_Cmd + jmp GetMin_End + clr wdt + call FIFO0_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP GetMin_Loop + + CALL Write_FIFO0 +GetMin_End: + ;;RET + ;;2005-12-13 modify + jmp USB_EP0_ISR_END + + +;return 0x0C00 +GetMax: + clr wdt + MOV A,00H + MOV FIFO_OUT1,A +;; MOV A,0CH + MOV A,Max_Volume + MOV FIFO_OUT2,A + MOV A,02H + MOV FIFO_SendLen,A +GetMax_Loop: + clr wdt + call Check_Real_Cmd + sz bFlag_Real_Cmd + jmp GetMax_End + clr wdt + + call FIFO0_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP GetMax_Loop + + + CALL Write_FIFO0 +GetMax_End: +; RET + ;;2005-12-13 modify + jmp USB_EP0_ISR_END + + + + + +;return 0x0100 1db +GetRes: + clr wdt + MOV A,00H + MOV FIFO_OUT1,A + MOV A,01H + MOV FIFO_OUT2,A + MOV A,02H + MOV FIFO_SendLen,A +GetRes_Loop: + clr wdt + call Check_Real_Cmd + sz bFlag_Real_Cmd + jmp GetRes_End + + call FIFO0_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP GetRes_Loop + + CALL Write_FIFO0 +GetRes_End: +; RET + ;;2005-12-13 modify + jmp USB_EP0_ISR_END + + +GetCur: +;; call Check_Real_Cmd +;; sz bFlag_Real_Cmd +;; jmp GetCur_End +;; +;; +;; call FIFO0_WR_CHECK +;; SNZ bFlag_FIFO_Ready +;; JMP GetCur + +;; +;; MOV A,FIFO_wLengthL +;; MOV FIFO_SendLen,A +;; +;; MOV FIFO_TEMP,A +;; MOV A,OFFSET FIFO_OUT1 +;; MOV MP1,A +;;GetCur_Fill0: +;; MOV A,00H +;; MOV R1,A +;; INC MP1 +;; DEC FIFO_TEMP +;; MOV A,00H +;; XOR A,FIFO_TEMP +;; SNZ Z +;; JMP GetCur_Fill0 +;; CALL Write_FIFO0 + clr wdt + MOV A,FIFO_wLengthL + MOV FIFO_SendLen,A + + MOV A,01H + XOR A,FIFO_SendLen + sz z + jmp GetCur_Mute + + MOV A,02H + XOR A,FIFO_SendLen + sz z + jmp GetCur_Volume + jmp GetCur_End + +GetCur_Mute: + clr wdt + MOV A,00H + sz bFlag_Audio_Mute + MOV A,01H + mov FIFO_OUT1,A +GetCur_Mute_Loop: + clr wdt + call Check_Real_Cmd + sz bFlag_Real_Cmd + jmp GetCur_End + + + call FIFO0_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP GetCur_Mute_Loop + + call Write_FIFO0 + jmp GetCur_End +GetCur_Volume: + clr wdt + MOV A,VolumeH_Save + mov FIFO_OUT1,A + + MOV A,VolumeL_Save + mov FIFO_OUT2,A +GetCur_Volume_Loop: + clr wdt + call Check_Real_Cmd + sz bFlag_Real_Cmd + jmp GetCur_End + + + call FIFO0_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP GetCur_Volume_Loop + + call Write_FIFO0 + jmp GetCur_End +GetCur_End: +; RET + ;;2005-12-13 modify + jmp USB_EP0_ISR_END + +;-------------------------------------------------------------- +; ゼЧΘ +SetIdle: + JMP SendStall0 ;can't parser + +;============================================================== +;Standard Get Descriptor routines +; +;Return the device descriptor to the host +GetDeviceDescriptor: + clr wdt + MOV A,LOW device_desc_table + MOV TBLP,A + TABRDL data_count + ;modify 2005-12-02 + CALL Execute + jmp USB_EP0_ISR_END + +GetConfigurationDescriptor: + clr wdt + MOV A,LOW config_desc_length + MOV TBLP,A + TABRDL data_count + MOV A,LOW config_desc_table + ;modify 2005-12-02 + call Execute + jmp USB_EP0_ISR_END +;Not Ready!!!!!!!!! +GetStringDescriptor: + clr wdt + MOV A,FIFO_WVALUEL + XOR A,00H + SZ Z + JMP LanguageString + + MOV A,FIFO_WVALUEL + XOR A,01H + SZ Z + JMP ManufacturerString + + MOV A,FIFO_WVALUEL + XOR A,02H + SZ Z + JMP ProductString + + MOV A,FIFO_WVALUEL + XOR A,03H + SZ Z + JMP SerialNumberString + + + JMP SendStall0 ;other no support + +LanguageString: + clr wdt + MOV A,LOW USBStringLanguageDescription + MOV TBLP,A + TABRDL data_count + MOV A,LOW USBStringLanguageDescription + ;modify 2005-12-02 + call execute + jmp USB_EP0_ISR_END +ManufacturerString: + clr wdt + MOV A,LOW USBStringDescription1 + MOV TBLP,A + TABRDL data_count + MOV A,LOW USBStringDescription1 + ;modify 2005-12-02 + call execute + jmp USB_EP0_ISR_END +ProductString: + clr wdt + MOV A,LOW USBStringDescription2 + MOV TBLP,A + TABRDL data_count + MOV A,LOW USBStringDescription2 + ;modify 2005-12-02 + call execute + jmp USB_EP0_ISR_END + + +SerialNumberString: + clr wdt + MOV A,LOW USBStringDescription3 + MOV TBLP,A + TABRDL data_count + MOV A,LOW USBStringDescription3 + ;modify 2005-12-02 + call execute + + jmp USB_EP0_ISR_END + + + +;-------------------------------------------------- +;HID class Get Descriptor routines +;return the HID descriptor and enable endpoint one +;-------------------------------------------------- +GetReportDescriptor: + clr wdt + MOV A,LOW report_desc_length + MOV TBLP,A + TABRDL data_count ;Report length = Low byte of Report_Size + MOV A,LOW hid_report_desc_table + CALL execute ;send descriptor to host + ; + ;Enumeration is complete!! + ; + set bFlag_Enum_Ready ;set Enumeration flag + ;modify 2005-12-02 + jmp USB_EP0_ISR_END + +GetHIDDescriptor: + clr wdt + MOV A,LOW hid_desc_length + MOV TBLP,A + TABRDL data_count ;Report length = Low byte of Report_Size + MOV A,LOW HID_Desc + ;modify 2005-12-02 + CALL execute ;send descriptor to host + jmp USB_EP0_ISR_END + +Execute: + clr wdt + MOV data_start,A + call get_descriptor_length + call control_read + RET + +;=============================================================== +SendStall0: + SET STALL.@STALL_STL0 + JMP USB_EP0_ISR_END + ;return to USB_EP0_ISR + + + + + + + + + + + + + +;*************************************************************** +; Delay Test Function +; Most instructions Timing is one cycles = 0.33333 us +; call , jmp , ret is 2 cycles +;*************************************************************** + +Delay_28us: + mov a,1EH +Delay_28us_cont: + clr wdt + sdz acc + jmp Delay_28us_cont +Delay_3us: + clr wdt + NOP + NOP + NOP + NOP + clr wdt + ret + + +;----BEGIN (Get pipe bit) +;Input : ACC pipe number +;Output: ACC pip bit (D0:pipe 0, D1:pipe 1...) +GetPipeBit: + INC ACC + MOV FIFO_TEMP,A + MOV A,80H +GetPipeBitLoop: + clr wdt + RL ACC + SDZ FIFO_TEMP + JMP GetPipeBitLoop + RET +;----END (Get pipe bit) + + + + +Public Control_Read +Public FIFO0_RD_CHECK +Public FIFO1_RD_CHECK +Public FIFO2_RD_CHECK +Public FIFO3_RD_CHECK +Public FIFO4_RD_CHECK +Public FIFO5_RD_CHECK +Public FIFO0_WR_CHECK +Public FIFO1_WR_CHECK +Public FIFO2_WR_CHECK +Public FIFO3_WR_CHECK +Public FIFO4_WR_CHECK +Public FIFO5_WR_CHECK +Public Read_FIFO0 +Public Read_FIFO1 +Public Read_FIFO2 +Public Read_FIFO3 +Public Read_FIFO4 +Public Read_FIFO5 +Public Write_FIFO0 +Public Write_FIFO1 +Public Write_FIFO2 +Public Write_FIFO3 +Public Write_FIFO4 +Public Write_FIFO5 +Public Send_Hand_Shake +Public get_descriptor_length + + + +Public SetAddress +Public SetConfiguration +Public SetInterface +Public GetInterface +Public GetDescriptor +Public SetIdle +Public GetDeviceDescriptor +Public GetConfigurationDescriptor +Public GetStringDescriptor +Public GetStatus +;modify for Remote Wakeup +Public GetStatus_Interface +;--------------------------------- +Public SetFeature +Public ClearFeature +Public SetFeature_Endpoint +Public ClearFeature_Endpoint +Public GetStatus_Endpoint + +Public SetReport + +Public Check_Real_Cmd + +Public Execute +Public SendStall0 + +Public GetConfiguration + +Public Delay_3us + + +Public SetCur +Public GetMin +Public GetMax +Public GetRes +Public GetCur +Public GetPipeBit diff --git a/PRG/ht82a821r.inc b/PRG/ht82a821r.inc new file mode 100644 index 0000000..180585c --- /dev/null +++ b/PRG/ht82a821r.inc @@ -0,0 +1,98 @@ +; ht48rb4.INC +; This file contains the definition of registers for +; Holtek ht48rb4 microcontroller. +; Generated by Cfg2IncH V1.0. +; Do not modify manually. + +IAR0 EQU [00H] +R0 EQU [00H] ;old style declaration, not recommended for use +MP0 EQU [01H] +IAR1 EQU [02H] +R1 EQU [02H] ;old style declaration, not recommended for use +MP1 EQU [03H] +BP EQU [04H] +ACC EQU [05H] +PCL EQU [06H] +TBLP EQU [07H] +TBLH EQU [08H] +WDTS EQU [09H] +STATUS EQU [0AH] +INTC0 EQU [0BH] +TMR0H EQU [0CH] +TMR0L EQU [0DH] +TMR0C EQU [0EH] +TMR1H EQU [0FH] +TMR1L EQU [010H] +TMR1C EQU [011H] +PA EQU [012H] +PAC EQU [013H] +PB EQU [014H] +PBC EQU [015H] +PC EQU [016H] +PCC EQU [017H] +PD EQU [018H] +PDC EQU [019H] +USVC EQU [01CH] +USF EQU [01DH] +TBHP EQU [01FH] +USC EQU [020H] +USR EQU [021H] +UCC EQU [022H] +AWR EQU [023H] +STALREG EQU [024H] +STALL EQU [024H] +SIES EQU [025H] +MISC EQU [026H] +SETIO EQU [027H] +FIFO0 EQU [028H] +FIFO1 EQU [029H] +FIFO2 EQU [02AH] +TUSB_R EQU [02FH] + +C EQU [0AH].0 +AC EQU [0AH].1 +Z EQU [0AH].2 +OV EQU [0AH].3 +PDF EQU [0AH].4 +TO EQU [0AH].5 +EMI EQU [0BH].0 +EEI EQU [0BH].1 +ET0I EQU [0BH].2 +ET1I EQU [0BH].3 +EIF EQU [0BH].4 +T0F EQU [0BH].5 +T1F EQU [0BH].6 +PA0 EQU [012H].0 +PA1 EQU [012H].1 +PA2 EQU [012H].2 +PA3 EQU [012H].3 +PA4 EQU [012H].4 +PA5 EQU [012H].5 +PA6 EQU [012H].6 +PA7 EQU [012H].7 +PB0 EQU [014H].0 +PB1 EQU [014H].1 +PB2 EQU [014H].2 +PB3 EQU [014H].3 +PB4 EQU [014H].4 +PB5 EQU [014H].5 +PB6 EQU [014H].6 +PB7 EQU [014H].7 +PC0 EQU [016H].0 +PC1 EQU [016H].1 +PC2 EQU [016H].2 +PC3 EQU [016H].3 +PC4 EQU [016H].4 +PC5 EQU [016H].5 +PC6 EQU [016H].6 +PC7 EQU [016H].7 +PD0 EQU [018H].0 +PD1 EQU [018H].1 +PD2 EQU [018H].2 +PD3 EQU [018H].3 +PD4 EQU [018H].4 +PD5 EQU [018H].5 +PD6 EQU [018H].6 +PD7 EQU [018H].7 + +LASTPAGE EQU 0700H diff --git a/PRG/macro.asm b/PRG/macro.asm new file mode 100644 index 0000000..6fcc294 --- /dev/null +++ b/PRG/macro.asm @@ -0,0 +1,386 @@ +;******************************************************************************* +;* +;* (c) Copyright 2004, Holtek Semiconductor Inc. +;* +;******************************************************************************/ +;******************************************************************************* +;MODULE: main.asm + +;INITIAL: 11/12/2004 + +;AUTHOR: C351 Ansonku. + +;NOTE: HT48RB4 16 bit operation + +;REVISION: First issue +;******************************************************************************* +;******************************************************************************* +; 16 bit ADD with signed +; use ADD16 XH,XL,YH,YL,ZH,ZL +; operation +; XH XL +; +YH YL +; -------------- +; ZH ZL +;******************************************************************************* +ADD16 MACRO XH,XL,YH,YL,ZH,ZL + MOV A,XL + ADD A,YL + MOV ZL,A + MOV A,XH + ADC A,YH + MOV ZH,A +ENDM +;******************************************************************************* +; 16 bit ADD with unsigned +; use ADD16 XH,XL,YL,ZH,ZL +; operation +; XH XL +; + YL +; -------------- +; ZH ZL +;******************************************************************************* +ADD16U MACRO XH,XL,YL,ZH,ZL + mov a,xh + mov zh,a + MOV A,XL + ADD A,YL + SZ C + INC ZH + MOV ZL,A +ENDM + + +;******************************************************************************* +; 16 bit sub with signed +; use SUB16 XH,XL,YH,YL,ZH,ZL +; operation +; XH XL +; -YH YL +; -------------- +; ZH ZL +;******************************************************************************* +SUB16 MACRO XH,XL,YH,YL,ZH,ZL + MOV A,XL + CLR C + SUB A,YL + MOV ZL,A + MOV A,XH + SBC A,YH + MOV ZH,A + +ENDM + + +;******************************************************************************* +; 16 bit shift right with signed +; use RR16 XH,XL,ZH,ZL +; operation +;******************************************************************************* +RR16 MACRO XH,XL,ZH,ZL + CLR C + MOV A,XH + AND A,80H + SNZ Z + SET C + RRCA XH + MOV ZH,A + RRCA XL + MOV ZL,A +ENDM +;******************************************************************************* +; 16 bit shift left with signed +; use RL16 XH,XL,ZH,ZL +; operation +;******************************************************************************* +RL16 MACRO XH,XL,ZH,ZL + CLR C + SZ XL.7 + SET C + + RLCA XH + MOV ZH,A + CLR C + RLCA XL + MOV ZL,A +ENDM +;******************************************************************************* +; 16 bit shift left with signed +; use RL16N XH,XL,ZH,ZL +; operation +;******************************************************************************* +RL16N MACRO XH,XL,ZH,ZL,N + ;MOV A,8 + ;SUB A,N + ;mov a,Xl SHR A + ;mov zh,a + ;mov a,xh SHL N + ;orm a,zh +ENDM +;******************************************************************************* +; 8 bit multiply with signed +; use mul8 X,Y,ZH,ZL +; operation +;******************************************************************************* +Mul8 MACRO X,Y,ZH,ZL + Local Mul8_End + CLR operator1H ;sum + CLR operator1L + CLR operator2H ;multiply + CLR operator3H ;operator + CLR operator3L + mov A,Y + mov operator2L,A + + SZ X.7 + SET operator2H +Mul16_doloop: + MOV A,6 + MOV Counter3,A + SDZ Counter3 + JMP Mul8_End + SNZ X.Counter3 + jmp Mul18_Next_Bit + RL16 operator2H,operator2L,operator3H,operator3L + ADD16 operator3H,operator3L,operator1H,operaotr1L,operator1H,operator1L + + +Mul18_Next_Bit: + JMP Mul16_doloop + + +Mul8_End: + + +ENDM + +;******************************************************************************* +; 8 bit macro +;******************************************************************************* +;******************************************************************************* +; 16 bit ADD with signed +; use ADD16 X,Y,Z +; operation +; X +; +Y +; -------------- +; Z +;******************************************************************************* +ADD8 MACRO X1,Y1,Z1 + MOV A,X1 + ADD A,Y1 + MOV Z1,A +ENDM + +;******************************************************************************* +; 16 bit sub with signed +; use SUB16 X,Y,Z +; operation +; X +; -Y +; -------------- +; Z +;******************************************************************************* +SUB8 MACRO X1,Y1,Z1 + MOV A,X1 + SUB A,Y1 + MOV Z1,A +ENDM + +;******************************************************************************* +; 8 bit shift right with signed +; use RR8 X,Z +; operation +;******************************************************************************* +RR8 MACRO X,Y + Local RR8_End,RR8_Modify_FF,RR8_Modify_FF_End + mov a,X + inc acc + SZ Z + jmp RR8_Modify_FF + jmp RR8_Modify_FF_End +RR8_Modify_FF: + clr Y + jmp RR8_End + +RR8_Modify_FF_End: + CLR C + MOV A,X + AND A,80H + SNZ Z + SET C + RRCA X + MOV Y,A + + + +RR8_End: +ENDM +;******************************************************************************* +; 8 bit shift left with signed +; use RL16 X,Z +; operation +;******************************************************************************* +RL8 MACRO X,Y + CLR C + RLCA X + MOV Y,A +ENDM + +;******************************************************************************* +; 8 bit abs +; use ABS8 X,Y +; operation +;******************************************************************************* +ABS8 MACRO X,Y + Local ABS8_End + + kmov y,x + mov a,x + and a,80H + SZ Z + jmp ABS8_End + CPL y + INC y + +ABS8_End: + +ENDM + + + + + + +;******************************************************************************* +; kmov +; use kmov destination,source +; operation +;******************************************************************************* +KMOV MACRO mem1,mem2 + mov a,mem2 + mov mem1,a + ENDM + +KOR MACRO mem1,mem2 + mov a,mem2 + orm a,mem1 + ENDM + + + +;******************************************************************************* +; make oled column address +; use oled_make_col_add source,MSB,LSB +; +;******************************************************************************* +oled_make_col_add macro mem1,mem2,mem3 + mov a,0FH + AND a,mem1 + mov mem3,a + mov a,70H + and a,mem1 + mov mem2,a + clr c + rrc mem2 + clr c + rrc mem2 + clr c + rrc mem2 + clr c + rrc mem2 + set mem2.4 + +endm + + + +;*************************************** + +XMOV MACRO mem2,mem1 + mov a,mem1 + mov mem2,a + ENDM +;------------------------------------- +;;Move ARG2->ARG1(move by bit) +xmov1 MACRO ARG1,ARG2 + LOCAL xmov1_1,xmov1_end + sz ARG2 + jmp xmov1_1 + clr ARG1 + jmp xmov1_end +xmov1_1: + set ARG1 +xmov1_end: + ENDM +;------------------------------------- +;;if MEM2=MEM1 =>Skip Next Instruction +EQUJMP MACRO MEM2,MEM1 + MOV A,MEM1 + XOR A,MEM2 + SNZ Z + ENDM +;;------------------------ + +;;if MEM2!=MEM1 =>Skip Next Instruction +NEJMP MACRO MEM2,MEM1 + MOV A,MEM1 + XOR A,MEM2 + SZ Z + ENDM +;;------------------------ +;;if (REG1==REG2) goto REG3 +JLER MACRO REG1,REG2,REG3 + mov a,REG1 + sub a,REG2 + sz z + jmp REG3 + ENDM +;********************************************** +;MACRO: JLNR +;PURPOSE: REG1 != REG2 goto REG3 +;********************************************** +JLNR MACRO REG1,REG2,REG3 + mov a,REG1 + sub a,REG2 + snz z + jmp REG3 + ENDM +;;------------------------ +;;if MEM2>MEM1 =>Skip Next Instruction +LBRJ MACRO MEM2,MEM1 + MOV A,MEM1 + SUB A,MEM2 + SZ C + ENDM +;;------------------------ + +;;if MEM2<=MEM1 =>Skip Next Instruction +LSERJ MACRO MEM2,MEM1 + MOV A,MEM1 + SUB A,MEM2 + SNZ C + ENDM +;;------------------------ + +;;if MEM2Skip Next Instruction +LSRJ MACRO MEM2,MEM1 + MOV A,MEM2 + SUB A,MEM1 + SZ C + ENDM +;;------------------------ + +;;if MEM2>=MEM1 =>Skip Next Instruction +LBERJ MACRO MEM2,MEM1 + MOV A,MEM2 + SUB A,MEM1 + SNZ C + ENDM +;;------------------------ + +SWAPWORD MACRO DA + EQU (DA>>8)+(DA<<8) + ENDM +;;------------------------ + \ No newline at end of file diff --git a/PRG/main.asm b/PRG/main.asm new file mode 100644 index 0000000..5e0295e --- /dev/null +++ b/PRG/main.asm @@ -0,0 +1,1807 @@ +;******************************************************************************* +;* +;* (c) Copyright 2005, Holtek Semiconductor Inc. +;* +;******************************************************************************/ +;******************************************************************************* +;MODULE: main.asm + +;INITIAL: 09/14/2006 + +;AUTHOR: C351 Ansonku. + +;NOTE: HT82A821R , HT82A822R Main Function + +;VERSION: 1.2 +;Function: +;key debounced N +;oled N +;volume adjust Y +;2005/05/13 Update Key Debounce +;2005/05/25 Modify Pop noise +;2005/06/06 Modify Send_Hand_Shake +;2005/06/10 耞 token ,安砞笿setup scmd,璶弄8 bytes睲埃scmd籔len0 +;2005/12/20 USB 瑈祘эノ jmp よΑ implement +;2005/12/20 盢 suspend 耞э main function い +;******************************************************************************* + +;*************************************************************** +;Include File +;ht82a822.inc ht82a822r register address defined +;const.inc user defined +;macro.asm macro function +;*************************************************************** +#include ht82a821r.inc +#include const.inc +#include macro.asm + +#define WaitBias 0 + +;==================================================================== +;Variable Defined , DATA 眖 40H 秨﹍ +;==================================================================== +DATA .SECTION AT 40H 'DATA' +#include memory.inc +;*************************************************************** +; USB ISR Var (い耞称ノ) +;*************************************************************** +isr_usb_acc DB ? +isr_usb_status DB ? +isr_usb_mp1 DB ? +isr_usb_mp0 DB ? +isr_usb_tblp DB ? +;*************************************************************** +; Timer0 ISR Var (い耞称ノ) +;*************************************************************** +;;isr_tmr0_acc DB ? +;;isr_tmr0_status DB ? +;;isr_tmr0_mp1 DB ? +;;isr_tmr0_mp0 DB ? +;;isr_tmr0_tblp DB ? +;*************************************************************** +; Timer1 ISR Var (い耞称ノ) +;*************************************************************** +;;isr_tmr1_acc DB ? +;;isr_tmr1_status DB ? +;;isr_tmr1_mp1 DB ? +;;isr_tmr1_mp0 DB ? +;;isr_tmr1_tblp DB ? + +;*************************************************************** +; Delay 跑计 +;*************************************************************** +Delay_1 DB ? +Delay_2 DB ? +Delay_3 DB ? + +;*************************************************************** +;USB FIFO Variable +;USB_Interface : to save usb current interface number +;USB_Interface_Alt : to save usb current alternate of interface number +;USB_Configuration : to save USB configuration number +;FIFO_ADDR : to save USB ADDRESS +;Loop_Counter , Data_Count , Data_Start : control_read variable +;*************************************************************** +;For FIFO Access +FIFO_SIZE db ? +FIFO_SendLen db ? +FIFO_out1 label byte +FIFO_Type db ? +FIFO_out2 label byte +FIFO_Request db ? +FIFO_out3 label byte +FIFO_wValueL db ? +FIFO_out4 label byte +FIFO_wValueH db ? +FIFO_out5 label byte +FIFO_wIndexL db ? +FIFO_out6 label byte +FIFO_wIndexH db ? +FIFO_out7 label byte +FIFO_wLengthL db ? +FIFO_out8 label byte +FIFO_wLengthH db ? + +FIFO_TEMP db ? +;************************************************************** +;USB 篈既 +; +; +;************************************************************** +USB_Interface db ? +USB_Interface_Alt db ? +USB_Configuration db ? +;//save usb address +FIFO_ADDR db ? + +Loop_Counter db ? +Data_Count db ? +Data_Start db ? + +;voice control +INC_Counter db ? +DEC_Counter db ? + + +;FIFO +bFlag_SetConfiguration_Ready dbit +bFlag_SetInterface_Ready dbit +bFlag_Real_Cmd dbit +bFlag_FIFO_Ready dbit +bFlag_FIFO_LEN0 dbit +bFlag_RD_HTable dbit +bFlag_wait_control_out dbit +bFlag_SET_ADDRESS dbit +bFlag_SCMD dbit +bFlag_Enum_Ready dbit +;Audio +PortC_data db ? +bFlag_Audio_Mute dbit +Volume1 db ? +Volume2 db ? + +;Mute_Save db ? +VolumeH_Save db ? +VolumeL_Save db ? + +nCmdIndex1 db ? + + +;************************************************************** +;Key 篈既 +; +; +;************************************************************** + +;;Key_Process db ? +;;Key_CheckIn db ? +;;Key_Counter db ? +;;Key_Temp db ? +;;Key_IncCounter db ? +;;Key_DecCounter db ? + +;modify for Remote Wakeup +bRmtWakeup dbit +b_wakeup dbit +;modify 2007-06-27 +b_forceresumeWakeup dbit +;modify 2007-07-03 +b_forusbRst dbit +bFlagTMR1 dbit + +;;*********************************************** + +extern control_read_table:NEAR +extern device_desc_table:NEAR +extern config_desc_table:NEAR + +extern end_config_desc_table:NEAR +extern hid_report_desc_table:NEAR +extern end_hid_report_desc_table:NEAR + +extern USBStringLanguageDescription:NEAR +extern USBStringDescription1:NEAR +extern USBStringDescription2:NEAR + +extern config_desc_length:NEAR +extern report_desc_length:NEAR +;function +extern Control_Read:NEAR +extern FIFO0_RD_CHECK:NEAR +extern FIFO1_RD_CHECK:NEAR +extern FIFO2_RD_CHECK:NEAR +extern FIFO3_RD_CHECK:NEAR +extern FIFO4_RD_CHECK:NEAR +extern FIFO5_RD_CHECK:NEAR +extern FIFO0_WR_CHECK:NEAR +extern FIFO1_WR_CHECK:NEAR +extern FIFO2_WR_CHECK:NEAR +extern FIFO3_WR_CHECK:NEAR +extern FIFO4_WR_CHECK:NEAR +extern FIFO5_WR_CHECK:NEAR +extern Read_FIFO0:NEAR +extern Read_FIFO1:NEAR +extern Read_FIFO2:NEAR +extern Read_FIFO3:NEAR +extern Read_FIFO4:NEAR +extern Read_FIFO5:NEAR +extern Write_FIFO0:NEAR +extern Write_FIFO1:NEAR +extern Write_FIFO2:NEAR +extern Write_FIFO3:NEAR +extern Write_FIFO4:NEAR +extern Write_FIFO5:NEAR +extern Send_Hand_Shake:NEAR +extern get_descriptor_length:NEAR + +extern SetAddress:NEAR +extern SetConfiguration:NEAR +extern SetInterface:NEAR +extern GetInterface:NEAR +extern GetDescriptor:NEAR +extern SetIdle:NEAR +extern GetDeviceDescriptor:NEAR +extern GetConfigurationDescriptor:NEAR +extern GetStringDescriptor:NEAR +extern GetStatus:NEAR +;modify for Remote Wakeup +extern GetStatus_Interface:NEAR +;---------------------------------------------- +extern SetFeature:NEAR +extern ClearFeature:NEAR +extern SetReport:NEAR +extern Execute:NEAR +extern SendStall0:NEAR +extern Delay_3us:NEAR + +extern SetFeature_Endpoint:NEAR +extern ClearFeature_Endpoint:NEAR +extern GetStatus_Endpoint:NEAR + +extern Check_Real_Cmd:NEAR +extern GetConfiguration:NEAR + + +;audio +extern SetCur:NEAR +extern GetMin:NEAR +extern GetMax:NEAR +extern GetRes:NEAR +extern GetCur:NEAR + +extern GetPipeBit:NEAR +;*************************************************************** +; MCU Interrupt Table +;*************************************************************** + + +CODE .section AT 00H 'code' + ORG 00H + jmp Start + ORG 04H + jmp USB_ISR + ORG 08H + jmp Timer_0_ISR + ORG 0CH + jmp Timer_1_ISR + + + ;----------------------------------------------------------- + ; Start : ORG 20H 磷秨玡 interrupt + ;----------------------------------------------------------- +ORG 20H +Start: + + call System_Initial + + ;----------------------------------------------------------- + ; Main LOOP Function : + ;----------------------------------------------------------- +Main: + ;----------------------------------------------------------- + ; Check Suspend Function : + ; 材Ω浪琩 suspend 莱璶 delay 1 S 浪琩Ω , 狦 suspend 癟腹临秈 halt + ; 叫浪琩 timer 琌Τ秨币 , 璝Τ莱既闽超 ,  resume 秨币 + ;----------------------------------------------------------- + SNZ USC.@USC_SUSP ;check SUSPEND ? + JMP Main_My_Function + + call wait_about_1s + SNZ USC.@USC_SUSP + JMP Main_My_Function + +ToSuspend_again: + clr wdt +;; clr TMR1C.4 + clr USB_LED_ON + clr UCC.@UCC_USBCKEN + clr b_forceresumeWakeup + ;clr b_forusbRst + ;----------------------------------------------------------- + ; Resume Function : + ;  function 璶р halt ぇ玡 timer 篈確 , 秨币 USBCKEN + ;----------------------------------------------------------- + HALT +;; set TMR1C.4 + set USB_LED_ON + set UCC.@UCC_USBCKEN + + ;modify 2007-06-28 + set AWR.@AWR_WKEN + + ;sZ b_forusbRst + ;JMP Start + + sz b_forceresumeWakeup + jmp RemoteWakeup + + snz b_wakeup + jmp RemoteWakeup_loop + ;clr b_wakeup + snz bRmtWakeup ; 浪琩USB device琌Enable RemoteWakeup + jmp ToSuspend_again ; 璝bRmtWakeup=0,玥suspend + clr bRmtWakeup + +;modify for Remote Wakeup +RemoteWakeup_loop: + clr b_wakeup + + + ;sz b_forceresumeWakeup + ;jmp RemoteWakeup + + ;sz USC.@USC_SUSP ; + ;jmp ToSuspend_again ; + ;JMP Main + +RemoteWakeup: + ;modify 2007-06-27 + clr b_forceresumeWakeup + SET USC.@USC_RMWK ; USC.RMWK=1 + nop + nop + nop + nop + nop + nop + CLR USC.@USC_RMWK ; USC.RMWK=0 + ;clr AWR.@AWR_WKEN + ;sZ b_forusbRst + ;JMP Start + + SZ USC.@USC_SUSP ;check SUSPEND ? + JMP Main + +;----------------------------------------------------- +Main_My_Function: + CLR WDT + SNZ bFlag_SetConfiguration_Ready + JMP main ;;USB Not OK + +;---------------------------------------------------- + SZ bIniFMOK + JMP L_MyFunction ;;IniFM OK + + MOV A,cFreqDefL + MOV mFreqL,A + MOV A,cFreqDefH + MOV mFreqH,A + CALL QN8072Init ;;Init QN8072 + SET bIniFMOK + + ;----------------------------------------------------------- + ; Here to add your another code !! + ;----------------------------------------------------------- +L_MyFunction: + clr wdt + NOP + snz bFlagTMR1 +;; jmp Main_End +;; IF UseMediaKey +;; call Key_Debounced +;; ENDIF + call Run_Volume_Step + + clr bFlagTMR1 + +Main_End: + + JMP Main + +;*************************************************************** +; System Initial +; 1.ram_initial +; 1.Timer Initial +; 2.USB Config +;*************************************************************** +System_Initial: + ;----------------------------------------------------------- + ; Debug + ;----------------------------------------------------------- + + + ;----------------------------------------------------------- + ; Modify Pop Noise + ; 癳い丁非 code  DA + ;----------------------------------------------------------- + clr wdt + mov a,WDTS + mov FIFO_TEMP,a + + mov a,01010111b + mov WDTS,a + + clr [02DH] + + + mov a,80H + mov [02EH],a + nop + nop + set [02FH].3 + nop + nop + clr [02FH].3 + nop + nop + + mov a,FIFO_TEMP + mov WDTS,a + ;----------------------------------------------------------- + ; ˙艼单筿甧ど丁 + ; 代刚莱赣р WaitBias 砞 0 , 獶代刚莱赣р WaitBais 砞 1 + ; Wait Bais and ROUT LOUT Capacity rise about 1.98ms + ; delay time = 255*255*30*3(sdz,jmp) cycle * 0.3333us/cycle = 1.98 ms + ;----------------------------------------------------------- + IF WaitBias + clr pac + + clr FIFO_OUT1 + clr FIFO_OUT2 + clr FIFO_OUT3 + mov a,9 + mov FIFO_OUT3,a + clr pa + + + + System_Initial_Loop: + clr wdt + sdz FIFO_OUT1 + jmp System_Initial_Loop + sdz FIFO_OUT2 + jmp System_Initial_Loop + sdz FIFO_OUT3 + jmp System_Initial_Loop + nop + set pa + clr wdt + ENDIF + ;----------------------------------------------------------- + ; Codec Limit + ;----------------------------------------------------------- + clr [02DH] + set [02EH] + + ;----------------------------------------------------------- + ; ram_initial : clear the ram of bank 0 + ;----------------------------------------------------------- + ram_initial: ;clear RAM (040H--0FFH) + MOV A,040H + MOV MP0,A + MOV A,192 + ram_initial_next_addr: + clr wdt + CLR R0 + INC MP0 + SDZ acc + JMP ram_initial_next_addr + + CLR bFlag_RD_HTable + ;----------------------------------------------------------- + ; timer_initial : do timer initial + ;----------------------------------------------------------- + timer_initial: +;; MOV A,80H ; 砞﹚ low  high 牟祇砞ず场璸家Α +;; MOV TMR0C,A ; +;; MOV A,00H ; +;; MOV TMR0L,A +;; MOV A,000H +;; MOV TMR0H,A + + mov a,80H + mov TMR1C,a + mov a,00H + mov TMR1L,a + mov TMR1H,a + + ;----------------------------------------------------------- + ; config_io_port : + ;----------------------------------------------------------- +;; clr PA + ;----------------------------------------------------------- + ; config_io_port :(USB Audio) + ;----------------------------------------------------------- + SET P_LED + CLR P_LEDC + SET P_SDA + CLR P_SDAC + SET P_SCL + CLR P_SCLC + + ;;Initial QN8072 Reg0~4 + MOV A,51H + MOV mQNReg[0],A + MOV A,18H + MOV mQNReg[1],A + MOV A,0B9H + MOV mQNReg[2],A + MOV A,50H + MOV mQNReg[3],A + MOV A,58H + MOV mQNReg[4],A + + +;; IF UseMediaKey +;; kmov pac,Key_Defined +;; ENDIF +;; IFE UseMediaKey +;; kmov pac,00000000b +;; ENDIF + +;; clr pb +;; clr pbc ;change to USB Len On +;;; clr pc ;for volume control +;; set pcc +;; clr pd +;; clr pdc + ;----------------------------------------------------------- + ; config_usb_speaker_register : + ;----------------------------------------------------------- + clr USVC ;mute & 0db + clr USF + ;----------------------------------------------------------- + ; reset variable : + ;----------------------------------------------------------- + clr bFlag_Audio_Mute + clr VolumeH_Save + mov a,Cur_Volume + mov VolumeL_Save,a + ;----------------------------------------------------------- + ; config_usb : do usb config + ;----------------------------------------------------------- + config_usb: + CLR INTC0 + SET INTC0.@INTC0_EEI ;enable USB + SET INTC0.@INTC0_EMI ;Global interrupt + + set MISC.@MISC_ISOEN + clr STALL + clr UCC.@UCC_SUSP2 + + ;SYSCLK + ;set UCC.6 //set to 6 MHz + + set UCC.@UCC_USBCKEN + nop + set USC.@USC_V33C ;//pc 秨﹍癳 command 筁ㄓ + clr wdt + ;modify for Remote Wakeup + clr bRmtWakeup + clr b_wakeup + clr b_forusbRst + ;clr AWR.@AWR_WKEN + RET + +;*************************************************************** +; Timer_0_ISR +; 1.Timer time = 21.2 ms +; 2.Do this procedure is 3.6ms +;*************************************************************** +Timer_0_ISR: +;; clr TMR0C.4 +;; MOV isr_tmr0_acc,A ;save ACC +;; MOV A,STATUS +;; MOV isr_tmr0_status,A ;save status +;; MOV A,MP1 +;; MOV isr_tmr0_mp1,A ;save mp1 +;; MOV A,MP0 +;; MOV isr_tmr0_mp0,A ;save mp0 +;; MOV A,TBLP +;; MOV isr_tmr0_tblp,A ;save TBLP + +Timer_0_My_Function: + ;----------------------------------------------------------- + ; Here to add your another code !! + ;----------------------------------------------------------- +;; NOP +;; clr wdt + +Timer_0_ISR_END: +;; MOV A,isr_tmr0_tblp ;restore TBLP +;; MOV TBLP,A +;; MOV A,isr_tmr0_mp0 ;restore MP0 +;; MOV MP0,A +;; MOV A,isr_tmr0_mp1 ;restore MP1 +;; MOV MP1,A +;; MOV A,isr_tmr0_status ;restore STATUS +;; MOV STATUS,A +;; MOV A,isr_tmr0_acc ;restore ACC +;; SET TMR0C.4 ;start timer0 + + RETI + +;*************************************************************** +; Timer_1_ISR +; 1.Timer time = 21.2 ms +; 2.Do this procedure is 3.6ms +;*************************************************************** +Timer_1_ISR: + CLR TMR1C.4 + + +;; MOV isr_tmr1_acc,A ;save ACC +;; MOV A,STATUS +;; MOV isr_tmr1_status,A ;save status +;; MOV A,MP1 +;; MOV isr_tmr1_mp1,A ;save mp1 +;; MOV A,MP0 +;; MOV isr_tmr1_mp0,A ;save mp0 +;; MOV A,TBLP +;; MOV isr_tmr1_tblp,A ;save TBLP +;; clr wdt + ;IF UseMediaKey + ;call Key_Debounced + ;ENDIF + ;call Run_Volume_Step + set bFlagTMR1 + +;; MOV A,isr_tmr1_tblp ;restore TBLP +;; MOV TBLP,A +;; MOV A,isr_tmr1_mp0 ;restore MP0 +;; MOV MP0,A +;; MOV A,isr_tmr1_mp1 ;restore MP1 +;; MOV MP1,A +;; MOV A,isr_tmr1_status ;restore STATUS +;; MOV STATUS,A +;; MOV A,isr_tmr1_acc ;restore ACC + +Timer_1_ISR_End: + SET TMR1C.4 + RETI + +;*************************************************************** +; USB_ISR : USB Interrupt Routine +; 1.Back up every status register +; 2.check which endpoint is interrupt +;*************************************************************** +USB_ISR: + ;CLR INTC0.@INTC0_EEI ;disable USB interrupt + ;SET INTC0.@INTC0_EMI + + MOV isr_usb_acc,A ;save ACC + MOV A,STATUS + MOV isr_usb_status,A ;save status + MOV A,MP1 + MOV isr_usb_mp1,A ;save mp1 + MOV A,MP0 + MOV isr_usb_mp0,A ;save mp0 + MOV A,TBLP + MOV isr_usb_tblp,A ;save TBLP + + ;modify 2007-07-03 + SZ USC.@USC_URST + SET b_forusbRst + CLR USC.@USC_URST + + ;modify 2007-06-27 + SZ USC.@USC_RESUME + set b_forceresumeWakeup;;JMP RemoteWakeup + + clr wdt + ;;Check Which FIFO is interrupt + JMP Check_Access_FIFO + + + +USB_ISR_END: + MOV A,isr_usb_tblp ;restore TBLP + MOV TBLP,A + MOV A,isr_usb_mp0 ;restore MP0 + MOV MP0,A + MOV A,isr_usb_mp1 ;restore MP1 + MOV MP1,A + MOV A,isr_usb_status ;restore STATUS + MOV STATUS,A + MOV A,isr_usb_acc ;restore ACC + + + ;CLR INTC0.@INTC0_EMI + ;SET INTC0.@INTC0_EEI + + + RETI + +;*************************************************************** +; USB_EPX_ISR +; ぇ玡ㄏノ USR@EP0IF EQU [01BH].0 穦盎代ぃ +; эΘ USB_STATUS_CONTROL.@EP0IF +;*************************************************************** +Check_Access_FIFO: + clr wdt + SZ USR.@USR_EP0F + JMP USB_EP0_ISR + SZ USR.@USR_EP1F + JMP USB_EP1_ISR + SZ USR.@USR_EP2F + JMP USB_EP2_ISR + JMP USB_ISR_END + +;----------------------------------------------------- +;EPNPOINT 0 +;----------------------------------------------------- +USB_EP0_ISR: + ;CLR USR.@USR_EP0F + +;;case1 + SZ MISC.@MISC_SCMD ;check setup token + JMP USB_EP0_SETUP_TOKEN + + SZ MISC.@MISC_LEN0 ;check out ack token + JMP USB_EP0_OUT_ACK_TOKEN + + CALL FIFO0_RD_CHECK + SZ bFlag_FIFO_Ready + JMP USB_EP0_OUT_TOKEN + ;clr MISC.@MISC_REQ + + CALL FIFO0_WR_CHECK + SZ bFlag_FIFO_Ready + JMP USB_EP0_IN_TOKEN ;else is in token + ;clr MISC.@MISC_REQ + + ;modify 2007-06-20 + CLR USR.@USR_EP0F ;Fix OHCI Volume + + JMP USB_EP0_ISR_END + + +;;case2 +;; SZ MISC.@MISC_SCMD ;check setup token +;; JMP USB_EP0_SETUP_TOKEN +;; +;; SZ MISC.@MISC_LEN0 ;check out ack token +;; JMP USB_EP0_OUT_ACK_TOKEN +;; +;; CALL FIFO0_RD_CHECK +;; SZ bFlag_FIFO_Ready +;; JMP USB_EP0_OUT_TOKEN +;; ;clr MISC.@MISC_REQ +;; +;; CALL FIFO0_WR_CHECK +;; SZ bFlag_FIFO_Ready +;; JMP USB_EP0_IN_TOKEN ;else is in token +;; ;clr MISC.@MISC_REQ +;; +;; +;; JMP USB_EP0_ISR_END + + +;;case3 +;; call FIFO0_RD_CHECK +;; sz bFlag_FIFO_Ready +;; jmp Have_Data_Out +;; +;; call FIFO0_WR_CHECK +;; sz bFlag_FIFO_Ready +;; jmp USB_EP0_IN_TOKEN +;; +;; jmp USB_EP0_ISR_END +;; +;;Have_Data_Out: +;; sz MISC.@MISC_SCMD +;; jmp USB_EP0_SETUP_TOKEN +;; sz MISC.@MISC_LEN0 +;; jmp USB_EP0_OUT_ACK_TOKEN +;; +;; jmp USB_EP0_OUT_TOKEN + + + + + +USB_EP0_SETUP_TOKEN: ;PARSE SETUP TOKEN + clr wdt + JMP StageOne + +USB_EP0_IN_TOKEN: + clr wdt + ;modify 2007-06-20 + CLR USR.@USR_EP0F ;Fix OHCI Volume + CALL control_read + JMP USB_EP0_ISR_END + +USB_EP0_OUT_ACK_TOKEN: + ;modify 2007-06-20 + CLR USR.@USR_EP0F ;Fix OHCI Volume + clr wdt + clr MISC.@MISC_LEN0 + JMP USB_EP0_ISR_END + +;-------------------------------------------------------------- +; Parser nCmdIndex1 +;-------------------------------------------------------------- +USB_EP0_OUT_TOKEN: + ;modify 2007-06-20 + CLR USR.@USR_EP0F ;Fix OHCI Volume + clr wdt + clr acc + xor a,nCmdIndex1 + sz z + jmp USB_EP0_ISR_END + +USB_EP0_OUT_TOKEN_Loop: + clr wdt + CALL Check_Real_Cmd + sz bFlag_Real_Cmd + jmp USB_EP0_OUT_TOKEN_End + + clr wdt + CALL FIFO0_RD_CHECK + SNZ bFlag_FIFO_Ready + JMP USB_EP0_OUT_TOKEN_Loop + + CALL READ_FIFO0 + NOP + CALL Send_Hand_Shake + + ;decode command + ;//parse Cmd , 21 = SetReport Out Data + mov a,21H + xor a,nCmdIndex1 + sz z + jmp ProcessOutData + + ;//parse Cmd , 18 = Mute Control + mov a,18H + xor a,nCmdIndex1 + sz z + jmp Implement_Mute + + ;//parse Cmd , 28 = Volume Control + mov a,28H + xor a,nCmdIndex1 + sz z + jmp Implement_Volume + + ;//unknow command + jmp USB_EP0_OUT_TOKEN_End + +USB_EP0_OUT_TOKEN_End: + clr nCmdIndex1 + JMP USB_EP0_ISR_END + + +Implement_Mute: + clr wdt + sz FIFO_out1.0 + clr USVC.7 ;mute + snz FIFO_out1.0 + set USVC.7 ;unmute + + sz FIFO_out1.0 + set bFlag_Audio_Mute ;mute + snz FIFO_out1.0 + clr bFlag_Audio_Mute ;unmute + + sz FIFO_out1.0 + set MUTE_LED_ON ;mute + snz FIFO_out1.0 + clr MUTE_LED_ON ;unmute + + + snz bFlag_Audio_Mute + jmp Implement_Mute_1 + + mov a,Min_Volume + mov USVC,a + + clr USVC.7 + + +Implement_Mute_1: + clr wdt + ;//kmov Mute_Save,FIFO_out1 + jmp USB_EP0_OUT_TOKEN_End + + +Implement_Volume: + clr wdt + kmov VolumeH_Save,FIFO_out1 + kmov VolumeL_Save,FIFO_out2 +Implement_Volume_End: + jmp USB_EP0_OUT_TOKEN_End + +USB_EP0_ISR_END: + ;//CLR USR.@USR_EP0F + JMP USB_ISR_END +;----------------------------------------------------- +;EPNPOINT 1 Interrupt +;----------------------------------------------------- +USB_EP1_ISR: + CLR USR.@USR_EP1F + SNZ bIniFMOK + JMP USB_EP1_ISR_END ;;FM Not initial OK,exit + + ;check the data is in fifo ? + CALL FIFO1_RD_CHECK + SNZ bFlag_FIFO_Ready + JMP USB_EP1_ISR_END + CALL Read_FIFO1 + + + ;;CALL FIFO1_WR_CHECK + ;;SNZ bFlag_FIFO_Ready + ;;JMP USB_EP1_ISR_END + ;;MOV A,00H + ;;MOV FIFO_OUT1,A + ;;MOV A,01H + ;;MOV FIFO_SendLen,A + ;;CALL WRITE_FIFO1 + + CALL QN8027 + + + +USB_EP1_ISR_END: + JMP USB_ISR_END +;----------------------------------------------------- +;EPNPOINT 2 Interrupt +;----------------------------------------------------- +USB_EP2_ISR: + CLR USR.@USR_EP2F + ;;SET ET0I ;enable timer0 + ;;SET TMR0C.4 ;璓 秨﹍璸计 + + + + clr MISC.@MISC_ISOEN ;闽超 ISO い耞 + + +USB_EP2_ISR_END: + JMP USB_ISR_END + + +;*************************************************************** +; Stage One .... Test bmRequestType +; CALL FIFO_RD_CHECK will return bFlag_FIFO_Ready?(1=Ready,0=not ready) +;*************************************************************** +StageOne: + clr wdt + CALL FIFO0_RD_CHECK + SNZ bFlag_FIFO_Ready + JMP StageOne_End ; the EP0 FIFO RD is not ready ⊿Τdata秈ㄓ + CALL Read_FIFO0 ; Read EP0 Command + clr MISC.@MISC_SCMD + clr MISC.@MISC_LEN0 + + ;modify 2007-06-20 + CLR USR.@USR_EP0F ;Fix OHCI Volume + + clr wdt + nop + + MOV A,FIFO_TYPE + XOR A,00H + SZ Z ;FIFO_TYPE=00H + JMP Request_Type00 + + MOV A,FIFO_TYPE + XOR A,01H + SZ Z ;FIFO_TYPE=01H + JMP Request_Type01 + + MOV A,FIFO_TYPE + XOR A,02H + SZ Z ;FIFO_TYPE=02H + JMP Request_Type02 + + MOV A,FIFO_TYPE + XOR A,80H + SZ Z ;FIFO_TYPE=80H + JMP Request_Type80 + + MOV A,FIFO_TYPE + XOR A,81H + SZ Z ;FIFO_TYPE=81H + JMP Request_Type81 + + MOV A,FIFO_TYPE + XOR A,82H + SZ Z ;FIFO_TYPE=82H + JMP Request_Type82 + +;=============================================================== +;HID & Audio +;=============================================================== + MOV A,FIFO_TYPE + XOR A,21H + SZ Z + JMP Request_Type21 + +;Volume Control + clr wdt + MOV A,FIFO_TYPE + XOR A,0A1H + SZ Z + JMP Request_TypeA1 + + JMP SendStall0 + + +StageOne_End: + ;modify 2007-06-20 + CLR USR.@USR_EP0F ;Fix OHCI Volume + RET + + +;*************************************************************** +; USB Stage2 +; +;*************************************************************** +;Device to Host with device as recipient +;=============================================================== +;Request_Type00 +;bRequest Function +; 1 Clear Feature +; 3 Set Feature +; 5 Set Address +; 7 not support +; 9 Set Configuration +;=============================================================== +;=============================================================== +Request_TYPE00: +;Set the device address to a non-zero value +;Set address + clr wdt + MOV A,FIFO_REQUEST + XOR A,set_address + SZ Z + JMP SetAddress + +;Set Configuration + MOV A,FIFO_REQUEST + XOR A,set_configuration + SNZ Z + JMP Request_TYPE00_NEXT + + SET ET1I + SET TMR1C.4 + + JMP SetConfiguration + +;Clear Feature +;The HT82A822R return ACK without ERROR +Request_TYPE00_NEXT: + MOV A,FIFO_REQUEST + XOR A,clear_feature + SZ Z + JMP ClearFeature + +;Set Feature + clr wdt + MOV A,FIFO_REQUEST + XOR A,set_feature + SZ Z + JMP SetFeature + + JMP SendStall0 +;=============================================================== +Request_Type01: + clr wdt + MOV A,FIFO_REQUEST + XOR A,set_interface + SZ Z + JMP SetInterface + + JMP SendStall0 +;=============================================================== +Request_Type02: + clr wdt + MOV A,FIFO_REQUEST + XOR A,clear_feature + SZ Z + JMP ClearFeature_Endpoint + + MOV A,FIFO_REQUEST + XOR A,set_feature + SZ Z + JMP SetFeature_Endpoint + + + + JMP SendStall0 + + + +;=============================================================== +Request_TYPE80: +;Get Status +;Get Descriptor 80 06 + clr wdt + MOV A,FIFO_REQUEST + XOR A,get_descriptor + SZ Z + JMP GetDescriptor + +;Get Configuration 80 08 + clr wdt + MOV A,FIFO_REQUEST + XOR A,get_configuration + SZ Z + JMP GetConfiguration + +;Get Status(DEVICE) 80 00 + clr wdt + MOV A,FIFO_REQUEST + XOR A,get_status + SZ Z + JMP GetStatus + + JMP SendStall0 + +;=============================================================== +Request_TYPE81: +;get status +;get interface -> not support +;HID class defines one more request for bmRequestType=81 +;get HID descriptor + clr wdt + MOV A,FIFO_REQUEST + XOR A,get_descriptor + SZ Z + JMP GetDescriptor + +;Get Interface + clr wdt + MOV A,FIFO_REQUEST + XOR A,get_interface + SZ Z + JMP GetInterface + +;Get Status(INTERFACE) 81 00 + clr wdt + MOV A,FIFO_REQUEST + XOR A,get_status + SZ Z + JMP GetStatus_Interface ;modify for Remote Wakeup + + JMP SendStall0 +;=============================================================== +Request_TYPE82: +;get status +;Get Status(INTERFACE) 82 00 + clr wdt + MOV A,FIFO_REQUEST + XOR A,get_status + SZ Z + JMP GetStatus_Endpoint + + JMP SendStall0 + +;=============================================================== +;=============================================================== +;Now parse HID class Descriptor Types +;=============================================================== +;host to device with endpoint as recipient +Request_TYPE21: + clr wdt + ;set report + MOV A,FIFO_REQUEST + XOR A,set_report + SZ Z + JMP SetReport + + ;------------------------------------------------------ + ;audio class-specific request code + ;------------------------------------------------------ + + MOV A,FIFO_REQUEST + XOR A,SET_CUR + SZ Z + JMP SetCur + +Request_TYPE21_End: + JMP SendStall0 + +Request_TypeA1: + MOV A,FIFO_REQUEST + XOR A,GET_MIN + SZ Z + JMP GetMin + + MOV A,FIFO_REQUEST + XOR A,GET_MAX + SZ Z + JMP GetMax + + MOV A,FIFO_REQUEST + XOR A,GET_RES + SZ Z + JMP GetRes + + MOV A,FIFO_REQUEST + XOR A,GET_CUR + SZ Z + JMP GetCur + + +Request_TYPEA1_End: + JMP SendStall0 +;=============================================================== +ProcessOutData: + sz bFlag_Real_Cmd + jmp ProcessOutData_End + +;; clr wdt +;; CALL FIFO0_RD_CHECK +;; SNZ bFlag_FIFO_Ready +;; JMP ProcessOutData ; the EP0 FIFO RD is not ready ⊿Τdata秈ㄓ + +;; CALL Read_FIFO0 + CALL QN8027 +;; nop +;; call FIFO1_WR_CHECK +;; snz bFlag_FIFO_Ready +;; jmp ProcessOutData_End + +;; call Write_FIFO1 + + +ProcessOutData_End: + clr nCmdIndex1 + jmp USB_EP0_ISR_END + + + + +Delay_20ms: + clr wdt + mov a,075H + mov Delay_1,a + mov a,0FFH + mov Delay_2,a +Delay_20ms_Wait: + clr wdt + SDZ Delay_2 + JMP Delay_20ms_Wait + SDZ Delay_1 + JMP Delay_20ms_Wait + RET + +Delay_5ms: + clr wdt + mov a,03AH + mov Delay_1,a + mov a,0FFH + mov Delay_2,a +Delay_5ms_Wait: + clr wdt + SDZ Delay_2 + JMP Delay_5ms_Wait + SDZ Delay_1 + JMP Delay_5ms_Wait + RET + + +Delay PROC + clr wdt + MOV A,0FFH + MOV Delay_1,A + MOV Delay_2,A + +Wait: + clr wdt + SDZ Delay_2 + JMP Wait + SDZ Delay_1 + JMP Wait + RET + +Delay ENDP + + + +;*************************************************************** +; Run_Volume_Step Module +; Volume1:Target +; Volume2:Now +;*************************************************************** +Run_Volume_Step: + clr wdt + ;check mute? + sz bFlag_Audio_Mute + jmp Run_Volume_Step_End + + + mov a,VolumeL_Save + mov Volume1,a + + ;check Volume1 = 080H ? + mov a,80H + xor a,Volume1 + sz z + jmp Run_Volume_Step_Process_Min + jmp Run_Volume_Step_1 + +Run_Volume_Step_Process_Min: + mov a,Min_Volume + mov Volume1,a + + + +Run_Volume_Step_1: + + clr Volume1.7 + + mov a,01111111b + and a,USVC + mov Volume2,a ;Volume2=now Volume1=target + + + mov a,Volume1 + xor a,Volume2 + sz z + jmp Run_Volume_Step_End ;target=now + + clr wdt + mov a,Volume1 + sub a,Volume2 ;target-now + sz C + jmp Run_Volume_1 ;>0 + jmp Run_Volume_2 ;<0 + +Run_Volume_1: + snz Volume1.6 + jmp Run_Volume_Step_Inc + snz Volume2.6 + jmp Run_Volume_Step_Dec + jmp Run_Volume_Step_Inc + +Run_Volume_2: + snz Volume2.6 + jmp Run_Volume_Step_Dec + snz Volume1.6 + jmp Run_Volume_Step_Inc + jmp Run_Volume_Step_Dec + + + +Run_Volume_Step_Inc: + INC Volume2 + jmp Run_Volume_Step_2 +Run_Volume_Step_Dec: + DEC Volume2 +Run_Volume_Step_2: + sz USVC.7 + set Volume2.7 + snz USVC.7 + clr Volume2.7 + kmov USVC,Volume2 + clr wdt +Run_Volume_Step_End: + ret + +;*************************************************************** +; Key_Debounced Module +; Key_Defined : 饼盎代 bit +; Key_Process : 矪瞶筁 叫 set  bit +; Key_CheckIn : 材Ω盎代惠璶 set  bit +; Key_Counter : 纗 bit  1 +; 狦惠璶硈尿笆玥叫づ set Key_Process ( INC,DEC Volume) +; 狦ぃ惠璶硈尿笆叫 set Key_Process ( Mute,Play,Stop) +;*************************************************************** +IF UseMediaKey +Key_Debounced: + clr wdt + mov a,VIOP + cpl acc + mov PortC_Data,a + + mov a,Key_Defined + andm a,PortC_Data + sz z + jmp Key_Debounced_ClearReg ;//⊿龄砆 + + +Key_Debounced_Detect_In: + kmov Key_Temp,PortC_Data + clr Key_Counter +Key_Debounced_Detect: + clr C + RRC Key_Temp + sz C + jmp Key_Debounced_Detect_End + inc Key_Counter + mov a,080H + xor a,Key_Temp + sz z + jmp Key_Debounced_Detect_End + jmp Key_Debounced_Detect +Key_Debounced_Detect_End: + mov a,Key_Counter + call GetPipeBit + + xor a,Key_CheckIn + snz z + jmp Key_Debounced_SetCheckIn + + ;check process + mov a,Key_Process + xor a,Key_CheckIn + sz z + jmp Key_Debounced_End + jmp Key_Debounced_Process + +;璝ぃ惠璶矪瞶叫 jmp Key_Debounced_End + nop + nop + nop +Key_Debounced_Process: + clr wdt + mov a,Key_Counter + addm a,pcl + jmp Key_Debounced_Process_WindowsMediaPlayer + jmp Key_Debounced_Process_Mute + jmp Key_Debounced_Process_Dec + jmp Key_Debounced_Process_Inc + jmp Key_Debounced_Process_PlayPause + jmp Key_Debounced_Process_Stop + jmp Key_Debounced_Process_NextTrack + jmp Key_Debounced_Process_PreviousTrack + +Key_Debounced_SetCheckIn: + mov Key_CheckIn,a + clr Key_Process + kmov Key_IncCounter,Const_Counter + kmov Key_DecCounter,Const_Counter + jmp Key_Debounced_End + +Key_Debounced_ClearReg: + clr acc + xor a,Key_CheckIn + sz z + jmp Key_Debounced_End + jmp Key_Debounced_ClearReg_2 +; clr acc +; xor a,Key_Process +; snz z +; jmp Key_Debounced_ClearReg_2 +; jmp Key_Debounced_End + +Key_Debounced_ClearReg_2: + clr Key_CheckIn + clr Key_Process + +Key_Debounced_ClearReg_1: + CALL FIFO1_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP Key_Debounced_End + + IF UseReportID + MOV A,01H ;REPORT ID + MOV FIFO_OUT1,A + MOV A,00H + MOV FIFO_OUT2,A + MOV A,02H + MOV FIFO_SendLen,A + ELSE + MOV A,00H + MOV FIFO_OUT1,A + MOV A,01H + MOV FIFO_SendLen,A + ENDIF + CALL WRITE_FIFO1 + ;//write fifo + nop + + +Key_Debounced_My_Function: + ;----------------------------------------------------------- + ; Here to add your another code !! + ;----------------------------------------------------------- + nop + + + jmp Key_Debounced_End + +Key_Debounced_End: + clr wdt + ret +;=========================Process +Key_Debounced_Process_Mute: + clr wdt + CALL FIFO1_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP Key_Debounced_End + + IF UseReportID + MOV A,01H ;REPORT ID + MOV FIFO_OUT1,A + MOV A,08H + MOV FIFO_OUT2,A + MOV A,02H + MOV FIFO_SendLen,A + ELSE + MOV A,08H + MOV FIFO_OUT1,A + MOV A,01H + MOV FIFO_SendLen,A + ENDIF + CALL WRITE_FIFO1 + nop + kmov Key_Process,Key_CheckIn + jmp Key_Debounced_End +Key_Debounced_Process_Dec: + clr wdt + sdz Key_DecCounter + jmp Key_Debounced_End + + CALL FIFO1_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP Key_Debounced_End + IF UseReportID + MOV A,01H ;REPORT ID + MOV FIFO_OUT1,A + MOV A,02H + MOV FIFO_OUT2,A + MOV A,02H + MOV FIFO_SendLen,A + ELSE + MOV A,02H + MOV FIFO_OUT1,A + MOV A,01H + MOV FIFO_SendLen,A + ENDIF + CALL WRITE_FIFO1 + nop + kmov Key_DecCounter,Const_Counter + nop + jmp Key_Debounced_End + +Key_Debounced_Process_Inc: + clr wdt + sdz Key_IncCounter + jmp Key_Debounced_End + + CALL FIFO1_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP Key_Debounced_End + IF UseReportID + MOV A,01H ;REPORT ID + MOV FIFO_OUT1,A + MOV A,01H + MOV FIFO_OUT2,A + MOV A,02H + MOV FIFO_SendLen,A + else + MOV A,01H + MOV FIFO_OUT1,A + MOV A,01H + MOV FIFO_SendLen,A + ENDIF + CALL WRITE_FIFO1 + nop + kmov Key_IncCounter,Const_Counter + nop + jmp Key_Debounced_End + +;=============================================================== +; User Add Some Key Debounced Code +;=============================================================== +Key_Debounced_Process_WindowsMediaPlayer: + ;----------------------------------------------------------- + ; Here to add your another code !! + ;----------------------------------------------------------- + clr wdt + CALL FIFO1_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP Key_Debounced_End + + IF UseReportID + MOV A,01H ;REPORT ID + MOV FIFO_OUT1,A + MOV A,04H + MOV FIFO_OUT2,A + MOV A,02H + MOV FIFO_SendLen,A + ELSE + MOV A,04H + MOV FIFO_OUT1,A + MOV A,01H + MOV FIFO_SendLen,A + ENDIF + CALL WRITE_FIFO1 + nop + kmov Key_Process,Key_CheckIn + jmp Key_Debounced_End + +Key_Debounced_Process_PlayPause: + ;----------------------------------------------------------- + ; Here to add your another code !! + ;----------------------------------------------------------- + clr wdt + CALL FIFO1_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP Key_Debounced_End + + IF UseReportID + MOV A,01H ;REPORT ID + MOV FIFO_OUT1,A + MOV A,10H + MOV FIFO_OUT2,A + MOV A,02H + MOV FIFO_SendLen,A + ELSE + MOV A,10H + MOV FIFO_OUT1,A + MOV A,01H + MOV FIFO_SendLen,A + ENDIF + CALL WRITE_FIFO1 + nop + kmov Key_Process,Key_CheckIn + + jmp Key_Debounced_End + +Key_Debounced_Process_Stop: + ;----------------------------------------------------------- + ; Here to add your another code !! + ;----------------------------------------------------------- + clr wdt + CALL FIFO1_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP Key_Debounced_End + IF UseReportID + MOV A,01H ;REPORT ID + MOV FIFO_OUT1,A + MOV A,20H + MOV FIFO_OUT2,A + MOV A,02H + MOV FIFO_SendLen,A + ELSE + MOV A,20H + MOV FIFO_OUT1,A + MOV A,01H + MOV FIFO_SendLen,A + ENDIF + CALL WRITE_FIFO1 + nop + kmov Key_Process,Key_CheckIn + + jmp Key_Debounced_End + +Key_Debounced_Process_NextTrack: + ;----------------------------------------------------------- + ; Here to add your another code !! + ;----------------------------------------------------------- + clr wdt + CALL FIFO1_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP Key_Debounced_End + IF UseReportID + MOV A,01H ;REPORT ID + MOV FIFO_OUT1,A + MOV A,40H + MOV FIFO_OUT2,A + MOV A,02H + MOV FIFO_SendLen,A + ELSE + MOV A,40H + MOV FIFO_OUT1,A + MOV A,01H + MOV FIFO_SendLen,A + ENDIF + CALL WRITE_FIFO1 + nop + kmov Key_Process,Key_CheckIn + + jmp Key_Debounced_End + +Key_Debounced_Process_PreviousTrack: + ;----------------------------------------------------------- + ; Here to add your another code !! + ;----------------------------------------------------------- + clr wdt + CALL FIFO1_WR_CHECK + SNZ bFlag_FIFO_Ready + JMP Key_Debounced_End + IF UseReportID + MOV A,01H ;REPORT ID + MOV FIFO_OUT1,A + MOV A,80H + MOV FIFO_OUT2,A + MOV A,02H + MOV FIFO_SendLen,A + ELSE + MOV A,80H + MOV FIFO_OUT1,A + MOV A,01H + MOV FIFO_SendLen,A + ENDIF + CALL WRITE_FIFO1 + nop + kmov Key_Process,Key_CheckIn + + jmp Key_Debounced_End +ENDIF + + +wait_about_1s: + ;;;******************************************* + ;;;delay 1S 255*255*3*16*0.3333333=1.04S + ;;;******************************************* + clr wdt + clr Delay_1 + clr Delay_2 + kmov Delay_3,16 + wait_about_1s_loop: + clr wdt + sdz Delay_1 + jmp wait_about_1s_loop + sdz Delay_2 + jmp wait_about_1s_loop + sdz Delay_3 + jmp wait_about_1s_loop + clr wdt + nop + ret + + + +Public FIFO_Size +Public FIFO_SendLen + +Public FIFO_Type +Public FIFO_Request +Public FIFO_wValueL +Public FIFO_wValueH +Public FIFO_wIndexL +Public FIFO_wIndexH +Public FIFO_wLengthL +Public FIFO_wLengthH + +Public FIFO_Out1 +Public FIFO_Out2 +Public FIFO_Out3 +Public FIFO_Out4 +Public FIFO_Out5 +Public FIFO_Out6 +Public FIFO_Out7 +Public FIFO_Out8 + +Public USB_Interface +Public USB_Interface_Alt +Public USB_Configuration + +Public FIFO_ADDR + + + +Public nCmdIndex1 + + +Public Loop_Counter +Public Data_Count +Public Data_Start +Public FIFO_TEMP +Public bFlag_Real_Cmd +Public bFlag_FIFO_Ready +Public bFlag_FIFO_LEN0 +Public bFlag_RD_HTable +Public bFlag_wait_control_out +Public bFlag_SET_ADDRESS +Public bFlag_SCMD +Public bFlag_Enum_Ready +Public bFlag_SetConfiguration_Ready +Public bFlag_SetInterface_Ready + + +Public USB_ISR_END +Public USB_EP0_ISR_END +Public StageOne + + + +Public VolumeH_Save +Public VolumeL_Save +Public bFlag_Audio_Mute +;modify for Remote Wakeup +public bRmtWakeup +public b_wakeup + +;;----------------------------------------------- +#include QN8027Driver.asm +#include QN8072Sub.asm + +END diff --git a/PRG/memory.inc b/PRG/memory.inc new file mode 100644 index 0000000..bcbfe3f --- /dev/null +++ b/PRG/memory.inc @@ -0,0 +1,60 @@ +;;*********************************************** +;;QN8072 memory +;;*********************************************** +mQNReg db 5 dup (?) ;;QN8072 Reg0~4 + +mFMAddr db ? ;;QN8072 Reg addr +mFMData db ? ;;QN8072 Reg data +mFreqL db ? ;;QN8072 Freq +mFreqH db ? + +mFMACK db ? ;;IIC ACK get OK? +mFMSend db ? ;;IIC Send data +mFMCnt db ? ;;IIC Send count + +;;*********************************************** +;;Temp +;;*********************************************** +mMK0 db ? +mMK1 db ? + +;;*********************************************** +;;BIT +;;*********************************************** +bIniFMOK dbit ;;0-FM initial no. 1-FM initial OK + +;;*********************************************** +;;IO Define +;;*********************************************** +P_LEDC EQU [013H].3 +P_LED EQU PA.3 +P_SCLC EQU [013H].0 +P_SCL EQU PA.0 +P_SDAC EQU [013H].1 +P_SDA EQU PA.1 + +;;*********************************************** +;;User Define +;;*********************************************** +cFreqDefL EQU 18H +cFreqDefH EQU 01H ;;QN8072 define freq : 90.00MHz (Chanel = (Freq-76)/0.05) + +QN8072_I2C_WRITE_ADDR EQU 58H ;;QN8072 Write address +QN8072_I2C_READ_ADDR EQU 59H ;;QN8072 Read address + +;;*********************************************** +;;USB Translate Define +;;*********************************************** +cFMUSBType_Main EQU 50H ;;USB Data is main data +cFMUSBType_Set EQU 51H ;;USB Data is Set data + + @FMKeyOn EQU 0 ;;FM On + @FMKeyOff EQU 1 ;;FM Off + @FMKeyMute EQU 2 ;;FM Mute + @FMKeyNoMute EQU 3 ;;FM NoMute + @FMKeyTun EQU 4 ;;FM Tun(add/dec) + + @FMMono EQU 0 ;;FM Stereo(0)/mono(1) + @FMFreq EQU 1 ;;FM freq 87.5~108M(0)/76~90(1) + @FMDeemp EQU 2 ;;FM De-emphasis 50(0)/75(1) + diff --git a/keenectl.c b/keenectl.c new file mode 100644 index 0000000..13cdde3 --- /dev/null +++ b/keenectl.c @@ -0,0 +1,198 @@ +#include +#include +#include +#include + +#define LED_VENDOR_ID 0x046d +#define LED_PRODUCT_ID 0x0a0e + +static void send_data(struct usb_dev_handle *handle, char *data) +{ + int ret; + + ret = usb_control_msg(handle, + USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, // request type + 0x00000009, // request + 0x0200, // value + 0x02, // index + data, + 0x00000008, + 5000); + + if (ret == -1) { + fprintf(stderr, "Permission Denied\n"); + } else { + fprintf(stderr, "usb_control_msg returned %d\n", ret); + } +} + +static struct usb_device *device_init(void) +{ + struct usb_bus *usb_bus; + struct usb_device *dev; + + usb_init(); + usb_find_busses(); + usb_find_devices(); + + for (usb_bus = usb_busses; + usb_bus; + usb_bus = usb_bus->next) { + for (dev = usb_bus->devices; + dev; + dev = dev->next) { + if ((dev->descriptor.idVendor + == LED_VENDOR_ID) && + (dev->descriptor.idProduct + == LED_PRODUCT_ID)) + return dev; + } + } + return NULL; +} + +int main(int argc, char **argv) +{ + struct usb_device *usb_dev; + struct usb_dev_handle *usb_handle; + + usb_dev = device_init(); + if (usb_dev == NULL) { + fprintf(stderr, "Device not found\n"); + return 1; + } + + usb_handle = usb_open(usb_dev); + if (usb_handle == NULL) { + fprintf(stderr, + "Not able to claim the USB device\n"); + usb_close(usb_handle); + return 1; + } + + if (argc != 8) { + fprintf(stderr, + "incorrect number of arguments\n"); + usb_close(usb_handle); + return 1; + } + + enum settings { + PREEM_50 = 0x00, + PREEM_75 = 0x04, + STEREO = 0x00, + MONO = 0x01, + ENABLE = 0x01, + DISABLE = 0x2, + MUTE = 0x04, + UNMUTE = 0x08, + FREQ = 0x10 + }; + + char conf1[8] = "\x00\x50\x00\x00\x00\x00\x00\x00"; + char conf2[8] = "\x00\x51\x00\x00\x00\x00\x00\x00"; + + int ival, ret; + float fval; + + // get TX + if (!strcasecmp(argv[1], "-")) { + conf2[2] = '\x00'; + } else { + ret = sscanf(argv[1], "%d", &ival); + if (ret == 1) { + if (ival >= 0 && ival <= 23) { + conf2[2] = (ival%6)<<4 | (23-ival)/6; + } else { + fprintf(stderr, "TX must be from 0 to 23\n"); + return 1; + } + } else { + fprintf(stderr, "TX must be integer\n"); + return 1; + } + } + + // get preemphasis + if (!strcasecmp(argv[2], "-") || !strcasecmp(argv[2], "50us")) { + conf2[3] |= PREEM_50; + } else if (!strcasecmp(argv[2], "75us")) { + conf2[3] |= PREEM_75; + } else { + fprintf(stderr, "preemphasis must be either 50us or 75us\n"); + return 1; + } + + // get channels + if (!strcasecmp(argv[3], "-") || !strcasecmp(argv[3], "stereo")) { + conf2[3] |= STEREO; + } else if (!strcasecmp(argv[3], "mono")) { + conf2[3] |= MONO; + } else { + fprintf(stderr, "channels must be mono or stereo\n"); + return 1; + } + + // get frequency + if (!strcasecmp(argv[4], "-")) { + fval = 90.0f; + } else { + ret = sscanf(argv[4], "%f", &fval); + if (ret == 1) { + if (fval < 76.0f || fval > 108.0f) { + fprintf(stderr, "frequency must be from 76.0 to 108.0\n"); + return 1; + } + } else { + fprintf(stderr, "frequency must be float\n"); + return 1; + } + } + long int ifreq = lround(20.0f*(fval-76.0f)); + conf1[2] = (ifreq >> 8) & 0xff; + conf1[3] = ifreq & 0xff; + + // get PA + if (!strcasecmp(argv[5], "-")) { + conf1[4] = 120; + } else { + ret = sscanf(argv[5], "%d", &ival); + if (ret == 1) { + if (ival >= 30 && ival <= 120) { + conf1[4] = ival; + } else { + fprintf(stderr, "PA ust be from 30 to 120\n"); + return 1; + } + } else { + fprintf(stderr, "PA must be integer\n"); + return 1; + } + } + + // get enable + if (!strcasecmp(argv[6], "-") || !strcasecmp(argv[6], "enable")) { + conf1[5] |= ENABLE; + } else if (!strcasecmp(argv[6], "disable")) { + conf1[5] |= DISABLE; + } else { + fprintf(stderr, "must be enable or disable"); + return 1; + } + + // get mute + if (!strcasecmp(argv[7], "-") || !strcasecmp(argv[7], "unmute")) { + conf1[5] |= UNMUTE; + } else if (!strcasecmp(argv[7], "mute")) { + conf1[5] |= MUTE; + } else { + fprintf(stderr, "mute must be mute or unmute"); + return 1; + } + conf1[5] |= FREQ; + + send_data(usb_handle, conf1); + send_data(usb_handle, conf2); + + return 0; +} diff --git a/notes b/notes new file mode 100644 index 0000000..d490656 --- /dev/null +++ b/notes @@ -0,0 +1,75 @@ +add50: 00 50 01 1b 1e 19 00 34 +add100: 00 50 01 1d 1e 19 00 34 +add200: 00 50 01 21 1e 19 00 34 + +configclose: 00 51 03 20 00 00 00 44 +configclose: 00 51 02 00 00 00 00 44 + +disable: 00 50 01 18 1e 0a 00 05 +enable: 00 50 01 18 1e 09 00 00 + +mute: 00 50 01 19 1e 05 00 8c +unmute: 00 50 01 19 1e 09 00 8c + +PA30: 00 50 01 19 1e 09 73 d0 +PA48: 00 50 01 19 30 09 73 d0 +PA77: 00 50 01 19 4d 09 73 d0 +PA103: 00 50 01 19 67 09 73 d0 +PA120: 00 50 01 19 78 09 73 d0 + +TX0: 00 51 03 00 03 1e 00 1d +TX6: 00 51 02 00 03 1e 00 1d +TX15: 00 51 31 00 03 1e 00 1d +TX23: 00 51 50 00 03 1e 00 1d + +MAIN: + 0 1 2 3 4 5 6 7 + 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 ++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + 0x0 | 0x50 | freq | PA | f|u|m|d|e| 0x0 or 0x73 | enable, disable, freq, PA, (un)mute + +CONFIG: + 0 1 2 3 4 5 6 7 + 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 ++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + 0x0 | 0x51 | TX | |7| |m| | TX, close + + 0 1 2 3 4 5 6 7 + 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 ++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + 0 0 0 0 0 0 0 0|0 1 0 1 0 0 0 1|'00000011'(TX) | 7 m|0|PA30-PA120 |0 0 0 f U M O O| 0x73 when PA | config close: 0x44 + |0 1 0 1 0 0 0 0|'00010011' | 5 o|0|0x1e-0x78 | r N U F N| val is set | freq: 0x44, 0x34, 0xd4 + | |'00100011' | u n| | | e M T F | 0 otherwise | TX: 0x1d + | |'00110011' | s o| | q U E | | PA: 0xd0 + '01000011' | | | T | | (un)mute: 0x8c + '01010011' +-+-+ | | E | | enable: 0x00 + '00000010' |freq 0x0 - 0x280 | | | | disable: 0x05 + '00010010' | 76 - 108 | + '00100010' | | + '00110010' + '01000010' + '01010010' + '00000001' + '00010001' + '00100001' + '00110001' + '01000001' + '01010001' + '00000000' + '00010000' + '00100000' + '00110000' + '01000000' + '01010000' + +TX: +0x3, 0x13, 0x23, 0x33, 0x43, 0x53, 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x00, 0x10, 0x20, 0x30, 0x40, 0x50 +3, 19, 35, 51, 67, 83, 2, 18, 34, 50, 66, 82, 1, 17, 33, 49, 65, 81, 0, 16, 32, 48, 64, 80 +[(i%6)*16+(23-i)/6 for i in xrange(24)] +[(i%6)<<4 | (23-i)/6 for i in xrange(24)] + +freq: += lroundf(20.0f*(x-76.0f)) + +PA: +0x1e - 0x78