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)
828 EBI_Init_TypeDef ebiConfig = EBI_INIT_DEFAULT;
834 #if defined(_EFM32_GECKO_FAMILY)
879 ebiConfig.mode = ebiModeD16A16ALE;
902 ebiConfig.banks = EBI_BANK0 | EBI_BANK1 | EBI_BANK2 | EBI_BANK3;
903 ebiConfig.csLines = EBI_CS0 | EBI_CS1 | EBI_CS2 | EBI_CS3;
906 ebiConfig.addrHoldCycles = 3;
907 ebiConfig.addrSetupCycles = 3;
910 ebiConfig.readStrobeCycles = 7;
911 ebiConfig.readHoldCycles = 3;
912 ebiConfig.readSetupCycles = 3;
915 ebiConfig.writeStrobeCycles = 7;
916 ebiConfig.writeHoldCycles = 3;
917 ebiConfig.writeSetupCycles = 3;
920 ebiConfig.alePolarity = ebiActiveHigh;
923 EBI_Init(&ebiConfig);
981 ebiConfig.banks = EBI_BANK2;
982 ebiConfig.csLines = EBI_CS2;
983 ebiConfig.mode = ebiModeD16A16ALE;
984 ebiConfig.alePolarity = ebiActiveHigh;
985 ebiConfig.blEnable =
true;
986 ebiConfig.noIdle =
true;
987 ebiConfig.ardyEnable =
false;
988 ebiConfig.addrHalfALE =
true;
989 ebiConfig.readPrefetch =
true;
990 ebiConfig.aLow = ebiALowA16;
991 ebiConfig.aHigh = ebiAHighA23;
992 ebiConfig.location = ebiLocation1;
995 ebiConfig.addrHoldCycles = 0;
996 ebiConfig.addrSetupCycles = 0;
999 ebiConfig.readStrobeCycles = 4;
1000 ebiConfig.readHoldCycles = 0;
1001 ebiConfig.readSetupCycles = 0;
1004 ebiConfig.writeStrobeCycles = 2;
1005 ebiConfig.writeHoldCycles = 0;
1006 ebiConfig.writeSetupCycles = 0;
1009 EBI_Init(&ebiConfig);
1015 ebiConfig.banks = EBI_BANK0;
1016 ebiConfig.csLines = EBI_CS0;
1017 ebiConfig.mode = ebiModeD16A16ALE;;
1018 ebiConfig.alePolarity = ebiActiveHigh;
1020 ebiConfig.blEnable =
false;
1021 ebiConfig.addrHalfALE =
true;
1022 ebiConfig.readPrefetch =
false;
1023 ebiConfig.noIdle =
true;
1030 ebiConfig.addrHoldCycles = 3;
1031 ebiConfig.addrSetupCycles = 3;
1034 ebiConfig.readStrobeCycles = 7;
1035 ebiConfig.readHoldCycles = 3;
1036 ebiConfig.readSetupCycles = 3;
1039 ebiConfig.writeStrobeCycles = 7;
1040 ebiConfig.writeHoldCycles = 3;
1041 ebiConfig.writeSetupCycles = 3;
1044 EBI_Init(&ebiConfig);
1051 ebiConfig.banks = EBI_BANK1;
1052 ebiConfig.csLines = EBI_CS1;
1055 ebiConfig.addrHoldCycles = 1;
1056 ebiConfig.addrSetupCycles = 1;
1059 ebiConfig.readStrobeCycles = 7;
1060 ebiConfig.readHoldCycles = 3;
1061 ebiConfig.readSetupCycles = 3;
1064 ebiConfig.writeStrobeCycles = 2;
1065 ebiConfig.writeHoldCycles = 1;
1066 ebiConfig.writeSetupCycles = 1;
1069 EBI_Init(&ebiConfig);
1075 ebiConfig.banks = EBI_BANK3;
1076 ebiConfig.csLines = EBI_CS3;
1077 ebiConfig.mode = ebiModeD16A16ALE;
1078 ebiConfig.alePolarity = ebiActiveHigh;
1081 ebiConfig.blEnable =
true;
1082 ebiConfig.addrHalfALE =
true;
1083 ebiConfig.readPrefetch =
false;
1084 ebiConfig.noIdle =
true;
1087 ebiConfig.addrHoldCycles = 0;
1088 ebiConfig.addrSetupCycles = 0;
1091 ebiConfig.readStrobeCycles = 6;
1092 ebiConfig.readHoldCycles = 0;
1093 ebiConfig.readSetupCycles = 0;
1096 ebiConfig.writeStrobeCycles = 5;
1097 ebiConfig.writeHoldCycles = 0;
1098 ebiConfig.writeSetupCycles = 0;
1101 EBI_Init(&ebiConfig);
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
#define USART_ROUTE_TXPEN
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.
#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.
__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.
#define BSP_STATUS_ILLEGAL_PARAM
#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.
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.
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
#define USART_ROUTE_CLKPEN
#define USART_ROUTE_RXPEN
uint16_t BSP_JoystickGet(void)
Get status of joystick on the DK.