aboutsummaryrefslogtreecommitdiff
path: root/quantum/quantum.h
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2018-11-02 12:31:40 -0400
committerGitHub <noreply@github.com>2018-11-02 12:31:40 -0400
commit15f6278aa623ceda4c220daee1cbedb9e38e6a97 (patch)
treebe1f80786f810c75d0f914899d299c530664d324 /quantum/quantum.h
parent5909d8aef1126357899b687155bfe377914891df (diff)
downloadqmk_firmware-15f6278aa623ceda4c220daee1cbedb9e38e6a97.tar.gz
qmk_firmware-15f6278aa623ceda4c220daee1cbedb9e38e6a97.zip
Add support for Atmega32A to pin declarations and universal matrix (#4015)
* add computed pins from mcu type * update for atmega32a * doc typo * add atmega16 chips, link to references * remove avr include from config * exclude assembler in config.h includes * consolodate options, add 646 * fix typo in pindef
Diffstat (limited to 'quantum/quantum.h')
-rw-r--r--quantum/quantum.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 1d3ee033f..fe670c8eb 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -140,26 +140,28 @@ extern uint32_t default_layer_state;
140 140
141//Function substitutions to ease GPIO manipulation 141//Function substitutions to ease GPIO manipulation
142#ifdef __AVR__ 142#ifdef __AVR__
143 #define PIN_ADDRESS(p, offset) _SFR_IO8(ADDRESS_BASE + (p >> PORT_SHIFTER) + offset)
144
143 #define pin_t uint8_t 145 #define pin_t uint8_t
144 #define setPinInput(pin) _SFR_IO8((pin >> 4) + 1) &= ~ _BV(pin & 0xF) 146 #define setPinInput(pin) PIN_ADDRESS(pin, 1) &= ~ _BV(pin & 0xF)
145 #define setPinInputHigh(pin) ({\ 147 #define setPinInputHigh(pin) ({\
146 _SFR_IO8((pin >> 4) + 1) &= ~ _BV(pin & 0xF);\ 148 PIN_ADDRESS(pin, 1) &= ~ _BV(pin & 0xF);\
147 _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF);\ 149 PIN_ADDRESS(pin, 2) |= _BV(pin & 0xF);\
148 }) 150 })
149 #define setPinInputLow(pin) _Static_assert(0, "AVR Processors cannot impliment an input as pull low") 151 #define setPinInputLow(pin) _Static_assert(0, "AVR Processors cannot impliment an input as pull low")
150 #define setPinOutput(pin) _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF) 152 #define setPinOutput(pin) PIN_ADDRESS(pin, 1) |= _BV(pin & 0xF)
151 153
152 #define writePinHigh(pin) _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF) 154 #define writePinHigh(pin) PIN_ADDRESS(pin, 2) |= _BV(pin & 0xF)
153 #define writePinLow(pin) _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF) 155 #define writePinLow(pin) PIN_ADDRESS(pin, 2) &= ~_BV(pin & 0xF)
154 static inline void writePin(pin_t pin, uint8_t level){ 156 static inline void writePin(pin_t pin, uint8_t level){
155 if (level){ 157 if (level){
156 _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); 158 PIN_ADDRESS(pin, 2) |= _BV(pin & 0xF);
157 } else { 159 } else {
158 _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); 160 PIN_ADDRESS(pin, 2) &= ~_BV(pin & 0xF);
159 } 161 }
160 } 162 }
161 163
162 #define readPin(pin) (_SFR_IO8(pin >> 4) & _BV(pin & 0xF)) 164 #define readPin(pin) (PIN_ADDRESS(pin, 0) & _BV(pin & 0xF))
163#elif defined(PROTOCOL_CHIBIOS) 165#elif defined(PROTOCOL_CHIBIOS)
164 #define pin_t ioline_t 166 #define pin_t ioline_t
165 #define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT) 167 #define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT)