Please run it on your NUCLEO-L152

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pin_shield_1.h Source File

pin_shield_1.h

00001 #ifndef PIN_SHIELD_1_H_
00002 #define PIN_SHIELD_1_H_
00003 
00004 // just provide macros for the Arduino pins
00005 // i.e. PIN_LOW(), PIN_HIGH(), PIN_OUTPUT(), PIN_INPUT(), PIN_READ()
00006 
00007 #define LPC810  810
00008 #define LPC812  812
00009 #define LPC1343 1343
00010 #define LPC1768 1768
00011 #define LPC2103 2103
00012 #define LPC2148 2148
00013 
00014 #define ISTARGET_NUCLEO64 (0 \
00015         || defined(TARGET_NUCLEO_F072RB) \
00016         || defined(TARGET_NUCLEO_F103RB) \
00017         || defined(TARGET_NUCLEO_F401RE) \
00018         || defined(TARGET_NUCLEO_F411RE) \
00019         || defined(TARGET_NUCLEO_F446RE) \
00020         || defined(TARGET_NUCLEO_L152RE) \
00021         || defined(TARGET_NUCLEO_L433RC_P) \
00022         || defined(TARGET_NUCLEO_L476RG) \
00023         )
00024 
00025 #define ISTARGET_NUCLEO144 (0 \
00026         || defined(TARGET_NUCLEO_F767ZI) \
00027         )
00028 
00029 //#warning Using pin_SHIELD_1.h
00030 
00031 #if 0
00032 #elif defined(MY_BLUEPILL)
00033 #define PIN_MODE2(reg, pin, mode) reg=(reg&~(0x3<<((pin)<<1)))|(mode<<((pin)<<1))
00034   #if defined(__CC_ARM)
00035   #include <STM32F10X.h>
00036   #else
00037   #include <STM32F1XX.h>
00038   #endif
00039   #define D0_PORT GPIOB
00040   #define D0_PIN  11
00041   #define D1_PORT GPIOB
00042   #define D1_PIN  10
00043   #define D2_PORT GPIOB
00044   #define D2_PIN  6
00045   #define D3_PORT GPIOB
00046   #define D3_PIN  7
00047   #define D4_PORT GPIOA
00048   #define D4_PIN  0
00049   #define D5_PORT GPIOA
00050   #define D5_PIN  1
00051   #define D6_PORT GPIOA
00052   #define D6_PIN  2
00053   #define D7_PORT GPIOA
00054   #define D7_PIN  3
00055   #define D8_PORT GPIOA
00056   #define D8_PIN  9
00057   #define D9_PORT GPIOA
00058   #define D9_PIN  10
00059   #define D10_PORT GPIOB
00060   #define D10_PIN  12
00061   #define D11_PORT GPIOB
00062   #define D11_PIN  15
00063   #define D12_PORT GPIOB
00064   #define D12_PIN  14
00065   #define D13_PORT GPIOB
00066   #define D13_PIN  13
00067   #define A0_PORT GPIOB
00068   #define A0_PIN  1
00069   #define A1_PORT GPIOB
00070   #define A1_PIN  0
00071   #define A2_PORT GPIOA
00072   #define A2_PIN  7
00073   #define A3_PORT GPIOA
00074   #define A3_PIN  6
00075   #define A4_PORT GPIOA
00076   #define A4_PIN  5
00077   #define A5_PORT GPIOB
00078   #define A5_PIN  4
00079 // Shield Control macros
00080 #define PIN_LOW(port, pin)    (port)->BSRR = (1<<((pin)+16))
00081 #define PIN_HIGH(port, pin)   (port)->BSRR = (1<<(pin))
00082 #define PIN_READ(port, pin)   (port)->IDR & (1<<(pin))
00083 #define PIN_MODE4(reg, pin, mode) reg=(reg&~(0xF<<((pin)<<2)))|(mode<<((pin)<<2))
00084 #define PIN_OUTPUT(port, pin) {if (pin > 7) PIN_MODE4((port)->CRH, (pin&7), 0x3); else  PIN_MODE4((port)->CRL, pin, 0x3); } //50MHz push-pull only 0-7
00085 #define PIN_INPUT(port, pin) {if (pin > 7) PIN_MODE4((port)->CRH, (pin&7), 0x4); else  PIN_MODE4((port)->CRL, pin, 0x4); }  //input
00086 
00087 
00088 #elif defined(BLUEPILL)
00089 #define PIN_MODE2(reg, pin, mode) reg=(reg&~(0x3<<((pin)<<1)))|(mode<<((pin)<<1))
00090   #if defined(__CC_ARM)
00091   #include <STM32F10X.h>
00092   #else
00093   #include <STM32F1XX.h>
00094   #endif
00095   #define D0_PORT GPIOA
00096   #define D0_PIN  10
00097   #define D1_PORT GPIOA
00098   #define D1_PIN  9
00099   #define D2_PORT GPIOA
00100   #define D2_PIN  2
00101   #define D3_PORT GPIOA
00102   #define D3_PIN  3
00103   #define D4_PORT GPIOA
00104   #define D4_PIN  4
00105   #define D5_PORT GPIOA
00106   #define D5_PIN  5
00107   #define D6_PORT GPIOA
00108   #define D6_PIN  6
00109   #define D7_PORT GPIOA
00110   #define D7_PIN  7
00111   #define D8_PORT GPIOA
00112   #define D8_PIN  0
00113   #define D9_PORT GPIOA
00114   #define D9_PIN  1
00115   #define D10_PORT GPIOA
00116   #define D10_PIN  15
00117   #define D11_PORT GPIOB
00118   #define D11_PIN  5
00119   #define D12_PORT GPIOB
00120   #define D12_PIN  4
00121   #define D13_PORT GPIOB
00122   #define D13_PIN  3
00123   #define A0_PORT GPIOB
00124   #define A0_PIN  5      //original pcb uses SPI pin 
00125 //  #define A0_PIN  0      //hardware mod to Adapter to PB0.  Allows use of PB5 for SD Card
00126   #define A1_PORT GPIOB
00127   #define A1_PIN  6
00128   #define A2_PORT GPIOB
00129   #define A2_PIN  7
00130   #define A3_PORT GPIOB
00131   #define A3_PIN  8
00132   #define A4_PORT GPIOB
00133   #define A4_PIN  9
00134   #define A5_PORT GPIOB
00135   #define A5_PIN  10
00136 // Shield Control macros
00137 #define PIN_LOW(port, pin)    (port)->BSRR = (1<<((pin)+16))
00138 #define PIN_HIGH(port, pin)   (port)->BSRR = (1<<(pin))
00139 #define PIN_READ(port, pin)   (port)->IDR & (1<<(pin))
00140 #define PIN_MODE4(reg, pin, mode) reg=(reg&~(0xF<<((pin)<<2)))|(mode<<((pin)<<2))
00141 #define PIN_OUTPUT(port, pin) {if (pin > 7) PIN_MODE4((port)->CRH, (pin&7), 0x3); else  PIN_MODE4((port)->CRL, pin, 0x3); } //50MHz push-pull only 0-7
00142 #define PIN_INPUT(port, pin) {if (pin > 7) PIN_MODE4((port)->CRH, (pin&7), 0x4); else  PIN_MODE4((port)->CRL, pin, 0x4); }  //input
00143 
00144 
00145 #elif defined(ITEADMAPLE)
00146 #define PIN_MODE2(reg, pin, mode) reg=(reg&~(0x3<<((pin)<<1)))|(mode<<((pin)<<1))
00147   #if defined(__CC_ARM)
00148   #include <STM32F10X.h>
00149   #else
00150   #include <STM32F1XX.h>
00151   #endif
00152   #define D0_PORT GPIOA
00153   #define D0_PIN  3
00154   #define D1_PORT GPIOA
00155   #define D1_PIN  2
00156   #define D2_PORT GPIOA
00157   #define D2_PIN  0
00158   #define D3_PORT GPIOA
00159   #define D3_PIN  1
00160   #define D4_PORT GPIOB
00161   #define D4_PIN  5
00162   #define D5_PORT GPIOB
00163   #define D5_PIN  6
00164   #define D6_PORT GPIOA
00165   #define D6_PIN  8
00166   #define D7_PORT GPIOA
00167   #define D7_PIN  9
00168   #define D8_PORT GPIOA
00169   #define D8_PIN  10
00170   #define D9_PORT GPIOB
00171   #define D9_PIN  7
00172   #define D10_PORT GPIOA
00173   #define D10_PIN  4
00174   #define D11_PORT GPIOA
00175   #define D11_PIN  7
00176   #define D12_PORT GPIOA
00177   #define D12_PIN  6
00178   #define D13_PORT GPIOA
00179   #define D13_PIN  5
00180   #define A0_PORT GPIOC
00181   #define A0_PIN  0
00182   #define A1_PORT GPIOC
00183   #define A1_PIN  1
00184   #define A2_PORT GPIOC
00185   #define A2_PIN  2
00186   #define A3_PORT GPIOC
00187   #define A3_PIN  3
00188   #define A4_PORT GPIOC
00189   #define A4_PIN  4
00190   #define A5_PORT GPIOC
00191   #define A5_PIN  5
00192 // Shield Control macros
00193 #define PIN_LOW(port, pin)    (port)->BSRR = (1<<((pin)+16))
00194 #define PIN_HIGH(port, pin)   (port)->BSRR = (1<<(pin))
00195 #define PIN_READ(port, pin)   (port)->IDR & (1<<(pin))
00196 #define PIN_MODE4(reg, pin, mode) reg=(reg&~(0xF<<((pin)<<2)))|(mode<<((pin)<<2))
00197 #define PIN_OUTPUT(port, pin) {if (pin > 7) PIN_MODE4((port)->CRH, (pin&7), 0x3); else  PIN_MODE4((port)->CRL, pin, 0x3); } //50MHz push-pull only 0-7
00198 #define PIN_INPUT(port, pin) {if (pin > 7) PIN_MODE4((port)->CRH, (pin&7), 0x4); else  PIN_MODE4((port)->CRL, pin, 0x4); }  //input
00199 
00200 
00201 #elif defined(NUCLEO144) || ISTARGET_NUCLEO144
00202 #define PIN_MODE2(reg, pin, mode) reg=(reg&~(0x3<<((pin)<<1)))|(mode<<((pin)<<1))
00203 #if __MBED__
00204 #warning MBED knows everything
00205 #elif defined(STM32F767xx)
00206   #include <STM32F7XX.h>
00207 #endif
00208   #define D0_PORT GPIOG
00209   #define D0_PIN  9
00210   #define D1_PORT GPIOG
00211   #define D1_PIN  14
00212   #define D2_PORT GPIOF
00213   #define D2_PIN  15
00214   #define D3_PORT GPIOE
00215   #define D3_PIN  13
00216   #define D4_PORT GPIOF
00217   #define D4_PIN  14
00218   #define D5_PORT GPIOE
00219   #define D5_PIN  11
00220   #define D6_PORT GPIOE
00221   #define D6_PIN  9
00222   #define D7_PORT GPIOF
00223   #define D7_PIN  13
00224   #define D8_PORT GPIOF
00225   #define D8_PIN  12
00226   #define D9_PORT GPIOD
00227   #define D9_PIN  15
00228   #define D10_PORT GPIOD
00229   #define D10_PIN  14
00230   #define D11_PORT GPIOA
00231   #define D11_PIN  7
00232   #define D12_PORT GPIOA
00233   #define D12_PIN  6
00234   #define D13_PORT GPIOA
00235   #define D13_PIN  5
00236   #define A0_PORT GPIOA
00237   #define A0_PIN  3
00238   #define A1_PORT GPIOC
00239   #define A1_PIN  0
00240   #define A2_PORT GPIOC
00241   #define A2_PIN  3
00242   #define A3_PORT GPIOF
00243   #define A3_PIN  3
00244   #define A4_PORT GPIOF
00245   #define A4_PIN  5
00246   #define A5_PORT GPIOF
00247   #define A5_PIN  10
00248 // Shield Control macros
00249 #define PIN_LOW(port, pin)    (port)->BSRR = (1<<((pin)+16))
00250 #define PIN_HIGH(port, pin)   (port)->BSRR = (1<<(pin))
00251 //#define PIN_LOW(port, pin)    (port)->ODR &= ~(1<<(pin))
00252 //#define PIN_HIGH(port, pin)   (port)->ODR |=  (1<<(pin))
00253 #define PIN_READ(port, pin)   (port)->IDR & (1<<(pin))
00254 #define PIN_OUTPUT(port, pin) PIN_MODE2((port)->MODER, pin, 0x1)
00255 #define PIN_INPUT(port, pin) PIN_MODE2((port)->MODER, pin, 0x0)   //.kbv check this
00256 
00257 #elif defined(NUCLEO) || ISTARGET_NUCLEO64
00258 #define PIN_MODE2(reg, pin, mode) reg=(reg&~(0x3<<((pin)<<1)))|(mode<<((pin)<<1))
00259 #if __MBED__
00260 #warning MBED knows everything
00261 #elif defined(STM32F072xB)
00262   #include <STM32F0XX.h>
00263 #elif defined(STM32F103xB)
00264   #if defined(__CC_ARM)
00265   #include <STM32F10X.h>
00266   #else
00267   #include <STM32F1XX.h>
00268   #endif
00269 #elif defined(STM32L476xx) || defined(STM32L433xx)
00270   #include <STM32L4XX.h>
00271 #elif defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
00272   #include <STM32F4XX.h>
00273 #endif
00274   #define D0_PORT GPIOA
00275   #define D0_PIN  3
00276   #define D1_PORT GPIOA
00277   #define D1_PIN  2
00278   #define D2_PORT GPIOA
00279   #define D2_PIN  10
00280   #define D3_PORT GPIOB
00281   #define D3_PIN  3
00282   #define D4_PORT GPIOB
00283   #define D4_PIN  5
00284   #define D5_PORT GPIOB
00285   #define D5_PIN  4
00286   #define D6_PORT GPIOB
00287   #define D6_PIN  10
00288   #define D7_PORT GPIOA
00289   #define D7_PIN  8
00290   #define D8_PORT GPIOA
00291   #define D8_PIN  9
00292   #define D9_PORT GPIOC
00293   #define D9_PIN  7
00294   #define D10_PORT GPIOB
00295   #define D10_PIN  6
00296   #define D11_PORT GPIOA
00297   #define D11_PIN  7
00298   #define D12_PORT GPIOA
00299   #define D12_PIN  6
00300   #define D13_PORT GPIOA
00301   #define D13_PIN  5
00302   #define A0_PORT GPIOA
00303   #define A0_PIN  0
00304   #define A1_PORT GPIOA
00305   #define A1_PIN  1
00306   #define A2_PORT GPIOA
00307   #define A2_PIN  4
00308   #define A3_PORT GPIOB
00309   #define A3_PIN  0
00310   #define A4_PORT GPIOC
00311   #define A4_PIN  1
00312   #define A5_PORT GPIOC
00313   #define A5_PIN  0
00314 // Shield Control macros
00315 #define PIN_LOW(port, pin)    (port)->BSRR = (1<<((pin)+16))
00316 #define PIN_HIGH(port, pin)   (port)->BSRR = (1<<(pin))
00317 //#define PIN_LOW(port, pin)    (port)->ODR &= ~(1<<(pin))
00318 //#define PIN_HIGH(port, pin)   (port)->ODR |=  (1<<(pin))
00319 #define PIN_READ(port, pin)   (port)->IDR & (1<<(pin))
00320 #if defined(STM32F103xB)
00321   #warning STM32F103xB ******************************
00322 #define PIN_MODE4(reg, pin, mode) reg=(reg&~(0xF<<((pin)<<2)))|(mode<<((pin)<<2))
00323 #define PIN_OUTPUT(port, pin) PIN_MODE4((port)->CRL, pin, 0x3)   //50MHz push-pull only 0-7
00324 #define PIN_INPUT(port, pin)  PIN_MODE4((port)->CRL, pin, 0x4)   //digital input 
00325 #else
00326 #define PIN_OUTPUT(port, pin) PIN_MODE2((port)->MODER, pin, 0x1)
00327 #define PIN_INPUT(port, pin) PIN_MODE2((port)->MODER, pin, 0x0)   //.kbv check this
00328 #endif
00329 
00330 #elif __TARGET_PROCESSOR == LPC1768
00331   #include <LPC17xx.h>
00332 // configure macros for the control pins
00333   #define D0_PORT LPC_GPIO0
00334   #define D0_PIN  3
00335   #define D1_PORT LPC_GPIO0
00336   #define D1_PIN  2
00337   #define D2_PORT LPC_GPIO0
00338   #define D2_PIN  24           //p16
00339   #define D3_PORT LPC_GPIO0
00340   #define D3_PIN  23           //p15
00341   #define D4_PORT LPC_GPIO0
00342   #define D4_PIN  16           //p14
00343   #define D5_PORT LPC_GPIO0
00344   #define D5_PIN  15           //p13
00345   #define D6_PORT LPC_GPIO0
00346   #define D6_PIN  17           //p12
00347   #define D7_PORT LPC_GPIO0
00348   #define D7_PIN  18           //p11
00349   #define D8_PORT LPC_GPIO0
00350   #define D8_PIN  1            //p10
00351   #define D9_PORT LPC_GPIO0
00352   #define D9_PIN  0            //p9
00353   #define D10_PORT LPC_GPIO0
00354   #define D10_PIN  6           //p8
00355   #define D11_PORT LPC_GPIO0
00356   #define D11_PIN  9           //p5
00357   #define D12_PORT LPC_GPIO0
00358   #define D12_PIN  8           //p6 miso
00359   #define D13_PORT LPC_GPIO0
00360   #define D13_PIN  7           //p7
00361   #define A0_PORT LPC_GPIO0
00362   #define A0_PIN  25           //p17
00363   #define A1_PORT LPC_GPIO0
00364   #define A1_PIN  26           //p18
00365   #define A2_PORT LPC_GPIO1
00366   #define A2_PIN  30           //p19
00367   #define A3_PORT LPC_GPIO1
00368   #define A3_PIN  31           //p20
00369   #define A4_PORT LPC_GPIO0
00370   #define A4_PIN  10           //p28
00371   #define A5_PORT LPC_GP100
00372   #define A5_PIN  11           //p27
00373 // Shield Control macros
00374 #define PIN_LOW(port, pin)    (port)->FIOCLR = (1u<<(pin))
00375 #define PIN_HIGH(port, pin)   (port)->FIOSET = (1u<<(pin))
00376 #define PIN_OUTPUT(port, pin) (port)->FIODIR |= (1u<<(pin))
00377 #define PIN_INPUT(port, pin)  (port)->FIODIR &= ~(1u<<(pin))
00378 #define PIN_READ(port, pin)   (port)->FIOPIN & (1u<<(pin))
00379 
00380 #elif (defined(MK20D7) && defined(TEENSY)) || defined(TARGET_TEENSY3_1)
00381 #if __MBED__
00382 #warning MBED knows everything
00383 #else
00384   #include <MK20D5.h>
00385 #endif
00386   #define D0_PORT PTB
00387   #define D0_PIN  16
00388   #define D1_PORT PTB
00389   #define D1_PIN  17
00390   #define D2_PORT PTD
00391   #define D2_PIN  0
00392   #define D3_PORT PTA
00393   #define D3_PIN  12
00394   #define D4_PORT PTA
00395   #define D4_PIN  13
00396   #define D5_PORT PTD
00397   #define D5_PIN  7
00398   #define D6_PORT PTD
00399   #define D6_PIN  4
00400   #define D7_PORT PTD
00401   #define D7_PIN  2
00402   #define D8_PORT PTD
00403   #define D8_PIN  3
00404   #define D9_PORT PTC
00405   #define D9_PIN  3
00406   #define D10_PORT PTC
00407   #define D10_PIN  4
00408   #define D11_PORT PTC
00409   #define D11_PIN  6
00410   #define D12_PORT PTC
00411   #define D12_PIN  7
00412   #define D13_PORT PTC
00413   #define D13_PIN  5
00414   #define A0_PORT PTD
00415   #define A0_PIN  1
00416   #define A1_PORT PTC
00417   #define A1_PIN  0
00418   #define A2_PORT PTB
00419   #define A2_PIN  0
00420   #define A3_PORT PTB
00421   #define A3_PIN  1
00422   #define A4_PORT PTB
00423   #define A4_PIN  3
00424   #define A5_PORT PTB
00425   #define A5_PIN  2
00426 // Shield Control macros.   Deliberately avoid the IOSET registers
00427 #define PIN_LOW(port, pin)    (port)->PCOR =  (1<<(pin))
00428 #define PIN_HIGH(port, pin)   (port)->PSOR =  (1<<(pin))
00429 //#define PIN_LOW(port, pin)    (port)->PDOR &= ~(1<<(pin))
00430 //#define PIN_HIGH(port, pin)   (port)->PDOR |=  (1<<(pin))
00431 #define PIN_OUTPUT(port, pin) (port)->PDDR |= (1<<(pin))
00432 #define PIN_INPUT(port, pin)  (port)->PDDR &= ~(1u<<(pin))
00433 #define PIN_READ(port, pin)   (port)->PDIR & (1u<<(pin))
00434 
00435 
00436 #elif defined(MKL25Z4) || defined(TARGET_KL25Z)
00437   #include <MKL25Z4.h>
00438   #define D0_PORT PTA
00439   #define D0_PIN  1
00440   #define D1_PORT PTA
00441   #define D1_PIN  2
00442   #define D2_PORT PTD
00443   #define D2_PIN  4
00444   #define D3_PORT PTA
00445   #define D3_PIN  12
00446   #define D4_PORT PTA
00447   #define D4_PIN  4
00448   #define D5_PORT PTA
00449   #define D5_PIN  5
00450   #define D6_PORT PTC
00451   #define D6_PIN  8
00452   #define D7_PORT PTC
00453   #define D7_PIN  9
00454   #define D8_PORT PTA
00455   #define D8_PIN  13
00456   #define D9_PORT PTD
00457   #define D9_PIN  5
00458   #define D10_PORT PTD
00459   #define D10_PIN  0
00460   #define D11_PORT PTD
00461   #define D11_PIN  2
00462   #define D12_PORT PTD
00463   #define D12_PIN  3
00464   #define D13_PORT PTD
00465   #define D13_PIN  1
00466   #define A0_PORT PTB
00467   #define A0_PIN  0
00468   #define A1_PORT PTB
00469   #define A1_PIN  1
00470   #define A2_PORT PTB
00471   #define A2_PIN  2
00472   #define A3_PORT PTB
00473   #define A3_PIN  3
00474   #define A4_PORT PTC
00475   #define A4_PIN  2
00476   #define A5_PORT PTC
00477   #define A5_PIN  1
00478 // Shield Control macros.   Deliberately avoid the IOSET registers
00479 #define PIN_LOW(port, pin)    (port)->PCOR =  (1<<(pin))
00480 #define PIN_HIGH(port, pin)   (port)->PSOR =  (1<<(pin))
00481 //#define PIN_LOW(port, pin)    (port)->PDOR &= ~(1<<(pin))
00482 //#define PIN_HIGH(port, pin)   (port)->PDOR |=  (1<<(pin))
00483 #define PIN_OUTPUT(port, pin) (port)->PDDR |= (1<<(pin))
00484 #define PIN_INPUT(port, pin)  (port)->PDDR &= ~(1u<<(pin))
00485 #define PIN_READ(port, pin)   (port)->PDIR & (1u<<(pin))
00486 
00487 #elif defined(MKL26Z4)
00488   #include <MKL26Z4.h>
00489   #define D0_PORT PTA
00490   #define D0_PIN  1
00491   #define D1_PORT PTA
00492   #define D1_PIN  2
00493   #define D2_PORT PTD
00494   #define D2_PIN  3      //PTD4 on KL25
00495   #define D3_PORT PTA
00496   #define D3_PIN  12
00497   #define D4_PORT PTA
00498   #define D4_PIN  4
00499   #define D5_PORT PTA
00500   #define D5_PIN  5
00501   #define D6_PORT PTC
00502   #define D6_PIN  8
00503   #define D7_PORT PTC
00504   #define D7_PIN  9
00505   #define D8_PORT PTA
00506   #define D8_PIN  13
00507   #define D9_PORT PTD
00508   #define D9_PIN  2      //PTD5 on KL25
00509   #define D10_PORT PTD
00510   #define D10_PIN  4      //PTD0
00511   #define D11_PORT PTD
00512   #define D11_PIN  6      //PTD2
00513   #define D12_PORT PTD
00514   #define D12_PIN  7      //PTD3
00515   #define D13_PORT PTD
00516   #define D13_PIN  5      //PTD1
00517   #define A0_PORT PTB
00518   #define A0_PIN  0
00519   #define A1_PORT PTB
00520   #define A1_PIN  1
00521   #define A2_PORT PTB
00522   #define A2_PIN  2
00523   #define A3_PORT PTB
00524   #define A3_PIN  3
00525   #define A4_PORT PTC
00526   #define A4_PIN  2
00527   #define A5_PORT PTC
00528   #define A5_PIN  1
00529 // Shield Control macros.   Deliberately avoid the IOSET registers
00530 #define PIN_LOW(port, pin)    (port)->PCOR =  (1<<(pin))
00531 #define PIN_HIGH(port, pin)   (port)->PSOR =  (1<<(pin))
00532 //#define PIN_LOW(port, pin)    (port)->PDOR &= ~(1<<(pin))
00533 //#define PIN_HIGH(port, pin)   (port)->PDOR |=  (1<<(pin))
00534 #define PIN_OUTPUT(port, pin) (port)->PDDR |= (1<<(pin))
00535 #define PIN_INPUT(port, pin)  (port)->PDDR &= ~(1u<<(pin))
00536 #define PIN_READ(port, pin)   (port)->PDIR & (1u<<(pin))
00537 
00538 #elif defined(MKL05Z4) || defined(TARGET_KL05Z)
00539   #include <MKL05Z4.h>
00540   #define D0_PORT PTB
00541   #define D0_PIN  2
00542   #define D1_PORT PTB
00543   #define D1_PIN  1
00544   #define D2_PORT PTA
00545   #define D2_PIN  11
00546   #define D3_PORT PTB
00547   #define D3_PIN  5
00548   #define D4_PORT PTA
00549   #define D4_PIN  10
00550   #define D5_PORT PTA
00551   #define D5_PIN  12
00552   #define D6_PORT PTB
00553   #define D6_PIN  6
00554   #define D7_PORT PTB
00555   #define D7_PIN  7
00556   #define D8_PORT PTB
00557   #define D8_PIN  13
00558   #define D9_PORT PTB
00559   #define D9_PIN  5
00560   #define D10_PORT PTA
00561   #define D10_PIN  0
00562   #define D11_PORT PTA
00563   #define D11_PIN  2
00564   #define D12_PORT PTA
00565   #define D12_PIN  3
00566   #define D13_PORT PTB
00567   #define D13_PIN  1
00568   #define A0_PORT PTB
00569   #define A0_PIN  8
00570   #define A1_PORT PTB
00571   #define A1_PIN  9
00572   #define A2_PORT PTA
00573   #define A2_PIN  8
00574   #define A3_PORT PTA
00575   #define A3_PIN  0
00576   #define A4_PORT PTA
00577   #define A4_PIN  9
00578   #define A5_PORT PTB
00579   #define A5_PIN  13
00580 // Shield Control macros
00581 //#define PIN_LOW(port, pin)    (port)->PCOR =  (1<<(pin))
00582 //#define PIN_HIGH(port, pin)   (port)->PSOR =  (1<<(pin))
00583 #define PIN_LOW(port, pin)    (port)->PDOR &= ~(1<<(pin))
00584 #define PIN_HIGH(port, pin)   (port)->PDOR |=  (1<<(pin))
00585 #define PIN_OUTPUT(port, pin) (port)->PDDR |= (1<<(pin))
00586 #define PIN_INPUT(port, pin)  (port)->PDDR &= ~(1u<<(pin))
00587 #define PIN_READ(port, pin)   (port)->PDIR & (1u<<(pin))
00588 
00589 #elif defined(MK20D5) || defined(TARGET_K20D50M)
00590   #include <MK20D5.h>
00591   #define D0_PORT PTE
00592   #define D0_PIN  1
00593   #define D1_PORT PTE
00594   #define D1_PIN  0
00595   #define D2_PORT PTA
00596   #define D2_PIN  5
00597   #define D3_PORT PTD
00598   #define D3_PIN  4
00599   #define D4_PORT PTC
00600   #define D4_PIN  8
00601   #define D5_PORT PTA
00602   #define D5_PIN  1
00603   #define D6_PORT PTC
00604   #define D6_PIN  3
00605   #define D7_PORT PTC
00606   #define D7_PIN  4
00607   #define D8_PORT PTA
00608   #define D8_PIN  12
00609   #define D9_PORT PTA
00610   #define D9_PIN  2
00611   #define D10_PORT PTC
00612   #define D10_PIN  2
00613   #define D11_PORT PTD
00614   #define D11_PIN  2
00615   #define D12_PORT PTD
00616   #define D12_PIN  3
00617   #define D13_PORT PTD
00618   #define D13_PIN  1
00619   #define A0_PORT PTC
00620   #define A0_PIN  0
00621   #define A1_PORT PTC
00622   #define A1_PIN  1
00623   #define A2_PORT PTD
00624   #define A2_PIN  6
00625   #define A3_PORT PTD
00626   #define A3_PIN  5
00627   #define A4_PORT PTB
00628   #define A4_PIN  1
00629   #define A5_PORT PTB
00630   #define A5_PIN  0
00631 // Shield Control macros.   Deliberately avoid the IOSET registers
00632 #define PIN_LOW(port, pin)    (port)->PCOR =  (1<<(pin))
00633 #define PIN_HIGH(port, pin)   (port)->PSOR =  (1<<(pin))
00634 //#define PIN_LOW(port, pin)    (port)->PDOR &= ~(1<<(pin))
00635 //#define PIN_HIGH(port, pin)   (port)->PDOR |=  (1<<(pin))
00636 #define PIN_OUTPUT(port, pin) (port)->PDDR |= (1<<(pin))
00637 #define PIN_INPUT(port, pin)  (port)->PDDR &= ~(1u<<(pin))
00638 #define PIN_READ(port, pin)   (port)->PDIR & (1u<<(pin))
00639 
00640 
00641 #elif defined(ZERO)
00642   #include <samd21.h>
00643 // configure macros for the data pins
00644 #if defined(D21_XPRO)
00645   #define D0_PORT PORT->Group[1]
00646   #define D0_PIN  9
00647   #define D1_PORT PORT->Group[1]
00648   #define D1_PIN  8
00649   #define D2_PORT PORT->Group[1]
00650   #define D2_PIN  14
00651   #define D3_PORT PORT->Group[1]
00652   #define D3_PIN  2
00653   #define D4_PORT PORT->Group[1]
00654   #define D4_PIN  5
00655   #define D5_PORT PORT->Group[0]
00656   #define D5_PIN  21
00657   #define D6_PORT PORT->Group[1]
00658   #define D6_PIN  15
00659   #define D7_PORT PORT->Group[0]
00660   #define D7_PIN  17
00661   #define D8_PORT PORT->Group[1]
00662   #define D8_PIN  6
00663   #define D9_PORT PORT->Group[1]
00664   #define D9_PIN  7
00665   #define D10_PORT PORT->Group[0]
00666   #define D10_PIN  5
00667   #define D11_PORT PORT->Group[0]
00668   #define D11_PIN  6
00669   #define D12_PORT PORT->Group[0]
00670   #define D12_PIN  4
00671   #define D13_PORT PORT->Group[0]
00672   #define D13_PIN  7
00673   #define A0_PORT PORT->Group[1]
00674   #define A0_PIN  0
00675   #define A1_PORT PORT->Group[1]
00676   #define A1_PIN  1
00677   #define A2_PORT PORT->Group[0]
00678   #define A2_PIN  10
00679   #define A3_PORT PORT->Group[0]
00680   #define A3_PIN  11
00681   #define A4_PORT PORT->Group[0]
00682   #define A4_PIN  8
00683   #define A5_PORT PORT->Group[0]
00684   #define A5_PIN  9
00685 #elif defined(M0_PRO)
00686   #define D0_PORT PORT->Group[0]
00687   #define D0_PIN  11
00688   #define D1_PORT PORT->Group[0]
00689   #define D1_PIN  10
00690     //M0 and Zero physical PA08 and PA14 are swapped
00691   #define D2_PORT PORT->Group[0] //PA08  (Zero-D4)
00692   #define D2_PIN  8
00693   #define D3_PORT PORT->Group[0]
00694   #define D3_PIN  9
00695   #define D4_PORT PORT->Group[0] //PA14  (Zero-D2)
00696   #define D4_PIN  14
00697   #define D5_PORT PORT->Group[0]
00698   #define D5_PIN  15
00699   #define D6_PORT PORT->Group[0]
00700   #define D6_PIN  20
00701   #define D7_PORT PORT->Group[0]
00702   #define D7_PIN  21
00703   #define D8_PORT PORT->Group[0]
00704   #define D8_PIN  6
00705   #define D9_PORT PORT->Group[0]
00706   #define D9_PIN  7
00707   #define D10_PORT PORT->Group[0]
00708   #define D10_PIN  18
00709   #define D11_PORT PORT->Group[0]
00710   #define D11_PIN  16
00711   #define D12_PORT PORT->Group[0]
00712   #define D12_PIN  19
00713   #define D13_PORT PORT->Group[0]
00714   #define D13_PIN  17
00715     //M0 and Zero Arduino digital pin numbering is DIFFERENT
00716   #define D16_PORT PORT->Group[0] //PA22 (SDA)  (Zero-D20)
00717   #define D16_PIN  22
00718   #define D17_PORT PORT->Group[0] //PA23 (SCL)  (Zero-D21)
00719   #define D17_PIN  23
00720   #define D18_PORT PORT->Group[0] //PA12 (MISO) (Zero-D22)
00721   #define D18_PIN  12
00722   #define D20_PORT PORT->Group[1] //PB11 (SCK)  (Zero-D24)
00723   #define D20_PIN  11
00724   #define D21_PORT PORT->Group[1] //PB10 (MOSI) (Zero-D23)
00725   #define D21_PIN  10
00726   #define A0_PORT PORT->Group[0] //PA02(M0-D24) (Zero-D14)   
00727   #define A0_PIN  2
00728   #define A1_PORT PORT->Group[1] //PB08
00729   #define A1_PIN  8
00730   #define A2_PORT PORT->Group[1] //PB09
00731   #define A2_PIN  9
00732   #define A3_PORT PORT->Group[0] //PA04
00733   #define A3_PIN  4
00734   #define A4_PORT PORT->Group[0] //PA05
00735   #define A4_PIN  5
00736   #define A5_PORT PORT->Group[1] //PB02
00737   #define A5_PIN  2
00738 
00739 #endif
00740 // Shield Control macros.
00741 #define PIN_LOW(port, pin)    (port).OUTCLR.reg = (1<<(pin))
00742 #define PIN_HIGH(port, pin)   (port).OUTSET.reg = (1<<(pin))
00743 #define PIN_OUTPUT(port, pin) (port).DIR.reg |= (1<<(pin))
00744 #define PIN_INPUT(port, pin)  (port).DIR.reg &= ~(1u<<(pin))
00745 #define PIN_READ(port, pin)   (port).IN.reg & (1u<<(pin))
00746 
00747 
00748 #elif defined(__AVR_ATxmegaA4U__)
00749   #include <avr/io.h>
00750   // PD6, PD7 is used for USB.   I could have used PORTA for bus,  PORTC for MSPI, SPI and remap
00751     #define D0_PORT PORTE
00752   #define D0_PIN  2
00753   #define D1_PORT PORTE
00754   #define D1_PIN  3
00755   #define D2_PORT PORTC
00756   #define D2_PIN  2
00757   #define D3_PORT PORTC
00758   #define D3_PIN  3
00759   #define D4_PORT PORTC
00760   #define D4_PIN  4
00761   #define D5_PORT PORTC
00762   #define D5_PIN  5
00763   #define D6_PORT PORTC
00764   #define D6_PIN  6
00765   #define D7_PORT PORTC
00766   #define D7_PIN  7
00767   #define D8_PORT PORTC
00768   #define D8_PIN  0
00769   #define D9_PORT PORTC
00770   #define D9_PIN  1
00771   #define D10_PORT PORTD
00772   #define D10_PIN  0
00773   #define D11_PORT PORTD
00774   #define D11_PIN  3
00775   #define D12_PORT PORTD
00776   #define D12_PIN  2
00777   #define D13_PORT PORTD
00778   #define D13_PIN  1
00779   #define A0_PORT PORTB
00780   #define A0_PIN  0
00781   #define A1_PORT PORTB
00782   #define A1_PIN  1
00783   #define A2_PORT PORTB
00784   #define A2_PIN  2
00785   #define A3_PORT PORTB
00786   #define A3_PIN  3
00787   #define A4_PORT PORTE
00788   #define A4_PIN  0
00789   #define A5_PORT PORTE
00790   #define A5_PIN  1
00791 // Shield Control macros.
00792 #define PIN_LOW(port, pin)    (port).OUTCLR.reg = (1<<(pin))
00793 #define PIN_HIGH(port, pin)   (port).OUTSET.reg = (1<<(pin))
00794 #define PIN_OUTPUT(port, pin) (port).DIR.reg |= (1<<(pin))
00795 #define PIN_INPUT(port, pin)  (port).DIR.reg &= ~(1u<<(pin))
00796 #define PIN_READ(port, pin)   (port).IN.reg & (1u<<(pin))
00797 
00798 
00799 #elif defined(__AVR_ATmega4809__) && defined(ARDUINO_AVR_NANO_EVERY)   //NANO-EVERY
00800 #warning using NANO-EVERY
00801   #include <avr/io.h>
00802   #define D0_PORT PORTC
00803   #define D0_PIN  5
00804   #define D1_PORT PORTC
00805   #define D1_PIN  4
00806   #define D2_PORT PORTA
00807   #define D2_PIN  0
00808   #define D3_PORT PORTF
00809   #define D3_PIN  5
00810   #define D4_PORT PORTC
00811   #define D4_PIN  6
00812   #define D5_PORT PORTB
00813   #define D5_PIN  2
00814   #define D6_PORT PORTF
00815   #define D6_PIN  4
00816   #define D7_PORT PORTA
00817   #define D7_PIN  1
00818   #define D8_PORT PORTE
00819   #define D8_PIN  3
00820   #define D9_PORT PORTB
00821   #define D9_PIN  0
00822   #define D10_PORT PORTB //PB1
00823   #define D10_PIN  1
00824   #define D11_PORT PORTE
00825   #define D11_PIN  0
00826   #define D12_PORT PORTE
00827   #define D12_PIN  1
00828   #define D13_PORT PORTE
00829   #define D13_PIN  2
00830   #define A0_PORT PORTD
00831   #define A0_PIN  3
00832   #define A1_PORT PORTD
00833   #define A1_PIN  2
00834   #define A2_PORT PORTD
00835   #define A2_PIN  1
00836   #define A3_PORT PORTD
00837   #define A3_PIN  0
00838   #define A4_PORT PORTF
00839   #define A4_PIN  2
00840   #define A5_PORT PORTF
00841   #define A5_PIN  3
00842   #define A6_PORT PORTD
00843   #define A6_PIN  5
00844   #define A7_PORT PORTD
00845   #define A7_PIN  4
00846 // Shield Control macros.
00847 #define PIN_LOW(port, pin)    (port).OUTCLR.reg = (1<<(pin))
00848 #define PIN_HIGH(port, pin)   (port).OUTSET.reg = (1<<(pin))
00849 #define PIN_OUTPUT(port, pin) (port).DIR.reg |= (1<<(pin))
00850 #define PIN_INPUT(port, pin)  (port).DIR.reg &= ~(1u<<(pin))
00851 #define PIN_READ(port, pin)   (port).IN.reg & (1u<<(pin))
00852 
00853 
00854 #elif defined(__AVR_ATmega4809__)    //XPRO_4809 with XPRO_SHIELD_ADAPTER
00855 #warning using XPRO_4809 with XPRO_SHIELD_ADAPTER
00856   #include <avr/io.h>
00857   #define D0_PORT PORTA
00858   #define D0_PIN  1
00859   #define D1_PORT PORTA
00860   #define D1_PIN  0
00861   #define D2_PORT PORTB
00862   #define D2_PIN  2
00863   #define D3_PORT PORTC
00864   #define D3_PIN  6
00865   #define D4_PORT PORTC
00866   #define D4_PIN  7
00867   #define D5_PORT PORTF
00868   #define D5_PIN  6
00869   #define D6_PORT PORTB
00870   #define D6_PIN  3
00871   #define D7_PORT PORTE
00872   #define D7_PIN  1
00873   #define D8_PORT PORTA
00874   #define D8_PIN  2
00875   #define D9_PORT PORTA
00876   #define D9_PIN  3
00877   #define D10_PORT PORTA
00878   #define D10_PIN  7
00879   #define D11_PORT PORTA //PC5
00880   #define D11_PIN  4
00881   #define D12_PORT PORTA
00882   #define D12_PIN  5
00883   #define D13_PORT PORTA
00884   #define D13_PIN  6
00885   #define A0_PORT PORTD
00886   #define A0_PIN  2
00887   #define A1_PORT PORTD
00888   #define A1_PIN  3
00889   #define A2_PORT PORTD
00890   #define A2_PIN  4
00891   #define A3_PORT PORTD
00892   #define A3_PIN  5
00893   #define A4_PORT PORTC
00894   #define A4_PIN  2
00895   #define A5_PORT PORTC
00896   #define A5_PIN  3
00897 // Shield Control macros.
00898 #define PIN_LOW(port, pin)    (port).OUTCLR.reg = (1<<(pin))
00899 #define PIN_HIGH(port, pin)   (port).OUTSET.reg = (1<<(pin))
00900 #define PIN_OUTPUT(port, pin) (port).DIR.reg |= (1<<(pin))
00901 #define PIN_INPUT(port, pin)  (port).DIR.reg &= ~(1u<<(pin))
00902 #define PIN_READ(port, pin)   (port).IN.reg & (1u<<(pin))
00903 
00904 
00905 #elif defined(__AVR_ATtiny1634__)
00906   #include <avr/io.h>
00907   // 
00908   #define D0_PORT PORTA //PA7
00909   #define D0_PIN  7
00910   #define D1_PORT PORTB //PB0
00911   #define D1_PIN  0
00912   #define D2_PORT PORTC //PC2
00913   #define D2_PIN  2
00914   #define D3_PORT PORTA //PA3
00915   #define D3_PIN  3
00916   #define D4_PORT PORTA //PA4
00917   #define D4_PIN  4
00918   #define D5_PORT PORTC //PC4
00919   #define D5_PIN  4
00920   #define D6_PORT PORTA //PA1
00921   #define D6_PIN  1
00922   #define D7_PORT PORTA //PA0
00923   #define D7_PIN  0
00924   #define D8_PORT PORTA //PA2
00925   #define D8_PIN  2
00926   #define D9_PORT PORTC //PC5
00927   #define D9_PIN  5
00928   #define D10_PORT PORTA //PA6
00929   #define D10_PIN  6
00930   #define D11_PORT PORTB //PB2
00931   #define D11_PIN  2
00932   #define D12_PORT PORTB //PB1
00933   #define D12_PIN  1
00934   #define D13_PORT PORTC //PC1
00935   #define D13_PIN  1
00936   #define A0_PORT PORTB //PB3
00937   #define A0_PIN  3
00938   #define A1_PORT PORTC //PC0
00939   #define A1_PIN  0
00940   #define A2_PORT PORTA //PA5
00941   #define A2_PIN  5
00942   #define A3_PORT PORTB //PB2
00943   #define A3_PIN  2
00944   #define A4_PORT PORTB //PB1
00945   #define A4_PIN  1
00946   #define A5_PORT PORTC //PC1
00947   #define A5_PIN  1
00948 #else
00949 #error MCU unselected
00950 #endif        // MCUs
00951 
00952 #endif     //PIN_SHIELD_1_H
00953 #if 0
00954 #if defined(M0_PRO)
00955 #endif
00956 #if defined(D21_XPRO)
00957 #endif
00958 #endif