bsp_dk_3200.c

Go to the documentation of this file.
00001 /***************************************************************************/
00018 #include "em_device.h"
00019 #include "em_cmu.h"
00020 #include "em_ebi.h"
00021 #include "em_gpio.h"
00022 #include "em_system.h"
00023 #include "em_usart.h"
00024 #include "bsp_dk_bcreg_3200.h"
00025 #include "bsp.h"
00026 
00027 #if defined( BSP_DK_3200 )
00028 
00030 /* USART used for SPI access */
00031 #define BSP_SPI_USART_USED  USART2          
00032 #define BSP_SPI_USART_CLK   cmuClock_USART2 
00034 /* GPIO pins used fotr SPI pins, please refer to DK user guide. */
00035 #define BSP_PORT_SPIBUS_CONNECT   gpioPortC   
00036 #define BSP_PIN_SPIBUS_CONNECT    13          
00037 #define BSP_PORT_EBIBUS_CONNECT   gpioPortC   
00038 #define BSP_PIN_EBIBUS_CONNECT    12          
00039 #define BSP_PORT_SPI_TX           gpioPortC   
00040 #define BSP_PIN_SPI_TX            2           
00041 #define BSP_PORT_SPI_RX           gpioPortC   
00042 #define BSP_PIN_SPI_RX            3           
00043 #define BSP_PORT_SPI_CLK          gpioPortC   
00044 #define BSP_PIN_SPI_CLK           4           
00045 #define BSP_PORT_SPI_CS           gpioPortC   
00046 #define BSP_PIN_SPI_CS            5           
00048 static uint16_t SpiBcAccess(uint8_t addr, uint8_t rw, uint16_t data);
00049 static void SpiBcInit(void);
00050 static void SpiBcDisable(void);
00051 static bool SpiInit(void);
00052 static uint16_t SpiRegisterRead(volatile uint16_t *addr);
00053 static void SpiRegisterWrite(volatile uint16_t *addr, uint16_t data);
00054 static volatile const uint16_t *lastAddr = 0; 
00056 #if defined( BSP_BC_CTRL_EBI )
00057 static void EbiConfigure(void);
00058 static bool EbiInit(void);
00059 static void EbiDisable(void);
00060 #endif
00061 
00062 static BSP_BusControl_TypeDef busMode = BSP_BusControl_Undefined;
00063 
00064 int BSP_BusControlModeSet(BSP_BusControl_TypeDef mode)
00065 {
00066   (void)mode;                 /* Unused parameter. */
00067   return BSP_STATUS_NOT_IMPLEMENTED;
00068 }
00069 
00070 BSP_BusControl_TypeDef BSP_BusControlModeGet( void )
00071 {
00072   return busMode;
00073 }
00074 
00075 uint32_t BSP_DipSwitchGet(void)
00076 {
00077   return (~BSP_RegisterRead(BC_DIPSWITCH)) & 0x00ff;
00078 }
00079 
00080 int BSP_Disable(void)
00081 {
00082 #if defined( BSP_BC_CTRL_EBI )
00083   /* Handover bus control */
00084   BSP_RegisterWrite(BC_BUS_CFG, 0);
00085   /* Disable EBI interface */
00086   EbiDisable();
00087 #else
00088 
00089   SpiBcDisable();
00090 #endif
00091 
00092   busMode = BSP_BusControl_Undefined;
00093 
00094   return BSP_STATUS_OK;
00095 }
00096 
00097 int BSP_DisplayControl(BSP_Display_TypeDef option)
00098 {
00099   (void)option;               /* Unused parameter. */
00100   return BSP_STATUS_NOT_IMPLEMENTED;
00101 }
00102 
00103 int BSP_EbiExtendedAddressRange(bool enable)
00104 {
00105   (void)enable;               /* Unused parameter. */
00106   return BSP_STATUS_NOT_IMPLEMENTED;
00107 }
00108 
00109 int BSP_EnergyModeSet(uint16_t energyMode)
00110 {
00111   BSP_RegisterWrite(BC_EM, energyMode);
00112   return BSP_STATUS_OK;
00113 }
00114 
00115 int BSP_Init(uint32_t flags)
00116 {
00117   bool ret = false;
00118   (void)flags;                /* Unused parameter. */
00119 
00120 #if defined( BSP_BC_CTRL_EBI )
00121   ret = EbiInit();
00122   busMode = BSP_BusControl_EBI;
00123 #else
00124   ret = SpiInit();
00125   busMode = BSP_BusControl_SPI;
00126 #endif
00127 
00128   if (ret == false)
00129   {
00130     /* Board is configured in wrong mode, please restart KIT! */
00131     while (1) ;
00132   }
00133 
00134   /* Set Energy Mode 0. */
00135   BSP_RegisterWrite(BC_EM, 0);
00136 
00137   return BSP_STATUS_OK;
00138 }
00139 
00140 int BSP_InterruptDisable(uint16_t flags)
00141 {
00142   uint16_t tmp;
00143 
00144   /* Clear flags from interrupt enable register */
00145   tmp   = BSP_RegisterRead(BC_INTEN);
00146   flags = ~(flags);
00147   tmp  &= flags;
00148   BSP_RegisterWrite(BC_INTEN, tmp);
00149   return BSP_STATUS_OK;
00150 }
00151 
00152 int BSP_InterruptEnable(uint16_t flags)
00153 {
00154   uint16_t tmp;
00155 
00156   /* Add flags to interrupt enable register */
00157   tmp  = BSP_RegisterRead(BC_INTEN);
00158   tmp |= flags;
00159   BSP_RegisterWrite(BC_INTEN, tmp);
00160   return BSP_STATUS_OK;
00161 }
00162 
00163 int BSP_InterruptFlagsClear(uint16_t flags)
00164 {
00165   BSP_RegisterWrite(BC_INTFLAG, flags);
00166   return BSP_STATUS_OK;
00167 }
00168 
00169 uint16_t BSP_InterruptFlagsGet(void)
00170 {
00171   return BSP_RegisterRead(BC_INTFLAG);
00172 }
00173 
00174 uint16_t BSP_JoystickGet(void)
00175 {
00176   uint16_t joyStick = 0;
00177   uint16_t aemState;
00178 
00179   /* Check state */
00180   aemState = BSP_RegisterRead(BC_AEMSTATE);
00181   /* Read pushbutton status */
00182   if (aemState == BC_AEMSTATE_EFM)
00183   {
00184     joyStick = (~(BSP_RegisterRead(BC_JOYSTICK))) & 0x001f;
00185   }
00186   return joyStick;
00187 }
00188 
00189 int BSP_PeripheralAccess(BSP_Peripheral_TypeDef perf, bool enable)
00190 {
00191   uint16_t bit;
00192   uint16_t tmp;
00193 
00194   /* Calculate which bit to set */
00195   bit = (uint16_t)perf;
00196 
00197   /* Read peripheral control register */
00198   tmp = BSP_RegisterRead(BC_PERCTRL);
00199 
00200   /* Enable or disable the specificed peripheral by setting board control switch */
00201   if (enable)
00202   {
00203     /* Enable peripheral */
00204     tmp |= bit;
00205 
00206     /* Special case for RS232, if enabled disable shutdown */
00207     if ((perf == BSP_RS232A) || (perf == BSP_RS232B))
00208     {
00209       /* clear shutdown bit */
00210       tmp &= ~(BC_PERCTRL_RS232_SHUTDOWN);
00211     }
00212 
00213     /* Special case for IRDA if enabled disable shutdown */
00214     if (perf == BSP_IRDA)
00215     {
00216       /* clear shutdown bit */
00217       tmp &= ~(BC_PERCTRL_IRDA_SHUTDOWN);
00218     }
00219   }
00220   else
00221   {
00222     /* Disable peripheral */
00223     tmp &= ~(bit);
00224 
00225     /* Special case for RS232, if enabled disable shutdown */
00226     if ((perf == BSP_RS232A) || (perf == BSP_RS232B))
00227     {
00228       /* Set shutdown bit */
00229       tmp |= (BC_PERCTRL_RS232_SHUTDOWN);
00230     }
00231 
00232     /* Special case for IRDA */
00233     if (perf == BSP_IRDA)
00234     {
00235       /* Set shutdown bit */
00236       tmp |= (BC_PERCTRL_IRDA_SHUTDOWN);
00237     }
00238   }
00239 
00240   BSP_RegisterWrite(BC_PERCTRL, tmp);
00241 
00242   return BSP_STATUS_OK;
00243 }
00244 
00245 uint16_t BSP_PushButtonsGet(void)
00246 {
00247   uint16_t pb = 0;
00248   uint16_t aemState;
00249 
00250   /* Check state */
00251   aemState = BSP_RegisterRead(BC_AEMSTATE);
00252   /* Read pushbutton status */
00253   if (aemState == BC_AEMSTATE_EFM)
00254   {
00255     pb = (~(BSP_RegisterRead(BC_PUSHBUTTON))) & 0x000f;
00256   }
00257   return pb;
00258 }
00259 
00260 uint16_t BSP_RegisterRead(volatile uint16_t *addr)
00261 {
00262 #if defined( BSP_BC_CTRL_EBI )
00263   return *addr;
00264 #else
00265   return SpiRegisterRead(addr);
00266 #endif
00267 }
00268 
00269 int BSP_RegisterWrite(volatile uint16_t *addr, uint16_t data)
00270 {
00271 #if defined( BSP_BC_CTRL_EBI )
00272   *addr = data;
00273 #else
00274   SpiRegisterWrite(addr, data);
00275 #endif
00276 
00277   return BSP_STATUS_OK;
00278 }
00279 
00280 #if defined( BSP_BC_CTRL_EBI )
00281 static void EbiConfigure(void)
00282 {
00283   EBI_Init_TypeDef ebiConfig = EBI_INIT_DEFAULT;
00284 
00285   /* Run time check if we have EBI on-chip capability on this device */
00286   switch ( SYSTEM_GetPartNumber() )
00287   {
00288     /* Only device types EFM32G 280/290/880 and 890 have EBI capability */
00289     case 280:
00290     case 290:
00291     case 880:
00292     case 890:
00293       break;
00294     default:
00295       /* This device do not have EBI capability - use SPI to interface DK */
00296       /* With high probability your project has been configured for an */
00297       /* incorrect part number. */
00298       while (1) ;
00299   }
00300 
00301   /* Enable clocks */
00302   CMU_ClockEnable(cmuClock_EBI, true);
00303   CMU_ClockEnable(cmuClock_GPIO, true);
00304 
00305   /* Configure mode - disable SPI, enable EBI */
00306   GPIO_PinModeSet(gpioPortC, 13, gpioModePushPull, 1);
00307   GPIO_PinModeSet(gpioPortC, 12, gpioModePushPull, 0);
00308 
00309   /* Configure GPIO pins as push pull */
00310   /* EBI AD9..15 */
00311   GPIO_PinModeSet(gpioPortA, 0, gpioModePushPull, 0);
00312   GPIO_PinModeSet(gpioPortA, 1, gpioModePushPull, 0);
00313   GPIO_PinModeSet(gpioPortA, 2, gpioModePushPull, 0);
00314   GPIO_PinModeSet(gpioPortA, 3, gpioModePushPull, 0);
00315   GPIO_PinModeSet(gpioPortA, 4, gpioModePushPull, 0);
00316   GPIO_PinModeSet(gpioPortA, 5, gpioModePushPull, 0);
00317   GPIO_PinModeSet(gpioPortA, 6, gpioModePushPull, 0);
00318 
00319   /* EBI AD8 */
00320   GPIO_PinModeSet(gpioPortA, 15, gpioModePushPull, 0);
00321 
00322   /* EBI CS0-CS3 */
00323   GPIO_PinModeSet(gpioPortD, 9, gpioModePushPull, 0);
00324   GPIO_PinModeSet(gpioPortD, 10, gpioModePushPull, 0);
00325   GPIO_PinModeSet(gpioPortD, 11, gpioModePushPull, 0);
00326   GPIO_PinModeSet(gpioPortD, 12, gpioModePushPull, 0);
00327 
00328   /* EBI AD0..7 */
00329   GPIO_PinModeSet(gpioPortE, 8, gpioModePushPull, 0);
00330   GPIO_PinModeSet(gpioPortE, 9, gpioModePushPull, 0);
00331   GPIO_PinModeSet(gpioPortE, 10, gpioModePushPull, 0);
00332   GPIO_PinModeSet(gpioPortE, 11, gpioModePushPull, 0);
00333   GPIO_PinModeSet(gpioPortE, 12, gpioModePushPull, 0);
00334   GPIO_PinModeSet(gpioPortE, 13, gpioModePushPull, 0);
00335   GPIO_PinModeSet(gpioPortE, 14, gpioModePushPull, 0);
00336   GPIO_PinModeSet(gpioPortE, 15, gpioModePushPull, 0);
00337 
00338   /* EBI ARDY/ALEN/Wen/Ren */
00339   GPIO_PinModeSet(gpioPortF, 2, gpioModePushPull, 0);
00340   GPIO_PinModeSet(gpioPortF, 3, gpioModePushPull, 0);
00341   GPIO_PinModeSet(gpioPortF, 4, gpioModePushPull, 0);
00342   GPIO_PinModeSet(gpioPortF, 5, gpioModePushPull, 0);
00343 
00344   /* Configure EBI controller, changing default values */
00345   ebiConfig.mode = ebiModeD16A16ALE;
00346   /* Enable bank 0 address map 0x80000000, FPGA Flash */
00347   /* Enable bank 1 address map 0x84000000, FPGA SRAM */
00348   /* Enable bank 2 address map 0x88000000, FPGA TFT Display (SSD2119) */
00349   /* Enable bank 3 address map 0x8c000000, FPGA Board Control Registers */
00350   ebiConfig.banks   = EBI_BANK0 | EBI_BANK1 | EBI_BANK2 | EBI_BANK3;
00351   ebiConfig.csLines = EBI_CS0 | EBI_CS1 | EBI_CS2 | EBI_CS3;
00352 
00353   /* Address Setup and hold time */
00354   ebiConfig.addrHoldCycles  = 3;
00355   ebiConfig.addrSetupCycles = 3;
00356 
00357   /* Read cycle times */
00358   ebiConfig.readStrobeCycles = 7;
00359   ebiConfig.readHoldCycles   = 3;
00360   ebiConfig.readSetupCycles  = 3;
00361 
00362   /* Write cycle times */
00363   ebiConfig.writeStrobeCycles = 7;
00364   ebiConfig.writeHoldCycles   = 3;
00365   ebiConfig.writeSetupCycles  = 3;
00366 
00367   /* Polarity values are default */
00368 
00369   /* Configure EBI */
00370   EBI_Init(&ebiConfig);
00371 }
00372 
00373 static void EbiDisable(void)
00374 {
00375   /* Disable EBI and SPI _BC_BUS_CONNECT */
00376   GPIO_PinModeSet(gpioPortC, 12, gpioModeDisabled, 0);
00377   GPIO_PinModeSet(gpioPortC, 13, gpioModeDisabled, 0);
00378 
00379   /* Configure GPIO pins as disabled */
00380   GPIO_PinModeSet(gpioPortA, 0, gpioModeDisabled, 0);
00381   GPIO_PinModeSet(gpioPortA, 1, gpioModeDisabled, 0);
00382   GPIO_PinModeSet(gpioPortA, 2, gpioModeDisabled, 0);
00383   GPIO_PinModeSet(gpioPortA, 3, gpioModeDisabled, 0);
00384   GPIO_PinModeSet(gpioPortA, 4, gpioModeDisabled, 0);
00385   GPIO_PinModeSet(gpioPortA, 5, gpioModeDisabled, 0);
00386   GPIO_PinModeSet(gpioPortA, 6, gpioModeDisabled, 0);
00387 
00388   GPIO_PinModeSet(gpioPortA, 15, gpioModeDisabled, 0);
00389 
00390   GPIO_PinModeSet(gpioPortD, 9, gpioModeDisabled, 0);
00391   GPIO_PinModeSet(gpioPortD, 10, gpioModeDisabled, 0);
00392   GPIO_PinModeSet(gpioPortD, 11, gpioModeDisabled, 0);
00393   GPIO_PinModeSet(gpioPortD, 12, gpioModeDisabled, 0);
00394 
00395   GPIO_PinModeSet(gpioPortE, 8, gpioModeDisabled, 0);
00396   GPIO_PinModeSet(gpioPortE, 9, gpioModeDisabled, 0);
00397   GPIO_PinModeSet(gpioPortE, 10, gpioModeDisabled, 0);
00398   GPIO_PinModeSet(gpioPortE, 11, gpioModeDisabled, 0);
00399   GPIO_PinModeSet(gpioPortE, 12, gpioModeDisabled, 0);
00400   GPIO_PinModeSet(gpioPortE, 13, gpioModeDisabled, 0);
00401   GPIO_PinModeSet(gpioPortE, 14, gpioModeDisabled, 0);
00402   GPIO_PinModeSet(gpioPortE, 15, gpioModeDisabled, 0);
00403 
00404   GPIO_PinModeSet(gpioPortF, 2, gpioModeDisabled, 0);
00405   GPIO_PinModeSet(gpioPortF, 3, gpioModeDisabled, 0);
00406   GPIO_PinModeSet(gpioPortF, 4, gpioModeDisabled, 0);
00407   GPIO_PinModeSet(gpioPortF, 5, gpioModeDisabled, 0);
00408 
00409   /* Disable EBI clock in CMU */
00410   CMU_ClockEnable(cmuClock_EBI, false);
00411 }
00412 
00413 /**************************************************************************/
00421 static bool EbiInit(void)
00422 {
00423   uint16_t ebiMagic;
00424   int      retry = 10;
00425 
00426   /* Disable all GPIO pins and register  */
00427   EbiDisable();
00428   /* Configure EBI */
00429   EbiConfigure();
00430   /* Verify that EBI access is working, if not kit is in SPI mode and needs to
00431    * be configured for EBI access */
00432   ebiMagic = BSP_RegisterRead(BC_MAGIC);
00433   while ((ebiMagic != BC_MAGIC_VALUE) && retry)
00434   {
00435     EbiDisable();
00436     /* Enable SPI interface */
00437     SpiInit();
00438     /* Set EBI mode - after this SPI access will no longer be available */
00439     ebiMagic = SpiRegisterRead(BC_MAGIC);
00440     SpiRegisterWrite(BC_CFG, BC_CFG_EBI);
00441     /* Disable SPI */
00442     SpiBcDisable();
00443 
00444     /* Now setup EBI again */
00445     EbiConfigure();
00446     /* Wait until ready */
00447     ebiMagic = BSP_RegisterRead(BC_MAGIC);
00448     if (ebiMagic == BC_MAGIC_VALUE) break;
00449 
00450     retry--;
00451   }
00452   if (!retry) return false;
00453 
00454   BSP_RegisterWrite(BC_LED, retry);
00455   return true;
00456 }
00457 #endif
00458 
00459 static uint16_t SpiBcAccess(uint8_t addr, uint8_t rw, uint16_t data)
00460 {
00461   uint16_t tmp;
00462 
00463   /* Enable CS */
00464   GPIO_PinOutClear(BSP_PORT_SPI_CS, BSP_PIN_SPI_CS);
00465 
00466   /* Write SPI address MSB */
00467   USART_Tx(BSP_SPI_USART_USED, (addr & 0x3) | rw << 3);
00468   /* Just ignore data read back */
00469   USART_Rx(BSP_SPI_USART_USED);
00470 
00471   /* Write SPI address  LSB */
00472   USART_Tx(BSP_SPI_USART_USED, data & 0xFF);
00473 
00474   tmp = (uint16_t) USART_Rx(BSP_SPI_USART_USED);
00475 
00476   /* SPI data MSB */
00477   USART_Tx(BSP_SPI_USART_USED, data >> 8);
00478   tmp |= (uint16_t) USART_Rx(BSP_SPI_USART_USED) << 8;
00479 
00480   /* Disable CS */
00481   GPIO_PinOutSet(BSP_PORT_SPI_CS, BSP_PIN_SPI_CS);
00482 
00483   return tmp;
00484 }
00485 
00486 static void SpiBcDisable(void)
00487 {
00488   USART_Reset(BSP_SPI_USART_USED);
00489 
00490   /* Disable LCD_SELECT */
00491   GPIO_PinModeSet(gpioPortD, 13, gpioModeDisabled, 0);
00492 
00493   /* Disable SPI pins */
00494   GPIO_PinModeSet(BSP_PORT_SPIBUS_CONNECT, 13, gpioModeDisabled, 0);
00495   GPIO_PinModeSet(BSP_PORT_SPIBUS_CONNECT, 12, gpioModeDisabled, 0);
00496   GPIO_PinModeSet(BSP_PORT_SPI_TX, BSP_PIN_SPI_TX, gpioModeDisabled, 0);
00497   GPIO_PinModeSet(BSP_PORT_SPI_RX, BSP_PIN_SPI_RX, gpioModeDisabled, 0);
00498   GPIO_PinModeSet(BSP_PORT_SPI_CLK, BSP_PIN_SPI_CLK, gpioModeDisabled, 0);
00499   GPIO_PinModeSet(BSP_PORT_SPI_CS, BSP_PIN_SPI_CS, gpioModeDisabled, 0);
00500 
00501   /* Disable USART clock - we can't disable GPIO or HFPER as we don't know who else
00502    * might be using it */
00503   CMU_ClockEnable(BSP_SPI_USART_CLK, false);
00504 }
00505 
00506 static void SpiBcInit(void)
00507 {
00508   USART_InitSync_TypeDef bcinit = USART_INITSYNC_DEFAULT;
00509 
00510   /* Enable module clocks */
00511   CMU_ClockEnable(BSP_SPI_USART_CLK, true);
00512 
00513   /* Configure SPI bus connect pins, DOUT set to 0, disable EBI */
00514   GPIO_PinModeSet(BSP_PORT_SPIBUS_CONNECT, BSP_PIN_SPIBUS_CONNECT, gpioModePushPull, 0);
00515   GPIO_PinModeSet(BSP_PORT_EBIBUS_CONNECT, BSP_PIN_EBIBUS_CONNECT, gpioModePushPull, 1);
00516 
00517   /* Configure SPI pins */
00518   GPIO_PinModeSet(BSP_PORT_SPI_TX, BSP_PIN_SPI_TX, gpioModePushPull, 0);
00519   GPIO_PinModeSet(BSP_PORT_SPI_RX, BSP_PIN_SPI_RX, gpioModeInput, 0);
00520   GPIO_PinModeSet(BSP_PORT_SPI_CLK, BSP_PIN_SPI_CLK, gpioModePushPull, 0);
00521 
00522   /* Keep CS high to not activate slave */
00523   GPIO_PinModeSet(BSP_PORT_SPI_CS, BSP_PIN_SPI_CS, gpioModePushPull, 1);
00524 
00525   /* Configure to use SPI master with manual CS */
00526   /* For now, configure SPI for worst case 32MHz clock in order to work for all */
00527   /* configurations. */
00528 
00529   bcinit.refFreq  = 32000000;
00530   bcinit.baudrate = 7000000;
00531 
00532   /* Initialize USART */
00533   USART_InitSync(BSP_SPI_USART_USED, &bcinit);
00534 
00535   /* Enable pins at default location */
00536   BSP_SPI_USART_USED->ROUTE = USART_ROUTE_TXPEN | USART_ROUTE_RXPEN | USART_ROUTE_CLKPEN;
00537 }
00538 
00539 static bool SpiInit(void)
00540 {
00541   uint16_t bcMagic;
00542 
00543   /* Enable HF and GPIO clocks */
00544   CMU_ClockEnable(cmuClock_HFPER, true);
00545   CMU_ClockEnable(cmuClock_GPIO, true);
00546 
00547   SpiBcInit();
00548   /* Read "board control Magic" register to verify SPI is up and running */
00549   /*  if not FPGA is configured to be in EBI mode  */
00550   bcMagic = SpiRegisterRead(BC_MAGIC);
00551   if (bcMagic != BC_MAGIC_VALUE)
00552   {
00553     return false;
00554   }
00555   else
00556   {
00557     return true;
00558   }
00559 }
00560 
00561 static uint16_t SpiRegisterRead(volatile uint16_t *addr)
00562 {
00563   uint16_t data;
00564 
00565   if (addr != lastAddr)
00566   {
00567     SpiBcAccess(0x00, 0, 0xFFFF & ((uint32_t) addr));           /* LSBs of address */
00568     SpiBcAccess(0x01, 0, 0xFF & ((uint32_t) addr >> 16));       /* MSBs of address */
00569     SpiBcAccess(0x02, 0, (0x0C000000 & (uint32_t) addr) >> 26); /* Chip select */
00570   }
00571   /* Read twice; when register address has changed we need two SPI transfer
00572    * to clock out valid data through board controller FIFOs */
00573   data     = SpiBcAccess(0x03, 1, 0);
00574   data     = SpiBcAccess(0x03, 1, 0);
00575   lastAddr = addr;
00576   return data;
00577 }
00578 
00579 static void SpiRegisterWrite(volatile uint16_t *addr, uint16_t data)
00580 {
00581   if (addr != lastAddr)
00582   {
00583     SpiBcAccess(0x00, 0, 0xFFFF & ((uint32_t) addr));           /* LSBs of address */
00584     SpiBcAccess(0x01, 0, 0xFF & ((uint32_t) addr >> 16));       /* MSBs of address */
00585     SpiBcAccess(0x02, 0, (0x0C000000 & (uint32_t) addr) >> 26); /* Chip select */
00586   }
00587   SpiBcAccess(0x03, 0, data);                                   /* Data */
00588   lastAddr = addr;
00589 }
00590 
00592 #endif  /* BSP_DK_3200 */