26 #if defined( BSP_DK_BRD3201 )
30 #define BSP_SPI_USART_USED USART2
31 #define BSP_SPI_USART_CLK cmuClock_USART2
34 #define BSP_PORT_SPI_TX gpioPortC
35 #define BSP_PIN_SPI_TX 2
36 #define BSP_PORT_SPI_RX gpioPortC
37 #define BSP_PIN_SPI_RX 3
38 #define BSP_PORT_SPI_CLK gpioPortC
39 #define BSP_PIN_SPI_CLK 4
40 #define BSP_PORT_SPI_CS gpioPortC
41 #define BSP_PIN_SPI_CS 5
50 } BSP_SpiControl_TypeDef;
61 static bool EbiInit(
void);
62 static void EbiDisable(
void);
63 static uint16_t SpiBcAccess(uint8_t addr, uint8_t rw, uint16_t data);
64 static void SpiBcInit(
void);
65 static void SpiControl(BSP_SpiControl_TypeDef device);
66 static void SpiBcDisable(
void);
67 static bool SpiInit(
void);
68 static uint16_t SpiRegisterRead(
volatile uint16_t *addr);
69 static void SpiRegisterWrite(
volatile uint16_t *addr, uint16_t data);
72 static uint32_t bspOperationMode;
74 static volatile const uint16_t *lastAddr = 0;
75 static uint16_t bcFwVersion;
399 if (bcFwVersion < 257)
402 intFlags &= ~(flags);
463 uint16_t perfControl;
494 SpiControl(BSP_SPI_Ethernet);
510 SpiControl(BSP_SPI_Audio);
527 #if defined(ETM_PRESENT)
540 SpiControl(BSP_SPI_OFF);
557 SpiControl(BSP_SPI_OFF);
565 SpiControl(BSP_SPI_OFF);
574 SpiControl(BSP_SPI_Display);
612 SpiControl(BSP_SPI_OFF);
621 SpiControl(BSP_SPI_OFF);
625 #if defined(ETM_PRESENT)
662 SpiControl(BSP_SPI_OFF);
695 return SpiRegisterRead(addr);
712 SpiRegisterWrite(addr, data);
721 static void EbiDisable(
void)
723 #if defined(_EFM32_GECKO_FAMILY)
826 static bool EbiInit(
void)
834 #if defined(_EFM32_GECKO_FAMILY)
1118 static uint16_t SpiBcAccess(uint8_t addr, uint8_t rw, uint16_t data)
1126 USART_Tx(BSP_SPI_USART_USED, (addr & 0x3) | rw << 3);
1131 USART_Tx(BSP_SPI_USART_USED, data & 0xFF);
1133 tmp = (uint16_t)
USART_Rx(BSP_SPI_USART_USED);
1136 USART_Tx(BSP_SPI_USART_USED, data >> 8);
1137 tmp |= (uint16_t)
USART_Rx(BSP_SPI_USART_USED) << 8;
1145 static void SpiBcDisable(
void)
1160 static void SpiBcInit(
void)
1179 #if defined(_EFM32_GECKO_FAMILY)
1193 static void SpiControl(BSP_SpiControl_TypeDef device)
1201 case BSP_SPI_Ethernet:
1205 case BSP_SPI_Display:
1216 static bool SpiInit(
void)
1238 static uint16_t SpiRegisterRead(
volatile uint16_t *addr)
1242 if (addr != lastAddr)
1244 SpiBcAccess(0x00, 0, 0xFFFF & ((uint32_t) addr));
1245 SpiBcAccess(0x01, 0, 0xFF & ((uint32_t) addr >> 16));
1246 SpiBcAccess(0x02, 0, (0x0C000000 & (uint32_t) addr) >> 26);
1250 data = SpiBcAccess(0x03, 1, 0);
1251 data = SpiBcAccess(0x03, 1, 0);
1257 static void SpiRegisterWrite(
volatile uint16_t *addr, uint16_t data)
1259 if (addr != lastAddr)
1261 SpiBcAccess(0x00, 0, 0xFFFF & ((uint32_t) addr));
1262 SpiBcAccess(0x01, 0, 0xFF & ((uint32_t) addr >> 16));
1263 SpiBcAccess(0x02, 0, (0x0C000000 & (uint32_t) addr) >> 26);
1265 SpiBcAccess(0x03, 0, data);
Clock management unit (CMU) API.
#define BC_PERICON_AUDIO_IN_SHIFT
#define BC_SPI_DEMUX_SLAVE_ETHERNET
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 BC_PERICON_RS232_SHUTDOWN_SHIFT
void USART_InitSync(USART_TypeDef *usart, const USART_InitSync_TypeDef *init)
Init USART for synchronous mode.
#define BC_SPI_DEMUX_SLAVE_AUDIO
int BSP_EnergyModeSet(uint16_t energyMode)
Inform board controller about current energy mode.
#define BC_PERICON_I2C_SHIFT
int BSP_BusControlModeSet(BSP_BusControl_TypeDef mode)
Configure Board Controller bus decode logic.
#define BC_EBI_CTRL_EXTADDR_MASK
uint8_t USART_Rx(USART_TypeDef *usart)
Receive one 4-8 bit frame, (or part of 10-16 bit frame).
#define BC_PERICON_SPI_SHIFT
#define BC_PERICON_TRACE_SHIFT
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
#define BC_DISPLAY_CTRL_RESET
Universal synchronous/asynchronous receiver/transmitter (USART/UART) peripheral API.
int BSP_InterruptEnable(uint16_t flags)
Enable interrupts from board controller.
int BSP_InterruptFlagsSet(uint16_t flags)
Set board controller interrupt flags.
EBI_Location_TypeDef location
#define BC_PERICON_ANALOG_DIFF_SHIFT
#define BC_PERICON_ANALOG_SE_SHIFT
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.
#define BC_PERICON_AUDIO_OUT_SHIFT
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 BC_DISPLAY_CTRL_POWER_ENABLE
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.
#define USART_ROUTE_RXPEN
__STATIC_INLINE void GPIO_PinOutSet(GPIO_Port_TypeDef port, unsigned int pin)
Set a single pin in GPIO data out register to 1.
void EBI_Init(const EBI_Init_TypeDef *ebiInit)
Configure and enable External Bus Interface.
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.
#define BSP_STATUS_ILLEGAL_PARAM
#define USART_ROUTE_CLKPEN
#define BC_PERICON_RS232_UART_SHIFT
uint16_t BSP_InterruptFlagsGet(void)
Get board controller interrupt flags.
#define BC_DISPLAY_CTRL_MODE_GENERIC
void USART_Reset(USART_TypeDef *usart)
Reset USART/UART to same state as after a HW reset.
#define BC_PERICON_I2S_ETH_SHIFT
int BSP_Init(uint32_t flags)
Initialize board support package functionality.
#define USART_ROUTE_TXPEN
EBI_Polarity_TypeDef alePolarity
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...
#define BC_PERICON_AUDIO_OUT_SEL_SHIFT
#define BC_PERICON_RS232_LEUART_SHIFT
Board Control register definitions.
int BSP_RegisterWrite(volatile uint16_t *addr, uint16_t data)
Write to a board controller register.
void EBI_Disable(void)
Disable External Bus Interface.
int BSP_Disable(void)
Deinitialize board support package functionality. Reverse actions performed by BSP_Init(). This function is a dummy on STK's.
#define BC_PERICON_TOUCH_SHIFT
__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 BC_SPI_DEMUX_SLAVE_DISPLAY
#define BC_PERICON_I2S_ETH_SEL_SHIFT
uint16_t BSP_JoystickGet(void)
Get status of joystick on the DK.