Skip to content

Commit

Permalink
variant(WB): add P-Nucleo WB55 USB Dongle
Browse files Browse the repository at this point in the history
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
  • Loading branch information
fpistm committed Mar 29, 2023
1 parent 5a3f412 commit ceb3beb
Show file tree
Hide file tree
Showing 4 changed files with 331 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
| :green_heart: | STM32L452RE-P | [Nucleo L452RE-P](http://www.st.com/en/evaluation-tools/nucleo-l452re-p.html) | *1.8.0* | |
| :green_heart: | STM32L476RG | [Nucleo L476RG](http://www.st.com/en/evaluation-tools/nucleo-l476rg.html) | *0.1.0* | |
| :yellow_heart: | STM32WB15CCU | [Nucleo-WB15CC](https://www.st.com/en/evaluation-tools/nucleo-wb15cc.html) | **2.5.0** | |
| :green_heart: | STM32WB55RG<br>STM32WB55CG | [P-Nucleo-WB55RG](https://www.st.com/en/evaluation-tools/p-nucleo-wb55.html) | *1.6.0* | BLE support with [STM32duinoBLE](https://github.com/stm32duino/STM32duinoBLE) |
| :green_heart: | STM32WB55RG | [P-Nucleo-WB55RG](https://www.st.com/en/evaluation-tools/p-nucleo-wb55.html) | *1.6.0* | BLE support with [STM32duinoBLE](https://github.com/stm32duino/STM32duinoBLE) |
| :yellow_heart: | STM32WB55CG | [P-Nucleo-WB55 USB Dongle](https://www.st.com/en/evaluation-tools/p-nucleo-wb55.html) | **2.5.0** | BLE support with [STM32duinoBLE](https://github.com/stm32duino/STM32duinoBLE) |
| :green_heart: | STM32WL55JC | [Nucleo WL55JC1](https://www.st.com/en/evaluation-tools/nucleo-wl55jc.html) | *2.1.0* | LoRa support not available |


Expand Down
14 changes: 14 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,20 @@ Nucleo_64.menu.pnum.P_NUCLEO_WB55RG.build.product_line=STM32WB55xx
Nucleo_64.menu.pnum.P_NUCLEO_WB55RG.build.variant=STM32WBxx/WB55R(C-E-G)V
Nucleo_64.menu.pnum.P_NUCLEO_WB55RG.build.cmsis_lib_gcc=arm_cortexM4lf_math

# P_NUCLEO_WB55 USB Dongle
Nucleo_64.menu.pnum.P_NUCLEO_WB55_USB_DONGLE=P-Nucleo WB55 USB Dongle
Nucleo_64.menu.pnum.P_NUCLEO_WB55_USB_DONGLE.node="No_mass_storage_for_this_board_Use_STLink_upload_method"
Nucleo_64.menu.pnum.P_NUCLEO_WB55_USB_DONGLE.upload.maximum_size=524288
Nucleo_64.menu.pnum.P_NUCLEO_WB55_USB_DONGLE.upload.maximum_data_size=196608
Nucleo_64.menu.pnum.P_NUCLEO_WB55_USB_DONGLE.build.mcu=cortex-m4
Nucleo_64.menu.pnum.P_NUCLEO_WB55_USB_DONGLE.build.fpu=-mfpu=fpv4-sp-d16
Nucleo_64.menu.pnum.P_NUCLEO_WB55_USB_DONGLE.build.float-abi=-mfloat-abi=hard
Nucleo_64.menu.pnum.P_NUCLEO_WB55_USB_DONGLE.build.board=P_NUCLEO_WB55_USB_DONGLE
Nucleo_64.menu.pnum.P_NUCLEO_WB55_USB_DONGLE.build.series=STM32WBxx
Nucleo_64.menu.pnum.P_NUCLEO_WB55_USB_DONGLE.build.product_line=STM32WB55xx
Nucleo_64.menu.pnum.P_NUCLEO_WB55_USB_DONGLE.build.variant=STM32WBxx/WB35C(C-E)UxA_WB55C(C-E-G)U
Nucleo_64.menu.pnum.P_NUCLEO_WB55_USB_DONGLE.build.cmsis_lib_gcc=arm_cortexM4lf_math

# NUCLEO_WL55JC1 board
Nucleo_64.menu.pnum.NUCLEO_WL55JC1=Nucleo WL55JC1
Nucleo_64.menu.pnum.NUCLEO_WL55JC1.node="NOD_WL55JC"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/*
*******************************************************************************
* Copyright (c) 2023, 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
*
*******************************************************************************
*/
#if defined(ARDUINO_P_NUCLEO_WB55_USB_DONGLE)
#include "pins_arduino.h"
#include "lock_resource.h"

// Digital PinName array
const PinName digitalPin[] = {
// CN1
PA_13,
PA_14,
PB_3,
PB_2,
PA_5,
PA_6,
PA_7,
// CN2
PB_8,
PB_9,
PA_0,
PA_2,
PA_3,
PB_6,
PA_9,
PA_8,
PA_1,
PB_7,
// Specific
PC_14,
PC_15,
PH_3,
PA_4,
PB_0,
PB_1,
PA_10,
PA_11,
PA_12
};

// Analog (Ax) pin number array
const uint32_t analogInputPin[] = {
4, // A0
5, // A1
6, // A2
9, // A3
10, // A4
11, // A5
13, // A6
14, // A7
15 // A8
};

// ----------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief System Clock Configuration
* @param None
* @retval None
*/
WEAK void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {};

/* This prevents concurrent access to RCC registers by CPU2 (M0+) */
hsem_lock(CFG_HW_RCC_SEMID, HSEM_LOCK_DEFAULT_RETRY);

/* Macro to configure the PLL multiplication factor */
__HAL_RCC_PLL_PLLM_CONFIG(RCC_PLLM_DIV2);

/* Macro to configure the PLL clock source */
__HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE);

__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_MEDIUMHIGH);
/* Configure the main internal regulator output voltage */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

/* This prevents the CPU2 (M0+) to disable the HSI48 oscillator */
hsem_lock(CFG_HW_CLK48_CONFIG_SEMID, HSEM_LOCK_DEFAULT_RETRY);

/* Initializes the CPU, AHB and APB busses clocks */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSI
| RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
Error_Handler();
}

/* Configure the SYSCLKSource, HCLK, PCLK1 and PCLK2 clocks dividers */
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK4 | RCC_CLOCKTYPE_HCLK2
| RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.AHBCLK2Divider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.AHBCLK4Divider = RCC_SYSCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
Error_Handler();
}

/* Initializes the peripherals clocks */
/* RNG needs to be configured like in M0 core, i.e. with HSI48 */
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SMPS | RCC_PERIPHCLK_RFWAKEUP
| RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_USB;
PeriphClkInitStruct.RFWakeUpClockSelection = RCC_RFWKPCLKSOURCE_LSE;
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_HSI48;
PeriphClkInitStruct.SmpsClockSelection = RCC_SMPSCLKSOURCE_HSE;
PeriphClkInitStruct.SmpsDivSelection = RCC_SMPSCLKDIV_RANGE0;
PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;

if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
Error_Handler();
}

LL_PWR_SMPS_SetStartupCurrent(LL_PWR_SMPS_STARTUP_CURRENT_80MA);
LL_PWR_SMPS_SetOutputVoltageLevel(LL_PWR_SMPS_OUTPUT_VOLTAGE_1V40);
LL_PWR_SMPS_Enable();

/* Select HSI as system clock source after Wake Up from Stop mode */
LL_RCC_SetClkAfterWakeFromStop(LL_RCC_STOP_WAKEUPCLOCK_HSI);

hsem_unlock(CFG_HW_RCC_SEMID);
}

#ifdef __cplusplus
}
#endif
#endif /* ARDUINO_P_NUCLEO_WB55_USB_DONGLE* */
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/*
*******************************************************************************
* Copyright (c) 2023, 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
*
*******************************************************************************
*/
#pragma once

/*----------------------------------------------------------------------------
* STM32 pins number
*----------------------------------------------------------------------------*/
// CN1
#define PA13 0 // SWDIO
#define PA14 1 // SWCLK
#define PB3 2 // SWO
#define PB2 3 // SPI1 NSS
#define PA5 PIN_A0 // SPI1 SCK
#define PA6 PIN_A1 // SPI1 MISO
#define PA7 PIN_A2 // SPI1 MOSI
// CN2
#define PB8 7 // I2C1 SCL
#define PB9 8 // I2C1 SDA
#define PA0 PIN_A3 // WKUP
#define PA2 PIN_A4 // LPUART1 TX
#define PA3 PIN_A5 // LPUART1 RX
#define PB6 12
#define PA9 PIN_A6 // SB2 close/SB6 open (default)
#define PA8 PIN_A7
#define PA1 PIN_A8
// Same position than PA9 on CN2
#define PB7 16 // SB2 open/SB6 close
// Specific
#define PC14 17 // OSC32-IN
#define PC15 18 // OSC32-OUT
#define PH3 19 // BOOT0
#define PA4 20 // LED1 BLUE
#define PB0 21 // LED2 GREEN
#define PB1 22 // LED3 RED
#define PA10 23 // USER_BTN
#define PA11 24 // USB_DM
#define PA12 25 // USB_DP

// Not connected
// PA15
// PB4
// PB5
// PE4

// Alternate pins number
#define PA7_ALT1 (PA7 | ALT1)
#define PB8_ALT1 (PB8 | ALT1)
#define PB9_ALT1 (PB9 | ALT1)

#define NUM_DIGITAL_PINS 26
#define NUM_ANALOG_INPUTS 9

// On-board LED pin number
#define LED1 PA4
#define LED2 PB0
#define LED3 PB1
#ifndef LED_BUILTIN
#define LED_BUILTIN LED1
#endif
#define LED_BLUE LED1
#define LED_GREEN LED2
#define LED_RED LED3

// On-board user button
// Note: use '_BTN' for SW1 as it is a register name of M24SR64-Y
#define SW1_BTN PA10
#ifndef USER_BTN
#define USER_BTN SW1_BTN
#endif

// SPI definitions
#ifndef PIN_SPI_SS
#define PIN_SPI_SS PB2
#endif
#ifndef PIN_SPI_SS1
#define PIN_SPI_SS1 PB6
#endif
#ifndef PIN_SPI_SS2
#define PIN_SPI_SS2 PA8
#endif
#ifndef PIN_SPI_SS3
#define PIN_SPI_SS3 PNUM_NOT_DEFINED
#endif
#ifndef PIN_SPI_MOSI
#define PIN_SPI_MOSI PA7
#endif
#ifndef PIN_SPI_MISO
#define PIN_SPI_MISO PA6
#endif
#ifndef PIN_SPI_SCK
#define PIN_SPI_SCK PA5
#endif

// I2C definitions
#ifndef PIN_WIRE_SDA
#define PIN_WIRE_SDA PB9
#endif
#ifndef PIN_WIRE_SCL
#define PIN_WIRE_SCL PB8
#endif

// Timer Definitions
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
#ifndef TIMER_TONE
#define TIMER_TONE TIM16
#endif
#ifndef TIMER_SERVO
#define TIMER_SERVO TIM17
#endif

// UART Definitions
#ifndef SERIAL_UART_INSTANCE
#define SERIAL_UART_INSTANCE 101
#endif

// Default pin used for generic 'Serial' instance
// Mandatory for Firmata
#ifndef PIN_SERIAL_RX
#define PIN_SERIAL_RX PA3
#endif
#ifndef PIN_SERIAL_TX
#define PIN_SERIAL_TX PA2
#endif

// Extra HAL modules
#if !defined(HAL_QSPI_MODULE_DISABLED)
#define HAL_QSPI_MODULE_ENABLED
#endif

/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/

#ifdef __cplusplus
// These serial port names are intended to allow libraries and architecture-neutral
// sketches to automatically default to the correct port name for a particular type
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
//
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
//
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
//
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
//
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
//
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
// pins are NOT connected to anything by default.
#ifndef SERIAL_PORT_MONITOR
#define SERIAL_PORT_MONITOR Serial
#endif
#ifndef SERIAL_PORT_HARDWARE
#define SERIAL_PORT_HARDWARE Serial
#endif
#endif

0 comments on commit ceb3beb

Please sign in to comment.