diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c b/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c index fded8defa3..0a2fad7d0d 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c @@ -36,7 +36,10 @@ #include "sl_power_manager.h" #endif +#ifdef SL_BOARD_NAME #include "sl_board_control.h" +#endif // SL_BOARD_NAME + #include "sl_si91x_ncp_utility.h" #include "spi_multiplex.h" diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index 6c03b6f1f4..1f10640e04 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -35,7 +35,6 @@ #include "em_gpio.h" #include "em_ldma.h" #include "gpiointerrupt.h" -#include "sl_board_control.h" #include "sl_device_init_clocks.h" #include "sl_device_init_hfxo.h" #include "sl_spidrv_instances.h" @@ -47,6 +46,10 @@ #include "wfx_host_events.h" #include "wfx_rsi.h" +#ifdef SL_BOARD_NAME +#include "sl_board_control.h" +#endif // SL_BOARD_NAME + #if defined(SL_CATALOG_POWER_MANAGER_PRESENT) #include "sl_power_manager.h" #endif @@ -65,18 +68,12 @@ #include "sl_mx25_flash_shutdown_usart_config.h" #endif // SL_MX25CTRL_MUX -#if defined(EFR32MG24) #include "em_eusart.h" #include "sl_spidrv_eusart_exp_config.h" #include "spi_multiplex.h" -#else -#error "Unknown platform" -#endif -#if defined(EFR32MG24) #define SL_SPIDRV_HANDLE sl_spidrv_eusart_exp_handle #define SL_SPIDRV_EXP_BITRATE_MULTIPLEXED SL_SPIDRV_EUSART_EXP_BITRATE -#endif #define CONCAT(A, B) (A##B) #define SPI_CLOCK(N) CONCAT(cmuClock_USART, N) @@ -113,10 +110,8 @@ void sl_wfx_host_gpio_init(void) // Enable GPIO clock. CMU_ClockEnable(cmuClock_GPIO, true); -#if defined(EFR32MG24) // Set CS pin to high/inactive GPIO_PinModeSet(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN, gpioModePushPull, PINOUT_SET); -#endif // EFR32MG24 GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModePushPull, PINOUT_SET); GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModePushPull, PINOUT_CLEAR); @@ -195,9 +190,7 @@ sl_status_t sl_wfx_host_spi_cs_assert(void) if (!spi_enabled) // Reduce sl_spidrv_init_instances { sl_spidrv_init_instances(); -#if defined(EFR32MG24) GPIO_PinOutClear(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN); -#endif // EFR32MG24 spi_enabled = true; } return SL_STATUS_OK; @@ -211,11 +204,9 @@ sl_status_t sl_wfx_host_spi_cs_deassert(void) status = SPIDRV_DeInit(SL_SPIDRV_HANDLE); if (SL_STATUS_OK == status) { -#if defined(EFR32MG24) GPIO_PinOutSet(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN); GPIO->EUSARTROUTE[SL_SPIDRV_EUSART_EXP_PERIPHERAL_NO].ROUTEEN = PINOUT_CLEAR; -#endif // EFR32MG24 - spi_enabled = false; + spi_enabled = false; } } #if SL_SPICTRL_MUX diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_board_configuration.h b/examples/platform/silabs/efr32/rs911x/hal/rsi_board_configuration.h index 4d8d9da1dd..ed04acf5b3 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/rsi_board_configuration.h +++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_board_configuration.h @@ -35,7 +35,8 @@ typedef struct #elif defined(EFR32MG24_BRD4187C) || defined(BRD4187C) #include "brd4187c.h" #else -#error "Need SPI Pins" +#include "sl_custom_board.h" +#warning "Modify sl_custom_board.h configuration file to match your hardware SPIDRV USART peripheral" #endif /* EFR32MG24_BRD4186C */ #endif /* _RSI_BOARD_CONFIGURATION_H_ */ diff --git a/examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h b/examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h index c1dceab06d..317bdc5bd2 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h +++ b/examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h @@ -36,7 +36,8 @@ typedef struct #elif defined(EFR32MG24_BRD4187C) || defined(BRD4187C) #include "brd4187c.h" #else -#error "Need SPI Pins" +#include "sl_custom_board.h" +#warning "Modify sl_custom_board.h configuration file to match your hardware SPIDRV USART peripheral" #endif #if EXP_BOARD #define RESET_PIN PIN(A, 6) diff --git a/examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.c b/examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.c index 4b876883c1..b16bbdc475 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.c +++ b/examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.c @@ -36,7 +36,9 @@ #include "spidrv.h" #include "task.h" +#ifdef SL_BOARD_NAME #include "sl_board_control.h" +#endif // SL_BOARD_NAME #include "sl_device_init_clocks.h" #include "sl_device_init_hfxo.h" @@ -242,4 +244,4 @@ sl_status_t sl_wfx_host_spiflash_cs_deassert(void) GPIO_PinOutSet(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); return SL_STATUS_OK; } -#endif // SL_MX25CTRL_MUX \ No newline at end of file +#endif // SL_MX25CTRL_MUX diff --git a/examples/platform/silabs/efr32/sl_custom_board.h b/examples/platform/silabs/efr32/sl_custom_board.h new file mode 100644 index 0000000000..420b715de9 --- /dev/null +++ b/examples/platform/silabs/efr32/sl_custom_board.h @@ -0,0 +1,71 @@ +/* + * This file is used to set the pins for the SPI for Custom boards + * The SPI pins are defined in the file + * + * !!!! MODIFY THIS FILE TO THE CORRECT PINS !!!! + */ + +#ifndef _CUSTOM_BOARD_H_ +#define _CUSTOM_BOARD_H_ + +#define WAKE_INDICATOR_PIN PIN(D, 2) +#ifdef RS911X_WIFI +// SPI ports and pins +#define EUS1MOSI_PORT gpioPortC +#define EUS1MOSI_PIN 1 +#define EUS1MISO_PORT gpioPortC +#define EUS1MISO_PIN 2 +#define EUS1SCLK_PORT gpioPortC +#define EUS1SCLK_PIN 3 +#define EUS1CS_PORT gpioPortC +#define EUS1CS_PIN 0 + +#define MY_USART EUSART1 +#define MY_USART_CLOCK cmuClock_EUSART1 +#define MY_USART_TX_SIGNAL dmadrvPeripheralSignal_EUSART1_TXBL +#define MY_USART_RX_SIGNAL dmadrvPeripheralSignal_EUSART1_RXDATAV + +#define WFX_RESET_PIN PIN(A, 6) +#define WFX_INTERRUPT_PIN PIN(A, 7) +#ifdef EXP_BOARD +#define WFX_SLEEP_CONFIRM_PIN PIN(D, 2) /* Expansion header pin7 */ +#else +#define WFX_SLEEP_CONFIRM_PIN PIN(A, 5) +#endif /* EXP_BOARD */ +#define SL_WFX_HOST_PINOUT_SPI_IRQ 5 + +#else /* WF200 */ + +#define PIN_OUT_SET 1 +#define PIN_OUT_CLEAR 0 + +#define MY_USART USART0 +#define MY_USART_CLOCK cmuClock_USART0 +#define MY_USART_TX_SIGNAL dmadrvPeripheralSignal_USART0_TXBL +#define MY_USART_RX_SIGNAL dmadrvPeripheralSignal_USART0_RXDATAV + +#define SL_WFX_HOST_PINOUT_RESET_PORT gpioPortA +#define SL_WFX_HOST_PINOUT_RESET_PIN 5 +#define SL_WFX_HOST_PINOUT_SPI_WIRQ_PORT gpioPortA /* SPI IRQ port */ +#define SL_WFX_HOST_PINOUT_SPI_WIRQ_PIN 8 /* SPI IRQ pin */ +#define SL_WFX_HOST_PINOUT_WUP_PORT gpioPortB +#define SL_WFX_HOST_PINOUT_WUP_PIN 5 + +#define SL_WFX_HOST_PINOUT_SPI_TX_PORT gpioPortC +#define SL_WFX_HOST_PINOUT_SPI_TX_PIN 1 +#define SL_WFX_HOST_PINOUT_SPI_TX_LOC 1 + +#define SL_WFX_HOST_PINOUT_SPI_RX_PORT gpioPortC +#define SL_WFX_HOST_PINOUT_SPI_RX_PIN 2 +#define SL_WFX_HOST_PINOUT_SPI_RX_LOC 1 + +#define SL_WFX_HOST_PINOUT_SPI_CLK_PORT gpioPortC +#define SL_WFX_HOST_PINOUT_SPI_CLK_PIN 3 +#define SL_WFX_HOST_PINOUT_SPI_CLK_LOC 1 + +#define SL_WFX_HOST_PINOUT_SPI_CS_PORT gpioPortC +#define SL_WFX_HOST_PINOUT_SPI_CS_PIN 0 +#define SL_WFX_HOST_PINOUT_SPI_CS_LOC 1 + +#endif /* WF200/9116 */ +#endif /* _CUSTOM_BOARD_H_ */ diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/examples/platform/silabs/efr32/wf200/efr_spi.c index 122652e96d..3ef34c928e 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/examples/platform/silabs/efr32/wf200/efr_spi.c @@ -98,11 +98,9 @@ sl_status_t sl_wfx_host_init_bus(void) * EUSARTROUTE register to do this. */ -#if defined(EFR32MG24) GPIO->USARTROUTE[0].ROUTEEN = GPIO_USART_ROUTEEN_RXPEN | // MISO GPIO_USART_ROUTEEN_TXPEN | // MOSI GPIO_USART_ROUTEEN_CLKPEN; -#endif spi_sem = xSemaphoreCreateBinaryStatic(&xEfrSpiSemaBuffer); xSemaphoreGive(spi_sem); @@ -338,11 +336,8 @@ void sl_wfx_host_gpio_init(void) { // Enable GPIO clock. CMU_ClockEnable(cmuClock_GPIO, true); - -#if defined(EFR32MG24) // configure WF200 CS pin. GPIO_PinModeSet(SL_SPIDRV_EXP_CS_PORT, SL_SPIDRV_EXP_CS_PIN, gpioModePushPull, 1); -#endif // Configure WF200 reset pin. GPIO_PinModeSet(SL_WFX_HOST_PINOUT_RESET_PORT, SL_WFX_HOST_PINOUT_RESET_PIN, gpioModePushPull, 0); // Configure WF200 WUP pin. diff --git a/examples/platform/silabs/efr32/wf200/sl_wfx_board.h b/examples/platform/silabs/efr32/wf200/sl_wfx_board.h index 3cbed666d6..35ce2f633d 100644 --- a/examples/platform/silabs/efr32/wf200/sl_wfx_board.h +++ b/examples/platform/silabs/efr32/wf200/sl_wfx_board.h @@ -25,6 +25,7 @@ #elif defined(EFR32MG24_BRD4187C) || defined(BRD4187C) || defined(EFR32MG24_BRD4187A) || defined(BRD4187A) #include "brd4187c.h" #else -#error "Need SPI Pins" +#include "sl_custom_board.h" +#warning "Modify sl_custom_board.h configuration file to match your hardware SPIDRV USART peripheral" #endif #endif /* _SL_WFX_BOARD_H_ */