doxyclang

This commit is contained in:
lady ada 2022-06-25 21:17:09 -04:00
parent 5125079021
commit e7d9d0162a
2 changed files with 33 additions and 5 deletions

View file

@ -47,7 +47,7 @@ Adafruit_PCF8574::Adafruit_PCF8574(void) {}
* @return True if initialization was successful, otherwise false. * @return True if initialization was successful, otherwise false.
*/ */
bool Adafruit_PCF8574::begin(uint8_t i2c_address, TwoWire *wire) { bool Adafruit_PCF8574::begin(uint8_t i2c_address, TwoWire *wire) {
delete(i2c_dev); delete (i2c_dev);
i2c_dev = new Adafruit_I2CDevice(i2c_address, wire); i2c_dev = new Adafruit_I2CDevice(i2c_address, wire);
@ -58,17 +58,33 @@ bool Adafruit_PCF8574::begin(uint8_t i2c_address, TwoWire *wire) {
return true; return true;
} }
/*!
* @brief Write one 'byte' of data directly to the GPIO control register
* @param d The data to write
* @return True if we were able to write the data successfully over I2C
*/
bool Adafruit_PCF8574::digitalWriteByte(uint8_t d) { bool Adafruit_PCF8574::digitalWriteByte(uint8_t d) {
_writebuf = d; _writebuf = d;
return i2c_dev->write(&_writebuf, 1); return i2c_dev->write(&_writebuf, 1);
} }
/*!
* @brief Read one 'byte' of data directly from the GPIO control register
* @return The byte of data read from the device
*/
uint8_t Adafruit_PCF8574::digitalReadByte(void) { uint8_t Adafruit_PCF8574::digitalReadByte(void) {
i2c_dev->read(&_readbuf, 1); i2c_dev->read(&_readbuf, 1);
return _readbuf; return _readbuf;
} }
/*!
* @brief Set one GPIO expander pin to 'high' (weak pullup) or 'low'
* (grounded)
* @param pinnum The GPIO pin number, from 0 to 7 inclusive
* @param val The boolean value to write: true means activate the pullup
* and false means turn on the sinking transistor.
* @return True if we were able to write the data successfully over I2C
*/
bool Adafruit_PCF8574::digitalWrite(uint8_t pinnum, bool val) { bool Adafruit_PCF8574::digitalWrite(uint8_t pinnum, bool val) {
if (val) { if (val) {
_writebuf |= 1 << pinnum; _writebuf |= 1 << pinnum;
@ -78,7 +94,15 @@ bool Adafruit_PCF8574::digitalWrite(uint8_t pinnum, bool val) {
return i2c_dev->write(&_writebuf, 1); return i2c_dev->write(&_writebuf, 1);
} }
/*!
* @brief Set one GPIO expander pin to 'output' (grounded) or 'input' (weak
* pullup)
* @param pinnum The GPIO pin number, from 0 to 7 inclusive
* @param val The value to write: INPUT or INPUT_PULLUP means activate the
* pullup and OUTPUT means turn on the sinking transistor, as this is an open
* drain device
* @return True if we were able to write the data successfully over I2C
*/
bool Adafruit_PCF8574::pinMode(uint8_t pinnum, uint8_t val) { bool Adafruit_PCF8574::pinMode(uint8_t pinnum, uint8_t val) {
if ((val == INPUT) || (val == INPUT_PULLUP)) { if ((val == INPUT) || (val == INPUT_PULLUP)) {
_writebuf |= 1 << pinnum; _writebuf |= 1 << pinnum;
@ -88,7 +112,12 @@ bool Adafruit_PCF8574::pinMode(uint8_t pinnum, uint8_t val) {
return i2c_dev->write(&_writebuf, 1); return i2c_dev->write(&_writebuf, 1);
} }
/*!
* @brief Get a GPIO expander pin value
* @param pinnum The GPIO pin number, from 0 to 7 inclusive
* @return True if the pin logic is NOT ground, false if the pin logic is
* ground
*/
bool Adafruit_PCF8574::digitalRead(uint8_t pinnum) { bool Adafruit_PCF8574::digitalRead(uint8_t pinnum) {
i2c_dev->read(&_readbuf, 1); i2c_dev->read(&_readbuf, 1);
return (_readbuf >> pinnum) & 0x1; return (_readbuf >> pinnum) & 0x1;

View file

@ -25,7 +25,6 @@
#define PCF8574_I2CADDR_DEFAULT 0x20 ///< DS3502 default I2C address #define PCF8574_I2CADDR_DEFAULT 0x20 ///< DS3502 default I2C address
/*! /*!
* @brief Class that stores state and functions for interacting with * @brief Class that stores state and functions for interacting with
* the PCF8574 I2C Expander * the PCF8574 I2C Expander