Skip to content

Commit

Permalink
i2c ACK NACK
Browse files Browse the repository at this point in the history
  • Loading branch information
salhk committed Oct 24, 2023
1 parent 218c5a7 commit 5e6522b
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 74 deletions.
4 changes: 2 additions & 2 deletions pic/PIC_HAL.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ function pic_reg_read(addr as word,length as byte)as string
si2c_start()
si2c_write(PIC_CHIP_ADDR_R)
for tmp=1 to length-1
data=data+chr(si2c_read(ACK))
data=data+chr(si2c_read(true))
next tmp
data=data+chr(si2c_read(NACK))
data=data+chr(si2c_read(false))
pic_reg_read=data
si2c_stop()
end function
Expand Down
4 changes: 2 additions & 2 deletions pic/tbt_pic_gra.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ function tbt_pic_gra_reg_read(addr as word,length as byte)as string
si2c_start()
si2c_write(PIC_CHIP_ADDR_R)
for tmp=1 to length-1
data=data+chr(si2c_read(ACK))
data=data+chr(si2c_read(true))
next tmp
data=data+chr(si2c_read(NACK))
data=data+chr(si2c_read(false))
tbt_pic_gra_reg_read=data
si2c_stop()
end function
Expand Down
4 changes: 2 additions & 2 deletions tibbits/tbt13/tbt13.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ function tbt13_get_prev(tbt_channel as byte) as word
si2c_get(tbt_channel)
si2c_start()
si2c_write(TBT13_READ_ADDR)
byte_hi=si2c_read(ACK)
byte_lo=si2c_read(ACK)
byte_hi=si2c_read(true)
byte_lo=si2c_read(true)
si2c_stop()

#if ADC_RESOLUTION=ADC_RES_LOW
Expand Down
20 changes: 10 additions & 10 deletions tibbits/tbt22/tbt22.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ sub tbt22_rtd_read_all(byref config as byte, byref rtd as word, byref hi_fault a
while (io.lineget(int_pin) = LOW)
wend

config = si2c_read(ACK) 'byte 0
tmp = si2c_read(ACK) 'byte 1
rtd = tmp * 256 + si2c_read(ACK) 'byte 2
tmp = si2c_read(ACK) 'byte 3
hi_fault = tmp * 256 + si2c_read(ACK)'byte 4
tmp = si2c_read(ACK) 'byte 5
lo_fault = tmp * 256 + si2c_read(ACK)'byte 6
fault = si2c_read(NACK) 'byte 7
config = si2c_read(true) 'byte 0
tmp = si2c_read(true) 'byte 1
rtd = tmp * 256 + si2c_read(true) 'byte 2
tmp = si2c_read(true) 'byte 3
hi_fault = tmp * 256 + si2c_read(true)'byte 4
tmp = si2c_read(true) 'byte 5
lo_fault = tmp * 256 + si2c_read(true)'byte 6
fault = si2c_read(false) 'byte 7
si2c_stop()
while (io.lineget(int_pin) = LOW)
wend
Expand Down Expand Up @@ -326,9 +326,9 @@ function tbt22_rtd_fw_version(tbt_channel as byte)as string
si2c_start()
si2c_write(TBT22_RTD_CODE_R)
for i = 0 to 14
s = s + chr(si2c_read(ACK))
s = s + chr(si2c_read(true))
next i
s = s + chr(si2c_read(NACK))
s = s + chr(si2c_read(false))
si2c_stop()

tbt22_rtd_fw_version = s
Expand Down
4 changes: 2 additions & 2 deletions tibbits/tbt28/tbt28.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ function tbt28_get(byref channel as byte) as word
si2c_get(channel)
si2c_start()
si2c_write(TBT28_READ_ADDR)
upper=si2c_read(ACK)
lower=si2c_read(NACK)
upper=si2c_read(true)
lower=si2c_read(false)
si2c_stop()

#if TBT28_DEBUG_PRINT=1
Expand Down
6 changes: 3 additions & 3 deletions tibbits/tbt29/tbt29.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ function tbt29_read_data(op as tbt29_regs, byref channel as byte) as word
si2c_write(TBT29_READ_ADDR)

if op=TBT29_REG_RESOL then
lower=si2c_read(ACK)
lower=si2c_read(true)
else
upper=si2c_read(ACK)
lower=si2c_read(NACK)
upper=si2c_read(true)
lower=si2c_read(false)
end if

si2c_stop()
Expand Down
8 changes: 4 additions & 4 deletions tibbits/tbt30/tbt30.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ function tbt30_get(byref humidity as word, byref temperature as word, channel as
'fetch humidity data
si2c_start()
si2c_write(TBT30_READ_ADDR)
data1=si2c_read(ACK)
data2=si2c_read(ACK)
data3=si2c_read(ACK)
data4=si2c_read(NACK)
data1=si2c_read(true)
data2=si2c_read(true)
data3=si2c_read(true)
data4=si2c_read(false)
si2c_stop()

status=data1 and &h80
Expand Down
24 changes: 12 additions & 12 deletions tibbits/tbt35/tbt35.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,27 @@ function tbt35_init(byref signature as string, use_ssi as no_yes, pin_clk as byt
si2c_write(TBT35_READ_ADDR)

'a0
tmp=si2c_read(ACK)
tmp=si2c_read(true)
a0_tmp=tmp*256
tmp=si2c_read(ACK)
tmp=si2c_read(true)
a0_tmp=a0_tmp+tmp

'b1
tmp=si2c_read(ACK)
tmp=si2c_read(true)
b1_tmp=tmp*256
tmp=si2c_read(ACK)
tmp=si2c_read(true)
b1_tmp=b1_tmp+tmp

'b2
tmp=si2c_read(ACK)
tmp=si2c_read(true)
b2_tmp=tmp*256
tmp=si2c_read(ACK)
tmp=si2c_read(true)
b2_tmp=b2_tmp+tmp

'c12
tmp=si2c_read(ACK)
tmp=si2c_read(true)
c12_tmp=tmp*256
tmp=si2c_read(NACK)
tmp=si2c_read(false)
c12_tmp=c12_tmp+tmp
si2c_stop()

Expand Down Expand Up @@ -369,15 +369,15 @@ function tbt35_get_kpa(channel as byte)as float
si2c_write(TBT35_READ_ADDR)

'pressure
tmp=si2c_read(ACK)
tmp=si2c_read(true)
padc=tmp*256
tmp=si2c_read(ACK)
tmp=si2c_read(true)
padc=padc+tmp

'temprature
tmp=si2c_read(ACK)
tmp=si2c_read(true)
tadc=tmp*256
tmp=si2c_read(NACK)
tmp=si2c_read(false)
tadc=tadc+tmp

si2c_stop()
Expand Down
2 changes: 1 addition & 1 deletion tibbits/tbt36/tbt36.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function tbt36_get_reg(cmd as byte) as byte


si2c_write(TBT36_READ_CODE)
tmp=si2c_read(NACK)
tmp=si2c_read(false)

if si2c_is_busy()=NO then
tbt36_error()
Expand Down
4 changes: 2 additions & 2 deletions tibbits/tbt40/tbt40.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ function tbt40_reg_read(addr as tbt40_regs, channel as byte)as word
si2c_write(addr+&hC) 'READ Command
si2c_start()
si2c_write(TBT40_READ_ADDR)
tbt40_reg_read=si2c_read(ACK)*256
tbt40_reg_read=tbt40_reg_read+si2c_read(NACK)
tbt40_reg_read=si2c_read(true)*256
tbt40_reg_read=tbt40_reg_read+si2c_read(false)
si2c_stop()
end function

Expand Down
2 changes: 1 addition & 1 deletion tibbits/tbt41/tbt41.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function tbt41_reg_read(addr as tbt41_regs)as byte
si2c_write(addr)
si2c_start()
si2c_write(TBT41_READ_CODE)
tbt41_reg_read=si2c_read(NACK)
tbt41_reg_read=si2c_read(false)
si2c_stop()
end function

Expand Down
48 changes: 24 additions & 24 deletions tibbits/tbt52/tbt52.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ function tbt52_init(use_ssi as no_yes,pin_clk as byte,pin_data as byte,pin_mclr

s=""
for i=0 to 14
s=s+chr(si2c_read(ACK))
s=s+chr(si2c_read(true))
next i
s=s+chr(si2c_read(NACK))
s=s+chr(si2c_read(false))

si2c_stop()

Expand Down Expand Up @@ -135,9 +135,9 @@ busy_wait:
wend
si2c_start()
si2c_write(&h21)
hi_byte=si2c_read(ACK)
lo_byte=si2c_read(ACK)
config=si2c_read(NACK)
hi_byte=si2c_read(true)
lo_byte=si2c_read(true)
config=si2c_read(false)
si2c_stop()

if (config and &h80) then goto busy_wait
Expand Down Expand Up @@ -208,10 +208,10 @@ sub param_read(pin_int as byte,channel as byte)
si2c_start()
si2c_write(&h21)

value(0)=si2c_read(ACK)
value(1)=si2c_read(ACK)
value(2)=si2c_read(ACK)
value(3)=si2c_read(ACK)
value(0)=si2c_read(true)
value(1)=si2c_read(true)
value(2)=si2c_read(true)
value(3)=si2c_read(true)

#if PLATFORM_TYPE_32
tmp=value(1)*&h10000
Expand Down Expand Up @@ -257,10 +257,10 @@ sub param_read(pin_int as byte,channel as byte)
#endif
end if

value(0)=si2c_read(ACK)
value(1)=si2c_read(ACK)
value(2)=si2c_read(ACK)
value(3)=si2c_read(ACK)
value(0)=si2c_read(true)
value(1)=si2c_read(true)
value(2)=si2c_read(true)
value(3)=si2c_read(true)
#if PLATFORM_TYPE_32
tmp=value(1)*&h10000
r=tmp
Expand Down Expand Up @@ -305,10 +305,10 @@ sub param_read(pin_int as byte,channel as byte)
#endif
end if

value(0)=si2c_read(ACK)
value(1)=si2c_read(ACK)
value(2)=si2c_read(ACK)
value(3)=si2c_read(ACK)
value(0)=si2c_read(true)
value(1)=si2c_read(true)
value(2)=si2c_read(true)
value(3)=si2c_read(true)
#if PLATFORM_TYPE_32
tmp=value(1)*&h10000
r=tmp
Expand Down Expand Up @@ -353,10 +353,10 @@ sub param_read(pin_int as byte,channel as byte)
#endif
end if

value(0)=si2c_read(ACK)
value(1)=si2c_read(ACK)
value(2)=si2c_read(ACK)
value(3)=si2c_read(NACK)
value(0)=si2c_read(true)
value(1)=si2c_read(true)
value(2)=si2c_read(true)
value(3)=si2c_read(false)
#if PLATFORM_TYPE_32
tmp=value(1)*&h10000
r=tmp
Expand Down Expand Up @@ -489,9 +489,9 @@ busy_wait:
wend
si2c_start()
si2c_write(&h21)
hi_byte=si2c_read(ACK)
lo_byte=si2c_read(ACK)
config=si2c_read(NACK)
hi_byte=si2c_read(true)
lo_byte=si2c_read(true)
config=si2c_read(false)
si2c_stop()
if (config and &h80) then goto busy_wait

Expand Down
10 changes: 5 additions & 5 deletions tibbits/tbt53/tbt53.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ function tbt53_init(use_ssi as no_yes, pin_clk as byte, pin_data as byte, byref

si2c_start()
si2c_write(TBT53_READ_ADDR)
hi_byte = si2c_read(ACK)
lo_byte = si2c_read(ACK)
config = si2c_read(NACK)
hi_byte = si2c_read(true)
lo_byte = si2c_read(true)
config = si2c_read(false)
si2c_stop()

#if TBT53_DEBUG_PRINT = 1
Expand All @@ -71,8 +71,8 @@ function tbt53_get_current(byref ma as real, channel as byte) as ok_ng
si2c_get(channel)
si2c_start()
si2c_write(TBT53_READ_ADDR)
hi_byte = si2c_read(ACK)
lo_byte = si2c_read(ACK)
hi_byte = si2c_read(true)
lo_byte = si2c_read(true)
si2c_stop()

tmp = hi_byte * 256
Expand Down
8 changes: 4 additions & 4 deletions tibbits/tbt62/tbt62.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ function tbt62_read_data(byref data as string, data_len as byte, tbt_channel as
i = 1
do
if i < data_len then
tmp = tmp + chr(si2c_read(ACK))
tmp = tmp + chr(si2c_read(true))
else
tmp = tmp + chr(si2c_read(NACK))
tmp = tmp + chr(si2c_read(false))
end if
i = i + 1
loop until i > data_len
Expand Down Expand Up @@ -370,9 +370,9 @@ function tbt62_checkTibbit(tbt_channel as byte) as EN_TBT62_INIT_RESULT
' Read version
version = ""
for i = 1 to 5
version = version + chr(si2c_read(ACK))
version = version + chr(si2c_read(true))
next i
version = version + chr(si2c_read(NACK))
version = version + chr(si2c_read(false))

' Send STOP
si2c_stop()
Expand Down

0 comments on commit 5e6522b

Please sign in to comment.