Mercurial > public > hwos_code
comparison src/i2c.asm @ 200:dcd513840c6c
cleanup
author | heinrichsweikamp |
---|---|
date | Wed, 12 Nov 2014 19:33:15 +0100 |
parents | 30ebaf72170d |
children | 4147cd5c0c8e |
comparison
equal
deleted
inserted
replaced
199:800f09c9089c | 200:dcd513840c6c |
---|---|
18 | 18 |
19 #include "ostc3.inc" ; Mandatory header | 19 #include "ostc3.inc" ; Mandatory header |
20 #include "wait.inc" | 20 #include "wait.inc" |
21 #include "math.inc" | 21 #include "math.inc" |
22 | 22 |
23 #DEFINE battery_offset .27302 ; 65536-(3,25Ah/0,085mAh) | 23 #DEFINE battery_offset .29065 ; 65536-(3,1Ah/0,085mAh) |
24 #DEFINE battery_devider .382 ; 3,25Ah/0,085mAh/100 [%] | 24 #DEFINE battery_devider .365 ; 3,1Ah/0,085mAh/100 [%] |
25 | 25 |
26 i2c CODE | 26 i2c CODE |
27 | 27 |
28 WaitMSSP: | 28 WaitMSSP: |
29 decfsz i2c_temp,F ; check for timeout during I2C action | 29 decfsz i2c_temp,F ; check for timeout during I2C action |
401 rcall WaitMSSP | 401 rcall WaitMSSP |
402 return | 402 return |
403 | 403 |
404 global lt2942_get_status | 404 global lt2942_get_status |
405 lt2942_get_status: ; Read status register | 405 lt2942_get_status: ; Read status register |
406 bcf c3_hardware ; Clear flag | 406 bcf cr_hardware ; Clear flag |
407 clrf i2c_temp | 407 clrf i2c_temp |
408 movlw 0x00 ; Point to Status reg | 408 movlw 0x00 ; Point to Status reg |
409 call I2C_TX_GAUGE | 409 call I2C_TX_GAUGE |
410 call I2C_RX_GAUGE | 410 call I2C_RX_GAUGE |
411 movff SSP1BUF,WREG | 411 movff SSP1BUF,WREG |
412 btfss WREG,7 ; 2942 found? | 412 btfss WREG,7 ; 2942 found? |
413 bsf c3_hardware ; Yes, set flag | 413 bsf cr_hardware ; Yes, set flag |
414 bsf SSP1CON2,PEN ; Stop condition | 414 bsf SSP1CON2,PEN ; Stop condition |
415 rcall WaitMSSP | 415 rcall WaitMSSP |
416 return | 416 return |
417 | 417 |
418 | 418 |