00001 #ifndef _DEV_SBBI2F_H_
00002 #define _DEV_SBBI2F_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
00052 #include <cfg/arch/gpio.h>
00053
00057 #ifndef SBBI2_MAX_DEVICES
00058 #define SBBI2_MAX_DEVICES 4
00059 #endif
00060
00061 #if defined(__AVR__)
00062
00063
00064
00065
00066
00067 #ifdef SBBI2_SCK_AVRBIT
00068 #define SBBI2_SCK_BIT SBBI2_SCK_AVRBIT
00069 #endif
00070 #ifdef SBBI2_MOSI_AVRBIT
00071 #define SBBI2_MOSI_BIT SBBI2_MOSI_AVRBIT
00072 #endif
00073 #ifdef SBBI2_MISO_AVRBIT
00074 #define SBBI2_MISO_BIT SBBI2_MISO_AVRBIT
00075 #endif
00076 #ifdef SBBI2_CS0_AVRBIT
00077 #define SBBI2_CS0_BIT SBBI2_CS0_AVRBIT
00078 #endif
00079 #ifdef SBBI2_CS1_AVRBIT
00080 #define SBBI2_CS1_BIT SBBI2_CS1_AVRBIT
00081 #endif
00082 #ifdef SBBI2_CS2_AVRBIT
00083 #define SBBI2_CS2_BIT SBBI2_CS2_AVRBIT
00084 #endif
00085 #ifdef SBBI2_CS3_AVRBIT
00086 #define SBBI2_CS3_BIT SBBI2_CS3_AVRBIT
00087 #endif
00088 #ifdef SBBI2_RST0_AVRBIT
00089 #define SBBI2_RST0_BIT SBBI2_RST0_AVRBIT
00090 #endif
00091 #ifdef SBBI2_RST1_AVRBIT
00092 #define SBBI2_RST1_BIT SBBI2_RST1_AVRBIT
00093 #endif
00094 #ifdef SBBI2_RST2_AVRBIT
00095 #define SBBI2_RST2_BIT SBBI2_RST2_AVRBIT
00096 #endif
00097 #ifdef SBBI2_RST3_AVRBIT
00098 #define SBBI2_RST3_BIT SBBI2_RST3_AVRBIT
00099 #endif
00100
00101 #ifdef SBBI2_CS0_BIT
00102
00103 #if (SBBI2_CS0_AVRPORT == AVRPORTB)
00104 #define SBBI2_CS0_SOD_REG PORTB
00105 #define SBBI2_CS0_OE_REG DDRB
00106 #elif (SBBI2_CS0_AVRPORT == AVRPORTD)
00107 #define SBBI2_CS0_SOD_REG PORTD
00108 #define SBBI2_CS0_OE_REG DDRD
00109 #elif (SBBI2_CS0_AVRPORT == AVRPORTE)
00110 #define SBBI2_CS0_SOD_REG PORTE
00111 #define SBBI2_CS0_OE_REG DDRE
00112 #elif (SBBI2_CS0_AVRPORT == AVRPORTF)
00113 #define SBBI2_CS0_SOD_REG PORTF
00114 #define SBBI2_CS0_OE_REG DDRF
00115 #elif (SBBI2_CS0_AVRPORT == AVRPORTG)
00116 #define SBBI2_CS0_SOD_REG PORTG
00117 #define SBBI2_CS0_OE_REG DDRG
00118 #elif (SBBI2_CS0_AVRPORT == AVRPORTH)
00119 #define SBBI2_CS0_SOD_REG PORTH
00120 #define SBBI2_CS0_OE_REG DDRH
00121 #endif
00122
00124 #define SBBI2_CS0_ENA() sbi(SBBI2_CS0_OE_REG, SBBI2_CS0_BIT)
00125
00126 #define SBBI2_CS0_CLR() cbi(SBBI2_CS0_SOD_REG, SBBI2_CS0_BIT)
00127
00128 #define SBBI2_CS0_SET() sbi(SBBI2_CS0_SOD_REG, SBBI2_CS0_BIT)
00129
00130 #endif
00131
00132 #ifdef SBBI2_CS1_BIT
00133
00134 #if (SBBI2_CS1_AVRPORT == AVRPORTB)
00135 #define SBBI2_CS1_SOD_REG PORTB
00136 #define SBBI2_CS1_OE_REG DDRB
00137 #elif (SBBI2_CS1_AVRPORT == AVRPORTD)
00138 #define SBBI2_CS1_SOD_REG PORTD
00139 #define SBBI2_CS1_OE_REG DDRD
00140 #elif (SBBI2_CS1_AVRPORT == AVRPORTE)
00141 #define SBBI2_CS1_SOD_REG PORTE
00142 #define SBBI2_CS1_OE_REG DDRE
00143 #elif (SBBI2_CS1_AVRPORT == AVRPORTF)
00144 #define SBBI2_CS1_SOD_REG PORTF
00145 #define SBBI2_CS1_OE_REG DDRF
00146 #elif (SBBI2_CS1_AVRPORT == AVRPORTG)
00147 #define SBBI2_CS1_SOD_REG PORTG
00148 #define SBBI2_CS1_OE_REG DDRG
00149 #elif (SBBI2_CS1_AVRPORT == AVRPORTH)
00150 #define SBBI2_CS1_SOD_REG PORTH
00151 #define SBBI2_CS1_OE_REG DDRH
00152 #endif
00153
00155 #define SBBI2_CS1_ENA() sbi(SBBI2_CS1_OE_REG, SBBI2_CS1_BIT)
00156
00157 #define SBBI2_CS1_CLR() cbi(SBBI2_CS1_SOD_REG, SBBI2_CS1_BIT)
00158
00159 #define SBBI2_CS1_SET() sbi(SBBI2_CS1_SOD_REG, SBBI2_CS1_BIT)
00160
00161 #endif
00162
00163 #ifdef SBBI2_CS2_BIT
00164
00165 #if (SBBI2_CS2_AVRPORT == AVRPORTB)
00166 #define SBBI2_CS2_SOD_REG PORTB
00167 #define SBBI2_CS2_OE_REG DDRB
00168 #elif (SBBI2_CS2_AVRPORT == AVRPORTD)
00169 #define SBBI2_CS2_SOD_REG PORTD
00170 #define SBBI2_CS2_OE_REG DDRD
00171 #elif (SBBI2_CS2_AVRPORT == AVRPORTE)
00172 #define SBBI2_CS2_SOD_REG PORTE
00173 #define SBBI2_CS2_OE_REG DDRE
00174 #elif (SBBI2_CS2_AVRPORT == AVRPORTF)
00175 #define SBBI2_CS2_SOD_REG PORTF
00176 #define SBBI2_CS2_OE_REG DDRF
00177 #elif (SBBI2_CS2_AVRPORT == AVRPORTG)
00178 #define SBBI2_CS2_SOD_REG PORTG
00179 #define SBBI2_CS2_OE_REG DDRG
00180 #elif (SBBI2_CS2_AVRPORT == AVRPORTH)
00181 #define SBBI2_CS2_SOD_REG PORTH
00182 #define SBBI2_CS2_OE_REG DDRH
00183 #endif
00184
00186 #define SBBI2_CS2_ENA() sbi(SBBI2_CS2_OE_REG, SBBI2_CS2_BIT)
00187
00188 #define SBBI2_CS2_CLR() cbi(SBBI2_CS2_SOD_REG, SBBI2_CS2_BIT)
00189
00190 #define SBBI2_CS2_SET() sbi(SBBI2_CS2_SOD_REG, SBBI2_CS2_BIT)
00191
00192 #endif
00193
00194 #ifdef SBBI2_CS3_BIT
00195
00196 #if (SBBI2_CS3_AVRPORT == AVRPORTB)
00197 #define SBBI2_CS3_SOD_REG PORTB
00198 #define SBBI2_CS3_OE_REG DDRB
00199 #elif (SBBI2_CS3_AVRPORT == AVRPORTD)
00200 #define SBBI2_CS3_SOD_REG PORTD
00201 #define SBBI2_CS3_OE_REG DDRD
00202 #elif (SBBI2_CS3_AVRPORT == AVRPORTE)
00203 #define SBBI2_CS3_SOD_REG PORTE
00204 #define SBBI2_CS3_OE_REG DDRE
00205 #elif (SBBI2_CS3_AVRPORT == AVRPORTF)
00206 #define SBBI2_CS3_SOD_REG PORTF
00207 #define SBBI2_CS3_OE_REG DDRF
00208 #elif (SBBI2_CS3_AVRPORT == AVRPORTG)
00209 #define SBBI2_CS3_SOD_REG PORTG
00210 #define SBBI2_CS3_OE_REG DDRG
00211 #elif (SBBI2_CS3_AVRPORT == AVRPORTH)
00212 #define SBBI2_CS3_SOD_REG PORTH
00213 #define SBBI2_CS3_OE_REG DDRH
00214 #endif
00215
00217 #define SBBI2_CS3_ENA() sbi(SBBI2_CS3_OE_REG, SBBI2_CS3_BIT)
00218
00219 #define SBBI2_CS3_CLR() cbi(SBBI2_CS3_SOD_REG, SBBI2_CS3_BIT)
00220
00221 #define SBBI2_CS3_SET() sbi(SBBI2_CS3_SOD_REG, SBBI2_CS3_BIT)
00222
00223 #endif
00224
00225 #ifdef SBBI2_RST0_BIT
00226
00227 #if (SBBI2_RST0_AVRPORT == AVRPORTB)
00228 #define SBBI2_RST0_SOD_REG PORTB
00229 #define SBBI2_RST0_OE_REG DDRB
00230 #elif (SBBI2_RST0_AVRPORT == AVRPORTD)
00231 #define SBBI2_RST0_SOD_REG PORTD
00232 #define SBBI2_RST0_OE_REG DDRD
00233 #elif (SBBI2_RST0_AVRPORT == AVRPORTE)
00234 #define SBBI2_RST0_SOD_REG PORTE
00235 #define SBBI2_RST0_OE_REG DDRE
00236 #elif (SBBI2_RST0_AVRPORT == AVRPORTF)
00237 #define SBBI2_RST0_SOD_REG PORTF
00238 #define SBBI2_RST0_OE_REG DDRF
00239 #elif (SBBI2_RST0_AVRPORT == AVRPORTG)
00240 #define SBBI2_RST0_SOD_REG PORTG
00241 #define SBBI2_RST0_OE_REG DDRG
00242 #elif (SBBI2_RST0_AVRPORT == AVRPORTH)
00243 #define SBBI2_RST0_SOD_REG PORTH
00244 #define SBBI2_RST0_OE_REG DDRH
00245 #endif
00246
00248 #define SBBI2_RST0_ENA() sbi(SBBI2_RST0_OE_REG, SBBI2_RST0_BIT)
00249
00250 #define SBBI2_RST0_CLR() cbi(SBBI2_RST0_SOD_REG, SBBI2_RST0_BIT)
00251
00252 #define SBBI2_RST0_SET() sbi(SBBI2_RST0_SOD_REG, SBBI2_RST0_BIT)
00253
00254 #endif
00255
00256 #ifdef SBBI2_RST1_BIT
00257
00258 #if (SBBI2_RST1_AVRPORT == AVRPORTB)
00259 #define SBBI2_RST1_SOD_REG PORTB
00260 #define SBBI2_RST1_OE_REG DDRB
00261 #elif (SBBI2_RST1_AVRPORT == AVRPORTD)
00262 #define SBBI2_RST1_SOD_REG PORTD
00263 #define SBBI2_RST1_OE_REG DDRD
00264 #elif (SBBI2_RST1_AVRPORT == AVRPORTE)
00265 #define SBBI2_RST1_SOD_REG PORTE
00266 #define SBBI2_RST1_OE_REG DDRE
00267 #elif (SBBI2_RST1_AVRPORT == AVRPORTF)
00268 #define SBBI2_RST1_SOD_REG PORTF
00269 #define SBBI2_RST1_OE_REG DDRF
00270 #elif (SBBI2_RST1_AVRPORT == AVRPORTG)
00271 #define SBBI2_RST1_SOD_REG PORTG
00272 #define SBBI2_RST1_OE_REG DDRG
00273 #elif (SBBI2_RST1_AVRPORT == AVRPORTH)
00274 #define SBBI2_RST1_SOD_REG PORTH
00275 #define SBBI2_RST1_OE_REG DDRH
00276 #endif
00277
00279 #define SBBI2_RST1_ENA() sbi(SBBI2_RST1_OE_REG, SBBI2_RST1_BIT)
00280
00281 #define SBBI2_RST1_CLR() cbi(SBBI2_RST1_SOD_REG, SBBI2_RST1_BIT)
00282
00283 #define SBBI2_RST1_SET() sbi(SBBI2_RST1_SOD_REG, SBBI2_RST1_BIT)
00284
00285 #endif
00286
00287 #ifdef SBBI2_RST2_BIT
00288
00289 #if (SBBI2_RST2_AVRPORT == AVRPORTB)
00290 #define SBBI2_RST2_SOD_REG PORTB
00291 #define SBBI2_RST2_OE_REG DDRB
00292 #elif (SBBI2_RST2_AVRPORT == AVRPORTD)
00293 #define SBBI2_RST2_SOD_REG PORTD
00294 #define SBBI2_RST2_OE_REG DDRD
00295 #elif (SBBI2_RST2_AVRPORT == AVRPORTE)
00296 #define SBBI2_RST2_SOD_REG PORTE
00297 #define SBBI2_RST2_OE_REG DDRE
00298 #elif (SBBI2_RST2_AVRPORT == AVRPORTF)
00299 #define SBBI2_RST2_SOD_REG PORTF
00300 #define SBBI2_RST2_OE_REG DDRF
00301 #elif (SBBI2_RST2_AVRPORT == AVRPORTG)
00302 #define SBBI2_RST2_SOD_REG PORTG
00303 #define SBBI2_RST2_OE_REG DDRG
00304 #elif (SBBI2_RST2_AVRPORT == AVRPORTH)
00305 #define SBBI2_RST2_SOD_REG PORTH
00306 #define SBBI2_RST2_OE_REG DDRH
00307 #endif
00308
00310 #define SBBI2_RST2_ENA() sbi(SBBI2_RST2_OE_REG, SBBI2_RST2_BIT)
00311
00312 #define SBBI2_RST2_CLR() cbi(SBBI2_RST2_SOD_REG, SBBI2_RST2_BIT)
00313
00314 #define SBBI2_RST2_SET() sbi(SBBI2_RST2_SOD_REG, SBBI2_RST2_BIT)
00315
00316 #endif
00317
00318 #ifdef SBBI2_RST3_BIT
00319
00320 #if (SBBI2_RST3_AVRPORT == AVRPORTB)
00321 #define SBBI2_RST3_SOD_REG PORTB
00322 #define SBBI2_RST3_OE_REG DDRB
00323 #elif (SBBI2_RST3_AVRPORT == AVRPORTD)
00324 #define SBBI2_RST3_SOD_REG PORTD
00325 #define SBBI2_RST3_OE_REG DDRD
00326 #elif (SBBI2_RST3_AVRPORT == AVRPORTE)
00327 #define SBBI2_RST3_SOD_REG PORTE
00328 #define SBBI2_RST3_OE_REG DDRE
00329 #elif (SBBI2_RST3_AVRPORT == AVRPORTF)
00330 #define SBBI2_RST3_SOD_REG PORTF
00331 #define SBBI2_RST3_OE_REG DDRF
00332 #elif (SBBI2_RST3_AVRPORT == AVRPORTG)
00333 #define SBBI2_RST3_SOD_REG PORTG
00334 #define SBBI2_RST3_OE_REG DDRG
00335 #elif (SBBI2_RST3_AVRPORT == AVRPORTH)
00336 #define SBBI2_RST3_SOD_REG PORTH
00337 #define SBBI2_RST3_OE_REG DDRH
00338 #endif
00339
00341 #define SBBI2_RST3_ENA() sbi(SBBI2_RST3_OE_REG, SBBI2_RST3_BIT)
00342
00343 #define SBBI2_RST3_CLR() cbi(SBBI2_RST3_SOD_REG, SBBI2_RST3_BIT)
00344
00345 #define SBBI2_RST3_SET() sbi(SBBI2_RST3_SOD_REG, SBBI2_RST3_BIT)
00346
00347 #endif
00348
00349 #ifdef SBBI2_SCK_BIT
00350
00351 #if (SBBI2_SCK_AVRPORT == AVRPORTB)
00352 #define SBBI2_SCK_SOD_REG PORTB
00353 #define SBBI2_SCK_OE_REG DDRB
00354 #elif (SBBI2_SCK_AVRPORT == AVRPORTD)
00355 #define SBBI2_SCK_SOD_REG PORTD
00356 #define SBBI2_SCK_OE_REG DDRD
00357 #elif (SBBI2_SCK_AVRPORT == AVRPORTE)
00358 #define SBBI2_SCK_SOD_REG PORTE
00359 #define SBBI2_SCK_OE_REG DDRE
00360 #elif (SBBI2_SCK_AVRPORT == AVRPORTF)
00361 #define SBBI2_SCK_SOD_REG PORTF
00362 #define SBBI2_SCK_OE_REG DDRF
00363 #elif (SBBI2_SCK_AVRPORT == AVRPORTG)
00364 #define SBBI2_SCK_SOD_REG PORTG
00365 #define SBBI2_SCK_OE_REG DDRG
00366 #elif (SBBI2_SCK_AVRPORT == AVRPORTH)
00367 #define SBBI2_SCK_SOD_REG PORTH
00368 #define SBBI2_SCK_OE_REG DDRH
00369 #endif
00370
00372 #define SBBI2_SCK_ENA() sbi(SBBI2_SCK_OE_REG, SBBI2_SCK_BIT)
00373
00374 #define SBBI2_SCK_CLR() cbi(SBBI2_SCK_SOD_REG, SBBI2_SCK_BIT)
00375
00376 #define SBBI2_SCK_SET() sbi(SBBI2_SCK_SOD_REG, SBBI2_SCK_BIT)
00377
00378 #if defined(SBBI2_MOSI_BIT)
00379
00380 #if (SBBI2_MOSI_AVRPORT == AVRPORTB)
00381 #define SBBI2_MOSI_SOD_REG PORTB
00382 #define SBBI2_MOSI_OE_REG DDRB
00383 #elif (SBBI2_MOSI_AVRPORT == AVRPORTD)
00384 #define SBBI2_MOSI_SOD_REG PORTD
00385 #define SBBI2_MOSI_OE_REG DDRD
00386 #elif (SBBI2_MOSI_AVRPORT == AVRPORTE)
00387 #define SBBI2_MOSI_SOD_REG PORTE
00388 #define SBBI2_MOSI_OE_REG DDRE
00389 #elif (SBBI2_MOSI_AVRPORT == AVRPORTF)
00390 #define SBBI2_MOSI_SOD_REG PORTF
00391 #define SBBI2_MOSI_OE_REG DDRF
00392 #elif (SBBI2_MOSI_AVRPORT == AVRPORTG)
00393 #define SBBI2_MOSI_SOD_REG PORTG
00394 #define SBBI2_MOSI_OE_REG DDRG
00395 #elif (SBBI2_MOSI_AVRPORT == AVRPORTH)
00396 #define SBBI2_MOSI_SOD_REG PORTH
00397 #define SBBI2_MOSI_OE_REG DDRH
00398 #endif
00399
00401 #define SBBI2_MOSI_ENA() sbi(SBBI2_MOSI_OE_REG, SBBI2_MOSI_BIT)
00402
00403 #define SBBI2_MOSI_CLR() cbi(SBBI2_MOSI_SOD_REG, SBBI2_MOSI_BIT)
00404
00405 #define SBBI2_MOSI_SET() sbi(SBBI2_MOSI_SOD_REG, SBBI2_MOSI_BIT)
00406
00407 #else
00408
00409 #define SBBI2_MOSI_ENA()
00410 #define SBBI2_MOSI_CLR()
00411 #define SBBI2_MOSI_SET()
00412
00413 #endif
00414
00415 #if defined(SBBI2_MISO_BIT)
00416
00417 #if (SBBI2_MISO_AVRPORT == AVRPORTB)
00418 #define SBBI2_MISO_PDS_REG PINB
00419 #define SBBI2_MISO_PUE_REG PORTB
00420 #define SBBI2_MISO_OE_REG DDRB
00421 #elif (SBBI2_MISO_AVRPORT == AVRPORTD)
00422 #define SBBI2_MISO_PDS_REG PIND
00423 #define SBBI2_MISO_PUE_REG PORTD
00424 #define SBBI2_MISO_OE_REG DDRD
00425 #elif (SBBI2_MISO_AVRPORT == AVRPORTE)
00426 #define SBBI2_MISO_PDS_REG PINE
00427 #define SBBI2_MISO_PUE_REG PORTE
00428 #define SBBI2_MISO_OE_REG DDRE
00429 #elif (SBBI2_MISO_AVRPORT == AVRPORTF)
00430 #define SBBI2_MISO_PDS_REG PINF
00431 #define SBBI2_MISO_PUE_REG PORTF
00432 #define SBBI2_MISO_OE_REG DDRF
00433 #elif (SBBI2_MISO_AVRPORT == AVRPORTG)
00434 #define SBBI2_MISO_PDS_REG PING
00435 #define SBBI2_MISO_PUE_REG PORTG
00436 #define SBBI2_MISO_OE_REG DDRG
00437 #elif (SBBI2_MISO_AVRPORT == AVRPORTH)
00438 #define SBBI2_MISO_PDS_REG PINH
00439 #define SBBI2_MISO_PUE_REG PORTH
00440 #define SBBI2_MISO_OE_REG DDRH
00441 #endif
00442
00444 #define SBBI2_MISO_ENA() \
00445 cbi(SBBI2_MISO_OE_REG, SBBI2_MISO_BIT); \
00446 sbi(SBBI2_MISO_PUE_REG, SBBI2_MISO_BIT)
00447
00448 #define SBBI2_MISO_TST() ((inb(SBBI2_MISO_PDS_REG) & _BV(SBBI2_MISO_BIT)) == _BV(SBBI2_MISO_BIT))
00449
00450 #else
00451
00452 #define SBBI2_MISO_ENA()
00453 #define SBBI2_MISO_TST() 0
00454
00455 #endif
00456
00457 #endif
00458
00459 #else
00460
00461
00462
00463
00464
00465 #ifdef SBBI2_CS0_BIT
00466
00467 #if !defined(SBBI2_CS0_PIO_ID)
00468 #define SBBI2_CS0_PE_REG PIO_PER
00469 #define SBBI2_CS0_OE_REG PIO_OER
00470 #define SBBI2_CS0_COD_REG PIO_CODR
00471 #define SBBI2_CS0_SOD_REG PIO_SODR
00472 #elif SBBI2_CS0_PIO_ID == PIOA_ID
00473 #define SBBI2_CS0_PE_REG PIOA_PER
00474 #define SBBI2_CS0_OE_REG PIOA_OER
00475 #define SBBI2_CS0_COD_REG PIOA_CODR
00476 #define SBBI2_CS0_SOD_REG PIOA_SODR
00477 #elif SBBI2_CS0_PIO_ID == PIOB_ID
00478 #define SBBI2_CS0_PE_REG PIOB_PER
00479 #define SBBI2_CS0_OE_REG PIOB_OER
00480 #define SBBI2_CS0_COD_REG PIOB_CODR
00481 #define SBBI2_CS0_SOD_REG PIOB_SODR
00482 #elif SBBI2_CS0_PIO_ID == PIOC_ID
00483 #define SBBI2_CS0_PE_REG PIOC_PER
00484 #define SBBI2_CS0_OE_REG PIOC_OER
00485 #define SBBI2_CS0_COD_REG PIOC_CODR
00486 #define SBBI2_CS0_SOD_REG PIOC_SODR
00487 #endif
00488
00490 #define SBBI2_CS0_ENA() \
00491 outr(SBBI2_CS0_PE_REG, _BV(SBBI2_CS0_BIT)); \
00492 outr(SBBI2_CS0_OE_REG, _BV(SBBI2_CS0_BIT))
00493
00494 #define SBBI2_CS0_CLR() outr(SBBI2_CS0_COD_REG, _BV(SBBI2_CS0_BIT))
00495
00496 #define SBBI2_CS0_SET() outr(SBBI2_CS0_SOD_REG, _BV(SBBI2_CS0_BIT))
00497
00498 #endif
00499
00500 #ifdef SBBI2_CS1_BIT
00501
00502 #if !defined(SBBI2_CS1_PIO_ID)
00503 #define SBBI2_CS1_PE_REG PIO_PER
00504 #define SBBI2_CS1_OE_REG PIO_OER
00505 #define SBBI2_CS1_COD_REG PIO_CODR
00506 #define SBBI2_CS1_SOD_REG PIO_SODR
00507 #elif SBBI2_CS1_PIO_ID == PIOA_ID
00508 #define SBBI2_CS1_PE_REG PIOA_PER
00509 #define SBBI2_CS1_OE_REG PIOA_OER
00510 #define SBBI2_CS1_COD_REG PIOA_CODR
00511 #define SBBI2_CS1_SOD_REG PIOA_SODR
00512 #elif SBBI2_CS1_PIO_ID == PIOB_ID
00513 #define SBBI2_CS1_PE_REG PIOB_PER
00514 #define SBBI2_CS1_OE_REG PIOB_OER
00515 #define SBBI2_CS1_COD_REG PIOB_CODR
00516 #define SBBI2_CS1_SOD_REG PIOB_SODR
00517 #elif SBBI2_CS1_PIO_ID == PIOC_ID
00518 #define SBBI2_CS1_PE_REG PIOC_PER
00519 #define SBBI2_CS1_OE_REG PIOC_OER
00520 #define SBBI2_CS1_COD_REG PIOC_CODR
00521 #define SBBI2_CS1_SOD_REG PIOC_SODR
00522 #endif
00523
00525 #define SBBI2_CS1_ENA() \
00526 outr(SBBI2_CS1_PE_REG, _BV(SBBI2_CS1_BIT)); \
00527 outr(SBBI2_CS1_OE_REG, _BV(SBBI2_CS1_BIT))
00528
00529 #define SBBI2_CS1_CLR() outr(SBBI2_CS1_COD_REG, _BV(SBBI2_CS1_BIT))
00530
00531 #define SBBI2_CS1_SET() outr(SBBI2_CS1_SOD_REG, _BV(SBBI2_CS1_BIT))
00532
00533 #endif
00534
00535 #ifdef SBBI2_CS2_BIT
00536
00537 #if !defined(SBBI2_CS2_PIO_ID)
00538 #define SBBI2_CS2_PE_REG PIO_PER
00539 #define SBBI2_CS2_OE_REG PIO_OER
00540 #define SBBI2_CS2_COD_REG PIO_CODR
00541 #define SBBI2_CS2_SOD_REG PIO_SODR
00542 #elif SBBI2_CS2_PIO_ID == PIOA_ID
00543 #define SBBI2_CS2_PE_REG PIOA_PER
00544 #define SBBI2_CS2_OE_REG PIOA_OER
00545 #define SBBI2_CS2_COD_REG PIOA_CODR
00546 #define SBBI2_CS2_SOD_REG PIOA_SODR
00547 #elif SBBI2_CS2_PIO_ID == PIOB_ID
00548 #define SBBI2_CS2_PE_REG PIOB_PER
00549 #define SBBI2_CS2_OE_REG PIOB_OER
00550 #define SBBI2_CS2_COD_REG PIOB_CODR
00551 #define SBBI2_CS2_SOD_REG PIOB_SODR
00552 #elif SBBI2_CS2_PIO_ID == PIOC_ID
00553 #define SBBI2_CS2_PE_REG PIOC_PER
00554 #define SBBI2_CS2_OE_REG PIOC_OER
00555 #define SBBI2_CS2_COD_REG PIOC_CODR
00556 #define SBBI2_CS2_SOD_REG PIOC_SODR
00557 #endif
00558
00560 #define SBBI2_CS2_ENA() \
00561 outr(SBBI2_CS2_PE_REG, _BV(SBBI2_CS2_BIT)); \
00562 outr(SBBI2_CS2_OE_REG, _BV(SBBI2_CS2_BIT))
00563
00564 #define SBBI2_CS2_CLR() outr(SBBI2_CS2_COD_REG, _BV(SBBI2_CS2_BIT))
00565
00566 #define SBBI2_CS2_SET() outr(SBBI2_CS2_SOD_REG, _BV(SBBI2_CS2_BIT))
00567
00568 #endif
00569
00570 #ifdef SBBI2_CS3_BIT
00571
00572 #if !defined(SBBI2_CS3_PIO_ID)
00573 #define SBBI2_CS3_PE_REG PIO_PER
00574 #define SBBI2_CS3_OE_REG PIO_OER
00575 #define SBBI2_CS3_COD_REG PIO_CODR
00576 #define SBBI2_CS3_SOD_REG PIO_SODR
00577 #elif SBBI2_CS3_PIO_ID == PIOA_ID
00578 #define SBBI2_CS3_PE_REG PIOA_PER
00579 #define SBBI2_CS3_OE_REG PIOA_OER
00580 #define SBBI2_CS3_COD_REG PIOA_CODR
00581 #define SBBI2_CS3_SOD_REG PIOA_SODR
00582 #elif SBBI2_CS3_PIO_ID == PIOB_ID
00583 #define SBBI2_CS3_PE_REG PIOB_PER
00584 #define SBBI2_CS3_OE_REG PIOB_OER
00585 #define SBBI2_CS3_COD_REG PIOB_CODR
00586 #define SBBI2_CS3_SOD_REG PIOB_SODR
00587 #elif SBBI2_CS3_PIO_ID == PIOC_ID
00588 #define SBBI2_CS3_PE_REG PIOC_PER
00589 #define SBBI2_CS3_OE_REG PIOC_OER
00590 #define SBBI2_CS3_COD_REG PIOC_CODR
00591 #define SBBI2_CS3_SOD_REG PIOC_SODR
00592 #endif
00593
00595 #define SBBI2_CS3_ENA() \
00596 outr(SBBI2_CS3_PE_REG, _BV(SBBI2_CS3_BIT)); \
00597 outr(SBBI2_CS3_OE_REG, _BV(SBBI2_CS3_BIT))
00598
00599 #define SBBI2_CS3_CLR() outr(SBBI2_CS3_COD_REG, _BV(SBBI2_CS3_BIT))
00600
00601 #define SBBI2_CS3_SET() outr(SBBI2_CS3_SOD_REG, _BV(SBBI2_CS3_BIT))
00602
00603 #endif
00604
00605 #ifdef SBBI2_RST0_BIT
00606
00607 #if !defined(SBBI2_RST0_PIO_ID)
00608 #define SBBI2_RST0_PE_REG PIO_PER
00609 #define SBBI2_RST0_OE_REG PIO_OER
00610 #define SBBI2_RST0_COD_REG PIO_CODR
00611 #define SBBI2_RST0_SOD_REG PIO_SODR
00612 #elif SBBI2_RST0_PIO_ID == PIOA_ID
00613 #define SBBI2_RST0_PE_REG PIOA_PER
00614 #define SBBI2_RST0_OE_REG PIOA_OER
00615 #define SBBI2_RST0_COD_REG PIOA_CODR
00616 #define SBBI2_RST0_SOD_REG PIOA_SODR
00617 #elif SBBI2_RST0_PIO_ID == PIOB_ID
00618 #define SBBI2_RST0_PE_REG PIOB_PER
00619 #define SBBI2_RST0_OE_REG PIOB_OER
00620 #define SBBI2_RST0_COD_REG PIOB_CODR
00621 #define SBBI2_RST0_SOD_REG PIOB_SODR
00622 #elif SBBI2_RST0_PIO_ID == PIOC_ID
00623 #define SBBI2_RST0_PE_REG PIOC_PER
00624 #define SBBI2_RST0_OE_REG PIOC_OER
00625 #define SBBI2_RST0_COD_REG PIOC_CODR
00626 #define SBBI2_RST0_SOD_REG PIOC_SODR
00627 #endif
00628
00630 #define SBBI2_RST0_ENA() \
00631 outr(SBBI2_RST0_PE_REG, _BV(SBBI2_RST0_BIT)); \
00632 outr(SBBI2_RST0_OE_REG, _BV(SBBI2_RST0_BIT))
00633
00634 #define SBBI2_RST0_CLR() outr(SBBI2_RST0_COD_REG, _BV(SBBI2_RST0_BIT))
00635
00636 #define SBBI2_RST0_SET() outr(SBBI2_RST0_SOD_REG, _BV(SBBI2_RST0_BIT))
00637
00638 #endif
00639
00640 #ifdef SBBI2_RST1_BIT
00641
00642 #if !defined(SBBI2_RST1_PIO_ID)
00643 #define SBBI2_RST1_PE_REG PIO_PER
00644 #define SBBI2_RST1_OE_REG PIO_OER
00645 #define SBBI2_RST1_COD_REG PIO_CODR
00646 #define SBBI2_RST1_SOD_REG PIO_SODR
00647 #elif SBBI2_RST1_PIO_ID == PIOA_ID
00648 #define SBBI2_RST1_PE_REG PIOA_PER
00649 #define SBBI2_RST1_OE_REG PIOA_OER
00650 #define SBBI2_RST1_COD_REG PIOA_CODR
00651 #define SBBI2_RST1_SOD_REG PIOA_SODR
00652 #elif SBBI2_RST1_PIO_ID == PIOB_ID
00653 #define SBBI2_RST1_PE_REG PIOB_PER
00654 #define SBBI2_RST1_OE_REG PIOB_OER
00655 #define SBBI2_RST1_COD_REG PIOB_CODR
00656 #define SBBI2_RST1_SOD_REG PIOB_SODR
00657 #elif SBBI2_RST1_PIO_ID == PIOC_ID
00658 #define SBBI2_RST1_PE_REG PIOC_PER
00659 #define SBBI2_RST1_OE_REG PIOC_OER
00660 #define SBBI2_RST1_COD_REG PIOC_CODR
00661 #define SBBI2_RST1_SOD_REG PIOC_SODR
00662 #endif
00663
00665 #define SBBI2_RST1_ENA() \
00666 outr(SBBI2_RST1_PE_REG, _BV(SBBI2_RST1_BIT)); \
00667 outr(SBBI2_RST1_OE_REG, _BV(SBBI2_RST1_BIT))
00668
00669 #define SBBI2_RST1_CLR() outr(SBBI2_RST1_COD_REG, _BV(SBBI2_RST1_BIT))
00670
00671 #define SBBI2_RST1_SET() outr(SBBI2_RST1_SOD_REG, _BV(SBBI2_RST1_BIT))
00672
00673 #endif
00674
00675 #ifdef SBBI2_RST2_BIT
00676
00677 #if !defined(SBBI2_RST2_PIO_ID)
00678 #define SBBI2_RST2_PE_REG PIO_PER
00679 #define SBBI2_RST2_OE_REG PIO_OER
00680 #define SBBI2_RST2_COD_REG PIO_CODR
00681 #define SBBI2_RST2_SOD_REG PIO_SODR
00682 #elif SBBI2_RST2_PIO_ID == PIOA_ID
00683 #define SBBI2_RST2_PE_REG PIOA_PER
00684 #define SBBI2_RST2_OE_REG PIOA_OER
00685 #define SBBI2_RST2_COD_REG PIOA_CODR
00686 #define SBBI2_RST2_SOD_REG PIOA_SODR
00687 #elif SBBI2_RST2_PIO_ID == PIOB_ID
00688 #define SBBI2_RST2_PE_REG PIOB_PER
00689 #define SBBI2_RST2_OE_REG PIOB_OER
00690 #define SBBI2_RST2_COD_REG PIOB_CODR
00691 #define SBBI2_RST2_SOD_REG PIOB_SODR
00692 #elif SBBI2_RST2_PIO_ID == PIOC_ID
00693 #define SBBI2_RST2_PE_REG PIOC_PER
00694 #define SBBI2_RST2_OE_REG PIOC_OER
00695 #define SBBI2_RST2_COD_REG PIOC_CODR
00696 #define SBBI2_RST2_SOD_REG PIOC_SODR
00697 #endif
00698
00700 #define SBBI2_RST2_ENA() \
00701 outr(SBBI2_RST2_PE_REG, _BV(SBBI2_RST2_BIT)); \
00702 outr(SBBI2_RST2_OE_REG, _BV(SBBI2_RST2_BIT))
00703
00704 #define SBBI2_RST2_CLR() outr(SBBI2_RST2_COD_REG, _BV(SBBI2_RST2_BIT))
00705
00706 #define SBBI2_RST2_SET() outr(SBBI2_RST2_SOD_REG, _BV(SBBI2_RST2_BIT))
00707
00708 #endif
00709
00710 #ifdef SBBI2_RST3_BIT
00711
00712 #if !defined(SBBI2_RST3_PIO_ID)
00713 #define SBBI2_RST3_PE_REG PIO_PER
00714 #define SBBI2_RST3_OE_REG PIO_OER
00715 #define SBBI2_RST3_COD_REG PIO_CODR
00716 #define SBBI2_RST3_SOD_REG PIO_SODR
00717 #elif SBBI2_RST3_PIO_ID == PIOA_ID
00718 #define SBBI2_RST3_PE_REG PIOA_PER
00719 #define SBBI2_RST3_OE_REG PIOA_OER
00720 #define SBBI2_RST3_COD_REG PIOA_CODR
00721 #define SBBI2_RST3_SOD_REG PIOA_SODR
00722 #elif SBBI2_RST3_PIO_ID == PIOB_ID
00723 #define SBBI2_RST3_PE_REG PIOB_PER
00724 #define SBBI2_RST3_OE_REG PIOB_OER
00725 #define SBBI2_RST3_COD_REG PIOB_CODR
00726 #define SBBI2_RST3_SOD_REG PIOB_SODR
00727 #elif SBBI2_RST3_PIO_ID == PIOC_ID
00728 #define SBBI2_RST3_PE_REG PIOC_PER
00729 #define SBBI2_RST3_OE_REG PIOC_OER
00730 #define SBBI2_RST3_COD_REG PIOC_CODR
00731 #define SBBI2_RST3_SOD_REG PIOC_SODR
00732 #endif
00733
00735 #define SBBI2_RST3_ENA() \
00736 outr(SBBI2_RST3_PE_REG, _BV(SBBI2_RST3_BIT)); \
00737 outr(SBBI2_RST3_OE_REG, _BV(SBBI2_RST3_BIT))
00738
00739 #define SBBI2_RST3_CLR() outr(SBBI2_RST3_COD_REG, _BV(SBBI2_RST3_BIT))
00740
00741 #define SBBI2_RST3_SET() outr(SBBI2_RST3_SOD_REG, _BV(SBBI2_RST3_BIT))
00742
00743 #endif
00744
00745 #ifdef SBBI2_SCK_BIT
00746
00747 #if !defined(SBBI2_SCK_PIO_ID)
00748 #define SBBI2_SCK_PE_REG PIO_PER
00749 #define SBBI2_SCK_OE_REG PIO_OER
00750 #define SBBI2_SCK_COD_REG PIO_CODR
00751 #define SBBI2_SCK_SOD_REG PIO_SODR
00752 #elif SBBI2_SCK_PIO_ID == PIOA_ID
00753 #define SBBI2_SCK_PE_REG PIOA_PER
00754 #define SBBI2_SCK_OE_REG PIOA_OER
00755 #define SBBI2_SCK_COD_REG PIOA_CODR
00756 #define SBBI2_SCK_SOD_REG PIOA_SODR
00757 #elif SBBI2_SCK_PIO_ID == PIOB_ID
00758 #define SBBI2_SCK_PE_REG PIOB_PER
00759 #define SBBI2_SCK_OE_REG PIOB_OER
00760 #define SBBI2_SCK_COD_REG PIOB_CODR
00761 #define SBBI2_SCK_SOD_REG PIOB_SODR
00762 #elif SBBI2_SCK_PIO_ID == PIOC_ID
00763 #define SBBI2_SCK_PE_REG PIOC_PER
00764 #define SBBI2_SCK_OE_REG PIOC_OER
00765 #define SBBI2_SCK_COD_REG PIOC_CODR
00766 #define SBBI2_SCK_SOD_REG PIOC_SODR
00767 #endif
00768
00770 #define SBBI2_SCK_ENA() \
00771 outr(SBBI2_SCK_PE_REG, _BV(SBBI2_SCK_BIT)); \
00772 outr(SBBI2_SCK_OE_REG, _BV(SBBI2_SCK_BIT))
00773
00774 #define SBBI2_SCK_CLR() outr(SBBI2_SCK_COD_REG, _BV(SBBI2_SCK_BIT))
00775
00776 #define SBBI2_SCK_SET() outr(SBBI2_SCK_SOD_REG, _BV(SBBI2_SCK_BIT))
00777
00778 #ifdef SBBI2_MOSI_BIT
00779
00780 #if !defined(SBBI2_MOSI_PIO_ID)
00781 #define SBBI2_MOSI_PE_REG PIO_PER
00782 #define SBBI2_MOSI_OE_REG PIO_OER
00783 #define SBBI2_MOSI_COD_REG PIO_CODR
00784 #define SBBI2_MOSI_SOD_REG PIO_SODR
00785 #elif SBBI2_MOSI_PIO_ID == PIOA_ID
00786 #define SBBI2_MOSI_PE_REG PIOA_PER
00787 #define SBBI2_MOSI_OE_REG PIOA_OER
00788 #define SBBI2_MOSI_COD_REG PIOA_CODR
00789 #define SBBI2_MOSI_SOD_REG PIOA_SODR
00790 #elif SBBI2_MOSI_PIO_ID == PIOB_ID
00791 #define SBBI2_MOSI_PE_REG PIOB_PER
00792 #define SBBI2_MOSI_OE_REG PIOB_OER
00793 #define SBBI2_MOSI_COD_REG PIOB_CODR
00794 #define SBBI2_MOSI_SOD_REG PIOB_SODR
00795 #elif SBBI2_MOSI_PIO_ID == PIOC_ID
00796 #define SBBI2_MOSI_PE_REG PIOC_PER
00797 #define SBBI2_MOSI_OE_REG PIOC_OER
00798 #define SBBI2_MOSI_COD_REG PIOC_CODR
00799 #define SBBI2_MOSI_SOD_REG PIOC_SODR
00800 #endif
00801
00803 #define SBBI2_MOSI_ENA() \
00804 outr(SBBI2_MOSI_PE_REG, _BV(SBBI2_MOSI_BIT)); \
00805 outr(SBBI2_MOSI_OE_REG, _BV(SBBI2_MOSI_BIT))
00806
00807 #define SBBI2_MOSI_CLR() outr(SBBI2_MOSI_COD_REG, _BV(SBBI2_MOSI_BIT))
00808
00809 #define SBBI2_MOSI_SET() outr(SBBI2_MOSI_SOD_REG, _BV(SBBI2_MOSI_BIT))
00810
00811 #else
00812
00813 #define SBBI2_MOSI_ENA()
00814 #define SBBI2_MOSI_CLR()
00815 #define SBBI2_MOSI_SET()
00816
00817 #endif
00818
00819 #ifdef SBBI2_MISO_BIT
00820
00821 #if !defined(SBBI2_MISO_PIO_ID)
00822 #define SBBI2_MISO_PE_REG PIO_PER
00823 #define SBBI2_MISO_OD_REG PIO_ODR
00824 #define SBBI2_MISO_PDS_REG PIO_PDSR
00825 #elif SBBI2_MISO_PIO_ID == PIOA_ID
00826 #define SBBI2_MISO_PE_REG PIOA_PER
00827 #define SBBI2_MISO_OD_REG PIOA_ODR
00828 #define SBBI2_MISO_PDS_REG PIOA_PDSR
00829 #elif SBBI2_MISO_PIO_ID == PIOB_ID
00830 #define SBBI2_MISO_PE_REG PIOB_PER
00831 #define SBBI2_MISO_OD_REG PIOB_ODR
00832 #define SBBI2_MISO_PDS_REG PIOB_PDSR
00833 #elif SBBI2_MISO_PIO_ID == PIOC_ID
00834 #define SBBI2_MISO_PE_REG PIOC_PER
00835 #define SBBI2_MISO_OD_REG PIOC_ODR
00836 #define SBBI2_MISO_PDS_REG PIOC_PDSR
00837 #endif
00838
00840 #define SBBI2_MISO_ENA() \
00841 outr(SBBI2_MISO_PE_REG, _BV(SBBI2_MISO_BIT)); \
00842 outr(SBBI2_MISO_OD_REG, _BV(SBBI2_MISO_BIT))
00843
00844 #define SBBI2_MISO_TST() ((inr(SBBI2_MISO_PDS_REG) & _BV(SBBI2_MISO_BIT)) == _BV(SBBI2_MISO_BIT))
00845
00846 #else
00847
00848 #define SBBI2_MISO_ENA()
00849 #define SBBI2_MISO_TST() 0
00850
00851 #endif
00852
00853 #endif
00854
00855 #endif
00856
00857 #define SBBI2_INIT() \
00858 { \
00859 SBBI2_SCK_CLR(); \
00860 SBBI2_SCK_ENA(); \
00861 SBBI2_MOSI_CLR(); \
00862 SBBI2_MOSI_ENA(); \
00863 SBBI2_MISO_ENA(); \
00864 }
00865
00866 #endif