qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

gpio_extr.h (1355B)


      1 #pragma once
      2 
      3 #include <stdint.h>
      4 
      5 // clang-format off
      6 
      7 #if defined(__AVR__)
      8 typedef uint8_t     port_data_t;
      9 
     10 #define readPort(port)                 PINx_ADDRESS(port)
     11 
     12 #define setPortBitInput(port, bit)     (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) &= ~_BV((bit)&0xF))
     13 #define setPortBitInputHigh(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) |= _BV((bit)&0xF))
     14 #define setPortBitOutput(port, bit)    (DDRx_ADDRESS(port) |= _BV((bit)&0xF))
     15 
     16 #define writePortBitLow(port, bit)     (PORTx_ADDRESS(port) &= ~_BV((bit)&0xF))
     17 #define writePortBitHigh(port, bit)    (PORTx_ADDRESS(port) |= _BV((bit)&0xF))
     18 
     19 #else
     20 typedef uint16_t     port_data_t;
     21 
     22 #define readPort(qmk_pin)                 palReadPort(PAL_PORT(qmk_pin))
     23 
     24 #define setPortBitInput(qmk_pin, bit)     palSetPadMode(PAL_PORT(qmk_pin), bit, PAL_MODE_INPUT)
     25 #define setPortBitInputHigh(qmk_pin, bit) palSetPadMode(PAL_PORT(qmk_pin), bit, PAL_MODE_INPUT_PULLUP)
     26 #define setPortBitInputLow(qmk_pin, bit)  palSetPadMode(PAL_PORT(qmk_pin), bit, PAL_MODE_INPUT_PULLDOWN)
     27 #define setPortBitOutput(qmk_pin, bit)    palSetPadMode(PAL_PORT(qmk_pin), bit, PAL_MODE_OUTPUT_PUSHPULL)
     28 
     29 #define writePortBitLow(qmk_pin, bit)     palClearLine(PAL_LINE(PAL_PORT(qmk_pin), bit))
     30 #define writePortBitHigh(qmk_pin, bit)    palSetLine(PAL_LINE(PAL_PORT(qmk_pin), bit))
     31 #endif