Skip to content

variant: WB: add STM32WB5MM-DK #1441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
| :green_heart: | STM32L475VG | [B-L475E-IOT01A](http://www.st.com/en/evaluation-tools/b-l475e-iot01a.html) | *1.0.1* | |
| :green_heart: | STM32F413ZH | [32F413HDISCOVERY](https://www.st.com/en/evaluation-tools/32f413hdiscovery.html) | *1.9.0* | |
| :green_heart: | STM32L4S5VI | [B-L4S5I-IOT01A](https://www.st.com/en/evaluation-tools/b-l4s5i-iot01a.html) | *2.0.0* | |
| :yellow_heart: | STM32WB5MMG | [STM32WB5MM-DK](https://www.st.com/en/evaluation-tools/stm32wb5mm-dk.html) | **2.1.0** | |

### [Eval](https://www.st.com/en/evaluation-tools/stm32-eval-boards.html) boards

Expand Down Expand Up @@ -407,6 +408,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
| Status | Device(s) | Name | Release | Notes |
| :----: | :-------: | ---- | :-----: | :---- |
| :green_heart: | STM32WB55CC<br>STM32WB55CE<br>STM32WB55CG | Generic Board | *2.0.0* | |
| :yellow_heart: | STM32WB5MMG | Generic Board | **2.1.0** | |
| :green_heart: | STM32WB55RC<br>STM32WB55RE<br>STM32WB55RG | Generic Board | *2.0.0* | |

### Generic STM32WL boards
Expand Down
22 changes: 22 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,20 @@ Disco.menu.pnum.B_L072Z_LRWAN1.build.peripheral_pins=-DCUSTOM_PERIPHERAL_PINS
Disco.menu.pnum.B_L072Z_LRWAN1.build.cmsis_lib_gcc=arm_cortexM0l_math
Disco.menu.pnum.B_L072Z_LRWAN1.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} -D__CORTEX_SC=0

# STM32WB5MM-DK board
Disco.menu.pnum.STM32WB5MM_DK=STM32WB5MM-DK
Disco.menu.pnum.STM32WB5MM_DK.node="DIS_WB5MMG"
Disco.menu.pnum.STM32WB5MM_DK.upload.maximum_size=827392
Disco.menu.pnum.STM32WB5MM_DK.upload.maximum_data_size=196608
Disco.menu.pnum.STM32WB5MM_DK.build.mcu=cortex-m4
Disco.menu.pnum.STM32WB5MM_DK.build.flags.fp=-mfpu=fpv4-sp-d16 -mfloat-abi=hard
Disco.menu.pnum.STM32WB5MM_DK.build.board=STM32WB5MM_DK
Disco.menu.pnum.STM32WB5MM_DK.build.series=STM32WBxx
Disco.menu.pnum.STM32WB5MM_DK.build.product_line=STM32WB5Mxx
Disco.menu.pnum.STM32WB5MM_DK.build.variant=STM32WBxx/WB5MMGH
Disco.menu.pnum.STM32WB5MM_DK.build.peripheral_pins=-DCUSTOM_PERIPHERAL_PINS
Disco.menu.pnum.STM32WB5MM_DK.build.cmsis_lib_gcc=arm_cortexM4lf_math

# Upload menu
Disco.menu.upload_method.MassStorage=Mass Storage
Disco.menu.upload_method.MassStorage.upload.protocol=
Expand Down Expand Up @@ -4948,6 +4962,14 @@ GenWB.menu.pnum.GENERIC_WB55CGUX.build.board=GENERIC_WB55CGUX
GenWB.menu.pnum.GENERIC_WB55CGUX.build.product_line=STM32WB55xx
GenWB.menu.pnum.GENERIC_WB55CGUX.build.variant=STM32WBxx/WB55C(C-E-G)U

# Generic WB5MMGHx
GenWB.menu.pnum.GENERIC_WB5MMGHX=Generic WB5MMGHx
GenWB.menu.pnum.GENERIC_WB5MMGHX.upload.maximum_size=827392
GenWB.menu.pnum.GENERIC_WB5MMGHX.upload.maximum_data_size=196608
GenWB.menu.pnum.GENERIC_WB5MMGHX.build.board=GENERIC_WB5MMGHX
GenWB.menu.pnum.GENERIC_WB5MMGHX.build.product_line=STM32WB5Mxx
GenWB.menu.pnum.GENERIC_WB5MMGHX.build.variant=STM32WBxx/WB5MMGH

# Generic WB55RCVx
GenWB.menu.pnum.GENERIC_WB55RCVX=Generic WB55RCVx
GenWB.menu.pnum.GENERIC_WB55RCVX.upload.maximum_size=131072
Expand Down
29 changes: 29 additions & 0 deletions cores/arduino/stm32/lock_resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,41 @@ typedef enum {
* HW semaphore Complement ID list defined in hw_conf.h from STM32WB.
* They could be used also for H7 dualcore targets.
*/

/**
* The CPU2 may be configured to store the Thread persistent data either in internal NVM storage on CPU2 or in
* SRAM2 buffer provided by the user application. This can be configured with the system command SHCI_C2_Config()
* When the CPU2 is requested to store persistent data in SRAM2, it can write data in this buffer at any time when needed.
* In order to read consistent data with the CPU1 from the SRAM2 buffer, the flow should be:
* + CPU1 takes CFG_HW_THREAD_NVM_SRAM_SEMID semaphore
* + CPU1 reads all persistent data from SRAM2 (most of the time, the goal is to write these data into an NVM managed by CPU1)
* + CPU1 releases CFG_HW_THREAD_NVM_SRAM_SEMID semaphore
* CFG_HW_THREAD_NVM_SRAM_SEMID semaphore makes sure CPU2 does not update the persistent data in SRAM2 at the same time CPU1 is reading them.
* There is no timing constraint on how long this semaphore can be kept.
*/
#define CFG_HW_THREAD_NVM_SRAM_SEMID 9

/**
* The CPU2 may be configured to store the BLE persistent data either in internal NVM storage on CPU2 or in
* SRAM2 buffer provided by the user application. This can be configured with the system command SHCI_C2_Config()
* When the CPU2 is requested to store persistent data in SRAM2, it can write data in this buffer at any time when needed.
* In order to read consistent data with the CPU1 from the SRAM2 buffer, the flow should be:
* + CPU1 takes CFG_HW_BLE_NVM_SRAM_SEMID semaphore
* + CPU1 reads all persistent data from SRAM2 (most of the time, the goal is to write these data into an NVM managed by CPU1)
* + CPU1 releases CFG_HW_BLE_NVM_SRAM_SEMID semaphore
* CFG_HW_BLE_NVM_SRAM_SEMID semaphore makes sure CPU2 does not update the persistent data in SRAM2 at the same time CPU1 is reading them.
* There is no timing constraint on how long this semaphore can be kept.
*/
#define CFG_HW_BLE_NVM_SRAM_SEMID 8

/*
* Index of the semaphore used by CPU2 to prevent the CPU1 to either write or
* erase data in flash. The CPU1 shall not either write or erase in flash when
* this semaphore is taken by the CPU2. When the CPU1 needs to either write or
* erase in flash, it shall first get the semaphore and release it just
* after writing a raw (64bits data) or erasing one sector.
* Once the Semaphore has been released, there shall be at least 1us before it can be taken again. This is required
* to give the opportunity to CPU2 to take it.
* On v1.4.0 and older CPU2 wireless firmware, this semaphore is unused and
* CPU2 is using PES bit. By default, CPU2 is using the PES bit to protect its
* timing. The CPU1 may request the CPU2 to use the semaphore instead of the
Expand Down
2 changes: 1 addition & 1 deletion libraries/IWatchdog/src/IWatchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void IWatchdogClass::begin(uint32_t timeout, uint32_t window)
}

// Enable the peripheral clock IWDG
#ifdef STM32WBxx
#ifdef RCC_CSR_LSI1ON
LL_RCC_LSI1_Enable();
while (LL_RCC_LSI1_IsReady() != 1) {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
RGB_LED_TLC59731

This example code is in the public domain.

Blink one RGB LED with different default colors:
RGB_LED_TLC59731::OFF
RGB_LED_TLC59731::RED
RGB_LED_TLC59731::GREEN
RGB_LED_TLC59731::BLUE
RGB_LED_TLC59731::MAGENTA
RGB_LED_TLC59731::CYAN
RGB_LED_TLC59731::YELLOW
RGB_LED_TLC59731::WHITE
*/

#include <RGB_LED_TLC59731.h>

static uint8_t step = 0;
static uint8_t* sequence[] = { RGB_LED_TLC59731::RED,
RGB_LED_TLC59731::GREEN,
RGB_LED_TLC59731::BLUE,
RGB_LED_TLC59731::MAGENTA,
RGB_LED_TLC59731::CYAN,
RGB_LED_TLC59731::YELLOW,
RGB_LED_TLC59731::WHITE
};
/**
STM32WB5MM-DK have an RGB LED connected to TLC59731
It requires to enable it thanks LED_SELECT pin
and to have JP5 on and JP4 off
*/
#if defined(RGB_LED) && defined(LED_SELECT)
RGB_LED_TLC59731 LED(RGB_LED, LED_SELECT);
#else
RGB_LED_TLC59731 LED;
#endif

void setup() {
/* Change Brightness */
LED.setBrightness(0x10);
}

void loop() {
/* Blink */
LED.on(sequence[step]);
delay(500);
LED.off();
delay(500);
step = (step == 6) ? 0 : step + 1;
}
31 changes: 31 additions & 0 deletions libraries/RGB_LED_TLC59731/keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#######################################
# Syntax Coloring Map For RGB_LED_TLC59731
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

RGB_LED_TLC59731 KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################

on KEYWORD2
off KEYWORD2
getBrightness KEYWORD2
setBrightness KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################

OFF LITERAL1
RED LITERAL1
GREEN LITERAL1
BLUE LITERAL1
MAGENTA LITERAL1
CYAN LITERAL1
YELLOW LITERAL1
WHITE LITERAL
9 changes: 9 additions & 0 deletions libraries/RGB_LED_TLC59731/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=RGB LED TLC59731
version=1.0.0
author=Frederic Pillon
maintainer=stm32duino
sentence=Allows to control one RGB LED driven by TLC59731 PWM LED Driver
paragraph=Control one RGB LED driven by TLC59731 PWM LED Driver
category=Signal Input/Output
url=https://github.com/stm32duino/Arduino_Core_STM32/tree/master/libraries/RGB_LED_TLC59731
architectures=stm32
142 changes: 142 additions & 0 deletions libraries/RGB_LED_TLC59731/src/RGB_LED_TLC59731.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
*******************************************************************************
* Copyright (c) 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
*
*******************************************************************************
*/
#include "RGB_LED_TLC59731.h"

#define WRITE_COMMAND 0x3A
#ifndef DEFAULT_BRIGHTNESS
#define DEFAULT_BRIGHTNESS 0x41
#endif
uint8_t RGB_LED_TLC59731::brightness = DEFAULT_BRIGHTNESS;
uint8_t RGB_LED_TLC59731::OFF[3] = {0, 0, 0 };
uint8_t RGB_LED_TLC59731::RED[3] = {DEFAULT_BRIGHTNESS, 0, 0 };
uint8_t RGB_LED_TLC59731::GREEN[3] = {0, DEFAULT_BRIGHTNESS, 0 };
uint8_t RGB_LED_TLC59731::BLUE[3] = {0, 0, DEFAULT_BRIGHTNESS};
uint8_t RGB_LED_TLC59731::MAGENTA[3] = {DEFAULT_BRIGHTNESS, 0, DEFAULT_BRIGHTNESS};
uint8_t RGB_LED_TLC59731::CYAN[3] = {0, DEFAULT_BRIGHTNESS, DEFAULT_BRIGHTNESS};
uint8_t RGB_LED_TLC59731::YELLOW[3] = {DEFAULT_BRIGHTNESS, DEFAULT_BRIGHTNESS, 0 };
uint8_t RGB_LED_TLC59731::WHITE[3] = {DEFAULT_BRIGHTNESS, DEFAULT_BRIGHTNESS, DEFAULT_BRIGHTNESS};

/**
* @brief Set RGB LED color
* @param rgb[3]: red,green, blue value in range [0-255]
* @retval None
*/
void RGB_LED_TLC59731::on(uint8_t rgb[3])
{
on(rgb[0], rgb[1], rgb[2]);
}

/**
* @brief Set RGB LED color
* @param red: red value in range [0-255]
* @param green: green value in range [0-255]
* @param blue: blue value in range [0-255]
* @retval None
*/
void RGB_LED_TLC59731::on(uint8_t red, uint8_t green, uint8_t blue)
{
if (!_enabled) {
if (_enable_pin != NC) {
pinMode(pinNametoDigitalPin(_enable_pin), OUTPUT);
digitalWriteFast(_enable_pin, HIGH);
}

pinMode(pinNametoDigitalPin(_rgb_pin), OUTPUT);
_enabled = true;
}
/* Data Transfer Rate (T_CYCLE) Measurement Sequence */
digitalWriteFast(_rgb_pin, HIGH);
delayMicroseconds(_T_Rise);
digitalWriteFast(_rgb_pin, LOW);
delayMicroseconds(_T_Cycle0);
/* Write command */
senByte(WRITE_COMMAND);
/* Write the GS data */
senByte(red);
senByte(green);
senByte(blue);
/* GS Latch */
delayMicroseconds(_T_GS_Lat);
}

/**
* @brief Set RGB LED Off
* @param None
* @retval None
*/
void RGB_LED_TLC59731::off(void)
{
/* Set RGB LED off value */
on(RGB_LED_TLC59731::OFF);
pinMode(pinNametoDigitalPin(_rgb_pin), INPUT_ANALOG);

if (_enable_pin != NC) {
digitalWriteFast(_enable_pin, LOW);
pinMode(pinNametoDigitalPin(_enable_pin), INPUT_ANALOG);
_enabled = false;
}
}

/**
* @brief Set brightness value
* @param value: new brightness value
* @retval None
*/
void RGB_LED_TLC59731::setBrightness(uint8_t value)
{
RGB_LED_TLC59731::brightness = value;
RGB_LED_TLC59731::RED[0] = value;
RGB_LED_TLC59731::GREEN[1] = value;
RGB_LED_TLC59731::BLUE[2] = value;
RGB_LED_TLC59731::MAGENTA[0] = value;
RGB_LED_TLC59731::MAGENTA[2] = value;
RGB_LED_TLC59731::CYAN[1] = value;
RGB_LED_TLC59731::CYAN[2] = value;
RGB_LED_TLC59731::YELLOW[0] = value;
RGB_LED_TLC59731::YELLOW[1] = value;
RGB_LED_TLC59731::WHITE[0] = value;
RGB_LED_TLC59731::WHITE[1] = value;
RGB_LED_TLC59731::WHITE[2] = value;
}

/* Private */
void RGB_LED_TLC59731::sendBit(uint8_t bit)
{
/* Start next cycle */
digitalWriteFast(_rgb_pin, HIGH);
delayMicroseconds(_T_Rise);
digitalWriteFast(_rgb_pin, LOW);
delayMicroseconds(_T_Rise);

if (bit) {
digitalWriteFast(_rgb_pin, HIGH);
delayMicroseconds(_T_Rise);
digitalWriteFast(_rgb_pin, LOW);
delayMicroseconds(_T_Cycle1);
} else {
delayMicroseconds(_T_Cycle0);
}
}


void RGB_LED_TLC59731::senByte(uint8_t byte)
{
sendBit(byte & (1 << 7));
sendBit(byte & (1 << 6));
sendBit(byte & (1 << 5));
sendBit(byte & (1 << 4));
sendBit(byte & (1 << 3));
sendBit(byte & (1 << 2));
sendBit(byte & (1 << 1));
sendBit(byte & (1 << 0));
}
57 changes: 57 additions & 0 deletions libraries/RGB_LED_TLC59731/src/RGB_LED_TLC59731.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
*******************************************************************************
* Copyright (c) 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
*
*******************************************************************************
*/
#ifndef __RGB_LED_TLC59731_H__
#define __RGB_LED_TLC59731_H__

#include "Arduino.h"

class RGB_LED_TLC59731 {

public:
RGB_LED_TLC59731(uint32_t rgb_pin = LED_BUILTIN, uint32_t enable_pin = NC):
_rgb_pin(digitalPinToPinName(rgb_pin)), _enable_pin(digitalPinToPinName(enable_pin)) {};
void on(uint8_t rgb[3]);
void on(uint8_t red, uint8_t green, uint8_t blue);
void off(void);
inline uint8_t getBrightness(void)
{
return brightness;
}
void setBrightness(uint8_t value);

static uint8_t brightness;
static uint8_t OFF[3];
static uint8_t RED[3];
static uint8_t GREEN[3];
static uint8_t BLUE[3];
static uint8_t MAGENTA[3];
static uint8_t CYAN[3];
static uint8_t YELLOW[3];
static uint8_t WHITE[3];

private:
PinName _rgb_pin;
PinName _enable_pin;

bool _enabled{false};
const uint32_t _T_Rise{1};
const uint32_t _T_Cycle0{4};
const uint32_t _T_Cycle1{1};
// GS Data Latch (GSLAT) Sequence delay
const uint32_t _T_GS_Lat{_T_Cycle0 * 8};

void sendBit(uint8_t bit);
void senByte(uint8_t byte);
};

#endif /* __RGB_LED_TLC59731_H__ */
Loading