27 #if defined( BSP_DK_BRD3200 )
31 #define BSP_SPI_USART_USED USART2
32 #define BSP_SPI_USART_CLK cmuClock_USART2
35 #define BSP_PORT_SPIBUS_CONNECT gpioPortC
36 #define BSP_PIN_SPIBUS_CONNECT 13
37 #define BSP_PORT_EBIBUS_CONNECT gpioPortC
38 #define BSP_PIN_EBIBUS_CONNECT 12
39 #define BSP_PORT_SPI_TX gpioPortC
40 #define BSP_PIN_SPI_TX 2
41 #define BSP_PORT_SPI_RX gpioPortC
42 #define BSP_PIN_SPI_RX 3
43 #define BSP_PORT_SPI_CLK gpioPortC
44 #define BSP_PIN_SPI_CLK 4
45 #define BSP_PORT_SPI_CS gpioPortC
46 #define BSP_PIN_SPI_CS 5
48 static uint16_t SpiBcAccess(uint8_t addr, uint8_t rw, uint16_t data);
49 static void SpiBcInit(
void);
50 static void SpiBcDisable(
void);
51 static bool SpiInit(
void);
52 static uint16_t SpiRegisterRead(
volatile uint16_t *addr);
53 static void SpiRegisterWrite(
volatile uint16_t *addr, uint16_t data);
54 static volatile const uint16_t *lastAddr = 0;
56 #if defined( BSP_BC_CTRL_EBI )
57 static void EbiConfigure(
void);
58 static bool EbiInit(
void);
59 static void EbiDisable(
void);
82 #if defined( BSP_BC_CTRL_EBI )
120 #if defined( BSP_BC_CTRL_EBI )
176 uint16_t joyStick = 0;
195 bit = (uint16_t)perf;
207 if ((perf == BSP_RS232A) || (perf == BSP_RS232B))
214 if (perf == BSP_IRDA)
226 if ((perf == BSP_RS232A) || (perf == BSP_RS232B))
233 if (perf == BSP_IRDA)
262 #if defined( BSP_BC_CTRL_EBI )
265 return SpiRegisterRead(addr);
271 #if defined( BSP_BC_CTRL_EBI )
274 SpiRegisterWrite(addr, data);
280 #if defined( BSP_BC_CTRL_EBI )
281 static void EbiConfigure(
void)
283 EBI_Init_TypeDef ebiConfig = EBI_INIT_DEFAULT;
345 ebiConfig.mode = ebiModeD16A16ALE;
350 ebiConfig.banks = EBI_BANK0 | EBI_BANK1 | EBI_BANK2 | EBI_BANK3;
351 ebiConfig.csLines = EBI_CS0 | EBI_CS1 | EBI_CS2 | EBI_CS3;
354 ebiConfig.addrHoldCycles = 3;
355 ebiConfig.addrSetupCycles = 3;
358 ebiConfig.readStrobeCycles = 7;
359 ebiConfig.readHoldCycles = 3;
360 ebiConfig.readSetupCycles = 3;
363 ebiConfig.writeStrobeCycles = 7;
364 ebiConfig.writeHoldCycles = 3;
365 ebiConfig.writeSetupCycles = 3;
370 EBI_Init(&ebiConfig);
373 static void EbiDisable(
void)
421 static bool EbiInit(
void)
439 ebiMagic = SpiRegisterRead(
BC_MAGIC);
452 if (!retry)
return false;
459 static uint16_t SpiBcAccess(uint8_t addr, uint8_t rw, uint16_t data)
467 USART_Tx(BSP_SPI_USART_USED, (addr & 0x3) | rw << 3);
472 USART_Tx(BSP_SPI_USART_USED, data & 0xFF);
474 tmp = (uint16_t)
USART_Rx(BSP_SPI_USART_USED);
477 USART_Tx(BSP_SPI_USART_USED, data >> 8);
478 tmp |= (uint16_t)
USART_Rx(BSP_SPI_USART_USED) << 8;
486 static void SpiBcDisable(
void)
506 static void SpiBcInit(
void)
539 static bool SpiInit(
void)
550 bcMagic = SpiRegisterRead(
BC_MAGIC);
561 static uint16_t SpiRegisterRead(
volatile uint16_t *addr)
565 if (addr != lastAddr)
567 SpiBcAccess(0x00, 0, 0xFFFF & ((uint32_t) addr));
568 SpiBcAccess(0x01, 0, 0xFF & ((uint32_t) addr >> 16));
569 SpiBcAccess(0x02, 0, (0x0C000000 & (uint32_t) addr) >> 26);
573 data = SpiBcAccess(0x03, 1, 0);
574 data = SpiBcAccess(0x03, 1, 0);
579 static void SpiRegisterWrite(
volatile uint16_t *addr, uint16_t data)
581 if (addr != lastAddr)
583 SpiBcAccess(0x00, 0, 0xFFFF & ((uint32_t) addr));
584 SpiBcAccess(0x01, 0, 0xFF & ((uint32_t) addr >> 16));
585 SpiBcAccess(0x02, 0, (0x0C000000 & (uint32_t) addr) >> 26);
587 SpiBcAccess(0x03, 0, data);
Clock management unit (CMU) API.
void USART_Tx(USART_TypeDef *usart, uint8_t data)
Transmit one 4-9 bit frame.
uint16_t BSP_PushButtonsGet(void)
Get status of the pushbutton switches on the DK.
Board support package API definitions.
#define USART_ROUTE_TXPEN
void USART_InitSync(USART_TypeDef *usart, const USART_InitSync_TypeDef *init)
Init USART for synchronous mode.
int BSP_EnergyModeSet(uint16_t energyMode)
Inform board controller about current energy mode.
int BSP_BusControlModeSet(BSP_BusControl_TypeDef mode)
Configure Board Controller bus decode logic.
uint8_t USART_Rx(USART_TypeDef *usart)
Receive one 4-8 bit frame, (or part of 10-16 bit frame).
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
Universal synchronous/asynchronous receiver/transmitter (USART/UART) peripheral API.
int BSP_InterruptEnable(uint16_t flags)
Enable interrupts from board controller.
uint16_t BSP_RegisterRead(volatile uint16_t *addr)
Read from a board controller register.
int BSP_InterruptDisable(uint16_t flags)
Disable interrupts from board controller.
External Bus Iterface (EBI) peripheral API.
int BSP_InterruptFlagsClear(uint16_t flags)
Clear board controller interrupt flags.
void GPIO_PinModeSet(GPIO_Port_TypeDef port, unsigned int pin, GPIO_Mode_TypeDef mode, unsigned int out)
Set the mode for a GPIO pin.
#define BSP_STATUS_NOT_IMPLEMENTED
int BSP_EbiExtendedAddressRange(bool enable)
Extended the EBI addressing range by enabling address lines A16-A22. On Gxxx_DK's this functions is a...
General Purpose IO (GPIO) peripheral API.
__STATIC_INLINE void GPIO_PinOutSet(GPIO_Port_TypeDef port, unsigned int pin)
Set a single pin in GPIO data out register to 1.
void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable)
Enable/disable a clock.
uint32_t BSP_DipSwitchGet(void)
Get status of the DIP switches on the DK.
uint16_t BSP_InterruptFlagsGet(void)
Get board controller interrupt flags.
void USART_Reset(USART_TypeDef *usart)
Reset USART/UART to same state as after a HW reset.
int BSP_Init(uint32_t flags)
Initialize board support package functionality.
#define BC_PERCTRL_IRDA_SHUTDOWN
int BSP_PeripheralAccess(BSP_Peripheral_TypeDef perf, bool enable)
DK Peripheral Access Control Enable or disable access to on-board peripherals through switches and SP...
__STATIC_INLINE uint16_t SYSTEM_GetPartNumber(void)
Get part number of the MCU.
Board Control register definitions.
int BSP_RegisterWrite(volatile uint16_t *addr, uint16_t data)
Write to a board controller register.
#define BC_PERCTRL_RS232_SHUTDOWN
int BSP_Disable(void)
Deinitialize board support package functionality. Reverse actions performed by BSP_Init(). This function is a dummy on STK's.
__STATIC_INLINE void GPIO_PinOutClear(GPIO_Port_TypeDef port, unsigned int pin)
Set a single pin in GPIO data out port register to 0.
BSP_BusControl_TypeDef BSP_BusControlModeGet(void)
Get current board controller bus decode logic configuration.
int BSP_DisplayControl(BSP_Display_TypeDef option)
Configure display control.
#define USART_INITSYNC_DEFAULT
#define USART_ROUTE_CLKPEN
#define USART_ROUTE_RXPEN
uint16_t BSP_JoystickGet(void)
Get status of joystick on the DK.