Added calibration specific error codes
This commit is contained in:
@@ -13,6 +13,18 @@ LONG_MIN .equ TAPE_WORKSPACE + 004h ; byte
|
||||
LONG_MAX .equ TAPE_WORKSPACE + 005h ; byte
|
||||
BLOCK_BUFFER .equ TAPE_WORKSPACE + 006h ; BLOCK_SIZE
|
||||
|
||||
; -------------------------------------------------------
|
||||
; Error return callback macro
|
||||
; creates a simple macro which puts a return code in a
|
||||
; and sets the carry flag
|
||||
; -------------------------------------------------------
|
||||
create_error_return MACRO &name, &code
|
||||
&name:
|
||||
ld a,&code
|
||||
scf
|
||||
ret
|
||||
ENDM
|
||||
|
||||
; -------------------------------------------------------
|
||||
; Measure edge-to-edge pulse
|
||||
; needs d (comparator state)
|
||||
@@ -133,7 +145,7 @@ make_window:
|
||||
; Calibration
|
||||
; d needs to be kept from now on
|
||||
; uses a,b,c,e,h,l
|
||||
; carry is error
|
||||
; carry is error, a contains error code
|
||||
; -------------------------------------------------------
|
||||
calibrate:
|
||||
ld a,(TAPE_PORT) ; get current state
|
||||
@@ -155,7 +167,7 @@ calibrate:
|
||||
; edge found
|
||||
; get short leader timing
|
||||
call average8
|
||||
jr c,cal_err ; timeout
|
||||
jr c,cal_err_short_leader_average
|
||||
ld (SHORT_AVG),a
|
||||
call make_window
|
||||
ld a,b
|
||||
@@ -175,9 +187,9 @@ calibrate:
|
||||
; is ignored
|
||||
4$:
|
||||
call sample_pulse
|
||||
jr c,cal_err
|
||||
jr c,cal_err_wait_for_long
|
||||
call sample_pulse
|
||||
jr c,cal_err
|
||||
jr c,cal_err_wait_for_long
|
||||
ld a,b
|
||||
; try again if its a short pulse
|
||||
cp c
|
||||
@@ -187,7 +199,7 @@ calibrate:
|
||||
jr nz,4$ ; repeat this 4 times
|
||||
; long leader found
|
||||
call average8
|
||||
jr c,cal_err ; timeout
|
||||
jr c,cal_err_long_leader_average
|
||||
ld (LONG_AVG),a
|
||||
call make_window
|
||||
ld a,b
|
||||
@@ -202,7 +214,7 @@ calibrate:
|
||||
ld c,a ; c = 1.5*short
|
||||
ld a,(LONG_AVG)
|
||||
cp c
|
||||
jr c,cal_err
|
||||
jr c,cal_err_sanity_check
|
||||
; Find the marker. marker is 2*long
|
||||
; threshold is 1.5*long
|
||||
ld a,(LONG_AVG)
|
||||
@@ -215,7 +227,7 @@ calibrate:
|
||||
ld e,0
|
||||
6$:
|
||||
call measure_pulse
|
||||
jr c,cal_err ; timeout
|
||||
jr c,cal_err_marker_measure
|
||||
ld a,b
|
||||
cp c
|
||||
jr c,5$ ; not a marker
|
||||
@@ -227,15 +239,21 @@ calibrate:
|
||||
; we are at the beginning of the first data pulse
|
||||
; next 8 bytes is the training byte 0x55
|
||||
call read_byte
|
||||
jr c,cal_err
|
||||
jr c,cal_err_training_read
|
||||
cp a,055h
|
||||
jr nz,cal_err ; training byte not 0x55
|
||||
jr nz,cal_err_training_incorrect
|
||||
; calibration complete
|
||||
or a ; clear carry
|
||||
ret
|
||||
cal_err:
|
||||
scf
|
||||
ret
|
||||
|
||||
create_error_return cal_err, 000h
|
||||
create_error_return cal_err_short_leader_average, 001h
|
||||
create_error_return cal_err_wait_for_long, 002h
|
||||
create_error_return cal_err_long_leader_average, 003h
|
||||
create_error_return cal_err_sanity_check, 004h
|
||||
create_error_return cal_err_marker_measure, 005h
|
||||
create_error_return cal_err_training_read, 006h
|
||||
create_error_return cal_err_training_incorrect, 007h
|
||||
|
||||
; -------------------------------------------------------
|
||||
; Read a single bit
|
||||
@@ -351,7 +369,7 @@ read_sync:
|
||||
; Read a block into BLOCK_BUFFER
|
||||
; needs d (comparator state)
|
||||
; uses b,c,d,e,h,l
|
||||
; returns error code in a
|
||||
; returns error code in a, specific error code in b
|
||||
; returns start of block in hl
|
||||
; carry is fail
|
||||
; -------------------------------------------------------
|
||||
@@ -364,6 +382,7 @@ read_block:
|
||||
; calibrate reader
|
||||
call calibrate
|
||||
jr nc,1$ ; if no error jump
|
||||
ld b,a
|
||||
ld a,BLOCK_ERROR_CALIBRATION
|
||||
scf
|
||||
jr 101$
|
||||
|
||||
Reference in New Issue
Block a user