Hi everyone,
I would rewritten this unit that used the functions of your inpout32.dll.
SUB i2c_init()
[b][color=red]OpenCom("LPT1:") [/color][/b] (1)
[color=limegreen]'OutPort(&h378+2,0)[/color]
Out32 (&h37A2, 0)
END SUB
SUB i2c_Start()
[color=limegreen]'OutPort(&h378+2,1)
'OutPort(&h378+2,3)[/color]
Out32(&h37A, &01)
Out32(&h37A, &03)
END SUB
SUB i2c_Stop()
[color=limegreen] 'OutPort(&h378+2,3)
'OutPort(&h378+2,1)
'OutPort(&h378+2,0)[/color]
Out32(&h37A, &03)
Out32(&h37A, &01)
Out32(&h37A, &00)
END SUB
SUB i2c_Ack()
[color=limegreen] 'OutPort(&h378+2,3)
'OutPort(&h378+2,1)[/color]
Delayus(10)
[color=limegreen] 'OutPort(&h378+2,3)[/color]
Out32(&h37A, &03)
Out32(&h37A, &01)
Delayus(10)
Out32(&h37A, &03)
END SUB
SUB i2c_NAck()
[color=limegreen]'OutPort(&h378+2,2)
'OutPort(&h378+2,0)[/color]
Delayus(10)
[color=limegreen] 'OutPort(&h378+2,2)[/color]
Out32(&h37A, &02)
Out32(&h37A, &00)
Delayus(10)
Out32(&h37A, &02)
END SUB
FUNCTION i2c_Write(BYVAL bWord AS BYTE) AS LONG
DIM bit_word, port_word, n AS BYTE
FUNCTION = TRUE
bit_word = &h80
FOR n = 1 TO 8
IF(bWord AND bit_word) = bit_word THEN port_word = 2 ELSE port_word = 3
[color=limegreen] 'OutPort(&h378+2,port_word)
'OutPort(&h378+2,port_word-2)[/color]
Delayus(10)
[color=limegreen] 'OutPort(&h378+2,port_word)[/color]
'bit_word = bit_word \ 2
Out32(&h37A, port_word)
Out32(&h37A, port_word-2)
Delayus(10)
Out32(&h37A, port_word)
bit_word = bit_word \ 2
NEXT
[color=limegreen] 'OutPort(&h378+2,2)
'OutPort(&h378+2,0) [/color]
Out32(&h37A, &02)
Out32(&h37A, &00)
Delayus(10)
[color=limegreen] 'IF(Inport(BA+2) AND 1)) = 0 THEN FUNCTION = FALSE[/color]
IF(Inp32(&h37A) AND 1)) = 0 THEN FUNCTION = FALSE
[color=limegreen] 'OutPort(&h378+2,2)[/color]
Out32(&h37A,&h02)
END FUNCTION
FUNCTION i2c_read() AS BYTE
END FUNCTION
How can I rewritten this OpenCOM("LPT1:") into Out32 and Inp32 functions with the inpout32.dll library?