summaryrefslogtreecommitdiff
path: root/software/ihu
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2011-07-26 23:48:30 +0000
committerChristian Pointner <equinox@mur.at>2011-07-26 23:48:30 +0000
commit1e45c7952baef93c18bee438be446fcbac385178 (patch)
tree53379f245ef28d658cd6f50da101f8efdc5d4a77 /software/ihu
parentimproved pic make file (diff)
ihu-ttx implement read of csum @ihu (not yet tested)
git-svn-id: https://svn.spreadspace.org/mur.sat@63 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/ihu')
-rw-r--r--software/ihu/ihu.asm71
1 files changed, 59 insertions, 12 deletions
diff --git a/software/ihu/ihu.asm b/software/ihu/ihu.asm
index 5258dfc..8951980 100644
--- a/software/ihu/ihu.asm
+++ b/software/ihu/ihu.asm
@@ -55,7 +55,9 @@ TMP EQU H'0020'
TTX_BYTE EQU H'0021'
TTX_BIT_CNT EQU H'0022'
TTX_BYTE_CNT EQU H'0023'
-WAIT_CNT EQU H'0024'
+TTX_CSUM EQU H'0024'
+
+WAIT_CNT EQU H'0030'
BUF EQU H'0040'
BUF_END EQU H'004F'
@@ -123,7 +125,7 @@ init
clrf PSTRCON
movlw b'00010000'
movwf OSCCON
- movlw b'00001111'
+ movlw b'10001111'
movwf TRISD
movlw b'00100100'
movwf TXSTA
@@ -193,9 +195,10 @@ ttx_send_byte
bcf TRISD,TTX_SDA
bcf STATUS,RP0
movwf TTX_BYTE
+ xorwf TTX_CSUM,f
movlw .8
movwf TTX_BIT_CNT
-ttx_next_bit
+ttx_send_next_bit
btfsc TTX_BYTE,7
bsf PORTD,TTX_SDA
btfss TTX_BYTE,7
@@ -211,13 +214,45 @@ ttx_next_bit
nop
rlf TTX_BYTE,f
decfsz TTX_BIT_CNT,f
- goto ttx_next_bit
+ goto ttx_send_next_bit
bsf STATUS,RP0
bsf TRISD,TTX_SDA
bcf STATUS,RP0
return
;; -------------------------------------
+ttx_recv_byte
+ movlw .8
+ movwf TTX_BIT_CNT
+ttx_recv_next_bit
+ bsf PORTD,TTX_SCL
+ nop
+ nop
+ nop
+ bcf PORTD,TTX_SCL
+ nop
+ nop
+ btfsc PORTD,TTX_SDA
+ bsf TTX_BYTE,0
+ btfss PORTD,TTX_SDA
+ bcf TTX_BYTE,0
+ nop
+ nop
+ rlf TTX_BYTE,f
+ decfsz TTX_BIT_CNT,f
+ goto ttx_recv_next_bit
+ return
+
+ ;; -------------------------------------
+ttx_break
+ movlw .13
+ movwf TTX_BIT_CNT
+ttx_wait_octet
+ decfsz TTX_BIT_CNT,f
+ goto ttx_wait_octet
+ return
+
+ ;; -------------------------------------
ttx_send_frame
movwf TTX_BYTE
andlw b'00001111'
@@ -227,6 +262,7 @@ ttx_send_frame
bcf PORTD,TTX_SCL
call wait_ms
+ clrf TTX_CSUM
movf TTX_BYTE,w
call ttx_send_byte
@@ -235,21 +271,29 @@ ttx_send_frame
return
ttx_next_byte
- movlw .16
- movwf TTX_BIT_CNT
-ttx_wait_octet
- decfsz TTX_BIT_CNT,f
- goto ttx_wait_octet
-
+ call ttx_break
movf INDF,w
call ttx_send_byte
incf FSR,f
decfsz TTX_BYTE_CNT,f
goto ttx_next_byte
-
+
+ call ttx_break
+ call ttx_recv_byte
+ movf TTX_BYTE,w
+ xorwf TTX_CSUM,w
+ btfss STATUS,Z
+ goto ttx_csum_error
return
+ttx_csum_error
+ bcf PORTD,TTX_RESET ;reset TTX
+ nop
+ nop
+ bsf PORTD,TTX_RESET
+ return
+
;; -------------------------------------
;; MAINLOOP
main
@@ -259,8 +303,11 @@ main
movlw BUF
movwf FSR
- movlw b'00010000'
+ movlw b'10101010'
+ movwf INDF
+ movlw b'00010001'
call ttx_send_frame
+
clrf TMP
goto main