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.

39 lines
866 B

#ifndef _PCA9555_H_
#define _PCA9555_H_
#include <iostream>
#include "../../communication/i2c/i2c.hpp"
#define PCA9555_ADDR 0x20 // Device Adress
#define PCA9555_INPUT_PORT_0_REG 0x00
#define PCA9555_INPUT_PORT_1_REG 0x01
#define PCA9555_OUTPUT_PORT_0_REG 0x02
#define PCA9555_OUTPUT_PORT_1_REG 0x03
#define PCA9555_POLARITY_INV_0_REG 0x04
#define PCA9555_POLARITY_INV_1_REG 0x05
#define PCA9555_CONFIG_0_REG 0x06
#define PCA9555_CONFIG_1_REG 0x07
class Pca9555
{
public:
Pca9555(I2C *i2c);
uint8_t readPin(uint8_t pin);
void setPin(uint8_t pin, uint8_t direction); // 1 = input 0 = output
void setPinPolarity(uint8_t pin, uint8_t polarity); // 1 = Inverted 0 = Normal
uint8_t getInterrupt();
void setAllOut();
void setAllIn();
private:
I2C* i2c_pca9555;
uint8_t intPinSrc;
uint8_t intPinDir;
uint8_t intPinPol;
};
#endif