00001 #ifndef _DEV_SBBIF3_H_
00002 #define _DEV_SBBIF3_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00055 #include <cfg/arch/gpio.h>
00056
00060 #ifndef SBBI3_MAX_DEVICES
00061 #define SBBI3_MAX_DEVICES 4
00062 #endif
00063
00064 #if defined(__AVR__)
00065
00066
00067
00068
00069
00070 #ifdef SBBI3_SCK_AVRBIT
00071 #define SBBI3_SCK_BIT SBBI3_SCK_AVRBIT
00072 #endif
00073 #ifdef SBBI3_MOSI_AVRBIT
00074 #define SBBI3_MOSI_BIT SBBI3_MOSI_AVRBIT
00075 #endif
00076 #ifdef SBBI3_MISO_AVRBIT
00077 #define SBBI3_MISO_BIT SBBI3_MISO_AVRBIT
00078 #endif
00079 #ifdef SBBI3_CS0_AVRBIT
00080 #define SBBI3_CS0_BIT SBBI3_CS0_AVRBIT
00081 #endif
00082 #ifdef SBBI3_CS1_AVRBIT
00083 #define SBBI3_CS1_BIT SBBI3_CS1_AVRBIT
00084 #endif
00085 #ifdef SBBI3_CS2_AVRBIT
00086 #define SBBI3_CS2_BIT SBBI3_CS2_AVRBIT
00087 #endif
00088 #ifdef SBBI3_CS3_AVRBIT
00089 #define SBBI3_CS3_BIT SBBI3_CS3_AVRBIT
00090 #endif
00091 #ifdef SBBI3_RST0_AVRBIT
00092 #define SBBI3_RST0_BIT SBBI3_RST0_AVRBIT
00093 #endif
00094 #ifdef SBBI3_RST1_AVRBIT
00095 #define SBBI3_RST1_BIT SBBI3_RST1_AVRBIT
00096 #endif
00097 #ifdef SBBI3_RST2_AVRBIT
00098 #define SBBI3_RST2_BIT SBBI3_RST2_AVRBIT
00099 #endif
00100 #ifdef SBBI3_RST3_AVRBIT
00101 #define SBBI3_RST3_BIT SBBI3_RST3_AVRBIT
00102 #endif
00103
00104 #ifdef SBBI3_CS0_BIT
00105
00106 #if (SBBI3_CS0_AVRPORT == AVRPORTB)
00107 #define SBBI3_CS0_SOD_REG PORTB
00108 #define SBBI3_CS0_OE_REG DDRB
00109 #elif (SBBI3_CS0_AVRPORT == AVRPORTD)
00110 #define SBBI3_CS0_SOD_REG PORTD
00111 #define SBBI3_CS0_OE_REG DDRD
00112 #elif (SBBI3_CS0_AVRPORT == AVRPORTE)
00113 #define SBBI3_CS0_SOD_REG PORTE
00114 #define SBBI3_CS0_OE_REG DDRE
00115 #elif (SBBI3_CS0_AVRPORT == AVRPORTF)
00116 #define SBBI3_CS0_SOD_REG PORTF
00117 #define SBBI3_CS0_OE_REG DDRF
00118 #elif (SBBI3_CS0_AVRPORT == AVRPORTG)
00119 #define SBBI3_CS0_SOD_REG PORTG
00120 #define SBBI3_CS0_OE_REG DDRG
00121 #elif (SBBI3_CS0_AVRPORT == AVRPORTH)
00122 #define SBBI3_CS0_SOD_REG PORTH
00123 #define SBBI3_CS0_OE_REG DDRH
00124 #endif
00125
00127 #define SBBI3_CS0_ENA() sbi(SBBI3_CS0_OE_REG, SBBI3_CS0_BIT)
00128
00129 #define SBBI3_CS0_CLR() cbi(SBBI3_CS0_SOD_REG, SBBI3_CS0_BIT)
00130
00131 #define SBBI3_CS0_SET() sbi(SBBI3_CS0_SOD_REG, SBBI3_CS0_BIT)
00132
00133 #endif
00134
00135 #ifdef SBBI3_CS1_BIT
00136
00137 #if (SBBI3_CS1_AVRPORT == AVRPORTB)
00138 #define SBBI3_CS1_SOD_REG PORTB
00139 #define SBBI3_CS1_OE_REG DDRB
00140 #elif (SBBI3_CS1_AVRPORT == AVRPORTD)
00141 #define SBBI3_CS1_SOD_REG PORTD
00142 #define SBBI3_CS1_OE_REG DDRD
00143 #elif (SBBI3_CS1_AVRPORT == AVRPORTE)
00144 #define SBBI3_CS1_SOD_REG PORTE
00145 #define SBBI3_CS1_OE_REG DDRE
00146 #elif (SBBI3_CS1_AVRPORT == AVRPORTF)
00147 #define SBBI3_CS1_SOD_REG PORTF
00148 #define SBBI3_CS1_OE_REG DDRF
00149 #elif (SBBI3_CS1_AVRPORT == AVRPORTG)
00150 #define SBBI3_CS1_SOD_REG PORTG
00151 #define SBBI3_CS1_OE_REG DDRG
00152 #elif (SBBI3_CS1_AVRPORT == AVRPORTH)
00153 #define SBBI3_CS1_SOD_REG PORTH
00154 #define SBBI3_CS1_OE_REG DDRH
00155 #endif
00156
00158 #define SBBI3_CS1_ENA() sbi(SBBI3_CS1_OE_REG, SBBI3_CS1_BIT)
00159
00160 #define SBBI3_CS1_CLR() cbi(SBBI3_CS1_SOD_REG, SBBI3_CS1_BIT)
00161
00162 #define SBBI3_CS1_SET() sbi(SBBI3_CS1_SOD_REG, SBBI3_CS1_BIT)
00163
00164 #endif
00165
00166 #ifdef SBBI3_CS2_BIT
00167
00168 #if (SBBI3_CS2_AVRPORT == AVRPORTB)
00169 #define SBBI3_CS2_SOD_REG PORTB
00170 #define SBBI3_CS2_OE_REG DDRB
00171 #elif (SBBI3_CS2_AVRPORT == AVRPORTD)
00172 #define SBBI3_CS2_SOD_REG PORTD
00173 #define SBBI3_CS2_OE_REG DDRD
00174 #elif (SBBI3_CS2_AVRPORT == AVRPORTE)
00175 #define SBBI3_CS2_SOD_REG PORTE
00176 #define SBBI3_CS2_OE_REG DDRE
00177 #elif (SBBI3_CS2_AVRPORT == AVRPORTF)
00178 #define SBBI3_CS2_SOD_REG PORTF
00179 #define SBBI3_CS2_OE_REG DDRF
00180 #elif (SBBI3_CS2_AVRPORT == AVRPORTG)
00181 #define SBBI3_CS2_SOD_REG PORTG
00182 #define SBBI3_CS2_OE_REG DDRG
00183 #elif (SBBI3_CS2_AVRPORT == AVRPORTH)
00184 #define SBBI3_CS2_SOD_REG PORTH
00185 #define SBBI3_CS2_OE_REG DDRH
00186 #endif
00187
00189 #define SBBI3_CS2_ENA() sbi(SBBI3_CS2_OE_REG, SBBI3_CS2_BIT)
00190
00191 #define SBBI3_CS2_CLR() cbi(SBBI3_CS2_SOD_REG, SBBI3_CS2_BIT)
00192
00193 #define SBBI3_CS2_SET() sbi(SBBI3_CS2_SOD_REG, SBBI3_CS2_BIT)
00194
00195 #endif
00196
00197 #ifdef SBBI3_CS3_BIT
00198
00199 #if (SBBI3_CS3_AVRPORT == AVRPORTB)
00200 #define SBBI3_CS3_SOD_REG PORTB
00201 #define SBBI3_CS3_OE_REG DDRB
00202 #elif (SBBI3_CS3_AVRPORT == AVRPORTD)
00203 #define SBBI3_CS3_SOD_REG PORTD
00204 #define SBBI3_CS3_OE_REG DDRD
00205 #elif (SBBI3_CS3_AVRPORT == AVRPORTE)
00206 #define SBBI3_CS3_SOD_REG PORTE
00207 #define SBBI3_CS3_OE_REG DDRE
00208 #elif (SBBI3_CS3_AVRPORT == AVRPORTF)
00209 #define SBBI3_CS3_SOD_REG PORTF
00210 #define SBBI3_CS3_OE_REG DDRF
00211 #elif (SBBI3_CS3_AVRPORT == AVRPORTG)
00212 #define SBBI3_CS3_SOD_REG PORTG
00213 #define SBBI3_CS3_OE_REG DDRG
00214 #elif (SBBI3_CS3_AVRPORT == AVRPORTH)
00215 #define SBBI3_CS3_SOD_REG PORTH
00216 #define SBBI3_CS3_OE_REG DDRH
00217 #endif
00218
00220 #define SBBI3_CS3_ENA() sbi(SBBI3_CS3_OE_REG, SBBI3_CS3_BIT)
00221
00222 #define SBBI3_CS3_CLR() cbi(SBBI3_CS3_SOD_REG, SBBI3_CS3_BIT)
00223
00224 #define SBBI3_CS3_SET() sbi(SBBI3_CS3_SOD_REG, SBBI3_CS3_BIT)
00225
00226 #endif
00227
00228 #ifdef SBBI3_RST0_BIT
00229
00230 #if (SBBI3_RST0_AVRPORT == AVRPORTB)
00231 #define SBBI3_RST0_SOD_REG PORTB
00232 #define SBBI3_RST0_OE_REG DDRB
00233 #elif (SBBI3_RST0_AVRPORT == AVRPORTD)
00234 #define SBBI3_RST0_SOD_REG PORTD
00235 #define SBBI3_RST0_OE_REG DDRD
00236 #elif (SBBI3_RST0_AVRPORT == AVRPORTE)
00237 #define SBBI3_RST0_SOD_REG PORTE
00238 #define SBBI3_RST0_OE_REG DDRE
00239 #elif (SBBI3_RST0_AVRPORT == AVRPORTF)
00240 #define SBBI3_RST0_SOD_REG PORTF
00241 #define SBBI3_RST0_OE_REG DDRF
00242 #elif (SBBI3_RST0_AVRPORT == AVRPORTG)
00243 #define SBBI3_RST0_SOD_REG PORTG
00244 #define SBBI3_RST0_OE_REG DDRG
00245 #elif (SBBI3_RST0_AVRPORT == AVRPORTH)
00246 #define SBBI3_RST0_SOD_REG PORTH
00247 #define SBBI3_RST0_OE_REG DDRH
00248 #endif
00249
00251 #define SBBI3_RST0_ENA() sbi(SBBI3_RST0_OE_REG, SBBI3_RST0_BIT)
00252
00253 #define SBBI3_RST0_CLR() cbi(SBBI3_RST0_SOD_REG, SBBI3_RST0_BIT)
00254
00255 #define SBBI3_RST0_SET() sbi(SBBI3_RST0_SOD_REG, SBBI3_RST0_BIT)
00256
00257 #endif
00258
00259 #ifdef SBBI3_RST1_BIT
00260
00261 #if (SBBI3_RST1_AVRPORT == AVRPORTB)
00262 #define SBBI3_RST1_SOD_REG PORTB
00263 #define SBBI3_RST1_OE_REG DDRB
00264 #elif (SBBI3_RST1_AVRPORT == AVRPORTD)
00265 #define SBBI3_RST1_SOD_REG PORTD
00266 #define SBBI3_RST1_OE_REG DDRD
00267 #elif (SBBI3_RST1_AVRPORT == AVRPORTE)
00268 #define SBBI3_RST1_SOD_REG PORTE
00269 #define SBBI3_RST1_OE_REG DDRE
00270 #elif (SBBI3_RST1_AVRPORT == AVRPORTF)
00271 #define SBBI3_RST1_SOD_REG PORTF
00272 #define SBBI3_RST1_OE_REG DDRF
00273 #elif (SBBI3_RST1_AVRPORT == AVRPORTG)
00274 #define SBBI3_RST1_SOD_REG PORTG
00275 #define SBBI3_RST1_OE_REG DDRG
00276 #elif (SBBI3_RST1_AVRPORT == AVRPORTH)
00277 #define SBBI3_RST1_SOD_REG PORTH
00278 #define SBBI3_RST1_OE_REG DDRH
00279 #endif
00280
00282 #define SBBI3_RST1_ENA() sbi(SBBI3_RST1_OE_REG, SBBI3_RST1_BIT)
00283
00284 #define SBBI3_RST1_CLR() cbi(SBBI3_RST1_SOD_REG, SBBI3_RST1_BIT)
00285
00286 #define SBBI3_RST1_SET() sbi(SBBI3_RST1_SOD_REG, SBBI3_RST1_BIT)
00287
00288 #endif
00289
00290 #ifdef SBBI3_RST2_BIT
00291
00292 #if (SBBI3_RST2_AVRPORT == AVRPORTB)
00293 #define SBBI3_RST2_SOD_REG PORTB
00294 #define SBBI3_RST2_OE_REG DDRB
00295 #elif (SBBI3_RST2_AVRPORT == AVRPORTD)
00296 #define SBBI3_RST2_SOD_REG PORTD
00297 #define SBBI3_RST2_OE_REG DDRD
00298 #elif (SBBI3_RST2_AVRPORT == AVRPORTE)
00299 #define SBBI3_RST2_SOD_REG PORTE
00300 #define SBBI3_RST2_OE_REG DDRE
00301 #elif (SBBI3_RST2_AVRPORT == AVRPORTF)
00302 #define SBBI3_RST2_SOD_REG PORTF
00303 #define SBBI3_RST2_OE_REG DDRF
00304 #elif (SBBI3_RST2_AVRPORT == AVRPORTG)
00305 #define SBBI3_RST2_SOD_REG PORTG
00306 #define SBBI3_RST2_OE_REG DDRG
00307 #elif (SBBI3_RST2_AVRPORT == AVRPORTH)
00308 #define SBBI3_RST2_SOD_REG PORTH
00309 #define SBBI3_RST2_OE_REG DDRH
00310 #endif
00311
00313 #define SBBI3_RST2_ENA() sbi(SBBI3_RST2_OE_REG, SBBI3_RST2_BIT)
00314
00315 #define SBBI3_RST2_CLR() cbi(SBBI3_RST2_SOD_REG, SBBI3_RST2_BIT)
00316
00317 #define SBBI3_RST2_SET() sbi(SBBI3_RST2_SOD_REG, SBBI3_RST2_BIT)
00318
00319 #endif
00320
00321 #ifdef SBBI3_RST3_BIT
00322
00323 #if (SBBI3_RST3_AVRPORT == AVRPORTB)
00324 #define SBBI3_RST3_SOD_REG PORTB
00325 #define SBBI3_RST3_OE_REG DDRB
00326 #elif (SBBI3_RST3_AVRPORT == AVRPORTD)
00327 #define SBBI3_RST3_SOD_REG PORTD
00328 #define SBBI3_RST3_OE_REG DDRD
00329 #elif (SBBI3_RST3_AVRPORT == AVRPORTE)
00330 #define SBBI3_RST3_SOD_REG PORTE
00331 #define SBBI3_RST3_OE_REG DDRE
00332 #elif (SBBI3_RST3_AVRPORT == AVRPORTF)
00333 #define SBBI3_RST3_SOD_REG PORTF
00334 #define SBBI3_RST3_OE_REG DDRF
00335 #elif (SBBI3_RST3_AVRPORT == AVRPORTG)
00336 #define SBBI3_RST3_SOD_REG PORTG
00337 #define SBBI3_RST3_OE_REG DDRG
00338 #elif (SBBI3_RST3_AVRPORT == AVRPORTH)
00339 #define SBBI3_RST3_SOD_REG PORTH
00340 #define SBBI3_RST3_OE_REG DDRH
00341 #endif
00342
00344 #define SBBI3_RST3_ENA() sbi(SBBI3_RST3_OE_REG, SBBI3_RST3_BIT)
00345
00346 #define SBBI3_RST3_CLR() cbi(SBBI3_RST3_SOD_REG, SBBI3_RST3_BIT)
00347
00348 #define SBBI3_RST3_SET() sbi(SBBI3_RST3_SOD_REG, SBBI3_RST3_BIT)
00349
00350 #endif
00351
00352 #ifdef SBBI3_SCK_BIT
00353
00354 #if (SBBI3_SCK_AVRPORT == AVRPORTB)
00355 #define SBBI3_SCK_SOD_REG PORTB
00356 #define SBBI3_SCK_OE_REG DDRB
00357 #elif (SBBI3_SCK_AVRPORT == AVRPORTD)
00358 #define SBBI3_SCK_SOD_REG PORTD
00359 #define SBBI3_SCK_OE_REG DDRD
00360 #elif (SBBI3_SCK_AVRPORT == AVRPORTE)
00361 #define SBBI3_SCK_SOD_REG PORTE
00362 #define SBBI3_SCK_OE_REG DDRE
00363 #elif (SBBI3_SCK_AVRPORT == AVRPORTF)
00364 #define SBBI3_SCK_SOD_REG PORTF
00365 #define SBBI3_SCK_OE_REG DDRF
00366 #elif (SBBI3_SCK_AVRPORT == AVRPORTG)
00367 #define SBBI3_SCK_SOD_REG PORTG
00368 #define SBBI3_SCK_OE_REG DDRG
00369 #elif (SBBI3_SCK_AVRPORT == AVRPORTH)
00370 #define SBBI3_SCK_SOD_REG PORTH
00371 #define SBBI3_SCK_OE_REG DDRH
00372 #endif
00373
00375 #define SBBI3_SCK_ENA() sbi(SBBI3_SCK_OE_REG, SBBI3_SCK_BIT)
00376
00377 #define SBBI3_SCK_CLR() cbi(SBBI3_SCK_SOD_REG, SBBI3_SCK_BIT)
00378
00379 #define SBBI3_SCK_SET() sbi(SBBI3_SCK_SOD_REG, SBBI3_SCK_BIT)
00380
00381 #if defined(SBBI3_MOSI_BIT)
00382
00383 #if (SBBI3_MOSI_AVRPORT == AVRPORTB)
00384 #define SBBI3_MOSI_SOD_REG PORTB
00385 #define SBBI3_MOSI_OE_REG DDRB
00386 #elif (SBBI3_MOSI_AVRPORT == AVRPORTD)
00387 #define SBBI3_MOSI_SOD_REG PORTD
00388 #define SBBI3_MOSI_OE_REG DDRD
00389 #elif (SBBI3_MOSI_AVRPORT == AVRPORTE)
00390 #define SBBI3_MOSI_SOD_REG PORTE
00391 #define SBBI3_MOSI_OE_REG DDRE
00392 #elif (SBBI3_MOSI_AVRPORT == AVRPORTF)
00393 #define SBBI3_MOSI_SOD_REG PORTF
00394 #define SBBI3_MOSI_OE_REG DDRF
00395 #elif (SBBI3_MOSI_AVRPORT == AVRPORTG)
00396 #define SBBI3_MOSI_SOD_REG PORTG
00397 #define SBBI3_MOSI_OE_REG DDRG
00398 #elif (SBBI3_MOSI_AVRPORT == AVRPORTH)
00399 #define SBBI3_MOSI_SOD_REG PORTH
00400 #define SBBI3_MOSI_OE_REG DDRH
00401 #endif
00402
00404 #define SBBI3_MOSI_ENA() sbi(SBBI3_MOSI_OE_REG, SBBI3_MOSI_BIT)
00405
00406 #define SBBI3_MOSI_CLR() cbi(SBBI3_MOSI_SOD_REG, SBBI3_MOSI_BIT)
00407
00408 #define SBBI3_MOSI_SET() sbi(SBBI3_MOSI_SOD_REG, SBBI3_MOSI_BIT)
00409
00410 #else
00411
00412 #define SBBI3_MOSI_ENA()
00413 #define SBBI3_MOSI_CLR()
00414 #define SBBI3_MOSI_SET()
00415
00416 #endif
00417
00418 #if defined(SBBI3_MISO_BIT)
00419
00420 #if (SBBI3_MISO_AVRPORT == AVRPORTB)
00421 #define SBBI3_MISO_PDS_REG PINB
00422 #define SBBI3_MISO_PUE_REG PORTB
00423 #define SBBI3_MISO_OE_REG DDRB
00424 #elif (SBBI3_MISO_AVRPORT == AVRPORTD)
00425 #define SBBI3_MISO_PDS_REG PIND
00426 #define SBBI3_MISO_PUE_REG PORTD
00427 #define SBBI3_MISO_OE_REG DDRD
00428 #elif (SBBI3_MISO_AVRPORT == AVRPORTE)
00429 #define SBBI3_MISO_PDS_REG PINE
00430 #define SBBI3_MISO_PUE_REG PORTE
00431 #define SBBI3_MISO_OE_REG DDRE
00432 #elif (SBBI3_MISO_AVRPORT == AVRPORTF)
00433 #define SBBI3_MISO_PDS_REG PINF
00434 #define SBBI3_MISO_PUE_REG PORTF
00435 #define SBBI3_MISO_OE_REG DDRF
00436 #elif (SBBI3_MISO_AVRPORT == AVRPORTG)
00437 #define SBBI3_MISO_PDS_REG PING
00438 #define SBBI3_MISO_PUE_REG PORTG
00439 #define SBBI3_MISO_OE_REG DDRG
00440 #elif (SBBI3_MISO_AVRPORT == AVRPORTH)
00441 #define SBBI3_MISO_PDS_REG PINH
00442 #define SBBI3_MISO_PUE_REG PORTH
00443 #define SBBI3_MISO_OE_REG DDRH
00444 #endif
00445
00447 #define SBBI3_MISO_ENA() \
00448 cbi(SBBI3_MISO_OE_REG, SBBI3_MISO_BIT); \
00449 sbi(SBBI3_MISO_PUE_REG, SBBI3_MISO_BIT)
00450
00451 #define SBBI3_MISO_TST() ((inb(SBBI3_MISO_PDS_REG) & _BV(SBBI3_MISO_BIT)) == _BV(SBBI3_MISO_BIT))
00452
00453 #else
00454
00455 #define SBBI3_MISO_ENA()
00456 #define SBBI3_MISO_TST() 0
00457
00458 #endif
00459
00460 #endif
00461
00462 #else
00463
00464
00465
00466
00467
00468 #ifdef SBBI3_CS0_BIT
00469
00470 #if !defined(SBBI3_CS0_PIO_ID)
00471 #define SBBI3_CS0_PE_REG PIO_PER
00472 #define SBBI3_CS0_OE_REG PIO_OER
00473 #define SBBI3_CS0_COD_REG PIO_CODR
00474 #define SBBI3_CS0_SOD_REG PIO_SODR
00475 #elif SBBI3_CS0_PIO_ID == PIOA_ID
00476 #define SBBI3_CS0_PE_REG PIOA_PER
00477 #define SBBI3_CS0_OE_REG PIOA_OER
00478 #define SBBI3_CS0_COD_REG PIOA_CODR
00479 #define SBBI3_CS0_SOD_REG PIOA_SODR
00480 #elif SBBI3_CS0_PIO_ID == PIOB_ID
00481 #define SBBI3_CS0_PE_REG PIOB_PER
00482 #define SBBI3_CS0_OE_REG PIOB_OER
00483 #define SBBI3_CS0_COD_REG PIOB_CODR
00484 #define SBBI3_CS0_SOD_REG PIOB_SODR
00485 #elif SBBI3_CS0_PIO_ID == PIOC_ID
00486 #define SBBI3_CS0_PE_REG PIOC_PER
00487 #define SBBI3_CS0_OE_REG PIOC_OER
00488 #define SBBI3_CS0_COD_REG PIOC_CODR
00489 #define SBBI3_CS0_SOD_REG PIOC_SODR
00490 #endif
00491
00493 #define SBBI3_CS0_ENA() \
00494 outr(SBBI3_CS0_PE_REG, _BV(SBBI3_CS0_BIT)); \
00495 outr(SBBI3_CS0_OE_REG, _BV(SBBI3_CS0_BIT))
00496
00497 #define SBBI3_CS0_CLR() outr(SBBI3_CS0_COD_REG, _BV(SBBI3_CS0_BIT))
00498
00499 #define SBBI3_CS0_SET() outr(SBBI3_CS0_SOD_REG, _BV(SBBI3_CS0_BIT))
00500
00501 #endif
00502
00503 #ifdef SBBI3_CS1_BIT
00504
00505 #if !defined(SBBI3_CS1_PIO_ID)
00506 #define SBBI3_CS1_PE_REG PIO_PER
00507 #define SBBI3_CS1_OE_REG PIO_OER
00508 #define SBBI3_CS1_COD_REG PIO_CODR
00509 #define SBBI3_CS1_SOD_REG PIO_SODR
00510 #elif SBBI3_CS1_PIO_ID == PIOA_ID
00511 #define SBBI3_CS1_PE_REG PIOA_PER
00512 #define SBBI3_CS1_OE_REG PIOA_OER
00513 #define SBBI3_CS1_COD_REG PIOA_CODR
00514 #define SBBI3_CS1_SOD_REG PIOA_SODR
00515 #elif SBBI3_CS1_PIO_ID == PIOB_ID
00516 #define SBBI3_CS1_PE_REG PIOB_PER
00517 #define SBBI3_CS1_OE_REG PIOB_OER
00518 #define SBBI3_CS1_COD_REG PIOB_CODR
00519 #define SBBI3_CS1_SOD_REG PIOB_SODR
00520 #elif SBBI3_CS1_PIO_ID == PIOC_ID
00521 #define SBBI3_CS1_PE_REG PIOC_PER
00522 #define SBBI3_CS1_OE_REG PIOC_OER
00523 #define SBBI3_CS1_COD_REG PIOC_CODR
00524 #define SBBI3_CS1_SOD_REG PIOC_SODR
00525 #endif
00526
00528 #define SBBI3_CS1_ENA() \
00529 outr(SBBI3_CS1_PE_REG, _BV(SBBI3_CS1_BIT)); \
00530 outr(SBBI3_CS1_OE_REG, _BV(SBBI3_CS1_BIT))
00531
00532 #define SBBI3_CS1_CLR() outr(SBBI3_CS1_COD_REG, _BV(SBBI3_CS1_BIT))
00533
00534 #define SBBI3_CS1_SET() outr(SBBI3_CS1_SOD_REG, _BV(SBBI3_CS1_BIT))
00535
00536 #endif
00537
00538 #ifdef SBBI3_CS2_BIT
00539
00540 #if !defined(SBBI3_CS2_PIO_ID)
00541 #define SBBI3_CS2_PE_REG PIO_PER
00542 #define SBBI3_CS2_OE_REG PIO_OER
00543 #define SBBI3_CS2_COD_REG PIO_CODR
00544 #define SBBI3_CS2_SOD_REG PIO_SODR
00545 #elif SBBI3_CS2_PIO_ID == PIOA_ID
00546 #define SBBI3_CS2_PE_REG PIOA_PER
00547 #define SBBI3_CS2_OE_REG PIOA_OER
00548 #define SBBI3_CS2_COD_REG PIOA_CODR
00549 #define SBBI3_CS2_SOD_REG PIOA_SODR
00550 #elif SBBI3_CS2_PIO_ID == PIOB_ID
00551 #define SBBI3_CS2_PE_REG PIOB_PER
00552 #define SBBI3_CS2_OE_REG PIOB_OER
00553 #define SBBI3_CS2_COD_REG PIOB_CODR
00554 #define SBBI3_CS2_SOD_REG PIOB_SODR
00555 #elif SBBI3_CS2_PIO_ID == PIOC_ID
00556 #define SBBI3_CS2_PE_REG PIOC_PER
00557 #define SBBI3_CS2_OE_REG PIOC_OER
00558 #define SBBI3_CS2_COD_REG PIOC_CODR
00559 #define SBBI3_CS2_SOD_REG PIOC_SODR
00560 #endif
00561
00563 #define SBBI3_CS2_ENA() \
00564 outr(SBBI3_CS2_PE_REG, _BV(SBBI3_CS2_BIT)); \
00565 outr(SBBI3_CS2_OE_REG, _BV(SBBI3_CS2_BIT))
00566
00567 #define SBBI3_CS2_CLR() outr(SBBI3_CS2_COD_REG, _BV(SBBI3_CS2_BIT))
00568
00569 #define SBBI3_CS2_SET() outr(SBBI3_CS2_SOD_REG, _BV(SBBI3_CS2_BIT))
00570
00571 #endif
00572
00573 #ifdef SBBI3_CS3_BIT
00574
00575 #if !defined(SBBI3_CS3_PIO_ID)
00576 #define SBBI3_CS3_PE_REG PIO_PER
00577 #define SBBI3_CS3_OE_REG PIO_OER
00578 #define SBBI3_CS3_COD_REG PIO_CODR
00579 #define SBBI3_CS3_SOD_REG PIO_SODR
00580 #elif SBBI3_CS3_PIO_ID == PIOA_ID
00581 #define SBBI3_CS3_PE_REG PIOA_PER
00582 #define SBBI3_CS3_OE_REG PIOA_OER
00583 #define SBBI3_CS3_COD_REG PIOA_CODR
00584 #define SBBI3_CS3_SOD_REG PIOA_SODR
00585 #elif SBBI3_CS3_PIO_ID == PIOB_ID
00586 #define SBBI3_CS3_PE_REG PIOB_PER
00587 #define SBBI3_CS3_OE_REG PIOB_OER
00588 #define SBBI3_CS3_COD_REG PIOB_CODR
00589 #define SBBI3_CS3_SOD_REG PIOB_SODR
00590 #elif SBBI3_CS3_PIO_ID == PIOC_ID
00591 #define SBBI3_CS3_PE_REG PIOC_PER
00592 #define SBBI3_CS3_OE_REG PIOC_OER
00593 #define SBBI3_CS3_COD_REG PIOC_CODR
00594 #define SBBI3_CS3_SOD_REG PIOC_SODR
00595 #endif
00596
00598 #define SBBI3_CS3_ENA() \
00599 outr(SBBI3_CS3_PE_REG, _BV(SBBI3_CS3_BIT)); \
00600 outr(SBBI3_CS3_OE_REG, _BV(SBBI3_CS3_BIT))
00601
00602 #define SBBI3_CS3_CLR() outr(SBBI3_CS3_COD_REG, _BV(SBBI3_CS3_BIT))
00603
00604 #define SBBI3_CS3_SET() outr(SBBI3_CS3_SOD_REG, _BV(SBBI3_CS3_BIT))
00605
00606 #endif
00607
00608 #ifdef SBBI3_RST0_BIT
00609
00610 #if !defined(SBBI3_RST0_PIO_ID)
00611 #define SBBI3_RST0_PE_REG PIO_PER
00612 #define SBBI3_RST0_OE_REG PIO_OER
00613 #define SBBI3_RST0_COD_REG PIO_CODR
00614 #define SBBI3_RST0_SOD_REG PIO_SODR
00615 #elif SBBI3_RST0_PIO_ID == PIOA_ID
00616 #define SBBI3_RST0_PE_REG PIOA_PER
00617 #define SBBI3_RST0_OE_REG PIOA_OER
00618 #define SBBI3_RST0_COD_REG PIOA_CODR
00619 #define SBBI3_RST0_SOD_REG PIOA_SODR
00620 #elif SBBI3_RST0_PIO_ID == PIOB_ID
00621 #define SBBI3_RST0_PE_REG PIOB_PER
00622 #define SBBI3_RST0_OE_REG PIOB_OER
00623 #define SBBI3_RST0_COD_REG PIOB_CODR
00624 #define SBBI3_RST0_SOD_REG PIOB_SODR
00625 #elif SBBI3_RST0_PIO_ID == PIOC_ID
00626 #define SBBI3_RST0_PE_REG PIOC_PER
00627 #define SBBI3_RST0_OE_REG PIOC_OER
00628 #define SBBI3_RST0_COD_REG PIOC_CODR
00629 #define SBBI3_RST0_SOD_REG PIOC_SODR
00630 #endif
00631
00633 #define SBBI3_RST0_ENA() \
00634 outr(SBBI3_RST0_PE_REG, _BV(SBBI3_RST0_BIT)); \
00635 outr(SBBI3_RST0_OE_REG, _BV(SBBI3_RST0_BIT))
00636
00637 #define SBBI3_RST0_CLR() outr(SBBI3_RST0_COD_REG, _BV(SBBI3_RST0_BIT))
00638
00639 #define SBBI3_RST0_SET() outr(SBBI3_RST0_SOD_REG, _BV(SBBI3_RST0_BIT))
00640
00641 #endif
00642
00643 #ifdef SBBI3_RST1_BIT
00644
00645 #if !defined(SBBI3_RST1_PIO_ID)
00646 #define SBBI3_RST1_PE_REG PIO_PER
00647 #define SBBI3_RST1_OE_REG PIO_OER
00648 #define SBBI3_RST1_COD_REG PIO_CODR
00649 #define SBBI3_RST1_SOD_REG PIO_SODR
00650 #elif SBBI3_RST1_PIO_ID == PIOA_ID
00651 #define SBBI3_RST1_PE_REG PIOA_PER
00652 #define SBBI3_RST1_OE_REG PIOA_OER
00653 #define SBBI3_RST1_COD_REG PIOA_CODR
00654 #define SBBI3_RST1_SOD_REG PIOA_SODR
00655 #elif SBBI3_RST1_PIO_ID == PIOB_ID
00656 #define SBBI3_RST1_PE_REG PIOB_PER
00657 #define SBBI3_RST1_OE_REG PIOB_OER
00658 #define SBBI3_RST1_COD_REG PIOB_CODR
00659 #define SBBI3_RST1_SOD_REG PIOB_SODR
00660 #elif SBBI3_RST1_PIO_ID == PIOC_ID
00661 #define SBBI3_RST1_PE_REG PIOC_PER
00662 #define SBBI3_RST1_OE_REG PIOC_OER
00663 #define SBBI3_RST1_COD_REG PIOC_CODR
00664 #define SBBI3_RST1_SOD_REG PIOC_SODR
00665 #endif
00666
00668 #define SBBI3_RST1_ENA() \
00669 outr(SBBI3_RST1_PE_REG, _BV(SBBI3_RST1_BIT)); \
00670 outr(SBBI3_RST1_OE_REG, _BV(SBBI3_RST1_BIT))
00671
00672 #define SBBI3_RST1_CLR() outr(SBBI3_RST1_COD_REG, _BV(SBBI3_RST1_BIT))
00673
00674 #define SBBI3_RST1_SET() outr(SBBI3_RST1_SOD_REG, _BV(SBBI3_RST1_BIT))
00675
00676 #endif
00677
00678 #ifdef SBBI3_RST2_BIT
00679
00680 #if !defined(SBBI3_RST2_PIO_ID)
00681 #define SBBI3_RST2_PE_REG PIO_PER
00682 #define SBBI3_RST2_OE_REG PIO_OER
00683 #define SBBI3_RST2_COD_REG PIO_CODR
00684 #define SBBI3_RST2_SOD_REG PIO_SODR
00685 #elif SBBI3_RST2_PIO_ID == PIOA_ID
00686 #define SBBI3_RST2_PE_REG PIOA_PER
00687 #define SBBI3_RST2_OE_REG PIOA_OER
00688 #define SBBI3_RST2_COD_REG PIOA_CODR
00689 #define SBBI3_RST2_SOD_REG PIOA_SODR
00690 #elif SBBI3_RST2_PIO_ID == PIOB_ID
00691 #define SBBI3_RST2_PE_REG PIOB_PER
00692 #define SBBI3_RST2_OE_REG PIOB_OER
00693 #define SBBI3_RST2_COD_REG PIOB_CODR
00694 #define SBBI3_RST2_SOD_REG PIOB_SODR
00695 #elif SBBI3_RST2_PIO_ID == PIOC_ID
00696 #define SBBI3_RST2_PE_REG PIOC_PER
00697 #define SBBI3_RST2_OE_REG PIOC_OER
00698 #define SBBI3_RST2_COD_REG PIOC_CODR
00699 #define SBBI3_RST2_SOD_REG PIOC_SODR
00700 #endif
00701
00703 #define SBBI3_RST2_ENA() \
00704 outr(SBBI3_RST2_PE_REG, _BV(SBBI3_RST2_BIT)); \
00705 outr(SBBI3_RST2_OE_REG, _BV(SBBI3_RST2_BIT))
00706
00707 #define SBBI3_RST2_CLR() outr(SBBI3_RST2_COD_REG, _BV(SBBI3_RST2_BIT))
00708
00709 #define SBBI3_RST2_SET() outr(SBBI3_RST2_SOD_REG, _BV(SBBI3_RST2_BIT))
00710
00711 #endif
00712
00713 #ifdef SBBI3_RST3_BIT
00714
00715 #if !defined(SBBI3_RST3_PIO_ID)
00716 #define SBBI3_RST3_PE_REG PIO_PER
00717 #define SBBI3_RST3_OE_REG PIO_OER
00718 #define SBBI3_RST3_COD_REG PIO_CODR
00719 #define SBBI3_RST3_SOD_REG PIO_SODR
00720 #elif SBBI3_RST3_PIO_ID == PIOA_ID
00721 #define SBBI3_RST3_PE_REG PIOA_PER
00722 #define SBBI3_RST3_OE_REG PIOA_OER
00723 #define SBBI3_RST3_COD_REG PIOA_CODR
00724 #define SBBI3_RST3_SOD_REG PIOA_SODR
00725 #elif SBBI3_RST3_PIO_ID == PIOB_ID
00726 #define SBBI3_RST3_PE_REG PIOB_PER
00727 #define SBBI3_RST3_OE_REG PIOB_OER
00728 #define SBBI3_RST3_COD_REG PIOB_CODR
00729 #define SBBI3_RST3_SOD_REG PIOB_SODR
00730 #elif SBBI3_RST3_PIO_ID == PIOC_ID
00731 #define SBBI3_RST3_PE_REG PIOC_PER
00732 #define SBBI3_RST3_OE_REG PIOC_OER
00733 #define SBBI3_RST3_COD_REG PIOC_CODR
00734 #define SBBI3_RST3_SOD_REG PIOC_SODR
00735 #endif
00736
00738 #define SBBI3_RST3_ENA() \
00739 outr(SBBI3_RST3_PE_REG, _BV(SBBI3_RST3_BIT)); \
00740 outr(SBBI3_RST3_OE_REG, _BV(SBBI3_RST3_BIT))
00741
00742 #define SBBI3_RST3_CLR() outr(SBBI3_RST3_COD_REG, _BV(SBBI3_RST3_BIT))
00743
00744 #define SBBI3_RST3_SET() outr(SBBI3_RST3_SOD_REG, _BV(SBBI3_RST3_BIT))
00745
00746 #endif
00747
00748 #ifdef SBBI3_SCK_BIT
00749
00750 #if !defined(SBBI3_SCK_PIO_ID)
00751 #define SBBI3_SCK_PE_REG PIO_PER
00752 #define SBBI3_SCK_OE_REG PIO_OER
00753 #define SBBI3_SCK_COD_REG PIO_CODR
00754 #define SBBI3_SCK_SOD_REG PIO_SODR
00755 #elif SBBI3_SCK_PIO_ID == PIOA_ID
00756 #define SBBI3_SCK_PE_REG PIOA_PER
00757 #define SBBI3_SCK_OE_REG PIOA_OER
00758 #define SBBI3_SCK_COD_REG PIOA_CODR
00759 #define SBBI3_SCK_SOD_REG PIOA_SODR
00760 #elif SBBI3_SCK_PIO_ID == PIOB_ID
00761 #define SBBI3_SCK_PE_REG PIOB_PER
00762 #define SBBI3_SCK_OE_REG PIOB_OER
00763 #define SBBI3_SCK_COD_REG PIOB_CODR
00764 #define SBBI3_SCK_SOD_REG PIOB_SODR
00765 #elif SBBI3_SCK_PIO_ID == PIOC_ID
00766 #define SBBI3_SCK_PE_REG PIOC_PER
00767 #define SBBI3_SCK_OE_REG PIOC_OER
00768 #define SBBI3_SCK_COD_REG PIOC_CODR
00769 #define SBBI3_SCK_SOD_REG PIOC_SODR
00770 #endif
00771
00773 #define SBBI3_SCK_ENA() \
00774 outr(SBBI3_SCK_PE_REG, _BV(SBBI3_SCK_BIT)); \
00775 outr(SBBI3_SCK_OE_REG, _BV(SBBI3_SCK_BIT))
00776
00777 #define SBBI3_SCK_CLR() outr(SBBI3_SCK_COD_REG, _BV(SBBI3_SCK_BIT))
00778
00779 #define SBBI3_SCK_SET() outr(SBBI3_SCK_SOD_REG, _BV(SBBI3_SCK_BIT))
00780
00781 #ifdef SBBI3_MOSI_BIT
00782
00783 #if !defined(SBBI3_MOSI_PIO_ID)
00784 #define SBBI3_MOSI_PE_REG PIO_PER
00785 #define SBBI3_MOSI_OE_REG PIO_OER
00786 #define SBBI3_MOSI_COD_REG PIO_CODR
00787 #define SBBI3_MOSI_SOD_REG PIO_SODR
00788 #elif SBBI3_MOSI_PIO_ID == PIOA_ID
00789 #define SBBI3_MOSI_PE_REG PIOA_PER
00790 #define SBBI3_MOSI_OE_REG PIOA_OER
00791 #define SBBI3_MOSI_COD_REG PIOA_CODR
00792 #define SBBI3_MOSI_SOD_REG PIOA_SODR
00793 #elif SBBI3_MOSI_PIO_ID == PIOB_ID
00794 #define SBBI3_MOSI_PE_REG PIOB_PER
00795 #define SBBI3_MOSI_OE_REG PIOB_OER
00796 #define SBBI3_MOSI_COD_REG PIOB_CODR
00797 #define SBBI3_MOSI_SOD_REG PIOB_SODR
00798 #elif SBBI3_MOSI_PIO_ID == PIOC_ID
00799 #define SBBI3_MOSI_PE_REG PIOC_PER
00800 #define SBBI3_MOSI_OE_REG PIOC_OER
00801 #define SBBI3_MOSI_COD_REG PIOC_CODR
00802 #define SBBI3_MOSI_SOD_REG PIOC_SODR
00803 #endif
00804
00806 #define SBBI3_MOSI_ENA() \
00807 outr(SBBI3_MOSI_PE_REG, _BV(SBBI3_MOSI_BIT)); \
00808 outr(SBBI3_MOSI_OE_REG, _BV(SBBI3_MOSI_BIT))
00809
00810 #define SBBI3_MOSI_CLR() outr(SBBI3_MOSI_COD_REG, _BV(SBBI3_MOSI_BIT))
00811
00812 #define SBBI3_MOSI_SET() outr(SBBI3_MOSI_SOD_REG, _BV(SBBI3_MOSI_BIT))
00813
00814 #else
00815
00816 #define SBBI3_MOSI_ENA()
00817 #define SBBI3_MOSI_CLR()
00818 #define SBBI3_MOSI_SET()
00819
00820 #endif
00821
00822 #ifdef SBBI3_MISO_BIT
00823
00824 #if !defined(SBBI3_MISO_PIO_ID)
00825 #define SBBI3_MISO_PE_REG PIO_PER
00826 #define SBBI3_MISO_OD_REG PIO_ODR
00827 #define SBBI3_MISO_PDS_REG PIO_PDSR
00828 #elif SBBI3_MISO_PIO_ID == PIOA_ID
00829 #define SBBI3_MISO_PE_REG PIOA_PER
00830 #define SBBI3_MISO_OD_REG PIOA_ODR
00831 #define SBBI3_MISO_PDS_REG PIOA_PDSR
00832 #elif SBBI3_MISO_PIO_ID == PIOB_ID
00833 #define SBBI3_MISO_PE_REG PIOB_PER
00834 #define SBBI3_MISO_OD_REG PIOB_ODR
00835 #define SBBI3_MISO_PDS_REG PIOB_PDSR
00836 #elif SBBI3_MISO_PIO_ID == PIOC_ID
00837 #define SBBI3_MISO_PE_REG PIOC_PER
00838 #define SBBI3_MISO_OD_REG PIOC_ODR
00839 #define SBBI3_MISO_PDS_REG PIOC_PDSR
00840 #endif
00841
00843 #define SBBI3_MISO_ENA() \
00844 outr(SBBI3_MISO_PE_REG, _BV(SBBI3_MISO_BIT)); \
00845 outr(SBBI3_MISO_OD_REG, _BV(SBBI3_MISO_BIT))
00846
00847 #define SBBI3_MISO_TST() ((inr(SBBI3_MISO_PDS_REG) & _BV(SBBI3_MISO_BIT)) == _BV(SBBI3_MISO_BIT))
00848
00849 #else
00850
00851 #define SBBI3_MISO_ENA()
00852 #define SBBI3_MISO_TST() 0
00853
00854 #endif
00855
00856 #endif
00857
00858 #endif
00859
00860 #define SBBI3_INIT() \
00861 { \
00862 SBBI3_SCK_CLR(); \
00863 SBBI3_SCK_ENA(); \
00864 SBBI3_MOSI_CLR(); \
00865 SBBI3_MOSI_ENA(); \
00866 SBBI3_MISO_ENA(); \
00867 }
00868
00869 #endif