/** * @brief Set the pin mode to input, output or pull-up input (internal 100KΩ pull-up resistor) * @param pin Pin number, it could be all enumeration values (eGPA0-eGPB7/ 0-15) included in ePin_t. * @param mode Mode, it can be set to Input, Output, Pull-up Input (internal 100KΩ pull-up resistor) * @return Return 0 if the setting is successful, otherwise return non-zero. */ int pinMode(ePin_t pin, uint8_t mode); /** * @brief Write digtial pin. The pin needs to be set to output mode before writing. * @param pin Pin number, it could be all enumeration values (eGPA0-eGPB7/ 0-15) inlcuded in ePin_t. * @param level High level 1 or Low level 0 * @return Return 0 if the writing is successful, otherwise return non-zero. */ int digitalWrite(ePin_t pin, uint8_t level); /** * @brief Read digital pin. The pin needs to be set to input mode before reading. * @param pin Pin number, it could be all enumeration values (eGPA0-eGPB7/ 0-15) included in ePin_t. * @return Return High or Low */ int digitalRead(ePin_t pin); /** * @brief Set a pin to interrupt mode * @param pin Pin number, it could be all enumeration values (eGPA0-eGPB7/ 0-15) included in ePin_t. * @param mode Interrupt mode: all enumeration values included in eInterruptMode_t. * @param cb Interrupt service function, needs to be defined and transferred parameter by users. Prototype: void func(int) */ void pinModeInterrupt(ePin_t pin, eInterruptMode_t mode, MCP23017_INT_CB cb); /** * @brief Poll if an interrupt occurs on a port group. * @param group Port group, it could be all enumeration values included in eGPIOGroup_t, GPIO GroupA(eGPIOA), * @n GPIO GroupB(eGPIOB) GroupA+B (eGPIOALL). * @n When setting to eGPIOA,poll if an interrupt occurs on the port group A. * @n When setting to eGPIOB, poll if an interrupt occurs on the port group B. * @n When setting to eGPIOALL, poll if an interrupt occurs on the port group A+B * @n None, poll if an interrupt occurs on the all ports of group A and B by default. */ void pollInterrupts(eGPIOGroup_t group=eGPIOALL); /** * @brief Convert pin into string description * @param pin Pin number, it could be all enumeration values (eGPA0-eGPB7/ 0-15) inlcuded in ePin_t. * @return Return pin description string * @n such as "eGPA0" "eGPA1" "eGPA2" "eGPA3" "eGPA4" "eGPA5" "eGPA6" "eGPA7" * @n "eGPB0" "eGPB1" "eGPB2" "eGPB3" "eGPB4" "eGPB5" "eGPB6" "eGPB7" * @n "eGPA" "eGPB" */ String pinDescription(ePin_t pin); /** * @brief Convert pin into string description * @param pin Pin number, range 0~15 * @return Return pin description string * @n such as "eGPA0" "eGPA1" "eGPA2" "eGPA3" "eGPA4" "eGPA5" "eGPA6" "eGPA7" * @n "eGPB0" "eGPB1" "eGPB2" "eGPB3" "eGPB4" "eGPB5" "eGPB6" "eGPB7" * @n "eGPA" "eGPB" */ String pinDescription(int pin);