This library is tested on EasyPIC4 board, PIC16F877A, PIC18F452 MCU and home made MCP23017 board, made by me.
First: copy i2cportexpander_lib_p16.mcl file in dir ../uses/P16 and i2cportexpander_lib.mcl file in dir ../uses/P18.
Library include :
Code: Select all
sub procedureI2CExpander_Init(dim byref RstPort as byte, dim RstPin, ModuleAddress as byte)
'I2C_Init(100000) must be called before initializing I2C Port Expander'
sub function I2CExpander_Read_Byte(dim ModuleAddress, RegAddress as byte) as byte
sub procedureI2CExpander_Write_Byte(dim ModuleAddress, RegAddress, Data as byte)
sub procedureI2CExpander_Set_Mode(dim ModuleAddress, Mode as byte)
sub procedureI2CExpander_Read_ArrayPortA(dim ModuleAddress, NoBytes as byte, dim byref DestArray as byte[100])
sub procedureI2CExpander_Read_Array(dim ModuleAddress, StartAddress, NoBytes as byte, dim byref DestArray as byte[100])
sub procedureI2CExpander_Write_Array(dim ModuleAddress, StartAddress, NoBytes as byte, dim byref SourceArray as byte[100])
sub function I2CExpander_Read_PortA(dim Address as byte) as byte
sub function I2CExpander_Read_PortB(dim Address as byte) as byte
sub procedureI2CExpander_Read_ArrayPortB(dim ModuleAddress, NoBytes as byte, dim byref DestArray as byte[100])
sub procedureI2CExpander_Write_PortA(dim ModuleAddress, Data as byte)
sub procedureI2CExpander_Write_PortB(dim ModuleAddress, Data as byte)
sub procedureI2CExpander_Set_DirectionPortA(dim ModuleAddress, Data as byte)
sub procedureI2CExpander_Set_DirectionPortB(dim ModuleAddress, Data as byte)
sub procedureI2CExpander_Set_PullUpsPortA(dim ModuleAddress, Data as byte)
sub procedureI2CExpander_Set_PullUpsPortB(dim ModuleAddress, Data as byte)
http://www.microelemente.ro/MikroBasic/ ... pander.zip
Source code of library is available in MikroPascal language:
http://www.microelemente.ro/I2CPortExp_Source.zip