summaryrefslogtreecommitdiff
path: root/software/ctr/ttx.inc
blob: 2e45f28f7184027575f74c49887c4031f0e30b1d (plain) (blame)
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
  ;;
  ;;  mur.sat
  ;;
  ;;  Somewhen in the year 2012, mur.at will have a nano satellite launched
  ;;  into a low earth orbit (310 km above the surface of our planet). The
  ;;  satellite itself is a TubeSat personal satellite kit, developed and
  ;;  launched by interorbital systems. mur.sat is a joint venture of mur.at,
  ;;  ESC im Labor and realraum.
  ;;
  ;;  Please visit the project hompage at sat.mur.at for further information.
  ;; 
  ;;
  ;;  Copyright (C) 2011 Christian Pointner <equinox@mur.at>
  ;;                         
  ;;  This file is part of mur.sat.
  ;;
  ;;  mur.sat 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
  ;;  any later version.
  ;;
  ;;  mur.sat 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 mur.sat. If not, see <http://www.gnu.org/licenses/>.
  ;;

  ;; -------------------------------------
dottime
  movwf     TMR0
  bcf       INTCON,T0IF
dot_inner
  btfss     INTCON,T0IF
  goto      dot_inner
  clrwdt
  return

  ;; -------------------------------------
send_char
  movwf     CHAR
  movlw     'Z' + 1
  subwf     CHAR,w
  btfsc     STATUS,C
  return
  movlw     ' '
  subwf     CHAR,f
  btfss     STATUS,C
  return
  btfsc     STATUS,Z
  return

  movf      CHAR,w
  call      getcw
  movwf     ELEMENT
  movf      CHAR,w
  call      getcwlen
  movwf     ELECNT
  movf      ELECNT,f
  btfsc     STATUS,Z
  return
  movf      CHAR,w
  xorwf     PARITY,f
  
char_next_element
  bsf       PORTA,CW_OUT
  btfss     ELEMENT,7
  movf      DOT,w
  btfsc     ELEMENT,7
  movf      DASH,w
  call      dottime
  bcf       PORTA,CW_OUT

  rlf       ELEMENT,f

  decfsz    ELECNT,f
  goto      char_espace
  return

char_espace
  movf      ESPACE,w
  call      dottime
  goto      char_next_element
  
  ;; -------------------------------------
send_callsign
  movlw     .6
  movwf     CHARCNT

callsign_next_char
  call      callsign
  call      send_char
  decfsz    CHARCNT,f
  goto      callsign_cspace
  return

callsign_cspace
  movf      CSPACE,w
  call      dottime
  movf      CHARCNT,w
  goto      callsign_next_char
  
  ;; -------------------------------------
send_base32
  movwf     PENTLECNT

case0  
  rrf       INDF0,w
  movwf     PENTLE0
  rrf       PENTLE0,f
  rrf       PENTLE0,w
  andlw     b'00011111'
  call      base32
  call      send_char
  decfsz    PENTLECNT,f
  goto      case1
  return

case1
  movf      CSPACE,w
  call      dottime
  rlf       INDF0,w
  movwf     PENTLE0
  rlf       PENTLE0,w
  andlw     b'00011100'
  movwf     PENTLE0
  incf      FSR0L,f
  swapf     INDF0,w
  movwf     PENTLE1
  rrf       PENTLE1,f
  rrf       PENTLE1,w
  andlw     b'00000011'
  iorwf     PENTLE0,w
  call      base32
  call      send_char
  decfsz    PENTLECNT,f
  goto      case2
  return

case2
  movf      CSPACE,w
  call      dottime
  rrf       INDF0,w
  andlw     b'00011111'
  call      base32
  call      send_char
  decfsz    PENTLECNT,f
  goto      case3
  return

case3
  movf      CSPACE,w
  call      dottime
  swapf     INDF0,w
  andlw     b'00010000'
  movwf     PENTLE0
  incf      FSR0L,f
  swapf     INDF0,w
  andlw     b'00001111'
  iorwf     PENTLE0,w
  call      base32
  call      send_char
  decfsz    PENTLECNT,f
  goto      case4
  return

case4
  movf      CSPACE,w
  call      dottime
  rlf       INDF0,w
  andlw     b'00011110'
  movwf     PENTLE0
  incf      FSR0L,f
  btfsc     INDF0,7
  bsf       PENTLE0,0
  movf      PENTLE0,w
  call      base32
  call      send_char
  decfsz    PENTLECNT,f
  goto      case5
  return

case5
  movf      CSPACE,w
  call      dottime
  rrf       INDF0,w
  movwf     PENTLE0
  rrf       PENTLE0,w
  andlw     b'00011111'
  call      base32
  call      send_char
  decfsz    PENTLECNT,f
  goto      case6
  return

case6
  movf      CSPACE,w
  call      dottime
  swapf     INDF0,w
  movwf     PENTLE0
  rrf       PENTLE0,w
  andlw     b'00011000'
  movwf     PENTLE0
  incf      FSR0L,f
  swapf     INDF0,w
  movwf     PENTLE1
  rrf       PENTLE1,w
  andlw     b'00000111'
  iorwf     PENTLE0,w
  call      base32
  call      send_char
  decfsz    PENTLECNT,f
  goto      case7
  return

case7
  movf      CSPACE,w
  call      dottime
  movf      INDF0,w
  andlw     b'00011111'
  call      base32
  call      send_char
  decfsz    PENTLECNT,f
  goto      caseend
  return

caseend
  movf      CSPACE,w
  call      dottime
  incf      FSR0L,f
  goto      case0
  
  ;; -------------------------------------
send_cnt
  rlf       BEACONCNTL,w
  movwf     TMP2
  rlf       BEACONCNTH,w
  movwf     TMP1
  movlw     TMP1
  movwf     FSR0L
  clrf      FSR0H
  movlw     .3
  call      send_base32
  return

  ;; -------------------------------------
send_parity
  movf      PARITY,w
  btfsc     PARITY,5
  xorlw     b'00000001'
  andlw     b'00011111'
  call      base32
  call      send_char

  movf      WSPACE,w
  call      dottime
  return

  ;; -------------------------------------
send_beacon
  bsf       PORTA,CW_ENABLE
  movf      TUNE,w
  call      dottime
  clrf      PARITY

  movlw     START_CHAR
  call      send_char

  movf      WSPACE,w
  call      dottime
    
  call      send_callsign

  movf      WSPACE,w
  call      dottime

  call      send_cnt

  movf      WSPACE,w
  call      dottime

  call      send_parity

  incfsz    BEACONCNTL,f
  goto      beacon_end
  incf      BEACONCNTH,f
  ;; TODO write new cnt value to EEPROM
  
beacon_end
  bcf       PORTA,CW_ENABLE
  return
  ;; -------------------------------------