piotran.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. /*
  2. * Copyright (C) 2008 by egnite GmbH
  3. * Copyright (C) 2013 by Uwe Bonnes
  4. *
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 3. Neither the name of the copyright holders nor the names of
  17. * contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  24. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  26. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  27. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  28. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  29. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  30. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31. * SUCH DAMAGE.
  32. *
  33. * For additional information see http://www.ethernut.de/
  34. *
  35. */
  36. /*
  37. * $Id: piotran.h 5630 2014-04-07 13:57:59Z u_bonnes $
  38. */
  39. #include <cfg/arch.h>
  40. /*!
  41. * \addtogroup xgPiotranslate
  42. */
  43. /*@{*/
  44. /*!
  45. * \file include/cfg/arch/piotran.h
  46. * \brief Port translations.
  47. *
  48. * This header file determines the target specific GPIO register names
  49. * by a simple configured port identifier. In addition it provides
  50. * several macros to configure, set, clear or query GPIO bits. The
  51. * exposed functionality is only a subset of the functionality on most
  52. * architectures, but choosen to be available on most architectures!
  53. *
  54. * Unlike most other header files, this one may be included several
  55. * times within a single source file, typically once for each configured
  56. * identifier. This header is not supposed to be included in
  57. * architecture specific drivers, as it exposes only restricted
  58. * functionality.
  59. *
  60. * \code
  61. * #undef GPIO_ID
  62. * #define GPIO_ID MY_PORT1_ID
  63. * #include <cfg/arch/piotran.h>
  64. * static INLINE void MY_PORT1_INIT(int bit) { GPIO_INIT(bit); }
  65. * static INLINE void MY_PORT1_SET_HI(int bit) { GPIO_SET_HI(bit); }
  66. * static INLINE void MY_PORT1_SET_LO(int bit) { GPIO_SET_LO(bit); }
  67. *
  68. * #undef GPIO_ID
  69. * #define GPIO_ID MY_PORT2_ID
  70. * #include <cfg/arch/piotran.h>
  71. * static INLINE void MY_PORT2_INIT(void) { GPIO_INIT(MY_PIN2_ID); }
  72. * static INLINE void MY_PORT2_SET_HI(void) { GPIO_SET_HI(MY_PIN2_ID); }
  73. * static INLINE void MY_PORT2_SET_LO(void) { GPIO_SET_LO(MY_PIN2_ID); }
  74. * static INLINE int MY_PORT2_GET(void) { return GPIO_GET(MY_PIN2_ID); }
  75. *
  76. * void Out1(int bit, int val)
  77. * {
  78. * if (val)
  79. * MY_PORT1_SET_HI(bit);
  80. * else
  81. * MY_PORT1_SET_LO(bit);
  82. * }
  83. *
  84. * void Toogle2(int bit)
  85. * {
  86. * if (MY_PORT2_GET())
  87. * MY_PORT2_SET_LO();
  88. * else
  89. * MY_PORT2_SET_HI();
  90. * }
  91. * \endcode
  92. *
  93. * In contrast to the routines in dev/gpio.h, these macros do not require
  94. * any function call and will therefore produce faster and smaller code,
  95. * with the exception of GPIO_INIT(). The following restricted macros are
  96. * available, allowing implementation for all NUTOS architectures:
  97. *
  98. * - GPIO_INIT Basic initialization to input, no pull-up, about 1 MHz speed
  99. * and push-pull when switched to output
  100. * - GPIO_SET_LO Sets output low.
  101. * - GPIO_SET_HI Sets output high.
  102. * - GPIO_GET Returns input status.
  103. * - GPIO_OUTPUT Configures as output.
  104. * - GPIO_INPUT Configures an input.
  105. * - GPIO_PULLUP_ON Enables input pull-up resistor.
  106. * - GPIO_PULLUP_OFF Disables input pull-up resistor.
  107. *
  108. * \note For open-drain pin to release, use GPIO_INPUT(); GPIO_SET_HI ,
  109. * for open-drain pin to drive low, use GPIO_SET_LO(); GPIO_OUTPUT()
  110. *
  111. * \note All listed macros will be available for any port identifier on
  112. * any target, even if the related function is not available. You
  113. * should check the target's datasheet.
  114. *
  115. * \note We use capital letters for the inline attribute to refer to a
  116. * preprocessor macro. If the compiler doesn't support inlined
  117. * function, then the macro will be empty. In this case a function
  118. * call may be used, depending on the compiler's optimization
  119. * strategy. Even if the compiler supports the inline keyword,
  120. * it may decide to generate a callable function.
  121. */
  122. /*
  123. * Remove any previously defined port macros.
  124. */
  125. #undef GPIO_INIT
  126. #undef GPIO_SET_LO
  127. #undef GPIO_SET_HI
  128. #undef GPIO_GET
  129. #undef GPIO_OUTPUT
  130. #undef GPIO_INPUT
  131. #undef GPIO_PULLUP_ON
  132. #undef GPIO_PULLUP_OFF
  133. #if defined(MCU_STM32)
  134. #if defined(MCU_STM32L1)
  135. #define GPIO_SPEED GPIO_CFG_SPEED_MED
  136. #else
  137. #define GPIO_SPEED GPIO_CFG_SPEED_SLOW
  138. #endif
  139. #define GPIO_INIT(b) GpioPinConfigSet(GPIO_ID, b, GPIO_CFG_INPUT|GPIO_SPEED)
  140. #define GPIO_SET_LO(b) GpioPinSetLow(GPIO_ID, b)
  141. #define GPIO_SET_HI(b) GpioPinSetHigh(GPIO_ID, b)
  142. #define GPIO_GET(b) GpioPinGet(GPIO_ID, b)
  143. #define GPIO_OUTPUT(b) GpioPinDrive(GPIO_ID, b)
  144. #define GPIO_INPUT(b) GpioPinRelease(GPIO_ID, b);
  145. #if defined(MCU_STM32F1)
  146. /* For F1, Pullup needs to set configuration _and_ output.
  147. * We can't handle this in a stateless way.
  148. */
  149. #define GPIO_PULLUP_ON(b)
  150. #define GPIO_PULLUP_OFF(b)
  151. #elif defined(MCU_STM32F3)
  152. #define GPIO_PULLUP_ON(b) (CM3REG(GPIO_ID, GPIO_TypeDef, PUPDR) |= (_BV(b<<1)))
  153. #define GPIO_PULLUP_OFF(b) (CM3REG(GPIO_ID, GPIO_TypeDef, PUPDR) &= ~(_BV(b<<1)))
  154. #else
  155. #define GPIO_PULLUP_ON(b) CM3BBSET(GPIO_ID, GPIO_TypeDef, PUPDR, (b<<1))
  156. #define GPIO_PULLUP_OFF(b) CM3BBCLR(GPIO_ID, GPIO_TypeDef, PUPDR, (b<<1))
  157. #endif
  158. #else
  159. #undef GPIO_PE_REG
  160. #undef GPIO_PD_REG
  161. #undef GPIO_PS_REG
  162. #undef GPIO_OE_REG
  163. #undef GPIO_OD_REG
  164. #undef GPIO_OS_REG
  165. #undef GPIO_SOD_REG
  166. #undef GPIO_COD_REG
  167. #undef GPIO_ODS_REG
  168. #undef GPIO_PDS_REG
  169. #undef GPIO_PUE_REG
  170. #undef GPIO_PUD_REG
  171. #undef GPIO_PUS_REG
  172. #undef GPIO_MDE_REG
  173. #undef GPIO_MDD_REG
  174. #undef GPIO_MDS_REG
  175. #undef GPIO_IFE_REG
  176. #undef GPIO_IFD_REG
  177. #undef GPIO_IFS_REG
  178. #if defined(__AVR__)
  179. /*
  180. * Determine AVR port names.
  181. */
  182. #include <cfg/arch/avr.h>
  183. #if GPIO_ID == PIOB_ID
  184. #define GPIO_PDS_REG PINB
  185. #define GPIO_SOD_REG PORTB
  186. #define GPIO_OE_REG DDRB
  187. #define GPIO_PUE_REG PORTB
  188. #elif GPIO_ID == PIOC_ID
  189. #define GPIO_PDS_REG PINC
  190. #define GPIO_SOD_REG PORTC
  191. #define GPIO_OE_REG DDRC
  192. #define GPIO_PUE_REG PORTC
  193. #elif GPIO_ID == PIOD_ID
  194. #define GPIO_PDS_REG PIND
  195. #define GPIO_SOD_REG PORTD
  196. #define GPIO_OE_REG DDRD
  197. #define GPIO_PUE_REG PORTD
  198. #elif GPIO_ID == PIOE_ID
  199. #define GPIO_PDS_REG PINE
  200. #define GPIO_SOD_REG PORTE
  201. #define GPIO_OE_REG DDRE
  202. #define GPIO_PUE_REG PORTE
  203. #elif GPIO_ID == PIOF_ID
  204. #define GPIO_PDS_REG PINF
  205. #define GPIO_SOD_REG PORTF
  206. #define GPIO_OE_REG DDRF
  207. #define GPIO_PUE_REG PORTF
  208. #elif GPIO_ID == PIOG_ID
  209. #define GPIO_PDS_REG PING
  210. #define GPIO_SOD_REG PORTG
  211. #define GPIO_OE_REG DDRG
  212. #define GPIO_PUE_REG PORTG
  213. #elif GPIO_ID == PIOH_ID
  214. #define GPIO_PDS_REG PINH
  215. #define GPIO_SOD_REG PORTH
  216. #define GPIO_OE_REG DDRH
  217. #define GPIO_PUE_REG PORTH
  218. #elif GPIO_ID == PIOI_ID
  219. #define GPIO_PDS_REG PINI
  220. #define GPIO_SOD_REG PORTI
  221. #define GPIO_OE_REG DDRI
  222. #define GPIO_PUE_REG PORTI
  223. #elif GPIO_ID == PIOJ_ID
  224. #define GPIO_PDS_REG PINJ
  225. #define GPIO_SOD_REG PORTJ
  226. #define GPIO_OE_REG DDRJ
  227. #define GPIO_PUE_REG PORTJ
  228. #elif GPIO_ID == PIOK_ID
  229. #define GPIO_PDS_REG PINK
  230. #define GPIO_SOD_REG PORTK
  231. #define GPIO_OE_REG DDRK
  232. #define GPIO_PUE_REG PORTK
  233. #elif GPIO_ID == PIOL_ID
  234. #define GPIO_PDS_REG PINL
  235. #define GPIO_SOD_REG PORTL
  236. #define GPIO_OE_REG DDRL
  237. #define GPIO_PUE_REG PORTL
  238. #else
  239. #define GPIO_PDS_REG PINA
  240. #define GPIO_SOD_REG PORTA
  241. #define GPIO_OE_REG DDRA
  242. #define GPIO_PUE_REG PORTA
  243. #endif
  244. #define GPIO_INIT do {\
  245. cbi(GPIO_OE_REG, b); \
  246. cbi(GPIO_SOD_REG, b);} while(0)
  247. #elif defined(MCU_AT91)
  248. /*
  249. * Determine AT91 port names.
  250. */
  251. #include <arch/arm/at91.h>
  252. #if GPIO_ID == PIOA_ID
  253. #define GPIO_PE_REG PIOA_PER
  254. #define GPIO_PD_REG PIOA_PDR
  255. #define GPIO_PS_REG PIOA_PSR
  256. #define GPIO_OE_REG PIOA_OER
  257. #define GPIO_OD_REG PIOA_ODR
  258. #define GPIO_OS_REG PIOA_OSR
  259. #define GPIO_SOD_REG PIOA_SODR
  260. #define GPIO_COD_REG PIOA_CODR
  261. #define GPIO_ODS_REG PIOA_ODSR
  262. #define GPIO_PDS_REG PIOA_PDSR
  263. #if defined(PIOA_PUER)
  264. #define GPIO_PUE_REG PIOA_PUER
  265. #if defined(PIOA_PUDR)
  266. #define GPIO_PUD_REG PIOA_PUDR
  267. #define GPIO_PUS_REG PIOA_PUSR
  268. #endif /* PIOA_PUDR */
  269. #endif /* PIOA_PUER */
  270. #if defined(PIOA_MDER)
  271. #define GPIO_MDE_REG PIOA_MDER
  272. #if defined(PIOA_MDDR)
  273. #define GPIO_MDD_REG PIOA_MDDR
  274. #define GPIO_MDS_REG PIOA_MDSR
  275. #endif /* PIOA_MDDR */
  276. #endif /* PIOA_MDER */
  277. #if defined(PIOA_IFER)
  278. #define GPIO_IFE_REG PIOA_IFER
  279. #if defined(PIOA_IFDR)
  280. #define GPIO_IFD_REG PIOA_IFDR
  281. #define GPIO_IFS_REG PIOA_IFSR
  282. #endif /* PIOA_IFDR */
  283. #endif /* PIOA_IFER */
  284. #elif GPIO_ID == PIOB_ID
  285. #define GPIO_PE_REG PIOB_PER
  286. #define GPIO_PD_REG PIOB_PDR
  287. #define GPIO_PS_REG PIOB_PSR
  288. #define GPIO_OE_REG PIOB_OER
  289. #define GPIO_OD_REG PIOB_ODR
  290. #define GPIO_OS_REG PIOB_OSR
  291. #define GPIO_SOD_REG PIOB_SODR
  292. #define GPIO_COD_REG PIOB_CODR
  293. #define GPIO_ODS_REG PIOB_ODSR
  294. #define GPIO_PDS_REG PIOB_PDSR
  295. #if defined(PIOB_PUER)
  296. #define GPIO_PUE_REG PIOB_PUER
  297. #if defined(PIOB_PUDR)
  298. #define GPIO_PUD_REG PIOB_PUDR
  299. #define GPIO_PUS_REG PIOB_PUSR
  300. #endif /* PIOB_PUDR */
  301. #endif /* PIOB_PUER */
  302. #if defined(PIOB_MDER)
  303. #define GPIO_MDE_REG PIOB_MDER
  304. #if defined(PIOB_MDDR)
  305. #define GPIO_MDD_REG PIOB_MDDR
  306. #define GPIO_MDS_REG PIOB_MDSR
  307. #endif /* PIOB_MDDR */
  308. #endif /* PIOB_MDER */
  309. #if defined(PIOB_IFER)
  310. #define GPIO_IFE_REG PIOB_IFER
  311. #if defined(PIOB_IFDR)
  312. #define GPIO_IFD_REG PIOB_IFDR
  313. #define GPIO_IFS_REG PIOB_IFSR
  314. #endif /* PIOB_IFDR */
  315. #endif /* PIOB_IFER */
  316. #elif GPIO_ID == PIOC_ID
  317. #define GPIO_PE_REG PIOC_PER
  318. #define GPIO_PD_REG PIOC_PDR
  319. #define GPIO_PS_REG PIOC_PSR
  320. #define GPIO_OE_REG PIOC_OER
  321. #define GPIO_OD_REG PIOC_ODR
  322. #define GPIO_OS_REG PIOC_OSR
  323. #define GPIO_SOD_REG PIOC_SODR
  324. #define GPIO_COD_REG PIOC_CODR
  325. #define GPIO_ODS_REG PIOC_ODSR
  326. #define GPIO_PDS_REG PIOC_PDSR
  327. #if defined(PIOC_PUER)
  328. #define GPIO_PUE_REG PIOC_PUER
  329. #if defined(PIOC_PUDR)
  330. #define GPIO_PUD_REG PIOC_PUDR
  331. #define GPIO_PUS_REG PIOC_PUSR
  332. #endif /* PIOC_PUDR */
  333. #endif /* PIOC_PUER */
  334. #if defined(PIOC_MDER)
  335. #define GPIO_MDE_REG PIOC_MDER
  336. #if defined(PIOC_MDDR)
  337. #define GPIO_MDD_REG PIOC_MDDR
  338. #define GPIO_MDS_REG PIOC_MDSR
  339. #endif /* PIOC_MDDR */
  340. #endif /* PIOC_MDER */
  341. #if defined(PIOC_IFER)
  342. #define GPIO_IFE_REG PIOC_IFER
  343. #if defined(PIOC_IFDR)
  344. #define GPIO_IFD_REG PIOC_IFDR
  345. #define GPIO_IFS_REG PIOC_IFSR
  346. #endif /* PIOC_IFDR */
  347. #endif /* PIOC_IFER */
  348. #else /* GPIO_ID */
  349. #define GPIO_PE_REG PIO_PER
  350. #define GPIO_PD_REG PIO_PDR
  351. #define GPIO_PS_REG PIO_PSR
  352. #define GPIO_OE_REG PIO_OER
  353. #define GPIO_OD_REG PIO_ODR
  354. #define GPIO_OS_REG PIO_OSR
  355. #define GPIO_SOD_REG PIO_SODR
  356. #define GPIO_COD_REG PIO_CODR
  357. #define GPIO_ODS_REG PIO_ODSR
  358. #define GPIO_PDS_REG PIO_PDSR
  359. #if defined(PIO_PUER)
  360. #define GPIO_PUE_REG PIO_PUER
  361. #if defined(PIO_PUDR)
  362. #define GPIO_PUD_REG PIO_PUDR
  363. #define GPIO_PUS_REG PIO_PUSR
  364. #endif /* PIO_PUDR */
  365. #endif /* PIO_PUER */
  366. #if defined(PIO_MDER)
  367. #define GPIO_MDE_REG PIO_MDER
  368. #if defined(PIO_MDDR)
  369. #define GPIO_MDD_REG PIO_MDDR
  370. #define GPIO_MDS_REG PIO_MDSR
  371. #endif /* PIO_MDDR */
  372. #endif /* PIO_MDER */
  373. #if defined(PIO_IFER)
  374. #define GPIO_IFE_REG PIO_IFER
  375. #if defined(PIO_IFDR)
  376. #define GPIO_IFD_REG PIO_IFDR
  377. #define GPIO_IFS_REG PIO_IFSR
  378. #endif /* PIO_IFDR */
  379. #endif /* PIO_IFER */
  380. #endif /* GPIO_ID */
  381. #elif defined(__AVR32__)
  382. #include <avr32/io.h>
  383. #define GPIO_PE_REG &AVR32_GPIO.port[GPIO_ID].gpers
  384. #define GPIO_PD_REG &AVR32_GPIO.port[GPIO_ID].pderc
  385. #define GPIO_PS_REG &AVR32_GPIO.port[GPIO_ID].pder
  386. #define GPIO_OE_REG &AVR32_GPIO.port[GPIO_ID].oders
  387. #define GPIO_OD_REG &AVR32_GPIO.port[GPIO_ID].oderc
  388. #define GPIO_OS_REG &AVR32_GPIO.port[GPIO_ID].oder
  389. #define GPIO_SOD_REG &AVR32_GPIO.port[GPIO_ID].ovrs
  390. #define GPIO_COD_REG &AVR32_GPIO.port[GPIO_ID].ovrc
  391. #define GPIO_ODS_REG &AVR32_GPIO.port[GPIO_ID].ovr
  392. #define GPIO_PDS_REG &AVR32_GPIO.port[GPIO_ID].pvr
  393. #define GPIO_PUE_REG &AVR32_GPIO.port[GPIO_ID].puers
  394. #define GPIO_PUD_REG &AVR32_GPIO.port[GPIO_ID].puerc
  395. #define GPIO_PUS_REG &AVR32_GPIO.port[GPIO_ID].puer
  396. #define GPIO_MDE_REG &AVR32_GPIO.port[GPIO_ID].odmerc
  397. #define GPIO_MDD_REG &AVR32_GPIO.port[GPIO_ID].odmers
  398. #define GPIO_MDS_REG &AVR32_GPIO.port[GPIO_ID].odmer
  399. #define GPIO_IFE_REG &AVR32_GPIO.port[GPIO_ID].gfers
  400. #define GPIO_IFD_REG &AVR32_GPIO.port[GPIO_ID].gferc
  401. #define GPIO_IFS_REG &AVR32_GPIO.port[GPIO_ID].gfer
  402. /* Additional targets can be added here. */
  403. #endif /* MCU */
  404. #if defined(GPIO_COD_REG)
  405. #define GPIO_SET_LO(b) outr(GPIO_COD_REG, _BV(b))
  406. #define GPIO_SET_HI(b) outr(GPIO_SOD_REG, _BV(b))
  407. #elif defined(GPIO_SOD_REG)
  408. #define GPIO_SET_LO(b) cbi(GPIO_SOD_REG, b)
  409. #define GPIO_SET_HI(b) sbi(GPIO_SOD_REG, b)
  410. #else
  411. #define GPIO_SET_LO(b)
  412. #define GPIO_SET_HI(b)
  413. #endif
  414. #if defined(GPIO_PDS_REG)
  415. #define GPIO_GET(b) ((inr(GPIO_PDS_REG) & _BV(b)) == _BV(b))
  416. #else
  417. #define GPIO_GET(b)
  418. #endif
  419. #if defined(GPIO_OD_REG)
  420. #define GPIO_OUTPUT(b) outr(GPIO_OE_REG, _BV(b))
  421. #elif defined(GPIO_OE_REG)
  422. #define GPIO_OUTPUT(b) sbi(GPIO_OE_REG, b)
  423. #else
  424. #define GPIO_OUTPUT(b)
  425. #endif
  426. #if defined(GPIO_OD_REG)
  427. #define GPIO_INPUT(b) outr(GPIO_OD_REG, _BV(b))
  428. #elif defined(GPIO_OE_REG)
  429. #define GPIO_INPUT(b) cbi(GPIO_OE_REG, b)
  430. #else
  431. #define GPIO_INPUT(b)
  432. #endif
  433. #if defined(GPIO_PUD_REG)
  434. #define GPIO_PULLUP_ON(b) outr(GPIO_PUE_REG, _BV(b))
  435. #elif defined(GPIO_PUE_REG)
  436. #define GPIO_PULLUP_ON(b) sbi(GPIO_PUE_REG, b)
  437. #else
  438. #define GPIO_PULLUP_ON(b)
  439. #endif
  440. #if defined(GPIO_PUD_REG)
  441. #define GPIO_PULLUP_OFF(b) outr(GPIO_PUD_REG, _BV(b))
  442. #elif defined(GPIO_PUE_REG)
  443. #define GPIO_PULLUP_OFF(b) cbi(GPIO_PUE_REG, b)
  444. #else
  445. #define GPIO_PULLUP_OFF(b)
  446. #endif
  447. #endif
  448. #if !defined(GPIO_INIT)
  449. #warning "Define GPIO_INIT for your architecture"
  450. #endif
  451. /*@}*/