-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand_NR_NT.asm
116 lines (103 loc) · 3.17 KB
/
command_NR_NT.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
; This file is part of Programator.
;
; Programator is free software: you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation, either version 3 of the
; License, or (at your option) any later version.
;
; Programator is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with Programator. If not, see <https://www.gnu.org/licenses/>.
;
; Copyright (c) 2022, 2024 Aleksander Mazur
;
; Procedury obsługi niskopoziomowej komunikacji
;-----------------------------------------------------------
; NT
if USE_HELP_DESC
dw s_help_NT
endif
command_icp51_transfer:
clr F0 ; czy wysłać tylko 7 bitów z następnego bajtu
command_icp51_transfer_loop:
acall get_hex_or_char
jnc command_icp51_send_byte
jnz command_icp51_transfer_next_char
; C=1, A=0 -> koniec
ret
command_icp51_send_byte:
; C=0, A=bajt do wysłania (lub 7 bitów jeśli F0)
jbc F0, command_icp51_transfer_7bits
; wysyłamy bajt z A
acall icp51_send_byte
sjmp command_icp51_transfer_loop
command_icp51_transfer_7bits:
; wysyłamy 7 bitów z A
acall icp51_send_7bits
sjmp command_icp51_transfer_loop
command_icp51_transfer_next_char:
; C=1, A=znak
cjne A, #' ', command_icp51_transfer_not_space
; spacja wraca do stanu początkowego
acall uart_send_char ; echo
sjmp command_icp51_transfer
command_icp51_transfer_not_space:
cjne A, #'R', command_icp51_transfer_not_R
; odbieramy bajt
acall icp51_recv_byte
acall uart_send_hex_byte
sjmp command_icp51_transfer_loop
command_icp51_transfer_not_R:
cjne A, #'S', command_icp51_transfer_not_S
; skraca następny bajt do 7 bitów (obcina najstarszy bit)
setb F0
sjmp command_icp51_transfer_loop
command_icp51_transfer_not_S:
cjne A, #'Z', command_icp51_transfer_not_Z
; wysyłamy bit 0
clr C
sjmp command_icp51_send_bit_fast
command_icp51_transfer_not_Z:
cjne A, #'J', command_icp51_transfer_not_J
; wysyłamy bit 1
setb C
command_icp51_send_bit_fast:
acall icp51_send_bit
sjmp command_icp51_transfer_loop
command_icp51_transfer_not_J:
cjne A, #'L', command_icp51_transfer_not_L
; wysyłamy bit 0, ale długo
clr C
sjmp command_icp51_send_bit_slow
command_icp51_transfer_not_L:
cjne A, #'H', command_icp51_transfer_not_H
; wysyłamy bit 1, ale długo
setb C
command_icp51_send_bit_slow:
acall icp51_send_bit_slow
sjmp command_icp51_transfer_loop
command_icp51_transfer_not_H:
ajmp error_illopt
;-----------------------------------------------------------
; NR
if USE_HELP_DESC
dw s_help_NR
endif
command_icp51_reset:
acall ensure_no_args
; jeśli mikrokontroler był już zainicjowany w trybie programowania, to zresetujmy go i zainicjujmy ponownie
jbc flag_icp51_init, command_icp51_reset2
sjmp command_icp51_reset_skip
command_icp51_reset2:
clr ICP51_RST
acall sleep_timer0_max
setb ICP51_RST
command_icp51_reset_skip:
ajmp icp51_init
;-----------------------------------------------------------
error_nothex_fwd:
acall error_nothex