⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ups17b.asm

📁 USB大全电子版全部资料3~包含源码、协议等
💻 ASM
📖 第 1 页 / 共 5 页
字号:
	call get_two_bytes

;put_Main_ConfigFrequency_String:

	mov   A, Asc_F		; Load ASCII 'F' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_F		; Load ASCII 'F' into accumulator

	call get_two_bytes

;put_LowVoltageTransfer_String:

	mov   A, Asc_F		; Load ASCII 'F' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_L		; Load ASCII 'L' into accumulator

	call get_two_bytes

;put_HighVoltageTransfer_String:

	mov   A, Asc_F		; Load ASCII 'F' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_H		; Load ASCII 'H' into accumulator

	call get_two_bytes

	pop	X			;

	pop	A			;

	ret				;

;

;********************************************************************************

;		Report ID 2

;********************************************************************************

get_reportID2:

	push	A			;

	push	X			;

	mov A, 02h

	mov [send_ptr], A

	call initialize_req

;put_AC_ConfigVoltage_String:

	mov   A, Asc_F		; Load ASCII 'F' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_O		; Load ASCII 'O' into accumulator

	call get_two_bytes

;put_AC_ConfigFrequency_String:

	mov   A, Asc_F		; Load ASCII 'F' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_R		; Load ASCII 'R' into accumulator

	call get_two_bytes

;put_AC_ConfigApparentPower_String:

	mov   A, Asc_F		; Load ASCII 'F' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_A		; Load ASCII 'A' into accumulator

	call get_two_bytes

;put_AC_ConfigActivePower_String:

	mov   A, Asc_F		; Load ASCII 'F' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_P		; Load ASCII 'P' into accumulator

	call get_two_bytes

;put_AC_DelayBeforeStartup_String:

	mov   A, Asc_C		; Load ASCII 'C' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_U		; Load ASCII 'U' into accumulator

	call get_three_bytes

;put_AC_DelayBeforeShutdown_String:

	mov   A, Asc_C		; Load ASCII 'C' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_S		; Load ASCII 'S' into accumulator

	call get_three_bytes

;

	pop	X			;

	pop	A			;

	ret				;

;

;********************************************************************************

;		Report ID 3

;********************************************************************************

get_reportID3:

	push	A			;

	push	X			;

	mov A, 03h

	mov [send_ptr], A

	call initialize_req

;put_Battery_PresentStatus_String:

	mov   A, Asc_A		; Load ASCII 'A' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_G		; Load ASCII 'G' into accumulator

	call end_req

; Check if an error has occured during communication with the UPS

	mov A, [rxFrameFlag]

	cmp A, 01h

	jz bad_value31

; NO error in the UPS communication

	call unsupported_check	; check if the request unsupported

;	mov A, [temp2]

	cmp A, 01h

	jz bad_value31

; Request is supported and no errors occured

; No change to BCD needed

	mov A, [rxBuf]

	and A, 0fh

	asr A				; bit 0 = used, bit1 = bad

	mov [data_send + 2], A

	jmp next31

bad_value31:

	; fill sent back byte with ffh

	mov A, 0ffh

	mov [data_send + 2], A

next31:

	call initialize_req

;put_Battery_Voltage_String:

	mov   A, Asc_B		; Load ASCII 'B' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_V		; Load ASCII 'V' into accumulator

	call get_three_bytes

;put_Battery_Temperature_String:

	mov   A, Asc_B		; Load ASCII 'B' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_T		; Load ASCII 'T' into accumulator

	call get_two_bytes

;get_Battery_TestResults_String:

	mov   A, Asc_T		; Load ASCII 'T' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_R		; Load ASCII 'R' into accumulator

;	mov   A, Asc_D		; Load ASCII 'D' into accumulator

	call end_req

; Check if an error has occured during communication with the UPS

	mov A, [rxFrameFlag]

	cmp A, 01h

	jz bad_value34

; NO error in the UPS communication

	call unsupported_check	; check if the request unsupported

;	mov A, [temp2]

	cmp A, 01h

	jz bad_value34

; Request is supported and no errors occured

; No change to BCD needed

	mov A, [rxBuf]

	and A, 0fh	

	mov [data_send + 8], A

	jmp next34

bad_value34:

	; fill sent back byte with ffh

	mov A, 0ffh

	mov [data_send + 8], A

next34:



	pop	X			;

	pop	A			;

	ret				;

;

;***************************************************************************

set_reportID3:

put_Battery_TestStart_String:

	push	A			;

	push	X			;



	mov	A, 00h		;

	mov	[txBufPtr], A	;

	mov	X, [txBufPtr]	;

	mov   A, Asc_T		; Load ASCII 'T' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_s		; Load ASCII 's' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Car_Ret		; Load carriage return into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Ln_Fd		; Load line feed into accumulator

	mov   [X + txBuf], A	;

;

	call	putCommand		;

;

	call	delay;

;

	pop	X			;

	pop	A			;

	ret



;********************************************************************************

;		Report ID 4

;********************************************************************************

get_reportID4:

	push	A			;

	push	X			;

	mov A, 04h

	mov [send_ptr], A

	call initialize_req

;put_PowerConverter_PresentStatus_String:

	mov   A, Asc_A		; Load ASCII 'A' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_G		; Load ASCII 'G' into accumulator

	call end_req

; Check if an error has occured during communication with the UPS

	mov A, [rxFrameFlag]

	cmp A, 01h

	jz bad_value41

; NO error in the UPS communication

	call unsupported_check	; check if the request unsupported

;	mov A, [temp2]

	cmp A, 01h

	jz bad_value41

; Request is supported and no errors occured

; No conversion needed

	mov A, [rxBuf]

	and A, 02h

	asr A

;	asr A

;	asr A

;	asr A

;	asr A

	mov [data_send + 3], A

	jmp next41

bad_value41:

	; fill sent back byte with ffh

	mov A, 0ffh

	mov [data_send + 3], A

next41:

	call initialize_req

;put_PowerConverter_In_Voltage_String:

	mov   A, Asc_N		; Load ASCII 'N' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_V		; Load ASCII 'V' into accumulator

	call get_two_bytes

;put_PowerConverter_In_Frequency_String:

	mov   A, Asc_N		; Load ASCII 'N' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_F		; Load ASCII 'F' into accumulator

	call get_two_bytes

;

	pop	X			;

	pop	A			;

	ret				;

;



;********************************************************************************

;		Report ID 5

;********************************************************************************

get_reportID5:

	push	A			;

	push	X			;

	mov A, 02h

	mov [send_ptr], A

	call initialize_req

;put_PowerConverter_Out_Voltage_String:

	mov   A, Asc_O		; Load ASCII 'O' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_V		; Load ASCII 'V' into accumulator

	call get_two_bytes

;put_PowerConverter_Out_Frequency_String:

	mov   A, Asc_O		; Load ASCII 'O' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_F		; Load ASCII 'F' into accumulator

	call get_two_bytes

;put_PowerConverter_Out_Load_String:

	mov   A, Asc_O		; Load ASCII 'O' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_L		; Load ASCII 'L' into accumulator

	call get_two_bytes

;put_PowerConverter_Out_PresStat_String:

	mov   A, Asc_A		; Load ASCII 'A' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_G		; Load ASCII 'G' into accumulator

	call end_req

; Check if an error has occured during communication with the UPS

	mov A, [rxFrameFlag]

	cmp A, 01h

	jz bad_value54

; NO error in the UPS communication

	call unsupported_check	; check if the request unsupported

;	mov A, [temp2]

	cmp A, 01h

	jz bad_value54

; Request is supported and no errors occured

; No conversion needed

	mov A, [rxBuf]

	and A, 08h

	cmp A, 08h

	jnz no_overload

	mov A, 01h

	jmp save_value

no_overload:

	mov A, 00h

save_value:

	mov [data_send + 8], A

; Get boost and buck

	call initialize_req

	mov   A, Asc_O		; Load ASCII 'O' into accumulator

	mov   [X + txBuf], A	;

	inc   [txBufPtr]		; Increment tx buffer pointer

	mov	X, [txBufPtr]	;

	mov   A, Asc_S		; Load ASCII 'S' into accumulator

	call end_req

; Check if an error has occured during communication with the UPS

	mov A, [rxFrameFlag]

	cmp A, 01h

	jz bad_value54

; NO error in the UPS communication

	call unsupported_check	; check if the request unsupported

;	mov A, [temp2]

	cmp A, 01h

	jz bad_value54

; Request is supported and no errors occured

; No conversion needed

	mov A, [rxBuf]

	and A, 0fh

	cmp A, 06h

	jz set_boost

	cmp A, 07h

	jz set_buck

	jmp next54

set_boost:

	mov A, [data_send + 8]

	or A, 02h

	mov [data_send + 8], A

	jmp next54

set_buck:

	mov A, [data_send + 8]

	or A, 04h

	mov [data_send + 8], A

	jmp next54		

bad_value54:

	; fill sent back byte with ffh

	mov A, 0ffh

	mov [data_send + 8], A

next54:



	pop	X			;

	pop	A			;

	ret				;



;************************************************************************

; This is the routine that is entered when a data item from the UPS is 

; requested and returns with the string resident in the receive buffer.

;************************************************************************

;

putCommand:

	mov	A, 00h		; Clear the accumulator.

	mov   [txBufPtr], A	; Reset tx buffer pointer.

	iowr	Watchdog		; Clear watchdog timer.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -