Add open-drain GPIO support. (#15282)
* Add open-drain GPIO support. * `qmk format-c` * Wording. * Remove port GPIO implementations as the only board that uses it has its own internal defs anyway. Will wait for first-class handling of ports in core before reimplementing.
This commit is contained in:
parent
f491e6b138
commit
6e40dfa022
4 changed files with 30 additions and 47 deletions
|
@ -25,7 +25,9 @@ typedef uint8_t pin_t;
|
|||
#define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF))
|
||||
#define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
|
||||
#define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low")
|
||||
#define setPinOutput(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF))
|
||||
#define setPinOutputPushPull(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF))
|
||||
#define setPinOutputOpenDrain(pin) _Static_assert(0, "AVR platform does not implement an open-drain output")
|
||||
#define setPinOutput(pin) setPinOutputPushPull(pin)
|
||||
|
||||
#define writePinHigh(pin) (PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
|
||||
#define writePinLow(pin) (PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF))
|
||||
|
@ -34,16 +36,3 @@ typedef uint8_t pin_t;
|
|||
#define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF)))
|
||||
|
||||
#define togglePin(pin) (PORTx_ADDRESS(pin) ^= _BV((pin)&0xF))
|
||||
|
||||
/* Operation of GPIO by port. */
|
||||
|
||||
typedef uint8_t port_data_t;
|
||||
|
||||
#define readPort(port) PINx_ADDRESS(port)
|
||||
|
||||
#define setPortBitInput(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) &= ~_BV((bit)&0xF))
|
||||
#define setPortBitInputHigh(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) |= _BV((bit)&0xF))
|
||||
#define setPortBitOutput(port, bit) (DDRx_ADDRESS(port) |= _BV((bit)&0xF))
|
||||
|
||||
#define writePortBitLow(port, bit) (PORTx_ADDRESS(port) &= ~_BV((bit)&0xF))
|
||||
#define writePortBitHigh(port, bit) (PORTx_ADDRESS(port) |= _BV((bit)&0xF))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue