diff options
author | Christian Pointner <equinox@mur.at> | 2011-07-29 23:43:30 +0000 |
---|---|---|
committer | Christian Pointner <equinox@mur.at> | 2011-07-29 23:43:30 +0000 |
commit | c93f3c269a4129871b2e184bb516a1ecc5dd4710 (patch) | |
tree | 2df2e746ab3f3bb848ee5c4420ba783948d110d6 | |
parent | put rtc and ttx in seperate files (diff) |
added get time function
git-svn-id: https://svn.spreadspace.org/mur.sat@77 7de4ea59-55d0-425e-a1af-a3118ea81d4c
-rw-r--r-- | software/ihu/ihu.asm | 3 | ||||
-rw-r--r-- | software/ihu/rtc.inc | 54 |
2 files changed, 50 insertions, 7 deletions
diff --git a/software/ihu/ihu.asm b/software/ihu/ihu.asm index 48045ce..93780f7 100644 --- a/software/ihu/ihu.asm +++ b/software/ihu/ihu.asm @@ -269,6 +269,9 @@ main btfsc STATUS,Z goto main + movlw BUF + movwf FSR + call rtc_get_time clrf TMP goto main diff --git a/software/ihu/rtc.inc b/software/ihu/rtc.inc index 18ac185..5a1446c 100644 --- a/software/ihu/rtc.inc +++ b/software/ihu/rtc.inc @@ -150,19 +150,19 @@ rtc_init movlw RTC_ADDR_W call i2c_send_byte btfsc RTC_BYTE,0 - goto rtc_init_error_ack + goto rtc_error_ack movlw RTC_REG_STAT call i2c_send_byte btfsc RTC_BYTE,0 - goto rtc_init_error_ack + goto rtc_error_ack call i2c_restart movlw RTC_ADDR_R call i2c_send_byte btfsc RTC_BYTE,0 - goto rtc_init_error_ack + goto rtc_error_ack call i2c_recv_byte call i2c_nack @@ -179,12 +179,12 @@ rtc_init_after_clock_fail movlw RTC_ADDR_W call i2c_send_byte btfsc RTC_BYTE,0 - goto rtc_init_error_ack + goto rtc_error_ack movlw RTC_REG_SEC call i2c_send_byte btfsc RTC_BYTE,0 - goto rtc_init_error_ack + goto rtc_error_ack movlw .16 movwf RTC_BYTE_CNT @@ -192,14 +192,54 @@ rtc_init_clear clrw call i2c_send_byte btfsc RTC_BYTE,0 - goto rtc_init_error_ack + goto rtc_error_ack decfsz RTC_BYTE_CNT,f goto rtc_init_clear call i2c_stop return -rtc_init_error_ack + ;; --------------- +rtc_get_time + call i2c_start + + movlw RTC_ADDR_W + call i2c_send_byte + btfsc RTC_BYTE,0 + goto rtc_error_ack + + movlw RTC_REG_SEC + call i2c_send_byte + btfsc RTC_BYTE,0 + goto rtc_error_ack + + call i2c_restart + + movlw RTC_ADDR_R + call i2c_send_byte + btfsc RTC_BYTE,0 + goto rtc_error_ack + + movlw .7 + movwf RTC_BYTE_CNT +rtc_get_time_loop + call i2c_recv_byte + movf RTC_BYTE,w + movwf INDF + decfsz RTC_BYTE_CNT,f + goto rtc_get_time_next + + call i2c_nack + call i2c_stop + return + +rtc_get_time_next + incf FSR,f + call i2c_ack + goto rtc_get_time_loop + + ;; --------------- +rtc_error_ack call i2c_stop ;; TODO: add error handling return |