From 5a3bb8920b733baf572aa89d4c63c88003e26763 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 4 Mar 2012 21:14:42 +0000 Subject: moved ttx_crx to ctr git-svn-id: https://svn.spreadspace.org/mur.sat@272 7de4ea59-55d0-425e-a1af-a3118ea81d4c --- software/ctr/Makefile | 36 +++++ software/ctr/ctr.asm | 381 ++++++++++++++++++++++++++++++++++++++++++++++++ software/ctr/i2c.inc | 148 +++++++++++++++++++ software/ctr/tables.inc | 208 ++++++++++++++++++++++++++ software/ctr/ttx.inc | 294 +++++++++++++++++++++++++++++++++++++ 5 files changed, 1067 insertions(+) create mode 100644 software/ctr/Makefile create mode 100644 software/ctr/ctr.asm create mode 100644 software/ctr/i2c.inc create mode 100644 software/ctr/tables.inc create mode 100644 software/ctr/ttx.inc (limited to 'software/ctr') diff --git a/software/ctr/Makefile b/software/ctr/Makefile new file mode 100644 index 0000000..3e20a1d --- /dev/null +++ b/software/ctr/Makefile @@ -0,0 +1,36 @@ +## +## 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 +## +## 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 . +## + +PROJECT := ctr +PROC_TYPE := 16F1847 + +include ../pic.include.mk + +AFLAGS := $(AFLAGS) -y diff --git a/software/ctr/ctr.asm b/software/ctr/ctr.asm new file mode 100644 index 0000000..bdff971 --- /dev/null +++ b/software/ctr/ctr.asm @@ -0,0 +1,381 @@ + ;; + ;; 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 + ;; + ;; 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 . + ;; + ;; ------------------------------------- + ;; PREAMBLE + + LIST p=16F1847 + include "p16f1847.inc" + __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF + __config _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _BORV_LO & _LVP_OFF + + + ;; ------------------------------------- + ;; DEFINES + ;; constants +DOT_DEF EQU .256 - .21 ; .29 +DASH_DEF EQU .256 - .63 ; .87 +WSPACE_DEF EQU .256 - .147 ; .203 +TUNE_DEF EQU DOT_DEF +BCNINTL_DEF EQU .256 - .120 +BCNINTH_DEF EQU .255 +START_CHAR EQU 'N' +ACK_CHAR EQU 'A' +OSC_LOW EQU b'00010000' ; 31,25 kHz +OSC_HIGH EQU b'01101000' ; 4 MHz + + + ;; I/O Pins +;; PortA +CW_ENABLE EQU 2 +CW_OUT EQU 3 +IHU_SS EQU 5 +IHU_SDO EQU 6 +IHU_INT EQU 7 +;; PortB +CLK_1HZ EQU 0 +IHU_SDI EQU 1 +CRX_INT EQU 3 +IHU_SCK EQU 4 +I2C_SDA EQU 6 +I2C_SCL EQU 7 + + + ;; variables +;; page 0 only +ELEMENT EQU H'0020' +ELECNT EQU H'0021' +CHAR EQU H'0022' +PARITY EQU H'0023' +CHARCNT EQU H'0024' +PENTLE0 EQU H'0025' +PENTLE1 EQU H'0026' +PENTLECNT EQU H'0027' +ACK_DATA EQU H'0028' +TMP1 EQU H'0029' +TMP2 EQU H'002A' + +BUF EQU H'0040' +BUF_END EQU H'004F' + +;; all pages +BEACON_INTL EQU H'0070' +BEACON_INTH EQU H'0071' +DOT EQU H'0072' +ESPACE EQU DOT +DASH EQU H'0073' +CSPACE EQU DASH +WSPACE EQU H'0074' +TUNE EQU H'0075' + +I2C_BYTE EQU H'0077' +I2C_BIT_CNT EQU H'0078' +I2C_BYTE_CNT EQU H'0079' + +NVSTATE EQU H'007A' +BEACONCNTH EQU H'007B' +BEACONCNTL EQU H'007C' +STATE EQU H'007D' +W_TEMP EQU H'007E' +STATUS_TEMP EQU H'007F' + + ;; ------------------------------------- + ;; OFFSET + org 0 + goto init + + ;; ------------------------------------- + ;; Interrupt Vector + org .4 + ;; save context + movwf W_TEMP + swapf STATUS,W + movwf STATUS_TEMP + +interrupt_end + ;; restore context + swapf STATUS_TEMP,W + movwf STATUS + swapf W_TEMP,F + swapf W_TEMP,W + retfie + + ;; ------------------------------------- + ;; TABLES + include "tables.inc" + + ;; ------------------------------------- + ;; SUBROUTINES + + ;; ------------------------------------- + include "ttx.inc" + + ;; ------------------------------------- + include "i2c.inc" + + + ;;; TODO remove this + ;; ------------------------------------- + ;; ------------------------------------- + ;; ------------------------------------- + ;; ------------------------------------- + ;; constants +RTC_ADDR_W EQU b'11010000' +RTC_ADDR_R EQU b'11010001' +RTC_REG_SEC EQU H'00' +RTC_REG_MIN EQU H'01' +RTC_REG_HOUR EQU H'02' +RTC_REG_DOW EQU H'03' +RTC_REG_DOM EQU H'04' +RTC_REG_MON EQU H'05' +RTC_REG_YEAR EQU H'06' +RTC_REG_A1S EQU H'07' +RTC_REG_A1M EQU H'08' +RTC_REG_A1H EQU H'09' +RTC_REG_A1D EQU H'0A' +RTC_REG_A2M EQU H'0B' +RTC_REG_A2H EQU H'0C' +RTC_REG_A2D EQU H'0D' +RTC_REG_CON EQU H'0E' +RTC_REG_STAT EQU H'0F' + + ;; ------------------------------------- +rtc_init + movlb .1 + movlw OSC_HIGH + movwf OSCCON + movlb .0 + + call i2c_start + + movlw RTC_ADDR_W + call i2c_send_byte + btfsc I2C_BYTE,0 + goto rtc_error_ack + + movlw RTC_REG_STAT + call i2c_send_byte + btfsc I2C_BYTE,0 + goto rtc_error_ack + + call i2c_restart + + movlw RTC_ADDR_R + call i2c_send_byte + btfsc I2C_BYTE,0 + goto rtc_error_ack + + call i2c_recv_byte + call i2c_nack + + btfsc I2C_BYTE,7 + goto rtc_init_after_clock_fail + + call i2c_stop + return + +rtc_init_after_clock_fail + call i2c_restart + + movlw RTC_ADDR_W + call i2c_send_byte + btfsc I2C_BYTE,0 + goto rtc_error_ack + + movlw RTC_REG_SEC + call i2c_send_byte + btfsc I2C_BYTE,0 + goto rtc_error_ack + + movlw .16 + movwf I2C_BYTE_CNT +rtc_init_clear + clrw + call i2c_send_byte + btfsc I2C_BYTE,0 + goto rtc_error_ack + decfsz I2C_BYTE_CNT,f + goto rtc_init_clear + + call i2c_stop + + movlb .1 + movlw OSC_LOW + movwf OSCCON + movlb .0 + + return + + ;; --------------- +rtc_get_time + movlb .1 + movlw OSC_HIGH + movwf OSCCON + movlb .0 + + + call i2c_start + + movlw RTC_ADDR_W + call i2c_send_byte + btfsc I2C_BYTE,0 + goto rtc_error_ack + + movlw RTC_REG_SEC + call i2c_send_byte + btfsc I2C_BYTE,0 + goto rtc_error_ack + + call i2c_restart + + movlw RTC_ADDR_R + call i2c_send_byte + btfsc I2C_BYTE,0 + goto rtc_error_ack + + movlw .7 + movwf I2C_BYTE_CNT +rtc_get_time_loop + call i2c_recv_byte + movf I2C_BYTE,w + movwf INDF1 + decfsz I2C_BYTE_CNT,f + goto rtc_get_time_next + + call i2c_nack + call i2c_stop + + movlb .1 + movlw OSC_LOW + movwf OSCCON + movlb .0 + return + +rtc_get_time_next + incf FSR1L,f + call i2c_ack + goto rtc_get_time_loop + + ;; --------------- +rtc_error_ack + call i2c_stop + ;; TODO: add error handling + + movlb .1 + movlw OSC_LOW + movwf OSCCON + movlb .0 + return + + ;; ------------------------------------- + ;; ------------------------------------- + ;; ------------------------------------- + ;; ------------------------------------- + ;; ------------------------------------- + + + ;; ------------------------------------- + ;; INIT +init + ;; BANK 3 + movlb .4 + clrf WPUA + clrf WPUB + + ;; BANK 3 + movlb .3 + clrf ANSELA + clrf ANSELB + + ;; BANK 2 + movlb .2 + movlw b'01100000' + movwf APFCON0 + clrf APFCON1 + bcf LATB,I2C_SDA + bcf LATB,I2C_SCL + + ;; BANK 1 + movlb .1 + movlw b'00110011' + movwf TRISA + movlw b'11111111' + movwf TRISB + movlw OSC_LOW + movwf OSCCON + movlw b'11000011' + movwf OPTION_REG + + ;; BANK 0 + movlb .0 + movlw b'00000000' + movwf INTCON + + + bcf PORTA,CW_OUT + bcf PORTA,CW_ENABLE + + clrf NVSTATE ; TODO: read State from EEPROM + movlw .42 + movwf BEACONCNTL ; TODO: read Beaconcnt from EEPROM + movlw .23 + movwf BEACONCNTH + movlw BCNINTL_DEF ; TODO: read Beacon Interval from EEPROM + movwf BEACON_INTL + movlw BCNINTH_DEF + movwf BEACON_INTH + + movlw DOT_DEF ; TODO: read cw timings from EEPROM + movwf DOT ; - DOT: length of . + movlw DASH_DEF ; - DASH: length of - + movwf DASH ; - WSPACE: length word space + movlw WSPACE_DEF ; - TUNE: tune in time of oscillator + movwf WSPACE + movlw TUNE_DEF + movwf TUNE + + ;; ------------------------------------- + ;; MAINLOOP +main + movlw BUF + movwf FSR1L + clrf FSR1H + call rtc_get_time + + ;; clrw + ;; call dottime + + ;; movlw b'00001100' + ;; xorwf PORTA,f + + goto main + + ;; ------------------------------------- + ;; END + end diff --git a/software/ctr/i2c.inc b/software/ctr/i2c.inc new file mode 100644 index 0000000..52c90e3 --- /dev/null +++ b/software/ctr/i2c.inc @@ -0,0 +1,148 @@ + ;; + ;; 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 + ;; + ;; 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 . + ;; + + ;; ------------------------------------- +i2c_start + movlb .1 + bcf TRISB,I2C_SDA + nop + bcf TRISB,I2C_SCL + movlb .0 + return + + ;; ------------------ +i2c_restart + movlb .1 + bsf TRISB,I2C_SDA + nop + bsf TRISB,I2C_SCL + nop + nop + nop + bcf TRISB,I2C_SDA + nop + bcf TRISB,I2C_SCL + movlb .0 + return + + ;; ------------------ +i2c_stop + movlb .1 + bsf TRISB,I2C_SCL + nop + bsf TRISB,I2C_SDA + movlb .0 + return + + ;; ------------------ +i2c_send_byte + movwf I2C_BYTE + movlw .8 + movwf I2C_BIT_CNT + movlb .1 +i2c_send_byte_next + btfss I2C_BYTE,7 + bcf TRISB,I2C_SDA + btfsc I2C_BYTE,7 + bsf TRISB,I2C_SDA + nop + bsf TRISB,I2C_SCL + nop + nop + bcf TRISB,I2C_SCL + rlf I2C_BYTE,f + decfsz I2C_BIT_CNT,f + goto i2c_send_byte_next + + nop + nop + bsf TRISB,I2C_SDA + bsf TRISB,I2C_SCL + movlb .0 + movf PORTB,w + movlb .1 + bcf TRISB,I2C_SCL + bcf TRISB,I2C_SDA + movlb .0 + andlw b'00010000' + movwf I2C_BYTE + swapf I2C_BYTE,f + return + + ;; ------------------ +i2c_recv_byte + clrf I2C_BYTE + movlw .8 + movwf I2C_BIT_CNT + movlb .1 + bsf TRISB,I2C_SDA +i2c_recv_byte_loop + bsf TRISB,I2C_SCL + movlb .0 + btfsc PORTB,I2C_SDA + bsf I2C_BYTE,0 + movlb .1 + bcf TRISB,I2C_SCL + decfsz I2C_BIT_CNT,f + goto i2c_recv_byte_next + + bcf TRISB,I2C_SDA + movlb .0 + return + +i2c_recv_byte_next + bcf STATUS,C + rlf I2C_BYTE,f + goto i2c_recv_byte_loop + + ;; ------------------ +i2c_ack + movlb .1 + bcf TRISB,I2C_SDA + bsf TRISB,I2C_SCL + nop + nop + bcf TRISB,I2C_SCL + movlb .0 + return + + ;; ------------------ +i2c_nack + movlb .1 + bsf TRISB,I2C_SDA + bsf TRISB,I2C_SCL + nop + nop + bcf TRISB,I2C_SCL + bcf TRISB,I2C_SDA + movlb .0 + return + + ;; ------------------------------------- diff --git a/software/ctr/tables.inc b/software/ctr/tables.inc new file mode 100644 index 0000000..4adf432 --- /dev/null +++ b/software/ctr/tables.inc @@ -0,0 +1,208 @@ + ;; + ;; 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 + ;; + ;; 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 . + ;; + + ;; ------------------------------------- + ;; Morse Codes: 0=dot, 1=dash +getcw + addwf PCL,f + nop + retlw b'00010000' ; ! + retlw b'01001000' ; " + retlw b'00000000' ; # + retlw b'00010010' ; $ + retlw b'00000000' ; % + retlw b'01000000' ; & + retlw b'01111000' ; ' + retlw b'10110000' ; ( + retlw b'10110100' ; ) + retlw b'00000000' ; * + retlw b'01010000' ; + + retlw b'11001100' ; , + retlw b'10000100' ; - + retlw b'01010100' ; . + retlw b'10010000' ; / + retlw b'11111000' ; 0 + retlw b'01111000' ; 1 + retlw b'00111000' ; 2 + retlw b'00011000' ; 3 + retlw b'00001000' ; 4 + retlw b'00000000' ; 5 + retlw b'10000000' ; 6 + retlw b'11000000' ; 7 + retlw b'11100000' ; 8 + retlw b'11110000' ; 9 + retlw b'11100000' ; : + retlw b'10101000' ; ; + retlw b'00010100' ; < + retlw b'10001000' ; = + retlw b'10001010' ; > + retlw b'00110000' ; ? + retlw b'01000000' ; @ + retlw b'01000000' ; A + retlw b'10000000' ; B + retlw b'10100000' ; C + retlw b'10000000' ; D + retlw b'00000000' ; E + retlw b'00100000' ; F + retlw b'11000000' ; G + retlw b'00000000' ; H + retlw b'00000000' ; I + retlw b'01110000' ; J + retlw b'10100000' ; K + retlw b'01000000' ; L + retlw b'11000000' ; M + retlw b'10000000' ; N + retlw b'11100000' ; O + retlw b'01100000' ; P + retlw b'11010000' ; Q + retlw b'01000000' ; R + retlw b'00000000' ; S + retlw b'10000000' ; T + retlw b'00100000' ; U + retlw b'00010000' ; V + retlw b'01100000' ; W + retlw b'10010000' ; X + retlw b'10110000' ; Y + retlw b'11000000' ; Z + + ;; ------------------------------------- + ;; Morse Code Length +getcwlen + addwf PCL,f + nop + retlw .5 ; ! + retlw .6 ; " + retlw .0 ; # + retlw .7 ; $ + retlw .0 ; % + retlw .5 ; & + retlw .6 ; ' + retlw .5 ; ( + retlw .6 ; ) + retlw .0 ; * + retlw .5 ; + + retlw .6 ; , + retlw .6 ; - + retlw .6 ; . + retlw .5 ; / + retlw .5 ; 0 + retlw .5 ; 1 + retlw .5 ; 2 + retlw .5 ; 3 + retlw .5 ; 4 + retlw .5 ; 5 + retlw .5 ; 6 + retlw .5 ; 7 + retlw .5 ; 8 + retlw .5 ; 9 + retlw .6 ; : + retlw .6 ; ; + retlw .6 ; < + retlw .5 ; = + retlw .7 ; > + retlw .6 ; ? + retlw .6 ; @ + retlw .2 ; A + retlw .4 ; B + retlw .4 ; C + retlw .3 ; D + retlw .1 ; E + retlw .4 ; F + retlw .3 ; G + retlw .4 ; H + retlw .2 ; I + retlw .4 ; J + retlw .3 ; K + retlw .4 ; L + retlw .2 ; M + retlw .2 ; N + retlw .3 ; O + retlw .4 ; P + retlw .4 ; Q + retlw .3 ; R + retlw .3 ; S + retlw .1 ; T + retlw .3 ; U + retlw .4 ; V + retlw .3 ; W + retlw .4 ; X + retlw .4 ; Y + retlw .4 ; Z + + ;; ------------------------------------- + ;; Base32 Code +base32 + addwf PCL,f + retlw 'A' + retlw 'B' + retlw 'C' + retlw 'D' + retlw 'E' + retlw 'F' + retlw 'G' + retlw 'H' + retlw 'I' + retlw 'J' + retlw 'K' + retlw 'L' + retlw 'M' + retlw 'N' + retlw 'O' + retlw 'P' + retlw 'Q' + retlw 'R' + retlw 'S' + retlw 'T' + retlw 'U' + retlw 'V' + retlw 'W' + retlw 'X' + retlw 'Y' + retlw 'Z' + retlw '2' + retlw '3' + retlw '4' + retlw '5' + retlw '6' + retlw '7' + + ;; ------------------------------------- + ;; fixed strings +callsign + addwf PCL,f + nop + retlw 'R' + retlw 'U' + retlw 'M' + retlw '6' + retlw 'E' + retlw 'O' + + ;; ------------------------------------- diff --git a/software/ctr/ttx.inc b/software/ctr/ttx.inc new file mode 100644 index 0000000..2e45f28 --- /dev/null +++ b/software/ctr/ttx.inc @@ -0,0 +1,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 + ;; + ;; 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 . + ;; + + ;; ------------------------------------- +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 + ;; ------------------------------------- -- cgit v1.2.3