diff options
author | Christian Pointner <equinox@mur.at> | 2011-07-31 01:56:18 +0000 |
---|---|---|
committer | Christian Pointner <equinox@mur.at> | 2011-07-31 01:56:18 +0000 |
commit | 2aaee32fc73b90ecfaa9edf494487831d892c855 (patch) | |
tree | 970a4615e72501bd8c029fc4d37f287f35b2f555 /software/ihu/temp.inc | |
parent | one wire write commands work (diff) |
1wire for DS1821 works now
git-svn-id: https://svn.spreadspace.org/mur.sat@84 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/ihu/temp.inc')
-rw-r--r-- | software/ihu/temp.inc | 79 |
1 files changed, 62 insertions, 17 deletions
diff --git a/software/ihu/temp.inc b/software/ihu/temp.inc index 63eab26..38b5254 100644 --- a/software/ihu/temp.inc +++ b/software/ihu/temp.inc @@ -113,42 +113,87 @@ owire_write_loop ;; ------------------------------------- owire_readbit + bsf STATUS,RP0 + bcf TRISA,OWIRE + nop + bsf TRISA,OWIRE + bcf STATUS,RP0 + nop + btfss PORTA,OWIRE + bcf OWIRE_BYTE,7 + btfsc PORTA,OWIRE + bsf OWIRE_BYTE,7 + movlw .17 + movwf OWIRE_CNT +owire_readbit_loop + decfsz OWIRE_CNT,f + goto owire_readbit_loop return ;; ------------------------------------- owire_read_byte + movlw .8 + movwf OWIRE_BIT_CNT +owire_read_loop + call owire_readbit + decfsz OWIRE_BIT_CNT,f + goto owire_read_next return +owire_read_next + rrf OWIRE_BYTE,f + goto owire_read_loop + ;; ------------------------------------- temp_init call owire_presence - ;; btfsc OWIRE_BYTE,0 - ;; goto temp_init_error + btfsc OWIRE_BYTE,0 + goto temp_init_error - movlw b'10101010' + movlw TEMP_CMD_W_STAT call owire_write_byte - movlw b'01010101' + movlw b'01000011' call owire_write_byte - movlw b'11001100' - call owire_write_byte - movlw b'00001111' - call owire_write_byte - movlw b'00111100' - call owire_write_byte - - - movlw '.' - movwf TXREG return temp_init_error - movlw 'E' - movwf TXREG + ;; TODO: react to missing device return ;; ------------------------------------- temp_read_value - ;; TODO: implement this + call owire_presence + btfsc OWIRE_BYTE,0 + goto temp_read_value_error + + movlw TEMP_CMD_START + call owire_write_byte + +temp_read_value_loop + movlw .100 + call wait_ms + call owire_presence + btfsc OWIRE_BYTE,0 + goto temp_read_value_error + + movlw TEMP_CMD_R_STAT + call owire_write_byte + call owire_read_byte + btfss OWIRE_BYTE,7 + goto temp_read_value_loop + + + call owire_presence + btfsc OWIRE_BYTE,0 + goto temp_read_value_error + + movlw TEMP_CMD_R_TEMP + call owire_write_byte + call owire_read_byte + return + +temp_read_value_error + ;; TODO: react to missing device return ;; ------------------------------------- |