Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB

  1. /*
  2. MCP23S08 MODULE
  3. Copyright (C) 2020 by Eddi De Pieri <eddi at depieri dot com>
  4. Adapted from https://github.com/kmpelectronics/Arduino
  5. Copyright (C) 2016 Plamen Kovandjiev <p.kovandiev@kmpelectronics.eu> & Dimitar Antonov <d.antonov@kmpelectronics.eu>
  6. (ref. https://github.com/kmpelectronics/Arduino/blob/master/ProDinoWiFiEsp/src/PRODINoESP8266/src/KMPDinoWiFiESP.cpp)
  7. */
  8. #pragma once
  9. #ifndef MCP23S08_H
  10. #define MCP23S08_H
  11. #include "espurna.h"
  12. #include "libs/BasePin.h"
  13. #if MCP23S08_SUPPORT
  14. constexpr size_t McpGpioPins = 8;
  15. // real hardware pin
  16. class McpGpioPin final : public BasePin {
  17. public:
  18. explicit McpGpioPin(unsigned char pin);
  19. void pinMode(int8_t mode);
  20. void digitalWrite(int8_t val);
  21. int digitalRead();
  22. };
  23. void MCP23S08Setup();
  24. uint8_t MCP23S08ReadRegister(uint8_t address);
  25. void MCP23S08WriteRegister(uint8_t address, uint8_t data);
  26. void MCP23S08SetDirection(uint8_t pinNumber, uint8_t mode);
  27. void MCP23S08SetPin(uint8_t pinNumber, bool state);
  28. bool MCP23S08GetPin(uint8_t pinNumber);
  29. bool mcpGpioValid(unsigned char gpio);
  30. #endif // MCP23S08_SUPPORT == 1
  31. #endif