board.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. #ifndef _DEV_BOARD_H_
  2. #define _DEV_BOARD_H_
  3. /*
  4. * Copyright (C) 2001-2007 by egnite Software GmbH
  5. * Copyright (C) 2012 by egnite GmbH
  6. *
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. Neither the name of the copyright holders nor the names of
  19. * contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  29. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  30. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  31. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  32. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33. * SUCH DAMAGE.
  34. *
  35. * For additional information see http://www.ethernut.de/
  36. */
  37. /*!
  38. * \file dev/board.h
  39. * \brief Default board configuration.
  40. *
  41. * The purpose of this file is to help creating Nut/OS applications,
  42. * which will run on many (or all) supported target boards without
  43. * I/O-device related modification, by simply adding
  44. * \code
  45. * #include <dev/board>
  46. * \endcode
  47. *
  48. * The file is intended for inclusion in application code only. If
  49. * it seems to be required in a library file, then something else
  50. * is probably broken. Ignoring this advice may lead to unforeseen
  51. * header file hell. As an exception, it may be included into certain
  52. * initialization files like nutinit.c.
  53. *
  54. * Roughly speaking, this file provides a number of default devices,
  55. * which are evaluated in three steps:
  56. *
  57. * - Board specific settings are defined first.
  58. * - All defaults, which had not been declared for the board, may
  59. * be specified based on the target CPU.
  60. * - Finally all defaults are set, which were neither based on the
  61. * board nor on the target CPU.
  62. *
  63. * Instead of referring to platform specific device drivers, like
  64. * \code
  65. * NutRegisterDevice(&devDebug0, 0, 0);
  66. * freopen("uart0", "w", stdout);
  67. * \endcode
  68. * applications can use globally assigned macros, like
  69. * \code
  70. * NutRegisterDevice(&DEV_DEBUG, 0, 0);
  71. * freopen(DEV_DEBUG_NAME, "w", stdout);
  72. * \endcode
  73. * which will work for all target boards.
  74. *
  75. * \verbatim
  76. * $Id: board.h 5701 2014-05-16 10:14:27Z olereinhardt $
  77. * \endverbatim
  78. */
  79. /*
  80. * \todo Not sure if we should include them here. Possibly yes, but in
  81. * this case we should add all device related configuration files.
  82. * However, simply adding the complete cfg directory without sense
  83. * will significantly increase compile times during distcheck
  84. * and make it harder to solve conflicts.
  85. */
  86. #include <cfg/arch.h>
  87. #include <cfg/uart.h>
  88. #include <compiler.h>
  89. /*
  90. * Include individual board header files.
  91. *
  92. * These files can be used to override any of the default settings,
  93. * which are following below. Each supported board should have this,
  94. * even if all defaults are fine. So users may modify the settings
  95. * without having to touch this global file. The selection is
  96. * based on the PLATFORM entry in the board configuration file.
  97. * Some boards, like the MMNET family, may share the same header file
  98. * or, like the USPS family, may even share the same platform, if they
  99. * are based on the same hardware design.
  100. *
  101. * Individual headers must not define any settings, which are
  102. * configured by default anyway. Keep the maintenance effort for
  103. * your board to a minimum. Developers are not be able to check
  104. * every individual board when adding global modifications.
  105. *
  106. * In order to allow modifications via Userconf.mk, all settings should
  107. * make sure, that they were previously undefined, .e.g:
  108. * \code
  109. * #ifndef SAMPLE_MACRO
  110. * #define SAMPLE_MACRO 1
  111. * #endif
  112. * \endcode
  113. *
  114. * All individual headers must contain the following preprocessor
  115. * check to make sure, that it is included via dev/board.h only:
  116. * \code
  117. * #ifndef _DEV_BOARD_H_
  118. * #error "Do not include this file directly. Use dev/board.h instead!"
  119. * #endif
  120. * \endcode
  121. * Otherwise compilation may fail after new items are added here.
  122. *
  123. * Please keep this list sorted alphabetically.
  124. */
  125. #if defined(ARTHERNET1)
  126. #include <arch/avr/board/arthernet1.h>
  127. #define BOARDNAME "ARTHERNET1"
  128. #elif defined(AT91SAM7X_EK)
  129. #include <arch/arm/board/at91sam7x_ek.h>
  130. #define BOARDNAME "AT91SAM7X_EK"
  131. #elif defined(AT91SAM9260_EK)
  132. #include <arch/arm/board/at91sam9260_ek.h>
  133. #define BOARDNAME "AT91SAM9260_EK"
  134. #elif defined(CHARON2)
  135. #include <arch/avr/board/charon2.h>
  136. #define BOARDNAME "CHARON2"
  137. #elif defined(ELEKTOR_IR1)
  138. #include <arch/arm/board/elektor_ir1.h>
  139. #define BOARDNAME "ELEKTOR_IR1"
  140. #elif defined(ENET_SAM7X)
  141. #include <arch/arm/board/enet_sam7x.h>
  142. #define BOARDNAME "ENET_SAM7X"
  143. #elif defined(ETHERNUT1)
  144. #include <arch/avr/board/ethernut1.h>
  145. #define BOARDNAME "ETHERNUT1"
  146. #elif defined(ETHERNUT2)
  147. #include <arch/avr/board/ethernut2.h>
  148. #define BOARDNAME "ETHERNUT2"
  149. #elif defined(AT90USBKEY)
  150. #include <arch/avr/board/at90usbkey.h>
  151. #define BOARDNAME "AT90USBKEY"
  152. #elif defined(ETHERNUT3)
  153. #include <arch/arm/board/ethernut3.h>
  154. #if defined(NUT_CONFIG_X12RTC)
  155. #define BOARDNAME "Ethernut 3.0"
  156. #else
  157. #define BOARDNAME "Ethernut 3.1"
  158. #endif
  159. #elif defined(ETHERNUT5)
  160. #include <arch/arm/board/ethernut5.h>
  161. #define BOARDNAME "ETHERNUT5"
  162. #elif defined(EVK1100)
  163. #include <arch/avr32/board/evk1100.h>
  164. #define BOARDNAME "EVK1100"
  165. #elif defined(EVK1101)
  166. #include <arch/avr32/board/evk1101.h>
  167. #define BOARDNAME "EVK1101"
  168. #elif defined(EVK1104)
  169. #include <arch/avr32/board/evk1104.h>
  170. #define BOARDNAME "EVK1104"
  171. #elif defined(EVK1105)
  172. #include <arch/avr32/board/evk1105.h>
  173. #define BOARDNAME "EVK1105"
  174. #elif defined(L1_DISCOVERY)
  175. #include <arch/cm3/board/l1_discovery.h>
  176. #define BOARDNAME "L1_DISCOVERY"
  177. #elif defined(F1_DISCOVERY)
  178. #include <arch/cm3/board/f1_discovery.h>
  179. #define BOARDNAME "F1_DISCOVERY"
  180. #elif defined(F4_DISCOVERY)
  181. #include <arch/cm3/board/f4_discovery.h>
  182. #define BOARDNAME "F4_DISCOVERY"
  183. #elif defined(F429_DISCOVERY)
  184. #include <arch/cm3/board/f429_discovery.h>
  185. #define BOARDNAME "F429_DISCOVERY"
  186. #elif defined(F3_DISCOVERY)
  187. #include <arch/cm3/board/f3_discovery.h>
  188. #define BOARDNAME "F3_DISCOVERY"
  189. #elif defined(FLECX1)
  190. #include <arch/cm3/board/flecx1.h>
  191. #define BOARDNAME "FLECX1"
  192. #elif defined(GBAXPORT2)
  193. #include <arch/arm/board/gba_xport2.h>
  194. #define BOARDNAME "GBAXPORT2"
  195. #elif defined(MBED_NXP_LPC1768)
  196. #include <arch/cm3/board/mbed.h>
  197. #define BOARDNAME "MBED_NXP_LPC1768"
  198. #elif defined(KOBOLD1)
  199. #include <arch/cm3/board/kobold1.h>
  200. #define BOARDNAME "KOBOLD1"
  201. #elif defined(KSK_LPC1788_SK)
  202. #include <arch/cm3/board/ksk_lpc1788_sk.h>
  203. #define BOARDNAME "KSK_LPC1788_SK"
  204. #elif defined(KSK_LPC4088)
  205. #include <arch/cm3/board/ksk_lpc4088.h>
  206. #define BOARDNAME "KSK_LPC4088"
  207. #elif defined(MCO_COMPACT)
  208. #include <arch/cm3/board/mco_compact.h>
  209. #define BOARDNAME "MCO_COMPACT"
  210. #elif defined(LISA)
  211. #include <arch/cm3/board/lisa.h>
  212. #define BOARDNAME "LISA"
  213. #elif defined(MMNET01) || defined(MMNET02) || defined(MMNET101) || defined(MMNET102)
  214. #include <arch/avr/board/mmnet.h>
  215. #define BOARDNAME "MMNET0x"
  216. #elif defined(MORPHOQ1)
  217. #include <arch/arm/board/morphoq1.h>
  218. #define BOARDNAME "MORPHOQ1"
  219. #elif defined(SAM7ETH)
  220. #include <arch/arm/board/sam7eth.h>
  221. #define BOARDNAME "SAM7ETH"
  222. #elif defined(STM3210C_EVAL)
  223. #include <arch/cm3/board/stm3210c_eval.h>
  224. #define BOARDNAME "STM3210C_EVAL"
  225. #elif defined(STM3210E_EVAL)
  226. #include <arch/cm3/board/stm3210e_eval.h>
  227. #define BOARDNAME "STM3210E_EVA"
  228. #elif defined(STM3220G_EVAL)
  229. #include <arch/cm3/board/stm3220g_eval.h>
  230. #define BOARDNAME "STM3220G_EVAL"
  231. #elif defined(STM3240G_EVAL)
  232. #include <arch/cm3/board/stm3240g_eval.h>
  233. #define BOARDNAME "STM3240G_EVAL"
  234. #elif defined(STEVAL_PCC010V2)
  235. #include <arch/cm3/board/steval_pcc010v2.h>
  236. #define BOARDNAME "STEVAL_PCC010V2"
  237. #elif defined(STM32_CAN)
  238. #include <arch/cm3/board/stm32_can.h>
  239. #define BOARDNAME "STM32_CAN"
  240. #elif defined(STM32_COMSTICK)
  241. #include <arch/cm3/board/stm32_comstick.h>
  242. #define BOARDNAME "STM32_COMSTICK"
  243. #elif defined(STM32F4DIS_BB)
  244. #define BOARDNAME "STM32F4DIS_BB"
  245. #include <arch/cm3/board/stm32f4dis_bb.h>
  246. #elif defined(USPS)
  247. #include <arch/cm3/board/usps.h>
  248. #define BOARDNAME "USPS"
  249. #elif defined(NUCLEO)
  250. #include <arch/cm3/board/nucleo.h>
  251. #define BOARDNAME "USPS"
  252. #elif defined(OLIMEX_LPCE2294)
  253. #include <arch/arm/board/olimex_lpce2294.h>
  254. #define BOARDNAME "OLIMEX_LPCE229"
  255. #elif defined(XNUT_100) || defined(XNUT_105)
  256. #include <arch/avr/board/xnut.h>
  257. #define BOARDNAME "XNUT_10x"
  258. #elif defined(SM2_MU)
  259. #include <arch/m68k/board/sm2_mu.h>
  260. #define BOARDNAME "SM2_MU"
  261. #elif defined(ZERO_EK)
  262. #include <arch/arm/board/zero_ek.h>
  263. #define BOARDNAME "ZERO_EK"
  264. #elif defined(__arm__)
  265. #if defined(__CORTEX__)
  266. #define BOARDNAME "Cortex Arm"
  267. #else
  268. #define BOARDNAME "Generic ARM"
  269. #endif
  270. #elif defined(__AVR32__)
  271. #define BOARDNAME "Generic AVR32"
  272. #elif defined(__AVR__)
  273. #define BOARDNAME "Generic AVR"
  274. #else
  275. #define BOARDNAME "Unknown"
  276. #endif
  277. /*
  278. * Define CPU specific defaults.
  279. *
  280. * After each board claims its individual settings, we will try
  281. * to figure out remaining defaults based on the CPU or CPU family.
  282. */
  283. #if defined(__AVR__)
  284. /*
  285. * UART devices for Atmel's AVR 8-bit family.
  286. */
  287. #include <dev/usartavr.h>
  288. /* We only need to define the devices, their names are system wide
  289. defaults. Note, that we use the advanced drivers here. Boards
  290. with scarce memory resources or running a slow clocks may use
  291. devUart0 and devUart1 instead. */
  292. #ifndef DEV_UART0
  293. #define DEV_UART0 devUsartAvr0
  294. #endif
  295. #ifndef DEV_UART1
  296. #define DEV_UART1 devUsartAvr1
  297. #endif
  298. /*
  299. * SPI bus controller for Atmel's AVR 8-bit family.
  300. */
  301. #include <dev/spibus_avr.h>
  302. #ifndef DEV_SPIBUS0
  303. #define DEV_SPIBUS0 spiBus0Avr
  304. #endif
  305. #elif defined(MCU_AT91)
  306. /*
  307. * Debug device for Atmel's ARM based AT91 family.
  308. *
  309. * All chips with DBGU interface will most likely use it for debug
  310. * output. If such an interface is not available, than we rely on
  311. * the system wide default, which is declared further down.
  312. *
  313. * \note We assume, that the system default debug driver devDebug0
  314. * is always available on devices without DBGU.
  315. */
  316. #ifdef DBGU_BASE
  317. #ifndef DEV_DEBUG
  318. #define DEV_DEBUG devDebug
  319. #endif
  320. #ifndef DEV_DEBUG_NAME
  321. #define DEV_DEBUG_NAME "dbgu"
  322. #endif
  323. #endif
  324. /*
  325. * UART devices for Atmel's ARM based AT91 family.
  326. *
  327. * Note, that DEV_UARTD is special. It uses the DGBU interface, but
  328. * as an interrupt driven driver, it shouldn't be used for debugging.
  329. */
  330. #include <dev/usartat91.h>
  331. #ifndef DEV_UART0
  332. #define DEV_UART0 devUsartAt910
  333. #endif
  334. #ifndef DEV_UART1
  335. #define DEV_UART1 devUsartAt911
  336. #endif
  337. #if !defined(DEV_UARTD) && defined(DBGU_BASE)
  338. #define DEV_UARTD devDbguAt91
  339. #endif
  340. /*
  341. * SPI bus controller for Atmel's ARM based AT91 family.
  342. */
  343. #if !defined(DEV_SPIBUS0) && defined(SPI0_BASE)
  344. #include <dev/spibus_at91.h>
  345. #define DEV_SPIBUS0 spiBus0At91
  346. #endif
  347. /*
  348. * TWI / I2C bus controller for Atmel's ARM based AT91 family.
  349. *
  350. * \todo Somewhere is a problem with bit banging. If the CPU has a TWI
  351. * hardware interface, we cannot define another controller based on bit
  352. * banging.
  353. */
  354. #include <cfg/twi.h>
  355. #include <dev/twif.h>
  356. #if defined(MCU_AT91R40008)
  357. #include <dev/twibus_bbif.h>
  358. #define DEF_TWIBUS TwBbifBus
  359. #else
  360. #include <dev/twibus_at91.h>
  361. #define DEF_TWIBUS At91TwiBus
  362. #endif
  363. #elif defined(MCU_LPC17xx)
  364. /*
  365. * UART devices for the ARM based LPC17xx family.
  366. *
  367. * \note Instead of providing literal names, references to the
  368. * driver structure are used here. Therefore all names are
  369. * given here, even it they use the system wide default
  370. * name. Furthermore, all possible devices seem to have
  371. * been added here, which makes it hard for applications
  372. * to figure out, if they are available at all on the
  373. * target hardware.
  374. */
  375. #include <dev/usart_lpc17xx.h>
  376. #ifndef DEV_UART0
  377. #define DEV_UART0 devUsartLpc17xx_0
  378. #endif
  379. #ifndef DEV_UART0_NAME
  380. #define DEV_UART0_NAME DEV_UART0.dev_name
  381. #endif
  382. #ifndef DEV_UART1
  383. #define DEV_UART1 devUsartLpc17xx_1
  384. #endif
  385. #ifndef DEV_UART1_NAME
  386. #define DEV_UART1_NAME DEV_UART1.dev_name
  387. #endif
  388. #ifndef DEV_UART2
  389. #define DEV_UART2 devUsartLpc17xx_2
  390. #endif
  391. #ifndef DEV_UART2_NAME
  392. #define DEV_UART2_NAME DEV_UART2.dev_name
  393. #endif
  394. #ifndef DEV_UART3
  395. #define DEV_UART3 devUsartLpc17xx_3
  396. #endif
  397. #ifndef DEV_UART3_NAME
  398. #define DEV_UART3_NAME DEV_UART3.dev_name
  399. #endif
  400. #elif defined(__AVR32__)
  401. /*
  402. * UART devices for Atmel's AVR 32-bit family.
  403. *
  404. * Clear and simple, that's how we like it. But wait, where is the
  405. * debug driver?
  406. */
  407. #include <dev/usartavr32.h>
  408. #ifndef DEV_UART0
  409. #define DEV_UART0 devUsartAvr320
  410. #endif
  411. #ifndef DEV_UART1
  412. #define DEV_UART1 devUsartAvr321
  413. #endif
  414. #ifndef DEV_UART2
  415. #define DEV_UART2 devUsartAvr322
  416. #endif
  417. /*
  418. * SPI bus controllers for Atmel's AVR 32-bit family.
  419. */
  420. #include <dev/spibus_avr32.h>
  421. #define DEV_SPIBUS0 spiBus0Avr32
  422. #define DEV_SPIBUS1 spiBus1Avr32
  423. #elif defined(MCU_STM32)
  424. /*
  425. * Debug devices for the ARM based STM32 family.
  426. *
  427. * \todo Looks like this debug driver is using a normal, possibly
  428. * interrupt driven UART driver, which makes its use quite
  429. * limited. Better do not use it within interrupt routines
  430. * and do not rely on synchronicity. Output may be intermixed
  431. * or even scrambled during debugging.
  432. */
  433. #ifndef DEV_DEBUG
  434. #define DEV_DEBUG DEV_UART1
  435. #endif
  436. #ifndef DEV_DEBUG_NAME
  437. #define DEV_DEBUG_NAME DEV_UART1_NAME
  438. #endif
  439. /*
  440. * UART devices for the ARM based STM32 family.
  441. *
  442. * \note Instead of providing literal names, references to the
  443. * driver structure are used here. Therefore all names are
  444. * given here, even it they use the system wide default
  445. * name. Furthermore, all possible devices seem to have
  446. * been added here, which makes it hard for applications
  447. * to figure out, if they are available at all on the
  448. * target hardware.
  449. */
  450. #include <dev/usartstm32.h>
  451. #ifndef DEV_UART1
  452. #define DEV_UART1 devUsartStm32_1
  453. #endif
  454. #ifndef DEV_UART1_NAME
  455. #define DEV_UART1_NAME DEV_UART1.dev_name
  456. #endif
  457. #ifndef DEV_UART2
  458. #define DEV_UART2 devUsartStm32_2
  459. #endif
  460. #ifndef DEV_UART2_NAME
  461. #define DEV_UART2_NAME DEV_UART2.dev_name
  462. #endif
  463. #ifndef DEV_UART3
  464. #define DEV_UART3 devUsartStm32_3
  465. #endif
  466. #ifndef DEV_UART3_NAME
  467. #define DEV_UART3_NAME DEV_UART3.dev_name
  468. #endif
  469. #ifndef DEV_UART4
  470. #define DEV_UART4 devUartStm32_4
  471. #endif
  472. #ifndef DEV_UART4_NAME
  473. #define DEV_UART4_NAME DEV_UART4.dev_name
  474. #endif
  475. #ifndef DEV_UART5
  476. #define DEV_UART5 devUartStm32_5
  477. #endif
  478. #ifndef DEV_UART5_NAME
  479. #define DEV_UART5_NAME DEV_UART5.dev_name
  480. #endif
  481. #ifndef DEV_UART6
  482. #define DEV_UART6 devUsartStm32_6
  483. #endif
  484. #ifndef DEV_UART6_NAME
  485. #define DEV_UART6_NAME DEV_USART6.dev_name
  486. #endif
  487. /*
  488. * System default UART0 is not available on STM32 boards. Thus,
  489. * we declare UART1 as the default.
  490. */
  491. #ifndef DEV_UART
  492. #define DEV_UART DEV_UART1
  493. #define DEV_UART_NAME DEV_UART1_NAME
  494. #endif
  495. /*
  496. * TWI / I2C bus controller for the ARM based STM32 family.
  497. */
  498. #include <cfg/twi.h>
  499. #include <dev/twif.h>
  500. #include <arch/cm3/stm/stm32_twi.h>
  501. #elif defined(__NUT_EMULATION__)
  502. /*
  503. * UART devices for the UNIX emulation.
  504. */
  505. #include <dev/usartavr.h>
  506. #ifndef DEV_UART0
  507. #define DEV_UART0 devUsartAvr0
  508. #endif
  509. #ifndef DEV_UART1
  510. #define DEV_UART1 devUsartAvr1
  511. #endif
  512. #define DEV_UART1_NAME "uart1"
  513. #endif
  514. /*
  515. * Define system wide defaults.
  516. *
  517. * After each board and each target CPU claimed their individual settings,
  518. * we will set all remaining defaults.
  519. *
  520. * Use most likely defaults here, to keep board and CPU defaults to a
  521. * minimum. For example, the UART0 device is named "uart0" by almost
  522. * all drivers and there is rarely any reason other than to confuse
  523. * people for choosing a different name. Sticking to the default
  524. * reduces code lines.
  525. */
  526. /*
  527. * UART device defaults.
  528. *
  529. * We have all kind of UART drivers. Some platforms, like the AVR, do
  530. * have four(!) of them, all running on the same physical interface:
  531. * One simple polling driver, one fast interrupt driven driver with
  532. * limited buffer and handshake capabilities, one full fledged driver
  533. * with all bells and whistles and one special driver optimized for
  534. * AHDLC.
  535. *
  536. * Furthermore all drivers use different structure variable names.
  537. * It doesn't make much sense to define any default here.
  538. *
  539. * Device names, however, are the same for most implementations.
  540. * We will also select the UART with the lowest index as our default
  541. * DEV_UART.
  542. */
  543. #ifdef DEV_UART0
  544. #ifndef DEV_UART0_NAME
  545. #define DEV_UART0_NAME "uart0"
  546. #endif
  547. #ifndef DEV_UART
  548. #define DEV_UART DEV_UART0
  549. #endif
  550. #ifndef DEV_UART_NAME
  551. #define DEV_UART_NAME DEV_UART0_NAME
  552. #endif
  553. #endif
  554. #ifdef DEV_UART1
  555. #ifndef DEV_UART1_NAME
  556. #define DEV_UART1_NAME "uart1"
  557. #endif
  558. #ifndef DEV_UART
  559. #define DEV_UART DEV_UART1
  560. #endif
  561. #ifndef DEV_UART_NAME
  562. #define DEV_UART_NAME DEV_UART1_NAME
  563. #endif
  564. #endif
  565. #ifdef DEV_UART2
  566. #ifndef DEV_UART2_NAME
  567. #define DEV_UART2_NAME "uart2"
  568. #endif
  569. #ifndef DEV_UART
  570. #define DEV_UART DEV_UART2
  571. #endif
  572. #ifndef DEV_UART_NAME
  573. #define DEV_UART_NAME DEV_UART2_NAME
  574. #endif
  575. #endif
  576. #ifdef DEV_UART3
  577. #ifndef DEV_UART3_NAME
  578. #define DEV_UART3_NAME "uart3"
  579. #endif
  580. #ifndef DEV_UART
  581. #define DEV_UART DEV_UART3
  582. #endif
  583. #ifndef DEV_UART_NAME
  584. #define DEV_UART_NAME DEV_UART3_NAME
  585. #endif
  586. #endif
  587. #ifdef DEV_UART4
  588. #ifndef DEV_UART4_NAME
  589. #define DEV_UART4_NAME "uart4"
  590. #endif
  591. #ifndef DEV_UART
  592. #define DEV_UART DEV_UART4
  593. #endif
  594. #ifndef DEV_UART_NAME
  595. #define DEV_UART_NAME DEV_UART4_NAME
  596. #endif
  597. #endif
  598. #ifdef DEV_UART5
  599. #ifndef DEV_UART5_NAME
  600. #define DEV_UART5_NAME "uart5"
  601. #endif
  602. #ifndef DEV_UART
  603. #define DEV_UART DEV_UART5
  604. #endif
  605. #ifndef DEV_UART_NAME
  606. #define DEV_UART_NAME DEV_UART5_NAME
  607. #endif
  608. #endif
  609. #ifdef DEV_UART6
  610. #ifndef DEV_UART6_NAME
  611. #define DEV_UART6_NAME "uart6"
  612. #endif
  613. #ifndef DEV_UART
  614. #define DEV_UART DEV_UART6
  615. #endif
  616. #ifndef DEV_UART_NAME
  617. #define DEV_UART_NAME DEV_UART6_NAME
  618. #endif
  619. #endif
  620. #ifdef DEV_UART7
  621. #ifndef DEV_UART7_NAME
  622. #define DEV_UART7_NAME "uart7"
  623. #endif
  624. #ifndef DEV_UART
  625. #define DEV_UART DEV_UART7
  626. #endif
  627. #ifndef DEV_UART_NAME
  628. #define DEV_UART_NAME DEV_UART7_NAME
  629. #endif
  630. #endif
  631. #ifdef DEV_UARTD
  632. #ifndef DEV_UARTD_NAME
  633. #define DEV_UARTD_NAME "uartd"
  634. #endif
  635. #ifndef DEV_UART
  636. #define DEV_UART DEV_UARTD
  637. #endif
  638. #ifndef DEV_UART_NAME
  639. #define DEV_UART_NAME DEV_UARTD_NAME
  640. #endif
  641. #endif
  642. /*
  643. * Debug device defaults.
  644. *
  645. * Due to its hardware dependency, there is no such thing like a global
  646. * debug device. However, in reality devDebug0 is available on most
  647. * platforms. Not sure, if it had been a good idea giving them all the same
  648. * structure name. Probably they were created by copying and pasting
  649. * the original AVR driver. The good news is, that they all share the same
  650. * header file.
  651. *
  652. * In most cases the driver will be implemented on the default UART. So
  653. * we can use that name as the most likely default.
  654. *
  655. * Note, that Nut/OS device names reflect the hardware they are attached to.
  656. * If more than one driver exists for the same hardware, they will all have
  657. * the same name. In most cases this prevents applications from accidently
  658. * using more than one driver on a specific hardware interface, because
  659. * NutRegisterDevice() expects a unique name for each registered device.
  660. */
  661. #include <dev/debug.h>
  662. #ifndef DEV_DEBUG
  663. #define DEV_DEBUG devDebug0
  664. #endif
  665. #ifndef DEV_DEBUG_NAME
  666. #define DEV_DEBUG_NAME DEV_UART_NAME
  667. #endif
  668. /*
  669. * Console device defaults.
  670. *
  671. * The console device is used for stdin and stdout, attached to the
  672. * main serial port of the board. If more than one serial port is
  673. * available, then the same port that is attached to the debug device
  674. * is selected. But it's not that easy really.
  675. *
  676. * In earlier releases Nut/OS provides the debug device for progress
  677. * reports. At that time the debug driver was write-only to keep it
  678. * small and simple. When user input was required, the interrupt
  679. * driven UART0 driver was used instead. As long as both drivers
  680. * referred to the same physical interface, this was no problem.
  681. *
  682. * The later supported AT91 family offers a unique DGBU interface,
  683. * which was naturally used for the debug driver. When running existing
  684. * applications, users of this hardware had to switch between DBGU
  685. * and UART0, either by changing jumper settings or changing connectors.
  686. * Can you imagine, how often users were desperately waiting for output
  687. * until they recognized, that the application requires to switch the
  688. * physical interface?
  689. *
  690. * To solve this, some debug drivers had been expanded with input
  691. * capabilities, allowing to use same interface for write-only and
  692. * read/write applications. But the increase of code size is not
  693. * bearable by all targets, and quite senseless, if they already have
  694. * a full UART driver at the same physical interface. If defined,
  695. * the configuration item NUT_DEV_DEBUG_READ enables the input
  696. * capability and is used here, to determine, whether the debug
  697. * device is able to support both, stdout and stdin.
  698. */
  699. #ifndef DEV_CONSOLE
  700. #ifdef NUT_DEV_DEBUG_READ
  701. /* Debug device is read/write, use it. */
  702. #define DEV_CONSOLE DEV_DEBUG
  703. #ifndef DEV_CONSOLE_NAME
  704. #define DEV_CONSOLE_NAME DEV_DEBUG_NAME
  705. #endif
  706. #else
  707. /* Debug device is write-only, use default UART. */
  708. #define DEV_CONSOLE DEV_UART
  709. #ifndef DEV_CONSOLE_NAME
  710. #define DEV_CONSOLE_NAME DEV_UART_NAME
  711. #endif
  712. #endif
  713. #endif
  714. /*
  715. * Ethernet device defaults.
  716. *
  717. * Boards may not offer any Ethernet interface. However, many of our
  718. * sample applications are network based. It would require a lot of
  719. * ugly preprocessor ifdefs to make them compile and avoid crashing
  720. * them on hardware without a network interface. Therefore a so called
  721. * Null-driver will be used if no real interface had been specified
  722. * above.
  723. */
  724. #ifndef DEV_ETHER
  725. #include <dev/null_ether.h>
  726. #endif
  727. #ifndef DEV_ETHER_NAME
  728. #define DEV_ETHER_NAME "eth0"
  729. #endif
  730. /*
  731. * SPI bus controller defaults.
  732. *
  733. * Select the interface with the lowest index as our default.
  734. */
  735. #ifndef DEV_SPIBUS
  736. #if defined(DEV_SPIBUS0)
  737. #define DEV_SPIBUS DEV_SPIBUS0
  738. #elif defined(DEV_SPIBUS1)
  739. #define DEV_SPIBUS DEV_SPIBUS1
  740. #endif
  741. #endif
  742. /*
  743. * No TWI / I2C bus controller defaults.
  744. */
  745. /*
  746. * Memory card driver defaults.
  747. *
  748. * We expect the board or CPU configuration to specify DEV_MMCARD0,
  749. * which will be used for the default interface DEV_MMCARD.
  750. */
  751. #if defined(DEV_MMCARD0)
  752. #ifndef DEV_MMCARD
  753. #define DEV_MMCARD DEV_MMCARD0
  754. #endif
  755. #ifndef DEV_MMCARD0_NAME
  756. #define DEV_MMCARD0_NAME "MMC0"
  757. #endif
  758. #ifndef DEV_MMCARD_NAME
  759. #define DEV_MMCARD_NAME DEV_MMCARD0_NAME
  760. #endif
  761. #endif
  762. /*
  763. * Real time clock defaults.
  764. *
  765. * We expect the board or CPU configuration to specify RTC_CHIP0,
  766. * which will be used for the default interface RTC_CHIP.
  767. *
  768. * This effort looks a little bit funny, because boards will rarely have
  769. * two of this. But who knows...
  770. */
  771. #ifdef RTC_CHIP0
  772. #ifndef RTC_CHIP
  773. #define RTC_CHIP RTC_CHIP0
  774. #endif
  775. #endif
  776. extern void NutBoardInit(void);
  777. extern void NutIdleInit(void);
  778. extern void NutMainInit(void);
  779. typedef void (*NutIdleCallback)(void);
  780. extern NutIdleCallback NutRegisterIdleCallback(NutIdleCallback func);
  781. #endif