sbbif3.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  1. #ifndef _DEV_SBBIF3_H_
  2. #define _DEV_SBBIF3_H_
  3. /*
  4. * Copyright (C) 2007 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. /*!
  35. * \file dev/sbbi3.h
  36. * \brief Serial bit banged interface 3.
  37. *
  38. * \verbatim
  39. *
  40. * $Log: sbbif3.h,v $
  41. * Revision 1.1 2007/04/12 09:07:54 haraldkipp
  42. * Configurable SPI added.
  43. *
  44. *
  45. * \endverbatim
  46. */
  47. #include <cfg/arch/gpio.h>
  48. /*!
  49. * \brief Maximum number of devices (chip selects).
  50. */
  51. #ifndef SBBI3_MAX_DEVICES
  52. #define SBBI3_MAX_DEVICES 4
  53. #endif
  54. #if defined(__AVR__) /* MCU */
  55. /*
  56. * AVR implementation.
  57. * ======================================
  58. */
  59. #ifdef SBBI3_CS0_BIT
  60. #if (SBBI3_CS0_AVRPORT == AVRPORTB)
  61. #define SBBI3_CS0_SOD_REG PORTB
  62. #define SBBI3_CS0_OE_REG DDRB
  63. #elif (SBBI3_CS0_AVRPORT == AVRPORTD)
  64. #define SBBI3_CS0_SOD_REG PORTD
  65. #define SBBI3_CS0_OE_REG DDRD
  66. #elif (SBBI3_CS0_AVRPORT == AVRPORTE)
  67. #define SBBI3_CS0_SOD_REG PORTE
  68. #define SBBI3_CS0_OE_REG DDRE
  69. #elif (SBBI3_CS0_AVRPORT == AVRPORTF)
  70. #define SBBI3_CS0_SOD_REG PORTF
  71. #define SBBI3_CS0_OE_REG DDRF
  72. #elif (SBBI3_CS0_AVRPORT == AVRPORTG)
  73. #define SBBI3_CS0_SOD_REG PORTG
  74. #define SBBI3_CS0_OE_REG DDRG
  75. #elif (SBBI3_CS0_AVRPORT == AVRPORTH)
  76. #define SBBI3_CS0_SOD_REG PORTH
  77. #define SBBI3_CS0_OE_REG DDRH
  78. #endif
  79. /*! \brief Enable SBBI3 chip select 0 output. */
  80. #define SBBI3_CS0_ENA() sbi(SBBI3_CS0_OE_REG, SBBI3_CS0_BIT)
  81. /*! \brief Set SBBI3 chip select 0 output low. */
  82. #define SBBI3_CS0_CLR() cbi(SBBI3_CS0_SOD_REG, SBBI3_CS0_BIT)
  83. /*! \brief Set SBBI3 chip select 0 output high. */
  84. #define SBBI3_CS0_SET() sbi(SBBI3_CS0_SOD_REG, SBBI3_CS0_BIT)
  85. #endif /* SBBI3_CS0_BIT */
  86. #ifdef SBBI3_CS1_BIT
  87. #if (SBBI3_CS1_AVRPORT == AVRPORTB)
  88. #define SBBI3_CS1_SOD_REG PORTB
  89. #define SBBI3_CS1_OE_REG DDRB
  90. #elif (SBBI3_CS1_AVRPORT == AVRPORTD)
  91. #define SBBI3_CS1_SOD_REG PORTD
  92. #define SBBI3_CS1_OE_REG DDRD
  93. #elif (SBBI3_CS1_AVRPORT == AVRPORTE)
  94. #define SBBI3_CS1_SOD_REG PORTE
  95. #define SBBI3_CS1_OE_REG DDRE
  96. #elif (SBBI3_CS1_AVRPORT == AVRPORTF)
  97. #define SBBI3_CS1_SOD_REG PORTF
  98. #define SBBI3_CS1_OE_REG DDRF
  99. #elif (SBBI3_CS1_AVRPORT == AVRPORTG)
  100. #define SBBI3_CS1_SOD_REG PORTG
  101. #define SBBI3_CS1_OE_REG DDRG
  102. #elif (SBBI3_CS1_AVRPORT == AVRPORTH)
  103. #define SBBI3_CS1_SOD_REG PORTH
  104. #define SBBI3_CS1_OE_REG DDRH
  105. #endif
  106. /*! \brief Enable SBBI3 chip select 1 output. */
  107. #define SBBI3_CS1_ENA() sbi(SBBI3_CS1_OE_REG, SBBI3_CS1_BIT)
  108. /*! \brief Set SBBI3 chip select 1 output low. */
  109. #define SBBI3_CS1_CLR() cbi(SBBI3_CS1_SOD_REG, SBBI3_CS1_BIT)
  110. /*! \brief Set SBBI3 chip select 1 output high. */
  111. #define SBBI3_CS1_SET() sbi(SBBI3_CS1_SOD_REG, SBBI3_CS1_BIT)
  112. #endif /* SBBI3_CS1_BIT */
  113. #ifdef SBBI3_CS2_BIT
  114. #if (SBBI3_CS2_AVRPORT == AVRPORTB)
  115. #define SBBI3_CS2_SOD_REG PORTB
  116. #define SBBI3_CS2_OE_REG DDRB
  117. #elif (SBBI3_CS2_AVRPORT == AVRPORTD)
  118. #define SBBI3_CS2_SOD_REG PORTD
  119. #define SBBI3_CS2_OE_REG DDRD
  120. #elif (SBBI3_CS2_AVRPORT == AVRPORTE)
  121. #define SBBI3_CS2_SOD_REG PORTE
  122. #define SBBI3_CS2_OE_REG DDRE
  123. #elif (SBBI3_CS2_AVRPORT == AVRPORTF)
  124. #define SBBI3_CS2_SOD_REG PORTF
  125. #define SBBI3_CS2_OE_REG DDRF
  126. #elif (SBBI3_CS2_AVRPORT == AVRPORTG)
  127. #define SBBI3_CS2_SOD_REG PORTG
  128. #define SBBI3_CS2_OE_REG DDRG
  129. #elif (SBBI3_CS2_AVRPORT == AVRPORTH)
  130. #define SBBI3_CS2_SOD_REG PORTH
  131. #define SBBI3_CS2_OE_REG DDRH
  132. #endif
  133. /*! \brief Enable SBBI3 chip select 2 output. */
  134. #define SBBI3_CS2_ENA() sbi(SBBI3_CS2_OE_REG, SBBI3_CS2_BIT)
  135. /*! \brief Set SBBI3 chip select 2 output low. */
  136. #define SBBI3_CS2_CLR() cbi(SBBI3_CS2_SOD_REG, SBBI3_CS2_BIT)
  137. /*! \brief Set SBBI3 chip select 2 output high. */
  138. #define SBBI3_CS2_SET() sbi(SBBI3_CS2_SOD_REG, SBBI3_CS2_BIT)
  139. #endif /* SBBI3_CS2_BIT */
  140. #ifdef SBBI3_CS3_BIT
  141. #if (SBBI3_CS3_AVRPORT == AVRPORTB)
  142. #define SBBI3_CS3_SOD_REG PORTB
  143. #define SBBI3_CS3_OE_REG DDRB
  144. #elif (SBBI3_CS3_AVRPORT == AVRPORTD)
  145. #define SBBI3_CS3_SOD_REG PORTD
  146. #define SBBI3_CS3_OE_REG DDRD
  147. #elif (SBBI3_CS3_AVRPORT == AVRPORTE)
  148. #define SBBI3_CS3_SOD_REG PORTE
  149. #define SBBI3_CS3_OE_REG DDRE
  150. #elif (SBBI3_CS3_AVRPORT == AVRPORTF)
  151. #define SBBI3_CS3_SOD_REG PORTF
  152. #define SBBI3_CS3_OE_REG DDRF
  153. #elif (SBBI3_CS3_AVRPORT == AVRPORTG)
  154. #define SBBI3_CS3_SOD_REG PORTG
  155. #define SBBI3_CS3_OE_REG DDRG
  156. #elif (SBBI3_CS3_AVRPORT == AVRPORTH)
  157. #define SBBI3_CS3_SOD_REG PORTH
  158. #define SBBI3_CS3_OE_REG DDRH
  159. #endif
  160. /*! \brief Enable SBBI3 chip select 3 output. */
  161. #define SBBI3_CS3_ENA() sbi(SBBI3_CS3_OE_REG, SBBI3_CS3_BIT)
  162. /*! \brief Set SBBI3 chip select 3 output low. */
  163. #define SBBI3_CS3_CLR() cbi(SBBI3_CS3_SOD_REG, SBBI3_CS3_BIT)
  164. /*! \brief Set SBBI3 chip select 3 output high. */
  165. #define SBBI3_CS3_SET() sbi(SBBI3_CS3_SOD_REG, SBBI3_CS3_BIT)
  166. #endif /* SBBI3_CS3_BIT */
  167. #ifdef SBBI3_RST0_BIT
  168. #if (SBBI3_RST0_AVRPORT == AVRPORTB)
  169. #define SBBI3_RST0_SOD_REG PORTB
  170. #define SBBI3_RST0_OE_REG DDRB
  171. #elif (SBBI3_RST0_AVRPORT == AVRPORTD)
  172. #define SBBI3_RST0_SOD_REG PORTD
  173. #define SBBI3_RST0_OE_REG DDRD
  174. #elif (SBBI3_RST0_AVRPORT == AVRPORTE)
  175. #define SBBI3_RST0_SOD_REG PORTE
  176. #define SBBI3_RST0_OE_REG DDRE
  177. #elif (SBBI3_RST0_AVRPORT == AVRPORTF)
  178. #define SBBI3_RST0_SOD_REG PORTF
  179. #define SBBI3_RST0_OE_REG DDRF
  180. #elif (SBBI3_RST0_AVRPORT == AVRPORTG)
  181. #define SBBI3_RST0_SOD_REG PORTG
  182. #define SBBI3_RST0_OE_REG DDRG
  183. #elif (SBBI3_RST0_AVRPORT == AVRPORTH)
  184. #define SBBI3_RST0_SOD_REG PORTH
  185. #define SBBI3_RST0_OE_REG DDRH
  186. #endif
  187. /*! \brief Enable SBBI3 reset 0 output. */
  188. #define SBBI3_RST0_ENA() sbi(SBBI3_RST0_OE_REG, SBBI3_RST0_BIT)
  189. /*! \brief Set SBBI3 reset 0 output low. */
  190. #define SBBI3_RST0_CLR() cbi(SBBI3_RST0_SOD_REG, SBBI3_RST0_BIT)
  191. /*! \brief Set SBBI3 reset 0 output high. */
  192. #define SBBI3_RST0_SET() sbi(SBBI3_RST0_SOD_REG, SBBI3_RST0_BIT)
  193. #endif /* SBBI3_RST0_BIT */
  194. #ifdef SBBI3_RST1_BIT
  195. #if (SBBI3_RST1_AVRPORT == AVRPORTB)
  196. #define SBBI3_RST1_SOD_REG PORTB
  197. #define SBBI3_RST1_OE_REG DDRB
  198. #elif (SBBI3_RST1_AVRPORT == AVRPORTD)
  199. #define SBBI3_RST1_SOD_REG PORTD
  200. #define SBBI3_RST1_OE_REG DDRD
  201. #elif (SBBI3_RST1_AVRPORT == AVRPORTE)
  202. #define SBBI3_RST1_SOD_REG PORTE
  203. #define SBBI3_RST1_OE_REG DDRE
  204. #elif (SBBI3_RST1_AVRPORT == AVRPORTF)
  205. #define SBBI3_RST1_SOD_REG PORTF
  206. #define SBBI3_RST1_OE_REG DDRF
  207. #elif (SBBI3_RST1_AVRPORT == AVRPORTG)
  208. #define SBBI3_RST1_SOD_REG PORTG
  209. #define SBBI3_RST1_OE_REG DDRG
  210. #elif (SBBI3_RST1_AVRPORT == AVRPORTH)
  211. #define SBBI3_RST1_SOD_REG PORTH
  212. #define SBBI3_RST1_OE_REG DDRH
  213. #endif
  214. /*! \brief Enable SBBI3 reset 1 output. */
  215. #define SBBI3_RST1_ENA() sbi(SBBI3_RST1_OE_REG, SBBI3_RST1_BIT)
  216. /*! \brief Set SBBI3 reset 1 output low. */
  217. #define SBBI3_RST1_CLR() cbi(SBBI3_RST1_SOD_REG, SBBI3_RST1_BIT)
  218. /*! \brief Set SBBI3 reset 1 output high. */
  219. #define SBBI3_RST1_SET() sbi(SBBI3_RST1_SOD_REG, SBBI3_RST1_BIT)
  220. #endif /* SBBI3_RST1_BIT */
  221. #ifdef SBBI3_RST2_BIT
  222. #if (SBBI3_RST2_AVRPORT == AVRPORTB)
  223. #define SBBI3_RST2_SOD_REG PORTB
  224. #define SBBI3_RST2_OE_REG DDRB
  225. #elif (SBBI3_RST2_AVRPORT == AVRPORTD)
  226. #define SBBI3_RST2_SOD_REG PORTD
  227. #define SBBI3_RST2_OE_REG DDRD
  228. #elif (SBBI3_RST2_AVRPORT == AVRPORTE)
  229. #define SBBI3_RST2_SOD_REG PORTE
  230. #define SBBI3_RST2_OE_REG DDRE
  231. #elif (SBBI3_RST2_AVRPORT == AVRPORTF)
  232. #define SBBI3_RST2_SOD_REG PORTF
  233. #define SBBI3_RST2_OE_REG DDRF
  234. #elif (SBBI3_RST2_AVRPORT == AVRPORTG)
  235. #define SBBI3_RST2_SOD_REG PORTG
  236. #define SBBI3_RST2_OE_REG DDRG
  237. #elif (SBBI3_RST2_AVRPORT == AVRPORTH)
  238. #define SBBI3_RST2_SOD_REG PORTH
  239. #define SBBI3_RST2_OE_REG DDRH
  240. #endif
  241. /*! \brief Enable SBBI3 reset 2 output. */
  242. #define SBBI3_RST2_ENA() sbi(SBBI3_RST2_OE_REG, SBBI3_RST2_BIT)
  243. /*! \brief Set SBBI3 chip reset 2 output low. */
  244. #define SBBI3_RST2_CLR() cbi(SBBI3_RST2_SOD_REG, SBBI3_RST2_BIT)
  245. /*! \brief Set SBBI3 chip reset 2 output high. */
  246. #define SBBI3_RST2_SET() sbi(SBBI3_RST2_SOD_REG, SBBI3_RST2_BIT)
  247. #endif /* SBBI3_RST2_BIT */
  248. #ifdef SBBI3_RST3_BIT
  249. #if (SBBI3_RST3_AVRPORT == AVRPORTB)
  250. #define SBBI3_RST3_SOD_REG PORTB
  251. #define SBBI3_RST3_OE_REG DDRB
  252. #elif (SBBI3_RST3_AVRPORT == AVRPORTD)
  253. #define SBBI3_RST3_SOD_REG PORTD
  254. #define SBBI3_RST3_OE_REG DDRD
  255. #elif (SBBI3_RST3_AVRPORT == AVRPORTE)
  256. #define SBBI3_RST3_SOD_REG PORTE
  257. #define SBBI3_RST3_OE_REG DDRE
  258. #elif (SBBI3_RST3_AVRPORT == AVRPORTF)
  259. #define SBBI3_RST3_SOD_REG PORTF
  260. #define SBBI3_RST3_OE_REG DDRF
  261. #elif (SBBI3_RST3_AVRPORT == AVRPORTG)
  262. #define SBBI3_RST3_SOD_REG PORTG
  263. #define SBBI3_RST3_OE_REG DDRG
  264. #elif (SBBI3_RST3_AVRPORT == AVRPORTH)
  265. #define SBBI3_RST3_SOD_REG PORTH
  266. #define SBBI3_RST3_OE_REG DDRH
  267. #endif
  268. /*! \brief Enable SBBI3 reset 3 output. */
  269. #define SBBI3_RST3_ENA() sbi(SBBI3_RST3_OE_REG, SBBI3_RST3_BIT)
  270. /*! \brief Set SBBI3 reset 3 output low. */
  271. #define SBBI3_RST3_CLR() cbi(SBBI3_RST3_SOD_REG, SBBI3_RST3_BIT)
  272. /*! \brief Set SBBI3 reset 3 output high. */
  273. #define SBBI3_RST3_SET() sbi(SBBI3_RST3_SOD_REG, SBBI3_RST3_BIT)
  274. #endif /* SBBI3_RST3_BIT */
  275. #ifdef SBBI3_SCK_BIT
  276. #if (SBBI3_SCK_AVRPORT == AVRPORTB)
  277. #define SBBI3_SCK_SOD_REG PORTB
  278. #define SBBI3_SCK_OE_REG DDRB
  279. #elif (SBBI3_SCK_AVRPORT == AVRPORTD)
  280. #define SBBI3_SCK_SOD_REG PORTD
  281. #define SBBI3_SCK_OE_REG DDRD
  282. #elif (SBBI3_SCK_AVRPORT == AVRPORTE)
  283. #define SBBI3_SCK_SOD_REG PORTE
  284. #define SBBI3_SCK_OE_REG DDRE
  285. #elif (SBBI3_SCK_AVRPORT == AVRPORTF)
  286. #define SBBI3_SCK_SOD_REG PORTF
  287. #define SBBI3_SCK_OE_REG DDRF
  288. #elif (SBBI3_SCK_AVRPORT == AVRPORTG)
  289. #define SBBI3_SCK_SOD_REG PORTG
  290. #define SBBI3_SCK_OE_REG DDRG
  291. #elif (SBBI3_SCK_AVRPORT == AVRPORTH)
  292. #define SBBI3_SCK_SOD_REG PORTH
  293. #define SBBI3_SCK_OE_REG DDRH
  294. #endif
  295. /*! \brief Enable SBBI3 clock output. */
  296. #define SBBI3_SCK_ENA() sbi(SBBI3_SCK_OE_REG, SBBI3_SCK_BIT)
  297. /*! \brief Set SBBI3 clock output low. */
  298. #define SBBI3_SCK_CLR() cbi(SBBI3_SCK_SOD_REG, SBBI3_SCK_BIT)
  299. /*! \brief Set SBBI3 clock output high. */
  300. #define SBBI3_SCK_SET() sbi(SBBI3_SCK_SOD_REG, SBBI3_SCK_BIT)
  301. #if defined(SBBI3_MOSI_BIT)
  302. #if (SBBI3_MOSI_AVRPORT == AVRPORTB)
  303. #define SBBI3_MOSI_SOD_REG PORTB
  304. #define SBBI3_MOSI_OE_REG DDRB
  305. #elif (SBBI3_MOSI_AVRPORT == AVRPORTD)
  306. #define SBBI3_MOSI_SOD_REG PORTD
  307. #define SBBI3_MOSI_OE_REG DDRD
  308. #elif (SBBI3_MOSI_AVRPORT == AVRPORTE)
  309. #define SBBI3_MOSI_SOD_REG PORTE
  310. #define SBBI3_MOSI_OE_REG DDRE
  311. #elif (SBBI3_MOSI_AVRPORT == AVRPORTF)
  312. #define SBBI3_MOSI_SOD_REG PORTF
  313. #define SBBI3_MOSI_OE_REG DDRF
  314. #elif (SBBI3_MOSI_AVRPORT == AVRPORTG)
  315. #define SBBI3_MOSI_SOD_REG PORTG
  316. #define SBBI3_MOSI_OE_REG DDRG
  317. #elif (SBBI3_MOSI_AVRPORT == AVRPORTH)
  318. #define SBBI3_MOSI_SOD_REG PORTH
  319. #define SBBI3_MOSI_OE_REG DDRH
  320. #endif
  321. /*! \brief Enable SBBI3 data output. */
  322. #define SBBI3_MOSI_ENA() sbi(SBBI3_MOSI_OE_REG, SBBI3_MOSI_BIT)
  323. /*! \brief Set SBBI3 data output low. */
  324. #define SBBI3_MOSI_CLR() cbi(SBBI3_MOSI_SOD_REG, SBBI3_MOSI_BIT)
  325. /*! \brief Set SBBI3 data output high. */
  326. #define SBBI3_MOSI_SET() sbi(SBBI3_MOSI_SOD_REG, SBBI3_MOSI_BIT)
  327. #else /* SBBI3_MOSI_BIT */
  328. #define SBBI3_MOSI_ENA()
  329. #define SBBI3_MOSI_CLR()
  330. #define SBBI3_MOSI_SET()
  331. #endif /* SBBI3_MOSI_BIT */
  332. #if defined(SBBI3_MISO_BIT)
  333. #if (SBBI3_MISO_AVRPORT == AVRPORTB)
  334. #define SBBI3_MISO_PDS_REG PINB
  335. #define SBBI3_MISO_PUE_REG PORTB
  336. #define SBBI3_MISO_OE_REG DDRB
  337. #elif (SBBI3_MISO_AVRPORT == AVRPORTD)
  338. #define SBBI3_MISO_PDS_REG PIND
  339. #define SBBI3_MISO_PUE_REG PORTD
  340. #define SBBI3_MISO_OE_REG DDRD
  341. #elif (SBBI3_MISO_AVRPORT == AVRPORTE)
  342. #define SBBI3_MISO_PDS_REG PINE
  343. #define SBBI3_MISO_PUE_REG PORTE
  344. #define SBBI3_MISO_OE_REG DDRE
  345. #elif (SBBI3_MISO_AVRPORT == AVRPORTF)
  346. #define SBBI3_MISO_PDS_REG PINF
  347. #define SBBI3_MISO_PUE_REG PORTF
  348. #define SBBI3_MISO_OE_REG DDRF
  349. #elif (SBBI3_MISO_AVRPORT == AVRPORTG)
  350. #define SBBI3_MISO_PDS_REG PING
  351. #define SBBI3_MISO_PUE_REG PORTG
  352. #define SBBI3_MISO_OE_REG DDRG
  353. #elif (SBBI3_MISO_AVRPORT == AVRPORTH)
  354. #define SBBI3_MISO_PDS_REG PINH
  355. #define SBBI3_MISO_PUE_REG PORTH
  356. #define SBBI3_MISO_OE_REG DDRH
  357. #endif
  358. /*! \brief Enable SBBI3 data input. */
  359. #define SBBI3_MISO_ENA() \
  360. cbi(SBBI3_MISO_OE_REG, SBBI3_MISO_BIT); \
  361. sbi(SBBI3_MISO_PUE_REG, SBBI3_MISO_BIT)
  362. /*! \brief Query SBBI3 data input. */
  363. #define SBBI3_MISO_TST() ((inb(SBBI3_MISO_PDS_REG) & _BV(SBBI3_MISO_BIT)) == _BV(SBBI3_MISO_BIT))
  364. #else /* SBBI3_MISO_BIT */
  365. #define SBBI3_MISO_ENA()
  366. #define SBBI3_MISO_TST() 0
  367. #endif /* SBBI3_MISO_BIT */
  368. #endif /* SBBI3_SCK_BIT */
  369. #else /* MCU */
  370. /*
  371. * AT91 implementation.
  372. * ======================================
  373. */
  374. #ifdef SBBI3_CS0_BIT
  375. #if !defined(SBBI3_CS0_PIO_ID)
  376. #define SBBI3_CS0_PE_REG PIO_PER
  377. #define SBBI3_CS0_OE_REG PIO_OER
  378. #define SBBI3_CS0_COD_REG PIO_CODR
  379. #define SBBI3_CS0_SOD_REG PIO_SODR
  380. #elif SBBI3_CS0_PIO_ID == PIOA_ID
  381. #define SBBI3_CS0_PE_REG PIOA_PER
  382. #define SBBI3_CS0_OE_REG PIOA_OER
  383. #define SBBI3_CS0_COD_REG PIOA_CODR
  384. #define SBBI3_CS0_SOD_REG PIOA_SODR
  385. #elif SBBI3_CS0_PIO_ID == PIOB_ID
  386. #define SBBI3_CS0_PE_REG PIOB_PER
  387. #define SBBI3_CS0_OE_REG PIOB_OER
  388. #define SBBI3_CS0_COD_REG PIOB_CODR
  389. #define SBBI3_CS0_SOD_REG PIOB_SODR
  390. #elif SBBI3_CS0_PIO_ID == PIOC_ID
  391. #define SBBI3_CS0_PE_REG PIOC_PER
  392. #define SBBI3_CS0_OE_REG PIOC_OER
  393. #define SBBI3_CS0_COD_REG PIOC_CODR
  394. #define SBBI3_CS0_SOD_REG PIOC_SODR
  395. #endif
  396. /*! \brief Enable SBBI3 chip select 0 output. */
  397. #define SBBI3_CS0_ENA() \
  398. outr(SBBI3_CS0_PE_REG, _BV(SBBI3_CS0_BIT)); \
  399. outr(SBBI3_CS0_OE_REG, _BV(SBBI3_CS0_BIT))
  400. /*! \brief Set SBBI3 chip select 0 output low. */
  401. #define SBBI3_CS0_CLR() outr(SBBI3_CS0_COD_REG, _BV(SBBI3_CS0_BIT))
  402. /*! \brief Set SBBI3 chip select 0 output high. */
  403. #define SBBI3_CS0_SET() outr(SBBI3_CS0_SOD_REG, _BV(SBBI3_CS0_BIT))
  404. #endif /* SBBI3_CS0_BIT */
  405. #ifdef SBBI3_CS1_BIT
  406. #if !defined(SBBI3_CS1_PIO_ID)
  407. #define SBBI3_CS1_PE_REG PIO_PER
  408. #define SBBI3_CS1_OE_REG PIO_OER
  409. #define SBBI3_CS1_COD_REG PIO_CODR
  410. #define SBBI3_CS1_SOD_REG PIO_SODR
  411. #elif SBBI3_CS1_PIO_ID == PIOA_ID
  412. #define SBBI3_CS1_PE_REG PIOA_PER
  413. #define SBBI3_CS1_OE_REG PIOA_OER
  414. #define SBBI3_CS1_COD_REG PIOA_CODR
  415. #define SBBI3_CS1_SOD_REG PIOA_SODR
  416. #elif SBBI3_CS1_PIO_ID == PIOB_ID
  417. #define SBBI3_CS1_PE_REG PIOB_PER
  418. #define SBBI3_CS1_OE_REG PIOB_OER
  419. #define SBBI3_CS1_COD_REG PIOB_CODR
  420. #define SBBI3_CS1_SOD_REG PIOB_SODR
  421. #elif SBBI3_CS1_PIO_ID == PIOC_ID
  422. #define SBBI3_CS1_PE_REG PIOC_PER
  423. #define SBBI3_CS1_OE_REG PIOC_OER
  424. #define SBBI3_CS1_COD_REG PIOC_CODR
  425. #define SBBI3_CS1_SOD_REG PIOC_SODR
  426. #endif
  427. /*! \brief Enable SBBI3 chip select output. */
  428. #define SBBI3_CS1_ENA() \
  429. outr(SBBI3_CS1_PE_REG, _BV(SBBI3_CS1_BIT)); \
  430. outr(SBBI3_CS1_OE_REG, _BV(SBBI3_CS1_BIT))
  431. /*! \brief Set SBBI3 chip select output low. */
  432. #define SBBI3_CS1_CLR() outr(SBBI3_CS1_COD_REG, _BV(SBBI3_CS1_BIT))
  433. /*! \brief Set SBBI3 chip select output high. */
  434. #define SBBI3_CS1_SET() outr(SBBI3_CS1_SOD_REG, _BV(SBBI3_CS1_BIT))
  435. #endif /* SBBI3_CS1_BIT */
  436. #ifdef SBBI3_CS2_BIT
  437. #if !defined(SBBI3_CS2_PIO_ID)
  438. #define SBBI3_CS2_PE_REG PIO_PER
  439. #define SBBI3_CS2_OE_REG PIO_OER
  440. #define SBBI3_CS2_COD_REG PIO_CODR
  441. #define SBBI3_CS2_SOD_REG PIO_SODR
  442. #elif SBBI3_CS2_PIO_ID == PIOA_ID
  443. #define SBBI3_CS2_PE_REG PIOA_PER
  444. #define SBBI3_CS2_OE_REG PIOA_OER
  445. #define SBBI3_CS2_COD_REG PIOA_CODR
  446. #define SBBI3_CS2_SOD_REG PIOA_SODR
  447. #elif SBBI3_CS2_PIO_ID == PIOB_ID
  448. #define SBBI3_CS2_PE_REG PIOB_PER
  449. #define SBBI3_CS2_OE_REG PIOB_OER
  450. #define SBBI3_CS2_COD_REG PIOB_CODR
  451. #define SBBI3_CS2_SOD_REG PIOB_SODR
  452. #elif SBBI3_CS2_PIO_ID == PIOC_ID
  453. #define SBBI3_CS2_PE_REG PIOC_PER
  454. #define SBBI3_CS2_OE_REG PIOC_OER
  455. #define SBBI3_CS2_COD_REG PIOC_CODR
  456. #define SBBI3_CS2_SOD_REG PIOC_SODR
  457. #endif
  458. /*! \brief Enable SBBI3 chip select output. */
  459. #define SBBI3_CS2_ENA() \
  460. outr(SBBI3_CS2_PE_REG, _BV(SBBI3_CS2_BIT)); \
  461. outr(SBBI3_CS2_OE_REG, _BV(SBBI3_CS2_BIT))
  462. /*! \brief Set SBBI3 chip select output low. */
  463. #define SBBI3_CS2_CLR() outr(SBBI3_CS2_COD_REG, _BV(SBBI3_CS2_BIT))
  464. /*! \brief Set SBBI3 chip select output high. */
  465. #define SBBI3_CS2_SET() outr(SBBI3_CS2_SOD_REG, _BV(SBBI3_CS2_BIT))
  466. #endif /* SBBI3_CS2_BIT */
  467. #ifdef SBBI3_CS3_BIT
  468. #if !defined(SBBI3_CS3_PIO_ID)
  469. #define SBBI3_CS3_PE_REG PIO_PER
  470. #define SBBI3_CS3_OE_REG PIO_OER
  471. #define SBBI3_CS3_COD_REG PIO_CODR
  472. #define SBBI3_CS3_SOD_REG PIO_SODR
  473. #elif SBBI3_CS3_PIO_ID == PIOA_ID
  474. #define SBBI3_CS3_PE_REG PIOA_PER
  475. #define SBBI3_CS3_OE_REG PIOA_OER
  476. #define SBBI3_CS3_COD_REG PIOA_CODR
  477. #define SBBI3_CS3_SOD_REG PIOA_SODR
  478. #elif SBBI3_CS3_PIO_ID == PIOB_ID
  479. #define SBBI3_CS3_PE_REG PIOB_PER
  480. #define SBBI3_CS3_OE_REG PIOB_OER
  481. #define SBBI3_CS3_COD_REG PIOB_CODR
  482. #define SBBI3_CS3_SOD_REG PIOB_SODR
  483. #elif SBBI3_CS3_PIO_ID == PIOC_ID
  484. #define SBBI3_CS3_PE_REG PIOC_PER
  485. #define SBBI3_CS3_OE_REG PIOC_OER
  486. #define SBBI3_CS3_COD_REG PIOC_CODR
  487. #define SBBI3_CS3_SOD_REG PIOC_SODR
  488. #endif
  489. /*! \brief Enable SBBI3 chip select output. */
  490. #define SBBI3_CS3_ENA() \
  491. outr(SBBI3_CS3_PE_REG, _BV(SBBI3_CS3_BIT)); \
  492. outr(SBBI3_CS3_OE_REG, _BV(SBBI3_CS3_BIT))
  493. /*! \brief Set SBBI3 chip select output low. */
  494. #define SBBI3_CS3_CLR() outr(SBBI3_CS3_COD_REG, _BV(SBBI3_CS3_BIT))
  495. /*! \brief Set SBBI3 chip select output high. */
  496. #define SBBI3_CS3_SET() outr(SBBI3_CS3_SOD_REG, _BV(SBBI3_CS3_BIT))
  497. #endif /* SBBI3_CS3_BIT */
  498. #ifdef SBBI3_RST0_BIT
  499. #if !defined(SBBI3_RST0_PIO_ID)
  500. #define SBBI3_RST0_PE_REG PIO_PER
  501. #define SBBI3_RST0_OE_REG PIO_OER
  502. #define SBBI3_RST0_COD_REG PIO_CODR
  503. #define SBBI3_RST0_SOD_REG PIO_SODR
  504. #elif SBBI3_RST0_PIO_ID == PIOA_ID
  505. #define SBBI3_RST0_PE_REG PIOA_PER
  506. #define SBBI3_RST0_OE_REG PIOA_OER
  507. #define SBBI3_RST0_COD_REG PIOA_CODR
  508. #define SBBI3_RST0_SOD_REG PIOA_SODR
  509. #elif SBBI3_RST0_PIO_ID == PIOB_ID
  510. #define SBBI3_RST0_PE_REG PIOB_PER
  511. #define SBBI3_RST0_OE_REG PIOB_OER
  512. #define SBBI3_RST0_COD_REG PIOB_CODR
  513. #define SBBI3_RST0_SOD_REG PIOB_SODR
  514. #elif SBBI3_RST0_PIO_ID == PIOC_ID
  515. #define SBBI3_RST0_PE_REG PIOC_PER
  516. #define SBBI3_RST0_OE_REG PIOC_OER
  517. #define SBBI3_RST0_COD_REG PIOC_CODR
  518. #define SBBI3_RST0_SOD_REG PIOC_SODR
  519. #endif
  520. /*! \brief Enable SBBI3 reset output. */
  521. #define SBBI3_RST0_ENA() \
  522. outr(SBBI3_RST0_PE_REG, _BV(SBBI3_RST0_BIT)); \
  523. outr(SBBI3_RST0_OE_REG, _BV(SBBI3_RST0_BIT))
  524. /*! \brief Set SBBI3 reset output low. */
  525. #define SBBI3_RST0_CLR() outr(SBBI3_RST0_COD_REG, _BV(SBBI3_RST0_BIT))
  526. /*! \brief Set SBBI3 reset output high. */
  527. #define SBBI3_RST0_SET() outr(SBBI3_RST0_SOD_REG, _BV(SBBI3_RST0_BIT))
  528. #endif /* SBBI3_RST0_BIT */
  529. #ifdef SBBI3_RST1_BIT
  530. #if !defined(SBBI3_RST1_PIO_ID)
  531. #define SBBI3_RST1_PE_REG PIO_PER
  532. #define SBBI3_RST1_OE_REG PIO_OER
  533. #define SBBI3_RST1_COD_REG PIO_CODR
  534. #define SBBI3_RST1_SOD_REG PIO_SODR
  535. #elif SBBI3_RST1_PIO_ID == PIOA_ID
  536. #define SBBI3_RST1_PE_REG PIOA_PER
  537. #define SBBI3_RST1_OE_REG PIOA_OER
  538. #define SBBI3_RST1_COD_REG PIOA_CODR
  539. #define SBBI3_RST1_SOD_REG PIOA_SODR
  540. #elif SBBI3_RST1_PIO_ID == PIOB_ID
  541. #define SBBI3_RST1_PE_REG PIOB_PER
  542. #define SBBI3_RST1_OE_REG PIOB_OER
  543. #define SBBI3_RST1_COD_REG PIOB_CODR
  544. #define SBBI3_RST1_SOD_REG PIOB_SODR
  545. #elif SBBI3_RST1_PIO_ID == PIOC_ID
  546. #define SBBI3_RST1_PE_REG PIOC_PER
  547. #define SBBI3_RST1_OE_REG PIOC_OER
  548. #define SBBI3_RST1_COD_REG PIOC_CODR
  549. #define SBBI3_RST1_SOD_REG PIOC_SODR
  550. #endif
  551. /*! \brief Enable SBBI3 reset output. */
  552. #define SBBI3_RST1_ENA() \
  553. outr(SBBI3_RST1_PE_REG, _BV(SBBI3_RST1_BIT)); \
  554. outr(SBBI3_RST1_OE_REG, _BV(SBBI3_RST1_BIT))
  555. /*! \brief Set SBBI3 reset output low. */
  556. #define SBBI3_RST1_CLR() outr(SBBI3_RST1_COD_REG, _BV(SBBI3_RST1_BIT))
  557. /*! \brief Set SBBI3 reset output high. */
  558. #define SBBI3_RST1_SET() outr(SBBI3_RST1_SOD_REG, _BV(SBBI3_RST1_BIT))
  559. #endif /* SBBI3_RST1_BIT */
  560. #ifdef SBBI3_RST2_BIT
  561. #if !defined(SBBI3_RST2_PIO_ID)
  562. #define SBBI3_RST2_PE_REG PIO_PER
  563. #define SBBI3_RST2_OE_REG PIO_OER
  564. #define SBBI3_RST2_COD_REG PIO_CODR
  565. #define SBBI3_RST2_SOD_REG PIO_SODR
  566. #elif SBBI3_RST2_PIO_ID == PIOA_ID
  567. #define SBBI3_RST2_PE_REG PIOA_PER
  568. #define SBBI3_RST2_OE_REG PIOA_OER
  569. #define SBBI3_RST2_COD_REG PIOA_CODR
  570. #define SBBI3_RST2_SOD_REG PIOA_SODR
  571. #elif SBBI3_RST2_PIO_ID == PIOB_ID
  572. #define SBBI3_RST2_PE_REG PIOB_PER
  573. #define SBBI3_RST2_OE_REG PIOB_OER
  574. #define SBBI3_RST2_COD_REG PIOB_CODR
  575. #define SBBI3_RST2_SOD_REG PIOB_SODR
  576. #elif SBBI3_RST2_PIO_ID == PIOC_ID
  577. #define SBBI3_RST2_PE_REG PIOC_PER
  578. #define SBBI3_RST2_OE_REG PIOC_OER
  579. #define SBBI3_RST2_COD_REG PIOC_CODR
  580. #define SBBI3_RST2_SOD_REG PIOC_SODR
  581. #endif
  582. /*! \brief Enable SBBI3 reset output. */
  583. #define SBBI3_RST2_ENA() \
  584. outr(SBBI3_RST2_PE_REG, _BV(SBBI3_RST2_BIT)); \
  585. outr(SBBI3_RST2_OE_REG, _BV(SBBI3_RST2_BIT))
  586. /*! \brief Set SBBI3 reset output low. */
  587. #define SBBI3_RST2_CLR() outr(SBBI3_RST2_COD_REG, _BV(SBBI3_RST2_BIT))
  588. /*! \brief Set SBBI3 reset output high. */
  589. #define SBBI3_RST2_SET() outr(SBBI3_RST2_SOD_REG, _BV(SBBI3_RST2_BIT))
  590. #endif /* SBBI3_RST2_BIT */
  591. #ifdef SBBI3_RST3_BIT
  592. #if !defined(SBBI3_RST3_PIO_ID)
  593. #define SBBI3_RST3_PE_REG PIO_PER
  594. #define SBBI3_RST3_OE_REG PIO_OER
  595. #define SBBI3_RST3_COD_REG PIO_CODR
  596. #define SBBI3_RST3_SOD_REG PIO_SODR
  597. #elif SBBI3_RST3_PIO_ID == PIOA_ID
  598. #define SBBI3_RST3_PE_REG PIOA_PER
  599. #define SBBI3_RST3_OE_REG PIOA_OER
  600. #define SBBI3_RST3_COD_REG PIOA_CODR
  601. #define SBBI3_RST3_SOD_REG PIOA_SODR
  602. #elif SBBI3_RST3_PIO_ID == PIOB_ID
  603. #define SBBI3_RST3_PE_REG PIOB_PER
  604. #define SBBI3_RST3_OE_REG PIOB_OER
  605. #define SBBI3_RST3_COD_REG PIOB_CODR
  606. #define SBBI3_RST3_SOD_REG PIOB_SODR
  607. #elif SBBI3_RST3_PIO_ID == PIOC_ID
  608. #define SBBI3_RST3_PE_REG PIOC_PER
  609. #define SBBI3_RST3_OE_REG PIOC_OER
  610. #define SBBI3_RST3_COD_REG PIOC_CODR
  611. #define SBBI3_RST3_SOD_REG PIOC_SODR
  612. #endif
  613. /*! \brief Enable SBBI3 reset output. */
  614. #define SBBI3_RST3_ENA() \
  615. outr(SBBI3_RST3_PE_REG, _BV(SBBI3_RST3_BIT)); \
  616. outr(SBBI3_RST3_OE_REG, _BV(SBBI3_RST3_BIT))
  617. /*! \brief Set SBBI3 reset output low. */
  618. #define SBBI3_RST3_CLR() outr(SBBI3_RST3_COD_REG, _BV(SBBI3_RST3_BIT))
  619. /*! \brief Set SBBI3 reset output high. */
  620. #define SBBI3_RST3_SET() outr(SBBI3_RST3_SOD_REG, _BV(SBBI3_RST3_BIT))
  621. #endif /* SBBI3_RST3_BIT */
  622. #ifdef SBBI3_SCK_BIT
  623. #if !defined(SBBI3_SCK_PIO_ID)
  624. #define SBBI3_SCK_PE_REG PIO_PER
  625. #define SBBI3_SCK_OE_REG PIO_OER
  626. #define SBBI3_SCK_COD_REG PIO_CODR
  627. #define SBBI3_SCK_SOD_REG PIO_SODR
  628. #elif SBBI3_SCK_PIO_ID == PIOA_ID
  629. #define SBBI3_SCK_PE_REG PIOA_PER
  630. #define SBBI3_SCK_OE_REG PIOA_OER
  631. #define SBBI3_SCK_COD_REG PIOA_CODR
  632. #define SBBI3_SCK_SOD_REG PIOA_SODR
  633. #elif SBBI3_SCK_PIO_ID == PIOB_ID
  634. #define SBBI3_SCK_PE_REG PIOB_PER
  635. #define SBBI3_SCK_OE_REG PIOB_OER
  636. #define SBBI3_SCK_COD_REG PIOB_CODR
  637. #define SBBI3_SCK_SOD_REG PIOB_SODR
  638. #elif SBBI3_SCK_PIO_ID == PIOC_ID
  639. #define SBBI3_SCK_PE_REG PIOC_PER
  640. #define SBBI3_SCK_OE_REG PIOC_OER
  641. #define SBBI3_SCK_COD_REG PIOC_CODR
  642. #define SBBI3_SCK_SOD_REG PIOC_SODR
  643. #endif
  644. /*! \brief Enable SBBI3 clock output. */
  645. #define SBBI3_SCK_ENA() \
  646. outr(SBBI3_SCK_PE_REG, _BV(SBBI3_SCK_BIT)); \
  647. outr(SBBI3_SCK_OE_REG, _BV(SBBI3_SCK_BIT))
  648. /*! \brief Set SBBI3 clock output low. */
  649. #define SBBI3_SCK_CLR() outr(SBBI3_SCK_COD_REG, _BV(SBBI3_SCK_BIT))
  650. /*! \brief Set SBBI3 clock output high. */
  651. #define SBBI3_SCK_SET() outr(SBBI3_SCK_SOD_REG, _BV(SBBI3_SCK_BIT))
  652. #ifdef SBBI3_MOSI_BIT
  653. #if !defined(SBBI3_MOSI_PIO_ID)
  654. #define SBBI3_MOSI_PE_REG PIO_PER
  655. #define SBBI3_MOSI_OE_REG PIO_OER
  656. #define SBBI3_MOSI_COD_REG PIO_CODR
  657. #define SBBI3_MOSI_SOD_REG PIO_SODR
  658. #elif SBBI3_MOSI_PIO_ID == PIOA_ID
  659. #define SBBI3_MOSI_PE_REG PIOA_PER
  660. #define SBBI3_MOSI_OE_REG PIOA_OER
  661. #define SBBI3_MOSI_COD_REG PIOA_CODR
  662. #define SBBI3_MOSI_SOD_REG PIOA_SODR
  663. #elif SBBI3_MOSI_PIO_ID == PIOB_ID
  664. #define SBBI3_MOSI_PE_REG PIOB_PER
  665. #define SBBI3_MOSI_OE_REG PIOB_OER
  666. #define SBBI3_MOSI_COD_REG PIOB_CODR
  667. #define SBBI3_MOSI_SOD_REG PIOB_SODR
  668. #elif SBBI3_MOSI_PIO_ID == PIOC_ID
  669. #define SBBI3_MOSI_PE_REG PIOC_PER
  670. #define SBBI3_MOSI_OE_REG PIOC_OER
  671. #define SBBI3_MOSI_COD_REG PIOC_CODR
  672. #define SBBI3_MOSI_SOD_REG PIOC_SODR
  673. #endif
  674. /*! \brief Enable SBBI3 data output. */
  675. #define SBBI3_MOSI_ENA() \
  676. outr(SBBI3_MOSI_PE_REG, _BV(SBBI3_MOSI_BIT)); \
  677. outr(SBBI3_MOSI_OE_REG, _BV(SBBI3_MOSI_BIT))
  678. /*! \brief Set SBBI3 data output low. */
  679. #define SBBI3_MOSI_CLR() outr(SBBI3_MOSI_COD_REG, _BV(SBBI3_MOSI_BIT))
  680. /*! \brief Set SBBI3 data output high. */
  681. #define SBBI3_MOSI_SET() outr(SBBI3_MOSI_SOD_REG, _BV(SBBI3_MOSI_BIT))
  682. #else /* SBBI3_MOSI_BIT */
  683. #define SBBI3_MOSI_ENA()
  684. #define SBBI3_MOSI_CLR()
  685. #define SBBI3_MOSI_SET()
  686. #endif /* SBBI3_MOSI_BIT */
  687. #ifdef SBBI3_MISO_BIT
  688. #if !defined(SBBI3_MISO_PIO_ID)
  689. #define SBBI3_MISO_PE_REG PIO_PER
  690. #define SBBI3_MISO_OD_REG PIO_ODR
  691. #define SBBI3_MISO_PDS_REG PIO_PDSR
  692. #elif SBBI3_MISO_PIO_ID == PIOA_ID
  693. #define SBBI3_MISO_PE_REG PIOA_PER
  694. #define SBBI3_MISO_OD_REG PIOA_ODR
  695. #define SBBI3_MISO_PDS_REG PIOA_PDSR
  696. #elif SBBI3_MISO_PIO_ID == PIOB_ID
  697. #define SBBI3_MISO_PE_REG PIOB_PER
  698. #define SBBI3_MISO_OD_REG PIOB_ODR
  699. #define SBBI3_MISO_PDS_REG PIOB_PDSR
  700. #elif SBBI3_MISO_PIO_ID == PIOC_ID
  701. #define SBBI3_MISO_PE_REG PIOC_PER
  702. #define SBBI3_MISO_OD_REG PIOC_ODR
  703. #define SBBI3_MISO_PDS_REG PIOC_PDSR
  704. #endif
  705. /*! \brief Enable SBBI3 data input. */
  706. #define SBBI3_MISO_ENA() \
  707. outr(SBBI3_MISO_PE_REG, _BV(SBBI3_MISO_BIT)); \
  708. outr(SBBI3_MISO_OD_REG, _BV(SBBI3_MISO_BIT))
  709. /*! \brief Query SBBI3 data input. */
  710. #define SBBI3_MISO_TST() ((inr(SBBI3_MISO_PDS_REG) & _BV(SBBI3_MISO_BIT)) == _BV(SBBI3_MISO_BIT))
  711. #else /* SBBI3_MISO_BIT */
  712. #define SBBI3_MISO_ENA()
  713. #define SBBI3_MISO_TST() 0
  714. #endif /* SBBI3_MISO_BIT */
  715. #endif /* SBBI3_SCK_BIT */
  716. #endif /* MCU */
  717. #define SBBI3_INIT() \
  718. { \
  719. SBBI3_SCK_CLR(); \
  720. SBBI3_SCK_ENA(); \
  721. SBBI3_MOSI_CLR(); \
  722. SBBI3_MOSI_ENA(); \
  723. SBBI3_MISO_ENA(); \
  724. }
  725. #endif