Go Down

Topic: New Library for NXP PCAL6524 I2C 24BIT GPIO (Read 324 times) previous topic - next topic

jrj12591

Mar 15, 2019, 04:08 am Last Edit: Mar 15, 2019, 04:12 am by jrj12591 Reason: Wrong button press before finished post
As a long time user of Arduino and the various public library I have decided to give back to the the community.

Please note this is my first public release of any library i created.

NXP's PCAL6524 is a 24 bit general purpose GPIO using the I2C buss.
It comes in a  HUQFN32 package and a VFBGA36 package.

This library was tested with the HUQFN32 package on a breakout board.

The 24 GPIO bits are available in 3 banks of 8. P0_0 - P0-7, P1_0 - P1_7, P2_0 - P2_7.

Each pin can be independently set as either a Input or output.


Additionally each pin set as an input can be set to trigger an interrupt pin.
         (This function is not incorporated currently in the library but is planned in the future)
Several other functions are available on the chip but no yet included in the library, including: Logic Inversion, Switch Debounceing, etc...

Each of the NXP can be address with up to 4 different address: 0x20, 0x21, 0x22, 0x23.  The current library is set for 0x22 to be the default address.

This library will allow for individual pins to set as Input or Outputs with the following command:
 .remotepinMode(PIN, MODE);

Each pin set as an output value can be changed with the following command:

 .remotedigitalWrite(PIN, HIGH OR LOW);

Each pin set as an input can be read with the following comand:
 .remotedigtalRead(PIN);

The library can be found on github at the link below:
https://github.com/jrj12591/PCAL6524

The Data Sheet for this IC can be found here:
https://www.nxp.com/docs/en/data-sheet/PCAL6524.pdf

pert

Thanks so much for your contribution to the Arduino community!

I took a quick look at your library, and I have some suggestions:

Move library to the root of the repository. You currently have the library in the PCAL6524 subfolder. This presents a couple of issues: A popular library installation technique is to download the .zip files of the library GitHub generates (Clone or download > Download ZIP or the Releases page) and then use the Arduino IDE's Sketch > Include Library > Add .ZIP Library on the downloaded file. This requires the library to be in the root of the repository, not in a subfolder. If the library is not in the root of the repository this installation technique fails:
Code: [Select]
Specified folder/zip file does not contain a valid library
This is the standard repository structure used in all official Arduino libraries:
https://github.com/arduino-libraries
This move is also required if you wanted to add your library to the Arduino Library Manager index, which provides an even easier installation option.


Remove duplicate example sketch. You currently have a copy of the remoteButton sketch at PCAL6524/remoteButton and at PCAL6524/examples/remoteButton. That will make the example more difficult to maintain and more likely that the duplicate copies will get out of sync.


Remove duplicate source files. You currently have a copy of the PCAL6524.h and PCAL6524.cpp at PCAL6524 and at PCAL6524/scr. That will make the code more difficult to maintain and more likely that the duplicate copies will get out of sync. The "scr" folder appears to have been an attempt to make the library have the 1.5 library format, but that requires this folder to be named "src", not "scr".

jrj12591

Thanks for your advice

I have fixed the repository on the Git hub to move the files to the top level of the repository.

I deleted the remoteButton folder in the top level.  It was never supposed to be there in the first place I apparently forgot to delete it after I moved it to the examples folder.

I also fixed the scr folder to src.  It was an attempt to follow the 1.5 formatting I just fat fingered the name.


If anyone want to take a look at the actual code and has suggestions on how to improve it it would be greatly appreciated.  I enough on how to program to be dangerous but not enough on how to be good.

Go Up