Commit 35a62370 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Arduino Nano GPIO: Add pinToPort and pinToBitmask helpers

parent b8366cf9
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -39,6 +39,18 @@ class GPIO {
		inline void setup() {
			DDRB = _BV(PB5);
		}
		inline volatile uint8_t * pinToPort(uint8_t pin) {
			if (pin <= pb7) {
				return &PORTB;
			}
			if (pin <= pc6) {
				return &PORTC;
			}
			return &PORTD;
		}
		inline unsigned char pinToBitmask(uint8_t pin) {
			return _BV(pin % 8);
		}
#pragma GCC diagnostic ignored "-Wunused-parameter"
		inline void led_on(unsigned char id) {
			PORTB |= _BV(PB5);