Skip to content

Commit

Permalink
Merge pull request #14746 from jeromecoutant/PR_WB15CC
Browse files Browse the repository at this point in the history
STM32WB: introduce STM32WB15CC NUCLEO
  • Loading branch information
0xc0170 committed Jun 10, 2021
2 parents b74f62c + 1a370ed commit aeaac0e
Show file tree
Hide file tree
Showing 20 changed files with 711 additions and 516 deletions.
18 changes: 18 additions & 0 deletions connectivity/drivers/ble/FEATURE_BLE/TARGET_STM32WB/HCIDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ static bool get_bd_address(uint8_t *bd_addr);
static bool sysevt_wait(void);
static bool sysevt_check(void);

#if DEVICE_FLASH
extern int BLE_inited;
#endif

namespace ble {
namespace vendor {
Expand Down Expand Up @@ -490,6 +492,20 @@ class TransportDriver : public CordioHCITransportDriver {
tr_info("WIRELESS COPROCESSOR FW VERSION ID = %d.%d.%d", p_wireless_info->VersionMajor, p_wireless_info->VersionMinor, p_wireless_info->VersionSub);
tr_info("WIRELESS COPROCESSOR FW STACK TYPE = %d (ROM size 0x%x)", p_wireless_info->StackType, MBED_ROM_SIZE);

#if STM32WB15xx
switch (p_wireless_info->StackType) {
case INFO_STACK_TYPE_BLE_FULL:
error("Wrong BLE FW\n");
break;
case INFO_STACK_TYPE_BLE_HCI:
if (MBED_ROM_SIZE > 0x32800) {
error("Wrong MBED_ROM_SIZE with HCI FW\n");
}
break;
default:
tr_error("StackType %u not expected\n", p_wireless_info->StackType);
}
#endif
#if STM32WB55xx
switch (p_wireless_info->StackType) {
case INFO_STACK_TYPE_BLE_FULL:
Expand Down Expand Up @@ -681,8 +697,10 @@ class TransportDriver : public CordioHCITransportDriver {
*/
SHCI_C2_BLE_Init(&ble_init_cmd_packet);

#if DEVICE_FLASH
/* Used in flash_api.c */
BLE_inited = 1;
#endif
}

TL_CmdPacket_t *bleCmdBuf;
Expand Down
16 changes: 15 additions & 1 deletion targets/TARGET_STM/TARGET_STM32WB/PeripheralNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,42 @@ typedef enum {
#define DEVICE_SPI_COUNT 2
typedef enum {
SPI_1 = (int)SPI1_BASE,
SPI_2 = (int)SPI2_BASE
#if defined SPI2_BASE
SPI_2 = (int)SPI2_BASE,
#endif
} SPIName;

typedef enum {
I2C_1 = (int)I2C1_BASE,
#if defined I2C3_BASE
I2C_3 = (int)I2C3_BASE
#endif
} I2CName;

typedef enum {
PWM_1 = (int)TIM1_BASE,
#if defined TIM2_BASE
PWM_2 = (int)TIM2_BASE,
#endif
#if defined TIM16_BASE
PWM_16 = (int)TIM16_BASE,
#endif
#if defined TIM17_BASE
PWM_17 = (int)TIM17_BASE
#endif
} PWMName;

#if defined QUADSPI_R_BASE
typedef enum {
QSPI_1 = (int)QUADSPI_R_BASE
} QSPIName;
#endif

#if defined USB_BASE
typedef enum {
USB_FS = (int)USB_BASE,
} USBName;
#endif

#ifdef __cplusplus
}
Expand Down
40 changes: 40 additions & 0 deletions targets/TARGET_STM/TARGET_STM32WB/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,33 @@ mbedls -m 0884:DISCO_WB5MMG
```


## NUCLEO_WB15CC (NUCLEO-WB15CC)

[st.com STM32WB15CC module page](https://www.st.com/en/microcontrollers-microprocessors/stm32wb15cc.html)

[st.com NUCLEO board page]()

[mbed.com platform page](https://os.mbed.com/platforms/ST-NUCLEO-WB15CC/)

- Total FLASH is 320KB

But FLASH is shared by M4 and M0 cores, [see BLE FW](#ble-fw)

- RAM: 48 KB
- SRAM1: 12 KB
- SRAM2a: 32 KB
- SRAM2b: 4 KB

SRAM1 is dedicated for M4 core, and then for mbed-os applications.

SRAM2 is dedicated for M0 core and inter CPU communication, and some part can not be addressed by M4.

NB: MBED CLI1 tool can be used thanks to this command:
```
mbedls -m 0883:NUCLEO_WB15CC
```


# BLE

## MBED-OS support
Expand All @@ -90,6 +117,8 @@ Official ST Application Note :

All available BLE FW for M0 core are provided in ths ST STM32CubeWB repo:

### STM32WB5x

https://github.com/STMicroelectronics/STM32CubeWB/tree/master/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x

Default BLE FW in ST boards is **stm32wb5x_BLE_Stack_full_fw.bin**
Expand All @@ -108,6 +137,17 @@ Example in your local mbed_app.json:
}
```

### STM32WB1x

https://github.com/STMicroelectronics/STM32CubeWB/tree/master/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB1x

Default BLE FW in ST boards is **stm32wb1x_BLE_Stack_full_fw.bin**
- **this is not supported in mbed**

It is mandatory to use **stm32wb1x_BLE_HCILayer_fw.bin**
- As explained in Release_Notes.html, this FW is flashed at @ 0x08032800
- Then "mbed_rom_size" is "0x32800" (202K) (default configuration in targets.json)


## BLE FW update

Expand Down
4 changes: 4 additions & 0 deletions targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/app_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@
* Maximum number of simultaneous connections that the device will support.
* Valid values are from 1 to 8
*/
#ifdef TARGET_MCU_STM32WB15xC
#define CFG_BLE_NUM_LINK 4
#else
#define CFG_BLE_NUM_LINK 8
#endif

/**
* Maximum number of Services that can be stored in the GATT database.
Expand Down
4 changes: 4 additions & 0 deletions targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/stm32_lpm_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ void PWR_EnterStopMode( void )
/************************************************************************************
* ENTER STOP MODE
***********************************************************************************/
#if defined(PWR_SUPPORT_STOP2)
LL_PWR_SetPowerMode( LL_PWR_MODE_STOP2 );
#else
LL_PWR_SetPowerMode( LL_PWR_MODE_STOP1 );
#endif

LL_LPM_EnableDeepSleep( ); /**< Set SLEEPDEEP bit of Cortex System Control Register */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

add_subdirectory(TARGET_NUCLEO_WB15CC EXCLUDE_FROM_ALL)

if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_stm32wb15xx.S)
set(LINKER_FILE TOOLCHAIN_GCC_ARM/stm32wb15xc.ld)
Expand All @@ -19,6 +21,7 @@ target_include_directories(mbed-stm32wb15xc
target_sources(mbed-stm32wb15xc
INTERFACE
${STARTUP_FILE}
system_clock.c
)

mbed_set_linker_script(mbed-stm32wb15xc ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

add_library(mbed-nucleo-wb15cc INTERFACE)

target_sources(mbed-nucleo-wb15cc
INTERFACE
PeripheralPins.c
)

target_include_directories(mbed-nucleo-wb15cc
INTERFACE
.
)

target_link_libraries(mbed-nucleo-wb15cc INTERFACE mbed-stm32wb15xc)
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/* mbed Microcontroller Library
* SPDX-License-Identifier: BSD-3-Clause
******************************************************************************
*
* Copyright (c) 2016-2021 STMicroelectronics.
* All rights reserved.
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*
* Automatically generated from STM32CubeMX/db/mcu/STM32WB15CCUx.xml
*/

#include "PeripheralPins.h"
#include "mbed_toolchain.h"

//==============================================================================
// Notes
//
// - The pins mentioned Px_y_ALTz are alternative possibilities which use other
// HW peripheral instances. You can use them the same way as any other "normal"
// pin (i.e. PwmOut pwm(PA_7_ALT0);). These pins are not displayed on the board
// pinout image on mbed.org.
//
// - The pins which are connected to other components present on the board have
// the comment "Connected to xxx". The pin function may not work properly in this
// case. These pins may not be displayed on the board pinout image on mbed.org.
// Please read the board reference manual and schematic for more information.
//
// - Warning: pins connected to the default STDIO_UART_TX and STDIO_UART_RX pins are commented
// See https://os.mbed.com/teams/ST/wiki/STDIO for more information.
//
//==============================================================================




//*** ADC ***

MBED_WEAK const PinMap PinMap_ADC[] = {
{PA_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 // Connected to B1 [Push Button]
{PA_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6
{PA_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7
{PA_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8
{PA_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9
{PA_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10
{PA_6, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 // Connected to B3 [Push Button]
{PA_7, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2
{PA_8, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3
// {PA_9, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 // Connected to STDIO_UART_TX
{NC, NC, 0}
};

MBED_WEAK const PinMap PinMap_ADC_Internal[] = {
{ADC_TEMP, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)},
{ADC_VREF, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)},
{ADC_VBAT, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)},
{NC, NC, 0}
};

//*** I2C ***

MBED_WEAK const PinMap PinMap_I2C_SDA[] = {
// {PA_10, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // Connected to STDIO_UART_RX
{PB_7, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
{PB_9, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
{NC, NC, 0}
};

MBED_WEAK const PinMap PinMap_I2C_SCL[] = {
// {PA_9, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // Connected to STDIO_UART_TX
{PB_6, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
{PB_8, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
{NC, NC, 0}
};

//*** PWM ***

// TIM2 cannot be used because already used by the us_ticker
// (update us_ticker_data.h file if another timer is chosen)
MBED_WEAK const PinMap PinMap_PWM[] = {
// {PA_0, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // Connected to B1 [Push Button]
// {PA_1, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2
// {PA_2, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3
// {PA_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4
// {PA_5, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
{PA_7, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
{PA_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1
// {PA_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 // Connected to STDIO_UART_TX
// {PA_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 // Connected to STDIO_UART_RX
{PA_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4
// {PA_15, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
// {PB_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 // Connected to JTDO
{PB_7, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_TIM1, 3, 0)}, // TIM1_CH3
{PB_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
{PB_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
{NC, NC, 0}
};

//*** SERIAL ***

MBED_WEAK const PinMap PinMap_UART_TX[] = {
{PA_2, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
{PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to STDIO_UART_TX
{PB_5, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to LD1 [Blue Led]
{PB_6, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
{NC, NC, 0}
};

MBED_WEAK const PinMap PinMap_UART_RX[] = {
{PA_3, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
{PA_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to STDIO_UART_RX
{PA_12, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)},
{PB_7, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
{NC, NC, 0}
};

MBED_WEAK const PinMap PinMap_UART_RTS[] = {
{PA_12, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
{PB_1, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to LD3 [Red Led]
{PB_3, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to JTDO
{NC, NC, 0}
};

MBED_WEAK const PinMap PinMap_UART_CTS[] = {
{PA_6, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to B3 [Push Button]
{PA_11, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
{PB_4, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
{NC, NC, 0}
};

//*** SPI ***

MBED_WEAK const PinMap PinMap_SPI_MOSI[] = {
{PA_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF4_SPI1)},
{PA_7, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)},
{PA_12, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)},
{PA_13, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to JTMS
{PB_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to LD1 [Blue Led]
{NC, NC, 0}
};

MBED_WEAK const PinMap PinMap_SPI_MISO[] = {
{PA_6, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to B3 [Push Button]
{PA_11, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)},
{PB_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)},
{NC, NC, 0}
};

MBED_WEAK const PinMap PinMap_SPI_SCLK[] = {
{PA_1, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)},
{PA_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)},
{PB_3, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to JTDO
{NC, NC, 0}
};

MBED_WEAK const PinMap PinMap_SPI_SSEL[] = {
{PA_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)},
{PA_14, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to JTCK
{PA_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)},
{PB_2, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)},
{PB_6, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)},
{NC, NC, 0}
};

0 comments on commit aeaac0e

Please sign in to comment.