forked from 74hc595/PIC16F1-USB-Bootloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bdt.inc
245 lines (198 loc) · 5.65 KB
/
bdt.inc
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
; vim:noet:sw=8:ts=8:ai:syn=pic
;
; USB 512-Word CDC Bootloader for PIC16(L)F1454/5/9
; Copyright (c) 2015, Matt Sarnoff (msarnoff.org)
; v1.0, February 12, 2015
; Released under a 3-clause BSD license: see the accompanying LICENSE file.
;
; Buffer descriptor table addresses (linear and banked)
; Valid only in ping-pong mode 0 (disabled).
BDT_START equ 0x2000
BDT_ENTRY_SIZE equ 4
NUM_BDT_ENTRIES equ 16
BDT_LEN equ BDT_ENTRY_SIZE*NUM_BDT_ENTRIES
EP0OUT equ 0x2000
EP0OUT_STAT equ EP0OUT+0
EP0OUT_CNT equ EP0OUT+1
EP0OUT_ADRL equ EP0OUT+2
EP0OUT_ADRH equ EP0OUT+3
EP0IN equ 0x2004
EP0IN_STAT equ EP0IN+0
EP0IN_CNT equ EP0IN+1
EP0IN_ADRL equ EP0IN+2
EP0IN_ADRH equ EP0IN+3
EP1OUT equ 0x2008
EP1OUT_STAT equ EP1OUT+0
EP1OUT_CNT equ EP1OUT+1
EP1OUT_ADRL equ EP1OUT+2
EP1OUT_ADRH equ EP1OUT+3
EP1IN equ 0x200C
EP1IN_STAT equ EP1IN+0
EP1IN_CNT equ EP1IN+1
EP1IN_ADRL equ EP1IN+2
EP1IN_ADRH equ EP1IN+3
EP2OUT equ 0x2010
EP2OUT_STAT equ EP2OUT+0
EP2OUT_CNT equ EP2OUT+1
EP2OUT_ADRL equ EP2OUT+2
EP2OUT_ADRH equ EP2OUT+3
EP2IN equ 0x2014
EP2IN_STAT equ EP2IN+0
EP2IN_CNT equ EP2IN+1
EP2IN_ADRL equ EP2IN+2
EP2IN_ADRH equ EP2IN+3
EP3OUT equ 0x2018
EP3OUT_STAT equ EP3OUT+0
EP3OUT_CNT equ EP3OUT+1
EP3OUT_ADRL equ EP3OUT+2
EP3OUT_ADRH equ EP3OUT+3
EP3IN equ 0x201C
EP3IN_STAT equ EP3IN+0
EP3IN_CNT equ EP3IN+1
EP3IN_ADRL equ EP3IN+2
EP3IN_ADRH equ EP3IN+3
EP4OUT equ 0x2020
EP4OUT_STAT equ EP4OUT+0
EP4OUT_CNT equ EP4OUT+1
EP4OUT_ADRL equ EP4OUT+2
EP4OUT_ADRH equ EP4OUT+3
EP4IN equ 0x2024
EP4IN_STAT equ EP4IN+0
EP4IN_CNT equ EP4IN+1
EP4IN_ADRL equ EP4IN+2
EP4IN_ADRH equ EP4IN+3
EP5OUT equ 0x2028
EP5OUT_STAT equ EP5OUT+0
EP5OUT_CNT equ EP5OUT+1
EP5OUT_ADRL equ EP5OUT+2
EP5OUT_ADRH equ EP5OUT+3
EP5IN equ 0x202C
EP5IN_STAT equ EP5IN+0
EP5IN_CNT equ EP5IN+1
EP5IN_ADRL equ EP5IN+2
EP5IN_ADRH equ EP5IN+3
EP6OUT equ 0x2030
EP6OUT_STAT equ EP6OUT+0
EP6OUT_CNT equ EP6OUT+1
EP6OUT_ADRL equ EP6OUT+2
EP6OUT_ADRH equ EP6OUT+3
EP6IN equ 0x2034
EP6IN_STAT equ EP6IN+0
EP6IN_CNT equ EP6IN+1
EP6IN_ADRL equ EP6IN+2
EP6IN_ADRH equ EP6IN+3
EP7OUT equ 0x2038
EP7OUT_STAT equ EP7OUT+0
EP7OUT_CNT equ EP7OUT+1
EP7OUT_ADRL equ EP7OUT+2
EP7OUT_ADRH equ EP7OUT+3
EP7IN equ 0x203C
EP7IN_STAT equ EP7IN+0
EP7IN_CNT equ EP7IN+1
EP7IN_ADRL equ EP7IN+2
EP7IN_ADRH equ EP7IN+3
; First address available for buffers.
; (Microchip warns against using BDT entries for unused endpoints as buffer space.)
BUF_START equ 0x2040
; Banked addresses, for use with non-indirect operations.
BANKED_BDT_START equ 0x0020
BANKED_EP0OUT equ 0x0020
BANKED_EP0OUT_STAT equ BANKED_EP0OUT+0
BANKED_EP0OUT_CNT equ BANKED_EP0OUT+1
BANKED_EP0OUT_ADRL equ BANKED_EP0OUT+2
BANKED_EP0OUT_ADRH equ BANKED_EP0OUT+3
BANKED_EP0IN equ 0x0024
BANKED_EP0IN_STAT equ BANKED_EP0IN+0
BANKED_EP0IN_CNT equ BANKED_EP0IN+1
BANKED_EP0IN_ADRL equ BANKED_EP0IN+2
BANKED_EP0IN_ADRH equ BANKED_EP0IN+3
BANKED_EP1OUT equ 0x0028
BANKED_EP1OUT_STAT equ BANKED_EP1OUT+0
BANKED_EP1OUT_CNT equ BANKED_EP1OUT+1
BANKED_EP1OUT_ADRL equ BANKED_EP1OUT+2
BANKED_EP1OUT_ADRH equ BANKED_EP1OUT+3
BANKED_EP1IN equ 0x002C
BANKED_EP1IN_STAT equ BANKED_EP1IN+0
BANKED_EP1IN_CNT equ BANKED_EP1IN+1
BANKED_EP1IN_ADRL equ BANKED_EP1IN+2
BANKED_EP1IN_ADRH equ BANKED_EP1IN+3
BANKED_EP2OUT equ 0x0030
BANKED_EP2OUT_STAT equ BANKED_EP2OUT+0
BANKED_EP2OUT_CNT equ BANKED_EP2OUT+1
BANKED_EP2OUT_ADRL equ BANKED_EP2OUT+2
BANKED_EP2OUT_ADRH equ BANKED_EP2OUT+3
BANKED_EP2IN equ 0x0034
BANKED_EP2IN_STAT equ BANKED_EP2IN+0
BANKED_EP2IN_CNT equ BANKED_EP2IN+1
BANKED_EP2IN_ADRL equ BANKED_EP2IN+2
BANKED_EP2IN_ADRH equ BANKED_EP2IN+3
BANKED_EP3OUT equ 0x0038
BANKED_EP3OUT_STAT equ BANKED_EP3OUT+0
BANKED_EP3OUT_CNT equ BANKED_EP3OUT+1
BANKED_EP3OUT_ADRL equ BANKED_EP3OUT+2
BANKED_EP3OUT_ADRH equ BANKED_EP3OUT+3
BANKED_EP3IN equ 0x003C
BANKED_EP3IN_STAT equ BANKED_EP3IN+0
BANKED_EP3IN_CNT equ BANKED_EP3IN+1
BANKED_EP3IN_ADRL equ BANKED_EP3IN+2
BANKED_EP3IN_ADRH equ BANKED_EP3IN+3
BANKED_EP4OUT equ 0x0040
BANKED_EP4OUT_STAT equ BANKED_EP4OUT+0
BANKED_EP4OUT_CNT equ BANKED_EP4OUT+1
BANKED_EP4OUT_ADRL equ BANKED_EP4OUT+2
BANKED_EP4OUT_ADRH equ BANKED_EP4OUT+3
BANKED_EP4IN equ 0x0044
BANKED_EP4IN_STAT equ BANKED_EP4IN+0
BANKED_EP4IN_CNT equ BANKED_EP4IN+1
BANKED_EP4IN_ADRL equ BANKED_EP4IN+2
BANKED_EP4IN_ADRH equ BANKED_EP4IN+3
BANKED_EP5OUT equ 0x0048
BANKED_EP5OUT_STAT equ BANKED_EP5OUT+0
BANKED_EP5OUT_CNT equ BANKED_EP5OUT+1
BANKED_EP5OUT_ADRL equ BANKED_EP5OUT+2
BANKED_EP5OUT_ADRH equ BANKED_EP5OUT+3
BANKED_EP5IN equ 0x004C
BANKED_EP5IN_STAT equ BANKED_EP5IN+0
BANKED_EP5IN_CNT equ BANKED_EP5IN+1
BANKED_EP5IN_ADRL equ BANKED_EP5IN+2
BANKED_EP5IN_ADRH equ BANKED_EP5IN+3
BANKED_EP6OUT equ 0x0050
BANKED_EP6OUT_STAT equ BANKED_EP6OUT+0
BANKED_EP6OUT_CNT equ BANKED_EP6OUT+1
BANKED_EP6OUT_ADRL equ BANKED_EP6OUT+2
BANKED_EP6OUT_ADRH equ BANKED_EP6OUT+3
BANKED_EP6IN equ 0x0054
BANKED_EP6IN_STAT equ BANKED_EP6IN+0
BANKED_EP6IN_CNT equ BANKED_EP6IN+1
BANKED_EP6IN_ADRL equ BANKED_EP6IN+2
BANKED_EP6IN_ADRH equ BANKED_EP6IN+3
BANKED_EP7OUT equ 0x0058
BANKED_EP7OUT_STAT equ BANKED_EP7OUT+0
BANKED_EP7OUT_CNT equ BANKED_EP7OUT+1
BANKED_EP7OUT_ADRL equ BANKED_EP7OUT+2
BANKED_EP7OUT_ADRH equ BANKED_EP7OUT+3
BANKED_EP7IN equ 0x005C
BANKED_EP7IN_STAT equ BANKED_EP7IN+0
BANKED_EP7IN_CNT equ BANKED_EP7IN+1
BANKED_EP7IN_ADRL equ BANKED_EP7IN+2
BANKED_EP7IN_ADRH equ BANKED_EP7IN+3
BANKED_BUF_START equ 0x0060
; BDnSTAT bit masks
_DAT0 equ 0x00
_DAT1 equ 0x40
_BSTALL equ 0x04
_DTSEN equ 0x08
_USIE equ 0x80
_UCPU equ 0x00
; BDnSTAT bit numbers (CPU mode)
UOWN equ 7
DTS equ 6
DTSEN equ 3
BSTALL equ 2
BC9 equ 1
BC8 equ 0
; BDnSTAT bit numbers (SIE mode)
PID3 equ 5
PID2 equ 4
PID1 equ 3
PID0 equ 2