20 #if !defined(_usb_h_) || defined(_avrpins_h_) 21 #error "Never include avrpins.h directly; include Usb.h instead" 28 #define pgm_read_pointer(p) pgm_read_word(p) 31 #if !defined(BOARD_MEGA_ADK) && defined(__AVR_ATmega2560__) && (USE_UHS_MEGA_ADK || defined(ARDUINO_AVR_ADK)) 32 #define BOARD_MEGA_ADK 33 #elif !defined(BOARD_BLACK_WIDDOW) && USE_UHS_BLACK_WIDDOW 34 #define BOARD_BLACK_WIDDOW 89 #define MAKE_PORT(portName, ddrName, pinName, className, ID) \ 92 typedef uint8_t DataT;\ 94 static void Write(DataT value){portName = value;}\ 95 static void ClearAndSet(DataT clearMask, DataT value){portName = (portName & ~clearMask) | value;}\ 96 static DataT Read(){return portName;}\ 97 static void DirWrite(DataT value){ddrName = value;}\ 98 static DataT DirRead(){return ddrName;}\ 99 static void Set(DataT value){portName |= value;}\ 100 static void Clear(DataT value){portName &= ~value;}\ 101 static void Toggle(DataT value){portName ^= value;}\ 102 static void DirSet(DataT value){ddrName |= value;}\ 103 static void DirClear(DataT value){ddrName &= ~value;}\ 104 static void DirToggle(DataT value){ddrName ^= value;}\ 105 static DataT PinRead(){return pinName;}\ 107 enum{Width=sizeof(DataT)*8};\ 111 #define MAKE_TCCR(TccrName, className) \ 114 typedef uint8_t DataT;\ 116 static void Write(DataT value){TccrName = value;}\ 117 static void ClearAndSet(DataT clearMask, DataT value){TccrName = (TccrName & ~clearMask) | value;}\ 118 static DataT Read(){return TccrName;}\ 119 static void Set(DataT value){TccrName |= value;}\ 120 static void Clear(DataT value){TccrName &= ~value;}\ 121 static void Toggle(DataT value){TccrName ^= value;}\ 122 enum{Width=sizeof(DataT)*8};\ 127 MAKE_PORT(PORTA, DDRA, PINA, Porta,
'A')
130 MAKE_PORT(PORTB, DDRB, PINB, Portb,
'B')
133 MAKE_PORT(PORTC, DDRC, PINC, Portc,
'C')
136 MAKE_PORT(PORTD, DDRD, PIND, Portd,
'D')
139 MAKE_PORT(PORTE, DDRE, PINE, Porte,
'E')
142 MAKE_PORT(PORTF, DDRF, PINF, Portf,
'F')
145 MAKE_PORT(PORTG, DDRG, PING, Portg,
'G')
148 MAKE_PORT(PORTH, DDRH, PINH, Porth,
'H')
151 MAKE_PORT(PORTJ, DDRJ, PINJ, Portj,
'J')
154 MAKE_PORT(PORTK, DDRK, PINK, Portk,
'K')
157 MAKE_PORT(PORTL, DDRL, PINL, Portl,
'L')
160 MAKE_PORT(PORTQ, DDRQ, PINQ, Portq,
'Q')
163 MAKE_PORT(PORTR, DDRR, PINR, Portr,
'R')
167 MAKE_TCCR(TCCR0A, Tccr0a)
170 MAKE_TCCR(TCCR1A, Tccr1a)
173 MAKE_TCCR(TCCR2A, Tccr2a)
178 template<
typename PORT, u
int8_t PIN>
192 static void Set(uint8_t val) {
198 static void SetDir(uint8_t val) {
204 static void Clear() {
205 PORT::Clear(1 << PIN);
208 static void Toggle() {
209 PORT::Toggle(1 << PIN);
212 static void SetDirRead() {
213 PORT::DirClear(1 << PIN);
216 static void SetDirWrite() {
217 PORT::DirSet(1 << PIN);
220 static uint8_t IsSet() {
221 return PORT::PinRead() & (uint8_t)(1 << PIN);
224 static void WaiteForSet() {
225 while(IsSet() == 0) {
229 static void WaiteForClear() {
239 template<
typename TCCR, u
int8_t COM>
253 static void Clear() {
254 TCCR::Clear(1 << COM);
257 static void Toggle() {
258 TCCR::Toggle(1 << COM);
264 typedef TPin<Porta, 0 > Pa0;
265 typedef TPin<Porta, 1 > Pa1;
266 typedef TPin<Porta, 2 > Pa2;
267 typedef TPin<Porta, 3 > Pa3;
268 typedef TPin<Porta, 4 > Pa4;
269 typedef TPin<Porta, 5 > Pa5;
270 typedef TPin<Porta, 6 > Pa6;
271 typedef TPin<Porta, 7 > Pa7;
275 typedef TPin<Portb, 0 > Pb0;
276 typedef TPin<Portb, 1 > Pb1;
277 typedef TPin<Portb, 2 > Pb2;
278 typedef TPin<Portb, 3 > Pb3;
279 typedef TPin<Portb, 4 > Pb4;
280 typedef TPin<Portb, 5 > Pb5;
281 typedef TPin<Portb, 6 > Pb6;
282 typedef TPin<Portb, 7 > Pb7;
286 typedef TPin<Portc, 0 > Pc0;
287 typedef TPin<Portc, 1 > Pc1;
288 typedef TPin<Portc, 2 > Pc2;
289 typedef TPin<Portc, 3 > Pc3;
290 typedef TPin<Portc, 4 > Pc4;
291 typedef TPin<Portc, 5 > Pc5;
292 typedef TPin<Portc, 6 > Pc6;
293 typedef TPin<Portc, 7 > Pc7;
297 typedef TPin<Portd, 0 > Pd0;
298 typedef TPin<Portd, 1 > Pd1;
299 typedef TPin<Portd, 2 > Pd2;
300 typedef TPin<Portd, 3 > Pd3;
301 typedef TPin<Portd, 4 > Pd4;
302 typedef TPin<Portd, 5 > Pd5;
303 typedef TPin<Portd, 6 > Pd6;
304 typedef TPin<Portd, 7 > Pd7;
308 typedef TPin<Porte, 0 > Pe0;
309 typedef TPin<Porte, 1 > Pe1;
310 typedef TPin<Porte, 2 > Pe2;
311 typedef TPin<Porte, 3 > Pe3;
312 typedef TPin<Porte, 4 > Pe4;
313 typedef TPin<Porte, 5 > Pe5;
314 typedef TPin<Porte, 6 > Pe6;
315 typedef TPin<Porte, 7 > Pe7;
319 typedef TPin<Portf, 0 > Pf0;
320 typedef TPin<Portf, 1 > Pf1;
321 typedef TPin<Portf, 2 > Pf2;
322 typedef TPin<Portf, 3 > Pf3;
323 typedef TPin<Portf, 4 > Pf4;
324 typedef TPin<Portf, 5 > Pf5;
325 typedef TPin<Portf, 6 > Pf6;
326 typedef TPin<Portf, 7 > Pf7;
330 typedef TPin<Portg, 0 > Pg0;
331 typedef TPin<Portg, 1 > Pg1;
332 typedef TPin<Portg, 2 > Pg2;
333 typedef TPin<Portg, 3 > Pg3;
334 typedef TPin<Portg, 4 > Pg4;
335 typedef TPin<Portg, 5 > Pg5;
336 typedef TPin<Portg, 6 > Pg6;
337 typedef TPin<Portg, 7 > Pg7;
341 typedef TPin<Porth, 0 > Ph0;
342 typedef TPin<Porth, 1 > Ph1;
343 typedef TPin<Porth, 2 > Ph2;
344 typedef TPin<Porth, 3 > Ph3;
345 typedef TPin<Porth, 4 > Ph4;
346 typedef TPin<Porth, 5 > Ph5;
347 typedef TPin<Porth, 6 > Ph6;
348 typedef TPin<Porth, 7 > Ph7;
352 typedef TPin<Portj, 0 > Pj0;
353 typedef TPin<Portj, 1 > Pj1;
354 typedef TPin<Portj, 2 > Pj2;
355 typedef TPin<Portj, 3 > Pj3;
356 typedef TPin<Portj, 4 > Pj4;
357 typedef TPin<Portj, 5 > Pj5;
358 typedef TPin<Portj, 6 > Pj6;
359 typedef TPin<Portj, 7 > Pj7;
363 typedef TPin<Portk, 0 > Pk0;
364 typedef TPin<Portk, 1 > Pk1;
365 typedef TPin<Portk, 2 > Pk2;
366 typedef TPin<Portk, 3 > Pk3;
367 typedef TPin<Portk, 4 > Pk4;
368 typedef TPin<Portk, 5 > Pk5;
369 typedef TPin<Portk, 6 > Pk6;
370 typedef TPin<Portk, 7 > Pk7;
374 typedef TPin<Portl, 0 > Pl0;
375 typedef TPin<Portl, 1 > Pl1;
376 typedef TPin<Portl, 2 > Pl2;
377 typedef TPin<Portl, 3 > Pl3;
378 typedef TPin<Portl, 4 > Pl4;
379 typedef TPin<Portl, 5 > Pl5;
380 typedef TPin<Portl, 6 > Pl6;
381 typedef TPin<Portl, 7 > Pl7;
385 typedef TPin<Portq, 0 > Pq0;
386 typedef TPin<Portq, 1 > Pq1;
387 typedef TPin<Portq, 2 > Pq2;
388 typedef TPin<Portq, 3 > Pq3;
389 typedef TPin<Portq, 4 > Pq4;
390 typedef TPin<Portq, 5 > Pq5;
391 typedef TPin<Portq, 6 > Pq6;
392 typedef TPin<Portq, 7 > Pq7;
396 typedef TPin<Portr, 0 > Pr0;
397 typedef TPin<Portr, 1 > Pr1;
398 typedef TPin<Portr, 2 > Pr2;
399 typedef TPin<Portr, 3 > Pr3;
400 typedef TPin<Portr, 4 > Pr4;
401 typedef TPin<Portr, 5 > Pr5;
402 typedef TPin<Portr, 6 > Pr6;
403 typedef TPin<Portr, 7 > Pr7;
407 typedef TCom<Tccr0a, COM0A1> Tc0a;
408 typedef TCom<Tccr0a, COM0B1> Tc0b;
412 typedef TCom<Tccr1a, COM1A1> Tc1a;
413 typedef TCom<Tccr1a, COM1B1> Tc1b;
417 typedef TCom<Tccr2a, COM2A1> Tc2a;
418 typedef TCom<Tccr2a, COM2B1> Tc2b;
421 template<
typename Tp_pin,
typename Tc_bit>
425 static void SetDir(uint8_t val) {
431 static void SetDirRead() {
432 Tp_pin::SetDirRead();
436 static void SetDirWrite() {
437 Tp_pin::SetDirWrite();
452 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 514 #ifdef BOARD_MEGA_ADK // These pins are not broken out on the Arduino ADK 515 #define P54 Pe6 // INT on Arduino ADK 516 #define P55 Pj2 // MAX_RESET on Arduino ADK 521 #elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) 549 #elif defined(CORE_TEENSY) && defined(__AVR_ATmega32U4__) 579 #elif defined(__AVR_ATmega32U4__) 582 #define P0 Pd2 // D0 - PD2 583 #define P1 Pd3 // D1 - PD3 584 #define P2 Pd1 // D2 - PD1 585 #define P3 Pd0 // D3 - PD0 586 #define P4 Pd4 // D4 - PD4 587 #define P5 Pc6 // D5 - PC6 588 #define P6 Pd7 // D6 - PD7 589 #define P7 Pe6 // D7 - PE6 591 #define P8 Pb4 // D8 - PB4 592 #define P9 Pb5 // D9 - PB5 593 #define P10 Pb6 // D10 - PB6 594 #define P11 Pb7 // D11 - PB7 595 #define P12 Pd6 // D12 - PD6 596 #define P13 Pc7 // D13 - PC7 598 #define P14 Pb3 // D14 - MISO - PB3 599 #define P15 Pb1 // D15 - SCK - PB1 600 #define P16 Pb2 // D16 - MOSI - PB2 601 #define P17 Pb0 // D17 - SS - PB0 603 #define P18 Pf7 // D18 - A0 - PF7 604 #define P19 Pf6 // D19 - A1 - PF6 605 #define P20 Pf5 // D20 - A2 - PF5 606 #define P21 Pf4 // D21 - A3 - PF4 607 #define P22 Pf1 // D22 - A4 - PF1 608 #define P23 Pf0 // D23 - A5 - PF0 610 #define P24 Pd4 // D24 / D4 - A6 - PD4 611 #define P25 Pd7 // D25 / D6 - A7 - PD7 612 #define P26 Pb4 // D26 / D8 - A8 - PB4 613 #define P27 Pb5 // D27 / D9 - A9 - PB5 614 #define P28 Pb6 // D28 / D10 - A10 - PB6 615 #define P29 Pd6 // D29 / D12 - A11 - PD6 619 #elif defined(CORE_TEENSY) && (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) 670 #elif defined(ARDUINO_AVR_BALANDUINO) && (defined(__AVR_ATmega644__) || defined(__AVR_ATmega1284P__)) 676 #if BALANDUINO_REVISION < 13 698 #if BALANDUINO_REVISION < 13 723 #elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) 762 #error "Please define board in avrpins.h" 764 #endif // Arduino pin definitions 766 #elif defined(__arm__) 769 #define pgm_read_pointer(p) pgm_read_dword(p) 771 #if defined(CORE_TEENSY) && (defined(__MK20DX128__) || defined(__MK20DX256__)) 773 #include "core_pins.h" 774 #include "avr_emulation.h" 776 #define GPIO_BITBAND_ADDR(reg, bit) (((uint32_t)&(reg) - 0x40000000) * 32 + (bit) * 4 + 0x42000000) 777 #define GPIO_BITBAND_PTR(reg, bit) ((uint8_t *)GPIO_BITBAND_ADDR((reg), (bit))) 779 #define MAKE_PIN(className, baseReg, pinNum, configReg) \ 782 static void Set() { \ 783 *GPIO_BITBAND_PTR(baseReg, pinNum) = 1; \ 785 static void Clear() { \ 786 *GPIO_BITBAND_PTR(baseReg, pinNum) = 0; \ 788 static void SetDirRead() { \ 789 configReg = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1); \ 790 *(GPIO_BITBAND_PTR(baseReg, pinNum) + 640) = 0; \ 792 static void SetDirWrite() { \ 793 configReg = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1); \ 794 *(GPIO_BITBAND_PTR(baseReg, pinNum) + 640) = 1; \ 796 static uint8_t IsSet() { \ 797 return *(GPIO_BITBAND_PTR(baseReg, pinNum) + 512); \ 801 MAKE_PIN(P0, CORE_PIN0_PORTREG, CORE_PIN0_BIT, CORE_PIN0_CONFIG);
802 MAKE_PIN(P1, CORE_PIN1_PORTREG, CORE_PIN1_BIT, CORE_PIN1_CONFIG);
803 MAKE_PIN(P2, CORE_PIN2_PORTREG, CORE_PIN2_BIT, CORE_PIN2_CONFIG);
804 MAKE_PIN(P3, CORE_PIN3_PORTREG, CORE_PIN3_BIT, CORE_PIN3_CONFIG);
805 MAKE_PIN(P4, CORE_PIN4_PORTREG, CORE_PIN4_BIT, CORE_PIN4_CONFIG);
806 MAKE_PIN(P5, CORE_PIN5_PORTREG, CORE_PIN5_BIT, CORE_PIN5_CONFIG);
807 MAKE_PIN(P6, CORE_PIN6_PORTREG, CORE_PIN6_BIT, CORE_PIN6_CONFIG);
808 MAKE_PIN(P7, CORE_PIN7_PORTREG, CORE_PIN7_BIT, CORE_PIN7_CONFIG);
809 MAKE_PIN(P8, CORE_PIN8_PORTREG, CORE_PIN8_BIT, CORE_PIN8_CONFIG);
810 MAKE_PIN(P9, CORE_PIN9_PORTREG, CORE_PIN9_BIT, CORE_PIN9_CONFIG);
811 MAKE_PIN(P10, CORE_PIN10_PORTREG, CORE_PIN10_BIT, CORE_PIN10_CONFIG);
812 MAKE_PIN(P11, CORE_PIN11_PORTREG, CORE_PIN11_BIT, CORE_PIN11_CONFIG);
813 MAKE_PIN(P12, CORE_PIN12_PORTREG, CORE_PIN12_BIT, CORE_PIN12_CONFIG);
814 MAKE_PIN(P13, CORE_PIN13_PORTREG, CORE_PIN13_BIT, CORE_PIN13_CONFIG);
815 MAKE_PIN(P14, CORE_PIN14_PORTREG, CORE_PIN14_BIT, CORE_PIN14_CONFIG);
816 MAKE_PIN(P15, CORE_PIN15_PORTREG, CORE_PIN15_BIT, CORE_PIN15_CONFIG);
817 MAKE_PIN(P16, CORE_PIN16_PORTREG, CORE_PIN16_BIT, CORE_PIN16_CONFIG);
818 MAKE_PIN(P17, CORE_PIN17_PORTREG, CORE_PIN17_BIT, CORE_PIN17_CONFIG);
819 MAKE_PIN(P18, CORE_PIN18_PORTREG, CORE_PIN18_BIT, CORE_PIN18_CONFIG);
820 MAKE_PIN(P19, CORE_PIN19_PORTREG, CORE_PIN19_BIT, CORE_PIN19_CONFIG);
821 MAKE_PIN(P20, CORE_PIN20_PORTREG, CORE_PIN20_BIT, CORE_PIN20_CONFIG);
822 MAKE_PIN(P21, CORE_PIN21_PORTREG, CORE_PIN21_BIT, CORE_PIN21_CONFIG);
823 MAKE_PIN(P22, CORE_PIN22_PORTREG, CORE_PIN22_BIT, CORE_PIN22_CONFIG);
824 MAKE_PIN(P23, CORE_PIN23_PORTREG, CORE_PIN23_BIT, CORE_PIN23_CONFIG);
825 MAKE_PIN(P24, CORE_PIN24_PORTREG, CORE_PIN24_BIT, CORE_PIN24_CONFIG);
826 MAKE_PIN(P25, CORE_PIN25_PORTREG, CORE_PIN25_BIT, CORE_PIN25_CONFIG);
827 MAKE_PIN(P26, CORE_PIN26_PORTREG, CORE_PIN26_BIT, CORE_PIN26_CONFIG);
828 MAKE_PIN(P27, CORE_PIN27_PORTREG, CORE_PIN27_BIT, CORE_PIN27_CONFIG);
829 MAKE_PIN(P28, CORE_PIN28_PORTREG, CORE_PIN28_BIT, CORE_PIN28_CONFIG);
830 MAKE_PIN(P29, CORE_PIN29_PORTREG, CORE_PIN29_BIT, CORE_PIN29_CONFIG);
831 MAKE_PIN(P30, CORE_PIN30_PORTREG, CORE_PIN30_BIT, CORE_PIN30_CONFIG);
832 MAKE_PIN(P31, CORE_PIN31_PORTREG, CORE_PIN31_BIT, CORE_PIN31_CONFIG);
833 MAKE_PIN(P32, CORE_PIN32_PORTREG, CORE_PIN32_BIT, CORE_PIN32_CONFIG);
834 MAKE_PIN(P33, CORE_PIN33_PORTREG, CORE_PIN33_BIT, CORE_PIN33_CONFIG);
838 #elif defined(CORE_TEENSY) && (defined(__MKL26Z64__)) 847 #include "core_pins.h" 848 #include "avr_emulation.h" 850 #define MAKE_PIN(className, baseReg, pinNum, configReg) \ 853 static void Set() { \ 854 *portSetRegister(pinNum) = digitalPinToBitMask(pinNum); \ 856 static void Clear() { \ 857 *portClearRegister(pinNum) = digitalPinToBitMask(pinNum); \ 859 static void SetDirRead() { \ 860 configReg = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1); \ 861 *portModeRegister(pinNum) &= ~digitalPinToBitMask(pinNum); \ 863 static void SetDirWrite() { \ 864 configReg = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1); \ 865 *portModeRegister(pinNum) |= digitalPinToBitMask(pinNum); \ 867 static uint8_t IsSet() { \ 868 return (*portInputRegister(pinNum) & digitalPinToBitMask(pinNum)) ? 1 : 0; \ 872 MAKE_PIN(P0, CORE_PIN0_PORTREG, 0, CORE_PIN0_CONFIG);
873 MAKE_PIN(P1, CORE_PIN1_PORTREG, 1, CORE_PIN1_CONFIG);
874 MAKE_PIN(P2, CORE_PIN2_PORTREG, 2, CORE_PIN2_CONFIG);
875 MAKE_PIN(P3, CORE_PIN3_PORTREG, 3, CORE_PIN3_CONFIG);
876 MAKE_PIN(P4, CORE_PIN4_PORTREG, 4, CORE_PIN4_CONFIG);
877 MAKE_PIN(P5, CORE_PIN5_PORTREG, 5, CORE_PIN5_CONFIG);
878 MAKE_PIN(P6, CORE_PIN6_PORTREG, 6, CORE_PIN6_CONFIG);
879 MAKE_PIN(P7, CORE_PIN7_PORTREG, 7, CORE_PIN7_CONFIG);
880 MAKE_PIN(P8, CORE_PIN8_PORTREG, 8, CORE_PIN8_CONFIG);
881 MAKE_PIN(P9, CORE_PIN9_PORTREG, 9, CORE_PIN9_CONFIG);
882 MAKE_PIN(P10, CORE_PIN10_PORTREG, 10, CORE_PIN10_CONFIG);
883 MAKE_PIN(P11, CORE_PIN11_PORTREG, 11, CORE_PIN11_CONFIG);
884 MAKE_PIN(P12, CORE_PIN12_PORTREG, 12, CORE_PIN12_CONFIG);
885 MAKE_PIN(P13, CORE_PIN13_PORTREG, 13, CORE_PIN13_CONFIG);
886 MAKE_PIN(P14, CORE_PIN14_PORTREG, 14, CORE_PIN14_CONFIG);
887 MAKE_PIN(P15, CORE_PIN15_PORTREG, 15, CORE_PIN15_CONFIG);
888 MAKE_PIN(P16, CORE_PIN16_PORTREG, 16, CORE_PIN16_CONFIG);
889 MAKE_PIN(P17, CORE_PIN17_PORTREG, 17, CORE_PIN17_CONFIG);
890 MAKE_PIN(P18, CORE_PIN18_PORTREG, 18, CORE_PIN18_CONFIG);
891 MAKE_PIN(P19, CORE_PIN19_PORTREG, 19, CORE_PIN19_CONFIG);
892 MAKE_PIN(P20, CORE_PIN20_PORTREG, 20, CORE_PIN20_CONFIG);
893 MAKE_PIN(P21, CORE_PIN21_PORTREG, 21, CORE_PIN21_CONFIG);
894 MAKE_PIN(P22, CORE_PIN22_PORTREG, 22, CORE_PIN22_CONFIG);
895 MAKE_PIN(P23, CORE_PIN23_PORTREG, 23, CORE_PIN23_CONFIG);
896 MAKE_PIN(P24, CORE_PIN24_PORTREG, 24, CORE_PIN24_CONFIG);
897 MAKE_PIN(P25, CORE_PIN25_PORTREG, 25, CORE_PIN25_CONFIG);
898 MAKE_PIN(P26, CORE_PIN26_PORTREG, 26, CORE_PIN26_CONFIG);
902 #elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) 916 #define MAKE_PIN(className, pio, pinMask) \ 919 static void Set() { \ 920 pio->PIO_SODR = pinMask; \ 922 static void Clear() { \ 923 pio->PIO_CODR = pinMask; \ 925 static void SetDirRead() { \ 926 pio->PIO_IDR = pinMask ; \ 927 pio->PIO_PUDR = pinMask; \ 928 pio->PIO_ODR = pinMask; \ 929 pio->PIO_PER = pinMask; \ 931 static void SetDirWrite() { \ 932 pio->PIO_IDR = pinMask ; \ 933 pio->PIO_PUDR = pinMask; \ 934 pio->PIO_OER = pinMask; \ 935 pio->PIO_PER = pinMask; \ 937 static uint8_t IsSet() { \ 938 return pio->PIO_PDSR & pinMask; \ 944 MAKE_PIN(P0, PIOA, PIO_PA8);
945 MAKE_PIN(P1, PIOA, PIO_PA9);
946 MAKE_PIN(P2, PIOB, PIO_PB25);
947 MAKE_PIN(P3, PIOC, PIO_PC28);
948 MAKE_PIN(P4, PIOC, PIO_PC26);
949 MAKE_PIN(P5, PIOC, PIO_PC25);
950 MAKE_PIN(P6, PIOC, PIO_PC24);
951 MAKE_PIN(P7, PIOC, PIO_PC23);
952 MAKE_PIN(P8, PIOC, PIO_PC22);
953 MAKE_PIN(P9, PIOC, PIO_PC21);
954 MAKE_PIN(P10, PIOC, PIO_PC29);
955 MAKE_PIN(P11, PIOD, PIO_PD7);
956 MAKE_PIN(P12, PIOD, PIO_PD8);
957 MAKE_PIN(P13, PIOB, PIO_PB27);
958 MAKE_PIN(P14, PIOD, PIO_PD4);
959 MAKE_PIN(P15, PIOD, PIO_PD5);
960 MAKE_PIN(P16, PIOA, PIO_PA13);
961 MAKE_PIN(P17, PIOA, PIO_PA12);
962 MAKE_PIN(P18, PIOA, PIO_PA11);
963 MAKE_PIN(P19, PIOA, PIO_PA10);
964 MAKE_PIN(P20, PIOB, PIO_PB12);
965 MAKE_PIN(P21, PIOB, PIO_PB13);
966 MAKE_PIN(P22, PIOB, PIO_PB26);
967 MAKE_PIN(P23, PIOA, PIO_PA14);
968 MAKE_PIN(P24, PIOA, PIO_PA15);
969 MAKE_PIN(P25, PIOD, PIO_PD0);
970 MAKE_PIN(P26, PIOD, PIO_PD1);
971 MAKE_PIN(P27, PIOD, PIO_PD2);
972 MAKE_PIN(P28, PIOD, PIO_PD3);
973 MAKE_PIN(P29, PIOD, PIO_PD6);
974 MAKE_PIN(P30, PIOD, PIO_PD9);
975 MAKE_PIN(P31, PIOA, PIO_PA7);
976 MAKE_PIN(P32, PIOD, PIO_PD10);
977 MAKE_PIN(P33, PIOC, PIO_PC1);
978 MAKE_PIN(P34, PIOC, PIO_PC2);
979 MAKE_PIN(P35, PIOC, PIO_PC3);
980 MAKE_PIN(P36, PIOC, PIO_PC4);
981 MAKE_PIN(P37, PIOC, PIO_PC5);
982 MAKE_PIN(P38, PIOC, PIO_PC6);
983 MAKE_PIN(P39, PIOC, PIO_PC7);
984 MAKE_PIN(P40, PIOC, PIO_PC8);
985 MAKE_PIN(P41, PIOC, PIO_PC9);
986 MAKE_PIN(P42, PIOA, PIO_PA19);
987 MAKE_PIN(P43, PIOA, PIO_PA20);
988 MAKE_PIN(P44, PIOC, PIO_PC19);
989 MAKE_PIN(P45, PIOC, PIO_PC18);
990 MAKE_PIN(P46, PIOC, PIO_PC17);
991 MAKE_PIN(P47, PIOC, PIO_PC16);
992 MAKE_PIN(P48, PIOC, PIO_PC15);
993 MAKE_PIN(P49, PIOC, PIO_PC14);
994 MAKE_PIN(P50, PIOC, PIO_PC13);
995 MAKE_PIN(P51, PIOC, PIO_PC12);
996 MAKE_PIN(P52, PIOB, PIO_PB21);
997 MAKE_PIN(P53, PIOB, PIO_PB14);
998 MAKE_PIN(P54, PIOA, PIO_PA16);
999 MAKE_PIN(P55, PIOA, PIO_PA24);
1000 MAKE_PIN(P56, PIOA, PIO_PA23);
1001 MAKE_PIN(P57, PIOA, PIO_PA22);
1002 MAKE_PIN(P58, PIOA, PIO_PA6);
1003 MAKE_PIN(P59, PIOA, PIO_PA4);
1004 MAKE_PIN(P60, PIOA, PIO_PA3);
1005 MAKE_PIN(P61, PIOA, PIO_PA2);
1006 MAKE_PIN(P62, PIOB, PIO_PB17);
1007 MAKE_PIN(P63, PIOB, PIO_PB18);
1008 MAKE_PIN(P64, PIOB, PIO_PB19);
1009 MAKE_PIN(P65, PIOB, PIO_PB20);
1010 MAKE_PIN(P66, PIOB, PIO_PB15);
1011 MAKE_PIN(P67, PIOB, PIO_PB16);
1012 MAKE_PIN(P68, PIOA, PIO_PA1);
1013 MAKE_PIN(P69, PIOA, PIO_PA0);
1014 MAKE_PIN(P70, PIOA, PIO_PA17);
1015 MAKE_PIN(P71, PIOA, PIO_PA18);
1016 MAKE_PIN(P72, PIOC, PIO_PC30);
1017 MAKE_PIN(P73, PIOA, PIO_PA21);
1018 MAKE_PIN(P74, PIOA, PIO_PA25);
1019 MAKE_PIN(P75, PIOA, PIO_PA26);
1020 MAKE_PIN(P76, PIOA, PIO_PA27);
1021 MAKE_PIN(P77, PIOA, PIO_PA28);
1022 MAKE_PIN(P78, PIOB, PIO_PB23);
1026 #elif defined(RBL_NRF51822) 1028 #define MAKE_PIN(className, pin) \ 1031 static void Set() { \ 1032 nrf_gpio_pin_set(pin); \ 1034 static void Clear() { \ 1035 nrf_gpio_pin_clear(pin); \ 1037 static void SetDirRead() { \ 1038 nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_NOPULL); \ 1040 static void SetDirWrite() { \ 1041 nrf_gpio_cfg_output(pin); \ 1043 static uint8_t IsSet() { \ 1044 return (uint8_t)nrf_gpio_pin_read(pin); \ 1049 MAKE_PIN(P0, Pin_nRF51822_to_Arduino(D0));
1050 MAKE_PIN(P1, Pin_nRF51822_to_Arduino(D1));
1051 MAKE_PIN(P2, Pin_nRF51822_to_Arduino(D2));
1052 MAKE_PIN(P3, Pin_nRF51822_to_Arduino(D3));
1053 MAKE_PIN(P4, Pin_nRF51822_to_Arduino(D4));
1054 MAKE_PIN(P5, Pin_nRF51822_to_Arduino(D5));
1055 MAKE_PIN(P6, Pin_nRF51822_to_Arduino(D6));
1056 MAKE_PIN(P7, Pin_nRF51822_to_Arduino(D7));
1057 MAKE_PIN(P8, Pin_nRF51822_to_Arduino(D8));
1058 MAKE_PIN(P9, Pin_nRF51822_to_Arduino(D9));
1059 MAKE_PIN(P10, Pin_nRF51822_to_Arduino(D10));
1060 MAKE_PIN(P11, Pin_nRF51822_to_Arduino(D11));
1061 MAKE_PIN(P12, Pin_nRF51822_to_Arduino(D12));
1062 MAKE_PIN(P13, Pin_nRF51822_to_Arduino(D13));
1063 MAKE_PIN(P14, Pin_nRF51822_to_Arduino(D14));
1064 MAKE_PIN(P15, Pin_nRF51822_to_Arduino(D15));
1065 MAKE_PIN(P17, Pin_nRF51822_to_Arduino(D17));
1066 MAKE_PIN(P18, Pin_nRF51822_to_Arduino(D18));
1067 MAKE_PIN(P16, Pin_nRF51822_to_Arduino(D16));
1068 MAKE_PIN(P19, Pin_nRF51822_to_Arduino(D19));
1069 MAKE_PIN(P20, Pin_nRF51822_to_Arduino(D20));
1070 MAKE_PIN(P21, Pin_nRF51822_to_Arduino(D21));
1071 MAKE_PIN(P22, Pin_nRF51822_to_Arduino(D22));
1072 MAKE_PIN(P23, Pin_nRF51822_to_Arduino(D23));
1073 MAKE_PIN(P24, Pin_nRF51822_to_Arduino(D24));
1077 #elif defined(STM32F446xx) 1080 #define MAKE_PIN(className, port, pin) \ 1083 static void Set() { \ 1084 HAL_GPIO_WritePin(port, pin, GPIO_PIN_SET); \ 1086 static void Clear() { \ 1087 HAL_GPIO_WritePin(port, pin, GPIO_PIN_RESET); \ 1089 static void SetDirRead() { \ 1090 static GPIO_InitTypeDef GPIO_InitStruct; \ 1091 GPIO_InitStruct.Pin = pin; \ 1092 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; \ 1093 GPIO_InitStruct.Pull = GPIO_NOPULL; \ 1094 HAL_GPIO_Init(port, &GPIO_InitStruct); \ 1096 static void SetDirWrite() { \ 1097 static GPIO_InitTypeDef GPIO_InitStruct; \ 1098 GPIO_InitStruct.Pin = pin; \ 1099 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; \ 1100 GPIO_InitStruct.Pull = GPIO_NOPULL; \ 1101 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; \ 1102 HAL_GPIO_Init(port, &GPIO_InitStruct); \ 1104 static GPIO_PinState IsSet() { \ 1105 return HAL_GPIO_ReadPin(port, pin); \ 1109 MAKE_PIN(P0, GPIOA, GPIO_PIN_3);
1110 MAKE_PIN(P1, GPIOA, GPIO_PIN_2);
1111 MAKE_PIN(P2, GPIOA, GPIO_PIN_10);
1112 MAKE_PIN(P3, GPIOB, GPIO_PIN_3);
1113 MAKE_PIN(P4, GPIOB, GPIO_PIN_5);
1114 MAKE_PIN(P5, GPIOB, GPIO_PIN_4);
1115 MAKE_PIN(P6, GPIOB, GPIO_PIN_10);
1116 MAKE_PIN(P7, GPIOA, GPIO_PIN_8);
1117 MAKE_PIN(P8, GPIOA, GPIO_PIN_9);
1118 MAKE_PIN(P9, GPIOC, GPIO_PIN_7);
1119 MAKE_PIN(P10, GPIOB, GPIO_PIN_6);
1120 MAKE_PIN(P11, GPIOA, GPIO_PIN_7);
1121 MAKE_PIN(P12, GPIOA, GPIO_PIN_6);
1122 MAKE_PIN(P13, GPIOA, GPIO_PIN_5);
1124 MAKE_PIN(P14, GPIOA, GPIO_PIN_0);
1125 MAKE_PIN(P15, GPIOA, GPIO_PIN_1);
1126 MAKE_PIN(P16, GPIOA, GPIO_PIN_4);
1127 MAKE_PIN(P17, GPIOB, GPIO_PIN_0);
1128 MAKE_PIN(P18, GPIOC, GPIO_PIN_1);
1129 MAKE_PIN(P19, GPIOC, GPIO_PIN_0);
1134 #error "Please define board in avrpins.h" 1138 #elif defined(__ARDUINO_X86__) // Intel Galileo, Intel Galileo 2 and Intel Edison 1140 #include <avr/pgmspace.h> 1143 #define pgm_read_pointer(p) pgm_read_dword(p) 1145 #if PLATFORM_ID == 0xE1 // Edison platform id 1146 #define pinToFastPin(pin) 1 // As far as I can tell all pins can be used as fast pins 1152 #define MAKE_PIN(className, pin) \ 1155 static void Set() { \ 1156 fastDigitalWrite(pin, HIGH); \ 1158 static void Clear() { \ 1159 fastDigitalWrite(pin, LOW); \ 1161 static void SetDirRead() { \ 1162 if (pinToFastPin(pin)) \ 1163 pinMode(pin, INPUT_FAST); \ 1165 pinMode(pin, INPUT); \ 1167 static void SetDirWrite() { \ 1168 if (pinToFastPin(pin)) \ 1169 pinMode(pin, OUTPUT_FAST); \ 1171 pinMode(pin, OUTPUT); \ 1173 static uint8_t IsSet() { \ 1174 return fastDigitalRead(pin); \ 1201 #elif defined(__MIPSEL__) 1205 #define pgm_read_pointer(p) pgm_read_dword(p) 1207 #define MAKE_PIN(className, pin) \ 1210 static void Set() { \ 1211 digitalWrite(pin, HIGH);\ 1213 static void Clear() { \ 1214 digitalWrite(pin, LOW); \ 1216 static void SetDirRead() { \ 1217 pinMode(pin, INPUT); \ 1219 static void SetDirWrite() { \ 1220 pinMode(pin, OUTPUT); \ 1222 static uint8_t IsSet() { \ 1223 return digitalRead(pin); \ 1246 #error "Please define board in avrpins.h" 1250 #endif //_avrpins_h_