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.

46 lines
1.0 KiB

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