From 2650a64b0251cf54e790f6425abe3d74a63cf922 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Wed, 19 Nov 2025 12:03:06 +0100 Subject: [PATCH 01/11] scripts: fix WB0x case for stm32cube HAL/LL update STM32WB0 series is a bit specific among other SoC series in that the HAL/LL resources has a single x suffix (stm32wb0x_...) while all other series have 2 x's (e.g. stm32f4xx). Also, the CMSIS device drivers directory name in STM32Cube has a single uppercase X suffix (Drivers/CMSIS/Device/ST/STM32WB0X/) while other series have 2 lowercase x's suffixes (e.g. Drivers/CMSIS/Device/ST/STM32F4x/). Signed-off-by: Etienne Carriere --- scripts/serie_update.py | 25 ++++++++++++++++++++----- scripts/update_stm32_package.py | 9 ++++++++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/scripts/serie_update.py b/scripts/serie_update.py index 06dbbdeb9..d49dc5f53 100644 --- a/scripts/serie_update.py +++ b/scripts/serie_update.py @@ -56,7 +56,7 @@ def __init__( """Class Stm32SerieUpdate constructor Args: - stm32_serie: stm32 serie ex:stm32f3xx + stm32_serie: stm32 series name (without 'x' suffixes), e.g. 'stm32f3' stm32cube_repo_path: directory path where to fetch github repo noclean: boolean to clean or not github repo after update done version_update: string to force a specified version to be updated @@ -76,9 +76,17 @@ def __init__( # Set serie variables self.stm32_serie = stm32_serie - self.stm32_seriexx = stm32_serie + "xx" # ex:stm32f3xx + + # STM32WB0 uses a single 'x' suffix in HAL/LL resources + if self.stm32_serie == 'stm32wb0': + x_suffix = 'x' + else: + x_suffix = 'xx' + + self.stm32_seriexx = stm32_serie + x_suffix + self.stm32_serie_upper = stm32_serie.upper() # ex:STM32F3 - self.stm32_seriexx_upper = self.stm32_serie_upper + "xx" # ex:STM32F3xx + self.stm32_seriexx_upper = self.stm32_serie_upper + x_suffix # ex:STM32F3xx self.serie = self.stm32_serie_upper[5:] self.noclean = noclean self.version_update = version_update @@ -273,13 +281,20 @@ def extract_source(self): temp_cmsis_soc_path = self.stm32cube_temp_serie / "soc" Path.mkdir(temp_cmsis_soc_path, parents=True) + # STM32WB0 uses a specifc CMSIS device driver path + # with a single uppercase X suffix. + if self.stm32_serie == 'stm32wb0': + cmsis_device_dir = 'STM32WB0X' + else: + cmsis_device_dir = self.stm32_seriexx_upper + stm32cube_cmsis_include_path = ( self.stm32cube_serie_path / "Drivers" / "CMSIS" / "Device" / "ST" - / self.stm32_seriexx_upper + / cmsis_device_dir / "Include" ) shutil.rmtree(temp_cmsis_soc_path, onerror=common_utils.remove_readonly) @@ -291,7 +306,7 @@ def extract_source(self): / "CMSIS" / "Device" / "ST" - / self.stm32_seriexx_upper + / cmsis_device_dir / "Source" / "Templates" ) diff --git a/scripts/update_stm32_package.py b/scripts/update_stm32_package.py index 5a1ec5c6b..a7a5f715e 100644 --- a/scripts/update_stm32_package.py +++ b/scripts/update_stm32_package.py @@ -78,9 +78,16 @@ def update_cubes(): "%s", f"*************** updating module {stmyyxx.name} *****************", ) + + # STM32WB0 uses a single 'x' suffix in HAL/LL resources + if stmyyxx.name == 'stm32wb0x': + serie_name = stmyyxx.name[:-1] + else: + serie_name = stmyyxx.name[:-2] + # Force the commit for each serie update_serie = serie_update.Stm32SerieUpdate( - stmyyxx.name[:-2], + serie_name, repo_path, noclean=args.noclean, debug=args.debug, From da686d084e51cb22315bc5acf35ca0f70c7d76fc Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Fri, 12 Dec 2025 11:43:50 +0100 Subject: [PATCH 02/11] stm32cube: update stm32wb0 to cube version V1.1.0 Update Cube version for STM32WB0x series on https://github.com/STMicroelectronics from version v1.0.0 to version v1.1.0 Signed-off-by: Etienne Carriere --- stm32cube/stm32wb0x/README | 10 ++- .../drivers/include/Legacy/stm32_hal_legacy.h | 70 +++++++++++++--- .../stm32wb0x/drivers/include/stm32wb0x_hal.h | 2 +- .../drivers/include/stm32wb0x_hal_uart.h | 5 +- .../drivers/include/stm32wb0x_ll_adc.h | 4 - .../drivers/include/stm32wb0x_ll_pka.h | 2 +- .../drivers/include/stm32wb0x_ll_rcc.h | 15 ++-- .../drivers/include/stm32wb0x_ll_rng.h | 62 ++++++++------- .../drivers/include/stm32wb0x_ll_system.h | 28 +++++-- .../drivers/include/stm32wb0x_ll_utils.h | 2 +- .../stm32wb0x/drivers/src/stm32wb0x_hal_adc.c | 16 ++-- .../stm32wb0x/drivers/src/stm32wb0x_hal_i2c.c | 79 +++++++++++++------ .../drivers/src/stm32wb0x_hal_radio.c | 18 ++--- .../drivers/src/stm32wb0x_hal_radio_timer.c | 19 ++++- .../drivers/src/stm32wb0x_hal_smbus.c | 4 +- .../drivers/src/stm32wb0x_hal_uart.c | 1 - .../stm32wb0x/drivers/src/stm32wb0x_ll_pka.c | 2 +- stm32cube/stm32wb0x/soc/stm32wb09.h | 3 - stm32cube/stm32wb0x/soc/stm32wb0x.h | 2 +- stm32cube/stm32wb0x/soc/system_stm32wb0x.c | 2 +- stm32cube/stm32wb0x/soc/system_stm32wb0x.h | 2 +- 21 files changed, 222 insertions(+), 126 deletions(-) diff --git a/stm32cube/stm32wb0x/README b/stm32cube/stm32wb0x/README index 2f6eefb1f..0d24bcd37 100644 --- a/stm32cube/stm32wb0x/README +++ b/stm32cube/stm32wb0x/README @@ -6,7 +6,7 @@ Origin: http://www.st.com/en/embedded-software/stm32cubewb0.html Status: - version v1.0.0 + version v1.1.0 Purpose: STMicroelectronics official MCU package for STM32WB0 series. @@ -23,7 +23,7 @@ URL: https://github.com/STMicroelectronics/STM32CubeWB0 Commit: - 61d80e00cdb6136a58a33b95d2137e3bc9baa28e + acb6e3c6086b69b3fff8111c89b825d6acbb3d71 Maintained-by: External @@ -44,7 +44,9 @@ Patch List: -Added stm32cube/stm32wb0x/drivers/include/stm32_assert.h -Removed unused stm32cube/stm32wb0x/drivers/include/stm32_assert_template.h - *Added patches to enable compilation with Zephyr + *Added patches to enable compilation with Zephyr. + See commit e8043b4d124e ("stm32cube: stm32wb0x: add compatibility patches") + from pull request https://github.com/zephyrproject-rtos/hal_stm32/pull/230. -exclude stm32cube/stm32wb0x/soc/system_stm32wb0.c from build . Missing definitions moved to 'zephyr/soc/st/stm32/stm32wb0xx/soc.c' . SystemCoreClock (CMSIS global variable) @@ -61,4 +63,4 @@ Patch List: . Remove definition of __blue_RAM variable . Moved to 'zephyr/soc/st/stm32/stm32wb0xx/soc.c' - See Release_Notes.html from STM32Cube for more details. + See release_note.html from STM32Cube diff --git a/stm32cube/stm32wb0x/drivers/include/Legacy/stm32_hal_legacy.h b/stm32cube/stm32wb0x/drivers/include/Legacy/stm32_hal_legacy.h index 9f367692d..9fcbd8996 100644 --- a/stm32cube/stm32wb0x/drivers/include/Legacy/stm32_hal_legacy.h +++ b/stm32cube/stm32wb0x/drivers/include/Legacy/stm32_hal_legacy.h @@ -472,9 +472,9 @@ extern "C" { #define TYPEPROGRAMDATA_FASTBYTE FLASH_TYPEPROGRAMDATA_FASTBYTE #define TYPEPROGRAMDATA_FASTHALFWORD FLASH_TYPEPROGRAMDATA_FASTHALFWORD #define TYPEPROGRAMDATA_FASTWORD FLASH_TYPEPROGRAMDATA_FASTWORD -#if 0 /** PATCH: do not define PAGESIZE (for POSIX compatibility) */ - #define PAGESIZE FLASH_PAGE_SIZE -#endif /* ENDOF PATCH */ +#if !defined(STM32F2) && !defined(STM32F4) && !defined(STM32F7) && !defined(STM32H7) +/* #define PAGESIZE FLASH_PAGE_SIZE */ +#endif /* STM32F2 && STM32F4 && STM32F7 && STM32H7 */ #define TYPEPROGRAM_FASTBYTE FLASH_TYPEPROGRAM_BYTE #define TYPEPROGRAM_FASTHALFWORD FLASH_TYPEPROGRAM_HALFWORD #define TYPEPROGRAM_FASTWORD FLASH_TYPEPROGRAM_WORD @@ -603,6 +603,15 @@ extern "C" { #define HAL_SYSCFG_DisableIOAnalogSwitchVDD HAL_SYSCFG_DisableIOSwitchVDD #endif /* STM32G4 */ +#if defined(STM32U5) + +#define HAL_SYSCFG_EnableIOAnalogSwitchBooster HAL_SYSCFG_EnableIOAnalogBooster +#define HAL_SYSCFG_DisableIOAnalogSwitchBooster HAL_SYSCFG_DisableIOAnalogBooster +#define HAL_SYSCFG_EnableIOAnalogSwitchVoltageSelection HAL_SYSCFG_EnableIOAnalogVoltageSelection +#define HAL_SYSCFG_DisableIOAnalogSwitchVoltageSelection HAL_SYSCFG_DisableIOAnalogVoltageSelection + +#endif /* STM32U5 */ + #if defined(STM32H5) #define SYSCFG_IT_FPU_IOC SBS_IT_FPU_IOC #define SYSCFG_IT_FPU_DZC SBS_IT_FPU_DZC @@ -877,6 +886,10 @@ extern "C" { #define __HAL_HRTIM_SetCompare __HAL_HRTIM_SETCOMPARE #define __HAL_HRTIM_GetCompare __HAL_HRTIM_GETCOMPARE +#if defined(STM32F3) || defined(STM32G4) || defined(STM32H7) +#define HRTIMInterruptResquests HRTIMInterruptRequests +#endif /* STM32F3 || STM32G4 || STM32H7 */ + #if defined(STM32G4) #define HAL_HRTIM_ExternalEventCounterConfig HAL_HRTIM_ExtEventCounterConfig #define HAL_HRTIM_ExternalEventCounterEnable HAL_HRTIM_ExtEventCounterEnable @@ -1014,8 +1027,8 @@ extern "C" { #define HRTIM_CALIBRATIONRATE_910 (HRTIM_DLLCR_CALRTE_0) #define HRTIM_CALIBRATIONRATE_114 (HRTIM_DLLCR_CALRTE_1) #define HRTIM_CALIBRATIONRATE_14 (HRTIM_DLLCR_CALRTE_1 | HRTIM_DLLCR_CALRTE_0) - #endif /* STM32F3 */ + /** * @} */ @@ -1266,10 +1279,10 @@ extern "C" { #define RTC_TAMPERPIN_PA0 RTC_TAMPERPIN_POS1 #define RTC_TAMPERPIN_PI8 RTC_TAMPERPIN_POS1 -#if defined(STM32H5) || defined(STM32H7RS) +#if defined(STM32H5) || defined(STM32H7RS) || defined(STM32N6) #define TAMP_SECRETDEVICE_ERASE_NONE TAMP_DEVICESECRETS_ERASE_NONE #define TAMP_SECRETDEVICE_ERASE_BKP_SRAM TAMP_DEVICESECRETS_ERASE_BKPSRAM -#endif /* STM32H5 || STM32H7RS */ +#endif /* STM32H5 || STM32H7RS || STM32N6 */ #if defined(STM32WBA) #define TAMP_SECRETDEVICE_ERASE_NONE TAMP_DEVICESECRETS_ERASE_NONE @@ -1281,10 +1294,10 @@ extern "C" { #define TAMP_SECRETDEVICE_ERASE_ALL TAMP_DEVICESECRETS_ERASE_ALL #endif /* STM32WBA */ -#if defined(STM32H5) || defined(STM32WBA) || defined(STM32H7RS) +#if defined(STM32H5) || defined(STM32WBA) || defined(STM32H7RS) || defined(STM32N6) #define TAMP_SECRETDEVICE_ERASE_DISABLE TAMP_DEVICESECRETS_ERASE_NONE #define TAMP_SECRETDEVICE_ERASE_ENABLE TAMP_SECRETDEVICE_ERASE_ALL -#endif /* STM32H5 || STM32WBA || STM32H7RS */ +#endif /* STM32H5 || STM32WBA || STM32H7RS || STM32N6 */ #if defined(STM32F7) #define RTC_TAMPCR_TAMPXE RTC_TAMPER_ENABLE_BITS_MASK @@ -2016,12 +2029,12 @@ extern "C" { /** @defgroup HAL_RTC_Aliased_Functions HAL RTC Aliased Functions maintained for legacy purpose * @{ */ -#if defined(STM32H5) || defined(STM32WBA) || defined(STM32H7RS) +#if defined(STM32H5) || defined(STM32WBA) || defined(STM32H7RS) || defined(STM32N6) #define HAL_RTCEx_SetBoothardwareKey HAL_RTCEx_LockBootHardwareKey #define HAL_RTCEx_BKUPBlock_Enable HAL_RTCEx_BKUPBlock #define HAL_RTCEx_BKUPBlock_Disable HAL_RTCEx_BKUPUnblock #define HAL_RTCEx_Erase_SecretDev_Conf HAL_RTCEx_ConfigEraseDeviceSecrets -#endif /* STM32H5 || STM32WBA || STM32H7RS */ +#endif /* STM32H5 || STM32WBA || STM32H7RS || STM32N6 */ /** * @} @@ -3681,7 +3694,10 @@ extern "C" { #define RCC_SYSCLKSOURCE_STATUS_PLLR RCC_SYSCLKSOURCE_STATUS_PLLCLK #endif -#if defined(STM32L4) || defined(STM32WB) || defined(STM32G0) || defined(STM32G4) || defined(STM32L5) || defined(STM32WL) || defined(STM32C0) || defined(STM32H7RS) || defined(STM32U0) + +#if defined(STM32L4) || defined(STM32WB) || defined(STM32G0) || defined(STM32G4) || defined(STM32L5) || \ + defined(STM32WL) || defined(STM32C0) || defined(STM32N6) || defined(STM32H7RS) || \ + defined(STM32U0) #define RCC_RTCCLKSOURCE_NO_CLK RCC_RTCCLKSOURCE_NONE #else #define RCC_RTCCLKSOURCE_NONE RCC_RTCCLKSOURCE_NO_CLK @@ -3930,7 +3946,10 @@ extern "C" { /** @defgroup HAL_RTC_Aliased_Macros HAL RTC Aliased Macros maintained for legacy purpose * @{ */ -#if defined (STM32G0) || defined (STM32L5) || defined (STM32L412xx) || defined (STM32L422xx) || defined (STM32L4P5xx)|| defined (STM32L4Q5xx) || defined (STM32G4) || defined (STM32WL) || defined (STM32U5) || defined (STM32WBA) || defined (STM32H5) || defined (STM32C0) || defined (STM32H7RS) || defined (STM32U0) +#if defined (STM32G0) || defined (STM32L5) || defined (STM32L412xx) || defined (STM32L422xx) || \ + defined (STM32L4P5xx)|| defined (STM32L4Q5xx) || defined (STM32G4) || defined (STM32WL) || defined (STM32U5) || \ + defined (STM32WBA) || defined (STM32H5) || \ + defined (STM32C0) || defined (STM32N6) || defined (STM32H7RS) || defined (STM32U0) || defined (STM32U3) #else #define __HAL_RTC_CLEAR_FLAG __HAL_RTC_EXTI_CLEAR_FLAG #endif @@ -4224,6 +4243,33 @@ extern "C" { #define HAL_PCD_SetTxFiFo HAL_PCDEx_SetTxFiFo #define HAL_PCD_SetRxFiFo HAL_PCDEx_SetRxFiFo +#if defined(STM32U5) +#define USB_OTG_GOTGCTL_BSESVLD USB_OTG_GOTGCTL_BSVLD +#define USB_OTG_GAHBCFG_GINT USB_OTG_GAHBCFG_GINTMSK +#define USB_OTG_GUSBCFG_PHYLPCS USB_OTG_GUSBCFG_PHYLPC +#define USB_OTG_GRSTCTL_HSRST USB_OTG_GRSTCTL_PSRST +#define USB_OTG_GINTSTS_BOUTNAKEFF USB_OTG_GINTSTS_GONAKEFF +#define USB_OTG_GINTSTS_WKUINT USB_OTG_GINTSTS_WKUPINT +#define USB_OTG_GINTMSK_PXFRM_IISOOXFRM USB_OTG_GINTMSK_IPXFRM_IISOOXFRM +#define USB_OTG_GRXSTSP_EPNUM USB_OTG_GRXSTSP_EPNUM_CHNUM +#define USB_OTG_GLPMCFG_L1ResumeOK USB_OTG_GLPMCFG_L1RSMOK +#define USB_OTG_HPTXFSIZ_PTXFD USB_OTG_HPTXFSIZ_PTXFSIZ +#define USB_OTG_HCCHAR_MC USB_OTG_HCCHAR_MCNT +#define USB_OTG_HCCHAR_MC_0 USB_OTG_HCCHAR_MCNT_0 +#define USB_OTG_HCCHAR_MC_1 USB_OTG_HCCHAR_MCNT_1 +#define USB_OTG_HCINTMSK_AHBERR USB_OTG_HCINTMSK_AHBERRM +#define USB_OTG_HCTSIZ_DOPING USB_OTG_HCTSIZ_DOPNG +#define USB_OTG_DOEPMSK_OPEM USB_OTG_DOEPMSK_OUTPKTERRM +#define USB_OTG_DIEPCTL_SODDFRM USB_OTG_DIEPCTL_SD1PID_SODDFRM +#define USB_OTG_DIEPTSIZ_MULCNT USB_OTG_DIEPTSIZ_MCNT +#define USB_OTG_DOEPCTL_SODDFRM USB_OTG_DOEPCTL_SD1PID_SODDFRM +#define USB_OTG_DOEPCTL_DPID USB_OTG_DOEPCTL_DPID_EONUM +#define USB_OTG_DOEPTSIZ_STUPCNT USB_OTG_DOEPTSIZ_RXDPID +#define USB_OTG_DOEPTSIZ_STUPCNT_0 USB_OTG_DOEPTSIZ_RXDPID_0 +#define USB_OTG_DOEPTSIZ_STUPCNT_1 USB_OTG_DOEPTSIZ_RXDPID_1 +#define USB_OTG_PCGCCTL_STOPCLK USB_OTG_PCGCCTL_STPPCLK +#define USB_OTG_PCGCCTL_GATECLK USB_OTG_PCGCCTL_GATEHCLK +#endif /** * @} */ diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal.h index b86ae976e..cc2e465b7 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal.h @@ -48,7 +48,7 @@ extern "C" { * @brief HAL Driver version number */ #define __STM32WB0x_HAL_VERSION_MAIN (0x01U) /*!< [31:24] main version */ -#define __STM32WB0x_HAL_VERSION_SUB1 (0x00U) /*!< [23:16] sub1 version */ +#define __STM32WB0x_HAL_VERSION_SUB1 (0x01U) /*!< [23:16] sub1 version */ #define __STM32WB0x_HAL_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ #define __STM32WB0x_HAL_VERSION_RC (0x00U) /*!< [7:0] release candidate */ #define __STM32WB0x_HAL_VERSION ((__STM32WB0x_HAL_VERSION_MAIN << 24U)\ diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_uart.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_uart.h index 532730db5..e8a7016f9 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_uart.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_uart.h @@ -1283,7 +1283,7 @@ typedef void (*pUART_RxEventCallbackTypeDef) /** @defgroup UART_Private_Macros UART Private Macros * @{ */ -/** @brief Get UART clok division factor from clock prescaler value. +/** @brief Get UART clock division factor from clock prescaler value. * @param __CLOCKPRESCALER__ UART prescaler value. * @retval UART clock division factor */ @@ -1298,8 +1298,7 @@ typedef void (*pUART_RxEventCallbackTypeDef) ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV16) ? 16U : \ ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV32) ? 32U : \ ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV64) ? 64U : \ - ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV128) ? 128U : \ - ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV256) ? 256U : 1U) + ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV128) ? 128U : 256U) /** @brief BRR division operation to set BRR register with LPUART. * @param __PCLK__ LPUART clock. diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_adc.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_adc.h index 4235ecede..f461f9ef5 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_adc.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_adc.h @@ -2070,8 +2070,6 @@ __STATIC_INLINE uint32_t LL_ADC_GetMicrophonePGAGain(const ADC_TypeDef *ADCx) * @arg @ref LL_ADC_CHANNEL_VINP1_VINM1 * @arg @ref LL_ADC_CHANNEL_VINP2_VINM2 * @arg @ref LL_ADC_CHANNEL_VINP3_VINM3 - * @arg @ref LL_ADC_CHANNEL_VBAT - * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR * @param Range This parameter can be one of the following values: * @arg @ref LL_ADC_VIN_RANGE_1V2 * @arg @ref LL_ADC_VIN_RANGE_2V4 @@ -2108,8 +2106,6 @@ __STATIC_INLINE void LL_ADC_SetChannelVoltageRange(ADC_TypeDef *ADCx, uint32_t C * @arg @ref LL_ADC_CHANNEL_VINP1_VINM1 * @arg @ref LL_ADC_CHANNEL_VINP2_VINM2 * @arg @ref LL_ADC_CHANNEL_VINP3_VINM3 - * @arg @ref LL_ADC_CHANNEL_VBAT - * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR * @retval Returned value can be one of the following values: * @arg @ref LL_ADC_VIN_RANGE_1V2 * @arg @ref LL_ADC_VIN_RANGE_2V4 diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_pka.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_pka.h index 047db024e..d5eea192d 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_pka.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_pka.h @@ -1,6 +1,6 @@ /** ****************************************************************************** - * @filestm32wb0x_ll_pka.h + * @file stm32wb0x_ll_pka.h * @author MCD Application Team * @brief Header file of PKA LL module. ****************************************************************************** diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_rcc.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_rcc.h index b41529d4d..c38f1b655 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_rcc.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_rcc.h @@ -1787,7 +1787,7 @@ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LPURSTREL(void) */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LOCKUPRST(void) { - return ((READ_BIT(RCC->CSR, RCC_CSR_LOCKUPRSTF) == (RCC_CSR_LOCKUPRSTF)) ? 1UL : 0UL); + return (((RAM_VR.ResetReason & LL_RCC_CSR_LOCKUPRSTF) == LL_RCC_CSR_LOCKUPRSTF) ? 1UL : 0UL); } /** @@ -1797,7 +1797,7 @@ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LOCKUPRST(void) */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_WDGRST(void) { - return ((READ_BIT(RCC->CSR, RCC_CSR_WDGRSTF) == (RCC_CSR_WDGRSTF)) ? 1UL : 0UL); + return (((RAM_VR.ResetReason & LL_RCC_CSR_WDGRSTF) == LL_RCC_CSR_WDGRSTF) ? 1UL : 0UL); } /** @@ -1807,7 +1807,7 @@ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_WDGRST(void) */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_SFTRST(void) { - return ((READ_BIT(RCC->CSR, RCC_CSR_SFTRSTF) == (RCC_CSR_SFTRSTF)) ? 1UL : 0UL); + return (((RAM_VR.ResetReason & LL_RCC_CSR_SFTRSTF) == LL_RCC_CSR_SFTRSTF) ? 1UL : 0UL); } /** @@ -1817,7 +1817,7 @@ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_SFTRST(void) */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PORRST(void) { - return ((READ_BIT(RCC->CSR, RCC_CSR_PORRSTF) == (RCC_CSR_PORRSTF)) ? 1UL : 0UL); + return (((RAM_VR.ResetReason & LL_RCC_CSR_PORRSTF) == LL_RCC_CSR_PORRSTF) ? 1UL : 0UL); } /** @@ -1827,17 +1827,16 @@ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PORRST(void) */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PADRST(void) { - return ((READ_BIT(RCC->CSR, RCC_CSR_PADRSTF) == (RCC_CSR_PADRSTF)) ? 1UL : 0UL); + return (((RAM_VR.ResetReason & LL_RCC_CSR_PADRSTF) == LL_RCC_CSR_PADRSTF) ? 1UL : 0UL); } /** - * @brief Set RMVF bit to clear the reset flags. - * @rmtoll CSR RMVF LL_RCC_ClearResetFlags + * @brief Clear all reset flags. * @retval None */ __STATIC_INLINE void LL_RCC_ClearResetFlags(void) { - WRITE_REG(RCC->CSR, RCC_CSR_RMVF); + RAM_VR.ResetReason = 0; } /** diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_rng.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_rng.h index e4ad0cb44..379539ff0 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_rng.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_rng.h @@ -677,35 +677,6 @@ __STATIC_INLINE uint32_t LL_RNG_GetSamplingClockEnableDivider(RNG_TypeDef *RNGx) return (uint32_t)(READ_BIT(RNGx->CR, RNG_CR_CLKDIV_15_0) >> RNG_CR_CLKDIV_15_0_Pos); } -/** - * @brief Set the random raw values from the random sources - * @note Available only in test mode for analog characterization where tst_bypass_ana_i input of the IP is - set to 10x0 Post processing is used0x1 Post processing is bypassed - * @rmtoll CR BP_POSTP LL_RNG_SetBypassOfPostProcessing - * @param RNGx RNG Instance - * @param value can be one of the following values: - * @arg LL_RNG_CR_BP_POSTP_0 - * @arg LL_RNG_CR_BP_POSTP_1 - * @retval None - */ -__STATIC_INLINE void LL_RNG_SetBypassOfPostProcessing(RNG_TypeDef *RNGx, uint32_t value) -{ - MODIFY_REG(RNGx->CR, RNG_CR_BP_POSTP, value); -} - -/** - * @brief Get the random raw values from the random sources - * @note Available only in test mode for analog characterization where tst_bypass_ana_i input of the IP is - set to 10x0 Post processing is used0x1 Post processing is bypassed - * @rmtoll CR BP_POSTP LL_RNG_GetBypassOfPostProcessing - * @retval can be one of the following values - * @arg LL_RNG_CR_BP_POSTP_0 - * @arg LL_RNG_CR_BP_POSTP_1 - */ -__STATIC_INLINE uint32_t LL_RNG_GetBypassOfPostProcessing(RNG_TypeDef *RNGx) -{ - return (uint32_t)(READ_BIT(RNGx->CR, RNG_CR_BP_POSTP)); -} /** * @brief Indicate if DISABLED value Flag is set or not. @@ -1870,6 +1841,39 @@ __STATIC_INLINE uint32_t LL_RNG_GetErrorIrq(RNG_TypeDef *RNGx) return (uint32_t)(READ_BIT(RNGx->IRQ_SR, RNG_IRQ_SR_ERROR_IRQ)); } +/** + * @brief Clear the FF_FULL_IRQ flag + * @note Flag is cleared by writing a 1 + * @rmtoll IRQ_SR FF_FULL_IRQ LL_RNG_ClearFfFullIrq + * @param RNGx RNG Instance + * @retval None + */ +__STATIC_INLINE void LL_RNG_ClearFfFullIrq(RNG_TypeDef *RNGx) +{ + SET_BIT(RNGx->IRQ_SR, RNG_IRQ_SR_FF_FULL_IRQ); +} +/** + * @brief Clear the ERROR_IRQ flag + * @note Flag is cleared by writing a 1 + * @rmtoll IRQ_SR ERROR_IRQ LL_RNG_ClearErrorIrq + * @param RNGx RNG Instance + * @retval None + */ +__STATIC_INLINE void LL_RNG_ClearErrorIrq(RNG_TypeDef *RNGx) +{ + SET_BIT(RNGx->IRQ_SR, RNG_IRQ_SR_ERROR_IRQ); +} +/** + * @brief Check if Random Number Generator is enabled + * @rmtoll CR RNG_DIS LL_RNG_IsEnabled + * @param RNGx RNG Instance + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_RNG_IsEnabled(RNG_TypeDef *RNGx) +{ + return ((READ_BIT(RNGx->CR, RNG_CR_DISABLE) != (RNG_CR_DISABLE)) ? 1UL : 0UL); +} + #if defined(USE_FULL_LL_DRIVER) /** @defgroup RNG_LL_EF_Init Initialization and de-initialization functions * @{ diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_system.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_system.h index 0a53a5ff9..5811be123 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_system.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_system.h @@ -182,6 +182,18 @@ typedef struct */ #define LL_FLASH_WAIT_STATES_0 0x00000000U /*!< FLASH Zero wait state */ #define LL_FLASH_WAIT_STATES_1 FLASH_CONFIG_WAIT_STATES_0 /*!< FLASH One wait state */ +/** + * @} + */ + +/** @defgroup SYSTEM_LL_EC_FLASH_FLAGS FLASH Flags Definition + * @{ + */ +#define LL_FLASH_FLAG_CMDDONE FLASH_IRQRAW_CMDDONE_RIS /*!< FLASH command done flag */ +#define LL_FLASH_FLAG_CMDSTART FLASH_IRQRAW_CMDSTART_RIS /*!< FLASH command started flag */ +#define LL_FLASH_FLAG_CMDERR FLASH_IRQRAW_CMDERR_RIS /*!< FLASH command error flag */ +#define LL_FLASH_FLAG_ILLCMD FLASH_IRQRAW_ILLCMD_RIS /*!< FLASH illegal command flag */ + /** * @} */ @@ -1378,10 +1390,10 @@ __STATIC_INLINE void LL_FLASH_DisableIT(FLASH_TypeDef *FLASHx, uint32_t interrup * @param FLASHx FLASH Instance * @param interrupt FLASH interrupt * This parameter can be any combination of the following values: - * @arg @ref FLASH_IT_CMDDONE Command Done Interrupt - * @arg @ref FLASH_IT_CMDSTART Command Started Interrupt - * @arg @ref FLASH_IT_CMDERR Command Error Interrupt - * @arg @ref FLASH_IT_ILLCMD Illegal Command Interrupt + * @arg @ref LL_FLASH_IT_CMDDONE Command Done Interrupt + * @arg @ref LL_FLASH_IT_CMDSTART Command Started Interrupt + * @arg @ref LL_FLASH_IT_CMDERR Command Error Interrupt + * @arg @ref LL_FLASH_IT_ILLCMD Illegal Command Interrupt * @retval The new state of interrupt flag (SET or RESET). */ __STATIC_INLINE uint32_t LL_FLASH_GetIT(FLASH_TypeDef *FLASHx, uint32_t interrupt) @@ -1394,10 +1406,10 @@ __STATIC_INLINE uint32_t LL_FLASH_GetIT(FLASH_TypeDef *FLASHx, uint32_t interrup * @param FLASHx FLASH Instance * @param interrupt FLASH interrupt * This parameter can be any combination of the following values: - * @arg @ref FLASH_IT_CMDDONE Command Done Interrupt - * @arg @ref FLASH_IT_CMDSTART Command Started Interrupt - * @arg @ref FLASH_IT_CMDERR Command Error Interrupt - * @arg @ref FLASH_IT_ILLCMD Illegal Command Interrupt + * @arg @ref LL_FLASH_IT_CMDDONE Command Done Interrupt + * @arg @ref LL_FLASH_IT_CMDSTART Command Started Interrupt + * @arg @ref LL_FLASH_IT_CMDERR Command Error Interrupt + * @arg @ref LL_FLASH_IT_ILLCMD Illegal Command Interrupt * @retval None */ __STATIC_INLINE void LL_FLASH_ClearIT(FLASH_TypeDef *FLASHx, uint32_t interrupt) diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_utils.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_utils.h index dd51863af..1f6f452a7 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_utils.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_utils.h @@ -228,7 +228,7 @@ __STATIC_INLINE uint32_t LL_GetFlashSize(void) */ __STATIC_INLINE uint32_t LL_GetPackageType(void) { - return (uint32_t)(READ_REG(*((uint32_t *)PACKAGE_BASE_ADDRESS)) & 0x1FU); + return (uint32_t)(READ_REG(*((uint32_t *)PACKAGE_BASE_ADDRESS))); } /** diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_adc.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_adc.c index faa575652..670dbf16a 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_adc.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_adc.c @@ -153,7 +153,7 @@ while off-loading the CPU (ratio adjustable from 1 to 128). (#) Disable the ADC interface (++) ADC clock can be hard reset and disabled at RCC top level. (++) Hard reset of ADC peripherals - using macro __ADCx_FORCE_RESET(), __ADCx_RELEASE_RESET(). + using macro __HAL_RCC_ADC_FORCE_RESET(), __HAL_RCC_ADC_RELEASE_RESET(). (++) ADC clock disable using the equivalent macro/functions as configuration step. (+++) Example: @@ -165,13 +165,13 @@ while off-loading the CPU (ratio adjustable from 1 to 128). (#) Optionally, in case of usage of ADC with interruptions: (++) Disable the NVIC for ADC - using function HAL_NVIC_EnableIRQ(ADCx_IRQn) + using function HAL_NVIC_DisableIRQ(ADCx_IRQn) (#) Optionally, in case of usage of DMA: (++) Deinitialize the DMA - using function HAL_DMA_Init(). + using function HAL_DMA_DeInit(). (++) Disable the NVIC for DMA - using function HAL_NVIC_EnableIRQ(DMAx_Channelx_IRQn) + using function HAL_NVIC_DisableIRQ(DMAx_Channelx_IRQn) [..] @@ -2212,7 +2212,11 @@ HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef *hadc, const ADC_Chann if (LL_ADC_IsConversionOngoing(hadc->Instance) == 0UL) { LL_ADC_SetSequencerRanks(hadc->Instance, sConfigChannel->Rank, sConfigChannel->Channel); - LL_ADC_SetChannelVoltageRange(hadc->Instance, sConfigChannel->Channel, sConfigChannel->VoltRange); + if ((sConfigChannel->Channel != ADC_CHANNEL_TEMPSENSOR) + && (sConfigChannel->Channel != ADC_CHANNEL_VBAT)) + { + LL_ADC_SetChannelVoltageRange(hadc->Instance, sConfigChannel->Channel, sConfigChannel->VoltRange); + } } /* If a conversion is on going no update could be done on */ /* neither of the channel configuration structure parameters. */ @@ -2233,7 +2237,7 @@ HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef *hadc, const ADC_Chann else if ((sConfigChannel->VoltRange == ADC_VIN_RANGE_1V2) || (sConfigChannel->Channel == ADC_CHANNEL_TEMPSENSOR)) { - /* 1.2V mode: [calibrated gain =0.96, gain clamped at 1] */ + /* 1.2V mode: [calibrated gain = 0.96, gain clamped at 1] */ tmp_gain = 0xFFFUL; } else if (sConfigChannel->VoltRange == ADC_VIN_RANGE_2V4) diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_i2c.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_i2c.c index f0b3a666b..afb424583 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_i2c.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_i2c.c @@ -3277,6 +3277,8 @@ HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAdd __IO uint32_t I2C_Trials = 0UL; + HAL_StatusTypeDef status = HAL_OK; + FlagStatus tmp1; FlagStatus tmp2; @@ -3334,37 +3336,64 @@ HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAdd /* Wait until STOPF flag is reset */ if (I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_STOPF, RESET, Timeout, tickstart) != HAL_OK) { - return HAL_ERROR; + /* A non acknowledge appear during STOP Flag waiting process, a new trial must be performed */ + if (hi2c->ErrorCode == HAL_I2C_ERROR_AF) + { + /* Clear STOP Flag */ + __HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_STOPF); + + /* Reset the error code for next trial */ + hi2c->ErrorCode = HAL_I2C_ERROR_NONE; + } + else + { + status = HAL_ERROR; + } } + else + { + /* A acknowledge appear during STOP Flag waiting process, this mean that device respond to its address */ - /* Clear STOP Flag */ - __HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_STOPF); + /* Clear STOP Flag */ + __HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_STOPF); - /* Device is ready */ - hi2c->State = HAL_I2C_STATE_READY; + /* Device is ready */ + hi2c->State = HAL_I2C_STATE_READY; - /* Process Unlocked */ - __HAL_UNLOCK(hi2c); + /* Process Unlocked */ + __HAL_UNLOCK(hi2c); - return HAL_OK; + return HAL_OK; + } } else { - /* Wait until STOPF flag is reset */ - if (I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_STOPF, RESET, Timeout, tickstart) != HAL_OK) - { - return HAL_ERROR; - } + /* A non acknowledge is detected, this mean that device not respond to its address, + a new trial must be performed */ /* Clear NACK Flag */ __HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_AF); - /* Clear STOP Flag, auto generated with autoend*/ - __HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_STOPF); + /* Wait until STOPF flag is reset */ + if (I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_STOPF, RESET, Timeout, tickstart) != HAL_OK) + { + status = HAL_ERROR; + } + else + { + /* Clear STOP Flag, auto generated with autoend*/ + __HAL_I2C_CLEAR_FLAG(hi2c, I2C_FLAG_STOPF); + } } /* Increment Trials */ I2C_Trials++; + + if ((I2C_Trials < Trials) && (status == HAL_ERROR)) + { + status = HAL_OK; + } + } while (I2C_Trials < Trials); /* Update I2C state */ @@ -6377,7 +6406,7 @@ static void I2C_ITSlaveCplt(I2C_HandleTypeDef *hi2c, uint32_t ITFlags) /* Increment Buffer pointer */ hi2c->pBuffPtr++; - if ((hi2c->XferSize > 0U)) + if (hi2c->XferSize > 0U) { hi2c->XferSize--; hi2c->XferCount--; @@ -6533,7 +6562,7 @@ static void I2C_ITListenCplt(I2C_HandleTypeDef *hi2c, uint32_t ITFlags) /* Increment Buffer pointer */ hi2c->pBuffPtr++; - if ((hi2c->XferSize > 0U)) + if (hi2c->XferSize > 0U) { hi2c->XferSize--; hi2c->XferCount--; @@ -6987,7 +7016,7 @@ static HAL_StatusTypeDef I2C_WaitOnFlagUntilTimeout(I2C_HandleTypeDef *hi2c, uin { if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) { - if ((__HAL_I2C_GET_FLAG(hi2c, Flag) == Status)) + if (__HAL_I2C_GET_FLAG(hi2c, Flag) == Status) { hi2c->ErrorCode |= HAL_I2C_ERROR_TIMEOUT; hi2c->State = HAL_I2C_STATE_READY; @@ -7027,7 +7056,7 @@ static HAL_StatusTypeDef I2C_WaitOnTXISFlagUntilTimeout(I2C_HandleTypeDef *hi2c, { if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) { - if ((__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_TXIS) == RESET)) + if (__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_TXIS) == RESET) { hi2c->ErrorCode |= HAL_I2C_ERROR_TIMEOUT; hi2c->State = HAL_I2C_STATE_READY; @@ -7066,7 +7095,7 @@ static HAL_StatusTypeDef I2C_WaitOnSTOPFlagUntilTimeout(I2C_HandleTypeDef *hi2c, /* Check for the Timeout */ if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) { - if ((__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_STOPF) == RESET)) + if (__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_STOPF) == RESET) { hi2c->ErrorCode |= HAL_I2C_ERROR_TIMEOUT; hi2c->State = HAL_I2C_STATE_READY; @@ -7144,7 +7173,7 @@ static HAL_StatusTypeDef I2C_WaitOnRXNEFlagUntilTimeout(I2C_HandleTypeDef *hi2c, /* Check for the Timeout */ if ((((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) && (status == HAL_OK)) { - if ((__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_RXNE) == RESET)) + if (__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_RXNE) == RESET) { hi2c->ErrorCode |= HAL_I2C_ERROR_TIMEOUT; hi2c->State = HAL_I2C_STATE_READY; @@ -7311,15 +7340,17 @@ static HAL_StatusTypeDef I2C_IsErrorOccurred(I2C_HandleTypeDef *hi2c, uint32_t T static void I2C_TransferConfig(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t Size, uint32_t Mode, uint32_t Request) { + uint32_t tmp; + /* Check the parameters */ assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance)); assert_param(IS_TRANSFER_MODE(Mode)); assert_param(IS_TRANSFER_REQUEST(Request)); /* Declaration of tmp to prevent undefined behavior of volatile usage */ - uint32_t tmp = ((uint32_t)(((uint32_t)DevAddress & I2C_CR2_SADD) | \ - (((uint32_t)Size << I2C_CR2_NBYTES_Pos) & I2C_CR2_NBYTES) | \ - (uint32_t)Mode | (uint32_t)Request) & (~0x80000000U)); + tmp = ((uint32_t)(((uint32_t)DevAddress & I2C_CR2_SADD) | \ + (((uint32_t)Size << I2C_CR2_NBYTES_Pos) & I2C_CR2_NBYTES) | \ + (uint32_t)Mode | (uint32_t)Request) & (~0x80000000U)); /* update CR2 register */ MODIFY_REG(hi2c->Instance->CR2, \ diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio.c index ae36e1a95..3fcbc3c7a 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio.c @@ -1,6 +1,6 @@ /** ****************************************************************************** - * @file stm32wb0x_hal_radio.h + * @file stm32wb0x_hal_radio.c * @author GPM WBL Application Team * @brief This file provides all the Radio Driver APIs. ****************************************************************************** @@ -204,17 +204,11 @@ static uint8_t CondRoutineRxTrue(ActionPacket *p) /* Round up HOT_TABLE_SIZE to an integer number of words then add 4 words for table management pointers */ volatile uint32_t hot_table_radio_config_u32[((HOT_TABLE_SIZE + 3) >> 2) + 4] = {0x00}; -#if 0 /** PATCH: do not define __blue_RAM here */ +#ifndef __ZEPHYR__ /** do not define __blue_RAM here, it is defined in Zephyr wtm32wb0x/soc.c */ /* BLUE RAM, reserved for radio communication. Not usable from the application */ __SECTION(".bss.__blue_RAM") -#if defined(STM32WB05) || defined(STM32WB09) -__REQUIRED(uint8_t __blue_RAM[CFG_NUM_RADIO_TASKS * 92 + 28]) = {0,}; -#elif defined(STM32WB06) || defined (STM32WB07) -__REQUIRED(uint8_t __blue_RAM[CFG_NUM_RADIO_TASKS * 80 + 28]) = {0,}; -#else -#warning "No Blue RAM allocated" -#endif -#endif /* ENDOF PATCH */ +__REQUIRED(uint8_t __blue_RAM[CFG_NUM_RADIO_TASKS * sizeof(STATMACH_TypeDef) + sizeof(GLOBALSTATMACH_TypeDef)]) = {0,}; +#endif /* __ZEPHYR__ */ /** * @} @@ -344,7 +338,7 @@ void HAL_RADIO_Init(RADIO_HandleTypeDef *hradio) #endif /* The commands in the hot table start at word 4 - * The words 0 t0 2 are used to point to the command list + * The words 0 to 2 are used to point to the command list * for the various trigger events, word 3 is a null command * (see function BLEPLAT_CNTR_SetRadioConfigData) */ @@ -398,7 +392,7 @@ void HAL_RADIO_Init(RADIO_HandleTypeDef *hradio) LL_RADIO_SetRadioConfigurationAddressPointer(hot_table_radio_config_u32[0]); /* Reload radio config pointer */ - *(uint32_t *)(RRM_BASE + 0x10U) = 0x01U; + RRM->UDRA_CTRL0 = RRM_UDRA_CTRL0_RELOAD_RDCFGPTR; LL_RADIO_Active2ErrorInterrupt_Enable(); #if USE_RADIO_PROPRIETARY_DRIVER diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio_timer.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio_timer.c index ad4161b7c..c853200be 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio_timer.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio_timer.c @@ -445,6 +445,12 @@ void HAL_RADIO_TIMER_Tick(void) { /* Collect calibration data */ _updateCalibrationData(); + RADIO_TIMER_Context.rootNode = _update_user_timeout(RADIO_TIMER_Context.rootNode, &expired); + if (expired == 1) + { + /* A new root timer is already expired, mimic timer expire */ + INCREMENT_EXPIRE_COUNT; + } } #if defined (STM32WB06) || defined (STM32WB07) @@ -454,6 +460,11 @@ void HAL_RADIO_TIMER_Tick(void) RADIO_TIMER_Context.radioTimer.pending = TRUE; _check_radio_activity(&RADIO_TIMER_Context.radioTimer, &expired); RADIO_TIMER_Context.rootNode = _update_user_timeout(RADIO_TIMER_Context.rootNode, &expired); + if (expired == 1) + { + /* A new root timer is already expired, mimic timer expire */ + INCREMENT_EXPIRE_COUNT; + } } #else _check_radio_activity(&RADIO_TIMER_Context.radioTimer, &expired); @@ -1258,7 +1269,7 @@ static VTIMER_HandleType *_update_user_timeout(VTIMER_HandleType *rootNode, uint delay = curr->expiryTime - HAL_RADIO_TIMER_GetCurrentSysTime(); if (delay > 0) { - /* Protection against interrupt must be used to avoid that the called function will be interrupted + /* Protection against interrupt must be used to avoid that the called function will be interrupted and so the timer programming will happen after the target time is already passed leading to a timer expiring after timer wraps, instead of the expected delay */ #if defined (STM32WB06) || defined (STM32WB07) @@ -1490,11 +1501,10 @@ static void _update_system_time(RADIO_TIMER_ContextTypeDef *context) static void _check_radio_activity(RADIO_TIMER_RadioHandleTypeDef *timerHandle, uint8_t *expired) { uint64_t nextCalibrationEvent, currentTime; - *expired = 0; - if (timerHandle->pending) { + nextCalibrationEvent = RADIO_TIMER_Context.calibrationData.last_calibration_time + \ RADIO_TIMER_Context.calibrationSettings.periodicCalibrationInterval; @@ -1512,8 +1522,10 @@ static void _check_radio_activity(RADIO_TIMER_RadioHandleTypeDef *timerHandle, u } else { + RADIO_TIMER_Context.radioTimer.pending = FALSE; *expired = 1; + } } else @@ -1523,6 +1535,7 @@ static void _check_radio_activity(RADIO_TIMER_RadioHandleTypeDef *timerHandle, u #endif } ATOMIC_SECTION_END(); + } } diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_smbus.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_smbus.c index bff76c0b0..5edd3c07d 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_smbus.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_smbus.c @@ -1950,7 +1950,7 @@ static HAL_StatusTypeDef SMBUS_Master_ISR(SMBUS_HandleTypeDef *hsmbus, uint32_t /* Increment Buffer pointer */ hsmbus->pBuffPtr++; - if ((hsmbus->XferSize > 0U)) + if (hsmbus->XferSize > 0U) { hsmbus->XferSize--; hsmbus->XferCount--; @@ -2378,7 +2378,7 @@ static HAL_StatusTypeDef SMBUS_Slave_ISR(SMBUS_HandleTypeDef *hsmbus, uint32_t S /* Increment Buffer pointer */ hsmbus->pBuffPtr++; - if ((hsmbus->XferSize > 0U)) + if (hsmbus->XferSize > 0U) { hsmbus->XferSize--; hsmbus->XferCount--; diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_uart.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_uart.c index c6736cb77..ef6aad3bf 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_uart.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_uart.c @@ -3897,7 +3897,6 @@ static void UART_DMAAbortOnError(DMA_HandleTypeDef *hdma) { UART_HandleTypeDef *huart = (UART_HandleTypeDef *)(hdma->Parent); huart->RxXferCount = 0U; - huart->TxXferCount = 0U; #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) /*Call registered error callback*/ diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_ll_pka.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_ll_pka.c index 53844fdb8..4364cf19e 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_ll_pka.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_ll_pka.c @@ -1,6 +1,6 @@ /** ****************************************************************************** - * @filestm32wb0x_ll_pka.c + * @file stm32wb0x_ll_pka.c * @author MCD Application Team * @brief PKA LL module driver. ****************************************************************************** diff --git a/stm32cube/stm32wb0x/soc/stm32wb09.h b/stm32cube/stm32wb0x/soc/stm32wb09.h index ece321a75..97331bd04 100644 --- a/stm32cube/stm32wb0x/soc/stm32wb09.h +++ b/stm32cube/stm32wb0x/soc/stm32wb09.h @@ -4148,9 +4148,6 @@ typedef struct /*!< WAKEUP Structure */ /* ============================================================================================================================*/ /* ===================================================== CR =====================================================*/ -#define RNG_CR_BP_POSTP_Pos (24UL) /*!CR2, PWR_CR2_RAMRET2); #endif /* PWR_CR2_RAMRET2 */ -#if defined(PWR_CR2_RAMRET2) +#if defined(PWR_CR2_RAMRET3) SET_BIT(PWR->CR2, PWR_CR2_RAMRET3); #endif /* PWR_CR2_RAMRET3 */ diff --git a/stm32cube/stm32wb0x/soc/system_stm32wb0x.h b/stm32cube/stm32wb0x/soc/system_stm32wb0x.h index 949157557..eea0a6500 100644 --- a/stm32cube/stm32wb0x/soc/system_stm32wb0x.h +++ b/stm32cube/stm32wb0x/soc/system_stm32wb0x.h @@ -66,7 +66,7 @@ extern "C" { * @brief RAM base address */ #define _MEMORY_RAM_BEGIN_ 0x20000000 -#define _MEMORY_RAM_SIZE_ 0x10000 /* 32KB */ +#define _MEMORY_RAM_SIZE_ 0x8000 /* 32KB */ #define _MEMORY_RAM_END_ 0x20007FFF /** From b8043adc10b3b396dda58ff1e3c759e08752861c Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Fri, 12 Dec 2025 11:44:35 +0100 Subject: [PATCH 03/11] stm32cube: common_ll: Regeneration after cube updates Re - generate common_ll headers after Cube updates Signed-off-by: Etienne Carriere --- stm32cube/common_ll/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stm32cube/common_ll/README.rst b/stm32cube/common_ll/README.rst index 2622c1e77..cc110a308 100644 --- a/stm32cube/common_ll/README.rst +++ b/stm32cube/common_ll/README.rst @@ -33,7 +33,7 @@ stm32n6xx 1.2.0 stm32u0xx 1.3.0 stm32u3xx 1.2.0 stm32u5xx 1.8.0 -stm32wb0x 1.0.0 +stm32wb0x 1.1.0 stm32wbaxx 1.7.0 stm32wbxx 1.23.0 stm32wlxx 1.3.1 From 84e3986a052ba3b327ecc4280f36fadd370448b2 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Thu, 11 Dec 2025 19:35:16 +0100 Subject: [PATCH 04/11] lib/stm32wb0: update paths to upgrade to STM32CubeWB0 1.1.0 or later Some common source and header files have moved in STM32CubeWB0 from a project specific directory to a common Common/BLE/ directory. Update local files paths to ease later update using update_stm32_package.py script. Signed-off-by: Etienne Carriere --- lib/stm32wb0/CMakeLists.txt | 28 +++++++++---------- .../System => Common/BLE}/Interfaces/hw_aes.c | 0 .../System => Common/BLE}/Interfaces/hw_aes.h | 0 .../System => Common/BLE}/Interfaces/hw_pka.c | 0 .../System => Common/BLE}/Interfaces/hw_pka.h | 0 .../System => Common/BLE}/Interfaces/hw_rng.c | 0 .../System => Common/BLE}/Interfaces/hw_rng.h | 0 .../BLE}/Modules/PKAMGR/Inc/pka_manager.h | 0 .../BLE}/Modules/PKAMGR/Src/pka_manager.c | 0 .../Modules/RADIO_utils/Inc/RADIO_utils.h | 0 .../Modules/RADIO_utils/Src/RADIO_utils.c | 0 .../System => Common/BLE}/Modules/asm.h | 0 .../BLE}/Modules/blue_unit_conversion.s | 0 .../System => Common/BLE}/Modules/compiler.h | 0 .../BLE}/Modules/crash_handler.h | 0 .../System => Common/BLE}/Modules/miscutil.c | 0 .../System => Common/BLE}/Modules/miscutil.h | 0 .../System => Common/BLE}/Modules/osal.h | 0 .../BLE}/Modules/osal_memcpy.s | 0 19 files changed, 14 insertions(+), 14 deletions(-) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Interfaces/hw_aes.c (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Interfaces/hw_aes.h (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Interfaces/hw_pka.c (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Interfaces/hw_pka.h (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Interfaces/hw_rng.c (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Interfaces/hw_rng.h (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Modules/PKAMGR/Inc/pka_manager.h (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Modules/PKAMGR/Src/pka_manager.c (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Modules/RADIO_utils/Inc/RADIO_utils.h (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Modules/RADIO_utils/Src/RADIO_utils.c (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Modules/asm.h (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Modules/blue_unit_conversion.s (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Modules/compiler.h (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Modules/crash_handler.h (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Modules/miscutil.c (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Modules/miscutil.h (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Modules/osal.h (100%) rename lib/stm32wb0/{BLE_TransparentMode/System => Common/BLE}/Modules/osal_memcpy.s (100%) diff --git a/lib/stm32wb0/CMakeLists.txt b/lib/stm32wb0/CMakeLists.txt index 5e23eed06..b5951ad48 100644 --- a/lib/stm32wb0/CMakeLists.txt +++ b/lib/stm32wb0/CMakeLists.txt @@ -5,19 +5,19 @@ zephyr_library() if(CONFIG_STM32WB0_RADIO_TIMER) - zephyr_include_directories(BLE_TransparentMode/System/Modules) - zephyr_library_sources(BLE_TransparentMode/System/Modules/blue_unit_conversion.s) + zephyr_include_directories(Common/BLE/Modules) + zephyr_library_sources(Common/BLE/Modules/blue_unit_conversion.s) endif() if(CONFIG_BT_STM32WB0) # Set the correct directory zephyr_include_directories(STM32_BLE) zephyr_include_directories(STM32_BLE/stack/include) -zephyr_include_directories(BLE_TransparentMode/System/Modules/PKAMGR/Inc) -zephyr_include_directories(BLE_TransparentMode/System/Interfaces) -zephyr_include_directories(BLE_TransparentMode/System/Modules/RADIO_utils/Inc) -zephyr_include_directories(BLE_TransparentMode/System/Config/Debug_GPIO) -zephyr_include_directories(BLE_TransparentMode/System/Modules/RTDebug) +zephyr_include_directories(Common/BLE/Modules/PKAMGR/Inc) +zephyr_include_directories(Common/BLE/Interfaces) +zephyr_include_directories(Common/BLE/Modules/RADIO_utils/Inc) +zephyr_include_directories(Common/BLE/Config/Debug_GPIO) +zephyr_include_directories(Common/BLE/Modules/RTDebug) zephyr_include_directories(BLE_TransparentMode/Core/Inc) zephyr_include_directories(BLE_TransparentMode/STM32_BLE/App) @@ -291,17 +291,17 @@ set_source_files_properties(BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c PROPE set_source_files_properties(STM32_BLE/stack/config/ble_stack_user_cfg.c PROPERTIES COMPILE_FLAGS -Wno-array-parameter) zephyr_library_sources(BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c) zephyr_library_sources(BLE_TransparentMode/STM32_BLE/Target/bleplat.c) -zephyr_library_sources(BLE_TransparentMode/System/Modules/PKAMGR/Src/pka_manager.c) -zephyr_library_sources(BLE_TransparentMode/System/Interfaces/hw_aes.c) -zephyr_library_sources(BLE_TransparentMode/System/Interfaces/hw_pka.c) -zephyr_library_sources(BLE_TransparentMode/System/Interfaces/hw_rng.c) -zephyr_library_sources(BLE_TransparentMode/System/Modules/osal_memcpy.s) +zephyr_library_sources(Common/BLE/Modules/PKAMGR/Src/pka_manager.c) +zephyr_library_sources(Common/BLE/Interfaces/hw_aes.c) +zephyr_library_sources(Common/BLE/Interfaces/hw_pka.c) +zephyr_library_sources(Common/BLE/Interfaces/hw_rng.c) +zephyr_library_sources(Common/BLE/Modules/osal_memcpy.s) zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc_tiny.c) zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/transport_layer.c) zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/dtm_preprocess_events.c) zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/adv_buff_alloc.c) -zephyr_library_sources(BLE_TransparentMode/System/Modules/RADIO_utils/Src/RADIO_utils.c) -zephyr_library_sources(BLE_TransparentMode/System/Modules/miscutil.c) +zephyr_library_sources(Common/BLE/Modules/RADIO_utils/Src/RADIO_utils.c) +zephyr_library_sources(Common/BLE/Modules/miscutil.c) zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/pawr_buff_alloc.c) zephyr_library_sources(STM32_BLE/stack/config/ble_stack_user_cfg.c) zephyr_library_sources(BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c) diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_aes.c b/lib/stm32wb0/Common/BLE/Interfaces/hw_aes.c similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_aes.c rename to lib/stm32wb0/Common/BLE/Interfaces/hw_aes.c diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_aes.h b/lib/stm32wb0/Common/BLE/Interfaces/hw_aes.h similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_aes.h rename to lib/stm32wb0/Common/BLE/Interfaces/hw_aes.h diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_pka.c b/lib/stm32wb0/Common/BLE/Interfaces/hw_pka.c similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_pka.c rename to lib/stm32wb0/Common/BLE/Interfaces/hw_pka.c diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_pka.h b/lib/stm32wb0/Common/BLE/Interfaces/hw_pka.h similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_pka.h rename to lib/stm32wb0/Common/BLE/Interfaces/hw_pka.h diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_rng.c b/lib/stm32wb0/Common/BLE/Interfaces/hw_rng.c similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_rng.c rename to lib/stm32wb0/Common/BLE/Interfaces/hw_rng.c diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_rng.h b/lib/stm32wb0/Common/BLE/Interfaces/hw_rng.h similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Interfaces/hw_rng.h rename to lib/stm32wb0/Common/BLE/Interfaces/hw_rng.h diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/PKAMGR/Inc/pka_manager.h b/lib/stm32wb0/Common/BLE/Modules/PKAMGR/Inc/pka_manager.h similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Modules/PKAMGR/Inc/pka_manager.h rename to lib/stm32wb0/Common/BLE/Modules/PKAMGR/Inc/pka_manager.h diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/PKAMGR/Src/pka_manager.c b/lib/stm32wb0/Common/BLE/Modules/PKAMGR/Src/pka_manager.c similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Modules/PKAMGR/Src/pka_manager.c rename to lib/stm32wb0/Common/BLE/Modules/PKAMGR/Src/pka_manager.c diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/RADIO_utils/Inc/RADIO_utils.h b/lib/stm32wb0/Common/BLE/Modules/RADIO_utils/Inc/RADIO_utils.h similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Modules/RADIO_utils/Inc/RADIO_utils.h rename to lib/stm32wb0/Common/BLE/Modules/RADIO_utils/Inc/RADIO_utils.h diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/RADIO_utils/Src/RADIO_utils.c b/lib/stm32wb0/Common/BLE/Modules/RADIO_utils/Src/RADIO_utils.c similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Modules/RADIO_utils/Src/RADIO_utils.c rename to lib/stm32wb0/Common/BLE/Modules/RADIO_utils/Src/RADIO_utils.c diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/asm.h b/lib/stm32wb0/Common/BLE/Modules/asm.h similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Modules/asm.h rename to lib/stm32wb0/Common/BLE/Modules/asm.h diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/blue_unit_conversion.s b/lib/stm32wb0/Common/BLE/Modules/blue_unit_conversion.s similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Modules/blue_unit_conversion.s rename to lib/stm32wb0/Common/BLE/Modules/blue_unit_conversion.s diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/compiler.h b/lib/stm32wb0/Common/BLE/Modules/compiler.h similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Modules/compiler.h rename to lib/stm32wb0/Common/BLE/Modules/compiler.h diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/crash_handler.h b/lib/stm32wb0/Common/BLE/Modules/crash_handler.h similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Modules/crash_handler.h rename to lib/stm32wb0/Common/BLE/Modules/crash_handler.h diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/miscutil.c b/lib/stm32wb0/Common/BLE/Modules/miscutil.c similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Modules/miscutil.c rename to lib/stm32wb0/Common/BLE/Modules/miscutil.c diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/miscutil.h b/lib/stm32wb0/Common/BLE/Modules/miscutil.h similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Modules/miscutil.h rename to lib/stm32wb0/Common/BLE/Modules/miscutil.h diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/osal.h b/lib/stm32wb0/Common/BLE/Modules/osal.h similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Modules/osal.h rename to lib/stm32wb0/Common/BLE/Modules/osal.h diff --git a/lib/stm32wb0/BLE_TransparentMode/System/Modules/osal_memcpy.s b/lib/stm32wb0/Common/BLE/Modules/osal_memcpy.s similarity index 100% rename from lib/stm32wb0/BLE_TransparentMode/System/Modules/osal_memcpy.s rename to lib/stm32wb0/Common/BLE/Modules/osal_memcpy.s From 32cf06e491287b381c8ec4f4477db1cec9c4703f Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Thu, 11 Dec 2025 19:36:54 +0100 Subject: [PATCH 05/11] lib/stm32wb0: indent with space chars in CMake file Replace tabulation indentation with space char indentation in CMakeLists.txt to betteer conform with CMake files convention. Signed-off-by: Etienne Carriere --- lib/stm32wb0/CMakeLists.txt | 230 ++++++++++++++++++------------------ 1 file changed, 115 insertions(+), 115 deletions(-) diff --git a/lib/stm32wb0/CMakeLists.txt b/lib/stm32wb0/CMakeLists.txt index b5951ad48..24f320951 100644 --- a/lib/stm32wb0/CMakeLists.txt +++ b/lib/stm32wb0/CMakeLists.txt @@ -5,8 +5,8 @@ zephyr_library() if(CONFIG_STM32WB0_RADIO_TIMER) - zephyr_include_directories(Common/BLE/Modules) - zephyr_library_sources(Common/BLE/Modules/blue_unit_conversion.s) + zephyr_include_directories(Common/BLE/Modules) + zephyr_library_sources(Common/BLE/Modules/blue_unit_conversion.s) endif() if(CONFIG_BT_STM32WB0) @@ -25,9 +25,9 @@ target_link_directories(app PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../zephyr/blob target_link_libraries(app PUBLIC -l:stm32wb0x_ble_stack_controller_only.a) function(min OUT_VAR) - list(SORT ARGN COMPARE NATURAL ORDER ASCENDING) - list(GET ARGN 0 MIN_ELEMENT) - set(${OUT_VAR} ${MIN_ELEMENT} PARENT_SCOPE) + list(SORT ARGN COMPARE NATURAL ORDER ASCENDING) + list(GET ARGN 0 MIN_ELEMENT) + set(${OUT_VAR} ${MIN_ELEMENT} PARENT_SCOPE) endfunction() ########### Begining of modularity selection ########### @@ -50,42 +50,42 @@ set(CFG_BLE_CONNECTION_SUBRATING_ENABLED "0") set(CFG_BLE_CONTROLLER_CIS_ENABLED "0") zephyr_compile_definitions( - -DBLESTACK_CONTROLLER_ONLY=1 - -DACI_HAL_GET_FIRMWARE_DETAILS_ENABLED=0 - -DACI_HAL_GET_FIRMWARE_DETAILS_V2_ENABLED=0 - -DACI_HAL_UPDATER_START_ENABLED=0 - -DACI_HAL_TRANSMITTER_TEST_PACKETS_ENABLED=0 - -DACI_HAL_TRANSMITTER_TEST_PACKETS_V2_ENABLED=0 - -DACI_HAL_WRITE_RADIO_REG_ENABLED=0 - -DACI_HAL_READ_RADIO_REG_ENABLED=0 + -DBLESTACK_CONTROLLER_ONLY=1 + -DACI_HAL_GET_FIRMWARE_DETAILS_ENABLED=0 + -DACI_HAL_GET_FIRMWARE_DETAILS_V2_ENABLED=0 + -DACI_HAL_UPDATER_START_ENABLED=0 + -DACI_HAL_TRANSMITTER_TEST_PACKETS_ENABLED=0 + -DACI_HAL_TRANSMITTER_TEST_PACKETS_V2_ENABLED=0 + -DACI_HAL_WRITE_RADIO_REG_ENABLED=0 + -DACI_HAL_READ_RADIO_REG_ENABLED=0 ) if(CONFIG_BT_OBSERVER) - set(CFG_BLE_CONTROLLER_SCAN_ENABLED "1") + set(CFG_BLE_CONTROLLER_SCAN_ENABLED "1") endif() if(CONFIG_BT_PRIVACY) - set(CFG_BLE_CONTROLLER_PRIVACY_ENABLED "1") + set(CFG_BLE_CONTROLLER_PRIVACY_ENABLED "1") endif() if(CONFIG_BT_SMP) - set(CFG_BLE_SECURE_CONNECTIONS_ENABLED "1") + set(CFG_BLE_SECURE_CONNECTIONS_ENABLED "1") endif() if(CONFIG_BT_CTLR_DATA_LENGTH GREATER 27) - set(CFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED "1") + set(CFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED "1") endif() if(CONFIG_BT_EXT_ADV) - set(CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED "1") + set(CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED "1") endif() if(CONFIG_BT_L2CAP_ECRED) - set(CFG_BLE_L2CAP_COS_ENABLED "1") + set(CFG_BLE_L2CAP_COS_ENABLED "1") endif() if(CONFIG_BT_PER_ADV OR CONFIG_BT_PER_ADV_SYNC) - set(CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED "1") + set(CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED "1") endif() if(CONFIG_BT_PER_ADV_RSP) @@ -93,23 +93,23 @@ if(CONFIG_BT_PER_ADV_RSP) endif() if(CONFIG_BT_DF) - set(CFG_BLE_CONTROLLER_CTE_ENABLED "1") + set(CFG_BLE_CONTROLLER_CTE_ENABLED "1") endif() if(CONFIG_BT_TRANSMIT_POWER_CONTROL) - set(CFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED "1") + set(CFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED "1") endif() if(CONFIG_BT_CONN) - set(CFG_BLE_CONNECTION_ENABLED "1") + set(CFG_BLE_CONNECTION_ENABLED "1") endif() if(CONFIG_BT_ISO_BROADCAST) - set(CFG_BLE_CONTROLLER_BIS_ENABLED "1") + set(CFG_BLE_CONTROLLER_BIS_ENABLED "1") endif() if(CONFIG_BT_ISO_UNICAST) - set(CFG_BLE_CONTROLLER_CIS_ENABLED "1") + set(CFG_BLE_CONTROLLER_CIS_ENABLED "1") endif() message(STATUS "BLE Stack modularity configuration:") @@ -131,22 +131,22 @@ message(STATUS "CONNECTION_SUBRATING_ENABLED=${CFG_BLE_CONNECTION_SUBRATING_ENAB message(STATUS "CONTROLLER_CIS_ENABLED=${CFG_BLE_CONTROLLER_CIS_ENABLED}") zephyr_compile_definitions( - -DCFG_BLE_CONTROLLER_SCAN_ENABLED=${CFG_BLE_CONTROLLER_SCAN_ENABLED} - -DCFG_BLE_CONTROLLER_PRIVACY_ENABLED=${CFG_BLE_CONTROLLER_PRIVACY_ENABLED} - -DCFG_BLE_SECURE_CONNECTIONS_ENABLED=${CFG_BLE_SECURE_CONNECTIONS_ENABLED} - -DCFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED=${CFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED} - -DCFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED=${CFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED} - -DCFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED=${CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED} - -DCFG_BLE_L2CAP_COS_ENABLED=${CFG_BLE_L2CAP_COS_ENABLED} - -DCFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED=${CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED} - -DCFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED=${CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED} - -DCFG_BLE_CONTROLLER_CTE_ENABLED=${CFG_BLE_CONTROLLER_CTE_ENABLED} - -DCFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED=${CFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED} - -DCFG_BLE_CONNECTION_ENABLED=${CFG_BLE_CONNECTION_ENABLED} - -DCFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED=${CFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED} - -DCFG_BLE_CONTROLLER_BIS_ENABLED=${CFG_BLE_CONTROLLER_BIS_ENABLED} - -DCFG_BLE_CONNECTION_SUBRATING_ENABLED=${CFG_BLE_CONNECTION_SUBRATING_ENABLED} - -DCFG_BLE_CONTROLLER_CIS_ENABLED=${CFG_BLE_CONTROLLER_CIS_ENABLED} + -DCFG_BLE_CONTROLLER_SCAN_ENABLED=${CFG_BLE_CONTROLLER_SCAN_ENABLED} + -DCFG_BLE_CONTROLLER_PRIVACY_ENABLED=${CFG_BLE_CONTROLLER_PRIVACY_ENABLED} + -DCFG_BLE_SECURE_CONNECTIONS_ENABLED=${CFG_BLE_SECURE_CONNECTIONS_ENABLED} + -DCFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED=${CFG_BLE_CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED} + -DCFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED=${CFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED} + -DCFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED=${CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED} + -DCFG_BLE_L2CAP_COS_ENABLED=${CFG_BLE_L2CAP_COS_ENABLED} + -DCFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED=${CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED} + -DCFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED=${CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED} + -DCFG_BLE_CONTROLLER_CTE_ENABLED=${CFG_BLE_CONTROLLER_CTE_ENABLED} + -DCFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED=${CFG_BLE_CONTROLLER_POWER_CONTROL_ENABLED} + -DCFG_BLE_CONNECTION_ENABLED=${CFG_BLE_CONNECTION_ENABLED} + -DCFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED=${CFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED} + -DCFG_BLE_CONTROLLER_BIS_ENABLED=${CFG_BLE_CONTROLLER_BIS_ENABLED} + -DCFG_BLE_CONNECTION_SUBRATING_ENABLED=${CFG_BLE_CONNECTION_SUBRATING_ENABLED} + -DCFG_BLE_CONTROLLER_CIS_ENABLED=${CFG_BLE_CONTROLLER_CIS_ENABLED} ) ########### End of modularity selection ########### @@ -165,66 +165,66 @@ set(CFG_BLE_NUM_AUX_SCAN_SLOTS "4") set(bt_max_conn "0") if(CONFIG_BT_PER_ADV_SYNC_MAX) - set(CFG_BLE_NUM_SYNC_SLOTS "${CONFIG_BT_PER_ADV_SYNC_MAX}") + set(CFG_BLE_NUM_SYNC_SLOTS "${CONFIG_BT_PER_ADV_SYNC_MAX}") endif() if(CONFIG_BT_EXT_ADV_MAX_ADV_SET) - set(CFG_BLE_NUM_ADV_SETS "${CONFIG_BT_EXT_ADV_MAX_ADV_SET}") + set(CFG_BLE_NUM_ADV_SETS "${CONFIG_BT_EXT_ADV_MAX_ADV_SET}") endif() if (CONFIG_BT_MAX_CONN) - #Maximum number of simultaneous connections - set(bt_max_conn "${CONFIG_BT_MAX_CONN}") + #Maximum number of simultaneous connections + set(bt_max_conn "${CONFIG_BT_MAX_CONN}") endif() if (CONFIG_BT_EATT_MAX) - # Maximum number of Enhanced ATT bearers - set(CFG_BLE_NUM_EATT_CHANNELS "${CONFIG_BT_EATT_MAX}") + # Maximum number of Enhanced ATT bearers + set(CFG_BLE_NUM_EATT_CHANNELS "${CONFIG_BT_EATT_MAX}") endif() if (CONFIG_BT_ISO_MAX_BIG) - # Maximum number of Broadcast Isochronous Groups (BIGs) to support - # A BIG can be used for either transmitting or receiving, but not at the same time. - if (CONFIG_BT_ISO_BROADCASTER) - set(CFG_BLE_NUM_BRC_BIG_MAX "${CONFIG_BT_ISO_MAX_BIG}") - endif() - if (CONFIG_BT_ISO_SYNC_RECEIVER) - set(CFG_BLE_NUM_SYNC_BIG_MAX "${CONFIG_BT_ISO_MAX_BIG}") - endif() + # Maximum number of Broadcast Isochronous Groups (BIGs) to support + # A BIG can be used for either transmitting or receiving, but not at the same time. + if (CONFIG_BT_ISO_BROADCASTER) + set(CFG_BLE_NUM_BRC_BIG_MAX "${CONFIG_BT_ISO_MAX_BIG}") + endif() + if (CONFIG_BT_ISO_SYNC_RECEIVER) + set(CFG_BLE_NUM_SYNC_BIG_MAX "${CONFIG_BT_ISO_MAX_BIG}") + endif() endif() if (CONFIG_BT_ISO_MAX_CHAN) - # Maximum number of simultaneous Bluetooth isochronous channels supported. - if (CONFIG_BT_ISO_BROADCASTER) - set(CFG_BLE_NUM_BRC_BIS_MAX "${CONFIG_BT_ISO_MAX_BIG}") - endif() - if (CONFIG_BT_ISO_SYNC_RECEIVER) - set(CFG_BLE_NUM_SYNC_BIS_MAX "${CONFIG_BT_ISO_MAX_BIG}") - endif() + # Maximum number of simultaneous Bluetooth isochronous channels supported. + if (CONFIG_BT_ISO_BROADCASTER) + set(CFG_BLE_NUM_BRC_BIS_MAX "${CONFIG_BT_ISO_MAX_BIG}") + endif() + if (CONFIG_BT_ISO_SYNC_RECEIVER) + set(CFG_BLE_NUM_SYNC_BIS_MAX "${CONFIG_BT_ISO_MAX_BIG}") + endif() endif() if (CONFIG_BT_ISO_MAX_CIG) - # Maximum number of CIGs that are supported by the host. - # A CIG can be used for either transmitting or receiving. - set(CFG_BLE_NUM_CIG_MAX "${CONFIG_BT_ISO_MAX_CIG}") + # Maximum number of CIGs that are supported by the host. + # A CIG can be used for either transmitting or receiving. + set(CFG_BLE_NUM_CIG_MAX "${CONFIG_BT_ISO_MAX_CIG}") endif() if (CONFIG_BT_ISO_MAX_CHAN) - # Maximum number of simultaneous Bluetooth isochronous channels supported. - set(CFG_BLE_NUM_CIS_MAX "${CONFIG_BT_ISO_MAX_CHAN}") + # Maximum number of simultaneous Bluetooth isochronous channels supported. + set(CFG_BLE_NUM_CIS_MAX "${CONFIG_BT_ISO_MAX_CHAN}") endif() zephyr_compile_definitions( - -DCFG_BLE_NUM_SYNC_SLOTS=${CFG_BLE_NUM_SYNC_SLOTS} - -DCFG_BLE_NUM_ADV_SETS=${CFG_BLE_NUM_ADV_SETS} - -DCFG_BLE_NUM_EATT_CHANNELS=${CFG_BLE_NUM_EATT_CHANNELS} - -DCFG_BLE_NUM_BRC_BIG_MAX=${CFG_BLE_NUM_BRC_BIG_MAX} - -DCFG_BLE_NUM_SYNC_BIG_MAX=${CFG_BLE_NUM_SYNC_BIG_MAX} - -DCFG_BLE_NUM_SYNC_BIS_MAX=${CFG_BLE_NUM_SYNC_BIS_MAX} - -DCFG_BLE_NUM_BRC_BIS_MAX=${CFG_BLE_NUM_BRC_BIS_MAX} - -DCFG_BLE_NUM_CIG_MAX=${CFG_BLE_NUM_CIG_MAX} - -DCFG_BLE_NUM_CIS_MAX=${CFG_BLE_NUM_CIS_MAX} - -DCFG_BLE_NUM_AUX_SCAN_SLOTS=${CFG_BLE_NUM_AUX_SCAN_SLOTS} + -DCFG_BLE_NUM_SYNC_SLOTS=${CFG_BLE_NUM_SYNC_SLOTS} + -DCFG_BLE_NUM_ADV_SETS=${CFG_BLE_NUM_ADV_SETS} + -DCFG_BLE_NUM_EATT_CHANNELS=${CFG_BLE_NUM_EATT_CHANNELS} + -DCFG_BLE_NUM_BRC_BIG_MAX=${CFG_BLE_NUM_BRC_BIG_MAX} + -DCFG_BLE_NUM_SYNC_BIG_MAX=${CFG_BLE_NUM_SYNC_BIG_MAX} + -DCFG_BLE_NUM_SYNC_BIS_MAX=${CFG_BLE_NUM_SYNC_BIS_MAX} + -DCFG_BLE_NUM_BRC_BIS_MAX=${CFG_BLE_NUM_BRC_BIS_MAX} + -DCFG_BLE_NUM_CIG_MAX=${CFG_BLE_NUM_CIG_MAX} + -DCFG_BLE_NUM_CIS_MAX=${CFG_BLE_NUM_CIS_MAX} + -DCFG_BLE_NUM_AUX_SCAN_SLOTS=${CFG_BLE_NUM_AUX_SCAN_SLOTS} ) ########### End of numeric value section ########### @@ -232,50 +232,50 @@ zephyr_compile_definitions( set(tasks "1") if(${CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED}) - MATH(EXPR tasks "2 * ${CFG_BLE_NUM_ADV_SETS}") - if(${CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED}) - MATH(EXPR tasks "${tasks} + ${CFG_BLE_NUM_ADV_SETS}") - if(${CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED} AND ${CFG_BLE_CONNECTION_ENABLED}) - MATH(EXPR tasks "${tasks} + 2 * ${CFG_BLE_NUM_ADV_SETS}") - endif() - if(${CFG_BLE_CONTROLLER_BIS_ENABLED}) - #radio_tasks += min(NUM_ADV_SETS_CONF, MAX_NUM_BRC_BIG) - min(temp ${CFG_BLE_NUM_ADV_SETS} ${CFG_BLE_NUM_BRC_BIG_MAX}) - MATH(EXPR tasks "${tasks} + ${temp}") - endif() - endif() + MATH(EXPR tasks "2 * ${CFG_BLE_NUM_ADV_SETS}") + if(${CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED}) + MATH(EXPR tasks "${tasks} + ${CFG_BLE_NUM_ADV_SETS}") + if(${CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED} AND ${CFG_BLE_CONNECTION_ENABLED}) + MATH(EXPR tasks "${tasks} + 2 * ${CFG_BLE_NUM_ADV_SETS}") + endif() + if(${CFG_BLE_CONTROLLER_BIS_ENABLED}) + #radio_tasks += min(NUM_ADV_SETS_CONF, MAX_NUM_BRC_BIG) + min(temp ${CFG_BLE_NUM_ADV_SETS} ${CFG_BLE_NUM_BRC_BIG_MAX}) + MATH(EXPR tasks "${tasks} + ${temp}") + endif() + endif() endif() if(${CFG_BLE_CONTROLLER_CIS_ENABLED} AND ${CFG_BLE_CONNECTION_ENABLED}) - MATH(EXPR tasks "${tasks} + ${CFG_BLE_NUM_CIG_MAX}") + MATH(EXPR tasks "${tasks} + ${CFG_BLE_NUM_CIG_MAX}") endif() if(${CFG_BLE_CONTROLLER_SCAN_ENABLED}) - MATH(EXPR tasks "${tasks} + 1") - if(${CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED}) - MATH(EXPR tasks "${tasks} + ${CFG_BLE_NUM_AUX_SCAN_SLOTS}") - if (${CFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED}) - MATH(EXPR tasks "${tasks} + 1") - endif() - if(${CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED}) - # radio_tasks += min(NUM_AUX_SCAN_SLOTS_CONF, NUM_SYNC_SLOTS_CONF) - min(temp ${CFG_BLE_NUM_AUX_SCAN_SLOTS} ${CFG_BLE_NUM_SYNC_SLOTS}) - MATH(EXPR tasks "${tasks} + ${temp}") - if(${CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED} AND ${CFG_BLE_CONNECTION_ENABLED}) - # radio_tasks += 2 * min(NUM_AUX_SCAN_SLOTS_CONF, NUM_SYNC_SLOTS_CONF) - min(temp ${CFG_BLE_NUM_AUX_SCAN_SLOTS} ${CFG_BLE_NUM_SYNC_SLOTS}) - MATH(EXPR tasks "${tasks} + 2*${temp}") - endif() - if(${CFG_BLE_CONTROLLER_BIS_ENABLED}) - #radio_tasks += min(NUM_AUX_SCAN_SLOTS_CONF, MAX_NUM_SYNC_BIG) - min(temp ${CFG_BLE_NUM_AUX_SCAN_SLOTS} ${CFG_BLE_NUM_SYNC_BIG_MAX}) - MATH(EXPR tasks "${tasks} +${temp}") - endif() - endif() - endif() # ${CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED} - if(${CFG_BLE_CONTROLLER_CIS_ENABLED} AND ${CFG_BLE_CONNECTION_ENABLED}) - MATH(EXPR tasks "${tasks} + ${CFG_BLE_NUM_CIG_MAX}") - endif() + MATH(EXPR tasks "${tasks} + 1") + if(${CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED}) + MATH(EXPR tasks "${tasks} + ${CFG_BLE_NUM_AUX_SCAN_SLOTS}") + if (${CFG_BLE_CONTROLLER_2M_CODED_PHY_ENABLED}) + MATH(EXPR tasks "${tasks} + 1") + endif() + if(${CFG_BLE_CONTROLLER_PERIODIC_ADV_ENABLED}) + # radio_tasks += min(NUM_AUX_SCAN_SLOTS_CONF, NUM_SYNC_SLOTS_CONF) + min(temp ${CFG_BLE_NUM_AUX_SCAN_SLOTS} ${CFG_BLE_NUM_SYNC_SLOTS}) + MATH(EXPR tasks "${tasks} + ${temp}") + if(${CFG_BLE_CONTROLLER_PERIODIC_ADV_WR_ENABLED} AND ${CFG_BLE_CONNECTION_ENABLED}) + # radio_tasks += 2 * min(NUM_AUX_SCAN_SLOTS_CONF, NUM_SYNC_SLOTS_CONF) + min(temp ${CFG_BLE_NUM_AUX_SCAN_SLOTS} ${CFG_BLE_NUM_SYNC_SLOTS}) + MATH(EXPR tasks "${tasks} + 2*${temp}") + endif() + if(${CFG_BLE_CONTROLLER_BIS_ENABLED}) + #radio_tasks += min(NUM_AUX_SCAN_SLOTS_CONF, MAX_NUM_SYNC_BIG) + min(temp ${CFG_BLE_NUM_AUX_SCAN_SLOTS} ${CFG_BLE_NUM_SYNC_BIG_MAX}) + MATH(EXPR tasks "${tasks} +${temp}") + endif() + endif() + endif() # ${CFG_BLE_CONTROLLER_EXT_ADV_SCAN_ENABLED} + if(${CFG_BLE_CONTROLLER_CIS_ENABLED} AND ${CFG_BLE_CONNECTION_ENABLED}) + MATH(EXPR tasks "${tasks} + ${CFG_BLE_NUM_CIG_MAX}") + endif() endif() message(STATUS "Number of computed radio tasks: ${tasks}") From e790e59d94f4d886e2c834ad3fbc312b90e50d5d Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Fri, 12 Dec 2025 11:16:53 +0100 Subject: [PATCH 06/11] lib/stm32wb0: bump to STM32CubeWB0 v1.1.0 Update stm32wb0 wireless library from STM32CubeWB0 release tag v1.0.0 to release tag v1.1.0 with Zephyr STM32 HAL local patches re-applied. This update was done manually, not using scripts/update_stm32_package.py that won't work due to major source/header file paths changes between STM32CubeWB0 release tags v1.0.0 and v1.1.0. Later updates will be able to be handled by the script. Signed-off-by: Etienne Carriere --- .../BLE_TransparentMode/Core/Inc/app_conf.h | 21 + .../Core/Src/stm32wb0x_hal_msp.c | 9 + .../STM32_BLE/App/aci_gatt_nwk.h | 17 + .../STM32_BLE/App/app_ble.h | 5 +- .../STM32_BLE/App/dtm_cmd_db.c | 114 +- .../STM32_BLE/App/dtm_cmd_en.h | 2 +- .../STM32_BLE/App/dtm_cmd_stack_en.h | 17 +- .../STM32_BLE/App/dtm_cmds.c | 2 + .../STM32_BLE/App/transport_layer.c | 6 +- .../STM32_BLE/Target/bleplat_cntr.c | 44 + lib/stm32wb0/Common/BLE/Interfaces/hw_pka.c | 2 +- lib/stm32wb0/README.rst | 40 +- .../stack/config/ble_stack_user_cfg.c | 178 +- .../STM32_BLE/stack/include/ble_api.h | 374 +- .../STM32_BLE/stack/include/ble_const.h | 46 +- .../STM32_BLE/stack/include/ble_events.h | 3217 ++++++++++++++++- .../STM32_BLE/stack/include/ble_gatt.h | 19 +- .../STM32_BLE/stack/include/ble_stack.h | 49 +- .../stack/include/ble_stack_user_cfg.h | 107 +- .../STM32_BLE/stack/include/ble_status.h | 8 +- .../STM32_BLE/stack/include/bleplat.h | 35 +- zephyr/module.yml | 6 +- 22 files changed, 4061 insertions(+), 257 deletions(-) diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_conf.h b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_conf.h index 16fb361be..cbc08d21f 100644 --- a/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_conf.h +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_conf.h @@ -148,6 +148,7 @@ #ifndef __ZEPHYR__ #define CFG_BLE_NUM_AUX_SCAN_SLOTS (4) #endif + /** * Maximum number of slots for synchronizing to a periodic advertising train, * if Periodic Advertising and Synchronizing Feature is enabled. @@ -223,6 +224,16 @@ */ #define CFG_BLE_USER_FIFO_SIZE (1024) +/** + * If 1, Peripheral Preferred Connection Parameters Characteristic is added in GAP service. + */ +#define CFG_BLE_GAP_PERIPH_PREF_CONN_PARAM_CHARACTERISTIC (1) + +/** + * If 1, Encrypted Key Material Characteristic is added in GAP service. + */ +#define CFG_BLE_GAP_ENCRYPTED_KEY_MATERIAL_CHARACTERISTIC (0) + /** * Number of allocated memory blocks used for packet allocation. * The use of BLE_STACK_MBLOCKS_CALC macro is suggested to calculate the minimum @@ -266,6 +277,11 @@ /****************************************************************************** * Initialization parameters used in Network Processor mode ******************************************************************************/ +/** + * Network mode (used in gap_profile.c) + */ +#define CFG_BLE_NETWORK_PROC_MODE (1) + /** * Size of buffer used for ATT queued writes */ @@ -287,6 +303,11 @@ */ #define CFG_BLE_GATT_ADV_NWK_BUFFER_SIZE (CFG_BLE_GATT_NWK_BUFFER_SIZE + CFG_BLE_ADV_NWK_BUFFER_SIZE + CFG_BLE_ATT_QUEUED_WRITE_SIZE) +/** +* Maximum number of characteristics that can be subscribed to check for security level. +*/ +#define CFG_BLE_GATT_CLT_NUM_CHARAC_SUBSCRIPTIONS_MAX (5) + /****************************************************************************** * BLE Stack modularity options ******************************************************************************/ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c b/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c index c304eefb4..ab2f82a9d 100644 --- a/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c @@ -76,6 +76,8 @@ void HAL_MspInit(void) /* USER CODE END MspInit 0 */ + __HAL_RCC_SYSCFG_CLK_ENABLE(); + /* System interrupt init*/ /* USER CODE BEGIN MspInit 1 */ @@ -104,6 +106,7 @@ void HAL_PKA_MspInit(PKA_HandleTypeDef* hpka) /* USER CODE BEGIN PKA_MspInit 1 */ /* USER CODE END PKA_MspInit 1 */ + } } @@ -176,6 +179,7 @@ void HAL_RADIO_MspInit(RADIO_HandleTypeDef* hradio) /* USER CODE BEGIN RADIO_MspInit 1 */ /* USER CODE END RADIO_MspInit 1 */ + } } @@ -246,6 +250,10 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) GPIO_InitStruct.Alternate = GPIO_AF2_USART1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + LL_PWR_SetNoPullB(LL_PWR_GPIO_BIT_0); + + LL_PWR_SetNoPullA(LL_PWR_GPIO_BIT_1); + /* USART1 DMA Init */ /* USART1_TX Init */ hdma_usart1_tx.Instance = DMA1_Channel1; @@ -287,6 +295,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) /* USER CODE BEGIN USART1_MspInit 1 */ /* USER CODE END USART1_MspInit 1 */ + } } diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_gatt_nwk.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_gatt_nwk.h index 2a6e5a409..86f58d036 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_gatt_nwk.h +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_gatt_nwk.h @@ -506,6 +506,23 @@ tBleStatus aci_gatt_clt_write_char_reliable_nwk(uint16_t Connection_Handle, uint16_t Attribute_Val_Length, uint8_t Attribute_Val[]); +/** + * @brief Add a subscription security level setting. + * Any received Notification, Indication or Multiple Notification that not meet this + * requirement will be discarded automatically. + * @param Conn_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * - 0xFFFF is a special value that identify the default setting + * @param Char_Handle Handle of the Characteristic + * Values: + * - 0x0001 ... 0xFFFF + * - 0xFFFF is a special value that identify the default setting + */ +tBleStatus aci_gatt_clt_add_subscription_security_level_nwk(uint16_t Conn_Handle, + uint16_t Char_Handle, + uint8_t Sec_Level); + /** * @brief * @param Conn_Handle Connection handle to be used to identify the connection with the peer device. diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/app_ble.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/app_ble.h index 11bc02f0c..7a3d45a3b 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/app_ble.h +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/app_ble.h @@ -104,9 +104,9 @@ typedef enum #define CONN_SUP_TIMEOUT_MS(x) ((uint16_t)((x)/10.0f)) #define CONN_CE_LENGTH_MS(x) ((uint16_t)((x)/0.625f)) -/* STM32WB09 Transparent Mode/DTM version (Bluetooth LE stack v4.0) */ +/* Transparent Mode/DTM version (Bluetooth LE stack v4.x) */ #define DTM_FW_VERSION_MAJOR 1 -#define DTM_FW_VERSION_MINOR 0 +#define DTM_FW_VERSION_MINOR 1 #define DTM_FW_VERSION_PATCH 0 #define UART_INTERFACE @@ -125,6 +125,7 @@ typedef enum void ModulesInit(void); void BLE_Init(void); void APP_BLE_Init(void); + /* USER CODE BEGIN EF */ /* USER CODE END EF */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c index 33dffa50f..19db5461f 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c @@ -3,7 +3,7 @@ ****************************************************************************** * @file DTM_cmd_db.c * @author AMS - RF Application team - * @date 24 October 2023 + * @date 29 August 2024 * @brief Autogenerated files, do not edit!! ****************************************************************************** * @attention @@ -2849,6 +2849,16 @@ typedef PACKED(struct) aci_gatt_clt_read_multiple_var_len_char_value_rp0_s { uint8_t Status; } aci_gatt_clt_read_multiple_var_len_char_value_rp0; +typedef PACKED(struct) aci_gatt_clt_add_subscription_security_level_nwk_cp0_s { + uint16_t Conn_Handle; + uint16_t Char_Value_Handle; + uint8_t Sec_Level; +} aci_gatt_clt_add_subscription_security_level_nwk_cp0; + +typedef PACKED(struct) aci_gatt_clt_add_subscription_security_level_nwk_rp0_s { + uint8_t Status; +} aci_gatt_clt_add_subscription_security_level_nwk_rp0; + typedef PACKED(struct) aci_l2cap_connection_parameter_update_req_cp0_s { uint16_t Connection_Handle; uint16_t Connection_Interval_Min; @@ -2905,6 +2915,18 @@ typedef PACKED(struct) aci_l2cap_cos_connection_resp_rp0_s { uint16_t CID[(HCI_MAX_PAYLOAD_SIZE - 2)/sizeof(uint16_t)]; } aci_l2cap_cos_connection_resp_rp0; +typedef PACKED(struct) aci_l2cap_cos_flow_control_credits_ind_cp0_s { + uint16_t Connection_Handle; + uint16_t CID; + uint16_t RX_Credits; + uint8_t CFC_Policy; +} aci_l2cap_cos_flow_control_credits_ind_cp0; + +typedef PACKED(struct) aci_l2cap_cos_flow_control_credits_ind_rp0_s { + uint8_t Status; + uint16_t RX_Credit_Balance; +} aci_l2cap_cos_flow_control_credits_ind_rp0; + typedef PACKED(struct) aci_l2cap_cos_disconnect_req_cp0_s { uint16_t Connection_Handle; uint16_t CID; @@ -3274,10 +3296,12 @@ uint16_t aci_gatt_srv_write_multiple_instance_handle_value_process(uint8_t *buff uint16_t aci_gatt_srv_read_multiple_instance_handle_value_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_gatt_srv_multi_notify_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_gatt_clt_read_multiple_var_len_char_value_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_gatt_clt_add_subscription_security_level_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_l2cap_connection_parameter_update_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_l2cap_connection_parameter_update_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_l2cap_cos_connection_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_l2cap_cos_connection_resp_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_l2cap_cos_flow_control_credits_ind_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_l2cap_cos_disconnect_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_l2cap_cos_sdu_data_transmit_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_l2cap_cos_reconfigure_req_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); @@ -4247,6 +4271,10 @@ const hci_command_table_type hci_command_table[] = { /* aci_gatt_clt_read_multiple_var_len_char_value */ {0xfd39, aci_gatt_clt_read_multiple_var_len_char_value_process}, #endif +#if (!defined(ACI_GATT_CLT_ADD_SUBSCRIPTION_SECURITY_LEVEL_NWK_ENABLED) || ACI_GATT_CLT_ADD_SUBSCRIPTION_SECURITY_LEVEL_NWK_ENABLED) && !ACI_GATT_CLT_ADD_SUBSCRIPTION_SECURITY_LEVEL_NWK_FORCE_DISABLED + /* aci_gatt_clt_add_subscription_security_level_nwk */ + {0xfd3a, aci_gatt_clt_add_subscription_security_level_nwk_process}, +#endif #if (!defined(ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ_ENABLED) || ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ_ENABLED) && !ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ_FORCE_DISABLED /* aci_l2cap_connection_parameter_update_req */ {0xfd81, aci_l2cap_connection_parameter_update_req_process}, @@ -4263,6 +4291,10 @@ const hci_command_table_type hci_command_table[] = { /* aci_l2cap_cos_connection_resp */ {0xfd84, aci_l2cap_cos_connection_resp_process}, #endif +#if (!defined(ACI_L2CAP_COS_FLOW_CONTROL_CREDITS_IND_ENABLED) || ACI_L2CAP_COS_FLOW_CONTROL_CREDITS_IND_ENABLED) && !ACI_L2CAP_COS_FLOW_CONTROL_CREDITS_IND_FORCE_DISABLED + /* aci_l2cap_cos_flow_control_credits_ind */ + {0xfd85, aci_l2cap_cos_flow_control_credits_ind_process}, +#endif #if (!defined(ACI_L2CAP_COS_DISCONNECT_REQ_ENABLED) || ACI_L2CAP_COS_DISCONNECT_REQ_ENABLED) && !ACI_L2CAP_COS_DISCONNECT_REQ_FORCE_DISABLED /* aci_l2cap_cos_disconnect_req */ {0xfd86, aci_l2cap_cos_disconnect_req_process}, @@ -14080,6 +14112,43 @@ uint16_t aci_gatt_clt_read_multiple_var_len_char_value_process(uint8_t *buffer_i } #endif +#if (!defined(ACI_GATT_CLT_ADD_SUBSCRIPTION_SECURITY_LEVEL_NWK_ENABLED) || ACI_GATT_CLT_ADD_SUBSCRIPTION_SECURITY_LEVEL_NWK_ENABLED) && !ACI_GATT_CLT_ADD_SUBSCRIPTION_SECURITY_LEVEL_NWK_FORCE_DISABLED +/* tBleStatus aci_gatt_clt_add_subscription_security_level_nwk(uint16_t Conn_Handle, + uint16_t Char_Value_Handle, + uint8_t Sec_Level); + */ +/* Command len: 2 + 2 + 1 */ +/* Response len: 1 */ +uint16_t aci_gatt_clt_add_subscription_security_level_nwk_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_gatt_clt_add_subscription_security_level_nwk_cp0 *cp0 = (aci_gatt_clt_add_subscription_security_level_nwk_cp0 *)(buffer_in + (0)); + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 1) + { + goto fail; + } + + *status = aci_gatt_clt_add_subscription_security_level_nwk(cp0->Conn_Handle /* 2 */, + cp0->Char_Value_Handle /* 2 */, + cp0->Sec_Level /* 1 */); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x3a; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + #if (!defined(ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ_ENABLED) || ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ_ENABLED) && !ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ_FORCE_DISABLED /* tBleStatus aci_l2cap_connection_parameter_update_req(uint16_t Connection_Handle, uint16_t Connection_Interval_Min, @@ -14266,6 +14335,49 @@ uint16_t aci_l2cap_cos_connection_resp_process(uint8_t *buffer_in, uint16_t buff } #endif +#if (!defined(ACI_L2CAP_COS_FLOW_CONTROL_CREDITS_IND_ENABLED) || ACI_L2CAP_COS_FLOW_CONTROL_CREDITS_IND_ENABLED) && !ACI_L2CAP_COS_FLOW_CONTROL_CREDITS_IND_FORCE_DISABLED +/* tBleStatus aci_l2cap_cos_flow_control_credits_ind(uint16_t Connection_Handle, + uint16_t CID, + uint16_t RX_Credits, + uint8_t CFC_Policy, + uint16_t *RX_Credit_Balance); + */ +/* Command len: 2 + 2 + 2 + 1 */ +/* Response len: 1 + 2 */ +uint16_t aci_l2cap_cos_flow_control_credits_ind_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + /* Input params */ + aci_l2cap_cos_flow_control_credits_ind_cp0 *cp0 = (aci_l2cap_cos_flow_control_credits_ind_cp0 *)(buffer_in + (0)); + + int output_size = 1 + 2; + /* Output params */ + aci_l2cap_cos_flow_control_credits_ind_rp0 *rp0 = (aci_l2cap_cos_flow_control_credits_ind_rp0 *) (buffer_out + 6); + uint16_t RX_Credit_Balance = 0; + + rp0->Status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 2 + 6)) { return 0; } + if(buffer_in_length != 2 + 2 + 2 + 1) + { + goto fail; + } + + rp0->Status = aci_l2cap_cos_flow_control_credits_ind(cp0->Connection_Handle /* 2 */, + cp0->CID /* 2 */, + cp0->RX_Credits /* 2 */, + cp0->CFC_Policy /* 1 */, + &RX_Credit_Balance); +fail: + rp0->RX_Credit_Balance = RX_Credit_Balance; + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x85; + buffer_out[5] = 0xfd; + return (output_size + 6); +} +#endif + #if (!defined(ACI_L2CAP_COS_DISCONNECT_REQ_ENABLED) || ACI_L2CAP_COS_DISCONNECT_REQ_ENABLED) && !ACI_L2CAP_COS_DISCONNECT_REQ_FORCE_DISABLED /* tBleStatus aci_l2cap_cos_disconnect_req(uint16_t Connection_Handle, uint16_t CID); diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_en.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_en.h index 96df1bdb7..30b3e080d 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_en.h +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_en.h @@ -79,7 +79,7 @@ (CONNECTION_ENABLED) #ifndef __ZEPHYR__ #define ACI_HAL_TRANSMITTER_TEST_PACKETS_V2_ENABLED\ - (CONTROLLER_CTE_ENABLED) + (CONTROLLER_CTE_ENABLED) #endif /* __ZEPHYR__ */ #define ACI_TEST_TX_NOTIFICATION_START_ENABLED\ (CONNECTION_ENABLED) diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_stack_en.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_stack_en.h index d4700307c..396e19ade 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_stack_en.h +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_stack_en.h @@ -98,6 +98,8 @@ (CONNECTION_ENABLED) #define ACI_GAP_TERMINATE_PROC_ENABLED\ (CONTROLLER_SCAN_ENABLED) +#define ACI_GATT_CLT_ADD_SUBSCRIPTION_SECURITY_LEVEL_ENABLED\ + (CONNECTION_ENABLED) #define ACI_GATT_CLT_CONFIRM_INDICATION_ENABLED\ (CONNECTION_ENABLED) #define ACI_GATT_CLT_DISC_ALL_CHAR_DESC_ENABLED\ @@ -261,7 +263,20 @@ (CONTROLLER_CTE_ENABLED &\ CONNECTION_ENABLED) #define HCI_LE_CONNECTION_UPDATE_ENABLED\ - (CONNECTION_ENABLED) + (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) #define HCI_LE_CREATE_BIG_ENABLED\ (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ CONTROLLER_PERIODIC_ADV_ENABLED &\ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c index 4d5224d7b..b95e1dd58 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c @@ -66,6 +66,7 @@ */ #define CONNECTION_BIT ((uint32_t)0x00000800) /*!< Bit 11 selected */ #define CONTROLLER_ONLY_BIT ((uint32_t)0x00001000) /*!< Bit 12 selected */ +#define DTM_DEBUG_BIT ((uint32_t)0x00002000) /*!< Bit 13 selected */ #define CONTROLLER_CHAN_CLASS_BIT ((uint32_t)0x00010000) /*!< Bit 16 selected */ #define CONTROLLER_BIS_BIT ((uint32_t)0x00020000) /*!< Bit 17 selected */ #define CONNECTION_SUBRATING_BIT ((uint32_t)0x00080000) /*!< Bit 19 selected */ @@ -100,6 +101,7 @@ ((uint32_t)(CONTROLLER_POWER_CONTROL_ENABLED * CONTROLLER_POWER_CONTROL_BIT)) | \ ((uint32_t)(CONNECTION_ENABLED * CONNECTION_BIT)) | \ ((uint32_t)(BLESTACK_CONTROLLER_ONLY * CONTROLLER_ONLY_BIT)) | \ + ((uint32_t)(DTM_DEBUG_ENABLED * DTM_DEBUG_BIT)) | \ ((uint32_t)(CONTROLLER_CHAN_CLASS_ENABLED * CONTROLLER_CHAN_CLASS_BIT)) | \ ((uint32_t)(CONTROLLER_BIS_ENABLED * CONTROLLER_BIS_BIT)) | \ ((uint32_t)(CONNECTION_SUBRATING_ENABLED * CONNECTION_SUBRATING_BIT)) | \ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.c index 5b5e06652..24a64de53 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.c +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.c @@ -213,10 +213,12 @@ static void transport_layer_send_data(uint8_t *data, uint16_t data_length) } } -static void transport_layer_DMA_RX_Data(uint16_t dma_counter) +static void transport_layer_DMA_RX_Data(UART_HandleTypeDef *huart) { static uint16_t rx_index = 0; + uint16_t dma_counter = DMA_RX_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(huart->hdmarx); + if(rx_index != dma_counter) { if(dma_counter > rx_index) @@ -385,7 +387,7 @@ void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) { - transport_layer_DMA_RX_Data(Size); + transport_layer_DMA_RX_Data(huart); } __weak void TL_ProcessReqCallback(void){} diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c index 6ca286c8b..ae4a45eb2 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c @@ -56,6 +56,48 @@ __disable_irq(); \ #define LL_PHY_CODED 0x04U #endif +#if defined (STM32WB06) || defined (STM32WB07) + +#define ANY_HW_ERROR_INTERRUPT_Msk ( \ + BLUE_STATUSREG_ADDPOINTERROR_Msk | \ + BLUE_STATUSREG_RXOVERFLOWERROR_Msk | \ + BLUE_STATUSREG_TXERROR_0_Msk | \ + BLUE_STATUSREG_TXERROR_1_Msk | \ + BLUE_STATUSREG_TXERROR_2_Msk | \ + BLUE_STATUSREG_TXERROR_3_Msk | \ + BLUE_STATUSREG_TXERROR_4_Msk | \ + BLUE_STATUSREG_ALLTABLEREADYERROR_Msk | \ + BLUE_STATUSREG_TXDATAREADYERROR_Msk | \ + BLUE_STATUSREG_NOACTIVELERROR_Msk | \ + BLUE_STATUSREG_INITDELAYERROR_Msk | \ + BLUE_STATUSREG_SEMATIMEOUTERROR_Msk | \ + BLUE_STATUSREG_ACTIVE2ERROR_Msk | \ + BLUE_STATUSREG_CONFIGERROR_Msk \ + ) + +#define WAKEUPINITDELAY_MT (64U) +#define TIMER12_INIT_DELAY_CAL (63U) +#define TIMER2_INIT_DELAY_NO_CAL (9U) +#define RCV_LEN_MARGIN_US (16U) +#define TX_DELAY_START (16U) +#define TX_DELAY_END (16U) + +#define RADIO_FSM_RX_DELAY_CAL (116U) +#define RADIO_FSM_RX_DELAY_NO_CAL (56U) +#define RADIO_FSM_TX_DELAY_CAL (118U) +#define RADIO_FSM_TX_DELAY_NO_CAL (58U) + +#define RECEIVE_CAL_DELAY_CHECK (RADIO_FSM_RX_DELAY_CAL) +#define RECEIVE_NO_CAL_DELAY_CHECK (RADIO_FSM_RX_DELAY_NO_CAL) +#define TRANSMIT_CAL_DELAY_CHECK (RADIO_FSM_TX_DELAY_CAL) +#define TRANSMIT_NO_CAL_DELAY_CHECK (RADIO_FSM_TX_DELAY_NO_CAL) + +#define CONFIG_END_DURATION (20U) +#define TX_DATA_READY_CHECK (5U) +#define TX_READY_TIMEOUT (5U) + +#elif defined (STM32WB05) || defined (STM32WB09) + #define ANY_HW_ERROR_INTERRUPT_Msk ( \ BLUE_STATUSREG_ADDPOINTERROR_Msk | \ BLUE_STATUSREG_RXOVERFLOWERROR_Msk | \ @@ -93,6 +135,8 @@ __disable_irq(); \ #define TX_DATA_READY_CHECK (5U) #define TX_READY_TIMEOUT (4U) +#endif + #ifndef LL_PHY_CODED #define LL_PHY_CODED 0x04U #endif diff --git a/lib/stm32wb0/Common/BLE/Interfaces/hw_pka.c b/lib/stm32wb0/Common/BLE/Interfaces/hw_pka.c index 70737556e..085288345 100644 --- a/lib/stm32wb0/Common/BLE/Interfaces/hw_pka.c +++ b/lib/stm32wb0/Common/BLE/Interfaces/hw_pka.c @@ -948,7 +948,7 @@ void HW_PKA_P256_StartPointCheck( const uint32_t* x, const uint32_t* y ) /* Set the point coordinate y */ HW_PKA_WriteOperand( PKA_POINT_CHECK_IN_INITIAL_POINT_Y, 8, y ); /* Set the Montgomery parameter */ - HW_PKA_WriteOperand( PKA_ECC_SCALAR_MUL_IN_MONTGOMERY_PARAM, 8, HW_PKA_P256_r2 ); + HW_PKA_WriteOperand( PKA_POINT_CHECK_IN_MONTGOMERY, 8, HW_PKA_P256_r2 ); /* Set the coefficient |b| */ HW_PKA_WriteOperand( PKA_POINT_CHECK_IN_B_COEFF, 8, HW_PKA_P256_b ); #endif /* STM32WB09 */ diff --git a/lib/stm32wb0/README.rst b/lib/stm32wb0/README.rst index dbc91a670..00799d537 100644 --- a/lib/stm32wb0/README.rst +++ b/lib/stm32wb0/README.rst @@ -6,7 +6,7 @@ Origin: https://github.com/STMicroelectronics/STM32CubeWB0 Status: - version v1.0.0 + version v1.1.0 Purpose: This library is used on STM32WB0 series to port BLE controller library in @@ -59,24 +59,24 @@ Description: Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/transport_layer.h Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/Target/bleplat.c Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Interfaces/hw_aes.c - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Interfaces/hw_aes.h - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Interfaces/hw_pka.c - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Interfaces/hw_pka.h - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Interfaces/hw_rng.c - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Interfaces/hw_rng.h - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/asm.h - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/blue_unit_conversion.s - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/compiler.h - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/crash_handler.h - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/miscutil.c - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/miscutil.h - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/osal.h - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/osal_memcpy.s - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/PKAMGR/Inc/pka_manager.h - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/PKAMGR/Src/pka_manager.c - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/RADIO_utils/Inc/RADIO_utils.h - Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/System/Modules/RADIO_utils/Src/RADIO_utils.c + Projects/Common/BLE/Interfaces/hw_aes.c + Projects/Common/BLE/Interfaces/hw_aes.h + Projects/Common/BLE/Interfaces/hw_pka.c + Projects/Common/BLE/Interfaces/hw_pka.h + Projects/Common/BLE/Interfaces/hw_rng.c + Projects/Common/BLE/Interfaces/hw_rng.h + Projects/Common/BLE/Modules/asm.h + Projects/Common/BLE/Modules/blue_unit_conversion.s + Projects/Common/BLE/Modules/compiler.h + Projects/Common/BLE/Modules/crash_handler.h + Projects/Common/BLE/Modules/miscutil.c + Projects/Common/BLE/Modules/miscutil.h + Projects/Common/BLE/Modules/osal.h + Projects/Common/BLE/Modules/osal_memcpy.s + Projects/Common/BLE/Modules/PKAMGR/Inc/pka_manager.h + Projects/Common/BLE/Modules/PKAMGR/Src/pka_manager.c + Projects/Common/BLE/Modules/RADIO_utils/Inc/RADIO_utils.h + Projects/Common/BLE/Modules/RADIO_utils/Src/RADIO_utils.c Dependencies: This library depends on STM32Cube HAL API. @@ -86,7 +86,7 @@ URL: https://github.com/STMicroelectronics/STM32CubeWB0 Commit: - 61d80e00cdb6136a58a33b95d2137e3bc9baa28e + acb6e3c6086b69b3fff8111c89b825d6acbb3d71 Maintained-by: External diff --git a/lib/stm32wb0/STM32_BLE/stack/config/ble_stack_user_cfg.c b/lib/stm32wb0/STM32_BLE/stack/config/ble_stack_user_cfg.c index b48a258c8..19c769575 100644 --- a/lib/stm32wb0/STM32_BLE/stack/config/ble_stack_user_cfg.c +++ b/lib/stm32wb0/STM32_BLE/stack/config/ble_stack_user_cfg.c @@ -71,6 +71,9 @@ #if !defined(CFG_BLE_CONNECTION_ENABLED) # error "CFG_BLE_CONNECTION_ENABLED is not defined" #endif +#if !defined(DTM_DEBUG_ENABLED) +# error "DTM_DEBUG_ENABLED is not defined" +#endif #if !defined(CFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED) # error "CFG_BLE_CONTROLLER_CHAN_CLASS_ENABLED is not defined" #endif @@ -489,6 +492,77 @@ tBleStatus hci_acl_data_ind_event_int_cb_ucfg(void* header_p, } #endif /* (CONNECTION_ENABLED == 1) */ +#if (DTM_DEBUG_ENABLED == 1) +uint8_t log_verbosity_set_ucfg(void* p) +{ + return log_verbosity_set(p); +} +#endif /* (DTM_DEBUG_ENABLED == 1) */ + +#if (DTM_DEBUG_ENABLED == 1) +void log_verbosity_get_ucfg(void* verb_p) +{ + log_verbosity_get(verb_p); +} +#endif /* (DTM_DEBUG_ENABLED == 1) */ + +#if (DTM_DEBUG_ENABLED == 1) +void log_init_ucfg(void) +{ + log_init(); +} +#endif /* (DTM_DEBUG_ENABLED == 1) */ + +#if (DTM_DEBUG_ENABLED == 1) +void log_notify_stu_ucfg(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t fmt, + uint8_t len, + uint8_t* buf_p) +{ + log_notify_stu(lvl, + cid, + mid, + uid, + fmt, + len, + buf_p); +} +#endif /* (DTM_DEBUG_ENABLED == 1) */ + +#if (DTM_DEBUG_ENABLED == 1) +void log_notify_us_deferred_ucfg(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t add_info_present, + uint32_t add_info) +{ + log_notify_us_deferred(lvl, + cid, + mid, + uid, + add_info_present, + add_info); +} +#endif /* (DTM_DEBUG_ENABLED == 1) */ + +#if (DTM_DEBUG_ENABLED == 1) +void log_notify_us_flush_ucfg(void) +{ + log_notify_us_flush(); +} +#endif /* (DTM_DEBUG_ENABLED == 1) */ + +#if (DTM_DEBUG_ENABLED == 1) +uint32_t log_csr_ucfg(void) +{ + return log_csr(); +} +#endif /* (DTM_DEBUG_ENABLED == 1) */ + #if ((CONTROLLER_CHAN_CLASS_ENABLED == 1) &&\ (CONNECTION_ENABLED == 1)) uint32_t chc_csr_ucfg(void) @@ -733,6 +807,15 @@ tBleStatus MBM_init_ucfg(void) #endif /* (CONNECTION_ENABLED == 1) ||\ (CONTROLLER_ISO_ENABLED == 1) */ +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus smp_debug_trudy__set_config_ucfg(uint32_t config) +{ + return smp_debug_trudy__set_config(config); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + #if (BLESTACK_CONTROLLER_ONLY == 0) #if ((SECURE_CONNECTIONS_ENABLED == 1) &&\ (CONNECTION_ENABLED == 1)) @@ -939,9 +1022,9 @@ tBleStatus llc_conn_multi_link_connection_ucfg(uint8_t enable) #endif /* (CONNECTION_ENABLED == 1) */ #if (CONNECTION_ENABLED == 1) -void llc_conn_peripheral_latency_cancellation_tsk_ucfg(uint16_t task_idx) +void llc_conn_peripheral_roll_back_params_tsk_ucfg(uint16_t task_idx) { - llc_conn_peripheral_latency_cancellation_tsk(task_idx); + llc_conn_peripheral_roll_back_params_tsk(task_idx); } #endif /* (CONNECTION_ENABLED == 1) */ @@ -1818,6 +1901,20 @@ void llc_priv_init_random_part_of_one_local_rpa_ucfg(void* peer_id_p) } #endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ +#if (CONTROLLER_PRIVACY_ENABLED == 1) +void llc_priv_enable_rpa_change_at_timeout_ucfg(uint8_t enable) +{ + llc_priv_enable_rpa_change_at_timeout(enable); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + +#if (CONTROLLER_PRIVACY_ENABLED == 1) +uint8_t llc_priv_is_rpa_change_at_timeout_enabled_ucfg(void) +{ + return llc_priv_is_rpa_change_at_timeout_enabled(); +} +#endif /* (CONTROLLER_PRIVACY_ENABLED == 1) */ + #if ((CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1)) &&\ (CONTROLLER_SCAN_ENABLED == 1) &&\ @@ -2151,6 +2248,22 @@ void llc_scan_conn_ind_sent_ucfg(void* ptr, #endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ (CONNECTION_ENABLED == 1) */ +#if (CONTROLLER_SCAN_ENABLED == 1) +uint8_t llc_scan_isr_uncoded_ucfg(void* cntxt_p) +{ + return llc_scan_isr_uncoded(cntxt_p); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) */ + +#if (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) +uint8_t llc_scan_isr_coded_ucfg(void* cntxt_p) +{ + return llc_scan_isr_coded(cntxt_p); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ + #if (CONTROLLER_SCAN_ENABLED == 1) &&\ (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) uint8_t llc_scan_process_ext_adv_ucfg(void* scan_p, @@ -2271,6 +2384,13 @@ void llc_scan_disable_ucfg(void* scan_p) #endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ +#if (CONTROLLER_SCAN_ENABLED == 1) +uint8_t llc_scan_stop_ucfg(uint8_t scan_disable) +{ + return llc_scan_stop(scan_disable); +} +#endif /* (CONTROLLER_SCAN_ENABLED == 1) */ + #if ((CONNECTION_SUBRATING_ENABLED == 1) &&\ (CONNECTION_ENABLED == 1)) uint8_t llc_subrate_get_active_sr_req_proc_ucfg(uint8_t conn_idx) @@ -3070,15 +3190,6 @@ void LL_init_ucfg(uint8_t dataLenExt, } #endif /* (CONNECTION_ENABLED == 1) */ -#if (BLESTACK_CONTROLLER_ONLY == 0) -#if (CONNECTION_ENABLED == 1) -tBleStatus smp_debug_trudy__set_config_ucfg(uint32_t config) -{ - return smp_debug_trudy__set_config(config); -} -#endif /* (CONNECTION_ENABLED == 1) */ -#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ - #if (BLESTACK_CONTROLLER_ONLY == 0) #if (\ (CONNECTION_ENABLED == 1)\ @@ -4321,6 +4432,15 @@ tBleStatus aci_gatt_clt_confirm_indication(uint16_t Connection_Handle, #endif /* (CONNECTION_ENABLED == 1) */ #endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if (CONNECTION_ENABLED == 1) +tBleStatus aci_gatt_clt_add_subscription_security_level(ble_gatt_clt_sec_level_st* sec_level_p) +{ + return aci_gatt_clt_add_subscription_security_level_api(sec_level_p); +} +#endif /* (CONNECTION_ENABLED == 1) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + #if (CONNECTION_ENABLED == 1) tBleStatus aci_hal_peripheral_latency_enable(uint16_t Connection_Handle, uint8_t Enable) @@ -4459,6 +4579,25 @@ tBleStatus aci_l2cap_cos_connection_resp(uint16_t connection_handle, (CONNECTION_ENABLED == 1)) */ #endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ +#if (BLESTACK_CONTROLLER_ONLY == 0) +#if ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) +tBleStatus aci_l2cap_cos_flow_control_credits_ind(uint16_t Connection_Handle, + uint16_t CID, + uint16_t RX_Credits, + uint8_t CFC_Policy, + uint16_t* RX_Credit_Balance) +{ + return aci_l2cap_cos_flow_control_credits_ind_api(Connection_Handle, + CID, + RX_Credits, + CFC_Policy, + RX_Credit_Balance); +} +#endif /* ((L2CAP_COS_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1)) */ +#endif /* (BLESTACK_CONTROLLER_ONLY == 0) */ + #if (BLESTACK_CONTROLLER_ONLY == 0) #if ((L2CAP_COS_ENABLED == 1) &&\ (CONNECTION_ENABLED == 1)) @@ -6089,7 +6228,20 @@ tBleStatus hci_le_set_extended_scan_enable(uint8_t Enable, #endif /* (CONTROLLER_SCAN_ENABLED == 1) &&\ (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) */ -#if (CONNECTION_ENABLED == 1) +#if (\ + (CONNECTION_ENABLED == 1)\ + &&\ + (\ + (CONTROLLER_SCAN_ENABLED == 1)\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_WR_ENABLED == 1)\ + )\ + )\ + ) tBleStatus hci_le_connection_update(uint16_t Connection_Handle, uint16_t Connection_Interval_Min, uint16_t Connection_Interval_Max, @@ -6106,7 +6258,7 @@ tBleStatus hci_le_connection_update(uint16_t Connection_Handle, Min_CE_Length, Max_CE_Length); } -#endif /* (CONNECTION_ENABLED == 1) */ +#endif #if ((CONNECTION_SUBRATING_ENABLED == 1) &&\ (CONNECTION_ENABLED == 1)) diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_api.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_api.h index fffd3a7a1..b1c4d8167 100644 --- a/lib/stm32wb0/STM32_BLE/stack/include/ble_api.h +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_api.h @@ -321,12 +321,12 @@ typedef struct Subevent_Data_Ptr_Parameters_t_s { /** *@addtogroup HCI HCI - *@brief Host Controller Interface. + *@brief Standard Host Controller Interface. *@{ */ /** *@defgroup HCI_Commands HCI Commands - *@brief Standard HCI Commands. + * Standard HCI Commands. *@{ */ /** @@ -334,13 +334,13 @@ typedef struct Subevent_Data_Ptr_Parameters_t_s { * The Connection_Handle command parameter indicates which connection is * to be disconnected. The Reason command parameter indicates the reason * for ending the connection. The remote Controller will receive the - * Reason command parameter in the @ref hci_disconnection_complete_event + * Reason command parameter in the @ref hci_disconnection_complete_event_rp0 * event. All synchronous connections on a physical link should be * disconnected before the ACL connection on the same physical connection * is disconnected. (See Bluetooth Specification v.4.1, Vol. 2, Part E, * 7.1.6) It is important to leave an 100 ms blank window before sending * any new command (including system hardware reset), since immediately - * after @ref hci_disconnection_complete_event event, system could save + * after @ref hci_disconnection_complete_event_rp0 event, system could save * important information in non volatile memory. * @param Connection_Handle Connection handle that identifies the connection. * Values: @@ -1560,10 +1560,9 @@ tBleStatus hci_le_set_address_resolution_enable(uint8_t Address_Resolution_Enabl * timeout applies to all addresses generated by the controller. (See * Bluetooth Specification v.4.2, Vol. 2, Part E, 7.8.45) * @param RPA_Timeout RPA_Timeout measured in seconds. Range for N: 0x0001 - - * 0xA1B8 (1 sec - approximately 11.5 hours) Default: N= 0x0384 (900 secs - * or 15 minutes) + * 0x0E10 (1 sec - 1 hour) Default: N= 0x0384 (900 secs or 15 minutes) * Values: - * - 0x0001 ... 0xA1B8 + * - 0x0001 ... 0x0E10 * @retval Value indicating success or error code. */ tBleStatus hci_le_set_resolvable_private_address_timeout(uint16_t RPA_Timeout); @@ -4927,12 +4926,12 @@ tBleStatus hci_tx_iso_data(uint16_t Connection_Handle, /** *@addtogroup HCI HCI - *@brief Host Controller Interface. + *@brief Standard Host Controller Interface. *@{ */ /** *@defgroup HCI_Test_Commands HCI Test Commands - *@brief Standard HCI commands for testing. + * Standard HCI commands for testing. *@{ */ /** @@ -5328,7 +5327,7 @@ tBleStatus hci_le_transmitter_test_v4(uint8_t TX_Channel, */ /** *@defgroup ACI_HAL_Commands ACI HAL Commands - *@brief Commands for HAL and proprietary LL. + * Commands for HAL and proprietary LL. *@{ */ /** @@ -5521,9 +5520,9 @@ tBleStatus aci_hal_get_link_status(uint8_t Bank_index, uint16_t Link_Connection_Handle[16 / 2]); /** * @brief This command set the bitmask associated to @ref - * aci_hal_end_of_radio_activity_event. Only the radio activities + * aci_hal_end_of_radio_activity_event_rp0. Only the radio activities * enabled in the mask will be reported to application by @ref - * aci_hal_end_of_radio_activity_event + * aci_hal_end_of_radio_activity_event_rp0 * @param Radio_Activity_Mask Bitmask of radio events * Flags: * - 0x0001: Idle @@ -5621,7 +5620,7 @@ tBleStatus aci_hal_peripheral_latency_enable(uint16_t Connection_Handle, * internal FIFO queues: isr1_fifo, isr2_fifo and user_fifo. These values * can be used to chose the maximum correct size for the queues, which * can be set through the BLE_STACK_Init() function. If one of these - * queues reaches the maximum size, an hci_hardware_error_event is + * queues reaches the maximum size, an hci_hardware_error_event_rp0 is * raised, with error code 0x03. * @param[out] ISR0_FIFO_Max_Level Maximum size reached by the FIFO used for * critical controller events produced by the ISR (e.g. rx data @@ -5671,7 +5670,7 @@ tBleStatus ll_set_legacy_scan_reponse_data_ptr(uint8_t Data_Length, * @param Advertising_Data Pointer to the buffer containing properly formatted * advertising data (see Core v5.2 Vol 3, part C, chapter 11). Its * content must not change, until an - * aci_hal_adv_scan_resp_data_update_event is received, which informs the + * aci_hal_adv_scan_resp_data_update_event_rp0 is received, which informs the * application that the buffer is no more used by the Bluetooth stack. * @retval Value indicating success or error code. */ @@ -5691,7 +5690,7 @@ tBleStatus ll_set_advertising_data_ptr(uint16_t Advertising_Handle, * @param Scan_Response_Data Pointer to the buffer containing properly formatted * scan response data (see Core v5.1 Vol 3, part C, chapter 11). Its * content must not change, until an - * aci_hal_adv_scan_resp_data_update_event is received, which informs the + * aci_hal_adv_scan_resp_data_update_event_rp0 is received, which informs the * application that the buffer is no more used by the Bluetooth stack. * @retval Value indicating success or error code. */ @@ -5736,7 +5735,7 @@ tBleStatus ll_get_advertising_info(uint16_t Advertising_Handle, * @param Advertising_Data Pointer to the buffer containing properly formatted * periodic advertising data (see Core v5.2 Vol 3, part C, chapter 11). * Its content must not change, until an - * aci_hal_adv_scan_resp_data_update_event is received, which informs the + * aci_hal_adv_scan_resp_data_update_event_rp0 is received, which informs the * application that the buffer is no more used by the Bluetooth stack. * @retval Value indicating success or error code. */ @@ -5838,7 +5837,7 @@ tBleStatus ll_set_periodic_advertising_response_data_ptr(uint16_t Sync_Handle, */ /** *@defgroup ACI_GAP_Commands ACI GAP Commands - *@brief Commands for GAP layer. + * Commands for GAP layer. *@{ */ /** @@ -5868,11 +5867,11 @@ tBleStatus aci_gap_init(uint8_t Privacy_Type, * during a pairing procedure. * @param IO_Capability IO capability of the device. * Values: - * - 0x00: IO_CAP_DISPLAY_ONLY - * - 0x01: IO_CAP_DISPLAY_YES_NO - * - 0x02: IO_CAP_KEYBOARD_ONLY - * - 0x03: IO_CAP_NO_INPUT_NO_OUTPUT - * - 0x04: IO_CAP_KEYBOARD_DISPLAY + * - 0x00: GAP_IO_CAP_DISPLAY_ONLY + * - 0x01: GAP_IO_CAP_DISPLAY_YES_NO + * - 0x02: GAP_IO_CAP_KEYBOARD_ONLY + * - 0x03: GAP_IO_CAP_NO_INPUT_NO_OUTPUT + * - 0x04: GAP_IO_CAP_KEYBOARD_DISPLAY * @retval Value indicating success or error code. */ tBleStatus aci_gap_set_io_capability(uint8_t IO_Capability); @@ -5890,10 +5889,10 @@ tBleStatus aci_gap_set_io_capability(uint8_t IO_Capability); * Library. If set to 1 (pairing response required for bonded devices * only), the pairing is automatically accepted (no user interaction) * except when the request comes from an already bonded device; in this - * case aci_gap_pairing_event is notified and the application has to give + * case aci_gap_pairing_event_rp0 is notified and the application has to give * a confirmation through aci_gap_pairing_resp to accept the request to * rebond. If Pairing_Response is set to 2 (explicit pairing response) a - * pairing confirmation is always required since aci_gap_pairing_event is + * pairing confirmation is always required since aci_gap_pairing_event_rp0 is * always raised when a Pairing Request from a Central or a Peripheral * Security Request form a Peripheral is received. If the command is * given during pairing, the command returns BLE_STATUS_NOT_ALLOWED. The @@ -5917,13 +5916,13 @@ tBleStatus aci_gap_set_io_capability(uint8_t IO_Capability); * supported but optional. - 0x02: Secure Connections Pairing supported * and mandatory (SC Only Mode). This is the recommended value. * Values: - * - 0x00: SC_IS_NOT_SUPPORTED - * - 0x01: SC_IS_SUPPORTED - * - 0x02: SC_IS_MANDATORY + * - 0x00: GAP_SC_NOT_SUPPORTED + * - 0x01: GAP_SC_OPTIONAL + * - 0x02: GAP_SC_MANDATORY * @param KeyPress_Notification_Support Keypress notification support * Values: - * - 0x00: KEYPRESS_IS_NOT_SUPPORTED - * - 0x01: KEYPRESS_IS_SUPPORTED + * - 0x00: GAP_KEYPRESS_NOT_SUPPORTED + * - 0x01: GAP_KEYPRESS_SUPPORTED * @param Min_Encryption_Key_Size Minimum encryption key size to be used during * pairing * Values: @@ -5949,7 +5948,7 @@ tBleStatus aci_gap_set_security_requirements(uint8_t Bonding_Mode, uint8_t Pairing_Response); /** * @brief This command should be send by the host in response to @ref - * aci_gap_passkey_req_event event. The command parameter contains the + * aci_gap_passkey_req_event_rp0 event. The command parameter contains the * pass key which will be used during the pairing process. * @param Connection_Handle Connection handle that identifies the connection. * Values: @@ -5973,7 +5972,13 @@ tBleStatus aci_gap_passkey_resp(uint16_t Connection_Handle, * encryption), 2 for unauthenticated pairing with encryption, 3 for * authenticated pairing with encryption, 4 for authenticated LE Secure * Connections pairing with encryption using a 128-bit strength - * encryption key. + * encryption key. The security level is achieved in a best-effort way. + * The pairing may be completed with an higher security level if it is + * requested by the peer. The pairing may also be completed with a lower + * security level than the one specified if it is not allowed by the + * peer, because of its security settings. Application can use the + * aci_gap_get_security_level command after the pairing complete event to + * determine the reached security level. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -5983,22 +5988,27 @@ tBleStatus aci_gap_passkey_resp(uint16_t Connection_Handle, * - 0x02: GAP_SECURITY_LEVEL_2 * - 0x03: GAP_SECURITY_LEVEL_3 * - 0x04: GAP_SECURITY_LEVEL_4 - * @param Force_Pairing + * @param Force_Pairing Valid only for Central role. Ignored if role is + * Peripheral. The bit b0 indicates whether pairing request has to be + * sent even if the peer device is bonded. The bit b1 indicates whether + * the link has to be re-encrypted after the key exchange. + * Flags: + * - 0x01: FORCE_PAIRING + * - 0x02: ENCRYPT_AFTER_KEY_EXCHANGE * @retval Value indicating success or error code. */ tBleStatus aci_gap_set_security(uint16_t Connection_Handle, uint8_t Security_Level, uint8_t Force_Pairing); /** - * @brief This command can be used to get the current security settings of the - * device. + * @brief This command can be used to get the current security level of a + * connection. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF - * @param[out] Security_Mode Security mode. + * @param[out] Security_Mode Security mode (deprecated, always 1). * Values: * - 0x01: Security Mode 1 - * - 0x02: Security Mode 2 * @param[out] Security_Level Security Level. * Values: * - 0x01: Security Level 1 @@ -6061,11 +6071,11 @@ tBleStatus aci_gap_get_security_level(uint16_t Connection_Handle, tBleStatus aci_gap_set_le_event_mask(uint8_t LE_Event_Mask[8]); /** * @brief Command the controller to terminate the connection. A @ref - * hci_disconnection_complete_event will be generated when the link is + * hci_disconnection_complete_event_rp0 will be generated when the link is * disconnected. After this event is received, the Bluetooth stack may * request to save GATT database information in non-volatile memory. So * it is important not to reset or power off the system immediately after - * @ref hci_disconnection_complete_event is received. This operation is + * @ref hci_disconnection_complete_event_rp0 is received. This operation is * normally completed within less than few milliseconds. * @param Connection_Handle Connection handle that identifies the connection. * Values: @@ -6090,12 +6100,13 @@ tBleStatus aci_gap_terminate(uint16_t Connection_Handle, * scanning), since it will trigger an erase of a Flash sector. After * this command, all devices previously recorded in the bonding table and * connected when command has been submitted will remain connected, - * preserving authentication and encryption of the link. + * preserving authentication and encryption of the link. Note also that + * devices are not removed from filter accept and resolving lists. * @retval Value indicating success or error code. */ tBleStatus aci_gap_clear_security_db(void); /** - * @brief This command shall be given in response to an aci_gap_paring_event, to + * @brief This command shall be given in response to an aci_gap_paring_event_rp0, to * allow or reject either the pairing request from the Central or the * security request from the Peripheral. * @param Connection_Handle Connection handle that identifies the connection. @@ -6132,7 +6143,7 @@ tBleStatus aci_gap_create_connection(uint8_t Initiating_PHY, uint8_t Peer_Address[6]); /** * @brief Terminate the specified GAP procedure. An @ref - * aci_gap_proc_complete_event event is generated when the procedure has + * aci_gap_proc_complete_event_rp0 event is generated when the procedure has * been completed, with the procedure code set to the corresponding * procedure. * @param Procedure_Code Code identifying the procedure. @@ -6151,7 +6162,7 @@ tBleStatus aci_gap_terminate_proc(uint8_t Procedure_Code); /** * @brief Start the connection update procedure (only when role is Central). A * @ref hci_le_connection_update is called. On completion of the - * procedure, an @ref hci_le_connection_update_complete_event event is + * procedure, an @ref hci_le_connection_update_complete_event_rp0 event is * returned to the upper layer. * @param Connection_Handle Connection handle that identifies the connection. * Values: @@ -6740,19 +6751,73 @@ tBleStatus aci_gap_remove_advertising_set(uint8_t Advertising_Handle); */ tBleStatus aci_gap_clear_advertising_sets(void); /** - * @brief The aci_gap_clear_advertising_sets - * @param Advertising_Handle - * @param Subevent - * @param Initiator_Filter_Policy - * @param Own_Address_Type - * @param Peer_Address_Type - * @param Peer_Address - * @param Connection_Interval_Min - * @param Connection_Interval_Max - * @param Max_Latency - * @param Supervision_Timeout - * @param Min_CE_Length - * @param Max_CE_Length + * @brief This command is used to create a connection between a periodic + * advertiser and a synchronized device. See LE Extended Create + * Connection [v2] command. + * @param Advertising_Handle Advertising_Handle identifying the periodic + * advertising train. + * Values: + * - 0x00 ... 0xEF + * - 0xFF: Not specified + * @param Subevent Subevent where the connection request is to be sent. + * Values: + * - 0x00 ... 0x7F + * - 0xFF: Not specified + * @param Initiator_Filter_Policy The Initiator_Filter_Policy parameter is used + * to determine whether the Filter Accept List is used. If the Filter + * Accept List is not used, the Peer_Address_Type and the Peer_Address + * parameters specify the address type and address of the device to + * connect to. 0x00 - Filter Accept List is not used to determine which + * device to connect to. Peer_Address_Type and Peer_Address shall be + * used. 0x01 - Filter Accept List is used to determine which device to + * connect to. Peer_Address_Type and Peer_Address shall be ignored. + * Values: + * - 0x00: FILTER_ACCEPT_LIST_NOT_USED + * - 0x01: FILTER_ACCEPT_LIST_USED + * @param Own_Address_Type The Own_Address_Type parameter indicates the type of + * address being used in the connection request packets. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Controller generates the Resolvable Private Address based on the local +IRK from the resolving list. If the resolving list contains no matching +entry, then use the public address. + * - 0x03: Controller generates the Resolvable Private Address based on the local +IRK from the resolving list. If the resolving list contains no matching +entry, then use the random address from the most recent successful +LE_Set_Random_Address Command. + * @param Peer_Address_Type The Peer_Address_Type parameter indicates the type + * of address used in the connectable advertisement sent by the peer. + * 0x00: Public Device Address or Public Identity Address 0x01: Random + * Device Address or Random (static) Identity Address + * Values: + * - 0x00: Public Address + * - 0x01: Random Address + * @param Peer_Address Public Device Address, Random Device Address, Public + * Identity Address, or Random (static) Identity Address of the device to + * be connected. + * @param Connection_Interval_Min Minimum value for the connection interval. + * This shall be less than or equal to Connection_Interval_Max. Time = N + * x 1.25 ms. + * Values: + * - 0x0006 ... 0x0C80 + * @param Connection_Interval_Max Maximum value for the connection interval. + * This shall be greater than or equal to Connection_Interval_Min. Time + * = N x 1.25 ms + * Values: + * - 0x0006 ... 0x0C80 + * @param Max_Latency Maximum Peripheral latency for the connection in number of + * connection events. + * Values: + * - 0x0000 ... 0x01F3 + * @param Supervision_Timeout Supervision timeout for the LE Link. Time = N x + * 10 ms + * Values: + * - 0x000A ... 0x0C80 + * @param Min_CE_Length The minimum length of connection event recommended for + * this LE connection. + * @param Max_CE_Length The maximum length of connection event recommended for + * this LE connection. * @retval Value indicating success or error code. */ tBleStatus aci_gap_create_periodic_advertising_connection(uint8_t Advertising_Handle, @@ -6803,7 +6868,7 @@ tBleStatus aci_gap_create_periodic_advertising_connection(uint8_t Advertising_Ha * @param Advertising_Data Pointer to the buffer containing properly formatted * advertising data (see Core v5.1 Vol 3, part C, chapter 11). Its * content must not change, until an - * aci_hal_adv_scan_resp_data_update_event is received, which informs the + * aci_hal_adv_scan_resp_data_update_event_rp0 is received, which informs the * application that the buffer is no more used by the Bluetooth stack. * @retval Value indicating success or error code. */ @@ -6824,7 +6889,7 @@ tBleStatus aci_gap_set_advertising_data(uint8_t Advertising_Handle, * @param Scan_Response_Data Pointer to the buffer containing properly formatted * scan response data (see Core v5.1 Vol 3, part C, chapter 11). Its * content must not change, until an - * aci_hal_adv_scan_resp_data_update_event is received, which informs the + * aci_hal_adv_scan_resp_data_update_event_rp0 is received, which informs the * application that the buffer is no more used by the Bluetooth stack. * @retval Value indicating success or error code. */ @@ -6832,12 +6897,19 @@ tBleStatus aci_gap_set_scan_response_data(uint8_t Advertising_Handle, uint16_t Scan_Response_Data_Length, uint8_t Scan_Response_Data[]); /** - * @brief - * @param Session_Key - * @param IV - * @param Data_Length - * @param Data - * @param[out] Encrypted_Data + * @brief This command is used by the application to encrypt data used in + * advertising packets. The Encrypted_Data buffer will contain the data + * formatted as described in Supplement to the Bluetooth Core + * Specification, part A, section 1.23 (Encrypted Data), including + * Randomizer (5 bytes) and MIC (4 bytes). So, the size of the output + * buffer must be 9 bytes larger than the length of input data. + * @param Session_Key The shared session key. + * @param IV The initialization vector. + * @param Data_Length Length of data. + * @param Data Plain data to be encrypted. + * @param[out] Encrypted_Data Pointer to the buffer that will contain encrypted + * data. Size of the buffer must be at least equal to Data_Length + + * 9. * @retval Value indicating success or error code. */ tBleStatus aci_gap_encrypt_adv_data(uint8_t Session_Key[16], @@ -6846,12 +6918,19 @@ tBleStatus aci_gap_encrypt_adv_data(uint8_t Session_Key[16], uint32_t * Data, uint8_t *Encrypted_Data); /** - * @brief - * @param Session_Key - * @param IV - * @param Encrypted_Data_Length - * @param Encrypted_Data - * @param[out] Decrypted_Data + * @brief Decrypt encrypted advertsing data. The input data must be formatted as + * described in Supplement to the Bluetooth Core Specification, part A, + * section 1.23 (Encrypted Data), so it must include Randomizer (5 bytes) + * and MIC (4 bytes). The decrypted data, generated inside buffer pointed + * by Decrypted_Data, only contains payload data, i.e. without Randomizer + * and MIC. + * @param Session_Key The shared session key. + * @param IV The initialization vector. + * @param Encrypted_Data_Length Length of encrypted data. + * @param Encrypted_Data Encrypted data, including Randomizer and MIC. + * @param[out] Decrypted_Data Pointer to the buffer that will contain decrypted + * data. Size of this buffer must be at least equal to + * Encrypted_Data_Length - 9. * @retval Value indicating success or error code. */ tBleStatus aci_gap_decrypt_adv_data(uint8_t Session_Key[16], @@ -6875,7 +6954,7 @@ tBleStatus aci_gap_decrypt_adv_data(uint8_t Session_Key[16], */ /** *@defgroup ACI_GATT_Commands ACI GATT Commands - *@brief Commands for GATT layer. + * Commands for GATT layer. *@{ */ /** @@ -6906,8 +6985,8 @@ tBleStatus aci_gap_decrypt_adv_data(uint8_t Session_Key[16], tBleStatus aci_gatt_set_event_mask(uint32_t GATT_Evt_Mask); /** * @brief Performs an ATT MTU exchange procedure. When the ATT MTU exchange - * procedure is completed, a @ref aci_att_exchange_mtu_resp_event event - * is generated. A @ref aci_gatt_clt_proc_complete_event event is also + * procedure is completed, a @ref aci_att_exchange_mtu_resp_event_rp0 event + * is generated. A @ref aci_gatt_clt_proc_complete_event_rp0 event is also * generated to indicate the end of the procedure. * @param Connection_Handle Connection handle that identifies the connection. * Values: @@ -6919,8 +6998,8 @@ tBleStatus aci_gatt_clt_exchange_config(uint16_t Connection_Handle); * @brief Sends a Prepare Write Request. The Prepare Write Request is used to * request the server to prepare to write the value of an attribute. The * responses of the procedure are given through the @ref - * aci_att_clt_prepare_write_resp_event event. The end of the procedure - * is indicated by a @ref aci_gatt_clt_proc_complete_event. + * aci_att_clt_prepare_write_resp_event_rp0 event. The end of the procedure + * is indicated by a @ref aci_gatt_clt_proc_complete_event_rp0. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -6948,8 +7027,8 @@ tBleStatus aci_gatt_clt_prepare_write_req(uint16_t Connection_Handle, * request the server to write or cancel the write of all the prepared * values currently held in the prepare queue from this client. The * result of the procedure is given through the @ref - * aci_att_clt_exec_write_resp_event event. The end of the procedure is - * indicated by a @ref aci_gatt_clt_proc_complete_event event. + * aci_att_clt_exec_write_resp_event_rp0 event. The end of the procedure is + * indicated by a @ref aci_gatt_clt_proc_complete_event_rp0 event. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -6967,7 +7046,7 @@ tBleStatus aci_gatt_clt_execute_write_req(uint16_t Connection_Handle, /** * @brief Starts the GATT client procedure to discover all primary services on * the server. The responses of the procedure are given through the @ref - * aci_att_clt_read_by_group_type_resp_event event. + * aci_att_clt_read_by_group_type_resp_event_rp0 event. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -6980,8 +7059,8 @@ tBleStatus aci_gatt_clt_disc_all_primary_services(uint16_t Connection_Handle, /** * @brief Starts the procedure to discover the primary services of the specified * UUID on the server. The responses of the procedure are given through - * the @ref aci_att_clt_find_by_type_value_resp_event event. The end of - * the procedure is indicated by a @ref aci_gatt_clt_proc_complete_event + * the @ref aci_att_clt_find_by_type_value_resp_event_rp0 event. The end of + * the procedure is indicated by a @ref aci_gatt_clt_proc_complete_event_rp0 * event. * @param Connection_Handle Connection handle that identifies the connection. * Values: @@ -7002,8 +7081,8 @@ tBleStatus aci_gatt_clt_disc_primary_service_by_uuid(uint16_t Connection_Handle, /** * @brief Starts the procedure to find all included services. The responses of * the procedure are given through the @ref - * aci_att_clt_read_by_type_resp_event event. The end of the procedure is - * indicated by a @ref aci_gatt_clt_proc_complete_event event. + * aci_att_clt_read_by_type_resp_event_rp0 event. The end of the procedure is + * indicated by a @ref aci_gatt_clt_proc_complete_event_rp0 event. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -7024,9 +7103,9 @@ tBleStatus aci_gatt_clt_find_included_services(uint16_t Connection_Handle, /** * @brief Starts the procedure to discover all the characteristics of a given * service. When the procedure is completed, a @ref - * aci_gatt_clt_proc_complete_event event is generated. Before procedure + * aci_gatt_clt_proc_complete_event_rp0 event is generated. Before procedure * completion the response packets are given through @ref - * aci_att_clt_read_by_type_resp_event event. + * aci_att_clt_read_by_type_resp_event_rp0 event. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -7047,9 +7126,9 @@ tBleStatus aci_gatt_clt_disc_all_char_of_service(uint16_t Connection_Handle, /** * @brief Starts the procedure to discover all the characteristics specified by * a UUID. When the procedure is completed, a @ref - * aci_gatt_clt_proc_complete_event event is generated. Before procedure + * aci_gatt_clt_proc_complete_event_rp0 event is generated. Before procedure * completion the response packets are given through @ref - * aci_gatt_clt_disc_read_char_by_uuid_resp_event event. + * aci_gatt_clt_disc_read_char_by_uuid_resp_event_rp0 event. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -7077,9 +7156,9 @@ tBleStatus aci_gatt_clt_disc_char_by_uuid(uint16_t Connection_Handle, /** * @brief Starts the procedure to discover all characteristic descriptors on the * server. When the procedure is completed, a @ref - * aci_gatt_clt_proc_complete_event event is generated. Before procedure + * aci_gatt_clt_proc_complete_event_rp0 event is generated. Before procedure * completion the response packets are given through @ref - * aci_att_clt_find_info_resp_event event. + * aci_att_clt_find_info_resp_event_rp0 event. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -7099,9 +7178,9 @@ tBleStatus aci_gatt_clt_disc_all_char_desc(uint16_t Connection_Handle, uint16_t End_Handle); /** * @brief Starts the procedure to read an attribute value. When the procedure is - * completed, a @ref aci_gatt_clt_proc_complete_event event is generated. + * completed, a @ref aci_gatt_clt_proc_complete_event_rp0 event is generated. * Before procedure completion the response packet is given through @ref - * aci_att_clt_read_resp_event event. + * aci_att_clt_read_resp_event_rp0 event. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -7118,9 +7197,9 @@ tBleStatus aci_gatt_clt_read(uint16_t Connection_Handle, /** * @brief Starts the procedure to read all the characteristics specified by the * UUID. When the procedure is completed, a @ref - * aci_gatt_clt_proc_complete_event event is generated. Before procedure + * aci_gatt_clt_proc_complete_event_rp0 event is generated. Before procedure * completion the response packets are given through @ref - * aci_gatt_clt_disc_read_char_by_uuid_resp_event event. + * aci_gatt_clt_disc_read_char_by_uuid_resp_event_rp0 event. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -7147,9 +7226,9 @@ tBleStatus aci_gatt_clt_read_using_char_uuid(uint16_t Connection_Handle, UUID_t *UUID); /** * @brief Starts the procedure to read a long attribute value. the procedure is - * completed, a @ref aci_gatt_clt_proc_complete_event event is generated. + * completed, a @ref aci_gatt_clt_proc_complete_event_rp0 event is generated. * Before procedure completion the response packets are given through - * @ref aci_att_clt_read_blob_resp_event event. + * @ref aci_att_clt_read_blob_resp_event_rp0 event. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -7173,9 +7252,9 @@ tBleStatus aci_gatt_clt_read_long(uint16_t Connection_Handle, * Values from a server when the client knows the Characteristic Value * Handles. Only values that have a known fixed size can be read, with * the exception of the last value that can have a variable length. When - * the procedure is completed, a @ref aci_gatt_clt_proc_complete_event + * the procedure is completed, a @ref aci_gatt_clt_proc_complete_event_rp0 * event is generated. Before procedure completion the response packets - * are given through @ref aci_att_clt_read_multiple_resp_event event. The + * are given through @ref aci_att_clt_read_multiple_resp_event_rp0 event. The * response only contains a set of Characteristic Values that is less * than or equal to (ATT_MTU - 1) octets in length. If the Set Of Values * is greater than (ATT_MTU - 1) octets in length, only the first @@ -7244,7 +7323,7 @@ tBleStatus aci_gatt_clt_signed_write_without_resp(uint16_t Connection_Handle, /** * @brief Allow application to confirm indication. This command has to be sent * when the application receives the event @ref - * aci_gatt_clt_indication_event. + * aci_gatt_clt_indication_event_rp0. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -7324,9 +7403,9 @@ tBleStatus aci_gatt_srv_multi_notify(uint16_t Connection_Handle, * procedure is useful when the attributes to read have a variable or * unknown value length (otherwise aci_gatt_clt_read_multiple_char_value * may be used). When the procedure is completed, a @ref - * aci_gatt_clt_proc_complete_event event is generated. Before procedure + * aci_gatt_clt_proc_complete_event_rp0 event is generated. Before procedure * completion the response packets are given through @ref - * aci_att_clt_read_multiple_var_len_resp_event event. + * aci_att_clt_read_multiple_var_len_resp_event_rp0 event. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -7460,9 +7539,9 @@ tBleStatus aci_gatt_srv_read_handle_value(uint16_t Attr_Handle, uint16_t *Length, uint8_t * *Value); /** - * @brief Command to be given in response to aci_gatt_srv_read_event, - * aci_gatt_srv_write_event, aci_att_srv_prepare_write_req_event or - * aci_att_srv_exec_write_req_event. It ends the ATT transaction + * @brief Command to be given in response to aci_gatt_srv_read_event_rp0, + * aci_gatt_srv_write_event_rp0, aci_att_srv_prepare_write_req_event_rp0 or + * aci_att_srv_exec_write_req_event_rp0. It ends the ATT transaction * initiated by the remote client. * @param Connection_Handle Connection handle that identifies the connection. * Values: @@ -7492,7 +7571,7 @@ tBleStatus aci_gatt_srv_read_handle_value(uint16_t Attr_Handle, * - 0x11: Insufficient resources * @param Val_Length Length of the Val field. * @param Val Pointer to the value that must be returned in the response, in - * case this is a reply to an aci_gatt_srv_read_event(). In other cases + * case this is a reply to an aci_gatt_srv_read_event_rp0. In other cases * it is ignored. * @retval Value indicating success or error code. */ @@ -7505,9 +7584,9 @@ tBleStatus aci_gatt_srv_resp(uint16_t Connection_Handle, /** * @brief Starts the procedure to write an attribute (characteristic value or * descriptor). When the procedure is completed, a @ref - * aci_gatt_clt_proc_complete_event event is generated. Note: the buffer + * aci_gatt_clt_proc_complete_event_rp0 event is generated. Note: the buffer * containing the value to be written must be kept valid until the @ref - * aci_gatt_clt_proc_complete_event is received + * aci_gatt_clt_proc_complete_event_rp0 is received * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -7530,12 +7609,12 @@ tBleStatus aci_gatt_clt_write(uint16_t Connection_Handle, * the Client knows the Attribute Handle but the length of the Value is * longer than what can be sent in a single Write Request Attribute * Protocol message. During the procedure, - * aci_att_clt_prepare_write_resp_event and - * aci_att_clt_exec_write_resp_event are raised. Note: The memory + * aci_att_clt_prepare_write_resp_event_rp0 and + * aci_att_clt_exec_write_resp_event_rp0 are raised. Note: The memory * pointed by Write_Ops_p parameter and the buffer containing the value * to be written must be kept valid while the procedure is running. They * can be released (or their content can be changed) when the - * aci_gatt_clt_proc_complete_event is emitted indicating that the + * aci_gatt_clt_proc_complete_event_rp0 is emitted indicating that the * procedure is completed, or an error was received. * @param Connection_Handle Connection handle that identifies the connection. * Values: @@ -7551,13 +7630,13 @@ tBleStatus aci_gatt_clt_write_long(uint16_t Connection_Handle, /** * @brief Starts the procedure to write a characteristic reliably (a check is * made on the written values). When the procedure is completed, a @ref - * aci_gatt_clt_proc_complete_event event is generated. During the - * procedure, @ref aci_att_clt_prepare_write_resp_event and @ref - * aci_att_clt_exec_write_resp_event events are raised. Note: The memory + * aci_gatt_clt_proc_complete_event_rp0 event is generated. During the + * procedure, @ref aci_att_clt_prepare_write_resp_event_rp0 and @ref + * aci_att_clt_exec_write_resp_event_rp0 events are raised. Note: The memory * pointed by Write_Ops_p parameter and the buffer containing the value * to be written must be kept valid while the procedure is running. They * can be released (or their content can be changed) when the - * aci_gatt_clt_proc_complete_event is emitted indicating that the + * aci_gatt_clt_proc_complete_event_rp0 is emitted indicating that the * procedure is completed, or an error was received. * @param Connection_Handle Connection handle that identifies the connection. * Values: @@ -7593,6 +7672,23 @@ tBleStatus aci_gatt_srv_read_multiple_instance_handle_value(uint16_t Connection_ uint16_t Attr_Handle, uint16_t *Value_Length, uint8_t * *Value); +/** + * @brief Set minimum security level to accept server-initiated packets + * (Notification, Indication, Multiple Notification). A default level can + * be specified using 0xFFFF value for both Conn_Handle and + * Char_Value_Handle values. If a Notification is received when the + * requested minimum security level is not reached then it will be + * discarded. If a Multiple Notification is received and at least one of + * its attributes doesn't reach requested minimum security level then the + * Multiple Notification is discarded. If an Indication is received when + * the requested minimum security level is not reached then a + * Confirmation is sent and the Indication is discarded. + * @param sec_level_p Pointer to the structure containing the parameters for the + * command: connection handle, attribute handle and minimum security + * level. + * @retval Value indicating success or error code. + */ +tBleStatus aci_gatt_clt_add_subscription_security_level(ble_gatt_clt_sec_level_st * sec_level_p); /** * @} */ @@ -7609,12 +7705,12 @@ tBleStatus aci_gatt_srv_read_multiple_instance_handle_value(uint16_t Connection_ */ /** *@defgroup ACI_L2CAP_Commands ACI L2CAP Commands - *@brief Commands for L2CAP layer. + * Commands for L2CAP layer. *@{ */ /** * @brief Send an L2CAP connection parameter update request from the peripheral - * to the central. An @ref aci_l2cap_connection_update_resp_event event + * to the central. An @ref aci_l2cap_connection_update_resp_event_rp0 event * will be raised when the central will respond to the request (accepts * or rejects). * @param Connection_Handle Connection handle that identifies the connection. @@ -7647,7 +7743,7 @@ tBleStatus aci_l2cap_connection_parameter_update_req(uint16_t Connection_Handle, uint16_t Timeout_Multiplier); /** * @brief Accept or reject a connection update. This command should be sent in - * response to a @ref aci_l2cap_connection_update_req_event event from + * response to a @ref aci_l2cap_connection_update_req_event_rp0 event from * the controller. The accept parameter has to be set if the connection * parameters given in the event are acceptable. * @param Connection_Handle Connection handle that identifies the connection. @@ -7710,7 +7806,11 @@ tBleStatus aci_l2cap_connection_parameter_update_resp(uint16_t Connection_Handle * receiving on this channel. * Values: * - 23 ... 65533 - * @param Channel_Type + * @param Channel_Type Type of channel: LE Credit Based Flow Control Mode or + * Enhanced Credit Based Flow Control Mode. + * Values: + * - 0x00: L2CAP_CHANNEL_TYPE_LE_CFC + * - 0x01: L2CAP_CHANNEL_TYPE_ECFC * @param CID_Count * @retval Value indicating success or error code. */ @@ -7724,7 +7824,7 @@ tBleStatus aci_l2cap_cos_connection_req(uint16_t Connection_Handle, * @brief Command to be sent to respond to a request to open an L2CAP channel * using LE Credit based Flow Control or Enhanced Credit Based Flow * Control Mode. The request is notified through - * aci_l2cap_cos_connection_req_event(). + * aci_l2cap_cos_connection_req_event_rp0. * @param Connection_Handle Connection handle that identifies the connection. * Values: * - 0x0000 ... 0x0EFF @@ -7742,18 +7842,21 @@ tBleStatus aci_l2cap_cos_connection_req(uint16_t Connection_Handle, * - 23 ... 65533 * @param Result It indicates the outcome of the connection request. A result * value of 0x0000 indicates success while a non-zero value indicates a - * fail. + * fail. Code values starting from 0x000C can be used only for ECFC + * channel type. * Values: - * - 0x0000: L2CAP_CONNECTION_SUCCESSFUL + * - 0x0000: L2CAP_CONN_SUCCESSFUL * - 0x0002: L2CAP_CONN_FAIL_SPSM_NOT_SUPPORTED * - 0x0004: L2CAP_CONN_FAIL_INSUFFICIENT_RESOURCES * - 0x0005: L2CAP_CONN_FAIL_INSUFFICIENT_AUTHENTICATION * - 0x0006: L2CAP_CONN_FAIL_INSUFFICIENT_AUTHORIZATION * - 0x0007: L2CAP_CONN_FAIL_KEY_SIZE_TOO_SHORT * - 0x0008: L2CAP_CONN_FAIL_INSUFFICIENT_ENCRYPTION - * - 0x0009: L2CAP_CONN_FAIL_INVALID_SOURCE_CID - * - 0x000A: L2CAP_CONN_FAIL_SOURCE_CID_ALREADY_ALLOCATED * - 0x000B: L2CAP_CONN_FAIL_UNACCEPTABLE_PARAMETERS + * - 0x000C: L2CAP_CONN_FAIL_INVALID_PARAMETERS + * - 0x000D: L2CAP_CONN_FAIL_NO_INFO + * - 0x000E: L2CAP_CONN_FAIL_AUTHENTICATION_PENDING + * - 0x000F: L2CAP_CONN_FAIL_AUTHORIZATION_PENDING * @param CID_Count * @param[out] CID * @retval Value indicating success or error code. @@ -7765,6 +7868,31 @@ tBleStatus aci_l2cap_cos_connection_resp(uint16_t Connection_Handle, uint16_t Result, uint8_t CID_Count, uint16_t CID[]); +/** + * @brief Command to be issued when the device is capable of receiving + * additional K-frames in LE Credit Based Flow Control mode. + * @param Connection_Handle Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + * @param CID The local channel endpoint that identifies the L2CAP channel. + * @param RX_Credits Additional number of K-frames that local L2CAP layer entity + * can currently receive from the peer. + * @param CFC_Policy Policy to handle flow control. If 0, flow control is + * handled by application: credits must be sent using + * aci_l2cap_send_flow_control_credits(). If 1, flow control is handled + * automatically by the stack. + * Values: + * - 0x00: L2CAP_CFC_MANUAL + * - 0x01: L2CAP_CFC_AUTO + * @param[out] RX_Credit_Balance Current number of K-frames that peer's L2CAP + * layer entity can send. + * @retval Value indicating success or error code. + */ +tBleStatus aci_l2cap_cos_flow_control_credits_ind(uint16_t Connection_Handle, + uint16_t CID, + uint16_t RX_Credits, + uint8_t CFC_Policy, + uint16_t *RX_Credit_Balance); /** * @brief Command to terminate an L2CAP channel. * @param Connection_Handle @@ -7795,7 +7923,7 @@ tBleStatus aci_l2cap_cos_sdu_data_transmit(uint16_t Connection_Handle, * to request to change its receive MTU or MPS values compared to when * the channels were created or last reconfigured. * @param Connection_Handle Identifier received in the - * aci_eatt_connection_event. + * aci_eatt_connection_event_rp0. * @param MTU The maximum SDU size (in octets) that the L2CAP layer entity can * receive on each of the Source CID channels (represented by Local_CID * array parameter). This is equal to the maximum size of an ATT packet @@ -7831,8 +7959,8 @@ tBleStatus aci_l2cap_cos_reconfigure_req(uint16_t Connection_Handle, * to be used upon the reception of an * ACI_L2CAP_ECFC_RECONFIGURATION_EVENT. * @param Connection_Handle Identifier received in the - * aci_eatt_connection_event. - * @param Identifier Identifier received in the aci_eatt_connection_event. + * aci_eatt_connection_event_rp0. + * @param Identifier Identifier received in the aci_eatt_connection_event_rp0. * @param Result It indicates the outcome of the connection request. A result * value of 0x0000 indicates success while a non-zero value indicates the * connection request was refused. diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_const.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_const.h index 30b3a0ac9..9850098bf 100644 --- a/lib/stm32wb0/STM32_BLE/stack/include/ble_const.h +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_const.h @@ -29,7 +29,7 @@ /** * @defgroup Link_Layer Link Layer constants and types - * @brief Constants and types related to Link Layer functions + * Constants and types related to Link Layer functions * @{ */ @@ -357,7 +357,7 @@ */ /** *@addtogroup HAL_constants HAL/LL Constants - *@brief Constants for Hardware abstraction Layer and Link Layer. + * Constants for Hardware abstraction Layer and Link Layer. *@{ */ @@ -370,8 +370,8 @@ #define CONFIG_DATA_ER_OFFSET (0x08) /**< Encryption root key used to derive LTK and CSRK */ #define CONFIG_DATA_IR_OFFSET (0x18) /**< Identity root key used to derive LTK and CSRK */ #define CONFIG_DATA_LL_WITHOUT_HOST (0x2C) /**< Switch on/off Link Layer only mode. Set to 1 to disable Host. - It can be written only if aci_hal_write_config_data() is the first command - after reset. */ + It can be written only if aci_hal_write_config_data() is the first command + after reset. */ #define CONFIG_DATA_STATIC_RANDOM_ADDRESS (0x2E) /**< To set the static random address used by the stack, instead of the one stored in NVM. */ #define CONFIG_DATA_SCAN_CH_MAP (0x2F) /**< To set the channel map for scanning. */ #define CONFIG_DATA_STORED_STATIC_RANDOM_ADDRESS (0x80) /**< The static random address stored in NVM. */ @@ -448,7 +448,7 @@ /** *@addtogroup GAP_constants GAP Constants - *@brief Constants for GAP layer + * Constants for GAP layer *@{ */ @@ -456,8 +456,8 @@ * @name Characteristic value lengths * @{ */ -#define APPEARANCE_CHAR_LEN (2) -#define PERIPHERAL_PREFERRED_CONN_PARAMS_CHAR_LEN (8) +#define APPEARANCE_CHAR_LEN (2) +#define PERIPHERAL_PREFERRED_CONN_PARAMS_CHAR_LEN (8) #define CENTRAL_ADDRESS_RESOLUTION_CHAR_LEN (1) /** * @} @@ -469,9 +469,9 @@ * @{ */ -#define AD_TYPE_FLAGS (0x01) +#define AD_TYPE_FLAGS (0x01) -#define AD_TYPE_16_BIT_SERV_UUID (0x02) +#define AD_TYPE_16_BIT_SERV_UUID (0x02) #define AD_TYPE_16_BIT_SERV_UUID_CMPLT_LIST (0x03) #define AD_TYPE_32_BIT_SERV_UUID (0x04) #define AD_TYPE_32_BIT_SERV_UUID_CMPLT_LIST (0x05) @@ -554,8 +554,8 @@ * Values for Operation parameter (see aci_gap_set_advertising_data()). * @{ */ -#define ADV_COMPLETE_DATA (0x03) -#define ADV_UNCHANGED_DATA (0x04) +#define ADV_COMPLETE_DATA (0x03) +#define ADV_UNCHANGED_DATA (0x04) /** * @} */ @@ -688,8 +688,8 @@ * @name Authentication requirements * @{ */ -#define BONDING (0x01) -#define NO_BONDING (0x00) +#define BONDING 0x01 +#define NO_BONDING 0x00 /** * @} */ @@ -772,12 +772,12 @@ /** * @anchor pairing_failed_codes * @name Pairing failed error codes - * Error codes in @ref aci_gap_pairing_complete_event event + * Error codes in @ref aci_gap_pairing_complete_event_rp0 event * @{ */ -#define SM_PAIRING_SUCCESS (0x00) -#define SM_PAIRING_TIMEOUT (0x01) -#define SM_PAIRING_FAILED (0x02) +#define SM_PAIRING_SUCCESS (0x00) +#define SM_PAIRING_TIMEOUT (0x01) +#define SM_PAIRING_FAILED (0x02) /** * @} */ @@ -785,7 +785,7 @@ /** * @anchor secure_connections_support * @name Secure connection support option code - * Error codes in @ref aci_gap_set_authentication_requirement API + * Error codes in @ref aci_gap_set_security_requirements() * @{ */ #define GAP_SC_NOT_SUPPORTED (0x00) /* Not supported */ @@ -799,7 +799,7 @@ /** * @anchor keypress_support * @name Secure connection key press notification option code - * Error codes in @ref aci_gap_set_authentication_requirement API + * Error codes in @ref aci_gap_set_security_requirements() * @{ */ #define GAP_KEYPRESS_NOT_SUPPORTED (0x00) @@ -951,7 +951,7 @@ */ #define GATT_DONT_NOTIFY_EVENTS (0x00) /**< Do not notify events. */ #define GATT_NOTIFY_ATTRIBUTE_WRITE (0x01) /**< The application will be notified when a client writes to this attribute. - An @ref aci_gatt_srv_attribute_modified_event will be issued. */ + An @ref aci_gatt_srv_attribute_modified_event_rp0 will be issued. */ #define GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP (0x02) /**< The application will be notified when a write request, a write cmd or a signed write cmd are received by the server for this attribute.*/ #define GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP (0x04) /**< The application will be notified when a read request of any type is @@ -1043,13 +1043,13 @@ typedef PACKED(struct) _charactFormat { */ /** *@addtogroup L2CAP_constants L2CAP Constants - *@brief Constants for L2CAP layer. + * Constants for L2CAP layer. *@{ */ /** - *@name L2CAP Connection Event Type - *@see aci_l2cap_cfc_connection_event + *@name L2CAP Channel Type + *@see @ref aci_l2cap_cos_connection_req_event_rp0 *@{ */ #define L2CAP_CONN_REQ 0 diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_events.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_events.h index 07e7fdee1..1f0563690 100644 --- a/lib/stm32wb0/STM32_BLE/stack/include/ble_events.h +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_events.h @@ -2,7 +2,7 @@ ****************************************************************************** * @file ble_events.h * @author GPM WBL Application team - * @brief Header file for Bluetooth Low Energy stack events callbacks + * @brief Header file for Bluetooth Low Energy stack event structures * Autogenerated files, do not edit!! ****************************************************************************** * @attention @@ -69,8 +69,7 @@ typedef PACKED(struct) _hci_event_pckt{ typedef PACKED(struct) _hci_event_ext_pckt{ uint8_t evt; /*!< HCI_VENDOR_EVT_CODE is the only allowed value. */ uint16_t plen; /*!< Parameter Total Length, i.e. length of data field. */ - uint8_t data[0]; /*!< Event payload. To be casted to one of event struct types of @ref HCI_evt_structs. - Current possible type is only aci_blecore_event. */ + uint8_t data[0]; /*!< Event payload. Currently it can be only an aci_blecore_event. */ } hci_event_ext_pckt; /** @@ -99,6 +98,15 @@ typedef PACKED(struct) _hci_iso_data_pckt{ * @} */ +/** + *@addtogroup HCI HCI + *@brief Standard Host Controller Interface. + *@{ + */ + +/** @defgroup HCI_evt HCI events + * @{ + */ /** @defgroup HCI_evt_code HCI event codes * @{ @@ -127,45 +135,227 @@ typedef PACKED(struct) _hci_iso_data_pckt{ * Types to be used to cast data field of @ref hci_event_pckt type * @{ */ + +/** + * The Disconnection Complete event occurs when a connection is terminated. The + * status parameter indicates if the disconnection was successful or not. The + * reason parameter indicates the reason for the disconnection if the + * disconnection was successful. If the disconnection was not successful, the + * value of the reason parameter can be ignored by the Host. For example, this + * can be the case if the Host has issued the Disconnect command and there was a + * parameter error, or the command was not presently allowed, or a + * Connection_Handle that didn't correspond to a connection was given. + */ typedef PACKED(struct) hci_disconnection_complete_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection_Handle which was disconnected. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * Reason for disconnection. See Error Codes. + */ uint8_t Reason; } hci_disconnection_complete_event_rp0; +/** + * The Encryption Change event is used to indicate that the change of the + * encryption mode has been completed. The Connection_Handle will be a + * Connection_Handle for an ACL connection. The Encryption_Enabled event + * parameter specifies the new Encryption_Enabled parameter for the + * Connection_Handle specified by the Connection_Handle event parameter. This + * event will occur on both devices to notify the Hosts when Encryption has + * changed for the specified Connection_Handle between two devices. Note: This + * event shall not be generated if encryption is paused or resumed; during a + * role switch, for example. The meaning of the Encryption_Enabled parameter + * depends on whether the Host has indicated support for Secure Connections in + * the Secure_Connections_Host_Support parameter. When + * Secure_Connections_Host_Support is 'disabled' or the Connection_Handle refers + * to an LE link, the Controller shall only use Encryption_Enabled values 0x00 + * (OFF) and 0x01 (ON). (See Bluetooth Specification v.4.1, Vol. 2, Part E, + * 7.7.8) + */ typedef PACKED(struct) hci_encryption_change_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * Link Level Encryption. + * Values: + * - 0x00: Link Level Encryption OFF + * - 0x01: Link Level Encryption is ON with AES-CCM + */ uint8_t Encryption_Enabled; } hci_encryption_change_event_rp0; +/** + * The Read Remote Version Information Complete event is used to indicate the + * completion of the process obtaining the version information of the remote + * Controller specified by the Connection_Handle event parameter. The + * Connection_Handle shall be for an ACL connection. The Version event parameter + * defines the specification version of the LE Controller. The Manufacturer_Name + * event parameter indicates the manufacturer of the remote Controller. The + * Subversion event parameter is controlled by the manufacturer and is + * implementation dependent. The Subversion event parameter defines the various + * revisions that each version of the Bluetooth hardware will go through as + * design processes change and errors are fixed. This allows the software to + * determine what Bluetooth hardware is being used and, if necessary, to work + * around various bugs in the hardware. When the Connection_Handle is associated + * with an LE-U logical link, the Version event parameter shall be Link Layer + * VersNr parameter, the Manufacturer_Name event parameter shall be the CompId + * parameter, and the Subversion event parameter shall be the SubVersNr + * parameter. (See Bluetooth Specification v.4.1, Vol. 2, Part E, 7.7.12) + */ typedef PACKED(struct) hci_read_remote_version_information_complete_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * Version of the Current LMP in the remote Controller + */ uint8_t Version; +/** + * Manufacturer Name of the remote Controller + */ uint16_t Manufacturer_Name; +/** + * Subversion of the LMP in the remote Controller + */ uint16_t Subversion; } hci_read_remote_version_information_complete_event_rp0; +/** + * The Hardware Error event is used to indicate some implementation specific + * type of hardware failure for the controller. This event is used to notify the + * Host that a hardware failure has occurred in the Controller. + */ typedef PACKED(struct) hci_hardware_error_event_rp0_s { +/** + * Error code 0x01 and 0x02 are errors generally caused by hardware issue on the + * PCB; another possible cause is a slow crystal startup. In the latter case, + * the HS_STARTUP_TIME in the device configuration needs to be tuned. Error code + * 0x03 indicates an internal error of the protocol stack. This event with error + * code 0x04 is raised when a radio interrupt is served late. This usually + * happens when interrupts are disabled for too long time or when a Flash + * operation is performed (which can be also triggered by the Stack to store + * bonding information). Stack will try to recover the situation, so there is + * normally no need to reset the device. However this condition should be + * avoided as much as possible. Error code 0x05 is raised when an error happens + * during a TX transaction. After this event is received with error code 0x00, + * 0x01, 0x02 or 0x03, it is recommended to force a device reset. + * Values: + * - 0x00: Generic HW error + * - 0x01: Radio state error + * - 0x02: Timer overrun error + * - 0x03: Internal queue overflow error + * - 0x04: Late Radio ISR + * - 0x05: TX Error + */ uint8_t Hardware_Code; } hci_hardware_error_event_rp0; +/** + * The Number Of Completed Packets event is used by the Controller to indicate + * to the Host how many HCI Data Packets have been completed (transmitted or + * flushed) for each Connection_Handle since the previous Number Of Completed + * Packets event was sent to the Host. This means that the corresponding buffer + * space has been freed in the Controller. Based on this information, and the + * HC_Total_Num_ACL_Data_Packets and HC_Total_Num_Synchronous_- Data_Packets + * return parameter of the Read_Buffer_Size command, the Host can determine for + * which Connection_Handles the following HCI Data Packets should be sent to the + * Controller. The Number Of Completed Packets event must not be sent before the + * corresponding Connection Complete event. While the Controller has HCI data + * packets in its buffer, it must keep sending the Number Of Completed Packets + * event to the Host at least periodically, until it finally reports that all + * the pending ACL Data Packets have been transmitted or flushed. + */ typedef PACKED(struct) hci_number_of_completed_packets_event_rp0_s { +/** + * The number of Connection_Handles and Num_HCI_Data_Packets parameters pairs + * contained in this event + */ uint8_t Number_of_Handles; +/** + * See @ref packed_Handle_Packets_Pair_Entry_t + */ packed_Handle_Packets_Pair_Entry_t Handle_Packets_Pair_Entry[(HCI_MAX_PAYLOAD_SIZE - 1)/sizeof(packed_Handle_Packets_Pair_Entry_t)]; } hci_number_of_completed_packets_event_rp0; +/** + * This event is used to indicate that the Controller's data buffers have been + * overflowed. This can occur if the Host has sent more packets than allowed. + * The Link_Type parameter is used to indicate that the overflow was caused by + * ACL data. + */ typedef PACKED(struct) hci_data_buffer_overflow_event_rp0_s { +/** + * On which type of channel overflow has occurred. + * Values: + * - 0x01: ACL Buffer Overflow + */ uint8_t Link_Type; } hci_data_buffer_overflow_event_rp0; +/** + * The Encryption Key Refresh Complete event is used to indicate to the Host + * that the encryption key was refreshed on the given Connection_Handle any time + * encryption is paused and then resumed. If the Encryption Key Refresh Complete + * event was generated due to an encryption pause and resume operation embedded + * within a change connection link key procedure, the Encryption Key Refresh + * Complete event shall be sent prior to the Change Connection Link Key Complete + * event. If the Encryption Key Refresh Complete event was generated due to an + * encryption pause and resume operation embedded within a role switch + * procedure, the Encryption Key Refresh Complete event shall be sent prior to + * the Role Change event. + */ typedef PACKED(struct) hci_encryption_key_refresh_complete_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; } hci_encryption_key_refresh_complete_event_rp0; +/** + * The HCI_Authenticated_Payload_Timeout_Expired event is used to indicate that + * a packet containing a valid MIC on the Connection_Handle was not received + * within the authenticatedPayloadTO. Note: A Host may choose to disconnect the + * link when this occurs. + */ typedef PACKED(struct) hci_authenticated_payload_timeout_expired_event_rp0_s { +/** + * Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; } hci_authenticated_payload_timeout_expired_event_rp0; @@ -185,8 +375,10 @@ typedef PACKED(struct) hci_le_meta_event_s { * This is data field of @ref hci_event_pckt or @ref hci_event_ext_pckt if evt field is equal to HCI_VENDOR_EVT_CODE. */ typedef PACKED(struct) aci_blecore_event_s { - uint16_t ecode; /*!< A value of @ref ACI_evt_code. */ - uint8_t data[0]; /*!< Proprietary event parameters. To be casted to a struct of @ref ACI_evt_structs. */ + uint16_t ecode; /*!< A proprietary ACI event code. See @ref ACI_HAL_evt_code (HAL/LL), @ref ACI_GAP_evt_code (GAP), + @ref ACI_GATT_evt_code (GATT), @ref ACI_L2CAP_evt_code (L2CAP). */ + uint8_t data[0]; /*!< Proprietary event parameters. To be casted to a struct of @ref ACI_hal_evt_structs, @ref ACI_gap_evt_structs, + @ref ACI_gatt_evt_structs, @ref ACI_l2cap_evt_structs. */ } aci_blecore_event; /** @@ -246,364 +438,2174 @@ typedef PACKED(struct) aci_blecore_event_s { * Types to be used to cast data field of hci_le_meta_event type * @{ */ + +/** + * The LE Connection Complete event indicates to both of the Hosts forming the + * connection that a new connection has been created. Upon the creation of the + * connection a Connection_Handle shall be assigned by the Controller, and + * passed to the Host in this event. If the connection establishment fails this + * event shall be provided to the Host that had issued the LE_Create_Connection + * command. This event indicates to the Host which issued a LE_Create_Connection + * command and received a Command Status event if the connection establishment + * failed or was successful. The Central_Clock_Accuracy parameter is only valid + * for a peripheral. On a central, this parameter shall be set to 0x00. + */ typedef PACKED(struct) hci_le_connection_complete_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle to be used to identify the connection with the peer device. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * Role of the local device in the connection. + * Values: + * - 0x00: Central + * - 0x01: Peripheral + */ uint8_t Role; +/** + * The address type of the peer device. + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + */ uint8_t Peer_Address_Type; +/** + * Public Device Address or Random Device Address of the peer device + */ uint8_t Peer_Address[6]; +/** + * Connection interval used on this connection. Time = N * 1.25 msec + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + */ uint16_t Connection_Interval; +/** + * Maximum Peripheral latency for the connection in number of connection events. + * Values: + * - 0x0000 ... 0x01F3 + */ uint16_t Peripheral_Latency; +/** + * Supervision timeout for the LE Link. It shall be a multiple of 10 ms and + * larger than (1 + connPeripheralLatency) * connInterval * 2. Time = N * 10 + * msec. + * Values: + * - 0x000A (100 ms) ... 0x0C80 (32000 ms) + */ uint16_t Supervision_Timeout; +/** + * Central clock accuracy. Only valid for a Peripheral. + * Values: + * - 0x00: 500 ppm + * - 0x01: 250 ppm + * - 0x02: 150 ppm + * - 0x03: 100 ppm + * - 0x04: 75 ppm + * - 0x05: 50 ppm + * - 0x06: 30 ppm + * - 0x07: 20 ppm + */ uint8_t Central_Clock_Accuracy; } hci_le_connection_complete_event_rp0; +/** + * The LE Advertising Report event indicates that a Bluetooth device or multiple + * Bluetooth devices have responded to an active scan or received some + * information during a passive scan. The Controller may queue these advertising + * reports and send information from multiple devices in one LE Advertising + * Report event. + */ typedef PACKED(struct) hci_le_advertising_report_event_rp0_s { +/** + * Number of responses in this event. + * Values: + * - 0x01 + */ uint8_t Num_Reports; +/** + * See @ref packed_Advertising_Report_t + */ packed_Advertising_Report_t Advertising_Report; /* N elements of variable size */ } hci_le_advertising_report_event_rp0; +/** + * The LE Connection Update Complete event is used to indicate that the + * Controller process to update the connection has completed. On a peripheral, + * if no connection parameters are updated, then this event shall not be issued. + * On a central, this event shall be issued if the Connection_Update command was + * sent. + */ typedef PACKED(struct) hci_le_connection_update_complete_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle to be used to identify the connection with the peer device. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * Connection interval used on this connection. Time = N * 1.25 msec + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + */ uint16_t Connection_Interval; +/** + * Maximum Peripheral latency for the connection in number of connection events. + * Values: + * - 0x0000 ... 0x01F3 + */ uint16_t Peripheral_Latency; +/** + * Supervision timeout for the LE Link. It shall be a multiple of 10 ms and + * larger than (1 + connPeripheralLatency) * connInterval * 2. Time = N * 10 + * msec. + * Values: + * - 0x000A (100 ms) ... 0x0C80 (32000 ms) + */ uint16_t Supervision_Timeout; } hci_le_connection_update_complete_event_rp0; +/** + * The LE Read Remote Features Complete event is used to indicate the completion + * of the process of the Controller obtaining the used features of the remote + * Bluetooth device specified by the Connection_Handle event parameter. + */ typedef PACKED(struct) hci_le_read_remote_features_complete_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle to be used to identify the connection with the peer device. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * Bit Mask List of used LE features. For details see LE Link Layer + * specification. + */ uint8_t LE_Features[8]; } hci_le_read_remote_features_complete_event_rp0; +/** + * The LE Long Term Key Request event indicates that the central device is + * attempting to encrypt or re-encrypt the link and is requesting the Long Term + * Key from the Host. (See [Vol 6] Part B, Section 5.1.3). + */ typedef PACKED(struct) hci_le_long_term_key_request_event_rp0_s { +/** + * Connection handle to be used to identify the connection with the peer device. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * 64-bit random number + */ uint8_t Random_Number[8]; +/** + * 16-bit encrypted diversifier + */ uint16_t Encrypted_Diversifier; } hci_le_long_term_key_request_event_rp0; +/** + * The LE Data Length Change event notifies the Host of a change to either the + * maximum Payload length or the maximum transmission time of Data Channel PDUs + * in either direction. The values reported are the maximum that will actually + * be used on the connection following the change. + */ typedef PACKED(struct) hci_le_data_length_change_event_rp0_s { +/** + * Connection_Handle to be used to identify a connection. + */ uint16_t Connection_Handle; +/** + * The maximum number of payload octets in a Link Layer Data Channel PDU that + * the local Controller will send on this connection (connEffectiveMaxTxOctets + * defined in [Vol 6] Part B, Section 4.5.10). Range 0x001B-0x00FB (0x0000 - + * 0x001A and 0x00FC - 0xFFFF Reserved for future use) + */ uint16_t MaxTxOctets; +/** + * The maximum time that the local Controller will take to send a Link Layer + * Data Channel PDU on this connection (connEffectiveMaxTx-Time defined in [Vol + * 6] Part B, Section 4.5.10). Range 0x0148-0x0848 (0x0000 - 0x0127 and 0x0849 - + * 0xFFFF Reserved for future use) + */ uint16_t MaxTxTime; +/** + * The maximum number of payload octets in a Link Layer Data Channel PDU that + * the local controller expects to receive on this connection + * (connEfectiveMaxRxOctets defined in [Vol 6] Part B, Section 4.5.10). Range + * 0x001B-0x00FB (0x0000 - 0x001A and 0x00FC - 0xFFFF Reserved for future use) + */ uint16_t MaxRxOctets; +/** + * The maximum time that the local Controller expects to take to receive a Link + * Layer Data Channel PDU on this connection (connEffectiveMax-RxTime defined in + * [Vol 6] Part B, Section 4.5.10). Range 0x0148-0x0848 (0x0000 - 0x0127 and + * 0x0849 - 0xFFFF Reserved for future use) + */ uint16_t MaxRxTime; } hci_le_data_length_change_event_rp0; +/** + * This event is generated when local P-256 key generation is complete. + */ typedef PACKED(struct) hci_le_read_local_p256_public_key_complete_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Local P-256 public key. + */ uint8_t Local_P256_Public_Key[64]; } hci_le_read_local_p256_public_key_complete_event_rp0; +/** + * This event indicates that LE Diffie Hellman key generation has been completed + * by the Controller. + */ typedef PACKED(struct) hci_le_generate_dhkey_complete_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Diffie Hellman Key + */ uint8_t DHKey[32]; } hci_le_generate_dhkey_complete_event_rp0; +/** + * The LE Enhanced Connection Complete event indicates to both of the Hosts + * forming the connection that a new connection has been created. Upon the + * creation of the connection a Connection_Handle shall be assigned by the + * Controller, and passed to the Host in this event. If the connection + * establishment fails, this event shall be provided to the Host that had issued + * the LE_Create_Connection command. If this event is unmasked and LE Connection + * Complete event is unmasked, only the LE Enhanced Connection Complete event is + * sent when a new connection has been completed. This event indicates to the + * Host that issued a LE_Create_Connection command and received a Command Status + * event if the connection establishment failed or was successful. The + * Central_Clock_Accuracy parameter is only valid for a peripheral. On a + * central, this parameter shall be set to 0x00. + */ typedef PACKED(struct) hci_le_enhanced_connection_complete_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle to be used to identify the connection with the peer device. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * Role of the local device in the connection. + * Values: + * - 0x00: Central + * - 0x01: Peripheral + */ uint8_t Role; +/** + * 0x00 Public Device Address 0x01 Random Device Address 0x02 Public Identity + * Address (Corresponds to Resolved Private Address) 0x03 Random (Static) + * Identity Address (Corresponds to Resolved Private Address) + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Public Identity Address + * - 0x03: Random (Static) Identity Address + */ uint8_t Peer_Address_Type; +/** + * Public Device Address, Random Device Address, Public Identity Address or + * Random (static) Identity Address of the device to be connected. + */ uint8_t Peer_Address[6]; +/** + * Resolvable Private Address being used by the local device for this + * connection. This is only valid when the Own_Address_Type is set to 0x02 or + * 0x03. For other Own_Address_Type values, the Controller shall return all + * zeros. + */ uint8_t Local_Resolvable_Private_Address[6]; +/** + * Resolvable Private Address being used by the peer device for this connection. + * This is only valid for Peer_Address_Type 0x02 and 0x03. For other + * Peer_Address_Type values, the Controller shall return all zeros. + */ uint8_t Peer_Resolvable_Private_Address[6]; +/** + * Connection interval used on this connection. Time = N * 1.25 msec + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + */ uint16_t Connection_Interval; +/** + * Maximum Peripheral latency for the connection in number of connection events. + * Values: + * - 0x0000 ... 0x01F3 + */ uint16_t Peripheral_Latency; +/** + * Supervision timeout for the LE Link. It shall be a multiple of 10 ms and + * larger than (1 + connPeripheralLatency) * connInterval * 2. Time = N * 10 + * msec. + * Values: + * - 0x000A (100 ms) ... 0x0C80 (32000 ms) + */ uint16_t Supervision_Timeout; +/** + * Central clock accuracy. Only valid for a Peripheral. + * Values: + * - 0x00: 500 ppm + * - 0x01: 250 ppm + * - 0x02: 150 ppm + * - 0x03: 100 ppm + * - 0x04: 75 ppm + * - 0x05: 50 ppm + * - 0x06: 30 ppm + * - 0x07: 20 ppm + */ uint8_t Central_Clock_Accuracy; } hci_le_enhanced_connection_complete_event_rp0; +/** + * The HCI_LE_Directed_Advertising_Report event indicates that directed + * advertisements have been received where the advertiser is using a resolvable + * private address for the TargetA field of the advertising PDU which the + * Controller is unable to resolve and the Scanning_Filter_Policy is equal to + * 0x02 or 0x03. Direct_Address_Type and Direct_Address specify the address the + * directed advertisements are being directed to. Address_Type and Address + * specify the address of the advertiser sending the directed advertisements. + * The Controller may queue these advertising reports and send information from + * multiple advertisers in one HCI_LE_Directed_Advertising_Report event. This + * event shall only be generated if scanning was enabled using the + * HCI_LE_Set_Scan_Enable command. It only reports advertising events that used + * legacy advertising PDUs. + */ typedef PACKED(struct) hci_le_directed_advertising_report_event_rp0_s { +/** + * Number of responses in this event. + * Values: + * - 0x01 + */ uint8_t Num_Reports; +/** + * See @ref packed_Direct_Advertising_Report_t + */ packed_Direct_Advertising_Report_t Direct_Advertising_Report[(HCI_MAX_PAYLOAD_SIZE - 1)/sizeof(packed_Direct_Advertising_Report_t)]; } hci_le_directed_advertising_report_event_rp0; +/** + * The LE PHY Update Complete Event is used to indicate that the Controller has + * changed the transmitter PHY or receiver PHY in use. If the Controller changes + * the transmitter PHY, the receiver PHY, or both PHYs, this event shall be + * issued. If an LE_Set_PHY command was sent and the Controller determines that + * neither PHY will change as a result, it issues this event immediately. + */ typedef PACKED(struct) hci_le_phy_update_complete_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection_Handle to be used to identify a connection. + */ uint16_t Connection_Handle; +/** + * The transmitter PHY for the connection + * Values: + * - 0x01: The transmitter PHY for the connection is LE 1M + * - 0x02: The transmitter PHY for the connection is LE 2M + * - 0x03: The transmitter PHY for the connection is LE Coded + */ uint8_t TX_PHY; +/** + * The receiver PHY for the connection + * Values: + * - 0x01: The receiver PHY for the connection is LE 1M + * - 0x02: The receiver PHY for the connection is LE 2M + * - 0x03: The receiver PHY for the connection is LE Coded + */ uint8_t RX_PHY; } hci_le_phy_update_complete_event_rp0; +/** + * The LE Extended Advertising Report event indicates that one or more Bluetooth + * devices have responded to an active scan or have broadcast advertisements + * that were received during a passive scan. The Controller may coalesce + * multiple advertising reports from the same or different advertisers into a + * single LE Extended Advertising Report event, provided all the parameters from + * all the advertising reports fit in a single HCI event. This event shall only + * be generated if scanning was enabled using the LE Set Extended Scan Enable + * command. It reports advertising events using either legacy or extended + * advertising PDUs. The Controller may split the data from a single + * advertisement (whether one PDU or several) into several reports. If so, each + * report except the last shall have an Event_Type with a data status field of + * "incomplete, more data to come", while the last shall have the value + * "complete"; the Address_Type, Address, Advertising_SID, Primary_PHY, and + * Secondary_PHY fields shall be the same in all the reports. When a scan + * response is received, bits 0-2 and 4 of the event type shall indicate the + * properties of the original advertising event. An Event_Type with a data + * status field of "incomplete, data truncated" indicates that the Controller + * attempted to receive an AUX_CHAIN_IND PDU but was not successful. + */ typedef PACKED(struct) hci_le_extended_advertising_report_event_rp0_s { +/** + * Number of separate reports in the event + * Values: + * - 0x01 ... 0x0A + */ uint8_t Num_Reports; +/** + * See @ref packed_Extended_Advertising_Report_t + */ packed_Extended_Advertising_Report_t Extended_Advertising_Report; /* N elements of variable size */ } hci_le_extended_advertising_report_event_rp0; +/** + * The LE Periodic Advertising Report event indicates that the Controller has + * received a Periodic Advertising packet. The Sync_Handle parameter indicates + * the identifier for the periodic advertisements specified by the Advertising + * SID subfield of the ADI field in the ADV_EXT_IND PDU. The Controller may + * split the data from a single periodic advertisement (whether one PDU or + * several) into several reports. If so, each report except the last shall have + * a Data_Status of "incomplete, more data to come", while the last shall have + * the value "complete". A Data_Status of "incomplete, data truncated" indicates + * that the Controller attempted to receive an AUX_CHAIN_IND PDU but was not + * successful. The Unused parameter shall be set to 0xFF by the Controller and + * ignored by the Host. + */ typedef PACKED(struct) hci_le_periodic_advertising_sync_established_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Sync handle that identifies the synchronization information about the + * periodic advertising train. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Sync_Handle; +/** + * Advertising SID subfield in the ADI field of the PDU + * Values: + * - 0x00 ... 0x0F: Value of the Advertising SID subfield in the ADI field of the PDU + * - 0x10 ... 0xFF: Reserved for future use + */ uint8_t Advertising_SID; +/** + * Advertising Address Type + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Public Identity Address (corresponds to Resolved Private Address) + * - 0x03: Random (static) Identity Address (corresponds to Resolved PrivateAddress) + */ uint8_t Advertiser_Address_Type; +/** + * Public Device Address, Random Device Address, Public Identity Address, or + * Random (static) Identity Address of the advertiser + */ uint8_t Advertiser_Address[6]; +/** + * Advertiser PHY + * Values: + * - 0x01: Advertiser PHY is LE 1M + * - 0x02: Advertiser PHY is LE 2M + * - 0x03: Advertiser PHY is LE Coded + * - 0x04 ... 0xFF: Reserved for future use + */ uint8_t Advertiser_PHY; +/** + * Periodic Advertising Interval Time = N * 1.25 ms Time Range: 7.5 ms to + * 81.91875 s + * Values: + * - 0x0006 (7.50 ms) ... 0xFFFF (NaN) + */ uint16_t Periodic_Advertising_Interval; +/** + * Advertiser Clock Accuracy + * Values: + * - 0x00: 500 ppm + * - 0x01: 250 ppm + * - 0x02: 150 ppm + * - 0x03: 100 ppm + * - 0x04: 75 ppm + * - 0x05: 50 ppm + * - 0x06: 30 ppm + * - 0x07: 20 ppm + * - 0x08 ... 0xFF: Reserved for future use + */ uint8_t Advertiser_Clock_Accuracy; } hci_le_periodic_advertising_sync_established_event_rp0; +/** + * The LE Periodic Advertising Report event indicates that the Controller has + * received a Periodic Advertising packet. The Sync_Handle parameter indicates + * the identifier for the periodic advertisements specified by the Advertising + * SID subfield of the ADI field in the ADV_EXT_IND PDU. The Controller may + * split the data from a single periodic advertisement (whether one PDU or + * several) into several reports. If so, each report except the last shall have + * a Data_Status of "incomplete, more data to come", while the last shall have + * the value "complete". A Data_Status of "incomplete, data truncated" indicates + * that the Controller attempted to receive an AUX_CHAIN_IND PDU but was not + * successful. The Unused parameter shall be set to 0xFF by the Controller and + * ignored by the Host. + */ typedef PACKED(struct) hci_le_periodic_advertising_report_event_rp0_s { +/** + * Sync handle that identifies the synchronization information about the + * periodic advertising train. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Sync_Handle; +/** + * TX Power. Units: dBm + * Values: + * - -127 ... 126 + * - 127: NA + */ int8_t TX_Power; +/** + * RSSI value Units: dBm + * Values: + * - -127 ... 20: RSSI value + * - 127: RSSI is not available + */ int8_t RSSI; +/** + * + * Values: + * - 0x00: AoA Constant Tone Extension + * - 0x01: AoD Constant Tone Extension with 1 microsecond slots + * - 0x02: AoD Constant Tone Extension with 2 microseconds slots + * - 0xFF: No Constant Tone Extension + */ uint8_t CTE_Type; +/** + * Data Status + * Values: + * - 0x00: Data complete + * - 0x01: Data incomplete, more data to come + * - 0x02: Data incomplete, data truncated, no more to come + * - 0x03 ... 0xFF: Reserved for future use + */ uint8_t Data_Status; +/** + * Length of the Data field + * Values: + * - 0 ... 247: Length of the Data field + * - 248 ... 255: Reserved for future use + */ uint8_t Data_Length; +/** + * Data received from a Periodic Advertising packet + */ uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; } hci_le_periodic_advertising_report_event_rp0; +/** + * The LE Periodic Advertising Sync Lost event indicates that the Controller has + * not received a Periodic Advertising packet identified by Sync_Handle within + * the timeout period. + */ typedef PACKED(struct) hci_le_periodic_advertising_sync_lost_event_rp0_s { +/** + * Sync handle that identifies the synchronization information about the + * periodic advertising train. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Sync_Handle; } hci_le_periodic_advertising_sync_lost_event_rp0; +/** + * The LE Advertising Set Terminated event indicates that the Controller has + * terminated advertising in the advertising sets specified by the + * Advertising_Handle parameter. This event shall be generated every time + * connectable advertising in an advertising set results in a connection being + * created. This event shall only be generated if advertising was enabled using + * the LE Set Extended Advertising Enable command. The Connection_Handle + * parameter is only valid when advertising ends because a connection was + * created. If the Max_Extended_Advertising_Events parameter in the + * LE_Set_Extended_Advertising_Enable command was non-zero, the + * Num_Completed_Extended_Advertising_Events parameter shall be set to the + * number of completed extended advertising events the Controller had + * transmitted when either the duration elapsed or the maximum number of + * extended advertising events was reached; otherwise it shall be set to zero. + * If advertising has terminated as a result of the advertising duration + * elapsing, the Status parameter shall be set to the error code Advertising + * Timeout (0x3C). If advertising has terminated because the + * Max_Extended_Advertising_Events was reached, the Status parameter shall be + * set to the error code Limit Reached (0x43). + */ typedef PACKED(struct) hci_le_advertising_set_terminated_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Advertising handle in which advertising has ended + * Values: + * - 0x00 ... 0xEF: Advertising_Handle in which advertising has ended + * - 0xF0 ... 0xFF: Reserved for future use + */ uint8_t Advertising_Handle; +/** + * Connection_Handle to be used to identify a connection. + */ uint16_t Connection_Handle; +/** + * Number of completed extended advertising events transmitted by the Controller + */ uint8_t Num_Completed_Extended_Advertising_Events; } hci_le_advertising_set_terminated_event_rp0; +/** + * The LE Scan Request Received event indicates that a SCAN_REQ PDU or an + * AUX_SCAN_REQ PDU has been received by the advertiser. The request contains a + * device address from a scanner that is allowed by the advertising filter + * policy. The advertising set is identified by Advertising_Handle. This event + * shall only be generated if advertising was enabled using the LE Set Extended + * Advertising Enable command. The Scanner_Address_Type and Scanner_Address + * indicates the type of the address and the address of the scanner device. + */ typedef PACKED(struct) hci_le_scan_request_received_event_rp0_s { +/** + * It is used to identify an advertising set + * Values: + * - 0x00 ... 0xEF: Used to identify an advertising set + * - 0xF0 ... 0xFF: Reserved for future use + */ uint8_t Advertising_Handle; +/** + * Scanner address type + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Public Identity Address (corresponds to Resolved Private Address) + * - 0x03: Random (static) Identity Address (corresponds to Resolved Private +Address) + * - 0x04 ... 0xFF: Reserved for future use + */ uint8_t Scanner_Address_Type; +/** + * Public Device Address, Random Device Address, Public Identity Address or + * Random (static) Identity Address of the advertising device + */ uint8_t Scanner_Address[6]; } hci_le_scan_request_received_event_rp0; +/** + * The LE Channel Selection Algorithm Event indicates which channel selection + * algorithm is used on a data channel connection (see [Vol 6] Part B, Section + * 4.5.8). + */ typedef PACKED(struct) hci_le_channel_selection_algorithm_event_rp0_s { +/** + * Connection_Handle to be used to identify a connection. + */ uint16_t Connection_Handle; +/** + * Channel selection algorithm to be used on a data channel connection + * Values: + * - 0x00: LE Channel Selection Algorithm #1 is used + * - 0x01: LE Channel Selection Algorithm #2 is used + * - 0x02 ... 0xFF: Reserved for future use + */ uint8_t Channel_Selection_Algorithm; } hci_le_channel_selection_algorithm_event_rp0; +/** + * The HCI_LE_Connectionless_IQ_Report event is used by the Controller to report + * IQ information from the Constant Tone Extension of a received advertising + * packet forming part of the periodic advertising train identified by + * Sync_Handle and to report IQ information from the Constant Tone Extension of + * a received Test Mode packet (see Section 7.8.28). The index of the channel on + * which the packet was received, the RSSI of the packet (excluding the Constant + * Tone Extension), the ID of the antenna on which this was measured, the type + * of Constant Tone Extension, the value of paEventCounter, and the IQ samples + * of the Constant Tone Extension of the advertisement are reported in the + * corresponding parameters. For any given sample, either both or neither of + * I_Sample[i] and Q_Sample[i] shall equal 0x80. The Slot_Durations parameter + * specifies the sampling rate used by the Controller. The Packet_Status + * parameter indicates whether the received packet had a valid CRC and, if not, + * whether the Controller has determined the position and size of the Constant + * Tone Extension using the Length and CTETime fields. Note: A Controller is not + * required to generate this event for packets that have a bad CRC. The Constant + * Tone Extension format is defined in [Vol 6] Part B, Section 2.5.1. If the PDU + * contains AdvData, then the HCI_LE_Periodic_Advertising_Report event shall be + * generated before this event. The Controller is not required to generate this + * event for a Constant Tone Extension with a type that it does not support. + * This event is also used by the Controller to report that it has insufficient + * resources to report IQ samples for all received Constant Tone Extensions and + * has failed to sample at least once. In this case Packet_Status shall be set + * to 0xFF and Sample_Count to 0x00. + */ typedef PACKED(struct) hci_le_connectionless_iq_report_event_rp0_s { +/** + * Sync_Handle identifying the periodic advertising train. + * Values: + * - 0x0000 ... 0x0EFF + * - 0x0FFF: TEST_SYNC_HANDLE + */ uint16_t Sync_Handle; +/** + * 0x25-0x27 can be used only for packets generated during test modes. + * Values: + * - 0x00 ... 0x27: The index of the channel on which the packet was received. + */ uint8_t Channel_Index; +/** + * RSSI of the packet. Units: 0.1 dBm. + * Values: + * - -1270 ... 200 + */ int16_t RSSI; +/** + * Antenna ID + */ uint8_t RSSI_Antenna_ID; +/** + * Type of Constant Tone Extension. + * Values: + * - 0x00: AoA_CTE + * - 0x01: AoD_CTE_1us + * - 0x02: AoD_CTE_2us + */ uint8_t CTE_Type; +/** + * Sampling rate used by the Controller. + * Values: + * - 0x01: CTE_SLOT_1us + * - 0x02: CTE_SLOT_2us + */ uint8_t Slot_Durations; +/** + * It indicates whether the received packet had a valid CRC and, if not, whether + * the Controller has determined the position and size of the Constant Tone + * Extension using the Length and CTETime fields. 0x00 - CRC was correct; 0x01 + * - CRC was incorrect and the Length and CTETime fields of the packet were used + * to determine sampling points; 0x02 - CRC was incorrect but the Controller + * has determined the position and length of the Constant Tone Extension in some + * other way; 0xFF - Insufficient resources to sample (Channel_Index, CTE_Type, + * and Slot_Durations invalid). + * Values: + * - 0x00: CRC_OK + * - 0x01: CRC_ERROR_1 + * - 0x02: CRC_ERROR_2 + * - 0xFF: NO_SAMPLES + */ uint8_t Packet_Status; +/** + * The value of paEventCounter (see [Vol 6] Part B, Section 4.4.2.1) for the + * reported AUX_SYNC_IND PDU + */ uint16_t Periodic_Event_Counter; +/** + * Total number of sample pairs (there shall be the same number of I samples and + * Q samples). Note: This number is dependent on the switch and sample slot + * durations used. + * Values: + * - 0x00 + * - 0x09 ... 0x52 + */ uint8_t Sample_Count; +/** + * See @ref packed_Samples_t + */ packed_Samples_t Samples[(HCI_MAX_PAYLOAD_SIZE - 12)/sizeof(packed_Samples_t)]; } hci_le_connectionless_iq_report_event_rp0; +/** + * The HCI_LE_Connection_IQ_Report event is used by the Controller to report the + * IQ samples from the Constant Tone Extension of a received packet (see [Vol 6] + * Part B, Section 2.4.2.26). The Connection_Handle parameter identifies the + * connection that corresponds to the reported information. The receiver PHY, + * the index of the data channel, the RSSI value of the packet (excluding the + * Constant Tone Extension), the ID of the antenna on which this was measured, + * the type of Constant Tone Extension, the value of connEventCounter, and the + * IQ samples of the Constant Tone Extension of the received packet are reported + * in the corresponding parameters. For any given sample, either both or neither + * of I_Sample[i] and Q_Sample[i] shall equal 0x80. The Slot_Durations parameter + * specifies the sampling rate used by the Controller. The Packet_Status + * parameter indicates whether the received packet had a valid CRC and, if not, + * whether the Controller has determined the position and size of the Constant + * Tone Extension using the Length and CTETime fields. Note: A Controller is not + * required to generate this event for packets that have a bad CRC. This event + * is also used by the Controller to report that it has insufficient resources + * to report IQ samples for all received Constant Tone Extensions and has failed + * to sample at least once. In this case Packet_Status shall be set to 0xFF and + * Sample_Count to 0x00. The Constant Tone Extension format is defined in [Vol + * 6] Part B, Section 2.1.5. + */ typedef PACKED(struct) hci_le_connection_iq_report_event_rp0_s { +/** + * Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * + * Values: + * - 0x01: The receiver PHY for the connection is LE 1M + * - 0x02: The receiver PHY for the connection is LE 2M + */ uint8_t RX_PHY; +/** + * + * Values: + * - 0x00 ... 0x24: The index of the data channel on which the Data Physical Channel PDU was received. + */ uint8_t Data_Channel_Index; +/** + * RSSI of the packet. Units: 0.1 dBm. + * Values: + * - -1270 ... 200 + */ int16_t RSSI; +/** + * ID of the antenna on which the RSSI is measured + */ uint8_t RSSI_Antenna_ID; +/** + * + * Values: + * - 0x00: AoA Constant Tone Extension + * - 0x01: AoD Constant Tone Extension with 1 microsecond slots + * - 0x02: AoD Constant Tone Extension with 2 microseconds slots + */ uint8_t CTE_Type; +/** + * Sampling rate used by the Controller. + * Values: + * - 0x01: CTE_SLOT_1us + * - 0x02: CTE_SLOT_2us + */ uint8_t Slot_Durations; +/** + * + * Values: + * - 0x00: CRC was correct + * - 0x01: CRC was incorrect and the Length and CTETime fields of the packet were used to determine sampling points + * - 0x02: CRC was incorrect but the Controller has determined the position and length of the Constant Tone Extension in some other way + * - 0xFF: Insufficient resources to sample (Channel_Index, CTE_Type, and Slot_Durations invalid). + */ uint8_t Packet_Status; +/** + * The value of connEventCounter (see [Vol 6] Part B, Section 4.5.1) for the + * reported PDU + */ uint16_t Connection_Event_Counter; +/** + * Total number of sample pairs. + * Values: + * - 0x00 + * - 0x09 ... 0x52 + */ uint8_t Sample_Count; +/** + * See @ref packed_Samples_t + */ packed_Samples_t Samples[(HCI_MAX_PAYLOAD_SIZE - 13)/sizeof(packed_Samples_t)]; } hci_le_connection_iq_report_event_rp0; +/** + * This event is used by the Controller to report an issue following a request + * to a peer device to reply with a packet containing an LL_CTE_RSP PDU and a + * Constant Tone Extension. It shall be generated if the packet containing the + * LL_CTE_RSP PDU sent in response did not contain a Constant Tone Extension or + * if the peer rejected the request. It shall not be generated if the packet + * containing the LL_CTE_RSP PDU had a CRC error or if the procedure response + * timeout timer (see [Vol 6] Part B, Section 5.2) expired. + */ typedef PACKED(struct) hci_le_cte_request_failed_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; } hci_le_cte_request_failed_event_rp0; +/** + * The HCI_LE_Periodic_Advertising_Sync_Transfer_Received event is used by the + * Controller to report that it has received periodic advertising + * synchronization information from the device referred to by the + * Connection_Handle parameter and either successfully synchronized to the + * periodic advertising train or timed out while attempting to synchronize. The + * Status will be zero if it successfully synchronized and non-zero otherwise. + * The Service_Data value is provided by the Host of the device sending the + * information. The Sync_Handle identifies the periodic advertising in + * subsequent commands and events and shall be assigned by the Controller. The + * remaining parameters provide information about the periodic advertising (see + * Section 7.7.65.14). If Status is non-zero, all parameter values are valid + * except Sync_Handle, which the Host shall ignore. Note: If the Controller is + * already synchronized to the periodic advertising train described in the + * received information, no event will be generated. + */ typedef PACKED(struct) hci_le_periodic_advertising_sync_transfer_received_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * A value provided by the peer device + */ uint16_t Service_data; +/** + * Sync handle that identifies the synchronization information about the + * periodic advertising train. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Sync_Handle; +/** + * + * Values: + * - 0x00 ... 0x0F: Value of the Advertising SID used to advertise the periodic advertising + */ uint8_t Advertising_SID; +/** + * + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Public Identity Address (corresponds to Resolved Private Address) + * - 0x03: Random (static) Identity Address (corresponds to Resolved Private Address) + */ uint8_t Advertiser_Address_Type; +/** + * Public Device Address, Random Device Address, Public Identity Address, or + * Random (static) Identity Address of the advertiser + */ uint8_t Advertiser_Address[6]; +/** + * + * Values: + * - 0x01: Advertiser PHY is LE 1M + * - 0x02: Advertiser PHY is LE 2M + * - 0x03: Advertiser PHY is LE Coded + */ uint8_t Advertiser_PHY; +/** + * Periodic advertising interval. Time = N * 1.25 ms; Time Range: 7.5ms to + * 81.91875 s. + * Values: + * - 0x0006 (7.50 ms) ... 0xFFFF (NaN) + */ uint16_t Periodic_Advertising_Interval; +/** + * Advertiser Clock Accuracy + * Values: + * - 0x00: 500 ppm + * - 0x01: 250 ppm + * - 0x02: 150 ppm + * - 0x03: 100 ppm + * - 0x04: 75 ppm + * - 0x05: 60 ppm + * - 0x06: 30 ppm + * - 0x07: 20 ppm + */ uint8_t Advertiser_Clock_Accuracy; } hci_le_periodic_advertising_sync_transfer_received_event_rp0; +/** + * The HCI_LE_CIS_Established event indicates that a CIS has been established, + * was considered lost before being established, or (on the Central) was + * rejected by the Peripheral. It is generated by the Controller in the Central + * and Peripheral. The Connection_Handle parameter shall be set to the value + * provided in the HCI_LE_Create_CIS command on the Central and in the + * HCI_LE_CIS_Request event on the Peripheral. The CIG_Sync_Delay parameter is + * the maximum time, in microseconds, for transmission of PDUs of all CISes in a + * CIG event (see [Vol 6] Part B, Section 4.5.14.1). The CIS_Sync_Delay + * parameter is the maximum time, in microseconds, for transmission of PDUs of + * the specified CIS in a CIG event (see [Vol 6] Part B, Section 4.5.14.1). The + * Transport_Latency_C_To_P and Transport_Latency_P_To_C parameters are the + * actual transport latencies, in microseconds, as described in [Vol 6] Part G, + * Section 3.2.1 and [Vol 6] Part G, Section 3.2.2. The PHY_C_To_P parameter + * indicates the PHY selected for packets from the Central to Peripheral. The + * PHY_P_To_C parameter indicates the PHY selected for packets from the + * Peripheral to Central. The NSE, BN_C_To_P, BN_P_To_C, FT_C_To_P, FT_P_To_C, + * Max_PDU_- C_To_P, Max_PDU_P_To_C, and ISO_Interval parameters are the + * corresponding parameters of the CIS (see [Vol 6] Part B, Section 4.5.13.1). + * If this event is generated on the Peripheral with a non-zero status, the + * Controller shall delete the Connection_Handle and any associated ISO data + * paths. + */ typedef PACKED(struct) hci_le_cis_established_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle of the CIS. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * The maximum time, in microseconds, for transmission of PDUs of all CISes in a + * CIG event. + * Values: + * - 0x0000EA ... 0x7FFFFF + */ uint8_t CIG_Sync_Delay[3]; +/** + * The maximum time, in microseconds, for transmission of PDUs of the specified + * CIS in a CIG event. + * Values: + * - 0x0000EA ... 0x7FFFFF + */ uint8_t CIS_Sync_Delay[3]; +/** + * The actual transport latency, in microseconds, from Central to Peripheral. + * Values: + * - 0x0000EA ... 0x7FFFFF + */ uint8_t Transport_Latency_C_To_P[3]; +/** + * The actual transport latency, in microseconds, from Peripheral to Central. + * Values: + * - 0x0000EA ... 0x7FFFFF + */ uint8_t Transport_Latency_P_To_C[3]; +/** + * The transmitter PHY of packets from the Central. + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY + */ uint8_t PHY_C_To_P; +/** + * The transmitter PHY of packets from the Peripheral. + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY + */ uint8_t PHY_P_To_C; +/** + * Maximum number of subevents in each isochronous event. + * Values: + * - 0x01 ... 0x1F + */ uint8_t NSE; +/** + * The burst number for Central to Peripheral transmission. + * Values: + * - 0x00: No data + * - 0x01 ... 0x0F + */ uint8_t BN_C_To_P; +/** + * The burst number for Peripheral to Central transmission. + * Values: + * - 0x00: No data + * - 0x01 ... 0x0F + */ uint8_t BN_P_To_C; +/** + * The flush timeout, in multiples of the ISO_Interval for the CIS, for each + * payload sent from the Central to the Peripheral. + * Values: + * - 0x01 ... 0xFF + */ uint8_t FT_C_To_P; +/** + * The flush timeout, in multiples of the ISO_Interval for the CIS, for each + * payload sent from the Peripheral to the Central. + * Values: + * - 0x01 ... 0xFF + */ uint8_t FT_P_To_C; +/** + * Maximum size, in octets, of the payload from Central to Peripheral. + * Values: + * - 0x0000 ... 0x00FB + */ uint16_t Max_PDU_C_To_P; +/** + * Maximum size, in octets, of the payload from Peripheral to Central. + * Values: + * - 0x0000 ... 0x00FB + */ uint16_t Max_PDU_P_To_C; +/** + * The time between two consecutive CIS anchor points. Time = N * 1.25 ms. + * Values: + * - 0x0004 (5.00 ms) ... 0x0C80 (4000.00 ms) + */ uint16_t ISO_Interval; } hci_le_cis_established_event_rp0; +/** + * The HCI_LE_CIS_Request event indicates that a Controller has received a + * request to establish a CIS. If the Controller receives such a request while + * the HCI_LE_CIS_Request event is masked away, it shall reject it. Otherwise + * the Controller shall assign a connection handle for the requested CIS and + * send the handle in the CIS_Connection_Handle parameter of the event. When the + * Host receives this event it shall respond with either an + * HCI_LE_Accept_CIS_Request command or an HCI_LE_Reject_CIS_Request command + * before the timer Connection_Accept_Timeout expires. If it does not, the + * Controller shall reject the request and generate an HCI_LE_CIS_Established + * event with the status Connection Accept Timeout Exceeded (0x10). The + * ACL_Connection_Handle is the connection handle of the ACL connection that is + * associated with the requested CIS. The CIG_ID parameter contains the + * identifier of the CIG that contains the requested CIS. This parameter is sent + * by the Central in the request to establish the CIS. The CIS_ID parameter + * contains the identifier of the requested CIS. This parameter is sent by the + * Central in the request to establish the CIS. + */ typedef PACKED(struct) hci_le_cis_request_event_rp0_s { +/** + * Connection handle of the ACL. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t ACL_Connection_Handle; +/** + * Connection handle of the CIS. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t CIS_Connection_Handle; +/** + * Identifier of the CIG. + * Values: + * - 0x00 ... 0xEF + */ uint8_t CIG_ID; +/** + * Identifier of the CIS. + * Values: + * - 0x00 ... 0xEF + */ uint8_t CIS_ID; } hci_le_cis_request_event_rp0; +/** + * The HCI_LE_Create_BIG_Complete event indicates that the HCI_LE_Create_BIG + * command has completed. + */ typedef PACKED(struct) hci_le_create_big_complete_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * The identifier of the BIG. + * Values: + * - 0x00 ... 0xEF + */ uint8_t BIG_Handle; +/** + * The maximum time in microseconds for transmission of PDUs of all BISes in a + * BIG event. + * Values: + * - 0x0000EA ... 0x7FFFFF + */ uint8_t BIG_Sync_Delay[3]; +/** + * The maximum delay time, in microseconds, for transmission of SDUs of all + * BISes in a BIG event. + * Values: + * - 0x0000EA ... 0x7FFFFF + */ uint8_t Transport_Latency_BIG[3]; +/** + * The PHY used to create the BIG. + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY + */ uint8_t PHY; +/** + * The number of subevents in each BIS event in the BIG. + * Values: + * - 0x01 ... 0x1E + */ uint8_t NSE; +/** + * The number of new payloads in each BIS event. + * Values: + * - 0x01 ... 0x07 + */ uint8_t BN; +/** + * Offset used for pre-transmissions. + * Values: + * - 0x00 ... 0x0F + */ uint8_t PTO; +/** + * The number of times a payload is transmitted in a BIS event. + * Values: + * - 0x01 ... 0x0F + */ uint8_t IRC; +/** + * Maximum size, in octets, of the payload. + * Values: + * - 0x0000 ... 0x00FB + */ uint16_t Max_PDU; +/** + * The time between two consecutive BIG anchor points. Time = N * 1.25 ms. + * Values: + * - 0x0004 (5.00 ms) ... 0x0C80 (4000.00 ms) + */ uint16_t ISO_Interval; +/** + * Total number of BISes in the BIG. + * Values: + * - 0x01 ... 0x1F + */ uint8_t Num_BIS; +/** + * The connection handles of the BISes in the BIG. + */ uint16_t Connection_Handle[(HCI_MAX_PAYLOAD_SIZE - 18)/sizeof(uint16_t)]; } hci_le_create_big_complete_event_rp0; +/** + * The HCI_LE_Terminate_BIG_Complete event indicates that the transmission of + * all the BISes in the BIG are terminated. + */ typedef PACKED(struct) hci_le_terminate_big_complete_event_rp0_s { +/** + * The identifier of the BIG. + * Values: + * - 0x00 ... 0xEF + */ uint8_t BIG_Handle; +/** + * Reason for termination. See Error Codes. + */ uint8_t Reason; } hci_le_terminate_big_complete_event_rp0; +/** + * The HCI_LE_BIG_Sync_Established event indicates that the + * HCI_LE_BIG_Create_Sync command has completed. + */ typedef PACKED(struct) hci_le_big_sync_established_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * The identifier of the BIG. + * Values: + * - 0x00 ... 0xEF + */ uint8_t BIG_Handle; +/** + * The maximum delay time, in microseconds, for transmission of SDUs of all + * BISes in a BIG event. + * Values: + * - 0x0000EA ... 0x7FFFFF + */ uint8_t Transport_Latency_BIG[3]; +/** + * The number of subevents in each BIS event in the BIG. + * Values: + * - 0x01 ... 0x1E + */ uint8_t NSE; +/** + * The number of new payloads in each BIS event. + * Values: + * - 0x01 ... 0x07 + */ uint8_t BN; +/** + * Offset used for pre-transmissions. + * Values: + * - 0x00 ... 0x0F + */ uint8_t PTO; +/** + * The number of times a payload is transmitted in a BIS event. + * Values: + * - 0x01 ... 0x0F + */ uint8_t IRC; +/** + * Maximum size, in octets, of the payload. + * Values: + * - 0x0000 ... 0x00FB + */ uint16_t Max_PDU; +/** + * The time between two consecutive BIG anchor points. Time = N * 1.25 ms. + * Values: + * - 0x0004 (5.00 ms) ... 0x0C80 (4000.00 ms) + */ uint16_t ISO_Interval; +/** + * Total number of BISes in the BIG. + * Values: + * - 0x01 ... 0x1F + */ uint8_t Num_BIS; +/** + * The connection handles of the BISes in the BIG. + */ uint16_t Connection_Handle[(HCI_MAX_PAYLOAD_SIZE - 14)/sizeof(uint16_t)]; } hci_le_big_sync_established_event_rp0; +/** + * The HCI_LE_BIG_Sync_Lost event indicates that the Controller has not received + * any PDUs on a BIG within the timeout period BIG_Sync_Timeout or the BIG has + * been terminated by the remote device. + */ typedef PACKED(struct) hci_le_big_sync_lost_event_rp0_s { +/** + * The identifier of the BIG. + * Values: + * - 0x00 ... 0xEF + */ uint8_t BIG_Handle; +/** + * Reason for termination. See Error Codes. + */ uint8_t Reason; } hci_le_big_sync_lost_event_rp0; +/** + * The HCI_LE_Request_Peer_SCA_Complete event indicates that the + * HCI_LE_Request_Peer_SCA command has been completed. The Peer_Clock_Accuracy + * parameter contains the sleep clock accuracy of the peer. The + * Connection_Handle is the connection handle of the ACL connection in which the + * HCI_LE_Request_Peer_SCA command is issued. + */ typedef PACKED(struct) hci_le_request_peer_sca_complete_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle of the ACL. + */ uint16_t Connection_Handle; +/** + * Sleep clock accuracy of the peer. + * Values: + * - 0x00: 251 ppm to 500 ppm + * - 0x01: 151 ppm to 250 ppm + * - 0x02: 101 ppm to 150 ppm + * - 0x03: 76 ppm to 100 ppm + * - 0x04: 51 ppm to 75 ppm + * - 0x05: 31 ppm to 50 ppm + * - 0x06: 21 ppm to 30 ppm + * - 0x07: 0 ppm to 20 ppm + */ uint8_t Peer_Clock_Accuracy; } hci_le_request_peer_sca_complete_event_rp0; +/** + * Report a path loss threshold crossing on the ACL connection identified by the + * Connection_Handle parameter. + */ typedef PACKED(struct) hci_le_path_loss_threshold_event_rp0_s { +/** + * Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * Current path loss (always zero or positive). Units: dB. + * Values: + * - 0 ... 254 + * - 255: NA + */ uint8_t Current_Path_Loss; +/** + * The Zone_Entered parameter indicates which zone was entered. + * Values: + * - 0x00: LOW_ZONE + * - 0x01: MIDDLE_ZONE + * - 0x02: HIGH_ZONE + */ uint8_t Zone_Entered; } hci_le_path_loss_threshold_event_rp0; +/** + * Report the transmit power level on the ACL connection identified by the + * Connection_Handle parameter. + */ typedef PACKED(struct) hci_le_transmit_power_reporting_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * The reason why the event was sent and the device whose transmit power level + * is being reported. - 0x00: Local transmit power changed - 0x01: Remote + * transmit power changed - 0x02: HCI_LE_Read_Remote_Transmit_Power_Level + * command completed + * Values: + * - 0x00: LOCAL_TX_POWER_CHANGE + * - 0x01: REMOTE_TX_POWER_CHANGE + * - 0x02: READ_REMOTE_TX_POWER_COMPLETE + */ uint8_t Reason; +/** + * PHY associated with the connection (not necessarily the currently used one). + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY_S8 + * - 0x04: LE_CODED_PHY_S2 + */ uint8_t PHY; +/** + * The transmit power level for the PHY (dBm). + * Values: + * - -127 ... 20 + * - 126: POWER_NOT_MANAGED + * - 127: POWER_NA + */ int8_t Transmit_Power_Level; +/** + * It indicates whether the transmit power level that is being reported has + * reached its minimum and/or maximum level. Transmit_Power_Level_Flag shall be + * ignored if the Transmit_Power_Level parameter is set to 0x7E or 0x7F. + * Flags: + * - 0x01: MIN_TX_POWER_BIT + * - 0x02: MAX_TX_POWER_BIT + */ uint8_t Transmit_Power_Level_Flag; +/** + * The Delta parameter is set to the change in power level for the transmitter + * being reported, whenever it changes its transmit power level. Delta shall be + * ignored if the Transmit_Power_Level parameter is set to 0x7E. + * Values: + * - 0 ... 126 + * - 127: NA + */ int8_t Delta; } hci_le_transmit_power_reporting_event_rp0; +/** + * The HCI_LE_BIGInfo_Advertising_Report event indicates that the Controller has + * received an Advertising PDU that contained a BIGInfo field. If the Controller + * also generates an HCI_LE_Periodic_Advertising_Report event, the + * HCI_LE_BIGInfo_Advertising_Report event shall immediately follow that event. + * An HCI_LE_BIGInfo_Advertising_Report event shall be generated even if the + * Controller is already synchronized to the BIG. The Sync_Handle parameter + * shall identify the periodic advertising train containing the BIGInfo field + * and shall be the same as the corresponding field in the + * HCI_LE_Periodic_Advertising_Report event if one is generated. The Num_BIS, + * NSE, ISO_Interval, BN, PTO, IRC, Max_PDU, SDU_Interval, Max_SDU, PHY, and + * Framing parameters correspond to the associated fields in the BIGInfo field + * of the Advertising PDU. If the BIGInfo field indicates that the corresponding + * BIG is encrypted, the Encryption parameter shall be set to 0x01. Otherwise, + * the Encryption parameter shall be set to 0x00. + */ typedef PACKED(struct) hci_le_biginfo_advertising_report_event_rp0_s { +/** + * Sync_Handle identifying the periodic advertising train. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Sync_Handle; +/** + * Value of the Num_BIS subfield of the BIGInfo field. + * Values: + * - 0x01 ... 0x1F + */ uint8_t Num_BIS; +/** + * Value of the NSE subfield of the BIGInfo field. + */ uint8_t NSE; +/** + * Value of the ISO_Interval subfield of the BIGInfo field. + */ uint16_t ISO_Interval; +/** + * Value of the BN subfield of the BIGInfo field. + * Values: + * - 0x01 ... 0x07 + */ uint8_t BN; +/** + * Value of the PTO subfield of the BIGInfo field. + * Values: + * - 0x00 ... 0x0F + */ uint8_t PTO; +/** + * Value of the IRC subfield of the BIGInfo field. + * Values: + * - 0x01 ... 0x0F + */ uint8_t IRC; +/** + * Value of the Max_PDU subfield of the BIGInfo. + * Values: + * - 0x0000 ... 0x00FB + */ uint16_t Max_PDU; +/** + * Value of the SDU_Interval subfield of the BIGInfo field. + * Values: + * - 0x0000FF ... 0x0FFFFF + */ uint8_t SDU_Interval[3]; +/** + * Value of the Max_SDU subfield of the BIGInfo field in the Advertising PDU. + * Values: + * - 0x0001 ... 0x0FFF + */ uint16_t Max_SDU; +/** + * The PHY on which the BIG is transmitted. + * Values: + * - 0x01: LE_1M_PHY + * - 0x02: LE_2M_PHY + * - 0x03: LE_CODED_PHY + */ uint8_t PHY; +/** + * If BIG carries encrypted (1) or unencrypted (0) data. + * Values: + * - 0x00: Unencrypted + * - 0x01: Encrypted + */ uint8_t Framing; +/** + * If BIG carries encrypted (1) or unencrypted (0) data. + * Values: + * - 0x00: Unencrypted + * - 0x01: Encrypted + */ uint8_t Encryption; } hci_le_biginfo_advertising_report_event_rp0; +/** + * The HCI_LE_Subrate_Change event is used to indicate that a Connection Subrate + * Update procedure has completed and some parameters of the specified + * connection have changed. This event shall be issued if the + * HCI_LE_Subrate_Request command was issued by the Host or the parameters are + * updated successfully following a request from the peer device. If no + * parameters are updated following a request from the peer device or the + * parameters were changed using the Connection Update procedure, then this + * event shall not be issued. + */ typedef PACKED(struct) hci_le_subrate_change_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Handle identifying the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * New subrate factor applied to the specified underlying connection interval. + * Values: + * - 0x0001 ... 0x01F4 + */ uint16_t Subrate_Factor; +/** + * New Peripheral latency for the connection in number of subrated connection + * events, + * Values: + * - 0x0000 ... 0x01F3 + */ uint16_t Peripheral_Latency; +/** + * Number of underlying connection events to remain active after a packet + * containing a Link Layer PDU with a non-zero Length field is sent or received. + * Values: + * - 0x0000 ... 0x01F3 + */ uint16_t Continuation_Number; +/** + * New supervision timeout for this connection. Time = N x 10 ms. + * Values: + * - 0x000A (100 ms) ... 0x0C80 (32000 ms) + */ uint16_t Supervision_Timeout; } hci_le_subrate_change_event_rp0; +/** + * The HCI_LE_Periodic_Advertising_Sync_Established event indicates that the + * Controller has received the first periodic advertising packet from an + * advertiser after the HCI_LE_Periodic_Advertising_Create_Sync command has been + * sent to the Controller. The Sync_Handle parameter identifies the periodic + * advertising train in subsequent commands and events and shall be assigned by + * the Controller. The Advertising_SID parameter is set to the value of the + * Advertising SID subfield in the ADI field of the advertising PDU referring to + * the periodic advertising train. The Advertiser_Address_Type and + * Advertiser_Address parameters specify the address of the periodic advertiser. + * The Advertiser_PHY parameter specifies the PHY used for the periodic + * advertising. The Periodic_Advertising_Interval parameter specifies the + * interval between the periodic advertising events. The + * Advertiser_Clock_Accuracy parameter specifies the accuracy of the periodic + * advertiser's clock. If the periodic advertising has subevents or response + * slots, then the Num_- Subevents, Subevent_Interval, Response_Slot_Delay, and + * Response_Slot_- Spacing specify the parameters for these subevents, otherwise + * these values shall be set to 0x00. + */ typedef PACKED(struct) hci_le_periodic_advertising_sync_established_v2_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Sync handle that identifies the synchronization information about the + * periodic advertising train. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Sync_Handle; +/** + * Advertising SID subfield in the ADI field of the PDU + * Values: + * - 0x00 ... 0x0F: Value of the Advertising SID subfield in the ADI field of the PDU + * - 0x10 ... 0xFF: Reserved for future use + */ uint8_t Advertising_SID; +/** + * Advertising Address Type + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Public Identity Address (corresponds to Resolved Private Address) + * - 0x03: Random (static) Identity Address (corresponds to Resolved PrivateAddress) + */ uint8_t Advertiser_Address_Type; +/** + * Public Device Address, Random Device Address, Public Identity Address, or + * Random (static) Identity Address of the advertiser + */ uint8_t Advertiser_Address[6]; +/** + * Advertiser PHY + * Values: + * - 0x01: Advertiser PHY is LE 1M + * - 0x02: Advertiser PHY is LE 2M + * - 0x03: Advertiser PHY is LE Coded + * - 0x04 ... 0xFF: Reserved for future use + */ uint8_t Advertiser_PHY; +/** + * Periodic Advertising Interval Time = N * 1.25 ms Time Range: 7.5 ms to + * 81.91875 s + * Values: + * - 0x0006 (7.50 ms) ... 0xFFFF (NaN) + */ uint16_t Periodic_Advertising_Interval; +/** + * Advertiser Clock Accuracy + * Values: + * - 0x00: 500 ppm + * - 0x01: 250 ppm + * - 0x02: 150 ppm + * - 0x03: 100 ppm + * - 0x04: 75 ppm + * - 0x05: 50 ppm + * - 0x06: 30 ppm + * - 0x07: 20 ppm + * - 0x08 ... 0xFF: Reserved for future use + */ uint8_t Advertiser_Clock_Accuracy; +/** + * Number of subevents. + * Values: + * - 0x00 ... 0x80 + */ uint8_t Num_Subevents; +/** + * Subevent interval. Time = N x 1.25 ms. + * Values: + * - 0x00 (NaN) : No subevents + * - 0x06 (7.50 ms) ... 0xFF (318.75 ms) + */ uint8_t Subevent_Interval; +/** + * Response slot delay. Range: 0x01 to 0xFE. Time = N x 1.25 ms + * Values: + * - 0x00 (NaN) : No response slots + * - 0x01 (1.25 ms) ... 0xFE (317.50 ms) + */ uint8_t Response_Slot_Delay; +/** + * Response slot spacing Range: 0x02 to 0xFF Time = N x 0.125 ms + * Values: + * - 0x00 (0.000 ms) : No response slots + * - 0x02 (0.250 ms) ... 0xFF (31.875 ms) + */ uint8_t Response_Slot_Spacing; } hci_le_periodic_advertising_sync_established_v2_event_rp0; +/** + * The HCI_LE_Periodic_Advertising_Report event indicates that the Controller + * has received a periodic advertisement or has failed to receive an + * AUX_SYNC_SUBEVENT_IND PDU. The Sync_Handle parameter identifies the periodic + * advertising train that the report relates to. The RSSI parameter contains the + * RSSI value, excluding any Constant Tone Extension. If the Controller supports + * the Connectionless CTE Receiver feature, RSSI shall not be set to 0x7F. When + * multiple advertising packets are used to complete a periodic advertising + * report (e.g., a packet containing an AUX_SYNC_IND PDU combined with one + * containing an AUX_CHAIN PDU), the RSSI event parameter shall be set based on + * the last packet received and the TX_Power event parameter shall be set based + * on the AUX_SYNC_IND PDU. However, the second or subsequent events for the + * same periodic advertisement may instead have a TX_Power value of 0x7F. The + * Controller may split the data from a single periodic advertisement (whether + * one PDU or several) into several reports. If so, each report except the last + * shall have a Data_Status of "incomplete, more data to come", while the last + * shall have the value "complete". No further reports shall be sent for a given + * periodic advertisement after one with a Data_Status other than "incomplete, + * more data to come". A Data_Status of "incomplete, data truncated" indicates + * that the Controller attempted to receive an AUX_CHAIN_IND PDU but was not + * successful or received it but was unable to store the data. The CTE_Type + * parameter indicates the type of Constant Tone Extension in the periodic + * advertising packets. The Periodic_Event_Counter parameter indicates the + * periodic advertising event counter (paEventCounter) of the event that the + * periodic advertising packet was received in. The Subevent parameter indicates + * the Periodic Advertising with Responses subevent that the periodic + * advertising packet was received in. If the Periodic Advertising does not have + * subevents, then Subevent shall be set to 0xFF. If the Controller receives an + * AUX_CHAIN_IND PDU with no AdvData, it should send the report (or the last + * report if it has split the data) immediately without waiting for any + * subsequent AUX_CHAIN_IND PDUs. + */ typedef PACKED(struct) hci_le_periodic_advertising_report_v2_event_rp0_s { +/** + * Sync handle that identifies the synchronization information about the + * periodic advertising train. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Sync_Handle; +/** + * TX Power. Units: dBm + * Values: + * - -127 ... 126 + * - 127: NA + */ int8_t TX_Power; +/** + * RSSI value Units: dBm + * Values: + * - -127 ... 20: RSSI value + * - 127: RSSI is not available + */ int8_t RSSI; +/** + * + * Values: + * - 0x00: AoA Constant Tone Extension + * - 0x01: AoD Constant Tone Extension with 1 microsecond slots + * - 0x02: AoD Constant Tone Extension with 2 microseconds slots + * - 0xFF: No Constant Tone Extension + */ uint8_t CTE_Type; +/** + * The value of paEventCounter (see [Vol 6] Part B, Section 4.4.2.1) for the + * reported periodic advertising packet. + */ uint16_t Periodic_Event_Counter; +/** + * The subevent number. + * Values: + * - 0x00 ... 0x7F + * - 0xFF: No subevents + */ uint8_t Subevent; +/** + * Data Status + * Values: + * - 0x00: Data complete + * - 0x01: Data incomplete, more data to come + * - 0x02: Data incomplete, data truncated, no more to come + * - 0xFF: Failed to receive an AUX_SYNC_SUBEVENT_IND PDU + */ uint8_t Data_Status; +/** + * Length of the Data field + * Values: + * - 0 ... 247: Length of the Data field + * - 248 ... 255: Reserved for future use + */ uint8_t Data_Length; +/** + * Data received from a Periodic Advertising packet + */ uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 10)/sizeof(uint8_t)]; } hci_le_periodic_advertising_report_v2_event_rp0; +/** + * The HCI_LE_Periodic_Advertising_Sync_Transfer_Received event is used by the + * Controller to report that it has received periodic advertising + * synchronization information from the device referred to by the + * Connection_Handle parameter and either successfully synchronized to the + * periodic advertising train or timed out while attempting to synchronize. The + * Status will be zero if it successfully synchronized and non-zero otherwise. + * The Service_Data value is provided by the Host of the device sending the + * information. The Sync_Handle identifies the periodic advertising in + * subsequent commands and events and shall be assigned by the Controller. The + * remaining parameters provide information about the periodic advertising (see + * Section 7.7.65.14). If there are no subevents or response slots, then the + * Controller shall set the Num_Subevents parameter to zero and the Host shall + * ignore the Subevent_Interval, Response_Slot_Delay, and Response_Slot_- + * Spacing parameters. If Status is non-zero, all parameter values are valid + * except Sync_Handle, which the Host shall ignore. Note: If the Controller is + * already synchronized to the periodic advertising train described in the + * received information, no event will be generated. + */ typedef PACKED(struct) hci_le_periodic_advertising_sync_transfer_received_v2_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * A value provided by the peer device + */ uint16_t Service_data; +/** + * Sync handle that identifies the synchronization information about the + * periodic advertising train. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Sync_Handle; +/** + * + * Values: + * - 0x00 ... 0x0F: Value of the Advertising SID used to advertise the periodic advertising + */ uint8_t Advertising_SID; +/** + * + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Public Identity Address (corresponds to Resolved Private Address) + * - 0x03: Random (static) Identity Address (corresponds to Resolved Private Address) + */ uint8_t Advertiser_Address_Type; +/** + * Public Device Address, Random Device Address, Public Identity Address, or + * Random (static) Identity Address of the advertiser + */ uint8_t Advertiser_Address[6]; +/** + * + * Values: + * - 0x01: Advertiser PHY is LE 1M + * - 0x02: Advertiser PHY is LE 2M + * - 0x03: Advertiser PHY is LE Coded + */ uint8_t Advertiser_PHY; +/** + * Periodic advertising interval. Time = N * 1.25 ms; Time Range: 7.5ms to + * 81.91875 s. + * Values: + * - 0x0006 (7.50 ms) ... 0xFFFF (NaN) + */ uint16_t Periodic_Advertising_Interval; +/** + * Advertiser Clock Accuracy + * Values: + * - 0x00: 500 ppm + * - 0x01: 250 ppm + * - 0x02: 150 ppm + * - 0x03: 100 ppm + * - 0x04: 75 ppm + * - 0x05: 60 ppm + * - 0x06: 30 ppm + * - 0x07: 20 ppm + */ uint8_t Advertiser_Clock_Accuracy; +/** + * Number of subevents. + * Values: + * - 0x00 ... 0x80 + */ uint8_t Num_Subevents; +/** + * Subevent interval. Time = N x 1.25 ms. + * Values: + * - 0x00 (NaN) : No subevents + * - 0x06 (7.50 ms) ... 0xFF (318.75 ms) + */ uint8_t Subevent_Interval; +/** + * Response slot delay. Range: 0x01 to 0xFE. Time = N x 1.25 ms + * Values: + * - 0x00 (NaN) : No response slots + * - 0x01 (1.25 ms) ... 0xFE (317.50 ms) + */ uint8_t Response_Slot_Delay; +/** + * Response slot spacing Range: 0x02 to 0xFF Time = N x 0.125 ms + * Values: + * - 0x00 (0.000 ms) : No response slots + * - 0x02 (0.250 ms) ... 0xFF (31.875 ms) + */ uint8_t Response_Slot_Spacing; } hci_le_periodic_advertising_sync_transfer_received_v2_event_rp0; +/** + * The HCI_LE_Periodic_Advertising_Subevent_Data_Request event is used to allow + * the Controller to indicate that it is ready to transmit one or more subevents + * and is requesting the advertising data for these subevents. The + * Subevent_Data_Count parameter shall be less than or equal to the number of + * subevents. The Subevent_Start parameter is the first subevent being requested + * and the Subevent_Data_Count parameter determines the subsequent subevents + * being requested. The subevent numbers wrap from one less than the number of + * subevents to zero. This event should be sent from the Controller when it has + * no data for upcoming subevents. The Controller should request data for as + * many subevents as it has memory to accept to minimize the number of events + * generated by the Controller. + */ typedef PACKED(struct) hci_le_periodic_advertising_subevent_data_request_event_rp0_s { +/** + * Used to identify a periodic advertising train. + */ uint8_t Advertising_Handle; +/** + * The first subevent that data is requested for. + * Values: + * - 0x00 ... 0x7F + */ uint8_t Subevent_Start; +/** + * The number of subevents that data is requested for. + * Values: + * - 0x01 ... 0x80 + */ uint8_t Subevent_Data_Count; } hci_le_periodic_advertising_subevent_data_request_event_rp0; +/** + * The HCI_LE_Periodic_Advertising_Response_Report event indicates that one or + * more Bluetooth devices have responded to a periodic advertising subevent + * during a PAwR train. The Controller may queue these advertising reports and + * send information from multiple devices in one HCI_LE_Periodic_Advertising_- + * Response_Report event. The Controller may fail to transmit the + * synchronization packet required to enable the response packets to be sent. If + * this happens, the Controller can report this to the Host using the Tx_Status + * parameter. The Controller may split the data from a single response into + * several reports. If so, each report except the last shall have a Data_Status + * of "incomplete, more data to come", while the last shall have the value + * "complete". No further reports shall be sent for a given periodic + * advertisement after one with a Data_Status other than "incomplete, more data + * to come". + */ typedef PACKED(struct) hci_le_periodic_advertising_response_report_event_rp0_s { +/** + * Used to identify a periodic advertising train. + */ uint8_t Advertising_Handle; +/** + * The subevent number. + */ uint8_t Subevent; +/** + * If AUX_SYNC_SUBEVENT_IND was transmitted or not. + */ uint8_t Tx_Status; +/** + * Number of responses in event. + * Values: + * - 0x00 ... 0x19 + */ uint8_t Num_Responses; +/** + * See @ref packed_Periodic_Advertising_Response_t + */ packed_Periodic_Advertising_Response_t Periodic_Advertising_Response; /* N elements of variable size */ } hci_le_periodic_advertising_response_report_event_rp0; +/** + * The HCI_LE_Enhanced_Connection_Complete event indicates to both of the Hosts + * forming the connection that a new connection has been created. Upon the + * creation of the connection a Connection_Handle shall be assigned by the + * Controller, and passed to the Host in this event. If the connection creation + * fails, this event shall be provided to the Host that had issued the + * HCI_LE_Create_- Connection or HCI_LE_Extended_Create_Connection command. If + * this event is unmasked and the HCI_LE_Connection_Complete event is unmasked, + * only the HCI_LE_Enhanced_Connection_Complete event is sent when a new + * connection has been created. This event indicates to the Host that issued an + * HCI_LE_Create_Connection or HCI_LE_Extended_Create_Connection command and + * received an HCI_Command_Status event if the connection creation failed or was + * successful. The Peer_Address, Peer_Resolvable_Private_Address, and Local_- + * Resolvable_Private_Address shall always reflect the most recent packet sent + * and received on air. The Central_Clock_Accuracy parameter is only valid for a + * Peripheral. On a Central, this parameter shall be set to 0x00. If the + * connection is established from periodic advertising with responses and Role + * is 0x00, then the Advertising_Handle parameter shall be set according to the + * periodic advertising train the connection was established from. If the + * connection is established from periodic advertising with responses and Role + * is 0x01, then the Sync_Handle parameter shall be set according to the + * periodic advertising train the connection was established from. In all other + * circumstances, Advertising_Handle and Sync_Handle shall be set to No + * Advertising_Handle and No Sync_Handle and shall be ignored by the Host. + */ typedef PACKED(struct) hci_le_enhanced_connection_complete_v2_event_rp0_s { +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Connection handle to be used to identify the connection with the peer device. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * Role of the local device in the connection. + * Values: + * - 0x00: Central + * - 0x01: Peripheral + */ uint8_t Role; +/** + * 0x00 Public Device Address 0x01 Random Device Address 0x02 Public Identity + * Address (Corresponds to Resolved Private Address) 0x03 Random (Static) + * Identity Address (Corresponds to Resolved Private Address) + * Values: + * - 0x00: Public Device Address + * - 0x01: Random Device Address + * - 0x02: Public Identity Address + * - 0x03: Random (Static) Identity Address + */ uint8_t Peer_Address_Type; +/** + * Public Device Address, Random Device Address, Public Identity Address or + * Random (static) Identity Address of the device to be connected. + */ uint8_t Peer_Address[6]; +/** + * Resolvable Private Address being used by the local device for this + * connection. This is only valid when the Own_Address_Type is set to 0x02 or + * 0x03. For other Own_Address_Type values, the Controller shall return all + * zeros. + */ uint8_t Local_Resolvable_Private_Address[6]; +/** + * Resolvable Private Address being used by the peer device for this connection. + * This is only valid for Peer_Address_Type 0x02 and 0x03. For other + * Peer_Address_Type values, the Controller shall return all zeros. + */ uint8_t Peer_Resolvable_Private_Address[6]; +/** + * Connection interval used on this connection. Time = N * 1.25 msec + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + */ uint16_t Connection_Interval; +/** + * Maximum Peripheral latency for the connection in number of connection events. + * Values: + * - 0x0000 ... 0x01F3 + */ uint16_t Peripheral_Latency; +/** + * Supervision timeout for the LE Link. It shall be a multiple of 10 ms and + * larger than (1 + connPeripheralLatency) * connInterval * 2. Time = N * 10 + * msec. + * Values: + * - 0x000A (100 ms) ... 0x0C80 (32000 ms) + */ uint16_t Supervision_Timeout; +/** + * Central clock accuracy. Only valid for a Peripheral. + * Values: + * - 0x00: 500 ppm + * - 0x01: 250 ppm + * - 0x02: 150 ppm + * - 0x03: 100 ppm + * - 0x04: 75 ppm + * - 0x05: 50 ppm + * - 0x06: 30 ppm + * - 0x07: 20 ppm + */ uint8_t Central_Clock_Accuracy; +/** + * Used to identify an advertising set. + */ uint8_t Advertising_Handle; +/** + * Sync_Handle identifying the periodic advertising train. + * Values: + * - 0x0000 ... 0x0EFF + * - 0xFFFF: No Sync_Handle + */ uint16_t Sync_Handle; } hci_le_enhanced_connection_complete_v2_event_rp0; @@ -611,17 +2613,48 @@ typedef PACKED(struct) hci_le_enhanced_connection_complete_v2_event_rp0_s { * @} */ -/** @defgroup ACI_evt_code ACI proprietary event codes - * Codes found in ecode field of aci_blecore_event struct. - * @{ +/** + * @} */ -/* Vendor specific codes of ACI GAP events */ +/** + * @} + */ + +/** + *@addtogroup HAL_LL HAL/LL + *@{ + */ + +/** @defgroup ACI_HAL_evt_code ACI HAL proprietary event codes + * ACI HAL event codes found in ecode field of aci_blecore_event struct. + * @{ + */ #define ACI_HAL_END_OF_RADIO_ACTIVITY_VSEVT_CODE 0x0004 #define ACI_HAL_FW_ERROR_VSEVT_CODE 0x0006 #define ACI_HAL_ADV_SCAN_RESP_DATA_UPDATE_VSEVT_CODE 0x0010 #define ACI_HAL_PAWR_DATA_FREE_VSEVT_CODE 0x0011 + +/** + * @} + */ + +/** + * @} + */ + +/** + *@addtogroup GAP GAP + *@brief Generic Access Profile + *@{ + */ + +/** @defgroup ACI_GAP_evt_code ACI GAP proprietary event codes + * ACI GAP event codes found in ecode field of aci_blecore_event struct. + * @{ + */ + #define ACI_GAP_LIMITED_DISCOVERABLE_VSEVT_CODE 0x0400 #define ACI_GAP_PAIRING_COMPLETE_VSEVT_CODE 0x0401 #define ACI_GAP_PASSKEY_REQ_VSEVT_CODE 0x0402 @@ -630,6 +2663,25 @@ typedef PACKED(struct) hci_le_enhanced_connection_complete_v2_event_rp0_s { #define ACI_GAP_NUMERIC_COMPARISON_VALUE_VSEVT_CODE 0x0409 #define ACI_GAP_KEYPRESS_NOTIFICATION_VSEVT_CODE 0x040A #define ACI_GAP_PAIRING_VSEVT_CODE 0x040B + +/** + * @} + */ + +/** + * @} + */ + +/** + *@addtogroup L2CAP L2CAP + *@{ + */ + +/** @defgroup ACI_L2CAP_evt_code ACI L2CAP proprietary event codes + * ACI L2CAP event codes found in ecode field of aci_blecore_event struct. + * @{ + */ + #define ACI_L2CAP_CONNECTION_UPDATE_RESP_VSEVT_CODE 0x0800 #define ACI_L2CAP_PROC_TIMEOUT_VSEVT_CODE 0x0801 #define ACI_L2CAP_CONNECTION_UPDATE_REQ_VSEVT_CODE 0x0802 @@ -641,6 +2693,26 @@ typedef PACKED(struct) hci_le_enhanced_connection_complete_v2_event_rp0_s { #define ACI_L2CAP_COS_SDU_DATA_RX_VSEVT_CODE 0x080D #define ACI_L2CAP_COS_CONNECTION_REQ_VSEVT_CODE 0x080E #define ACI_L2CAP_COS_CONNECTION_RESP_VSEVT_CODE 0x080F + +/** + * @} + */ + +/** + * @} + */ + +/** + *@addtogroup GATT GATT + *@brief Generic Attribute Profile. + *@{ + */ + +/** @defgroup ACI_GATT_evt_code ACI GATT proprietary event codes + * ACI GATT event codes found in ecode field of aci_blecore_event struct. + * @{ + */ + #define ACI_GATT_SRV_ATTRIBUTE_MODIFIED_VSEVT_CODE 0x0C01 #define ACI_GATT_PROC_TIMEOUT_VSEVT_CODE 0x0C02 #define ACI_ATT_EXCHANGE_MTU_RESP_VSEVT_CODE 0x0C03 @@ -670,328 +2742,1453 @@ typedef PACKED(struct) hci_le_enhanced_connection_complete_v2_event_rp0_s { * @} */ -/** @defgroup ACI_evt_structs Proprietary ACI event structures +/** + * @} + */ + +/** + *@addtogroup HAL_LL HAL/LL + *@{ + */ + +/** @defgroup ACI_hal_evt_structs ACI HAL event structures * Types to be used to cast data field of hci_event_pckt type or * hci_event_ext_pckt type. * @{ */ + +/** + * This event is generated when the device completes a radio activity and + * provide information when a new radio activity will be performed. Information + * provided includes type of radio activity and absolute time in system ticks + * when a new radio activity is schedule, if any. Application can use this + * information to schedule user activities synchronous to selected radio + * activities. A command @ref aci_hal_set_radio_activity_mask is provided to + * enable radio activity events of user interests, by default no events are + * enabled. User should take into account that enabling radio events in + * application with intense radio activity could lead to a fairly high rate of + * events generated. Application use cases includes synchronizing notification + * with connection interval, switching antenna at the end of advertising or + * performing flash erase operation while radio is idle. + */ typedef PACKED(struct) aci_hal_end_of_radio_activity_event_rp0_s { +/** + * Completed radio events + * Values: + * - 0x00: Idle + * - 0x01: Advertising + * - 0x02: Connection event peripheral + * - 0x03: Scanning + * - 0x04: Connection request + * - 0x05: Connection event central + * - 0x06: TX test mode + * - 0x07: RX test mode + */ uint8_t Last_State; +/** + * Incoming radio events + * Values: + * - 0x00: Idle + * - 0x01: Advertising + * - 0x02: Connection event peripheral + * - 0x03: Scanning + * - 0x04: Connection request + * - 0x05: Connection event central + * - 0x06: TX test mode + * - 0x07: RX test mode + */ uint8_t Next_State; +/** + * 32bit absolute current time expressed in internal time units. + */ uint32_t Next_State_SysTime; } aci_hal_end_of_radio_activity_event_rp0; +/** + * This event is generated to report firmware error information. + */ typedef PACKED(struct) aci_hal_fw_error_event_rp0_s { +/** + * Code identifying the type of error that has occurred in Bluetooth stack. + * 0x01: L2CAP layer failed recombining a PDU; 0x02: GATT layer received an + * unexpteced response (protocol violation); 0x03: GATT layer received an + * unexpteced request (protocol violation); 0x04: No space to store info GATT + * database info in NVM (database clean-up needed or bonding entries to be + * removed); 0x05: No space to store bonding info in NVM (database clean-up + * needed or bonding entries to be removed); 0x06: Link Layer scheduler failed + * to reschedule slots for too many times (a system reset is recommended; 0x07: + * Out of memory resources for isochronous channels; 0x08: Error in programming + * timer for CTE reception functionality. + * Values: + * - 0x01: HAL_FW_L2CAP_RECOMBINATION_ERROR + * - 0x02: HAL_FW_GATT_UNEXPECTED_RESPONSE_ERROR + * - 0x03: HAL_FW_GATT_SEQUENTIAL_PROTOCOL_ERROR + * - 0x04: HAL_FW_BONDING_DB_FULL_GATTSERVICE_ERROR + * - 0x05: HAL_FW_BONDING_DB_FULL_PAIRING_ERROR + * - 0x06: HAL_FW_SCHEDULER_OVERRUN_ERROR + * - 0x07: HAL_FW_MEMBUF_NOT_AVAILABLE + * - 0x08: HAL_FW_CTE_TIMER_PROGRAM_ERROR + */ uint8_t FW_Error_Type; +/** + * Length of Data in octets + */ uint8_t Data_Length; +/** + * The error event info. If FW_Error_Type is 0x01, 0x02 or 0x03, this parameter + * contains the connection handle where the abnormal condition has occurred. + */ uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 2)/sizeof(uint8_t)]; } aci_hal_fw_error_event_rp0; +/** + * This event is raised when the advertising or scan response data pointer + * provided by application becomes active or inactive. + */ typedef PACKED(struct) aci_hal_adv_scan_resp_data_update_event_rp0_s { +/** + * + */ void * Old_Pointer; +/** + * + */ void * New_Pointer; } aci_hal_adv_scan_resp_data_update_event_rp0; +/** + * This event is raised when the PAwR subevent data or the PAwR response data + * pointer provided by application is no more used by the stack and the + * associated memory can be freed. + */ typedef PACKED(struct) aci_hal_pawr_data_free_event_rp0_s { +/** + * Pointer to the data that can be freed. + */ void * Buffer; +/** + * Type of data pointed by the buffer. + * Values: + * - 0x00: HAL_PAWR_DATA_TYPE_SUBEVENT + * - 0x01: HAL_PAWR_DATA_TYPE_RESPONSE + */ uint8_t Type; } aci_hal_pawr_data_free_event_rp0; +/** + * @} + */ + +/** + * @} + */ + +/** + *@addtogroup GAP GAP + *@brief Generic Access Profile + *@{ + */ + +/** @defgroup ACI_gap_evt_structs ACI GAP event structures + * Types to be used to cast data field of hci_event_pckt type or + * hci_event_ext_pckt type. + * @{ + */ + +/** + * This event is generated when the pairing process has completed successfully + * or a pairing procedure timeout has occurred or the pairing has failed. This + * is to notify the application that we have paired with a remote device so that + * it can take further actions or to notify that a timeout has occurred so that + * the upper layer can decide to disconnect the link. + */ typedef PACKED(struct) aci_gap_pairing_complete_event_rp0_s { +/** + * Connection handle on which the pairing procedure completed + */ uint16_t Connection_Handle; +/** + * Pairing status. If 0x02, see Reason code. + * Values: + * - 0x00: Success + * - 0x01: Timeout + * - 0x02: Pairing Failed + * - 0x03: Encryption failed, LTK missing on local device + * - 0x04: Encryption failed, LTK missing on peer device + * - 0x05: Encryption not supported by remote device + */ uint8_t Status; +/** + * Pairing reason error code + * Values: + * - 0x00 + * - 0x01: SM_PASSKEY_ENTRY_FAILED + * - 0x02: SM_OOB_NOT_AVAILABLE + * - 0x03: SM_AUTHENTICATION_REQUIREMENTS + * - 0x04: SM_CONFIRM_VALUE_FAILED + * - 0x05: SM_PAIRING_NOT_SUPPORTED + * - 0x06: SM_ENCRYPTION_KEY_SIZE + * - 0x07: SM_CMD_NOT_SUPPORTED + * - 0x08: SM_UNSPECIFIED_REASON + * - 0x09: SM_REPEATED_ATTEMPTS + * - 0x0A: SM_INVALID_PARAMETERS + * - 0x0B: SMP_DHKEY_CHECK_FAILED + * - 0x0C: SMP_NUMCOMPARISON_FAILED + * - 0x0D: SM_BR_EDR_PAIRING_IN_PROGRESS + * - 0x0E: SM_CROSS_TRANSPORT_KEY_NOT_ALLOWED + * - 0x0F: SM_KEY_REJECTED + */ uint8_t Reason; } aci_gap_pairing_complete_event_rp0; +/** + * This event is generated by the Security manager to the application when a + * passkey is required for pairing. When this event is received, the application + * has to respond with the @ref aci_gap_passkey_resp command. + */ typedef PACKED(struct) aci_gap_passkey_req_event_rp0_s { +/** + * Connection handle for which the passkey has been requested. + */ uint16_t Connection_Handle; +/** + * This parameter informs the application if the passkey needs to be displayed + * or requested for input on the local device. + * Values: + * - 0x00: PASSKEY_DISPLAY + * - 0x01: PASSKEY_INPUT + */ uint8_t Display_Input; } aci_gap_passkey_req_event_rp0; +/** + * This event is sent by the GAP to the upper layers when a procedure previously + * started has been terminated by the upper layer or has completed for any other + * reason + */ typedef PACKED(struct) aci_gap_proc_complete_event_rp0_s { +/** + * Code identifying the procedure. + * Values: + * - 0x00: GAP_LIMITED_DISCOVERY_PROC + * - 0x01: GAP_GENERAL_DISCOVERY_PROC + * - 0x02: GAP_AUTO_CONNECTION_ESTABLISHMENT_PROC + * - 0x03: GAP_GENERAL_CONNECTION_ESTABLISHMENT_PROC + * - 0x04: GAP_SELECTIVE_CONNECTION_ESTABLISHMENT_PROC + * - 0x05: GAP_OBSERVATION_PROC + * - 0x06: GAP_DIRECT_CONNECTION_ESTABLISHMENT_PROC + * - 0x07: GAP_NAME_DISCOVERY_PROC + */ uint8_t Procedure_Code; +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Status; +/** + * Length of Data in octets + */ uint8_t Data_Length; +/** + * Procedure Specific Data: - For Name Discovery Procedure: the name of the peer + * device if the procedure completed successfully. + */ uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 3)/sizeof(uint8_t)]; } aci_gap_proc_complete_event_rp0; +/** + * This event is sent only by a privacy enabled Peripheral. The event is sent to + * the upper layers when the peripheral is unsuccessful in resolving the + * resolvable address of the peer device after connecting to it. + */ typedef PACKED(struct) aci_gap_addr_not_resolved_event_rp0_s { +/** + * Connection handle for which the private address could not be resolved with + * any of the stored IRK's. + */ uint16_t Connection_Handle; } aci_gap_addr_not_resolved_event_rp0; +/** + * This event is sent only during SC v.4.2 Pairing, when Numeric Comparison + * Association model is selected, in order to show the Numeric Value generated, + * and to ask for Confirmation to the User. When this event is received, the + * application has to respond with the @ref + * aci_gap_numeric_comparison_value_confirm_yesno command + */ typedef PACKED(struct) aci_gap_numeric_comparison_value_event_rp0_s { +/** + * Connection handle related to the underlying Pairing + */ uint16_t Connection_Handle; +/** + * + */ uint32_t Numeric_Value; } aci_gap_numeric_comparison_value_event_rp0; +/** + * This event is sent only during SC v.4.2 Pairing, when Keypress Notifications + * are supported, in order to show the input type signalled by the peer device, + * having Keyboard only I/O capabilities. When this event is received, no action + * is required to the User. + */ typedef PACKED(struct) aci_gap_keypress_notification_event_rp0_s { +/** + * Connection handle related to the underlying Pairing + */ uint16_t Connection_Handle; +/** + * Type of Keypress input notified/signaled by peer device + * Values: + * - 0x00: PASSKEY_ENTRY_STARTED + * - 0x01: PASSKEY_DIGIT_ENTERED + * - 0x02: PASSKEY_DIGIT_ERASED + * - 0x03: PASSKEY_CLEARED + * - 0x04: PASSKEY_ENTRY_COMPLETED + */ uint8_t Notification_Type; } aci_gap_keypress_notification_event_rp0; +/** + * This event may be generated when there is a request to start a pairing + * process. Application shall respond with aci_gap_pairing_resp command to + * accept or reject the incoming pairing procedure notified through this event. + * If the pairing is going to start with a non-bonded device, the Bonded + * parameter is set to 0. Instead, if the pairing process is going to start with + * an already bonded device, the event is raised with Bonded parameter set to 1. + * This may happen either if the peer has lost the bond or if it is a malicious + * device. If aci_gap_set_security_requirements command was given with + * Pairing_Response set to 1 (pairing confirmation only for bonded devices), the + * event is raised only if pairing is going to be initiated with a bonded + * device. + */ typedef PACKED(struct) aci_gap_pairing_event_rp0_s { +/** + * + */ uint16_t Connection_Handle; +/** + * Indicates if the peer device is already bonded or not. + * Values: + * - 0x00: DEVICE_NOT_BONDED + * - 0x01: DEVICE_BONDED + */ uint8_t Bonded; } aci_gap_pairing_event_rp0; +/** + * @} + */ + +/** + * @} + */ + +/** + *@addtogroup L2CAP L2CAP + *@{ + */ + +/** @defgroup ACI_l2cap_evt_structs ACI L2CAP event structures + * Types to be used to cast data field of hci_event_pckt type or + * hci_event_ext_pckt type. + * @{ + */ + +/** + * This event is generated when the central responds to the connection update + * request packet with a connection update response packet. + */ typedef PACKED(struct) aci_l2cap_connection_update_resp_event_rp0_s { +/** + * Connection handle referring to the COS Channel where the Disconnection has + * been received. + */ uint16_t Connection_Handle; +/** + * + */ uint16_t Result; } aci_l2cap_connection_update_resp_event_rp0; +/** + * This event is generated when the central does not respond to the connection + * update request packet with a connection update response packet or a command + * reject packet within 30 seconds. + */ typedef PACKED(struct) aci_l2cap_proc_timeout_event_rp0_s { +/** + * Handle of the connection related to this L2CAP procedure. + */ uint16_t Connection_Handle; +/** + * Length of following data + */ uint8_t Data_Length; +/** + * + */ uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 3)/sizeof(uint8_t)]; } aci_l2cap_proc_timeout_event_rp0; +/** + * The event is given by the L2CAP layer when a connection update request is + * received from the peripheral. The upper layer which receives this event has + * to respond by sending a @ref aci_l2cap_connection_parameter_update_resp + * command. + */ typedef PACKED(struct) aci_l2cap_connection_update_req_event_rp0_s { +/** + * Handle of the connection related to this L2CAP procedure. + */ uint16_t Connection_Handle; +/** + * This is the identifier which associates the request to the response. + */ uint8_t Identifier; +/** + * Length of the L2CAP connection update request. + */ uint16_t L2CAP_Length; +/** + * Minimum value for the connection event interval. This shall be less than or + * equal to Connection_Interval_Max. Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + */ uint16_t Connection_Interval_Min; +/** + * Maximum value for the connection event interval. This shall be greater than + * or equal to Connection_Interval_Min. Time = N * 1.25 msec. + * Values: + * - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms) + */ uint16_t Connection_Interval_Max; +/** + * Maximum Peripheral latency for the connection in number of connection events. + * Values: + * - 0x0000 ... 0x01F3 + */ uint16_t Max_Latency; +/** + * Defines connection timeout parameter in the following manner: Timeout + * Multiplier * 10ms. + * Values: + * - 10 (100 ms) ... 3200 (32000 ms) + */ uint16_t Timeout_Multiplier; } aci_l2cap_connection_update_req_event_rp0; +/** + * Event raised when an L2CAP channel using LE Credit Based Flow Control mode is + * terminated. + */ typedef PACKED(struct) aci_l2cap_cos_disconnection_complete_event_rp0_s { +/** + * Handle identifying the connection. + */ uint16_t Connection_Handle; +/** + * The local channel endpoint that identifies the L2CAP channel. + */ uint16_t CID; } aci_l2cap_cos_disconnection_complete_event_rp0; +/** + * Event raised when an L2CAP_FLOW_CONTROL_CREDIT_IND is received from the peer, + * which means that it is capable of receiving additional K-frames (for example + * after it has processed one or more K-frames) in LE Credit Based Flow Control. + */ typedef PACKED(struct) aci_l2cap_cos_flow_control_credit_event_rp0_s { +/** + * Handle identifying the connection. + */ uint16_t Connection_Handle; +/** + * The local channel endpoint that identifies the L2CAP channel. + */ uint16_t CID; +/** + * The number of additional k-frames that the peer's L2CAP layer entity can + * receive. + */ uint16_t TX_Credits; +/** + * Remaining number of K-frames that local L2CAP layer entity can currently send + * to the peer. + * Values: + * - 1 ... 65535 + */ uint16_t TX_Credit_Balance; } aci_l2cap_cos_flow_control_credit_event_rp0; +/** + * Event raised when an SDU to be transmitted has been processed by the local + * L2CAP layer entity. + */ typedef PACKED(struct) aci_l2cap_cos_sdu_data_tx_event_rp0_s { +/** + * Handle identifying the connection. + */ uint16_t Connection_Handle; +/** + * The local channel endpoint that identifies the L2CAP channel. + */ uint16_t CID; +/** + * + */ uint16_t SDU_Length; +/** + * Remaining number of K-frames that local L2CAP layer entity can currently send + * to the peer. + */ uint16_t TX_Credit_Balance; } aci_l2cap_cos_sdu_data_tx_event_rp0; +/** + * Event generated when receiving an L2CAP_CREDIT_BASED_RECONFIGURE_REQ or an + * L2CAP_CREDIT_BASED_RECONFIGURE_RSP, to reconfigure one or more (up to 5) + * L2CAP Enhanced Credit Based Flow Control channels. + */ typedef PACKED(struct) aci_l2cap_cos_reconfiguration_event_rp0_s { +/** + * Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * + * Values: + * - 0x00: L2CAP_ECFC_RECONFIGURE_REQ + * - 0x01: L2CAP_ECFC_RECONFIGURE_RESP + */ uint8_t Event_Type; +/** + * Result of the connection request if Event_Type is L2CAP_ECFC_CONN_RESP. To be + * ignored if Event_Type is L2CAP_ECFC_CONN_REQ. + * Values: + * - 0x0000: L2CAP_RECONFIG_SUCCESSFUL + * - 0x0001: L2CAP_RECONFIG_FAIL_MTU_REDUCTION_NOT_ALLOWED + * - 0x0002: L2CAP_RECONFIG_FAIL_MPS_REDUCTION_NOT_ALLOWED + * - 0x0003: L2CAP_RECONFIG_FAIL_INVALID_CID + * - 0x0004: L2CAP_RECONFIG_FAIL_UNACCEPTABLE_PARAMETERS + */ uint16_t Result; +/** + * This is the identifier which associates the request to the response. + */ uint8_t Identifier; +/** + * The maximum SDU size (in octets) that the remote L2CAP layer entity can + * receive on this channel after successful reconfiguration. + * Values: + * - 64 ... 65535 + */ uint16_t Peer_MTU; +/** + * The maximum PDU payload size (in octets) that the remote L2CAP layer entity + * can receive on this channel after successful reconfiguration. + * Values: + * - 64 ... 65535 + */ uint16_t Peer_MPS; +/** + * Number of Channels that are going to be created. + * Values: + * - 0x01 ... 0x05 + */ uint8_t CID_Count; +/** + * Array of up to 5 two-octet values that represent the local channel endpoints + * identifying the EATT channels to be reconfigured. + */ uint16_t Local_CID[(HCI_MAX_PAYLOAD_SIZE - 11)/sizeof(uint16_t)]; } aci_l2cap_cos_reconfiguration_event_rp0; +/** + * This event is generated when the central rejects a L2CAP request. + */ typedef PACKED(struct) aci_l2cap_command_reject_event_rp0_s { +/** + * Handle identifying the connection. + */ uint16_t Connection_Handle; +/** + * This is the identifier which associates the request to the response. + */ uint8_t Identifier; +/** + * Reason + */ uint16_t Reason; +/** + * Length of following data + */ uint8_t Data_Length; +/** + * Data field associated with Reason + */ uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; } aci_l2cap_command_reject_event_rp0; +/** + * Event raised when an SDU has been received. Use aci_l2cap_extract_sdu_data() + * to extract SDU from buffer. + */ typedef PACKED(struct) aci_l2cap_cos_sdu_data_rx_event_rp0_s { +/** + * Handle identifying the connection. + */ uint16_t Connection_Handle; +/** + * The local channel endpoint that identifies the L2CAP channel. + */ uint16_t CID; +/** + * Remaining number of K-frames that local L2CAP layer entity can currently + * receive from the peer. If automatic management of credits is enabled, this + * number will automatically change after the SDU is extracted. + */ uint16_t RX_Credit_Balance; +/** + * + */ uint16_t SDU_Length; } aci_l2cap_cos_sdu_data_rx_event_rp0; +/** + * Event generated when a request is received from the peer to create one L2CAP + * Credit Based Flow Control channel or one or more (up to 5) L2CAP Enhanced + * Credit Based Flow Control channels. + */ typedef PACKED(struct) aci_l2cap_cos_connection_req_event_rp0_s { +/** + * Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * Type of channel: LE Credit Based Flow Control Mode or Enhanced Credit Based + * Flow Control Mode. + * Values: + * - 0x00: L2CAP_CHANNEL_TYPE_LE_CFC + * - 0x01: L2CAP_CHANNEL_TYPE_ECFC + */ uint8_t Channel_Type; +/** + * This is the identifier which associates the request to the response. + */ uint8_t Identifier; +/** + * Simplified Protocol/Service Multiplexer + * Values: + * - 0x0001 ... 0x00FF + */ uint16_t SPSM; +/** + * The maximum SDU size (in octets) that the remote L2CAP layer entity can + * receive on this channel. + * Values: + * - 64 ... 65535 + */ uint16_t Peer_MTU; +/** + * The maximum PDU payload size (in octets) that the remote L2CAP layer entity + * can receive on this channel. + * Values: + * - 64 ... 65535 + */ uint16_t Peer_MPS; +/** + * The number of K-frames that can be sent to the L2CAP layer entity of the peer + * device as soon as the L2CAP channel is established. + */ uint16_t Initial_Credits; +/** + * + */ uint8_t CID_Count; } aci_l2cap_cos_connection_req_event_rp0; +/** + * Event generated when a response is received from the peer to create one L2CAP + * Credit Based Flow Control channel or one or more (up to 5) L2CAP Enhanced + * Credit Based Flow Control channels. + */ typedef PACKED(struct) aci_l2cap_cos_connection_resp_event_rp0_s { +/** + * Connection handle that identifies the connection. + * Values: + * - 0x0000 ... 0x0EFF + */ uint16_t Connection_Handle; +/** + * Type of channel: LE Credit Based Flow Control Mode or Enhanced Credit Based + * Flow Control Mode. + * Values: + * - 0x00: L2CAP_CHANNEL_TYPE_LE_CFC + * - 0x01: L2CAP_CHANNEL_TYPE_ECFC + */ uint8_t Channel_Type; +/** + * The maximum SDU size (in octets) that the remote L2CAP layer entity can + * receive on this channel. + * Values: + * - 64 ... 65535 + */ uint16_t Peer_MTU; +/** + * The maximum PDU payload size (in octets) that the remote L2CAP layer entity + * can receive on this channel. + * Values: + * - 64 ... 65535 + */ uint16_t Peer_MPS; +/** + * The number of K-frames that can be sent to the L2CAP layer entity of the peer + * device as soon as the L2CAP channel is established. + */ uint16_t Initial_Credits; +/** + * Outcome of the connection request. + * Values: + * - 0x0000: L2CAP_CONN_SUCCESSFUL + * - 0x0002: L2CAP_CONN_FAIL_SPSM_NOT_SUPPORTED + * - 0x0004: L2CAP_CONN_FAIL_INSUFFICIENT_RESOURCES + * - 0x0005: L2CAP_CONN_FAIL_INSUFFICIENT_AUTHENTICATION + * - 0x0006: L2CAP_CONN_FAIL_INSUFFICIENT_AUTHORIZATION + * - 0x0007: L2CAP_CONN_FAIL_KEY_SIZE_TOO_SHORT + * - 0x0008: L2CAP_CONN_FAIL_INSUFFICIENT_ENCRYPTION + * - 0x0009: L2CAP_CONN_FAIL_INVALID_SOURCE_CID + * - 0x000A: L2CAP_CONN_FAIL_SOURCE_CID_ALREADY_ALLOCATED + * - 0x000B: L2CAP_CONN_FAIL_UNACCEPTABLE_PARAMETERS + * - 0x000C: L2CAP_CONN_FAIL_INVALID_PARAMETERS + * - 0x000D: L2CAP_CONN_FAIL_NO_INFO + * - 0x000E: L2CAP_CONN_FAIL_AUTHENTICATION_PENDING + * - 0x000F: L2CAP_CONN_FAIL_AUTHORIZATION_PENDING + */ uint16_t Result; +/** + * Number of channels to be created which are present in the L2CAP Credit Based + * Connection Request. The effective number of channels that will be opened can + * be less than this value (see Local_CID) . + * Values: + * - 0x01 ... 0x05 + */ uint8_t CID_Count; +/** + * Array of up to 5 two-octet values that represent the local channel endpoints. + */ uint16_t CID[(HCI_MAX_PAYLOAD_SIZE - 12)/sizeof(uint16_t)]; } aci_l2cap_cos_connection_resp_event_rp0; +/** + * @} + */ + +/** + * @} + */ + +/** + *@addtogroup GATT GATT + *@brief Generic Attribute Profile. + *@{ + */ + +/** @defgroup ACI_gatt_evt_structs ACI GATT event structures + * Types to be used to cast data field of hci_event_pckt type or + * hci_event_ext_pckt type. + * @{ + */ + +/** + * This event is generated to the application by the GATT server when a client + * modifies any attribute on the server, as consequence of one of the following + * GATT procedures: - write without response - signed write without response - + * write characteristic value - write long characteristic value - reliable + * write. + */ typedef PACKED(struct) aci_gatt_srv_attribute_modified_event_rp0_s { +/** + * The connection handle which modified the attribute. + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * Handle of the attribute that was modified. + */ uint16_t Attr_Handle; +/** + * Length of Attr_Data in octets + */ uint16_t Attr_Data_Length; +/** + * A concatenation of Handle, Length and Values for each of the attributes being + * notified. + */ uint8_t Attr_Data[(HCI_MAX_PAYLOAD_SIZE - 8)/sizeof(uint8_t)]; } aci_gatt_srv_attribute_modified_event_rp0; +/** + * This event is generated by the client/server to the application on a GATT + * timeout (30 seconds). This is a critical event that should not happen during + * normal operating conditions. It is an indication of either a major disruption + * in the communication link or a mistake in the application which does not + * provide a reply to GATT procedures. After this event, the GATT channel is + * closed and no more GATT communication can be performed. The applications is + * expected to issue an @ref aci_gap_terminate to disconnect from the peer + * device. + */ typedef PACKED(struct) aci_gatt_proc_timeout_event_rp0_s { +/** + * Connection handle on which the GATT procedure has timed out + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; } aci_gatt_proc_timeout_event_rp0; +/** + * This event is generated in response to an Exchange MTU request (local or from + * the peer), which can happen only on an unenhaced ATT bearer. See + * aci_gatt_clt_exchange_config(). + */ typedef PACKED(struct) aci_att_exchange_mtu_resp_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * ATT_MTU value agreed between server and client. This is the minimum of the + * Client Rx MTU and the Server Rx MTU. + */ uint16_t MTU; } aci_att_exchange_mtu_resp_event_rp0; +/** + * This event is generated in response to a Find Information Request during a + * discovery procedure for all the characteristic descriptors. See + * aci_gatt_clt_disc_all_char_desc() and Find Information Response in Bluetooth + * Core spec. + */ typedef PACKED(struct) aci_att_clt_find_info_resp_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * Format of the hanndle-uuid pairs + */ uint8_t Format; +/** + * Length of Handle_UUID_Pair in octets + */ uint16_t Event_Data_Length; +/** + * A sequence of handle-uuid pairs. if format=1, each pair is:[2 octets for + * handle, 2 octets for UUIDs], if format=2, each pair is:[2 octets for handle, + * 16 octets for UUIDs] + */ uint8_t Handle_UUID_Pair[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; } aci_att_clt_find_info_resp_event_rp0; +/** + * This event is generated during a "discover service by UUID" procedure. See + * aci_gatt_clt_disc_primary_service_by_uuid(). + */ typedef PACKED(struct) aci_att_clt_find_by_type_value_resp_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * Number of attribute, group handle pairs + */ uint8_t Num_of_Handle_Pair; +/** + * See @ref packed_Attribute_Group_Handle_Pair_t + */ packed_Attribute_Group_Handle_Pair_t Attribute_Group_Handle_Pair[(HCI_MAX_PAYLOAD_SIZE - 5)/sizeof(packed_Attribute_Group_Handle_Pair_t)]; } aci_att_clt_find_by_type_value_resp_event_rp0; +/** + * This event is generated in response to a ATT_READ_BY_TYPE_REQ, during a "find + * included service" procedure or a "discover all characteristics" procedure. + * See aci_gatt_clt_find_included_services() and + * aci_gatt_clt_disc_all_char_of_service(). + */ typedef PACKED(struct) aci_att_clt_read_by_type_resp_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * The size of each attribute handle-value pair + */ uint8_t Handle_Value_Pair_Length; +/** + * Length of Handle_Value_Pair_Data in octets + */ uint16_t Data_Length; +/** + * Attribute Data List as defined in Bluetooth Core v4.1 spec. A sequence of + * handle-value pairs: [2 octets for Attribute Handle, (Handle_Value_Pair_Length + * - 2 octets) for Attribute Value] + */ uint8_t Handle_Value_Pair_Data[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; } aci_att_clt_read_by_type_resp_event_rp0; +/** + * This event is generated in response to a Read Request. See + * aci_gatt_clt_read(). + */ typedef PACKED(struct) aci_att_clt_read_resp_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * Length of following data + */ uint16_t Event_Data_Length; +/** + * The value of the attribute. + */ uint8_t Attribute_Value[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; } aci_att_clt_read_resp_event_rp0; +/** + * This event can be generated during a read long characteristic value + * procedure. See aci_gatt_clt_read_long(). + */ typedef PACKED(struct) aci_att_clt_read_blob_resp_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * Length of following data + */ uint16_t Event_Data_Length; +/** + * Part of the attribute value. + */ uint8_t Attribute_Value[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; } aci_att_clt_read_blob_resp_event_rp0; +/** + * This event is generated in response to a Read Multiple Request. See + * aci_gatt_clt_read_multiple_char_value(). + */ typedef PACKED(struct) aci_att_clt_read_multiple_resp_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * Length of following data + */ uint16_t Event_Data_Length; +/** + * A set of two or more values. A concatenation of attribute values for each of + * the attribute handles in the request in the order that they were requested. + */ uint8_t Set_Of_Values[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; } aci_att_clt_read_multiple_resp_event_rp0; +/** + * This event is generated in response to a Read By Group Type Request, during a + * "discover all primary services" procedure. See + * aci_gatt_clt_disc_all_primary_services(). + */ typedef PACKED(struct) aci_att_clt_read_by_group_type_resp_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * The size of each attribute data + */ uint8_t Attribute_Data_Length; +/** + * Length of Attribute_Data_List in octets + */ uint16_t Data_Length; +/** + * Attribute Data List as defined in Bluetooth Core v4.1 spec. A sequence of + * attribute handle, end group handle, attribute value tuples: [2 octets for + * Attribute Handle, 2 octets End Group Handle, (Attribute_Data_Length - 4 + * octets) for Attribute Value] + */ uint8_t Attribute_Data_List[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; } aci_att_clt_read_by_group_type_resp_event_rp0; +/** + * This event is generated in response to an ATT_PREPARE_WRITE_REQ during a + * write long characteristic value procedure. See aci_gatt_clt_write_long(). + */ typedef PACKED(struct) aci_att_clt_prepare_write_resp_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * The handle of the attribute to be written + */ uint16_t Attribute_Handle; +/** + * The offset of the first octet to be written. + */ uint16_t Offset; +/** + * Length of Part_Attribute_Value in octets + */ uint16_t Part_Attribute_Value_Length; +/** + * The value of the attribute to be written + */ uint8_t Part_Attribute_Value[(HCI_MAX_PAYLOAD_SIZE - 10)/sizeof(uint8_t)]; } aci_att_clt_prepare_write_resp_event_rp0; +/** + * This event is generated in response to an ATT Execute Write Request, during a + * write long characteristic value procedure. See aci_gatt_clt_write_long(). + */ typedef PACKED(struct) aci_att_clt_exec_write_resp_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; } aci_att_clt_exec_write_resp_event_rp0; +/** + * This event is generated when an indication is received from the server. + */ typedef PACKED(struct) aci_gatt_clt_indication_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * The handle of the attribute + */ uint16_t Attribute_Handle; +/** + * Length of Attribute_Value in octets + */ uint16_t Attribute_Value_Length; +/** + * The current value of the attribute + */ uint8_t Attribute_Value[(HCI_MAX_PAYLOAD_SIZE - 8)/sizeof(uint8_t)]; } aci_gatt_clt_indication_event_rp0; +/** + * This event is generated when a notification is received from the server. + */ typedef PACKED(struct) aci_gatt_clt_notification_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * The handle of the attribute + */ uint16_t Attribute_Handle; +/** + * Length of Attribute_Value in octets + */ uint16_t Attribute_Value_Length; +/** + * The current value of the attribute + */ uint8_t Attribute_Value[(HCI_MAX_PAYLOAD_SIZE - 8)/sizeof(uint8_t)]; } aci_gatt_clt_notification_event_rp0; +/** + * This event is generated when a GATT client procedure completes either with + * error or successfully. + */ typedef PACKED(struct) aci_gatt_clt_proc_complete_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * For standard error codes see Bluetooth specification, Vol. 2, part D. For + * proprietary error code refer to Error codes section. + */ uint8_t Error_Code; } aci_gatt_clt_proc_complete_event_rp0; +/** + * This event is generated when an Error Response is received from the server. + * The error response can be given by the server at the end of one of the GATT + * discovery procedures. This does not mean that the procedure ended with an + * error, but this error event is part of the procedure itself. + */ typedef PACKED(struct) aci_gatt_clt_error_resp_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * The request that generated this error response + */ uint8_t Req_Opcode; +/** + * The attribute handle that generated this error response + */ uint16_t Attribute_Handle; +/** + * The reason why the request has generated an error response (ATT error codes) + * Values: + * - 0x01: Invalid handle + * - 0x02: Read not permitted + * - 0x03: Write not permitted + * - 0x04: Invalid PDU + * - 0x05: Insufficient authentication + * - 0x06: Request not supported + * - 0x07: Invalid offset + * - 0x08: Insufficient authorization + * - 0x09: Prepare queue full + * - 0x0A: Attribute not found + * - 0x0B: Attribute not long + * - 0x0C: Insufficient encryption key size + * - 0x0D: Invalid attribute value length + * - 0x0E: Unlikely error + * - 0x0F: Insufficient encryption + * - 0x10: Unsupported group type + * - 0x11: Insufficient resources + */ uint8_t Error_Code; } aci_gatt_clt_error_resp_event_rp0; +/** + * This event can be generated during a "Discover Characteristics By UUID" + * procedure or a "Read using Characteristic UUID" procedure. During a "Discover + * Characteristics By UUID" procedure, Attribute_Value is a characteristic + * declaration as defined in Bluetooth Core spec (vol.3, Part G, ch. 3.3.1), + * i.e. it is composed by: Characteristic Properties (1 octet), Characteristic + * Value Handle (2 octets) and Characteristic UUID (2 or 16 octets). During a + * "Read using Characteristic UUID" procedure, Attribute_Value is the value of + * the characteristic. + */ typedef PACKED(struct) aci_gatt_clt_disc_read_char_by_uuid_resp_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * The handle of the attribute + */ uint16_t Attribute_Handle; +/** + * Length of Attribute_Value in octets + */ uint8_t Attribute_Value_Length; +/** + * The attribute value will be a characteristic declaration as defined in + * Bluetooth Core spec (vol.3, Part G, ch. 3.3.1), when a "Discover + * Characteristics By UUID" has been started. It will be the value of the + * Characteristic if a "Read using Characteristic UUID" has been performed. + */ uint8_t Attribute_Value[(HCI_MAX_PAYLOAD_SIZE - 7)/sizeof(uint8_t)]; } aci_gatt_clt_disc_read_char_by_uuid_resp_event_rp0; +/** + * Each time Bluetooth stack raises the error code + * BLE_STATUS_INSUFFICIENT_RESOURCES, aci_gatt_tx_pool_available_event() is + * generated as soon as the available buffer size is greater than maximum ATT + * MTU. + */ typedef PACKED(struct) aci_gatt_tx_pool_available_event_rp0_s { +/** + * Connection handle related to the request + */ uint16_t Connection_Handle; +/** + * Not used. + */ uint16_t Available_Buffers; } aci_gatt_tx_pool_available_event_rp0; +/** + * This event is generated when the client has sent the confirmation to a + * previously sent indication. + */ typedef PACKED(struct) aci_gatt_srv_confirmation_event_rp0_s { +/** + * Connection handle related to the event. + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; } aci_gatt_srv_confirmation_event_rp0; +/** + * This event is generated when the BLE stack needs an attribute value to be + * returned to the peer, as a result of a remote read operation (Read By Type + * Request, Read Request, Read Blob Request, Read Multiple Request). After this + * event is received, aci_gatt_srv_resp() must be used to send the response. + * This event is not generated if the read is requested on a characteristic or a + * descriptor which have an associated buffer handled by the stack (see + * ble_gatt_chr_def_t and ble_gatt_descr_def_t). + */ typedef PACKED(struct) aci_gatt_srv_read_event_rp0_s { +/** + * Handle identifying the connection where the read operation has been received. + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * Handle of the attribute to read. + */ uint16_t Attribute_Handle; +/** + * Offset from which the peer is requesting the attribute value. + */ uint16_t Data_Offset; } aci_gatt_srv_read_event_rp0; +/** + * This event is generated when the peer wants to write into a writable + * characteristic value or descriptor using a write request or command (Write + * Request, Write command, Signed Write command). If a response is needed, + * application must respond with an aci_gatt_srv_resp(). + */ typedef PACKED(struct) aci_gatt_srv_write_event_rp0_s { +/** + * Handle identifying the connection where the write operation has been + * received. + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * If 1, application must call aci_gatt_srv_resp() to give a response to the + * peer. + */ uint8_t Resp_Needed; +/** + * Handle of the attribute to write. + */ uint16_t Attribute_Handle; +/** + * Length of the data to write. + */ uint16_t Data_Length; +/** + * Data to write. + */ uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 9)/sizeof(uint8_t)]; } aci_gatt_srv_write_event_rp0; +/** + * This event is generated when a prepare write request is received. Application + * should queue this request and execute or discard it only when a + * aci_att_srv_exec_write_req_event is received. + */ typedef PACKED(struct) aci_att_srv_prepare_write_req_event_rp0_s { +/** + * Handle identifying the connection where the prepare write operation has been + * received. + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * Handle of the attribute to write. + */ uint16_t Attribute_Handle; +/** + * Offset from which data has to be written. + */ uint16_t Data_Offset; +/** + * Length of the data to write. + */ uint16_t Data_Length; +/** + * Data to write. + */ uint8_t Data[(HCI_MAX_PAYLOAD_SIZE - 10)/sizeof(uint8_t)]; } aci_att_srv_prepare_write_req_event_rp0; +/** + * This event is generated when an execute write request is received from the + * peer. This happens when the client wants to write a long attribute (i.e. an + * attribute with a size greater than ATT_MTU -3) or more than one attribute in + * a single operation. The aci_gatt_srv_resp command must be sent to give a + * response to the peer. + */ typedef PACKED(struct) aci_att_srv_exec_write_req_event_rp0_s { +/** + * Handle identifying the connection where the execute write operation has been + * received. + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * If 1, peer wants to execute all the queued writes. If 0, all queued writes + * must be discarded. + * Values: + * - 0x00: FLUSH + * - 0x01: EXECUTE + */ uint8_t Flags; } aci_att_srv_exec_write_req_event_rp0; +/** + * This event is generated in response to a Read Multiple Variable Request. See + * aci_gatt_clt_read_multiple_var_len_char_value(). + */ typedef PACKED(struct) aci_att_clt_read_multiple_var_len_resp_event_rp0_s { +/** + * Connection handle related to the response + */ uint16_t Connection_Handle; +/** + * If equal to 0x0004, the event is related to an unenhanced ATT bearer. + * Otherwise, the value is the local endpoint identifying the enhanced ATT + * bearer. + */ uint16_t CID; +/** + * Length of following data + */ uint16_t Event_Data_Length; +/** + * A set of two or more values. A concatenation of attribute values for each of + * the attribute handles in the request in the order that they were requested. + */ uint8_t Set_Of_Values[(HCI_MAX_PAYLOAD_SIZE - 6)/sizeof(uint8_t)]; } aci_att_clt_read_multiple_var_len_resp_event_rp0; +/** + * @} + */ + /** * @} */ diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_gatt.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_gatt.h index e12866633..fe8569346 100644 --- a/lib/stm32wb0/STM32_BLE/stack/include/ble_gatt.h +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_gatt.h @@ -35,7 +35,7 @@ /** *@addtogroup GATT_constants GATT Constants - *@brief Constants for GATT layer + * Constants for GATT layer *@{ */ @@ -51,6 +51,9 @@ #define BLE_GATT_MAX_ATTR_VALUE_SIZE (512U) /**< Max size of an attribute value. @see 3.2.9 Long * attribute values - BLUETOOTH CORE SPECIFICATION * Version 5.1 | Vol 3, Part F page 2297 */ + +#define BLE_GATT_CLT_SEC_ALL_CONN_HANDLES (0xFFFFU) /**< Used to set default minimum security level */ +#define BLE_GATT_CLT_SEC_ALL_ATTR_HANDLES (0xFFFFU) /**< Used to set default minimum security level */ /** *@} */ @@ -494,7 +497,7 @@ typedef struct { typedef struct ble_gatt_val_buffer_def_s { uint8_t op_flags; /**< See @ref SRV_VALBUFFER_OP_FLAGS */ - uint16_t val_len; /**< Actual value length. It can differ from buffer_len if BLE_GATT_SRV_PERM_ENCRY_READ the BLE_GATT_SRV_OP_VALUE_VAR_LENGTH_FLAG is set in op_flags */ + uint16_t val_len; /**< Actual value length. It can differ from buffer_len if BLE_GATT_SRV_OP_VALUE_VAR_LENGTH_FLAG is set in op_flags */ uint16_t buffer_len; /**< Buffer length. */ uint8_t *buffer_p; /**< Pointer to the storage buffer. */ } ble_gatt_val_buffer_def_t; @@ -508,7 +511,8 @@ typedef struct ble_gatt_descr_def_s { uint8_t min_key_size; uint8_t permissions; /**< Access permissions. See @ref GATT_SRV_PERMS. */ ble_uuid_t uuid; /**< UUID for this descriptor */ - ble_gatt_val_buffer_def_t *val_buffer_p; /**< Pointer to the value buffer structure. */ + ble_gatt_val_buffer_def_t *val_buffer_p; /**< Pointer to the value buffer structure. If NULL, aci_gatt_srv_read_event + and aci_gatt_srv_write_event are generated for this characteristic descriptor. */ } ble_gatt_descr_def_t; typedef struct ble_gatt_chr_def_s { @@ -524,7 +528,8 @@ typedef struct ble_gatt_chr_def_s { uint8_t descr_count; /**< Number of descriptors. */ ble_gatt_descr_def_t *descrs_p; /**< Pointer to the descriptors vector. */ } descrs; /**< List of descriptors. */ - ble_gatt_val_buffer_def_t *val_buffer_p; /**< Pointer to the value buffer structure. */ + ble_gatt_val_buffer_def_t *val_buffer_p; /**< Pointer to the value buffer structure. If NULL, aci_gatt_srv_read_event + and aci_gatt_srv_write_event are generated for this characteristic value. */ } ble_gatt_chr_def_t; typedef struct ble_gatt_srv_def_s { @@ -541,6 +546,12 @@ typedef struct ble_gatt_srv_def_s { } chrs; /**< List of characteristics. */ } ble_gatt_srv_def_t; +typedef struct ble_gatt_clt_sec_level_s { + uint8_t sec_level; /**< Security Level. See Vol 3, Part C, 10.2 LE SECURITY MODES */ + uint16_t attr_handle; /**< Attribute Handle */ + uint16_t conn_handle; /**< Connection Handle */ + struct ble_gatt_clt_sec_level_s *next_p; +} ble_gatt_clt_sec_level_st; /****************************************************************************** * FUNCTION PROTOTYPES *****************************************************************************/ diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_stack.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_stack.h index 5a1f47765..0f4308f3c 100644 --- a/lib/stm32wb0/STM32_BLE/stack/include/ble_stack.h +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_stack.h @@ -196,12 +196,12 @@ * - a part, that may be considered "fixed", i.e., independent from the above * mentioned parameters. */ -# define BLE_STACK_FIXED_BUFFER_SIZE_BYTES (970U) +# define BLE_STACK_FIXED_BUFFER_SIZE_BYTES (978U) /** * Amount of memory needed by each radio link */ -# define COEFF_CONN_SUPP_EN (840U + BLE_STACK_GATT_ATTRIBUTE_SIZE * BLE_STACK_NUM_GATT_MANDATORY_ATTRIBUTES) +# define COEFF_CONN_SUPP_EN (848U + BLE_STACK_GATT_ATTRIBUTE_SIZE * BLE_STACK_NUM_GATT_MANDATORY_ATTRIBUTES) # define COEFF_NUM_OF_LINKS_0 (48U) # define COEFF_NUM_OF_LINKS_1 (656U) # define BLE_STACK_LINKS_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) \ @@ -267,7 +267,7 @@ # define BLE_STACK_CONTROLLER_SCAN_SIZE(SCAN_EN, EXT_ADV_EN, PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_AUX_EVENT,\ NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE, NUM_SYNC_SUBEVENTS) \ - (((SCAN_EN) == 1U) ? 320U + (192U + 48U * (NUM_AUX_EVENT) + \ + (((SCAN_EN) == 1U) ? 324U + (192U + 48U * (NUM_AUX_EVENT) + \ BLE_STACK_PER_SYNC_SIZE(PER_ADV_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE) + \ BLE_STACK_PER_SYNC_WR_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_SYNC_SUBEVENTS)) * (EXT_ADV_EN) : 0U) @@ -275,7 +275,7 @@ /** * Amount of memory needed to support controller privacy feature */ -# define BLE_STACK_CONTROLLER_PRIV_SIZE(ENABLED, FILTER_ACCEPT_LIST_SIZE_LOG2) (((ENABLED) == 1U) ? 104U + 80U * (1U << (FILTER_ACCEPT_LIST_SIZE_LOG2)) : 0U) +# define BLE_STACK_CONTROLLER_PRIV_SIZE(ENABLED, FILTER_ACCEPT_LIST_SIZE_LOG2) (((ENABLED) == 1U) ? 112U + 80U * (1U << (FILTER_ACCEPT_LIST_SIZE_LOG2)) : 0U) /** * Amount of memory needed to support CTE feature @@ -311,6 +311,11 @@ # define BLE_STACK_CHC_NUM_OF_LINKS(NUM_OF_LINKS) (28U * (NUM_OF_LINKS)) # define BLE_STACK_CHC_SIZE(CONN_SUPP_EN, CHC_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) && ((CHC_EN) == 1U) ? BLE_STACK_CHC_NUM_OF_LINKS(NUM_OF_LINKS) : 0U) +/** +* Amount of memory needed to support the logging feature +*/ +#define BLE_STACK_LOG_SIZE(BLE_STACK_LOG_EN) (((BLE_STACK_LOG_EN) == 1U) ? 104U : 0U) + /** * Amount of memory needed by FIFOs */ @@ -400,14 +405,14 @@ # define BLE_STACK_CONTROLLER_SCAN_SIZE(SCAN_EN, EXT_ADV_EN, PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_AUX_EVENT,\ NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE, NUM_SYNC_SUBEVENTS) \ - (((SCAN_EN) == 1U) ? 320U + (164U + 48U * (NUM_AUX_EVENT) + \ + (((SCAN_EN) == 1U) ? 324U + (164U + 48U * (NUM_AUX_EVENT) + \ BLE_STACK_PER_SYNC_SIZE(PER_ADV_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE) + \ BLE_STACK_PER_SYNC_WR_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_SYNC_SUBEVENTS)) * (EXT_ADV_EN) : 0U) /** * Amount of memory needed to support controller privacy feature */ -# define BLE_STACK_CONTROLLER_PRIV_SIZE(ENABLED, FILTER_ACCEPT_LIST_SIZE_LOG2) (((ENABLED) == 1U) ? 104U + 80U * (1U << (FILTER_ACCEPT_LIST_SIZE_LOG2)) : 0U) +# define BLE_STACK_CONTROLLER_PRIV_SIZE(ENABLED, FILTER_ACCEPT_LIST_SIZE_LOG2) (((ENABLED) == 1U) ? 112U + 80U * (1U << (FILTER_ACCEPT_LIST_SIZE_LOG2)) : 0U) /** * Amount of memory needed to support CTE feature @@ -444,6 +449,11 @@ # define BLE_STACK_CHC_NUM_OF_LINKS(NUM_OF_LINKS) (28U * (NUM_OF_LINKS)) # define BLE_STACK_CHC_SIZE(CONN_SUPP_EN, CHC_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) && ((CHC_EN) == 1U) ? BLE_STACK_CHC_NUM_OF_LINKS(NUM_OF_LINKS) : 0U) +/** +* Amount of memory needed to support the logging feature +*/ +#define BLE_STACK_LOG_SIZE(BLE_STACK_LOG_EN) (((BLE_STACK_LOG_EN) == 1U) ? 104U : 0U) + /** * Amount of memory needed by FIFOs */ @@ -535,6 +545,7 @@ BLE_STACK_NUM_BRC_BIS,\ BLE_STACK_NUM_CIG,\ BLE_STACK_NUM_CIS,\ + BLE_STACK_LOG_EN,\ ISR0_FIFO_SIZE,\ ISR1_FIFO_SIZE,\ USER_FIFO_SIZE)\ @@ -571,6 +582,7 @@ BLE_STACK_ISO_SIZE(BLE_STACK_NUM_BRC_BIG, BLE_STACK_NUM_BRC_BIS, \ BLE_STACK_NUM_SYNC_BIG, BLE_STACK_NUM_SYNC_BIS, \ BLE_STACK_NUM_CIG, BLE_STACK_NUM_CIS) + \ + BLE_STACK_LOG_SIZE(BLE_STACK_LOG_EN) + \ BLE_STACK_FIFO_SIZE(ISR0_FIFO_SIZE, ISR1_FIFO_SIZE, USER_FIFO_SIZE) \ ) @@ -658,6 +670,7 @@ on the available device RAM) BLE_STACK_NUM_BRC_BIS,\ BLE_STACK_NUM_CIG,\ BLE_STACK_NUM_CIS,\ + DTM_DEBUG_ENABLED,\ ISR0_FIFO_SIZE,\ ISR1_FIFO_SIZE,\ USER_FIFO_SIZE\ @@ -703,11 +716,8 @@ typedef struct { /** * @brief This function executes the processing of all Host Stack layers. * - * The BLE Stack Tick function has to be executed regularly to process incoming Link Layer packets and to process Host Layers procedures. All - * stack callbacks are called by this function. - * - * If Low Speed Ring Oscillator is used instead of the LS Crystal oscillator this function performs also the LS RO calibration and hence must - * be called at least once at every system wake-up in order to keep the 500 ppm accuracy (at least 500 ppm accuracy is mandatory if acting as a Central). + * The BLE Stack Tick function has to be executed to process incoming Link Layer packets and to process Host Layers procedures. All + * stack callbacks are called by this function. This function should be executed after every call to the BLE_STACK_ProcessRequest(). * * No BLE stack function must be called while the BLE_STACK_Tick is running. For example, if a BLE stack function may be called inside an * interrupt routine, that interrupt must be disabled during the execution of BLE_STACK_Tick(). Example (if a stack function may be called inside @@ -717,9 +727,8 @@ typedef struct { * BLE_STACK_Tick(); * NVIC_EnableIRQ(UART_IRQn); * @endcode - - * @note The API name and parameters are subject to change in future releases. - * @return None + * + * @note Do not call BLE_STACK_Tick() directly from BLE_STACK_ProcessRequest(). */ void BLE_STACK_Tick(void); @@ -741,11 +750,9 @@ tBleStatus BLE_STACK_Init(const BLE_STACK_InitTypeDef *BLE_STACK_InitStruct); * * @param hci_pckt: The user event received from the BLE stack * @param length: Length of the event - * @retval None */ void BLE_STACK_Event(hci_pckt *hci_pckt, uint16_t length); - /** * @brief Returns the BLE Stack matching sleep mode * @@ -764,8 +771,6 @@ uint8_t BLE_STACK_SleepCheck(void); * This is the base function called for any radio ISR. * * @param[in] BlueInterrupt value of the radio interrupt register - * - * @return None */ void BLE_STACK_RadioHandler(uint32_t BlueInterrupt); @@ -785,6 +790,14 @@ Information provided includes type of radio activity and absolute time in system */ uint8_t BLE_STACK_ReadNextRadioActivity(uint32_t *NextStateSysTime); +/** + * @brief This function is called whenever an execution of BLE_STACK_Tick() is requested. + * + * It may be called from an interrupt context, so it should return as quick as possible. + * The BLE_STACK_Tick() must not be called directly by this API. + */ +void BLE_STACK_ProcessRequest(void); + /* Statistics per link */ typedef struct llc_conn_per_statistic_s { diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_stack_user_cfg.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_stack_user_cfg.h index 17020d1fa..51a9bb7a8 100644 --- a/lib/stm32wb0/STM32_BLE/stack/include/ble_stack_user_cfg.h +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_stack_user_cfg.h @@ -13,7 +13,7 @@ * -- LE 2M/Coded PHY * -- Extended Advertising * -- Periodic Advertising and Synchronizer - * -- Periodic Advertising with Responses + * -- Periodic Advertising with Responses * -- L2CAP Connection Oriented Channels * -- Constant Tone Extension * -- Power Control & Path Loss Monitoring @@ -59,10 +59,6 @@ #define CONTROLLER_CIS_ENABLED CFG_BLE_CONTROLLER_CIS_ENABLED -/** - * @} - */ - /* --------------------- Derived defines --------------------- */ #if (CONTROLLER_BIS_ENABLED == 1U) || (CONTROLLER_CIS_ENABLED == 1U) # define CONTROLLER_ISO_ENABLED (1U) /* ISO Support: ENABLED */ @@ -70,6 +66,10 @@ # define CONTROLLER_ISO_ENABLED (0U) /* ISO Support: DISABLED */ #endif +#if !defined(DTM_DEBUG_ENABLED) +# define DTM_DEBUG_ENABLED (0U) /* Logging: DISABLED */ +#endif + /* --------------------- Defines used by function prototypes -------------------- */ #if !defined(LLC_MAX_NUM_DATA_CHAN) @@ -305,6 +305,67 @@ tBleStatus hci_acl_data_ind_event_int_cb_ucfg_weak(void* header_p, tBleStatus hci_acl_data_ind_event_int_cb(void* header_p, uint8_t* buff_p); +uint8_t log_verbosity_set_ucfg(void* p); +uint8_t log_verbosity_set_ucfg_weak(void* p); +uint8_t log_verbosity_set(void* p); + +void log_verbosity_get_ucfg(void* verb_p); +void log_verbosity_get_ucfg_weak(void* verb_p); +void log_verbosity_get(void* verb_p); + +void log_init_ucfg(void); +void log_init_ucfg_weak(void); +void log_init(void); + +void log_notify_stu_ucfg(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t fmt, + uint8_t len, + uint8_t* buf_p); +void log_notify_stu_ucfg_weak(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t fmt, + uint8_t len, + uint8_t* buf_p); +void log_notify_stu(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t fmt, + uint8_t len, + uint8_t* buf_p); + +void log_notify_us_deferred_ucfg(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t add_info_present, + uint32_t add_info); +void log_notify_us_deferred_ucfg_weak(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t add_info_present, + uint32_t add_info); +void log_notify_us_deferred(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t add_info_present, + uint32_t add_info); + +void log_notify_us_flush_ucfg(void); +void log_notify_us_flush_ucfg_weak(void); +void log_notify_us_flush(void); + +uint32_t log_csr_ucfg(void); +uint32_t log_csr_ucfg_weak(void); +uint32_t log_csr(void); + uint32_t chc_csr_ucfg(void); uint32_t chc_csr_ucfg_weak(void); uint32_t chc_csr(void); @@ -459,6 +520,10 @@ tBleStatus MBM_init_ucfg(void); tBleStatus MBM_init_ucfg_weak(void); tBleStatus MBM_init(void); +tBleStatus smp_debug_trudy__set_config_ucfg(uint32_t config); +tBleStatus smp_debug_trudy__set_config_ucfg_weak(uint32_t config); +tBleStatus smp_debug_trudy__set_config(uint32_t config); + uint32_t secure_connections_csr_ucfg(void); uint32_t secure_connections_csr_ucfg_weak(void); uint32_t secure_connections_csr(void); @@ -550,9 +615,9 @@ tBleStatus llc_conn_multi_link_connection_ucfg(uint8_t enable); tBleStatus llc_conn_multi_link_connection_ucfg_weak(uint8_t enable); tBleStatus llc_conn_multi_link_connection(uint8_t enable); -void llc_conn_peripheral_latency_cancellation_tsk_ucfg(uint16_t task_idx); -void llc_conn_peripheral_latency_cancellation_tsk_ucfg_weak(uint16_t task_idx); -void llc_conn_peripheral_latency_cancellation_tsk(uint16_t task_idx); +void llc_conn_peripheral_roll_back_params_tsk_ucfg(uint16_t task_idx); +void llc_conn_peripheral_roll_back_params_tsk_ucfg_weak(uint16_t task_idx); +void llc_conn_peripheral_roll_back_params_tsk(uint16_t task_idx); uint8_t llc_check_sreq_or_creq_tx_addr_ucfg(void* tx_addr7_p, uint8_t pdu_type, @@ -1066,6 +1131,14 @@ void llc_priv_init_random_part_of_one_local_rpa_ucfg(void* peer_id_p); void llc_priv_init_random_part_of_one_local_rpa_ucfg_weak(void* peer_id_p); void llc_priv_init_random_part_of_one_local_rpa(void* peer_id_p); +void llc_priv_enable_rpa_change_at_timeout_ucfg(uint8_t enable); +void llc_priv_enable_rpa_change_at_timeout_ucfg_weak(uint8_t enable); +void llc_priv_enable_rpa_change_at_timeout(uint8_t enable); + +uint8_t llc_priv_is_rpa_change_at_timeout_enabled_ucfg(void); +uint8_t llc_priv_is_rpa_change_at_timeout_enabled_ucfg_weak(void); +uint8_t llc_priv_is_rpa_change_at_timeout_enabled(void); + void llc_pscan_cancel_slot_cte_ucfg(void* cntxt_per_p); void llc_pscan_cancel_slot_cte_ucfg_weak(void* cntxt_per_p); void llc_pscan_cancel_slot_cte(void* cntxt_per_p); @@ -1194,6 +1267,14 @@ void llc_scan_conn_ind_sent_ucfg_weak(void* ptr, void llc_scan_conn_ind_sent(void* ptr, uint8_t idx); +uint8_t llc_scan_isr_uncoded_ucfg(void* cntxt_p); +uint8_t llc_scan_isr_uncoded_ucfg_weak(void* cntxt_p); +uint8_t llc_scan_isr_uncoded(void* cntxt_p); + +uint8_t llc_scan_isr_coded_ucfg(void* cntxt_p); +uint8_t llc_scan_isr_coded_ucfg_weak(void* cntxt_p); +uint8_t llc_scan_isr_coded(void* cntxt_p); + uint8_t llc_scan_process_ext_adv_ucfg(void* scan_p, void* params_p, uint32_t direct_addr[2], @@ -1279,6 +1360,10 @@ void llc_scan_disable_ucfg(void* scan_p); void llc_scan_disable_ucfg_weak(void* scan_p); void llc_scan_disable(void* scan_p); +uint8_t llc_scan_stop_ucfg(uint8_t scan_disable); +uint8_t llc_scan_stop_ucfg_weak(uint8_t scan_disable); +uint8_t llc_scan_stop(uint8_t scan_disable); + uint8_t llc_subrate_get_active_sr_req_proc_ucfg(uint8_t conn_idx); uint8_t llc_subrate_get_active_sr_req_proc_ucfg_weak(uint8_t conn_idx); uint8_t llc_subrate_get_active_sr_req_proc(uint8_t conn_idx); @@ -1737,10 +1822,6 @@ void LL_init(uint8_t dataLenExt, uint8_t Cns, uint8_t Chc); -tBleStatus smp_debug_trudy__set_config_ucfg(uint32_t config); -tBleStatus smp_debug_trudy__set_config_ucfg_weak(uint32_t config); -tBleStatus smp_debug_trudy__set_config(uint32_t config); - tBleStatus smp_start_encryption_ucfg(void* params); tBleStatus smp_start_encryption_ucfg_weak(void* params); tBleStatus smp_start_encryption(void* params); @@ -2135,6 +2216,8 @@ tBleStatus aci_gatt_clt_execute_write_req_api(uint16_t Connection_Handle, tBleStatus aci_gatt_clt_confirm_indication_api(uint16_t Connection_Handle, uint16_t CID); +tBleStatus aci_gatt_clt_add_subscription_security_level_api(ble_gatt_clt_sec_level_st* sec_level_p); + tBleStatus aci_hal_peripheral_latency_enable_api(uint16_t Connection_Handle, uint8_t Enable); diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_status.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_status.h index fb2f4bf78..61790a81e 100644 --- a/lib/stm32wb0/STM32_BLE/stack/include/ble_status.h +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_status.h @@ -226,10 +226,10 @@ typedef uint8_t tBleStatus; */ /** - * @brief The remote device in in the Blacklist and the pairing operation it requested - * cannot be performed. + * @brief The remote device is in the reject list due to repeated pairing attempts + * and the procedure cannot be started. */ -#define BLE_STATUS_DEV_IN_BLACKLIST ((tBleStatus)(0xB0)) +#define BLE_STATUS_REPEATED_ATTEMPTS ((tBleStatus)(0xB0)) /** * @brief CSRK not found during validation of an incoming signed packet @@ -309,7 +309,7 @@ typedef uint8_t tBleStatus; #define BLE_STATUS_INVALID_SCAN_CONFIGURATION ((tBleStatus)(0xD1)) /** - * @brief The configuration set by the aci_gap_set_connect_configuration command + * @brief The configuration set by the aci_gap_set_connection_configuration command * is not coherent with the GAP procedure that is requested to be started */ #define BLE_STATUS_INVALID_CONNECT_CONFIGURATION ((tBleStatus)(0xD2)) diff --git a/lib/stm32wb0/STM32_BLE/stack/include/bleplat.h b/lib/stm32wb0/STM32_BLE/stack/include/bleplat.h index 81c636012..6c91c30bb 100644 --- a/lib/stm32wb0/STM32_BLE/stack/include/bleplat.h +++ b/lib/stm32wb0/STM32_BLE/stack/include/bleplat.h @@ -122,11 +122,10 @@ int BLEPLAT_MemCmp(void *S1, void *S2, unsigned int Size); * This function returns the device ID, version and revision numbers. * To be called by the BLE Stack for ensuring platform independence. * - * @param[out] device_id Device ID (6 = STM32WB09) - * @param[out] major_cut Device cut version/major number - * @param[out] minor_cut Device cut revision/minor number + * @param[out] pDeviceId Device ID (6 = STM32WB09) + * @param[out] pMajorCut Device cut version/major number + * @param[out] pMinorCut Device cut revision/minor number * - * @retval None */ void BLEPLAT_GetPartInfo(uint8_t *pDeviceId, uint8_t *pMajorCut, uint8_t *pMinorCut); @@ -194,7 +193,7 @@ void BLEPLAT_RngGetRandom32(uint32_t* Num); /** * @brief Convert TX output power in dBm to the related Power Amplifier level - * @param TX_dBm Desired TX output power. + * @param TxDBm Desired TX output power. * * @retval PA level that has to be set in the radio register to have a TX * output power lower than or equal to the desired output power @@ -203,7 +202,7 @@ uint8_t BLEPLAT_DBmToPALevel(int8_t TxDBm); /** * @brief Convert TX output power in dBm to the related Power Amplifier level - * @param TX_dBm Desired TX output power. + * @param TxDBm Desired TX output power. * * @retval PA level that has to be set in the radio register to have a TX * output power greater than or equal to the desired output power @@ -212,7 +211,7 @@ uint8_t BLEPLAT_DBmToPALevelGe(int8_t TxDBm); /** * @brief Convert Power Amplifier level to TX output power in dBm - * @param PA_Level Level setting for the Power Amplifier + * @param PaLevel Level setting for the Power Amplifier * * @retval Output power in dBm, corresponding to the given PA level. If PA * level is invalid, returned value is 127. @@ -221,19 +220,17 @@ int8_t BLEPLAT_PALevelToDBm(uint8_t PaLevel); /** * @brief Return minimum and maximum supported TX power. - * @param[out] Min_Tx_Power Minimum supported TX power in dBm. - * @param[out] Max_Tx_Power Maximum supported TX power in dBm. + * @param[out] MinTxPower Minimum supported TX power in dBm. + * @param[out] MaxTxPower Maximum supported TX power in dBm. * - * @retval None */ void BLEPLAT_ReadTransmitPower(int8_t *MinTxPower, int8_t *MaxTxPower); /** * @brief Configure the radio in order to increase output power level. * @note This function should be called only by the BLE stack. - * @param enable Enable or disable the ability to reach maximum TX power. + * @param Enable Enable or disable the ability to reach maximum TX power. * Set to 1 to enable high power mode. Set ot 0 to disable. - * @retval None */ void BLEPLAT_SetHighPower(uint8_t Enable); @@ -245,17 +242,17 @@ void BLEPLAT_SetHighPower(uint8_t Enable); int8_t BLEPLAT_CalculateRSSI(void); /** - * @brief Return the next value of the average of RSSI values - * given the current RSSI average value and the next RSSI value. + * @brief This function must return the average of RSSI values + * given the past RSSI average value and the next RSSI value. * All values are signed and expressed in dBm. * An Exponential Moving Average algorithm is applied. - * @param avg_rssi Current RSSI average value. - * Set to 127 to return the 'rssi' value. - * @param rssi Next RSSI value - * @param rssi_filter_coeff Coefficient used for the filtering of + * @param AvgRssi Past RSSI average value. + * It is 127 if no average is available yet (i.e. first sample). + * @param Rssi Current RSSI value + * @param RssiFilterCoeff Coefficient used for the filtering of * the RSSI samples and the calculation of * the average RSSI. - * @retval Next RSSI average value + * @retval RSSI average value */ int8_t BLEPLAT_UpdateAvgRSSI(int8_t AvgRssi, int8_t Rssi, uint8_t RssiFilterCoeff); diff --git a/zephyr/module.yml b/zephyr/module.yml index 4fef1b5e3..d53efe1c3 100644 --- a/zephyr/module.yml +++ b/zephyr/module.yml @@ -47,11 +47,11 @@ blobs: url: https://github.com/STMicroelectronics/STM32CubeWBA/raw/v1.7.0/Middlewares/ST/STM32_WPAN/ble/stack/lib/stm32wba_ble_stack_llobasic.a description: "Binary Stack library for the STM32WBA Bluetooth subsystem" - path: stm32wb0/lib/stm32wb0x_ble_stack_controller_only.a - sha256: 54bf69acaa59afc368132f8170e9910858a2c801538494d8de96fa567c02e233 + sha256: e6b82f379a9cf071b36914cf4ba92192d6da2cd3c4fef1a4e1126df534e822b3 type: lib - version: '1.0.0' + version: '1.1.0' license-path: zephyr/blobs/stm32wb0/lib/license.md - url: https://github.com/STMicroelectronics/STM32CubeWB0/raw/v1.0.0/Middlewares/ST/STM32_BLE/stack/lib/stm32wb0x_ble_stack_controller_only.a + url: https://github.com/STMicroelectronics/STM32CubeWB0/raw/v1.1.0/Middlewares/ST/STM32_BLE/stack/lib/stm32wb0x_ble_stack_controller_only.a description: "Binary Stack library for the STM32WB0 Bluetooth subsystem" - path: stm32wba/lib/WBA6_LinkLayer15_4_Zephyr.a sha256: 189e087aef9942b6fa77e0573346cedbb1ea354ee4aa7649bfbd465779969fb3 From 2cd4fe992cf521ca70a8cfcf4c1f50652bfbbe36 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Thu, 11 Dec 2025 16:56:38 +0100 Subject: [PATCH 07/11] scripts: support WB0 wireless libraries update Add wireless library update from STM32CubeWB0. Factorize use of ble_library.update() for the 3 series (wb, wba, wb0) in serie_update.py script for sakee of simplicity. Signed-off-by: Etienne Carriere --- scripts/ble_library.py | 90 +++++++++++++++++++++++++++++++++++++++-- scripts/serie_update.py | 21 ++-------- 2 files changed, 91 insertions(+), 20 deletions(-) diff --git a/scripts/ble_library.py b/scripts/ble_library.py index 6dc8f8b76..eedc3a0d7 100644 --- a/scripts/ble_library.py +++ b/scripts/ble_library.py @@ -145,6 +145,80 @@ ], } +wb0_ble_transparent_mode_app_path = "Projects/NUCLEO-WB09KE/Applications/BLE/" \ + + "BLE_TransparentMode" + +file_list_wb0 = { + "STM32_BLE": [ + "Middlewares/ST/STM32_BLE/ble.h", + "Middlewares/ST/STM32_BLE/stack/config/ble_stack_user_cfg.c", + "Middlewares/ST/STM32_BLE/stack/include/ble_api.h", + "Middlewares/ST/STM32_BLE/stack/include/ble_const.h", + "Middlewares/ST/STM32_BLE/stack/include/ble_events.h", + "Middlewares/ST/STM32_BLE/stack/include/ble_gatt.h", + "Middlewares/ST/STM32_BLE/stack/include/bleplat_cntr.h", + "Middlewares/ST/STM32_BLE/stack/include/bleplat.h", + "Middlewares/ST/STM32_BLE/stack/include/ble_stack.h", + "Middlewares/ST/STM32_BLE/stack/include/ble_stack_user_cfg.h", + "Middlewares/ST/STM32_BLE/stack/include/ble_status.h", + "Middlewares/ST/STM32_BLE/stack/include/ble_types.h", + "Middlewares/ST/STM32_BLE/stack/include/uuid.h", + ], + "BLE_TransparentMode": [ + wb0_ble_transparent_mode_app_path + "/Core/Inc/app_common.h", + wb0_ble_transparent_mode_app_path + "/Core/Inc/app_conf.h", + wb0_ble_transparent_mode_app_path + "/Core/Src/stm32wb0x_hal_msp.c", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/aci_adv_nwk.c", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/aci_adv_nwk.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/aci_gatt_nwk.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/aci_l2cap_nwk.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/adv_buff_alloc.c", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/adv_buff_alloc.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/adv_buff_alloc_tiny.c", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/adv_buff_alloc_tiny.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/app_ble.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/ble_conf.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dm_alloc.c", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dm_alloc.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_burst.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_cmd_db.c", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_cmd_db.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_cmd_en.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_cmds.c", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_cmd_stack_en.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_preprocess_events.c", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_preprocess_events.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/fifo.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/hci_parser.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/pawr_buff_alloc.c", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/pawr_buff_alloc.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/transport_layer.c", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/transport_layer.h", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/Target/bleplat.c", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/Target/bleplat_cntr.c", + ], + "Common": [ + "Projects/Common/BLE/Interfaces/hw_aes.c", + "Projects/Common/BLE/Interfaces/hw_aes.h", + "Projects/Common/BLE/Interfaces/hw_pka.c", + "Projects/Common/BLE/Interfaces/hw_pka.h", + "Projects/Common/BLE/Interfaces/hw_rng.c", + "Projects/Common/BLE/Interfaces/hw_rng.h", + "Projects/Common/BLE/Modules/asm.h", + "Projects/Common/BLE/Modules/blue_unit_conversion.s", + "Projects/Common/BLE/Modules/compiler.h", + "Projects/Common/BLE/Modules/crash_handler.h", + "Projects/Common/BLE/Modules/miscutil.c", + "Projects/Common/BLE/Modules/miscutil.h", + "Projects/Common/BLE/Modules/osal.h", + "Projects/Common/BLE/Modules/osal_memcpy.s", + "Projects/Common/BLE/Modules/PKAMGR/Inc/pka_manager.h", + "Projects/Common/BLE/Modules/PKAMGR/Src/pka_manager.c", + "Projects/Common/BLE/Modules/RADIO_utils/Inc/RADIO_utils.h", + "Projects/Common/BLE/Modules/RADIO_utils/Src/RADIO_utils.c", + ], +} + def os_cmd(cmd, cwd=None, shell=False): """Execute a command with subprocess.check_call() @@ -193,15 +267,25 @@ def copy_ble_lib_files(src_repo_path, dest_lib_path, stm32_serie): logging.error("Abort") sys.exit() - elif stm32_serie == "stm32wba": + elif stm32_serie in ["stm32wba", "stm32wb0"]: + + if stm32_serie == "stm32wba": + target_file_list = file_list_wba + elif stm32_serie == "stm32wb0": + target_file_list = file_list_wb0 + else: + logging.error(f"File : Unexpected series {stm32_serie}") + logging.error("Abort") + sys.exit() + # Remove existing *.c and *.h files for root, _, files in os.walk(dest_lib_path): for file in files: if file.endswith(".c") or file.endswith(".h"): os.remove(os.path.join(root, file)) - for dir_name in file_list_wba: - for file in file_list_wba[dir_name]: + for dir_name in target_file_list: + for file in target_file_list[dir_name]: # Src file path to be copied src_file_path = Path(src_repo_path / file) if src_file_path.exists(): diff --git a/scripts/serie_update.py b/scripts/serie_update.py index d49dc5f53..c4110b825 100644 --- a/scripts/serie_update.py +++ b/scripts/serie_update.py @@ -779,11 +779,11 @@ def update_stm32_hal_serie(self): self.apply_zephyr_patch() self.merge_commit() - # 8) In case of stm32wb, update ble library - if self.stm32_serie == "stm32wb": + # 8) In case of stm32wb/wba/wb0, update library + if self.stm32_serie in ["stm32wb", "stm32wba", "stm32wb0"]: ble_library.update( self.stm32cube_serie_path, - Path(self.zephyr_hal_stm32_path / "lib" / "stm32wb"), + Path(self.zephyr_hal_stm32_path / "lib" / self.stm32_serie), self.stm32cube_temp, self.current_version, self.version_update, @@ -792,19 +792,6 @@ def update_stm32_hal_serie(self): ) self.merge_commit(lib=True) - # 9) In case of stm32wba, update hci library - elif self.stm32_serie == "stm32wba": - ble_library.update( - self.stm32cube_serie_path, - Path(self.zephyr_hal_stm32_path / "lib" / "stm32wba"), - self.stm32cube_temp, - self.current_version, - self.version_update, - self.update_commit, - self.stm32_serie - ) - self.merge_commit(lib=True) - - # 10) clean + # 9) clean self.clean_files() logging.info("%s", f"Done {self.stm32_serie}\n") From 8f12c8b015d89964a599a0d18ef0cc01db9697eb Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Fri, 12 Dec 2025 12:10:36 +0100 Subject: [PATCH 08/11] stm32cube: update stm32wb0 to cube version V1.4.0 Update Cube version for STM32WB0x series on https://github.com/STMicroelectronics from version v1.1.0 to version v1.4.0 Signed-off-by: Etienne Carriere --- stm32cube/stm32wb0x/README | 4 +- .../drivers/include/Legacy/stm32_hal_legacy.h | 43 +- .../stm32wb0x/drivers/include/stm32wb0x_hal.h | 2 +- .../drivers/include/stm32wb0x_hal_adc.h | 12 +- .../drivers/include/stm32wb0x_hal_i2s.h | 4 +- .../drivers/include/stm32wb0x_hal_radio.h | 18 + .../include/stm32wb0x_hal_radio_timer.h | 2 +- .../drivers/include/stm32wb0x_hal_smartcard.h | 6 +- .../drivers/include/stm32wb0x_hal_spi.h | 46 +- .../drivers/include/stm32wb0x_hal_uart.h | 12 +- .../drivers/include/stm32wb0x_hal_uart_ex.h | 2 + .../drivers/include/stm32wb0x_hal_usart.h | 15 +- .../drivers/include/stm32wb0x_ll_adc.h | 22 +- .../drivers/include/stm32wb0x_ll_lpuart.h | 4 + .../drivers/include/stm32wb0x_ll_rcc.h | 37 ++ .../drivers/include/stm32wb0x_ll_spi.h | 167 +++--- .../drivers/include/stm32wb0x_ll_usart.h | 4 + .../drivers/src/stm32wb0x_hal_gpio.c | 16 +- .../stm32wb0x/drivers/src/stm32wb0x_hal_i2s.c | 4 +- .../drivers/src/stm32wb0x_hal_radio.c | 104 ++-- .../drivers/src/stm32wb0x_hal_radio_timer.c | 307 +++++----- .../drivers/src/stm32wb0x_hal_rcc_ex.c | 2 + .../stm32wb0x/drivers/src/stm32wb0x_hal_spi.c | 546 ++++++++---------- .../src/stm32wb0x_hal_timebase_tim_template.c | 5 + .../drivers/src/stm32wb0x_hal_uart.c | 204 +++---- .../drivers/src/stm32wb0x_hal_uart_ex.c | 52 +- .../stm32wb0x/drivers/src/stm32wb0x_ll_spi.c | 9 +- stm32cube/stm32wb0x/soc/stm32wb05.h | 1 + stm32cube/stm32wb0x/soc/stm32wb06.h | 1 + stm32cube/stm32wb0x/soc/stm32wb07.h | 1 + stm32cube/stm32wb0x/soc/stm32wb09.h | 1 + stm32cube/stm32wb0x/soc/stm32wb0x.h | 2 +- stm32cube/stm32wb0x/soc/system_stm32wb0x.c | 10 +- 33 files changed, 881 insertions(+), 784 deletions(-) diff --git a/stm32cube/stm32wb0x/README b/stm32cube/stm32wb0x/README index 0d24bcd37..a79f65752 100644 --- a/stm32cube/stm32wb0x/README +++ b/stm32cube/stm32wb0x/README @@ -6,7 +6,7 @@ Origin: http://www.st.com/en/embedded-software/stm32cubewb0.html Status: - version v1.1.0 + version v1.4.0 Purpose: STMicroelectronics official MCU package for STM32WB0 series. @@ -23,7 +23,7 @@ URL: https://github.com/STMicroelectronics/STM32CubeWB0 Commit: - acb6e3c6086b69b3fff8111c89b825d6acbb3d71 + feb9b9624b10a3af4e5dccb390a01b0cc4d71771 Maintained-by: External diff --git a/stm32cube/stm32wb0x/drivers/include/Legacy/stm32_hal_legacy.h b/stm32cube/stm32wb0x/drivers/include/Legacy/stm32_hal_legacy.h index 9fcbd8996..3729be054 100644 --- a/stm32cube/stm32wb0x/drivers/include/Legacy/stm32_hal_legacy.h +++ b/stm32cube/stm32wb0x/drivers/include/Legacy/stm32_hal_legacy.h @@ -361,7 +361,10 @@ extern "C" { #if defined(STM32L4R5xx) || defined(STM32L4R9xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || \ defined(STM32L4S7xx) || defined(STM32L4S9xx) #define DMA_REQUEST_DCMI_PSSI DMA_REQUEST_DCMI -#endif +#elif defined(STM32L4P5xx) || defined(STM32L4Q5xx) +#define DMA_REQUEST_PSSI DMA_REQUEST_DCMI_PSSI +#define LL_DMAMUX_REQ_PSSI LL_DMAMUX_REQ_DCMI_PSSI +#endif /* STM32L4R5xx || STM32L4R9xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */ #endif /* STM32L4 */ @@ -472,9 +475,9 @@ extern "C" { #define TYPEPROGRAMDATA_FASTBYTE FLASH_TYPEPROGRAMDATA_FASTBYTE #define TYPEPROGRAMDATA_FASTHALFWORD FLASH_TYPEPROGRAMDATA_FASTHALFWORD #define TYPEPROGRAMDATA_FASTWORD FLASH_TYPEPROGRAMDATA_FASTWORD -#if !defined(STM32F2) && !defined(STM32F4) && !defined(STM32F7) && !defined(STM32H7) +#if !defined(STM32F2) && !defined(STM32F4) && !defined(STM32F7) && !defined(STM32H7) && !defined(STM32H5) /* #define PAGESIZE FLASH_PAGE_SIZE */ -#endif /* STM32F2 && STM32F4 && STM32F7 && STM32H7 */ +#endif /* STM32F2 && STM32F4 && STM32F7 && STM32H7 && STM32H5 */ #define TYPEPROGRAM_FASTBYTE FLASH_TYPEPROGRAM_BYTE #define TYPEPROGRAM_FASTHALFWORD FLASH_TYPEPROGRAM_HALFWORD #define TYPEPROGRAM_FASTWORD FLASH_TYPEPROGRAM_WORD @@ -538,6 +541,10 @@ extern "C" { #define FLASH_FLAG_WDW FLASH_FLAG_WBNE #define OB_WRP_SECTOR_All OB_WRP_SECTOR_ALL #endif /* STM32H7 */ +#if defined(STM32H7RS) +#define FLASH_OPTKEY1 FLASH_OPT_KEY1 +#define FLASH_OPTKEY2 FLASH_OPT_KEY2 +#endif /* STM32H7RS */ #if defined(STM32U5) #define OB_USER_nRST_STOP OB_USER_NRST_STOP #define OB_USER_nRST_STDBY OB_USER_NRST_STDBY @@ -560,6 +567,9 @@ extern "C" { #define OB_nBOOT0_RESET OB_NBOOT0_RESET #define OB_nBOOT0_SET OB_NBOOT0_SET #endif /* STM32U0 */ +#if defined(STM32H5) +#define FLASH_ECC_AREA_EDATA FLASH_ECC_AREA_EDATA_BANK1 +#endif /* STM32H5 */ /** * @} @@ -1299,22 +1309,22 @@ extern "C" { #define TAMP_SECRETDEVICE_ERASE_ENABLE TAMP_SECRETDEVICE_ERASE_ALL #endif /* STM32H5 || STM32WBA || STM32H7RS || STM32N6 */ -#if defined(STM32F7) +#if defined(STM32F7) || defined(STM32WB) #define RTC_TAMPCR_TAMPXE RTC_TAMPER_ENABLE_BITS_MASK #define RTC_TAMPCR_TAMPXIE RTC_TAMPER_IT_ENABLE_BITS_MASK -#endif /* STM32F7 */ +#endif /* STM32F7 || STM32WB */ #if defined(STM32H7) #define RTC_TAMPCR_TAMPXE RTC_TAMPER_X #define RTC_TAMPCR_TAMPXIE RTC_TAMPER_X_INTERRUPT #endif /* STM32H7 */ -#if defined(STM32F7) || defined(STM32H7) || defined(STM32L0) +#if defined(STM32F7) || defined(STM32H7) || defined(STM32L0) || defined(STM32WB) #define RTC_TAMPER1_INTERRUPT RTC_IT_TAMP1 #define RTC_TAMPER2_INTERRUPT RTC_IT_TAMP2 #define RTC_TAMPER3_INTERRUPT RTC_IT_TAMP3 #define RTC_ALL_TAMPER_INTERRUPT RTC_IT_TAMP -#endif /* STM32F7 || STM32H7 || STM32L0 */ +#endif /* STM32F7 || STM32H7 || STM32L0 || STM32WB */ /** * @} @@ -1481,7 +1491,7 @@ extern "C" { #define TIM_TIM3_TI1_COMP1COMP2_OUT TIM_TIM3_TI1_COMP1_COMP2 #endif -#if defined(STM32U5) +#if defined(STM32U5) || defined(STM32MP2) #define OCREF_CLEAR_SELECT_Pos OCREF_CLEAR_SELECT_POS #define OCREF_CLEAR_SELECT_Msk OCREF_CLEAR_SELECT_MSK #endif @@ -2142,6 +2152,13 @@ extern "C" { #define UFB_MODE_BitNumber UFB_MODE_BIT_NUMBER #define CMP_PD_BitNumber CMP_PD_BIT_NUMBER +#if defined(STM32H7RS) || defined(STM32N6) +#define FMC_SWAPBMAP_DISABLE FMC_SWAPBANK_MODE0 +#define FMC_SWAPBMAP_SDRAM_SRAM FMC_SWAPBANK_MODE1 +#define HAL_SetFMCMemorySwappingConfig HAL_FMC_SetBankSwapConfig +#define HAL_GetFMCMemorySwappingConfig HAL_FMC_GetBankSwapConfig +#endif /* STM32H7RS || STM32N6 */ + /** * @} */ @@ -3694,10 +3711,7 @@ extern "C" { #define RCC_SYSCLKSOURCE_STATUS_PLLR RCC_SYSCLKSOURCE_STATUS_PLLCLK #endif - -#if defined(STM32L4) || defined(STM32WB) || defined(STM32G0) || defined(STM32G4) || defined(STM32L5) || \ - defined(STM32WL) || defined(STM32C0) || defined(STM32N6) || defined(STM32H7RS) || \ - defined(STM32U0) +#if defined(STM32L4) || defined(STM32WB) || defined(STM32G0) || defined(STM32G4) || defined(STM32L5) || defined(STM32WL) || defined(STM32C0) || defined(STM32N6) || defined(STM32H7RS) || defined(STM32U0) #define RCC_RTCCLKSOURCE_NO_CLK RCC_RTCCLKSOURCE_NONE #else #define RCC_RTCCLKSOURCE_NONE RCC_RTCCLKSOURCE_NO_CLK @@ -3946,10 +3960,7 @@ extern "C" { /** @defgroup HAL_RTC_Aliased_Macros HAL RTC Aliased Macros maintained for legacy purpose * @{ */ -#if defined (STM32G0) || defined (STM32L5) || defined (STM32L412xx) || defined (STM32L422xx) || \ - defined (STM32L4P5xx)|| defined (STM32L4Q5xx) || defined (STM32G4) || defined (STM32WL) || defined (STM32U5) || \ - defined (STM32WBA) || defined (STM32H5) || \ - defined (STM32C0) || defined (STM32N6) || defined (STM32H7RS) || defined (STM32U0) || defined (STM32U3) +#if defined (STM32G0) || defined (STM32L5) || defined (STM32L412xx) || defined (STM32L422xx) || defined (STM32L4P5xx)|| defined (STM32L4Q5xx) || defined (STM32G4) || defined (STM32WL) || defined (STM32U5) || defined (STM32WBA) || defined (STM32H5) || defined (STM32C0) || defined (STM32N6) || defined (STM32H7RS) || defined (STM32U0) || defined (STM32U3) #else #define __HAL_RTC_CLEAR_FLAG __HAL_RTC_EXTI_CLEAR_FLAG #endif diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal.h index cc2e465b7..cfa9ae892 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal.h @@ -48,7 +48,7 @@ extern "C" { * @brief HAL Driver version number */ #define __STM32WB0x_HAL_VERSION_MAIN (0x01U) /*!< [31:24] main version */ -#define __STM32WB0x_HAL_VERSION_SUB1 (0x01U) /*!< [23:16] sub1 version */ +#define __STM32WB0x_HAL_VERSION_SUB1 (0x04U) /*!< [23:16] sub1 version */ #define __STM32WB0x_HAL_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ #define __STM32WB0x_HAL_VERSION_RC (0x00U) /*!< [7:0] release candidate */ #define __STM32WB0x_HAL_VERSION ((__STM32WB0x_HAL_VERSION_MAIN << 24U)\ diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_adc.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_adc.h index 920a97cb2..e73d2beb4 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_adc.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_adc.h @@ -365,10 +365,14 @@ typedef void (*pADC_CallbackTypeDef)(ADC_HandleTypeDef *hadc); /*!< pointer to * @{ */ -#define ADC_SAMPLING_AT_START (LL_ADC_SAMPLING_AT_START) /*!< Sampling only at conversion start (default) */ -#define ADC_SAMPLING_AT_END (LL_ADC_SAMPLING_AT_END) /*!< Sampling sampling phase starts after end of - conversion, and stops upon trigger event - (Also known as Bulb sampling mode). */ +#define ADC_SAMPLING_AT_START (LL_ADC_SAMPLING_AT_START) /*!< Sampling phase starts only at conversion start and + sampling time is 125ns regardless of the sampling + period (default). */ +#define ADC_SAMPLING_AT_END (LL_ADC_SAMPLING_AT_END) /*!< Sampling phase starts after end of + conversion, and stops upon trigger event (Also known + as Bulb sampling mode). + Sampling time is a function of the sampling period + (Sample rate). */ /** * @} diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_i2s.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_i2s.h index 08efcbe32..4486e2cc7 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_i2s.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_i2s.h @@ -451,8 +451,8 @@ void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s); * @{ */ /* Peripheral Control and State functions ************************************/ -HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s); -uint32_t HAL_I2S_GetError(I2S_HandleTypeDef *hi2s); +HAL_I2S_StateTypeDef HAL_I2S_GetState(const I2S_HandleTypeDef *hi2s); +uint32_t HAL_I2S_GetError(const I2S_HandleTypeDef *hi2s); /** * @} */ diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_radio.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_radio.h index c48a4353a..e1bed9337 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_radio.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_radio.h @@ -96,6 +96,20 @@ typedef struct #endif /* USE_RADIO_PROPRIETARY_DRIVER */ +/** + * @} + */ + +/** @defgroup RADIO_TIMER_Exported_Constants Radio Timer Exported Constants + * @{ + */ + +#define RADIO_INITDELAY_WAKEUP (64U) +#define RADIO_INITDELAY_TIMER12_CAL (63U) +#define RADIO_INITDELAY_TIMER2_NOCAL (9U) + +#define RADIO_TXDELAY_START (16U) +#define RADIO_TXDELAY_END (24U) /** * @} */ @@ -109,10 +123,14 @@ void HAL_RADIO_Init(RADIO_HandleTypeDef *hradio); void HAL_RADIO_TXRX_IRQHandler(void); +void HAL_RADIO_RRM_IRQHandler(void); + void HAL_RADIO_TXRX_SEQ_IRQHandler(void); void HAL_RADIO_TxRxCallback(uint32_t flags); +void HAL_RADIO_RRMCallback(uint32_t ble_irq_status); + void HAL_RADIO_TxRxSeqCallback(void); int8_t HAL_RADIO_ReadRSSI(void); diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_radio_timer.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_radio_timer.h index 8d835a724..40d83e6f2 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_radio_timer.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_radio_timer.h @@ -173,7 +173,7 @@ RADIO_TIMER_Status HAL_RADIO_TIMER_GetRadioTimerStatus(uint64_t *time); * @param event_type: Specify if it is a TX (1) or RX (0) event. * @param cal_req: Specify if PLL calibration is requested (1) or not (0). * @retval 0 if radio activity has been scheduled successfully. - * @retval 1 if radio activity has been rejected (it is too close or in the past). + * @retval 1 if radio activity has been rejected. */ uint32_t HAL_RADIO_TIMER_SetRadioTimerValue(uint32_t time, uint8_t event_type, uint8_t cal_req); diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_smartcard.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_smartcard.h index 366ee70d0..d8beeee4a 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_smartcard.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_smartcard.h @@ -713,13 +713,13 @@ typedef void (*pSMARTCARD_CallbackTypeDef)(SMARTCARD_HandleTypeDef *hsmartcard) */ #define __HAL_SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & SMARTCARD_CR_MASK) >>\ SMARTCARD_CR_POS) == 1U)?\ - ((__HANDLE__)->Instance->CR1 &= ~ (1U <<\ + ((__HANDLE__)->Instance->CR1 &= ~ (1UL <<\ ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \ ((((__INTERRUPT__) & SMARTCARD_CR_MASK) >>\ SMARTCARD_CR_POS) == 2U)?\ - ((__HANDLE__)->Instance->CR2 &= ~ (1U <<\ + ((__HANDLE__)->Instance->CR2 &= ~ (1UL <<\ ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \ - ((__HANDLE__)->Instance->CR3 &= ~ (1U <<\ + ((__HANDLE__)->Instance->CR3 &= ~ (1UL <<\ ((__INTERRUPT__) & SMARTCARD_IT_MASK)))) /** @brief Check whether the specified SmartCard interrupt has occurred or not. diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_spi.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_spi.h index a7319a72c..7e8cd1c4f 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_spi.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_spi.h @@ -118,7 +118,7 @@ typedef struct __SPI_HandleTypeDef SPI_InitTypeDef Init; /*!< SPI communication parameters */ - uint8_t *pTxBuffPtr; /*!< Pointer to SPI Tx transfer Buffer */ + const uint8_t *pTxBuffPtr; /*!< Pointer to SPI Tx transfer Buffer */ uint16_t TxXferSize; /*!< SPI Tx Transfer size */ @@ -426,11 +426,12 @@ typedef void (*pSPI_CallbackTypeDef)(SPI_HandleTypeDef *hspi); /*!< pointer to * @retval None */ #if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U) -#define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) do{ \ - (__HANDLE__)->State = HAL_SPI_STATE_RESET; \ - (__HANDLE__)->MspInitCallback = NULL; \ - (__HANDLE__)->MspDeInitCallback = NULL; \ - } while(0) +#define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) \ + do{ \ + (__HANDLE__)->State = HAL_SPI_STATE_RESET; \ + (__HANDLE__)->MspInitCallback = NULL; \ + (__HANDLE__)->MspDeInitCallback = NULL; \ + } while(0) #else #define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET) #endif /* USE_HAL_SPI_REGISTER_CALLBACKS */ @@ -533,7 +534,7 @@ typedef void (*pSPI_CallbackTypeDef)(SPI_HandleTypeDef *hspi); /*!< pointer to __IO uint32_t tmpreg_fre = 0x00U; \ tmpreg_fre = (__HANDLE__)->Instance->SR; \ UNUSED(tmpreg_fre); \ - }while(0U) + } while(0U) /** @brief Enable the SPI peripheral. * @param __HANDLE__ specifies the SPI Handle. @@ -577,8 +578,11 @@ typedef void (*pSPI_CallbackTypeDef)(SPI_HandleTypeDef *hspi); /*!< pointer to * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @retval None */ -#define SPI_RESET_CRC(__HANDLE__) do{CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN);\ - SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN);}while(0U) +#define SPI_RESET_CRC(__HANDLE__) \ + do{ \ + CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN); \ + SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN); \ + } while(0U) /** @brief Check whether the specified SPI flag is set or not. * @param __SR__ copy of SPI SR register. @@ -596,7 +600,7 @@ typedef void (*pSPI_CallbackTypeDef)(SPI_HandleTypeDef *hspi); /*!< pointer to * @retval SET or RESET. */ #define SPI_CHECK_FLAG(__SR__, __FLAG__) ((((__SR__) & ((__FLAG__) & SPI_FLAG_MASK)) == \ - ((__FLAG__) & SPI_FLAG_MASK)) ? SET : RESET) + ((__FLAG__) & SPI_FLAG_MASK)) ? SET : RESET) /** @brief Check whether the specified SPI Interrupt is set or not. * @param __CR2__ copy of SPI CR2 register. @@ -608,7 +612,7 @@ typedef void (*pSPI_CallbackTypeDef)(SPI_HandleTypeDef *hspi); /*!< pointer to * @retval SET or RESET. */ #define SPI_CHECK_IT_SOURCE(__CR2__, __INTERRUPT__) ((((__CR2__) & (__INTERRUPT__)) == \ - (__INTERRUPT__)) ? SET : RESET) + (__INTERRUPT__)) ? SET : RESET) /** @brief Checks if SPI Mode parameter is in allowed range. * @param __MODE__ specifies the SPI Mode. @@ -746,7 +750,7 @@ typedef void (*pSPI_CallbackTypeDef)(SPI_HandleTypeDef *hspi); /*!< pointer to */ #define IS_SPI_CRC_POLYNOMIAL(__POLYNOMIAL__) (((__POLYNOMIAL__) >= 0x1U) && \ ((__POLYNOMIAL__) <= 0xFFFFU) && \ - (((__POLYNOMIAL__)&0x1U) != 0U)) + (((__POLYNOMIAL__)&0x1U) != 0U)) /** @brief Checks if DMA handle is valid. * @param __HANDLE__ specifies a DMA Handle. @@ -789,17 +793,17 @@ HAL_StatusTypeDef HAL_SPI_UnRegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_Ca * @{ */ /* I/O operation functions ***************************************************/ -HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); +HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size, uint32_t Timeout); HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); -HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, - uint32_t Timeout); -HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); +HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData, + uint16_t Size, uint32_t Timeout); +HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); -HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, +HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); -HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); +HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); -HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, +HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi); HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi); @@ -825,8 +829,8 @@ void HAL_SPI_AbortCpltCallback(SPI_HandleTypeDef *hspi); * @{ */ /* Peripheral State and Error functions ***************************************/ -HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi); -uint32_t HAL_SPI_GetError(SPI_HandleTypeDef *hspi); +HAL_SPI_StateTypeDef HAL_SPI_GetState(const SPI_HandleTypeDef *hspi); +uint32_t HAL_SPI_GetError(const SPI_HandleTypeDef *hspi); /** * @} */ diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_uart.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_uart.h index e8a7016f9..4370a23f6 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_uart.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_uart.h @@ -47,12 +47,10 @@ typedef struct { uint32_t BaudRate; /*!< This member configures the UART communication baud rate. The baud rate register is computed using the following formula: - LPUART: - ======= + @note For LPUART : Baud Rate Register = ((256 * lpuart_ker_ckpres) / ((huart->Init.BaudRate))) - where lpuart_ker_ck_pres is the UART input clock divided by a prescaler - UART: - ===== + where lpuart_ker_ck_pres is the UART input clock divided by a prescaler. + @note For UART : - If oversampling is 16 or in LIN mode, Baud Rate Register = ((uart_ker_ckpres) / ((huart->Init.BaudRate))) - If oversampling is 8, @@ -297,7 +295,11 @@ typedef enum HAL_UART_ABORT_COMPLETE_CB_ID = 0x05U, /*!< UART Abort Complete Callback ID */ HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x06U, /*!< UART Abort Transmit Complete Callback ID */ HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID = 0x07U, /*!< UART Abort Receive Complete Callback ID */ +#if defined(USART_CR1_UESM) +#if defined(USART_CR3_WUFIE) HAL_UART_WAKEUP_CB_ID = 0x08U, /*!< UART Wakeup Callback ID */ +#endif /* USART_CR3_WUFIE */ +#endif /* USART_CR1_UESM */ HAL_UART_RX_FIFO_FULL_CB_ID = 0x09U, /*!< UART Rx Fifo Full Callback ID */ HAL_UART_TX_FIFO_EMPTY_CB_ID = 0x0AU, /*!< UART Tx Fifo Empty Callback ID */ diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_uart_ex.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_uart_ex.h index fd21e34dc..6b1425fbf 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_uart_ex.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_uart_ex.h @@ -151,8 +151,10 @@ HAL_StatusTypeDef HAL_RS485Ex_Init(UART_HandleTypeDef *huart, uint32_t Polarity, */ #if defined(USART_CR1_UESM) +#if defined(USART_CR3_WUFIE) void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart); +#endif /* USART_CR3_WUFIE */ #endif /* USART_CR1_UESM */ void HAL_UARTEx_RxFifoFullCallback(UART_HandleTypeDef *huart); void HAL_UARTEx_TxFifoEmptyCallback(UART_HandleTypeDef *huart); diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_usart.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_usart.h index 535d0db66..d531b6e33 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_usart.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_hal_usart.h @@ -537,10 +537,10 @@ typedef void (*pUSART_CallbackTypeDef)(USART_HandleTypeDef *husart); /*!< poin */ #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__)\ (((((__INTERRUPT__) & USART_CR_MASK) >> USART_CR_POS) == 1U)?\ - ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ + ((__HANDLE__)->Instance->CR1 |= (1UL << ((__INTERRUPT__) & USART_IT_MASK))): \ ((((__INTERRUPT__) & USART_CR_MASK) >> USART_CR_POS) == 2U)?\ - ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ - ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & USART_IT_MASK)))) + ((__HANDLE__)->Instance->CR2 |= (1UL << ((__INTERRUPT__) & USART_IT_MASK))): \ + ((__HANDLE__)->Instance->CR3 |= (1UL << ((__INTERRUPT__) & USART_IT_MASK)))) /** @brief Disable the specified USART interrupt. * @param __HANDLE__ specifies the USART Handle. @@ -562,10 +562,10 @@ typedef void (*pUSART_CallbackTypeDef)(USART_HandleTypeDef *husart); /*!< poin */ #define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__)\ (((((__INTERRUPT__) & USART_CR_MASK) >> USART_CR_POS) == 1U)?\ - ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ + ((__HANDLE__)->Instance->CR1 &= ~ (1UL << ((__INTERRUPT__) & USART_IT_MASK))): \ ((((__INTERRUPT__) & USART_CR_MASK) >> USART_CR_POS) == 2U)?\ - ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \ - ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK)))) + ((__HANDLE__)->Instance->CR2 &= ~ (1UL << ((__INTERRUPT__) & USART_IT_MASK))): \ + ((__HANDLE__)->Instance->CR3 &= ~ (1UL << ((__INTERRUPT__) & USART_IT_MASK)))) /** @brief Check whether the specified USART interrupt has occurred or not. * @param __HANDLE__ specifies the USART Handle. @@ -695,8 +695,7 @@ typedef void (*pUSART_CallbackTypeDef)(USART_HandleTypeDef *husart); /*!< poin ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV16) ? 16U : \ ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV32) ? 32U : \ ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV64) ? 64U : \ - ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV128) ? 128U : \ - ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV256) ? 256U : 1U) + ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV128) ? 128U : 256U) /** @brief BRR division operation to set BRR register in 8-bit oversampling mode. * @param __PCLK__ USART clock. diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_adc.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_adc.h index f461f9ef5..58da97cd7 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_adc.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_adc.h @@ -348,8 +348,14 @@ typedef struct * @{ */ -#define LL_ADC_SAMPLING_AT_START (0x00000000UL) /*!< Sampling only at conversion start */ -#define LL_ADC_SAMPLING_AT_END (ADC_CONF_ADC_CONT_1V2) /*!< Sampling starts at the end of conversion (default)*/ +#define LL_ADC_SAMPLING_AT_START (0x00000000UL) /*!< Sampling phase starts only at conversion start and + sampling time is 125ns regardless of the sampling + period (default). */ +#define LL_ADC_SAMPLING_AT_END (ADC_CONF_ADC_CONT_1V2) /*!< Sampling phase starts after end of + conversion, and stops upon trigger event (Also known + as Bulb sampling mode). + Sampling time is a function of the sampling period + (Sample rate). */ /** * @} @@ -2769,7 +2775,7 @@ __STATIC_INLINE void LL_ADC_SetCalibPointGain(ADC_TypeDef *ADCx, uint32_t Point, /** * @brief Get the gain of the calibration point 1. - * @rmtoll COMP_1 GAIN1 LL_ADC_GetCalibPoint1Gain + * @rmtoll COMP_1 GAIN1 LL_ADC_GetCalibPointGain * @param ADCx ADC instance * @param Point This parameter can be one of the following values: * @arg @ref LL_ADC_CALIB_POINT_1 @@ -2788,7 +2794,7 @@ __STATIC_INLINE uint32_t LL_ADC_GetCalibPointGain(const ADC_TypeDef *ADCx, uint3 /** * @brief Set the offset of the calibration point 1. - * @rmtoll COMP_1 OFFSET1 LL_ADC_SetCalibPoint1Offset + * @rmtoll COMP_1 OFFSET1 LL_ADC_SetCalibPointOffset * @param ADCx ADC instance * @param Offset the signed offset of the first calibration point. * @param Point This parameter can be one of the following values: @@ -2808,7 +2814,7 @@ __STATIC_INLINE void LL_ADC_SetCalibPointOffset(ADC_TypeDef *ADCx, uint32_t Poin /** * @brief Get the offset of the calibration point 1. - * @rmtoll COMP_1 OFFSET1 LL_ADC_GetCalibPoint1Offset + * @rmtoll COMP_1 OFFSET1 LL_ADC_GetCalibPointOffset * @param ADCx ADC instance * @param Point This parameter can be one of the following values: * @arg @ref LL_ADC_CALIB_POINT_1 @@ -2895,7 +2901,7 @@ __STATIC_INLINE uint32_t LL_ADC_GetCalibPointForDiff(const ADC_TypeDef *ADCx, ui /** * @brief Set the use of a specific calibration point for * ADC single positive mode - * @rmtoll COMP_SEL ADC_COMP_SEL_OFFSET_GAIN7 LL_ADC_SetCalibPointForSinglePos3V6 + * @rmtoll COMP_SEL ADC_COMP_SEL_OFFSET_GAIN7 LL_ADC_SetCalibPointForSinglePos * @param ADCx ADC instance * @param Point This parameter can be one of the following values: * @arg @ref LL_ADC_CALIB_POINT_1 @@ -2931,7 +2937,7 @@ __STATIC_INLINE void LL_ADC_SetCalibPointForSinglePos(ADC_TypeDef *ADCx, uint32_ /** * @brief Get what calibration point is used for * ADC single positive mode - * @rmtoll COMP_SEL ADC_COMP_SEL_OFFSET_GAIN7 LL_ADC_GetCalibPointForSinglePos3V6 + * @rmtoll COMP_SEL ADC_COMP_SEL_OFFSET_GAIN7 LL_ADC_GetCalibPointForSinglePos * @param ADCx ADC instance * @param Range This parameter can be one of the following values: * @arg @ref LL_ADC_VIN_RANGE_1V2 @@ -3043,6 +3049,8 @@ __STATIC_INLINE uint32_t LL_ADC_GetCalibPointForSingleNeg(const ADC_TypeDef *ADC /** * @brief Configure the WatchDoG threshold low and high. + * @rmtoll WD_TH ADC_WD_TH_WD_LT LL_ADC_ConfigureAWDThresholds\n + * WD_TH ADC_WD_TH_WD_HT LL_ADC_ConfigureAWDThresholds * @param ADCx ADC instance * @param LowThreshold This parameter is a 12-bit value. * @param HighThreshold This parameter is a 12-bit value. diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_lpuart.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_lpuart.h index 87c7c67e9..77eb1e67f 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_lpuart.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_lpuart.h @@ -56,6 +56,10 @@ static const uint16_t LPUART_PRESCALER_TAB[] = (uint16_t)32, (uint16_t)64, (uint16_t)128, + (uint16_t)256, + (uint16_t)256, + (uint16_t)256, + (uint16_t)256, (uint16_t)256 }; /** diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_rcc.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_rcc.h index c38f1b655..1a7987cf4 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_rcc.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_rcc.h @@ -1459,6 +1459,43 @@ __STATIC_INLINE uint32_t LL_RCC_GetSPI3I2SClockSource(void) * @} */ +/** @defgroup RCC_LL_EF_RTC RTC + * @{ + */ + +/** + * @brief Enable RTC + * @rmtoll APB0ENR RTCEN LL_RCC_EnableRTC + * @retval None + */ +__STATIC_INLINE void LL_RCC_EnableRTC(void) +{ + SET_BIT(RCC->APB0ENR, RCC_APB0ENR_RTCEN); +} + +/** + * @brief Disable RTC + * @rmtoll APB0ENR RTCEN LL_RCC_DisableRTC + * @retval None + */ +__STATIC_INLINE void LL_RCC_DisableRTC(void) +{ + CLEAR_BIT(RCC->APB0ENR, RCC_APB0ENR_RTCEN); +} + +/** + * @brief Check if RTC has been enabled or not + * @rmtoll APB0ENR RTCEN LL_RCC_IsEnabledRTC + * @retval State of bit (1 or 0). + */ +__STATIC_INLINE uint32_t LL_RCC_IsEnabledRTC(void) +{ + return ((READ_BIT(RCC->APB0ENR, RCC_APB0ENR_RTCEN) == (RCC_APB0ENR_RTCEN)) ? 1UL : 0UL); +} + +/** + * @} + */ /** @defgroup RCC_LL_EF_PLL PLL * @{ diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_spi.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_spi.h index 322db50e6..bc72f8c0b 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_spi.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_spi.h @@ -55,53 +55,66 @@ typedef struct uint32_t TransferDirection; /*!< Specifies the SPI unidirectional or bidirectional data mode. This parameter can be a value of @ref SPI_LL_EC_TRANSFER_MODE. - This feature can be modified afterwards using unitary function @ref LL_SPI_SetTransferDirection().*/ + This feature can be modified afterwards using unitary + function @ref LL_SPI_SetTransferDirection().*/ uint32_t Mode; /*!< Specifies the SPI mode (Master/Slave). This parameter can be a value of @ref SPI_LL_EC_MODE. - This feature can be modified afterwards using unitary function @ref LL_SPI_SetMode().*/ + This feature can be modified afterwards using unitary + function @ref LL_SPI_SetMode().*/ uint32_t DataWidth; /*!< Specifies the SPI data width. This parameter can be a value of @ref SPI_LL_EC_DATAWIDTH. - This feature can be modified afterwards using unitary function @ref LL_SPI_SetDataWidth().*/ + This feature can be modified afterwards using unitary + function @ref LL_SPI_SetDataWidth().*/ uint32_t ClockPolarity; /*!< Specifies the serial clock steady state. This parameter can be a value of @ref SPI_LL_EC_POLARITY. - This feature can be modified afterwards using unitary function @ref LL_SPI_SetClockPolarity().*/ + This feature can be modified afterwards using unitary + function @ref LL_SPI_SetClockPolarity().*/ uint32_t ClockPhase; /*!< Specifies the clock active edge for the bit capture. This parameter can be a value of @ref SPI_LL_EC_PHASE. - This feature can be modified afterwards using unitary function @ref LL_SPI_SetClockPhase().*/ + This feature can be modified afterwards using unitary + function @ref LL_SPI_SetClockPhase().*/ - uint32_t NSS; /*!< Specifies whether the NSS signal is managed by hardware (NSS pin) or by software using the SSI bit. + uint32_t NSS; /*!< Specifies whether the NSS signal is managed by hardware (NSS pin) + or by software using the SSI bit. This parameter can be a value of @ref SPI_LL_EC_NSS_MODE. - This feature can be modified afterwards using unitary function @ref LL_SPI_SetNSSMode().*/ + This feature can be modified afterwards using unitary + function @ref LL_SPI_SetNSSMode().*/ - uint32_t BaudRate; /*!< Specifies the BaudRate prescaler value which will be used to configure the transmit and receive SCK clock. + uint32_t BaudRate; /*!< Specifies the BaudRate prescaler value which will be used + to configure the transmit and receive SCK clock. This parameter can be a value of @ref SPI_LL_EC_BAUDRATEPRESCALER. - @note The communication clock is derived from the master clock. The slave clock does not need to be set. + @note The communication clock is derived from the master clock. + The slave clock does not need to be set. - This feature can be modified afterwards using unitary function @ref LL_SPI_SetBaudRatePrescaler().*/ + This feature can be modified afterwards using unitary + function @ref LL_SPI_SetBaudRatePrescaler().*/ uint32_t BitOrder; /*!< Specifies whether data transfers start from MSB or LSB bit. This parameter can be a value of @ref SPI_LL_EC_BIT_ORDER. - This feature can be modified afterwards using unitary function @ref LL_SPI_SetTransferBitOrder().*/ + This feature can be modified afterwards using unitary + function @ref LL_SPI_SetTransferBitOrder().*/ uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not. This parameter can be a value of @ref SPI_LL_EC_CRC_CALCULATION. - This feature can be modified afterwards using unitary functions @ref LL_SPI_EnableCRC() and @ref LL_SPI_DisableCRC().*/ + This feature can be modified afterwards using unitary + functions @ref LL_SPI_EnableCRC() and @ref LL_SPI_DisableCRC().*/ uint32_t CRCPoly; /*!< Specifies the polynomial used for the CRC calculation. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFF. - This feature can be modified afterwards using unitary function @ref LL_SPI_SetCRCPolynomial().*/ + This feature can be modified afterwards using unitary + function @ref LL_SPI_SetCRCPolynomial().*/ } LL_SPI_InitTypeDef; @@ -378,7 +391,7 @@ __STATIC_INLINE void LL_SPI_Disable(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsEnabled(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsEnabled(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->CR1, SPI_CR1_SPE) == (SPI_CR1_SPE)) ? 1UL : 0UL); } @@ -408,7 +421,7 @@ __STATIC_INLINE void LL_SPI_SetMode(SPI_TypeDef *SPIx, uint32_t Mode) * @arg @ref LL_SPI_MODE_MASTER * @arg @ref LL_SPI_MODE_SLAVE */ -__STATIC_INLINE uint32_t LL_SPI_GetMode(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetMode(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_MSTR | SPI_CR1_SSI)); } @@ -436,7 +449,7 @@ __STATIC_INLINE void LL_SPI_SetStandard(SPI_TypeDef *SPIx, uint32_t Standard) * @arg @ref LL_SPI_PROTOCOL_MOTOROLA * @arg @ref LL_SPI_PROTOCOL_TI */ -__STATIC_INLINE uint32_t LL_SPI_GetStandard(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetStandard(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_FRF)); } @@ -465,7 +478,7 @@ __STATIC_INLINE void LL_SPI_SetClockPhase(SPI_TypeDef *SPIx, uint32_t ClockPhase * @arg @ref LL_SPI_PHASE_1EDGE * @arg @ref LL_SPI_PHASE_2EDGE */ -__STATIC_INLINE uint32_t LL_SPI_GetClockPhase(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetClockPhase(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_CPHA)); } @@ -494,7 +507,7 @@ __STATIC_INLINE void LL_SPI_SetClockPolarity(SPI_TypeDef *SPIx, uint32_t ClockPo * @arg @ref LL_SPI_POLARITY_LOW * @arg @ref LL_SPI_POLARITY_HIGH */ -__STATIC_INLINE uint32_t LL_SPI_GetClockPolarity(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetClockPolarity(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_CPOL)); } @@ -534,7 +547,7 @@ __STATIC_INLINE void LL_SPI_SetBaudRatePrescaler(SPI_TypeDef *SPIx, uint32_t Bau * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV128 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV256 */ -__STATIC_INLINE uint32_t LL_SPI_GetBaudRatePrescaler(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetBaudRatePrescaler(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_BR)); } @@ -562,7 +575,7 @@ __STATIC_INLINE void LL_SPI_SetTransferBitOrder(SPI_TypeDef *SPIx, uint32_t BitO * @arg @ref LL_SPI_LSB_FIRST * @arg @ref LL_SPI_MSB_FIRST */ -__STATIC_INLINE uint32_t LL_SPI_GetTransferBitOrder(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetTransferBitOrder(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_LSBFIRST)); } @@ -599,7 +612,7 @@ __STATIC_INLINE void LL_SPI_SetTransferDirection(SPI_TypeDef *SPIx, uint32_t Tra * @arg @ref LL_SPI_HALF_DUPLEX_RX * @arg @ref LL_SPI_HALF_DUPLEX_TX */ -__STATIC_INLINE uint32_t LL_SPI_GetTransferDirection(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetTransferDirection(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_RXONLY | SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE)); } @@ -648,7 +661,7 @@ __STATIC_INLINE void LL_SPI_SetDataWidth(SPI_TypeDef *SPIx, uint32_t DataWidth) * @arg @ref LL_SPI_DATAWIDTH_15BIT * @arg @ref LL_SPI_DATAWIDTH_16BIT */ -__STATIC_INLINE uint32_t LL_SPI_GetDataWidth(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetDataWidth(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_DS)); } @@ -675,7 +688,7 @@ __STATIC_INLINE void LL_SPI_SetRxFIFOThreshold(SPI_TypeDef *SPIx, uint32_t Thres * @arg @ref LL_SPI_RX_FIFO_TH_HALF * @arg @ref LL_SPI_RX_FIFO_TH_QUARTER */ -__STATIC_INLINE uint32_t LL_SPI_GetRxFIFOThreshold(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetRxFIFOThreshold(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_FRXTH)); } @@ -719,7 +732,7 @@ __STATIC_INLINE void LL_SPI_DisableCRC(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsEnabledCRC(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsEnabledCRC(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->CR1, SPI_CR1_CRCEN) == (SPI_CR1_CRCEN)) ? 1UL : 0UL); } @@ -747,7 +760,7 @@ __STATIC_INLINE void LL_SPI_SetCRCWidth(SPI_TypeDef *SPIx, uint32_t CRCLength) * @arg @ref LL_SPI_CRC_8BIT * @arg @ref LL_SPI_CRC_16BIT */ -__STATIC_INLINE uint32_t LL_SPI_GetCRCWidth(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetCRCWidth(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_CRCL)); } @@ -782,7 +795,7 @@ __STATIC_INLINE void LL_SPI_SetCRCPolynomial(SPI_TypeDef *SPIx, uint32_t CRCPoly * @param SPIx SPI Instance * @retval Returned value is a number between Min_Data = 0x00 and Max_Data = 0xFFFF */ -__STATIC_INLINE uint32_t LL_SPI_GetCRCPolynomial(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetCRCPolynomial(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_REG(SPIx->CRCPR)); } @@ -793,7 +806,7 @@ __STATIC_INLINE uint32_t LL_SPI_GetCRCPolynomial(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval Returned value is a number between Min_Data = 0x00 and Max_Data = 0xFFFF */ -__STATIC_INLINE uint32_t LL_SPI_GetRxCRC(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetRxCRC(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_REG(SPIx->RXCRCR)); } @@ -804,7 +817,7 @@ __STATIC_INLINE uint32_t LL_SPI_GetRxCRC(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval Returned value is a number between Min_Data = 0x00 and Max_Data = 0xFFFF */ -__STATIC_INLINE uint32_t LL_SPI_GetTxCRC(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetTxCRC(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_REG(SPIx->TXCRCR)); } @@ -845,7 +858,7 @@ __STATIC_INLINE void LL_SPI_SetNSSMode(SPI_TypeDef *SPIx, uint32_t NSS) * @arg @ref LL_SPI_NSS_HARD_INPUT * @arg @ref LL_SPI_NSS_HARD_OUTPUT */ -__STATIC_INLINE uint32_t LL_SPI_GetNSSMode(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetNSSMode(const SPI_TypeDef *SPIx) { uint32_t Ssm = (READ_BIT(SPIx->CR1, SPI_CR1_SSM)); uint32_t Ssoe = (READ_BIT(SPIx->CR2, SPI_CR2_SSOE) << 16U); @@ -883,7 +896,7 @@ __STATIC_INLINE void LL_SPI_DisableNSSPulseMgt(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsEnabledNSSPulse(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsEnabledNSSPulse(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->CR2, SPI_CR2_NSSP) == (SPI_CR2_NSSP)) ? 1UL : 0UL); } @@ -902,7 +915,7 @@ __STATIC_INLINE uint32_t LL_SPI_IsEnabledNSSPulse(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_RXNE(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_RXNE(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->SR, SPI_SR_RXNE) == (SPI_SR_RXNE)) ? 1UL : 0UL); } @@ -913,7 +926,7 @@ __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_RXNE(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TXE(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TXE(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->SR, SPI_SR_TXE) == (SPI_SR_TXE)) ? 1UL : 0UL); } @@ -924,7 +937,7 @@ __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TXE(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_CRCERR(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_CRCERR(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->SR, SPI_SR_CRCERR) == (SPI_SR_CRCERR)) ? 1UL : 0UL); } @@ -935,7 +948,7 @@ __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_CRCERR(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_MODF(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_MODF(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->SR, SPI_SR_MODF) == (SPI_SR_MODF)) ? 1UL : 0UL); } @@ -946,7 +959,7 @@ __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_MODF(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_OVR(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_OVR(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->SR, SPI_SR_OVR) == (SPI_SR_OVR)) ? 1UL : 0UL); } @@ -964,7 +977,7 @@ __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_OVR(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_BSY(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_BSY(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->SR, SPI_SR_BSY) == (SPI_SR_BSY)) ? 1UL : 0UL); } @@ -975,7 +988,7 @@ __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_BSY(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_FRE(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_FRE(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->SR, SPI_SR_FRE) == (SPI_SR_FRE)) ? 1UL : 0UL); } @@ -990,7 +1003,7 @@ __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_FRE(SPI_TypeDef *SPIx) * @arg @ref LL_SPI_RX_FIFO_HALF_FULL * @arg @ref LL_SPI_RX_FIFO_FULL */ -__STATIC_INLINE uint32_t LL_SPI_GetRxFIFOLevel(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetRxFIFOLevel(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->SR, SPI_SR_FRLVL)); } @@ -1005,7 +1018,7 @@ __STATIC_INLINE uint32_t LL_SPI_GetRxFIFOLevel(SPI_TypeDef *SPIx) * @arg @ref LL_SPI_TX_FIFO_HALF_FULL * @arg @ref LL_SPI_TX_FIFO_FULL */ -__STATIC_INLINE uint32_t LL_SPI_GetTxFIFOLevel(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetTxFIFOLevel(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->SR, SPI_SR_FTLVL)); } @@ -1045,7 +1058,7 @@ __STATIC_INLINE void LL_SPI_ClearFlag_MODF(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval None */ -__STATIC_INLINE void LL_SPI_ClearFlag_OVR(SPI_TypeDef *SPIx) +__STATIC_INLINE void LL_SPI_ClearFlag_OVR(const SPI_TypeDef *SPIx) { __IO uint32_t tmpreg; tmpreg = SPIx->DR; @@ -1061,7 +1074,7 @@ __STATIC_INLINE void LL_SPI_ClearFlag_OVR(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval None */ -__STATIC_INLINE void LL_SPI_ClearFlag_FRE(SPI_TypeDef *SPIx) +__STATIC_INLINE void LL_SPI_ClearFlag_FRE(const SPI_TypeDef *SPIx) { __IO uint32_t tmpreg; tmpreg = SPIx->SR; @@ -1078,7 +1091,8 @@ __STATIC_INLINE void LL_SPI_ClearFlag_FRE(SPI_TypeDef *SPIx) /** * @brief Enable error interrupt - * @note This bit controls the generation of an interrupt when an error condition occurs (CRCERR, OVR, MODF in SPI mode, FRE at TI mode). + * @note This bit controls the generation of an interrupt when an error condition + * occurs (CRCERR, OVR, MODF in SPI mode, FRE at TI mode). * @rmtoll CR2 ERRIE LL_SPI_EnableIT_ERR * @param SPIx SPI Instance * @retval None @@ -1112,7 +1126,8 @@ __STATIC_INLINE void LL_SPI_EnableIT_TXE(SPI_TypeDef *SPIx) /** * @brief Disable error interrupt - * @note This bit controls the generation of an interrupt when an error condition occurs (CRCERR, OVR, MODF in SPI mode, FRE at TI mode). + * @note This bit controls the generation of an interrupt when an error condition + * occurs (CRCERR, OVR, MODF in SPI mode, FRE at TI mode). * @rmtoll CR2 ERRIE LL_SPI_DisableIT_ERR * @param SPIx SPI Instance * @retval None @@ -1150,7 +1165,7 @@ __STATIC_INLINE void LL_SPI_DisableIT_TXE(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_ERR(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_ERR(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->CR2, SPI_CR2_ERRIE) == (SPI_CR2_ERRIE)) ? 1UL : 0UL); } @@ -1161,7 +1176,7 @@ __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_ERR(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_RXNE(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_RXNE(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->CR2, SPI_CR2_RXNEIE) == (SPI_CR2_RXNEIE)) ? 1UL : 0UL); } @@ -1172,7 +1187,7 @@ __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_RXNE(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_TXE(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_TXE(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->CR2, SPI_CR2_TXEIE) == (SPI_CR2_TXEIE)) ? 1UL : 0UL); } @@ -1213,7 +1228,7 @@ __STATIC_INLINE void LL_SPI_DisableDMAReq_RX(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_RX(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_RX(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->CR2, SPI_CR2_RXDMAEN) == (SPI_CR2_RXDMAEN)) ? 1UL : 0UL); } @@ -1246,7 +1261,7 @@ __STATIC_INLINE void LL_SPI_DisableDMAReq_TX(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_TX(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_TX(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->CR2, SPI_CR2_TXDMAEN) == (SPI_CR2_TXDMAEN)) ? 1UL : 0UL); } @@ -1273,7 +1288,7 @@ __STATIC_INLINE void LL_SPI_SetDMAParity_RX(SPI_TypeDef *SPIx, uint32_t Parity) * @arg @ref LL_SPI_DMA_PARITY_ODD * @arg @ref LL_SPI_DMA_PARITY_EVEN */ -__STATIC_INLINE uint32_t LL_SPI_GetDMAParity_RX(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetDMAParity_RX(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_LDMARX) >> SPI_CR2_LDMARX_Pos); } @@ -1300,7 +1315,7 @@ __STATIC_INLINE void LL_SPI_SetDMAParity_TX(SPI_TypeDef *SPIx, uint32_t Parity) * @arg @ref LL_SPI_DMA_PARITY_ODD * @arg @ref LL_SPI_DMA_PARITY_EVEN */ -__STATIC_INLINE uint32_t LL_SPI_GetDMAParity_TX(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_GetDMAParity_TX(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_LDMATX) >> SPI_CR2_LDMATX_Pos); } @@ -1311,7 +1326,7 @@ __STATIC_INLINE uint32_t LL_SPI_GetDMAParity_TX(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval Address of data register */ -__STATIC_INLINE uint32_t LL_SPI_DMA_GetRegAddr(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_SPI_DMA_GetRegAddr(const SPI_TypeDef *SPIx) { return (uint32_t) &(SPIx->DR); } @@ -1388,7 +1403,7 @@ __STATIC_INLINE void LL_SPI_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData) * @{ */ -ErrorStatus LL_SPI_DeInit(SPI_TypeDef *SPIx); +ErrorStatus LL_SPI_DeInit(const SPI_TypeDef *SPIx); ErrorStatus LL_SPI_Init(SPI_TypeDef *SPIx, LL_SPI_InitTypeDef *SPI_InitStruct); void LL_SPI_StructInit(LL_SPI_InitTypeDef *SPI_InitStruct); @@ -1655,7 +1670,7 @@ __STATIC_INLINE void LL_I2S_Disable(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsEnabled(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsEnabled(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SE) == (SPI_I2SCFGR_I2SE)) ? 1UL : 0UL); } @@ -1688,7 +1703,7 @@ __STATIC_INLINE void LL_I2S_SetDataFormat(SPI_TypeDef *SPIx, uint32_t DataFormat * @arg @ref LL_I2S_DATAFORMAT_24B * @arg @ref LL_I2S_DATAFORMAT_32B */ -__STATIC_INLINE uint32_t LL_I2S_GetDataFormat(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_GetDataFormat(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN)); } @@ -1715,7 +1730,7 @@ __STATIC_INLINE void LL_I2S_SetClockPolarity(SPI_TypeDef *SPIx, uint32_t ClockPo * @arg @ref LL_I2S_POLARITY_LOW * @arg @ref LL_I2S_POLARITY_HIGH */ -__STATIC_INLINE uint32_t LL_I2S_GetClockPolarity(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_GetClockPolarity(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_CKPOL)); } @@ -1750,7 +1765,7 @@ __STATIC_INLINE void LL_I2S_SetStandard(SPI_TypeDef *SPIx, uint32_t Standard) * @arg @ref LL_I2S_STANDARD_PCM_SHORT * @arg @ref LL_I2S_STANDARD_PCM_LONG */ -__STATIC_INLINE uint32_t LL_I2S_GetStandard(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_GetStandard(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SSTD | SPI_I2SCFGR_PCMSYNC)); } @@ -1781,7 +1796,7 @@ __STATIC_INLINE void LL_I2S_SetTransferMode(SPI_TypeDef *SPIx, uint32_t Mode) * @arg @ref LL_I2S_MODE_MASTER_TX * @arg @ref LL_I2S_MODE_MASTER_RX */ -__STATIC_INLINE uint32_t LL_I2S_GetTransferMode(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_GetTransferMode(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SCFG)); } @@ -1804,7 +1819,7 @@ __STATIC_INLINE void LL_I2S_SetPrescalerLinear(SPI_TypeDef *SPIx, uint8_t Presca * @param SPIx SPI Instance * @retval PrescalerLinear Value between Min_Data=0x02 and Max_Data=0xFF */ -__STATIC_INLINE uint32_t LL_I2S_GetPrescalerLinear(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_GetPrescalerLinear(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->I2SPR, SPI_I2SPR_I2SDIV)); } @@ -1831,7 +1846,7 @@ __STATIC_INLINE void LL_I2S_SetPrescalerParity(SPI_TypeDef *SPIx, uint32_t Presc * @arg @ref LL_I2S_PRESCALER_PARITY_EVEN * @arg @ref LL_I2S_PRESCALER_PARITY_ODD */ -__STATIC_INLINE uint32_t LL_I2S_GetPrescalerParity(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_GetPrescalerParity(const SPI_TypeDef *SPIx) { return (uint32_t)(READ_BIT(SPIx->I2SPR, SPI_I2SPR_ODD) >> 8U); } @@ -1864,7 +1879,7 @@ __STATIC_INLINE void LL_I2S_DisableMasterClock(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsEnabledMasterClock(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsEnabledMasterClock(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->I2SPR, SPI_I2SPR_MCKOE) == (SPI_I2SPR_MCKOE)) ? 1UL : 0UL); } @@ -1898,7 +1913,7 @@ __STATIC_INLINE void LL_I2S_DisableAsyncStart(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsEnabledAsyncStart(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsEnabledAsyncStart(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_ASTRTEN) == (SPI_I2SCFGR_ASTRTEN)) ? 1UL : 0UL); } @@ -1918,7 +1933,7 @@ __STATIC_INLINE uint32_t LL_I2S_IsEnabledAsyncStart(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_RXNE(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_RXNE(const SPI_TypeDef *SPIx) { return LL_SPI_IsActiveFlag_RXNE(SPIx); } @@ -1929,7 +1944,7 @@ __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_RXNE(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_TXE(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_TXE(const SPI_TypeDef *SPIx) { return LL_SPI_IsActiveFlag_TXE(SPIx); } @@ -1940,7 +1955,7 @@ __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_TXE(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_BSY(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_BSY(const SPI_TypeDef *SPIx) { return LL_SPI_IsActiveFlag_BSY(SPIx); } @@ -1951,7 +1966,7 @@ __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_BSY(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_OVR(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_OVR(const SPI_TypeDef *SPIx) { return LL_SPI_IsActiveFlag_OVR(SPIx); } @@ -1962,7 +1977,7 @@ __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_OVR(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_UDR(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_UDR(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->SR, SPI_SR_UDR) == (SPI_SR_UDR)) ? 1UL : 0UL); } @@ -1973,7 +1988,7 @@ __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_UDR(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_FRE(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_FRE(const SPI_TypeDef *SPIx) { return LL_SPI_IsActiveFlag_FRE(SPIx); } @@ -1987,7 +2002,7 @@ __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_FRE(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_CHSIDE(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_CHSIDE(const SPI_TypeDef *SPIx) { return ((READ_BIT(SPIx->SR, SPI_SR_CHSIDE) == (SPI_SR_CHSIDE)) ? 1UL : 0UL); } @@ -2009,7 +2024,7 @@ __STATIC_INLINE void LL_I2S_ClearFlag_OVR(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval None */ -__STATIC_INLINE void LL_I2S_ClearFlag_UDR(SPI_TypeDef *SPIx) +__STATIC_INLINE void LL_I2S_ClearFlag_UDR(const SPI_TypeDef *SPIx) { __IO uint32_t tmpreg; tmpreg = SPIx->SR; @@ -2022,7 +2037,7 @@ __STATIC_INLINE void LL_I2S_ClearFlag_UDR(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval None */ -__STATIC_INLINE void LL_I2S_ClearFlag_FRE(SPI_TypeDef *SPIx) +__STATIC_INLINE void LL_I2S_ClearFlag_FRE(const SPI_TypeDef *SPIx) { LL_SPI_ClearFlag_FRE(SPIx); } @@ -2109,7 +2124,7 @@ __STATIC_INLINE void LL_I2S_DisableIT_TXE(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_ERR(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_ERR(const SPI_TypeDef *SPIx) { return LL_SPI_IsEnabledIT_ERR(SPIx); } @@ -2120,7 +2135,7 @@ __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_ERR(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_RXNE(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_RXNE(const SPI_TypeDef *SPIx) { return LL_SPI_IsEnabledIT_RXNE(SPIx); } @@ -2131,7 +2146,7 @@ __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_RXNE(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_TXE(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_TXE(const SPI_TypeDef *SPIx) { return LL_SPI_IsEnabledIT_TXE(SPIx); } @@ -2172,7 +2187,7 @@ __STATIC_INLINE void LL_I2S_DisableDMAReq_RX(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsEnabledDMAReq_RX(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsEnabledDMAReq_RX(const SPI_TypeDef *SPIx) { return LL_SPI_IsEnabledDMAReq_RX(SPIx); } @@ -2205,7 +2220,7 @@ __STATIC_INLINE void LL_I2S_DisableDMAReq_TX(SPI_TypeDef *SPIx) * @param SPIx SPI Instance * @retval State of bit (1 or 0). */ -__STATIC_INLINE uint32_t LL_I2S_IsEnabledDMAReq_TX(SPI_TypeDef *SPIx) +__STATIC_INLINE uint32_t LL_I2S_IsEnabledDMAReq_TX(const SPI_TypeDef *SPIx) { return LL_SPI_IsEnabledDMAReq_TX(SPIx); } @@ -2250,7 +2265,7 @@ __STATIC_INLINE void LL_I2S_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData) * @{ */ -ErrorStatus LL_I2S_DeInit(SPI_TypeDef *SPIx); +ErrorStatus LL_I2S_DeInit(const SPI_TypeDef *SPIx); ErrorStatus LL_I2S_Init(SPI_TypeDef *SPIx, LL_I2S_InitTypeDef *I2S_InitStruct); void LL_I2S_StructInit(LL_I2S_InitTypeDef *I2S_InitStruct); void LL_I2S_ConfigPrescaler(SPI_TypeDef *SPIx, uint32_t PrescalerLinear, uint32_t PrescalerParity); diff --git a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_usart.h b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_usart.h index e6c994f36..d21a32e86 100644 --- a/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_usart.h +++ b/stm32cube/stm32wb0x/drivers/include/stm32wb0x_ll_usart.h @@ -56,6 +56,10 @@ static const uint32_t USART_PRESCALER_TAB[] = 32UL, 64UL, 128UL, + 256UL, + 256UL, + 256UL, + 256UL, 256UL }; /** diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_gpio.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_gpio.c index 1023f618c..5a91ceae4 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_gpio.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_gpio.c @@ -348,11 +348,11 @@ void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin) tmp = SYSCFG->IO_IER; if(GPIOx == GPIOA) { - tmp = ~(1<IO_IER = tmp; @@ -360,22 +360,22 @@ void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin) tmp = SYSCFG->IO_DTR; if(GPIOx == GPIOA) { - tmp = ~(1<IO_DTR = tmp; tmp = SYSCFG->IO_IBER; if(GPIOx == GPIOA) { - tmp = ~(1<IO_IBER = tmp; @@ -383,11 +383,11 @@ void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin) tmp = SYSCFG->IO_IEVR; if(GPIOx == GPIOA) { - tmp = ~(1<IO_IEVR = tmp; diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_i2s.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_i2s.c index 3f8e92701..8af7a01c2 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_i2s.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_i2s.c @@ -1615,7 +1615,7 @@ __weak void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) * the configuration information for I2S module * @retval HAL state */ -HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s) +HAL_I2S_StateTypeDef HAL_I2S_GetState(const I2S_HandleTypeDef *hi2s) { return hi2s->State; } @@ -1626,7 +1626,7 @@ HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s) * the configuration information for I2S module * @retval I2S Error Code */ -uint32_t HAL_I2S_GetError(I2S_HandleTypeDef *hi2s) +uint32_t HAL_I2S_GetError(const I2S_HandleTypeDef *hi2s) { return hi2s->ErrorCode; } diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio.c index 3fcbc3c7a..0eb261482 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio.c @@ -70,11 +70,6 @@ * @{ */ -/* initDelay */ -#define INITDELAY_WAKEUP (0x40U) -#define INITDELAY_TIMER12_CAL (0x3FU) -#define INITDELAY_TIMER2_NOCAL (0x9U) - /* Init_radio_delay */ #if defined (STM32WB05) || defined(STM32WB09 ) #define DELAYCHK_TRANSMIT_CAL (0x5AU) @@ -102,8 +97,6 @@ #if defined (STM32WB06) || defined(STM32WB07) #define TXREADY_TIMEOUT (0x5U) #endif -#define TXDELAY_START (0x10U) -#define TXDELAY_END (0x10U) /* RX parameter init */ #define RCV_TIMEOUT (0x100) @@ -300,9 +293,9 @@ void HAL_RADIO_Init(RADIO_HandleTypeDef *hradio) #endif /* STM32WB05 or STM32WB09 */ /*Set InitDelay*/ - LL_RADIO_SetWakeupInitDelay(INITDELAY_WAKEUP); - LL_RADIO_SetTimer12InitDelayCal(INITDELAY_TIMER12_CAL); - LL_RADIO_SetTimer12InitDelayNoCal(INITDELAY_TIMER2_NOCAL); + LL_RADIO_SetWakeupInitDelay(RADIO_INITDELAY_WAKEUP); + LL_RADIO_SetTimer12InitDelayCal(RADIO_INITDELAY_TIMER12_CAL); + LL_RADIO_SetTimer12InitDelayNoCal(RADIO_INITDELAY_TIMER2_NOCAL); /*Set Init_radio_delay*/ LL_RADIO_SetReceivedCalDelayChk(DELAYCHK_RECEIVE_CAL); @@ -313,8 +306,8 @@ void HAL_RADIO_Init(RADIO_HandleTypeDef *hradio) /* Initial and final TX delays: control the on-air start time of the TX packet * and the length of the packet "tail" after last bit is transmitted */ - LL_RADIO_SetTxDelayStart(TXDELAY_START); - LL_RADIO_SetTxDelayEnd(TXDELAY_END); + LL_RADIO_SetTxDelayStart(RADIO_TXDELAY_START); + LL_RADIO_SetTxDelayEnd(RADIO_TXDELAY_END); /* Timeout for TX ready signal from the radio FSM after the 2nd init phase * has expired @@ -395,6 +388,9 @@ void HAL_RADIO_Init(RADIO_HandleTypeDef *hradio) RRM->UDRA_CTRL0 = RRM_UDRA_CTRL0_RELOAD_RDCFGPTR; LL_RADIO_Active2ErrorInterrupt_Enable(); + /* Enable RRM Port Grant interrupt */ + SET_BIT(RRM->BLE_IRQ_ENABLE, RRM_BLE_IRQ_ENABLE_PORT_GRANT); + #if USE_RADIO_PROPRIETARY_DRIVER globalParameters.back2backTime = BACK_TO_BACK_TIME; globalParameters.tone_start_stop_flag = 0; @@ -542,6 +538,7 @@ static void HAL_RADIO_ActionPacketIsr(uint32_t int_flags) LL_RADIO_TIMER_DisableTimer2(BLUE); LL_RADIO_TIMER_DisableBLEWakeupTimer(WAKEUP); MODIFY_REG(BLUEGLOB->BYTE4, GLOBAL_BYTE4_ACTIVE_Msk, BLUE_IDLE_0); + HAL_RADIO_TIMER_ClearRadioTimerValue(); } else { @@ -605,39 +602,6 @@ static void HAL_RADIO_ActionPacketIsr(uint32_t int_flags) return ; } -/** - * @brief RADIO MSP Init - * @param hradio pointer to a RADIO_HandleTypeDef structure that contains - * the configuration information for RADIO module - * @retval None - */ -__weak void HAL_RADIO_MspInit(RADIO_HandleTypeDef *hradio) -{ - /* Prevent unused argument(s) compilation warning */ - UNUSED(hradio); - - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_I2S_MspInit could be implemented in the user file - */ -} - -/** - * @brief RADIO MSP DeInit - * @param hradio pointer to a RADIO_HandleTypeDef structure that contains - * the configuration information for RADIO module - * @retval None - */ -__weak void HAL_RADIO_MspDeInit(RADIO_HandleTypeDef *hradio) -{ - /* Prevent unused argument(s) compilation warning */ - UNUSED(hradio); - - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_RADIO_MspDeInit could be implemented in the user file - */ -} - - /** * @brief This routine force the radio to be stopped. After calling this function, * the ISR is not triggered unless, "MakeActionPacketPending" API called again. @@ -1748,10 +1712,45 @@ uint8_t HAL_RADIO_ReceivePacketWithAck(uint8_t channel, uint32_t wakeup_time, ui #endif /* USE_RADIO_PROPRIETARY_DRIVER */ +/** + * @brief RADIO MSP Init + * @param hradio pointer to a RADIO_HandleTypeDef structure that contains + * the configuration information for RADIO module + * @retval None + */ +__weak void HAL_RADIO_MspInit(RADIO_HandleTypeDef *hradio) +{ + /* Prevent unused argument(s) compilation warning */ + UNUSED(hradio); + + /* NOTE : This function Should not be modified, when the callback is needed, + the HAL_RADIO_MspInit could be implemented in the user file + */ +} + +/** + * @brief RADIO MSP DeInit + * @param hradio pointer to a RADIO_HandleTypeDef structure that contains + * the configuration information for RADIO module + * @retval None + */ +__weak void HAL_RADIO_MspDeInit(RADIO_HandleTypeDef *hradio) +{ + /* Prevent unused argument(s) compilation warning */ + UNUSED(hradio); + + /* NOTE : This function Should not be modified, when the callback is needed, + the HAL_RADIO_MspDeInit could be implemented in the user file + */ +} + __weak void HAL_RADIO_TxRxCallback(uint32_t flags) { } +__weak void HAL_RADIO_RRMCallback(uint32_t ble_irq_status) +{ +} __weak void HAL_RADIO_TxRxSeqCallback(void) { @@ -1762,7 +1761,7 @@ void HAL_RADIO_TXRX_IRQHandler(void) uint32_t blue_status = BLUE->STATUSREG; uint32_t blue_interrupt = BLUE->INTERRUPT1REG; - /** clear all pending interrupts */ + /* clear all pending interrupts */ BLUE->INTERRUPT1REG = blue_interrupt; HAL_RADIO_TIMER_EndOfRadioActivityIsr(); @@ -1783,6 +1782,19 @@ void HAL_RADIO_TXRX_IRQHandler(void) blue_interrupt = BLUE->INTERRUPT1REG; } +void HAL_RADIO_RRM_IRQHandler(void) +{ + uint32_t ble_irq_status = RRM->BLE_IRQ_STATUS; + + /* Clear RRM Status register */ + RRM->BLE_IRQ_STATUS = ble_irq_status; + + HAL_RADIO_RRMCallback(ble_irq_status); + + /* Ensure flag is cleared */ + ble_irq_status = RRM->BLE_IRQ_STATUS; +} + void HAL_RADIO_TXRX_SEQ_IRQHandler(void) { diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio_timer.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio_timer.c index c853200be..f34bbafec 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio_timer.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_radio_timer.c @@ -53,7 +53,6 @@ /* Includes ------------------------------------------------------------------*/ #include "stm32wb0x_hal.h" - /** @addtogroup STM32WB0x_HAL_Driver * @{ */ @@ -72,6 +71,7 @@ typedef struct { uint8_t periodicCalibration; /*!< Periodic calibration enable status */ uint32_t periodicCalibrationInterval; /*!< Periodic calibration interval in ms, to disable set to 0 */ + uint32_t periodicCalibrationIntervalMTU; /*!< Periodic calibration interval in Machine Time Unit, to disable set to 0 */ bool calibration_in_progress; /*!< Flag to indicate that a periodic calibration has been started */ } CalibrationSettingsTypeDef; @@ -82,8 +82,7 @@ typedef struct int32_t freq1; /** Round(((freq/64)*0x753)/256) */ int32_t period1; /** Round (( ((period /256) * 0x8BCF6) + (((period % 256)* 0x8BCF6)/256)) / 32) */ int32_t last_period1; /** Period global in last calibration */ - uint64_t last_calibration_time; /** Absolute system time when last calibration was performed */ - uint32_t calibration_machine_interval; /** Calibration Interval MTU */ + uint64_t nextCalibrationEvent; /** Absolute system time when next calibration will be performed */ uint8_t calibration_data_available; /** Flag to signal if a new calibration data is available or not */ } CalibrationDataTypeDef; @@ -115,9 +114,10 @@ typedef struct VTIMER_HandleType calibrationTimer; RADIO_TIMER_RadioHandleTypeDef radioTimer; uint32_t hs_startup_time; /*!< HS startup time */ - uint64_t cumulative_time; /** Absolute system time since power up */ - uint64_t last_system_time; /** Last System Time */ - uint32_t last_machine_time; /** Last machine time used to update cumulative time */ + uint64_t last_calib_system_time; /** Absolute system time of last calibration since power up */ + uint32_t last_calib_machine_time; /** Last calibration machine time used to update cumulative time */ + uint64_t last_system_time; /** Last System Time since power up*/ + uint32_t last_machine_time; /** Last Machine Time used paired with last_system_time */ uint8_t last_setup_time; /**setup time of last timer programmed*/ uint32_t last_anchor_mt; VTIMER_HandleType *rootNode; /*!< First timer of the host timer queue */ @@ -149,7 +149,13 @@ typedef struct * It is expressed in STU. */ #define RADIO_ACTIVITY_MARGIN (204800) +/* Time after that calibration should be completed + * It is expressed in STU.*/ + +#define CALIBRATION_CHECK_DURATION (100) + /* Threshold to take into account the calibration duration. */ + #define CALIB_SAFE_THR (370) /* Minimum threshold to safely program the radio timer (expressed in STU) */ @@ -184,6 +190,9 @@ it is not sure the timer can be cleared properly */ #define RADIO_TX_RX_EXCEPTION_NUMBER 18 #endif +/* This is the maximum timeout that can be used to program a timer with 32 bits */ +#define HAL_RADIO_TIMER_MAX_32BIT_TIMEOUT (0xFFFFFFFF - 410) + /** * @} */ @@ -258,19 +267,19 @@ static void _updateCalibrationData(void); static uint32_t _us_to_systime(uint32_t time); static uint32_t _us_to_machinetime(uint32_t time); -static void _configureTxRxDelay(RADIO_TIMER_ContextTypeDef *context, uint8_t calculate_st); +static void _configureTxRxDelay(uint8_t calculate_st); static void _update_xtal_startup_time(uint16_t hs_startup_time, int32_t freq1); uint32_t blue_unit_conversion(uint32_t time, uint32_t period_freq, uint32_t thr); /* Translate MTU to STU and vice-versa. It is implemented using integer operation. */ -static uint64_t _get_system_time_and_machine(RADIO_TIMER_ContextTypeDef *context, uint32_t *current_machine_time); +static void _update_calibration_time(void); +static void _update_system_and_machine_time(void); static int32_t _start_timer(VTIMER_HandleType *timerHandle, uint64_t time); static VTIMER_HandleType *_update_user_timeout(VTIMER_HandleType *rootNode, uint8_t *expired); static VTIMER_HandleType *_insert_timer_in_queue(VTIMER_HandleType *rootNode, VTIMER_HandleType *handle); static void _virtualTimeBaseEnable(FunctionalState state); static VTIMER_HandleType *_remove_timer_in_queue(VTIMER_HandleType *rootNode, VTIMER_HandleType *handle); static VTIMER_HandleType *_check_callbacks(VTIMER_HandleType *rootNode, VTIMER_HandleType **expiredList); -static void _update_system_time(RADIO_TIMER_ContextTypeDef *context); -static void _check_radio_activity(RADIO_TIMER_RadioHandleTypeDef *timerHandle, uint8_t *expired); +static uint8_t _check_radio_activity(uint8_t update_sys_time); #if defined (STM32WB06) || defined (STM32WB07) static uint32_t TIMER_SetRadioHostWakeupTime(uint32_t delay, bool *share); static void _set_controller_as_host(void); @@ -278,7 +287,7 @@ static void _check_host_activity(void); #else static uint32_t VTIMER_SetWakeupTime(uint32_t delay, bool allow_sleep); #endif -static uint8_t TIMER_SetRadioTimerValue(uint32_t timeout, bool event_type, bool cal_req); +static uint8_t TIMER_SetRadioTimerValue(void); static uint64_t TIMER_GetPastSysTime(uint32_t time, uint64_t *current_system_time); static bool TIMER_SleepCheck(void); static uint8_t TIMER_GetRadioTimerValue(uint32_t *time); @@ -347,12 +356,11 @@ void HAL_RADIO_TIMER_Init(RADIO_TIMER_InitTypeDef *RADIO_TIMER_InitStruct) /* Init Radio Timer Context */ RADIO_TIMER_Context.last_setup_time = 0; - RADIO_TIMER_Context.cumulative_time = 0; - RADIO_TIMER_Context.last_machine_time = LL_RADIO_TIMER_GetAbsoluteTime(WAKEUP); + RADIO_TIMER_Context.last_calib_system_time = 0; + RADIO_TIMER_Context.last_calib_machine_time = LL_RADIO_TIMER_GetAbsoluteTime(WAKEUP); RADIO_TIMER_Context.last_system_time = 0; - RADIO_TIMER_Context.calibrationData.last_calibration_time = 0; RADIO_TIMER_Context.calibrationData.calibration_data_available = 0; - RADIO_TIMER_Context.calibrationData.calibration_machine_interval = blue_unit_conversion(RADIO_TIMER_Context.calibrationSettings.periodicCalibrationInterval, + RADIO_TIMER_Context.calibrationSettings.periodicCalibrationIntervalMTU = blue_unit_conversion(RADIO_TIMER_Context.calibrationSettings.periodicCalibrationInterval, RADIO_TIMER_Context.calibrationData.freq1, MULT64_THR_FREQ); RADIO_TIMER_Context.wakeup_calibration = RADIO_TIMER_Context.calibrationSettings.periodicCalibration; @@ -374,9 +382,8 @@ void HAL_RADIO_TIMER_Init(RADIO_TIMER_InitTypeDef *RADIO_TIMER_InitStruct) RADIO_TIMER_Context.calibrationTimer.userData = NULL; _start_timer(&RADIO_TIMER_Context.calibrationTimer, HAL_RADIO_TIMER_GetCurrentSysTime() + RADIO_TIMER_Context.calibrationSettings.periodicCalibrationInterval); - /* Tx & Rx delay configuration */ - _configureTxRxDelay(&RADIO_TIMER_Context, TRUE); + _configureTxRxDelay(TRUE); } /** @@ -389,16 +396,6 @@ void HAL_RADIO_TIMER_Tick(void) { uint8_t expired = 0; - ATOMIC_SECTION_BEGIN(); - if (RADIO_TIMER_Context.radioTimer.active) - { - if (RADIO_TIMER_Context.radioTimer.expiryTime < HAL_RADIO_TIMER_GetCurrentSysTime()) - { - RADIO_TIMER_Context.radioTimer.active = FALSE; - } - } - ATOMIC_SECTION_END(); - /* Check for expired timers */ while (DIFF8(RADIO_TIMER_Context.expired_count, RADIO_TIMER_Context.served_count)) { @@ -445,12 +442,6 @@ void HAL_RADIO_TIMER_Tick(void) { /* Collect calibration data */ _updateCalibrationData(); - RADIO_TIMER_Context.rootNode = _update_user_timeout(RADIO_TIMER_Context.rootNode, &expired); - if (expired == 1) - { - /* A new root timer is already expired, mimic timer expire */ - INCREMENT_EXPIRE_COUNT; - } } #if defined (STM32WB06) || defined (STM32WB07) @@ -458,20 +449,12 @@ void HAL_RADIO_TIMER_Tick(void) { RADIO_TIMER_Context.waitCal = 0; RADIO_TIMER_Context.radioTimer.pending = TRUE; - _check_radio_activity(&RADIO_TIMER_Context.radioTimer, &expired); - RADIO_TIMER_Context.rootNode = _update_user_timeout(RADIO_TIMER_Context.rootNode, &expired); - if (expired == 1) - { - /* A new root timer is already expired, mimic timer expire */ - INCREMENT_EXPIRE_COUNT; - } } -#else - _check_radio_activity(&RADIO_TIMER_Context.radioTimer, &expired); #endif + _check_radio_activity(TRUE); //Start Radio Timer after calibration - HAL_RADIO_TIMER_StopVirtualTimer(&RADIO_TIMER_Context.calibrationTimer); /* Schedule next calibration event */ + HAL_RADIO_TIMER_StopVirtualTimer(&RADIO_TIMER_Context.calibrationTimer); _start_timer(&RADIO_TIMER_Context.calibrationTimer, HAL_RADIO_TIMER_GetCurrentSysTime() + RADIO_TIMER_Context.calibrationSettings.periodicCalibrationInterval); } @@ -481,9 +464,10 @@ void HAL_RADIO_TIMER_Tick(void) { if (RADIO_TIMER_Context.calibrationSettings.periodicCalibration) { - if (HAL_RADIO_TIMER_GetCurrentSysTime() > (RADIO_TIMER_Context.calibrationData.last_calibration_time + + if (HAL_RADIO_TIMER_GetCurrentSysTime() > (RADIO_TIMER_Context.last_calib_system_time + TIMER_SYSTICK_PER_FIVE_SECONDS)) { + HAL_RADIO_TIMER_StopVirtualTimer(&RADIO_TIMER_Context.calibrationTimer); _calibration_callback(&RADIO_TIMER_Context.calibrationTimer); } } @@ -602,37 +586,40 @@ PowerSaveLevels HAL_RADIO_TIMER_PowerSaveLevelCheck(void) * @param event_type: Specify if it is a TX (1) or RX (0) event. * @param cal_req: Specify if PLL calibration is requested (1) or not (0). * @retval 0 if radio activity has been scheduled successfully. - * @retval 1 if radio activity has been rejected (it is too close or in the past). + * @retval 1 if radio activity has been rejected. */ uint32_t HAL_RADIO_TIMER_SetRadioTimerValue(uint32_t time, uint8_t event_type, uint8_t cal_req) { uint8_t retVal = 0; -#if defined (STM32WB06) || defined (STM32WB07) - uint64_t current_time; -#endif RADIO_TIMER_Context.radioTimer.event_type = event_type; RADIO_TIMER_Context.radioTimer.cal_req = cal_req; - RADIO_TIMER_Context.radioTimer.expiryTime = RADIO_TIMER_Context.calibrationData.last_calibration_time + (uint32_t)(time - (uint32_t)RADIO_TIMER_Context.calibrationData.last_calibration_time); RADIO_TIMER_Context.radioTimer.active = FALSE; RADIO_TIMER_Context.radioTimer.intTxRx_to_be_served = FALSE; RADIO_TIMER_Context.radioTimer.pending = TRUE; + ATOMIC_SECTION_BEGIN(); + RADIO_TIMER_Context.radioTimer.expiryTime = HAL_RADIO_TIMER_GetFutureSysTime64(time); + if(RADIO_TIMER_Context.radioTimer.expiryTime - RADIO_TIMER_Context.last_system_time > HAL_RADIO_TIMER_MAX_32BIT_TIMEOUT) + { + RADIO_TIMER_Context.radioTimer.pending = FALSE; + ATOMIC_SECTION_END(); + return 1; + } #if defined (STM32WB06) || defined (STM32WB07) - current_time = HAL_RADIO_TIMER_GetCurrentSysTime(); if (RADIO_TIMER_Context.rootNode == NULL) { - _check_radio_activity(&RADIO_TIMER_Context.radioTimer, &retVal); + retVal = _check_radio_activity(FALSE); } else { - if (RADIO_TIMER_Context.rootNode->expiryTime < current_time || + if (RADIO_TIMER_Context.rootNode->expiryTime < RADIO_TIMER_Context.last_system_time || ((RADIO_TIMER_Context.radioTimer.expiryTime < (RADIO_TIMER_Context.rootNode->expiryTime + RADIO_TIMER_Context.hostMargin)) && RADIO_TIMER_Context.rootNode->active) || !RADIO_TIMER_Context.rootNode->active) { /* Program the radio timer */ - _check_radio_activity(&RADIO_TIMER_Context.radioTimer, &retVal); + retVal = _check_radio_activity(FALSE); if ((RADIO_TIMER_Context.radioTimer.expiryTime >= RADIO_TIMER_Context.rootNode->expiryTime) && RADIO_TIMER_Context.rootNode->active) { @@ -646,14 +633,15 @@ uint32_t HAL_RADIO_TIMER_SetRadioTimerValue(uint32_t time, uint8_t event_type, u Make sure radio errors are disabled. This call is not needed if radio errors are not enabled by the BLE stack. */ _set_controller_as_host(); + _check_host_activity(); } } #else - _check_radio_activity(&RADIO_TIMER_Context.radioTimer, &retVal); + retVal = _check_radio_activity(FALSE); #endif + ATOMIC_SECTION_END(); _virtualTimeBaseEnable(ENABLE); - return retVal; } @@ -797,9 +785,9 @@ uint32_t HAL_RADIO_TIMER_ClearRadioTimerValue(void) /** * @brief Program the radio timer (a.k.a Timer1) as close as possible. - * The current time is sampled and increased by two. + * The current time is sampled and increased by 4. * It means that the timer is going to trigger in a timer interval that goes - * from one to two machine time units. + * from three to four time units. */ void HAL_RADIO_TIMER_SetRadioCloseTimeout(void) { @@ -807,7 +795,7 @@ void HAL_RADIO_TIMER_SetRadioCloseTimeout(void) ATOMIC_SECTION_BEGIN(); current_time = LL_RADIO_TIMER_GetAbsoluteTime(WAKEUP); - LL_RADIO_TIMER_SetTimeout(BLUE, ((current_time + 2) & TIMER_MAX_VALUE)); + LL_RADIO_TIMER_SetTimeout(BLUE, ((current_time + 4) & TIMER_MAX_VALUE)); LL_RADIO_TIMER_EnableTimer1(BLUE); ATOMIC_SECTION_END(); } @@ -832,7 +820,12 @@ void HAL_RADIO_TIMER_RadioTimerIsr(void) */ void HAL_RADIO_TIMER_EndOfRadioActivityIsr(void) { + if (RADIO_TIMER_Context.radioTimer.active) + { + RADIO_TIMER_Context.radioTimer.active = FALSE; + } RADIO_TIMER_Context.radioTimer.intTxRx_to_be_served = FALSE; + } /* ----------------------- Radio Timer time unit APIs ------------------------*/ @@ -868,8 +861,8 @@ uint32_t HAL_RADIO_TIMER_MachineTimeToSysTime(uint32_t time) */ uint64_t HAL_RADIO_TIMER_GetCurrentSysTime(void) { - uint32_t current_machine_time; - return _get_system_time_and_machine(&RADIO_TIMER_Context, ¤t_machine_time); + _update_system_and_machine_time(); + return RADIO_TIMER_Context.last_system_time; } /** @@ -976,9 +969,10 @@ uint64_t HAL_RADIO_TIMER_ExpiryTime(VTIMER_HandleType *timerHandle) void HAL_RADIO_TIMER_WakeUpCallback(void) { volatile uint32_t status = 0; - uint8_t expired; UNUSED(status); - _check_radio_activity(&RADIO_TIMER_Context.radioTimer, &expired); + + _check_radio_activity(TRUE); + if (RADIO_TIMER_Context.hostIsRadioPending) { RADIO_TIMER_Context.hostIsRadioPending = 0; @@ -1038,7 +1032,7 @@ uint64_t HAL_RADIO_TIMER_GetSysTime64(uint32_t sys_time) { uint64_t time; - time = RADIO_TIMER_Context.calibrationData.last_calibration_time + (uint32_t)(sys_time - (uint32_t)RADIO_TIMER_Context.calibrationData.last_calibration_time); + time = RADIO_TIMER_Context.last_calib_system_time + (uint32_t)(sys_time - (uint32_t)RADIO_TIMER_Context.last_calib_system_time); return time; } @@ -1052,13 +1046,11 @@ uint64_t HAL_RADIO_TIMER_GetSysTime64(uint32_t sys_time) */ uint64_t HAL_RADIO_TIMER_GetFutureSysTime64(uint32_t sys_time) { - uint64_t current_time; uint32_t sysTime_ms32b; + _update_system_and_machine_time(); + sysTime_ms32b = RADIO_TIMER_Context.last_system_time >> 32; /* Most significant 32 bits of sysTime64 */ - current_time = HAL_RADIO_TIMER_GetCurrentSysTime(); - sysTime_ms32b = current_time >> 32; /* Most significant 32 bits of sysTime64 */ - - if (sys_time < (uint32_t)current_time) + if (sys_time < (uint32_t)RADIO_TIMER_Context.last_system_time) { /* Need to get most signicant 32 bits of current time increased by one */ sysTime_ms32b++; @@ -1144,22 +1136,22 @@ static void _get_calibration_data(CalibrationDataTypeDef *calibrationData) calibrationData->freq = freq; } -static void _configureTxRxDelay(RADIO_TIMER_ContextTypeDef *context, uint8_t calculate_st) +static void _configureTxRxDelay(uint8_t calculate_st) { uint8_t tx_delay_start; tx_delay_start = (BLUEGLOB->TXDELAYSTART * 125 / 1000) + 1; - BLUEGLOB->WAKEUPINITDELAY = blue_unit_conversion(WAKEUP_INIT_DELAY, context->calibrationData.freq1, MULT64_THR_FREQ); - context->TxRxDelay.tim12_delay_mt = _us_to_machinetime(BLUEGLOB->TIMER12INITDELAYCAL); - context->TxRxDelay.tx_cal_delay = _us_to_machinetime(BLUEGLOB->TRANSMITCALDELAYCHK + tx_delay_start); - context->TxRxDelay.tx_no_cal_delay = _us_to_machinetime(BLUEGLOB->TRANSMITNOCALDELAYCHK + tx_delay_start); - context->TxRxDelay.rx_cal_delay = _us_to_machinetime(BLUEGLOB->RECEIVECALDELAYCHK); - context->TxRxDelay.rx_no_cal_delay = _us_to_machinetime(BLUEGLOB->RECEIVENOCALDELAYCHK); + BLUEGLOB->WAKEUPINITDELAY = blue_unit_conversion(WAKEUP_INIT_DELAY, RADIO_TIMER_Context.calibrationData.freq1, MULT64_THR_FREQ); + RADIO_TIMER_Context.TxRxDelay.tim12_delay_mt = _us_to_machinetime(BLUEGLOB->TIMER12INITDELAYCAL); + RADIO_TIMER_Context.TxRxDelay.tx_cal_delay = _us_to_machinetime(BLUEGLOB->TRANSMITCALDELAYCHK + tx_delay_start); + RADIO_TIMER_Context.TxRxDelay.tx_no_cal_delay = _us_to_machinetime(BLUEGLOB->TRANSMITNOCALDELAYCHK + tx_delay_start); + RADIO_TIMER_Context.TxRxDelay.rx_cal_delay = _us_to_machinetime(BLUEGLOB->RECEIVECALDELAYCHK); + RADIO_TIMER_Context.TxRxDelay.rx_no_cal_delay = _us_to_machinetime(BLUEGLOB->RECEIVENOCALDELAYCHK); if (calculate_st) { - context->TxRxDelay.tx_cal_delay_st = _us_to_systime(BLUEGLOB->TRANSMITCALDELAYCHK + tx_delay_start) + WAKEUP_INIT_DELAY; + RADIO_TIMER_Context.TxRxDelay.tx_cal_delay_st = _us_to_systime(BLUEGLOB->TRANSMITCALDELAYCHK + tx_delay_start) + WAKEUP_INIT_DELAY; } } @@ -1198,11 +1190,15 @@ static void _update_xtal_startup_time(uint16_t hs_startup_time, int32_t freq1) static void _calibration_callback(void *handle) { - if (RADIO_TIMER_Context.calibrationSettings.periodicCalibration) + if(RADIO_TIMER_Context.calibrationSettings.calibration_in_progress == FALSE) { - _timer_start_calibration(); + if (RADIO_TIMER_Context.calibrationSettings.periodicCalibration) + { + _timer_start_calibration(); + } + RADIO_TIMER_Context.calibrationSettings.calibration_in_progress = TRUE; } - RADIO_TIMER_Context.calibrationSettings.calibration_in_progress = TRUE; + _start_timer(&RADIO_TIMER_Context.calibrationTimer, HAL_RADIO_TIMER_GetCurrentSysTime() + CALIBRATION_CHECK_DURATION); } static int32_t _start_timer(VTIMER_HandleType *timerHandle, uint64_t time) @@ -1226,27 +1222,33 @@ static int32_t _start_timer(VTIMER_HandleType *timerHandle, uint64_t time) INCREMENT_EXPIRE_COUNT; } } + #if defined (STM32WB06) || defined (STM32WB07) + else + { + _check_host_activity(); + } + #endif + return expired; } -static uint64_t _get_system_time_and_machine(RADIO_TIMER_ContextTypeDef *context, uint32_t *current_machine_time) +static void _update_system_and_machine_time(void) { uint32_t difftime; uint64_t new_time; ATOMIC_SECTION_BEGIN(); - new_time = context->cumulative_time; - *current_machine_time = LL_RADIO_TIMER_GetAbsoluteTime(WAKEUP); - difftime = TIME_ABSDIFF(*current_machine_time, context->last_machine_time); - new_time += blue_unit_conversion(difftime, context->calibrationData.period1, MULT64_THR_PERIOD); - if (new_time < context->last_system_time) + new_time = RADIO_TIMER_Context.last_calib_system_time; + RADIO_TIMER_Context.last_machine_time = LL_RADIO_TIMER_GetAbsoluteTime(WAKEUP); + difftime = TIME_ABSDIFF(RADIO_TIMER_Context.last_machine_time, RADIO_TIMER_Context.last_calib_machine_time); + new_time += blue_unit_conversion(difftime, RADIO_TIMER_Context.calibrationData.period1, MULT64_THR_PERIOD); + if (new_time < RADIO_TIMER_Context.last_system_time) { - new_time += blue_unit_conversion(TIMER_MAX_VALUE, context->calibrationData.period1, MULT64_THR_PERIOD); + new_time += blue_unit_conversion(TIMER_MAX_VALUE, RADIO_TIMER_Context.calibrationData.period1, MULT64_THR_PERIOD); } - context->last_system_time = new_time; + RADIO_TIMER_Context.last_system_time = new_time; ATOMIC_SECTION_END(); - return new_time; } /* Set timeout and skip non active timers */ @@ -1261,12 +1263,12 @@ static VTIMER_HandleType *_update_user_timeout(VTIMER_HandleType *rootNode, uint if (curr->active) { ATOMIC_SECTION_BEGIN(); + _update_system_and_machine_time(); #if defined (STM32WB06) || defined (STM32WB07) - uint8_t dummy; bool share = FALSE; - _check_radio_activity(&RADIO_TIMER_Context.radioTimer, &dummy); + uint8_t dummy = _check_radio_activity(FALSE); #endif - delay = curr->expiryTime - HAL_RADIO_TIMER_GetCurrentSysTime(); + delay = curr->expiryTime - RADIO_TIMER_Context.last_system_time; if (delay > 0) { /* Protection against interrupt must be used to avoid that the called function will be interrupted @@ -1454,40 +1456,51 @@ static void _updateCalibrationData(void) { if (RADIO_TIMER_Context.calibrationSettings.periodicCalibration) { - _get_calibration_data(&RADIO_TIMER_Context.calibrationData); - _update_xtal_startup_time(RADIO_TIMER_Context.hs_startup_time, RADIO_TIMER_Context.calibrationData.freq1); - _configureTxRxDelay(&RADIO_TIMER_Context, FALSE); + + CalibrationDataTypeDef updatedCalibrationData; + _get_calibration_data(&updatedCalibrationData); + _update_xtal_startup_time(RADIO_TIMER_Context.hs_startup_time, updatedCalibrationData.freq1); + + ATOMIC_SECTION_BEGIN(); RADIO_TIMER_Context.calibrationData.calibration_data_available = 1; + RADIO_TIMER_Context.calibrationData.freq = updatedCalibrationData.freq; + RADIO_TIMER_Context.calibrationData.freq1 = updatedCalibrationData.freq1; + RADIO_TIMER_Context.calibrationData.period = updatedCalibrationData.period; + RADIO_TIMER_Context.calibrationData.period1 = updatedCalibrationData.period1; + _update_calibration_time(); + ATOMIC_SECTION_END(); + + _configureTxRxDelay(FALSE); } + else + { ATOMIC_SECTION_BEGIN(); - _update_system_time(&RADIO_TIMER_Context); + _update_calibration_time(); ATOMIC_SECTION_END(); + } } -/* This function update the system time after a calibration. +/* This function update the cumulative time after a calibration. * If the user calls too often this function, you could have rounding issues in the integer maths. */ -static void _update_system_time(RADIO_TIMER_ContextTypeDef *context) +static void _update_calibration_time(void) { - uint32_t current_machine_time; - uint32_t period; - - current_machine_time = LL_RADIO_TIMER_GetAbsoluteTime(WAKEUP); - period = context->calibrationData.last_period1; - context->cumulative_time = context->calibrationData.last_calibration_time + \ - blue_unit_conversion(TIME_ABSDIFF(current_machine_time, - context->last_machine_time), - period, MULT64_THR_PERIOD); + RADIO_TIMER_Context.last_machine_time = LL_RADIO_TIMER_GetAbsoluteTime(WAKEUP); + RADIO_TIMER_Context.last_calib_system_time += blue_unit_conversion(TIME_ABSDIFF(RADIO_TIMER_Context.last_machine_time, + RADIO_TIMER_Context.last_calib_machine_time), + RADIO_TIMER_Context.calibrationData.last_period1, + MULT64_THR_PERIOD); - if ((context->calibrationSettings.periodicCalibration == 0) - && (TIME_ABSDIFF(current_machine_time, - context->last_machine_time) < context->calibrationData.calibration_machine_interval)) + if ((RADIO_TIMER_Context.calibrationSettings.periodicCalibration == 0) //LSE + && (TIME_ABSDIFF(RADIO_TIMER_Context.last_machine_time, + RADIO_TIMER_Context.last_calib_machine_time) < RADIO_TIMER_Context.calibrationSettings.periodicCalibrationIntervalMTU)) { - context->cumulative_time += blue_unit_conversion(TIMER_MAX_VALUE, period, MULT64_THR_PERIOD); + RADIO_TIMER_Context.last_calib_system_time += blue_unit_conversion(TIMER_MAX_VALUE, RADIO_TIMER_Context.calibrationData.last_period1, MULT64_THR_PERIOD); } - context->last_machine_time = current_machine_time; - context->calibrationData.last_calibration_time = context->cumulative_time; - context->calibrationData.last_period1 = context->calibrationData.period1; + RADIO_TIMER_Context.last_system_time = RADIO_TIMER_Context.last_calib_system_time; + RADIO_TIMER_Context.last_calib_machine_time = RADIO_TIMER_Context.last_machine_time; + RADIO_TIMER_Context.calibrationData.nextCalibrationEvent = RADIO_TIMER_Context.last_calib_system_time + RADIO_TIMER_Context.calibrationSettings.periodicCalibrationInterval; + RADIO_TIMER_Context.calibrationData.last_period1 = RADIO_TIMER_Context.calibrationData.period1; } /* Check if it is time to program the pending radio timer (large timeouts). @@ -1498,45 +1511,45 @@ static void _update_system_time(RADIO_TIMER_ContextTypeDef *context) The check on the next calibration event is made even though the calibration is disabled (max cal. interval) in order to avoid counter wrapping with timeouts far in the future. */ -static void _check_radio_activity(RADIO_TIMER_RadioHandleTypeDef *timerHandle, uint8_t *expired) +static uint8_t _check_radio_activity(uint8_t update_sys_time) { - uint64_t nextCalibrationEvent, currentTime; - *expired = 0; - if (timerHandle->pending) + uint8_t expired = 0; + if (RADIO_TIMER_Context.radioTimer.pending) { - nextCalibrationEvent = RADIO_TIMER_Context.calibrationData.last_calibration_time + \ - RADIO_TIMER_Context.calibrationSettings.periodicCalibrationInterval; - ATOMIC_SECTION_BEGIN(); - currentTime = HAL_RADIO_TIMER_GetCurrentSysTime(); - if ((timerHandle->expiryTime < (nextCalibrationEvent + RADIO_ACTIVITY_MARGIN)) || \ - (currentTime > (nextCalibrationEvent + CALIB_SAFE_THR))) + if(update_sys_time == TRUE) { - if (timerHandle->expiryTime - TIMER1_INIT_DELAY > (currentTime + TIMER1_MARGIN)) + _update_system_and_machine_time(); + } + + if ((RADIO_TIMER_Context.radioTimer.expiryTime < (RADIO_TIMER_Context.calibrationData.nextCalibrationEvent + RADIO_ACTIVITY_MARGIN)) || \ + (RADIO_TIMER_Context.last_system_time > (RADIO_TIMER_Context.calibrationData.nextCalibrationEvent + CALIB_SAFE_THR))) + { + if (RADIO_TIMER_Context.radioTimer.expiryTime - TIMER1_INIT_DELAY > (RADIO_TIMER_Context.last_system_time + TIMER1_MARGIN)) { - *expired = TIMER_SetRadioTimerValue(timerHandle->expiryTime, timerHandle->event_type, timerHandle->cal_req); - timerHandle->pending = FALSE; /* timer has been served. No more pending */ - timerHandle->active = TRUE; /* timer has been programmed and it becomes ACTIVE */ - timerHandle->intTxRx_to_be_served = TRUE; + expired = TIMER_SetRadioTimerValue(); + RADIO_TIMER_Context.radioTimer.pending = FALSE; /* timer has been served. No more pending */ + RADIO_TIMER_Context.radioTimer.active = TRUE; /* timer has been programmed and it becomes ACTIVE */ + RADIO_TIMER_Context.radioTimer.intTxRx_to_be_served = TRUE; } else { RADIO_TIMER_Context.radioTimer.pending = FALSE; - *expired = 1; - + expired = 1; } } else { + #if defined (STM32WB06) || defined (STM32WB07) RADIO_TIMER_Context.waitCal = 1; #endif } ATOMIC_SECTION_END(); - } + return expired; } #if defined (STM32WB06) || defined (STM32WB07) @@ -1621,15 +1634,15 @@ static void _check_host_activity(void) * @retval 0 if a correct timeout has been programmed in the timeout register * @retval 1 if a correct timeout cannot be programmed */ -static uint8_t TIMER_SetRadioTimerValue(uint32_t timeout, bool event_type, bool cal_req) +static uint8_t TIMER_SetRadioTimerValue(void) { - uint32_t current_time, delay, radio_init_delay, device_delay, rel_timeout, rel_timeout_mt; + uint32_t delay, radio_init_delay, device_delay, rel_timeout, rel_timeout_mt; uint8_t ret_val; /*choose the 2nd init duration. Check the event_type and cal. request*/ - if (event_type == TX) + if (RADIO_TIMER_Context.radioTimer.event_type == TX) { - if (cal_req) + if (RADIO_TIMER_Context.radioTimer.cal_req) { radio_init_delay = RADIO_TIMER_Context.TxRxDelay.tx_cal_delay; device_delay = RADIO_TIMER_Context.TxRxDelay.tx_cal_delay_st; @@ -1642,7 +1655,7 @@ static uint8_t TIMER_SetRadioTimerValue(uint32_t timeout, bool event_type, bool } else { - if (cal_req) + if (RADIO_TIMER_Context.radioTimer.cal_req) { radio_init_delay = RADIO_TIMER_Context.TxRxDelay.rx_cal_delay; device_delay = RADIO_TIMER_Context.TxRxDelay.tx_cal_delay_st; @@ -1655,33 +1668,34 @@ static uint8_t TIMER_SetRadioTimerValue(uint32_t timeout, bool event_type, bool } /* At this point, it is care of the upper layers to guarantee that the timeout represents an absolute time in the future */ - rel_timeout = timeout - (uint32_t)_get_system_time_and_machine(&RADIO_TIMER_Context, ¤t_time); - + rel_timeout = (uint32_t)RADIO_TIMER_Context.radioTimer.expiryTime - (uint32_t)RADIO_TIMER_Context.last_system_time; rel_timeout_mt = blue_unit_conversion(rel_timeout, RADIO_TIMER_Context.calibrationData.freq1, MULT64_THR_FREQ); /*Check if the timeout is beyond the wakeup time offset. Then program either the WakeUp timer or the Timer1*/ if (rel_timeout > (device_delay + RADIO_TIMER_Context.hs_startup_time + MARGIN_EXT)) { /*The timeout is after the wakeup_time_offset, So it is ok to program the wakeup timer*/ + delay = rel_timeout_mt - BLUEGLOB->WAKEUPINITDELAY - radio_init_delay; - LL_RADIO_TIMER_SetBLEWakeupTime(WAKEUP, ((current_time + delay) & TIMER_MAX_VALUE)); + LL_RADIO_TIMER_SetBLEWakeupTime(WAKEUP, ((RADIO_TIMER_Context.last_machine_time + delay) & TIMER_MAX_VALUE)); LL_RADIO_TIMER_SetSleepRequestMode(WAKEUP, 0); LL_RADIO_TIMER_DisableTimer1(BLUE); LL_RADIO_TIMER_DisableTimer2(BLUE); LL_RADIO_TIMER_EnableBLEWakeupTimer(WAKEUP); LL_RADIO_TIMER_EnableWakeupTimerLowPowerMode(WAKEUP); radio_init_delay += BLUEGLOB->WAKEUPINITDELAY; + } else { delay = rel_timeout_mt - RADIO_TIMER_Context.TxRxDelay.tim12_delay_mt - radio_init_delay; - LL_RADIO_TIMER_SetTimeout(BLUE, ((current_time + delay) & TIMER_MAX_VALUE)); + LL_RADIO_TIMER_SetTimeout(BLUE, ((RADIO_TIMER_Context.last_machine_time + delay) & TIMER_MAX_VALUE)); LL_RADIO_TIMER_DisableBLEWakeupTimer(WAKEUP); LL_RADIO_TIMER_EnableTimer1(BLUE); radio_init_delay += RADIO_TIMER_Context.TxRxDelay.tim12_delay_mt; } - RADIO_TIMER_Context.last_anchor_mt = (current_time + rel_timeout_mt) & TIMER_MAX_VALUE; + RADIO_TIMER_Context.last_anchor_mt = (RADIO_TIMER_Context.last_machine_time + rel_timeout_mt) & TIMER_MAX_VALUE; #if defined (STM32WB06) || defined (STM32WB07) BLUEGLOB->BYTE4 |= 1 << 7; @@ -1715,11 +1729,12 @@ static uint8_t TIMER_SetRadioTimerValue(uint32_t timeout, bool event_type, bool */ static uint64_t TIMER_GetPastSysTime(uint32_t time, uint64_t *current_system_time) { - uint32_t delta_systime, current_machine_time; - - *current_system_time = _get_system_time_and_machine(&RADIO_TIMER_Context, ¤t_machine_time); - delta_systime = blue_unit_conversion(TIME_DIFF(current_machine_time, time), RADIO_TIMER_Context.calibrationData.period1, MULT64_THR_PERIOD); - + uint32_t delta_systime; + ATOMIC_SECTION_BEGIN(); + _update_system_and_machine_time(); + *current_system_time = RADIO_TIMER_Context.last_system_time; + delta_systime = blue_unit_conversion(TIME_DIFF(RADIO_TIMER_Context.last_machine_time, time), RADIO_TIMER_Context.calibrationData.period1, MULT64_THR_PERIOD); + ATOMIC_SECTION_END(); return (*current_system_time - delta_systime); } diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_rcc_ex.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_rcc_ex.c index d692fbc01..aeed5b687 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_rcc_ex.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_rcc_ex.c @@ -315,6 +315,8 @@ uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk) frequency = LSE_VALUE; break; case RCC_LPUART1_CLKSOURCE_16M: + frequency = 16000000U; + break; default: frequency = HSE_VALUE / 2; break; diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_spi.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_spi.c index 7761fe422..d53d3c0c8 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_spi.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_spi.c @@ -44,7 +44,8 @@ (+++) Configure the DMA handle parameters (+++) Configure the DMA Tx or Rx Stream/Channel (+++) Associate the initialized hdma_tx(or _rx) handle to the hspi DMA Tx or Rx handle - (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx or Rx Stream/Channel + (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx + or Rx Stream/Channel (#) Program the Mode, BidirectionalMode , Data size, Baudrate Prescaler, NSS management, Clock polarity and phase, FirstBit and CRC configuration in the hspi Init structure. @@ -190,7 +191,8 @@ @note The max SPI frequency depend on SPI data size (4bits, 5bits,..., 8bits,...15bits, 16bits), SPI mode(2 Lines fullduplex, 2 lines RxOnly, 1 line TX/RX) and Process mode (Polling, IT, DMA). @note - (#) TX/RX processes are HAL_SPI_TransmitReceive(), HAL_SPI_TransmitReceive_IT() and HAL_SPI_TransmitReceive_DMA() + (#) TX/RX processes are HAL_SPI_TransmitReceive(), HAL_SPI_TransmitReceive_IT() and + HAL_SPI_TransmitReceive_DMA() (#) RX processes are HAL_SPI_Receive(), HAL_SPI_Receive_IT() and HAL_SPI_Receive_DMA() (#) TX processes are HAL_SPI_Transmit(), HAL_SPI_Transmit_IT() and HAL_SPI_Transmit_DMA() @@ -813,43 +815,40 @@ HAL_StatusTypeDef HAL_SPI_UnRegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_Ca * @brief Transmit an amount of data in blocking mode. * @param hspi pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. - * @param pData pointer to data buffer - * @param Size amount of data to be sent - * @param Timeout Timeout duration + * @param pData pointer to data buffer (u8 or u16 data elements) + * @param Size amount of data elements (u8 or u16) to be sent + * @param Timeout Timeout duration in ms * @retval HAL status */ -HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout) +HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size, uint32_t Timeout) { uint32_t tickstart; - HAL_StatusTypeDef errorcode = HAL_OK; uint16_t initial_TxXferCount; /* Check Direction parameter */ assert_param(IS_SPI_DIRECTION_2LINES_OR_1LINE(hspi->Init.Direction)); - /* Process Locked */ - __HAL_LOCK(hspi); - /* Init tickstart for timeout management*/ tickstart = HAL_GetTick(); initial_TxXferCount = Size; if (hspi->State != HAL_SPI_STATE_READY) { - errorcode = HAL_BUSY; - goto error; + return HAL_BUSY; } if ((pData == NULL) || (Size == 0U)) { - errorcode = HAL_ERROR; - goto error; + return HAL_ERROR; } + /* Process Locked */ + __HAL_LOCK(hspi); + /* Set the transaction information */ hspi->State = HAL_SPI_STATE_BUSY_TX; hspi->ErrorCode = HAL_SPI_ERROR_NONE; - hspi->pTxBuffPtr = (uint8_t *)pData; + hspi->pTxBuffPtr = (const uint8_t *)pData; hspi->TxXferSize = Size; hspi->TxXferCount = Size; @@ -888,7 +887,7 @@ HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint { if ((hspi->Init.Mode == SPI_MODE_SLAVE) || (initial_TxXferCount == 0x01U)) { - hspi->Instance->DR = *((uint16_t *)hspi->pTxBuffPtr); + hspi->Instance->DR = *((const uint16_t *)hspi->pTxBuffPtr); hspi->pTxBuffPtr += sizeof(uint16_t); hspi->TxXferCount--; } @@ -898,7 +897,7 @@ HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint /* Wait until TXE flag is set to send data */ if (__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXE)) { - hspi->Instance->DR = *((uint16_t *)hspi->pTxBuffPtr); + hspi->Instance->DR = *((const uint16_t *)hspi->pTxBuffPtr); hspi->pTxBuffPtr += sizeof(uint16_t); hspi->TxXferCount--; } @@ -907,9 +906,9 @@ HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint /* Timeout management */ if ((((HAL_GetTick() - tickstart) >= Timeout) && (Timeout != HAL_MAX_DELAY)) || (Timeout == 0U)) { - errorcode = HAL_TIMEOUT; hspi->State = HAL_SPI_STATE_READY; - goto error; + __HAL_UNLOCK(hspi); + return HAL_TIMEOUT; } } } @@ -919,47 +918,27 @@ HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint { if ((hspi->Init.Mode == SPI_MODE_SLAVE) || (initial_TxXferCount == 0x01U)) { - if (hspi->TxXferCount > 1U) - { - /* write on the data register in packing mode */ - hspi->Instance->DR = *((uint16_t *)hspi->pTxBuffPtr); - hspi->pTxBuffPtr += sizeof(uint16_t); - hspi->TxXferCount -= 2U; - } - else - { - *((__IO uint8_t *)&hspi->Instance->DR) = (*hspi->pTxBuffPtr); - hspi->pTxBuffPtr ++; - hspi->TxXferCount--; - } + *((__IO uint8_t *)&hspi->Instance->DR) = *((const uint8_t *)hspi->pTxBuffPtr); + hspi->pTxBuffPtr += sizeof(uint8_t); + hspi->TxXferCount--; } while (hspi->TxXferCount > 0U) { /* Wait until TXE flag is set to send data */ if (__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXE)) { - if (hspi->TxXferCount > 1U) - { - /* write on the data register in packing mode */ - hspi->Instance->DR = *((uint16_t *)hspi->pTxBuffPtr); - hspi->pTxBuffPtr += sizeof(uint16_t); - hspi->TxXferCount -= 2U; - } - else - { - *((__IO uint8_t *)&hspi->Instance->DR) = (*hspi->pTxBuffPtr); - hspi->pTxBuffPtr++; - hspi->TxXferCount--; - } + *((__IO uint8_t *)&hspi->Instance->DR) = *((const uint8_t *)hspi->pTxBuffPtr); + hspi->pTxBuffPtr += sizeof(uint8_t); + hspi->TxXferCount--; } else { /* Timeout management */ if ((((HAL_GetTick() - tickstart) >= Timeout) && (Timeout != HAL_MAX_DELAY)) || (Timeout == 0U)) { - errorcode = HAL_TIMEOUT; hspi->State = HAL_SPI_STATE_READY; - goto error; + __HAL_UNLOCK(hspi); + return HAL_TIMEOUT; } } } @@ -984,29 +963,31 @@ HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint __HAL_SPI_CLEAR_OVRFLAG(hspi); } + hspi->State = HAL_SPI_STATE_READY; + /* Process Unlocked */ + __HAL_UNLOCK(hspi); + if (hspi->ErrorCode != HAL_SPI_ERROR_NONE) { - errorcode = HAL_ERROR; + return HAL_ERROR; } else { - hspi->State = HAL_SPI_STATE_READY; + return HAL_OK; } - -error: - /* Process Unlocked */ - __HAL_UNLOCK(hspi); - return errorcode; } /** * @brief Receive an amount of data in blocking mode. * @param hspi pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. - * @param pData pointer to data buffer - * @param Size amount of data to be received - * @param Timeout Timeout duration + * @param pData pointer to data buffer (u8 or u16 data elements) + * @param Size amount of data elements (u8 or u16) to be received + * @param Timeout Timeout duration in ms * @retval HAL status + * @note In master mode, if the direction is set to SPI_DIRECTION_2LINES + * the receive buffer is written to data register (DR) to generate + * clock pulses and receive data */ HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout) { @@ -1016,12 +997,15 @@ HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint1 __IO uint8_t tmpreg8 = 0; #endif /* USE_SPI_CRC */ uint32_t tickstart; - HAL_StatusTypeDef errorcode = HAL_OK; if (hspi->State != HAL_SPI_STATE_READY) { - errorcode = HAL_BUSY; - goto error; + return HAL_BUSY; + } + + if ((pData == NULL) || (Size == 0U)) + { + return HAL_ERROR; } if ((hspi->Init.Mode == SPI_MODE_MASTER) && (hspi->Init.Direction == SPI_DIRECTION_2LINES)) @@ -1031,17 +1015,11 @@ HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint1 return HAL_SPI_TransmitReceive(hspi, pData, pData, Size, Timeout); } - /* Process Locked */ - __HAL_LOCK(hspi); - /* Init tickstart for timeout management*/ tickstart = HAL_GetTick(); - if ((pData == NULL) || (Size == 0U)) - { - errorcode = HAL_ERROR; - goto error; - } + /* Process Locked */ + __HAL_LOCK(hspi); /* Set the transaction information */ hspi->State = HAL_SPI_STATE_BUSY_RX; @@ -1113,9 +1091,9 @@ HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint1 /* Timeout management */ if ((((HAL_GetTick() - tickstart) >= Timeout) && (Timeout != HAL_MAX_DELAY)) || (Timeout == 0U)) { - errorcode = HAL_TIMEOUT; hspi->State = HAL_SPI_STATE_READY; - goto error; + __HAL_UNLOCK(hspi); + return HAL_TIMEOUT; } } } @@ -1137,9 +1115,9 @@ HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint1 /* Timeout management */ if ((((HAL_GetTick() - tickstart) >= Timeout) && (Timeout != HAL_MAX_DELAY)) || (Timeout == 0U)) { - errorcode = HAL_TIMEOUT; hspi->State = HAL_SPI_STATE_READY; - goto error; + __HAL_UNLOCK(hspi); + return HAL_TIMEOUT; } } } @@ -1156,8 +1134,8 @@ HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint1 if (SPI_WaitFlagStateUntilTimeout(hspi, SPI_FLAG_RXNE, SET, Timeout, tickstart) != HAL_OK) { /* the latest data has not been received */ - errorcode = HAL_TIMEOUT; - goto error; + __HAL_UNLOCK(hspi); + return HAL_TIMEOUT; } /* Receive last data in 16 Bit mode */ @@ -1175,8 +1153,9 @@ HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint1 if (SPI_WaitFlagStateUntilTimeout(hspi, SPI_FLAG_RXNE, SET, Timeout, tickstart) != HAL_OK) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); - errorcode = HAL_TIMEOUT; - goto error; + hspi->State = HAL_SPI_STATE_READY; + __HAL_UNLOCK(hspi); + return HAL_TIMEOUT; } /* Read CRC to Flush DR and RXNE flag */ @@ -1202,8 +1181,9 @@ HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint1 { /* Error on the CRC reception */ SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); - errorcode = HAL_TIMEOUT; - goto error; + hspi->State = HAL_SPI_STATE_READY; + __HAL_UNLOCK(hspi); + return HAL_TIMEOUT; } /* Read 8bit CRC again in case of 16bit CRC in 8bit Data mode */ tmpreg8 = *ptmpreg8; @@ -1229,35 +1209,33 @@ HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint1 } #endif /* USE_SPI_CRC */ + hspi->State = HAL_SPI_STATE_READY; + /* Unlock the process */ + __HAL_UNLOCK(hspi); if (hspi->ErrorCode != HAL_SPI_ERROR_NONE) { - errorcode = HAL_ERROR; + return HAL_ERROR; } else { - hspi->State = HAL_SPI_STATE_READY; + return HAL_OK; } - -error : - __HAL_UNLOCK(hspi); - return errorcode; } /** * @brief Transmit and Receive an amount of data in blocking mode. * @param hspi pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. - * @param pTxData pointer to transmission data buffer - * @param pRxData pointer to reception data buffer - * @param Size amount of data to be sent and received - * @param Timeout Timeout duration + * @param pTxData pointer to transmission data buffer (u8 or u16 data elements) + * @param pRxData pointer to reception data buffer (u8 or u16 data elements) + * @param Size amount of data elements (u8 or u16) to be sent and received + * @param Timeout Timeout duration in ms * @retval HAL status */ -HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, - uint32_t Timeout) +HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData, + uint16_t Size, uint32_t Timeout) { uint16_t initial_TxXferCount; - uint16_t initial_RxXferCount; uint32_t tmp_mode; HAL_SPI_StateTypeDef tmp_state; uint32_t tickstart; @@ -1271,14 +1249,10 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD /* Variable used to alternate Rx and Tx during transfer */ uint32_t txallowed = 1U; - HAL_StatusTypeDef errorcode = HAL_OK; /* Check Direction parameter */ assert_param(IS_SPI_DIRECTION_2LINES(hspi->Init.Direction)); - /* Process Locked */ - __HAL_LOCK(hspi); - /* Init tickstart for timeout management*/ tickstart = HAL_GetTick(); @@ -1286,25 +1260,26 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD tmp_state = hspi->State; tmp_mode = hspi->Init.Mode; initial_TxXferCount = Size; - initial_RxXferCount = Size; #if (USE_SPI_CRC != 0U) spi_cr1 = READ_REG(hspi->Instance->CR1); spi_cr2 = READ_REG(hspi->Instance->CR2); #endif /* USE_SPI_CRC */ if (!((tmp_state == HAL_SPI_STATE_READY) || \ - ((tmp_mode == SPI_MODE_MASTER) && (hspi->Init.Direction == SPI_DIRECTION_2LINES) && (tmp_state == HAL_SPI_STATE_BUSY_RX)))) + ((tmp_mode == SPI_MODE_MASTER) && (hspi->Init.Direction == SPI_DIRECTION_2LINES) && + (tmp_state == HAL_SPI_STATE_BUSY_RX)))) { - errorcode = HAL_BUSY; - goto error; + return HAL_BUSY; } if ((pTxData == NULL) || (pRxData == NULL) || (Size == 0U)) { - errorcode = HAL_ERROR; - goto error; + return HAL_ERROR; } + /* Process Locked */ + __HAL_LOCK(hspi); + /* Don't overwrite in case of HAL_SPI_STATE_BUSY_RX */ if (hspi->State != HAL_SPI_STATE_BUSY_RX) { @@ -1316,7 +1291,7 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD hspi->pRxBuffPtr = (uint8_t *)pRxData; hspi->RxXferCount = Size; hspi->RxXferSize = Size; - hspi->pTxBuffPtr = (uint8_t *)pTxData; + hspi->pTxBuffPtr = (const uint8_t *)pTxData; hspi->TxXferCount = Size; hspi->TxXferSize = Size; @@ -1333,7 +1308,7 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD #endif /* USE_SPI_CRC */ /* Set the Rx Fifo threshold */ - if ((hspi->Init.DataSize > SPI_DATASIZE_8BIT) || (initial_RxXferCount > 1U)) + if (hspi->Init.DataSize > SPI_DATASIZE_8BIT) { /* Set fiforxthreshold according the reception data length: 16bit */ CLEAR_BIT(hspi->Instance->CR2, SPI_RXFIFO_THRESHOLD); @@ -1356,7 +1331,7 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD { if ((hspi->Init.Mode == SPI_MODE_SLAVE) || (initial_TxXferCount == 0x01U)) { - hspi->Instance->DR = *((uint16_t *)hspi->pTxBuffPtr); + hspi->Instance->DR = *((const uint16_t *)hspi->pTxBuffPtr); hspi->pTxBuffPtr += sizeof(uint16_t); hspi->TxXferCount--; @@ -1379,7 +1354,7 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD /* Check TXE flag */ if ((__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXE)) && (hspi->TxXferCount > 0U) && (txallowed == 1U)) { - hspi->Instance->DR = *((uint16_t *)hspi->pTxBuffPtr); + hspi->Instance->DR = *((const uint16_t *)hspi->pTxBuffPtr); hspi->pTxBuffPtr += sizeof(uint16_t); hspi->TxXferCount--; /* Next Data is a reception (Rx). Tx not allowed */ @@ -1410,9 +1385,9 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD } if (((HAL_GetTick() - tickstart) >= Timeout) && (Timeout != HAL_MAX_DELAY)) { - errorcode = HAL_TIMEOUT; hspi->State = HAL_SPI_STATE_READY; - goto error; + __HAL_UNLOCK(hspi); + return HAL_TIMEOUT; } } } @@ -1421,49 +1396,31 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD { if ((hspi->Init.Mode == SPI_MODE_SLAVE) || (initial_TxXferCount == 0x01U)) { - if (hspi->TxXferCount > 1U) - { - hspi->Instance->DR = *((uint16_t *)hspi->pTxBuffPtr); - hspi->pTxBuffPtr += sizeof(uint16_t); - hspi->TxXferCount -= 2U; - } - else - { - *(__IO uint8_t *)&hspi->Instance->DR = (*hspi->pTxBuffPtr); - hspi->pTxBuffPtr++; - hspi->TxXferCount--; + *((__IO uint8_t *)&hspi->Instance->DR) = *((const uint8_t *)hspi->pTxBuffPtr); + hspi->pTxBuffPtr += sizeof(uint8_t); + hspi->TxXferCount--; #if (USE_SPI_CRC != 0U) - /* Enable CRC Transmission */ - if ((hspi->TxXferCount == 0U) && (hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE)) + /* Enable CRC Transmission */ + if ((hspi->TxXferCount == 0U) && (hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE)) + { + /* Set NSS Soft to received correctly the CRC on slave mode with NSS pulse activated */ + if ((READ_BIT(spi_cr1, SPI_CR1_MSTR) == 0U) && (READ_BIT(spi_cr2, SPI_CR2_NSSP) == SPI_CR2_NSSP)) { - /* Set NSS Soft to received correctly the CRC on slave mode with NSS pulse activated */ - if ((READ_BIT(spi_cr1, SPI_CR1_MSTR) == 0U) && (READ_BIT(spi_cr2, SPI_CR2_NSSP) == SPI_CR2_NSSP)) - { - SET_BIT(hspi->Instance->CR1, SPI_CR1_SSM); - } - SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT); + SET_BIT(hspi->Instance->CR1, SPI_CR1_SSM); } -#endif /* USE_SPI_CRC */ + SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT); } +#endif /* USE_SPI_CRC */ } while ((hspi->TxXferCount > 0U) || (hspi->RxXferCount > 0U)) { /* Check TXE flag */ if ((__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXE)) && (hspi->TxXferCount > 0U) && (txallowed == 1U)) { - if (hspi->TxXferCount > 1U) - { - hspi->Instance->DR = *((uint16_t *)hspi->pTxBuffPtr); - hspi->pTxBuffPtr += sizeof(uint16_t); - hspi->TxXferCount -= 2U; - } - else - { - *(__IO uint8_t *)&hspi->Instance->DR = (*hspi->pTxBuffPtr); - hspi->pTxBuffPtr++; - hspi->TxXferCount--; - } + *(__IO uint8_t *)&hspi->Instance->DR = *((const uint8_t *)hspi->pTxBuffPtr); + hspi->pTxBuffPtr++; + hspi->TxXferCount--; /* Next Data is a reception (Rx). Tx not allowed */ txallowed = 0U; @@ -1484,31 +1441,17 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD /* Wait until RXNE flag is reset */ if ((__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_RXNE)) && (hspi->RxXferCount > 0U)) { - if (hspi->RxXferCount > 1U) - { - *((uint16_t *)hspi->pRxBuffPtr) = (uint16_t)hspi->Instance->DR; - hspi->pRxBuffPtr += sizeof(uint16_t); - hspi->RxXferCount -= 2U; - if (hspi->RxXferCount <= 1U) - { - /* Set RX Fifo threshold before to switch on 8 bit data size */ - SET_BIT(hspi->Instance->CR2, SPI_RXFIFO_THRESHOLD); - } - } - else - { - (*(uint8_t *)hspi->pRxBuffPtr) = *(__IO uint8_t *)&hspi->Instance->DR; - hspi->pRxBuffPtr++; - hspi->RxXferCount--; - } + (*(uint8_t *)hspi->pRxBuffPtr) = *(__IO uint8_t *)&hspi->Instance->DR; + hspi->pRxBuffPtr++; + hspi->RxXferCount--; /* Next Data is a Transmission (Tx). Tx is allowed */ txallowed = 1U; } if ((((HAL_GetTick() - tickstart) >= Timeout) && ((Timeout != HAL_MAX_DELAY))) || (Timeout == 0U)) { - errorcode = HAL_TIMEOUT; hspi->State = HAL_SPI_STATE_READY; - goto error; + __HAL_UNLOCK(hspi); + return HAL_TIMEOUT; } } } @@ -1522,8 +1465,9 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD { /* Error on the CRC reception */ SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); - errorcode = HAL_TIMEOUT; - goto error; + hspi->State = HAL_SPI_STATE_READY; + __HAL_UNLOCK(hspi); + return HAL_TIMEOUT; } /* Read CRC */ if (hspi->Init.DataSize == SPI_DATASIZE_16BIT) @@ -1548,8 +1492,9 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD { /* Error on the CRC reception */ SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); - errorcode = HAL_TIMEOUT; - goto error; + hspi->State = HAL_SPI_STATE_READY; + __HAL_UNLOCK(hspi); + return HAL_TIMEOUT; } /* Read 8bit CRC again in case of 16bit CRC in 8bit Data mode */ tmpreg8 = *ptmpreg8; @@ -1565,43 +1510,44 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); /* Clear CRC Flag */ __HAL_SPI_CLEAR_CRCERRFLAG(hspi); - - errorcode = HAL_ERROR; + __HAL_UNLOCK(hspi); + return HAL_ERROR; } #endif /* USE_SPI_CRC */ /* Check the end of the transaction */ if (SPI_EndRxTxTransaction(hspi, Timeout, tickstart) != HAL_OK) { - errorcode = HAL_ERROR; hspi->ErrorCode = HAL_SPI_ERROR_FLAG; + __HAL_UNLOCK(hspi); + return HAL_ERROR; } + + hspi->State = HAL_SPI_STATE_READY; + /* Unlock the process */ + __HAL_UNLOCK(hspi); + if (hspi->ErrorCode != HAL_SPI_ERROR_NONE) { - errorcode = HAL_ERROR; + return HAL_ERROR; } else { - hspi->State = HAL_SPI_STATE_READY; + return HAL_OK; } - -error : - __HAL_UNLOCK(hspi); - return errorcode; } /** * @brief Transmit an amount of data in non-blocking mode with Interrupt. * @param hspi pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. - * @param pData pointer to data buffer - * @param Size amount of data to be sent + * @param pData pointer to data buffer (u8 or u16 data elements) + * @param Size amount of data elements (u8 or u16) to be sent * @retval HAL status */ -HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size) +HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size) { - HAL_StatusTypeDef errorcode = HAL_OK; /* Check Direction parameter */ assert_param(IS_SPI_DIRECTION_2LINES_OR_1LINE(hspi->Init.Direction)); @@ -1609,14 +1555,12 @@ HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, u if ((pData == NULL) || (Size == 0U)) { - errorcode = HAL_ERROR; - goto error; + return HAL_ERROR; } if (hspi->State != HAL_SPI_STATE_READY) { - errorcode = HAL_BUSY; - goto error; + return HAL_BUSY; } /* Process Locked */ @@ -1625,7 +1569,7 @@ HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, u /* Set the transaction information */ hspi->State = HAL_SPI_STATE_BUSY_TX; hspi->ErrorCode = HAL_SPI_ERROR_NONE; - hspi->pTxBuffPtr = (uint8_t *)pData; + hspi->pTxBuffPtr = (const uint8_t *)pData; hspi->TxXferSize = Size; hspi->TxXferCount = Size; @@ -1673,27 +1617,28 @@ HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, u /* Enable TXE and ERR interrupt */ __HAL_SPI_ENABLE_IT(hspi, (SPI_IT_TXE | SPI_IT_ERR)); -error : - return errorcode; + return HAL_OK; } /** * @brief Receive an amount of data in non-blocking mode with Interrupt. * @param hspi pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. - * @param pData pointer to data buffer - * @param Size amount of data to be sent + * @param pData pointer to data buffer (u8 or u16 data elements) + * @param Size amount of data elements (u8 or u16) to be received * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size) { - HAL_StatusTypeDef errorcode = HAL_OK; - if (hspi->State != HAL_SPI_STATE_READY) { - errorcode = HAL_BUSY; - goto error; + return HAL_BUSY; + } + + if ((pData == NULL) || (Size == 0U)) + { + return HAL_ERROR; } if ((hspi->Init.Direction == SPI_DIRECTION_2LINES) && (hspi->Init.Mode == SPI_MODE_MASTER)) @@ -1704,12 +1649,6 @@ HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, ui } - if ((pData == NULL) || (Size == 0U)) - { - errorcode = HAL_ERROR; - goto error; - } - /* Process Locked */ __HAL_LOCK(hspi); @@ -1781,24 +1720,23 @@ HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, ui /* Enable RXNE and ERR interrupt */ __HAL_SPI_ENABLE_IT(hspi, (SPI_IT_RXNE | SPI_IT_ERR)); -error : - return errorcode; + return HAL_OK; } /** * @brief Transmit and Receive an amount of data in non-blocking mode with Interrupt. * @param hspi pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. - * @param pTxData pointer to transmission data buffer - * @param pRxData pointer to reception data buffer - * @param Size amount of data to be sent and received + * @param pTxData pointer to transmission data buffer (u8 or u16 data elements) + * @param pRxData pointer to reception data buffer (u8 or u16 data elements) + * @param Size amount of data elements (u8 or u16) to be sent and received * @retval HAL status */ -HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size) +HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData, + uint16_t Size) { uint32_t tmp_mode; HAL_SPI_StateTypeDef tmp_state; - HAL_StatusTypeDef errorcode = HAL_OK; /* Check Direction parameter */ assert_param(IS_SPI_DIRECTION_2LINES(hspi->Init.Direction)); @@ -1808,16 +1746,15 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *p tmp_mode = hspi->Init.Mode; if (!((tmp_state == HAL_SPI_STATE_READY) || \ - ((tmp_mode == SPI_MODE_MASTER) && (hspi->Init.Direction == SPI_DIRECTION_2LINES) && (tmp_state == HAL_SPI_STATE_BUSY_RX)))) + ((tmp_mode == SPI_MODE_MASTER) && (hspi->Init.Direction == SPI_DIRECTION_2LINES) && + (tmp_state == HAL_SPI_STATE_BUSY_RX)))) { - errorcode = HAL_BUSY; - goto error; + return HAL_BUSY; } if ((pTxData == NULL) || (pRxData == NULL) || (Size == 0U)) { - errorcode = HAL_ERROR; - goto error; + return HAL_ERROR; } /* Process locked */ @@ -1831,7 +1768,7 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *p /* Set the transaction information */ hspi->ErrorCode = HAL_SPI_ERROR_NONE; - hspi->pTxBuffPtr = (uint8_t *)pTxData; + hspi->pTxBuffPtr = (const uint8_t *)pTxData; hspi->TxXferSize = Size; hspi->TxXferCount = Size; hspi->pRxBuffPtr = (uint8_t *)pRxData; @@ -1892,21 +1829,19 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *p /* Enable TXE, RXNE and ERR interrupt */ __HAL_SPI_ENABLE_IT(hspi, (SPI_IT_TXE | SPI_IT_RXNE | SPI_IT_ERR)); -error : - return errorcode; + return HAL_OK; } /** * @brief Transmit an amount of data in non-blocking mode with DMA. * @param hspi pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. - * @param pData pointer to data buffer - * @param Size amount of data to be sent + * @param pData pointer to data buffer (u8 or u16 data elements) + * @param Size amount of data elements (u8 or u16) to be sent * @retval HAL status */ -HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size) +HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size) { - HAL_StatusTypeDef errorcode = HAL_OK; /* Check tx dma handle */ assert_param(IS_SPI_DMA_HANDLE(hspi->hdmatx)); @@ -1914,25 +1849,23 @@ HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, /* Check Direction parameter */ assert_param(IS_SPI_DIRECTION_2LINES_OR_1LINE(hspi->Init.Direction)); - /* Process Locked */ - __HAL_LOCK(hspi); - if (hspi->State != HAL_SPI_STATE_READY) { - errorcode = HAL_BUSY; - goto error; + return HAL_BUSY; } if ((pData == NULL) || (Size == 0U)) { - errorcode = HAL_ERROR; - goto error; + return HAL_ERROR; } + /* Process Locked */ + __HAL_LOCK(hspi); + /* Set the transaction information */ hspi->State = HAL_SPI_STATE_BUSY_TX; hspi->ErrorCode = HAL_SPI_ERROR_NONE; - hspi->pTxBuffPtr = (uint8_t *)pData; + hspi->pTxBuffPtr = (const uint8_t *)pData; hspi->TxXferSize = Size; hspi->TxXferCount = Size; @@ -1994,9 +1927,9 @@ HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, { /* Update SPI error code */ SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_DMA); - errorcode = HAL_ERROR; - - goto error; + /* Process Unlocked */ + __HAL_UNLOCK(hspi); + return HAL_ERROR; } /* Check if the SPI is already enabled */ @@ -2006,16 +1939,16 @@ HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, __HAL_SPI_ENABLE(hspi); } + /* Process Unlocked */ + __HAL_UNLOCK(hspi); + /* Enable the SPI Error Interrupt Bit */ __HAL_SPI_ENABLE_IT(hspi, (SPI_IT_ERR)); /* Enable Tx DMA Request */ SET_BIT(hspi->Instance->CR2, SPI_CR2_TXDMAEN); -error : - /* Process Unlocked */ - __HAL_UNLOCK(hspi); - return errorcode; + return HAL_OK; } /** @@ -2023,22 +1956,24 @@ error : * @note In case of MASTER mode and SPI_DIRECTION_2LINES direction, hdmatx shall be defined. * @param hspi pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. - * @param pData pointer to data buffer + * @param pData pointer to data buffer (u8 or u16 data elements) * @note When the CRC feature is enabled the pData Length must be Size + 1. - * @param Size amount of data to be sent + * @param Size amount of data elements (u8 or u16) to be received * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size) { - HAL_StatusTypeDef errorcode = HAL_OK; - /* Check rx dma handle */ assert_param(IS_SPI_DMA_HANDLE(hspi->hdmarx)); if (hspi->State != HAL_SPI_STATE_READY) { - errorcode = HAL_BUSY; - goto error; + return HAL_BUSY; + } + + if ((pData == NULL) || (Size == 0U)) + { + return HAL_ERROR; } if ((hspi->Init.Direction == SPI_DIRECTION_2LINES) && (hspi->Init.Mode == SPI_MODE_MASTER)) @@ -2055,12 +1990,6 @@ HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, u /* Process Locked */ __HAL_LOCK(hspi); - if ((pData == NULL) || (Size == 0U)) - { - errorcode = HAL_ERROR; - goto error; - } - /* Set the transaction information */ hspi->State = HAL_SPI_STATE_BUSY_RX; hspi->ErrorCode = HAL_SPI_ERROR_NONE; @@ -2138,9 +2067,9 @@ HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, u { /* Update SPI error code */ SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_DMA); - errorcode = HAL_ERROR; - - goto error; + /* Process Unlocked */ + __HAL_UNLOCK(hspi); + return HAL_ERROR; } /* Check if the SPI is already enabled */ @@ -2150,34 +2079,33 @@ HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, u __HAL_SPI_ENABLE(hspi); } + /* Process Unlocked */ + __HAL_UNLOCK(hspi); + /* Enable the SPI Error Interrupt Bit */ __HAL_SPI_ENABLE_IT(hspi, (SPI_IT_ERR)); /* Enable Rx DMA Request */ SET_BIT(hspi->Instance->CR2, SPI_CR2_RXDMAEN); -error: - /* Process Unlocked */ - __HAL_UNLOCK(hspi); - return errorcode; + return HAL_OK; } /** * @brief Transmit and Receive an amount of data in non-blocking mode with DMA. * @param hspi pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. - * @param pTxData pointer to transmission data buffer - * @param pRxData pointer to reception data buffer + * @param pTxData pointer to transmission data buffer (u8 or u16 data elements) + * @param pRxData pointer to reception data buffer (u8 or u16 data elements) * @note When the CRC feature is enabled the pRxData Length must be Size + 1 - * @param Size amount of data to be sent + * @param Size amount of data elements (u8 or u16) to be sent and received * @retval HAL status */ -HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, +HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData, uint16_t Size) { uint32_t tmp_mode; HAL_SPI_StateTypeDef tmp_state; - HAL_StatusTypeDef errorcode = HAL_OK; /* Check rx & tx dma handles */ assert_param(IS_SPI_DMA_HANDLE(hspi->hdmarx)); @@ -2186,26 +2114,25 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t * /* Check Direction parameter */ assert_param(IS_SPI_DIRECTION_2LINES(hspi->Init.Direction)); - /* Process locked */ - __HAL_LOCK(hspi); - /* Init temporary variables */ tmp_state = hspi->State; tmp_mode = hspi->Init.Mode; if (!((tmp_state == HAL_SPI_STATE_READY) || - ((tmp_mode == SPI_MODE_MASTER) && (hspi->Init.Direction == SPI_DIRECTION_2LINES) && (tmp_state == HAL_SPI_STATE_BUSY_RX)))) + ((tmp_mode == SPI_MODE_MASTER) && (hspi->Init.Direction == SPI_DIRECTION_2LINES) && + (tmp_state == HAL_SPI_STATE_BUSY_RX)))) { - errorcode = HAL_BUSY; - goto error; + return HAL_BUSY; } if ((pTxData == NULL) || (pRxData == NULL) || (Size == 0U)) { - errorcode = HAL_ERROR; - goto error; + return HAL_ERROR; } + /* Process locked */ + __HAL_LOCK(hspi); + /* Don't overwrite in case of HAL_SPI_STATE_BUSY_RX */ if (hspi->State != HAL_SPI_STATE_BUSY_RX) { @@ -2214,7 +2141,7 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t * /* Set the transaction information */ hspi->ErrorCode = HAL_SPI_ERROR_NONE; - hspi->pTxBuffPtr = (uint8_t *)pTxData; + hspi->pTxBuffPtr = (const uint8_t *)pTxData; hspi->TxXferSize = Size; hspi->TxXferCount = Size; hspi->pRxBuffPtr = (uint8_t *)pRxData; @@ -2305,9 +2232,9 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t * { /* Update SPI error code */ SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_DMA); - errorcode = HAL_ERROR; - - goto error; + /* Process Unlocked */ + __HAL_UNLOCK(hspi); + return HAL_ERROR; } /* Enable Rx DMA Request */ @@ -2326,9 +2253,9 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t * { /* Update SPI error code */ SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_DMA); - errorcode = HAL_ERROR; - - goto error; + /* Process Unlocked */ + __HAL_UNLOCK(hspi); + return HAL_ERROR; } /* Check if the SPI is already enabled */ @@ -2337,16 +2264,17 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t * /* Enable SPI peripheral */ __HAL_SPI_ENABLE(hspi); } + + /* Process Unlocked */ + __HAL_UNLOCK(hspi); + /* Enable the SPI Error Interrupt Bit */ __HAL_SPI_ENABLE_IT(hspi, (SPI_IT_ERR)); /* Enable Tx DMA Request */ SET_BIT(hspi->Instance->CR2, SPI_CR2_TXDMAEN); -error : - /* Process Unlocked */ - __HAL_UNLOCK(hspi); - return errorcode; + return HAL_OK; } /** @@ -2439,7 +2367,8 @@ HAL_StatusTypeDef HAL_SPI_Abort(SPI_HandleTypeDef *hspi) __HAL_SPI_DISABLE(hspi); /* Empty the FRLVL fifo */ - if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, HAL_GetTick()) != HAL_OK) + if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, + HAL_GetTick()) != HAL_OK) { hspi->ErrorCode = HAL_SPI_ERROR_ABORT; } @@ -2472,7 +2401,8 @@ HAL_StatusTypeDef HAL_SPI_Abort(SPI_HandleTypeDef *hspi) } /* Empty the FRLVL fifo */ - if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, HAL_GetTick()) != HAL_OK) + if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, + HAL_GetTick()) != HAL_OK) { hspi->ErrorCode = HAL_SPI_ERROR_ABORT; } @@ -2727,9 +2657,11 @@ HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi) { HAL_StatusTypeDef errorcode = HAL_OK; /* The Lock is not implemented on this API to allow the user application - to call the HAL SPI API under callbacks HAL_SPI_TxCpltCallback() or HAL_SPI_RxCpltCallback() or HAL_SPI_TxRxCpltCallback(): + to call the HAL SPI API under callbacks HAL_SPI_TxCpltCallback() or HAL_SPI_RxCpltCallback() or + HAL_SPI_TxRxCpltCallback(): when calling HAL_DMA_Abort() API the DMA TX/RX Transfer complete interrupt is generated - and the correspond call back is executed HAL_SPI_TxCpltCallback() or HAL_SPI_RxCpltCallback() or HAL_SPI_TxRxCpltCallback() + and the correspond call back is executed HAL_SPI_TxCpltCallback() or HAL_SPI_RxCpltCallback() or + HAL_SPI_TxRxCpltCallback() */ /* Abort the SPI DMA tx Stream/Channel */ @@ -3019,7 +2951,7 @@ __weak void HAL_SPI_AbortCpltCallback(SPI_HandleTypeDef *hspi) * the configuration information for SPI module. * @retval SPI state */ -HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi) +HAL_SPI_StateTypeDef HAL_SPI_GetState(const SPI_HandleTypeDef *hspi) { /* Return SPI handle state */ return hspi->State; @@ -3031,7 +2963,7 @@ HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi) * the configuration information for SPI module. * @retval SPI error code in bitmap format */ -uint32_t HAL_SPI_GetError(SPI_HandleTypeDef *hspi) +uint32_t HAL_SPI_GetError(const SPI_HandleTypeDef *hspi) { /* Return SPI ErrorCode */ return hspi->ErrorCode; @@ -3058,7 +2990,7 @@ uint32_t HAL_SPI_GetError(SPI_HandleTypeDef *hspi) */ static void SPI_DMATransmitCplt(DMA_HandleTypeDef *hdma) { - SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ + SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); uint32_t tickstart; /* Init tickstart for timeout management*/ @@ -3115,7 +3047,7 @@ static void SPI_DMATransmitCplt(DMA_HandleTypeDef *hdma) */ static void SPI_DMAReceiveCplt(DMA_HandleTypeDef *hdma) { - SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ + SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); uint32_t tickstart; #if (USE_SPI_CRC != 0U) __IO uint32_t tmpreg = 0U; @@ -3232,7 +3164,7 @@ static void SPI_DMAReceiveCplt(DMA_HandleTypeDef *hdma) */ static void SPI_DMATransmitReceiveCplt(DMA_HandleTypeDef *hdma) { - SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ + SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); uint32_t tickstart; #if (USE_SPI_CRC != 0U) __IO uint32_t tmpreg = 0U; @@ -3270,7 +3202,8 @@ static void SPI_DMATransmitReceiveCplt(DMA_HandleTypeDef *hdma) } else { - if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_HALF_FULL, SPI_DEFAULT_TIMEOUT, tickstart) != HAL_OK) + if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_HALF_FULL, SPI_DEFAULT_TIMEOUT, + tickstart) != HAL_OK) { /* Error on the CRC reception */ SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); @@ -3332,7 +3265,7 @@ static void SPI_DMATransmitReceiveCplt(DMA_HandleTypeDef *hdma) */ static void SPI_DMAHalfTransmitCplt(DMA_HandleTypeDef *hdma) { - SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ + SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Call user Tx half complete callback */ #if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U) @@ -3350,7 +3283,7 @@ static void SPI_DMAHalfTransmitCplt(DMA_HandleTypeDef *hdma) */ static void SPI_DMAHalfReceiveCplt(DMA_HandleTypeDef *hdma) { - SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ + SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Call user Rx half complete callback */ #if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U) @@ -3368,7 +3301,7 @@ static void SPI_DMAHalfReceiveCplt(DMA_HandleTypeDef *hdma) */ static void SPI_DMAHalfTransmitReceiveCplt(DMA_HandleTypeDef *hdma) { - SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ + SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Call user TxRx half complete callback */ #if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U) @@ -3386,7 +3319,7 @@ static void SPI_DMAHalfTransmitReceiveCplt(DMA_HandleTypeDef *hdma) */ static void SPI_DMAError(DMA_HandleTypeDef *hdma) { - SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ + SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Stop the disable DMA transfer on SPI side */ CLEAR_BIT(hspi->Instance->CR2, SPI_CR2_TXDMAEN | SPI_CR2_RXDMAEN); @@ -3409,7 +3342,7 @@ static void SPI_DMAError(DMA_HandleTypeDef *hdma) */ static void SPI_DMAAbortOnError(DMA_HandleTypeDef *hdma) { - SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ + SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); hspi->RxXferCount = 0U; hspi->TxXferCount = 0U; @@ -3431,7 +3364,7 @@ static void SPI_DMAAbortOnError(DMA_HandleTypeDef *hdma) */ static void SPI_DMATxAbortCallback(DMA_HandleTypeDef *hdma) { - SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ + SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); hspi->hdmatx->XferAbortCallback = NULL; @@ -3447,7 +3380,8 @@ static void SPI_DMATxAbortCallback(DMA_HandleTypeDef *hdma) __HAL_SPI_DISABLE(hspi); /* Empty the FRLVL fifo */ - if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, HAL_GetTick()) != HAL_OK) + if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, + HAL_GetTick()) != HAL_OK) { hspi->ErrorCode = HAL_SPI_ERROR_ABORT; } @@ -3497,7 +3431,7 @@ static void SPI_DMATxAbortCallback(DMA_HandleTypeDef *hdma) */ static void SPI_DMARxAbortCallback(DMA_HandleTypeDef *hdma) { - SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ + SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Disable SPI Peripheral */ __HAL_SPI_DISABLE(hspi); @@ -3514,7 +3448,8 @@ static void SPI_DMARxAbortCallback(DMA_HandleTypeDef *hdma) } /* Empty the FRLVL fifo */ - if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, HAL_GetTick()) != HAL_OK) + if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, + HAL_GetTick()) != HAL_OK) { hspi->ErrorCode = HAL_SPI_ERROR_ABORT; } @@ -3650,14 +3585,14 @@ static void SPI_2linesTxISR_8BIT(struct __SPI_HandleTypeDef *hspi) /* Transmit data in packing Bit mode */ if (hspi->TxXferCount >= 2U) { - hspi->Instance->DR = *((uint16_t *)hspi->pTxBuffPtr); + hspi->Instance->DR = *((const uint16_t *)hspi->pTxBuffPtr); hspi->pTxBuffPtr += sizeof(uint16_t); hspi->TxXferCount -= 2U; } /* Transmit data in 8 Bit mode */ else { - *(__IO uint8_t *)&hspi->Instance->DR = (*hspi->pTxBuffPtr); + *(__IO uint8_t *)&hspi->Instance->DR = *((const uint8_t *)hspi->pTxBuffPtr); hspi->pTxBuffPtr++; hspi->TxXferCount--; } @@ -3751,7 +3686,7 @@ static void SPI_2linesRxISR_16BITCRC(struct __SPI_HandleTypeDef *hspi) static void SPI_2linesTxISR_16BIT(struct __SPI_HandleTypeDef *hspi) { /* Transmit data in 16 Bit mode */ - hspi->Instance->DR = *((uint16_t *)hspi->pTxBuffPtr); + hspi->Instance->DR = *((const uint16_t *)hspi->pTxBuffPtr); hspi->pTxBuffPtr += sizeof(uint16_t); hspi->TxXferCount--; @@ -3904,7 +3839,7 @@ static void SPI_RxISR_16BIT(struct __SPI_HandleTypeDef *hspi) */ static void SPI_TxISR_8BIT(struct __SPI_HandleTypeDef *hspi) { - *(__IO uint8_t *)&hspi->Instance->DR = (*hspi->pTxBuffPtr); + *(__IO uint8_t *)&hspi->Instance->DR = *((const uint8_t *)hspi->pTxBuffPtr); hspi->pTxBuffPtr++; hspi->TxXferCount--; @@ -3930,7 +3865,7 @@ static void SPI_TxISR_8BIT(struct __SPI_HandleTypeDef *hspi) static void SPI_TxISR_16BIT(struct __SPI_HandleTypeDef *hspi) { /* Transmit data in 16 Bit mode */ - hspi->Instance->DR = *((uint16_t *)hspi->pTxBuffPtr); + hspi->Instance->DR = *((const uint16_t *)hspi->pTxBuffPtr); hspi->pTxBuffPtr += sizeof(uint16_t); hspi->TxXferCount--; @@ -4009,7 +3944,10 @@ static HAL_StatusTypeDef SPI_WaitFlagStateUntilTimeout(SPI_HandleTypeDef *hspi, { tmp_timeout = 0U; } - count--; + else + { + count--; + } } } @@ -4032,7 +3970,7 @@ static HAL_StatusTypeDef SPI_WaitFifoStateUntilTimeout(SPI_HandleTypeDef *hspi, __IO uint32_t count; uint32_t tmp_timeout; uint32_t tmp_tickstart; - __IO uint8_t *ptmpreg8; + __IO const uint8_t *ptmpreg8; __IO uint8_t tmpreg8 = 0; /* Adjust Timeout value in case of end of transfer */ @@ -4091,7 +4029,10 @@ static HAL_StatusTypeDef SPI_WaitFifoStateUntilTimeout(SPI_HandleTypeDef *hspi, { tmp_timeout = 0U; } - count--; + else + { + count--; + } } } @@ -4387,7 +4328,8 @@ static void SPI_AbortRx_ISR(SPI_HandleTypeDef *hspi) } /* Empty the FRLVL fifo */ - if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, HAL_GetTick()) != HAL_OK) + if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, + HAL_GetTick()) != HAL_OK) { hspi->ErrorCode = HAL_SPI_ERROR_ABORT; } @@ -4430,7 +4372,8 @@ static void SPI_AbortTx_ISR(SPI_HandleTypeDef *hspi) __HAL_SPI_DISABLE(hspi); /* Empty the FRLVL fifo */ - if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, HAL_GetTick()) != HAL_OK) + if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, + HAL_GetTick()) != HAL_OK) { hspi->ErrorCode = HAL_SPI_ERROR_ABORT; } @@ -4459,7 +4402,8 @@ static void SPI_AbortTx_ISR(SPI_HandleTypeDef *hspi) } /* Empty the FRLVL fifo */ - if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, HAL_GetTick()) != HAL_OK) + if (SPI_WaitFifoStateUntilTimeout(hspi, SPI_FLAG_FRLVL, SPI_FRLVL_EMPTY, SPI_DEFAULT_TIMEOUT, + HAL_GetTick()) != HAL_OK) { hspi->ErrorCode = HAL_SPI_ERROR_ABORT; } diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_timebase_tim_template.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_timebase_tim_template.c index d7e383784..e3bd89fa8 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_timebase_tim_template.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_timebase_tim_template.c @@ -111,6 +111,11 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP; if (HAL_TIM_Base_Init(&TimHandle) == HAL_OK) { +#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1U) + /* Register callback */ + HAL_TIM_RegisterCallback(&TimHandle, HAL_TIM_PERIOD_ELAPSED_CB_ID, TimeBase_TIM_PeriodElapsedCallback); +#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */ + /* Start the TIM time Base generation in interrupt mode */ return HAL_TIM_Base_Start_IT(&TimHandle); } diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_uart.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_uart.c index ef6aad3bf..0b595ed76 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_uart.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_uart.c @@ -721,7 +721,11 @@ __weak void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) * @arg @ref HAL_UART_ABORT_COMPLETE_CB_ID Abort Complete Callback ID * @arg @ref HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID Abort Transmit Complete Callback ID * @arg @ref HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID Abort Receive Complete Callback ID +#if defined(USART_CR1_UESM) +#if defined(USART_CR3_WUFIE) * @arg @ref HAL_UART_WAKEUP_CB_ID Wakeup Callback ID +#endif +#endif * @arg @ref HAL_UART_RX_FIFO_FULL_CB_ID Rx Fifo Full Callback ID * @arg @ref HAL_UART_TX_FIFO_EMPTY_CB_ID Tx Fifo Empty Callback ID * @arg @ref HAL_UART_MSPINIT_CB_ID MspInit Callback ID @@ -854,7 +858,11 @@ HAL_StatusTypeDef HAL_UART_RegisterCallback(UART_HandleTypeDef *huart, HAL_UART_ * @arg @ref HAL_UART_ABORT_COMPLETE_CB_ID Abort Complete Callback ID * @arg @ref HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID Abort Transmit Complete Callback ID * @arg @ref HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID Abort Receive Complete Callback ID +#if defined(USART_CR1_UESM) +#if defined(USART_CR3_WUFIE) * @arg @ref HAL_UART_WAKEUP_CB_ID Wakeup Callback ID +#endif +#endif * @arg @ref HAL_UART_RX_FIFO_FULL_CB_ID Rx Fifo Full Callback ID * @arg @ref HAL_UART_TX_FIFO_EMPTY_CB_ID Tx Fifo Empty Callback ID * @arg @ref HAL_UART_MSPINIT_CB_ID MspInit Callback ID @@ -1032,75 +1040,83 @@ HAL_StatusTypeDef HAL_UART_UnRegisterRxEventCallback(UART_HandleTypeDef *huart) =============================================================================== ##### IO operation functions ##### =============================================================================== + [..] This subsection provides a set of functions allowing to manage the UART asynchronous and Half duplex data transfers. - (#) There are two mode of transfer: - (+) Blocking mode: The communication is performed in polling mode. - The HAL status of all data processing is returned by the same function - after finishing transfer. - (+) Non-Blocking mode: The communication is performed using Interrupts - or DMA, These API's return the HAL status. - The end of the data processing will be indicated through the - dedicated UART IRQ when using Interrupt mode or the DMA IRQ when - using DMA mode. - The HAL_UART_TxCpltCallback(), HAL_UART_RxCpltCallback() user callbacks - will be executed respectively at the end of the transmit or Receive process - The HAL_UART_ErrorCallback()user callback will be executed when a communication error is detected + (#) There are two modes of transfer: + (++) Blocking mode: The communication is performed in polling mode. + The HAL status of all data processing is returned by the same function + after finishing transfer. + (++) Non-Blocking mode: The communication is performed using Interrupts + or DMA, These API's return the HAL status. + The end of the data processing will be indicated through the + dedicated UART IRQ when using Interrupt mode or the DMA IRQ when + using DMA mode. + The HAL_UART_TxCpltCallback(), HAL_UART_RxCpltCallback() user callbacks + will be executed respectively at the end of the transmit or Receive process + The HAL_UART_ErrorCallback()user callback will be executed when a communication error is detected (#) Blocking mode API's are : - (+) HAL_UART_Transmit() - (+) HAL_UART_Receive() + (++) HAL_UART_Transmit() + (++) HAL_UART_Receive() (#) Non-Blocking mode API's with Interrupt are : - (+) HAL_UART_Transmit_IT() - (+) HAL_UART_Receive_IT() - (+) HAL_UART_IRQHandler() + (++) HAL_UART_Transmit_IT() + (++) HAL_UART_Receive_IT() + (++) HAL_UART_IRQHandler() (#) Non-Blocking mode API's with DMA are : - (+) HAL_UART_Transmit_DMA() - (+) HAL_UART_Receive_DMA() - (+) HAL_UART_DMAPause() - (+) HAL_UART_DMAResume() - (+) HAL_UART_DMAStop() + (++) HAL_UART_Transmit_DMA() + (++) HAL_UART_Receive_DMA() + (++) HAL_UART_DMAPause() + (++) HAL_UART_DMAResume() + (++) HAL_UART_DMAStop() (#) A set of Transfer Complete Callbacks are provided in Non_Blocking mode: - (+) HAL_UART_TxHalfCpltCallback() - (+) HAL_UART_TxCpltCallback() - (+) HAL_UART_RxHalfCpltCallback() - (+) HAL_UART_RxCpltCallback() - (+) HAL_UART_ErrorCallback() + (++) HAL_UART_TxHalfCpltCallback() + (++) HAL_UART_TxCpltCallback() + (++) HAL_UART_RxHalfCpltCallback() + (++) HAL_UART_RxCpltCallback() + (++) HAL_UART_ErrorCallback() (#) Non-Blocking mode transfers could be aborted using Abort API's : - (+) HAL_UART_Abort() - (+) HAL_UART_AbortTransmit() - (+) HAL_UART_AbortReceive() - (+) HAL_UART_Abort_IT() - (+) HAL_UART_AbortTransmit_IT() - (+) HAL_UART_AbortReceive_IT() + (++) HAL_UART_Abort() + (++) HAL_UART_AbortTransmit() + (++) HAL_UART_AbortReceive() + (++) HAL_UART_Abort_IT() + (++) HAL_UART_AbortTransmit_IT() + (++) HAL_UART_AbortReceive_IT() (#) For Abort services based on interrupts (HAL_UART_Abortxxx_IT), a set of Abort Complete Callbacks are provided: - (+) HAL_UART_AbortCpltCallback() - (+) HAL_UART_AbortTransmitCpltCallback() - (+) HAL_UART_AbortReceiveCpltCallback() + (++) HAL_UART_AbortCpltCallback() + (++) HAL_UART_AbortTransmitCpltCallback() + (++) HAL_UART_AbortReceiveCpltCallback() (#) A Rx Event Reception Callback (Rx event notification) is available for Non_Blocking modes of enhanced reception services: - (+) HAL_UARTEx_RxEventCallback() + (++) HAL_UARTEx_RxEventCallback() +#if defined(USART_CR1_UESM) +#if defined(USART_CR3_WUFIE) + + (#) Wakeup from Stop mode Callback: + (++) HAL_UARTEx_WakeupCallback() +#endif +#endif (#) In Non-Blocking mode transfers, possible errors are split into 2 categories. Errors are handled as follows : - (+) Error is considered as Recoverable and non blocking : Transfer could go till end, but error severity is - to be evaluated by user : this concerns Frame Error, Parity Error or Noise Error - in Interrupt mode reception . - Received character is then retrieved and stored in Rx buffer, Error code is set to allow user - to identify error type, and HAL_UART_ErrorCallback() user callback is executed. - Transfer is kept ongoing on UART side. - If user wants to abort it, Abort services should be called by user. - (+) Error is considered as Blocking : Transfer could not be completed properly and is aborted. - This concerns Overrun Error In Interrupt mode reception and all errors in DMA mode. - Error code is set to allow user to identify error type, and HAL_UART_ErrorCallback() - user callback is executed. + (++) Error is considered as Recoverable and non blocking : Transfer could go till end, but error severity is + to be evaluated by user : this concerns Frame Error, Parity Error or Noise Error + in Interrupt mode reception . + Received character is then retrieved and stored in Rx buffer, Error code is set to allow user + to identify error type, and HAL_UART_ErrorCallback() user callback is executed. + Transfer is kept ongoing on UART side. + If user wants to abort it, Abort services should be called by user. + (++) Error is considered as Blocking : Transfer could not be completed properly and is aborted. + This concerns Overrun Error In Interrupt mode reception and all errors in DMA mode. + Error code is set to allow user to identify error type, and HAL_UART_ErrorCallback() + user callback is executed. -@- In the Half duplex communication, it is forbidden to run the transmit and receive process in parallel, the UART state HAL_UART_STATE_BUSY_TX_RX can't be useful. @@ -1194,7 +1210,15 @@ HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, const uint8_t *pD huart->Instance->TDR = (uint8_t)(*pdata8bits & 0xFFU); pdata8bits++; } - huart->TxXferCount--; + if ((huart->gState & HAL_UART_STATE_BUSY_TX) == HAL_UART_STATE_BUSY_TX) + { + huart->TxXferCount--; + } + else + { + /* Process was aborted during the transmission */ + return HAL_ERROR; + } } if (UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_TC, RESET, tickstart, Timeout) != HAL_OK) @@ -1306,7 +1330,15 @@ HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, ui *pdata8bits = (uint8_t)(huart->Instance->RDR & (uint8_t)uhMask); pdata8bits++; } - huart->RxXferCount--; + if (huart->RxState == HAL_UART_STATE_BUSY_RX) + { + huart->RxXferCount--; + } + else + { + /* Process was aborted during the reception */ + return HAL_ERROR; + } } /* At end of Rx process, restore huart->RxState to Ready */ @@ -1814,10 +1846,6 @@ HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart) } #endif /* HAL_DMA_MODULE_ENABLED */ - /* Reset Tx and Rx transfer counters */ - huart->TxXferCount = 0U; - huart->RxXferCount = 0U; - /* Clear the Error flags in the ICR register */ __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF | UART_CLEAR_NEF | UART_CLEAR_PEF | UART_CLEAR_FEF); @@ -1886,9 +1914,6 @@ HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart) } #endif /* HAL_DMA_MODULE_ENABLED */ - /* Reset Tx transfer counter */ - huart->TxXferCount = 0U; - /* Flush the whole TX FIFO (if needed) */ if (huart->FifoMode == UART_FIFOMODE_ENABLE) { @@ -1953,9 +1978,6 @@ HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart) } #endif /* HAL_DMA_MODULE_ENABLED */ - /* Reset Rx transfer counter */ - huart->RxXferCount = 0U; - /* Clear the Error flags in the ICR register */ __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF | UART_CLEAR_NEF | UART_CLEAR_PEF | UART_CLEAR_FEF); @@ -2083,10 +2105,6 @@ HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart) /* if no DMA abort complete callback execution is required => call user Abort Complete callback */ if (abortcplt == 1U) { - /* Reset Tx and Rx transfer counters */ - huart->TxXferCount = 0U; - huart->RxXferCount = 0U; - /* Clear ISR function pointers */ huart->RxISR = NULL; huart->TxISR = NULL; @@ -2167,8 +2185,6 @@ HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart) } else { - /* Reset Tx transfer counter */ - huart->TxXferCount = 0U; /* Clear TxISR function pointers */ huart->TxISR = NULL; @@ -2189,9 +2205,6 @@ HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart) else #endif /* HAL_DMA_MODULE_ENABLED */ { - /* Reset Tx transfer counter */ - huart->TxXferCount = 0U; - /* Clear TxISR function pointers */ huart->TxISR = NULL; @@ -2266,9 +2279,6 @@ HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart) } else { - /* Reset Rx transfer counter */ - huart->RxXferCount = 0U; - /* Clear RxISR function pointer */ huart->pRxBuffPtr = NULL; @@ -2295,9 +2305,6 @@ HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart) else #endif /* HAL_DMA_MODULE_ENABLED */ { - /* Reset Rx transfer counter */ - huart->RxXferCount = 0U; - /* Clear RxISR function pointer */ huart->pRxBuffPtr = NULL; @@ -3709,8 +3716,6 @@ static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma) /* DMA Normal mode */ if (HAL_IS_BIT_CLR(hdma->Instance->CCR, DMA_CCR_CIRC)) { - huart->TxXferCount = 0U; - /* Disable the DMA transfer for transmit request by resetting the DMAT bit in the UART CR3 register */ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT); @@ -3761,8 +3766,6 @@ static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma) /* DMA Normal mode */ if (HAL_IS_BIT_CLR(hdma->Instance->CCR, DMA_CCR_CIRC)) { - huart->RxXferCount = 0U; - /* Disable PE and ERR (Frame error, noise error, overrun error) interrupts */ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_PEIE); ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE); @@ -3789,12 +3792,22 @@ static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma) If Reception till IDLE event has been selected : use Rx Event callback */ if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE) { + /* Check current nb of data still to be received on DMA side. + DMA Normal mode, remaining nb of data will be 0 + DMA Circular mode, remaining nb of data is reset to RxXferSize */ + uint16_t nb_remaining_rx_data = (uint16_t) __HAL_DMA_GET_COUNTER(hdma); + if (nb_remaining_rx_data < huart->RxXferSize) + { + /* Update nb of remaining data */ + huart->RxXferCount = nb_remaining_rx_data; + } + #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) /*Call registered Rx Event callback*/ - huart->RxEventCallback(huart, huart->RxXferSize); + huart->RxEventCallback(huart, (huart->RxXferSize - huart->RxXferCount)); #else /*Call legacy weak Rx Event callback*/ - HAL_UARTEx_RxEventCallback(huart, huart->RxXferSize); + HAL_UARTEx_RxEventCallback(huart, (huart->RxXferSize - huart->RxXferCount)); #endif /* USE_HAL_UART_REGISTER_CALLBACKS */ } else @@ -3827,12 +3840,22 @@ static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma) If Reception till IDLE event has been selected : use Rx Event callback */ if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE) { + huart->RxXferCount = huart->RxXferSize / 2U; + + /* Check current nb of data still to be received on DMA side. */ + uint16_t nb_remaining_rx_data = (uint16_t) __HAL_DMA_GET_COUNTER(hdma); + if (nb_remaining_rx_data <= huart->RxXferSize) + { + /* Update nb of remaining data */ + huart->RxXferCount = nb_remaining_rx_data; + } + #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) /*Call registered Rx Event callback*/ - huart->RxEventCallback(huart, huart->RxXferSize / 2U); + huart->RxEventCallback(huart, (huart->RxXferSize - huart->RxXferCount)); #else /*Call legacy weak Rx Event callback*/ - HAL_UARTEx_RxEventCallback(huart, huart->RxXferSize / 2U); + HAL_UARTEx_RxEventCallback(huart, (huart->RxXferSize - huart->RxXferCount)); #endif /* USE_HAL_UART_REGISTER_CALLBACKS */ } else @@ -3864,7 +3887,6 @@ static void UART_DMAError(DMA_HandleTypeDef *hdma) if ((HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT)) && (gstate == HAL_UART_STATE_BUSY_TX)) { - huart->TxXferCount = 0U; UART_EndTxTransfer(huart); } @@ -3872,7 +3894,6 @@ static void UART_DMAError(DMA_HandleTypeDef *hdma) if ((HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR)) && (rxstate == HAL_UART_STATE_BUSY_RX)) { - huart->RxXferCount = 0U; UART_EndRxTransfer(huart); } @@ -3896,7 +3917,6 @@ static void UART_DMAError(DMA_HandleTypeDef *hdma) static void UART_DMAAbortOnError(DMA_HandleTypeDef *hdma) { UART_HandleTypeDef *huart = (UART_HandleTypeDef *)(hdma->Parent); - huart->RxXferCount = 0U; #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) /*Call registered error callback*/ @@ -3930,10 +3950,6 @@ static void UART_DMATxAbortCallback(DMA_HandleTypeDef *hdma) } } - /* No Abort process still ongoing : All DMA channels are aborted, call user Abort Complete callback */ - huart->TxXferCount = 0U; - huart->RxXferCount = 0U; - /* Reset errorCode */ huart->ErrorCode = HAL_UART_ERROR_NONE; @@ -3985,10 +4001,6 @@ static void UART_DMARxAbortCallback(DMA_HandleTypeDef *hdma) } } - /* No Abort process still ongoing : All DMA channels are aborted, call user Abort Complete callback */ - huart->TxXferCount = 0U; - huart->RxXferCount = 0U; - /* Reset errorCode */ huart->ErrorCode = HAL_UART_ERROR_NONE; @@ -4026,8 +4038,6 @@ static void UART_DMATxOnlyAbortCallback(DMA_HandleTypeDef *hdma) { UART_HandleTypeDef *huart = (UART_HandleTypeDef *)(hdma->Parent); - huart->TxXferCount = 0U; - /* Flush the whole TX FIFO (if needed) */ if (huart->FifoMode == UART_FIFOMODE_ENABLE) { @@ -4059,8 +4069,6 @@ static void UART_DMARxOnlyAbortCallback(DMA_HandleTypeDef *hdma) { UART_HandleTypeDef *huart = (UART_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; - huart->RxXferCount = 0U; - /* Clear the Error flags in the ICR register */ __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF | UART_CLEAR_NEF | UART_CLEAR_PEF | UART_CLEAR_FEF); diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_uart_ex.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_uart_ex.c index fd5d1e95d..9890d1a4a 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_uart_ex.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_hal_uart_ex.c @@ -24,7 +24,7 @@ ============================================================================== ##### UART peripheral extended features ##### ============================================================================== - + [..] (#) Declare a UART_HandleTypeDef handle structure. (#) For the UART RS485 Driver Enable mode, initialize the UART registers @@ -255,19 +255,17 @@ HAL_StatusTypeDef HAL_RS485Ex_Init(UART_HandleTypeDef *huart, uint32_t Polarity, =============================================================================== ##### IO operation functions ##### =============================================================================== + [..] This subsection provides a set of Wakeup and FIFO mode related callback functions. - #if defined(USART_CR1_UESM) #if defined(USART_CR3_WUFIE) (#) Wakeup from Stop mode Callback: - (+) HAL_UARTEx_WakeupCallback() - + (++) HAL_UARTEx_WakeupCallback() #endif #endif (#) TX/RX Fifos Callbacks: - (+) HAL_UARTEx_RxFifoFullCallback() - (+) HAL_UARTEx_TxFifoEmptyCallback() - + (++) HAL_UARTEx_RxFifoFullCallback() + (++) HAL_UARTEx_TxFifoEmptyCallback() @endverbatim * @{ */ @@ -353,19 +351,19 @@ __weak void HAL_UARTEx_TxFifoEmptyCallback(UART_HandleTypeDef *huart) (#) Compared to standard reception services which only consider number of received data elements as reception completion criteria, these functions also consider additional events as triggers for updating reception status to caller : - (+) Detection of inactivity period (RX line has not been active for a given period). - (++) RX inactivity detected by IDLE event, i.e. RX line has been in idle state (normally high state) + (++) Detection of inactivity period (RX line has not been active for a given period). + (+++) RX inactivity detected by IDLE event, i.e. RX line has been in idle state (normally high state) for 1 frame time, after last received byte. - (++) RX inactivity detected by RTO, i.e. line has been in idle state + (+++) RX inactivity detected by RTO, i.e. line has been in idle state for a programmable time, after last received byte. - (+) Detection that a specific character has been received. + (++) Detection that a specific character has been received. - (#) There are two mode of transfer: - (+) Blocking mode: The reception is performed in polling mode, until either expected number of data is received, + (#) There are two modes of transfer: + (++) Blocking mode: The reception is performed in polling mode, until either expected number of data is received, or till IDLE event occurs. Reception is handled only during function execution. When function exits, no data reception could occur. HAL status and number of actually received data elements, are returned by function after finishing transfer. - (+) Non-Blocking mode: The reception is performed using Interrupts or DMA. + (++) Non-Blocking mode: The reception is performed using Interrupts or DMA. These API's return the HAL status. The end of the data processing will be indicated through the dedicated UART IRQ when using Interrupt mode or the DMA IRQ when using DMA mode. @@ -373,13 +371,13 @@ __weak void HAL_UARTEx_TxFifoEmptyCallback(UART_HandleTypeDef *huart) The HAL_UART_ErrorCallback()user callback will be executed when a reception error is detected. (#) Blocking mode API: - (+) HAL_UARTEx_ReceiveToIdle() + (++) HAL_UARTEx_ReceiveToIdle() (#) Non-Blocking mode API with Interrupt: - (+) HAL_UARTEx_ReceiveToIdle_IT() + (++) HAL_UARTEx_ReceiveToIdle_IT() (#) Non-Blocking mode API with DMA: - (+) HAL_UARTEx_ReceiveToIdle_DMA() + (++) HAL_UARTEx_ReceiveToIdle_DMA() @endverbatim * @{ @@ -1008,17 +1006,15 @@ HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_DMA(UART_HandleTypeDef *huart, uint8_ * Half Transfer, or Transfer Complete), this function allows to retrieve the Rx Event type that has lead * to Rx Event callback execution. * @note This function is expected to be called within the user implementation of Rx Event Callback, - * in order to provide the accurate value : - * In Interrupt Mode : - * - HAL_UART_RXEVENT_TC : when Reception has been completed (expected nb of data has been received) - * - HAL_UART_RXEVENT_IDLE : when Idle event occurred prior reception has been completed (nb of - * received data is lower than expected one) - * In DMA Mode : - * - HAL_UART_RXEVENT_TC : when Reception has been completed (expected nb of data has been received) - * - HAL_UART_RXEVENT_HT : when half of expected nb of data has been received - * - HAL_UART_RXEVENT_IDLE : when Idle event occurred prior reception has been completed (nb of - * received data is lower than expected one). - * In DMA mode, RxEvent callback could be called several times; + * in order to provide the accurate value. + * @note In Interrupt Mode: + * - HAL_UART_RXEVENT_TC : when Reception has been completed (expected nb of data has been received). + * - HAL_UART_RXEVENT_IDLE : when Idle event occurred prior reception has been completed. + * @note In DMA Mode: + * - HAL_UART_RXEVENT_TC : when Reception has been completed (expected nb of data has been received). + * - HAL_UART_RXEVENT_HT : when half of expected nb of data has been received. + * - HAL_UART_RXEVENT_IDLE : when Idle event occurred prior reception has been completed. + * @note In DMA mode, RxEvent callback could be called several times; * When DMA is configured in Normal Mode, HT event does not stop Reception process; * When DMA is configured in Circular Mode, HT, TC or IDLE events don't stop Reception process; * @param huart UART handle. diff --git a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_ll_spi.c b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_ll_spi.c index 4130c80db..d6db5ac95 100644 --- a/stm32cube/stm32wb0x/drivers/src/stm32wb0x_ll_spi.c +++ b/stm32cube/stm32wb0x/drivers/src/stm32wb0x_ll_spi.c @@ -130,7 +130,7 @@ * - SUCCESS: SPI registers are de-initialized * - ERROR: SPI registers are not de-initialized */ -ErrorStatus LL_SPI_DeInit(SPI_TypeDef *SPIx) +ErrorStatus LL_SPI_DeInit(const SPI_TypeDef *SPIx) { ErrorStatus status = ERROR; @@ -179,8 +179,9 @@ ErrorStatus LL_SPI_DeInit(SPI_TypeDef *SPIx) /** * @brief Initialize the SPI registers according to the specified parameters in SPI_InitStruct. - * @note As some bits in SPI configuration registers can only be written when the SPI is disabled (SPI_CR1_SPE bit =0), - * SPI peripheral should be in disabled state prior calling this function. Otherwise, ERROR result will be returned. + * @note As some bits in SPI configuration registers can only be written when the + * SPI is disabled (SPI_CR1_SPE bit = 0), SPI peripheral should be in disabled state prior + * calling this function. Otherwise, ERROR result will be returned. * @param SPIx SPI Instance * @param SPI_InitStruct pointer to a @ref LL_SPI_InitTypeDef structure * @retval An ErrorStatus enumeration value. (Return always SUCCESS) @@ -364,7 +365,7 @@ void LL_SPI_StructInit(LL_SPI_InitTypeDef *SPI_InitStruct) * - SUCCESS: SPI registers are de-initialized * - ERROR: SPI registers are not de-initialized */ -ErrorStatus LL_I2S_DeInit(SPI_TypeDef *SPIx) +ErrorStatus LL_I2S_DeInit(const SPI_TypeDef *SPIx) { return LL_SPI_DeInit(SPIx); } diff --git a/stm32cube/stm32wb0x/soc/stm32wb05.h b/stm32cube/stm32wb0x/soc/stm32wb05.h index 759d715e0..fb3c43094 100644 --- a/stm32cube/stm32wb0x/soc/stm32wb05.h +++ b/stm32cube/stm32wb0x/soc/stm32wb05.h @@ -75,6 +75,7 @@ typedef enum DMA_IRQn = 17, /*!< 17 DMA interrupt */ RADIO_TXRX_IRQn = 18, /*!< 18 BLE Tx/Rx interrupt */ RADIO_TIMER_ERROR_IRQn = 20, /*!< 20 RADIO TIMER Error interrupt */ + RADIO_RRM_IRQn = 22, /*!< 22 RADIO Resource Manager interrupt */ RADIO_TIMER_CPU_WKUP_IRQn = 23, /*!< 23 RADIO TIMER CPU Wakeup interrupt */ RADIO_TIMER_TXRX_WKUP_IRQn = 24, /*!< 24 RADIO TIMER Tx/Rx Wakeup interrupt */ RADIO_TXRX_SEQ_IRQn = 25, /*!< 25 BLE RX/TX sequence interrupt */ diff --git a/stm32cube/stm32wb0x/soc/stm32wb06.h b/stm32cube/stm32wb0x/soc/stm32wb06.h index 8a43479ce..95bcc9543 100644 --- a/stm32cube/stm32wb0x/soc/stm32wb06.h +++ b/stm32cube/stm32wb0x/soc/stm32wb06.h @@ -78,6 +78,7 @@ typedef enum DMA_IRQn = 17, /*!< 17 DMA interrupt */ RADIO_TXRX_IRQn = 18, /*!< 18 RADIO Tx/Rx interrupt */ RADIO_TIMER_ERROR_IRQn = 20, /*!< 20 RADIO TIMER Error interrupt */ + RADIO_RRM_IRQn = 22, /*!< 22 RADIO Resource Manager interrupt */ RADIO_TIMER_CPU_WKUP_IRQn = 23, /*!< 23 RADIO TIMER CPU Wakeup interrupt */ RADIO_TIMER_TXRX_WKUP_IRQn = 24, /*!< 24 RADIO TIMER Tx/Rx Wakeup interrupt */ RADIO_TXRX_SEQ_IRQn = 25 /*!< 25 RADIO Tx/Rx sequence interrupt */ diff --git a/stm32cube/stm32wb0x/soc/stm32wb07.h b/stm32cube/stm32wb0x/soc/stm32wb07.h index 31c2bc977..9432008c5 100644 --- a/stm32cube/stm32wb0x/soc/stm32wb07.h +++ b/stm32cube/stm32wb0x/soc/stm32wb07.h @@ -78,6 +78,7 @@ typedef enum DMA_IRQn = 17, /*!< 17 DMA interrupt */ RADIO_TXRX_IRQn = 18, /*!< 18 RADIO Tx/Rx interrupt */ RADIO_TIMER_ERROR_IRQn = 20, /*!< 20 RADIO TIMER Error interrupt */ + RADIO_RRM_IRQn = 22, /*!< 22 RADIO Resource Manager interrupt */ RADIO_TIMER_CPU_WKUP_IRQn = 23, /*!< 23 RADIO TIMER CPU Wakeup interrupt */ RADIO_TIMER_TXRX_WKUP_IRQn = 24, /*!< 24 RADIO TIMER Tx/Rx Wakeup interrupt */ RADIO_TXRX_SEQ_IRQn = 25 /*!< 25 RADIO Tx/Rx sequence interrupt */ diff --git a/stm32cube/stm32wb0x/soc/stm32wb09.h b/stm32cube/stm32wb0x/soc/stm32wb09.h index 97331bd04..e18e8238a 100644 --- a/stm32cube/stm32wb0x/soc/stm32wb09.h +++ b/stm32cube/stm32wb0x/soc/stm32wb09.h @@ -100,6 +100,7 @@ typedef enum DMA_IRQn = 17, /*!< 17 DMA interrupt */ RADIO_TXRX_IRQn = 18, /*!< 18 RADIO Tx/Rx interrupt */ RADIO_TIMER_ERROR_IRQn = 20, /*!< 20 RADIO TIMER Error interrupt */ + RADIO_RRM_IRQn = 22, /*!< 22 RADIO Resource Manager interrupt */ RADIO_TIMER_CPU_WKUP_IRQn = 23, /*!< 23 RADIO TIMER CPU Wakeup interrupt */ RADIO_TIMER_TXRX_WKUP_IRQn = 24, /*!< 24 RADIO TIMER Tx/Rx Wakeup interrupt */ RADIO_TXRX_SEQ_IRQn = 25, /*!< 25 RADIO Tx/Rx sequence interrupt */ diff --git a/stm32cube/stm32wb0x/soc/stm32wb0x.h b/stm32cube/stm32wb0x/soc/stm32wb0x.h index a1e39bc8f..01b922198 100644 --- a/stm32cube/stm32wb0x/soc/stm32wb0x.h +++ b/stm32cube/stm32wb0x/soc/stm32wb0x.h @@ -79,7 +79,7 @@ extern "C" { * @brief CMSIS Device version number */ #define __STM32WB0x_CMSIS_VERSION_MAIN (0x01U) /*!< [31:24] main version */ -#define __STM32WB0x_CMSIS_VERSION_SUB1 (0x01U) /*!< [23:16] sub1 version */ +#define __STM32WB0x_CMSIS_VERSION_SUB1 (0x04U) /*!< [23:16] sub1 version */ #define __STM32WB0x_CMSIS_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ #define __STM32WB0x_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */ #define __STM32WB0x_CMSIS_DEVICE_VERSION ((__STM32WB0x_CMSIS_VERSION_MAIN << 24)\ diff --git a/stm32cube/stm32wb0x/soc/system_stm32wb0x.c b/stm32cube/stm32wb0x/soc/system_stm32wb0x.c index 2c5b8bbb5..f52a5a1d6 100644 --- a/stm32cube/stm32wb0x/soc/system_stm32wb0x.c +++ b/stm32cube/stm32wb0x/soc/system_stm32wb0x.c @@ -97,14 +97,16 @@ #if defined(VECT_TAB_SRAM) #define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field. This value must be a multiple of 0x100. */ -#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. - This value must be a multiple of 0x100. */ #else #define VECT_TAB_BASE_ADDRESS NVM_BASE /*!< Vector Table base address field. This value must be a multiple of 0x100. */ -#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. - This value must be a multiple of 0x100. */ #endif /* VECT_TAB_SRAM */ + +#if !defined(VECT_TAB_OFFSET) +#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table offset field. + This value must be a multiple of 0x100. */ +#endif /* VECT_TAB_OFFSET */ + #endif /* USER_VECT_TAB_ADDRESS */ /******************************************************************************/ From 9f13405368d8f257b8e207a6fa241452d04beba8 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Fri, 12 Dec 2025 12:11:08 +0100 Subject: [PATCH 09/11] lib/stm32: update stm32wb0 to cube version V1.4.0 Update Cube version for STM32WB0x series on https://github.com/STMicroelectronics from version v1.1.0 to version v1.4.0 Signed-off-by: Etienne Carriere --- .../BLE_TransparentMode/Core/Inc/app_conf.h | 27 +- .../Core/Src/stm32wb0x_hal_msp.c | 119 +- .../STM32_BLE/App/aci_adv_nwk.c | 5 + .../STM32_BLE/App/app_ble.h | 2 +- .../STM32_BLE/App/dtm_cmd_db.c | 58 +- .../STM32_BLE/App/dtm_cmd_db.h | 1 + .../STM32_BLE/App/dtm_cmd_en.h | 2 + .../STM32_BLE/App/dtm_cmd_stack_en.h | 172 +- .../STM32_BLE/App/dtm_cmds.c | 53 +- .../STM32_BLE/App/transport_layer.c | 16 + .../STM32_BLE/Target/bleplat_cntr.c | 244 +-- .../BLE/Modules/RADIO_utils/Src/RADIO_utils.c | 22 +- lib/stm32wb0/README.rst | 4 +- .../stack/config/ble_stack_user_cfg.c | 1566 ++++++++++------- .../STM32_BLE/stack/include/ble_api.h | 662 +++---- .../STM32_BLE/stack/include/ble_gatt.h | 4 +- .../STM32_BLE/stack/include/ble_stack.h | 178 +- .../stack/include/ble_stack_user_cfg.h | 695 +++++--- .../STM32_BLE/stack/include/bleplat_cntr.h | 4 +- zephyr/module.yml | 6 +- 20 files changed, 2222 insertions(+), 1618 deletions(-) diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_conf.h b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_conf.h index cbc08d21f..93d3ba997 100644 --- a/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_conf.h +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_conf.h @@ -61,10 +61,11 @@ #ifndef __ZEPHYR__ /* It is handled by CMakeLists.txt */ #define CFG_BLE_NUM_RADIO_TASKS (CFG_NUM_RADIO_TASKS) -#endif +#endif /* __ZEPHYR__ */ /** - * Maximum number of Attributes that can be stored in the GATT database. + * Maximum number of attributes that can be stored in the GATT database in addition to the attributes number already defined for the GATT and GAP services + * (BLE_STACK_NUM_GATT_MANDATORY_ATTRIBUTES value on STM32_BLE middleware, ble_stack.h header file). */ #define CFG_BLE_NUM_GATT_ATTRIBUTES (60) @@ -108,7 +109,7 @@ */ #ifndef __ZEPHYR__ #define CFG_BLE_NUM_EATT_CHANNELS (6) -#endif +#endif /* __ZEPHYR__ */ /** * Maximum number of channels in LE Credit Based Flow Control mode [0-255]. @@ -129,7 +130,7 @@ #ifndef __ZEPHYR__ /* It is handled by CMakeLists.txt */ #define CFG_BLE_NUM_ADV_SETS (2) -#endif +#endif /* __ZEPHYR__ */ /** * Maximum number of Periodic Advertising with Responses subevents. @@ -147,7 +148,7 @@ */ #ifndef __ZEPHYR__ #define CFG_BLE_NUM_AUX_SCAN_SLOTS (4) -#endif +#endif /* __ZEPHYR__ */ /** * Maximum number of slots for synchronizing to a periodic advertising train, @@ -156,7 +157,7 @@ #ifndef __ZEPHYR__ /* It is handled by CMakeLists.txt */ #define CFG_BLE_NUM_SYNC_SLOTS (2) -#endif +#endif /* __ZEPHYR__ */ /** * Two's logarithm of Filter Accept, Resolving and Advertiser list size. @@ -206,6 +207,12 @@ #define CFG_BLE_NUM_CIS_MAX (2U) #endif /* __ZEPHYR__ */ +/** +* Maximum number of simultaneous Link Layer procedures that can be managed, in addition to the minimum required by the stack. +* The minimum number guarantees one LL procedure initiated by the peer for each link, one LL procedure automatically initiated by the Controller and one LL procedure initiated by the Host. +*/ +#define CFG_BLE_EXTRA_LL_PROCEDURE_CONTEXTS (0) + /** * Size of the internal FIFO used for critical controller events produced by the * ISR (e.g. rx data packets). @@ -266,6 +273,7 @@ CFG_BLE_NUM_BRC_BIS_MAX,\ CFG_BLE_NUM_CIG_MAX,\ CFG_BLE_NUM_CIS_MAX,\ + CFG_BLE_EXTRA_LL_PROCEDURE_CONTEXTS,\ CFG_BLE_ISR0_FIFO_SIZE,\ CFG_BLE_ISR1_FIFO_SIZE,\ CFG_BLE_USER_FIFO_SIZE)) @@ -329,7 +337,7 @@ #define CFG_BLE_CONTROLLER_BIS_ENABLED (1U) #define CFG_BLE_CONNECTION_SUBRATING_ENABLED (1U) #define CFG_BLE_CONTROLLER_CIS_ENABLED (1U) -#endif +#endif /* __ZEPHYR__ */ /****************************************************************************** * Low Power @@ -338,12 +346,17 @@ * low power mode. It means that all what can have an impact on the consumptions * are powered down.(For instance LED, Access to Debugger, Etc.) * + * When CFG_LPM_SUPPORTED and CFG_FULL_LOW_EMULATED are both set to 1, the system is configured to + * emulate the Deepstop mode without losing the debugger connection and breakpoints nor watchpoints. + * ******************************************************************************/ #define CFG_FULL_LOW_POWER (0) #define CFG_LPM_SUPPORTED (1) +#define CFG_LPM_EMULATED (0) + /** * Low Power configuration */ diff --git a/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c b/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c index ab2f82a9d..c3966774c 100644 --- a/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c +++ b/lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c @@ -86,70 +86,70 @@ void HAL_MspInit(void) } /** -* @brief PKA MSP Initialization -* This function configures the hardware resources used in this example -* @param hpka: PKA handle pointer -* @retval None -*/ + * @brief PKA MSP Initialization + * This function configures the hardware resources used in this example + * @param hpka: PKA handle pointer + * @retval None + */ void HAL_PKA_MspInit(PKA_HandleTypeDef* hpka) { if(hpka->Instance==PKA) { - /* USER CODE BEGIN PKA_MspInit 0 */ + /* USER CODE BEGIN PKA_MspInit 0 */ - /* USER CODE END PKA_MspInit 0 */ + /* USER CODE END PKA_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_PKA_CLK_ENABLE(); /* PKA interrupt Init */ HAL_NVIC_SetPriority(PKA_IRQn, 1, 0); HAL_NVIC_EnableIRQ(PKA_IRQn); - /* USER CODE BEGIN PKA_MspInit 1 */ + /* USER CODE BEGIN PKA_MspInit 1 */ - /* USER CODE END PKA_MspInit 1 */ + /* USER CODE END PKA_MspInit 1 */ } } /** -* @brief PKA MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hpka: PKA handle pointer -* @retval None -*/ + * @brief PKA MSP De-Initialization + * This function freeze the hardware resources used in this example + * @param hpka: PKA handle pointer + * @retval None + */ void HAL_PKA_MspDeInit(PKA_HandleTypeDef* hpka) { if(hpka->Instance==PKA) { - /* USER CODE BEGIN PKA_MspDeInit 0 */ + /* USER CODE BEGIN PKA_MspDeInit 0 */ - /* USER CODE END PKA_MspDeInit 0 */ + /* USER CODE END PKA_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_PKA_CLK_DISABLE(); /* PKA interrupt DeInit */ HAL_NVIC_DisableIRQ(PKA_IRQn); - /* USER CODE BEGIN PKA_MspDeInit 1 */ + /* USER CODE BEGIN PKA_MspDeInit 1 */ - /* USER CODE END PKA_MspDeInit 1 */ + /* USER CODE END PKA_MspDeInit 1 */ } } /** -* @brief RADIO MSP Initialization -* This function configures the hardware resources used in this example -* @param hradio: RADIO handle pointer -* @retval None -*/ + * @brief RADIO MSP Initialization + * This function configures the hardware resources used in this example + * @param hradio: RADIO handle pointer + * @retval None + */ void HAL_RADIO_MspInit(RADIO_HandleTypeDef* hradio) { RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hradio->Instance==RADIO) { - /* USER CODE BEGIN RADIO_MspInit 0 */ + /* USER CODE BEGIN RADIO_MspInit 0 */ - /* USER CODE END RADIO_MspInit 0 */ + /* USER CODE END RADIO_MspInit 0 */ /** Initializes the peripherals clock */ @@ -176,27 +176,29 @@ void HAL_RADIO_MspInit(RADIO_HandleTypeDef* hradio) HAL_NVIC_EnableIRQ(RADIO_TXRX_IRQn); HAL_NVIC_SetPriority(RADIO_TXRX_SEQ_IRQn, 0, 0); HAL_NVIC_EnableIRQ(RADIO_TXRX_SEQ_IRQn); - /* USER CODE BEGIN RADIO_MspInit 1 */ + HAL_NVIC_SetPriority(RADIO_RRM_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(RADIO_RRM_IRQn); + /* USER CODE BEGIN RADIO_MspInit 1 */ - /* USER CODE END RADIO_MspInit 1 */ + /* USER CODE END RADIO_MspInit 1 */ } } /** -* @brief RADIO MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hradio: RADIO handle pointer -* @retval None -*/ + * @brief RADIO MSP De-Initialization + * This function freeze the hardware resources used in this example + * @param hradio: RADIO handle pointer + * @retval None + */ void HAL_RADIO_MspDeInit(RADIO_HandleTypeDef* hradio) { if(hradio->Instance==RADIO) { - /* USER CODE BEGIN RADIO_MspDeInit 0 */ + /* USER CODE BEGIN RADIO_MspDeInit 0 */ - /* USER CODE END RADIO_MspDeInit 0 */ + /* USER CODE END RADIO_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_RADIO_CLK_DISABLE(); __HAL_RCC_RADIO_FORCE_RESET(); @@ -205,28 +207,29 @@ void HAL_RADIO_MspDeInit(RADIO_HandleTypeDef* hradio) /* RADIO interrupt DeInit */ HAL_NVIC_DisableIRQ(RADIO_TXRX_IRQn); HAL_NVIC_DisableIRQ(RADIO_TXRX_SEQ_IRQn); - /* USER CODE BEGIN RADIO_MspDeInit 1 */ + HAL_NVIC_DisableIRQ(RADIO_RRM_IRQn); + /* USER CODE BEGIN RADIO_MspDeInit 1 */ - /* USER CODE END RADIO_MspDeInit 1 */ + /* USER CODE END RADIO_MspDeInit 1 */ } } /** -* @brief UART MSP Initialization -* This function configures the hardware resources used in this example -* @param huart: UART handle pointer -* @retval None -*/ + * @brief UART MSP Initialization + * This function configures the hardware resources used in this example + * @param huart: UART handle pointer + * @retval None + */ #ifndef __ZEPHYR__ void HAL_UART_MspInit(UART_HandleTypeDef* huart) { GPIO_InitTypeDef GPIO_InitStruct = {0}; if(huart->Instance==USART1) { - /* USER CODE BEGIN USART1_MspInit 0 */ + /* USER CODE BEGIN USART1_MspInit 0 */ - /* USER CODE END USART1_MspInit 0 */ + /* USER CODE END USART1_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_USART1_CLK_ENABLE(); @@ -250,9 +253,13 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) GPIO_InitStruct.Alternate = GPIO_AF2_USART1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - LL_PWR_SetNoPullB(LL_PWR_GPIO_BIT_0); + HAL_PWREx_DisableGPIOPullUp(PWR_GPIO_B, PWR_GPIO_BIT_0); + + HAL_PWREx_DisableGPIOPullUp(PWR_GPIO_A, PWR_GPIO_BIT_1); - LL_PWR_SetNoPullA(LL_PWR_GPIO_BIT_1); + HAL_PWREx_DisableGPIOPullDown(PWR_GPIO_B, PWR_GPIO_BIT_0); + + HAL_PWREx_DisableGPIOPullDown(PWR_GPIO_A, PWR_GPIO_BIT_1); /* USART1 DMA Init */ /* USART1_TX Init */ @@ -292,27 +299,27 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) /* USART1 interrupt Init */ HAL_NVIC_SetPriority(USART1_IRQn, 2, 0); HAL_NVIC_EnableIRQ(USART1_IRQn); - /* USER CODE BEGIN USART1_MspInit 1 */ + /* USER CODE BEGIN USART1_MspInit 1 */ - /* USER CODE END USART1_MspInit 1 */ + /* USER CODE END USART1_MspInit 1 */ } } /** -* @brief UART MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param huart: UART handle pointer -* @retval None -*/ + * @brief UART MSP De-Initialization + * This function freeze the hardware resources used in this example + * @param huart: UART handle pointer + * @retval None + */ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) { if(huart->Instance==USART1) { - /* USER CODE BEGIN USART1_MspDeInit 0 */ + /* USER CODE BEGIN USART1_MspDeInit 0 */ - /* USER CODE END USART1_MspDeInit 0 */ + /* USER CODE END USART1_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_USART1_CLK_DISABLE(); @@ -330,9 +337,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) /* USART1 interrupt DeInit */ HAL_NVIC_DisableIRQ(USART1_IRQn); - /* USER CODE BEGIN USART1_MspDeInit 1 */ + /* USER CODE BEGIN USART1_MspDeInit 1 */ - /* USER CODE END USART1_MspDeInit 1 */ + /* USER CODE END USART1_MspDeInit 1 */ } } diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.c index 903ffd282..a7049700b 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.c +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.c @@ -212,6 +212,11 @@ tBleStatus hci_le_set_periodic_advertising_subevent_data(uint8_t Advertising_Han return BLE_ERROR_UNKNOWN_ADVERTISING_IDENTIFIER; } + if ((Num_Subevents == 0) || (Num_Subevents > 0x0F)) + { + return BLE_ERROR_INVALID_HCI_CMD_PARAMS; + } + if(pawr_buff_subevent_num_available() < Num_Subevents) { /* This happens is host has given more data than what requested by the Controller. */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/app_ble.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/app_ble.h index 7a3d45a3b..323acd359 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/app_ble.h +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/app_ble.h @@ -106,7 +106,7 @@ typedef enum /* Transparent Mode/DTM version (Bluetooth LE stack v4.x) */ #define DTM_FW_VERSION_MAJOR 1 -#define DTM_FW_VERSION_MINOR 1 +#define DTM_FW_VERSION_MINOR 2 #define DTM_FW_VERSION_PATCH 0 #define UART_INTERFACE diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c index 19db5461f..9f1badd32 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.c @@ -3,7 +3,7 @@ ****************************************************************************** * @file DTM_cmd_db.c * @author AMS - RF Application team - * @date 29 August 2024 + * @date 17 June 2025 * @brief Autogenerated files, do not edit!! ****************************************************************************** * @attention @@ -3212,6 +3212,7 @@ uint16_t aci_hal_tone_stop_process(uint8_t *buffer_in, uint16_t buffer_in_length uint16_t aci_hal_get_link_status_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_hal_set_radio_activity_mask_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_hal_set_le_power_control_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); +uint16_t aci_hal_updater_start_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_hal_transmitter_test_packets_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_hal_transmitter_test_packets_v2_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); uint16_t aci_hal_write_radio_reg_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length); @@ -3932,6 +3933,10 @@ const hci_command_table_type hci_command_table[] = { /* aci_hal_set_le_power_control */ {0xfc1c, aci_hal_set_le_power_control_process}, #endif +#if (!defined(ACI_HAL_UPDATER_START_ENABLED) || ACI_HAL_UPDATER_START_ENABLED) && !ACI_HAL_UPDATER_START_FORCE_DISABLED + /* aci_hal_updater_start */ + {0xfc20, aci_hal_updater_start_process}, +#endif #if (!defined(ACI_HAL_TRANSMITTER_TEST_PACKETS_ENABLED) || ACI_HAL_TRANSMITTER_TEST_PACKETS_ENABLED) && !ACI_HAL_TRANSMITTER_TEST_PACKETS_FORCE_DISABLED /* aci_hal_transmitter_test_packets */ {0xfc2b, aci_hal_transmitter_test_packets_process}, @@ -10145,6 +10150,16 @@ uint16_t aci_hal_get_fw_build_number_process(uint8_t *buffer_in, uint16_t buffer } #endif +#if (!defined(ACI_HAL_UPDATER_START_ENABLED) || ACI_HAL_UPDATER_START_ENABLED) && !ACI_HAL_UPDATER_START_DISABLED +tBleStatus aci_hal_updater_start(void) +{ + // For ACI_HAL_UPDATER_START, set flag to issue a updater start + RAM_VR.BlueFlag = BLUE_FLAG_RAM_RESET; + TL_ResetReqCallback(); + return BLE_STATUS_SUCCESS; +} +#endif + #if (!defined(ACI_HAL_GET_FIRMWARE_DETAILS_ENABLED) || ACI_HAL_GET_FIRMWARE_DETAILS_ENABLED) && !ACI_HAL_GET_FIRMWARE_DETAILS_FORCE_DISABLED /* tBleStatus aci_hal_get_firmware_details(uint8_t *DTM_version_major, uint8_t *DTM_version_minor, @@ -10632,6 +10647,37 @@ uint16_t aci_hal_set_le_power_control_process(uint8_t *buffer_in, uint16_t buffe } #endif +#if (!defined(ACI_HAL_UPDATER_START_ENABLED) || ACI_HAL_UPDATER_START_ENABLED) && !ACI_HAL_UPDATER_START_FORCE_DISABLED +/* tBleStatus aci_hal_updater_start(void); + */ +/* Command len: 0 */ +/* Response len: 1 */ +uint16_t aci_hal_updater_start_process(uint8_t *buffer_in, uint16_t buffer_in_length, uint8_t *buffer_out, uint16_t buffer_out_max_length) +{ + + int output_size = 1; + /* Output params */ + uint8_t *status = (uint8_t *) (buffer_out + 6); + + *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; + if (buffer_out_max_length < (1 + 6)) { return 0; } + if(buffer_in_length != 0) + { + goto fail; + } + + *status = aci_hal_updater_start(); +fail: + buffer_out[0] = 0x04; + buffer_out[1] = 0x0E; + buffer_out[2] = output_size + 3; + buffer_out[3] = 0x01; + buffer_out[4] = 0x20; + buffer_out[5] = 0xfc; + return (output_size + 6); +} +#endif + #if (!defined(ACI_HAL_TRANSMITTER_TEST_PACKETS_ENABLED) || ACI_HAL_TRANSMITTER_TEST_PACKETS_ENABLED) && !ACI_HAL_TRANSMITTER_TEST_PACKETS_FORCE_DISABLED /* tBleStatus aci_hal_transmitter_test_packets(uint8_t TX_Frequency, uint8_t Length_Of_Test_Data, @@ -10693,7 +10739,7 @@ uint16_t aci_hal_transmitter_test_packets_v2_process(uint8_t *buffer_in, uint16_ int output_size = 1; /* Output params */ - uint8_t *status = (uint8_t *) (buffer_out + 6); + uint8_t *status = (uint8_t *) (buffer_out + 3); *status = BLE_ERROR_INVALID_HCI_CMD_PARAMS; if (buffer_out_max_length < (1 + 6)) { return 0; } @@ -10713,11 +10759,11 @@ uint16_t aci_hal_transmitter_test_packets_v2_process(uint8_t *buffer_in, uint16_ cp0->Antenna_IDs /* cp0->Switching_Pattern_Length * (sizeof(uint8_t)) */); fail: buffer_out[0] = 0x04; - buffer_out[1] = 0x0E; + buffer_out[1] = 0x0F; buffer_out[2] = output_size + 3; - buffer_out[3] = 0x01; - buffer_out[4] = 0x2c; - buffer_out[5] = 0xfc; + buffer_out[4] = 0x01; + buffer_out[5] = 0x2c; + buffer_out[6] = 0xfc; return (output_size + 6); } #endif diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.h index 4bd5b302f..2a09cce67 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.h +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_db.h @@ -39,6 +39,7 @@ tBleStatus aci_hal_transmitter_test_packets(uint8_t TX_Frequency,uint8_t Length_ tBleStatus aci_hal_transmitter_test_packets_v2(uint8_t TX_Channel,uint8_t Test_Data_Length,uint8_t Packet_Payload,uint16_t Number_Of_Packets,uint8_t PHY,uint8_t CTE_Length,uint8_t CTE_Type,uint8_t Switching_Pattern_Length, uint8_t Antenna_IDs[]); tBleStatus aci_hal_write_radio_reg(uint32_t Start_Address, uint8_t Num_Bytes, uint8_t Data[]); tBleStatus aci_hal_read_radio_reg(uint32_t Start_Address, uint8_t Num_Bytes, uint8_t *Data_Length, uint8_t Data[]); +tBleStatus aci_hal_updater_start(void); tBleStatus hci_le_read_maximum_advertising_data_length(uint16_t *Maximum_Advertising_Data_Length); tBleStatus aci_test_tx_notification_start(uint16_t Connection_Handle, uint16_t Service_Handle, uint16_t Char_Handle, uint16_t Value_Length); tBleStatus aci_test_tx_write_command_start(uint16_t Connection_Handle, uint16_t Attr_Handle, uint16_t Value_Length); diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_en.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_en.h index 30b3e080d..beb7bd528 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_en.h +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_en.h @@ -92,6 +92,8 @@ #define ACI_TEST_REPORT_ENABLED\ (CONNECTION_ENABLED) +#define ACI_HAL_UPDATER_START_FORCE_DISABLED 1 + #if CONFIG_NO_HCI_COMMANDS /* Macros to force exclusion of some unnecessary HCI/ACI commands from DTM */ #define HCI_DISCONNECT_FORCE_DISABLED 1 diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_stack_en.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_stack_en.h index 396e19ade..657df9e3b 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_stack_en.h +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_stack_en.h @@ -228,8 +228,7 @@ (CONNECTION_ENABLED) #define HCI_LE_ACCEPT_CIS_REQUEST_ENABLED\ (CONNECTION_ENABLED &\ - CONTROLLER_CIS_ENABLED &\ - CONTROLLER_ISO_ENABLED) + CONTROLLER_CIS_ENABLED) #define HCI_LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST_ENABLED\ (CONTROLLER_SCAN_ENABLED &\ CONTROLLER_EXT_ADV_SCAN_ENABLED &\ @@ -240,14 +239,12 @@ (CONTROLLER_SCAN_ENABLED &\ CONTROLLER_EXT_ADV_SCAN_ENABLED &\ CONTROLLER_PERIODIC_ADV_ENABLED &\ - CONTROLLER_BIS_ENABLED &\ - CONTROLLER_ISO_ENABLED) + CONTROLLER_BIS_ENABLED) #define HCI_LE_BIG_TERMINATE_SYNC_ENABLED\ (CONTROLLER_SCAN_ENABLED &\ CONTROLLER_EXT_ADV_SCAN_ENABLED &\ CONTROLLER_PERIODIC_ADV_ENABLED &\ - CONTROLLER_BIS_ENABLED &\ - CONTROLLER_ISO_ENABLED) + CONTROLLER_BIS_ENABLED) #define HCI_LE_CLEAR_ADVERTISING_SETS_ENABLED\ (CONTROLLER_EXT_ADV_SCAN_ENABLED) #define HCI_LE_CLEAR_PERIODIC_ADVERTISER_LIST_ENABLED\ @@ -280,21 +277,18 @@ #define HCI_LE_CREATE_BIG_ENABLED\ (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ CONTROLLER_PERIODIC_ADV_ENABLED &\ - CONTROLLER_BIS_ENABLED &\ - CONTROLLER_ISO_ENABLED) + CONTROLLER_BIS_ENABLED) #define HCI_LE_CREATE_BIG_TEST_ENABLED\ (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ CONTROLLER_PERIODIC_ADV_ENABLED &\ - CONTROLLER_BIS_ENABLED &\ - CONTROLLER_ISO_ENABLED) + CONTROLLER_BIS_ENABLED) #define HCI_LE_CREATE_CIS_ENABLED\ (\ (CONNECTION_ENABLED == 1)\ &&\ (\ (CONNECTION_ENABLED == 1) &&\ - (CONTROLLER_CIS_ENABLED == 1) &&\ - (CONTROLLER_ISO_ENABLED == 1)\ + (CONTROLLER_CIS_ENABLED == 1)\ )\ &&\ (\ @@ -343,13 +337,57 @@ #define HCI_LE_GENERATE_DHKEY_ENABLED\ (CONNECTION_ENABLED) #define HCI_LE_ISO_READ_TEST_COUNTERS_ENABLED\ - (CONTROLLER_ISO_ENABLED) + (\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1)\ + )\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1)\ + )\ + ) #define HCI_LE_ISO_RECEIVE_TEST_ENABLED\ - (CONTROLLER_ISO_ENABLED) + (\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1)\ + )\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1)\ + )\ + ) #define HCI_LE_ISO_TEST_END_ENABLED\ - (CONTROLLER_ISO_ENABLED) + (\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1)\ + )\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1)\ + )\ + ) #define HCI_LE_ISO_TRANSMIT_TEST_ENABLED\ - (CONTROLLER_ISO_ENABLED) + (\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1)\ + )\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1)\ + )\ + ) #define HCI_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY_ENABLED\ (CONNECTION_ENABLED) #define HCI_LE_LONG_TERM_KEY_REQUEST_REPLY_ENABLED\ @@ -378,13 +416,46 @@ #define HCI_LE_READ_ANTENNA_INFORMATION_ENABLED\ (CONTROLLER_CTE_ENABLED) #define HCI_LE_READ_BUFFER_SIZE_V2_ENABLED\ - (CONTROLLER_ISO_ENABLED) + (\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1)\ + )\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1)\ + )\ + ) #define HCI_LE_READ_CHANNEL_MAP_ENABLED\ (CONNECTION_ENABLED) #define HCI_LE_READ_ISO_LINK_QUALITY_ENABLED\ - (CONTROLLER_ISO_ENABLED) + (\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1)\ + )\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1)\ + )\ + ) #define HCI_LE_READ_ISO_TX_SYNC_ENABLED\ - (CONTROLLER_ISO_ENABLED) + (\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1)\ + )\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1)\ + )\ + ) #define HCI_LE_READ_LOCAL_P256_PUBLIC_KEY_ENABLED\ (CONNECTION_ENABLED) #define HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS_ENABLED\ @@ -419,8 +490,7 @@ (CONTROLLER_CTE_ENABLED) #define HCI_LE_REJECT_CIS_REQUEST_ENABLED\ (CONNECTION_ENABLED &\ - CONTROLLER_CIS_ENABLED &\ - CONTROLLER_ISO_ENABLED) + CONTROLLER_CIS_ENABLED) #define HCI_LE_REMOVE_ADVERTISING_SET_ENABLED\ (CONTROLLER_EXT_ADV_SCAN_ENABLED) #define HCI_LE_REMOVE_CIG_ENABLED\ @@ -429,8 +499,7 @@ &&\ (\ (CONNECTION_ENABLED == 1) &&\ - (CONTROLLER_CIS_ENABLED == 1) &&\ - (CONTROLLER_ISO_ENABLED == 1)\ + (CONTROLLER_CIS_ENABLED == 1)\ )\ &&\ (\ @@ -451,11 +520,21 @@ #define HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST_ENABLED\ (CONTROLLER_PRIVACY_ENABLED) #define HCI_LE_REMOVE_ISO_DATA_PATH_ENABLED\ - (CONTROLLER_ISO_ENABLED) + (\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1)\ + )\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1)\ + )\ + ) #define HCI_LE_REQUEST_PEER_SCA_ENABLED\ (CONNECTION_ENABLED &\ - CONTROLLER_CIS_ENABLED &\ - CONTROLLER_ISO_ENABLED) + CONTROLLER_CIS_ENABLED) #define HCI_LE_SET_ADDRESS_RESOLUTION_ENABLE_ENABLED\ (CONTROLLER_PRIVACY_ENABLED) #define HCI_LE_SET_ADVERTISING_SET_RANDOM_ADDRESS_ENABLED\ @@ -466,8 +545,7 @@ &&\ (\ (CONNECTION_ENABLED == 1) &&\ - (CONTROLLER_CIS_ENABLED == 1) &&\ - (CONTROLLER_ISO_ENABLED == 1)\ + (CONTROLLER_CIS_ENABLED == 1)\ )\ &&\ (\ @@ -487,8 +565,7 @@ &&\ (\ (CONNECTION_ENABLED == 1) &&\ - (CONTROLLER_CIS_ENABLED == 1) &&\ - (CONTROLLER_ISO_ENABLED == 1)\ + (CONTROLLER_CIS_ENABLED == 1)\ )\ &&\ (\ @@ -611,15 +688,25 @@ (CONTROLLER_POWER_CONTROL_ENABLED &\ CONNECTION_ENABLED) #define HCI_LE_SETUP_ISO_DATA_PATH_ENABLED\ - (CONTROLLER_ISO_ENABLED) + (\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1)\ + )\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1)\ + )\ + ) #define HCI_LE_SUBRATE_REQUEST_ENABLED\ (CONNECTION_ENABLED &\ CONNECTION_SUBRATING_ENABLED) #define HCI_LE_TERMINATE_BIG_ENABLED\ (CONTROLLER_EXT_ADV_SCAN_ENABLED &\ CONTROLLER_PERIODIC_ADV_ENABLED &\ - CONTROLLER_BIS_ENABLED &\ - CONTROLLER_ISO_ENABLED) + CONTROLLER_BIS_ENABLED) #define HCI_LE_TRANSMITTER_TEST_V2_ENABLED\ (CONTROLLER_2M_CODED_PHY_ENABLED) #define HCI_LE_TRANSMITTER_TEST_V3_ENABLED\ @@ -637,8 +724,7 @@ (CONNECTION_ENABLED) #define HCI_READ_CONNECTION_ACCEPT_TIMEOUT_ENABLED\ (CONNECTION_ENABLED &\ - CONTROLLER_CIS_ENABLED &\ - CONTROLLER_ISO_ENABLED) + CONTROLLER_CIS_ENABLED) #define HCI_READ_REMOTE_VERSION_INFORMATION_ENABLED\ (CONNECTION_ENABLED) #define HCI_READ_RSSI_ENABLED\ @@ -646,7 +732,18 @@ #define HCI_READ_TRANSMIT_POWER_LEVEL_ENABLED\ (CONNECTION_ENABLED) #define HCI_TX_ISO_DATA_ENABLED\ - (CONTROLLER_ISO_ENABLED) + (\ + (\ + (CONNECTION_ENABLED == 1) &&\ + (CONTROLLER_CIS_ENABLED == 1)\ + )\ + ||\ + (\ + (CONTROLLER_EXT_ADV_SCAN_ENABLED == 1) &&\ + (CONTROLLER_PERIODIC_ADV_ENABLED == 1) &&\ + (CONTROLLER_BIS_ENABLED == 1)\ + )\ + ) #define HCI_WRITE_AFH_CHANNEL_ASSESSMENT_MODE_ENABLED\ (CONNECTION_ENABLED &\ CONTROLLER_CHAN_CLASS_ENABLED) @@ -654,7 +751,6 @@ (CONNECTION_ENABLED) #define HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT_ENABLED\ (CONNECTION_ENABLED &\ - CONTROLLER_CIS_ENABLED &\ - CONTROLLER_ISO_ENABLED) + CONTROLLER_CIS_ENABLED) #endif /* _DTM_CMD_STACK_EN_H_ */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c index b95e1dd58..2e4f6273f 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c @@ -20,6 +20,7 @@ #include "stm32wb0x.h" #include "ble_stack.h" +#include "dtm_cmds.h" #include "dtm_cmd_db.h" #include "transport_layer.h" #include "adv_buff_alloc.h" @@ -109,6 +110,10 @@ ((uint32_t)(CONTROLLER_PERIODIC_ADV_WR_ENABLED * CONTROLLER_PERIODIC_ADV_WR_BIT)) \ ) +/* irq_count used for the aci_hal_transmitter_test_packets() command implementation */ +uint16_t irq_count = 0; +uint16_t num_packets = 0; + tBleStatus aci_hal_get_firmware_details(uint8_t *DTM_version_major, uint8_t *DTM_version_minor, uint8_t *DTM_version_patch, @@ -191,7 +196,6 @@ tBleStatus aci_hal_transmitter_test_packets(uint8_t TX_Frequency, uint16_t Number_Of_Packets, uint8_t PHY) { - extern uint16_t num_packets; tBleStatus status; if(Number_Of_Packets == 0) @@ -215,7 +219,12 @@ tBleStatus aci_hal_transmitter_test_packets(uint8_t TX_Frequency, if(status == 0x00) { - num_packets = Number_Of_Packets; + num_packets = Number_Of_Packets - 1; /* Request to stop one packet before the end */ + + if(num_packets == 0) + { + DTM_CMDS_TxTestStopRequest(); + } } return status; @@ -247,7 +256,6 @@ tBleStatus aci_hal_transmitter_test_packets_v2(uint8_t TX_Channel, uint8_t Switching_Pattern_Length, uint8_t Antenna_IDs[]) { - extern uint16_t num_packets; tBleStatus status; if(Number_Of_Packets == 0) @@ -266,13 +274,50 @@ tBleStatus aci_hal_transmitter_test_packets_v2(uint8_t TX_Channel, if(status == 0x00) { - num_packets = Number_Of_Packets; + num_packets = Number_Of_Packets - 1; /* Request to stop one packet before the end */ + + if(num_packets == 0) + { + DTM_CMDS_TxTestStopRequest(); + } } return status; } #endif +/* It must be called at the end of a TX */ +void DTM_CMDS_TxEnd(void) +{ + if(irq_count != num_packets) + { + irq_count++; + + if(irq_count == num_packets) + { + DTM_CMDS_TxTestStopRequest(); + } + } +} + +/* Check if the desired number of packets has been sent and possibly send the + aci_hal_le_test_end_event. */ +void DTM_CMDS_TxTestStop(void) +{ + uint32_t Number_Of_TX_Packets = 0; + uint16_t Number_Of_RX_Packets; + + /* Reached number of tx test packets */ + hci_le_test_end(&Number_Of_RX_Packets); + aci_hal_le_tx_test_packet_number(&Number_Of_TX_Packets); + aci_hal_le_test_end_event(Number_Of_TX_Packets); + + ATOMIC_SECTION_BEGIN(); + irq_count = 0; + num_packets = 0; + ATOMIC_SECTION_END(); +} + #if (CONNECTION_ENABLED == 1) && (BLESTACK_CONTROLLER_ONLY==0) tBleStatus aci_test_tx_notification_start(uint16_t Connection_Handle, uint16_t Service_Handle, uint16_t Char_Handle, uint16_t Value_Length) diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.c index 24a64de53..672bc1eb4 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.c +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.c @@ -30,6 +30,7 @@ #include "hci_parser.h" #include "dtm_preprocess_events.h" #include "app_common.h" +#include "dtm_cmds.h" /* Private typedef -----------------------------------------------------------*/\ @@ -81,6 +82,8 @@ static uint8_t DMA_RX_Buffer[DMA_RX_BUFFER_SIZE]; static event_lost_register_t event_lost_register; static uint8_t dma_state = DMA_IDLE; +bool tx_test_stop_request = false; + #ifdef DEBUG_DTM DebugLabel debug_buf[DEBUG_ARRAY_LEN] = {EMPTY,}; uint32_t debug_cnt = 0; @@ -252,6 +255,12 @@ void transport_layer_tick(void) uint16_t len; uint16_t size = 0; + if(tx_test_stop_request) + { + tx_test_stop_request = false; + DTM_CMDS_TxTestStop(); + } + /* Event queue */ if ((fifo_size(&event_fifo) > 0) && (dma_state == DMA_IDLE)) { uint8_t *ptr; @@ -309,6 +318,7 @@ void transport_layer_tick(void) else { fifo_roll_back(&command_fifo, size); + TL_ProcessReqCallback(); } #else DEBUG_NOTES(COMMAND_PROCESSED); @@ -471,3 +481,9 @@ void BLE_STACK_Event(hci_pckt *hci_pckt, uint16_t length) } } +/* Handle request to stop TX test for aci_hal_transmitter_test_packets */ +void DTM_CMDS_TxTestStopRequest(void) +{ + tx_test_stop_request = true; + TL_ProcessReqCallback(); +} diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c index ae4a45eb2..098add778 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat_cntr.c @@ -40,11 +40,6 @@ * @{ */ -#define ATOMIC_SECTION_BEGIN() uint32_t uwPRIMASK_Bit = __get_PRIMASK(); \ -__disable_irq(); \ - /* Must be called in the same or in a lower scope of ATOMIC_SECTION_BEGIN */ -#define ATOMIC_SECTION_END() __set_PRIMASK(uwPRIMASK_Bit) - #define MAX_PA_LEVEL 31 #define HP_PA_LEVEL 32 /* Fake PA level that can be reached in high power mode. */ @@ -75,27 +70,11 @@ __disable_irq(); \ BLUE_STATUSREG_CONFIGERROR_Msk \ ) -#define WAKEUPINITDELAY_MT (64U) -#define TIMER12_INIT_DELAY_CAL (63U) -#define TIMER2_INIT_DELAY_NO_CAL (9U) -#define RCV_LEN_MARGIN_US (16U) -#define TX_DELAY_START (16U) -#define TX_DELAY_END (16U) - #define RADIO_FSM_RX_DELAY_CAL (116U) #define RADIO_FSM_RX_DELAY_NO_CAL (56U) #define RADIO_FSM_TX_DELAY_CAL (118U) #define RADIO_FSM_TX_DELAY_NO_CAL (58U) -#define RECEIVE_CAL_DELAY_CHECK (RADIO_FSM_RX_DELAY_CAL) -#define RECEIVE_NO_CAL_DELAY_CHECK (RADIO_FSM_RX_DELAY_NO_CAL) -#define TRANSMIT_CAL_DELAY_CHECK (RADIO_FSM_TX_DELAY_CAL) -#define TRANSMIT_NO_CAL_DELAY_CHECK (RADIO_FSM_TX_DELAY_NO_CAL) - -#define CONFIG_END_DURATION (20U) -#define TX_DATA_READY_CHECK (5U) -#define TX_READY_TIMEOUT (5U) - #elif defined (STM32WB05) || defined (STM32WB09) #define ANY_HW_ERROR_INTERRUPT_Msk ( \ @@ -114,27 +93,11 @@ __disable_irq(); \ BLUE_STATUSREG_CONFIGERROR_Msk \ ) -#define WAKEUPINITDELAY_MT (64U) -#define TIMER12_INIT_DELAY_CAL (63U) -#define TIMER2_INIT_DELAY_NO_CAL (9U) -#define RCV_LEN_MARGIN_US (16U) -#define TX_DELAY_START (16U) -#define TX_DELAY_END (16U) - #define RADIO_FSM_RX_DELAY_CAL (90U) #define RADIO_FSM_RX_DELAY_NO_CAL (50U) #define RADIO_FSM_TX_DELAY_CAL (92U) #define RADIO_FSM_TX_DELAY_NO_CAL (52U) -#define RECEIVE_CAL_DELAY_CHECK (RADIO_FSM_RX_DELAY_CAL) -#define RECEIVE_NO_CAL_DELAY_CHECK (RADIO_FSM_RX_DELAY_NO_CAL) -#define TRANSMIT_CAL_DELAY_CHECK (RADIO_FSM_TX_DELAY_CAL - 2U) -#define TRANSMIT_NO_CAL_DELAY_CHECK (RADIO_FSM_TX_DELAY_NO_CAL - 2U) - -#define CONFIG_END_DURATION (20U) -#define TX_DATA_READY_CHECK (5U) -#define TX_READY_TIMEOUT (4U) - #endif #ifndef LL_PHY_CODED @@ -154,8 +117,6 @@ __disable_irq(); \ #define PHY_CODED_S2 (0x6U) #define PHY_CODED_S8 (0x4U) -#define BIT_TX_SKIP (0x0UL) - /** * @} */ @@ -207,107 +168,151 @@ BLEPLAT_CNTR_ResultStatus BLEPLAT_CNTR_Deinit(void) return BLEPLAT_CNTR_SUCCESS; } -/* Moved from the Stack library to the application environment - * - */ /* Calculate the Timeout to be programmed on Timer2 to obtain a give T_IFS - * when the next packet is a transmit one -*/ -uint32_t BLEPLAT_CNTR_GetTimer2TimeoutForIfs(uint32_t T_Ifs, BLEPLAT_CNTR_Transaction Transaction, uint8_t Cal_Enabled) + when the next packet is a transmit one */ +uint32_t BLEPLAT_CNTR_GetTimer2TimeoutForIfs(uint32_t T_Ifs, BLEPLAT_CNTR_Transaction Transaction, uint8_t Rx_Phy, uint8_t Tx_Phy, uint8_t Cal_Enabled) { - uint32_t Timeout = T_Ifs; - uint32_t Tx_Delay_Comp; - uint32_t Init_Delay=0; + uint32_t Timeout = T_Ifs; + uint32_t Tx_Delay_Comp; + uint32_t Init_Delay = 0; + + if(Transaction == BLEPLAT_CNTR_RxTx) + { + /* The correction values below have been determined by T_IFS measurements in + connection, initiating and active scanning */ +#if defined(STM32WB06) || defined(STM32WB07) + + const int32_t Adjust_Value = 4; - if(Transaction == BLEPLAT_CNTR_RxTx) +#elif defined (STM32WB05) || defined (STM32WB09) + + int32_t Adjust_Value; + + if((Rx_Phy == PHY_1MBPS) && + (Tx_Phy == PHY_1MBPS)) { - /* The correction values below have been determined by sniffer - * T_IFS measurements in connection, initiating and active - * scanning - */ -#ifdef STM32WB05 - const int32_t Adjust_Value = 4; -#else - const int32_t Adjust_Value = 6; -#endif - Tx_Delay_Comp = (TX_DELAY_START>>3) + Adjust_Value; + Adjust_Value = 4; } - else if(Transaction == BLEPLAT_CNTR_TxRx) + else if((Rx_Phy == PHY_1MBPS) && + (Tx_Phy == PHY_2MBPS)) { - /* The correction values below have been set to correspond to the hardcoded - * values used in prrevious versions of the stack. - * They could be optimized after careful analysis of timing margins and - * AGC behavior. - */ -#ifdef STM32WB05 - const int32_t Adjust_Value = 4; -#else - const int32_t Adjust_Value = 4; -#endif - Tx_Delay_Comp = (TX_DELAY_END>>3) + Adjust_Value; + Adjust_Value = 3; } - else if(Transaction == BLEPLAT_CNTR_TxTx) + else if((Rx_Phy == PHY_1MBPS) && + ((Tx_Phy == PHY_CODED_S2) || (Tx_Phy == PHY_CODED_S8))) { - /* The correction values below have been determined by sniffer - * T_IFS measurements in extended advertising (AUX_CHAIN_IND) - */ -#ifdef STM32WB05 - const int32_t Adjust_Value = 1; -#else - const int32_t Adjust_Value = 2; -#endif - Tx_Delay_Comp = ((TX_DELAY_START + TX_DELAY_END)>>3) + Adjust_Value; + Adjust_Value = 4; + } + else if((Rx_Phy == PHY_2MBPS) && + ((Tx_Phy == PHY_1MBPS) || (Tx_Phy == PHY_CODED_S2) || (Tx_Phy == PHY_CODED_S8))) + { + Adjust_Value = 6; + } + else if((Rx_Phy == PHY_2MBPS) && + (Tx_Phy == PHY_2MBPS)) + { + Adjust_Value = 4; + } + else if(((Rx_Phy == PHY_CODED_S2) || (Rx_Phy == PHY_CODED_S8)) && + (Tx_Phy == PHY_1MBPS)) + { + Adjust_Value = 5; + } + else if(((Rx_Phy == PHY_CODED_S2) || (Rx_Phy == PHY_CODED_S8)) && + (Tx_Phy == PHY_2MBPS)) + { + Adjust_Value = 4; + } + else if(((Rx_Phy == PHY_CODED_S2) || (Rx_Phy == PHY_CODED_S8)) && + ((Tx_Phy == PHY_CODED_S2) || (Tx_Phy == PHY_CODED_S8))) + { + Adjust_Value = 5; } else { - Tx_Delay_Comp = 0; + Adjust_Value = 6; } +#endif + + Tx_Delay_Comp = (RADIO_TXDELAY_START>>3) + Adjust_Value; + } + else if(Transaction == BLEPLAT_CNTR_TxRx) + { + /* The correction values below have been set to correspond to the hardcoded + values used in previous versions of the stack. + They could be optimized after careful analysis of timing margins and + AGC behavior. */ + const int32_t Adjust_Value = 4; + + Tx_Delay_Comp = (RADIO_TXDELAY_END>>3) + Adjust_Value; + } + else if(Transaction == BLEPLAT_CNTR_TxTx) + { + /* The correction values below have been determined by sniffer + * T_IFS measurements in extended advertising (AUX_CHAIN_IND) + */ +#if defined(STM32WB06) || defined(STM32WB07) + + const int32_t Adjust_Value = 1; - if((Transaction == BLEPLAT_CNTR_RxTx) || (Transaction == BLEPLAT_CNTR_TxTx)) +#elif defined (STM32WB05) || defined (STM32WB09) + + const int32_t Adjust_Value = 2; + +#endif + + Tx_Delay_Comp = ((RADIO_TXDELAY_START + RADIO_TXDELAY_END)>>3) + Adjust_Value; + } + else + { + Tx_Delay_Comp = 0; + } + + if((Transaction == BLEPLAT_CNTR_RxTx) || (Transaction == BLEPLAT_CNTR_TxTx)) + { + if(Cal_Enabled == TRUE) { - if(Cal_Enabled == TRUE) - { - Init_Delay = TIMER12_INIT_DELAY_CAL + RADIO_FSM_TX_DELAY_CAL; - } - else - { - Init_Delay = TIMER2_INIT_DELAY_NO_CAL + RADIO_FSM_TX_DELAY_NO_CAL; - } + Init_Delay = RADIO_INITDELAY_TIMER12_CAL + RADIO_FSM_TX_DELAY_CAL; } - else if((Transaction == BLEPLAT_CNTR_TxRx) || (Transaction == BLEPLAT_CNTR_RxRx)) + else { - /* The calculation below is based on the following sequence: + Init_Delay = RADIO_INITDELAY_TIMER2_NOCAL + RADIO_FSM_TX_DELAY_NO_CAL; + } + } + else if((Transaction == BLEPLAT_CNTR_TxRx) || (Transaction == BLEPLAT_CNTR_RxRx)) + { + /* The calculation below is based on the following sequence: * - When Timer2 expires the sequencer performs the 1st initialization step and sends - * a take_req to the radio - * - When TIMER12_INIT_DELAY_CAL or TIMER2_INIT_DELAY_NO_CAL expire the sequencer sends - * a tx_rx_req to the radio - * - When the radio FSM reaches the RX state (after RADIO_FSM_RX_DELAY_CAL or - * RADIO_FSM_RX_DELAY_NO_CAL) the demodulator is turned on - * - * The sum of Timer2 timeout + TIMER(1)2_INIT_DELAY(_NO)_CAL + RADIO_FSM_RX_DELAY(_NO)_CAL - * must be equal to the T IFS. - * - * The current calculation of Timer2 for TX-RX events is slightly conservative - * since it soes not consider the delay from digital modulator to antenna and from - * antenna to digital demodulator. As a consequence the demodulator is turned on - * a few microseconds earlier than stricty needed. - */ - if(Cal_Enabled == TRUE) - { - Init_Delay = TIMER12_INIT_DELAY_CAL + RADIO_FSM_RX_DELAY_CAL; - } - else - { - Init_Delay = TIMER2_INIT_DELAY_NO_CAL + RADIO_FSM_RX_DELAY_NO_CAL; - } + * a take_req to the radio + * - When RADIO_INITDELAY_TIMER12_CAL or RADIO_INITDELAY_TIMER2_NOCAL expire the sequencer sends + * a tx_rx_req to the radio + * - When the radio FSM reaches the RX state (after RADIO_FSM_RX_DELAY_CAL or + * RADIO_FSM_RX_DELAY_NO_CAL) the demodulator is turned on + * + * The sum of Timer2 timeout + TIMER(1)2_INIT_DELAY(_NO)_CAL + RADIO_FSM_RX_DELAY(_NO)_CAL + * must be equal to the T IFS. + * + * The current calculation of Timer2 for TX-RX events is slightly conservative + * since it soes not consider the delay from digital modulator to antenna and from + * antenna to digital demodulator. As a consequence the demodulator is turned on + * a few microseconds earlier than stricty needed. + */ + if(Cal_Enabled == TRUE) + { + Init_Delay = RADIO_INITDELAY_TIMER12_CAL + RADIO_FSM_RX_DELAY_CAL; } else { + Init_Delay = RADIO_INITDELAY_TIMER2_NOCAL + RADIO_FSM_RX_DELAY_NO_CAL; } + } + else + { + } - Timeout -= (Init_Delay + Tx_Delay_Comp); + Timeout -= (Init_Delay + Tx_Delay_Comp); - return Timeout; + return Timeout; } void BLEPLAT_CNTR_ClearInterrupt(uint32_t x) @@ -1241,6 +1246,11 @@ uint8_t BLEPLAT_CNTR_DemodDelaySt(uint8_t RxPHY) return (uint8_t)((LL_PHY_CODED == RxPHY) ? 0x9DU : 0x12U); } +uint32_t BLEPLAT_CNTR_IsEnabledTimer1(void) +{ + return LL_RADIO_TIMER_IsEnabledTimer1(BLUE); +} + /** * @} */ diff --git a/lib/stm32wb0/Common/BLE/Modules/RADIO_utils/Src/RADIO_utils.c b/lib/stm32wb0/Common/BLE/Modules/RADIO_utils/Src/RADIO_utils.c index 4f09cc043..c5f424670 100644 --- a/lib/stm32wb0/Common/BLE/Modules/RADIO_utils/Src/RADIO_utils.c +++ b/lib/stm32wb0/Common/BLE/Modules/RADIO_utils/Src/RADIO_utils.c @@ -67,25 +67,25 @@ /* Expected TX output power (dBm) for each PA level when SMPS voltage is 1.4V */ static const int8_t normal_pa_level_table[TX_POWER_LEVELS] = { - -54, -21, -20, -19, -17, -16, -15, -14, - -13, -12, -11, -10, -9, -8, -7, -6, - -6, -4, -3, -3, -2, -2, -1, -1, - 0, 0, 1, 2, 3, 4, 5, 6 + -60, -23, -22, -21, -20, -18, -17, -16, + -15, -14, -13, -13, -12, -11, -10, -9, + -8, -7, -6, -5, -4, -3, -3, -2, + -1, 0, 2, 3, 4, 5, 5, 6 }; #if defined(STM32WB09) static const int8_t high_power_pa_level_table[HP_TX_POWER_LEVELS] = { - -54, -21, -20, -19, -17, -16, -15, -14, - -13, -12, -11, -10, -9, -8, -7, -6, - -6, -4, -3, -3, -2, -2, -1, -1, - 0, 0, 1, 2, 3, 4, 5, 6, - 8 + -60, -24, -23, -22, -21, -19, -18, -17, + -16, -15, -14, -13, -12, -11, -10, -9, + -8, -7, -6, -5, -4, -4, -3, -2, + -1, 0, 1, 2, 3, 4, 5, 6, + 7 }; #else /* Expected TX output power (dBm) for each PA level when SMPS voltage is 1.9V (high power mode). */ static const int8_t high_power_pa_level_table[HP_TX_POWER_LEVELS] = { - -54, -19, -18, -17, -16, -15, -14, -13, + -60, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -3, -2, -1, 0, 1, 2, 3, 8, 8, 8, 8, 8, 8, 8 @@ -344,7 +344,7 @@ int8_t RADIO_UpdateAvgRSSI(int8_t avg_rssi, int8_t rssi, uint8_t rssi_filter_coe void RADIO_AntIdxRemap(uint8_t AntPattLen, uint8_t *pAntRamTable, const uint8_t* pAntPatt) { -#if defined(STM32WB07) || defined(STM32WB06) || defined(STM32WB09) +#if defined(STM32WB05) || defined(STM32WB09) for (uint8_t i=0; i 0U) ? \ - (12U + 4U) \ - : 0U) - -#define BLE_STACK_BIG_SIZE(NUM_BRC_BIG, NUM_BRC_BIS, NUM_SYNC_BIG, NUM_SYNC_BIS) ((((NUM_BRC_BIG) + (NUM_SYNC_BIG)) > 0U) ? \ - (248U * (NUM_BRC_BIG) + \ - 8U * (NUM_BRC_BIG) * (NUM_BRC_BIS) + \ - 296U * (NUM_SYNC_BIG) + \ - 20U * (NUM_SYNC_BIS) * (NUM_SYNC_BIG)) \ - : 0U) - -#define BLE_STACK_CIG_SIZE(NUM_CIG, NUM_CIS) (((NUM_CIG) > 0U) ? \ - (16U + 56U + \ - 168U * (NUM_CIG) + \ - 192U * (NUM_CIS)) \ - : 0U) +#define BLE_STACK_ISO_CMN(NUM_ISO_GROUPS) (((NUM_ISO_GROUPS) > 0U) ? \ + (12U + 56U * (NUM_ISO_GROUPS)) \ + : 0U) +#define BLE_STACK_BIG_SIZE(BIS_EN, SYNC_EN, NUM_BRC_BIG, NUM_BRC_BIS, NUM_SYNC_BIG, NUM_SYNC_BIS) \ + (((BIS_EN) > 0U) ? \ + ((244U + 8U * (NUM_BRC_BIS)) * (NUM_BRC_BIG) + \ + (((SYNC_EN) > 0U) ? \ + ((280U + 20U * (NUM_SYNC_BIS)) * (NUM_SYNC_BIG)) \ + : 0U)) \ + : 0U) + +#define BLE_STACK_CIG_SIZE(CONN_SUPP_EN, NUM_CIG, NUM_CIS) ((((NUM_CIG) > 0U) && ((CONN_SUPP_EN) != 0U)) ? \ + (56U + \ + 128U * (NUM_CIG) + \ + 180U * (NUM_CIS)) \ + : 0U) #define BLE_STACK_ISOAL_SIZE(NUM_TX_STREAMS, NUM_RX_STREAMS) ((((NUM_TX_STREAMS) + (NUM_RX_STREAMS)) > 0U) ? \ - (20U + \ - 12U * ((NUM_TX_STREAMS) + (NUM_RX_STREAMS)) + \ - 52U * (NUM_TX_STREAMS) + \ - 28U * (NUM_RX_STREAMS)) \ + (24U + \ + 60U * (NUM_TX_STREAMS) + \ + 40U * (NUM_RX_STREAMS)) \ : 0U) -#define BLE_STACK_ISO_SIZE(NUM_BRC_BIG, NUM_BRC_BIS, NUM_SYNC_BIG, NUM_SYNC_BIS, NUM_CIG, NUM_CIS) \ - (BLE_STACK_ISO_CMN_SIZE(NUM_BRC_BIG, NUM_SYNC_BIG, NUM_CIG) + \ - BLE_STACK_BIG_SIZE(NUM_BRC_BIG, NUM_BRC_BIS, NUM_SYNC_BIG, NUM_SYNC_BIS) + \ - BLE_STACK_CIG_SIZE(NUM_CIG, NUM_CIS) + \ +#define BLE_STACK_ISO_SIZE(EXT_ADV_SCN_EN, PER_ADV_SCN_EN, SCN_EN, CONN_SUPP_EN, NUM_BRC_BIG, NUM_BRC_BIS, NUM_SYNC_BIG, NUM_SYNC_BIS, NUM_CIG, NUM_CIS) \ + (BLE_STACK_ISO_CMN((NUM_BRC_BIG) + (NUM_SYNC_BIG) + (NUM_CIG)) + \ + BLE_STACK_BIG_SIZE(((EXT_ADV_SCN_EN) + (PER_ADV_SCN_EN)), SCN_EN, NUM_BRC_BIG, NUM_BRC_BIS, NUM_SYNC_BIG, NUM_SYNC_BIS) + \ + BLE_STACK_CIG_SIZE(CONN_SUPP_EN, NUM_CIG, NUM_CIS) + \ BLE_STACK_ISOAL_SIZE((NUM_BRC_BIG) * (NUM_BRC_BIS) + (NUM_CIS), \ (NUM_SYNC_BIG) * (NUM_SYNC_BIS) + (NUM_CIS))) @@ -196,16 +185,18 @@ * - a part, that may be considered "fixed", i.e., independent from the above * mentioned parameters. */ -# define BLE_STACK_FIXED_BUFFER_SIZE_BYTES (978U) +# define BLE_STACK_FIXED_BUFFER_SIZE_BYTES (1058U) /** * Amount of memory needed by each radio link */ -# define COEFF_CONN_SUPP_EN (848U + BLE_STACK_GATT_ATTRIBUTE_SIZE * BLE_STACK_NUM_GATT_MANDATORY_ATTRIBUTES) -# define COEFF_NUM_OF_LINKS_0 (48U) -# define COEFF_NUM_OF_LINKS_1 (656U) +# define COEFF_CONN_SUPP_EN (980U + BLE_STACK_GATT_ATTRIBUTE_SIZE * BLE_STACK_NUM_GATT_MANDATORY_ATTRIBUTES) +# define COEFF_NUM_OF_LINKS_0 (8U) +# define COEFF_NUM_OF_LINKS_1 (664U) # define BLE_STACK_LINKS_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) \ - (((CONN_SUPP_EN) == 1U) || ((NUM_OF_LINKS) > 0U) ? COEFF_CONN_SUPP_EN * (CONN_SUPP_EN) + COEFF_NUM_OF_LINKS_0 * (NUM_OF_LINKS) + COEFF_NUM_OF_LINKS_1 * (CONN_SUPP_EN) * (NUM_OF_LINKS) : 0U) + (((CONN_SUPP_EN) == 1U) || ((NUM_OF_LINKS) > 0U) ? COEFF_CONN_SUPP_EN * (CONN_SUPP_EN) + \ + COEFF_NUM_OF_LINKS_0 * (NUM_OF_LINKS) + \ + COEFF_NUM_OF_LINKS_1 * (CONN_SUPP_EN) * (NUM_OF_LINKS) : 0U) /** * Amount of memory needed for mem. blocks allocated for connections @@ -223,7 +214,7 @@ * subtracted from the total */ # define BLE_STACK_CONTROLLER_EXT_ADV_SIZE(ENABLED, NUM_ADV_SET, NUM_AUX_EVENT, NUM_OF_LINKS) \ - (((ENABLED) == 1U) ? -276U + 368U * (NUM_ADV_SET) + 0U * (NUM_AUX_EVENT) + 0U * (NUM_OF_LINKS) : 0U) + (((ENABLED) == 1U) ? -304U + 396U * (NUM_ADV_SET) + 0U * (NUM_AUX_EVENT) + 0U * (NUM_OF_LINKS) : 0U) /** * Amount of memory needed for the Filter Accept List and, if connections are supported, also for connection ID list @@ -245,10 +236,10 @@ * Amount of memory needed to support periodic advertising and synchronizing feature */ # define BLE_STACK_CONTROLLER_PERIODIC_ADV_WR_SIZE(PER_ADV_WR_EN, CONN_SUPP_EN, NUM_ADV_SET, NUM_SUBEVENTS_PAWR, MAX_SUBEVENT_DATA_COUNT_PAWR) \ - ((((PER_ADV_WR_EN) == 1U) && ((CONN_SUPP_EN) == 1U)) ? (132U + 8U * (NUM_SUBEVENTS_PAWR) + 16U * (MAX_SUBEVENT_DATA_COUNT_PAWR)) * (NUM_ADV_SET) : 0U) + ((((PER_ADV_WR_EN) == 1U) && ((CONN_SUPP_EN) == 1U)) ? (228U + 12U * (NUM_SUBEVENTS_PAWR) + 16U * (MAX_SUBEVENT_DATA_COUNT_PAWR)) * (NUM_ADV_SET) : 0U) # define BLE_STACK_CONTROLLER_PERIODIC_ADV_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_LINKS, NUM_ADV_SET, NUM_SUBEVENTS_PAWR, MAX_SUBEVENT_DATA_COUNT_PAWR) \ - (((PER_ADV_EN) == 1U) ? (156U * (NUM_ADV_SET) + 32U * (NUM_LINKS) + \ + (((PER_ADV_EN) == 1U) ? (204U * (NUM_ADV_SET) + 32U * (NUM_LINKS) + \ BLE_STACK_CONTROLLER_PERIODIC_ADV_WR_SIZE(PER_ADV_WR_EN, CONN_SUPP_EN, NUM_ADV_SET, NUM_SUBEVENTS_PAWR, MAX_SUBEVENT_DATA_COUNT_PAWR)) : \ 0U) @@ -257,19 +248,19 @@ */ # define BLE_STACK_BASE_SIZE(CONN_SUPP_EN) (((CONN_SUPP_EN) == 1U) ? 32U : 20U) -# define BLE_STACK_PAST_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) ? 24U * (NUM_OF_LINKS) : 0U) +# define BLE_STACK_PAST_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) ? 8U * (NUM_OF_LINKS) : 0U) # define BLE_STACK_PER_SYNC_SIZE(PER_ADV_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE)\ - (((PER_ADV_EN) == 1U) ? BLE_STACK_BASE_SIZE(CONN_SUPP_EN) + 144U * (NUM_SYNC_SLOTS) + 8U * (1U << (ADV_LIST_LIZE)) + BLE_STACK_PAST_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) : 0U) + (((PER_ADV_EN) == 1U) ? BLE_STACK_BASE_SIZE(CONN_SUPP_EN) + 192U * (NUM_SYNC_SLOTS) + 8U * (1U << (ADV_LIST_LIZE)) + BLE_STACK_PAST_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) : 0U) # define BLE_STACK_PER_SYNC_WR_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_SYNC_SUBEVENTS)\ - (((PER_ADV_WR_EN & PER_ADV_EN & CONN_SUPP_EN) == 1U) ? 176U * (NUM_SYNC_SLOTS) + ALIGN_32(NUM_SYNC_SUBEVENTS) : 0U) + (((PER_ADV_WR_EN & PER_ADV_EN & CONN_SUPP_EN) == 1U) ? 224U * (NUM_SYNC_SLOTS) + ALIGN_32(NUM_SYNC_SUBEVENTS) : 0U) # define BLE_STACK_CONTROLLER_SCAN_SIZE(SCAN_EN, EXT_ADV_EN, PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_AUX_EVENT,\ NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE, NUM_SYNC_SUBEVENTS) \ - (((SCAN_EN) == 1U) ? 324U + (192U + 48U * (NUM_AUX_EVENT) + \ - BLE_STACK_PER_SYNC_SIZE(PER_ADV_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE) + \ - BLE_STACK_PER_SYNC_WR_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_SYNC_SUBEVENTS)) * (EXT_ADV_EN) : 0U) + (((SCAN_EN) == 1U) ? 564U + (((EXT_ADV_EN) == 1U ) ? (192U + 96U * (NUM_AUX_EVENT) + \ + BLE_STACK_PER_SYNC_SIZE(PER_ADV_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE) + \ + BLE_STACK_PER_SYNC_WR_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_SYNC_SUBEVENTS)) : 0U) : 0U) /** @@ -302,7 +293,7 @@ /** * Amount of memory needed to support PCL feature */ -# define BLE_STACK_PCL_NUM_OF_LINKS(NUM_OF_LINKS) (32U * (NUM_OF_LINKS)) +# define BLE_STACK_PCL_NUM_OF_LINKS(NUM_OF_LINKS) (36U * (NUM_OF_LINKS)) # define BLE_STACK_PCL_SIZE(CONN_SUPP_EN, PCL_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) && ((PCL_EN) == 1U) ? 20U + BLE_STACK_PCL_NUM_OF_LINKS(NUM_OF_LINKS) : 0U) /** @@ -311,10 +302,15 @@ # define BLE_STACK_CHC_NUM_OF_LINKS(NUM_OF_LINKS) (28U * (NUM_OF_LINKS)) # define BLE_STACK_CHC_SIZE(CONN_SUPP_EN, CHC_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) && ((CHC_EN) == 1U) ? BLE_STACK_CHC_NUM_OF_LINKS(NUM_OF_LINKS) : 0U) +/** + * Amount of memory needed for Link Layer extra Control Procedure contexts + */ +# define BLE_STACK_EXTRA_LL_PROCEDURE_CONTEXTS_SIZE(CONN_SUPP_EN, EXTRA_LL_PROCEDURE_CONTEXTS) (((CONN_SUPP_EN) == 1U) ? (72U * (EXTRA_LL_PROCEDURE_CONTEXTS)) : 0U) + /** * Amount of memory needed to support the logging feature */ -#define BLE_STACK_LOG_SIZE(BLE_STACK_LOG_EN) (((BLE_STACK_LOG_EN) == 1U) ? 104U : 0U) +#define BLE_STACK_LOG_SIZE(BLE_STACK_LOG_EN) (((BLE_STACK_LOG_EN) == 1U) ? 2540U : 0U) /** * Amount of memory needed by FIFOs @@ -334,16 +330,18 @@ #else // (BLESTACK_CONTROLLER_ONLY == 1) -# define BLE_STACK_FIXED_BUFFER_SIZE_BYTES (828U) +# define BLE_STACK_FIXED_BUFFER_SIZE_BYTES (908U) /** * Amount of memory needed by each radio link */ -# define COEFF_CONN_SUPP_EN (180U) -# define COEFF_NUM_OF_LINKS_0 (48U) // [DB] NOTE: scheduler's tasks -# define COEFF_NUM_OF_LINKS_1 (484U) +# define COEFF_CONN_SUPP_EN (312U) +# define COEFF_NUM_OF_LINKS_0 (8U) // [DB] NOTE: scheduler's tasks +# define COEFF_NUM_OF_LINKS_1 (488U) # define BLE_STACK_LINKS_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) \ - (((CONN_SUPP_EN) == 1U) || ((NUM_OF_LINKS) > 0U) ? COEFF_CONN_SUPP_EN * (CONN_SUPP_EN) + COEFF_NUM_OF_LINKS_0 * (NUM_OF_LINKS) + COEFF_NUM_OF_LINKS_1 * (CONN_SUPP_EN) * (NUM_OF_LINKS) : 0U) + (((CONN_SUPP_EN) == 1U) || ((NUM_OF_LINKS) > 0U) ? COEFF_CONN_SUPP_EN * (CONN_SUPP_EN) + \ + COEFF_NUM_OF_LINKS_0 * (NUM_OF_LINKS) + \ + COEFF_NUM_OF_LINKS_1 * (CONN_SUPP_EN) * (NUM_OF_LINKS) : 0U) /** * Amount of memory needed for mem. blocks allocated for connections @@ -361,7 +359,7 @@ * subtracted from the total */ # define BLE_STACK_CONTROLLER_EXT_ADV_SIZE(ENABLED, NUM_ADV_SET, NUM_AUX_EVENT, NUM_OF_LINKS) \ - (((ENABLED) == 1U) ? -256U + 348U * (NUM_ADV_SET) + 0U * (NUM_AUX_EVENT) + 0U * (NUM_OF_LINKS) : 0U) + (((ENABLED) == 1U) ? -284U + 376U * (NUM_ADV_SET) + 0U * (NUM_AUX_EVENT) + 0U * (NUM_OF_LINKS) : 0U) /** * Amount of memory needed for the Filter Accept List and, if connections are supported, also for connection ID list @@ -383,10 +381,10 @@ * Amount of memory needed to support periodic advertising and synchronizing feature */ # define BLE_STACK_CONTROLLER_PERIODIC_ADV_WR_SIZE(PER_ADV_WR_EN, CONN_SUPP_EN, NUM_ADV_SET, NUM_SUBEVENTS_PAWR, MAX_SUBEVENT_DATA_COUNT_PAWR) \ - ((((PER_ADV_WR_EN) == 1U) && ((CONN_SUPP_EN) == 1U)) ? (132U + 8U * (NUM_SUBEVENTS_PAWR) + 16U * (MAX_SUBEVENT_DATA_COUNT_PAWR)) * (NUM_ADV_SET) : 0U) + ((((PER_ADV_WR_EN) == 1U) && ((CONN_SUPP_EN) == 1U)) ? (132U + 96U + 12U * (NUM_SUBEVENTS_PAWR) + 16U * (MAX_SUBEVENT_DATA_COUNT_PAWR)) * (NUM_ADV_SET) : 0U) # define BLE_STACK_CONTROLLER_PERIODIC_ADV_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_LINKS, NUM_ADV_SET, NUM_SUBEVENTS_PAWR, MAX_SUBEVENT_DATA_COUNT_PAWR) \ - (((PER_ADV_EN) == 1U) ? (156U * (NUM_ADV_SET) + 32U * (NUM_LINKS) + \ + (((PER_ADV_EN) == 1U) ? (204U * (NUM_ADV_SET) + 32U * (NUM_LINKS) + \ BLE_STACK_CONTROLLER_PERIODIC_ADV_WR_SIZE(PER_ADV_WR_EN, CONN_SUPP_EN, NUM_ADV_SET, NUM_SUBEVENTS_PAWR, MAX_SUBEVENT_DATA_COUNT_PAWR)) : \ 0U) @@ -395,19 +393,19 @@ */ # define BLE_STACK_BASE_SIZE(CONN_SUPP_EN) (((CONN_SUPP_EN) == 1U) ? 32U : 20U) -# define BLE_STACK_PAST_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) ? 24U * (NUM_OF_LINKS) : 0U) +# define BLE_STACK_PAST_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) ? 8U * (NUM_OF_LINKS) : 0U) # define BLE_STACK_PER_SYNC_SIZE(PER_ADV_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE)\ - (((PER_ADV_EN) == 1U) ? BLE_STACK_BASE_SIZE(CONN_SUPP_EN) + 144U * (NUM_SYNC_SLOTS) + 8U * (1U << (ADV_LIST_LIZE)) + BLE_STACK_PAST_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) : 0U) + (((PER_ADV_EN) == 1U) ? BLE_STACK_BASE_SIZE(CONN_SUPP_EN) + 192U * (NUM_SYNC_SLOTS) + 8U * (1U << (ADV_LIST_LIZE)) + BLE_STACK_PAST_SIZE(CONN_SUPP_EN, NUM_OF_LINKS) : 0U) # define BLE_STACK_PER_SYNC_WR_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_SYNC_SUBEVENTS)\ - (((PER_ADV_WR_EN & PER_ADV_EN & CONN_SUPP_EN) == 1U) ? 176U * (NUM_SYNC_SLOTS) + ALIGN_32(NUM_SYNC_SUBEVENTS) : 0U) + (((PER_ADV_WR_EN & PER_ADV_EN & CONN_SUPP_EN) == 1U) ? 224U * (NUM_SYNC_SLOTS) + ALIGN_32(NUM_SYNC_SUBEVENTS) : 0U) # define BLE_STACK_CONTROLLER_SCAN_SIZE(SCAN_EN, EXT_ADV_EN, PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_AUX_EVENT,\ NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE, NUM_SYNC_SUBEVENTS) \ - (((SCAN_EN) == 1U) ? 324U + (164U + 48U * (NUM_AUX_EVENT) + \ + (((SCAN_EN) == 1U) ? 564U + (((EXT_ADV_EN) == 1U ) ? (164U + 96U * (NUM_AUX_EVENT) + \ BLE_STACK_PER_SYNC_SIZE(PER_ADV_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_OF_LINKS, ADV_LIST_LIZE) + \ - BLE_STACK_PER_SYNC_WR_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_SYNC_SUBEVENTS)) * (EXT_ADV_EN) : 0U) + BLE_STACK_PER_SYNC_WR_SIZE(PER_ADV_EN, PER_ADV_WR_EN, CONN_SUPP_EN, NUM_SYNC_SLOTS, NUM_SYNC_SUBEVENTS)) : 0U) : 0U) /** * Amount of memory needed to support controller privacy feature @@ -440,7 +438,7 @@ /** * Amount of memory needed to support PCL feature */ -# define BLE_STACK_PCL_NUM_OF_LINKS(NUM_OF_LINKS) (32U * (NUM_OF_LINKS)) +# define BLE_STACK_PCL_NUM_OF_LINKS(NUM_OF_LINKS) (36U * (NUM_OF_LINKS)) # define BLE_STACK_PCL_SIZE(CONN_SUPP_EN, PCL_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) && ((PCL_EN) == 1U) ? 20U + BLE_STACK_PCL_NUM_OF_LINKS(NUM_OF_LINKS) : 0U) /** @@ -449,10 +447,15 @@ # define BLE_STACK_CHC_NUM_OF_LINKS(NUM_OF_LINKS) (28U * (NUM_OF_LINKS)) # define BLE_STACK_CHC_SIZE(CONN_SUPP_EN, CHC_EN, NUM_OF_LINKS) (((CONN_SUPP_EN) == 1U) && ((CHC_EN) == 1U) ? BLE_STACK_CHC_NUM_OF_LINKS(NUM_OF_LINKS) : 0U) +/** + * Amount of memory needed for extra Link Layer Control Procedure contexts + */ +# define BLE_STACK_EXTRA_LL_PROCEDURE_CONTEXTS_SIZE(CONN_SUPP_EN, EXTRA_LL_PROCEDURE_CONTEXTS) (((CONN_SUPP_EN) == 1U) ? (72U * (EXTRA_LL_PROCEDURE_CONTEXTS)) : 0U) + /** * Amount of memory needed to support the logging feature */ -#define BLE_STACK_LOG_SIZE(BLE_STACK_LOG_EN) (((BLE_STACK_LOG_EN) == 1U) ? 104U : 0U) +#define BLE_STACK_LOG_SIZE(BLE_STACK_LOG_EN) (((BLE_STACK_LOG_EN) == 1U) ? 2540U : 0U) /** * Amount of memory needed by FIFOs @@ -506,7 +509,8 @@ * @param BLE_STACK_NUM_BRC_BIS: Number of BIG Broadcaster streams per group to support. * @param BLE_STACK_NUM_CIG: Number of CIG groups to support. * @param BLE_STACK_NUM_CIS: Number of CIS streams to support. - * @param BLE_STACK_CIS_EN: Enable or disable the Connected Isochronous Streams feature. Valid values are 0 or 1. + * @param BLE_STACK_EXTRA_LL_PROCEDURE_CONTEXTS: Number of extra Control Procedure contexts. + * @param BLE_STACK_LOG_EN: Enable or disable log buffer allocation in stack. Valid values are 0 or 1. * @param ISR0_FIFO_SIZE: Size of the internal FIFO used for critical controller events produced by the ISR (e.g. rx data packets) * @param ISR1_FIFO_SIZE: Size of the internal FIFO used for non-critical controller events produced by the ISR (e.g. advertising or IQ sampling reports) * @param USER_FIFO_SIZE: Size of the internal FIFO used for controller and host events produced outside the ISR @@ -545,6 +549,7 @@ BLE_STACK_NUM_BRC_BIS,\ BLE_STACK_NUM_CIG,\ BLE_STACK_NUM_CIS,\ + BLE_STACK_EXTRA_LL_PROCEDURE_CONTEXTS,\ BLE_STACK_LOG_EN,\ ISR0_FIFO_SIZE,\ ISR1_FIFO_SIZE,\ @@ -579,9 +584,11 @@ BLE_STACK_CTE_EN, BLE_STACK_NUM_LINKS, NUM_CTE_ANT_IDS, NUM_CTE_IQSAMPLES) + \ BLE_STACK_PCL_SIZE(BLE_STACK_CONN_SUPP_EN, BLE_STACK_PCL_EN, BLE_STACK_NUM_LINKS) + \ BLE_STACK_CHC_SIZE(BLE_STACK_CONN_SUPP_EN, BLE_STACK_CHC_EN, BLE_STACK_NUM_LINKS) + \ - BLE_STACK_ISO_SIZE(BLE_STACK_NUM_BRC_BIG, BLE_STACK_NUM_BRC_BIS, \ + BLE_STACK_ISO_SIZE(BLE_STACK_EXT_ADV_SCAN_EN, CONTROLLER_PERIODIC_ADV_EN, BLE_STACK_SCAN_EN, BLE_STACK_CONN_SUPP_EN, \ + BLE_STACK_NUM_BRC_BIG, BLE_STACK_NUM_BRC_BIS, \ BLE_STACK_NUM_SYNC_BIG, BLE_STACK_NUM_SYNC_BIS, \ BLE_STACK_NUM_CIG, BLE_STACK_NUM_CIS) + \ + BLE_STACK_EXTRA_LL_PROCEDURE_CONTEXTS_SIZE(BLE_STACK_CONN_SUPP_EN, BLE_STACK_EXTRA_LL_PROCEDURE_CONTEXTS) + \ BLE_STACK_LOG_SIZE(BLE_STACK_LOG_EN) + \ BLE_STACK_FIFO_SIZE(ISR0_FIFO_SIZE, ISR1_FIFO_SIZE, USER_FIFO_SIZE) \ ) @@ -607,6 +614,13 @@ on the available device RAM) * @param NUM_SYNC_SLOTS: Number of radio tasks to allocate for synchronizing to periodic advertisements. * @param BLE_STACK_NUM_CTE_ANT_IDS: Maximum antenna switching pattern length . * @param BLE_STACK_NUM_IQSAMPLES: Maximum number of IQ-Samples in the buffer. + * @param BLE_STACK_NUM_SYNC_BIG: Number of BIG Synchronous groups to support. + * @param BLE_STACK_NUM_BRC_BIG: Number of BIG Broadcaster groups to support. + * @param BLE_STACK_NUM_SYNC_BIS: Number of BIG Synchronous streams per group to support. + * @param BLE_STACK_NUM_BRC_BIS: Number of BIG Broadcaster streams per group to support. + * @param BLE_STACK_NUM_CIG: Number of CIG groups to support. + * @param BLE_STACK_NUM_CIS: Number of CIS streams to support. + * @param BLE_STACK_EXTRA_LL_PROCEDURE_CONTEXTS: Number of extra Control Procedure contexts. * @param ISR0_FIFO_SIZE: Size of the internal FIFO used for critical controller events produced by the ISR (e.g. rx data packets). * @param ISR1_FIFO_SIZE: Size of the internal FIFO used for non-critical controller events produced by the ISR (e.g. advertising or IQ sampling reports). * @param USER_FIFO_SIZE: Size of the internal FIFO used for controller and host events produced outside the ISR. @@ -632,6 +646,7 @@ on the available device RAM) BLE_STACK_NUM_BRC_BIS,\ BLE_STACK_NUM_CIG,\ BLE_STACK_NUM_CIS,\ + BLE_STACK_EXTRA_LL_PROCEDURE_CONTEXTS,\ ISR0_FIFO_SIZE,\ ISR1_FIFO_SIZE,\ USER_FIFO_SIZE)\ @@ -670,6 +685,7 @@ on the available device RAM) BLE_STACK_NUM_BRC_BIS,\ BLE_STACK_NUM_CIG,\ BLE_STACK_NUM_CIS,\ + BLE_STACK_EXTRA_LL_PROCEDURE_CONTEXTS,\ DTM_DEBUG_ENABLED,\ ISR0_FIFO_SIZE,\ ISR1_FIFO_SIZE,\ @@ -707,6 +723,7 @@ typedef struct { uint8_t NumOfBrcBIS; /**< Maximum number of ISO Broadcaster streams. */ uint8_t NumOfCIG; /**< Maximum number of Connected Isochronous Groups. */ uint8_t NumOfCIS; /**< Maximum number of Connected Isochronous Streams. */ + uint8_t ExtraLLProcedureContexts; /**< Number of extra Link Layer Control Procedure contexts */ uint16_t isr0_fifo_size; /**< Size of the internal FIFO used for critical controller events produced by the ISR (e.g. rx data packets)*/ uint16_t isr1_fifo_size; /**< Size of the internal FIFO used for non-critical controller events produced by the ISR (e.g. advertising or IQ sampling reports)*/ uint16_t user_fifo_size; /**< Size of the internal FIFO used for controller and host events produced outside the ISR */ @@ -732,6 +749,17 @@ typedef struct { */ void BLE_STACK_Tick(void); +/** + * @brief This function executes the processing of all Host Stack layers without calling BLE_STACK_Event() . + * + * This version of the BLE Stack Tick function is useful in case the classic BLE_STACK_Tick() cannot be called for long time. + * In fact it is possible to call this BLE_STACK_TickNoEvents() from an interrupt context (e.g. from the Systick ISR) while being sure + * that BLE_STACK_Event() will not be called by this function. + * + * @note Do not call BLE_STACK_TickNoEvents() while other BLE Stack functions are being executed. + */ +void BLE_STACK_TickNoEvents(void); + /** * @brief The BLE Stack initialization routine * @@ -764,6 +792,16 @@ void BLE_STACK_Event(hci_pckt *hci_pckt, uint16_t length); */ uint8_t BLE_STACK_SleepCheck(void); +/** + * + * @brief Radio Resource Manager (RRM) ISR routine. + * + * This is the base function called for any RRM ISR. + * + * @param[in] RRMStatus Value of RRM Status register + */ +void BLE_STACK_RRMHandler(uint32_t RRMStatus); + /** * * @brief Radio ISR routine. @@ -793,7 +831,7 @@ uint8_t BLE_STACK_ReadNextRadioActivity(uint32_t *NextStateSysTime); /** * @brief This function is called whenever an execution of BLE_STACK_Tick() is requested. * - * It may be called from an interrupt context, so it should return as quick as possible. + * It may be called from an interrupt context, so it should return as quickly as possible. * The BLE_STACK_Tick() must not be called directly by this API. */ void BLE_STACK_ProcessRequest(void); diff --git a/lib/stm32wb0/STM32_BLE/stack/include/ble_stack_user_cfg.h b/lib/stm32wb0/STM32_BLE/stack/include/ble_stack_user_cfg.h index 51a9bb7a8..c556f862e 100644 --- a/lib/stm32wb0/STM32_BLE/stack/include/ble_stack_user_cfg.h +++ b/lib/stm32wb0/STM32_BLE/stack/include/ble_stack_user_cfg.h @@ -1,4 +1,5 @@ + /** ****************************************************************************** * @file ble_stack_user_cfg.h @@ -222,18 +223,18 @@ void GAP_central_connection_complete_handler(uint8_t status, uint16_t connectionHandle); uint8_t GAP_parse_connectable_advertising_report_ucfg(uint8_t* adv_buf, - uint8_t extended); + uint8_t extended); uint8_t GAP_parse_connectable_advertising_report_ucfg_weak(uint8_t* adv_buf, - uint8_t extended); + uint8_t extended); uint8_t GAP_parse_connectable_advertising_report(uint8_t* adv_buf, - uint8_t extended); + uint8_t extended); uint8_t GAP_parse_advertising_report_ucfg(uint8_t* adv_buf, - uint8_t extended); + uint8_t extended); uint8_t GAP_parse_advertising_report_ucfg_weak(uint8_t* adv_buf, - uint8_t extended); + uint8_t extended); uint8_t GAP_parse_advertising_report(uint8_t* adv_buf, - uint8_t extended); + uint8_t extended); void GAP_DiscProcTimeoutcb_ucfg(uint8_t timer_id); void GAP_DiscProcTimeoutcb_ucfg_weak(uint8_t timer_id); @@ -279,9 +280,9 @@ tBleStatus GAP_set_controller_random_address_ucfg(uint8_t random_address[6]); tBleStatus GAP_set_controller_random_address_ucfg_weak(uint8_t random_address[6]); tBleStatus GAP_set_controller_random_address_extended(uint8_t random_address[6]); -tBleStatus GAP_init_advertising_sets_ucfg(uint8_t own_address_type); -tBleStatus GAP_init_advertising_sets_ucfg_weak(uint8_t own_address_type); -tBleStatus GAP_init_advertising_sets(uint8_t own_address_type); +tBleStatus GAP_init_advertising_sets_ucfg(void); +tBleStatus GAP_init_advertising_sets_ucfg_weak(void); +tBleStatus GAP_init_advertising_sets(void); tBleStatus GAP_suspend_resume_active_advertising_sets_ucfg(uint8_t resume); tBleStatus GAP_suspend_resume_active_advertising_sets_ucfg_weak(uint8_t resume); @@ -305,75 +306,6 @@ tBleStatus hci_acl_data_ind_event_int_cb_ucfg_weak(void* header_p, tBleStatus hci_acl_data_ind_event_int_cb(void* header_p, uint8_t* buff_p); -uint8_t log_verbosity_set_ucfg(void* p); -uint8_t log_verbosity_set_ucfg_weak(void* p); -uint8_t log_verbosity_set(void* p); - -void log_verbosity_get_ucfg(void* verb_p); -void log_verbosity_get_ucfg_weak(void* verb_p); -void log_verbosity_get(void* verb_p); - -void log_init_ucfg(void); -void log_init_ucfg_weak(void); -void log_init(void); - -void log_notify_stu_ucfg(uint8_t lvl, - uint8_t cid, - uint16_t mid, - uint8_t uid, - uint8_t fmt, - uint8_t len, - uint8_t* buf_p); -void log_notify_stu_ucfg_weak(uint8_t lvl, - uint8_t cid, - uint16_t mid, - uint8_t uid, - uint8_t fmt, - uint8_t len, - uint8_t* buf_p); -void log_notify_stu(uint8_t lvl, - uint8_t cid, - uint16_t mid, - uint8_t uid, - uint8_t fmt, - uint8_t len, - uint8_t* buf_p); - -void log_notify_us_deferred_ucfg(uint8_t lvl, - uint8_t cid, - uint16_t mid, - uint8_t uid, - uint8_t add_info_present, - uint32_t add_info); -void log_notify_us_deferred_ucfg_weak(uint8_t lvl, - uint8_t cid, - uint16_t mid, - uint8_t uid, - uint8_t add_info_present, - uint32_t add_info); -void log_notify_us_deferred(uint8_t lvl, - uint8_t cid, - uint16_t mid, - uint8_t uid, - uint8_t add_info_present, - uint32_t add_info); - -void log_notify_us_flush_ucfg(void); -void log_notify_us_flush_ucfg_weak(void); -void log_notify_us_flush(void); - -uint32_t log_csr_ucfg(void); -uint32_t log_csr_ucfg_weak(void); -uint32_t log_csr(void); - -uint32_t chc_csr_ucfg(void); -uint32_t chc_csr_ucfg_weak(void); -uint32_t chc_csr(void); - -void Controller_Process_Q_ucfg(uint16_t task_idx); -void Controller_Process_Q_ucfg_weak(uint16_t task_idx); -void Controller_Process_Q(uint16_t task_idx); - void LLC_offline_control_procedures_processing_ucfg(uint16_t task_idx); void LLC_offline_control_procedures_processing_ucfg_weak(uint16_t task_idx); void LLC_offline_control_procedures_processing(uint16_t task_idx); @@ -546,6 +478,105 @@ void smp_sap_hci_le_generate_dhkey_complete_evt_hndl_ucfg_weak(uint8_t status, void smp_sap_hci_le_generate_dhkey_complete_evt_hndl(uint8_t status, uint8_t dhkey[32]); +uint8_t ble_stack_log_verbosity_set_ucfg(void* p); +uint8_t ble_stack_log_verbosity_set_ucfg_weak(void* p); +uint8_t ble_stack_log_verbosity_set(void* p); + +void ble_stack_log_verbosity_get_ucfg(void* verb_p); +void ble_stack_log_verbosity_get_ucfg_weak(void* verb_p); +void ble_stack_log_verbosity_get(void* verb_p); + +void ble_stack_log_init_ucfg(void); +void ble_stack_log_init_ucfg_weak(void); +void ble_stack_log_init(void); + +void ble_stack_log_notify_stu_ucfg(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t fmt, + uint8_t len, + uint8_t* buf_p, + uint8_t isr); +void ble_stack_log_notify_stu_ucfg_weak(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t fmt, + uint8_t len, + uint8_t* buf_p, + uint8_t isr); +void ble_stack_log_notify_stu(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t fmt, + uint8_t len, + uint8_t* buf_p, + uint8_t isr); + +void ble_stack_log_notify_us_deferred_ucfg(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t add_info_present, + uint32_t add_info); +void ble_stack_log_notify_us_deferred_ucfg_weak(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t add_info_present, + uint32_t add_info); +void ble_stack_log_notify_us_deferred(uint8_t lvl, + uint8_t cid, + uint16_t mid, + uint8_t uid, + uint8_t add_info_present, + uint32_t add_info); + +void ble_stack_log_notify_us_flush_ucfg(void); +void ble_stack_log_notify_us_flush_ucfg_weak(void); +void ble_stack_log_notify_us_flush(void); + +uint32_t ble_stack_log_csr_ucfg(void); +uint32_t ble_stack_log_csr_ucfg_weak(void); +uint32_t ble_stack_log_csr(void); + +int llc_isr_tim_mon_reset_stat_params_ucfg(uint8_t* params_p); +int llc_isr_tim_mon_reset_stat_params_ucfg_weak(uint8_t* params_p); +int llc_isr_tim_mon_reset_stat_params(uint8_t* params_p); + +void llc_isr_tim_mon_stat_abs_ucfg(uint8_t mod_id, + uint8_t var_id, + uint8_t checkp); +void llc_isr_tim_mon_stat_abs_ucfg_weak(uint8_t mod_id, + uint8_t var_id, + uint8_t checkp); +void llc_isr_tim_mon_stat_abs(uint8_t mod_id, + uint8_t var_id, + uint8_t checkp); + +void llc_isr_tim_mon_stat_rel_ucfg(uint8_t mod_id, + uint8_t var_id, + uint8_t checkp); +void llc_isr_tim_mon_stat_rel_ucfg_weak(uint8_t mod_id, + uint8_t var_id, + uint8_t checkp); +void llc_isr_tim_mon_stat_rel(uint8_t mod_id, + uint8_t var_id, + uint8_t checkp); + +void llc_isr_tim_mon_stat_check_ucfg(uint8_t mod_id, + uint8_t var_id); +void llc_isr_tim_mon_stat_check_ucfg_weak(uint8_t mod_id, + uint8_t var_id); +void llc_isr_tim_mon_stat_check(uint8_t mod_id, + uint8_t var_id); + +void llc_isr_tim_mon_stat_notify_ucfg(void); +void llc_isr_tim_mon_stat_notify_ucfg_weak(void); +void llc_isr_tim_mon_stat_notify(void); + uint32_t l2c_cos_csr_ucfg(void); uint32_t l2c_cos_csr_ucfg_weak(void); uint32_t l2c_cos_csr(void); @@ -601,6 +632,32 @@ void llc_conn_check_subrate_and_set_params_ucfg_weak(void* cntxt_p, void llc_conn_check_subrate_and_set_params(void* cntxt_p, void* params_p); +void llc_conn_mem_allocate_ucfg(uint8_t phy_upd_en, + uint8_t cte_en, + uint8_t pcl_en, + uint8_t cns_en, + uint8_t chc_en, + uint8_t padv_en); +void llc_conn_mem_allocate_ucfg_weak(uint8_t phy_upd_en, + uint8_t cte_en, + uint8_t pcl_en, + uint8_t cns_en, + uint8_t chc_en, + uint8_t padv_en); +void llc_conn_mem_allocate(uint8_t phy_upd_en, + uint8_t cte_en, + uint8_t pcl_en, + uint8_t cns_en, + uint8_t chc_en, + uint8_t padv_en); + +void llc_conn_list_replace_rpa_addresses_ucfg(void* peer_id_addr_p, + uint32_t peer_irk[4]); +void llc_conn_list_replace_rpa_addresses_ucfg_weak(void* peer_id_addr_p, + uint32_t peer_irk[4]); +void llc_conn_list_replace_rpa_addresses(void* peer_id_addr_p, + uint32_t peer_irk[4]); + uint32_t llc_conn_calc_skip_ucfg(void* cntxt_p, uint16_t event_counter, uint16_t latency); @@ -619,6 +676,10 @@ void llc_conn_peripheral_roll_back_params_tsk_ucfg(uint16_t task_idx); void llc_conn_peripheral_roll_back_params_tsk_ucfg_weak(uint16_t task_idx); void llc_conn_peripheral_roll_back_params_tsk(uint16_t task_idx); +void llc_cpe_tsk_ucfg(uint16_t task_idx); +void llc_cpe_tsk_ucfg_weak(uint16_t task_idx); +void llc_cpe_tsk(uint16_t task_idx); + uint8_t llc_check_sreq_or_creq_tx_addr_ucfg(void* tx_addr7_p, uint8_t pdu_type, uint8_t adv_event_prop, @@ -815,21 +876,21 @@ tBleStatus llc_big_cmn_get_iso_params(uint8_t direction, uint16_t conn_handle, void* param_p); -uint32_t llc_cig_cen_get_cis_offset_from_acl_us_ucfg(void* ctx_p, +uint16_t llc_cig_cen_get_cis_offset_from_acl_us_ucfg(void* ctx_p, void* cis_p, uint8_t conn_idx, - uint16_t* event_count_p, - uint32_t* cig_anchor_st_p); -uint32_t llc_cig_cen_get_cis_offset_from_acl_us_ucfg_weak(void* ctx_p, + uint32_t* cis_min_offset_us_p, + uint32_t* cis_max_offset_us_p); +uint16_t llc_cig_cen_get_cis_offset_from_acl_us_ucfg_weak(void* ctx_p, void* cis_p, uint8_t conn_idx, - uint16_t* event_count_p, - uint32_t* cig_anchor_st_p); -uint32_t llc_cig_cen_get_cis_offset_from_acl_us(void* ctx_p, + uint32_t* cis_min_offset_us_p, + uint32_t* cis_max_offset_us_p); +uint16_t llc_cig_cen_get_cis_offset_from_acl_us(void* ctx_p, void* cis_p, uint8_t conn_idx, - uint16_t* event_count_p, - uint32_t* cig_anchor_st_p); + uint32_t* cis_min_offset_us_p, + uint32_t* cis_max_offset_us_p); uint32_t llc_cig_cen_get_sdu_synchronization_us_ucfg(uint16_t conn_handle, uint8_t framed, @@ -898,6 +959,28 @@ uint32_t llc_cig_cmn_get_own_cig_event_time(void* ctx_p, uint16_t conn_handle, uint16_t num_enq_packet); +void llc_cig_cmn_get_cis_anchor_range_ucfg(void* cig_p, + void* cis_p, + uint8_t conn_idx, + uint16_t event_offset, + uint16_t* acl_event_counter_p, + uint32_t* cis_min_offset_us_p, + uint32_t* cis_max_offset_us_p); +void llc_cig_cmn_get_cis_anchor_range_ucfg_weak(void* cig_p, + void* cis_p, + uint8_t conn_idx, + uint16_t event_offset, + uint16_t* acl_event_counter_p, + uint32_t* cis_min_offset_us_p, + uint32_t* cis_max_offset_us_p); +void llc_cig_cmn_get_cis_anchor_range(void* cig_p, + void* cis_p, + uint8_t conn_idx, + uint16_t event_offset, + uint16_t* acl_event_counter_p, + uint32_t* cis_min_offset_us_p, + uint32_t* cis_max_offset_us_p); + tBleStatus llc_cig_cmn_enqueue_pdu_to_tx_ucfg(void* ctx_p, uint32_t iso_interval_idx, uint16_t conn_handle, @@ -925,13 +1008,13 @@ void llc_cig_cmn_start_cis_ucfg_weak(uint8_t conn_idx, void llc_cig_cmn_start_cis(uint8_t conn_idx, uint16_t instant); -uint8_t llc_cig_cmn_is_active_cis_on_acl_ucfg(uint16_t acl_conn_handle); -uint8_t llc_cig_cmn_is_active_cis_on_acl_ucfg_weak(uint16_t acl_conn_handle); -uint8_t llc_cig_cmn_is_active_cis_on_acl(uint16_t acl_conn_handle); +uint8_t llc_cig_cmn_is_active_cis_on_acl_ucfg(uint8_t acl_conn_idx); +uint8_t llc_cig_cmn_is_active_cis_on_acl_ucfg_weak(uint8_t acl_conn_idx); +uint8_t llc_cig_cmn_is_active_cis_on_acl(uint8_t acl_conn_idx); -void llc_cig_cmn_terminate_cises_on_acl_ucfg(uint16_t acl_conn_handle); -void llc_cig_cmn_terminate_cises_on_acl_ucfg_weak(uint16_t acl_conn_handle); -void llc_cig_cmn_terminate_cises_on_acl(uint16_t acl_conn_handle); +void llc_cig_cmn_terminate_cises_on_acl_ucfg(uint8_t conn_idx); +void llc_cig_cmn_terminate_cises_on_acl_ucfg_weak(uint8_t conn_idx); +void llc_cig_cmn_terminate_cises_on_acl(uint8_t conn_idx); void llc_cig_cmn_cis_established_event_gen_ucfg(void* cig_p, void* cis_p, @@ -943,6 +1026,23 @@ void llc_cig_cmn_cis_established_event_gen(void* cig_p, void* cis_p, uint8_t status); +tBleStatus llc_cig_cmn_check_params_ucfg(uint8_t cig_id, + void* cig_p, + void* cis_p); +tBleStatus llc_cig_cmn_check_params_ucfg_weak(uint8_t cig_id, + void* cig_p, + void* cis_p); +tBleStatus llc_cig_cmn_check_params(uint8_t cig_id, + void* cig_p, + void* cis_p); + +tBleStatus llc_cig_cmn_check_iso_params_ucfg(void* cig_p, + void* cis_p); +tBleStatus llc_cig_cmn_check_iso_params_ucfg_weak(void* cig_p, + void* cis_p); +tBleStatus llc_cig_cmn_check_iso_params(void* cig_p, + void* cis_p); + tBleStatus llc_cig_cmn_get_iso_params_ucfg(uint8_t direction, uint16_t conn_handle, void* param_p); @@ -978,6 +1078,25 @@ tBleStatus llc_cig_cmn_read_iso_link_quality(uint16_t conn_handle, uint32_t* rx_unreceived_packets_p, uint32_t* duplicate_packets_p); +tBleStatus llc_cig_cmn_validate_cis_params_from_acl_ucfg(void* ctx_p, + void* cis_p, + uint8_t conn_idx, + uint16_t event_counter, + uint32_t cis_min_offset_us, + uint32_t cis_max_offset_us); +tBleStatus llc_cig_cmn_validate_cis_params_from_acl_ucfg_weak(void* ctx_p, + void* cis_p, + uint8_t conn_idx, + uint16_t event_counter, + uint32_t cis_min_offset_us, + uint32_t cis_max_offset_us); +tBleStatus llc_cig_cmn_validate_cis_params_from_acl(void* ctx_p, + void* cis_p, + uint8_t conn_idx, + uint16_t event_counter, + uint32_t cis_min_offset_us, + uint32_t cis_max_offset_us); + void llc_iso_cmn_mem_alloc_ucfg(void); void llc_iso_cmn_mem_alloc_ucfg_weak(void); void llc_iso_cmn_mem_alloc(void); @@ -1021,11 +1140,11 @@ uint8_t llc_padv_check_if_syncinfo_is_included_and_start_periodic_advertising_uc uint8_t llc_padv_check_if_syncinfo_is_included_and_start_periodic_advertising(void* context_p); uint8_t llc_padv_update_sync_info_ucfg(void* padv_per_p, - uint32_t aux_adv_ind_anchor); + uint32_t aux_adv_ind_anchor); uint8_t llc_padv_update_sync_info_ucfg_weak(void* padv_per_p, - uint32_t aux_adv_ind_anchor); + uint32_t aux_adv_ind_anchor); uint8_t llc_padv_update_sync_info(void* padv_per_p, - uint32_t aux_adv_ind_anchor); + uint32_t aux_adv_ind_anchor); void llc_padv_prepare_periodic_advertising_payload_ucfg(void* padv_per_p, uint8_t extended_header_flags, @@ -1042,11 +1161,11 @@ uint32_t llc_padv_periodic_adv_sync_csr_ucfg_weak(void); uint32_t llc_padv_periodic_adv_sync_csr(void); uint8_t llc_padv_wr_create_connection_cancel_ucfg(void* _padv_per_p, - uint8_t advertising_handle); + uint8_t advertising_handle); uint8_t llc_padv_wr_create_connection_cancel_ucfg_weak(void* _padv_per_p, - uint8_t advertising_handle); + uint8_t advertising_handle); uint8_t llc_padv_wr_create_connection_cancel(void* _padv_per_p, - uint8_t advertising_handle); + uint8_t advertising_handle); void llc_padv_wr_set_start_parameters_ucfg(void* set_padv_wr_start_parameters_p); void llc_padv_wr_set_start_parameters_ucfg_weak(void* set_padv_wr_start_parameters_p); @@ -1057,11 +1176,11 @@ tBleStatus llc_padv_wr_set_periodic_advertising_subevent_data_ucfg_weak(void* se tBleStatus llc_padv_wr_set_periodic_advertising_subevent_data(void* set_padv_wr_data_p); uint8_t llc_padv_wr_set_ctrdata_ucfg(void* padv_per_p, - uint8_t* ctrdata_p); + uint8_t* ctrdata_p); uint8_t llc_padv_wr_set_ctrdata_ucfg_weak(void* padv_per_p, - uint8_t* ctrdata_p); + uint8_t* ctrdata_p); uint8_t llc_padv_wr_set_ctrdata(void* padv_per_p, - uint8_t* ctrdata_p); + uint8_t* ctrdata_p); void llc_padv_wr_set_acad_ucfg(void* padv_per_p, uint8_t* ext_hdr_p); @@ -1082,6 +1201,50 @@ void llc_padv_wr_disable_ext_ucfg(void* _padv_per_p); void llc_padv_wr_disable_ext_ucfg_weak(void* _padv_per_p); void llc_padv_wr_disable_ext(void* _padv_per_p); +void llc_past_mem_allocate_ucfg(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en, + uint8_t conn_en); +void llc_past_mem_allocate_ucfg_weak(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en, + uint8_t conn_en); +void llc_past_mem_allocate(uint8_t scan_en, + uint8_t ext_en, + uint8_t pscan_en, + uint8_t conn_en); + +void llc_past_init_ucfg(uint8_t conn_idx); +void llc_past_init_ucfg_weak(uint8_t conn_idx); +void llc_past_init(uint8_t conn_idx); + +void llc_past_by_scanner_ucfg(void* params, + uint32_t conn_anchor, + uint32_t conn_interval, + uint16_t conn_event_count, + uint8_t* pdu_p); +void llc_past_by_scanner_ucfg_weak(void* params, + uint32_t conn_anchor, + uint32_t conn_interval, + uint16_t conn_event_count, + uint8_t* pdu_p); +void llc_past_by_scanner(void* params, + uint32_t conn_anchor, + uint32_t conn_interval, + uint16_t conn_event_count, + uint8_t* pdu_p); + +void llc_past_peer_init_ucfg(uint8_t* pdu_p, + uint8_t conn_idx); +void llc_past_peer_init_ucfg_weak(uint8_t* pdu_p, + uint8_t conn_idx); +void llc_past_peer_init(uint8_t* pdu_p, + uint8_t conn_idx); + +void llc_past_register_cpf_ucfg(void); +void llc_past_register_cpf_ucfg_weak(void); +void llc_past_register_cpf(void); + void llc_priv_generate_peer_rpa_from_peer_id_ucfg(void* peer_p, uint8_t in_isr); void llc_priv_generate_peer_rpa_from_peer_id_ucfg_weak(void* peer_p, @@ -1089,6 +1252,36 @@ void llc_priv_generate_peer_rpa_from_peer_id_ucfg_weak(void* peer_p, void llc_priv_generate_peer_rpa_from_peer_id(void* peer_p, uint8_t in_isr); +uint8_t llc_check_creq_rx_addr_ucfg(uint8_t* rx_addr7_p, + uint8_t* tx_addr7_p, + uint8_t* local_addr7_p, + uint8_t* rl_index_p); +uint8_t llc_check_creq_rx_addr_ucfg_weak(uint8_t* rx_addr7_p, + uint8_t* tx_addr7_p, + uint8_t* local_addr7_p, + uint8_t* rl_index_p); +uint8_t llc_check_creq_rx_addr(uint8_t* rx_addr7_p, + uint8_t* tx_addr7_p, + uint8_t* local_addr7_p, + uint8_t* rl_index_p); + +uint8_t llc_priv_generate_rpa_from_rl_index_ucfg(uint8_t rl_index, + uint8_t local_rpa, + uint8_t in_isr, + void* addr8_rpa_p); +uint8_t llc_priv_generate_rpa_from_rl_index_ucfg_weak(uint8_t rl_index, + uint8_t local_rpa, + uint8_t in_isr, + void* addr8_rpa_p); +uint8_t llc_priv_generate_rpa_from_rl_index(uint8_t rl_index, + uint8_t local_rpa, + uint8_t in_isr, + void* addr8_rpa_p); + +void llc_priv_get_id_addr_from_rpa_ucfg(void* addr_p); +void llc_priv_get_id_addr_from_rpa_ucfg_weak(void* addr_p); +void llc_priv_get_id_addr_from_rpa(void* addr_p); + void llc_priv_init_ucfg(uint8_t first_call); void llc_priv_init_ucfg_weak(uint8_t first_call); void llc_priv_init(uint8_t first_call); @@ -1143,10 +1336,6 @@ void llc_pscan_cancel_slot_cte_ucfg(void* cntxt_per_p); void llc_pscan_cancel_slot_cte_ucfg_weak(void* cntxt_per_p); void llc_pscan_cancel_slot_cte(void* cntxt_per_p); -uint8_t llc_pscan_isr_ucfg(void* cntxt_per_p); -uint8_t llc_pscan_isr_ucfg_weak(void* cntxt_per_p); -uint8_t llc_pscan_isr(void* cntxt_per_p); - void llc_pscan_init_ucfg(void); void llc_pscan_init_ucfg_weak(void); void llc_pscan_init(void); @@ -1189,10 +1378,6 @@ void llc_pscan_synchronizing_ucfg(void* params_p); void llc_pscan_synchronizing_ucfg_weak(void* params_p); void llc_pscan_synchronizing(void* params_p); -void llc_pscan_wrong_cte_type_ucfg(void* cntxt_p); -void llc_pscan_wrong_cte_type_ucfg_weak(void* cntxt_p); -void llc_pscan_wrong_cte_type(void* cntxt_p); - void llc_pscan_wr_init_ucfg(void); void llc_pscan_wr_init_ucfg_weak(void); void llc_pscan_wr_init(void); @@ -1225,14 +1410,14 @@ void llc_pscan_wr_config_tx_blue_sm(void* params_p, uint8_t pawr_feat); uint8_t llc_pscan_wr_get_pawr_info_ucfg(uint8_t acad_size, - uint8_t* acad_p, - uint8_t* pawr_info_p); + uint8_t* acad_p, + uint8_t* pawr_info_p); uint8_t llc_pscan_wr_get_pawr_info_ucfg_weak(uint8_t acad_size, - uint8_t* acad_p, - uint8_t* pawr_info_p); + uint8_t* acad_p, + uint8_t* pawr_info_p); uint8_t llc_pscan_wr_get_pawr_info(uint8_t acad_size, - uint8_t* acad_p, - uint8_t* pawr_info_p); + uint8_t* acad_p, + uint8_t* pawr_info_p); uint8_t llc_pscan_wr_check_pawr_active_ucfg(uint8_t conn_idx); uint8_t llc_pscan_wr_check_pawr_active_ucfg_weak(uint8_t conn_idx); @@ -1260,6 +1445,10 @@ void llc_pscan_wr_set_scheduler_params_ucfg(void* params_p); void llc_pscan_wr_set_scheduler_params_ucfg_weak(void* params_p); void llc_pscan_wr_set_scheduler_params(void* params_p); +void llc_sca_upd_register_cpf_ucfg(void); +void llc_sca_upd_register_cpf_ucfg_weak(void); +void llc_sca_upd_register_cpf(void); + void llc_scan_conn_ind_sent_ucfg(void* ptr, uint8_t idx); void llc_scan_conn_ind_sent_ucfg_weak(void* ptr, @@ -1267,27 +1456,19 @@ void llc_scan_conn_ind_sent_ucfg_weak(void* ptr, void llc_scan_conn_ind_sent(void* ptr, uint8_t idx); -uint8_t llc_scan_isr_uncoded_ucfg(void* cntxt_p); -uint8_t llc_scan_isr_uncoded_ucfg_weak(void* cntxt_p); -uint8_t llc_scan_isr_uncoded(void* cntxt_p); - -uint8_t llc_scan_isr_coded_ucfg(void* cntxt_p); -uint8_t llc_scan_isr_coded_ucfg_weak(void* cntxt_p); -uint8_t llc_scan_isr_coded(void* cntxt_p); - -uint8_t llc_scan_process_ext_adv_ucfg(void* scan_p, +void llc_scan_process_ext_adv_ucfg(void* scan_p, void* params_p, uint32_t direct_addr[2], uint8_t idx, uint8_t advertiser_addr_flag, uint8_t* send_report_p); -uint8_t llc_scan_process_ext_adv_ucfg_weak(void* scan_p, +void llc_scan_process_ext_adv_ucfg_weak(void* scan_p, void* params_p, uint32_t direct_addr[2], uint8_t idx, uint8_t advertiser_addr_flag, uint8_t* send_report_p); -uint8_t llc_scan_process_ext_adv(void* scan_p, +void llc_scan_process_ext_adv(void* scan_p, void* params_p, uint32_t direct_addr[2], uint8_t idx, @@ -1360,14 +1541,6 @@ void llc_scan_disable_ucfg(void* scan_p); void llc_scan_disable_ucfg_weak(void* scan_p); void llc_scan_disable(void* scan_p); -uint8_t llc_scan_stop_ucfg(uint8_t scan_disable); -uint8_t llc_scan_stop_ucfg_weak(uint8_t scan_disable); -uint8_t llc_scan_stop(uint8_t scan_disable); - -uint8_t llc_subrate_get_active_sr_req_proc_ucfg(uint8_t conn_idx); -uint8_t llc_subrate_get_active_sr_req_proc_ucfg_weak(uint8_t conn_idx); -uint8_t llc_subrate_get_active_sr_req_proc(uint8_t conn_idx); - void llc_subrate_new_sr_base_event_ucfg(uint16_t sr_factor, uint16_t* sr_base_event_p); void llc_subrate_new_sr_base_event_ucfg_weak(uint16_t sr_factor, @@ -1383,6 +1556,10 @@ uint8_t llc_subrate_offline_processing_ucfg(void* cntxt_p); uint8_t llc_subrate_offline_processing_ucfg_weak(void* cntxt_p); uint8_t llc_subrate_offline_processing(void* cntxt_p); +void llc_subrate_register_cpf_ucfg(void); +void llc_subrate_register_cpf_ucfg_weak(void); +void llc_subrate_register_cpf(void); + void llc_mngm_csa2_select_subevent_channel_ucfg(uint8_t subevent_counter, uint8_t* subevent_index_p, uint16_t prn_s, @@ -1408,58 +1585,6 @@ void llc_mngm_csa2_select_subevent_channel(uint8_t subevent_counter, void* _csa2_table_p, uint8_t* channel_index_p); -void LL_cpe_init_length_update_ucfg(void); -void LL_cpe_init_length_update_ucfg_weak(void); -void LL_cpe_init_length_update(void); - -void LL_cpe_init_phy_update_ucfg(void); -void LL_cpe_init_phy_update_ucfg_weak(void); -void LL_cpe_init_phy_update(void); - -void LL_cpe_init_cte_ucfg(void); -void LL_cpe_init_cte_ucfg_weak(void); -void LL_cpe_init_cte(void); - -void LL_cpe_init_past_ucfg(void); -void LL_cpe_init_past_ucfg_weak(void); -void LL_cpe_init_past(void); - -void LL_cpe_init_pcl_ucfg(void); -void LL_cpe_init_pcl_ucfg_weak(void); -void LL_cpe_init_pcl(void); - -void LL_cpe_init_conn_update_ucfg(void); -void LL_cpe_init_conn_update_ucfg_weak(void); -void LL_cpe_init_conn_update(void); - -void LL_cpe_init_chmap_update_ucfg(void); -void LL_cpe_init_chmap_update_ucfg_weak(void); -void LL_cpe_init_chmap_update(void); - -void LL_cpe_init_chc_enable_ucfg(void); -void LL_cpe_init_chc_enable_ucfg_weak(void); -void LL_cpe_init_chc_enable(void); - -void LL_cpe_init_chc_reporting_ucfg(void); -void LL_cpe_init_chc_reporting_ucfg_weak(void); -void LL_cpe_init_chc_reporting(void); - -void LL_cpe_init_subrate_ucfg(void); -void LL_cpe_init_subrate_ucfg_weak(void); -void LL_cpe_init_subrate(void); - -void LL_cpe_init_sca_upd_ucfg(void); -void LL_cpe_init_sca_upd_ucfg_weak(void); -void LL_cpe_init_sca_upd(void); - -void LL_cpe_init_cis_ucfg(void); -void LL_cpe_init_cis_ucfg_weak(void); -void LL_cpe_init_cis(void); - -void LL_cpe_init_ucfg(void); -void LL_cpe_init_ucfg_weak(void); -void LL_cpe_init(void); - void LLC_channel_map_copy_to_cpf_context_ucfg(void* cntxt_p, uint8_t conn_idx); void LLC_channel_map_copy_to_cpf_context_ucfg_weak(void* cntxt_p, @@ -1483,10 +1608,29 @@ uint8_t LLC_chc_reporting_offline_processing_ucfg(uint8_t conn_idx); uint8_t LLC_chc_reporting_offline_processing_ucfg_weak(uint8_t conn_idx); uint8_t LLC_chc_reporting_offline_processing(uint8_t conn_idx); +uint32_t chc_csr_ucfg(void); +uint32_t chc_csr_ucfg_weak(void); +uint32_t chc_csr(void); + +void llc_chan_class_register_cpf_ucfg(void); +void llc_chan_class_register_cpf_ucfg_weak(void); +void llc_chan_class_register_cpf(void); + +void llc_chc_notify_all_conn_links_ucfg(uint8_t* chmap_p, + uint8_t* local_chclass_p); +void llc_chc_notify_all_conn_links_ucfg_weak(uint8_t* chmap_p, + uint8_t* local_chclass_p); +void llc_chc_notify_all_conn_links(uint8_t* chmap_p, + uint8_t* local_chclass_p); + void LL_cpf_cis_processing_ucfg(uint16_t task_idx); void LL_cpf_cis_processing_ucfg_weak(uint16_t task_idx); void LL_cpf_cis_processing(uint16_t task_idx); +void llc_cis_register_cpf_ucfg(void); +void llc_cis_register_cpf_ucfg_weak(void); +void llc_cis_register_cpf(void); + void LL_conn_upd_max_tx_time_coded_ucfg(void* params); void LL_conn_upd_max_tx_time_coded_ucfg_weak(void* params); void LL_conn_upd_max_tx_time_coded(void* params); @@ -1495,6 +1639,10 @@ void LL_conn_upd_data_length_change_event_ucfg(void* params); void LL_conn_upd_data_length_change_event_ucfg_weak(void* params); void LL_conn_upd_data_length_change_event(void* params); +void llc_cte_register_cpf_ucfg(void); +void llc_cte_register_cpf_ucfg_weak(void); +void llc_cte_register_cpf(void); + void llc_conn_init_cte_ctxt_ucfg(uint8_t conn_idx); void llc_conn_init_cte_ctxt_ucfg_weak(uint8_t conn_idx); void llc_conn_init_cte_ctxt(uint8_t conn_idx); @@ -1510,6 +1658,13 @@ void LLC_connection_cte_response_pause_resume_ucfg_weak(uint8_t conn_idx, void LLC_connection_cte_response_pause_resume(uint8_t conn_idx, uint8_t tx_phy); +void LLC_connection_cte_request_disable_ucfg(uint8_t conn_idx, + uint8_t taskslot_no); +void LLC_connection_cte_request_disable_ucfg_weak(uint8_t conn_idx, + uint8_t taskslot_no); +void LLC_connection_cte_request_disable(uint8_t conn_idx, + uint8_t taskslot_no); + void LLC_connection_cte_response_disable_ucfg(uint8_t conn_idx, uint8_t taskslot_no); void LLC_connection_cte_response_disable_ucfg_weak(uint8_t conn_idx, @@ -1524,60 +1679,14 @@ void llc_cte_process_rx_cte_ucfg_weak(void* params, void llc_cte_process_rx_cte(void* params, uint8_t cte_type); +void llc_len_upd_register_cpf_ucfg(void); +void llc_len_upd_register_cpf_ucfg_weak(void); +void llc_len_upd_register_cpf(void); + void LLC_authenticated_payload_timeout_processing_ucfg(uint16_t task_idx); void LLC_authenticated_payload_timeout_processing_ucfg_weak(uint16_t task_idx); void LLC_authenticated_payload_timeout_processing(uint16_t task_idx); -void llc_past_mem_allocate_ucfg(uint8_t scan_en, - uint8_t ext_en, - uint8_t pscan_en, - uint8_t conn_en); -void llc_past_mem_allocate_ucfg_weak(uint8_t scan_en, - uint8_t ext_en, - uint8_t pscan_en, - uint8_t conn_en); -void llc_past_mem_allocate(uint8_t scan_en, - uint8_t ext_en, - uint8_t pscan_en, - uint8_t conn_en); - -void LL_past_load_txctrl_packet_from_scanner_ucfg(void* params, - uint8_t* pdu_p, - uint32_t instant_anchor, - uint32_t connect_interval, - uint16_t connect_event_count, - uint16_t connect_event_cnt); -void LL_past_load_txctrl_packet_from_scanner_ucfg_weak(void* params, - uint8_t* pdu_p, - uint32_t instant_anchor, - uint32_t connect_interval, - uint16_t connect_event_count, - uint16_t connect_event_cnt); -void LL_past_load_txctrl_packet_from_scanner(void* params, - uint8_t* pdu_p, - uint32_t instant_anchor, - uint32_t connect_interval, - uint16_t connect_event_count, - uint16_t connect_event_cnt); - -void LL_periodicscan_deploy_scanner_from_past_ucfg(void* params, - uint8_t conn_idx, - uint8_t pawr_feat); -void LL_periodicscan_deploy_scanner_from_past_ucfg_weak(void* params, - uint8_t conn_idx, - uint8_t pawr_feat); -void LL_periodicscan_deploy_scanner_from_past(void* params, - uint8_t conn_idx, - uint8_t pawr_feat); - -void LL_past_initialize_connect_context_ucfg(uint8_t conn_idx); -void LL_past_initialize_connect_context_ucfg_weak(uint8_t conn_idx); -void LL_past_initialize_connect_context(uint8_t conn_idx); - -void LL_past_default_params_ucfg(uint8_t conn_idx); -void LL_past_default_params_ucfg_weak(uint8_t conn_idx); -void LL_past_default_params(uint8_t conn_idx); - void llc_conn_init_pcl_ctxt_ucfg(uint8_t conn_idx); void llc_conn_init_pcl_ctxt_ucfg_weak(uint8_t conn_idx); void llc_conn_init_pcl_ctxt(uint8_t conn_idx); @@ -1622,6 +1731,10 @@ uint8_t LLC_pcl_offline_processing_ucfg(uint8_t conn_idx); uint8_t LLC_pcl_offline_processing_ucfg_weak(uint8_t conn_idx); uint8_t LLC_pcl_offline_processing(uint8_t conn_idx); +void llc_pcl_register_cpf_ucfg(void); +void llc_pcl_register_cpf_ucfg_weak(void); +void llc_pcl_register_cpf(void); + tBleStatus LL_Read_RSSI_ucfg(int8_t* rssiVal, uint16_t connHandle); tBleStatus LL_Read_RSSI_ucfg_weak(int8_t* rssiVal, @@ -1641,13 +1754,20 @@ uint8_t LL_phy_upd_pending_ucfg(uint8_t conn_idx); uint8_t LL_phy_upd_pending_ucfg_weak(uint8_t conn_idx); uint8_t LL_phy_upd_pending(uint8_t conn_idx); +void llc_phy_upd_register_cpf_ucfg(void); +void llc_phy_upd_register_cpf_ucfg_weak(void); +void llc_phy_upd_register_cpf(void); + tBleStatus LL_phy_update_init_ucfg(void); tBleStatus LL_phy_update_init_ucfg_weak(void); tBleStatus LL_phy_update_init(void); -tBleStatus LL_phy_update_init_per_st_data_ucfg(uint8_t conn_idx); -tBleStatus LL_phy_update_init_per_st_data_ucfg_weak(uint8_t conn_idx); -tBleStatus LL_phy_update_init_per_st_data(uint8_t conn_idx); +tBleStatus LL_phy_update_init_per_st_data_ucfg(uint8_t conn_idx, + uint8_t hw_phy); +tBleStatus LL_phy_update_init_per_st_data_ucfg_weak(uint8_t conn_idx, + uint8_t hw_phy); +tBleStatus LL_phy_update_init_per_st_data(uint8_t conn_idx, + uint8_t hw_phy); void LL_phy_upd_evt_pending_check_isr_ucfg(uint8_t conn_idx); void LL_phy_upd_evt_pending_check_isr_ucfg_weak(uint8_t conn_idx); @@ -1674,14 +1794,14 @@ void LLC_connless_process_rx_cte(uint8_t iq_samples_ready, uint8_t channel); uint8_t LLC_check_iq_samples_ready_ucfg(uint8_t* iq_samples_number, - uint8_t* channel, - uint8_t taskslot_no); + uint8_t* channel, + uint8_t taskslot_no); uint8_t LLC_check_iq_samples_ready_ucfg_weak(uint8_t* iq_samples_number, - uint8_t* channel, - uint8_t taskslot_no); + uint8_t* channel, + uint8_t taskslot_no); uint8_t LLC_check_iq_samples_ready(uint8_t* iq_samples_number, - uint8_t* channel, - uint8_t taskslot_no); + uint8_t* channel, + uint8_t taskslot_no); void llc_cte_init_ucfg(void); void llc_cte_init_ucfg_weak(void); @@ -1704,9 +1824,12 @@ void llc_cte_timer_error_ucfg(void); void llc_cte_timer_error_ucfg_weak(void); void llc_cte_timer_error(void); -void llc_cte_timer_start_ucfg(void* params); -void llc_cte_timer_start_ucfg_weak(void* params); -void llc_cte_timer_start(void* params); +void llc_cte_timer_start_ucfg(void* params, + uint32_t radio_task_anchor); +void llc_cte_timer_start_ucfg_weak(void* params, + uint32_t radio_task_anchor); +void llc_cte_timer_start(void* params, + uint32_t radio_task_anchor); uint8_t llc_cte_timer_stop_ucfg(void); uint8_t llc_cte_timer_stop_ucfg_weak(void); @@ -1720,15 +1843,15 @@ void LLC_test_set_cte_ucfg(void* params); void LLC_test_set_cte_ucfg_weak(void* params); void LLC_test_set_cte(void* params); -void ADV_ISR_connect_request_received_ucfg(void* pointer, - uint8_t* packet, - void* PeerIDAddress_p); -void ADV_ISR_connect_request_received_ucfg_weak(void* pointer, - uint8_t* packet, - void* PeerIDAddress_p); -void ADV_ISR_connect_request_received(void* pointer, - uint8_t* packet, - void* PeerIDAddress_p); +uint8_t ADV_ISR_connect_request_received_ucfg(void* pointer, + uint8_t* packet, + void* PeerIDAddress_p); +uint8_t ADV_ISR_connect_request_received_ucfg_weak(void* pointer, + uint8_t* packet, + void* PeerIDAddress_p); +uint8_t ADV_ISR_connect_request_received(void* pointer, + uint8_t* packet, + void* PeerIDAddress_p); void LL_eadv_EauxIsr_connect_response_sent_ucfg(void* pointer); void LL_eadv_EauxIsr_connect_response_sent_ucfg_weak(void* pointer); @@ -1752,9 +1875,12 @@ tBleStatus llc_eadv_max_supported_data_check_ucfg_weak(uint16_t data_length, tBleStatus llc_eadv_max_supported_data_check(uint16_t data_length, void* pointer); -void LL_eadv_start_extended_ucfg(void* pointer); -void LL_eadv_start_extended_ucfg_weak(void* pointer); -void LL_eadv_start_extended(void* pointer); +tBleStatus LL_eadv_start_extended_ucfg(void* pointer, + uint32_t anchor_stu); +tBleStatus LL_eadv_start_extended_ucfg_weak(void* pointer, + uint32_t anchor_stu); +tBleStatus LL_eadv_start_extended(void* pointer, + uint32_t anchor_stu); uint8_t ext_adv_scan_enabled_ucfg(void); uint8_t ext_adv_scan_enabled_ucfg_weak(void); @@ -1768,12 +1894,9 @@ tBleStatus LL_Remove_Advertising_Set_ucfg(uint16_t Advertising_Handle); tBleStatus LL_Remove_Advertising_Set_ucfg_weak(uint16_t Advertising_Handle); tBleStatus LL_Remove_Advertising_Set(uint16_t Advertising_Handle); -uint8_t Data_Len_Update_Offline_Processing_ucfg(void* params, - uint32_t ctrl_flds); -uint8_t Data_Len_Update_Offline_Processing_ucfg_weak(void* params, - uint32_t ctrl_flds); -uint8_t Data_Len_Update_Offline_Processing(void* params, - uint32_t ctrl_flds); +uint8_t Data_Len_Update_Offline_Processing_ucfg(void* params); +uint8_t Data_Len_Update_Offline_Processing_ucfg_weak(void* params); +uint8_t Data_Len_Update_Offline_Processing(void* params); tBleStatus ll_write_supported_data_ucfg(uint16_t Supported_Max_Tx_Octets, uint16_t Supported_Max_Tx_Time, @@ -2549,25 +2672,6 @@ tBleStatus hci_le_remove_advertising_set_api(uint8_t Advertising_Handle); tBleStatus hci_le_clear_advertising_sets_api(void); -tBleStatus hci_le_set_default_periodic_advertising_sync_transfer_parameters_api(uint8_t Mode, - uint16_t Skip, - uint16_t Sync_Timeout, - uint8_t CTE_Type); - -tBleStatus hci_le_set_periodic_advertising_sync_transfer_parameters_api(uint16_t Connection_Handle, - uint8_t Mode, - uint16_t Skip, - uint16_t Sync_Timeout, - uint8_t CTE_Type); - -tBleStatus hci_le_periodic_advertising_set_info_transfer_api(uint16_t Connection_Handle, - uint16_t Service_Data, - uint8_t Advertising_Handle); - -tBleStatus hci_le_periodic_advertising_sync_transfer_api(uint16_t Connection_Handle, - uint16_t Service_Data, - uint16_t Sync_Handle); - tBleStatus hci_le_iso_transmit_test_api(uint16_t Connection_Handle, uint8_t Payload_Type); @@ -2648,6 +2752,25 @@ tBleStatus hci_le_set_periodic_advertising_parameters_v2_api(uint8_t Advertising uint8_t Response_Slot_Spacing, uint8_t Num_Response_Slots); +tBleStatus hci_le_periodic_advertising_set_info_transfer_api(uint16_t Connection_Handle, + uint16_t Service_Data, + uint8_t Advertising_Handle); + +tBleStatus hci_le_periodic_advertising_sync_transfer_api(uint16_t Connection_Handle, + uint16_t Service_Data, + uint16_t Sync_Handle); + +tBleStatus hci_le_set_default_periodic_advertising_sync_transfer_parameters_api(uint8_t Mode, + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t CTE_Type); + +tBleStatus hci_le_set_periodic_advertising_sync_transfer_parameters_api(uint16_t Connection_Handle, + uint8_t Mode, + uint16_t Skip, + uint16_t Sync_Timeout, + uint8_t CTE_Type); + tBleStatus hci_le_enhanced_read_transmit_power_level_api(uint16_t Connection_Handle, uint8_t PHY, int8_t* Current_TX_Power_Level, diff --git a/lib/stm32wb0/STM32_BLE/stack/include/bleplat_cntr.h b/lib/stm32wb0/STM32_BLE/stack/include/bleplat_cntr.h index b780259a4..5baa9f3d0 100644 --- a/lib/stm32wb0/STM32_BLE/stack/include/bleplat_cntr.h +++ b/lib/stm32wb0/STM32_BLE/stack/include/bleplat_cntr.h @@ -239,8 +239,8 @@ void BLEPLAT_CNTR_SmToggleSn(uint8_t smNo); void BLEPLAT_CNTR_StartEncrypt(void); uint32_t BLEPLAT_CNTR_TimeDiff(uint32_t x, uint32_t y); uint8_t BLEPLAT_CNTR_DemodDelaySt(uint8_t RxPHY); -uint32_t BLEPLAT_CNTR_GetTimer2TimeoutForIfs(uint32_t T_Ifs, BLEPLAT_CNTR_Transaction Transaction, uint8_t Cal_Enabled); - +uint32_t BLEPLAT_CNTR_GetTimer2TimeoutForIfs(uint32_t T_Ifs, BLEPLAT_CNTR_Transaction Transaction, uint8_t Rx_Phy, uint8_t Tx_Phy, uint8_t Cal_Enabled); +uint32_t BLEPLAT_CNTR_IsEnabledTimer1(void); /** * @} diff --git a/zephyr/module.yml b/zephyr/module.yml index d53efe1c3..b97986fad 100644 --- a/zephyr/module.yml +++ b/zephyr/module.yml @@ -47,11 +47,11 @@ blobs: url: https://github.com/STMicroelectronics/STM32CubeWBA/raw/v1.7.0/Middlewares/ST/STM32_WPAN/ble/stack/lib/stm32wba_ble_stack_llobasic.a description: "Binary Stack library for the STM32WBA Bluetooth subsystem" - path: stm32wb0/lib/stm32wb0x_ble_stack_controller_only.a - sha256: e6b82f379a9cf071b36914cf4ba92192d6da2cd3c4fef1a4e1126df534e822b3 + sha256: f4d44401f8caba4d81e7c38e7549745b7525650d61f53541f5e030d1228e52b9 type: lib - version: '1.1.0' + version: '1.4.0' license-path: zephyr/blobs/stm32wb0/lib/license.md - url: https://github.com/STMicroelectronics/STM32CubeWB0/raw/v1.1.0/Middlewares/ST/STM32_BLE/stack/lib/stm32wb0x_ble_stack_controller_only.a + url: https://github.com/STMicroelectronics/STM32CubeWB0/raw/v1.4.0/Middlewares/ST/STM32_BLE/stack/lib/stm32wb0x_ble_stack_controller_only.a description: "Binary Stack library for the STM32WB0 Bluetooth subsystem" - path: stm32wba/lib/WBA6_LinkLayer15_4_Zephyr.a sha256: 189e087aef9942b6fa77e0573346cedbb1ea354ee4aa7649bfbd465779969fb3 From 6e4e5f3936ce7fa30374322f225f0f1f59d4ef56 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Mon, 15 Dec 2025 09:15:46 +0100 Subject: [PATCH 10/11] lib/stm32wb0: fix v1.4.0 build Consider dtm_cmds.h header file added in STMB32CubeWB0 v1.4.0. Disable build of DTM_CMDS_TxTestStopRequest() in Zephyr context. Signed-off-by: Etienne Carriere --- .../STM32_BLE/App/dtm_cmds.h | 31 +++++++++++++++++++ .../STM32_BLE/App/transport_layer.c | 2 ++ lib/stm32wb0/README.rst | 1 + scripts/ble_library.py | 1 + 4 files changed, 35 insertions(+) create mode 100644 lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.h diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.h b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.h new file mode 100644 index 000000000..ca49b6dbe --- /dev/null +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.h @@ -0,0 +1,31 @@ +/* USER CODE BEGIN Header */ + +/** + ****************************************************************************** + * @file dtm_cmds.h + * @author GPM WBL Application Team + * @brief Header file for module implementing come ACI commands outside of BLE Stack + ****************************************************************************** + * @attention + * + * Copyright (c) 2025 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. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +#ifndef DTM_CMDS_H +#define DTM_CMDS_H + +void DTM_CMDS_TxEnd(void); + +void DTM_CMDS_TxTestStopRequest(void); + +void DTM_CMDS_TxTestStop(void); + +#endif /* DTM_CMDS_H */ diff --git a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.c b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.c index 672bc1eb4..180f3ff75 100644 --- a/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.c +++ b/lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/transport_layer.c @@ -481,9 +481,11 @@ void BLE_STACK_Event(hci_pckt *hci_pckt, uint16_t length) } } +#ifndef __ZEPHYR__ /* Handle request to stop TX test for aci_hal_transmitter_test_packets */ void DTM_CMDS_TxTestStopRequest(void) { tx_test_stop_request = true; TL_ProcessReqCallback(); } +#endif /* __ZEPHYR__ */ diff --git a/lib/stm32wb0/README.rst b/lib/stm32wb0/README.rst index 273839f8b..a2274520c 100644 --- a/lib/stm32wb0/README.rst +++ b/lib/stm32wb0/README.rst @@ -49,6 +49,7 @@ Description: Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_en.h Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_cmd_stack_en.h Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.c + Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_cmds.h Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_preprocess_events.c Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/dtm_preprocess_events.h Projects/NUCLEO-WB09KE/Applications/BLE/BLE_TransparentMode/STM32_BLE/App/fifo.h diff --git a/scripts/ble_library.py b/scripts/ble_library.py index eedc3a0d7..39d7090f9 100644 --- a/scripts/ble_library.py +++ b/scripts/ble_library.py @@ -185,6 +185,7 @@ wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_cmd_db.h", wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_cmd_en.h", wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_cmds.c", + wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_cmds.h", wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_cmd_stack_en.h", wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_preprocess_events.c", wb0_ble_transparent_mode_app_path + "/STM32_BLE/App/dtm_preprocess_events.h", From 3bc848f14f56020d05a99f78e195c265f4333f6e Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Fri, 12 Dec 2025 12:11:16 +0100 Subject: [PATCH 11/11] stm32cube: common_ll: Regeneration after cube updates Re - generate common_ll headers after Cube updates Signed-off-by: Etienne Carriere --- stm32cube/common_ll/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stm32cube/common_ll/README.rst b/stm32cube/common_ll/README.rst index cc110a308..32e8b1b1c 100644 --- a/stm32cube/common_ll/README.rst +++ b/stm32cube/common_ll/README.rst @@ -33,7 +33,7 @@ stm32n6xx 1.2.0 stm32u0xx 1.3.0 stm32u3xx 1.2.0 stm32u5xx 1.8.0 -stm32wb0x 1.1.0 +stm32wb0x 1.4.0 stm32wbaxx 1.7.0 stm32wbxx 1.23.0 stm32wlxx 1.3.1