PCA9554.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /***************************************************************************
  2. Title: PCA9554
  3. by: AD0ND
  4. This file is free software; you can redistribute it and/or modify
  5. it under the terms of either the GNU General Public License version 2
  6. or the GNU Lesser General Public License version 2.1, both as
  7. published by the Free Software Foundation.
  8. ***************************************************************************/
  9. #ifndef PCA9554_h
  10. #define PCA9554_h
  11. #include <Arduino.h>
  12. #include <Wire.h>
  13. //PCA9554 Command Byte
  14. #define INPUTPORT0 0x00
  15. #define OUTPUTPORT0 0x01
  16. #define POLINVPORT0 0x02
  17. #define CONFIGPORT0 0x03
  18. #define ALLOUTPUT 0x00
  19. #define ALLINPUT 0xFF
  20. class PCA9554
  21. {
  22. public :
  23. PCA9554(byte SlaveAddress);
  24. bool twiRead(byte &registerAddress);
  25. bool twiWrite(byte registerAddress, byte dataWrite);
  26. bool pinMode0(byte pinNumber, bool state);
  27. bool portMode0(byte value);
  28. bool digitalWrite0(byte pinNumber, bool state);
  29. bool digitalWritePort0(byte value);
  30. bool digitalRead0(byte &pinNumber);
  31. bool digitalReadPort0(byte &value);
  32. private :
  33. int _SlaveAddress;
  34. };
  35. #endif