diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-11-20 11:39:42 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-11-20 12:58:33 -0500 |
commit | bf92ffb5bff9eedb36df697397b9a6ae27bc168e (patch) | |
tree | fbbee2fdbfd88aeb047907a707b8e53deb55b784 /src/avr/internal.h | |
parent | 2cc0313b721597238d0774a40a4bcee7e838558a (diff) | |
download | kutter-bf92ffb5bff9eedb36df697397b9a6ae27bc168e.tar.gz kutter-bf92ffb5bff9eedb36df697397b9a6ae27bc168e.tar.xz kutter-bf92ffb5bff9eedb36df697397b9a6ae27bc168e.zip |
avr: Split gpio.c into gpio.c, adc.c, hard_pwm.c, and spi.c
Split up gpio.c into multiple files in an effort to make the code a
little more understandable.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/avr/internal.h')
-rw-r--r-- | src/avr/internal.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/avr/internal.h b/src/avr/internal.h new file mode 100644 index 00000000..ab800864 --- /dev/null +++ b/src/avr/internal.h @@ -0,0 +1,18 @@ +#ifndef __AVR_INTERNAL_H +#define __AVR_INTERNAL_H +// Local definitions for avr code + +#define GPIO(PORT, NUM) (((PORT)-'A') * 8 + (NUM)) +#define GPIO2PORT(PIN) ((PIN) / 8) +#define GPIO2BIT(PIN) (1<<((PIN) % 8)) + +struct gpio_digital_regs { + // gcc (pre v6) does better optimization when uint8_t are bitfields + volatile uint8_t in : 8, mode : 8, out : 8; +}; +extern volatile uint8_t * const digital_regs[]; + +#define GPIO2REGS(pin) \ + ((struct gpio_digital_regs*)READP(digital_regs[GPIO2PORT(pin)])) + +#endif // internal.h |