summaryrefslogtreecommitdiff
path: root/software/ttx_crx/ttx_crx.asm
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2012-03-04 21:14:42 +0000
committerChristian Pointner <equinox@mur.at>2012-03-04 21:14:42 +0000
commit5a3bb8920b733baf572aa89d4c63c88003e26763 (patch)
tree6385624f99d290d6dde174911df72708a4a1e2e2 /software/ttx_crx/ttx_crx.asm
parentadded datasheet for PMGD370XN (diff)
moved ttx_crx to ctr
git-svn-id: https://svn.spreadspace.org/mur.sat@272 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/ttx_crx/ttx_crx.asm')
-rw-r--r--software/ttx_crx/ttx_crx.asm381
1 files changed, 0 insertions, 381 deletions
diff --git a/software/ttx_crx/ttx_crx.asm b/software/ttx_crx/ttx_crx.asm
deleted file mode 100644
index bdff971..0000000
--- a/software/ttx_crx/ttx_crx.asm
+++ /dev/null
@@ -1,381 +0,0 @@
- ;;
- ;; 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/>.
- ;;
- ;; -------------------------------------
- ;; 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