You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1727 lines
34 KiB
1727 lines
34 KiB
#CC-RL Compiler RL78 Assembler Source
|
|
#@ CC-RL Version : V1.15.00 [06 Dec 2024]
|
|
#@ Commmand :
|
|
#@ -cpu=S3
|
|
#@ -S
|
|
#@ -Olite
|
|
#@ -I .
|
|
#@ -asm_path=tmp
|
|
#@ r_main.c
|
|
#@ owi.c
|
|
#@ app_owi_service.c
|
|
#@ compiled at Tue Sep 15 15:24:24 2026
|
|
|
|
.PUBLIC _OWI_GetCaptureError
|
|
.PUBLIC _OWI_GetCaptureSync
|
|
.EXTERN _R_WDT_Restart
|
|
.PUBLIC _GPIO_Clear
|
|
.PUBLIC _GPIO_Input
|
|
.PUBLIC _GPIO_Read
|
|
.PUBLIC _OWI_HasTimeout
|
|
.PUBLIC _OWI_ClearTimeout
|
|
.PUBLIC _OWI_GetLastTimeoutByteIndex
|
|
.PUBLIC _OWI_GetLastTimeoutBitIndex
|
|
.PUBLIC _OWI_Init
|
|
.PUBLIC _OWI_Start
|
|
.EXTERN _delay_us
|
|
.PUBLIC _OWI_Stop
|
|
.EXTERN _R_TAU1_Channel5_Stop
|
|
.EXTERN _R_TAU1_Channel5_CaptureReset
|
|
.EXTERN _R_TAU1_Channel5_Start
|
|
.EXTERN _R_TAU1_Channel5_CaptureOverflowed
|
|
.EXTERN _R_TAU1_Channel5_GetLowWidthTicks
|
|
.PUBLIC _OWI_SecureStop
|
|
.PUBLIC _OWI_WriteBit
|
|
.PUBLIC _OWI_WriteByte
|
|
.PUBLIC _OWI_ReadBit
|
|
.PUBLIC _OWI_ReadByte
|
|
.EXTERN _memset
|
|
.PUBLIC _OWI_T_CommandModeRaw
|
|
.PUBLIC _OWI_CommandModeRaw
|
|
.PUBLIC _OWI_ReadBytesRaw
|
|
|
|
.SECTION .textf,TEXTF
|
|
.TYPE _OWI_GetCaptureError,function,.LFE1-_OWI_GetCaptureError
|
|
_OWI_GetCaptureError:
|
|
.STACK _OWI_GetCaptureError = 4
|
|
mov a, !LOWW(_g_capture_error@3)
|
|
ret
|
|
.LFE1:
|
|
.TYPE _OWI_GetCaptureSync,function,.LFE2-_OWI_GetCaptureSync
|
|
_OWI_GetCaptureSync:
|
|
.STACK _OWI_GetCaptureSync = 4
|
|
movw ax, !LOWW(_g_capture_sync@4)
|
|
ret
|
|
.LFE2:
|
|
.TYPE _OWI_KickWdt@1,function,.LFE3-_OWI_KickWdt@1
|
|
_OWI_KickWdt@1:
|
|
.STACK _OWI_KickWdt@1 = 4
|
|
call !!_R_WDT_Restart
|
|
ret
|
|
.LFE3:
|
|
.TYPE _GPIO_Clear,function,.LFE4-_GPIO_Clear
|
|
_GPIO_Clear:
|
|
.STACK _GPIO_Clear = 4
|
|
movw de, #0x0057
|
|
mov a, [de]
|
|
set1 a.0
|
|
mov [de], a
|
|
and 0xFFF07, #0xFE
|
|
mov a, #0xFE
|
|
and a, !0xFF27
|
|
mov 0xFFF27, a
|
|
ret
|
|
.LFE4:
|
|
.TYPE _GPIO_Input,function,.LFE5-_GPIO_Input
|
|
_GPIO_Input:
|
|
.STACK _GPIO_Input = 4
|
|
movw de, #0x0057
|
|
mov a, [de]
|
|
set1 a.0
|
|
mov [de], a
|
|
or 0xFFF07, #0x01
|
|
oneb a
|
|
or a, !0xFF27
|
|
mov 0xFFF27, a
|
|
ret
|
|
.LFE5:
|
|
.TYPE _GPIO_Read,function,.LFE6-_GPIO_Read
|
|
_GPIO_Read:
|
|
.STACK _GPIO_Read = 4
|
|
mov a, 0xFFF07
|
|
shrw ax, 8+0x00000
|
|
shlw ax, 0x0F
|
|
shrw ax, 0x0F
|
|
ret
|
|
.LFE6:
|
|
.TYPE _OWI_Release@1,function,.LFE7-_OWI_Release@1
|
|
_OWI_Release@1:
|
|
.STACK _OWI_Release@1 = 4
|
|
movw de, #0x0057
|
|
mov a, [de]
|
|
set1 a.0
|
|
mov [de], a
|
|
or 0xFFF07, #0x01
|
|
oneb a
|
|
or a, !0xFF27
|
|
mov 0xFFF27, a
|
|
ret
|
|
.LFE7:
|
|
.TYPE _OWI_DriveLow@1,function,.LFE8-_OWI_DriveLow@1
|
|
_OWI_DriveLow@1:
|
|
.STACK _OWI_DriveLow@1 = 4
|
|
movw de, #0x0057
|
|
mov a, [de]
|
|
set1 a.0
|
|
mov [de], a
|
|
and 0xFFF07, #0xFE
|
|
mov a, #0xFE
|
|
and a, !0xFF27
|
|
mov 0xFFF27, a
|
|
ret
|
|
.LFE8:
|
|
.TYPE _OWI_HasTimeout,function,.LFE9-_OWI_HasTimeout
|
|
_OWI_HasTimeout:
|
|
.STACK _OWI_HasTimeout = 4
|
|
mov a, !LOWW(_g_owi_timeout_latched@2)
|
|
ret
|
|
.LFE9:
|
|
.TYPE _OWI_ClearTimeout,function,.LFE10-_OWI_ClearTimeout
|
|
_OWI_ClearTimeout:
|
|
.STACK _OWI_ClearTimeout = 4
|
|
clrb !LOWW(_g_owi_timeout_latched@2)
|
|
clrb !LOWW(_g_capture_error@3)
|
|
clrw ax
|
|
movw !LOWW(_g_capture_sync@4), ax
|
|
movw ax, #0xFFFF
|
|
movw !LOWW(_g_owi_last_timeout_byte_index@9), ax
|
|
mov !LOWW(_g_owi_last_timeout_bit_index@10), #0xFF
|
|
ret
|
|
.LFE10:
|
|
.TYPE _OWI_GetLastTimeoutByteIndex,function,.LFE11-_OWI_GetLastTimeoutByteIndex
|
|
_OWI_GetLastTimeoutByteIndex:
|
|
.STACK _OWI_GetLastTimeoutByteIndex = 4
|
|
movw ax, !LOWW(_g_owi_last_timeout_byte_index@9)
|
|
ret
|
|
.LFE11:
|
|
.TYPE _OWI_GetLastTimeoutBitIndex,function,.LFE12-_OWI_GetLastTimeoutBitIndex
|
|
_OWI_GetLastTimeoutBitIndex:
|
|
.STACK _OWI_GetLastTimeoutBitIndex = 4
|
|
mov a, !LOWW(_g_owi_last_timeout_bit_index@10)
|
|
ret
|
|
.LFE12:
|
|
.TYPE _OWI_Init,function,.LFE13-_OWI_Init
|
|
_OWI_Init:
|
|
.STACK _OWI_Init = 4
|
|
movw !LOWW(_bit_period_us@1), ax
|
|
movw ax, bc
|
|
movw !LOWW(_bit_period_us@1+0x00002), ax
|
|
movw de, #0x0037
|
|
mov a, [de+0x30]
|
|
clr1 a.0
|
|
mov [de+0x30], a
|
|
mov a, [de+0x10]
|
|
clr1 a.0
|
|
mov [de+0x10], a
|
|
mov a, [de+0x20]
|
|
set1 a.0
|
|
mov [de+0x20], a
|
|
mov a, [de]
|
|
clr1 a.0
|
|
mov [de], a
|
|
call $!_OWI_ClearTimeout
|
|
call $!_GPIO_Input
|
|
call $!_OWI_KickWdt@1
|
|
ret
|
|
.LFE13:
|
|
.TYPE _OWI_Start,function,.LFE14-_OWI_Start
|
|
_OWI_Start:
|
|
.STACK _OWI_Start = 4
|
|
call $!_GPIO_Clear
|
|
clrw bc
|
|
movw ax, #0x0032
|
|
call !!_delay_us
|
|
call $!_GPIO_Input
|
|
clrw bc
|
|
movw ax, #0x04B0
|
|
call !!_delay_us
|
|
ret
|
|
.LFE14:
|
|
.TYPE _OWI_Stop,function,.LFE15-_OWI_Stop
|
|
_OWI_Stop:
|
|
.STACK _OWI_Stop = 4
|
|
call $!_GPIO_Input
|
|
clrw bc
|
|
movw ax, #0x0960
|
|
call !!_delay_us
|
|
clrw bc
|
|
movw ax, #0x0E10
|
|
call !!_delay_us
|
|
ret
|
|
.LFE15:
|
|
.TYPE _OWI_StopRead@1,function,.LFE16-_OWI_StopRead@1
|
|
_OWI_StopRead@1:
|
|
.STACK _OWI_StopRead@1 = 4
|
|
call $!_OWI_DriveLow@1
|
|
clrw bc
|
|
movw ax, #0x0960
|
|
call !!_delay_us
|
|
call $!_OWI_Release@1
|
|
clrw bc
|
|
movw ax, #0x0E10
|
|
call !!_delay_us
|
|
ret
|
|
.LFE16:
|
|
.TYPE _OWI_WaitForFallingEdge@1,function,.LFE17-_OWI_WaitForFallingEdge@1
|
|
_OWI_WaitForFallingEdge@1:
|
|
.STACK _OWI_WaitForFallingEdge@1 = 10
|
|
push bc
|
|
push ax
|
|
push hl
|
|
movw ax, !LOWW(_bit_period_us@1)
|
|
shlw ax, 0x02
|
|
movw [sp+0x00], ax
|
|
br $.BB@LABEL@17_2
|
|
.BB@LABEL@17_1: ; bb
|
|
clrw bc
|
|
onew ax
|
|
call !!_delay_us
|
|
.BB@LABEL@17_2: ; bb4
|
|
call $!_GPIO_Read
|
|
or a, x
|
|
bz $.BB@LABEL@17_5
|
|
.BB@LABEL@17_3: ; bb8
|
|
movw ax, [sp+0x00]
|
|
movw bc, ax
|
|
addw ax, ax
|
|
decw bc
|
|
pop ax
|
|
push bc
|
|
bnh $.BB@LABEL@17_5
|
|
.BB@LABEL@17_4: ; bb8.bb16_crit_edge
|
|
clrb a
|
|
br $.BB@LABEL@17_6
|
|
.BB@LABEL@17_5: ; bb15
|
|
oneb a
|
|
.BB@LABEL@17_6: ; bb16
|
|
bf a.0, $.BB@LABEL@17_1
|
|
.BB@LABEL@17_7: ; bb20
|
|
movw ax, [sp+0x00]
|
|
addw ax, ax
|
|
bnh $.BB@LABEL@17_10
|
|
.BB@LABEL@17_8: ; bb20.bb43_crit_edge
|
|
oneb a
|
|
.BB@LABEL@17_9: ; bb43
|
|
addw sp, #0x06
|
|
ret
|
|
.BB@LABEL@17_10: ; if_then_bb
|
|
cmp0 !LOWW(_g_owi_timeout_latched@2)
|
|
bz $.BB@LABEL@17_12
|
|
.BB@LABEL@17_11: ; if_then_bb.bb43_crit_edge
|
|
clrb a
|
|
br $.BB@LABEL@17_9
|
|
.BB@LABEL@17_12: ; if_then_bb37
|
|
oneb !LOWW(_g_owi_timeout_latched@2)
|
|
movw ax, [sp+0x02]
|
|
movw !LOWW(_g_owi_last_timeout_byte_index@9), ax
|
|
mov a, [sp+0x04]
|
|
mov !LOWW(_g_owi_last_timeout_bit_index@10), a
|
|
br $.BB@LABEL@17_11
|
|
.LFE17:
|
|
.TYPE _OWI_ReadByte_StreamSynced@1,function,.LFE18-_OWI_ReadByte_StreamSynced@1
|
|
_OWI_ReadByte_StreamSynced@1:
|
|
.STACK _OWI_ReadByte_StreamSynced@1 = 12
|
|
push ax
|
|
subw sp, #0x06
|
|
clrb b
|
|
movw ax, #0x0007
|
|
br $.BB@LABEL@18_8
|
|
.BB@LABEL@18_1: ; bb
|
|
movw ax, [sp+0x06]
|
|
movw !LOWW(_g_owi_current_read_byte_index@11), ax
|
|
movw ax, [sp+0x04]
|
|
mov a, #0x07
|
|
sub a, x
|
|
mov !LOWW(_g_owi_current_read_bit_index@12), a
|
|
movw ax, !LOWW(_bit_period_us@1+0x00002)
|
|
movw bc, ax
|
|
shlw ax, 0x0F
|
|
movw de, ax
|
|
movw ax, bc
|
|
shrw ax, 0x01
|
|
movw bc, ax
|
|
movw ax, !LOWW(_bit_period_us@1)
|
|
shrw ax, 0x01
|
|
addw ax, de
|
|
call !!_delay_us
|
|
call $!_GPIO_Read
|
|
or a, x
|
|
bz $.BB@LABEL@18_3
|
|
.BB@LABEL@18_2: ; bb.bb12_crit_edge
|
|
onew ax
|
|
br $.BB@LABEL@18_4
|
|
.BB@LABEL@18_3: ; bb11
|
|
clrw ax
|
|
.BB@LABEL@18_4: ; bb11
|
|
movw [sp+0x00], ax
|
|
movw ax, !LOWW(_bit_period_us@1+0x00002)
|
|
movw bc, ax
|
|
shlw ax, 0x0F
|
|
movw de, ax
|
|
movw ax, bc
|
|
shrw ax, 0x01
|
|
movw bc, ax
|
|
movw ax, !LOWW(_bit_period_us@1)
|
|
shrw ax, 0x01
|
|
addw ax, de
|
|
call !!_delay_us
|
|
movw ax, [sp+0x04]
|
|
movw de, ax
|
|
movw hl, sp
|
|
mov a, e
|
|
mov b, a
|
|
movw ax, [hl]
|
|
cmp0 b
|
|
br $.BB@LABEL@18_6
|
|
.BB@LABEL@18_5: ; bb12
|
|
addw ax, ax
|
|
dec b
|
|
.BB@LABEL@18_6: ; bb12
|
|
bnz $.BB@LABEL@18_5
|
|
.BB@LABEL@18_7: ; bb12
|
|
mov a, x
|
|
or a, [hl+0x02]
|
|
mov b, a
|
|
decw de
|
|
movw ax, de
|
|
.BB@LABEL@18_8: ; bb12
|
|
movw [sp+0x04], ax
|
|
mov a, b
|
|
mov [sp+0x02], a
|
|
movw ax, [sp+0x04]
|
|
bf a.7, $.BB@LABEL@18_1
|
|
.BB@LABEL@18_9: ; bb36
|
|
mov a, [sp+0x02]
|
|
addw sp, #0x08
|
|
ret
|
|
.LFE18:
|
|
.TYPE _OWI_CapturePrepare@1,function,.LFE19-_OWI_CapturePrepare@1
|
|
_OWI_CapturePrepare@1:
|
|
.STACK _OWI_CapturePrepare@1 = 4
|
|
call !!_R_TAU1_Channel5_Stop
|
|
movw de, #0x0072
|
|
mov a, [de]
|
|
set1 a.5
|
|
mov [de], a
|
|
clr1 0xFFFDE.5
|
|
clr1 0xFFFDA.5
|
|
call $!_GPIO_Input
|
|
ret
|
|
.LFE19:
|
|
.TYPE _OWI_CaptureBegin@1,function,.LFE20-_OWI_CaptureBegin@1
|
|
_OWI_CaptureBegin@1:
|
|
.STACK _OWI_CaptureBegin@1 = 4
|
|
clrw ax
|
|
movw !LOWW(_g_owi_capture_threshold_ticks@5+0x00002), ax
|
|
movw !LOWW(_g_owi_capture_threshold_ticks@5), ax
|
|
clrb !LOWW(_g_owi_capture_pending_index@7)
|
|
clrb !LOWW(_g_owi_capture_pending_count@8)
|
|
call !!_R_TAU1_Channel5_CaptureReset
|
|
call !!_R_TAU1_Channel5_Start
|
|
ret
|
|
.LFE20:
|
|
.TYPE _OWI_WriteCapturedReadAddress@1,function,.LFE21-_OWI_WriteCapturedReadAddress@1
|
|
_OWI_WriteCapturedReadAddress@1:
|
|
.STACK _OWI_WriteCapturedReadAddress@1 = 10
|
|
push ax
|
|
subw sp, #0x04
|
|
shrw ax, 8+0x00000
|
|
shrw ax, 0x01
|
|
bnc $.BB@LABEL@21_2
|
|
.BB@LABEL@21_1: ; entry.bb6_crit_edge
|
|
movw ax, #0x012C
|
|
br $.BB@LABEL@21_3
|
|
.BB@LABEL@21_2: ; bb5
|
|
movw ax, #0x0384
|
|
.BB@LABEL@21_3: ; bb5
|
|
movw [sp+0x02], ax
|
|
movw ax, #0x0007
|
|
br $.BB@LABEL@21_8
|
|
.BB@LABEL@21_4: ; bb8
|
|
mov a, [sp+0x00]
|
|
mov b, a
|
|
mov a, [sp+0x05]
|
|
shrw ax, 8+0x00000
|
|
cmp0 b
|
|
br $.BB@LABEL@21_6
|
|
.BB@LABEL@21_5: ; bb8
|
|
shrw ax, 0x01
|
|
dec b
|
|
.BB@LABEL@21_6: ; bb8
|
|
bnz $.BB@LABEL@21_5
|
|
.BB@LABEL@21_7: ; bb8
|
|
shlw ax, 0x0F
|
|
shrw ax, 0x0F
|
|
call $!_OWI_WriteBit
|
|
movw ax, [sp+0x00]
|
|
decw ax
|
|
.BB@LABEL@21_8: ; bb8
|
|
movw [sp+0x00], ax
|
|
addw ax, ax
|
|
bh $.BB@LABEL@21_4
|
|
.BB@LABEL@21_9: ; bb23
|
|
call $!_OWI_Release@1
|
|
movw hl, sp
|
|
movw ax, #0x04B0
|
|
subw ax, [hl+0x02]
|
|
movw de, ax
|
|
clrw ax
|
|
clrw bc
|
|
sknc
|
|
.BB@LABEL@21_10: ; bb23
|
|
decw ax
|
|
.BB@LABEL@21_11: ; bb23
|
|
subw ax, bc
|
|
movw bc, ax
|
|
movw ax, de
|
|
call !!_delay_us
|
|
call $!_OWI_DriveLow@1
|
|
clrw bc
|
|
movw ax, [sp+0x02]
|
|
call !!_delay_us
|
|
call $!_OWI_CaptureBegin@1
|
|
call $!_OWI_Release@1
|
|
addw sp, #0x06
|
|
ret
|
|
.LFE21:
|
|
.TYPE _OWI_CaptureEnd@1,function,.LFE22-_OWI_CaptureEnd@1
|
|
_OWI_CaptureEnd@1:
|
|
.STACK _OWI_CaptureEnd@1 = 4
|
|
call !!_R_TAU1_Channel5_Stop
|
|
call $!_GPIO_Input
|
|
ret
|
|
.LFE22:
|
|
.TYPE _OWI_CaptureWaitLowWidth@1,function,.LFE23-_OWI_CaptureWaitLowWidth@1
|
|
_OWI_CaptureWaitLowWidth@1:
|
|
.STACK _OWI_CaptureWaitLowWidth@1 = 16
|
|
push de
|
|
push bc
|
|
push ax
|
|
subw sp, #0x04
|
|
movw ax, !LOWW(_bit_period_us@1)
|
|
movw de, ax
|
|
shrw ax, 0x0E
|
|
movw bc, ax
|
|
movw ax, !LOWW(_bit_period_us@1+0x00002)
|
|
shlw ax, 0x02
|
|
addw ax, bc
|
|
movw [sp+0x00], ax
|
|
movw ax, de
|
|
shlw ax, 0x02
|
|
movw [sp+0x02], ax
|
|
br $.BB@LABEL@23_5
|
|
.BB@LABEL@23_1: ; bb
|
|
call !!_R_TAU1_Channel5_CaptureOverflowed
|
|
cmp0 a
|
|
bnz $.BB@LABEL@23_9
|
|
.BB@LABEL@23_2: ; if_break_bb
|
|
movw ax, [sp+0x08]
|
|
call !!_R_TAU1_Channel5_GetLowWidthTicks
|
|
cmp0 a
|
|
bnz $.BB@LABEL@23_15
|
|
.BB@LABEL@23_3: ; if_break_bb16
|
|
call !!_R_TAU1_Channel5_CaptureOverflowed
|
|
cmp0 a
|
|
bnz $.BB@LABEL@23_9
|
|
.BB@LABEL@23_4: ; if_break_bb24
|
|
clrw bc
|
|
onew ax
|
|
call !!_delay_us
|
|
.BB@LABEL@23_5: ; bb25
|
|
pop de
|
|
push de
|
|
push de
|
|
pop bc
|
|
movw ax, [sp+0x02]
|
|
movw hl, ax
|
|
addw ax, #0xFFFF
|
|
movw [sp+0x02], ax
|
|
skc
|
|
.BB@LABEL@23_6: ; bb25
|
|
decw de
|
|
.BB@LABEL@23_7: ; bb25
|
|
pop ax
|
|
push de
|
|
movw ax, hl
|
|
addw ax, bc
|
|
bnz $.BB@LABEL@23_1
|
|
.BB@LABEL@23_8: ; bb25
|
|
bc $.BB@LABEL@23_1
|
|
.BB@LABEL@23_9: ; bb33
|
|
cmp0 !LOWW(_g_owi_timeout_latched@2)
|
|
bz $.BB@LABEL@23_11
|
|
.BB@LABEL@23_10: ; bb33.bb61_crit_edge
|
|
clrb a
|
|
br $.BB@LABEL@23_16
|
|
.BB@LABEL@23_11: ; if_then_bb45
|
|
call !!_R_TAU1_Channel5_CaptureOverflowed
|
|
cmp0 a
|
|
bz $.BB@LABEL@23_13
|
|
.BB@LABEL@23_12: ; if_then_bb45.bb53_crit_edge
|
|
mov a, #0x02
|
|
br $.BB@LABEL@23_14
|
|
.BB@LABEL@23_13: ; bb51
|
|
oneb a
|
|
.BB@LABEL@23_14: ; bb53
|
|
mov !LOWW(_g_capture_error@3), a
|
|
oneb !LOWW(_g_owi_timeout_latched@2)
|
|
movw ax, [sp+0x04]
|
|
movw !LOWW(_g_owi_last_timeout_byte_index@9), ax
|
|
mov a, [sp+0x06]
|
|
mov !LOWW(_g_owi_last_timeout_bit_index@10), a
|
|
br $.BB@LABEL@23_10
|
|
.BB@LABEL@23_15: ; if_break_bb.bb61_crit_edge
|
|
oneb a
|
|
.BB@LABEL@23_16: ; bb61
|
|
addw sp, #0x0A
|
|
ret
|
|
.LFE23:
|
|
.TYPE _OWI_CaptureFindThreshold@1,function,.LFE24-_OWI_CaptureFindThreshold@1
|
|
_OWI_CaptureFindThreshold@1:
|
|
.STACK _OWI_CaptureFindThreshold@1 = 82
|
|
push bc
|
|
push ax
|
|
subw sp, #0x48
|
|
movw ax, !LOWW(_bit_period_us@1)
|
|
movw de, ax
|
|
shrw ax, 0x0B
|
|
movw bc, ax
|
|
movw ax, !LOWW(_bit_period_us@1+0x00002)
|
|
shlw ax, 0x05
|
|
addw ax, bc
|
|
movw hl, ax
|
|
shlw ax, 0x0F
|
|
movw bc, ax
|
|
movw ax, de
|
|
shlw ax, 0x05
|
|
shrw ax, 0x01
|
|
addw ax, bc
|
|
movw [sp+0x06], ax
|
|
movw ax, hl
|
|
shrw ax, 0x01
|
|
movw [sp+0x04], ax
|
|
clrb a
|
|
br $.BB@LABEL@24_2
|
|
.BB@LABEL@24_1: ; bb
|
|
mov x, #0x04
|
|
mulu x
|
|
movw bc, ax
|
|
addw ax, hl
|
|
addw ax, #0x0008
|
|
movw de, ax
|
|
movw ax, bc
|
|
addw ax, [hl+0x48]
|
|
movw hl, ax
|
|
movw ax, [hl+0x02]
|
|
movw [de+0x02], ax
|
|
movw ax, [hl]
|
|
movw [de], ax
|
|
mov a, [sp+0x00]
|
|
inc a
|
|
.BB@LABEL@24_2: ; bb
|
|
mov [sp+0x00], a
|
|
movw hl, sp
|
|
cmp a, [hl+0x4A]
|
|
bc $.BB@LABEL@24_1
|
|
.BB@LABEL@24_3: ; bb14.bb74_crit_edge
|
|
clrb a
|
|
mov [sp+0x4B], a
|
|
br $.BB@LABEL@24_10
|
|
.BB@LABEL@24_4: ; bb27
|
|
mov a, [sp+0x4B]
|
|
mov x, #0x04
|
|
mulu x
|
|
movw bc, ax
|
|
movw ax, hl
|
|
addw ax, #0x0008
|
|
movw [hl], ax
|
|
addw ax, bc
|
|
movw hl, ax
|
|
mov a, [sp+0x48]
|
|
mov b, a
|
|
mov x, #0x04
|
|
mulu x
|
|
movw de, ax
|
|
movw ax, [sp+0x00]
|
|
addw ax, de
|
|
movw de, ax
|
|
movw ax, [de+0x02]
|
|
cmpw ax, [hl+0x02]
|
|
movw ax, [de]
|
|
sknz
|
|
.BB@LABEL@24_5: ; bb27
|
|
cmpw ax, [hl+0x00]
|
|
.BB@LABEL@24_6: ; bb27
|
|
bnc $.BB@LABEL@24_8
|
|
.BB@LABEL@24_7: ; if_then_bb
|
|
movw ax, [de]
|
|
movw [sp+0x02], ax
|
|
movw ax, [hl+0x02]
|
|
movw [sp+0x48], ax
|
|
movw ax, [hl]
|
|
movw [sp+0x00], ax
|
|
movw ax, [de+0x02]
|
|
movw [hl+0x02], ax
|
|
movw ax, [sp+0x02]
|
|
movw [hl], ax
|
|
movw ax, [sp+0x48]
|
|
movw [de+0x02], ax
|
|
movw ax, [sp+0x00]
|
|
movw [de], ax
|
|
.BB@LABEL@24_8: ; bb63
|
|
movw hl, sp
|
|
inc b
|
|
mov a, b
|
|
mov [sp+0x48], a
|
|
mov a, [sp+0x4A]
|
|
cmp b, a
|
|
bc $.BB@LABEL@24_4
|
|
.BB@LABEL@24_9: ; bb71
|
|
inc [hl+0x4B]
|
|
.BB@LABEL@24_10: ; bb74
|
|
mov a, [sp+0x4A]
|
|
dec a
|
|
mov x, a
|
|
mov a, [sp+0x4B]
|
|
cmp a, x
|
|
bc $.BB@LABEL@24_12
|
|
.BB@LABEL@24_11: ; bb74.bb118_crit_edge
|
|
clrw bc
|
|
clrb a
|
|
mov [sp+0x4B], a
|
|
push bc
|
|
pop de
|
|
br $.BB@LABEL@24_22
|
|
.BB@LABEL@24_12: ; bb74.bb63_crit_edge
|
|
mov b, a
|
|
br $.BB@LABEL@24_8
|
|
.BB@LABEL@24_13: ; bb86
|
|
mov x, #0x04
|
|
mulu x
|
|
movw hl, ax
|
|
movw ax, sp
|
|
addw ax, #0x0008
|
|
addw ax, hl
|
|
movw hl, ax
|
|
movw ax, [hl+0x04]
|
|
subw ax, [hl+0x00]
|
|
movw [sp+0x48], ax
|
|
movw ax, [hl+0x06]
|
|
sknc
|
|
.BB@LABEL@24_14: ; bb86
|
|
decw ax
|
|
.BB@LABEL@24_15: ; bb86
|
|
subw ax, [hl+0x02]
|
|
movw [sp+0x02], ax
|
|
cmpw ax, de
|
|
movw ax, [sp+0x48]
|
|
sknz
|
|
.BB@LABEL@24_16: ; bb86
|
|
cmpw ax, bc
|
|
.BB@LABEL@24_17: ; bb86
|
|
bnh $.BB@LABEL@24_21
|
|
.BB@LABEL@24_18: ; if_then_bb105
|
|
movw ax, [sp+0x02]
|
|
shlw ax, 0x0F
|
|
movw de, ax
|
|
movw ax, [sp+0x02]
|
|
shrw ax, 0x01
|
|
movw [sp+0x00], ax
|
|
movw ax, [sp+0x48]
|
|
movw bc, ax
|
|
shrw ax, 0x01
|
|
addw ax, de
|
|
addw ax, [hl+0x00]
|
|
movw [sp+0x06], ax
|
|
movw ax, [sp+0x00]
|
|
sknc
|
|
.BB@LABEL@24_19: ; if_then_bb105
|
|
incw ax
|
|
.BB@LABEL@24_20: ; if_then_bb105
|
|
addw ax, [hl+0x02]
|
|
movw [sp+0x04], ax
|
|
movw ax, [sp+0x02]
|
|
movw de, ax
|
|
.BB@LABEL@24_21: ; if_break_bb115
|
|
movw hl, sp
|
|
inc [hl+0x4B]
|
|
.BB@LABEL@24_22: ; bb118
|
|
mov a, [sp+0x4A]
|
|
dec a
|
|
mov x, a
|
|
mov a, [sp+0x4B]
|
|
cmp a, x
|
|
bc $.BB@LABEL@24_13
|
|
.BB@LABEL@24_23: ; bb129
|
|
movw ax, [sp+0x04]
|
|
movw bc, ax
|
|
movw ax, [sp+0x06]
|
|
addw sp, #0x4C
|
|
ret
|
|
.LFE24:
|
|
.TYPE _OWI_CaptureExpectedHeaderBit@1,function,.LFE25-_OWI_CaptureExpectedHeaderBit@1
|
|
_OWI_CaptureExpectedHeaderBit@1:
|
|
.STACK _OWI_CaptureExpectedHeaderBit@1 = 4
|
|
mov x, #0x07
|
|
sub x, a
|
|
mov a, x
|
|
mov b, a
|
|
movw ax, #0x0026
|
|
cmp0 b
|
|
br $.BB@LABEL@25_2
|
|
.BB@LABEL@25_1: ; entry
|
|
shrw ax, 0x01
|
|
dec b
|
|
.BB@LABEL@25_2: ; entry
|
|
bnz $.BB@LABEL@25_1
|
|
.BB@LABEL@25_3: ; entry
|
|
mov a, x
|
|
and a, #0x01
|
|
ret
|
|
.LFE25:
|
|
.TYPE _OWI_CaptureFindHeaderEnd@1,function,.LFE26-_OWI_CaptureFindHeaderEnd@1
|
|
_OWI_CaptureFindHeaderEnd@1:
|
|
.STACK _OWI_CaptureFindHeaderEnd@1 = 10
|
|
push de
|
|
push ax
|
|
push hl
|
|
movw ax, [sp+0x04]
|
|
or a, x
|
|
bz $.BB@LABEL@26_7
|
|
.BB@LABEL@26_1: ; entry
|
|
mov a, c
|
|
cmp a, #0x08
|
|
bc $.BB@LABEL@26_7
|
|
.BB@LABEL@26_2: ; entry.bb39_crit_edge
|
|
clrb a
|
|
br $.BB@LABEL@26_5
|
|
.BB@LABEL@26_3: ; bb21
|
|
movw ax, [sp+0x02]
|
|
movw hl, ax
|
|
pop bc
|
|
push bc
|
|
mov a, [hl+b]
|
|
mov [sp+0x00], a
|
|
mov a, b
|
|
call $!_OWI_CaptureExpectedHeaderBit@1
|
|
movw hl, sp
|
|
cmp a, [hl]
|
|
bnz $.BB@LABEL@26_7
|
|
.BB@LABEL@26_4: ; if_break_bb36
|
|
mov a, [sp+0x01]
|
|
inc a
|
|
.BB@LABEL@26_5: ; if_break_bb36
|
|
mov [sp+0x01], a
|
|
cmp a, #0x08
|
|
bc $.BB@LABEL@26_3
|
|
.BB@LABEL@26_6: ; bb45
|
|
movw ax, [sp+0x04]
|
|
movw de, ax
|
|
mov [de+0x00], #0x08
|
|
oneb a
|
|
br $.BB@LABEL@26_8
|
|
.BB@LABEL@26_7: ; bb48
|
|
clrb a
|
|
.BB@LABEL@26_8: ; bb48
|
|
addw sp, #0x06
|
|
ret
|
|
.LFE26:
|
|
.TYPE _OWI_CaptureGetDecodedBit@1,function,.LFE27-_OWI_CaptureGetDecodedBit@1
|
|
_OWI_CaptureGetDecodedBit@1:
|
|
.STACK _OWI_CaptureGetDecodedBit@1 = 10
|
|
subw sp, #0x04
|
|
push de
|
|
movw hl, ax
|
|
movw ax, [sp+0x00]
|
|
or a, x
|
|
bz $.BB@LABEL@27_12
|
|
.BB@LABEL@27_1: ; if_break_bb
|
|
mov a, !LOWW(_g_owi_capture_pending_index@7)
|
|
mov b, a
|
|
cmp a, !LOWW(_g_owi_capture_pending_count@8)
|
|
bnc $.BB@LABEL@27_3
|
|
.BB@LABEL@27_2: ; if_then_bb11
|
|
pop de
|
|
push de
|
|
mov a, LOWW(_g_owi_capture_pending_bits@6)[b]
|
|
mov [de], a
|
|
inc !LOWW(_g_owi_capture_pending_index@7)
|
|
br $.BB@LABEL@27_10
|
|
.BB@LABEL@27_3: ; if_break_bb20
|
|
movw ax, sp
|
|
addw ax, #0x0002
|
|
movw de, ax
|
|
movw ax, hl
|
|
call $!_OWI_CaptureWaitLowWidth@1
|
|
cmp0 a
|
|
bz $.BB@LABEL@27_12
|
|
.BB@LABEL@27_4: ; if_break_bb35
|
|
movw ax, [sp+0x04]
|
|
cmpw ax, !LOWW(_g_owi_capture_threshold_ticks@5+0x00002)
|
|
movw ax, [sp+0x02]
|
|
sknz
|
|
.BB@LABEL@27_5: ; if_break_bb35
|
|
cmpw ax, !LOWW(_g_owi_capture_threshold_ticks@5)
|
|
.BB@LABEL@27_6: ; if_break_bb35
|
|
bnc $.BB@LABEL@27_8
|
|
.BB@LABEL@27_7: ; if_break_bb35.bb44_crit_edge
|
|
oneb b
|
|
br $.BB@LABEL@27_9
|
|
.BB@LABEL@27_8: ; bb42
|
|
clrb b
|
|
.BB@LABEL@27_9: ; bb44
|
|
pop de
|
|
push de
|
|
mov a, b
|
|
mov [de], a
|
|
.BB@LABEL@27_10: ; bb44
|
|
oneb a
|
|
.BB@LABEL@27_11: ; bb44
|
|
addw sp, #0x06
|
|
ret
|
|
.BB@LABEL@27_12: ; bb49
|
|
clrb a
|
|
br $.BB@LABEL@27_11
|
|
.LFE27:
|
|
.TYPE _OWI_ReadByte_Captured@1,function,.LFE28-_OWI_ReadByte_Captured@1
|
|
_OWI_ReadByte_Captured@1:
|
|
.STACK _OWI_ReadByte_Captured@1 = 92
|
|
push ax
|
|
subw sp, #0x56
|
|
or a, x
|
|
clrb a
|
|
bz $.BB@LABEL@28_4
|
|
.BB@LABEL@28_1: ; entry.bb181_crit_edge
|
|
mov [sp+0x00], a
|
|
movw ax, #0x0007
|
|
br $!.BB@LABEL@28_30
|
|
.BB@LABEL@28_2: ; bb
|
|
clrw ax
|
|
movw !LOWW(_g_owi_current_read_byte_index@11), ax
|
|
mov a, [sp+0x00]
|
|
mov !LOWW(_g_owi_current_read_bit_index@12), a
|
|
mov a, [sp+0x00]
|
|
mov c, a
|
|
mov x, #0x04
|
|
mulu x
|
|
movw de, ax
|
|
movw ax, sp
|
|
addw ax, #0x0016
|
|
addw ax, de
|
|
movw de, ax
|
|
clrw ax
|
|
call $!_OWI_CaptureWaitLowWidth@1
|
|
cmp0 a
|
|
.bz $!.BB@LABEL@28_31
|
|
.BB@LABEL@28_3: ; if_break_bb
|
|
mov a, [sp+0x00]
|
|
inc a
|
|
.BB@LABEL@28_4: ; if_break_bb
|
|
mov [sp+0x00], a
|
|
cmp a, #0x10
|
|
bc $.BB@LABEL@28_2
|
|
.BB@LABEL@28_5: ; bb30
|
|
mov c, #0x10
|
|
movw ax, sp
|
|
addw ax, #0x0016
|
|
call $!_OWI_CaptureFindThreshold@1
|
|
movw !LOWW(_g_owi_capture_threshold_ticks@5), ax
|
|
movw ax, bc
|
|
movw !LOWW(_g_owi_capture_threshold_ticks@5+0x00002), ax
|
|
clrb a
|
|
br $.BB@LABEL@28_12
|
|
.BB@LABEL@28_6: ; bb33
|
|
mov x, #0x04
|
|
mulu x
|
|
movw bc, ax
|
|
movw ax, sp
|
|
addw ax, #0x0016
|
|
addw ax, bc
|
|
movw de, ax
|
|
movw ax, [de+0x02]
|
|
cmpw ax, !LOWW(_g_owi_capture_threshold_ticks@5+0x00002)
|
|
movw ax, [de]
|
|
sknz
|
|
.BB@LABEL@28_7: ; bb33
|
|
cmpw ax, !LOWW(_g_owi_capture_threshold_ticks@5)
|
|
.BB@LABEL@28_8: ; bb33
|
|
bnc $.BB@LABEL@28_10
|
|
.BB@LABEL@28_9: ; bb33.bb49_crit_edge
|
|
oneb b
|
|
br $.BB@LABEL@28_11
|
|
.BB@LABEL@28_10: ; bb47
|
|
clrb b
|
|
.BB@LABEL@28_11: ; bb49
|
|
movw ax, sp
|
|
addw ax, #0x0005
|
|
movw hl, ax
|
|
mov a, [sp+0x00]
|
|
xch a, b
|
|
mov [hl+b], a
|
|
inc b
|
|
mov a, b
|
|
.BB@LABEL@28_12: ; bb49
|
|
mov [sp+0x00], a
|
|
mov a, [sp+0x00]
|
|
cmp a, #0x10
|
|
bc $.BB@LABEL@28_6
|
|
.BB@LABEL@28_13: ; bb61
|
|
clrw ax
|
|
clrb b
|
|
br $.BB@LABEL@28_15
|
|
.BB@LABEL@28_14: ; bb62
|
|
addw ax, #0x0005
|
|
movw hl, ax
|
|
mov a, [hl+b]
|
|
shrw ax, 8+0x00000
|
|
movw de, ax
|
|
movw ax, !LOWW(_g_capture_sync@4)
|
|
addw ax, ax
|
|
or a, d
|
|
xch a, x
|
|
or a, e
|
|
xch a, x
|
|
inc b
|
|
.BB@LABEL@28_15: ; bb62
|
|
movw !LOWW(_g_capture_sync@4), ax
|
|
mov a, b
|
|
cmp a, #0x10
|
|
movw ax, sp
|
|
bc $.BB@LABEL@28_14
|
|
.BB@LABEL@28_16: ; bb81
|
|
incw ax
|
|
movw de, ax
|
|
mov c, #0x10
|
|
movw ax, sp
|
|
addw ax, #0x0005
|
|
call $!_OWI_CaptureFindHeaderEnd@1
|
|
cmp0 a
|
|
bnz $.BB@LABEL@28_19
|
|
.BB@LABEL@28_17: ; if_then_bb94
|
|
cmp0 !LOWW(_g_owi_timeout_latched@2)
|
|
.bnz $!.BB@LABEL@28_31
|
|
.BB@LABEL@28_18: ; if_then_bb106
|
|
oneb !LOWW(_g_owi_timeout_latched@2)
|
|
mov !LOWW(_g_capture_error@3), #0x03
|
|
clrw ax
|
|
movw !LOWW(_g_owi_last_timeout_byte_index@9), ax
|
|
clrb !LOWW(_g_owi_last_timeout_bit_index@10)
|
|
clrb a
|
|
br $.BB@LABEL@28_33
|
|
.BB@LABEL@28_19: ; if_break_bb109
|
|
clrb !LOWW(_g_owi_capture_pending_index@7)
|
|
pop hl
|
|
push hl
|
|
mov a, #0x10
|
|
sub a, h
|
|
mov !LOWW(_g_owi_capture_pending_count@8), a
|
|
clrb a
|
|
br $.BB@LABEL@28_21
|
|
.BB@LABEL@28_20: ; bb114
|
|
shrw ax, 8+0x00000
|
|
movw bc, ax
|
|
mov a, h
|
|
shrw ax, 8+0x00000
|
|
addw ax, bc
|
|
movw bc, ax
|
|
movw ax, sp
|
|
addw ax, #0x0005
|
|
addw ax, bc
|
|
movw de, ax
|
|
mov a, [sp+0x00]
|
|
mov b, a
|
|
mov a, [de]
|
|
mov LOWW(_g_owi_capture_pending_bits@6)[b], a
|
|
inc b
|
|
mov a, b
|
|
.BB@LABEL@28_21: ; bb114
|
|
mov [sp+0x00], a
|
|
mov a, [sp+0x00]
|
|
cmp a, !LOWW(_g_owi_capture_pending_count@8)
|
|
bc $.BB@LABEL@28_20
|
|
.BB@LABEL@28_22: ; bb129.bb190_crit_edge
|
|
mov [sp+0x00], #0x26
|
|
br $.BB@LABEL@28_32
|
|
.BB@LABEL@28_23: ; bb140
|
|
movw ax, [sp+0x56]
|
|
movw !LOWW(_g_owi_current_read_byte_index@11), ax
|
|
movw ax, [sp+0x02]
|
|
mov a, #0x07
|
|
sub a, x
|
|
mov c, a
|
|
mov !LOWW(_g_owi_current_read_bit_index@12), a
|
|
movw ax, sp
|
|
addw ax, #0x0004
|
|
movw de, ax
|
|
movw ax, [sp+0x56]
|
|
call $!_OWI_CaptureGetDecodedBit@1
|
|
movw hl, sp
|
|
cmp0 a
|
|
bz $.BB@LABEL@28_32
|
|
.BB@LABEL@28_24: ; if_break_bb161
|
|
mov a, [sp+0x04]
|
|
cmp0 a
|
|
bz $.BB@LABEL@28_29
|
|
.BB@LABEL@28_25: ; if_then_bb167
|
|
mov a, [sp+0x02]
|
|
mov b, a
|
|
onew ax
|
|
cmp0 b
|
|
br $.BB@LABEL@28_27
|
|
.BB@LABEL@28_26: ; if_then_bb167
|
|
addw ax, ax
|
|
dec b
|
|
.BB@LABEL@28_27: ; if_then_bb167
|
|
bnz $.BB@LABEL@28_26
|
|
.BB@LABEL@28_28: ; if_then_bb167
|
|
mov a, x
|
|
or a, [hl]
|
|
mov [hl], a
|
|
.BB@LABEL@28_29: ; if_break_bb178
|
|
movw ax, [sp+0x02]
|
|
decw ax
|
|
.BB@LABEL@28_30: ; if_break_bb178
|
|
movw [sp+0x02], ax
|
|
bf a.7, $.BB@LABEL@28_23
|
|
br $.BB@LABEL@28_32
|
|
.BB@LABEL@28_31: ; bb.bb190_crit_edge
|
|
clrb a
|
|
mov [sp+0x00], a
|
|
.BB@LABEL@28_32: ; bb190
|
|
mov a, [sp+0x00]
|
|
.BB@LABEL@28_33: ; bb190
|
|
addw sp, #0x58
|
|
ret
|
|
.LFE28:
|
|
.TYPE _OWI_SecureStop,function,.LFE29-_OWI_SecureStop
|
|
_OWI_SecureStop:
|
|
.STACK _OWI_SecureStop = 6
|
|
push hl
|
|
call $!_GPIO_Clear
|
|
clrw ax
|
|
movw [sp+0x00], ax
|
|
clrw bc
|
|
movw ax, #0x0960
|
|
call !!_delay_us
|
|
br $.BB@LABEL@29_2
|
|
.BB@LABEL@29_1: ; bb
|
|
call $!_GPIO_Input
|
|
clrw bc
|
|
movw ax, #0x00F0
|
|
call !!_delay_us
|
|
call $!_GPIO_Clear
|
|
clrw bc
|
|
movw ax, #0x012C
|
|
call !!_delay_us
|
|
movw hl, sp
|
|
incw [hl+0x00]
|
|
.BB@LABEL@29_2: ; bb2
|
|
movw ax, [sp+0x00]
|
|
xor a, #0x80
|
|
cmpw ax, #0x8003
|
|
bc $.BB@LABEL@29_1
|
|
.BB@LABEL@29_3: ; bb6
|
|
call $!_GPIO_Input
|
|
clrw bc
|
|
movw ax, #0x0960
|
|
call !!_delay_us
|
|
call $!_GPIO_Clear
|
|
clrw bc
|
|
movw ax, #0x0032
|
|
call !!_delay_us
|
|
call $!_GPIO_Input
|
|
pop ax
|
|
ret
|
|
.LFE29:
|
|
.TYPE _OWI_WriteBit,function,.LFE30-_OWI_WriteBit
|
|
_OWI_WriteBit:
|
|
.STACK _OWI_WriteBit = 6
|
|
push hl
|
|
or a, x
|
|
bz $.BB@LABEL@30_2
|
|
.BB@LABEL@30_1: ; entry.bb4_crit_edge
|
|
movw ax, #0x012C
|
|
br $.BB@LABEL@30_3
|
|
.BB@LABEL@30_2: ; bb3
|
|
movw ax, #0x0384
|
|
.BB@LABEL@30_3: ; bb3
|
|
movw [sp+0x00], ax
|
|
call $!_OWI_Release@1
|
|
movw hl, sp
|
|
movw ax, #0x04B0
|
|
subw ax, [hl+0x00]
|
|
movw de, ax
|
|
clrw ax
|
|
clrw bc
|
|
sknc
|
|
.BB@LABEL@30_4: ; bb4
|
|
decw ax
|
|
.BB@LABEL@30_5: ; bb4
|
|
subw ax, bc
|
|
movw bc, ax
|
|
movw ax, de
|
|
call !!_delay_us
|
|
call $!_OWI_DriveLow@1
|
|
clrw bc
|
|
movw ax, [sp+0x00]
|
|
call !!_delay_us
|
|
call $!_OWI_Release@1
|
|
pop ax
|
|
ret
|
|
.LFE30:
|
|
.TYPE _OWI_WriteByte,function,.LFE31-_OWI_WriteByte
|
|
_OWI_WriteByte:
|
|
.STACK _OWI_WriteByte = 8
|
|
push ax
|
|
push hl
|
|
movw ax, #0x0007
|
|
br $.BB@LABEL@31_5
|
|
.BB@LABEL@31_1: ; bb
|
|
mov a, x
|
|
mov b, a
|
|
mov a, [sp+0x03]
|
|
shrw ax, 8+0x00000
|
|
cmp0 b
|
|
br $.BB@LABEL@31_3
|
|
.BB@LABEL@31_2: ; bb
|
|
shrw ax, 0x01
|
|
dec b
|
|
.BB@LABEL@31_3: ; bb
|
|
bnz $.BB@LABEL@31_2
|
|
.BB@LABEL@31_4: ; bb
|
|
shlw ax, 0x0F
|
|
shrw ax, 0x0F
|
|
call $!_OWI_WriteBit
|
|
movw ax, [sp+0x00]
|
|
decw ax
|
|
.BB@LABEL@31_5: ; bb
|
|
movw [sp+0x00], ax
|
|
bf a.7, $.BB@LABEL@31_1
|
|
.BB@LABEL@31_6: ; bb13
|
|
call $!_GPIO_Input
|
|
addw sp, #0x04
|
|
ret
|
|
.LFE31:
|
|
.TYPE _OWI_ReadBit,function,.LFE32-_OWI_ReadBit
|
|
_OWI_ReadBit:
|
|
.STACK _OWI_ReadBit = 6
|
|
push hl
|
|
movw ax, !LOWW(_bit_period_us@1)
|
|
addw ax, ax
|
|
movw [sp+0x00], ax
|
|
br $.BB@LABEL@32_2
|
|
.BB@LABEL@32_1: ; bb
|
|
clrw bc
|
|
onew ax
|
|
call !!_delay_us
|
|
.BB@LABEL@32_2: ; bb4
|
|
call $!_GPIO_Read
|
|
or a, x
|
|
bnz $.BB@LABEL@32_5
|
|
.BB@LABEL@32_3: ; bb12
|
|
movw ax, [sp+0x00]
|
|
movw bc, ax
|
|
addw ax, ax
|
|
decw bc
|
|
pop ax
|
|
push bc
|
|
bnh $.BB@LABEL@32_5
|
|
.BB@LABEL@32_4: ; bb12.bb21_crit_edge
|
|
clrb a
|
|
br $.BB@LABEL@32_6
|
|
.BB@LABEL@32_5: ; bb20
|
|
oneb a
|
|
.BB@LABEL@32_6: ; bb21
|
|
bf a.0, $.BB@LABEL@32_1
|
|
.BB@LABEL@32_7: ; bb26
|
|
movw ax, [sp+0x00]
|
|
addw ax, ax
|
|
bnh $.BB@LABEL@32_17
|
|
.BB@LABEL@32_8: ; if_break_bb46
|
|
movw ax, !LOWW(_bit_period_us@1)
|
|
addw ax, ax
|
|
movw [sp+0x00], ax
|
|
br $.BB@LABEL@32_10
|
|
.BB@LABEL@32_9: ; bb50
|
|
clrw bc
|
|
onew ax
|
|
call !!_delay_us
|
|
.BB@LABEL@32_10: ; bb51
|
|
call $!_GPIO_Read
|
|
or a, x
|
|
bz $.BB@LABEL@32_13
|
|
.BB@LABEL@32_11: ; bb55
|
|
movw ax, [sp+0x00]
|
|
movw bc, ax
|
|
addw ax, ax
|
|
decw bc
|
|
pop ax
|
|
push bc
|
|
bnh $.BB@LABEL@32_13
|
|
.BB@LABEL@32_12: ; bb55.bb64_crit_edge
|
|
clrb a
|
|
br $.BB@LABEL@32_14
|
|
.BB@LABEL@32_13: ; bb63
|
|
oneb a
|
|
.BB@LABEL@32_14: ; bb64
|
|
bf a.0, $.BB@LABEL@32_9
|
|
.BB@LABEL@32_15: ; bb69
|
|
movw ax, [sp+0x00]
|
|
addw ax, ax
|
|
bnh $.BB@LABEL@32_17
|
|
.BB@LABEL@32_16: ; bb69.bb95_crit_edge
|
|
clrw ax
|
|
movw [sp+0x00], ax
|
|
br $.BB@LABEL@32_21
|
|
.BB@LABEL@32_17: ; if_then_bb74
|
|
cmp0 !LOWW(_g_owi_timeout_latched@2)
|
|
bnz $.BB@LABEL@32_19
|
|
.BB@LABEL@32_18: ; if_then_bb86
|
|
oneb !LOWW(_g_owi_timeout_latched@2)
|
|
movw ax, !LOWW(_g_owi_current_read_byte_index@11)
|
|
movw !LOWW(_g_owi_last_timeout_byte_index@9), ax
|
|
mov a, !LOWW(_g_owi_current_read_bit_index@12)
|
|
mov !LOWW(_g_owi_last_timeout_bit_index@10), a
|
|
.BB@LABEL@32_19: ; bb128
|
|
clrb a
|
|
br $.BB@LABEL@32_25
|
|
.BB@LABEL@32_20: ; bb92
|
|
clrw bc
|
|
onew ax
|
|
call !!_delay_us
|
|
movw hl, sp
|
|
incw [hl+0x00]
|
|
.BB@LABEL@32_21: ; bb95
|
|
call $!_GPIO_Read
|
|
or a, x
|
|
bnz $.BB@LABEL@32_23
|
|
.BB@LABEL@32_22: ; bb105
|
|
movw ax, !LOWW(_bit_period_us@1)
|
|
addw ax, ax
|
|
xor a, #0x80
|
|
movw bc, ax
|
|
movw ax, [sp+0x00]
|
|
xor a, #0x80
|
|
cmpw ax, bc
|
|
bc $.BB@LABEL@32_20
|
|
.BB@LABEL@32_23: ; bb120
|
|
movw ax, !LOWW(_bit_period_us@1+0x00002)
|
|
shlw ax, 0x0F
|
|
movw bc, ax
|
|
movw ax, !LOWW(_bit_period_us@1)
|
|
shrw ax, 0x01
|
|
addw ax, bc
|
|
xor a, #0x80
|
|
movw bc, ax
|
|
movw ax, [sp+0x00]
|
|
xor a, #0x80
|
|
cmpw ax, bc
|
|
bnc $.BB@LABEL@32_19
|
|
.BB@LABEL@32_24: ; bb120.bb135_crit_edge
|
|
oneb a
|
|
.BB@LABEL@32_25: ; bb135
|
|
pop bc
|
|
ret
|
|
.LFE32:
|
|
.TYPE _OWI_ReadByte,function,.LFE33-_OWI_ReadByte
|
|
_OWI_ReadByte:
|
|
.STACK _OWI_ReadByte = 10
|
|
subw sp, #0x06
|
|
movw hl, sp
|
|
clrb c
|
|
movw ax, #0x0007
|
|
movw [sp+0x04], ax
|
|
br $.BB@LABEL@33_5
|
|
.BB@LABEL@33_1: ; bb
|
|
addw ax, ax
|
|
dec c
|
|
.BB@LABEL@33_2: ; bb
|
|
bnz $.BB@LABEL@33_1
|
|
.BB@LABEL@33_3: ; bb
|
|
mov a, x
|
|
or a, [hl+0x02]
|
|
mov c, a
|
|
cmp0 b
|
|
bnz $.BB@LABEL@33_8
|
|
.BB@LABEL@33_4: ; if_break_bb
|
|
decw [hl+0x04]
|
|
.BB@LABEL@33_5: ; bb23
|
|
mov a, c
|
|
mov [sp+0x02], a
|
|
movw ax, [sp+0x04]
|
|
bt a.7, $.BB@LABEL@33_7
|
|
.BB@LABEL@33_6: ; bb
|
|
mov a, x
|
|
mov [sp+0x01], a
|
|
mov a, #0x07
|
|
sub a, [hl+0x01]
|
|
mov !LOWW(_g_owi_current_read_bit_index@12), a
|
|
call $!_OWI_ReadBit
|
|
mov [sp+0x00], a
|
|
call $!_OWI_HasTimeout
|
|
mov b, a
|
|
mov a, [sp+0x01]
|
|
mov c, a
|
|
mov a, [sp+0x00]
|
|
movw hl, sp
|
|
shrw ax, 8+0x00000
|
|
cmp0 c
|
|
br $.BB@LABEL@33_2
|
|
.BB@LABEL@33_7: ; bb23.bb29_crit_edge
|
|
mov a, [sp+0x02]
|
|
.BB@LABEL@33_8: ; bb29
|
|
addw sp, #0x06
|
|
ret
|
|
.LFE33:
|
|
.TYPE _owi_result_init@1,function,.LFE34-_owi_result_init@1
|
|
_owi_result_init@1:
|
|
.STACK _owi_result_init@1 = 6
|
|
push ax
|
|
cmpw ax, #0x0000
|
|
bz $.BB@LABEL@34_2
|
|
.BB@LABEL@34_1: ; if_break_bb
|
|
movw de, #0x0148
|
|
clrw bc
|
|
call !!_memset
|
|
pop de
|
|
push de
|
|
mov [de+0x00], #0x01
|
|
pop bc
|
|
push bc
|
|
movw ax, #0xFFFF
|
|
movw 0x0144[bc], ax
|
|
mov 0x0146[bc], #0xFF
|
|
.BB@LABEL@34_2: ; return
|
|
pop ax
|
|
ret
|
|
.LFE34:
|
|
.TYPE _owi_result_latch_timeout@1,function,.LFE35-_owi_result_latch_timeout@1
|
|
_owi_result_latch_timeout@1:
|
|
.STACK _owi_result_latch_timeout@1 = 6
|
|
push ax
|
|
or a, x
|
|
bz $.BB@LABEL@35_3
|
|
.BB@LABEL@35_1: ; if_break_bb
|
|
call $!_OWI_HasTimeout
|
|
cmp0 a
|
|
bz $.BB@LABEL@35_3
|
|
.BB@LABEL@35_2: ; if_then_bb13
|
|
pop de
|
|
push de
|
|
mov [de+0x00], #0x00
|
|
mov [de+0x01], #0x01
|
|
call $!_OWI_GetLastTimeoutByteIndex
|
|
movw bc, ax
|
|
movw ax, [sp+0x00]
|
|
xchw ax, bc
|
|
movw 0x0144[bc], ax
|
|
call $!_OWI_GetLastTimeoutBitIndex
|
|
mov b, a
|
|
movw ax, [sp+0x00]
|
|
xchw ax, bc
|
|
mov 0x0146[bc], a
|
|
.BB@LABEL@35_3: ; return
|
|
pop ax
|
|
ret
|
|
.LFE35:
|
|
.TYPE _OWI_T_CommandModeRaw,function,.LFE36-_OWI_T_CommandModeRaw
|
|
_OWI_T_CommandModeRaw:
|
|
.STACK _OWI_T_CommandModeRaw = 14
|
|
push de
|
|
push bc
|
|
push ax
|
|
subw sp, #0x04
|
|
mov a, b
|
|
mov [sp+0x00], a
|
|
movw ax, de
|
|
call $!_owi_result_init@1
|
|
clrw ax
|
|
movw [sp+0x02], ax
|
|
clrw bc
|
|
movw ax, #0x04B0
|
|
call $!_OWI_Init
|
|
call $!_OWI_ClearTimeout
|
|
call $!_OWI_KickWdt@1
|
|
call $!_OWI_SecureStop
|
|
call $!_OWI_KickWdt@1
|
|
mov a, [sp+0x00]
|
|
add a, a
|
|
call $!_OWI_WriteByte
|
|
call $!_OWI_KickWdt@1
|
|
br $.BB@LABEL@36_2
|
|
.BB@LABEL@36_1: ; bb
|
|
call $!_OWI_KickWdt@1
|
|
movw ax, [sp+0x04]
|
|
movw hl, sp
|
|
addw ax, [hl+0x02]
|
|
movw de, ax
|
|
mov a, [de]
|
|
call $!_OWI_WriteByte
|
|
call $!_OWI_KickWdt@1
|
|
movw hl, sp
|
|
incw [hl+0x02]
|
|
.BB@LABEL@36_2: ; bb12
|
|
mov a, [sp+0x06]
|
|
shrw ax, 8+0x00000
|
|
or a, #0x80
|
|
movw bc, ax
|
|
movw ax, [sp+0x02]
|
|
xor a, #0x80
|
|
cmpw ax, bc
|
|
bc $.BB@LABEL@36_1
|
|
.BB@LABEL@36_3: ; bb18
|
|
call $!_OWI_Stop
|
|
call $!_OWI_KickWdt@1
|
|
movw ax, [sp+0x08]
|
|
call $!_owi_result_latch_timeout@1
|
|
addw sp, #0x0A
|
|
ret
|
|
.LFE36:
|
|
.TYPE _OWI_CommandModeRaw,function,.LFE37-_OWI_CommandModeRaw
|
|
_OWI_CommandModeRaw:
|
|
.STACK _OWI_CommandModeRaw = 14
|
|
push de
|
|
push bc
|
|
push ax
|
|
subw sp, #0x04
|
|
mov a, b
|
|
mov [sp+0x00], a
|
|
movw ax, de
|
|
call $!_owi_result_init@1
|
|
clrw ax
|
|
movw [sp+0x02], ax
|
|
clrw bc
|
|
movw ax, #0x04B0
|
|
call $!_OWI_Init
|
|
call $!_OWI_ClearTimeout
|
|
call $!_OWI_KickWdt@1
|
|
call $!_OWI_SecureStop
|
|
call $!_OWI_KickWdt@1
|
|
mov a, [sp+0x00]
|
|
add a, a
|
|
call $!_OWI_WriteByte
|
|
call $!_OWI_KickWdt@1
|
|
br $.BB@LABEL@37_2
|
|
.BB@LABEL@37_1: ; bb
|
|
call $!_OWI_KickWdt@1
|
|
movw ax, [sp+0x04]
|
|
movw hl, sp
|
|
addw ax, [hl+0x02]
|
|
movw de, ax
|
|
mov a, [de]
|
|
call $!_OWI_WriteByte
|
|
call $!_OWI_KickWdt@1
|
|
movw hl, sp
|
|
incw [hl+0x02]
|
|
.BB@LABEL@37_2: ; bb12
|
|
mov a, [sp+0x06]
|
|
shrw ax, 8+0x00000
|
|
or a, #0x80
|
|
movw bc, ax
|
|
movw ax, [sp+0x02]
|
|
xor a, #0x80
|
|
cmpw ax, bc
|
|
bc $.BB@LABEL@37_1
|
|
.BB@LABEL@37_3: ; bb18
|
|
call $!_OWI_Stop
|
|
call $!_OWI_KickWdt@1
|
|
movw ax, [sp+0x08]
|
|
call $!_owi_result_latch_timeout@1
|
|
addw sp, #0x0A
|
|
ret
|
|
.LFE37:
|
|
.TYPE _OWI_ReadBytesRaw,function,.LFE38-_OWI_ReadBytesRaw
|
|
_OWI_ReadBytesRaw:
|
|
.STACK _OWI_ReadBytesRaw = 12
|
|
push ax
|
|
push de
|
|
push hl
|
|
push bc
|
|
movw ax, [sp+0x04]
|
|
cmpw ax, #0x0000
|
|
.bz $!.BB@LABEL@38_33
|
|
.BB@LABEL@38_1: ; if_break_bb
|
|
call $!_owi_result_init@1
|
|
clrw bc
|
|
movw ax, #0x04B0
|
|
call $!_OWI_Init
|
|
movw ax, [sp+0x06]
|
|
movw bc, ax
|
|
addw ax, ax
|
|
bh $.BB@LABEL@38_3
|
|
.BB@LABEL@38_2: ; if_then_bb13
|
|
movw ax, [sp+0x04]
|
|
movw de, ax
|
|
mov [de+0x00], #0x00
|
|
br $!.BB@LABEL@38_33
|
|
.BB@LABEL@38_3: ; if_break_bb17
|
|
movw ax, bc
|
|
xor a, #0x80
|
|
cmpw ax, #0x8141
|
|
bc $.BB@LABEL@38_5
|
|
.BB@LABEL@38_4: ; if_then_bb23
|
|
movw ax, #0x0140
|
|
movw [sp+0x06], ax
|
|
.BB@LABEL@38_5: ; if_break_bb25
|
|
movw ax, [sp+0x04]
|
|
movw de, ax
|
|
clrw ax
|
|
movw [de+0x02], ax
|
|
call $!_OWI_ClearTimeout
|
|
movw ax, [sp+0x06]
|
|
xor a, #0x80
|
|
cmpw ax, #0x8077
|
|
bc $.BB@LABEL@38_7
|
|
.BB@LABEL@38_6: ; if_break_bb25.bb34_crit_edge
|
|
oneb a
|
|
br $.BB@LABEL@38_8
|
|
.BB@LABEL@38_7: ; bb32
|
|
clrb a
|
|
.BB@LABEL@38_8: ; bb32
|
|
mov [sp+0x02], a
|
|
call $!_OWI_KickWdt@1
|
|
movw ax, [sp+0x06]
|
|
cmpw ax, #0x007F
|
|
sknz
|
|
.BB@LABEL@38_9: ; if_then_bb42
|
|
call $!_OWI_CapturePrepare@1
|
|
.BB@LABEL@38_10: ; if_break_bb43
|
|
call $!_OWI_SecureStop
|
|
mov a, [sp+0x00]
|
|
mov b, a
|
|
shl b, 0x01
|
|
inc b
|
|
movw ax, [sp+0x06]
|
|
cmpw ax, #0x007F
|
|
mov a, b
|
|
bnz $.BB@LABEL@38_12
|
|
.BB@LABEL@38_11: ; if_then_bb48
|
|
call $!_OWI_WriteCapturedReadAddress@1
|
|
br $.BB@LABEL@38_13
|
|
.BB@LABEL@38_12: ; if_else_bb
|
|
call $!_OWI_WriteByte
|
|
.BB@LABEL@38_13: ; if_break_bb59
|
|
movw ax, [sp+0x06]
|
|
clrw bc
|
|
cmpw ax, #0x007F
|
|
bnz $.BB@LABEL@38_23
|
|
.BB@LABEL@38_14: ; if_break_bb59.bb116_crit_edge
|
|
movw ax, bc
|
|
br $.BB@LABEL@38_21
|
|
.BB@LABEL@38_15: ; bb65
|
|
call $!_OWI_KickWdt@1
|
|
movw ax, [sp+0x00]
|
|
call $!_OWI_ReadByte_Captured@1
|
|
mov [sp+0x02], a
|
|
call !!_R_TAU1_Channel5_CaptureOverflowed
|
|
cmp0 a
|
|
bz $.BB@LABEL@38_18
|
|
.BB@LABEL@38_16: ; bb72
|
|
call $!_OWI_HasTimeout
|
|
cmp0 a
|
|
bnz $.BB@LABEL@38_18
|
|
.BB@LABEL@38_17: ; if_then_bb91
|
|
oneb !LOWW(_g_owi_timeout_latched@2)
|
|
movw ax, [sp+0x00]
|
|
movw !LOWW(_g_owi_last_timeout_byte_index@9), ax
|
|
mov !LOWW(_g_owi_last_timeout_bit_index@10), #0xFF
|
|
mov !LOWW(_g_capture_error@3), #0x02
|
|
.BB@LABEL@38_18: ; if_break_bb93
|
|
call $!_OWI_HasTimeout
|
|
cmp0 a
|
|
movw ax, [sp+0x04]
|
|
bz $.BB@LABEL@38_20
|
|
.BB@LABEL@38_19: ; if_then_bb99
|
|
call $!_owi_result_latch_timeout@1
|
|
br $.BB@LABEL@38_22
|
|
.BB@LABEL@38_20: ; if_break_bb102
|
|
movw hl, ax
|
|
addw ax, [hl+0x02]
|
|
addw ax, #0x0004
|
|
movw de, ax
|
|
mov a, [sp+0x02]
|
|
mov [de], a
|
|
movw ax, [sp+0x04]
|
|
movw hl, ax
|
|
incw [hl+0x02]
|
|
movw ax, [sp+0x00]
|
|
incw ax
|
|
movw bc, ax
|
|
.BB@LABEL@38_21: ; if_break_bb102
|
|
movw [sp+0x00], ax
|
|
movw ax, [sp+0x06]
|
|
xor a, #0x80
|
|
movw de, ax
|
|
movw ax, bc
|
|
xor a, #0x80
|
|
cmpw ax, de
|
|
bc $.BB@LABEL@38_15
|
|
.BB@LABEL@38_22: ; bb123
|
|
call $!_OWI_CaptureEnd@1
|
|
br $.BB@LABEL@38_32
|
|
.BB@LABEL@38_23: ; if_break_bb125
|
|
movw ax, #0x0064
|
|
call !!_delay_us
|
|
call $!_OWI_KickWdt@1
|
|
clrb c
|
|
clrw ax
|
|
call $!_OWI_WaitForFallingEdge@1
|
|
cmp0 a
|
|
bz $.BB@LABEL@38_29
|
|
.BB@LABEL@38_24: ; if_break_bb125.bb201_crit_edge
|
|
clrw bc
|
|
movw ax, bc
|
|
br $.BB@LABEL@38_31
|
|
.BB@LABEL@38_25: ; bb141
|
|
call $!_OWI_KickWdt@1
|
|
mov a, [sp+0x02]
|
|
cmp0 a
|
|
bz $.BB@LABEL@38_28
|
|
.BB@LABEL@38_26: ; bb146
|
|
movw ax, [sp+0x06]
|
|
addw ax, #0xFFCE
|
|
movw bc, ax
|
|
movw ax, [sp+0x00]
|
|
cmpw ax, bc
|
|
bnz $.BB@LABEL@38_28
|
|
.BB@LABEL@38_27: ; if_then_bb160
|
|
call $!_OWI_KickWdt@1
|
|
movw ax, [sp+0x00]
|
|
clrb c
|
|
call $!_OWI_WaitForFallingEdge@1
|
|
cmp0 a
|
|
bz $.BB@LABEL@38_29
|
|
.BB@LABEL@38_28: ; if_break_bb177
|
|
movw ax, [sp+0x00]
|
|
call $!_OWI_ReadByte_StreamSynced@1
|
|
mov b, a
|
|
movw ax, [sp+0x04]
|
|
movw hl, sp
|
|
addw ax, [hl+0x00]
|
|
addw ax, #0x0004
|
|
movw de, ax
|
|
mov a, b
|
|
mov [de], a
|
|
call $!_OWI_HasTimeout
|
|
cmp0 a
|
|
bz $.BB@LABEL@38_30
|
|
.BB@LABEL@38_29: ; if_then_bb191
|
|
movw ax, [sp+0x04]
|
|
call $!_owi_result_latch_timeout@1
|
|
br $.BB@LABEL@38_32
|
|
.BB@LABEL@38_30: ; if_break_bb194
|
|
movw ax, [sp+0x04]
|
|
movw hl, ax
|
|
incw [hl+0x02]
|
|
movw ax, [sp+0x00]
|
|
incw ax
|
|
movw bc, ax
|
|
.BB@LABEL@38_31: ; if_break_bb194
|
|
movw [sp+0x00], ax
|
|
movw ax, [sp+0x06]
|
|
xor a, #0x80
|
|
movw de, ax
|
|
movw ax, bc
|
|
xor a, #0x80
|
|
cmpw ax, de
|
|
bc $.BB@LABEL@38_25
|
|
.BB@LABEL@38_32: ; bb208
|
|
call $!_OWI_StopRead@1
|
|
call $!_OWI_KickWdt@1
|
|
.BB@LABEL@38_33: ; return
|
|
addw sp, #0x08
|
|
ret
|
|
.LFE38:
|
|
.SECTION .data,DATA
|
|
.ALIGN 2
|
|
.TYPE _bit_period_us@1,object,4
|
|
_bit_period_us@1:
|
|
.DB4 0x000004B0
|
|
.TYPE _g_owi_timeout_latched@2,object,1
|
|
_g_owi_timeout_latched@2:
|
|
.DS (1)
|
|
.TYPE _g_capture_error@3,object,1
|
|
_g_capture_error@3:
|
|
.DS (1)
|
|
.ALIGN 2
|
|
.TYPE _g_capture_sync@4,object,2
|
|
_g_capture_sync@4:
|
|
.DS (2)
|
|
.ALIGN 2
|
|
.TYPE _g_owi_capture_threshold_ticks@5,object,4
|
|
_g_owi_capture_threshold_ticks@5:
|
|
.DS (4)
|
|
.TYPE _g_owi_capture_pending_index@7,object,1
|
|
_g_owi_capture_pending_index@7:
|
|
.DS (1)
|
|
.TYPE _g_owi_capture_pending_count@8,object,1
|
|
_g_owi_capture_pending_count@8:
|
|
.DS (1)
|
|
.ALIGN 2
|
|
.TYPE _g_owi_last_timeout_byte_index@9,object,2
|
|
_g_owi_last_timeout_byte_index@9:
|
|
.DB2 0xFFFF
|
|
.TYPE _g_owi_last_timeout_bit_index@10,object,1
|
|
_g_owi_last_timeout_bit_index@10:
|
|
.DB 0xFF
|
|
.ALIGN 2
|
|
.TYPE _g_owi_current_read_byte_index@11,object,2
|
|
_g_owi_current_read_byte_index@11:
|
|
.DS (2)
|
|
.TYPE _g_owi_current_read_bit_index@12,object,1
|
|
_g_owi_current_read_bit_index@12:
|
|
.DS (1)
|
|
.SECTION .bss,BSS
|
|
.TYPE _g_owi_capture_pending_bits@6,object,16
|
|
_g_owi_capture_pending_bits@6:
|
|
.DS (16)
|
|
|