bsp_dk_3200.c

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