first commit

This commit is contained in:
YunHorn Technology 2022-09-29 20:47:09 +08:00
commit 8b3f629004
16 changed files with 3488 additions and 0 deletions

6
LICENSE.txt Normal file
View File

@ -0,0 +1,6 @@
This software component is provided to you as part of a software package and
applicable license terms are in the Package_license file. If you received this
software component outside of a package or without applicable license terms,
the terms of the BSD-3-Clause license shall apply.
You may obtain a copy of the BSD-3-Clause at:
https://opensource.org/licenses/BSD-3-Clause

36
README.md Normal file
View File

@ -0,0 +1,36 @@
# BSP STM32WLXX-NUCLEO Component
![latest tag](https://img.shields.io/github/v/tag/STMicroelectronics/stm32wlxx-nucleo.svg?color=brightgreen)
## Overview
**STM32Cube** is an STMicroelectronics original initiative to ease developers' life by reducing efforts, time and cost.
**STM32Cube** covers the overall STM32 products portfolio. It includes a comprehensive embedded software platform delivered for each STM32 series.
* The CMSIS modules (core and device) corresponding to the ARM(tm) core implemented in this STM32 product.
* The STM32 HAL-LL drivers, an abstraction layer offering a set of APIs ensuring maximized portability across the STM32 portfolio.
* The BSP drivers of each evaluation, demonstration or nucleo board provided for this STM32 series.
* A consistent set of middleware libraries such as RTOS, USB, FatFS, graphics, touch sensing library...
* A full set of software projects (basic examples, applications, and demonstrations) for each board provided for this STM32 series.
Two models of publication are proposed for the STM32Cube embedded software:
* The monolithic **MCU Package**: all STM32Cube software modules of one STM32 series are present (Drivers, Middleware, Projects, Utilities) in the repository (usual name **STM32Cubexx**, xx corresponding to the STM32 series).
* The **MCU component**: each STM32Cube software module being part of the STM32Cube MCU Package, is delivered as an individual repository, allowing the user to select and get only the required software functions.
## Description
This **stm32wlxx-nucleo** MCU component repository is one element of the **STM32CubeWL** MCU embedded software package, providing the **STM32WLXX-NUCLEO** BSP BOARD component part.
## Release note
Details about the content of this release are available in the release note [here](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/stm32wlxx-nucleo/blob/main/Release_Notes.html).
## Compatibility information
Below is the list of the BSP *component* drivers to be used with this BSP *board* driver. It is **crucial** that you use a consistent set of CMSIS - HAL - BSP versions, as mentioned in [this](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/STM32CubeWL/blob/main/Release_Notes.html) release note.
* [stm32-bsp-common](https://github.com/STMicroelectronics/stm32-bsp-common)
## Troubleshooting
Please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) guide.

105
Release_Notes.html Normal file
View File

@ -0,0 +1,105 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for STM32WLxx_Nucleo</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="_htmresc/mini-st_2020.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
<link rel="icon" type="image/x-icon" href="_htmresc/favicon.png" />
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<center>
<h1 id="release-notes-for">Release Notes for</h1>
<h1 id="stm32wlxx_nucleo"><mark>STM32WLxx_Nucleo</mark></h1>
<p>Copyright © 2020 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="_htmresc/st_logo_2020.png" alt="ST logo" /></a>
</center>
<h1 id="purpose">Purpose</h1>
<p>This driver provides a set of functions to manage:</p>
<ul>
<li>RF Switches, LEDs and push-button available on STM32WLxx_Nucleo Kit from STMicroelectronics</li>
</ul>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section3" checked aria-hidden="true"> <label for="collapse-section3" aria-hidden="true"><strong>V1.2.0 / 4-February-2022</strong></label>
<div>
<h2 id="main-changes">Main Changes</h2>
<p><strong>Maintenance Release</strong></p>
<h2 id="contents">Contents</h2>
<ul>
<li>All source files and templates: update disclaimer to add reference to the new license agreement</li>
<li>Add README.md file</li>
<li>Rename BSP_BUTTON_SWx_IT_PRIORITY constant to BSP_BUTTON_USER_IT_PRIORITY</li>
<li>Add new interface BSP_RADIO_GetRFOMaxPowerConfig to get the RFO Max Power configuration</li>
</ul>
<h2 id="known-limitations">Known Limitations</h2>
<p>None</p>
<h2 id="dependencies">Dependencies</h2>
<p>None</p>
<h2 id="notes">Notes</h2>
<p>stm32wlxx_nucleo_conf_template.h file must be copied in user application as stm32wlxx_nucleo_conf.h with optional configuration update</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section2" aria-hidden="true"> <label for="collapse-section2" aria-hidden="true"><strong>V1.1.0 / 16-June-2021</strong></label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<p><strong>Maintenance Release</strong></p>
<h2 id="contents-1">Contents</h2>
<ul>
<li>Move some radio definitions (TCXO, DSDC) from stm32wlxx_nucleo_conf.h to stm32wlxx_nucleo_radio.h</li>
<li>Add 2 interfaces to check BSP_RADIO_IsTCXO and BSP_RADIO_IsDCDC definitions</li>
<li>Remove radio API BSP_RADIO_GetWakeUpTime from stm32wlxx_nucleo_radio.c</li>
</ul>
<h2 id="known-limitations-1">Known Limitations</h2>
<p>None</p>
<h2 id="dependencies-1">Dependencies</h2>
<p>None</p>
<h2 id="notes-1">Notes</h2>
<p>stm32wlxx_nucleo_conf_template.h file must be copied in user application as stm32wlxx_nucleo_conf.h with optional configuration update</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section1" aria-hidden="true"> <label for="collapse-section1" aria-hidden="true"><strong>V1.0.0 / 28-October-2020</strong></label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<p><strong>First Official Release</strong></p>
<h2 id="contents-2">Contents</h2>
<p>First official release of board drivers for <strong>NUCLEO-WL55JC board (MB1389 C-01)</strong> in line with STM32Cube BSP drivers development guidelines (UM2298 - revision 2)</p>
<h2 id="known-limitations-2">Known Limitations</h2>
<p>None</p>
<h2 id="dependencies-2">Dependencies</h2>
<p>None</p>
<h2 id="notes-2">Notes</h2>
<p>stm32wlxx_nucleo_conf_template.h file must be copied in user application as stm32wlxx_nucleo_conf.h with optional configuration update</p>
</div>
</div>
</div>
</div>
<footer class="sticky">
<div class="columns">
<div class="column" style="width:95%;">
<p>For complete documentation on STM32WLxx, visit: <a href="http://www.st.com/stm32wl">www.st.com/stm32wl</a></p>
<p><em>This release note uses up to date web standards and, for this reason, should not be opened with Internet Explorer but preferably with popular browsers such as Google Chrome, Mozilla Firefox, Opera or Microsoft Edge.</em></p>
</div><div class="column" style="width:5%;">
<p><abbr title="Based on template cx566953 version 2.0">Info</abbr></p>
</div>
</div>
</footer>
</body>
</html>

Binary file not shown.

2
_htmresc/Add button.svg Normal file
View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#13254a"><path d="M100 .212C44.868.212 0 44.889 0 99.788c0 55.132 44.868 100 100 100s100-44.868 100-100C200 44.889 155.132.212 100 .212zm0 181.164c-44.974 0-81.587-36.614-81.587-81.587 0-44.762 36.614-81.164 81.587-81.164 44.995 0 81.587 36.402 81.587 81.164 0 44.973-36.592 81.587-81.587 81.587z" style="fill: #e6007e;"/><path d="M141.1 88.127h-29.439V58.688c0-6.392-5.185-11.598-11.598-11.598-6.413 0-11.619 5.206-11.619 11.598v29.439H58.476c-6.392 0-11.598 5.185-11.598 11.598 0 6.413 5.206 11.619 11.598 11.619h29.968v29.968c0 6.392 5.206 11.598 11.619 11.598 6.413 0 11.598-5.206 11.598-11.598v-29.968H141.1c6.392 0 11.598-5.206 11.598-11.619 0-6.413-5.206-11.598-11.598-11.598z" style="fill: #e6007e;"/></g></svg>

After

Width:  |  Height:  |  Size: 830 B

2
_htmresc/Update.svg Normal file
View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#03234b"><path d="M170.934 64.569l-.04-.055-29.049 40.038-.057.079h14.867a59.366 59.366 0 0 1-1.488 15.615c-1.158 5.318-3.807 13.448-9.848 21.977-2.766 4.118-6.375 7.726-9.208 10.408-3.426 2.857-7.461 6.095-12 8.376-8.121 4.568-17.881 7.138-28.225 7.432-10.907.248-20.201-2.61-26.072-5.052-8.283-3.479-14.111-7.807-16.85-10.078-1.254-.956-2.25-1.907-3.057-2.676a28.662 28.662 0 0 0-1.157-1.069 158.874 158.874 0 0 0-1.479-1.362l-4.435-3.956 3.569 4.81.183.243c.2.263.548.722 1.048 1.389.276.334.579.747.93 1.226l.008.01c.689.939 1.546 2.107 2.664 3.322 3 3.536 8.178 8.801 15.808 13.801 5.969 3.866 15.672 8.901 28.001 10.935a79.05 79.05 0 0 0 12.485.998c7.97 0 15.651-1.228 22.828-3.649 6.366-1.877 12.192-4.981 17.053-7.771 6.16-3.936 10.817-7.586 14.654-11.488 8.084-7.899 14.884-17.913 19.15-28.199 3.259-7.594 5.456-15.727 6.529-24.175l.055-.425.083-.641H200l-29.066-40.063zM58.159 99.232l-12.655.563c-.097-.881-.159-1.986-.227-3.474a59.184 59.184 0 0 1 1.446-16.56c1.157-5.316 3.804-13.444 9.848-21.977 2.168-3.228 5.009-6.44 9.208-10.415 3.41-2.849 7.432-6.08 12.005-8.375 8.114-4.568 17.87-7.138 28.213-7.432 10.9-.25 20.196 2.607 26.072 5.045 8.258 3.473 14.105 7.812 16.857 10.091 1.257.951 2.253 1.904 3.057 2.673l.017.016c.43.411.801.766 1.136 1.051.475.438.841.777 1.091 1.01l.138.128.248.229 4.04 3.613-3.165-4.456c-.058-.083-.312-.417-.73-.971l-.507-.67a28.922 28.922 0 0 1-.901-1.192l-.02-.027c-.69-.945-1.548-2.121-2.677-3.346-3.002-3.537-8.182-8.803-15.813-13.801-5.964-3.865-15.662-8.9-27.997-10.935-8.484-1.363-21.496-2.009-35.313 2.651-6.355 1.88-12.186 4.983-17.054 7.772-6.163 3.944-10.82 7.595-14.654 11.488-8.079 7.894-14.882 17.909-19.155 28.2-3.268 7.624-5.463 15.757-6.523 24.173-.436 3.281-.642 5.421-.664 6.926L0 101.831l30.683 38.727.042.053 27.38-41.298.054-.081z" style="fill: #e6007e;"/></g></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
_htmresc/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

1711
_htmresc/mini-st_2020.css Normal file

File diff suppressed because it is too large Load Diff

BIN
_htmresc/st_logo_2020.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

676
stm32wlxx_STS.c Normal file
View File

@ -0,0 +1,676 @@
/**
******************************************************************************
* @file stm32wlxx_STS.c
* @author MCD Application Team
* @brief This file provides set of firmware functions to manage:
* - LEDs and push-buttons available on STM32WLXX-Nucleo
* Kit from STMicroelectronics
******************************************************************************
* @attention
*
* Copyright (c) 2020-2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32wlxx_STS.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32WLXX_NUCLEO
* @{
*/
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL
* @brief This file provides set of firmware functions to manage LEDs and push-buttons
* on STM32WLXX-Nucleo Kit from STMicroelectronics.
* @{
*/
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Variables LOW LEVEL Exported Variables
* @{
*/
EXTI_HandleTypeDef hpb_exti[BUTTONn];
#if (USE_BSP_COM_FEATURE > 0)
UART_HandleTypeDef hcom_uart[COMn];
#endif /* (USE_BSP_COM_FEATURE > 0) */
/**
* @}
*/
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Private_Defines LOW LEVEL Private Defines
* @{
*/
/**
* @}
*/
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Private_TypesDefinitions LOW LEVEL Private Typedef
* @{
*/
typedef void (* BSP_EXTI_LineCallback) (void);
/**
* @}
*/
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Private_Variables LOW LEVEL Private Variables
* @{
*/
static GPIO_TypeDef* LED_PORT[LEDn] = {LED1_GPIO_PORT, LED2_GPIO_PORT, LED3_GPIO_PORT};
static const uint16_t LED_PIN[LEDn] = {LED1_PIN, LED2_PIN, LED3_PIN};
static GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {BUTTON_SW1_GPIO_PORT, BUTTON_SW2_GPIO_PORT, BUTTON_SW3_GPIO_PORT};
static const uint16_t BUTTON_PIN[BUTTONn] = {BUTTON_SW1_PIN, BUTTON_SW2_PIN, BUTTON_SW3_PIN};
static const IRQn_Type BUTTON_IRQn[BUTTONn] = {BUTTON_SW1_EXTI_IRQn, BUTTON_SW2_EXTI_IRQn, BUTTON_SW3_EXTI_IRQn};
#if (USE_BSP_COM_FEATURE > 0)
static USART_TypeDef* COM_USART[COMn] = {COM1_UART};
#if (USE_COM_LOG > 0)
static COM_TypeDef COM_ActiveLogPort = COM1;
#endif
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
static uint32_t IsComMspCbValid[COMn] = {0};
#endif
#endif /* (USE_BSP_COM_FEATURE > 0) */
/**
* @}
*/
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Private_Functions LOW LEVEL Private Functions
* @{
*/
static void BUTTON_SW1_EXTI_Callback(void);
static void BUTTON_SW2_EXTI_Callback(void);
static void BUTTON_SW3_EXTI_Callback(void);
#if (USE_BSP_COM_FEATURE > 0)
static void COM1_MspInit(UART_HandleTypeDef *huart);
static void COM1_MspDeInit(UART_HandleTypeDef *huart);
#endif /* (USE_BSP_COM_FEATURE > 0) */
/**
* @}
*/
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Functions
* @{
*/
/**
* @brief This method returns the STM32WLXX NUCLEO BSP Driver revision
* @retval version: 0xXYZR (8bits for each decimal, R for RC)
*/
uint32_t BSP_GetVersion(void)
{
return (int32_t)__STM32WLXX_NUCLEO_BSP_VERSION;
}
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL_LED_Functions
* @{
*/
/**
* @brief Configures LED GPIO.
* @param Led: LED to be configured.
* This parameter can be one of the following values:
* @arg LED1
* @arg LED2
* @arg LED3
* @retval BSP status
*/
int32_t BSP_LED_Init(Led_TypeDef Led)
{
GPIO_InitTypeDef gpio_init_structure = {0};
/* Enable the GPIO_LED Clock */
LEDx_GPIO_CLK_ENABLE(Led);
/* Configure the GPIO_LED pin */
gpio_init_structure.Pin = LED_PIN[Led];
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(LED_PORT[Led], &gpio_init_structure);
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
return BSP_ERROR_NONE;
}
/**
* @brief DeInit LEDs.
* @param Led: LED to be de-init.
* This parameter can be one of the following values:
* @arg LED1
* @arg LED2
* @arg LED3
* @note Led DeInit does not disable the GPIO clock nor disable the Mfx
* @retval BSP status
*/
int32_t BSP_LED_DeInit(Led_TypeDef Led)
{
/* Turn off LED */
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
/* DeInit the GPIO_LED pin */
HAL_GPIO_DeInit(LED_PORT[Led], LED_PIN[Led]);
return BSP_ERROR_NONE;
}
/**
* @brief Turns selected LED On.
* @param Led: Specifies the Led to be set on.
* This parameter can be one of the following values:
* @arg LED1
* @arg LED2
* @arg LED3
* @retval BSP status
*/
int32_t BSP_LED_On(Led_TypeDef Led)
{
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_SET);
return BSP_ERROR_NONE;
}
/**
* @brief Turns selected LED Off.
* @param Led: Specifies the Led to be set off.
* This parameter can be one of the following values:
* @arg LED1
* @arg LED2
* @arg LED3
* @retval BSP status
*/
int32_t BSP_LED_Off(Led_TypeDef Led)
{
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
return BSP_ERROR_NONE;
}
/**
* @brief Toggles the selected LED.
* @param Led: Specifies the Led to be toggled.
* This parameter can be one of the following values:
* @arg LED1
* @arg LED2
* @arg LED3
* @retval BSP status
*/
int32_t BSP_LED_Toggle(Led_TypeDef Led)
{
HAL_GPIO_TogglePin(LED_PORT[Led], LED_PIN[Led]);
return BSP_ERROR_NONE;
}
/**
* @brief Get the status of the selected LED.
* @param Led Specifies the Led to get its state.
* This parameter can be one of following parameters:
* @arg LED1
* @arg LED2
* @arg LED3
* @retval LED status
*/
int32_t BSP_LED_GetState(Led_TypeDef Led)
{
return (int32_t)HAL_GPIO_ReadPin(LED_PORT[Led], LED_PIN[Led]);
}
/**
* @}
*/
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL_BUTTON_Functions
* @{
*/
/**
* @brief Configures Button GPIO and EXTI Line.
* @param Button: Specifies the Button to be configured.
* This parameter can be one of following parameters:
* @arg BUTTON_SW1
* @arg BUTTON_SW2
* @arg BUTTON_SW3
* @param ButtonMode: Specifies Button mode.
* This parameter can be one of following parameters:
* @arg BUTTON_MODE_GPIO: Button will be used as simple IO
* @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt
* generation capability
* @retval BSP status
*/
int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
{
GPIO_InitTypeDef gpio_init_structure = {0};
static BSP_EXTI_LineCallback button_callback[BUTTONn] = {BUTTON_SW1_EXTI_Callback, BUTTON_SW2_EXTI_Callback, BUTTON_SW3_EXTI_Callback};
static uint32_t button_interrupt_priority[BUTTONn] = {BSP_BUTTON_USER_IT_PRIORITY, BSP_BUTTON_USER_IT_PRIORITY, BSP_BUTTON_USER_IT_PRIORITY};
static const uint32_t button_exti_line[BUTTONn] = {BUTTON_SW1_EXTI_LINE, BUTTON_SW2_EXTI_LINE, BUTTON_SW3_EXTI_LINE};
/* Enable the BUTTON Clock */
BUTTONx_GPIO_CLK_ENABLE(Button);
gpio_init_structure.Pin = BUTTON_PIN[Button];
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
if(ButtonMode == BUTTON_MODE_GPIO)
{
/* Configure Button pin as input */
gpio_init_structure.Mode = GPIO_MODE_INPUT;
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
}
else /* (ButtonMode == BUTTON_MODE_EXTI) */
{
/* Configure Button pin as input with External interrupt */
gpio_init_structure.Mode = GPIO_MODE_IT_FALLING;
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
(void)HAL_EXTI_GetHandle(&hpb_exti[Button], button_exti_line[Button]);
(void)HAL_EXTI_RegisterCallback(&hpb_exti[Button], HAL_EXTI_COMMON_CB_ID, button_callback[Button]);
/* Enable and set Button EXTI Interrupt to the lowest priority */
HAL_NVIC_SetPriority((BUTTON_IRQn[Button]), button_interrupt_priority[Button], 0x00);
HAL_NVIC_EnableIRQ((BUTTON_IRQn[Button]));
}
return BSP_ERROR_NONE;
}
/**
* @brief Push Button DeInit.
* @param Button: Button to be configured
* This parameter can be one of following parameters:
* @arg BUTTON_SW1
* @arg BUTTON_SW2
* @arg BUTTON_SW3
* @note PB DeInit does not disable the GPIO clock
* @retval BSP status
*/
int32_t BSP_PB_DeInit(Button_TypeDef Button)
{
HAL_NVIC_DisableIRQ((BUTTON_IRQn[Button]));
HAL_GPIO_DeInit(BUTTON_PORT[Button], BUTTON_PIN[Button]);
return BSP_ERROR_NONE;
}
/**
* @brief Returns the selected Button state.
* @param Button: Specifies the Button to be checked.
* This parameter can be one of following parameters:
* @arg BUTTON_SW1
* @arg BUTTON_SW2
* @arg BUTTON_SW3
* @retval The Button GPIO pin value.
*/
int32_t BSP_PB_GetState(Button_TypeDef Button)
{
return (int32_t)HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]);
}
/**
* @brief This function handles Push-Button interrupt requests.
* @param Button Specifies the pin connected EXTI line
* @retval None
*/
void BSP_PB_IRQHandler(Button_TypeDef Button)
{
HAL_EXTI_IRQHandler(&hpb_exti[Button]);
}
/**
* @brief BSP Push Button callback
* @param Button: Specifies the Button to be checked.
* This parameter can be one of following parameters:
* @arg BUTTON_SW1
* @arg BUTTON_SW2
* @arg BUTTON_SW3
* @retval None.
*/
__weak void BSP_PB_Callback(Button_TypeDef Button)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(Button);
/* This function should be implemented by the user application.
It is called into this driver when an event on Button is triggered. */
}
/**
* @}
*/
#if (USE_BSP_COM_FEATURE > 0)
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL_COM_Functions
* @{
*/
/**
* @brief Configures COM port.
* @param COM COM port to be configured.
* This parameter can be COM1
* @param COM_Init Pointer to a UART_HandleTypeDef structure that contains the
* configuration information for the specified USART peripheral.
* @retval BSP error code
*/
int32_t BSP_COM_Init(COM_TypeDef COM, COM_InitTypeDef *COM_Init)
{
int32_t ret = BSP_ERROR_NONE;
if(COM > COMn)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
#if (USE_HAL_UART_REGISTER_CALLBACKS == 0)
/* Init the UART Msp */
COM1_MspInit(&hcom_uart[COM]);
#else
if(IsComMspCbValid == 0U)
{
if(BSP_COM_RegisterDefaultMspCallbacks(COM) != BSP_ERROR_NONE)
{
return BSP_ERROR_MSP_FAILURE;
}
}
#endif
if(MX_LPUART1_Init(&hcom_uart[COM], COM_Init) != HAL_OK)
{
return BSP_ERROR_PERIPH_FAILURE;
}
}
return ret;
}
/**
* @brief DeInit COM port.
* @param COM COM port to be configured.
* This parameter can be COM1
* @retval BSP status
*/
int32_t BSP_COM_DeInit(COM_TypeDef COM)
{
int32_t ret = BSP_ERROR_NONE;
if(COM >= COMn)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
/* USART configuration */
hcom_uart[COM].Instance = COM_USART[COM];
#if (USE_HAL_UART_REGISTER_CALLBACKS == 0)
COM1_MspDeInit(&hcom_uart[COM]);
#endif /* (USE_HAL_UART_REGISTER_CALLBACKS == 0) */
if(HAL_UART_DeInit(&hcom_uart[COM]) != HAL_OK)
{
return BSP_ERROR_PERIPH_FAILURE;
}
}
return ret;
}
/**
* @brief Configures COM port.
* @param huart USART handle
* @param COM_Init Pointer to a UART_HandleTypeDef structure that contains the
* configuration information for the specified USART peripheral.
* @retval HAL error code
*/
__weak HAL_StatusTypeDef MX_LPUART1_Init(UART_HandleTypeDef *huart, MX_UART_InitTypeDef *COM_Init)
{
/* USART configuration */
huart->Instance = COM_USART[COM1];
huart->Init.BaudRate = COM_Init->BaudRate;
huart->Init.Mode = UART_MODE_TX_RX;
huart->Init.Parity = (uint32_t)COM_Init->Parity;
huart->Init.WordLength = COM_Init->WordLength;
huart->Init.StopBits = (uint32_t)COM_Init->StopBits;
huart->Init.HwFlowCtl = (uint32_t)COM_Init->HwFlowCtl;
huart->Init.OverSampling = UART_OVERSAMPLING_8;
return HAL_UART_Init(huart);
}
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
/**
* @brief Register Default COM Msp Callbacks
* @param COM COM port to be configured.
* This parameter can be COM1
* @retval BSP status
*/
int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM)
{
int32_t ret = BSP_ERROR_NONE;
if(COM >= COMn)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
/* Register default MspInit/MspDeInit Callback */
if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPINIT_CB_ID, COM1_MspInit) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPDEINIT_CB_ID, COM1_MspDeInit) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
IsComMspCbValid[COM] = 1U;
}
}
/* BSP status */
return ret;
}
/**
* @brief Register COM Msp Callback registering
* @param COM COM port to be configured.
* This parameter can be COM1
* @param Callbacks pointer to COM1 MspInit/MspDeInit callback functions
* @retval BSP status
*/
int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM , BSP_COM_Cb_t *Callback)
{
int32_t ret = BSP_ERROR_NONE;
if(COM >= COMn)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
/* Register MspInit/MspDeInit Callbacks */
if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPINIT_CB_ID, Callback->pMspInitCb) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPDEINIT_CB_ID, Callback->pMspDeInitCb) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
IsComMspCbValid[COM] = 1U;
}
}
/* BSP status */
return ret;
}
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
#if (USE_COM_LOG > 0)
/**
* @brief Select the active COM port.
* @param COM COM port to be activated.
* This parameter can be COM1
* @retval BSP status
*/
int32_t BSP_COM_SelectLogPort(COM_TypeDef COM)
{
if(COM_ActiveLogPort != COM)
{
COM_ActiveLogPort = COM;
}
return BSP_ERROR_NONE;
}
/**
* @brief Redirect console output to COM
*/
#ifdef __GNUC__
int __io_putchar (int ch)
#else
int fputc (int ch, FILE *f)
#endif /* __GNUC__ */
{
(void) HAL_UART_Transmit(&hcom_uart [COM_ActiveLogPort], (uint8_t *) &ch, 1, COM_POLL_TIMEOUT);
return ch;
}
#endif /* USE_COM_LOG */
/**
* @}
*/
#endif /* (USE_BSP_COM_FEATURE > 0) */
/**
* @}
*/
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL_Private_Functions
* @{
*/
/**
* @brief Button SW1 EXTI line detection callback.
* @retval None
*/
static void BUTTON_SW1_EXTI_Callback(void)
{
BSP_PB_Callback(BUTTON_SW1);
}
/**
* @brief Button SW2 EXTI line detection callback.
* @retval None
*/
static void BUTTON_SW2_EXTI_Callback(void)
{
BSP_PB_Callback(BUTTON_SW2);
}
/**
* @brief Button SW3 EXTI line detection callback.
* @retval None
*/
static void BUTTON_SW3_EXTI_Callback(void)
{
BSP_PB_Callback(BUTTON_SW3);
}
#if (USE_BSP_COM_FEATURE > 0)
/**
* @brief Initializes COM1 MSP.
* @param huart UART handle
* @retval BSP status
*/
static void COM1_MspInit(UART_HandleTypeDef *huart)
{
GPIO_InitTypeDef gpio_init_structure;
/* Prevent unused argument(s) compilation warning */
UNUSED(huart);
/* Enable GPIO clock */
COM1_TX_GPIO_CLK_ENABLE();
COM1_RX_GPIO_CLK_ENABLE();
/* Enable USART clock */
COM1_CLK_ENABLE();
/* Configure USART Tx as alternate function */
gpio_init_structure.Pin = COM1_TX_PIN;
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Alternate = COM1_TX_AF;
HAL_GPIO_Init(COM1_TX_GPIO_PORT, &gpio_init_structure);
/* Configure USART Rx as alternate function */
gpio_init_structure.Pin = COM1_RX_PIN;
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
gpio_init_structure.Alternate = COM1_RX_AF;
HAL_GPIO_Init(COM1_RX_GPIO_PORT, &gpio_init_structure);
}
/**
* @brief DeInitialize COM1 MSP part
* @param huart UART handle
* @retval BSP status
*/
static void COM1_MspDeInit(UART_HandleTypeDef *huart)
{
GPIO_InitTypeDef gpio_init_structure;
/* Prevent unused argument(s) compilation warning */
UNUSED(huart);
/* COM GPIO pin configuration */
gpio_init_structure.Pin = COM1_TX_PIN;
HAL_GPIO_DeInit(COM1_TX_GPIO_PORT, gpio_init_structure.Pin);
gpio_init_structure.Pin = COM1_RX_PIN;
HAL_GPIO_DeInit(COM1_RX_GPIO_PORT, gpio_init_structure.Pin);
/* Disable USART clock */
COM1_CLK_DISABLE();
}
#endif /* (USE_BSP_COM_FEATURE > 0) */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/

356
stm32wlxx_STS.h Normal file
View File

@ -0,0 +1,356 @@
/**
******************************************************************************
* @file stm32wlxx_STS.h
* @author MCD Application Team
* @brief Header for stm32wlxx_STS.c
******************************************************************************
* @attention
*
* Copyright (c) 2020-2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32WLXX_STS_H
#define STM32WLXX_STS_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32wlxx_nucleo_errno.h"
#include "stm32wlxx_nucleo_conf.h"
#if (USE_BSP_COM_FEATURE > 0)
#if (USE_COM_LOG > 0)
#ifndef __GNUC__
#include "stdio.h"
#endif
#endif
#endif
/** @addtogroup BSP
* @{
*/
/** @defgroup STM32WLXX_NUCLEO STM32WLXX-NUCLEO
* @{
*/
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL LOW LEVEL
* @{
*/
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Types LOW LEVEL Exported Types
* @{
*/
typedef enum
{
LED1 = 0,
LED2 = 1,
LED3 = 2,
/* Color led aliases */
LED_BLUE = LED1,
LED_GREEN = LED2,
LED_RED = LED3
}Led_TypeDef;
typedef enum
{
BUTTON_SW1 = 0,
BUTTON_SW2 = 1,
BUTTON_SW3 = 2,
}Button_TypeDef;
typedef enum
{
BUTTON_MODE_GPIO = 0,
BUTTON_MODE_EXTI = 1
}ButtonMode_TypeDef;
#if (USE_BSP_COM_FEATURE > 0)
typedef enum
{
COM1 = 0U,
COMn
}COM_TypeDef;
typedef enum
{
COM_STOPBITS_1 = UART_STOPBITS_1,
COM_STOPBITS_2 = UART_STOPBITS_2,
}COM_StopBitsTypeDef;
typedef enum
{
COM_PARITY_NONE = UART_PARITY_NONE,
COM_PARITY_EVEN = UART_PARITY_EVEN,
COM_PARITY_ODD = UART_PARITY_ODD,
}COM_ParityTypeDef;
typedef enum
{
COM_HWCONTROL_NONE = UART_HWCONTROL_NONE,
COM_HWCONTROL_RTS = UART_HWCONTROL_RTS,
COM_HWCONTROL_CTS = UART_HWCONTROL_CTS,
COM_HWCONTROL_RTS_CTS = UART_HWCONTROL_RTS_CTS,
}COM_HwFlowCtlTypeDef;
typedef enum
{
COM_WORDLENGTH_7B = UART_WORDLENGTH_7B,
COM_WORDLENGTH_8B = UART_WORDLENGTH_8B,
COM_WORDLENGTH_9B = UART_WORDLENGTH_9B,
}COM_WordLengthTypeDef;
typedef struct
{
uint32_t BaudRate;
COM_WordLengthTypeDef WordLength;
COM_StopBitsTypeDef StopBits;
COM_ParityTypeDef Parity;
COM_HwFlowCtlTypeDef HwFlowCtl;
}COM_InitTypeDef;
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
typedef struct
{
pUART_CallbackTypeDef pMspInitCb;
pUART_CallbackTypeDef pMspDeInitCb;
}BSP_COM_Cb_t;
#endif /* (USE_HAL_UART_REGISTER_CALLBACKS == 1) */
#endif /* (USE_BSP_COM_FEATURE > 0) */
typedef enum
{
ABSENT = 0,
PRESENT = 1,
}Presence_TypeDef;
/**
* @}
*/
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Constants LOW LEVEL Exported Constants
* @{
*/
/**
* @brief STM32WLXX NUCLEO BSP Driver version number
*/
#define __STM32WLXX_NUCLEO_BSP_VERSION_MAIN (0x01U) /*!< [31:24] main version */
#define __STM32WLXX_NUCLEO_BSP_VERSION_SUB1 (0x02U) /*!< [23:16] sub1 version */
#define __STM32WLXX_NUCLEO_BSP_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */
#define __STM32WLXX_NUCLEO_BSP_VERSION_RC (0x00U) /*!< [7:0] release candidate */
#define __STM32WLXX_NUCLEO_BSP_VERSION ((__STM32WLXX_NUCLEO_BSP_VERSION_MAIN << 24)\
|(__STM32WLXX_NUCLEO_BSP_VERSION_SUB1 << 16)\
|(__STM32WLXX_NUCLEO_BSP_VERSION_SUB2 << 8 )\
|(__STM32WLXX_NUCLEO_BSP_VERSION_RC))
/**
* @brief Define for STM32WLXX_NUCLEO board
*/
#if !defined (USE_STM32WLXX_NUCLEO)
#define USE_STM32WLXX_NUCLEO
#endif
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_LED LOW LEVEL LED Constants
* @{
*/
#define LEDn 3
#define LED1_PIN GPIO_PIN_15
#define LED1_GPIO_PORT GPIOB
#define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define LED1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define LED2_PIN GPIO_PIN_9
#define LED2_GPIO_PORT GPIOB
#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define LED3_PIN GPIO_PIN_11
#define LED3_GPIO_PORT GPIOB
#define LED3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define LED3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define LEDx_GPIO_CLK_ENABLE(__INDEX__) __HAL_RCC_GPIOB_CLK_ENABLE() /* All Led on same port */
#define LEDx_GPIO_CLK_DISABLE(__INDEX__) __HAL_RCC_GPIOB_CLK_DISABLE() /* All Led on same port */
/**
* @}
*/
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_BUTTON LOW LEVEL BUTTON Constants
* @{
*/
#define BUTTONn 3
/**
* @brief Key push-buttons
*/
#define BUTTON_SW1_PIN GPIO_PIN_0
#define BUTTON_SW1_GPIO_PORT GPIOA
#define BUTTON_SW1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define BUTTON_SW1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define BUTTON_SW1_EXTI_LINE EXTI_LINE_0
#ifdef CORE_CM0PLUS
#define BUTTON_SW1_EXTI_IRQn EXTI1_0_IRQn
#else
#define BUTTON_SW1_EXTI_IRQn EXTI0_IRQn
#endif
#define H_EXTI_0 hpb_exti[BUTTON_SW1]
#define BUTTON_SW2_PIN GPIO_PIN_1
#define BUTTON_SW2_GPIO_PORT GPIOA
#define BUTTON_SW2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define BUTTON_SW2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define BUTTON_SW2_EXTI_LINE EXTI_LINE_1
#ifdef CORE_CM0PLUS
#define BUTTON_SW2_EXTI_IRQn EXTI1_0_IRQn
#else
#define BUTTON_SW2_EXTI_IRQn EXTI1_IRQn
#endif
#define H_EXTI_1 hpb_exti[BUTTON_SW2]
#define BUTTON_SW3_PIN GPIO_PIN_6
#define BUTTON_SW3_GPIO_PORT GPIOC
#define BUTTON_SW3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define BUTTON_SW3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define BUTTON_SW3_EXTI_LINE EXTI_LINE_6
#ifdef CORE_CM0PLUS
#define BUTTON_SW3_EXTI_IRQn EXTI15_4_IRQn
#else
#define BUTTON_SW3_EXTI_IRQn EXTI9_5_IRQn
#endif
#define H_EXTI_6 hpb_exti[BUTTON_SW3]
#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do { if ((__INDEX__) == BUTTON_SW1) BUTTON_SW1_GPIO_CLK_ENABLE(); else \
if ((__INDEX__) == BUTTON_SW2) BUTTON_SW2_GPIO_CLK_ENABLE(); else \
if ((__INDEX__) == BUTTON_SW3) BUTTON_SW3_GPIO_CLK_ENABLE();} while(0)
#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) do { if ((__INDEX__) == BUTTON_SW1) BUTTON_SW1_GPIO_CLK_DISABLE(); else \
if ((__INDEX__) == BUTTON_SW2) BUTTON_SW2_GPIO_CLK_DISABLE(); else \
if ((__INDEX__) == BUTTON_SW3) BUTTON_SW3_GPIO_CLK_DISABLE();} while(0)
/**
* @}
*/
#if (USE_BSP_COM_FEATURE > 0)
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_COM LOW LEVEL COM Port Constants
* @{
*/
#define COM1_UART LPUART1
#define COM1_CLK_ENABLE() __HAL_RCC_LPUART1_CLK_ENABLE()
#define COM1_CLK_DISABLE() __HAL_RCC_LPUART1_CLK_DISABLE()
#define COM1_TX_PIN GPIO_PIN_2
#define COM1_TX_GPIO_PORT GPIOA
#define COM1_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define COM1_TX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define COM1_TX_AF GPIO_AF8_LPUART1
#define COM1_RX_PIN GPIO_PIN_3
#define COM1_RX_GPIO_PORT GPIOA
#define COM1_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define COM1_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define COM1_RX_AF GPIO_AF8_LPUART1
#define COM_POLL_TIMEOUT 1000
#define MX_UART_InitTypeDef COM_InitTypeDef
/**
* @}
*/
#endif /* (USE_BSP_COM_FEATURE > 0)*/
/**
* @}
*/
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Variables
* @{
*/
extern EXTI_HandleTypeDef hpb_exti[];
#if (USE_BSP_COM_FEATURE > 0)
extern UART_HandleTypeDef hcom_uart[];
#endif /* (USE_BSP_COM_FEATURE > 0) */
/**
* @}
*/
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_Exported_Functions LOW LEVEL Exported Functions
* @{
*/
uint32_t BSP_GetVersion(void);
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_LED_Functions LOW LEVEL LED Functions
* @{
*/
int32_t BSP_LED_Init(Led_TypeDef Led);
int32_t BSP_LED_DeInit(Led_TypeDef Led);
int32_t BSP_LED_On(Led_TypeDef Led);
int32_t BSP_LED_Off(Led_TypeDef Led);
int32_t BSP_LED_Toggle(Led_TypeDef Led);
int32_t BSP_LED_GetState(Led_TypeDef Led);
/**
* @}
*/
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_BUTTON_Functions LOW LEVEL BUTTON Functions
* @{
*/
int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode);
int32_t BSP_PB_DeInit(Button_TypeDef Button);
int32_t BSP_PB_GetState(Button_TypeDef Button);
void BSP_PB_Callback(Button_TypeDef Button);
void BSP_PB_IRQHandler(Button_TypeDef Button);
/**
* @}
*/
#if (USE_BSP_COM_FEATURE > 0)
/** @defgroup STM32WLXX_NUCLEO_LOW_LEVEL_COM_Functions LOW LEVEL COM Port Functions
* @{
*/
int32_t BSP_COM_Init(COM_TypeDef COM, COM_InitTypeDef *COM_Init);
int32_t BSP_COM_DeInit(COM_TypeDef COM);
#if (USE_COM_LOG > 0)
int32_t BSP_COM_SelectLogPort (COM_TypeDef COM);
#endif
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM);
int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM , BSP_COM_Cb_t *Callback);
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
HAL_StatusTypeDef MX_LPUART1_Init(UART_HandleTypeDef *huart, MX_UART_InitTypeDef *COM_Init);
/**
* @}
*/
#endif /* (USE_BSP_COM_FEATURE > 0) */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32WLXX_STS_H */

220
stm32wlxx_STS_radio.c Normal file
View File

@ -0,0 +1,220 @@
/**
******************************************************************************
* @file stm32wlxx_STS_radio.c
* @author MCD Application Team
* @brief This file provides set of firmware functions to manage:
* - RF circuitry available on STM32WLXX-Nucleo
* Kit from STMicroelectronics
******************************************************************************
* @attention
*
* Copyright (c) 2020-2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32wlxx_STS_radio.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32WLXX_NUCLEO
* @{
*/
/** @addtogroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL
* @brief This file provides set of firmware functions to Radio switch
* available on STM32WLXX-Nucleo Kit from STMicroelectronics.
* @{
*/
/** @addtogroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_Exported_Functions
* @{
*/
/**
* @brief Init Radio Switch
* @retval BSP status
*/
int32_t BSP_RADIO_Init(void)
{
GPIO_InitTypeDef gpio_init_structure = {0};
/* Enable the Radio Switch Clock */
RF_SW_CTRL3_GPIO_CLK_ENABLE();
/* Configure the Radio Switch pin */
gpio_init_structure.Pin = RF_SW_CTRL1_PIN;
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(RF_SW_CTRL1_GPIO_PORT, &gpio_init_structure);
gpio_init_structure.Pin = RF_SW_CTRL2_PIN;
HAL_GPIO_Init(RF_SW_CTRL2_GPIO_PORT, &gpio_init_structure);
gpio_init_structure.Pin = RF_SW_CTRL3_PIN;
HAL_GPIO_Init(RF_SW_CTRL3_GPIO_PORT, &gpio_init_structure);
HAL_GPIO_WritePin(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN, GPIO_PIN_RESET);
HAL_GPIO_WritePin(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN, GPIO_PIN_RESET);
HAL_GPIO_WritePin(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN, GPIO_PIN_RESET);
return BSP_ERROR_NONE;
}
/**
* @brief DeInit Radio Switch
* @retval BSP status
*/
int32_t BSP_RADIO_DeInit(void)
{
RF_SW_CTRL3_GPIO_CLK_ENABLE();
/* Turn off switch */
HAL_GPIO_WritePin(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN, GPIO_PIN_RESET);
HAL_GPIO_WritePin(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN, GPIO_PIN_RESET);
HAL_GPIO_WritePin(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN, GPIO_PIN_RESET);
/* DeInit the Radio Switch pin */
HAL_GPIO_DeInit(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN);
HAL_GPIO_DeInit(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN);
HAL_GPIO_DeInit(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN);
return BSP_ERROR_NONE;
}
/**
* @brief Configure Radio Switch.
* @param Config: Specifies the Radio RF switch path to be set.
* This parameter can be one of following parameters:
* @arg RADIO_SWITCH_OFF
* @arg RADIO_SWITCH_RX
* @arg RADIO_SWITCH_RFO_LP
* @arg RADIO_SWITCH_RFO_HP
* @retval BSP status
*/
int32_t BSP_RADIO_ConfigRFSwitch(BSP_RADIO_Switch_TypeDef Config)
{
switch (Config)
{
case RADIO_SWITCH_OFF:
{
/* Turn off switch */
HAL_GPIO_WritePin(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN, GPIO_PIN_RESET);
HAL_GPIO_WritePin(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN, GPIO_PIN_RESET);
HAL_GPIO_WritePin(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN, GPIO_PIN_RESET);
break;
}
case RADIO_SWITCH_RX:
{
/*Turns On in Rx Mode the RF Switch */
HAL_GPIO_WritePin(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN, GPIO_PIN_RESET);
break;
}
case RADIO_SWITCH_RFO_LP:
{
/*Turns On in Tx Low Power the RF Switch */
HAL_GPIO_WritePin(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN, GPIO_PIN_SET);
break;
}
case RADIO_SWITCH_RFO_HP:
{
/*Turns On in Tx High Power the RF Switch */
HAL_GPIO_WritePin(RF_SW_CTRL3_GPIO_PORT, RF_SW_CTRL3_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(RF_SW_CTRL1_GPIO_PORT, RF_SW_CTRL1_PIN, GPIO_PIN_RESET);
HAL_GPIO_WritePin(RF_SW_CTRL2_GPIO_PORT, RF_SW_CTRL2_PIN, GPIO_PIN_SET);
break;
}
default:
break;
}
return BSP_ERROR_NONE;
}
/**
* @brief Return Board Configuration
* @retval
* RADIO_CONF_RFO_LP_HP
* RADIO_CONF_RFO_LP
* RADIO_CONF_RFO_HP
*/
int32_t BSP_RADIO_GetTxConfig(void)
{
return RADIO_CONF_RFO_LP_HP;
}
/**
* @brief Get If TCXO is to be present on board
* @note never remove called by MW,
* @retval
* RADIO_CONF_TCXO_NOT_SUPPORTED
* RADIO_CONF_TCXO_SUPPORTED
*/
int32_t BSP_RADIO_IsTCXO(void)
{
return RADIO_CONF_TCXO_SUPPORTED;
}
/**
* @brief Get If DCDC is to be present on board
* @note never remove called by MW,
* @retval
* RADIO_CONF_DCDC_NOT_SUPPORTED
* RADIO_CONF_DCDC_SUPPORTED
*/
int32_t BSP_RADIO_IsDCDC(void)
{
return RADIO_CONF_DCDC_SUPPORTED;
}
/**
* @brief Return RF Output Max Power Configuration
* @retval
* RADIO_CONF_RFO_LP_MAX_15_dBm for LP mode
* RADIO_CONF_RFO_HP_MAX_22_dBm for HP mode
*/
int32_t BSP_RADIO_GetRFOMaxPowerConfig(BSP_RADIO_RFOMaxPowerConfig_TypeDef Config)
{
int32_t ret;
if(Config == RADIO_RFO_LP_MAXPOWER)
{
ret = RADIO_CONF_RFO_LP_MAX_15_dBm;
}
else
{
ret = RADIO_CONF_RFO_HP_MAX_22_dBm;
}
return ret;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/

181
stm32wlxx_STS_radio.h Normal file
View File

@ -0,0 +1,181 @@
/**
******************************************************************************
* @file stm32wlxx_STS_radio.h
* @author MCD Application Team
* @brief Header for stm32wlxx_nucleo_radio.c
******************************************************************************
* @attention
*
* Copyright (c) 2020-2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32WLXX_STS_RADIO_H
#define STM32WLXX_STS_RADIO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32wlxx_nucleo_errno.h"
#include "stm32wlxx_nucleo_conf.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32WLXX_NUCLEO STM32WLXX-NUCLEO
* @{
*/
/** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL RADIO LOW LEVEL
* @{
*/
/** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_Exported_Types RADIO LOW LEVEL Exported Types
* @{
*/
typedef enum
{
RADIO_SWITCH_OFF = 0,
RADIO_SWITCH_RX = 1,
RADIO_SWITCH_RFO_LP = 2,
RADIO_SWITCH_RFO_HP = 3,
}BSP_RADIO_Switch_TypeDef;
typedef enum
{
RADIO_RFO_LP_MAXPOWER = 0,
RADIO_RFO_HP_MAXPOWER,
} BSP_RADIO_RFOMaxPowerConfig_TypeDef;
/**
* @}
*/
/** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_Exported_Constants RADIO LOW LEVEL Exported Constants
* @{
*/
/** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_RADIOCONFIG RADIO LOW LEVEL RADIO CONFIG Constants
* @{
*/
#define RADIO_CONF_RFO_LP_HP 0U
#define RADIO_CONF_RFO_LP 1U
#define RADIO_CONF_RFO_HP 2U
#define RADIO_CONF_TCXO_NOT_SUPPORTED 0U
#define RADIO_CONF_TCXO_SUPPORTED 1U
#define RADIO_CONF_DCDC_NOT_SUPPORTED 0U
#define RADIO_CONF_DCDC_SUPPORTED 1U
#define RADIO_CONF_RFO_HP_MAX_22_dBm ((int32_t) 22)
#define RADIO_CONF_RFO_HP_MAX_20_dBm ((int32_t) 20)
#define RADIO_CONF_RFO_HP_MAX_17_dBm ((int32_t) 17)
#define RADIO_CONF_RFO_HP_MAX_14_dBm ((int32_t) 14)
#define RADIO_CONF_RFO_LP_MAX_15_dBm ((int32_t) 15)
#define RADIO_CONF_RFO_LP_MAX_14_dBm ((int32_t) 14)
#define RADIO_CONF_RFO_LP_MAX_10_dBm ((int32_t) 10)
/**
* @}
*/
/** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_RFSWITCH RADIO LOW LEVEL RF SWITCH Constants
* @{
**
**
#define RF_SW_CTRL3_PIN GPIO_PIN_3
#define RF_SW_CTRL3_GPIO_PORT GPIOC
#define RF_SW_CTRL3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define RF_SW_CTRL3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define RF_SW_CTRL1_PIN GPIO_PIN_4
#define RF_SW_CTRL1_GPIO_PORT GPIOC
#define RF_SW_CTRL1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define RF_SW_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define RF_SW_CTRL2_PIN GPIO_PIN_5
#define RF_SW_CTRL2_GPIO_PORT GPIOC
#define RF_SW_CTRL2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define RF_SW_CTRL2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define RF_TCXO_VCC_PIN GPIO_PIN_0
#define RF_TCXO_VCC_GPIO_PORT GPIOB
#define RF_TCXO_VCC_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define RF_TCXO_VCC_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
**
**
*/
#define RF_SW_CTRL3_PIN GPIO_PIN_9
#define RF_SW_CTRL3_GPIO_PORT GPIOA
#define RF_SW_CTRL3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define RF_SW_CTRL3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
// NOT USED CTRL1_PIN
#define RF_SW_CTRL1_PIN GPIO_PIN_4
#define RF_SW_CTRL1_GPIO_PORT GPIOC
#define RF_SW_CTRL1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define RF_SW_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define RF_SW_CTRL2_PIN GPIO_PIN_13
#define RF_SW_CTRL2_GPIO_PORT GPIOC
#define RF_SW_CTRL2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define RF_SW_CTRL2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define RF_TCXO_VCC_PIN GPIO_PIN_0
#define RF_TCXO_VCC_GPIO_PORT GPIOB
#define RF_TCXO_VCC_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define RF_TCXO_VCC_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
/**
* @}
*/
/**
* @}
*/
/** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_Exported_Functions RADIO LOW LEVEL Exported Functions
* @{
*/
int32_t BSP_RADIO_Init(void);
int32_t BSP_RADIO_DeInit(void);
int32_t BSP_RADIO_ConfigRFSwitch(BSP_RADIO_Switch_TypeDef Config);
int32_t BSP_RADIO_GetTxConfig(void);
int32_t BSP_RADIO_IsTCXO(void);
int32_t BSP_RADIO_IsDCDC(void);
int32_t BSP_RADIO_GetRFOMaxPowerConfig(BSP_RADIO_RFOMaxPowerConfig_TypeDef Config);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32WLXX_NUCLEO_RADIO_H */

74
stm32wlxx_nucleo_conf.h Normal file
View File

@ -0,0 +1,74 @@
/**
******************************************************************************
* @file stm32wlxx_nucleo_conf.h
* @author MCD Application Team
* @brief STM32WLxx_Nucleo board configuration file.
******************************************************************************
* @attention
*
* Copyright (c) 2020-2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32WLXX_NUCLEO_CONF_H
#define STM32WLXX_NUCLEO_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32wlxx_hal.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32WLXX_NUCLEO
* @{
*/
/** @defgroup STM32WLXX_NUCLEO_CONFIG CONFIG
* @{
*/
/** @defgroup STM32WLXX_NUCLEO_CONFIG_Exported_Constants Exported Constants
* @{
*/
/* COM usage define */
#define USE_BSP_COM_FEATURE 0U
/* COM log define */
#define USE_COM_LOG 0U
/* IRQ priorities */
#define BSP_BUTTON_USER_IT_PRIORITY 15U
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32WLXX_NUCLEO_CONF_H */

View File

@ -0,0 +1,74 @@
/**
******************************************************************************
* @file stm32wlxx_nucleo_conf.h
* @author MCD Application Team
* @brief STM32WLxx_Nucleo board configuration file.
******************************************************************************
* @attention
*
* Copyright (c) 2020-2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32WLXX_NUCLEO_CONF_H
#define STM32WLXX_NUCLEO_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32wlxx_hal.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32WLXX_NUCLEO
* @{
*/
/** @defgroup STM32WLXX_NUCLEO_CONFIG CONFIG
* @{
*/
/** @defgroup STM32WLXX_NUCLEO_CONFIG_Exported_Constants Exported Constants
* @{
*/
/* COM usage define */
#define USE_BSP_COM_FEATURE 0U
/* COM log define */
#define USE_COM_LOG 0U
/* IRQ priorities */
#define BSP_BUTTON_USER_IT_PRIORITY 15U
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32WLXX_NUCLEO_CONF_H */

45
stm32wlxx_nucleo_errno.h Normal file
View File

@ -0,0 +1,45 @@
/**
******************************************************************************
* @file stm32wlxx_nucleo_errno.h
* @author MCD Application Team
* @brief Error Code.
******************************************************************************
* @attention
*
* Copyright (c) 2020-2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32WLXX_NUCLEO_ERRNO_H
#define STM32WLXX_NUCLEO_ERRNO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Common Error codes */
#define BSP_ERROR_NONE 0
#define BSP_ERROR_NO_INIT -1
#define BSP_ERROR_WRONG_PARAM -2
#define BSP_ERROR_BUSY -3
#define BSP_ERROR_PERIPH_FAILURE -4
#define BSP_ERROR_COMPONENT_FAILURE -5
#define BSP_ERROR_UNKNOWN_FAILURE -6
#define BSP_ERROR_UNKNOWN_COMPONENT -7
#define BSP_ERROR_BUS_FAILURE -8
#define BSP_ERROR_CLOCK_FAILURE -9
#define BSP_ERROR_MSP_FAILURE -10
#define BSP_ERROR_FEATURE_NOT_SUPPORTED -11
#ifdef __cplusplus
}
#endif
#endif /* STM32WLXX_NUCLEO_ERRNO_H */