Skip to content

Commit

Permalink
[Silabs] Fixing the build for the custom boards on NCP (#35055)
Browse files Browse the repository at this point in the history
* fixing the build for the custom boards on ncp

* Restyled by clang-format

* applying the restyler

* addressing the review comments and adding sl_custom_board.h file

* adding the warning message for 917 NCP

* Restyled by whitespace

* Restyled by clang-format

* Apply suggestions from code review

Co-authored-by: Yufeng Wang <[email protected]>

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Junior Martinez <[email protected]>
Co-authored-by: Yufeng Wang <[email protected]>
  • Loading branch information
4 people authored Aug 24, 2024
1 parent be0009e commit a93f4b6
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 23 deletions.
3 changes: 3 additions & 0 deletions examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
19 changes: 5 additions & 14 deletions examples/platform/silabs/efr32/rs911x/hal/efx_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
#endif // SL_MX25CTRL_MUX
71 changes: 71 additions & 0 deletions examples/platform/silabs/efr32/sl_custom_board.h
Original file line number Diff line number Diff line change
@@ -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_ */
5 changes: 0 additions & 5 deletions examples/platform/silabs/efr32/wf200/efr_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion examples/platform/silabs/efr32/wf200/sl_wfx_board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */

0 comments on commit a93f4b6

Please sign in to comment.