uint8_t MCP23017::getLastInterruptPinValue(){ uint8_t intPin=getLastInterruptPin(); if(intPin!=MCP23017_INT_ERR){ uint8_t intcapreg=regForPin(intPin,MCP23017_INTCAPA,MCP23017_INTCAPB); uint8_t bit=bitForPin(intPin); return (readRegister(intcapreg)>>bit) & (0x01); }
void MCP23017::digitalWrite(uint8_t pin, uint8_t d) { uint8_t gpio; uint8_t bit=bitForPin(pin); // read the current GPIO output latches uint8_t regAddr=regForPin(pin,MCP23017_OLATA,MCP23017_OLATB); gpio = readRegister(regAddr); // set the pin and direction bit_write(d,gpio,bit); // write the new GPIO regAddr=regForPin(pin,MCP23017_GPIOA,MCP23017_GPIOB); writeRegister(regAddr,gpio); }
/** * Helper to update a single bit of an A/B register. * - Reads the current register value * - Writes the new register value */ void MCP23017::updateRegisterBit(uint8_t pin, uint8_t pValue, uint8_t portAaddr, uint8_t portBaddr) { uint8_t regValue; uint8_t regAddr=regForPin(pin,portAaddr,portBaddr); uint8_t bit=bitForPin(pin); regValue = readRegister(regAddr); // set the value for the particular bit bit_write(pValue,regValue,bit); writeRegister(regAddr,regValue); }
/** * Helper to update a single bit of an A/B register. * - Reads the current register value * - Writes the new register value */ void RFduinoProXShield::updateRegisterBit(uint8_t pin, uint8_t pValue, uint8_t portAaddr, uint8_t portBaddr) { uint8_t regValue; uint8_t regAddr=regForPin(pin,portAaddr,portBaddr); uint8_t bit=bitForPin(pin); regValue = readRegister(regAddr); // set the value for the particular bit bitWrite(regValue,bit,pValue); writeRegister(regAddr,regValue); }
uint8_t MCP23017::digitalRead(uint8_t pin) { uint8_t bit=bitForPin(pin); uint8_t regAddr=regForPin(pin,MCP23017_GPIOA,MCP23017_GPIOB); return (readRegister(regAddr) >> bit) & 0x1; }