Skip to content

Commit a93f4b6

Browse files
chirag-silabsrestyled-commitsjmartinez-silabsyufengwangca
authored
[Silabs] Fixing the build for the custom boards on NCP (#35055)
* 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 <yufengwang@google.com> * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Co-authored-by: Yufeng Wang <yufengwang@google.com>
1 parent be0009e commit a93f4b6

8 files changed

+88
-23
lines changed

examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c

+3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
#include "sl_power_manager.h"
3737
#endif
3838

39+
#ifdef SL_BOARD_NAME
3940
#include "sl_board_control.h"
41+
#endif // SL_BOARD_NAME
42+
4043
#include "sl_si91x_ncp_utility.h"
4144
#include "spi_multiplex.h"
4245

examples/platform/silabs/efr32/rs911x/hal/efx_spi.c

+5-14
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "em_gpio.h"
3636
#include "em_ldma.h"
3737
#include "gpiointerrupt.h"
38-
#include "sl_board_control.h"
3938
#include "sl_device_init_clocks.h"
4039
#include "sl_device_init_hfxo.h"
4140
#include "sl_spidrv_instances.h"
@@ -47,6 +46,10 @@
4746
#include "wfx_host_events.h"
4847
#include "wfx_rsi.h"
4948

49+
#ifdef SL_BOARD_NAME
50+
#include "sl_board_control.h"
51+
#endif // SL_BOARD_NAME
52+
5053
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
5154
#include "sl_power_manager.h"
5255
#endif
@@ -65,18 +68,12 @@
6568
#include "sl_mx25_flash_shutdown_usart_config.h"
6669
#endif // SL_MX25CTRL_MUX
6770

68-
#if defined(EFR32MG24)
6971
#include "em_eusart.h"
7072
#include "sl_spidrv_eusart_exp_config.h"
7173
#include "spi_multiplex.h"
72-
#else
73-
#error "Unknown platform"
74-
#endif
7574

76-
#if defined(EFR32MG24)
7775
#define SL_SPIDRV_HANDLE sl_spidrv_eusart_exp_handle
7876
#define SL_SPIDRV_EXP_BITRATE_MULTIPLEXED SL_SPIDRV_EUSART_EXP_BITRATE
79-
#endif
8077

8178
#define CONCAT(A, B) (A##B)
8279
#define SPI_CLOCK(N) CONCAT(cmuClock_USART, N)
@@ -113,10 +110,8 @@ void sl_wfx_host_gpio_init(void)
113110
// Enable GPIO clock.
114111
CMU_ClockEnable(cmuClock_GPIO, true);
115112

116-
#if defined(EFR32MG24)
117113
// Set CS pin to high/inactive
118114
GPIO_PinModeSet(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN, gpioModePushPull, PINOUT_SET);
119-
#endif // EFR32MG24
120115

121116
GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModePushPull, PINOUT_SET);
122117
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)
195190
if (!spi_enabled) // Reduce sl_spidrv_init_instances
196191
{
197192
sl_spidrv_init_instances();
198-
#if defined(EFR32MG24)
199193
GPIO_PinOutClear(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN);
200-
#endif // EFR32MG24
201194
spi_enabled = true;
202195
}
203196
return SL_STATUS_OK;
@@ -211,11 +204,9 @@ sl_status_t sl_wfx_host_spi_cs_deassert(void)
211204
status = SPIDRV_DeInit(SL_SPIDRV_HANDLE);
212205
if (SL_STATUS_OK == status)
213206
{
214-
#if defined(EFR32MG24)
215207
GPIO_PinOutSet(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN);
216208
GPIO->EUSARTROUTE[SL_SPIDRV_EUSART_EXP_PERIPHERAL_NO].ROUTEEN = PINOUT_CLEAR;
217-
#endif // EFR32MG24
218-
spi_enabled = false;
209+
spi_enabled = false;
219210
}
220211
}
221212
#if SL_SPICTRL_MUX

examples/platform/silabs/efr32/rs911x/hal/rsi_board_configuration.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ typedef struct
3535
#elif defined(EFR32MG24_BRD4187C) || defined(BRD4187C)
3636
#include "brd4187c.h"
3737
#else
38-
#error "Need SPI Pins"
38+
#include "sl_custom_board.h"
39+
#warning "Modify sl_custom_board.h configuration file to match your hardware SPIDRV USART peripheral"
3940
#endif /* EFR32MG24_BRD4186C */
4041

4142
#endif /* _RSI_BOARD_CONFIGURATION_H_ */

examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ typedef struct
3636
#elif defined(EFR32MG24_BRD4187C) || defined(BRD4187C)
3737
#include "brd4187c.h"
3838
#else
39-
#error "Need SPI Pins"
39+
#include "sl_custom_board.h"
40+
#warning "Modify sl_custom_board.h configuration file to match your hardware SPIDRV USART peripheral"
4041
#endif
4142
#if EXP_BOARD
4243
#define RESET_PIN PIN(A, 6)

examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
#include "spidrv.h"
3737
#include "task.h"
3838

39+
#ifdef SL_BOARD_NAME
3940
#include "sl_board_control.h"
41+
#endif // SL_BOARD_NAME
4042

4143
#include "sl_device_init_clocks.h"
4244
#include "sl_device_init_hfxo.h"
@@ -242,4 +244,4 @@ sl_status_t sl_wfx_host_spiflash_cs_deassert(void)
242244
GPIO_PinOutSet(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN);
243245
return SL_STATUS_OK;
244246
}
245-
#endif // SL_MX25CTRL_MUX
247+
#endif // SL_MX25CTRL_MUX
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* This file is used to set the pins for the SPI for Custom boards
3+
* The SPI pins are defined in the file
4+
*
5+
* !!!! MODIFY THIS FILE TO THE CORRECT PINS !!!!
6+
*/
7+
8+
#ifndef _CUSTOM_BOARD_H_
9+
#define _CUSTOM_BOARD_H_
10+
11+
#define WAKE_INDICATOR_PIN PIN(D, 2)
12+
#ifdef RS911X_WIFI
13+
// SPI ports and pins
14+
#define EUS1MOSI_PORT gpioPortC
15+
#define EUS1MOSI_PIN 1
16+
#define EUS1MISO_PORT gpioPortC
17+
#define EUS1MISO_PIN 2
18+
#define EUS1SCLK_PORT gpioPortC
19+
#define EUS1SCLK_PIN 3
20+
#define EUS1CS_PORT gpioPortC
21+
#define EUS1CS_PIN 0
22+
23+
#define MY_USART EUSART1
24+
#define MY_USART_CLOCK cmuClock_EUSART1
25+
#define MY_USART_TX_SIGNAL dmadrvPeripheralSignal_EUSART1_TXBL
26+
#define MY_USART_RX_SIGNAL dmadrvPeripheralSignal_EUSART1_RXDATAV
27+
28+
#define WFX_RESET_PIN PIN(A, 6)
29+
#define WFX_INTERRUPT_PIN PIN(A, 7)
30+
#ifdef EXP_BOARD
31+
#define WFX_SLEEP_CONFIRM_PIN PIN(D, 2) /* Expansion header pin7 */
32+
#else
33+
#define WFX_SLEEP_CONFIRM_PIN PIN(A, 5)
34+
#endif /* EXP_BOARD */
35+
#define SL_WFX_HOST_PINOUT_SPI_IRQ 5
36+
37+
#else /* WF200 */
38+
39+
#define PIN_OUT_SET 1
40+
#define PIN_OUT_CLEAR 0
41+
42+
#define MY_USART USART0
43+
#define MY_USART_CLOCK cmuClock_USART0
44+
#define MY_USART_TX_SIGNAL dmadrvPeripheralSignal_USART0_TXBL
45+
#define MY_USART_RX_SIGNAL dmadrvPeripheralSignal_USART0_RXDATAV
46+
47+
#define SL_WFX_HOST_PINOUT_RESET_PORT gpioPortA
48+
#define SL_WFX_HOST_PINOUT_RESET_PIN 5
49+
#define SL_WFX_HOST_PINOUT_SPI_WIRQ_PORT gpioPortA /* SPI IRQ port */
50+
#define SL_WFX_HOST_PINOUT_SPI_WIRQ_PIN 8 /* SPI IRQ pin */
51+
#define SL_WFX_HOST_PINOUT_WUP_PORT gpioPortB
52+
#define SL_WFX_HOST_PINOUT_WUP_PIN 5
53+
54+
#define SL_WFX_HOST_PINOUT_SPI_TX_PORT gpioPortC
55+
#define SL_WFX_HOST_PINOUT_SPI_TX_PIN 1
56+
#define SL_WFX_HOST_PINOUT_SPI_TX_LOC 1
57+
58+
#define SL_WFX_HOST_PINOUT_SPI_RX_PORT gpioPortC
59+
#define SL_WFX_HOST_PINOUT_SPI_RX_PIN 2
60+
#define SL_WFX_HOST_PINOUT_SPI_RX_LOC 1
61+
62+
#define SL_WFX_HOST_PINOUT_SPI_CLK_PORT gpioPortC
63+
#define SL_WFX_HOST_PINOUT_SPI_CLK_PIN 3
64+
#define SL_WFX_HOST_PINOUT_SPI_CLK_LOC 1
65+
66+
#define SL_WFX_HOST_PINOUT_SPI_CS_PORT gpioPortC
67+
#define SL_WFX_HOST_PINOUT_SPI_CS_PIN 0
68+
#define SL_WFX_HOST_PINOUT_SPI_CS_LOC 1
69+
70+
#endif /* WF200/9116 */
71+
#endif /* _CUSTOM_BOARD_H_ */

examples/platform/silabs/efr32/wf200/efr_spi.c

-5
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,9 @@ sl_status_t sl_wfx_host_init_bus(void)
9898
* EUSARTROUTE register to do this.
9999
*/
100100

101-
#if defined(EFR32MG24)
102101
GPIO->USARTROUTE[0].ROUTEEN = GPIO_USART_ROUTEEN_RXPEN | // MISO
103102
GPIO_USART_ROUTEEN_TXPEN | // MOSI
104103
GPIO_USART_ROUTEEN_CLKPEN;
105-
#endif
106104

107105
spi_sem = xSemaphoreCreateBinaryStatic(&xEfrSpiSemaBuffer);
108106
xSemaphoreGive(spi_sem);
@@ -338,11 +336,8 @@ void sl_wfx_host_gpio_init(void)
338336
{
339337
// Enable GPIO clock.
340338
CMU_ClockEnable(cmuClock_GPIO, true);
341-
342-
#if defined(EFR32MG24)
343339
// configure WF200 CS pin.
344340
GPIO_PinModeSet(SL_SPIDRV_EXP_CS_PORT, SL_SPIDRV_EXP_CS_PIN, gpioModePushPull, 1);
345-
#endif
346341
// Configure WF200 reset pin.
347342
GPIO_PinModeSet(SL_WFX_HOST_PINOUT_RESET_PORT, SL_WFX_HOST_PINOUT_RESET_PIN, gpioModePushPull, 0);
348343
// Configure WF200 WUP pin.

examples/platform/silabs/efr32/wf200/sl_wfx_board.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#elif defined(EFR32MG24_BRD4187C) || defined(BRD4187C) || defined(EFR32MG24_BRD4187A) || defined(BRD4187A)
2626
#include "brd4187c.h"
2727
#else
28-
#error "Need SPI Pins"
28+
#include "sl_custom_board.h"
29+
#warning "Modify sl_custom_board.h configuration file to match your hardware SPIDRV USART peripheral"
2930
#endif
3031
#endif /* _SL_WFX_BOARD_H_ */

0 commit comments

Comments
 (0)