diff options
Diffstat (limited to 'include/arduino-nano/driver/gpio.h')
-rw-r--r-- | include/arduino-nano/driver/gpio.h | 111 |
1 files changed, 0 insertions, 111 deletions
diff --git a/include/arduino-nano/driver/gpio.h b/include/arduino-nano/driver/gpio.h deleted file mode 100644 index 6acf977..0000000 --- a/include/arduino-nano/driver/gpio.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef GPIO_H -#define GPIO_H - -#include <avr/io.h> - -class GPIO { - private: - GPIO(const GPIO ©); - - public: - GPIO () {} - - enum Pin : unsigned char { - pb0 = 8, - pb1 = 9, - pb2 = 10, - pb3 = 11, - pb4 = 12, - pb5 = 13, - pb6 = 14, - pb7 = 15, - pc0 = 16, - pc1 = 17, - pc2 = 18, - pc3 = 19, - pc4 = 20, - pc5 = 21, - pc6 = 22, - pd0 = 24, - pd1 = 25, - pd2 = 26, - pd3 = 27, - pd4 = 28, - pd5 = 29, - pd6 = 30, - pd7 = 31 - }; - - inline void setup() { - DDRB = _BV(PB5); - } - inline void led_on(unsigned char id) { - PORTB |= _BV(PB5); - } - inline void led_off(unsigned char id) { - PORTB &= ~_BV(PB5); - } - inline void led_toggle(unsigned char id) { - PINB = _BV(PB5); - } - inline void input(unsigned char const pin) { - if (pin < 8) { - } else if (pin < 16) { - DDRB &= ~_BV(pin - 8); - } else if (pin < 24) { - DDRC &= ~_BV(pin - 16); - } else if (pin < 32) { - DDRD &= ~_BV(pin - 24); - } - } - inline void output(unsigned char const pin) { - if (pin < 8) { - } else if (pin < 16) { - DDRB |= _BV(pin - 8); - } else if (pin < 24) { - DDRC |= _BV(pin - 16); - } else if (pin < 32) { - DDRD |= _BV(pin - 24); - } - } - inline unsigned char read(unsigned char const pin) { - if (pin < 8) { - } - if (pin < 16) { - return (PINB & _BV(pin - 8)); - } - if (pin < 24) { - return (PINC & _BV(pin - 16)); - } - if (pin < 32) { - return (PIND & _BV(pin - 24)); - } - return 0; - } - inline void write(unsigned char const pin, unsigned char value) { - if (pin < 8) { - } else if (pin < 16) { - if (value) { - PORTB |= _BV(pin - 8); - } else { - PORTB &= ~_BV(pin - 8); - } - } else if (pin < 24) { - if (value) { - PORTB |= _BV(pin - 16); - } else { - PORTB &= ~_BV(pin - 16); - } - } else if (pin < 32) { - if (value) { - PORTB |= _BV(pin - 24); - } else { - PORTB &= ~_BV(pin - 24); - } - } - } -}; - -extern GPIO gpio; - -#endif |