@@ -0,0 +1,167 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx.h | |||
* @author MCD Application Team | |||
* @brief CMSIS STM32WBxx Device Peripheral Access Layer Header File. | |||
* | |||
* The file is the unique include file that the application programmer | |||
* is using in the C source code, usually in main.c. This file contains: | |||
* - Configuration section that allows to select: | |||
* - The STM32WBxx device used in the target application | |||
* - To use or not the peripheral's drivers in application code(i.e. | |||
* code will be based on direct access to peripheral's registers | |||
* rather than drivers API), this option is controlled by | |||
* "#define USE_HAL_DRIVER" | |||
* | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/** @addtogroup CMSIS | |||
* @{ | |||
*/ | |||
/** @addtogroup stm32wbxx | |||
* @{ | |||
*/ | |||
#ifndef __STM32WBxx_H | |||
#define __STM32WBxx_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif /* __cplusplus */ | |||
/** @addtogroup Library_configuration_section | |||
* @{ | |||
*/ | |||
/** | |||
* @brief STM32 Family | |||
*/ | |||
#if !defined (STM32WB) | |||
#define STM32WB | |||
#endif /* STM32WB */ | |||
/* Tip: To avoid modifying this file each time you need to switch between these | |||
devices, you can define the device in your toolchain compiler preprocessor. | |||
*/ | |||
#if !defined (USE_HAL_DRIVER) | |||
/** | |||
* @brief Comment the line below if you will not use the peripherals drivers. | |||
In this case, these drivers will not be included and the application code will | |||
be based on direct access to peripherals registers | |||
*/ | |||
/*#define USE_HAL_DRIVER */ | |||
#endif /* USE_HAL_DRIVER */ | |||
/** | |||
* @brief CMSIS Device version number | |||
*/ | |||
#define __STM32WBxx_CMSIS_VERSION_MAIN (0x01U) /*!< [31:24] main version */ | |||
#define __STM32WBxx_CMSIS_VERSION_SUB1 (0x01U) /*!< [23:16] sub1 version */ | |||
#define __STM32WBxx_CMSIS_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ | |||
#define __STM32WBxx_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */ | |||
#define __STM32WBxx_CMSIS_DEVICE_VERSION ((__STM32WBxx_CMSIS_VERSION_MAIN << 24)\ | |||
|(__STM32WBxx_CMSIS_VERSION_SUB1 << 16)\ | |||
|(__STM32WBxx_CMSIS_VERSION_SUB2 << 8 )\ | |||
|(__STM32WBxx_CMSIS_VERSION_RC)) | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup Device_Included | |||
* @{ | |||
*/ | |||
#if defined(STM32WB55xx) | |||
#include "stm32wb55xx.h" | |||
#else | |||
#error "Please select first the target STM32WBxx device used in your application, for instance xxx (in stm32wbxx.h file)" | |||
#endif | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup Exported_types | |||
* @{ | |||
*/ | |||
typedef enum | |||
{ | |||
RESET = 0, | |||
SET = !RESET | |||
} FlagStatus, ITStatus; | |||
typedef enum | |||
{ | |||
DISABLE = 0, | |||
ENABLE = !DISABLE | |||
} FunctionalState; | |||
#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) | |||
typedef enum | |||
{ | |||
SUCCESS = 0, | |||
ERROR = !SUCCESS | |||
} ErrorStatus; | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup Exported_macros | |||
* @{ | |||
*/ | |||
#define SET_BIT(REG, BIT) ((REG) |= (BIT)) | |||
#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) | |||
#define READ_BIT(REG, BIT) ((REG) & (BIT)) | |||
#define CLEAR_REG(REG) ((REG) = (0x0)) | |||
#define WRITE_REG(REG, VAL) ((REG) = (VAL)) | |||
#define READ_REG(REG) ((REG)) | |||
#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) | |||
#define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) | |||
/** | |||
* @} | |||
*/ | |||
#if defined (USE_HAL_DRIVER) | |||
#include "stm32wbxx_hal.h" | |||
#endif /* USE_HAL_DRIVER */ | |||
#ifdef __cplusplus | |||
} | |||
#endif /* __cplusplus */ | |||
#endif /* __STM32WBxx_H */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,111 @@ | |||
/** | |||
****************************************************************************** | |||
* @file system_stm32wbxx.h | |||
* @author MCD Application Team | |||
* @brief CMSIS Cortex Device System Source File for STM32WBxx devices. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/** @addtogroup CMSIS | |||
* @{ | |||
*/ | |||
/** @addtogroup stm32wbxx_system | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Define to prevent recursive inclusion | |||
*/ | |||
#ifndef __SYSTEM_STM32WBXX_H | |||
#define __SYSTEM_STM32WBXX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
#include <stdint.h> | |||
/** @addtogroup STM32WBxx_System_Includes | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup STM32WBxx_System_Exported_types | |||
* @{ | |||
*/ | |||
/* The SystemCoreClock variable is updated in three ways: | |||
1) by calling CMSIS function SystemCoreClockUpdate() | |||
2) by calling HAL API function HAL_RCC_GetSysClockFreq() | |||
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency | |||
Note: If you use this function to configure the system clock; then there | |||
is no need to call the 2 first functions listed above, since SystemCoreClock | |||
variable is updated automatically. | |||
*/ | |||
extern uint32_t SystemCoreClock; /*!< System Clock Frequency */ | |||
extern const uint32_t AHBPrescTable[16]; /*!< AHB prescalers table values */ | |||
extern const uint32_t APBPrescTable[8]; /*!< APB prescalers table values */ | |||
extern const uint32_t MSIRangeTable[16]; /*!< MSI ranges table values */ | |||
extern const uint32_t SmpsPrescalerTable[4][6]; /*!< SMPS factor ranges table values */ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup STM32WBxx_System_Exported_Constants | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup STM32WBxx_System_Exported_Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup STM32WBxx_System_Exported_Functions | |||
* @{ | |||
*/ | |||
extern void SystemInit(void); | |||
extern void SystemCoreClockUpdate(void); | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /*__SYSTEM_STM32WBXX_H */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,368 @@ | |||
;****************************************************************************** | |||
;* File Name : startup_stm32wb55xx_cm4.s | |||
;* Author : MCD Application Team | |||
;* Description : STM32WB55xx devices vector table for MDK-ARM toolchain. | |||
;* This module performs: | |||
;* - Set the initial SP | |||
;* - Set the initial PC == Reset_Handler | |||
;* - Set the vector table entries with the exceptions ISR address | |||
;* - Branches to __main in the C library (which eventually | |||
;* calls main()). | |||
;* After Reset the CortexM4 processor is in Thread mode, | |||
;* priority is Privileged, and the Stack is set to Main. | |||
;* <<< Use Configuration Wizard in Context Menu >>> | |||
;****************************************************************************** | |||
;* @attention | |||
;* | |||
;* Copyright (c) 2019 STMicroelectronics. All rights reserved. | |||
;* | |||
;* This software component is licensed by ST under BSD 3-Clause license, | |||
;* the "License"; You may not use this file except in compliance with the | |||
;* License. You may obtain a copy of the License at: | |||
;* opensource.org/licenses/BSD-3-Clause | |||
;* | |||
;****************************************************************************** | |||
; Amount of memory (in bytes) allocated for Stack | |||
; Tailor this value to your application needs | |||
; <h> Stack Configuration | |||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> | |||
; </h> | |||
Stack_Size EQU 0x00000400 | |||
AREA STACK, NOINIT, READWRITE, ALIGN=3 | |||
Stack_Mem SPACE Stack_Size | |||
__initial_sp | |||
; <h> Heap Configuration | |||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> | |||
; </h> | |||
Heap_Size EQU 0x00000200 | |||
AREA HEAP, NOINIT, READWRITE, ALIGN=3 | |||
__heap_base | |||
Heap_Mem SPACE Heap_Size | |||
__heap_limit | |||
PRESERVE8 | |||
THUMB | |||
; Vector Table Mapped to Address 0 at Reset | |||
AREA RESET, DATA, READONLY | |||
EXPORT __Vectors | |||
EXPORT __Vectors_End | |||
EXPORT __Vectors_Size | |||
__Vectors DCD __initial_sp ; Top of Stack | |||
DCD Reset_Handler ; Reset Handler | |||
DCD NMI_Handler ; NMI Handler | |||
DCD HardFault_Handler ; Hard Fault Handler | |||
DCD MemManage_Handler ; MPU Fault Handler | |||
DCD BusFault_Handler ; Bus Fault Handler | |||
DCD UsageFault_Handler ; Usage Fault Handler | |||
DCD 0 ; Reserved | |||
DCD 0 ; Reserved | |||
DCD 0 ; Reserved | |||
DCD 0 ; Reserved | |||
DCD SVC_Handler ; SVCall Handler | |||
DCD DebugMon_Handler ; Debug Monitor Handler | |||
DCD 0 ; Reserved | |||
DCD PendSV_Handler ; PendSV Handler | |||
DCD SysTick_Handler ; SysTick Handler | |||
; External Interrupts | |||
DCD WWDG_IRQHandler ; Window WatchDog | |||
DCD PVD_PVM_IRQHandler ; PVD and PVM detector | |||
DCD TAMP_STAMP_LSECSS_IRQHandler ; RTC Tamper and TimeStamp Interrupts and LSECSS Interrupts | |||
DCD RTC_WKUP_IRQHandler ; RTC Wakeup Interrupt | |||
DCD FLASH_IRQHandler ; FLASH global Interrupt | |||
DCD RCC_IRQHandler ; RCC Interrupt | |||
DCD EXTI0_IRQHandler ; EXTI Line 0 Interrupt | |||
DCD EXTI1_IRQHandler ; EXTI Line 1 Interrupt | |||
DCD EXTI2_IRQHandler ; EXTI Line 2 Interrupt | |||
DCD EXTI3_IRQHandler ; EXTI Line 3 Interrup | |||
DCD EXTI4_IRQHandler ; EXTI Line 4 Interrupt | |||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 Interrupt | |||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 Interrupt | |||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 Interrupt | |||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 Interrupt | |||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 Interrupt | |||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 Interrupt | |||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 Interrupt | |||
DCD ADC1_IRQHandler ; ADC1 Interrupt | |||
DCD USB_HP_IRQHandler ; USB High Priority Interrupt | |||
DCD USB_LP_IRQHandler ; USB Low Priority Interrupt | |||
DCD C2SEV_PWR_C2H_IRQHandler ; CPU M0+ SEV Interrupt | |||
DCD COMP_IRQHandler ; COMP1 and COMP2 Interrupts | |||
DCD EXTI9_5_IRQHandler ; EXTI Lines [9:5] Interrupt | |||
DCD TIM1_BRK_IRQHandler ; TIM1 Break Interrupt | |||
DCD TIM1_UP_TIM16_IRQHandler ; TIM1 Update and TIM16 global Interrupts | |||
DCD TIM1_TRG_COM_TIM17_IRQHandler ; TIM1 Trigger and Communication and TIM17 global Interrupts | |||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare Interrupt | |||
DCD TIM2_IRQHandler ; TIM2 Global Interrupt | |||
DCD PKA_IRQHandler ; PKA Interrupt | |||
DCD I2C1_EV_IRQHandler ; I2C1 Event Interrupt | |||
DCD I2C1_ER_IRQHandler ; I2C1 Error Interrupt | |||
DCD I2C3_EV_IRQHandler ; I2C3 Event Interrupt | |||
DCD I2C3_ER_IRQHandler ; I2C3 Error Interrupt | |||
DCD SPI1_IRQHandler ; SPI1 Interrupt | |||
DCD SPI2_IRQHandler ; SPI2 Interrupt | |||
DCD USART1_IRQHandler ; USART1 Interrupt | |||
DCD LPUART1_IRQHandler ; LPUART1 Interrupt | |||
DCD SAI1_IRQHandler ; SAI Interrupt | |||
DCD TSC_IRQHandler ; TSC Interrupt | |||
DCD EXTI15_10_IRQHandler ; EXTI Lines1[15:10 ]Interrupts | |||
DCD RTC_Alarm_IRQHandler ; RTC Alarms (A and B) Interrupt | |||
DCD CRS_IRQHandler ; CRS interrupt | |||
DCD PWR_SOTF_BLEACT_802ACT_RFPHASE_IRQHandler ; WKUP Interrupt from PWR | |||
DCD IPCC_C1_RX_IRQHandler ; IPCC CPU1 RX occupied interrupt | |||
DCD IPCC_C1_TX_IRQHandler ; IPCC CPU1 RX free interrupt | |||
DCD HSEM_IRQHandler ; HSEM0 Interrupt | |||
DCD LPTIM1_IRQHandler ; LPTIM1 Interrupt | |||
DCD LPTIM2_IRQHandler ; LPTIM2 Interrupt | |||
DCD LCD_IRQHandler ; LCD Interrupt | |||
DCD QUADSPI_IRQHandler ; QUADSPI Interrupt | |||
DCD AES1_IRQHandler ; AES1 Interrupt | |||
DCD AES2_IRQHandler ; AES2 Interrupt | |||
DCD RNG_IRQHandler ; RNG1 Interrupt | |||
DCD FPU_IRQHandler ; FPU Interrupt | |||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel 1 Interrupt | |||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel 2 Interrupt | |||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel 3 Interrupt | |||
DCD DMA2_Channel4_IRQHandler ; DMA2 Channel 4 Interrupt | |||
DCD DMA2_Channel5_IRQHandler ; DMA2 Channel 5 Interrupt | |||
DCD DMA2_Channel6_IRQHandler ; DMA2 Channel 6 Interrupt | |||
DCD DMA2_Channel7_IRQHandler ; DMA2 Channel 7 Interrupt | |||
DCD DMAMUX1_OVR_IRQHandler ; DMAMUX overrun Interrupt | |||
__Vectors_End | |||
__Vectors_Size EQU __Vectors_End - __Vectors | |||
AREA |.text|, CODE, READONLY | |||
; Reset handler | |||
Reset_Handler PROC | |||
EXPORT Reset_Handler [WEAK] | |||
IMPORT SystemInit | |||
IMPORT __main | |||
LDR R0, =SystemInit | |||
BLX R0 | |||
LDR R0, =__main | |||
BX R0 | |||
ENDP | |||
; Dummy Exception Handlers (infinite loops which can be modified) | |||
NMI_Handler PROC | |||
EXPORT NMI_Handler [WEAK] | |||
B . | |||
ENDP | |||
HardFault_Handler\ | |||
PROC | |||
EXPORT HardFault_Handler [WEAK] | |||
B . | |||
ENDP | |||
MemManage_Handler\ | |||
PROC | |||
EXPORT MemManage_Handler [WEAK] | |||
B . | |||
ENDP | |||
BusFault_Handler\ | |||
PROC | |||
EXPORT BusFault_Handler [WEAK] | |||
B . | |||
ENDP | |||
UsageFault_Handler\ | |||
PROC | |||
EXPORT UsageFault_Handler [WEAK] | |||
B . | |||
ENDP | |||
SVC_Handler PROC | |||
EXPORT SVC_Handler [WEAK] | |||
B . | |||
ENDP | |||
DebugMon_Handler\ | |||
PROC | |||
EXPORT DebugMon_Handler [WEAK] | |||
B . | |||
ENDP | |||
PendSV_Handler PROC | |||
EXPORT PendSV_Handler [WEAK] | |||
B . | |||
ENDP | |||
SysTick_Handler PROC | |||
EXPORT SysTick_Handler [WEAK] | |||
B . | |||
ENDP | |||
Default_Handler PROC | |||
EXPORT WWDG_IRQHandler [WEAK] | |||
EXPORT PVD_PVM_IRQHandler [WEAK] | |||
EXPORT TAMP_STAMP_LSECSS_IRQHandler [WEAK] | |||
EXPORT RTC_WKUP_IRQHandler [WEAK] | |||
EXPORT FLASH_IRQHandler [WEAK] | |||
EXPORT RCC_IRQHandler [WEAK] | |||
EXPORT EXTI0_IRQHandler [WEAK] | |||
EXPORT EXTI1_IRQHandler [WEAK] | |||
EXPORT EXTI2_IRQHandler [WEAK] | |||
EXPORT EXTI3_IRQHandler [WEAK] | |||
EXPORT EXTI4_IRQHandler [WEAK] | |||
EXPORT DMA1_Channel1_IRQHandler [WEAK] | |||
EXPORT DMA1_Channel2_IRQHandler [WEAK] | |||
EXPORT DMA1_Channel3_IRQHandler [WEAK] | |||
EXPORT DMA1_Channel4_IRQHandler [WEAK] | |||
EXPORT DMA1_Channel5_IRQHandler [WEAK] | |||
EXPORT DMA1_Channel6_IRQHandler [WEAK] | |||
EXPORT DMA1_Channel7_IRQHandler [WEAK] | |||
EXPORT ADC1_IRQHandler [WEAK] | |||
EXPORT USB_HP_IRQHandler [WEAK] | |||
EXPORT USB_LP_IRQHandler [WEAK] | |||
EXPORT C2SEV_PWR_C2H_IRQHandler [WEAK] | |||
EXPORT COMP_IRQHandler [WEAK] | |||
EXPORT EXTI9_5_IRQHandler [WEAK] | |||
EXPORT TIM1_BRK_IRQHandler [WEAK] | |||
EXPORT TIM1_UP_TIM16_IRQHandler [WEAK] | |||
EXPORT TIM1_TRG_COM_TIM17_IRQHandler [WEAK] | |||
EXPORT TIM1_CC_IRQHandler [WEAK] | |||
EXPORT TIM2_IRQHandler [WEAK] | |||
EXPORT PKA_IRQHandler [WEAK] | |||
EXPORT I2C1_EV_IRQHandler [WEAK] | |||
EXPORT I2C1_ER_IRQHandler [WEAK] | |||
EXPORT I2C3_EV_IRQHandler [WEAK] | |||
EXPORT I2C3_ER_IRQHandler [WEAK] | |||
EXPORT SPI1_IRQHandler [WEAK] | |||
EXPORT SPI2_IRQHandler [WEAK] | |||
EXPORT USART1_IRQHandler [WEAK] | |||
EXPORT LPUART1_IRQHandler [WEAK] | |||
EXPORT SAI1_IRQHandler [WEAK] | |||
EXPORT TSC_IRQHandler [WEAK] | |||
EXPORT EXTI15_10_IRQHandler [WEAK] | |||
EXPORT RTC_Alarm_IRQHandler [WEAK] | |||
EXPORT CRS_IRQHandler [WEAK] | |||
EXPORT PWR_SOTF_BLEACT_802ACT_RFPHASE_IRQHandler [WEAK] | |||
EXPORT IPCC_C1_RX_IRQHandler [WEAK] | |||
EXPORT IPCC_C1_TX_IRQHandler [WEAK] | |||
EXPORT HSEM_IRQHandler [WEAK] | |||
EXPORT LPTIM1_IRQHandler [WEAK] | |||
EXPORT LPTIM2_IRQHandler [WEAK] | |||
EXPORT LCD_IRQHandler [WEAK] | |||
EXPORT QUADSPI_IRQHandler [WEAK] | |||
EXPORT AES1_IRQHandler [WEAK] | |||
EXPORT AES2_IRQHandler [WEAK] | |||
EXPORT RNG_IRQHandler [WEAK] | |||
EXPORT FPU_IRQHandler [WEAK] | |||
EXPORT DMA2_Channel1_IRQHandler [WEAK] | |||
EXPORT DMA2_Channel2_IRQHandler [WEAK] | |||
EXPORT DMA2_Channel3_IRQHandler [WEAK] | |||
EXPORT DMA2_Channel4_IRQHandler [WEAK] | |||
EXPORT DMA2_Channel5_IRQHandler [WEAK] | |||
EXPORT DMA2_Channel6_IRQHandler [WEAK] | |||
EXPORT DMA2_Channel7_IRQHandler [WEAK] | |||
EXPORT DMAMUX1_OVR_IRQHandler [WEAK] | |||
WWDG_IRQHandler | |||
PVD_PVM_IRQHandler | |||
TAMP_STAMP_LSECSS_IRQHandler | |||
RTC_WKUP_IRQHandler | |||
FLASH_IRQHandler | |||
RCC_IRQHandler | |||
EXTI0_IRQHandler | |||
EXTI1_IRQHandler | |||
EXTI2_IRQHandler | |||
EXTI3_IRQHandler | |||
EXTI4_IRQHandler | |||
DMA1_Channel1_IRQHandler | |||
DMA1_Channel2_IRQHandler | |||
DMA1_Channel3_IRQHandler | |||
DMA1_Channel4_IRQHandler | |||
DMA1_Channel5_IRQHandler | |||
DMA1_Channel6_IRQHandler | |||
DMA1_Channel7_IRQHandler | |||
ADC1_IRQHandler | |||
USB_HP_IRQHandler | |||
USB_LP_IRQHandler | |||
C2SEV_PWR_C2H_IRQHandler | |||
COMP_IRQHandler | |||
EXTI9_5_IRQHandler | |||
TIM1_BRK_IRQHandler | |||
TIM1_UP_TIM16_IRQHandler | |||
TIM1_TRG_COM_TIM17_IRQHandler | |||
TIM1_CC_IRQHandler | |||
TIM2_IRQHandler | |||
PKA_IRQHandler | |||
I2C1_EV_IRQHandler | |||
I2C1_ER_IRQHandler | |||
I2C3_EV_IRQHandler | |||
I2C3_ER_IRQHandler | |||
SPI1_IRQHandler | |||
SPI2_IRQHandler | |||
USART1_IRQHandler | |||
LPUART1_IRQHandler | |||
SAI1_IRQHandler | |||
TSC_IRQHandler | |||
EXTI15_10_IRQHandler | |||
RTC_Alarm_IRQHandler | |||
CRS_IRQHandler | |||
PWR_SOTF_BLEACT_802ACT_RFPHASE_IRQHandler | |||
IPCC_C1_RX_IRQHandler | |||
IPCC_C1_TX_IRQHandler | |||
HSEM_IRQHandler | |||
LPTIM1_IRQHandler | |||
LPTIM2_IRQHandler | |||
LCD_IRQHandler | |||
QUADSPI_IRQHandler | |||
AES1_IRQHandler | |||
AES2_IRQHandler | |||
RNG_IRQHandler | |||
FPU_IRQHandler | |||
DMA2_Channel1_IRQHandler | |||
DMA2_Channel2_IRQHandler | |||
DMA2_Channel3_IRQHandler | |||
DMA2_Channel4_IRQHandler | |||
DMA2_Channel5_IRQHandler | |||
DMA2_Channel6_IRQHandler | |||
DMA2_Channel7_IRQHandler | |||
DMAMUX1_OVR_IRQHandler | |||
B . | |||
ENDP | |||
ALIGN | |||
;******************************************************************************* | |||
; User Stack and Heap initialization | |||
;******************************************************************************* | |||
IF :DEF:__MICROLIB | |||
EXPORT __initial_sp | |||
EXPORT __heap_base | |||
EXPORT __heap_limit | |||
ELSE | |||
IMPORT __use_two_region_memory | |||
EXPORT __user_initial_stackheap | |||
__user_initial_stackheap | |||
LDR R0, = Heap_Mem | |||
LDR R1, =(Stack_Mem + Stack_Size) | |||
LDR R2, = (Heap_Mem + Heap_Size) | |||
LDR R3, = Stack_Mem | |||
BX LR | |||
ALIGN | |||
ENDIF | |||
END | |||
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE***** |
@@ -0,0 +1,427 @@ | |||
/** | |||
****************************************************************************** | |||
* @file startup_stm32wb55xx_cm4.s | |||
* @author MCD Application Team | |||
* @brief STM32WB55xx devices vector table GCC toolchain. | |||
* This module performs: | |||
* - Set the initial SP | |||
* - Set the initial PC == Reset_Handler, | |||
* - Set the vector table entries with the exceptions ISR address | |||
* - Branches to main in the C library (which eventually | |||
* calls main()). | |||
* After Reset the Cortex-M4 processor is in Thread mode, | |||
* priority is Privileged, and the Stack is set to Main. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
.syntax unified | |||
.cpu cortex-m4 | |||
.fpu softvfp | |||
.thumb | |||
.global g_pfnVectors | |||
.global Default_Handler | |||
/* start address for the initialization values of the .data section. | |||
defined in linker script */ | |||
.word _sidata | |||
/* start address for the .data section. defined in linker script */ | |||
.word _sdata | |||
/* end address for the .data section. defined in linker script */ | |||
.word _edata | |||
/* start address for the .bss section. defined in linker script */ | |||
.word _sbss | |||
/* end address for the .bss section. defined in linker script */ | |||
.word _ebss | |||
.section .text.Reset_Handler | |||
.weak Reset_Handler | |||
.type Reset_Handler, %function | |||
Reset_Handler: | |||
ldr r0, =_estack | |||
mov sp, r0 /* set stack pointer */ | |||
/* Copy the data segment initializers from flash to SRAM */ | |||
ldr r0, =_sdata | |||
ldr r1, =_edata | |||
ldr r2, =_sidata | |||
movs r3, #0 | |||
b LoopCopyDataInit | |||
CopyDataInit: | |||
ldr r4, [r2, r3] | |||
str r4, [r0, r3] | |||
adds r3, r3, #4 | |||
LoopCopyDataInit: | |||
adds r4, r0, r3 | |||
cmp r4, r1 | |||
bcc CopyDataInit | |||
/* Zero fill the bss segment. */ | |||
ldr r2, =_sbss | |||
ldr r4, =_ebss | |||
movs r3, #0 | |||
b LoopFillZerobss | |||
FillZerobss: | |||
str r3, [r2] | |||
adds r2, r2, #4 | |||
LoopFillZerobss: | |||
cmp r2, r4 | |||
bcc FillZerobss | |||
/* Call the clock system intitialization function.*/ | |||
bl SystemInit | |||
/* Call static constructors */ | |||
bl __libc_init_array | |||
/* Call the application s entry point.*/ | |||
bl main | |||
LoopForever: | |||
b LoopForever | |||
.size Reset_Handler, .-Reset_Handler | |||
/** | |||
* @brief This is the code that gets called when the processor receives an | |||
* unexpected interrupt. This simply enters an infinite loop, preserving | |||
* the system state for examination by a debugger. | |||
* | |||
* @param None | |||
* @retval None | |||
*/ | |||
.section .text.Default_Handler,"ax",%progbits | |||
Default_Handler: | |||
Infinite_Loop: | |||
b Infinite_Loop | |||
.size Default_Handler, .-Default_Handler | |||
/****************************************************************************** | |||
* | |||
* The minimal vector table for a Cortex-M4. Note that the proper constructs | |||
* must be placed on this to ensure that it ends up at physical address | |||
* 0x0000.0000. | |||
* | |||
******************************************************************************/ | |||
.section .isr_vector,"a",%progbits | |||
.type g_pfnVectors, %object | |||
.size g_pfnVectors, .-g_pfnVectors | |||
g_pfnVectors: | |||
.word _estack | |||
.word Reset_Handler | |||
.word NMI_Handler | |||
.word HardFault_Handler | |||
.word MemManage_Handler | |||
.word BusFault_Handler | |||
.word UsageFault_Handler | |||
.word 0 | |||
.word 0 | |||
.word 0 | |||
.word 0 | |||
.word SVC_Handler | |||
.word DebugMon_Handler | |||
.word 0 | |||
.word PendSV_Handler | |||
.word SysTick_Handler | |||
.word WWDG_IRQHandler | |||
.word PVD_PVM_IRQHandler | |||
.word TAMP_STAMP_LSECSS_IRQHandler | |||
.word RTC_WKUP_IRQHandler | |||
.word FLASH_IRQHandler | |||
.word RCC_IRQHandler | |||
.word EXTI0_IRQHandler | |||
.word EXTI1_IRQHandler | |||
.word EXTI2_IRQHandler | |||
.word EXTI3_IRQHandler | |||
.word EXTI4_IRQHandler | |||
.word DMA1_Channel1_IRQHandler | |||
.word DMA1_Channel2_IRQHandler | |||
.word DMA1_Channel3_IRQHandler | |||
.word DMA1_Channel4_IRQHandler | |||
.word DMA1_Channel5_IRQHandler | |||
.word DMA1_Channel6_IRQHandler | |||
.word DMA1_Channel7_IRQHandler | |||
.word ADC1_IRQHandler | |||
.word USB_HP_IRQHandler | |||
.word USB_LP_IRQHandler | |||
.word C2SEV_PWR_C2H_IRQHandler | |||
.word COMP_IRQHandler | |||
.word EXTI9_5_IRQHandler | |||
.word TIM1_BRK_IRQHandler | |||
.word TIM1_UP_TIM16_IRQHandler | |||
.word TIM1_TRG_COM_TIM17_IRQHandler | |||
.word TIM1_CC_IRQHandler | |||
.word TIM2_IRQHandler | |||
.word PKA_IRQHandler | |||
.word I2C1_EV_IRQHandler | |||
.word I2C1_ER_IRQHandler | |||
.word I2C3_EV_IRQHandler | |||
.word I2C3_ER_IRQHandler | |||
.word SPI1_IRQHandler | |||
.word SPI2_IRQHandler | |||
.word USART1_IRQHandler | |||
.word LPUART1_IRQHandler | |||
.word SAI1_IRQHandler | |||
.word TSC_IRQHandler | |||
.word EXTI15_10_IRQHandler | |||
.word RTC_Alarm_IRQHandler | |||
.word CRS_IRQHandler | |||
.word PWR_SOTF_BLEACT_802ACT_RFPHASE_IRQHandler | |||
.word IPCC_C1_RX_IRQHandler | |||
.word IPCC_C1_TX_IRQHandler | |||
.word HSEM_IRQHandler | |||
.word LPTIM1_IRQHandler | |||
.word LPTIM2_IRQHandler | |||
.word LCD_IRQHandler | |||
.word QUADSPI_IRQHandler | |||
.word AES1_IRQHandler | |||
.word AES2_IRQHandler | |||
.word RNG_IRQHandler | |||
.word FPU_IRQHandler | |||
.word DMA2_Channel1_IRQHandler | |||
.word DMA2_Channel2_IRQHandler | |||
.word DMA2_Channel3_IRQHandler | |||
.word DMA2_Channel4_IRQHandler | |||
.word DMA2_Channel5_IRQHandler | |||
.word DMA2_Channel6_IRQHandler | |||
.word DMA2_Channel7_IRQHandler | |||
.word DMAMUX1_OVR_IRQHandler | |||
/******************************************************************************* | |||
* | |||
* Provide weak aliases for each Exception handler to the Default_Handler. | |||
* As they are weak aliases, any function with the same name will override | |||
* this definition. | |||
* | |||
*******************************************************************************/ | |||
.weak NMI_Handler | |||
.thumb_set NMI_Handler,Default_Handler | |||
.weak HardFault_Handler | |||
.thumb_set HardFault_Handler,Default_Handler | |||
.weak MemManage_Handler | |||
.thumb_set MemManage_Handler,Default_Handler | |||
.weak BusFault_Handler | |||
.thumb_set BusFault_Handler,Default_Handler | |||
.weak UsageFault_Handler | |||
.thumb_set UsageFault_Handler,Default_Handler | |||
.weak SVC_Handler | |||
.thumb_set SVC_Handler,Default_Handler | |||
.weak DebugMon_Handler | |||
.thumb_set DebugMon_Handler,Default_Handler | |||
.weak PendSV_Handler | |||
.thumb_set PendSV_Handler,Default_Handler | |||
.weak SysTick_Handler | |||
.thumb_set SysTick_Handler,Default_Handler | |||
.weak WWDG_IRQHandler | |||
.thumb_set WWDG_IRQHandler,Default_Handler | |||
.weak PVD_PVM_IRQHandler | |||
.thumb_set PVD_PVM_IRQHandler,Default_Handler | |||
.weak TAMP_STAMP_LSECSS_IRQHandler | |||
.thumb_set TAMP_STAMP_LSECSS_IRQHandler,Default_Handler | |||
.weak RTC_WKUP_IRQHandler | |||
.thumb_set RTC_WKUP_IRQHandler,Default_Handler | |||
.weak FLASH_IRQHandler | |||
.thumb_set FLASH_IRQHandler,Default_Handler | |||
.weak RCC_IRQHandler | |||
.thumb_set RCC_IRQHandler,Default_Handler | |||
.weak EXTI0_IRQHandler | |||
.thumb_set EXTI0_IRQHandler,Default_Handler | |||
.weak EXTI1_IRQHandler | |||
.thumb_set EXTI1_IRQHandler,Default_Handler | |||
.weak EXTI2_IRQHandler | |||
.thumb_set EXTI2_IRQHandler,Default_Handler | |||
.weak EXTI3_IRQHandler | |||
.thumb_set EXTI3_IRQHandler,Default_Handler | |||
.weak EXTI4_IRQHandler | |||
.thumb_set EXTI4_IRQHandler,Default_Handler | |||
.weak DMA1_Channel1_IRQHandler | |||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler | |||
.weak DMA1_Channel2_IRQHandler | |||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler | |||
.weak DMA1_Channel3_IRQHandler | |||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler | |||
.weak DMA1_Channel4_IRQHandler | |||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler | |||
.weak DMA1_Channel5_IRQHandler | |||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler | |||
.weak DMA1_Channel6_IRQHandler | |||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler | |||
.weak DMA1_Channel7_IRQHandler | |||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler | |||
.weak ADC1_IRQHandler | |||
.thumb_set ADC1_IRQHandler,Default_Handler | |||
.weak USB_HP_IRQHandler | |||
.thumb_set USB_HP_IRQHandler,Default_Handler | |||
.weak USB_LP_IRQHandler | |||
.thumb_set USB_LP_IRQHandler,Default_Handler | |||
.weak C2SEV_PWR_C2H_IRQHandler | |||
.thumb_set C2SEV_PWR_C2H_IRQHandler,Default_Handler | |||
.weak COMP_IRQHandler | |||
.thumb_set COMP_IRQHandler,Default_Handler | |||
.weak EXTI9_5_IRQHandler | |||
.thumb_set EXTI9_5_IRQHandler,Default_Handler | |||
.weak TIM1_BRK_IRQHandler | |||
.thumb_set TIM1_BRK_IRQHandler,Default_Handler | |||
.weak TIM1_UP_TIM16_IRQHandler | |||
.thumb_set TIM1_UP_TIM16_IRQHandler,Default_Handler | |||
.weak TIM1_TRG_COM_TIM17_IRQHandler | |||
.thumb_set TIM1_TRG_COM_TIM17_IRQHandler,Default_Handler | |||
.weak TIM1_CC_IRQHandler | |||
.thumb_set TIM1_CC_IRQHandler,Default_Handler | |||
.weak TIM2_IRQHandler | |||
.thumb_set TIM2_IRQHandler,Default_Handler | |||
.weak PKA_IRQHandler | |||
.thumb_set PKA_IRQHandler,Default_Handler | |||
.weak I2C1_EV_IRQHandler | |||
.thumb_set I2C1_EV_IRQHandler,Default_Handler | |||
.weak I2C1_ER_IRQHandler | |||
.thumb_set I2C1_ER_IRQHandler,Default_Handler | |||
.weak I2C3_EV_IRQHandler | |||
.thumb_set I2C3_EV_IRQHandler,Default_Handler | |||
.weak I2C3_ER_IRQHandler | |||
.thumb_set I2C3_ER_IRQHandler,Default_Handler | |||
.weak SPI1_IRQHandler | |||
.thumb_set SPI1_IRQHandler,Default_Handler | |||
.weak SPI2_IRQHandler | |||
.thumb_set SPI2_IRQHandler,Default_Handler | |||
.weak USART1_IRQHandler | |||
.thumb_set USART1_IRQHandler,Default_Handler | |||
.weak LPUART1_IRQHandler | |||
.thumb_set LPUART1_IRQHandler,Default_Handler | |||
.weak SAI1_IRQHandler | |||
.thumb_set SAI1_IRQHandler,Default_Handler | |||
.weak TSC_IRQHandler | |||
.thumb_set TSC_IRQHandler,Default_Handler | |||
.weak EXTI15_10_IRQHandler | |||
.thumb_set EXTI15_10_IRQHandler,Default_Handler | |||
.weak RTC_Alarm_IRQHandler | |||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler | |||
.weak CRS_IRQHandler | |||
.thumb_set CRS_IRQHandler,Default_Handler | |||
.weak PWR_SOTF_BLEACT_802ACT_RFPHASE_IRQHandler | |||
.thumb_set PWR_SOTF_BLEACT_802ACT_RFPHASE_IRQHandler,Default_Handler | |||
.weak IPCC_C1_RX_IRQHandler | |||
.thumb_set IPCC_C1_RX_IRQHandler,Default_Handler | |||
.weak IPCC_C1_TX_IRQHandler | |||
.thumb_set IPCC_C1_TX_IRQHandler,Default_Handler | |||
.weak HSEM_IRQHandler | |||
.thumb_set HSEM_IRQHandler,Default_Handler | |||
.weak LPTIM1_IRQHandler | |||
.thumb_set LPTIM1_IRQHandler,Default_Handler | |||
.weak LPTIM2_IRQHandler | |||
.thumb_set LPTIM2_IRQHandler,Default_Handler | |||
.weak LCD_IRQHandler | |||
.thumb_set LCD_IRQHandler,Default_Handler | |||
.weak QUADSPI_IRQHandler | |||
.thumb_set QUADSPI_IRQHandler,Default_Handler | |||
.weak AES1_IRQHandler | |||
.thumb_set AES1_IRQHandler,Default_Handler | |||
.weak AES2_IRQHandler | |||
.thumb_set AES2_IRQHandler,Default_Handler | |||
.weak RNG_IRQHandler | |||
.thumb_set RNG_IRQHandler,Default_Handler | |||
.weak FPU_IRQHandler | |||
.thumb_set FPU_IRQHandler,Default_Handler | |||
.weak DMA2_Channel1_IRQHandler | |||
.thumb_set DMA2_Channel1_IRQHandler,Default_Handler | |||
.weak DMA2_Channel2_IRQHandler | |||
.thumb_set DMA2_Channel2_IRQHandler,Default_Handler | |||
.weak DMA2_Channel3_IRQHandler | |||
.thumb_set DMA2_Channel3_IRQHandler,Default_Handler | |||
.weak DMA2_Channel4_IRQHandler | |||
.thumb_set DMA2_Channel4_IRQHandler,Default_Handler | |||
.weak DMA2_Channel5_IRQHandler | |||
.thumb_set DMA2_Channel5_IRQHandler,Default_Handler | |||
.weak DMA2_Channel6_IRQHandler | |||
.thumb_set DMA2_Channel6_IRQHandler,Default_Handler | |||
.weak DMA2_Channel7_IRQHandler | |||
.thumb_set DMA2_Channel7_IRQHandler,Default_Handler | |||
.weak DMAMUX1_OVR_IRQHandler | |||
.thumb_set DMAMUX1_OVR_IRQHandler,Default_Handler | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,517 @@ | |||
;****************************************************************************** | |||
;* File Name : startup_stm32wb55xx_cm4.s | |||
;* Author : MCD Application Team | |||
;* Description : M4 core vector table of the STM32WB55xx devices for the | |||
;* IAR (EWARM) toolchain. | |||
;* | |||
;* This module performs: | |||
;* - Set the initial SP | |||
;* - Set the initial PC == _iar_program_start, | |||
;* - Set the vector table entries with the exceptions ISR | |||
;* address. | |||
;* - Branches to main in the C library (which eventually | |||
;* calls main()). | |||
;* After Reset the Cortex-M4 processor is in Thread mode, | |||
;* priority is Privileged, and the Stack is set to Main. | |||
;****************************************************************************** | |||
;* @attention | |||
;* | |||
;* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
;* All rights reserved.</center></h2> | |||
;* | |||
;* This software component is licensed by ST under BSD 3-Clause license, | |||
;* the "License"; You may not use this file except in compliance with the | |||
;* License. You may obtain a copy of the License at: | |||
;* opensource.org/licenses/BSD-3-Clause | |||
;* | |||
;****************************************************************************** | |||
; | |||
; | |||
; The modules in this file are included in the libraries, and may be replaced | |||
; by any user-defined modules that define the PUBLIC symbol _program_start or | |||
; a user defined start symbol. | |||
; To override the cstartup defined in the library, simply add your modified | |||
; version to the workbench project. | |||
; | |||
; The vector table is normally located at address 0. | |||
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6. | |||
; The name "__vector_table" has special meaning for C-SPY: | |||
; it is where the SP start value is found, and the NVIC vector | |||
; table register (VTOR) is initialized to this address if != 0. | |||
; | |||
; Cortex-M version | |||
; | |||
MODULE ?cstartup | |||
;; Forward declaration of sections. | |||
SECTION CSTACK:DATA:NOROOT(3) | |||
SECTION .intvec:CODE:NOROOT(2) | |||
EXTERN __iar_program_start | |||
EXTERN SystemInit | |||
PUBLIC __vector_table | |||
DATA | |||
__vector_table | |||
DCD sfe(CSTACK) | |||
DCD Reset_Handler ; Reset Handler | |||
DCD NMI_Handler ; NMI Handler | |||
DCD HardFault_Handler ; Hard Fault Handler | |||
DCD MemManage_Handler ; MPU Fault Handler | |||
DCD BusFault_Handler ; Bus Fault Handler | |||
DCD UsageFault_Handler ; Usage Fault Handler | |||
DCD 0 ; Reserved | |||
DCD 0 ; Reserved | |||
DCD 0 ; Reserved | |||
DCD 0 ; Reserved | |||
DCD SVC_Handler ; SVCall Handler | |||
DCD DebugMon_Handler ; Debug Monitor Handler | |||
DCD 0 ; Reserved | |||
DCD PendSV_Handler ; PendSV Handler | |||
DCD SysTick_Handler ; SysTick Handler | |||
; External Interrupts | |||
DCD WWDG_IRQHandler ; Window WatchDog | |||
DCD PVD_PVM_IRQHandler ; PVD and PVM Interrupt | |||
DCD TAMP_STAMP_LSECSS_IRQHandler ; RTC Tamper, TimeStamp Interrupts and LSECSS Interrupts | |||
DCD RTC_WKUP_IRQHandler ; RTC Wakeup Interrupt | |||
DCD FLASH_IRQHandler ; FLASH global Interrupt | |||
DCD RCC_IRQHandler ; RCC Interrupt | |||
DCD EXTI0_IRQHandler ; EXTI Line 0 Interrupt | |||
DCD EXTI1_IRQHandler ; EXTI Line 1 Interrupt | |||
DCD EXTI2_IRQHandler ; EXTI Line 2 Interrupt | |||
DCD EXTI3_IRQHandler ; EXTI Line 3 Interrup | |||
DCD EXTI4_IRQHandler ; EXTI Line 4 Interrupt | |||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 Interrupt | |||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 Interrupt | |||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 Interrupt | |||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 Interrupt | |||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 Interrupt | |||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 Interrupt | |||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 Interrupt | |||
DCD ADC1_IRQHandler ; ADC1 Interrupt | |||
DCD USB_HP_IRQHandler ; USB High Priority Interrupt | |||
DCD USB_LP_IRQHandler ; USB Low Priority Interrupt | |||
DCD C2SEV_PWR_C2H_IRQHandler ; CPU M0+ SEV Interrupt | |||
DCD COMP_IRQHandler ; COMP1 and COMP2 Interrupts | |||
DCD EXTI9_5_IRQHandler ; EXTI Lines [9:5] Interrupt | |||
DCD TIM1_BRK_IRQHandler ; TIM1 Break Interrupt | |||
DCD TIM1_UP_TIM16_IRQHandler ; TIM1 Update and TIM16 global Interrupts | |||
DCD TIM1_TRG_COM_TIM17_IRQHandler ; TIM1 Trigger and Communication and TIM17 global Interrupts | |||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare Interrupt | |||
DCD TIM2_IRQHandler ; TIM2 Global Interrupt | |||
DCD PKA_IRQHandler ; PKA Interrupt | |||
DCD I2C1_EV_IRQHandler ; I2C1 Event Interrupt | |||
DCD I2C1_ER_IRQHandler ; I2C1 Error Interrupt | |||
DCD I2C3_EV_IRQHandler ; I2C3 Event Interrupt | |||
DCD I2C3_ER_IRQHandler ; I2C3 Error Interrupt | |||
DCD SPI1_IRQHandler ; SPI1 Interrupt | |||
DCD SPI2_IRQHandler ; SPI2 Interrupt | |||
DCD USART1_IRQHandler ; USART1 Interrupt | |||
DCD LPUART1_IRQHandler ; LPUART1 Interrupt | |||
DCD SAI1_IRQHandler ; SAI Interrupt | |||
DCD TSC_IRQHandler ; TSC Interrupt | |||
DCD EXTI15_10_IRQHandler ; EXTI Lines1[15:10 ]Interrupts | |||
DCD RTC_Alarm_IRQHandler ; RTC Alarms (A and B) Interrupt | |||
DCD CRS_IRQHandler ; CRS interrupt | |||
DCD PWR_SOTF_BLEACT_802ACT_RFPHASE_IRQHandler ; WKUP Interrupt from PWR | |||
DCD IPCC_C1_RX_IRQHandler ; IPCC CPU1 RX occupied interrupt | |||
DCD IPCC_C1_TX_IRQHandler ; IPCC CPU1 RX free interrupt | |||
DCD HSEM_IRQHandler ; HSEM0 Interrupt | |||
DCD LPTIM1_IRQHandler ; LPTIM1 Interrupt | |||
DCD LPTIM2_IRQHandler ; LPTIM2 Interrupt | |||
DCD LCD_IRQHandler ; LCD Interrupt | |||
DCD QUADSPI_IRQHandler ; QUADSPI Interrupt | |||
DCD AES1_IRQHandler ; AES1 Interrupt | |||
DCD AES2_IRQHandler ; AES2 Interrupt | |||
DCD RNG_IRQHandler ; RNG1 Interrupt | |||
DCD FPU_IRQHandler ; FPU Interrupt | |||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel 1 Interrupt | |||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel 2 Interrupt | |||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel 3 Interrupt | |||
DCD DMA2_Channel4_IRQHandler ; DMA2 Channel 4 Interrupt | |||
DCD DMA2_Channel5_IRQHandler ; DMA2 Channel 5 Interrupt | |||
DCD DMA2_Channel6_IRQHandler ; DMA2 Channel 6 Interrupt | |||
DCD DMA2_Channel7_IRQHandler ; DMA2 Channel 7 Interrupt | |||
DCD DMAMUX1_OVR_IRQHandler ; DMAMUX overrun Interrupt | |||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |||
;; | |||
;; Default interrupt handlers. | |||
;; | |||
THUMB | |||
PUBWEAK Reset_Handler | |||
SECTION .text:CODE:NOROOT:REORDER(2) | |||
Reset_Handler | |||
LDR R0, =SystemInit | |||
BLX R0 | |||
LDR R0, =__iar_program_start | |||
BX R0 | |||
PUBWEAK NMI_Handler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
NMI_Handler | |||
B NMI_Handler | |||
PUBWEAK HardFault_Handler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
HardFault_Handler | |||
B HardFault_Handler | |||
PUBWEAK MemManage_Handler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
MemManage_Handler | |||
B MemManage_Handler | |||
PUBWEAK BusFault_Handler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
BusFault_Handler | |||
B BusFault_Handler | |||
PUBWEAK UsageFault_Handler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
UsageFault_Handler | |||
B UsageFault_Handler | |||
PUBWEAK SVC_Handler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
SVC_Handler | |||
B SVC_Handler | |||
PUBWEAK DebugMon_Handler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DebugMon_Handler | |||
B DebugMon_Handler | |||
PUBWEAK PendSV_Handler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
PendSV_Handler | |||
B PendSV_Handler | |||
PUBWEAK SysTick_Handler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
SysTick_Handler | |||
B SysTick_Handler | |||
PUBWEAK WWDG_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
WWDG_IRQHandler | |||
B WWDG_IRQHandler | |||
PUBWEAK PVD_PVM_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
PVD_PVM_IRQHandler | |||
B PVD_PVM_IRQHandler | |||
PUBWEAK TAMP_STAMP_LSECSS_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
TAMP_STAMP_LSECSS_IRQHandler | |||
B TAMP_STAMP_LSECSS_IRQHandler | |||
PUBWEAK RTC_WKUP_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
RTC_WKUP_IRQHandler | |||
B RTC_WKUP_IRQHandler | |||
PUBWEAK FLASH_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
FLASH_IRQHandler | |||
B FLASH_IRQHandler | |||
PUBWEAK RCC_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
RCC_IRQHandler | |||
B RCC_IRQHandler | |||
PUBWEAK EXTI0_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
EXTI0_IRQHandler | |||
B EXTI0_IRQHandler | |||
PUBWEAK EXTI1_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
EXTI1_IRQHandler | |||
B EXTI1_IRQHandler | |||
PUBWEAK EXTI2_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
EXTI2_IRQHandler | |||
B EXTI2_IRQHandler | |||
PUBWEAK EXTI3_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
EXTI3_IRQHandler | |||
B EXTI3_IRQHandler | |||
PUBWEAK EXTI4_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
EXTI4_IRQHandler | |||
B EXTI4_IRQHandler | |||
PUBWEAK DMA1_Channel1_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA1_Channel1_IRQHandler | |||
B DMA1_Channel1_IRQHandler | |||
PUBWEAK DMA1_Channel2_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA1_Channel2_IRQHandler | |||
B DMA1_Channel2_IRQHandler | |||
PUBWEAK DMA1_Channel3_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA1_Channel3_IRQHandler | |||
B DMA1_Channel3_IRQHandler | |||
PUBWEAK DMA1_Channel4_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA1_Channel4_IRQHandler | |||
B DMA1_Channel4_IRQHandler | |||
PUBWEAK DMA1_Channel5_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA1_Channel5_IRQHandler | |||
B DMA1_Channel5_IRQHandler | |||
PUBWEAK DMA1_Channel6_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA1_Channel6_IRQHandler | |||
B DMA1_Channel6_IRQHandler | |||
PUBWEAK DMA1_Channel7_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA1_Channel7_IRQHandler | |||
B DMA1_Channel7_IRQHandler | |||
PUBWEAK ADC1_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
ADC1_IRQHandler | |||
B ADC1_IRQHandler | |||
PUBWEAK USB_HP_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
USB_HP_IRQHandler | |||
B USB_HP_IRQHandler | |||
PUBWEAK USB_LP_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
USB_LP_IRQHandler | |||
B USB_LP_IRQHandler | |||
PUBWEAK C2SEV_PWR_C2H_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
C2SEV_PWR_C2H_IRQHandler | |||
B C2SEV_PWR_C2H_IRQHandler | |||
PUBWEAK COMP_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
COMP_IRQHandler | |||
B COMP_IRQHandler | |||
PUBWEAK EXTI9_5_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
EXTI9_5_IRQHandler | |||
B EXTI9_5_IRQHandler | |||
PUBWEAK TIM1_BRK_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
TIM1_BRK_IRQHandler | |||
B TIM1_BRK_IRQHandler | |||
PUBWEAK TIM1_UP_TIM16_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
TIM1_UP_TIM16_IRQHandler | |||
B TIM1_UP_TIM16_IRQHandler | |||
PUBWEAK TIM1_TRG_COM_TIM17_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
TIM1_TRG_COM_TIM17_IRQHandler | |||
B TIM1_TRG_COM_TIM17_IRQHandler | |||
PUBWEAK TIM1_CC_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
TIM1_CC_IRQHandler | |||
B TIM1_CC_IRQHandler | |||
PUBWEAK TIM2_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
TIM2_IRQHandler | |||
B TIM2_IRQHandler | |||
PUBWEAK PKA_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
PKA_IRQHandler | |||
B PKA_IRQHandler | |||
PUBWEAK I2C1_EV_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
I2C1_EV_IRQHandler | |||
B I2C1_EV_IRQHandler | |||
PUBWEAK I2C1_ER_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
I2C1_ER_IRQHandler | |||
B I2C1_ER_IRQHandler | |||
PUBWEAK I2C3_EV_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
I2C3_EV_IRQHandler | |||
B I2C3_EV_IRQHandler | |||
PUBWEAK I2C3_ER_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
I2C3_ER_IRQHandler | |||
B I2C3_ER_IRQHandler | |||
PUBWEAK SPI1_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
SPI1_IRQHandler | |||
B SPI1_IRQHandler | |||
PUBWEAK SPI2_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
SPI2_IRQHandler | |||
B SPI2_IRQHandler | |||
PUBWEAK USART1_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
USART1_IRQHandler | |||
B USART1_IRQHandler | |||
PUBWEAK LPUART1_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
LPUART1_IRQHandler | |||
B LPUART1_IRQHandler | |||
PUBWEAK SAI1_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
SAI1_IRQHandler | |||
B SAI1_IRQHandler | |||
PUBWEAK TSC_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
TSC_IRQHandler | |||
B TSC_IRQHandler | |||
PUBWEAK EXTI15_10_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
EXTI15_10_IRQHandler | |||
B EXTI15_10_IRQHandler | |||
PUBWEAK RTC_Alarm_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
RTC_Alarm_IRQHandler | |||
B RTC_Alarm_IRQHandler | |||
PUBWEAK CRS_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
CRS_IRQHandler | |||
B CRS_IRQHandler | |||
PUBWEAK PWR_SOTF_BLEACT_802ACT_RFPHASE_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
PWR_SOTF_BLEACT_802ACT_RFPHASE_IRQHandler | |||
B PWR_SOTF_BLEACT_802ACT_RFPHASE_IRQHandler | |||
PUBWEAK IPCC_C1_RX_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
IPCC_C1_RX_IRQHandler | |||
B IPCC_C1_RX_IRQHandler | |||
PUBWEAK IPCC_C1_TX_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
IPCC_C1_TX_IRQHandler | |||
B IPCC_C1_TX_IRQHandler | |||
PUBWEAK HSEM_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
HSEM_IRQHandler | |||
B HSEM_IRQHandler | |||
PUBWEAK LPTIM1_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
LPTIM1_IRQHandler | |||
B LPTIM1_IRQHandler | |||
PUBWEAK LPTIM2_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
LPTIM2_IRQHandler | |||
B LPTIM2_IRQHandler | |||
PUBWEAK LCD_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
LCD_IRQHandler | |||
B LCD_IRQHandler | |||
PUBWEAK QUADSPI_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
QUADSPI_IRQHandler | |||
B QUADSPI_IRQHandler | |||
PUBWEAK AES1_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
AES1_IRQHandler | |||
B AES1_IRQHandler | |||
PUBWEAK AES2_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
AES2_IRQHandler | |||
B AES2_IRQHandler | |||
PUBWEAK RNG_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
RNG_IRQHandler | |||
B RNG_IRQHandler | |||
PUBWEAK FPU_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
FPU_IRQHandler | |||
B FPU_IRQHandler | |||
PUBWEAK DMA2_Channel1_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA2_Channel1_IRQHandler | |||
B DMA2_Channel1_IRQHandler | |||
PUBWEAK DMA2_Channel2_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA2_Channel2_IRQHandler | |||
B DMA2_Channel2_IRQHandler | |||
PUBWEAK DMA2_Channel3_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA2_Channel3_IRQHandler | |||
B DMA2_Channel3_IRQHandler | |||
PUBWEAK DMA2_Channel4_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA2_Channel4_IRQHandler | |||
B DMA2_Channel4_IRQHandler | |||
PUBWEAK DMA2_Channel5_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA2_Channel5_IRQHandler | |||
B DMA2_Channel5_IRQHandler | |||
PUBWEAK DMA2_Channel6_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA2_Channel6_IRQHandler | |||
B DMA2_Channel6_IRQHandler | |||
PUBWEAK DMA2_Channel7_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMA2_Channel7_IRQHandler | |||
B DMA2_Channel7_IRQHandler | |||
PUBWEAK DMAMUX1_OVR_IRQHandler | |||
SECTION .text:CODE:NOROOT:REORDER(1) | |||
DMAMUX1_OVR_IRQHandler | |||
B DMAMUX1_OVR_IRQHandler | |||
END | |||
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE***** |
@@ -0,0 +1,353 @@ | |||
/** | |||
****************************************************************************** | |||
* @file system_stm32wbxx.c | |||
* @author MCD Application Team | |||
* @brief CMSIS Cortex Device Peripheral Access Layer System Source File | |||
* | |||
* This file provides two functions and one global variable to be called from | |||
* user application: | |||
* - SystemInit(): This function is called at startup just after reset and | |||
* before branch to main program. This call is made inside | |||
* the "startup_stm32wbxx.s" file. | |||
* | |||
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used | |||
* by the user application to setup the SysTick | |||
* timer or configure other parameters. | |||
* | |||
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must | |||
* be called whenever the core clock is changed | |||
* during program execution. | |||
* | |||
* After each device reset the MSI (4 MHz) is used as system clock source. | |||
* Then SystemInit() function is called, in "startup_stm32wbxx.s" file, to | |||
* configure the system clock before to branch to main program. | |||
* | |||
* This file configures the system clock as follows: | |||
*============================================================================= | |||
*----------------------------------------------------------------------------- | |||
* System Clock source | MSI | |||
*----------------------------------------------------------------------------- | |||
* SYSCLK(Hz) | 4000000 | |||
*----------------------------------------------------------------------------- | |||
* HCLK(Hz) | 4000000 | |||
*----------------------------------------------------------------------------- | |||
* AHB Prescaler | 1 | |||
*----------------------------------------------------------------------------- | |||
* APB1 Prescaler | 1 | |||
*----------------------------------------------------------------------------- | |||
* APB2 Prescaler | 1 | |||
*----------------------------------------------------------------------------- | |||
* PLL_M | 1 | |||
*----------------------------------------------------------------------------- | |||
* PLL_N | 8 | |||
*----------------------------------------------------------------------------- | |||
* PLL_P | 7 | |||
*----------------------------------------------------------------------------- | |||
* PLL_Q | 2 | |||
*----------------------------------------------------------------------------- | |||
* PLL_R | 2 | |||
*----------------------------------------------------------------------------- | |||
* PLLSAI1_P | NA | |||
*----------------------------------------------------------------------------- | |||
* PLLSAI1_Q | NA | |||
*----------------------------------------------------------------------------- | |||
* PLLSAI1_R | NA | |||
*----------------------------------------------------------------------------- | |||
* Require 48MHz for USB OTG FS, | Disabled | |||
* SDIO and RNG clock | | |||
*----------------------------------------------------------------------------- | |||
*============================================================================= | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/** @addtogroup CMSIS | |||
* @{ | |||
*/ | |||
/** @addtogroup stm32WBxx_system | |||
* @{ | |||
*/ | |||
/** @addtogroup stm32WBxx_System_Private_Includes | |||
* @{ | |||
*/ | |||
#include "stm32wbxx.h" | |||
#if !defined (HSE_VALUE) | |||
#define HSE_VALUE (32000000UL) /*!< Value of the External oscillator in Hz */ | |||
#endif /* HSE_VALUE */ | |||
#if !defined (MSI_VALUE) | |||
#define MSI_VALUE (4000000UL) /*!< Value of the Internal oscillator in Hz*/ | |||
#endif /* MSI_VALUE */ | |||
#if !defined (HSI_VALUE) | |||
#define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ | |||
#endif /* HSI_VALUE */ | |||
#if !defined (LSI_VALUE) | |||
#define LSI_VALUE (32000UL) /*!< Value of LSI in Hz*/ | |||
#endif /* LSI_VALUE */ | |||
#if !defined (LSE_VALUE) | |||
#define LSE_VALUE (32768UL) /*!< Value of LSE in Hz*/ | |||
#endif /* LSE_VALUE */ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup STM32WBxx_System_Private_TypesDefinitions | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup STM32WBxx_System_Private_Defines | |||
* @{ | |||
*/ | |||
/*!< Uncomment the following line if you need to relocate your vector Table in | |||
Internal SRAM. */ | |||
/* #define VECT_TAB_SRAM */ | |||
#define VECT_TAB_OFFSET 0x0U /*!< Vector Table base offset field. | |||
This value must be a multiple of 0x200. */ | |||
#define VECT_TAB_BASE_ADDRESS SRAM1_BASE /*!< Vector Table base offset field. | |||
This value must be a multiple of 0x200. */ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup STM32WBxx_System_Private_Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup STM32WBxx_System_Private_Variables | |||
* @{ | |||
*/ | |||
/* The SystemCoreClock variable is updated in three ways: | |||
1) by calling CMSIS function SystemCoreClockUpdate() | |||
2) by calling HAL API function HAL_RCC_GetHCLKFreq() | |||
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency | |||
Note: If you use this function to configure the system clock; then there | |||
is no need to call the 2 first functions listed above, since SystemCoreClock | |||
variable is updated automatically. | |||
*/ | |||
uint32_t SystemCoreClock = 4000000UL ; /*CPU1: M4 on MSI clock after startup (4MHz)*/ | |||
const uint32_t AHBPrescTable[16UL] = {1UL, 3UL, 5UL, 1UL, 1UL, 6UL, 10UL, 32UL, 2UL, 4UL, 8UL, 16UL, 64UL, 128UL, 256UL, 512UL}; | |||
const uint32_t APBPrescTable[8UL] = {0UL, 0UL, 0UL, 0UL, 1UL, 2UL, 3UL, 4UL}; | |||
const uint32_t MSIRangeTable[16UL] = {100000UL, 200000UL, 400000UL, 800000UL, 1000000UL, 2000000UL, \ | |||
4000000UL, 8000000UL, 16000000UL, 24000000UL, 32000000UL, 48000000UL, 0UL, 0UL, 0UL, 0UL}; /* 0UL values are incorrect cases */ | |||
const uint32_t SmpsPrescalerTable[4UL][6UL]={{1UL,3UL,2UL,2UL,1UL,2UL}, \ | |||
{2UL,6UL,4UL,3UL,2UL,4UL}, \ | |||
{4UL,12UL,8UL,6UL,4UL,8UL}, \ | |||
{4UL,12UL,8UL,6UL,4UL,8UL}}; | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup STM32WBxx_System_Private_FunctionPrototypes | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup STM32WBxx_System_Private_Functions | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Setup the microcontroller system. | |||
* @param None | |||
* @retval None | |||
*/ | |||
void SystemInit(void) | |||
{ | |||
/* Configure the Vector Table location add offset address ------------------*/ | |||
#if defined(VECT_TAB_SRAM) && defined(VECT_TAB_BASE_ADDRESS) | |||
/* program in SRAMx */ | |||
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAMx for CPU1 */ | |||
#else /* program in FLASH */ | |||
SCB->VTOR = VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ | |||
#endif | |||
/* FPU settings ------------------------------------------------------------*/ | |||
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) | |||
SCB->CPACR |= ((3UL << (10UL*2UL))|(3UL << (11UL*2UL))); /* set CP10 and CP11 Full Access */ | |||
#endif | |||
/* Reset the RCC clock configuration to the default reset state ------------*/ | |||
/* Set MSION bit */ | |||
RCC->CR |= RCC_CR_MSION; | |||
/* Reset CFGR register */ | |||
RCC->CFGR = 0x00070000U; | |||
/* Reset PLLSAI1ON, PLLON, HSECSSON, HSEON, HSION, and MSIPLLON bits */ | |||
RCC->CR &= (uint32_t)0xFAF6FEFBU; | |||
/*!< Reset LSI1 and LSI2 bits */ | |||
RCC->CSR &= (uint32_t)0xFFFFFFFAU; | |||
/*!< Reset HSI48ON bit */ | |||
RCC->CRRCR &= (uint32_t)0xFFFFFFFEU; | |||
/* Reset PLLCFGR register */ | |||
RCC->PLLCFGR = 0x22041000U; | |||
/* Reset PLLSAI1CFGR register */ | |||
RCC->PLLSAI1CFGR = 0x22041000U; | |||
/* Reset HSEBYP bit */ | |||
RCC->CR &= 0xFFFBFFFFU; | |||
/* Disable all interrupts */ | |||
RCC->CIER = 0x00000000; | |||
} | |||
/** | |||
* @brief Update SystemCoreClock variable according to Clock Register Values. | |||
* The SystemCoreClock variable contains the core clock (HCLK), it can | |||
* be used by the user application to setup the SysTick timer or configure | |||
* other parameters. | |||
* | |||
* @note Each time the core clock (HCLK) changes, this function must be called | |||
* to update SystemCoreClock variable value. Otherwise, any configuration | |||
* based on this variable will be incorrect. | |||
* | |||
* @note - The system frequency computed by this function is not the real | |||
* frequency in the chip. It is calculated based on the predefined | |||
* constant and the selected clock source: | |||
* | |||
* - If SYSCLK source is MSI, SystemCoreClock will contain the MSI_VALUE(*) | |||
* | |||
* - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) | |||
* | |||
* - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) | |||
* | |||
* - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***) | |||
* or HSI_VALUE(*) or MSI_VALUE(*) multiplied/divided by the PLL factors. | |||
* | |||
* (*) MSI_VALUE is a constant defined in stm32wbxx_hal.h file (default value | |||
* 4 MHz) but the real value may vary depending on the variations | |||
* in voltage and temperature. | |||
* | |||
* (**) HSI_VALUE is a constant defined in stm32wbxx_hal_conf.h file (default value | |||
* 16 MHz) but the real value may vary depending on the variations | |||
* in voltage and temperature. | |||
* | |||
* (***) HSE_VALUE is a constant defined in stm32wbxx_hal_conf.h file (default value | |||
* 32 MHz), user has to ensure that HSE_VALUE is same as the real | |||
* frequency of the crystal used. Otherwise, this function may | |||
* have wrong result. | |||
* | |||
* - The result of this function could be not correct when using fractional | |||
* value for HSE crystal. | |||
* | |||
* @param None | |||
* @retval None | |||
*/ | |||
void SystemCoreClockUpdate(void) | |||
{ | |||
uint32_t tmp, msirange, pllvco, pllr, pllsource , pllm; | |||
/* Get MSI Range frequency--------------------------------------------------*/ | |||
/*MSI frequency range in Hz*/ | |||
msirange = MSIRangeTable[(RCC->CR & RCC_CR_MSIRANGE) >> RCC_CR_MSIRANGE_Pos]; | |||
/* Get SYSCLK source -------------------------------------------------------*/ | |||
switch (RCC->CFGR & RCC_CFGR_SWS) | |||
{ | |||
case 0x00: /* MSI used as system clock source */ | |||
SystemCoreClock = msirange; | |||
break; | |||
case 0x04: /* HSI used as system clock source */ | |||
/* HSI used as system clock source */ | |||
SystemCoreClock = HSI_VALUE; | |||
break; | |||
case 0x08: /* HSE used as system clock source */ | |||
SystemCoreClock = HSE_VALUE; | |||
break; | |||
case 0x0C: /* PLL used as system clock source */ | |||
/* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN | |||
SYSCLK = PLL_VCO / PLLR | |||
*/ | |||
pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); | |||
pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> RCC_PLLCFGR_PLLM_Pos) + 1UL ; | |||
if(pllsource == 0x02UL) /* HSI used as PLL clock source */ | |||
{ | |||
pllvco = (HSI_VALUE / pllm); | |||
} | |||
else if(pllsource == 0x03UL) /* HSE used as PLL clock source */ | |||
{ | |||
pllvco = (HSE_VALUE / pllm); | |||
} | |||
else /* MSI used as PLL clock source */ | |||
{ | |||
pllvco = (msirange / pllm); | |||
} | |||
pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> RCC_PLLCFGR_PLLN_Pos); | |||
pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> RCC_PLLCFGR_PLLR_Pos) + 1UL); | |||
SystemCoreClock = pllvco/pllr; | |||
break; | |||
default: | |||
SystemCoreClock = msirange; | |||
break; | |||
} | |||
/* Compute HCLK clock frequency --------------------------------------------*/ | |||
/* Get HCLK1 prescaler */ | |||
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> RCC_CFGR_HPRE_Pos)]; | |||
/* HCLK clock frequency */ | |||
SystemCoreClock = SystemCoreClock / tmp; | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,57 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32_assert.h | |||
* @author MCD Application Team | |||
* @brief STM32 assert template file. | |||
* This file should be copied to the application folder and renamed | |||
* to stm32_assert.h. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32_ASSERT_H | |||
#define STM32_ASSERT_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/* Includes ------------------------------------------------------------------*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
#ifdef USE_FULL_ASSERT | |||
/** | |||
* @brief The assert_param macro is used for function's parameters check. | |||
* @param expr If expr is false, it calls assert_failed function | |||
* which reports the name of the source file and the source | |||
* line number of the call that failed. | |||
* If expr is true, it returns no value. | |||
* @retval None | |||
*/ | |||
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) | |||
/* Exported functions ------------------------------------------------------- */ | |||
void assert_failed(uint8_t* file, uint32_t line); | |||
#else | |||
#define assert_param(expr) ((void)0U) | |||
#endif /* USE_FULL_ASSERT */ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32_ASSERT_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,668 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal.h | |||
* @author MCD Application Team | |||
* @brief This file contains all the functions prototypes for the HAL | |||
* module driver. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_H | |||
#define STM32WBxx_HAL_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_conf.h" | |||
#include "stm32wbxx_ll_system.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup HAL HAL | |||
* @{ | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup HAL_Exported_Constants HAL Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup HAL_TICK_FREQ Tick Frequency | |||
* @{ | |||
*/ | |||
#define HAL_TICK_FREQ_10HZ 100U | |||
#define HAL_TICK_FREQ_100HZ 10U | |||
#define HAL_TICK_FREQ_1KHZ 1U | |||
#define HAL_TICK_FREQ_DEFAULT HAL_TICK_FREQ_1KHZ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SYSCFG_Exported_Constants SYSCFG Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup SYSCFG_BootMode BOOT Mode | |||
* @{ | |||
*/ | |||
#define SYSCFG_BOOT_MAINFLASH LL_SYSCFG_REMAP_FLASH /*!< Main Flash memory mapped at 0x00000000 */ | |||
#define SYSCFG_BOOT_SYSTEMFLASH LL_SYSCFG_REMAP_SYSTEMFLASH /*!< System Flash memory mapped at 0x00000000 */ | |||
#define SYSCFG_BOOT_SRAM LL_SYSCFG_REMAP_SRAM /*!< SRAM1 mapped at 0x00000000 */ | |||
#define SYSCFG_BOOT_QUADSPI LL_SYSCFG_REMAP_QUADSPI /*!< QUADSPI memory mapped at 0x00000000 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SYSCFG_FPU_Interrupts FPU Interrupts | |||
* @{ | |||
*/ | |||
#define SYSCFG_IT_FPU_IOC SYSCFG_CFGR1_FPU_IE_0 /*!< Floating Point Unit Invalid operation Interrupt */ | |||
#define SYSCFG_IT_FPU_DZC SYSCFG_CFGR1_FPU_IE_1 /*!< Floating Point Unit Divide-by-zero Interrupt */ | |||
#define SYSCFG_IT_FPU_UFC SYSCFG_CFGR1_FPU_IE_2 /*!< Floating Point Unit Underflow Interrupt */ | |||
#define SYSCFG_IT_FPU_OFC SYSCFG_CFGR1_FPU_IE_3 /*!< Floating Point Unit Overflow Interrupt */ | |||
#define SYSCFG_IT_FPU_IDC SYSCFG_CFGR1_FPU_IE_4 /*!< Floating Point Unit Input denormal Interrupt */ | |||
#define SYSCFG_IT_FPU_IXC SYSCFG_CFGR1_FPU_IE_5 /*!< Floating Point Unit Inexact Interrupt */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SYSCFG_SRAM2WRP SRAM2 Page Write protection (0 to 31) | |||
* @{ | |||
*/ | |||
#define SYSCFG_SRAM2WRP_PAGE0 LL_SYSCFG_SRAM2WRP_PAGE0 /*!< SRAM2A Write protection page 0 */ | |||
#define SYSCFG_SRAM2WRP_PAGE1 LL_SYSCFG_SRAM2WRP_PAGE1 /*!< SRAM2A Write protection page 1 */ | |||
#define SYSCFG_SRAM2WRP_PAGE2 LL_SYSCFG_SRAM2WRP_PAGE2 /*!< SRAM2A Write protection page 2 */ | |||
#define SYSCFG_SRAM2WRP_PAGE3 LL_SYSCFG_SRAM2WRP_PAGE3 /*!< SRAM2A Write protection page 3 */ | |||
#define SYSCFG_SRAM2WRP_PAGE4 LL_SYSCFG_SRAM2WRP_PAGE4 /*!< SRAM2A Write protection page 4 */ | |||
#define SYSCFG_SRAM2WRP_PAGE5 LL_SYSCFG_SRAM2WRP_PAGE5 /*!< SRAM2A Write protection page 5 */ | |||
#define SYSCFG_SRAM2WRP_PAGE6 LL_SYSCFG_SRAM2WRP_PAGE6 /*!< SRAM2A Write protection page 6 */ | |||
#define SYSCFG_SRAM2WRP_PAGE7 LL_SYSCFG_SRAM2WRP_PAGE7 /*!< SRAM2A Write protection page 7 */ | |||
#define SYSCFG_SRAM2WRP_PAGE8 LL_SYSCFG_SRAM2WRP_PAGE8 /*!< SRAM2A Write protection page 8 */ | |||
#define SYSCFG_SRAM2WRP_PAGE9 LL_SYSCFG_SRAM2WRP_PAGE9 /*!< SRAM2A Write protection page 9 */ | |||
#define SYSCFG_SRAM2WRP_PAGE10 LL_SYSCFG_SRAM2WRP_PAGE10 /*!< SRAM2A Write protection page 10 */ | |||
#define SYSCFG_SRAM2WRP_PAGE11 LL_SYSCFG_SRAM2WRP_PAGE11 /*!< SRAM2A Write protection page 11 */ | |||
#define SYSCFG_SRAM2WRP_PAGE12 LL_SYSCFG_SRAM2WRP_PAGE12 /*!< SRAM2A Write protection page 12 */ | |||
#define SYSCFG_SRAM2WRP_PAGE13 LL_SYSCFG_SRAM2WRP_PAGE13 /*!< SRAM2A Write protection page 13 */ | |||
#define SYSCFG_SRAM2WRP_PAGE14 LL_SYSCFG_SRAM2WRP_PAGE14 /*!< SRAM2A Write protection page 14 */ | |||
#define SYSCFG_SRAM2WRP_PAGE15 LL_SYSCFG_SRAM2WRP_PAGE15 /*!< SRAM2A Write protection page 15 */ | |||
#define SYSCFG_SRAM2WRP_PAGE16 LL_SYSCFG_SRAM2WRP_PAGE16 /*!< SRAM2A Write protection page 16 */ | |||
#define SYSCFG_SRAM2WRP_PAGE17 LL_SYSCFG_SRAM2WRP_PAGE17 /*!< SRAM2A Write protection page 17 */ | |||
#define SYSCFG_SRAM2WRP_PAGE18 LL_SYSCFG_SRAM2WRP_PAGE18 /*!< SRAM2A Write protection page 18 */ | |||
#define SYSCFG_SRAM2WRP_PAGE19 LL_SYSCFG_SRAM2WRP_PAGE19 /*!< SRAM2A Write protection page 19 */ | |||
#define SYSCFG_SRAM2WRP_PAGE20 LL_SYSCFG_SRAM2WRP_PAGE20 /*!< SRAM2A Write protection page 20 */ | |||
#define SYSCFG_SRAM2WRP_PAGE21 LL_SYSCFG_SRAM2WRP_PAGE21 /*!< SRAM2A Write protection page 21 */ | |||
#define SYSCFG_SRAM2WRP_PAGE22 LL_SYSCFG_SRAM2WRP_PAGE22 /*!< SRAM2A Write protection page 22 */ | |||
#define SYSCFG_SRAM2WRP_PAGE23 LL_SYSCFG_SRAM2WRP_PAGE23 /*!< SRAM2A Write protection page 23 */ | |||
#define SYSCFG_SRAM2WRP_PAGE24 LL_SYSCFG_SRAM2WRP_PAGE24 /*!< SRAM2A Write protection page 24 */ | |||
#define SYSCFG_SRAM2WRP_PAGE25 LL_SYSCFG_SRAM2WRP_PAGE25 /*!< SRAM2A Write protection page 25 */ | |||
#define SYSCFG_SRAM2WRP_PAGE26 LL_SYSCFG_SRAM2WRP_PAGE26 /*!< SRAM2A Write protection page 26 */ | |||
#define SYSCFG_SRAM2WRP_PAGE27 LL_SYSCFG_SRAM2WRP_PAGE27 /*!< SRAM2A Write protection page 27 */ | |||
#define SYSCFG_SRAM2WRP_PAGE28 LL_SYSCFG_SRAM2WRP_PAGE28 /*!< SRAM2A Write protection page 28 */ | |||
#define SYSCFG_SRAM2WRP_PAGE29 LL_SYSCFG_SRAM2WRP_PAGE29 /*!< SRAM2A Write protection page 29 */ | |||
#define SYSCFG_SRAM2WRP_PAGE30 LL_SYSCFG_SRAM2WRP_PAGE30 /*!< SRAM2A Write protection page 30 */ | |||
#define SYSCFG_SRAM2WRP_PAGE31 LL_SYSCFG_SRAM2WRP_PAGE31 /*!< SRAM2A Write protection page 31 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SYSCFG_SRAM2WRP_32_63 SRAM2 Page Write protection (32 to 63) | |||
* @{ | |||
*/ | |||
#define SYSCFG_SRAM2WRP_PAGE32 LL_SYSCFG_SRAM2WRP_PAGE32 /*!< SRAM2B Write protection page 32 */ | |||
#define SYSCFG_SRAM2WRP_PAGE33 LL_SYSCFG_SRAM2WRP_PAGE33 /*!< SRAM2B Write protection page 33 */ | |||
#define SYSCFG_SRAM2WRP_PAGE34 LL_SYSCFG_SRAM2WRP_PAGE34 /*!< SRAM2B Write protection page 34 */ | |||
#define SYSCFG_SRAM2WRP_PAGE35 LL_SYSCFG_SRAM2WRP_PAGE35 /*!< SRAM2B Write protection page 35 */ | |||
#define SYSCFG_SRAM2WRP_PAGE36 LL_SYSCFG_SRAM2WRP_PAGE36 /*!< SRAM2B Write protection page 36 */ | |||
#define SYSCFG_SRAM2WRP_PAGE37 LL_SYSCFG_SRAM2WRP_PAGE37 /*!< SRAM2B Write protection page 37 */ | |||
#define SYSCFG_SRAM2WRP_PAGE38 LL_SYSCFG_SRAM2WRP_PAGE38 /*!< SRAM2B Write protection page 38 */ | |||
#define SYSCFG_SRAM2WRP_PAGE39 LL_SYSCFG_SRAM2WRP_PAGE39 /*!< SRAM2B Write protection page 39 */ | |||
#define SYSCFG_SRAM2WRP_PAGE40 LL_SYSCFG_SRAM2WRP_PAGE40 /*!< SRAM2B Write protection page 40 */ | |||
#define SYSCFG_SRAM2WRP_PAGE41 LL_SYSCFG_SRAM2WRP_PAGE41 /*!< SRAM2B Write protection page 41 */ | |||
#define SYSCFG_SRAM2WRP_PAGE42 LL_SYSCFG_SRAM2WRP_PAGE42 /*!< SRAM2B Write protection page 42 */ | |||
#define SYSCFG_SRAM2WRP_PAGE43 LL_SYSCFG_SRAM2WRP_PAGE43 /*!< SRAM2B Write protection page 43 */ | |||
#define SYSCFG_SRAM2WRP_PAGE44 LL_SYSCFG_SRAM2WRP_PAGE44 /*!< SRAM2B Write protection page 44 */ | |||
#define SYSCFG_SRAM2WRP_PAGE45 LL_SYSCFG_SRAM2WRP_PAGE45 /*!< SRAM2B Write protection page 45 */ | |||
#define SYSCFG_SRAM2WRP_PAGE46 LL_SYSCFG_SRAM2WRP_PAGE46 /*!< SRAM2B Write protection page 46 */ | |||
#define SYSCFG_SRAM2WRP_PAGE47 LL_SYSCFG_SRAM2WRP_PAGE47 /*!< SRAM2B Write protection page 47 */ | |||
#define SYSCFG_SRAM2WRP_PAGE48 LL_SYSCFG_SRAM2WRP_PAGE48 /*!< SRAM2B Write protection page 48 */ | |||
#define SYSCFG_SRAM2WRP_PAGE49 LL_SYSCFG_SRAM2WRP_PAGE49 /*!< SRAM2B Write protection page 49 */ | |||
#define SYSCFG_SRAM2WRP_PAGE50 LL_SYSCFG_SRAM2WRP_PAGE50 /*!< SRAM2B Write protection page 50 */ | |||
#define SYSCFG_SRAM2WRP_PAGE51 LL_SYSCFG_SRAM2WRP_PAGE51 /*!< SRAM2B Write protection page 51 */ | |||
#define SYSCFG_SRAM2WRP_PAGE52 LL_SYSCFG_SRAM2WRP_PAGE52 /*!< SRAM2B Write protection page 52 */ | |||
#define SYSCFG_SRAM2WRP_PAGE53 LL_SYSCFG_SRAM2WRP_PAGE53 /*!< SRAM2B Write protection page 53 */ | |||
#define SYSCFG_SRAM2WRP_PAGE54 LL_SYSCFG_SRAM2WRP_PAGE54 /*!< SRAM2B Write protection page 54 */ | |||
#define SYSCFG_SRAM2WRP_PAGE55 LL_SYSCFG_SRAM2WRP_PAGE55 /*!< SRAM2B Write protection page 55 */ | |||
#define SYSCFG_SRAM2WRP_PAGE56 LL_SYSCFG_SRAM2WRP_PAGE56 /*!< SRAM2B Write protection page 56 */ | |||
#define SYSCFG_SRAM2WRP_PAGE57 LL_SYSCFG_SRAM2WRP_PAGE57 /*!< SRAM2B Write protection page 57 */ | |||
#define SYSCFG_SRAM2WRP_PAGE58 LL_SYSCFG_SRAM2WRP_PAGE58 /*!< SRAM2B Write protection page 58 */ | |||
#define SYSCFG_SRAM2WRP_PAGE59 LL_SYSCFG_SRAM2WRP_PAGE59 /*!< SRAM2B Write protection page 59 */ | |||
#define SYSCFG_SRAM2WRP_PAGE60 LL_SYSCFG_SRAM2WRP_PAGE60 /*!< SRAM2B Write protection page 60 */ | |||
#define SYSCFG_SRAM2WRP_PAGE61 LL_SYSCFG_SRAM2WRP_PAGE61 /*!< SRAM2B Write protection page 61 */ | |||
#define SYSCFG_SRAM2WRP_PAGE62 LL_SYSCFG_SRAM2WRP_PAGE62 /*!< SRAM2B Write protection page 62 */ | |||
#define SYSCFG_SRAM2WRP_PAGE63 LL_SYSCFG_SRAM2WRP_PAGE63 /*!< SRAM2B Write protection page 63 */ | |||
/** | |||
* @} | |||
*/ | |||
#if defined(VREFBUF) | |||
/** @defgroup SYSCFG_VREFBUF_VoltageScale VREFBUF Voltage Scale | |||
* @{ | |||
*/ | |||
#define SYSCFG_VREFBUF_VOLTAGE_SCALE0 LL_VREFBUF_VOLTAGE_SCALE0 /*!< Voltage reference scale 0 (VREF_OUT1) */ | |||
#define SYSCFG_VREFBUF_VOLTAGE_SCALE1 LL_VREFBUF_VOLTAGE_SCALE1 /*!< Voltage reference scale 1 (VREF_OUT2) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SYSCFG_VREFBUF_HighImpedance VREFBUF High Impedance | |||
* @{ | |||
*/ | |||
#define SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE 0x00000000U /*!< VREF_plus pin is internally connected to Voltage reference buffer output */ | |||
#define SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE VREFBUF_CSR_HIZ /*!< VREF_plus pin is high impedance */ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* VREFBUF */ | |||
/** @defgroup SYSCFG_SRAM_flags_definition SRAM Flags | |||
* @{ | |||
*/ | |||
#define SYSCFG_FLAG_SRAM2_PE SYSCFG_CFGR2_SPF /*!< SRAM2 parity error */ | |||
#define SYSCFG_FLAG_SRAM2_BUSY SYSCFG_SCSR_SRAM2BSY /*!< SRAM2 busy by erase operation */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SYSCFG_FastModePlus_GPIO Fast-mode Plus on GPIO | |||
* @{ | |||
*/ | |||
/** @brief Fast-mode Plus driving capability on a specific GPIO | |||
*/ | |||
#define SYSCFG_FASTMODEPLUS_PB6 SYSCFG_CFGR1_I2C_PB6_FMP /*!< Enable Fast-mode Plus on PB6 */ | |||
#define SYSCFG_FASTMODEPLUS_PB7 SYSCFG_CFGR1_I2C_PB7_FMP /*!< Enable Fast-mode Plus on PB7 */ | |||
#define SYSCFG_FASTMODEPLUS_PB8 SYSCFG_CFGR1_I2C_PB8_FMP /*!< Enable Fast-mode Plus on PB8 */ | |||
#define SYSCFG_FASTMODEPLUS_PB9 SYSCFG_CFGR1_I2C_PB9_FMP /*!< Enable Fast-mode Plus on PB9 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup Secure_IP_Write_Access Secure IP Write Access | |||
* @{ | |||
*/ | |||
#define HAL_SYSCFG_SECURE_ACCESS_AES1 LL_SYSCFG_SECURE_ACCESS_AES1 /*!< Enabling the security access of Advanced Encryption Standard 1 KEY[7:0] */ | |||
#define HAL_SYSCFG_SECURE_ACCESS_AES2 LL_SYSCFG_SECURE_ACCESS_AES2 /*!< Enabling the security access of Advanced Encryption Standard 2 */ | |||
#define HAL_SYSCFG_SECURE_ACCESS_PKA LL_SYSCFG_SECURE_ACCESS_PKA /*!< Enabling the security access of Public Key Accelerator */ | |||
#define HAL_SYSCFG_SECURE_ACCESS_RNG LL_SYSCFG_SECURE_ACCESS_RNG /*!< Enabling the security access of Random Number Generator */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup HAL_Exported_Macros HAL Exported Macros | |||
* @{ | |||
*/ | |||
/** @defgroup DBGMCU_Exported_Macros DBGMCU Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Freeze and Unfreeze Peripherals in Debug mode | |||
*/ | |||
/** @defgroup DBGMCU_APBx_GRPx_STOP_IP DBGMCU CPU1 APBx GRPx STOP IP | |||
* @{ | |||
*/ | |||
#if defined(LL_DBGMCU_APB1_GRP1_TIM2_STOP) | |||
#define __HAL_DBGMCU_FREEZE_TIM2() LL_DBGMCU_APB1_GRP1_FreezePeriph(LL_DBGMCU_APB1_GRP1_TIM2_STOP) | |||
#define __HAL_DBGMCU_UNFREEZE_TIM2() LL_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_DBGMCU_APB1_GRP1_TIM2_STOP) | |||
#endif | |||
#if defined(LL_DBGMCU_APB1_GRP1_RTC_STOP) | |||
#define __HAL_DBGMCU_FREEZE_RTC() LL_DBGMCU_APB1_GRP1_FreezePeriph(LL_DBGMCU_APB1_GRP1_RTC_STOP) | |||
#define __HAL_DBGMCU_UNFREEZE_RTC() LL_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_DBGMCU_APB1_GRP1_RTC_STOP) | |||
#endif | |||
#if defined(LL_DBGMCU_APB1_GRP1_WWDG_STOP) | |||
#define __HAL_DBGMCU_FREEZE_WWDG() LL_DBGMCU_APB1_GRP1_FreezePeriph(LL_DBGMCU_APB1_GRP1_WWDG_STOP) | |||
#define __HAL_DBGMCU_UNFREEZE_WWDG() LL_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_DBGMCU_APB1_GRP1_WWDG_STOP) | |||
#endif | |||
#if defined(LL_DBGMCU_APB1_GRP1_IWDG_STOP) | |||
#define __HAL_DBGMCU_FREEZE_IWDG() LL_DBGMCU_APB1_GRP1_FreezePeriph(LL_DBGMCU_APB1_GRP1_IWDG_STOP) | |||
#define __HAL_DBGMCU_UNFREEZE_IWDG() LL_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_DBGMCU_APB1_GRP1_IWDG_STOP) | |||
#endif | |||
#if defined(LL_DBGMCU_APB1_GRP1_I2C1_STOP) | |||
#define __HAL_DBGMCU_FREEZE_I2C1_TIMEOUT() LL_DBGMCU_APB1_GRP1_FreezePeriph(LL_DBGMCU_APB1_GRP1_I2C1_STOP) | |||
#define __HAL_DBGMCU_UNFREEZE_I2C1_TIMEOUT() LL_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_DBGMCU_APB1_GRP1_I2C1_STOP) | |||
#endif | |||
#if defined(LL_DBGMCU_APB1_GRP1_I2C3_STOP) | |||
#define __HAL_DBGMCU_FREEZE_I2C3_TIMEOUT() LL_DBGMCU_APB1_GRP1_FreezePeriph(LL_DBGMCU_APB1_GRP1_I2C3_STOP) | |||
#define __HAL_DBGMCU_UNFREEZE_I2C3_TIMEOUT() LL_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_DBGMCU_APB1_GRP1_I2C3_STOP) | |||
#endif | |||
#if defined(LL_DBGMCU_APB1_GRP1_LPTIM1_STOP) | |||
#define __HAL_DBGMCU_FREEZE_LPTIM1() LL_DBGMCU_APB1_GRP1_FreezePeriph(LL_DBGMCU_APB1_GRP1_LPTIM1_STOP) | |||
#define __HAL_DBGMCU_UNFREEZE_LPTIM1() LL_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_DBGMCU_APB1_GRP1_LPTIM1_STOP) | |||
#endif | |||
#if defined(LL_DBGMCU_APB1_GRP2_LPTIM2_STOP) | |||
#define __HAL_DBGMCU_FREEZE_LPTIM2() LL_DBGMCU_APB1_GRP2_FreezePeriph(LL_DBGMCU_APB1_GRP2_LPTIM2_STOP) | |||
#define __HAL_DBGMCU_UNFREEZE_LPTIM2() LL_DBGMCU_APB1_GRP2_UnFreezePeriph(LL_DBGMCU_APB1_GRP2_LPTIM2_STOP) | |||
#endif | |||
#if defined(LL_DBGMCU_APB2_GRP1_TIM1_STOP) | |||
#define __HAL_DBGMCU_FREEZE_TIM1() LL_DBGMCU_APB2_GRP1_FreezePeriph(LL_DBGMCU_APB2_GRP1_TIM1_STOP) | |||
#define __HAL_DBGMCU_UNFREEZE_TIM1() LL_DBGMCU_APB2_GRP1_UnFreezePeriph(LL_DBGMCU_APB2_GRP1_TIM1_STOP) | |||
#endif | |||
#if defined(LL_DBGMCU_APB2_GRP1_TIM16_STOP) | |||
#define __HAL_DBGMCU_FREEZE_TIM16() LL_DBGMCU_APB2_GRP1_FreezePeriph(LL_DBGMCU_APB2_GRP1_TIM16_STOP) | |||
#define __HAL_DBGMCU_UNFREEZE_TIM16() LL_DBGMCU_APB2_GRP1_UnFreezePeriph(LL_DBGMCU_APB2_GRP1_TIM16_STOP) | |||
#endif | |||
#if defined(LL_DBGMCU_APB2_GRP1_TIM17_STOP) | |||
#define __HAL_DBGMCU_FREEZE_TIM17() LL_DBGMCU_APB2_GRP1_FreezePeriph(LL_DBGMCU_APB2_GRP1_TIM17_STOP) | |||
#define __HAL_DBGMCU_UNFREEZE_TIM17() LL_DBGMCU_APB2_GRP1_UnFreezePeriph(LL_DBGMCU_APB2_GRP1_TIM17_STOP) | |||
#endif | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DBGMCU_C2_APBx_GRPx_STOP_IP DBGMCU CPU2 APBx GRPx STOP IP | |||
* @{ | |||
*/ | |||
#if defined(LL_C2_DBGMCU_APB1_GRP1_TIM2_STOP) | |||
#define __HAL_C2_DBGMCU_FREEZE_TIM2() LL_C2_DBGMCU_APB1_GRP1_FreezePeriph(LL_C2_DBGMCU_APB1_GRP1_TIM2_STOP) | |||
#define __HAL_C2_DBGMCU_UNFREEZE_TIM2() LL_C2_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_C2_DBGMCU_APB1_GRP1_TIM2_STOP) | |||
#endif | |||
#if defined(LL_C2_DBGMCU_APB1_GRP1_RTC_STOP) | |||
#define __HAL_C2_DBGMCU_FREEZE_RTC() LL_C2_DBGMCU_APB1_GRP1_FreezePeriph(LL_C2_DBGMCU_APB1_GRP1_RTC_STOP) | |||
#define __HAL_C2_DBGMCU_UNFREEZE_RTC() LL_C2_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_C2_DBGMCU_APB1_GRP1_RTC_STOP) | |||
#endif | |||
#if defined(LL_C2_DBGMCU_APB1_GRP1_IWDG_STOP) | |||
#define __HAL_C2_DBGMCU_FREEZE_IWDG() LL_C2_DBGMCU_APB1_GRP1_FreezePeriph(LL_C2_DBGMCU_APB1_GRP1_IWDG_STOP) | |||
#define __HAL_C2_DBGMCU_UNFREEZE_IWDG() LL_C2_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_C2_DBGMCU_APB1_GRP1_IWDG_STOP) | |||
#endif | |||
#if defined(LL_C2_DBGMCU_APB1_GRP1_I2C1_STOP) | |||
#define __HAL_C2_DBGMCU_FREEZE_I2C1_TIMEOUT() LL_C2_DBGMCU_APB1_GRP1_FreezePeriph(LL_C2_DBGMCU_APB1_GRP1_I2C1_STOP) | |||
#define __HAL_C2_DBGMCU_UNFREEZE_I2C1_TIMEOUT() LL_C2_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_C2_DBGMCU_APB1_GRP1_I2C1_STOP) | |||
#endif | |||
#if defined(LL_C2_DBGMCU_APB1_GRP1_I2C3_STOP) | |||
#define __HAL_C2_DBGMCU_FREEZE_I2C3_TIMEOUT() LL_C2_DBGMCU_APB1_GRP1_FreezePeriph(LL_C2_DBGMCU_APB1_GRP1_I2C3_STOP) | |||
#define __HAL_C2_DBGMCU_UNFREEZE_I2C3_TIMEOUT() LL_C2_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_C2_DBGMCU_APB1_GRP1_I2C3_STOP) | |||
#endif | |||
#if defined(LL_C2_DBGMCU_APB1_GRP1_LPTIM1_STOP) | |||
#define __HAL_C2_DBGMCU_FREEZE_LPTIM1() LL_C2_DBGMCU_APB1_GRP1_FreezePeriph(LL_C2_DBGMCU_APB1_GRP1_LPTIM1_STOP) | |||
#define __HAL_C2_DBGMCU_UNFREEZE_LPTIM1() LL_C2_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_C2_DBGMCU_APB1_GRP1_LPTIM1_STOP) | |||
#endif | |||
#if defined(LL_C2_DBGMCU_APB1_GRP2_LPTIM2_STOP) | |||
#define __HAL_C2_DBGMCU_FREEZE_LPTIM2() LL_C2_DBGMCU_APB1_GRP2_FreezePeriph(LL_C2_DBGMCU_APB1_GRP2_LPTIM2_STOP) | |||
#define __HAL_C2_DBGMCU_UNFREEZE_LPTIM2() LL_C2_DBGMCU_APB1_GRP2_UnFreezePeriph(LL_C2_DBGMCU_APB1_GRP2_LPTIM2_STOP) | |||
#endif | |||
#if defined(LL_C2_DBGMCU_APB2_GRP1_TIM1_STOP) | |||
#define __HAL_C2_DBGMCU_FREEZE_TIM1() LL_C2_DBGMCU_APB2_GRP1_FreezePeriph(LL_C2_DBGMCU_APB2_GRP1_TIM1_STOP) | |||
#define __HAL_C2_DBGMCU_UNFREEZE_TIM1() LL_C2_DBGMCU_APB2_GRP1_UnFreezePeriph(LL_C2_DBGMCU_APB2_GRP1_TIM1_STOP) | |||
#endif | |||
#if defined(LL_C2_DBGMCU_APB2_GRP1_TIM16_STOP) | |||
#define __HAL_C2_DBGMCU_FREEZE_TIM16() LL_C2_DBGMCU_APB2_GRP1_FreezePeriph(LL_C2_DBGMCU_APB2_GRP1_TIM16_STOP) | |||
#define __HAL_C2_DBGMCU_UNFREEZE_TIM16() LL_C2_DBGMCU_APB2_GRP1_UnFreezePeriph(LL_C2_DBGMCU_APB2_GRP1_TIM16_STOP) | |||
#endif | |||
#if defined(LL_C2_DBGMCU_APB2_GRP1_TIM17_STOP) | |||
#define __HAL_C2_DBGMCU_FREEZE_TIM17() LL_C2_DBGMCU_APB2_GRP1_FreezePeriph(LL_C2_DBGMCU_APB2_GRP1_TIM17_STOP) | |||
#define __HAL_C2_DBGMCU_UNFREEZE_TIM17() LL_C2_DBGMCU_APB2_GRP1_UnFreezePeriph(LL_C2_DBGMCU_APB2_GRP1_TIM17_STOP) | |||
#endif | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SYSCFG_Exported_Macros SYSCFG Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Main Flash memory mapped at 0x00000000 | |||
*/ | |||
#define __HAL_SYSCFG_REMAPMEMORY_FLASH() LL_SYSCFG_SetRemapMemory(LL_SYSCFG_REMAP_FLASH) | |||
/** @brief System Flash memory mapped at 0x00000000 | |||
*/ | |||
#define __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH() LL_SYSCFG_SetRemapMemory(LL_SYSCFG_REMAP_SYSTEMFLASH) | |||
/** @brief Embedded SRAM mapped at 0x00000000 | |||
*/ | |||
#define __HAL_SYSCFG_REMAPMEMORY_SRAM() LL_SYSCFG_SetRemapMemory(LL_SYSCFG_REMAP_SRAM) | |||
/** @brief QUADSPI mapped at 0x00000000. | |||
*/ | |||
#define __HAL_SYSCFG_REMAPMEMORY_QUADSPI() LL_SYSCFG_SetRemapMemory(LL_SYSCFG_REMAP_QUADSPI) | |||
/** | |||
* @brief Return the boot mode as configured by user. | |||
* @retval The boot mode as configured by user. The returned value can be one | |||
* of the following values: | |||
* @arg @ref SYSCFG_BOOT_MAINFLASH | |||
* @arg @ref SYSCFG_BOOT_SYSTEMFLASH | |||
* @arg @ref SYSCFG_BOOT_SRAM | |||
* @arg @ref SYSCFG_BOOT_QUADSPI | |||
*/ | |||
#define __HAL_SYSCFG_GET_BOOT_MODE() LL_SYSCFG_GetRemapMemory() | |||
/** @brief SRAM2 page 0 to 31 write protection enable macro | |||
* @param __SRAM2WRP__ This parameter can be a combination of values of @ref SYSCFG_SRAM2WRP | |||
* @note Write protection can only be disabled by a system reset | |||
*/ | |||
/* Legacy define */ | |||
#define __HAL_SYSCFG_SRAM2_WRP_1_31_ENABLE __HAL_SYSCFG_SRAM2_WRP_0_31_ENABLE | |||
#define __HAL_SYSCFG_SRAM2_WRP_0_31_ENABLE(__SRAM2WRP__) do {assert_param(IS_SYSCFG_SRAM2WRP_PAGE((__SRAM2WRP__)));\ | |||
LL_SYSCFG_EnableSRAM2PageWRP_0_31(__SRAM2WRP__);\ | |||
}while(0) | |||
/** @brief SRAM2 page 32 to 63 write protection enable macro | |||
* @param __SRAM2WRP__ This parameter can be a combination of values of @ref SYSCFG_SRAM2WRP_32_63 | |||
* @note Write protection can only be disabled by a system reset | |||
*/ | |||
#define __HAL_SYSCFG_SRAM2_WRP_32_63_ENABLE(__SRAM2WRP__) do {assert_param(IS_SYSCFG_SRAM2WRP_PAGE((__SRAM2WRP__)));\ | |||
LL_SYSCFG_EnableSRAM2PageWRP_32_63(__SRAM2WRP__);\ | |||
}while(0) | |||
/** @brief SRAM2 page write protection unlock prior to erase | |||
* @note Writing a wrong key reactivates the write protection | |||
*/ | |||
#define __HAL_SYSCFG_SRAM2_WRP_UNLOCK() LL_SYSCFG_UnlockSRAM2WRP() | |||
/** @brief SRAM2 erase | |||
* @note __SYSCFG_GET_FLAG(SYSCFG_FLAG_SRAM2_BUSY) may be used to check end of erase | |||
*/ | |||
#define __HAL_SYSCFG_SRAM2_ERASE() LL_SYSCFG_EnableSRAM2Erase() | |||
/** @brief Floating Point Unit interrupt enable/disable macros | |||
* @param __INTERRUPT__ This parameter can be a value of @ref SYSCFG_FPU_Interrupts | |||
*/ | |||
#define __HAL_SYSCFG_FPU_INTERRUPT_ENABLE(__INTERRUPT__) do {assert_param(IS_SYSCFG_FPU_INTERRUPT((__INTERRUPT__)));\ | |||
SET_BIT(SYSCFG->CFGR1, (__INTERRUPT__));\ | |||
}while(0) | |||
#define __HAL_SYSCFG_FPU_INTERRUPT_DISABLE(__INTERRUPT__) do {assert_param(IS_SYSCFG_FPU_INTERRUPT((__INTERRUPT__)));\ | |||
CLEAR_BIT(SYSCFG->CFGR1, (__INTERRUPT__));\ | |||
}while(0) | |||
/** @brief SYSCFG Break ECC lock. | |||
* Enable and lock the connection of Flash ECC error connection to TIM1/16/17 Break input. | |||
* @note The selected configuration is locked and can be unlocked only by system reset. | |||
*/ | |||
#define __HAL_SYSCFG_BREAK_ECC_LOCK() LL_SYSCFG_SetTIMBreakInputs(LL_SYSCFG_TIMBREAK_ECC) | |||
/** @brief SYSCFG Break Cortex-M4 Lockup lock. | |||
* Enable and lock the connection of Cortex-M4 LOCKUP (Hardfault) output to TIM1/16/17 Break input. | |||
* @note The selected configuration is locked and can be unlocked only by system reset. | |||
*/ | |||
#define __HAL_SYSCFG_BREAK_LOCKUP_LOCK() LL_SYSCFG_SetTIMBreakInputs(LL_SYSCFG_TIMBREAK_LOCKUP) | |||
/** @brief SYSCFG Break PVD lock. | |||
* Enable and lock the PVD connection to Timer1/16/17 Break input, as well as the PVDE and PLS[2:0] in the PWR_CR2 register. | |||
* @note The selected configuration is locked and can be unlocked only by system reset. | |||
*/ | |||
#define __HAL_SYSCFG_BREAK_PVD_LOCK() LL_SYSCFG_SetTIMBreakInputs(LL_SYSCFG_TIMBREAK_PVD) | |||
/** @brief SYSCFG Break SRAM2 parity lock. | |||
* Enable and lock the SRAM2 parity error signal connection to TIM1/16/17 Break input. | |||
* @note The selected configuration is locked and can be unlocked by system reset. | |||
*/ | |||
#define __HAL_SYSCFG_BREAK_SRAM2PARITY_LOCK() LL_SYSCFG_SetTIMBreakInputs(LL_SYSCFG_TIMBREAK_SRAM2_PARITY) | |||
/** @brief Check SYSCFG flag is set or not. | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref SYSCFG_FLAG_SRAM2_PE SRAM2 Parity Error Flag | |||
* @arg @ref SYSCFG_FLAG_SRAM2_BUSY SRAM2 Erase Ongoing | |||
* @retval The new state of __FLAG__ (TRUE or FALSE). | |||
*/ | |||
#define __HAL_SYSCFG_GET_FLAG(__FLAG__) ((((((__FLAG__) == SYSCFG_SCSR_SRAM2BSY)? SYSCFG->SCSR : SYSCFG->CFGR2) & (__FLAG__))!= 0U) ? 1U : 0U) | |||
/** @brief Set the SPF bit to clear the SRAM Parity Error Flag. | |||
*/ | |||
#define __HAL_SYSCFG_CLEAR_FLAG() LL_SYSCFG_ClearFlag_SP() | |||
/** @brief Fast mode Plus driving capability enable/disable macros | |||
* @param __FASTMODEPLUS__ This parameter can be a value of @ref SYSCFG_FastModePlus_GPIO | |||
*/ | |||
#define __HAL_SYSCFG_FASTMODEPLUS_ENABLE(__FASTMODEPLUS__) do {assert_param(IS_SYSCFG_FASTMODEPLUS((__FASTMODEPLUS__))); \ | |||
LL_SYSCFG_EnableFastModePlus(__FASTMODEPLUS__); \ | |||
}while(0) | |||
#define __HAL_SYSCFG_FASTMODEPLUS_DISABLE(__FASTMODEPLUS__) do {assert_param(IS_SYSCFG_FASTMODEPLUS((__FASTMODEPLUS__))); \ | |||
LL_SYSCFG_DisableFastModePlus(__FASTMODEPLUS__); \ | |||
}while(0) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup HAL_Private_Macros HAL Private Macros | |||
* @{ | |||
*/ | |||
/** @defgroup SYSCFG_Private_Macros SYSCFG Private Macros | |||
* @{ | |||
*/ | |||
#define IS_SYSCFG_FPU_INTERRUPT(__INTERRUPT__) ((((__INTERRUPT__) & SYSCFG_IT_FPU_IOC) == SYSCFG_IT_FPU_IOC) || \ | |||
(((__INTERRUPT__) & SYSCFG_IT_FPU_DZC) == SYSCFG_IT_FPU_DZC) || \ | |||
(((__INTERRUPT__) & SYSCFG_IT_FPU_UFC) == SYSCFG_IT_FPU_UFC) || \ | |||
(((__INTERRUPT__) & SYSCFG_IT_FPU_OFC) == SYSCFG_IT_FPU_OFC) || \ | |||
(((__INTERRUPT__) & SYSCFG_IT_FPU_IDC) == SYSCFG_IT_FPU_IDC) || \ | |||
(((__INTERRUPT__) & SYSCFG_IT_FPU_IXC) == SYSCFG_IT_FPU_IXC)) | |||
#define IS_SYSCFG_SRAM2WRP_PAGE(__PAGE__) (((__PAGE__) > 0U) && ((__PAGE__) <= 0xFFFFFFFFU)) | |||
#define IS_SYSCFG_VREFBUF_VOLTAGE_SCALE(__SCALE__) (((__SCALE__) == SYSCFG_VREFBUF_VOLTAGE_SCALE0) || \ | |||
((__SCALE__) == SYSCFG_VREFBUF_VOLTAGE_SCALE1)) | |||
#define IS_SYSCFG_VREFBUF_HIGH_IMPEDANCE(__VALUE__) (((__VALUE__) == SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE) || \ | |||
((__VALUE__) == SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE)) | |||
#define IS_SYSCFG_VREFBUF_TRIMMING(__VALUE__) (((__VALUE__) > 0U) && ((__VALUE__) <= VREFBUF_CCR_TRIM)) | |||
#define IS_SYSCFG_FASTMODEPLUS(__PIN__) ((((__PIN__) & SYSCFG_FASTMODEPLUS_PB6) == SYSCFG_FASTMODEPLUS_PB6) || \ | |||
(((__PIN__) & SYSCFG_FASTMODEPLUS_PB7) == SYSCFG_FASTMODEPLUS_PB7) || \ | |||
(((__PIN__) & SYSCFG_FASTMODEPLUS_PB8) == SYSCFG_FASTMODEPLUS_PB8) || \ | |||
(((__PIN__) & SYSCFG_FASTMODEPLUS_PB9) == SYSCFG_FASTMODEPLUS_PB9)) | |||
#define IS_SYSCFG_SECURITY_ACCESS(__VALUE__) ((((__VALUE__) & HAL_SYSCFG_SECURE_ACCESS_AES1) == HAL_SYSCFG_SECURE_ACCESS_AES1) || \ | |||
(((__VALUE__) & HAL_SYSCFG_SECURE_ACCESS_AES2) == HAL_SYSCFG_SECURE_ACCESS_AES2) || \ | |||
(((__VALUE__) & HAL_SYSCFG_SECURE_ACCESS_PKA) == HAL_SYSCFG_SECURE_ACCESS_PKA) || \ | |||
(((__VALUE__) & HAL_SYSCFG_SECURE_ACCESS_RNG) == HAL_SYSCFG_SECURE_ACCESS_RNG)) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup HAL_Private_Macros HAL Private Macros | |||
* @{ | |||
*/ | |||
#define IS_TICKFREQ(FREQ) (((FREQ) == HAL_TICK_FREQ_10HZ) || \ | |||
((FREQ) == HAL_TICK_FREQ_100HZ) || \ | |||
((FREQ) == HAL_TICK_FREQ_1KHZ)) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup HAL_Exported_Functions HAL Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup HAL_Exported_Functions_Group1 HAL Initialization and Configuration functions | |||
* @{ | |||
*/ | |||
/* Initialization and Configuration functions ******************************/ | |||
HAL_StatusTypeDef HAL_Init(void); | |||
HAL_StatusTypeDef HAL_DeInit(void); | |||
void HAL_MspInit(void); | |||
void HAL_MspDeInit(void); | |||
HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup HAL_Exported_Functions_Group2 HAL Control functions | |||
* @{ | |||
*/ | |||
/* Peripheral Control functions ************************************************/ | |||
void HAL_IncTick(void); | |||
void HAL_Delay(uint32_t Delay); | |||
uint32_t HAL_GetTick(void); | |||
uint32_t HAL_GetTickPrio(void); | |||
HAL_StatusTypeDef HAL_SetTickFreq(uint32_t Freq); | |||
uint32_t HAL_GetTickFreq(void); | |||
void HAL_SuspendTick(void); | |||
void HAL_ResumeTick(void); | |||
uint32_t HAL_GetHalVersion(void); | |||
uint32_t HAL_GetREVID(void); | |||
uint32_t HAL_GetDEVID(void); | |||
uint32_t HAL_GetUIDw0(void); | |||
uint32_t HAL_GetUIDw1(void); | |||
uint32_t HAL_GetUIDw2(void); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup HAL_Exported_Functions_Group3 HAL Debug functions | |||
* @{ | |||
*/ | |||
/* DBGMCU Peripheral Control functions *****************************************/ | |||
void HAL_DBGMCU_EnableDBGSleepMode(void); | |||
void HAL_DBGMCU_DisableDBGSleepMode(void); | |||
void HAL_DBGMCU_EnableDBGStopMode(void); | |||
void HAL_DBGMCU_DisableDBGStopMode(void); | |||
void HAL_DBGMCU_EnableDBGStandbyMode(void); | |||
void HAL_DBGMCU_DisableDBGStandbyMode(void); | |||
/** | |||
* @} | |||
*/ | |||
/* Exported variables ---------------------------------------------------------*/ | |||
/** @addtogroup HAL_Exported_Variables | |||
* @{ | |||
*/ | |||
extern __IO uint32_t uwTick; | |||
extern uint32_t uwTickPrio; | |||
extern uint32_t uwTickFreq; | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup HAL_Exported_Functions_Group4 HAL System Configuration functions | |||
* @{ | |||
*/ | |||
/* SYSCFG Control functions ****************************************************/ | |||
void HAL_SYSCFG_SRAM2Erase(void); | |||
void HAL_SYSCFG_DisableSRAMFetch(void); | |||
uint32_t HAL_SYSCFG_IsEnabledSRAMFetch(void); | |||
void HAL_SYSCFG_VREFBUF_VoltageScalingConfig(uint32_t VoltageScaling); | |||
void HAL_SYSCFG_VREFBUF_HighImpedanceConfig(uint32_t Mode); | |||
void HAL_SYSCFG_VREFBUF_TrimmingConfig(uint32_t TrimmingValue); | |||
HAL_StatusTypeDef HAL_SYSCFG_EnableVREFBUF(void); | |||
void HAL_SYSCFG_DisableVREFBUF(void); | |||
void HAL_SYSCFG_EnableIOBooster(void); | |||
void HAL_SYSCFG_DisableIOBooster(void); | |||
void HAL_SYSCFG_EnableIOVdd(void); | |||
void HAL_SYSCFG_DisableIOVdd(void); | |||
void HAL_SYSCFG_EnableSecurityAccess(uint32_t SecurityAccess); | |||
void HAL_SYSCFG_DisableSecurityAccess(uint32_t SecurityAccess); | |||
uint32_t HAL_SYSCFG_IsEnabledSecurityAccess(uint32_t SecurityAccess); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,764 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_adc_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of ADC HAL extended module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_ADC_EX_H | |||
#define STM32WBxx_HAL_ADC_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup ADCEx | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup ADCEx_Exported_Types ADC Extended Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief ADC Injected Conversion Oversampling structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Ratio; /*!< Configures the oversampling ratio. | |||
This parameter can be a value of @ref ADC_HAL_EC_OVS_RATIO */ | |||
uint32_t RightBitShift; /*!< Configures the division coefficient for the Oversampler. | |||
This parameter can be a value of @ref ADC_HAL_EC_OVS_SHIFT */ | |||
}ADC_InjOversamplingTypeDef; | |||
/** | |||
* @brief Structure definition of ADC group injected and ADC channel affected to ADC group injected | |||
* @note Parameters of this structure are shared within 2 scopes: | |||
* - Scope channel: InjectedChannel, InjectedRank, InjectedSamplingTime , InjectedSingleDiff, InjectedOffsetNumber, InjectedOffset | |||
* - Scope ADC group injected (affects all channels of injected group): InjectedNbrOfConversion, InjectedDiscontinuousConvMode, | |||
* AutoInjectedConv, QueueInjectedContext, ExternalTrigInjecConv, ExternalTrigInjecConvEdge, InjecOversamplingMode, InjecOversampling. | |||
* @note The setting of these parameters by function HAL_ADCEx_InjectedConfigChannel() is conditioned to ADC state. | |||
* ADC state can be either: | |||
* - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'InjectedSingleDiff') | |||
* - For parameters 'InjectedDiscontinuousConvMode', 'QueueInjectedContext', 'InjecOversampling': ADC enabled without conversion on going on injected group. | |||
* - For parameters 'InjectedSamplingTime', 'InjectedOffset', 'InjectedOffsetNumber', 'AutoInjectedConv': ADC enabled without conversion on going on regular and injected groups. | |||
* - For parameters 'InjectedChannel', 'InjectedRank', 'InjectedNbrOfConversion', 'ExternalTrigInjecConv', 'ExternalTrigInjecConvEdge': ADC enabled and while conversion on going | |||
* on ADC groups regular and injected. | |||
* If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed | |||
* without error reporting (as it can be the expected behavior in case of intended action to update another parameter (which fulfills the ADC state condition) on the fly). | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t InjectedChannel; /*!< Specifies the channel to configure into ADC group injected. | |||
This parameter can be a value of @ref ADC_HAL_EC_CHANNEL | |||
Note: Depending on devices and ADC instances, some channels may not be available on device package pins. Refer to device datasheet for channels availability. */ | |||
uint32_t InjectedRank; /*!< Specifies the rank in the ADC group injected sequencer. | |||
This parameter must be a value of @ref ADC_INJ_SEQ_RANKS. | |||
Note: to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by | |||
the new channel setting (or parameter number of conversions adjusted) */ | |||
uint32_t InjectedSamplingTime; /*!< Sampling time value to be set for the selected channel. | |||
Unit: ADC clock cycles. | |||
Conversion time is the addition of sampling time and processing time | |||
(12.5 ADC clock cycles at ADC resolution 12 bits, 10.5 cycles at 10 bits, 8.5 cycles at 8 bits, 6.5 cycles at 6 bits). | |||
This parameter can be a value of @ref ADC_HAL_EC_CHANNEL_SAMPLINGTIME. | |||
Caution: This parameter applies to a channel that can be used in a regular and/or injected group. | |||
It overwrites the last setting. | |||
Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor), | |||
sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting) | |||
Refer to device datasheet for timings values. */ | |||
uint32_t InjectedSingleDiff; /*!< Selection of single-ended or differential input. | |||
In differential mode: Differential measurement is between the selected channel 'i' (positive input) and channel 'i+1' (negative input). | |||
Only channel 'i' has to be configured, channel 'i+1' is configured automatically. | |||
This parameter must be a value of @ref ADC_HAL_EC_CHANNEL_SINGLE_DIFF_ENDING. | |||
Caution: This parameter applies to a channel that can be used in a regular and/or injected group. | |||
It overwrites the last setting. | |||
Note: Refer to Reference Manual to ensure the selected channel is available in differential mode. | |||
Note: When configuring a channel 'i' in differential mode, the channel 'i+1' is not usable separately. | |||
Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion). | |||
If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behavior in case | |||
of another parameter update on the fly) */ | |||
uint32_t InjectedOffsetNumber; /*!< Selects the offset number. | |||
This parameter can be a value of @ref ADC_HAL_EC_OFFSET_NB. | |||
Caution: Only one offset is allowed per channel. This parameter overwrites the last setting. */ | |||
uint32_t InjectedOffset; /*!< Defines the offset to be subtracted from the raw converted data. | |||
Offset value must be a positive number. | |||
Depending of ADC resolution selected (12, 10, 8 or 6 bits), this parameter must be a number | |||
between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively. | |||
Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled | |||
without continuous mode or external trigger that could launch a conversion). */ | |||
uint32_t InjectedNbrOfConversion; /*!< Specifies the number of ranks that will be converted within the ADC group injected sequencer. | |||
To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled. | |||
This parameter must be a number between Min_Data = 1 and Max_Data = 4. | |||
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to | |||
configure a channel on injected group can impact the configuration of other channels previously set. */ | |||
FunctionalState InjectedDiscontinuousConvMode; /*!< Specifies whether the conversions sequence of ADC group injected is performed in Complete-sequence/Discontinuous-sequence | |||
(main sequence subdivided in successive parts). | |||
Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded. | |||
Discontinuous mode can be enabled only if continuous mode is disabled. | |||
This parameter can be set to ENABLE or DISABLE. | |||
Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion). | |||
Note: For injected group, discontinuous mode converts the sequence channel by channel (discontinuous length fixed to 1 rank). | |||
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to | |||
configure a channel on injected group can impact the configuration of other channels previously set. */ | |||
FunctionalState AutoInjectedConv; /*!< Enables or disables the selected ADC group injected automatic conversion after regular one | |||
This parameter can be set to ENABLE or DISABLE. | |||
Note: To use Automatic injected conversion, discontinuous mode must be disabled ('DiscontinuousConvMode' and 'InjectedDiscontinuousConvMode' set to DISABLE) | |||
Note: To use Automatic injected conversion, injected group external triggers must be disabled ('ExternalTrigInjecConv' set to ADC_INJECTED_SOFTWARE_START) | |||
Note: In case of DMA used with regular group: if DMA configured in normal mode (single shot) JAUTO will be stopped upon DMA transfer complete. | |||
To maintain JAUTO always enabled, DMA must be configured in circular mode. | |||
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to | |||
configure a channel on injected group can impact the configuration of other channels previously set. */ | |||
FunctionalState QueueInjectedContext; /*!< Specifies whether the context queue feature is enabled. | |||
This parameter can be set to ENABLE or DISABLE. | |||
If context queue is enabled, injected sequencer&channels configurations are queued on up to 2 contexts. If a | |||
new injected context is set when queue is full, error is triggered by interruption and through function | |||
'HAL_ADCEx_InjectedQueueOverflowCallback'. | |||
Caution: This feature request that the sequence is fully configured before injected conversion start. | |||
Therefore, configure channels with as many calls to HAL_ADCEx_InjectedConfigChannel() as the 'InjectedNbrOfConversion' parameter. | |||
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to | |||
configure a channel on injected group can impact the configuration of other channels previously set. | |||
Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion). */ | |||
uint32_t ExternalTrigInjecConv; /*!< Selects the external event used to trigger the conversion start of injected group. | |||
If set to ADC_INJECTED_SOFTWARE_START, external triggers are disabled and software trigger is used instead. | |||
This parameter can be a value of @ref ADC_injected_external_trigger_source. | |||
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to | |||
configure a channel on injected group can impact the configuration of other channels previously set. */ | |||
uint32_t ExternalTrigInjecConvEdge; /*!< Selects the external trigger edge of injected group. | |||
This parameter can be a value of @ref ADC_injected_external_trigger_edge. | |||
If trigger source is set to ADC_INJECTED_SOFTWARE_START, this parameter is discarded. | |||
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to | |||
configure a channel on injected group can impact the configuration of other channels previously set. */ | |||
FunctionalState InjecOversamplingMode; /*!< Specifies whether the oversampling feature is enabled or disabled. | |||
This parameter can be set to ENABLE or DISABLE. | |||
Note: This parameter can be modified only if there is no conversion is ongoing (both ADSTART and JADSTART cleared). */ | |||
ADC_InjOversamplingTypeDef InjecOversampling; /*!< Specifies the Oversampling parameters. | |||
Caution: this setting overwrites the previous oversampling configuration if oversampling already enabled. | |||
Note: This parameter can be modified only if there is no conversion is ongoing (both ADSTART and JADSTART cleared). */ | |||
}ADC_InjectionConfTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup ADCEx_Exported_Constants ADC Extended Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup ADC_injected_external_trigger_source ADC group injected trigger source | |||
* @{ | |||
*/ | |||
/* ADC group regular trigger sources for all ADC instances */ | |||
#define ADC_INJECTED_SOFTWARE_START (LL_ADC_INJ_TRIG_SOFTWARE) /*!< Software triggers injected group conversion start */ | |||
#define ADC_EXTERNALTRIGINJEC_T1_TRGO (LL_ADC_INJ_TRIG_EXT_TIM1_TRGO) /*!< ADC group injected conversion trigger from external peripheral: TIM1 TRGO. Trigger edge set to rising edge (default setting). */ | |||
#define ADC_EXTERNALTRIGINJEC_T1_TRGO2 (LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2) /*!< ADC group injected conversion trigger from external peripheral: TIM1 TRGO2. Trigger edge set to rising edge (default setting). */ | |||
#define ADC_EXTERNALTRIGINJEC_T1_CC4 (LL_ADC_INJ_TRIG_EXT_TIM1_CH4) /*!< ADC group injected conversion trigger from external peripheral: TIM1 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ | |||
#define ADC_EXTERNALTRIGINJEC_T2_TRGO (LL_ADC_INJ_TRIG_EXT_TIM2_TRGO) /*!< ADC group injected conversion trigger from external peripheral: TIM2 TRGO. Trigger edge set to rising edge (default setting). */ | |||
#define ADC_EXTERNALTRIGINJEC_T2_CC1 (LL_ADC_INJ_TRIG_EXT_TIM2_CH1) /*!< ADC group injected conversion trigger from external peripheral: TIM2 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ | |||
#define ADC_EXTERNALTRIGINJEC_EXT_IT15 (LL_ADC_INJ_TRIG_EXT_EXTI_LINE15) /*!< ADC group injected conversion trigger from external peripheral: external interrupt line 15. Trigger edge set to rising edge (default setting). */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup ADC_injected_external_trigger_edge ADC group injected trigger edge (when external trigger is selected) | |||
* @{ | |||
*/ | |||
#define ADC_EXTERNALTRIGINJECCONV_EDGE_NONE (0x00000000UL) /*!< Injected conversions hardware trigger detection disabled */ | |||
#define ADC_EXTERNALTRIGINJECCONV_EDGE_RISING (ADC_JSQR_JEXTEN_0) /*!< Injected conversions hardware trigger detection on the rising edge */ | |||
#define ADC_EXTERNALTRIGINJECCONV_EDGE_FALLING (ADC_JSQR_JEXTEN_1) /*!< Injected conversions hardware trigger detection on the falling edge */ | |||
#define ADC_EXTERNALTRIGINJECCONV_EDGE_RISINGFALLING (ADC_JSQR_JEXTEN) /*!< Injected conversions hardware trigger detection on both the rising and falling edges */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup ADC_HAL_EC_CHANNEL_SINGLE_DIFF_ENDING Channel - Single or differential ending | |||
* @{ | |||
*/ | |||
#define ADC_SINGLE_ENDED (LL_ADC_SINGLE_ENDED) /*!< ADC channel ending set to single ended (literal also used to set calibration mode) */ | |||
#define ADC_DIFFERENTIAL_ENDED (LL_ADC_DIFFERENTIAL_ENDED) /*!< ADC channel ending set to differential (literal also used to set calibration mode) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup ADC_HAL_EC_OFFSET_NB ADC instance - Offset number | |||
* @{ | |||
*/ | |||
#define ADC_OFFSET_NONE (ADC_OFFSET_4 + 1U) /*!< ADC offset disabled: no offset correction for the selected ADC channel */ | |||
#define ADC_OFFSET_1 (LL_ADC_OFFSET_1) /*!< ADC offset number 1: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */ | |||
#define ADC_OFFSET_2 (LL_ADC_OFFSET_2) /*!< ADC offset number 2: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */ | |||
#define ADC_OFFSET_3 (LL_ADC_OFFSET_3) /*!< ADC offset number 3: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */ | |||
#define ADC_OFFSET_4 (LL_ADC_OFFSET_4) /*!< ADC offset number 4: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup ADC_INJ_SEQ_RANKS ADC group injected - Sequencer ranks | |||
* @{ | |||
*/ | |||
#define ADC_INJECTED_RANK_1 (LL_ADC_INJ_RANK_1) /*!< ADC group injected sequencer rank 1 */ | |||
#define ADC_INJECTED_RANK_2 (LL_ADC_INJ_RANK_2) /*!< ADC group injected sequencer rank 2 */ | |||
#define ADC_INJECTED_RANK_3 (LL_ADC_INJ_RANK_3) /*!< ADC group injected sequencer rank 3 */ | |||
#define ADC_INJECTED_RANK_4 (LL_ADC_INJ_RANK_4) /*!< ADC group injected sequencer rank 4 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup ADC_HAL_EC_GROUPS ADC instance - Groups | |||
* @{ | |||
*/ | |||
#define ADC_REGULAR_GROUP (LL_ADC_GROUP_REGULAR) /*!< ADC group regular (available on all STM32 devices) */ | |||
#define ADC_INJECTED_GROUP (LL_ADC_GROUP_INJECTED) /*!< ADC group injected (not available on all STM32 devices)*/ | |||
#define ADC_REGULAR_INJECTED_GROUP (LL_ADC_GROUP_REGULAR_INJECTED) /*!< ADC both groups regular and injected */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup ADC_CFGR_fields ADCx CFGR fields | |||
* @{ | |||
*/ | |||
#define ADC_CFGR_FIELDS (ADC_CFGR_AWD1CH | ADC_CFGR_JAUTO | ADC_CFGR_JAWD1EN |\ | |||
ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL | ADC_CFGR_JQM |\ | |||
ADC_CFGR_JDISCEN | ADC_CFGR_DISCNUM | ADC_CFGR_DISCEN |\ | |||
ADC_CFGR_AUTDLY | ADC_CFGR_CONT | ADC_CFGR_OVRMOD |\ | |||
ADC_CFGR_EXTEN | ADC_CFGR_EXTSEL | ADC_CFGR_ALIGN |\ | |||
ADC_CFGR_RES | ADC_CFGR_DMACFG | ADC_CFGR_DMAEN ) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup ADC_SMPR1_fields ADCx SMPR1 fields | |||
* @{ | |||
*/ | |||
#define ADC_SMPR1_FIELDS (ADC_SMPR1_SMP9 | ADC_SMPR1_SMP8 | ADC_SMPR1_SMP7 |\ | |||
ADC_SMPR1_SMP6 | ADC_SMPR1_SMP5 | ADC_SMPR1_SMP4 |\ | |||
ADC_SMPR1_SMP3 | ADC_SMPR1_SMP2 | ADC_SMPR1_SMP1 |\ | |||
ADC_SMPR1_SMP0) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup ADC_CFGR_fields_2 ADCx CFGR sub fields | |||
* @{ | |||
*/ | |||
/* ADC_CFGR fields of parameters that can be updated when no conversion | |||
(neither regular nor injected) is on-going */ | |||
#define ADC_CFGR_FIELDS_2 ((ADC_CFGR_DMACFG | ADC_CFGR_AUTDLY)) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup ADCEx_Private_Macro_internal_HAL_driver ADC Extended Private Macros | |||
* @{ | |||
*/ | |||
/* Macro reserved for internal HAL driver usage, not intended to be used in */ | |||
/* code of final user. */ | |||
/** | |||
* @brief Test if conversion trigger of injected group is software start | |||
* or external trigger. | |||
* @param __HANDLE__ ADC handle. | |||
* @retval SET (software start) or RESET (external trigger). | |||
*/ | |||
#define ADC_IS_SOFTWARE_START_INJECTED(__HANDLE__) \ | |||
(((__HANDLE__)->Instance->JSQR & ADC_JSQR_JEXTEN) == 0UL) | |||
/** | |||
* @brief Check whether or not ADC is independent. | |||
* @param __HANDLE__ ADC handle. | |||
* @note When multimode feature is not available, the macro always returns SET. | |||
* @retval SET (ADC is independent) or RESET (ADC is not). | |||
*/ | |||
#define ADC_IS_INDEPENDENT(__HANDLE__) (SET) | |||
/** | |||
* @brief Set the selected injected Channel rank. | |||
* @param __CHANNELNB__ Channel number. | |||
* @param __RANKNB__ Rank number. | |||
* @retval None | |||
*/ | |||
#define ADC_JSQR_RK(__CHANNELNB__, __RANKNB__) ((((__CHANNELNB__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << ((__RANKNB__) & ADC_INJ_RANK_ID_JSQR_MASK)) | |||
/** | |||
* @brief Configure ADC injected context queue | |||
* @param __INJECT_CONTEXT_QUEUE_MODE__ Injected context queue mode. | |||
* @retval None | |||
*/ | |||
#define ADC_CFGR_INJECT_CONTEXT_QUEUE(__INJECT_CONTEXT_QUEUE_MODE__) ((__INJECT_CONTEXT_QUEUE_MODE__) << ADC_CFGR_JQM_Pos) | |||
/** | |||
* @brief Configure ADC discontinuous conversion mode for injected group | |||
* @param __INJECT_DISCONTINUOUS_MODE__ Injected discontinuous mode. | |||
* @retval None | |||
*/ | |||
#define ADC_CFGR_INJECT_DISCCONTINUOUS(__INJECT_DISCONTINUOUS_MODE__) ((__INJECT_DISCONTINUOUS_MODE__) << ADC_CFGR_JDISCEN_Pos) | |||
/** | |||
* @brief Configure ADC discontinuous conversion mode for regular group | |||
* @param __REG_DISCONTINUOUS_MODE__ Regular discontinuous mode. | |||
* @retval None | |||
*/ | |||
#define ADC_CFGR_REG_DISCONTINUOUS(__REG_DISCONTINUOUS_MODE__) ((__REG_DISCONTINUOUS_MODE__) << ADC_CFGR_DISCEN_Pos) | |||
/** | |||
* @brief Configure the number of discontinuous conversions for regular group. | |||
* @param __NBR_DISCONTINUOUS_CONV__ Number of discontinuous conversions. | |||
* @retval None | |||
*/ | |||
#define ADC_CFGR_DISCONTINUOUS_NUM(__NBR_DISCONTINUOUS_CONV__) (((__NBR_DISCONTINUOUS_CONV__) - 1UL) << ADC_CFGR_DISCNUM_Pos) | |||
/** | |||
* @brief Configure the ADC auto delay mode. | |||
* @param __AUTOWAIT__ Auto delay bit enable or disable. | |||
* @retval None | |||
*/ | |||
#define ADC_CFGR_AUTOWAIT(__AUTOWAIT__) ((__AUTOWAIT__) << ADC_CFGR_AUTDLY_Pos) | |||
/** | |||
* @brief Configure ADC continuous conversion mode. | |||
* @param __CONTINUOUS_MODE__ Continuous mode. | |||
* @retval None | |||
*/ | |||
#define ADC_CFGR_CONTINUOUS(__CONTINUOUS_MODE__) ((__CONTINUOUS_MODE__) << ADC_CFGR_CONT_Pos) | |||
/** | |||
* @brief Configure the ADC DMA continuous request. | |||
* @param __DMACONTREQ_MODE__ DMA continuous request mode. | |||
* @retval None | |||
*/ | |||
#define ADC_CFGR_DMACONTREQ(__DMACONTREQ_MODE__) ((__DMACONTREQ_MODE__) << ADC_CFGR_DMACFG_Pos) | |||
/** | |||
* @brief Shift the offset with respect to the selected ADC resolution. | |||
* @note Offset has to be left-aligned on bit 11, the LSB (right bits) are set to 0. | |||
* If resolution 12 bits, no shift. | |||
* If resolution 10 bits, shift of 2 ranks on the left. | |||
* If resolution 8 bits, shift of 4 ranks on the left. | |||
* If resolution 6 bits, shift of 6 ranks on the left. | |||
* Therefore, shift = (12 - resolution) = 12 - (12- (((RES[1:0]) >> 3)*2)). | |||
* @param __HANDLE__ ADC handle | |||
* @param __OFFSET__ Value to be shifted | |||
* @retval None | |||
*/ | |||
#define ADC_OFFSET_SHIFT_RESOLUTION(__HANDLE__, __OFFSET__) \ | |||
((__OFFSET__) << ((((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) >> 3UL) * 2UL)) | |||
/** | |||
* @brief Shift the AWD1 threshold with respect to the selected ADC resolution. | |||
* @note Thresholds have to be left-aligned on bit 11, the LSB (right bits) are set to 0. | |||
* If resolution 12 bits, no shift. | |||
* If resolution 10 bits, shift of 2 ranks on the left. | |||
* If resolution 8 bits, shift of 4 ranks on the left. | |||
* If resolution 6 bits, shift of 6 ranks on the left. | |||
* Therefore, shift = (12 - resolution) = 12 - (12- (((RES[1:0]) >> 3)*2)). | |||
* @param __HANDLE__ ADC handle | |||
* @param __THRESHOLD__ Value to be shifted | |||
* @retval None | |||
*/ | |||
#define ADC_AWD1THRESHOLD_SHIFT_RESOLUTION(__HANDLE__, __THRESHOLD__) \ | |||
((__THRESHOLD__) << ((((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) >> 3UL) * 2UL)) | |||
/** | |||
* @brief Shift the AWD2 and AWD3 threshold with respect to the selected ADC resolution. | |||
* @note Thresholds have to be left-aligned on bit 7. | |||
* If resolution 12 bits, shift of 4 ranks on the right (the 4 LSB are discarded). | |||
* If resolution 10 bits, shift of 2 ranks on the right (the 2 LSB are discarded). | |||
* If resolution 8 bits, no shift. | |||
* If resolution 6 bits, shift of 2 ranks on the left (the 2 LSB are set to 0). | |||
* @param __HANDLE__ ADC handle | |||
* @param __THRESHOLD__ Value to be shifted | |||
* @retval None | |||
*/ | |||
#define ADC_AWD23THRESHOLD_SHIFT_RESOLUTION(__HANDLE__, __THRESHOLD__) \ | |||
((((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) != (ADC_CFGR_RES_1 | ADC_CFGR_RES_0)) ? \ | |||
((__THRESHOLD__) >> ((4UL - ((((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) >> 3UL) * 2UL)) & 0x1FUL)) : \ | |||
((__THRESHOLD__) << 2UL) \ | |||
) | |||
/** | |||
* @brief Clear Common Control Register. | |||
* @param __HANDLE__ ADC handle. | |||
* @retval None | |||
*/ | |||
#define ADC_CLEAR_COMMON_CONTROL_REGISTER(__HANDLE__) CLEAR_BIT(__LL_ADC_COMMON_INSTANCE((__HANDLE__)->Instance)->CCR, ADC_CCR_CKMODE | \ | |||
ADC_CCR_PRESC | \ | |||
ADC_CCR_VBATEN | \ | |||
ADC_CCR_TSEN | \ | |||
ADC_CCR_VREFEN ) | |||
/** | |||
* @brief Verify the ADC instance connected to the temperature sensor. | |||
* @param __HANDLE__ ADC handle. | |||
* @retval SET (ADC instance is valid) or RESET (ADC instance is invalid) | |||
*/ | |||
#define ADC_TEMPERATURE_SENSOR_INSTANCE(__HANDLE__) (((__HANDLE__)->Instance) == ADC1) | |||
/** | |||
* @brief Verify the ADC instance connected to the battery voltage VBAT. | |||
* @param __HANDLE__ ADC handle. | |||
* @retval SET (ADC instance is valid) or RESET (ADC instance is invalid) | |||
*/ | |||
#define ADC_BATTERY_VOLTAGE_INSTANCE(__HANDLE__) (((__HANDLE__)->Instance) == ADC1) | |||
/** | |||
* @brief Verify the ADC instance connected to the internal voltage reference VREFINT. | |||
* @param __HANDLE__ ADC handle. | |||
* @retval SET (ADC instance is valid) or RESET (ADC instance is invalid) | |||
*/ | |||
#define ADC_VREFINT_INSTANCE(__HANDLE__) (((__HANDLE__)->Instance) == ADC1) | |||
/** | |||
* @brief Verify the length of scheduled injected conversions group. | |||
* @param __LENGTH__ number of programmed conversions. | |||
* @retval SET (__LENGTH__ is within the maximum number of possible programmable injected conversions) or RESET (__LENGTH__ is null or too large) | |||
*/ | |||
#define IS_ADC_INJECTED_NB_CONV(__LENGTH__) (((__LENGTH__) >= (1U)) && ((__LENGTH__) <= (4U))) | |||
/** | |||
* @brief Calibration factor size verification (7 bits maximum). | |||
* @param __CALIBRATION_FACTOR__ Calibration factor value. | |||
* @retval SET (__CALIBRATION_FACTOR__ is within the authorized size) or RESET (__CALIBRATION_FACTOR__ is too large) | |||
*/ | |||
#define IS_ADC_CALFACT(__CALIBRATION_FACTOR__) ((__CALIBRATION_FACTOR__) <= (0x7FU)) | |||
/** | |||
* @brief Verify the ADC channel setting. | |||
* @param __HANDLE__ ADC handle. | |||
* @param __CHANNEL__ programmed ADC channel. | |||
* @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid) | |||
*/ | |||
#define IS_ADC_CHANNEL(__HANDLE__, __CHANNEL__) ((((__HANDLE__)->Instance) == ADC1) && \ | |||
(((__CHANNEL__) == ADC_CHANNEL_0) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_1) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_2) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_3) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_4) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_5) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_6) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_7) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_8) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_9) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_10) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_11) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_12) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_13) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_14) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_15) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_16) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_17) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_18) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_VREFINT) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_TEMPSENSOR) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_VBAT))) | |||
/** | |||
* @brief Verify the ADC channel setting in differential mode. | |||
* @param __HANDLE__ ADC handle. | |||
* @param __CHANNEL__ programmed ADC channel. | |||
* @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid) | |||
*/ | |||
#define IS_ADC_DIFF_CHANNEL(__HANDLE__, __CHANNEL__) (((__CHANNEL__) == ADC_CHANNEL_1) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_2) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_3) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_4) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_5) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_6) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_7) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_8) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_9) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_10) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_11) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_12) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_13) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_14) || \ | |||
((__CHANNEL__) == ADC_CHANNEL_15) ) | |||
/** | |||
* @brief Verify the ADC single-ended input or differential mode setting. | |||
* @param __SING_DIFF__ programmed channel setting. | |||
* @retval SET (__SING_DIFF__ is valid) or RESET (__SING_DIFF__ is invalid) | |||
*/ | |||
#define IS_ADC_SINGLE_DIFFERENTIAL(__SING_DIFF__) (((__SING_DIFF__) == ADC_SINGLE_ENDED) || \ | |||
((__SING_DIFF__) == ADC_DIFFERENTIAL_ENDED) ) | |||
/** | |||
* @brief Verify the ADC offset management setting. | |||
* @param __OFFSET_NUMBER__ ADC offset management. | |||
* @retval SET (__OFFSET_NUMBER__ is valid) or RESET (__OFFSET_NUMBER__ is invalid) | |||
*/ | |||
#define IS_ADC_OFFSET_NUMBER(__OFFSET_NUMBER__) (((__OFFSET_NUMBER__) == ADC_OFFSET_NONE) || \ | |||
((__OFFSET_NUMBER__) == ADC_OFFSET_1) || \ | |||
((__OFFSET_NUMBER__) == ADC_OFFSET_2) || \ | |||
((__OFFSET_NUMBER__) == ADC_OFFSET_3) || \ | |||
((__OFFSET_NUMBER__) == ADC_OFFSET_4) ) | |||
/** | |||
* @brief Verify the ADC injected channel setting. | |||
* @param __CHANNEL__ programmed ADC injected channel. | |||
* @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid) | |||
*/ | |||
#define IS_ADC_INJECTED_RANK(__CHANNEL__) (((__CHANNEL__) == ADC_INJECTED_RANK_1) || \ | |||
((__CHANNEL__) == ADC_INJECTED_RANK_2) || \ | |||
((__CHANNEL__) == ADC_INJECTED_RANK_3) || \ | |||
((__CHANNEL__) == ADC_INJECTED_RANK_4) ) | |||
/** | |||
* @brief Verify the ADC injected conversions external trigger. | |||
* @param __HANDLE__ ADC handle. | |||
* @param __INJTRIG__ programmed ADC injected conversions external trigger. | |||
* @retval SET (__INJTRIG__ is a valid value) or RESET (__INJTRIG__ is invalid) | |||
*/ | |||
#define IS_ADC_EXTTRIGINJEC(__HANDLE__, __INJTRIG__) (((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T1_TRGO) || \ | |||
((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T1_CC4) || \ | |||
((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T2_TRGO) || \ | |||
((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T2_CC1) || \ | |||
((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_EXT_IT15) || \ | |||
((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T1_TRGO2) || \ | |||
((__INJTRIG__) == ADC_INJECTED_SOFTWARE_START) ) | |||
/** | |||
* @brief Verify the ADC edge trigger setting for injected group. | |||
* @param __EDGE__ programmed ADC edge trigger setting. | |||
* @retval SET (__EDGE__ is a valid value) or RESET (__EDGE__ is invalid) | |||
*/ | |||
#define IS_ADC_EXTTRIGINJEC_EDGE(__EDGE__) (((__EDGE__) == ADC_EXTERNALTRIGINJECCONV_EDGE_NONE) || \ | |||
((__EDGE__) == ADC_EXTERNALTRIGINJECCONV_EDGE_RISING) || \ | |||
((__EDGE__) == ADC_EXTERNALTRIGINJECCONV_EDGE_FALLING) || \ | |||
((__EDGE__) == ADC_EXTERNALTRIGINJECCONV_EDGE_RISINGFALLING) ) | |||
/** | |||
* @brief Verify the ADC analog watchdog setting. | |||
* @param __WATCHDOG__ programmed ADC analog watchdog setting. | |||
* @retval SET (__WATCHDOG__ is valid) or RESET (__WATCHDOG__ is invalid) | |||
*/ | |||
#define IS_ADC_ANALOG_WATCHDOG_NUMBER(__WATCHDOG__) (((__WATCHDOG__) == ADC_ANALOGWATCHDOG_1) || \ | |||
((__WATCHDOG__) == ADC_ANALOGWATCHDOG_2) || \ | |||
((__WATCHDOG__) == ADC_ANALOGWATCHDOG_3) ) | |||
/** | |||
* @brief Verify the ADC analog watchdog mode setting. | |||
* @param __WATCHDOG_MODE__ programmed ADC analog watchdog mode setting. | |||
* @retval SET (__WATCHDOG_MODE__ is valid) or RESET (__WATCHDOG_MODE__ is invalid) | |||
*/ | |||
#define IS_ADC_ANALOG_WATCHDOG_MODE(__WATCHDOG_MODE__) (((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_NONE) || \ | |||
((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \ | |||
((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \ | |||
((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \ | |||
((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_ALL_REG) || \ | |||
((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \ | |||
((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) ) | |||
/** | |||
* @brief Verify the ADC conversion (regular or injected or both). | |||
* @param __CONVERSION__ ADC conversion group. | |||
* @retval SET (__CONVERSION__ is valid) or RESET (__CONVERSION__ is invalid) | |||
*/ | |||
#define IS_ADC_CONVERSION_GROUP(__CONVERSION__) (((__CONVERSION__) == ADC_REGULAR_GROUP) || \ | |||
((__CONVERSION__) == ADC_INJECTED_GROUP) || \ | |||
((__CONVERSION__) == ADC_REGULAR_INJECTED_GROUP) ) | |||
/** | |||
* @brief Verify the ADC event type. | |||
* @param __EVENT__ ADC event. | |||
* @retval SET (__EVENT__ is valid) or RESET (__EVENT__ is invalid) | |||
*/ | |||
#define IS_ADC_EVENT_TYPE(__EVENT__) (((__EVENT__) == ADC_EOSMP_EVENT) || \ | |||
((__EVENT__) == ADC_AWD_EVENT) || \ | |||
((__EVENT__) == ADC_AWD2_EVENT) || \ | |||
((__EVENT__) == ADC_AWD3_EVENT) || \ | |||
((__EVENT__) == ADC_OVR_EVENT) || \ | |||
((__EVENT__) == ADC_JQOVF_EVENT) ) | |||
/** | |||
* @brief Verify the ADC oversampling ratio. | |||
* @param __RATIO__ programmed ADC oversampling ratio. | |||
* @retval SET (__RATIO__ is a valid value) or RESET (__RATIO__ is invalid) | |||
*/ | |||
#define IS_ADC_OVERSAMPLING_RATIO(__RATIO__) (((__RATIO__) == ADC_OVERSAMPLING_RATIO_2 ) || \ | |||
((__RATIO__) == ADC_OVERSAMPLING_RATIO_4 ) || \ | |||
((__RATIO__) == ADC_OVERSAMPLING_RATIO_8 ) || \ | |||
((__RATIO__) == ADC_OVERSAMPLING_RATIO_16 ) || \ | |||
((__RATIO__) == ADC_OVERSAMPLING_RATIO_32 ) || \ | |||
((__RATIO__) == ADC_OVERSAMPLING_RATIO_64 ) || \ | |||
((__RATIO__) == ADC_OVERSAMPLING_RATIO_128 ) || \ | |||
((__RATIO__) == ADC_OVERSAMPLING_RATIO_256 )) | |||
/** | |||
* @brief Verify the ADC oversampling shift. | |||
* @param __SHIFT__ programmed ADC oversampling shift. | |||
* @retval SET (__SHIFT__ is a valid value) or RESET (__SHIFT__ is invalid) | |||
*/ | |||
#define IS_ADC_RIGHT_BIT_SHIFT(__SHIFT__) (((__SHIFT__) == ADC_RIGHTBITSHIFT_NONE) || \ | |||
((__SHIFT__) == ADC_RIGHTBITSHIFT_1 ) || \ | |||
((__SHIFT__) == ADC_RIGHTBITSHIFT_2 ) || \ | |||
((__SHIFT__) == ADC_RIGHTBITSHIFT_3 ) || \ | |||
((__SHIFT__) == ADC_RIGHTBITSHIFT_4 ) || \ | |||
((__SHIFT__) == ADC_RIGHTBITSHIFT_5 ) || \ | |||
((__SHIFT__) == ADC_RIGHTBITSHIFT_6 ) || \ | |||
((__SHIFT__) == ADC_RIGHTBITSHIFT_7 ) || \ | |||
((__SHIFT__) == ADC_RIGHTBITSHIFT_8 )) | |||
/** | |||
* @brief Verify the ADC oversampling triggered mode. | |||
* @param __MODE__ programmed ADC oversampling triggered mode. | |||
* @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) | |||
*/ | |||
#define IS_ADC_TRIGGERED_OVERSAMPLING_MODE(__MODE__) (((__MODE__) == ADC_TRIGGEREDMODE_SINGLE_TRIGGER) || \ | |||
((__MODE__) == ADC_TRIGGEREDMODE_MULTI_TRIGGER) ) | |||
/** | |||
* @brief Verify the ADC oversampling regular conversion resumed or continued mode. | |||
* @param __MODE__ programmed ADC oversampling regular conversion resumed or continued mode. | |||
* @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) | |||
*/ | |||
#define IS_ADC_REGOVERSAMPLING_MODE(__MODE__) (((__MODE__) == ADC_REGOVERSAMPLING_CONTINUED_MODE) || \ | |||
((__MODE__) == ADC_REGOVERSAMPLING_RESUMED_MODE) ) | |||
/** | |||
* @brief Verify the DFSDM mode configuration. | |||
* @param __HANDLE__ ADC handle. | |||
* @note When DMSDFM configuration is not supported, the macro systematically reports SET. For | |||
* this reason, the input parameter is the ADC handle and not the configuration parameter | |||
* directly. | |||
* @retval SET (DFSDM mode configuration is valid) or RESET (DFSDM mode configuration is invalid) | |||
*/ | |||
#define IS_ADC_DFSDMCFG_MODE(__HANDLE__) (SET) | |||
/** | |||
* @brief Return the DFSDM configuration mode. | |||
* @param __HANDLE__ ADC handle. | |||
* @note When DMSDFM configuration is not supported, the macro systematically reports 0x0 (i.e disabled). | |||
* For this reason, the input parameter is the ADC handle and not the configuration parameter | |||
* directly. | |||
* @retval DFSDM configuration mode | |||
*/ | |||
#define ADC_CFGR_DFSDM(__HANDLE__) (0x0UL) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup ADCEx_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup ADCEx_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
/* ADC calibration */ | |||
HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef* hadc, uint32_t SingleDiff); | |||
uint32_t HAL_ADCEx_Calibration_GetValue(ADC_HandleTypeDef *hadc, uint32_t SingleDiff); | |||
HAL_StatusTypeDef HAL_ADCEx_Calibration_SetValue(ADC_HandleTypeDef *hadc, uint32_t SingleDiff, uint32_t CalibrationFactor); | |||
/* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef* hadc); | |||
HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef* hadc); | |||
HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout); | |||
/* Non-blocking mode: Interruption */ | |||
HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef* hadc); | |||
HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc); | |||
/* ADC retrieve conversion value intended to be used with polling or interruption */ | |||
uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank); | |||
/* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption) */ | |||
void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc); | |||
void HAL_ADCEx_InjectedQueueOverflowCallback(ADC_HandleTypeDef* hadc); | |||
void HAL_ADCEx_LevelOutOfWindow2Callback(ADC_HandleTypeDef* hadc); | |||
void HAL_ADCEx_LevelOutOfWindow3Callback(ADC_HandleTypeDef* hadc); | |||
void HAL_ADCEx_EndOfSamplingCallback(ADC_HandleTypeDef* hadc); | |||
/* ADC group regular conversions stop */ | |||
HAL_StatusTypeDef HAL_ADCEx_RegularStop(ADC_HandleTypeDef* hadc); | |||
HAL_StatusTypeDef HAL_ADCEx_RegularStop_IT(ADC_HandleTypeDef* hadc); | |||
HAL_StatusTypeDef HAL_ADCEx_RegularStop_DMA(ADC_HandleTypeDef* hadc); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup ADCEx_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
/* Peripheral Control functions ***********************************************/ | |||
HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc,ADC_InjectionConfTypeDef* sConfigInjected); | |||
HAL_StatusTypeDef HAL_ADCEx_EnableInjectedQueue(ADC_HandleTypeDef* hadc); | |||
HAL_StatusTypeDef HAL_ADCEx_DisableInjectedQueue(ADC_HandleTypeDef* hadc); | |||
HAL_StatusTypeDef HAL_ADCEx_DisableVoltageRegulator(ADC_HandleTypeDef* hadc); | |||
HAL_StatusTypeDef HAL_ADCEx_EnterADCDeepPowerDownMode(ADC_HandleTypeDef* hadc); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_ADC_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,711 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_comp.h | |||
* @author MCD Application Team | |||
* @brief Header file of COMP HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_COMP_H | |||
#define STM32WBxx_HAL_COMP_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
#include "stm32wbxx_ll_exti.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup COMP | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup COMP_Exported_Types COMP Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief COMP Init structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t WindowMode; /*!< Set window mode of a pair of comparators instances | |||
(2 consecutive instances odd and even COMP<x> and COMP<x+1>). | |||
Note: HAL COMP driver allows to set window mode from any COMP instance of the pair of COMP instances composing window mode. | |||
This parameter can be a value of @ref COMP_WindowMode */ | |||
uint32_t Mode; /*!< Set comparator operating mode to adjust power and speed. | |||
Note: For the characteristics of comparator power modes | |||
(propagation delay and power consumption), refer to device datasheet. | |||
This parameter can be a value of @ref COMP_PowerMode */ | |||
uint32_t InputPlus; /*!< Set comparator input plus (non-inverting input). | |||
This parameter can be a value of @ref COMP_InputPlus */ | |||
uint32_t InputMinus; /*!< Set comparator input minus (inverting input). | |||
This parameter can be a value of @ref COMP_InputMinus */ | |||
uint32_t Hysteresis; /*!< Set comparator hysteresis mode of the input minus. | |||
This parameter can be a value of @ref COMP_Hysteresis */ | |||
uint32_t OutputPol; /*!< Set comparator output polarity. | |||
This parameter can be a value of @ref COMP_OutputPolarity */ | |||
uint32_t BlankingSrce; /*!< Set comparator blanking source. | |||
This parameter can be a value of @ref COMP_BlankingSrce */ | |||
uint32_t TriggerMode; /*!< Set the comparator output triggering External Interrupt Line (EXTI). | |||
This parameter can be a value of @ref COMP_EXTI_TriggerMode */ | |||
} COMP_InitTypeDef; | |||
/** | |||
* @brief HAL COMP state machine: HAL COMP states definition | |||
*/ | |||
#define COMP_STATE_BITFIELD_LOCK (0x10U) | |||
typedef enum | |||
{ | |||
HAL_COMP_STATE_RESET = 0x00U, /*!< COMP not yet initialized */ | |||
HAL_COMP_STATE_RESET_LOCKED = (HAL_COMP_STATE_RESET | COMP_STATE_BITFIELD_LOCK), /*!< COMP not yet initialized and configuration is locked */ | |||
HAL_COMP_STATE_READY = 0x01U, /*!< COMP initialized and ready for use */ | |||
HAL_COMP_STATE_READY_LOCKED = (HAL_COMP_STATE_READY | COMP_STATE_BITFIELD_LOCK), /*!< COMP initialized but configuration is locked */ | |||
HAL_COMP_STATE_BUSY = 0x02U, /*!< COMP is running */ | |||
HAL_COMP_STATE_BUSY_LOCKED = (HAL_COMP_STATE_BUSY | COMP_STATE_BITFIELD_LOCK) /*!< COMP is running and configuration is locked */ | |||
} HAL_COMP_StateTypeDef; | |||
/** | |||
* @brief COMP Handle Structure definition | |||
*/ | |||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) | |||
typedef struct __COMP_HandleTypeDef | |||
#else | |||
typedef struct | |||
#endif | |||
{ | |||
COMP_TypeDef *Instance; /*!< Register base address */ | |||
COMP_InitTypeDef Init; /*!< COMP required parameters */ | |||
HAL_LockTypeDef Lock; /*!< Locking object */ | |||
__IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */ | |||
__IO uint32_t ErrorCode; /*!< COMP error code */ | |||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) | |||
void (* TriggerCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP trigger callback */ | |||
void (* MspInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp Init callback */ | |||
void (* MspDeInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp DeInit callback */ | |||
#endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ | |||
} COMP_HandleTypeDef; | |||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) | |||
/** | |||
* @brief HAL COMP Callback ID enumeration definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_COMP_TRIGGER_CB_ID = 0x00U, /*!< COMP trigger callback ID */ | |||
HAL_COMP_MSPINIT_CB_ID = 0x01U, /*!< COMP Msp Init callback ID */ | |||
HAL_COMP_MSPDEINIT_CB_ID = 0x02U /*!< COMP Msp DeInit callback ID */ | |||
} HAL_COMP_CallbackIDTypeDef; | |||
/** | |||
* @brief HAL COMP Callback pointer definition | |||
*/ | |||
typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer to a COMP callback function */ | |||
#endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup COMP_Exported_Constants COMP Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup COMP_Error_Code COMP Error Code | |||
* @{ | |||
*/ | |||
#define HAL_COMP_ERROR_NONE (0x00UL) /*!< No error */ | |||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) | |||
#define HAL_COMP_ERROR_INVALID_CALLBACK (0x01UL) /*!< Invalid Callback error */ | |||
#endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_WindowMode COMP Window Mode | |||
* @{ | |||
*/ | |||
#define COMP_WINDOWMODE_DISABLE (0x00000000UL) /*!< Window mode disable: Comparators instances pair COMP1 and COMP2 are independent */ | |||
#define COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_WINMODE) /*!< Window mode enable: Comparators instances pair COMP1 and COMP2 have their input plus connected together. The common input is COMP1 input plus (COMP2 input plus is no more accessible). */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_PowerMode COMP power mode | |||
* @{ | |||
*/ | |||
/* Note: For the characteristics of comparator power modes */ | |||
/* (propagation delay and power consumption), */ | |||
/* refer to device datasheet. */ | |||
#define COMP_POWERMODE_HIGHSPEED (0x00000000UL) /*!< High Speed */ | |||
#define COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_PWRMODE_0) /*!< Medium Speed */ | |||
#define COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_PWRMODE) /*!< Ultra-low power mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_InputPlus COMP input plus (non-inverting input) | |||
* @{ | |||
*/ | |||
#define COMP_INPUT_PLUS_IO1 (0x00000000UL) /*!< Comparator input plus connected to IO1 (pin PC5 for COMP1, pin PB4 for COMP2) */ | |||
#define COMP_INPUT_PLUS_IO2 (COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PB6 for COMP2) */ | |||
#if defined(COMP_CSR_INPSEL_1) | |||
#define COMP_INPUT_PLUS_IO3 (COMP_CSR_INPSEL_1) /*!< Comparator input plus connected to IO3 (pin PA1 for COMP1, pin PA3 for COMP2) */ | |||
#endif | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_InputMinus COMP input minus (inverting input) | |||
* @{ | |||
*/ | |||
#define COMP_INPUT_MINUS_1_4VREFINT ( COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/4 VrefInt */ | |||
#define COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/2 VrefInt */ | |||
#define COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 3/4 VrefInt */ | |||
#define COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN ) /*!< Comparator input minus connected to VrefInt */ | |||
#define COMP_INPUT_MINUS_IO1 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 ) /*!< Comparator input minus connected to IO1 (pin PB1 for COMP1, pin PB3 for COMP2) */ | |||
#define COMP_INPUT_MINUS_IO2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO2 (pin PC4 for COMP1, pin PB7 for COMP2) */ | |||
#define COMP_INPUT_MINUS_IO3 ( COMP_CSR_INMESEL_0 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO3 (pin PA0 for COMP1, pin PA2 for COMP2) */ | |||
#define COMP_INPUT_MINUS_IO4 (COMP_CSR_INMESEL_1 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO4 (pin PA4 for COMP1, pin PA4 for COMP2) */ | |||
#define COMP_INPUT_MINUS_IO5 (COMP_CSR_INMESEL_1 | COMP_CSR_INMESEL_0 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO5 (pin PA5 for COMP1, pin PA5 for COMP2) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_Hysteresis COMP hysteresis | |||
* @{ | |||
*/ | |||
#define COMP_HYSTERESIS_NONE (0x00000000UL) /*!< No hysteresis */ | |||
#define COMP_HYSTERESIS_LOW ( COMP_CSR_HYST_0) /*!< Hysteresis level low */ | |||
#define COMP_HYSTERESIS_MEDIUM (COMP_CSR_HYST_1 ) /*!< Hysteresis level medium */ | |||
#define COMP_HYSTERESIS_HIGH (COMP_CSR_HYST_1 | COMP_CSR_HYST_0) /*!< Hysteresis level high */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_OutputPolarity COMP output Polarity | |||
* @{ | |||
*/ | |||
#define COMP_OUTPUTPOL_NONINVERTED (0x00000000UL) /*!< COMP output level is not inverted (comparator output is high when the input plus is at a higher voltage than the input minus) */ | |||
#define COMP_OUTPUTPOL_INVERTED (COMP_CSR_POLARITY) /*!< COMP output level is inverted (comparator output is low when the input plus is at a higher voltage than the input minus) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_BlankingSrce COMP blanking source | |||
* @{ | |||
*/ | |||
#define COMP_BLANKINGSRC_NONE (0x00000000UL) /*!<Comparator output without blanking */ | |||
/* Note: Output blanking source common to all COMP instances */ | |||
#define COMP_BLANKINGSRC_TIM1_OC5 (COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM1 OC5 (common to all COMP instances: COMP1, COMP2) */ | |||
#define COMP_BLANKINGSRC_TIM2_OC3 (COMP_CSR_BLANKING_1) /*!< Comparator output blanking source TIM2 OC3 (common to all COMP instances: COMP1, COMP2) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_OutputLevel COMP Output Level | |||
* @{ | |||
*/ | |||
/* Note: Comparator output level values are fixed to "0" and "1", */ | |||
/* corresponding COMP register bit is managed by HAL function to match */ | |||
/* with these values (independently of bit position in register). */ | |||
/* When output polarity is not inverted, comparator output is low when | |||
the input plus is at a lower voltage than the input minus */ | |||
#define COMP_OUTPUT_LEVEL_LOW (0x00000000UL) | |||
/* When output polarity is not inverted, comparator output is high when | |||
the input plus is at a higher voltage than the input minus */ | |||
#define COMP_OUTPUT_LEVEL_HIGH (0x00000001UL) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI | |||
* @{ | |||
*/ | |||
#define COMP_TRIGGERMODE_NONE (0x00000000UL) /*!< Comparator output triggering no External Interrupt Line */ | |||
#define COMP_TRIGGERMODE_IT_RISING (COMP_EXTI_IT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */ | |||
#define COMP_TRIGGERMODE_IT_FALLING (COMP_EXTI_IT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */ | |||
#define COMP_TRIGGERMODE_IT_RISING_FALLING (COMP_EXTI_IT | COMP_EXTI_RISING | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on both rising and falling edges */ | |||
#define COMP_TRIGGERMODE_EVENT_RISING (COMP_EXTI_EVENT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */ | |||
#define COMP_TRIGGERMODE_EVENT_FALLING (COMP_EXTI_EVENT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */ | |||
#define COMP_TRIGGERMODE_EVENT_RISING_FALLING (COMP_EXTI_EVENT | COMP_EXTI_RISING | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on both rising and falling edges */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup COMP_Exported_Macros COMP Exported Macros | |||
* @{ | |||
*/ | |||
/** @defgroup COMP_Handle_Management COMP Handle Management | |||
* @{ | |||
*/ | |||
/** @brief Reset COMP handle state. | |||
* @param __HANDLE__ COMP handle | |||
* @retval None | |||
*/ | |||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) | |||
#define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) do{ \ | |||
(__HANDLE__)->State = HAL_COMP_STATE_RESET; \ | |||
(__HANDLE__)->MspInitCallback = NULL; \ | |||
(__HANDLE__)->MspDeInitCallback = NULL; \ | |||
} while(0) | |||
#else | |||
#define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET) | |||
#endif | |||
/** | |||
* @brief Clear COMP error code (set it to no error code "HAL_COMP_ERROR_NONE"). | |||
* @param __HANDLE__ COMP handle | |||
* @retval None | |||
*/ | |||
#define COMP_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_COMP_ERROR_NONE) | |||
/** | |||
* @brief Enable the specified comparator. | |||
* @param __HANDLE__ COMP handle | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN) | |||
/** | |||
* @brief Disable the specified comparator. | |||
* @param __HANDLE__ COMP handle | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN) | |||
/** | |||
* @brief Lock the specified comparator configuration. | |||
* @note Using this macro induce HAL COMP handle state machine being no | |||
* more in line with COMP instance state. | |||
* To keep HAL COMP handle state machine updated, it is recommended | |||
* to use function "HAL_COMP_Lock')". | |||
* @param __HANDLE__ COMP handle | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_LOCK(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK) | |||
/** | |||
* @brief Check whether the specified comparator is locked. | |||
* @param __HANDLE__ COMP handle | |||
* @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked | |||
*/ | |||
#define __HAL_COMP_IS_LOCKED(__HANDLE__) (READ_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK) == COMP_CSR_LOCK) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_Exti_Management COMP external interrupt line management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable the COMP1 EXTI line rising edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP1) | |||
/** | |||
* @brief Disable the COMP1 EXTI line rising edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP1) | |||
/** | |||
* @brief Enable the COMP1 EXTI line falling edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP1) | |||
/** | |||
* @brief Disable the COMP1 EXTI line falling edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP1) | |||
/** | |||
* @brief Enable the COMP1 EXTI line rising & falling edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ | |||
LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP1); \ | |||
LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP1); \ | |||
} while(0) | |||
/** | |||
* @brief Disable the COMP1 EXTI line rising & falling edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ | |||
LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP1); \ | |||
LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP1); \ | |||
} while(0) | |||
/** | |||
* @brief Enable the COMP1 EXTI line in interrupt mode. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP1_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP1) | |||
/** | |||
* @brief Disable the COMP1 EXTI line in interrupt mode. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP1_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP1) | |||
/** | |||
* @brief Generate a software interrupt on the COMP1 EXTI line. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP1) | |||
/** | |||
* @brief Enable the COMP1 EXTI line in event mode. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP1) | |||
/** | |||
* @brief Disable the COMP1 EXTI line in event mode. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP1) | |||
/** | |||
* @brief Check whether the COMP1 EXTI line flag is set. | |||
* @retval RESET or SET | |||
*/ | |||
#define __HAL_COMP_COMP1_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP1) | |||
/** | |||
* @brief Clear the COMP1 EXTI flag. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP1) | |||
/** | |||
* @brief Enable the COMP2 EXTI line rising edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP2) | |||
/** | |||
* @brief Disable the COMP2 EXTI line rising edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP2) | |||
/** | |||
* @brief Enable the COMP2 EXTI line falling edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP2) | |||
/** | |||
* @brief Disable the COMP2 EXTI line falling edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP2) | |||
/** | |||
* @brief Enable the COMP2 EXTI line rising & falling edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ | |||
LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP2); \ | |||
LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP2); \ | |||
} while(0) | |||
/** | |||
* @brief Disable the COMP2 EXTI line rising & falling edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ | |||
LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP2); \ | |||
LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP2); \ | |||
} while(0) | |||
/** | |||
* @brief Enable the COMP2 EXTI line in interrupt mode. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP2_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP2) | |||
/** | |||
* @brief Disable the COMP2 EXTI line in interrupt mode. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP2_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP2) | |||
/** | |||
* @brief Generate a software interrupt on the COMP2 EXTI line. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP2) | |||
/** | |||
* @brief Enable the COMP2 EXTI line in event mode. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP2) | |||
/** | |||
* @brief Disable the COMP2 EXTI line in event mode. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP2) | |||
/** | |||
* @brief Check whether the COMP2 EXTI line flag is set. | |||
* @retval RESET or SET | |||
*/ | |||
#define __HAL_COMP_COMP2_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP2) | |||
/** | |||
* @brief Clear the COMP2 EXTI flag. | |||
* @retval None | |||
*/ | |||
#define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP2) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/** @defgroup COMP_Private_Constants COMP Private Constants | |||
* @{ | |||
*/ | |||
/** @defgroup COMP_ExtiLine COMP EXTI Lines | |||
* @{ | |||
*/ | |||
#define COMP_EXTI_LINE_COMP1 (LL_EXTI_LINE_20) /*!< EXTI line 20 connected to COMP1 output */ | |||
#define COMP_EXTI_LINE_COMP2 (LL_EXTI_LINE_21) /*!< EXTI line 21 connected to COMP2 output */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_ExtiLine COMP EXTI Lines | |||
* @{ | |||
*/ | |||
#define COMP_EXTI_IT (0x00000001UL) /*!< EXTI line event with interruption */ | |||
#define COMP_EXTI_EVENT (0x00000002UL) /*!< EXTI line event only (without interruption) */ | |||
#define COMP_EXTI_RISING (0x00000010UL) /*!< EXTI line event on rising edge */ | |||
#define COMP_EXTI_FALLING (0x00000020UL) /*!< EXTI line event on falling edge */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup COMP_Private_Macros COMP Private Macros | |||
* @{ | |||
*/ | |||
/** @defgroup COMP_GET_EXTI_LINE COMP private macros to get EXTI line associated with comparators | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Get the specified EXTI line for a comparator instance. | |||
* @param __INSTANCE__ specifies the COMP instance. | |||
* @retval value of @ref COMP_ExtiLine | |||
*/ | |||
#define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 \ | |||
: COMP_EXTI_LINE_COMP2) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_IS_COMP_Definitions COMP private macros to check input parameters | |||
* @{ | |||
*/ | |||
#define IS_COMP_WINDOWMODE(__WINDOWMODE__) (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE) || \ | |||
((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON) ) | |||
#define IS_COMP_POWERMODE(__POWERMODE__) (((__POWERMODE__) == COMP_POWERMODE_HIGHSPEED) || \ | |||
((__POWERMODE__) == COMP_POWERMODE_MEDIUMSPEED) || \ | |||
((__POWERMODE__) == COMP_POWERMODE_ULTRALOWPOWER) ) | |||
#define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \ | |||
((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \ | |||
((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO3)) | |||
/* Note: On this STM32 serie, comparator input minus parameters are */ | |||
/* the same on all COMP instances. */ | |||
/* However, comparator instance kept as macro parameter for */ | |||
/* compatibility with other STM32 families. */ | |||
#define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \ | |||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \ | |||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \ | |||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \ | |||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \ | |||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2) || \ | |||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO3) || \ | |||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO4) || \ | |||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO5)) | |||
#define IS_COMP_HYSTERESIS(__HYSTERESIS__) (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE) || \ | |||
((__HYSTERESIS__) == COMP_HYSTERESIS_LOW) || \ | |||
((__HYSTERESIS__) == COMP_HYSTERESIS_MEDIUM) || \ | |||
((__HYSTERESIS__) == COMP_HYSTERESIS_HIGH)) | |||
#define IS_COMP_OUTPUTPOL(__POL__) (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \ | |||
((__POL__) == COMP_OUTPUTPOL_INVERTED)) | |||
#define IS_COMP_BLANKINGSRCE(__OUTPUT_BLANKING_SOURCE__) \ | |||
( ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) \ | |||
|| ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5) \ | |||
|| ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3) \ | |||
) | |||
/* Note: Output blanking source common to all COMP instances */ | |||
/* Macro kept for compatibility with other STM32 series */ | |||
#define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__) \ | |||
(IS_COMP_BLANKINGSRCE(__OUTPUT_BLANKING_SOURCE__)) | |||
#define IS_COMP_TRIGGERMODE(__MODE__) (((__MODE__) == COMP_TRIGGERMODE_NONE) || \ | |||
((__MODE__) == COMP_TRIGGERMODE_IT_RISING) || \ | |||
((__MODE__) == COMP_TRIGGERMODE_IT_FALLING) || \ | |||
((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING) || \ | |||
((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING) || \ | |||
((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING) || \ | |||
((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING)) | |||
#define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW) || \ | |||
((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH)) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup COMP_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup COMP_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions **********************************/ | |||
HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp); | |||
HAL_StatusTypeDef HAL_COMP_DeInit(COMP_HandleTypeDef *hcomp); | |||
void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp); | |||
void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp); | |||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) | |||
/* Callbacks Register/UnRegister functions ***********************************/ | |||
HAL_StatusTypeDef HAL_COMP_RegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID, | |||
pCOMP_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID); | |||
#endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
/** @addtogroup COMP_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp); | |||
HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp); | |||
void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp); | |||
/** | |||
* @} | |||
*/ | |||
/* Peripheral Control functions ************************************************/ | |||
/** @addtogroup COMP_Exported_Functions_Group3 | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp); | |||
uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp); | |||
/* Callback in interrupt mode */ | |||
void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp); | |||
/** | |||
* @} | |||
*/ | |||
/* Peripheral State functions **************************************************/ | |||
/** @addtogroup COMP_Exported_Functions_Group4 | |||
* @{ | |||
*/ | |||
HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp); | |||
uint32_t HAL_COMP_GetError(COMP_HandleTypeDef *hcomp); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_COMP_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,353 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_conf.h | |||
* @author MCD Application Team | |||
* @brief HAL configuration file. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_CONF_H | |||
#define STM32WBxx_HAL_CONF_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/* ########################## Module Selection ############################## */ | |||
/** | |||
* @brief This is the list of modules to be used in the HAL driver | |||
*/ | |||
#define HAL_MODULE_ENABLED | |||
#define HAL_ADC_MODULE_ENABLED | |||
#define HAL_COMP_MODULE_ENABLED | |||
#define HAL_CORTEX_MODULE_ENABLED | |||
#define HAL_CRC_MODULE_ENABLED | |||
#define HAL_CRYP_MODULE_ENABLED | |||
#define HAL_DMA_MODULE_ENABLED | |||
#define HAL_EXTI_MODULE_ENABLED | |||
#define HAL_FLASH_MODULE_ENABLED | |||
#define HAL_GPIO_MODULE_ENABLED | |||
#define HAL_HSEM_MODULE_ENABLED | |||
#define HAL_I2C_MODULE_ENABLED | |||
#define HAL_IPCC_MODULE_ENABLED | |||
#define HAL_IRDA_MODULE_ENABLED | |||
#define HAL_IWDG_MODULE_ENABLED | |||
#define HAL_LCD_MODULE_ENABLED | |||
#define HAL_LPTIM_MODULE_ENABLED | |||
#define HAL_PCD_MODULE_ENABLED | |||
#define HAL_PKA_MODULE_ENABLED | |||
#define HAL_PWR_MODULE_ENABLED | |||
#define HAL_QSPI_MODULE_ENABLED | |||
#define HAL_RCC_MODULE_ENABLED | |||
#define HAL_RNG_MODULE_ENABLED | |||
#define HAL_RTC_MODULE_ENABLED | |||
#define HAL_SAI_MODULE_ENABLED | |||
#define HAL_SMARTCARD_MODULE_ENABLED | |||
#define HAL_SMBUS_MODULE_ENABLED | |||
#define HAL_SPI_MODULE_ENABLED | |||
#define HAL_TIM_MODULE_ENABLED | |||
#define HAL_TSC_MODULE_ENABLED | |||
#define HAL_UART_MODULE_ENABLED | |||
#define HAL_USART_MODULE_ENABLED | |||
#define HAL_WWDG_MODULE_ENABLED | |||
#define USE_HAL_ADC_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_COMP_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_CRYP_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_I2C_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_PCD_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_PKA_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_QSPI_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_RNG_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_RTC_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_SAI_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_SPI_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_TIM_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_TSC_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_UART_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_USART_REGISTER_CALLBACKS 0u | |||
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0u | |||
/* ########################## Oscillator Values adaptation ####################*/ | |||
/** | |||
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application. | |||
* This value is used by the RCC HAL module to compute the system frequency | |||
* (when HSE is used as system clock source, directly or through the PLL). | |||
*/ | |||
#if !defined (HSE_VALUE) | |||
#define HSE_VALUE (32000000UL) /*!< Value of the External oscillator in Hz */ | |||
#endif /* HSE_VALUE */ | |||
#if !defined (HSE_STARTUP_TIMEOUT) | |||
#define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ | |||
#endif /* HSE_STARTUP_TIMEOUT */ | |||
/** | |||
* @brief Internal Multiple Speed oscillator (MSI) default value. | |||
* This value is the default MSI range value after Reset. | |||
*/ | |||
#if !defined (MSI_VALUE) | |||
#define MSI_VALUE (4000000UL) /*!< Value of the Internal oscillator in Hz*/ | |||
#endif /* MSI_VALUE */ | |||
/** | |||
* @brief Internal High Speed oscillator (HSI) value. | |||
* This value is used by the RCC HAL module to compute the system frequency | |||
* (when HSI is used as system clock source, directly or through the PLL). | |||
*/ | |||
#if !defined (HSI_VALUE) | |||
#define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ | |||
#endif /* HSI_VALUE */ | |||
/** | |||
* @brief Internal Low Speed oscillator (LSI1) value. | |||
*/ | |||
#if !defined (LSI1_VALUE) | |||
#define LSI1_VALUE (32000UL) /*!< LSI1 Typical Value in Hz*/ | |||
#endif /* LSI1_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz | |||
The real value may vary depending on the variations | |||
in voltage and temperature.*/ | |||
/** | |||
* @brief Internal Low Speed oscillator (LSI2) value. | |||
*/ | |||
#if !defined (LSI2_VALUE) | |||
#define LSI2_VALUE (32000UL) /*!< LSI2 Typical Value in Hz*/ | |||
#endif /* LSI2_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz | |||
The real value may vary depending on the variations | |||
in voltage and temperature.*/ | |||
/** | |||
* @brief External Low Speed oscillator (LSE) value. | |||
* This value is used by the UART, RTC HAL module to compute the system frequency | |||
*/ | |||
#if !defined (LSE_VALUE) | |||
#define LSE_VALUE (32768UL) /*!< Value of the External oscillator in Hz*/ | |||
#endif /* LSE_VALUE */ | |||
/** | |||
* @brief Internal Multiple Speed oscillator (HSI48) default value. | |||
* This value is the default HSI48 range value after Reset. | |||
*/ | |||
#if !defined (HSI48_VALUE) | |||
#define HSI48_VALUE (48000000UL) /*!< Value of the Internal oscillator in Hz*/ | |||
#endif /* HSI48_VALUE */ | |||
#if !defined (LSE_STARTUP_TIMEOUT) | |||
#define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ | |||
#endif /* LSE_STARTUP_TIMEOUT */ | |||
/** | |||
* @brief External clock source for SAI1 peripheral | |||
* This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source | |||
* frequency. | |||
*/ | |||
#if !defined (EXTERNAL_SAI1_CLOCK_VALUE) | |||
#define EXTERNAL_SAI1_CLOCK_VALUE (48000UL) /*!< Value of the SAI1 External clock source in Hz*/ | |||
#endif /* EXTERNAL_SAI1_CLOCK_VALUE */ | |||
/* Tip: To avoid modifying this file each time you need to use different HSE, | |||
=== you can define the HSE value in your toolchain compiler preprocessor. */ | |||
/* ########################### System Configuration ######################### */ | |||
/** | |||
* @brief This is the HAL system configuration section | |||
*/ | |||
#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ | |||
#define TICK_INT_PRIORITY ((1UL<<__NVIC_PRIO_BITS) - 1UL) /*!< tick interrupt priority (lowest by default) */ | |||
#define USE_RTOS 0 | |||
#define PREFETCH_ENABLE 0 | |||
#define INSTRUCTION_CACHE_ENABLE 1 | |||
#define DATA_CACHE_ENABLE 1 | |||
/* ########################## Assert Selection ############################## */ | |||
/** | |||
* @brief Uncomment the line below to expanse the "assert_param" macro in the | |||
* HAL drivers code | |||
*/ | |||
/* #define USE_FULL_ASSERT 1 */ | |||
/* ################## SPI peripheral configuration ########################## */ | |||
/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver | |||
* Activated: CRC code is present inside driver | |||
* Deactivated: CRC code cleaned from driver | |||
*/ | |||
#define USE_SPI_CRC 1U | |||
/* Includes ------------------------------------------------------------------*/ | |||
/** | |||
* @brief Include module's header file | |||
*/ | |||
#ifdef HAL_DMA_MODULE_ENABLED | |||
#include "stm32wbxx_hal_dma.h" | |||
#endif /* HAL_DMA_MODULE_ENABLED */ | |||
#ifdef HAL_ADC_MODULE_ENABLED | |||
#include "stm32wbxx_hal_adc.h" | |||
#endif /* HAL_ADC_MODULE_ENABLED */ | |||
#ifdef HAL_COMP_MODULE_ENABLED | |||
#include "stm32wbxx_hal_comp.h" | |||
#endif /* HAL_COMP_MODULE_ENABLED */ | |||
#ifdef HAL_CORTEX_MODULE_ENABLED | |||
#include "stm32wbxx_hal_cortex.h" | |||
#endif /* HAL_CORTEX_MODULE_ENABLED */ | |||
#ifdef HAL_CRC_MODULE_ENABLED | |||
#include "stm32wbxx_hal_crc.h" | |||
#endif /* HAL_CRC_MODULE_ENABLED */ | |||
#ifdef HAL_CRYP_MODULE_ENABLED | |||
#include "stm32wbxx_hal_cryp.h" | |||
#endif /* HAL_CRYP_MODULE_ENABLED */ | |||
#ifdef HAL_EXTI_MODULE_ENABLED | |||
#include "stm32wbxx_hal_exti.h" | |||
#endif /* HAL_EXTI_MODULE_ENABLED */ | |||
#ifdef HAL_FLASH_MODULE_ENABLED | |||
#include "stm32wbxx_hal_flash.h" | |||
#endif /* HAL_FLASH_MODULE_ENABLED */ | |||
#ifdef HAL_GPIO_MODULE_ENABLED | |||
#include "stm32wbxx_hal_gpio.h" | |||
#endif /* HAL_GPIO_MODULE_ENABLED */ | |||
#ifdef HAL_HSEM_MODULE_ENABLED | |||
#include "stm32wbxx_hal_hsem.h" | |||
#endif /* HAL_HSEM_MODULE_ENABLED */ | |||
#ifdef HAL_I2C_MODULE_ENABLED | |||
#include "stm32wbxx_hal_i2c.h" | |||
#endif /* HAL_I2C_MODULE_ENABLED */ | |||
#ifdef HAL_IPCC_MODULE_ENABLED | |||
#include "stm32wbxx_hal_ipcc.h" | |||
#endif /* HAL_IPCC_MODULE_ENABLED */ | |||
#ifdef HAL_IRDA_MODULE_ENABLED | |||
#include "stm32wbxx_hal_irda.h" | |||
#endif /* HAL_IRDA_MODULE_ENABLED */ | |||
#ifdef HAL_IWDG_MODULE_ENABLED | |||
#include "stm32wbxx_hal_iwdg.h" | |||
#endif /* HAL_IWDG_MODULE_ENABLED */ | |||
#ifdef HAL_LCD_MODULE_ENABLED | |||
#include "stm32wbxx_hal_lcd.h" | |||
#endif /* HAL_LCD_MODULE_ENABLED */ | |||
#ifdef HAL_LPTIM_MODULE_ENABLED | |||
#include "stm32wbxx_hal_lptim.h" | |||
#endif /* HAL_LPTIM_MODULE_ENABLED */ | |||
#ifdef HAL_PCD_MODULE_ENABLED | |||
#include "stm32wbxx_hal_pcd.h" | |||
#endif /* HAL_PCD_MODULE_ENABLED */ | |||
#ifdef HAL_PKA_MODULE_ENABLED | |||
#include "stm32wbxx_hal_pka.h" | |||
#endif /* HAL_PKA_MODULE_ENABLED */ | |||
#ifdef HAL_PWR_MODULE_ENABLED | |||
#include "stm32wbxx_hal_pwr.h" | |||
#endif /* HAL_PWR_MODULE_ENABLED */ | |||
#ifdef HAL_QSPI_MODULE_ENABLED | |||
#include "stm32wbxx_hal_qspi.h" | |||
#endif /* HAL_QSPI_MODULE_ENABLED */ | |||
#ifdef HAL_RCC_MODULE_ENABLED | |||
#include "stm32wbxx_hal_rcc.h" | |||
#endif /* HAL_RCC_MODULE_ENABLED */ | |||
#ifdef HAL_RNG_MODULE_ENABLED | |||
#include "stm32wbxx_hal_rng.h" | |||
#endif /* HAL_RNG_MODULE_ENABLED */ | |||
#ifdef HAL_RTC_MODULE_ENABLED | |||
#include "stm32wbxx_hal_rtc.h" | |||
#endif /* HAL_RTC_MODULE_ENABLED */ | |||
#ifdef HAL_SAI_MODULE_ENABLED | |||
#include "stm32wbxx_hal_sai.h" | |||
#endif /* HAL_SAI_MODULE_ENABLED */ | |||
#ifdef HAL_SMARTCARD_MODULE_ENABLED | |||
#include "stm32wbxx_hal_smartcard.h" | |||
#endif /* HAL_SMARTCARD_MODULE_ENABLED */ | |||
#ifdef HAL_SMBUS_MODULE_ENABLED | |||
#include "stm32wbxx_hal_smbus.h" | |||
#endif /* HAL_SMBUS_MODULE_ENABLED */ | |||
#ifdef HAL_SPI_MODULE_ENABLED | |||
#include "stm32wbxx_hal_spi.h" | |||
#endif /* HAL_SPI_MODULE_ENABLED */ | |||
#ifdef HAL_TIM_MODULE_ENABLED | |||
#include "stm32wbxx_hal_tim.h" | |||
#endif /* HAL_TIM_MODULE_ENABLED */ | |||
#ifdef HAL_TSC_MODULE_ENABLED | |||
#include "stm32wbxx_hal_tsc.h" | |||
#endif /* HAL_TSC_MODULE_ENABLED */ | |||
#ifdef HAL_UART_MODULE_ENABLED | |||
#include "stm32wbxx_hal_uart.h" | |||
#endif /* HAL_UART_MODULE_ENABLED */ | |||
#ifdef HAL_USART_MODULE_ENABLED | |||
#include "stm32wbxx_hal_usart.h" | |||
#endif /* HAL_USART_MODULE_ENABLED */ | |||
#ifdef HAL_WWDG_MODULE_ENABLED | |||
#include "stm32wbxx_hal_wwdg.h" | |||
#endif /* HAL_WWDG_MODULE_ENABLED */ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
#ifdef USE_FULL_ASSERT | |||
/** | |||
* @brief The assert_param macro is used for function's parameters check. | |||
* @param expr If expr is false, it calls assert_failed function | |||
* which reports the name of the source file and the source | |||
* line number of the call that failed. | |||
* If expr is true, it returns no value. | |||
* @retval None | |||
*/ | |||
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) | |||
/* Exported functions ------------------------------------------------------- */ | |||
void assert_failed(uint8_t* file, uint32_t line); | |||
#else | |||
#define assert_param(expr) ((void)0U) | |||
#endif /* USE_FULL_ASSERT */ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_CONF_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,420 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_cortex.h | |||
* @author MCD Application Team | |||
* @brief Header file of CORTEX HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_CORTEX_H | |||
#define STM32WBxx_HAL_CORTEX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
#include "stm32wb55xx.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup CORTEX CORTEX | |||
* @brief CORTEX HAL module driver | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup CORTEX_Exported_Types CORTEX Exported Types | |||
* @{ | |||
*/ | |||
#if (__MPU_PRESENT == 1) | |||
/** @defgroup CORTEX_MPU_Region_Initialization_Structure_definition MPU Region Initialization Structure Definition | |||
* @brief MPU Region initialization structure | |||
* @{ | |||
*/ | |||
typedef struct | |||
{ | |||
uint8_t Enable; /*!< Specifies the status of the region. | |||
This parameter can be a value of @ref CORTEX_MPU_Region_Enable */ | |||
uint8_t Number; /*!< Specifies the number of the region to protect. | |||
This parameter can be a value of @ref CORTEX_MPU_Region_Number */ | |||
uint32_t BaseAddress; /*!< Specifies the base address of the region to protect. | |||
*/ | |||
uint8_t Size; /*!< Specifies the size of the region to protect. | |||
This parameter can be a value of @ref CORTEX_MPU_Region_Size */ | |||
uint8_t SubRegionDisable; /*!< Specifies the number of the subregion protection to disable. | |||
This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF */ | |||
uint8_t TypeExtField; /*!< Specifies the TEX field level. | |||
This parameter can be a value of @ref CORTEX_MPU_TEX_Levels */ | |||
uint8_t AccessPermission; /*!< Specifies the region access permission type. | |||
This parameter can be a value of @ref CORTEX_MPU_Region_Permission_Attributes */ | |||
uint8_t DisableExec; /*!< Specifies the instruction access status. | |||
This parameter can be a value of @ref CORTEX_MPU_Instruction_Access */ | |||
uint8_t IsShareable; /*!< Specifies the shareability status of the protected region. | |||
This parameter can be a value of @ref CORTEX_MPU_Access_Shareable */ | |||
uint8_t IsCacheable; /*!< Specifies the cacheable status of the region protected. | |||
This parameter can be a value of @ref CORTEX_MPU_Access_Cacheable */ | |||
uint8_t IsBufferable; /*!< Specifies the bufferable status of the protected region. | |||
This parameter can be a value of @ref CORTEX_MPU_Access_Bufferable */ | |||
}MPU_Region_InitTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
#endif /* __MPU_PRESENT */ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup CORTEX_Exported_Constants CORTEX Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup CORTEX_Preemption_Priority_Group CORTEX Preemption Priority Group | |||
* @{ | |||
*/ | |||
#define NVIC_PRIORITYGROUP_0 (0x00000007U) /*!< 0 bit for pre-emption priority, | |||
4 bits for subpriority */ | |||
#define NVIC_PRIORITYGROUP_1 (0x00000006U) /*!< 1 bit for pre-emption priority, | |||
3 bits for subpriority */ | |||
#define NVIC_PRIORITYGROUP_2 (0x00000005U) /*!< 2 bits for pre-emption priority, | |||
2 bits for subpriority */ | |||
#define NVIC_PRIORITYGROUP_3 (0x00000004U) /*!< 3 bits for pre-emption priority, | |||
1 bit for subpriority */ | |||
#define NVIC_PRIORITYGROUP_4 (0x00000003U) /*!< 4 bits for pre-emption priority, | |||
0 bit for subpriority */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_SysTick_clock_source CORTEX SysTick clock source | |||
* @{ | |||
*/ | |||
#define SYSTICK_CLKSOURCE_HCLK_DIV8 0x00000000U | |||
#define SYSTICK_CLKSOURCE_HCLK 0x00000004U | |||
/** | |||
* @} | |||
*/ | |||
#if (__MPU_PRESENT == 1) | |||
/** @defgroup CORTEX_MPU_HFNMI_PRIVDEF_Control CORTEX MPU HFNMI and PRIVILEGED Access control | |||
* @{ | |||
*/ | |||
#define MPU_HFNMI_PRIVDEF_NONE 0x00000000U | |||
#define MPU_HARDFAULT_NMI (MPU_CTRL_HFNMIENA_Msk) | |||
#define MPU_PRIVILEGED_DEFAULT (MPU_CTRL_PRIVDEFENA_Msk) | |||
#define MPU_HFNMI_PRIVDEF (MPU_CTRL_HFNMIENA_Msk | MPU_CTRL_PRIVDEFENA_Msk) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_MPU_Region_Enable CORTEX MPU Region Enable | |||
* @{ | |||
*/ | |||
#define MPU_REGION_ENABLE ((uint8_t)0x01) | |||
#define MPU_REGION_DISABLE ((uint8_t)0x00) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_MPU_Instruction_Access CORTEX MPU Instruction Access | |||
* @{ | |||
*/ | |||
#define MPU_INSTRUCTION_ACCESS_ENABLE ((uint8_t)0x00) | |||
#define MPU_INSTRUCTION_ACCESS_DISABLE ((uint8_t)0x01) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_MPU_Access_Shareable CORTEX MPU Instruction Access Shareable | |||
* @{ | |||
*/ | |||
#define MPU_ACCESS_SHAREABLE ((uint8_t)0x01) | |||
#define MPU_ACCESS_NOT_SHAREABLE ((uint8_t)0x00) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_MPU_Access_Cacheable CORTEX MPU Instruction Access Cacheable | |||
* @{ | |||
*/ | |||
#define MPU_ACCESS_CACHEABLE ((uint8_t)0x01) | |||
#define MPU_ACCESS_NOT_CACHEABLE ((uint8_t)0x00) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_MPU_Access_Bufferable CORTEX MPU Instruction Access Bufferable | |||
* @{ | |||
*/ | |||
#define MPU_ACCESS_BUFFERABLE ((uint8_t)0x01) | |||
#define MPU_ACCESS_NOT_BUFFERABLE ((uint8_t)0x00) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_MPU_TEX_Levels CORTEX MPU TEX Levels | |||
* @{ | |||
*/ | |||
#define MPU_TEX_LEVEL0 ((uint8_t)0x00) | |||
#define MPU_TEX_LEVEL1 ((uint8_t)0x01) | |||
#define MPU_TEX_LEVEL2 ((uint8_t)0x02) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_MPU_Region_Size CORTEX MPU Region Size | |||
* @{ | |||
*/ | |||
#define MPU_REGION_SIZE_32B ((uint8_t)0x04) | |||
#define MPU_REGION_SIZE_64B ((uint8_t)0x05) | |||
#define MPU_REGION_SIZE_128B ((uint8_t)0x06) | |||
#define MPU_REGION_SIZE_256B ((uint8_t)0x07) | |||
#define MPU_REGION_SIZE_512B ((uint8_t)0x08) | |||
#define MPU_REGION_SIZE_1KB ((uint8_t)0x09) | |||
#define MPU_REGION_SIZE_2KB ((uint8_t)0x0A) | |||
#define MPU_REGION_SIZE_4KB ((uint8_t)0x0B) | |||
#define MPU_REGION_SIZE_8KB ((uint8_t)0x0C) | |||
#define MPU_REGION_SIZE_16KB ((uint8_t)0x0D) | |||
#define MPU_REGION_SIZE_32KB ((uint8_t)0x0E) | |||
#define MPU_REGION_SIZE_64KB ((uint8_t)0x0F) | |||
#define MPU_REGION_SIZE_128KB ((uint8_t)0x10) | |||
#define MPU_REGION_SIZE_256KB ((uint8_t)0x11) | |||
#define MPU_REGION_SIZE_512KB ((uint8_t)0x12) | |||
#define MPU_REGION_SIZE_1MB ((uint8_t)0x13) | |||
#define MPU_REGION_SIZE_2MB ((uint8_t)0x14) | |||
#define MPU_REGION_SIZE_4MB ((uint8_t)0x15) | |||
#define MPU_REGION_SIZE_8MB ((uint8_t)0x16) | |||
#define MPU_REGION_SIZE_16MB ((uint8_t)0x17) | |||
#define MPU_REGION_SIZE_32MB ((uint8_t)0x18) | |||
#define MPU_REGION_SIZE_64MB ((uint8_t)0x19) | |||
#define MPU_REGION_SIZE_128MB ((uint8_t)0x1A) | |||
#define MPU_REGION_SIZE_256MB ((uint8_t)0x1B) | |||
#define MPU_REGION_SIZE_512MB ((uint8_t)0x1C) | |||
#define MPU_REGION_SIZE_1GB ((uint8_t)0x1D) | |||
#define MPU_REGION_SIZE_2GB ((uint8_t)0x1E) | |||
#define MPU_REGION_SIZE_4GB ((uint8_t)0x1F) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_MPU_Region_Permission_Attributes CORTEX MPU Region Permission Attributes | |||
* @{ | |||
*/ | |||
#define MPU_REGION_NO_ACCESS ((uint8_t)0x00) | |||
#define MPU_REGION_PRIV_RW ((uint8_t)0x01) | |||
#define MPU_REGION_PRIV_RW_URO ((uint8_t)0x02) | |||
#define MPU_REGION_FULL_ACCESS ((uint8_t)0x03) | |||
#define MPU_REGION_PRIV_RO ((uint8_t)0x05) | |||
#define MPU_REGION_PRIV_RO_URO ((uint8_t)0x06) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_MPU_Region_Number CORTEX MPU Region Number | |||
* @{ | |||
*/ | |||
#define MPU_REGION_NUMBER0 ((uint8_t)0x00) | |||
#define MPU_REGION_NUMBER1 ((uint8_t)0x01) | |||
#define MPU_REGION_NUMBER2 ((uint8_t)0x02) | |||
#define MPU_REGION_NUMBER3 ((uint8_t)0x03) | |||
#define MPU_REGION_NUMBER4 ((uint8_t)0x04) | |||
#define MPU_REGION_NUMBER5 ((uint8_t)0x05) | |||
#define MPU_REGION_NUMBER6 ((uint8_t)0x06) | |||
#define MPU_REGION_NUMBER7 ((uint8_t)0x07) | |||
/** | |||
* @} | |||
*/ | |||
#endif /* __MPU_PRESENT */ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup CORTEX_Exported_Macros CORTEX Exported Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup CORTEX_Exported_Functions CORTEX Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup CORTEX_Exported_Functions_Group1 Initialization and Configuration functions | |||
* @brief Initialization and Configuration functions | |||
* @{ | |||
*/ | |||
/* Initialization and Configuration functions *****************************/ | |||
void HAL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup); | |||
void HAL_NVIC_SetPriority(IRQn_Type IRQn,uint32_t PreemptPriority, uint32_t SubPriority); | |||
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn); | |||
void HAL_NVIC_DisableIRQ(IRQn_Type IRQn); | |||
void HAL_NVIC_SystemReset(void); | |||
uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_Exported_Functions_Group2 Peripheral Control functions | |||
* @brief Cortex control functions | |||
* @{ | |||
*/ | |||
/* Peripheral Control functions *************************************************/ | |||
void HAL_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority); | |||
uint32_t HAL_NVIC_GetPriorityGrouping(void); | |||
uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn); | |||
void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn); | |||
void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn); | |||
void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource); | |||
void HAL_SYSTICK_IRQHandler(void); | |||
void HAL_SYSTICK_Callback(void); | |||
#if (__MPU_PRESENT == 1U) | |||
void HAL_MPU_Enable(uint32_t MPU_Control); | |||
void HAL_MPU_Disable(void); | |||
void HAL_MPU_ConfigRegion(MPU_Region_InitTypeDef *MPU_Init); | |||
#endif /* __MPU_PRESENT */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup CORTEX_Private_Macros CORTEX Private Macros | |||
* @{ | |||
*/ | |||
#define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PRIORITYGROUP_0) || \ | |||
((GROUP) == NVIC_PRIORITYGROUP_1) || \ | |||
((GROUP) == NVIC_PRIORITYGROUP_2) || \ | |||
((GROUP) == NVIC_PRIORITYGROUP_3) || \ | |||
((GROUP) == NVIC_PRIORITYGROUP_4)) | |||
#define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10U) | |||
#define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10U) | |||
#define IS_NVIC_DEVICE_IRQ(IRQ) ((IRQ) > SysTick_IRQn) | |||
#define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SYSTICK_CLKSOURCE_HCLK) || \ | |||
((SOURCE) == SYSTICK_CLKSOURCE_HCLK_DIV8)) | |||
#if (__MPU_PRESENT == 1) | |||
#define IS_MPU_REGION_ENABLE(STATE) (((STATE) == MPU_REGION_ENABLE) || \ | |||
((STATE) == MPU_REGION_DISABLE)) | |||
#define IS_MPU_INSTRUCTION_ACCESS(STATE) (((STATE) == MPU_INSTRUCTION_ACCESS_ENABLE) || \ | |||
((STATE) == MPU_INSTRUCTION_ACCESS_DISABLE)) | |||
#define IS_MPU_ACCESS_SHAREABLE(STATE) (((STATE) == MPU_ACCESS_SHAREABLE) || \ | |||
((STATE) == MPU_ACCESS_NOT_SHAREABLE)) | |||
#define IS_MPU_ACCESS_CACHEABLE(STATE) (((STATE) == MPU_ACCESS_CACHEABLE) || \ | |||
((STATE) == MPU_ACCESS_NOT_CACHEABLE)) | |||
#define IS_MPU_ACCESS_BUFFERABLE(STATE) (((STATE) == MPU_ACCESS_BUFFERABLE) || \ | |||
((STATE) == MPU_ACCESS_NOT_BUFFERABLE)) | |||
#define IS_MPU_TEX_LEVEL(TYPE) (((TYPE) == MPU_TEX_LEVEL0) || \ | |||
((TYPE) == MPU_TEX_LEVEL1) || \ | |||
((TYPE) == MPU_TEX_LEVEL2)) | |||
#define IS_MPU_REGION_PERMISSION_ATTRIBUTE(TYPE) (((TYPE) == MPU_REGION_NO_ACCESS) || \ | |||
((TYPE) == MPU_REGION_PRIV_RW) || \ | |||
((TYPE) == MPU_REGION_PRIV_RW_URO) || \ | |||
((TYPE) == MPU_REGION_FULL_ACCESS) || \ | |||
((TYPE) == MPU_REGION_PRIV_RO) || \ | |||
((TYPE) == MPU_REGION_PRIV_RO_URO)) | |||
#define IS_MPU_REGION_NUMBER(NUMBER) (((NUMBER) == MPU_REGION_NUMBER0) || \ | |||
((NUMBER) == MPU_REGION_NUMBER1) || \ | |||
((NUMBER) == MPU_REGION_NUMBER2) || \ | |||
((NUMBER) == MPU_REGION_NUMBER3) || \ | |||
((NUMBER) == MPU_REGION_NUMBER4) || \ | |||
((NUMBER) == MPU_REGION_NUMBER5) || \ | |||
((NUMBER) == MPU_REGION_NUMBER6) || \ | |||
((NUMBER) == MPU_REGION_NUMBER7)) | |||
#define IS_MPU_REGION_SIZE(SIZE) (((SIZE) == MPU_REGION_SIZE_32B) || \ | |||
((SIZE) == MPU_REGION_SIZE_64B) || \ | |||
((SIZE) == MPU_REGION_SIZE_128B) || \ | |||
((SIZE) == MPU_REGION_SIZE_256B) || \ | |||
((SIZE) == MPU_REGION_SIZE_512B) || \ | |||
((SIZE) == MPU_REGION_SIZE_1KB) || \ | |||
((SIZE) == MPU_REGION_SIZE_2KB) || \ | |||
((SIZE) == MPU_REGION_SIZE_4KB) || \ | |||
((SIZE) == MPU_REGION_SIZE_8KB) || \ | |||
((SIZE) == MPU_REGION_SIZE_16KB) || \ | |||
((SIZE) == MPU_REGION_SIZE_32KB) || \ | |||
((SIZE) == MPU_REGION_SIZE_64KB) || \ | |||
((SIZE) == MPU_REGION_SIZE_128KB) || \ | |||
((SIZE) == MPU_REGION_SIZE_256KB) || \ | |||
((SIZE) == MPU_REGION_SIZE_512KB) || \ | |||
((SIZE) == MPU_REGION_SIZE_1MB) || \ | |||
((SIZE) == MPU_REGION_SIZE_2MB) || \ | |||
((SIZE) == MPU_REGION_SIZE_4MB) || \ | |||
((SIZE) == MPU_REGION_SIZE_8MB) || \ | |||
((SIZE) == MPU_REGION_SIZE_16MB) || \ | |||
((SIZE) == MPU_REGION_SIZE_32MB) || \ | |||
((SIZE) == MPU_REGION_SIZE_64MB) || \ | |||
((SIZE) == MPU_REGION_SIZE_128MB) || \ | |||
((SIZE) == MPU_REGION_SIZE_256MB) || \ | |||
((SIZE) == MPU_REGION_SIZE_512MB) || \ | |||
((SIZE) == MPU_REGION_SIZE_1GB) || \ | |||
((SIZE) == MPU_REGION_SIZE_2GB) || \ | |||
((SIZE) == MPU_REGION_SIZE_4GB)) | |||
#define IS_MPU_SUB_REGION_DISABLE(SUBREGION) ((SUBREGION) < (uint16_t)0x00FFU) | |||
#endif /* __MPU_PRESENT */ | |||
/** | |||
* @} | |||
*/ | |||
/* Private functions ---------------------------------------------------------*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_CORTEX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
@@ -0,0 +1,344 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_crc.h | |||
* @author MCD Application Team | |||
* @brief Header file of CRC HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_CRC_H | |||
#define STM32WBxx_HAL_CRC_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup CRC | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup CRC_Exported_Types CRC Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief CRC HAL State Structure definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_CRC_STATE_RESET = 0x00U, /*!< CRC not yet initialized or disabled */ | |||
HAL_CRC_STATE_READY = 0x01U, /*!< CRC initialized and ready for use */ | |||
HAL_CRC_STATE_BUSY = 0x02U, /*!< CRC internal process is ongoing */ | |||
HAL_CRC_STATE_TIMEOUT = 0x03U, /*!< CRC timeout state */ | |||
HAL_CRC_STATE_ERROR = 0x04U /*!< CRC error state */ | |||
} HAL_CRC_StateTypeDef; | |||
/** | |||
* @brief CRC Init Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint8_t DefaultPolynomialUse; /*!< This parameter is a value of @ref CRC_Default_Polynomial and indicates if default polynomial is used. | |||
If set to DEFAULT_POLYNOMIAL_ENABLE, resort to default | |||
X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 +X^8 + X^7 + X^5 + X^4 + X^2+ X +1. | |||
In that case, there is no need to set GeneratingPolynomial field. | |||
If otherwise set to DEFAULT_POLYNOMIAL_DISABLE, GeneratingPolynomial and CRCLength fields must be set. */ | |||
uint8_t DefaultInitValueUse; /*!< This parameter is a value of @ref CRC_Default_InitValue_Use and indicates if default init value is used. | |||
If set to DEFAULT_INIT_VALUE_ENABLE, resort to default | |||
0xFFFFFFFF value. In that case, there is no need to set InitValue field. | |||
If otherwise set to DEFAULT_INIT_VALUE_DISABLE, InitValue field must be set. */ | |||
uint32_t GeneratingPolynomial; /*!< Set CRC generating polynomial as a 7, 8, 16 or 32-bit long value for a polynomial degree | |||
respectively equal to 7, 8, 16 or 32. This field is written in normal representation, | |||
e.g., for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65. | |||
No need to specify it if DefaultPolynomialUse is set to DEFAULT_POLYNOMIAL_ENABLE. */ | |||
uint32_t CRCLength; /*!< This parameter is a value of @ref CRC_Polynomial_Sizes and indicates CRC length. | |||
Value can be either one of | |||
@arg @ref CRC_POLYLENGTH_32B (32-bit CRC), | |||
@arg @ref CRC_POLYLENGTH_16B (16-bit CRC), | |||
@arg @ref CRC_POLYLENGTH_8B (8-bit CRC), | |||
@arg @ref CRC_POLYLENGTH_7B (7-bit CRC). */ | |||
uint32_t InitValue; /*!< Init value to initiate CRC computation. No need to specify it if DefaultInitValueUse | |||
is set to DEFAULT_INIT_VALUE_ENABLE. */ | |||
uint32_t InputDataInversionMode; /*!< This parameter is a value of @ref CRCEx_Input_Data_Inversion and specifies input data inversion mode. | |||
Can be either one of the following values | |||
@arg @ref CRC_INPUTDATA_INVERSION_NONE no input data inversion | |||
@arg @ref CRC_INPUTDATA_INVERSION_BYTE byte-wise inversion, 0x1A2B3C4D becomes 0x58D43CB2 | |||
@arg @ref CRC_INPUTDATA_INVERSION_HALFWORD halfword-wise inversion, 0x1A2B3C4D becomes 0xD458B23C | |||
@arg @ref CRC_INPUTDATA_INVERSION_WORD word-wise inversion, 0x1A2B3C4D becomes 0xB23CD458 */ | |||
uint32_t OutputDataInversionMode; /*!< This parameter is a value of @ref CRCEx_Output_Data_Inversion and specifies output data (i.e. CRC) inversion mode. | |||
Can be either | |||
@arg @ref CRC_OUTPUTDATA_INVERSION_DISABLE no CRC inversion, | |||
@arg @ref CRC_OUTPUTDATA_INVERSION_ENABLE CRC 0x11223344 is converted into 0x22CC4488 */ | |||
} CRC_InitTypeDef; | |||
/** | |||
* @brief CRC Handle Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
CRC_TypeDef *Instance; /*!< Register base address */ | |||
CRC_InitTypeDef Init; /*!< CRC configuration parameters */ | |||
HAL_LockTypeDef Lock; /*!< CRC Locking object */ | |||
__IO HAL_CRC_StateTypeDef State; /*!< CRC communication state */ | |||
uint32_t InputDataFormat; /*!< This parameter is a value of @ref CRC_Input_Buffer_Format and specifies input data format. | |||
Can be either | |||
@arg @ref CRC_INPUTDATA_FORMAT_BYTES input data is a stream of bytes (8-bit data) | |||
@arg @ref CRC_INPUTDATA_FORMAT_HALFWORDS input data is a stream of half-words (16-bit data) | |||
@arg @ref CRC_INPUTDATA_FORMAT_WORDS input data is a stream of words (32-bit data) | |||
Note that constant CRC_INPUT_FORMAT_UNDEFINED is defined but an initialization error | |||
must occur if InputBufferFormat is not one of the three values listed above */ | |||
} CRC_HandleTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup CRC_Exported_Constants CRC Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup CRC_Default_Polynomial_Value Default CRC generating polynomial | |||
* @{ | |||
*/ | |||
#define DEFAULT_CRC32_POLY 0x04C11DB7U /*!< X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 +X^8 + X^7 + X^5 + X^4 + X^2+ X +1 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_Default_InitValue Default CRC computation initialization value | |||
* @{ | |||
*/ | |||
#define DEFAULT_CRC_INITVALUE 0xFFFFFFFFU /*!< Initial CRC default value */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_Default_Polynomial Indicates whether or not default polynomial is used | |||
* @{ | |||
*/ | |||
#define DEFAULT_POLYNOMIAL_ENABLE ((uint8_t)0x00U) /*!< Enable default generating polynomial 0x04C11DB7 */ | |||
#define DEFAULT_POLYNOMIAL_DISABLE ((uint8_t)0x01U) /*!< Disable default generating polynomial 0x04C11DB7 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_Default_InitValue_Use Indicates whether or not default init value is used | |||
* @{ | |||
*/ | |||
#define DEFAULT_INIT_VALUE_ENABLE ((uint8_t)0x00U) /*!< Enable initial CRC default value */ | |||
#define DEFAULT_INIT_VALUE_DISABLE ((uint8_t)0x01U) /*!< Disable initial CRC default value */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_Polynomial_Sizes Polynomial sizes to configure the peripheral | |||
* @{ | |||
*/ | |||
#define CRC_POLYLENGTH_32B 0x00000000U /*!< Resort to a 32-bit long generating polynomial */ | |||
#define CRC_POLYLENGTH_16B CRC_CR_POLYSIZE_0 /*!< Resort to a 16-bit long generating polynomial */ | |||
#define CRC_POLYLENGTH_8B CRC_CR_POLYSIZE_1 /*!< Resort to a 8-bit long generating polynomial */ | |||
#define CRC_POLYLENGTH_7B CRC_CR_POLYSIZE /*!< Resort to a 7-bit long generating polynomial */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_Polynomial_Size_Definitions CRC polynomial possible sizes actual definitions | |||
* @{ | |||
*/ | |||
#define HAL_CRC_LENGTH_32B 32U /*!< 32-bit long CRC */ | |||
#define HAL_CRC_LENGTH_16B 16U /*!< 16-bit long CRC */ | |||
#define HAL_CRC_LENGTH_8B 8U /*!< 8-bit long CRC */ | |||
#define HAL_CRC_LENGTH_7B 7U /*!< 7-bit long CRC */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_Input_Buffer_Format Input Buffer Format | |||
* @{ | |||
*/ | |||
/* WARNING: CRC_INPUT_FORMAT_UNDEFINED is created for reference purposes but | |||
* an error is triggered in HAL_CRC_Init() if InputDataFormat field is set | |||
* to CRC_INPUT_FORMAT_UNDEFINED: the format MUST be defined by the user for | |||
* the CRC APIs to provide a correct result */ | |||
#define CRC_INPUTDATA_FORMAT_UNDEFINED 0x00000000U /*!< Undefined input data format */ | |||
#define CRC_INPUTDATA_FORMAT_BYTES 0x00000001U /*!< Input data in byte format */ | |||
#define CRC_INPUTDATA_FORMAT_HALFWORDS 0x00000002U /*!< Input data in half-word format */ | |||
#define CRC_INPUTDATA_FORMAT_WORDS 0x00000003U /*!< Input data in word format */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_Aliases CRC API aliases | |||
* @{ | |||
*/ | |||
#define HAL_CRC_Input_Data_Reverse HAL_CRCEx_Input_Data_Reverse /*!< Aliased to HAL_CRCEx_Input_Data_Reverse for inter STM32 series compatibility */ | |||
#define HAL_CRC_Output_Data_Reverse HAL_CRCEx_Output_Data_Reverse /*!< Aliased to HAL_CRCEx_Output_Data_Reverse for inter STM32 series compatibility */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup CRC_Exported_Macros CRC Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset CRC handle state. | |||
* @param __HANDLE__ CRC handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_CRC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRC_STATE_RESET) | |||
/** | |||
* @brief Reset CRC Data Register. | |||
* @param __HANDLE__ CRC handle | |||
* @retval None | |||
*/ | |||
#define __HAL_CRC_DR_RESET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_RESET) | |||
/** | |||
* @brief Set CRC INIT non-default value | |||
* @param __HANDLE__ CRC handle | |||
* @param __INIT__ 32-bit initial value | |||
* @retval None | |||
*/ | |||
#define __HAL_CRC_INITIALCRCVALUE_CONFIG(__HANDLE__, __INIT__) ((__HANDLE__)->Instance->INIT = (__INIT__)) | |||
/** | |||
* @brief Store data in the Independent Data (ID) register. | |||
* @param __HANDLE__ CRC handle | |||
* @param __VALUE__ Value to be stored in the ID register | |||
* @note Refer to the Reference Manual to get the authorized __VALUE__ length in bits | |||
* @retval None | |||
*/ | |||
#define __HAL_CRC_SET_IDR(__HANDLE__, __VALUE__) (WRITE_REG((__HANDLE__)->Instance->IDR, (__VALUE__))) | |||
/** | |||
* @brief Return the data stored in the Independent Data (ID) register. | |||
* @param __HANDLE__ CRC handle | |||
* @note Refer to the Reference Manual to get the authorized __VALUE__ length in bits | |||
* @retval Value of the ID register | |||
*/ | |||
#define __HAL_CRC_GET_IDR(__HANDLE__) (((__HANDLE__)->Instance->IDR) & CRC_IDR_IDR) | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros --------------------------------------------------------*/ | |||
/** @defgroup CRC_Private_Macros CRC Private Macros | |||
* @{ | |||
*/ | |||
#define IS_DEFAULT_POLYNOMIAL(DEFAULT) (((DEFAULT) == DEFAULT_POLYNOMIAL_ENABLE) || \ | |||
((DEFAULT) == DEFAULT_POLYNOMIAL_DISABLE)) | |||
#define IS_DEFAULT_INIT_VALUE(VALUE) (((VALUE) == DEFAULT_INIT_VALUE_ENABLE) || \ | |||
((VALUE) == DEFAULT_INIT_VALUE_DISABLE)) | |||
#define IS_CRC_POL_LENGTH(LENGTH) (((LENGTH) == CRC_POLYLENGTH_32B) || \ | |||
((LENGTH) == CRC_POLYLENGTH_16B) || \ | |||
((LENGTH) == CRC_POLYLENGTH_8B) || \ | |||
((LENGTH) == CRC_POLYLENGTH_7B)) | |||
#define IS_CRC_INPUTDATA_FORMAT(FORMAT) (((FORMAT) == CRC_INPUTDATA_FORMAT_BYTES) || \ | |||
((FORMAT) == CRC_INPUTDATA_FORMAT_HALFWORDS) || \ | |||
((FORMAT) == CRC_INPUTDATA_FORMAT_WORDS)) | |||
/** | |||
* @} | |||
*/ | |||
/* Include CRC HAL Extended module */ | |||
#include "stm32wbxx_hal_crc_ex.h" | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup CRC_Exported_Functions CRC Exported Functions | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions ****************************/ | |||
/** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc); | |||
HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc); | |||
void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc); | |||
void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc); | |||
/** | |||
* @} | |||
*/ | |||
/* Peripheral Control functions ***********************************************/ | |||
/** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions | |||
* @{ | |||
*/ | |||
uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); | |||
uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); | |||
/** | |||
* @} | |||
*/ | |||
/* Peripheral State and Error functions ***************************************/ | |||
/** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions | |||
* @{ | |||
*/ | |||
HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_CRC_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,153 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_crc_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of CRC HAL extended module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_CRC_EX_H | |||
#define STM32WBxx_HAL_CRC_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup CRCEx | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup CRCEx_Exported_Constants CRC Extended Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup CRCEx_Input_Data_Inversion Input Data Inversion Modes | |||
* @{ | |||
*/ | |||
#define CRC_INPUTDATA_INVERSION_NONE 0x00000000U /*!< No input data inversion */ | |||
#define CRC_INPUTDATA_INVERSION_BYTE CRC_CR_REV_IN_0 /*!< Byte-wise input data inversion */ | |||
#define CRC_INPUTDATA_INVERSION_HALFWORD CRC_CR_REV_IN_1 /*!< HalfWord-wise input data inversion */ | |||
#define CRC_INPUTDATA_INVERSION_WORD CRC_CR_REV_IN /*!< Word-wise input data inversion */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRCEx_Output_Data_Inversion Output Data Inversion Modes | |||
* @{ | |||
*/ | |||
#define CRC_OUTPUTDATA_INVERSION_DISABLE 0x00000000U /*!< No output data inversion */ | |||
#define CRC_OUTPUTDATA_INVERSION_ENABLE CRC_CR_REV_OUT /*!< Bit-wise output data inversion */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup CRCEx_Exported_Macros CRC Extended Exported Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Set CRC output reversal | |||
* @param __HANDLE__ CRC handle | |||
* @retval None | |||
*/ | |||
#define __HAL_CRC_OUTPUTREVERSAL_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_REV_OUT) | |||
/** | |||
* @brief Unset CRC output reversal | |||
* @param __HANDLE__ CRC handle | |||
* @retval None | |||
*/ | |||
#define __HAL_CRC_OUTPUTREVERSAL_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(CRC_CR_REV_OUT)) | |||
/** | |||
* @brief Set CRC non-default polynomial | |||
* @param __HANDLE__ CRC handle | |||
* @param __POLYNOMIAL__ 7, 8, 16 or 32-bit polynomial | |||
* @retval None | |||
*/ | |||
#define __HAL_CRC_POLYNOMIAL_CONFIG(__HANDLE__, __POLYNOMIAL__) ((__HANDLE__)->Instance->POL = (__POLYNOMIAL__)) | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros --------------------------------------------------------*/ | |||
/** @defgroup CRCEx_Private_Macros CRC Extended Private Macros | |||
* @{ | |||
*/ | |||
#define IS_CRC_INPUTDATA_INVERSION_MODE(MODE) (((MODE) == CRC_INPUTDATA_INVERSION_NONE) || \ | |||
((MODE) == CRC_INPUTDATA_INVERSION_BYTE) || \ | |||
((MODE) == CRC_INPUTDATA_INVERSION_HALFWORD) || \ | |||
((MODE) == CRC_INPUTDATA_INVERSION_WORD)) | |||
#define IS_CRC_OUTPUTDATA_INVERSION_MODE(MODE) (((MODE) == CRC_OUTPUTDATA_INVERSION_DISABLE) || \ | |||
((MODE) == CRC_OUTPUTDATA_INVERSION_ENABLE)) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup CRCEx_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup CRCEx_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions ****************************/ | |||
HAL_StatusTypeDef HAL_CRCEx_Polynomial_Set(CRC_HandleTypeDef *hcrc, uint32_t Pol, uint32_t PolyLength); | |||
HAL_StatusTypeDef HAL_CRCEx_Input_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t InputReverseMode); | |||
HAL_StatusTypeDef HAL_CRCEx_Output_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t OutputReverseMode); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_CRC_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,627 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_cryp.h | |||
* @author MCD Application Team | |||
* @brief Header file of CRYP HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_CRYP_H | |||
#define STM32WBxx_HAL_CRYP_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup CRYP CRYP | |||
* @brief CRYP HAL module driver. | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup CRYP_Exported_Types CRYP Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief CRYP Init Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string. | |||
This parameter can be a value of @ref CRYP_Data_Type */ | |||
uint32_t KeySize; /*!< Used only in AES mode : 128, 192 or 256 bit key length in CRYP1. | |||
128 or 256 bit key length in TinyAES This parameter can be a value of @ref CRYP_Key_Size */ | |||
uint32_t *pKey; /*!< The key used for encryption/decryption */ | |||
uint32_t *pInitVect; /*!< The initialization vector used also as initialization | |||
counter in CTR mode */ | |||
uint32_t Algorithm; /*!< DES/ TDES Algorithm ECB/CBC | |||
AES Algorithm ECB/CBC/CTR/GCM or CCM | |||
This parameter can be a value of @ref CRYP_Algorithm_Mode */ | |||
uint32_t *Header; /*!< used only in AES GCM and CCM Algorithm for authentication, | |||
GCM : also known as Additional Authentication Data | |||
CCM : named B1 composed of the associated data length and Associated Data. */ | |||
uint32_t HeaderSize; /*!< The size of header buffer in word */ | |||
uint32_t *B0; /*!< B0 is first authentication block used only in AES CCM mode */ | |||
uint32_t DataWidthUnit; /*!< Data With Unit, this parameter can be value of @ref CRYP_Data_Width_Unit*/ | |||
uint32_t KeyIVConfigSkip; /*!< CRYP peripheral Key and IV configuration skip, to config Key and Initialization | |||
Vector only once and to skip configuration for consecutive processings. | |||
This parameter can be a value of @ref CRYP_Configuration_Skip */ | |||
} CRYP_ConfigTypeDef; | |||
/** | |||
* @brief CRYP State Structure definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_CRYP_STATE_RESET = 0x00U, /*!< CRYP not yet initialized or disabled */ | |||
HAL_CRYP_STATE_READY = 0x01U, /*!< CRYP initialized and ready for use */ | |||
HAL_CRYP_STATE_BUSY = 0x02U, /*!< CRYP BUSY, internal processing is ongoing */ | |||
#if (USE_HAL_CRYP_SUSPEND_RESUME == 1U) | |||
HAL_CRYP_STATE_SUSPENDED = 0x03U, /*!< CRYP suspended */ | |||
#endif /* USE_HAL_CRYP_SUSPEND_RESUME */ | |||
} HAL_CRYP_STATETypeDef; | |||
#if (USE_HAL_CRYP_SUSPEND_RESUME == 1U) | |||
/** | |||
* @brief HAL CRYP mode suspend definitions | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_CRYP_SUSPEND_NONE = 0x00U, /*!< CRYP processing suspension not requested */ | |||
HAL_CRYP_SUSPEND = 0x01U /*!< CRYP processing suspension requested */ | |||
}HAL_SuspendTypeDef; | |||
#endif /* USE_HAL_CRYP_SUSPEND_RESUME */ | |||
/** | |||
* @brief CRYP handle Structure definition | |||
*/ | |||
#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1) | |||
typedef struct __CRYP_HandleTypeDef | |||
#else | |||
typedef struct | |||
#endif | |||
{ | |||
AES_TypeDef *Instance; /*!< AES Register base address */ | |||
CRYP_ConfigTypeDef Init; /*!< CRYP required parameters */ | |||
FunctionalState AutoKeyDerivation; /*!< Used only in TinyAES to allow to bypass or not key write-up before decryption. | |||
This parameter can be a value of ENABLE/DISABLE */ | |||
uint32_t *pCrypInBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ | |||
uint32_t *pCrypOutBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ | |||
__IO uint16_t CrypHeaderCount; /*!< Counter of header data */ | |||
__IO uint16_t CrypInCount; /*!< Counter of input data */ | |||
__IO uint16_t CrypOutCount; /*!< Counter of output data */ | |||
uint16_t Size; /*!< length of input data in words */ | |||
uint32_t Phase; /*!< CRYP peripheral phase */ | |||
DMA_HandleTypeDef *hdmain; /*!< CRYP In DMA handle parameters */ | |||
DMA_HandleTypeDef *hdmaout; /*!< CRYP Out DMA handle parameters */ | |||
HAL_LockTypeDef Lock; /*!< CRYP locking object */ | |||
__IO HAL_CRYP_STATETypeDef State; /*!< CRYP peripheral state */ | |||
__IO uint32_t ErrorCode; /*!< CRYP peripheral error code */ | |||
uint32_t KeyIVConfig; /*!< CRYP peripheral Key and IV configuration flag, used when | |||
configuration can be skipped */ | |||
uint32_t SizesSum; /*!< Sum of successive payloads lengths (in bytes), stored | |||
for a single signature computation after several | |||
messages processing */ | |||
#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1U) | |||
void (*InCpltCallback)(struct __CRYP_HandleTypeDef *hcryp); /*!< CRYP Input FIFO transfer completed callback */ | |||
void (*OutCpltCallback)(struct __CRYP_HandleTypeDef *hcryp); /*!< CRYP Output FIFO transfer completed callback */ | |||
void (*ErrorCallback)(struct __CRYP_HandleTypeDef *hcryp); /*!< CRYP Error callback */ | |||
void (* MspInitCallback)(struct __CRYP_HandleTypeDef *hcryp); /*!< CRYP Msp Init callback */ | |||
void (* MspDeInitCallback)(struct __CRYP_HandleTypeDef *hcryp); /*!< CRYP Msp DeInit callback */ | |||
#endif /* (USE_HAL_CRYP_REGISTER_CALLBACKS) */ | |||
#if (USE_HAL_CRYP_SUSPEND_RESUME == 1U) | |||
__IO HAL_SuspendTypeDef SuspendRequest; /*!< CRYP peripheral suspension request flag */ | |||
CRYP_ConfigTypeDef Init_saved; /*!< copy of CRYP required parameters when processing is suspended */ | |||
uint32_t *pCrypInBuffPtr_saved; /*!< copy of CRYP input pointer when processing is suspended */ | |||
uint32_t *pCrypOutBuffPtr_saved; /*!< copy of CRYP output pointer when processing is suspended */ | |||
uint32_t CrypInCount_saved; /*!< copy of CRYP input data counter when processing is suspended */ | |||
uint32_t CrypOutCount_saved; /*!< copy of CRYP output data counter when processing is suspended */ | |||
uint32_t Phase_saved; /*!< copy of CRYP authentication phase when processing is suspended */ | |||
__IO HAL_CRYP_STATETypeDef State_saved; /*!< copy of CRYP peripheral state when processing is suspended */ | |||
uint32_t IV_saved[4]; /*!< copy of Initialisation Vector registers */ | |||
uint32_t SUSPxR_saved[8]; /*!< copy of suspension registers */ | |||
uint32_t CR_saved; /*!< copy of CRYP control register when processing is suspended*/ | |||
uint32_t Key_saved[8]; /*!< copy of key registers */ | |||
uint32_t Size_saved; /*!< copy of input buffer size */ | |||
uint16_t CrypHeaderCount_saved; /*!< copy of CRYP header data counter when processing is suspended */ | |||
uint32_t ResumingFlag; /*!< resumption flag to bypass steps already carried out */ | |||
FunctionalState AutoKeyDerivation_saved; /*!< copy of CRYP handle auto key derivation parameter */ | |||
#endif /* USE_HAL_CRYP_SUSPEND_RESUME */ | |||
} CRYP_HandleTypeDef; | |||
#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1U) | |||
/** @defgroup HAL_CRYP_Callback_ID_enumeration_definition HAL CRYP Callback ID enumeration definition | |||
* @brief HAL CRYP Callback ID enumeration definition | |||
* @{ | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_CRYP_MSPINIT_CB_ID = 0x00U, /*!< CRYP MspInit callback ID */ | |||
HAL_CRYP_MSPDEINIT_CB_ID = 0x01U, /*!< CRYP MspDeInit callback ID */ | |||
HAL_CRYP_INPUT_COMPLETE_CB_ID = 0x02U, /*!< CRYP Input FIFO transfer completed callback ID */ | |||
HAL_CRYP_OUTPUT_COMPLETE_CB_ID = 0x03U, /*!< CRYP Output FIFO transfer completed callback ID */ | |||
HAL_CRYP_ERROR_CB_ID = 0x04U, /*!< CRYP Error callback ID */ | |||
} HAL_CRYP_CallbackIDTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup HAL_CRYP_Callback_pointer_definition HAL CRYP Callback pointer definition | |||
* @brief HAL CRYP Callback pointer definition | |||
* @{ | |||
*/ | |||
typedef void (*pCRYP_CallbackTypeDef)(CRYP_HandleTypeDef *hcryp); /*!< pointer to a common CRYP callback function */ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup CRYP_Exported_Constants CRYP Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup CRYP_Error_Definition CRYP Error Definition | |||
* @{ | |||
*/ | |||
#define HAL_CRYP_ERROR_NONE 0x00000000U /*!< No error */ | |||
#define HAL_CRYP_ERROR_WRITE 0x00000001U /*!< Write error */ | |||
#define HAL_CRYP_ERROR_READ 0x00000002U /*!< Read error */ | |||
#define HAL_CRYP_ERROR_DMA 0x00000004U /*!< DMA error */ | |||
#define HAL_CRYP_ERROR_BUSY 0x00000008U /*!< Busy flag error */ | |||
#define HAL_CRYP_ERROR_TIMEOUT 0x00000010U /*!< Timeout error */ | |||
#define HAL_CRYP_ERROR_NOT_SUPPORTED 0x00000020U /*!< Not supported mode */ | |||
#define HAL_CRYP_ERROR_AUTH_TAG_SEQUENCE 0x00000040U /*!< Sequence are not respected only for GCM or CCM */ | |||
#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1U) | |||
#define HAL_CRYP_ERROR_INVALID_CALLBACK ((uint32_t)0x00000080U) /*!< Invalid Callback error */ | |||
#endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRYP_Data_Width_Unit CRYP Data Width Unit | |||
* @{ | |||
*/ | |||
#define CRYP_DATAWIDTHUNIT_WORD 0x00000000U /*!< By default, size unit is word */ | |||
#define CRYP_DATAWIDTHUNIT_BYTE 0x00000001U /*!< By default, size unit is byte */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRYP_Algorithm_Mode CRYP Algorithm Mode | |||
* @{ | |||
*/ | |||
#define CRYP_AES_ECB 0x00000000U /*!< Electronic codebook chaining algorithm */ | |||
#define CRYP_AES_CBC AES_CR_CHMOD_0 /*!< Cipher block chaining algorithm */ | |||
#define CRYP_AES_CTR AES_CR_CHMOD_1 /*!< Counter mode chaining algorithm */ | |||
#define CRYP_AES_GCM_GMAC (AES_CR_CHMOD_0 | AES_CR_CHMOD_1) /*!< Galois counter mode - Galois message authentication code */ | |||
#define CRYP_AES_CCM AES_CR_CHMOD_2 /*!< Counter with Cipher Mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRYP_Key_Size CRYP Key Size | |||
* @{ | |||
*/ | |||
#define CRYP_KEYSIZE_128B 0x00000000U /*!< 128-bit long key */ | |||
#define CRYP_KEYSIZE_256B AES_CR_KEYSIZE /*!< 256-bit long key */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRYP_Data_Type CRYP Data Type | |||
* @{ | |||
*/ | |||
#define CRYP_DATATYPE_32B 0x00000000U /*!< 32-bit data type (no swapping) */ | |||
#define CRYP_DATATYPE_16B AES_CR_DATATYPE_0 /*!< 16-bit data type (half-word swapping) */ | |||
#define CRYP_DATATYPE_8B AES_CR_DATATYPE_1 /*!< 8-bit data type (byte swapping) */ | |||
#define CRYP_DATATYPE_1B AES_CR_DATATYPE /*!< 1-bit data type (bit swapping) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRYP_Interrupt CRYP Interrupt | |||
* @{ | |||
*/ | |||
#define CRYP_IT_CCFIE AES_CR_CCFIE /*!< Computation Complete interrupt enable */ | |||
#define CRYP_IT_ERRIE AES_CR_ERRIE /*!< Error interrupt enable */ | |||
#define CRYP_IT_WRERR AES_SR_WRERR /*!< Write Error */ | |||
#define CRYP_IT_RDERR AES_SR_RDERR /*!< Read Error */ | |||
#define CRYP_IT_CCF AES_SR_CCF /*!< Computation completed */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRYP_Flags CRYP Flags | |||
* @{ | |||
*/ | |||
/* status flags */ | |||
#define CRYP_FLAG_BUSY AES_SR_BUSY /*!< GCM process suspension forbidden */ | |||
#define CRYP_FLAG_WRERR AES_SR_WRERR /*!< Write Error */ | |||
#define CRYP_FLAG_RDERR AES_SR_RDERR /*!< Read error */ | |||
#define CRYP_FLAG_CCF AES_SR_CCF /*!< Computation completed */ | |||
/* clearing flags */ | |||
#define CRYP_CCF_CLEAR AES_CR_CCFC /*!< Computation Complete Flag Clear */ | |||
#define CRYP_ERR_CLEAR AES_CR_ERRC /*!< Error Flag Clear */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRYP_Configuration_Skip CRYP Key and IV Configuration Skip Mode | |||
* @{ | |||
*/ | |||
#define CRYP_KEYIVCONFIG_ALWAYS 0x00000000U /*!< Peripheral Key and IV configuration to do systematically */ | |||
#define CRYP_KEYIVCONFIG_ONCE 0x00000001U /*!< Peripheral Key and IV configuration to do only once */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup CRYP_Exported_Macros CRYP Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset CRYP handle state | |||
* @param __HANDLE__ specifies the CRYP handle. | |||
* @retval None | |||
*/ | |||
#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1U) | |||
#define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) do{\ | |||
(__HANDLE__)->State = HAL_CRYP_STATE_RESET;\ | |||
(__HANDLE__)->MspInitCallback = NULL;\ | |||
(__HANDLE__)->MspDeInitCallback = NULL;\ | |||
}while(0U) | |||
#else | |||
#define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ( (__HANDLE__)->State = HAL_CRYP_STATE_RESET) | |||
#endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */ | |||
/** | |||
* @brief Enable/Disable the CRYP peripheral. | |||
* @param __HANDLE__ specifies the CRYP handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_CRYP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= AES_CR_EN) | |||
#define __HAL_CRYP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~AES_CR_EN) | |||
/** @brief Check whether the specified CRYP status flag is set or not. | |||
* @param __HANDLE__ specifies the CRYP handle. | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be one of the following values for TinyAES: | |||
* @arg @ref CRYP_FLAG_BUSY GCM process suspension forbidden | |||
* @arg @ref CRYP_IT_WRERR Write Error | |||
* @arg @ref CRYP_IT_RDERR Read Error | |||
* @arg @ref CRYP_IT_CCF Computation Complete | |||
* This parameter can be one of the following values for CRYP: | |||
* @arg CRYP_FLAG_BUSY: The CRYP core is currently processing a block of data | |||
* or a key preparation (for AES decryption). | |||
* @arg CRYP_FLAG_IFEM: Input FIFO is empty | |||
* @arg CRYP_FLAG_IFNF: Input FIFO is not full | |||
* @arg CRYP_FLAG_INRIS: Input FIFO service raw interrupt is pending | |||
* @arg CRYP_FLAG_OFNE: Output FIFO is not empty | |||
* @arg CRYP_FLAG_OFFU: Output FIFO is full | |||
* @arg CRYP_FLAG_OUTRIS: Input FIFO service raw interrupt is pending | |||
* @retval The state of __FLAG__ (TRUE or FALSE). | |||
*/ | |||
#define CRYP_FLAG_MASK 0x0000001FU | |||
#define __HAL_CRYP_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) | |||
/** @brief Clear the CRYP pending status flag. | |||
* @param __HANDLE__ specifies the CRYP handle. | |||
* @param __FLAG__ specifies the flag to clear. | |||
* This parameter can be one of the following values: | |||
* @arg @ref CRYP_ERR_CLEAR Read (RDERR) or Write Error (WRERR) Flag Clear | |||
* @arg @ref CRYP_CCF_CLEAR Computation Complete Flag (CCF) Clear | |||
* @retval None | |||
*/ | |||
#define __HAL_CRYP_CLEAR_FLAG(__HANDLE__, __FLAG__) SET_BIT((__HANDLE__)->Instance->CR, (__FLAG__)) | |||
/** @brief Check whether the specified CRYP interrupt source is enabled or not. | |||
* @param __HANDLE__ specifies the CRYP handle. | |||
* @param __INTERRUPT__ CRYP interrupt source to check | |||
* This parameter can be one of the following values for TinyAES: | |||
* @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR) | |||
* @arg @ref CRYP_IT_CCFIE Computation Complete interrupt | |||
* @retval State of interruption (TRUE or FALSE). | |||
*/ | |||
#define __HAL_CRYP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR & (__INTERRUPT__)) == (__INTERRUPT__)) | |||
/** @brief Check whether the specified CRYP interrupt is set or not. | |||
* @param __HANDLE__ specifies the CRYP handle. | |||
* @param __INTERRUPT__ specifies the interrupt to check. | |||
* This parameter can be one of the following values for TinyAES: | |||
* @arg @ref CRYP_IT_WRERR Write Error | |||
* @arg @ref CRYP_IT_RDERR Read Error | |||
* @arg @ref CRYP_IT_CCF Computation Complete | |||
* This parameter can be one of the following values for CRYP: | |||
* @arg CRYP_IT_INI: Input FIFO service masked interrupt status | |||
* @arg CRYP_IT_OUTI: Output FIFO service masked interrupt status | |||
* @retval The state of __INTERRUPT__ (TRUE or FALSE). | |||
*/ | |||
#define __HAL_CRYP_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__)) | |||
/** | |||
* @brief Enable the CRYP interrupt. | |||
* @param __HANDLE__ specifies the CRYP handle. | |||
* @param __INTERRUPT__ CRYP Interrupt. | |||
* This parameter can be one of the following values for TinyAES: | |||
* @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR) | |||
* @arg @ref CRYP_IT_CCFIE Computation Complete interrupt | |||
* This parameter can be one of the following values for CRYP: | |||
* @ CRYP_IT_INI : Input FIFO service interrupt mask. | |||
* @ CRYP_IT_OUTI : Output FIFO service interrupt mask.CRYP interrupt. | |||
* @retval None | |||
*/ | |||
#define __HAL_CRYP_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) |= (__INTERRUPT__)) | |||
/** | |||
* @brief Disable the CRYP interrupt. | |||
* @param __HANDLE__ specifies the CRYP handle. | |||
* @param __INTERRUPT__ CRYP Interrupt. | |||
* This parameter can be one of the following values for TinyAES: | |||
* @arg @ref CRYP_IT_ERRIE Error interrupt (used for RDERR and WRERR) | |||
* @arg @ref CRYP_IT_CCFIE Computation Complete interrupt | |||
* This parameter can be one of the following values for CRYP: | |||
* @ CRYP_IT_INI : Input FIFO service interrupt mask. | |||
* @ CRYP_IT_OUTI : Output FIFO service interrupt mask.CRYP interrupt. | |||
* @retval None | |||
*/ | |||
#define __HAL_CRYP_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) &= ~(__INTERRUPT__)) | |||
/** | |||
* @} | |||
*/ | |||
/* Include CRYP HAL Extended module */ | |||
#include "stm32wbxx_hal_cryp_ex.h" | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup CRYP_Exported_Functions CRYP Exported Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup CRYP_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp); | |||
HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp); | |||
void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp); | |||
void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp); | |||
HAL_StatusTypeDef HAL_CRYP_SetConfig(CRYP_HandleTypeDef *hcryp, CRYP_ConfigTypeDef *pConf); | |||
HAL_StatusTypeDef HAL_CRYP_GetConfig(CRYP_HandleTypeDef *hcryp, CRYP_ConfigTypeDef *pConf); | |||
#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1U) | |||
HAL_StatusTypeDef HAL_CRYP_RegisterCallback(CRYP_HandleTypeDef *hcryp, HAL_CRYP_CallbackIDTypeDef CallbackID, pCRYP_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_CRYP_UnRegisterCallback(CRYP_HandleTypeDef *hcryp, HAL_CRYP_CallbackIDTypeDef CallbackID); | |||
#endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */ | |||
#if (USE_HAL_CRYP_SUSPEND_RESUME == 1U) | |||
void HAL_CRYP_ProcessSuspend(CRYP_HandleTypeDef *hcryp); | |||
HAL_StatusTypeDef HAL_CRYP_Suspend(CRYP_HandleTypeDef *hcryp); | |||
HAL_StatusTypeDef HAL_CRYP_Resume(CRYP_HandleTypeDef *hcryp); | |||
#endif /* defined (USE_HAL_CRYP_SUSPEND_RESUME) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup CRYP_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
/* encryption/decryption ***********************************/ | |||
HAL_StatusTypeDef HAL_CRYP_Encrypt(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_CRYP_Decrypt(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_CRYP_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output); | |||
HAL_StatusTypeDef HAL_CRYP_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output); | |||
HAL_StatusTypeDef HAL_CRYP_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output); | |||
HAL_StatusTypeDef HAL_CRYP_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint32_t *Input, uint16_t Size, uint32_t *Output); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup CRYP_Exported_Functions_Group3 | |||
* @{ | |||
*/ | |||
/* Interrupt Handler functions **********************************************/ | |||
void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp); | |||
HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp); | |||
void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp); | |||
void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp); | |||
void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp); | |||
uint32_t HAL_CRYP_GetError(CRYP_HandleTypeDef *hcryp); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros --------------------------------------------------------*/ | |||
/** @defgroup CRYP_Private_Macros CRYP Private Macros | |||
* @{ | |||
*/ | |||
/** @defgroup CRYP_IS_CRYP_Definitions CRYP Private macros to check input parameters | |||
* @{ | |||
*/ | |||
#define IS_CRYP_ALGORITHM(ALGORITHM) (((ALGORITHM) == CRYP_AES_ECB) || \ | |||
((ALGORITHM) == CRYP_AES_CBC) || \ | |||
((ALGORITHM) == CRYP_AES_CTR) || \ | |||
((ALGORITHM) == CRYP_AES_GCM_GMAC)|| \ | |||
((ALGORITHM) == CRYP_AES_CCM)) | |||
#define IS_CRYP_KEYSIZE(KEYSIZE)(((KEYSIZE) == CRYP_KEYSIZE_128B) || \ | |||
((KEYSIZE) == CRYP_KEYSIZE_256B)) | |||
#define IS_CRYP_DATATYPE(DATATYPE)(((DATATYPE) == CRYP_DATATYPE_32B) || \ | |||
((DATATYPE) == CRYP_DATATYPE_16B) || \ | |||
((DATATYPE) == CRYP_DATATYPE_8B) || \ | |||
((DATATYPE) == CRYP_DATATYPE_1B)) | |||
#define IS_CRYP_INIT(CONFIG)(((CONFIG) == CRYP_KEYIVCONFIG_ALWAYS) || \ | |||
((CONFIG) == CRYP_KEYIVCONFIG_ONCE)) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/** @defgroup CRYP_Private_Constants CRYP Private Constants | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private defines -----------------------------------------------------------*/ | |||
/** @defgroup CRYP_Private_Defines CRYP Private Defines | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/** @defgroup CRYP_Private_Variables CRYP Private Variables | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private functions ---------------------------------------------------------*/ | |||
/** @defgroup CRYP_Private_Functions CRYP Private Functions | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_CRYP_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,133 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_cryp_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of CRYPEx HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_CRYP_EX_H | |||
#define STM32WBxx_HAL_CRYP_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup CRYPEx CRYPEx | |||
* @brief CRYP Extension HAL module driver. | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/** @defgroup CRYPEx_Private_Types CRYPEx Private Types | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/** @defgroup CRYPEx_Private_Variables CRYPEx Private Variables | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/** @defgroup CRYPEx_Private_Constants CRYPEx Private Constants | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup CRYPEx_Private_Macros CRYPEx Private Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private functions ---------------------------------------------------------*/ | |||
/** @defgroup CRYPEx_Private_Functions CRYPEx Private Functions | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup CRYPEx_Exported_Functions CRYPEx Exported Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup CRYPEx_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_CRYPEx_AESGCM_GenerateAuthTAG(CRYP_HandleTypeDef *hcryp, uint32_t *AuthTag, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_CRYPEx_AESCCM_GenerateAuthTAG(CRYP_HandleTypeDef *hcryp, uint32_t *AuthTag, uint32_t Timeout); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup CRYPEx_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
void HAL_CRYPEx_EnableAutoKeyDerivation(CRYP_HandleTypeDef *hcryp); | |||
void HAL_CRYPEx_DisableAutoKeyDerivation(CRYP_HandleTypeDef *hcryp); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_CRYP_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,200 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_def.h | |||
* @author MCD Application Team | |||
* @brief This file contains HAL common defines, enumeration, macros and | |||
* structures definitions. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef __STM32WBxx_HAL_DEF | |||
#define __STM32WBxx_HAL_DEF | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx.h" | |||
#include "Legacy/stm32_hal_legacy.h" /* Aliases file for old names compatibility */ | |||
#include <stddef.h> | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** | |||
* @brief HAL Status structures definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_OK = 0x00, | |||
HAL_ERROR = 0x01, | |||
HAL_BUSY = 0x02, | |||
HAL_TIMEOUT = 0x03 | |||
} HAL_StatusTypeDef; | |||
/** | |||
* @brief HAL Lock structures definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_UNLOCKED = 0x00, | |||
HAL_LOCKED = 0x01 | |||
} HAL_LockTypeDef; | |||
/* Exported macros -----------------------------------------------------------*/ | |||
#define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ | |||
#define HAL_MAX_DELAY 0xFFFFFFFFU | |||
#define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT)) | |||
#define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) | |||
#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ | |||
do{ \ | |||
(__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ | |||
(__DMA_HANDLE__).Parent = (__HANDLE__); \ | |||
} while(0) | |||
/** @brief Reset the Handle's State field. | |||
* @param __HANDLE__ specifies the Peripheral Handle. | |||
* @note This macro can be used for the following purpose: | |||
* - When the Handle is declared as local variable; before passing it as parameter | |||
* to HAL_PPP_Init() for the first time, it is mandatory to use this macro | |||
* to set to 0 the Handle's "State" field. | |||
* Otherwise, "State" field may have any random value and the first time the function | |||
* HAL_PPP_Init() is called, the low level hardware initialization will be missed | |||
* (i.e. HAL_PPP_MspInit() will not be executed). | |||
* - When there is a need to reconfigure the low level hardware: instead of calling | |||
* HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). | |||
* In this later function, when the Handle's "State" field is set to 0, it will execute the function | |||
* HAL_PPP_MspInit() which will reconfigure the low level hardware. | |||
* @retval None | |||
*/ | |||
#define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0) | |||
#if (USE_RTOS == 1) | |||
/* Reserved for future use */ | |||
#error " USE_RTOS should be 0 in the current HAL release " | |||
#else | |||
#define __HAL_LOCK(__HANDLE__) \ | |||
do{ \ | |||
if((__HANDLE__)->Lock == HAL_LOCKED) \ | |||
{ \ | |||
return HAL_BUSY; \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__HANDLE__)->Lock = HAL_LOCKED; \ | |||
} \ | |||
}while (0) | |||
#define __HAL_UNLOCK(__HANDLE__) \ | |||
do{ \ | |||
(__HANDLE__)->Lock = HAL_UNLOCKED; \ | |||
}while (0) | |||
#endif /* USE_RTOS */ | |||
#if defined ( __GNUC__ ) | |||
#ifndef __weak | |||
#define __weak __attribute__((weak)) | |||
#endif /* __weak */ | |||
#ifndef __packed | |||
#define __packed __attribute__((__packed__)) | |||
#endif /* __packed */ | |||
#endif /* __GNUC__ */ | |||
/* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ | |||
/* GNU Compiler */ | |||
#if defined (__GNUC__) | |||
#ifndef __ALIGN_END | |||
#define __ALIGN_END __attribute__ ((aligned (4))) | |||
#endif /* __ALIGN_END */ | |||
#ifndef __ALIGN_BEGIN | |||
#define __ALIGN_BEGIN | |||
#endif /* __ALIGN_BEGIN */ | |||
#else | |||
#ifndef __ALIGN_END | |||
#define __ALIGN_END | |||
#endif /* __ALIGN_END */ | |||
#ifndef __ALIGN_BEGIN | |||
/* ARM Compiler */ | |||
#if defined (__CC_ARM) | |||
#define __ALIGN_BEGIN __align(4) | |||
/* IAR Compiler */ | |||
#elif defined (__ICCARM__) | |||
#define __ALIGN_BEGIN | |||
#endif /* __CC_ARM */ | |||
#endif /* __ALIGN_BEGIN */ | |||
#endif /* __GNUC__ */ | |||
/** | |||
* @brief __RAM_FUNC definition | |||
*/ | |||
#if defined ( __CC_ARM ) | |||
/* ARM Compiler | |||
------------ | |||
RAM functions are defined using the toolchain options. | |||
Functions that are executed in RAM should reside in a separate source module. | |||
Using the 'Options for File' dialog you can simply change the 'Code / Const' | |||
area of a module to a memory space in physical RAM. | |||
Available memory areas are declared in the 'Target' tab of the 'Options for Target' | |||
dialog. | |||
*/ | |||
#define __RAM_FUNC | |||
#elif defined ( __ICCARM__ ) | |||
/* ICCARM Compiler | |||
--------------- | |||
RAM functions are defined using a specific toolchain keyword "__ramfunc". | |||
*/ | |||
#define __RAM_FUNC __ramfunc | |||
#elif defined ( __GNUC__ ) | |||
/* GNU Compiler | |||
------------ | |||
RAM functions are defined using a specific toolchain attribute | |||
"__attribute__((section(".RamFunc")))". | |||
*/ | |||
#define __RAM_FUNC __attribute__((section(".RamFunc"))) | |||
#endif | |||
/** | |||
* @brief __NOINLINE definition | |||
*/ | |||
#if defined ( __CC_ARM ) || defined ( __GNUC__ ) | |||
/* ARM & GNUCompiler | |||
---------------- | |||
*/ | |||
#define __NOINLINE __attribute__ ( (noinline) ) | |||
#elif defined ( __ICCARM__ ) | |||
/* ICCARM Compiler | |||
--------------- | |||
*/ | |||
#define __NOINLINE _Pragma("optimize = no_inline") | |||
#endif | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* ___STM32WBxx_HAL_DEF */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,651 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_dma.h | |||
* @author MCD Application Team | |||
* @brief Header file of DMA HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_DMA_H | |||
#define STM32WBxx_HAL_DMA_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
#include "stm32wbxx_ll_dma.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup DMA | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup DMA_Exported_Types DMA Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief DMA Configuration Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Request; /*!< Specifies the request selected for the specified channel. | |||
This parameter can be a value of @ref DMA_request */ | |||
uint32_t Direction; /*!< Specifies if the data will be transferred from memory to peripheral, | |||
from memory to memory or from peripheral to memory. | |||
This parameter can be a value of @ref DMA_Data_transfer_direction */ | |||
uint32_t PeriphInc; /*!< Specifies whether the Peripheral address register should be incremented or not. | |||
This parameter can be a value of @ref DMA_Peripheral_incremented_mode */ | |||
uint32_t MemInc; /*!< Specifies whether the memory address register should be incremented or not. | |||
This parameter can be a value of @ref DMA_Memory_incremented_mode */ | |||
uint32_t PeriphDataAlignment; /*!< Specifies the Peripheral data width. | |||
This parameter can be a value of @ref DMA_Peripheral_data_size */ | |||
uint32_t MemDataAlignment; /*!< Specifies the Memory data width. | |||
This parameter can be a value of @ref DMA_Memory_data_size */ | |||
uint32_t Mode; /*!< Specifies the operation mode of the DMAy Channelx. | |||
This parameter can be a value of @ref DMA_mode | |||
@note The circular buffer mode cannot be used if the memory-to-memory | |||
data transfer is configured on the selected Channel */ | |||
uint32_t Priority; /*!< Specifies the software priority for the DMAy Channelx. | |||
This parameter can be a value of @ref DMA_Priority_level */ | |||
} DMA_InitTypeDef; | |||
/** | |||
* @brief HAL DMA State structures definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_DMA_STATE_RESET = 0x00U, /*!< DMA not yet initialized or disabled */ | |||
HAL_DMA_STATE_READY = 0x01U, /*!< DMA initialized and ready for use */ | |||
HAL_DMA_STATE_BUSY = 0x02U, /*!< DMA process is ongoing */ | |||
HAL_DMA_STATE_TIMEOUT = 0x03U, /*!< DMA timeout state */ | |||
} HAL_DMA_StateTypeDef; | |||
/** | |||
* @brief HAL DMA Error Code structure definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_DMA_FULL_TRANSFER = 0x00U, /*!< Full transfer */ | |||
HAL_DMA_HALF_TRANSFER = 0x01U /*!< Half Transfer */ | |||
} HAL_DMA_LevelCompleteTypeDef; | |||
/** | |||
* @brief HAL DMA Callback ID structure definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_DMA_XFER_CPLT_CB_ID = 0x00U, /*!< Full transfer */ | |||
HAL_DMA_XFER_HALFCPLT_CB_ID = 0x01U, /*!< Half transfer */ | |||
HAL_DMA_XFER_ERROR_CB_ID = 0x02U, /*!< Error */ | |||
HAL_DMA_XFER_ABORT_CB_ID = 0x03U, /*!< Abort */ | |||
HAL_DMA_XFER_ALL_CB_ID = 0x04U /*!< All */ | |||
} HAL_DMA_CallbackIDTypeDef; | |||
/** | |||
* @brief DMA handle Structure definition | |||
*/ | |||
typedef struct __DMA_HandleTypeDef | |||
{ | |||
DMA_Channel_TypeDef *Instance; /*!< Register base address */ | |||
DMA_InitTypeDef Init; /*!< DMA communication parameters */ | |||
HAL_LockTypeDef Lock; /*!< DMA locking object */ | |||
__IO HAL_DMA_StateTypeDef State; /*!< DMA transfer state */ | |||
void *Parent; /*!< Parent object state */ | |||
void (* XferCpltCallback)(struct __DMA_HandleTypeDef *hdma); /*!< DMA transfer complete callback */ | |||
void (* XferHalfCpltCallback)(struct __DMA_HandleTypeDef *hdma); /*!< DMA Half transfer complete callback */ | |||
void (* XferErrorCallback)(struct __DMA_HandleTypeDef *hdma); /*!< DMA transfer error callback */ | |||
void (* XferAbortCallback)(struct __DMA_HandleTypeDef *hdma); /*!< DMA transfer abort callback */ | |||
__IO uint32_t ErrorCode; /*!< DMA Error code */ | |||
DMA_TypeDef *DmaBaseAddress; /*!< DMA Channel Base Address */ | |||
uint32_t ChannelIndex; /*!< DMA Channel Index */ | |||
DMAMUX_Channel_TypeDef *DMAmuxChannel; /*!< Register base address */ | |||
DMAMUX_ChannelStatus_TypeDef *DMAmuxChannelStatus; /*!< DMAMUX Channels Status Base Address */ | |||
uint32_t DMAmuxChannelStatusMask; /*!< DMAMUX Channel Status Mask */ | |||
DMAMUX_RequestGen_TypeDef *DMAmuxRequestGen; /*!< DMAMUX request generator Base Address */ | |||
DMAMUX_RequestGenStatus_TypeDef *DMAmuxRequestGenStatus; /*!< DMAMUX request generator Address */ | |||
uint32_t DMAmuxRequestGenStatusMask; /*!< DMAMUX request generator Status mask */ | |||
} DMA_HandleTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup DMA_Exported_Constants DMA Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup DMA_Error_Code DMA Error Code | |||
* @{ | |||
*/ | |||
#define HAL_DMA_ERROR_NONE 0x00000000U /*!< No error */ | |||
#define HAL_DMA_ERROR_TE 0x00000001U /*!< Transfer error */ | |||
#define HAL_DMA_ERROR_NO_XFER 0x00000004U /*!< Abort requested with no Xfer ongoing */ | |||
#define HAL_DMA_ERROR_TIMEOUT 0x00000020U /*!< Timeout error */ | |||
#define HAL_DMA_ERROR_NOT_SUPPORTED 0x00000100U /*!< Not supported mode */ | |||
#define HAL_DMA_ERROR_SYNC 0x00000200U /*!< DMAMUX sync overrun error */ | |||
#define HAL_DMA_ERROR_REQGEN 0x00000400U /*!< DMAMUX request generator overrun error */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DMA_request DMA request | |||
* @{ | |||
*/ | |||
#define DMA_REQUEST_MEM2MEM LL_DMAMUX_REQ_MEM2MEM /*!< memory to memory transfer */ | |||
#define DMA_REQUEST_GENERATOR0 LL_DMAMUX_REQ_GENERATOR0 /*!< DMAMUX request generator 0 */ | |||
#define DMA_REQUEST_GENERATOR1 LL_DMAMUX_REQ_GENERATOR1 /*!< DMAMUX request generator 1 */ | |||
#define DMA_REQUEST_GENERATOR2 LL_DMAMUX_REQ_GENERATOR2 /*!< DMAMUX request generator 2 */ | |||
#define DMA_REQUEST_GENERATOR3 LL_DMAMUX_REQ_GENERATOR3 /*!< DMAMUX request generator 3 */ | |||
#define DMA_REQUEST_ADC1 LL_DMAMUX_REQ_ADC1 /*!< DMAMUX ADC1 request */ | |||
#define DMA_REQUEST_SPI1_RX LL_DMAMUX_REQ_SPI1_RX /*!< DMAMUX SPI1 RX request */ | |||
#define DMA_REQUEST_SPI1_TX LL_DMAMUX_REQ_SPI1_TX /*!< DMAMUX SPI1 TX request */ | |||
#define DMA_REQUEST_SPI2_RX LL_DMAMUX_REQ_SPI2_RX /*!< DMAMUX SPI2 RX request */ | |||
#define DMA_REQUEST_SPI2_TX LL_DMAMUX_REQ_SPI2_TX /*!< DMAMUX SPI2 TX request */ | |||
#define DMA_REQUEST_I2C1_RX LL_DMAMUX_REQ_I2C1_RX /*!< DMAMUX I2C1 RX request */ | |||
#define DMA_REQUEST_I2C1_TX LL_DMAMUX_REQ_I2C1_TX /*!< DMAMUX I2C1 TX request */ | |||
#define DMA_REQUEST_I2C3_RX LL_DMAMUX_REQ_I2C3_RX /*!< DMAMUX I2C3 RX request */ | |||
#define DMA_REQUEST_I2C3_TX LL_DMAMUX_REQ_I2C3_TX /*!< DMAMUX I2C3 TX request */ | |||
#define DMA_REQUEST_USART1_RX LL_DMAMUX_REQ_USART1_RX /*!< DMAMUX USART1 RX request */ | |||
#define DMA_REQUEST_USART1_TX LL_DMAMUX_REQ_USART1_TX /*!< DMAMUX USART1 TX request */ | |||
#define DMA_REQUEST_LPUART1_RX LL_DMAMUX_REQ_LPUART1_RX /*!< DMAMUX LP_UART1_RX request */ | |||
#define DMA_REQUEST_LPUART1_TX LL_DMAMUX_REQ_LPUART1_TX /*!< DMAMUX LP_UART1_RX request */ | |||
#define DMA_REQUEST_SAI1_A LL_DMAMUX_REQ_SAI1_A /*!< DMAMUX SAI1 A request */ | |||
#define DMA_REQUEST_SAI1_B LL_DMAMUX_REQ_SAI1_B /*!< DMAMUX SAI1 B request */ | |||
#define DMA_REQUEST_QUADSPI LL_DMAMUX_REQ_QUADSPI /*!< DMAMUX QUADSPI request */ | |||
#define DMA_REQUEST_TIM1_CH1 LL_DMAMUX_REQ_TIM1_CH1 /*!< DMAMUX TIM1 CH1 request */ | |||
#define DMA_REQUEST_TIM1_CH2 LL_DMAMUX_REQ_TIM1_CH2 /*!< DMAMUX TIM1 CH2 request */ | |||
#define DMA_REQUEST_TIM1_CH3 LL_DMAMUX_REQ_TIM1_CH3 /*!< DMAMUX TIM1 CH3 request */ | |||
#define DMA_REQUEST_TIM1_CH4 LL_DMAMUX_REQ_TIM1_CH4 /*!< DMAMUX TIM1 CH4 request */ | |||
#define DMA_REQUEST_TIM1_UP LL_DMAMUX_REQ_TIM1_UP /*!< DMAMUX TIM1 UP request */ | |||
#define DMA_REQUEST_TIM1_TRIG LL_DMAMUX_REQ_TIM1_TRIG /*!< DMAMUX TIM1 TRIG request */ | |||
#define DMA_REQUEST_TIM1_COM LL_DMAMUX_REQ_TIM1_COM /*!< DMAMUX TIM1 COM request */ | |||
#define DMA_REQUEST_TIM2_CH1 LL_DMAMUX_REQ_TIM2_CH1 /*!< DMAMUX TIM2 CH1 request */ | |||
#define DMA_REQUEST_TIM2_CH2 LL_DMAMUX_REQ_TIM2_CH2 /*!< DMAMUX TIM2 CH2 request */ | |||
#define DMA_REQUEST_TIM2_CH3 LL_DMAMUX_REQ_TIM2_CH3 /*!< DMAMUX TIM2 CH3 request */ | |||
#define DMA_REQUEST_TIM2_CH4 LL_DMAMUX_REQ_TIM2_CH4 /*!< DMAMUX TIM2 CH4 request */ | |||
#define DMA_REQUEST_TIM2_UP LL_DMAMUX_REQ_TIM2_UP /*!< DMAMUX TIM2 UP request */ | |||
#define DMA_REQUEST_TIM16_CH1 LL_DMAMUX_REQ_TIM16_CH1 /*!< DMAMUX TIM16 CH1 request */ | |||
#define DMA_REQUEST_TIM16_UP LL_DMAMUX_REQ_TIM16_UP /*!< DMAMUX TIM16 UP request */ | |||
#define DMA_REQUEST_TIM17_CH1 LL_DMAMUX_REQ_TIM17_CH1 /*!< DMAMUX TIM17 CH1 request */ | |||
#define DMA_REQUEST_TIM17_UP LL_DMAMUX_REQ_TIM17_UP /*!< DMAMUX TIM17 UP request */ | |||
#define DMA_REQUEST_AES1_IN LL_DMAMUX_REQ_AES1_IN /*!< DMAMUX AES1 IN request */ | |||
#define DMA_REQUEST_AES1_OUT LL_DMAMUX_REQ_AES1_OUT /*!< DMAMUX AES1 OUT request */ | |||
#define DMA_REQUEST_AES2_IN LL_DMAMUX_REQ_AES2_IN /*!< DMAMUX AES2 IN request */ | |||
#define DMA_REQUEST_AES2_OUT LL_DMAMUX_REQ_AES2_OUT /*!< DMAMUX AES2 OUT request */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DMA_Data_transfer_direction DMA Data transfer direction | |||
* @{ | |||
*/ | |||
#define DMA_PERIPH_TO_MEMORY LL_DMA_DIRECTION_PERIPH_TO_MEMORY /*!< Peripheral to memory direction */ | |||
#define DMA_MEMORY_TO_PERIPH LL_DMA_DIRECTION_MEMORY_TO_PERIPH /*!< Memory to peripheral direction */ | |||
#define DMA_MEMORY_TO_MEMORY LL_DMA_DIRECTION_MEMORY_TO_MEMORY /*!< Memory to memory direction */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DMA_Peripheral_incremented_mode DMA Peripheral incremented mode | |||
* @{ | |||
*/ | |||
#define DMA_PINC_ENABLE LL_DMA_PERIPH_INCREMENT /*!< Peripheral increment mode Enable */ | |||
#define DMA_PINC_DISABLE LL_DMA_PERIPH_NOINCREMENT /*!< Peripheral increment mode Disable */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DMA_Memory_incremented_mode DMA Memory incremented mode | |||
* @{ | |||
*/ | |||
#define DMA_MINC_ENABLE LL_DMA_MEMORY_INCREMENT /*!< Memory increment mode Enable */ | |||
#define DMA_MINC_DISABLE LL_DMA_MEMORY_NOINCREMENT /*!< Memory increment mode Disable */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DMA_Peripheral_data_size DMA Peripheral data size | |||
* @{ | |||
*/ | |||
#define DMA_PDATAALIGN_BYTE LL_DMA_PDATAALIGN_BYTE /*!< Peripheral data alignment : Byte */ | |||
#define DMA_PDATAALIGN_HALFWORD LL_DMA_PDATAALIGN_HALFWORD /*!< Peripheral data alignment : HalfWord */ | |||
#define DMA_PDATAALIGN_WORD LL_DMA_PDATAALIGN_WORD /*!< Peripheral data alignment : Word */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DMA_Memory_data_size DMA Memory data size | |||
* @{ | |||
*/ | |||
#define DMA_MDATAALIGN_BYTE LL_DMA_MDATAALIGN_BYTE /*!< Memory data alignment : Byte */ | |||
#define DMA_MDATAALIGN_HALFWORD LL_DMA_MDATAALIGN_HALFWORD /*!< Memory data alignment : HalfWord */ | |||
#define DMA_MDATAALIGN_WORD LL_DMA_MDATAALIGN_WORD /*!< Memory data alignment : Word */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DMA_mode DMA mode | |||
* @{ | |||
*/ | |||
#define DMA_NORMAL LL_DMA_MODE_NORMAL /*!< Normal mode */ | |||
#define DMA_CIRCULAR LL_DMA_MODE_CIRCULAR /*!< Circular mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DMA_Priority_level DMA Priority level | |||
* @{ | |||
*/ | |||
#define DMA_PRIORITY_LOW LL_DMA_PRIORITY_LOW /*!< Priority level : Low */ | |||
#define DMA_PRIORITY_MEDIUM LL_DMA_PRIORITY_MEDIUM /*!< Priority level : Medium */ | |||
#define DMA_PRIORITY_HIGH LL_DMA_PRIORITY_HIGH /*!< Priority level : High */ | |||
#define DMA_PRIORITY_VERY_HIGH LL_DMA_PRIORITY_VERYHIGH /*!< Priority level : Very_High */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DMA_interrupt_enable_definitions DMA interrupt enable definitions | |||
* @{ | |||
*/ | |||
#define DMA_IT_TC LL_DMA_CCR_TCIE /*!< Transfer complete interrupt */ | |||
#define DMA_IT_HT LL_DMA_CCR_HTIE /*!< Half Transfer interrupt */ | |||
#define DMA_IT_TE LL_DMA_CCR_TEIE /*!< Transfer error interrupt */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DMA_flag_definitions DMA flag definitions | |||
* @{ | |||
*/ | |||
#define DMA_FLAG_GL1 LL_DMA_ISR_GIF1 /*!< Channel 1 global flag */ | |||
#define DMA_FLAG_TC1 LL_DMA_ISR_TCIF1 /*!< Channel 1 transfer complete flag */ | |||
#define DMA_FLAG_HT1 LL_DMA_ISR_HTIF1 /*!< Channel 1 half transfer flag */ | |||
#define DMA_FLAG_TE1 LL_DMA_ISR_TEIF1 /*!< Channel 1 transfer error flag */ | |||
#define DMA_FLAG_GL2 LL_DMA_ISR_GIF2 /*!< Channel 2 global flag */ | |||
#define DMA_FLAG_TC2 LL_DMA_ISR_TCIF2 /*!< Channel 2 transfer complete flag */ | |||
#define DMA_FLAG_HT2 LL_DMA_ISR_HTIF2 /*!< Channel 2 half transfer flag */ | |||
#define DMA_FLAG_TE2 LL_DMA_ISR_TEIF2 /*!< Channel 2 transfer error flag */ | |||
#define DMA_FLAG_GL3 LL_DMA_ISR_GIF3 /*!< Channel 3 global flag */ | |||
#define DMA_FLAG_TC3 LL_DMA_ISR_TCIF3 /*!< Channel 3 transfer complete flag */ | |||
#define DMA_FLAG_HT3 LL_DMA_ISR_HTIF3 /*!< Channel 3 half transfer flag */ | |||
#define DMA_FLAG_TE3 LL_DMA_ISR_TEIF3 /*!< Channel 3 transfer error flag */ | |||
#define DMA_FLAG_GL4 LL_DMA_ISR_GIF4 /*!< Channel 4 global flag */ | |||
#define DMA_FLAG_TC4 LL_DMA_ISR_TCIF4 /*!< Channel 4 transfer complete flag */ | |||
#define DMA_FLAG_HT4 LL_DMA_ISR_HTIF4 /*!< Channel 4 half transfer flag */ | |||
#define DMA_FLAG_TE4 LL_DMA_ISR_TEIF4 /*!< Channel 4 transfer error flag */ | |||
#define DMA_FLAG_GL5 LL_DMA_ISR_GIF5 /*!< Channel 5 global flag */ | |||
#define DMA_FLAG_TC5 LL_DMA_ISR_TCIF5 /*!< Channel 5 transfer complete flag */ | |||
#define DMA_FLAG_HT5 LL_DMA_ISR_HTIF5 /*!< Channel 5 half transfer flag */ | |||
#define DMA_FLAG_TE5 LL_DMA_ISR_TEIF5 /*!< Channel 5 transfer error flag */ | |||
#define DMA_FLAG_GL6 LL_DMA_ISR_GIF6 /*!< Channel 6 global flag */ | |||
#define DMA_FLAG_TC6 LL_DMA_ISR_TCIF6 /*!< Channel 6 transfer complete flag */ | |||
#define DMA_FLAG_HT6 LL_DMA_ISR_HTIF6 /*!< Channel 6 half transfer flag */ | |||
#define DMA_FLAG_TE6 LL_DMA_ISR_TEIF6 /*!< Channel 6 transfer error flag */ | |||
#define DMA_FLAG_GL7 LL_DMA_ISR_GIF7 /*!< Channel 7 global flag */ | |||
#define DMA_FLAG_TC7 LL_DMA_ISR_TCIF7 /*!< Channel 7 transfer complete flag */ | |||
#define DMA_FLAG_HT7 LL_DMA_ISR_HTIF7 /*!< Channel 7 half transfer flag */ | |||
#define DMA_FLAG_TE7 LL_DMA_ISR_TEIF7 /*!< Channel 7 transfer error flag */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup DMA_Exported_Macros DMA Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset DMA handle state | |||
* @param __HANDLE__ DMA handle | |||
* @retval None | |||
*/ | |||
#define __HAL_DMA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA_STATE_RESET) | |||
/** | |||
* @brief Enable the specified DMA Channel. | |||
* @param __HANDLE__ DMA handle | |||
* @retval None | |||
*/ | |||
#define __HAL_DMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CCR |= DMA_CCR_EN) | |||
/** | |||
* @brief Disable the specified DMA Channel. | |||
* @param __HANDLE__ DMA handle | |||
* @retval None | |||
*/ | |||
#define __HAL_DMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CCR &= ~DMA_CCR_EN) | |||
/* Interrupt & Flag management */ | |||
/** | |||
* @brief Returns the current DMA Channel transfer complete flag. | |||
* @param __HANDLE__ DMA handle | |||
* @retval The specified transfer complete flag index. | |||
*/ | |||
#define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \ | |||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TC1 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_TC1 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TC2 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_TC2 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TC3 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_TC3 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TC4 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_TC4 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TC5 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel5))? DMA_FLAG_TC5 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TC6 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel6))? DMA_FLAG_TC6 :\ | |||
DMA_FLAG_TC7) | |||
/** | |||
* @brief Returns the current DMA Channel half transfer complete flag. | |||
* @param __HANDLE__ DMA handle | |||
* @retval The specified half transfer complete flag index. | |||
*/ | |||
#define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\ | |||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_HT1 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_HT1 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_HT2 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_HT2 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_HT3 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_HT3 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_HT4 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_HT4 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_HT5 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel5))? DMA_FLAG_HT5 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_HT6 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel6))? DMA_FLAG_HT6 :\ | |||
DMA_FLAG_HT7) | |||
/** | |||
* @brief Returns the current DMA Channel transfer error flag. | |||
* @param __HANDLE__ DMA handle | |||
* @retval The specified transfer error flag index. | |||
*/ | |||
#define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\ | |||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TE1 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_TE1 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TE2 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_TE2 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TE3 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_TE3 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TE4 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_TE4 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TE5 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel5))? DMA_FLAG_TE5 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TE6 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel6))? DMA_FLAG_TE6 :\ | |||
DMA_FLAG_TE7) | |||
/** | |||
* @brief Returns the current DMA Channel Global interrupt flag. | |||
* @param __HANDLE__ DMA handle | |||
* @retval The specified transfer error flag index. | |||
*/ | |||
#define __HAL_DMA_GET_GI_FLAG_INDEX(__HANDLE__)\ | |||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_ISR_GIF1 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_ISR_GIF1 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_ISR_GIF2 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_ISR_GIF2 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_ISR_GIF3 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_ISR_GIF3 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_ISR_GIF4 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_ISR_GIF4 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_ISR_GIF5 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel5))? DMA_ISR_GIF5 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_ISR_GIF6 :\ | |||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel6))? DMA_ISR_GIF6 :\ | |||
DMA_ISR_GIF7) | |||
/** | |||
* @brief Get the DMA Channel pending flags. | |||
* @param __HANDLE__ DMA handle | |||
* @param __FLAG__ Get the specified flag. | |||
* This parameter can be any combination of the following values: | |||
* @arg DMA_FLAG_TCx: Transfer complete flag | |||
* @arg DMA_FLAG_HTx: Half transfer complete flag | |||
* @arg DMA_FLAG_TEx: Transfer error flag | |||
* @arg DMA_FLAG_GLx: Global interrupt flag | |||
* Where x can be from 1 to 7 to select the DMA Channel x flag. | |||
* @retval The state of FLAG (SET or RESET). | |||
*/ | |||
#define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__) (((uint32_t)((__HANDLE__)->Instance) > ((uint32_t)DMA1_Channel7))? \ | |||
(DMA2->ISR & (__FLAG__)) : (DMA1->ISR & (__FLAG__))) | |||
/** | |||
* @brief Clear the DMA Channel pending flags. | |||
* @param __HANDLE__ DMA handle | |||
* @param __FLAG__ specifies the flag to clear. | |||
* This parameter can be any combination of the following values: | |||
* @arg DMA_FLAG_TCx: Transfer complete flag | |||
* @arg DMA_FLAG_HTx: Half transfer complete flag | |||
* @arg DMA_FLAG_TEx: Transfer error flag | |||
* @arg DMA_FLAG_GLx: Global interrupt flag | |||
* Where x can be from 1 to 7 to select the DMA Channel x flag. | |||
* @retval None | |||
*/ | |||
#define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) (((uint32_t)((__HANDLE__)->Instance) > ((uint32_t)DMA1_Channel7))? \ | |||
(DMA2->IFCR = (__FLAG__)) : (DMA1->IFCR = (__FLAG__))) | |||
/** | |||
* @brief Enable the specified DMA Channel interrupts. | |||
* @param __HANDLE__ DMA handle | |||
* @param __INTERRUPT__ specifies the DMA interrupt sources to be enabled or disabled. | |||
* This parameter can be any combination of the following values: | |||
* @arg DMA_IT_TC: Transfer complete interrupt mask | |||
* @arg DMA_IT_HT: Half transfer complete interrupt mask | |||
* @arg DMA_IT_TE: Transfer error interrupt mask | |||
* @retval None | |||
*/ | |||
#define __HAL_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CCR |= (__INTERRUPT__)) | |||
/** | |||
* @brief Disable the specified DMA Channel interrupts. | |||
* @param __HANDLE__ DMA handle | |||
* @param __INTERRUPT__ specifies the DMA interrupt sources to be enabled or disabled. | |||
* This parameter can be any combination of the following values: | |||
* @arg DMA_IT_TC: Transfer complete interrupt mask | |||
* @arg DMA_IT_HT: Half transfer complete interrupt mask | |||
* @arg DMA_IT_TE: Transfer error interrupt mask | |||
* @retval None | |||
*/ | |||
#define __HAL_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CCR &= ~(__INTERRUPT__)) | |||
/** | |||
* @brief Check whether the specified DMA Channel interrupt is enabled or not. | |||
* @param __HANDLE__ DMA handle | |||
* @param __INTERRUPT__ specifies the DMA interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg DMA_IT_TC: Transfer complete interrupt mask | |||
* @arg DMA_IT_HT: Half transfer complete interrupt mask | |||
* @arg DMA_IT_TE: Transfer error interrupt mask | |||
* @retval The state of DMA_IT (SET or RESET). | |||
*/ | |||
#define __HAL_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CCR & (__INTERRUPT__))) | |||
/** | |||
* @brief Returns the number of remaining data units in the current DMA Channel transfer. | |||
* @param __HANDLE__ DMA handle | |||
* @retval The number of remaining data units in the current DMA Channel transfer. | |||
*/ | |||
#define __HAL_DMA_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CNDTR) | |||
/** | |||
* @} | |||
*/ | |||
/* Include DMA HAL Extension module */ | |||
#include "stm32wbxx_hal_dma_ex.h" | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup DMA_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup DMA_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions *****************************/ | |||
HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma); | |||
HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup DMA_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
HAL_StatusTypeDef HAL_DMA_Start(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength); | |||
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength); | |||
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma); | |||
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma); | |||
HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, HAL_DMA_LevelCompleteTypeDef CompleteLevel, uint32_t Timeout); | |||
void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma); | |||
HAL_StatusTypeDef HAL_DMA_RegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID, void (* pCallback)(DMA_HandleTypeDef *_hdma)); | |||
HAL_StatusTypeDef HAL_DMA_UnRegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup DMA_Exported_Functions_Group3 | |||
* @{ | |||
*/ | |||
/* Peripheral State and Error functions ***************************************/ | |||
HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma); | |||
uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup DMA_Private_Macros DMA Private Macros | |||
* @{ | |||
*/ | |||
#define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_PERIPH_TO_MEMORY ) || \ | |||
((DIRECTION) == DMA_MEMORY_TO_PERIPH) || \ | |||
((DIRECTION) == DMA_MEMORY_TO_MEMORY)) | |||
#define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1U) && ((SIZE) < 0x10000U)) | |||
#define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PINC_ENABLE) || \ | |||
((STATE) == DMA_PINC_DISABLE)) | |||
#define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MINC_ENABLE) || \ | |||
((STATE) == DMA_MINC_DISABLE)) | |||
#define IS_DMA_ALL_REQUEST(REQUEST) ((REQUEST) <= DMA_REQUEST_AES2_OUT) | |||
#define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PDATAALIGN_BYTE) || \ | |||
((SIZE) == DMA_PDATAALIGN_HALFWORD) || \ | |||
((SIZE) == DMA_PDATAALIGN_WORD)) | |||
#define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MDATAALIGN_BYTE) || \ | |||
((SIZE) == DMA_MDATAALIGN_HALFWORD) || \ | |||
((SIZE) == DMA_MDATAALIGN_WORD )) | |||
#define IS_DMA_MODE(MODE) (((MODE) == DMA_NORMAL ) || \ | |||
((MODE) == DMA_CIRCULAR)) | |||
#define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_PRIORITY_LOW ) || \ | |||
((PRIORITY) == DMA_PRIORITY_MEDIUM) || \ | |||
((PRIORITY) == DMA_PRIORITY_HIGH) || \ | |||
((PRIORITY) == DMA_PRIORITY_VERY_HIGH)) | |||
/** | |||
* @} | |||
*/ | |||
/* Private functions ---------------------------------------------------------*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_DMA_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,265 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_dma_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of DMA HAL extension module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_DMA_EX_H | |||
#define STM32WBxx_HAL_DMA_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
#include "stm32wbxx_ll_dmamux.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup DMAEx | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup DMAEx_Exported_Types DMAEx Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief HAL DMA Synchro definition | |||
*/ | |||
/** | |||
* @brief HAL DMAMUX Synchronization configuration structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t SyncSignalID; /*!< Specifies the synchronization signal gating the DMA request in periodic mode. | |||
This parameter can be a value of @ref DMAEx_DMAMUX_SyncSignalID_selection */ | |||
uint32_t SyncPolarity; /*!< Specifies the polarity of the signal on which the DMA request is synchronized. | |||
This parameter can be a value of @ref DMAEx_DMAMUX_SyncPolarity_selection */ | |||
FunctionalState SyncEnable; /*!< Specifies if the synchronization shall be enabled or disabled | |||
This parameter can take the value ENABLE or DISABLE*/ | |||
FunctionalState EventEnable; /*!< Specifies if an event shall be generated once the RequestNumber is reached. | |||
This parameter can take the value ENABLE or DISABLE */ | |||
uint32_t RequestNumber; /*!< Specifies the number of DMA request that will be authorized after a sync event | |||
This parameter must be a number between Min_Data = 1 and Max_Data = 32 */ | |||
} HAL_DMA_MuxSyncConfigTypeDef; | |||
/** | |||
* @brief HAL DMAMUX request generator parameters structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t SignalID; /*!< Specifies the ID of the signal used for DMAMUX request generator | |||
This parameter can be a value of @ref DMAEx_DMAMUX_SignalGeneratorID_selection */ | |||
uint32_t Polarity; /*!< Specifies the polarity of the signal on which the request is generated. | |||
This parameter can be a value of @ref DMAEx_DMAMUX_RequestGeneneratorPolarity_selection */ | |||
uint32_t RequestNumber; /*!< Specifies the number of DMA request that will be generated after a signal event | |||
This parameter must be a number between Min_Data = 1 and Max_Data = 32 */ | |||
} HAL_DMA_MuxRequestGeneratorConfigTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup DMAEx_Exported_Constants DMAEx Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup DMAEx_DMAMUX_SyncSignalID_selection DMAMUX SyncSignalID selection | |||
* @{ | |||
*/ | |||
#define HAL_DMAMUX1_SYNC_EXTI0 LL_DMAMUX_SYNC_EXTI_LINE0 /*!< Synchronization Signal is EXTI0 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI1 LL_DMAMUX_SYNC_EXTI_LINE1 /*!< Synchronization Signal is EXTI1 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI2 LL_DMAMUX_SYNC_EXTI_LINE2 /*!< Synchronization Signal is EXTI2 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI3 LL_DMAMUX_SYNC_EXTI_LINE3 /*!< Synchronization Signal is EXTI3 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI4 LL_DMAMUX_SYNC_EXTI_LINE4 /*!< Synchronization Signal is EXTI4 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI5 LL_DMAMUX_SYNC_EXTI_LINE5 /*!< Synchronization Signal is EXTI5 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI6 LL_DMAMUX_SYNC_EXTI_LINE6 /*!< Synchronization Signal is EXTI6 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI7 LL_DMAMUX_SYNC_EXTI_LINE7 /*!< Synchronization Signal is EXTI7 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI8 LL_DMAMUX_SYNC_EXTI_LINE8 /*!< Synchronization Signal is EXTI8 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI9 LL_DMAMUX_SYNC_EXTI_LINE9 /*!< Synchronization Signal is EXTI9 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI10 LL_DMAMUX_SYNC_EXTI_LINE10 /*!< Synchronization Signal is EXTI10 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI11 LL_DMAMUX_SYNC_EXTI_LINE11 /*!< Synchronization Signal is EXTI11 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI12 LL_DMAMUX_SYNC_EXTI_LINE12 /*!< Synchronization Signal is EXTI12 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI13 LL_DMAMUX_SYNC_EXTI_LINE13 /*!< Synchronization Signal is EXTI13 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI14 LL_DMAMUX_SYNC_EXTI_LINE14 /*!< Synchronization Signal is EXTI14 IT */ | |||
#define HAL_DMAMUX1_SYNC_EXTI15 LL_DMAMUX_SYNC_EXTI_LINE15 /*!< Synchronization Signal is EXTI15 IT */ | |||
#define HAL_DMAMUX1_SYNC_DMAMUX1_CH0_EVT LL_DMAMUX_SYNC_DMAMUX_CH0 /*!< Synchronization Signal is DMAMUX1 Channel0 Event */ | |||
#define HAL_DMAMUX1_SYNC_DMAMUX1_CH1_EVT LL_DMAMUX_SYNC_DMAMUX_CH1 /*!< Synchronization Signal is DMAMUX1 Channel1 Event */ | |||
#define HAL_DMAMUX1_SYNC_LPTIM1_OUT LL_DMAMUX_SYNC_LPTIM1_OUT /*!< Synchronization Signal is LPTIM1 OUT */ | |||
#define HAL_DMAMUX1_SYNC_LPTIM2_OUT LL_DMAMUX_SYNC_LPTIM2_OUT /*!< Synchronization Signal is LPTIM2 OUT */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DMAEx_DMAMUX_SyncPolarity_selection DMAMUX SyncPolarity selection | |||
* @{ | |||
*/ | |||
#define HAL_DMAMUX_SYNC_NO_EVENT LL_DMAMUX_SYNC_NO_EVENT /*!< block synchronization events */ | |||
#define HAL_DMAMUX_SYNC_RISING LL_DMAMUX_SYNC_POL_RISING /*!< synchronize with rising edge events */ | |||
#define HAL_DMAMUX_SYNC_FALLING LL_DMAMUX_SYNC_POL_FALLING /*!< synchronize with falling edge events */ | |||
#define HAL_DMAMUX_SYNC_RISING_FALLING LL_DMAMUX_SYNC_POL_RISING_FALLING /*!< synchronize with rising and falling edge events */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DMAEx_DMAMUX_SignalGeneratorID_selection DMAMUX SignalGeneratorID selection | |||
* @{ | |||
*/ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI0 LL_DMAMUX_REQ_GEN_EXTI_LINE0 /*!< Request generator Signal is EXTI0 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI1 LL_DMAMUX_REQ_GEN_EXTI_LINE1 /*!< Request generator Signal is EXTI1 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI2 LL_DMAMUX_REQ_GEN_EXTI_LINE2 /*!< Request generator Signal is EXTI2 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI3 LL_DMAMUX_REQ_GEN_EXTI_LINE3 /*!< Request generator Signal is EXTI3 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI4 LL_DMAMUX_REQ_GEN_EXTI_LINE4 /*!< Request generator Signal is EXTI4 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI5 LL_DMAMUX_REQ_GEN_EXTI_LINE5 /*!< Request generator Signal is EXTI5 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI6 LL_DMAMUX_REQ_GEN_EXTI_LINE6 /*!< Request generator Signal is EXTI6 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI7 LL_DMAMUX_REQ_GEN_EXTI_LINE7 /*!< Request generator Signal is EXTI7 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI8 LL_DMAMUX_REQ_GEN_EXTI_LINE8 /*!< Request generator Signal is EXTI8 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI9 LL_DMAMUX_REQ_GEN_EXTI_LINE9 /*!< Request generator Signal is EXTI9 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI10 LL_DMAMUX_REQ_GEN_EXTI_LINE10 /*!< Request generator Signal is EXTI10 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI11 LL_DMAMUX_REQ_GEN_EXTI_LINE11 /*!< Request generator Signal is EXTI11 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI12 LL_DMAMUX_REQ_GEN_EXTI_LINE12 /*!< Request generator Signal is EXTI12 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI13 LL_DMAMUX_REQ_GEN_EXTI_LINE13 /*!< Request generator Signal is EXTI13 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI14 LL_DMAMUX_REQ_GEN_EXTI_LINE14 /*!< Request generator Signal is EXTI14 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_EXTI15 LL_DMAMUX_REQ_GEN_EXTI_LINE15 /*!< Request generator Signal is EXTI15 IT */ | |||
#define HAL_DMAMUX1_REQ_GEN_DMAMUX1_CH0_EVT LL_DMAMUX_REQ_GEN_DMAMUX_CH0 /*!< Request generator Signal is DMAMUX1 Channel0 Event */ | |||
#define HAL_DMAMUX1_REQ_GEN_DMAMUX1_CH1_EVT LL_DMAMUX_REQ_GEN_DMAMUX_CH1 /*!< Request generator Signal is DMAMUX1 Channel1 Event */ | |||
#define HAL_DMAMUX1_REQ_GEN_LPTIM1_OUT LL_DMAMUX_REQ_GEN_LPTIM1_OUT /*!< Request generator Signal is LPTIM1 OUT */ | |||
#define HAL_DMAMUX1_REQ_GEN_LPTIM2_OUT LL_DMAMUX_REQ_GEN_LPTIM2_OUT /*!< Request generator Signal is LPTIM2 OUT */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup DMAEx_DMAMUX_RequestGeneneratorPolarity_selection DMAMUX RequestGeneneratorPolarity selection | |||
* @{ | |||
*/ | |||
#define HAL_DMAMUX_REQ_GEN_NO_EVENT LL_DMAMUX_REQ_GEN_NO_EVENT /*!< block request generator events */ | |||
#define HAL_DMAMUX_REQ_GEN_RISING LL_DMAMUX_REQ_GEN_POL_RISING /*!< generate request on rising edge events */ | |||
#define HAL_DMAMUX_REQ_GEN_FALLING LL_DMAMUX_REQ_GEN_POL_FALLING /*!< generate request on falling edge events */ | |||
#define HAL_DMAMUX_REQ_GEN_RISING_FALLING LL_DMAMUX_REQ_GEN_POL_RISING_FALLING /*!< generate request on rising and falling edge events */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup DMAEx_Exported_Functions | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
/** @addtogroup DMAEx_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
/* ------------------------- REQUEST -----------------------------------------*/ | |||
HAL_StatusTypeDef HAL_DMAEx_ConfigMuxRequestGenerator(DMA_HandleTypeDef *hdma, | |||
HAL_DMA_MuxRequestGeneratorConfigTypeDef *pRequestGeneratorConfig); | |||
HAL_StatusTypeDef HAL_DMAEx_EnableMuxRequestGenerator(DMA_HandleTypeDef *hdma); | |||
HAL_StatusTypeDef HAL_DMAEx_DisableMuxRequestGenerator(DMA_HandleTypeDef *hdma); | |||
/* -------------------------------------------------------------------------- */ | |||
/* ------------------------- SYNCHRO -----------------------------------------*/ | |||
HAL_StatusTypeDef HAL_DMAEx_ConfigMuxSync(DMA_HandleTypeDef *hdma, HAL_DMA_MuxSyncConfigTypeDef *pSyncConfig); | |||
/* -------------------------------------------------------------------------- */ | |||
void HAL_DMAEx_MUX_IRQHandler(DMA_HandleTypeDef *hdma); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup DMAEx_Private_Macros DMAEx Private Macros | |||
* @brief DMAEx private macros | |||
* @{ | |||
*/ | |||
#define IS_DMAMUX_SYNC_SIGNAL_ID(SIGNAL_ID) ((SIGNAL_ID) <= HAL_DMAMUX1_SYNC_LPTIM2_OUT) | |||
#define IS_DMAMUX_SYNC_REQUEST_NUMBER(REQUEST_NUMBER) (((REQUEST_NUMBER) > 0U) && ((REQUEST_NUMBER) <= 32U)) | |||
#define IS_DMAMUX_SYNC_POLARITY(POLARITY) (((POLARITY) == HAL_DMAMUX_SYNC_NO_EVENT) || \ | |||
((POLARITY) == HAL_DMAMUX_SYNC_RISING) || \ | |||
((POLARITY) == HAL_DMAMUX_SYNC_FALLING) || \ | |||
((POLARITY) == HAL_DMAMUX_SYNC_RISING_FALLING)) | |||
#define IS_DMAMUX_SYNC_STATE(SYNC) (((SYNC) == DISABLE) || ((SYNC) == ENABLE)) | |||
#define IS_DMAMUX_SYNC_EVENT(EVENT) (((EVENT) == DISABLE) || \ | |||
((EVENT) == ENABLE)) | |||
#define IS_DMAMUX_REQUEST_GEN_SIGNAL_ID(SIGNAL_ID) ((SIGNAL_ID) <= HAL_DMAMUX1_REQ_GEN_LPTIM2_OUT) | |||
#define IS_DMAMUX_REQUEST_GEN_REQUEST_NUMBER(REQUEST_NUMBER) (((REQUEST_NUMBER) > 0U) && ((REQUEST_NUMBER) <= 32U)) | |||
#define IS_DMAMUX_REQUEST_GEN_POLARITY(POLARITY) (((POLARITY) == HAL_DMAMUX_REQ_GEN_NO_EVENT) || \ | |||
((POLARITY) == HAL_DMAMUX_REQ_GEN_RISING) || \ | |||
((POLARITY) == HAL_DMAMUX_REQ_GEN_FALLING) || \ | |||
((POLARITY) == HAL_DMAMUX_REQ_GEN_RISING_FALLING)) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_DMA_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,324 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_exti.h | |||
* @author MCD Application Team | |||
* @brief Header file of EXTI HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_EXTI_H | |||
#define STM32WBxx_HAL_EXTI_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup EXTI EXTI | |||
* @brief EXTI HAL module driver | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup EXTI_Exported_Types EXTI Exported Types | |||
* @{ | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_EXTI_COMMON_CB_ID = 0x00U, | |||
} EXTI_CallbackIDTypeDef; | |||
/** | |||
* @brief EXTI Handle structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Line; /*!< Exti line number */ | |||
void (* PendingCallback)(void); /*!< Exti pending callback */ | |||
} EXTI_HandleTypeDef; | |||
/** | |||
* @brief EXTI Configuration structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Line; /*!< The Exti line to be configured. This parameter | |||
can be a value of @ref EXTI_Line */ | |||
uint32_t Mode; /*!< The Exit Mode to be configured for a core. | |||
This parameter can be a combination of @ref EXTI_Mode */ | |||
uint32_t Trigger; /*!< The Exti Trigger to be configured. This parameter | |||
can be a value of @ref EXTI_Trigger */ | |||
uint32_t GPIOSel; /*!< The Exti GPIO multiplexer selection to be configured. | |||
This parameter is only possible for line 0 to 15. It | |||
can be a value of @ref EXTI_GPIOSel */ | |||
} EXTI_ConfigTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup EXTI_Exported_Constants EXTI Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup EXTI_Line EXTI Line | |||
* @{ | |||
*/ | |||
#define EXTI_LINE_0 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x00u) | |||
#define EXTI_LINE_1 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x01u) | |||
#define EXTI_LINE_2 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x02u) | |||
#define EXTI_LINE_3 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x03u) | |||
#define EXTI_LINE_4 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x04u) | |||
#define EXTI_LINE_5 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x05u) | |||
#define EXTI_LINE_6 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x06u) | |||
#define EXTI_LINE_7 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x07u) | |||
#define EXTI_LINE_8 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x08u) | |||
#define EXTI_LINE_9 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x09u) | |||
#define EXTI_LINE_10 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Au) | |||
#define EXTI_LINE_11 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Bu) | |||
#define EXTI_LINE_12 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Cu) | |||
#define EXTI_LINE_13 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Du) | |||
#define EXTI_LINE_14 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Eu) | |||
#define EXTI_LINE_15 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Fu) | |||
#define EXTI_LINE_16 (EXTI_CONFIG | EXTI_REG1 | 0x10u) | |||
#define EXTI_LINE_17 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG1 | 0x11u) | |||
#define EXTI_LINE_18 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG1 | 0x12u) | |||
#define EXTI_LINE_19 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG1 | 0x13u) | |||
#define EXTI_LINE_20 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG1 | 0x14u) | |||
#define EXTI_LINE_21 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG1 | 0x15u) | |||
#define EXTI_LINE_22 (EXTI_DIRECT | EXTI_REG1 | 0x16u) | |||
#define EXTI_LINE_23 (EXTI_DIRECT | EXTI_REG1 | 0x17u) | |||
#define EXTI_LINE_24 (EXTI_DIRECT | EXTI_REG1 | 0x18u) | |||
#define EXTI_LINE_25 (EXTI_DIRECT | EXTI_REG1 | 0x19u) | |||
#define EXTI_LINE_26 (EXTI_RESERVED | EXTI_REG1 | 0x1Au) | |||
#define EXTI_LINE_27 (EXTI_RESERVED | EXTI_REG1 | 0x1Bu) | |||
#define EXTI_LINE_28 (EXTI_DIRECT | EXTI_REG1 | 0x1Cu) | |||
#define EXTI_LINE_29 (EXTI_DIRECT | EXTI_REG1 | 0x1Du) | |||
#define EXTI_LINE_30 (EXTI_DIRECT | EXTI_REG1 | 0x1Eu) | |||
#define EXTI_LINE_31 (EXTI_CONFIG | EXTI_REG1 | 0x1Fu) | |||
#define EXTI_LINE_32 (EXTI_RESERVED | EXTI_REG2 | 0x00u) | |||
#define EXTI_LINE_33 (EXTI_CONFIG | EXTI_REG2 | 0x01u) | |||
#define EXTI_LINE_34 (EXTI_RESERVED | EXTI_REG2 | 0x02u) | |||
#define EXTI_LINE_35 (EXTI_RESERVED | EXTI_REG2 | 0x03u) | |||
#define EXTI_LINE_36 (EXTI_DIRECT | EXTI_REG2 | 0x04u) | |||
#define EXTI_LINE_37 (EXTI_DIRECT | EXTI_REG2 | 0x05u) | |||
#define EXTI_LINE_38 (EXTI_DIRECT | EXTI_REG2 | 0x06u) | |||
#define EXTI_LINE_39 (EXTI_DIRECT | EXTI_REG2 | 0x07u) | |||
#define EXTI_LINE_40 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG2 | 0x08u) | |||
#define EXTI_LINE_41 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG2 | 0x09u) | |||
#define EXTI_LINE_42 (EXTI_DIRECT | EXTI_REG2 | 0x0Au) | |||
#define EXTI_LINE_43 (EXTI_DIRECT | EXTI_REG2 | 0x0Bu) | |||
#define EXTI_LINE_44 (EXTI_DIRECT | EXTI_REG2 | 0x0Cu) | |||
#define EXTI_LINE_45 (EXTI_DIRECT | EXTI_REG2 | 0x0Du) | |||
#define EXTI_LINE_46 (EXTI_DIRECT | EXTI_REG2 | 0x0Eu) | |||
#define EXTI_LINE_47 (EXTI_RESERVED | EXTI_REG2 | 0x0Fu) | |||
#define EXTI_LINE_48 (EXTI_DIRECT | EXTI_REG2 | 0x10u) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup EXTI_Mode EXTI Mode | |||
* @{ | |||
*/ | |||
#define EXTI_MODE_NONE 0x00000000u | |||
#define EXTI_MODE_INTERRUPT 0x00000001u | |||
#define EXTI_MODE_EVENT 0x00000002u | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup EXTI_Trigger EXTI Trigger | |||
* @{ | |||
*/ | |||
#define EXTI_TRIGGER_NONE 0x00000000u | |||
#define EXTI_TRIGGER_RISING 0x00000001u | |||
#define EXTI_TRIGGER_FALLING 0x00000002u | |||
#define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup EXTI_GPIOSel EXTI GPIOSel | |||
* @brief | |||
* @{ | |||
*/ | |||
#define EXTI_GPIOA 0x00000000u | |||
#define EXTI_GPIOB 0x00000001u | |||
#define EXTI_GPIOC 0x00000002u | |||
#define EXTI_GPIOD 0x00000003u | |||
#define EXTI_GPIOE 0x00000004u | |||
#define EXTI_GPIOH 0x00000007u | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup EXTI_Exported_Macros EXTI Exported Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private constants --------------------------------------------------------*/ | |||
/** @defgroup EXTI_Private_Constants EXTI Private Constants | |||
* @{ | |||
*/ | |||
/** | |||
* @brief EXTI Line property definition | |||
*/ | |||
#define EXTI_PROPERTY_SHIFT 24u | |||
#define EXTI_DIRECT (0x01uL << EXTI_PROPERTY_SHIFT) | |||
#define EXTI_CONFIG (0x02uL << EXTI_PROPERTY_SHIFT) | |||
#define EXTI_GPIO ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG) | |||
#define EXTI_RESERVED (0x08uL << EXTI_PROPERTY_SHIFT) | |||
#define EXTI_PROPERTY_MASK (EXTI_DIRECT | EXTI_CONFIG | EXTI_GPIO) | |||
/** | |||
* @brief EXTI Event presence definition | |||
*/ | |||
#define EXTI_EVENT_PRESENCE_SHIFT 28u | |||
#define EXTI_EVENT (0x01uL << EXTI_EVENT_PRESENCE_SHIFT) | |||
#define EXTI_EVENT_PRESENCE_MASK (EXTI_EVENT) | |||
/** | |||
* @brief EXTI Register and bit usage | |||
*/ | |||
#define EXTI_REG_SHIFT 16u | |||
#define EXTI_REG1 (0x00uL << EXTI_REG_SHIFT) | |||
#define EXTI_REG2 (0x01uL << EXTI_REG_SHIFT) | |||
#define EXTI_REG_MASK (EXTI_REG1 | EXTI_REG2) | |||
#define EXTI_PIN_MASK 0x0000001Fu | |||
/** | |||
* @brief EXTI Mask for interrupt & event mode | |||
*/ | |||
#define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT) | |||
/** | |||
* @brief EXTI Mask for trigger possibilities | |||
*/ | |||
#define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) | |||
/** | |||
* @brief EXTI Line number | |||
*/ | |||
#define EXTI_LINE_NB 49uL | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup EXTI_Private_Macros EXTI Private Macros | |||
* @{ | |||
*/ | |||
#define IS_EXTI_LINE(__LINE__) ((((__LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_EVENT_PRESENCE_MASK | EXTI_REG_MASK | EXTI_PIN_MASK)) == 0x00u) && \ | |||
((((__LINE__) & EXTI_PROPERTY_MASK) == EXTI_DIRECT) || \ | |||
(((__LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \ | |||
(((__LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \ | |||
(((__LINE__) & (EXTI_REG_MASK | EXTI_PIN_MASK)) < \ | |||
(((EXTI_LINE_NB / 32u) << EXTI_REG_SHIFT) | (EXTI_LINE_NB % 32u)))) | |||
#define IS_EXTI_MODE(__LINE__) ((((__LINE__) & EXTI_MODE_MASK) != 0x00u) && \ | |||
(((__LINE__) & ~EXTI_MODE_MASK) == 0x00u)) | |||
#define IS_EXTI_TRIGGER(__LINE__) (((__LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u) | |||
#define IS_EXTI_PENDING_EDGE(__LINE__) ((__LINE__) == EXTI_TRIGGER_RISING_FALLING) | |||
#define IS_EXTI_CONFIG_LINE(__LINE__) (((__LINE__) & EXTI_CONFIG) != 0x00u) | |||
#define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ | |||
((__PORT__) == EXTI_GPIOB) || \ | |||
((__PORT__) == EXTI_GPIOC) || \ | |||
((__PORT__) == EXTI_GPIOD) || \ | |||
((__PORT__) == EXTI_GPIOE) || \ | |||
((__PORT__) == EXTI_GPIOH)) | |||
#define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16u) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup EXTI_Exported_Functions EXTI Exported Functions | |||
* @brief EXTI Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup EXTI_Exported_Functions_Group1 Configuration functions | |||
* @brief Configuration functions | |||
* @{ | |||
*/ | |||
/* Configuration functions ****************************************************/ | |||
HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); | |||
HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); | |||
HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti); | |||
HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void)); | |||
HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup EXTI_Exported_Functions_Group2 IO operation functions | |||
* @brief IO operation functions | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti); | |||
uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); | |||
void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); | |||
void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_EXTI_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,938 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_flash.h | |||
* @author MCD Application Team | |||
* @brief Header file of FLASH HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_FLASH_H | |||
#define STM32WBxx_HAL_FLASH_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup FLASH | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup FLASH_Exported_Types FLASH Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief FLASH Erase structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t TypeErase; /*!< Mass erase or page erase. | |||
This parameter can be a value of @ref FLASH_TYPE_ERASE */ | |||
uint32_t Page; /*!< Initial Flash page to erase when page erase is enabled | |||
This parameter must be a value between 0 and (FLASH_PAGE_NB - 1) */ | |||
uint32_t NbPages; /*!< Number of pages to be erased. | |||
This parameter must be a value between 1 and (FLASH_PAGE_NB - value of initial page)*/ | |||
} FLASH_EraseInitTypeDef; | |||
/** | |||
* @brief FLASH Option Bytes Program structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t OptionType; /*!< Option byte to be configured. | |||
This parameter can be a combination of the values of @ref FLASH_OB_TYPE */ | |||
uint32_t WRPArea; /*!< Write protection area to be programmed (used for OPTIONBYTE_WRP). | |||
Only one WRP area could be programmed at the same time. | |||
This parameter can be value of @ref FLASH_OB_WRP_AREA */ | |||
uint32_t WRPStartOffset; /*!< Write protection start offset (used for OPTIONBYTE_WRP). | |||
This parameter must be a value between 0 and (max number of pages - 1) */ | |||
uint32_t WRPEndOffset; /*!< Write protection end offset (used for OPTIONBYTE_WRP). | |||
This parameter must be a value between WRPStartOffset and (max number of pages - 1) */ | |||
uint32_t RDPLevel; /*!< Set the read protection level (used for OPTIONBYTE_RDP). | |||
This parameter can be a value of @ref FLASH_OB_READ_PROTECTION */ | |||
uint32_t UserType; /*!< User option byte(s) to be configured (used for OPTIONBYTE_USER). | |||
This parameter can be a combination of @ref FLASH_OB_USER_TYPE */ | |||
uint32_t UserConfig; /*!< Value of the user option byte (used for OPTIONBYTE_USER). | |||
This parameter can be a combination of the values of | |||
@ref FLASH_OB_USER_AGC_TRIM, @ref FLASH_OB_USER_BOR_LEVEL | |||
@ref FLASH_OB_USER_nRST_STOP, @ref FLASH_OB_USER_nRST_STANDBY, | |||
@ref FLASH_OB_USER_nRST_SHUTDOWN, @ref FLASH_OB_USER_IWDG_SW, | |||
@ref FLASH_OB_USER_IWDG_STOP, @ref FLASH_OB_USER_IWDG_STANDBY, | |||
@ref FLASH_OB_USER_WWDG_SW, @ref FLASH_OB_USER_nBOOT1, | |||
@ref FLASH_OB_USER_SRAM2PE, @ref FLASH_OB_USER_SRAM2RST, | |||
@ref FLASH_OB_USER_nSWBOOT0, @ref FLASH_OB_USER_nBOOT0 */ | |||
uint32_t PCROPConfig; /*!< Configuration of the PCROP (used for OPTIONBYTE_PCROP). | |||
This parameter must be a combination of values of @ref FLASH_OB_PCROP_ZONE | |||
and @ref FLASH_OB_PCROP_RDP */ | |||
uint32_t PCROP1AStartAddr; /*!< PCROP Zone A Start address (used for OPTIONBYTE_PCROP). It represents first address of start block | |||
to protect. Make sure this parameter is multiple of PCROP granularity */ | |||
uint32_t PCROP1AEndAddr; /*!< PCROP Zone A End address (used for OPTIONBYTE_PCROP). It represents first address of end block | |||
to protect. Make sure this parameter is multiple of PCROP granularity */ | |||
uint32_t PCROP1BStartAddr; /*!< PCROP Zone B Start address (used for OPTIONBYTE_PCROP). It represents first address of start block | |||
to protect. Make sure this parameter is multiple of PCROP granularity */ | |||
uint32_t PCROP1BEndAddr; /*!< PCROP Zone B End address (used for OPTIONBYTE_PCROP). It represents first address of end block | |||
to protect. Make sure this parameter is multiple of PCROP granularity */ | |||
uint32_t SecureFlashStartAddr; /*!< Secure Flash start address (used for OPTIONBYTE_SECURE_MODE). | |||
This parameter must be a value between begin and end of Flash bank | |||
=> Contains the start address of the first 4kB page of the secure Flash area */ | |||
uint32_t SecureRAM2aStartAddr; /*!< Secure Backup RAM2a start address (used for OPTIONBYTE_SECURE_MODE). | |||
This parameter can be a value of @ref FLASH_SRAM2A_ADDRESS_RANGE */ | |||
uint32_t SecureRAM2bStartAddr; /*!< Secure non-Backup RAM2b start address (used for OPTIONBYTE_SECURE_MODE) | |||
This parameter can be a value of @ref FLASH_SRAM2B_ADDRESS_RANGE */ | |||
uint32_t SecureMode; /*!< Secure mode activated or desactivated. | |||
This parameter can be a value of @ref FLASH_OB_SECURITY_MODE */ | |||
uint32_t C2BootRegion; /*!< CPU2 Secure Boot memory region(used for OPTIONBYTE_C2_BOOT_VECT). | |||
This parameter can be a value of @ref C2_FLASH_OB_BOOT_REGION */ | |||
uint32_t C2SecureBootVectAddr; /*!< CPU2 Secure Boot reset vector (used for OPTIONBYTE_C2_BOOT_VECT). | |||
This parameter contains the CPU2 boot reset start address within | |||
the selected memory region. Make sure this parameter is word aligned. */ | |||
uint32_t IPCCdataBufAddr; /*!< IPCC mailbox data buffer base address (used for OPTIONBYTE_IPCC_BUF_ADDR). | |||
This parameter contains the IPCC mailbox data buffer start address area in SRAM2. | |||
Make sure this parameter is double-word aligned. */ | |||
} FLASH_OBProgramInitTypeDef; | |||
/** | |||
* @brief FLASH handle Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
HAL_LockTypeDef Lock; /* FLASH locking object */ | |||
uint32_t ErrorCode; /* FLASH error code */ | |||
uint32_t ProcedureOnGoing; /* Internal variable to indicate which procedure is ongoing or not in IT context */ | |||
uint32_t Address; /* Internal variable to save address selected for program in IT context */ | |||
uint32_t Page; /* Internal variable to define the current page which is erasing in IT context */ | |||
uint32_t NbPagesToErase; /* Internal variable to save the remaining pages to erase in IT context */ | |||
} FLASH_ProcessTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup FLASH_Exported_Constants FLASH Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup FLASH_KEYS FLASH Keys | |||
* @{ | |||
*/ | |||
#define FLASH_KEY1 0x45670123U /*!< Flash key1 */ | |||
#define FLASH_KEY2 0xCDEF89ABU /*!< Flash key2: used with FLASH_KEY1 | |||
to unlock the FLASH registers access */ | |||
#define FLASH_OPTKEY1 0x08192A3BU /*!< Flash option byte key1 */ | |||
#define FLASH_OPTKEY2 0x4C5D6E7FU /*!< Flash option byte key2: used with FLASH_OPTKEY1 | |||
to allow option bytes operations */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_LATENCY FLASH Latency | |||
* @{ | |||
*/ | |||
#define FLASH_LATENCY_0 0x00000000UL /*!< FLASH Zero wait state */ | |||
#define FLASH_LATENCY_1 FLASH_ACR_LATENCY_0 /*!< FLASH One wait state */ | |||
#define FLASH_LATENCY_2 FLASH_ACR_LATENCY_1 /*!< FLASH Two wait states */ | |||
#define FLASH_LATENCY_3 FLASH_ACR_LATENCY_2 /*!< FLASH Three wait states */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_FLAGS FLASH Flags Definition | |||
* @{ | |||
*/ | |||
#define FLASH_FLAG_EOP FLASH_SR_EOP /*!< FLASH End of operation flag */ | |||
#define FLASH_FLAG_OPERR FLASH_SR_OPERR /*!< FLASH Operation error flag */ | |||
#define FLASH_FLAG_PROGERR FLASH_SR_PROGERR /*!< FLASH Programming error flag */ | |||
#define FLASH_FLAG_WRPERR FLASH_SR_WRPERR /*!< FLASH Write protection error flag */ | |||
#define FLASH_FLAG_PGAERR FLASH_SR_PGAERR /*!< FLASH Programming alignment error flag */ | |||
#define FLASH_FLAG_SIZERR FLASH_SR_SIZERR /*!< FLASH Size error flag */ | |||
#define FLASH_FLAG_PGSERR FLASH_SR_PGSERR /*!< FLASH Programming sequence error flag */ | |||
#define FLASH_FLAG_MISERR FLASH_SR_MISERR /*!< FLASH Fast programming data miss error flag */ | |||
#define FLASH_FLAG_FASTERR FLASH_SR_FASTERR /*!< FLASH Fast programming error flag */ | |||
#define FLASH_FLAG_OPTNV FLASH_SR_OPTNV /*!< FLASH User Option OPTVAL indication */ | |||
#define FLASH_FLAG_RDERR FLASH_SR_RDERR /*!< FLASH PCROP read error flag */ | |||
#define FLASH_FLAG_OPTVERR FLASH_SR_OPTVERR /*!< FLASH Option validity error flag */ | |||
#define FLASH_FLAG_BSY FLASH_SR_BSY /*!< FLASH Busy flag */ | |||
#define FLASH_FLAG_CFGBSY FLASH_SR_CFGBSY /*!< FLASH Programming/erase configuration busy */ | |||
#define FLASH_FLAG_PESD FLASH_SR_PESD /*!< FLASH Programming/erase operation suspended */ | |||
#define FLASH_FLAG_ECCC FLASH_ECCR_ECCC /*!< FLASH ECC correction */ | |||
#define FLASH_FLAG_ECCD FLASH_ECCR_ECCD /*!< FLASH ECC detection */ | |||
#define FLASH_FLAG_SR_ERROR (FLASH_FLAG_OPERR | FLASH_FLAG_PROGERR | FLASH_FLAG_WRPERR | \ | |||
FLASH_FLAG_PGAERR | FLASH_FLAG_SIZERR | FLASH_FLAG_PGSERR | \ | |||
FLASH_FLAG_MISERR | FLASH_FLAG_FASTERR | FLASH_FLAG_RDERR | \ | |||
FLASH_FLAG_OPTVERR) /*!< All SR error flags */ | |||
#define FLASH_FLAG_ALL_ERRORS (FLASH_FLAG_SR_ERROR | FLASH_FLAG_ECCC | FLASH_FLAG_ECCD) | |||
/** @defgroup FLASH_INTERRUPT_DEFINITION FLASH Interrupts Definition | |||
* @brief FLASH Interrupt definition | |||
* @{ | |||
*/ | |||
#define FLASH_IT_EOP FLASH_CR_EOPIE /*!< End of FLASH Operation Interrupt source */ | |||
#define FLASH_IT_OPERR FLASH_CR_ERRIE /*!< Error Interrupt source */ | |||
#define FLASH_IT_RDERR FLASH_CR_RDERRIE /*!< PCROP Read Error Interrupt source */ | |||
#define FLASH_IT_ECCC (FLASH_ECCR_ECCCIE >> FLASH_ECCR_ECCCIE_Pos) /*!< ECC Correction Interrupt source */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_ERROR FLASH Error | |||
* @{ | |||
*/ | |||
#define HAL_FLASH_ERROR_NONE 0x00000000U | |||
#define HAL_FLASH_ERROR_OP FLASH_FLAG_OPERR | |||
#define HAL_FLASH_ERROR_PROG FLASH_FLAG_PROGERR | |||
#define HAL_FLASH_ERROR_WRP FLASH_FLAG_WRPERR | |||
#define HAL_FLASH_ERROR_PGA FLASH_FLAG_PGAERR | |||
#define HAL_FLASH_ERROR_SIZ FLASH_FLAG_SIZERR | |||
#define HAL_FLASH_ERROR_PGS FLASH_FLAG_PGSERR | |||
#define HAL_FLASH_ERROR_MIS FLASH_FLAG_MISERR | |||
#define HAL_FLASH_ERROR_FAST FLASH_FLAG_FASTERR | |||
#define HAL_FLASH_ERROR_RD FLASH_FLAG_RDERR | |||
#define HAL_FLASH_ERROR_OPTV FLASH_FLAG_OPTVERR | |||
#define HAL_FLASH_ERROR_ECCD FLASH_FLAG_ECCD | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_TYPE_ERASE FLASH Erase Type | |||
* @{ | |||
*/ | |||
#define FLASH_TYPEERASE_PAGES FLASH_CR_PER /*!< Pages erase only*/ | |||
#define FLASH_TYPEERASE_MASSERASE FLASH_CR_MER /*!< Flash mass erase activation*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_TYPE_PROGRAM FLASH Program Type | |||
* @{ | |||
*/ | |||
#define FLASH_TYPEPROGRAM_DOUBLEWORD FLASH_CR_PG /*!< Program a double-word (64-bit) at a specified address.*/ | |||
#define FLASH_TYPEPROGRAM_FAST FLASH_CR_FSTPG /*!< Fast program a 64 row double-word (64-bit) at a specified address. | |||
And another 64 row double-word (64-bit) will be programmed */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_TYPE FLASH Option Bytes Type | |||
* @{ | |||
*/ | |||
#define OPTIONBYTE_WRP 0x00000001U /*!< WRP option byte configuration */ | |||
#define OPTIONBYTE_RDP 0x00000002U /*!< RDP option byte configuration */ | |||
#define OPTIONBYTE_USER 0x00000004U /*!< User option byte configuration */ | |||
#define OPTIONBYTE_PCROP 0x00000008U /*!< PCROP option byte configuration */ | |||
#define OPTIONBYTE_IPCC_BUF_ADDR 0x00000010U /*!< IPCC mailbox buffer address configuration */ | |||
#define OPTIONBYTE_C2_BOOT_VECT 0x00000100U /*!< CPU2 Secure Boot reset vector */ | |||
#define OPTIONBYTE_SECURE_MODE 0x00000200U /*!< Secure mode on activated or not */ | |||
#define OPTIONBYTE_ALL (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER | \ | |||
OPTIONBYTE_PCROP | OPTIONBYTE_IPCC_BUF_ADDR | OPTIONBYTE_C2_BOOT_VECT | \ | |||
OPTIONBYTE_SECURE_MODE) /*!< All option byte configuration */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_WRP_AREA FLASH WRP Area | |||
* @{ | |||
*/ | |||
#define OB_WRPAREA_BANK1_AREAA 0x00000000U /*!< Flash Area A */ | |||
#define OB_WRPAREA_BANK1_AREAB 0x00000001U /*!< Flash Area B */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_READ_PROTECTION FLASH Option Bytes Read Protection | |||
* @{ | |||
*/ | |||
#define OB_RDP_LEVEL_0 0x000000AAU | |||
#define OB_RDP_LEVEL_1 0x000000BBU | |||
#define OB_RDP_LEVEL_2 0x000000CCU /*!< Warning: When enabling read protection level 2 | |||
it's no more possible to go back to level 1 or 0 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_TYPE FLASH Option Bytes User Type | |||
* @{ | |||
*/ | |||
#define OB_USER_BOR_LEV FLASH_OPTR_BOR_LEV /*!< BOR reset Level */ | |||
#define OB_USER_nRST_STOP FLASH_OPTR_nRST_STOP /*!< Reset generated when entering the stop mode */ | |||
#define OB_USER_nRST_STDBY FLASH_OPTR_nRST_STDBY /*!< Reset generated when entering the standby mode */ | |||
#define OB_USER_nRST_SHDW FLASH_OPTR_nRST_SHDW /*!< Reset generated when entering the shutdown mode */ | |||
#define OB_USER_IWDG_SW FLASH_OPTR_IWDG_SW /*!< Independent watchdog selection */ | |||
#define OB_USER_IWDG_STOP FLASH_OPTR_IWDG_STOP /*!< Independent watchdog counter freeze in stop mode */ | |||
#define OB_USER_IWDG_STDBY FLASH_OPTR_IWDG_STDBY /*!< Independent watchdog counter freeze in standby mode */ | |||
#define OB_USER_WWDG_SW FLASH_OPTR_WWDG_SW /*!< Window watchdog selection */ | |||
#define OB_USER_nBOOT1 FLASH_OPTR_nBOOT1 /*!< Boot configuration */ | |||
#define OB_USER_SRAM2PE FLASH_OPTR_SRAM2PE /*!< SRAM2 parity check enable */ | |||
#define OB_USER_SRAM2RST FLASH_OPTR_SRAM2RST /*!< SRAM2 erase when system reset */ | |||
#define OB_USER_nSWBOOT0 FLASH_OPTR_nSWBOOT0 /*!< Software BOOT0 */ | |||
#define OB_USER_nBOOT0 FLASH_OPTR_nBOOT0 /*!< nBOOT0 option bit */ | |||
#define OB_USER_AGC_TRIM FLASH_OPTR_AGC_TRIM /*!< Automatic Gain Control Trimming */ | |||
#define OB_USER_ALL (OB_USER_BOR_LEV | OB_USER_nRST_STOP | OB_USER_nRST_STDBY | \ | |||
OB_USER_nRST_SHDW | OB_USER_IWDG_SW | OB_USER_IWDG_STOP | \ | |||
OB_USER_IWDG_STDBY | OB_USER_WWDG_SW | OB_USER_nBOOT1 | \ | |||
OB_USER_SRAM2PE | OB_USER_SRAM2RST | OB_USER_nSWBOOT0 | \ | |||
OB_USER_nBOOT0 | OB_USER_AGC_TRIM) /*!< all option bits */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_AGC_TRIM FLASH Option Bytes Automatic Gain Control Trimming | |||
* @{ | |||
*/ | |||
#define OB_AGC_TRIM_0 0x00000000U /*!< Automatic Gain Control Trimming Value 0 */ | |||
#define OB_AGC_TRIM_1 FLASH_OPTR_AGC_TRIM_0 /*!< Automatic Gain Control Trimming Value 1 */ | |||
#define OB_AGC_TRIM_2 FLASH_OPTR_AGC_TRIM_1 /*!< Automatic Gain Control Trimming Value 2 */ | |||
#define OB_AGC_TRIM_3 (FLASH_OPTR_AGC_TRIM_1 | FLASH_OPTR_AGC_TRIM_0) /*!< Automatic Gain Control Trimming Value 3 */ | |||
#define OB_AGC_TRIM_4 FLASH_OPTR_AGC_TRIM_2 /*!< Automatic Gain Control Trimming Value 4 */ | |||
#define OB_AGC_TRIM_5 (FLASH_OPTR_AGC_TRIM_2 | FLASH_OPTR_AGC_TRIM_0) /*!< Automatic Gain Control Trimming Value 5 */ | |||
#define OB_AGC_TRIM_6 (FLASH_OPTR_AGC_TRIM_2 | FLASH_OPTR_AGC_TRIM_1) /*!< Automatic Gain Control Trimming Value 6 */ | |||
#define OB_AGC_TRIM_7 (FLASH_OPTR_AGC_TRIM_2 | FLASH_OPTR_AGC_TRIM_1 | FLASH_OPTR_AGC_TRIM_0) /*!< Automatic Gain Control Trimming Value 7 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_BOR_LEVEL FLASH Option Bytes User BOR Level | |||
* @{ | |||
*/ | |||
#define OB_BOR_LEVEL_0 0x00000000U /*!< Reset level threshold is around 1.7V */ | |||
#define OB_BOR_LEVEL_1 FLASH_OPTR_BOR_LEV_0 /*!< Reset level threshold is around 2.0V */ | |||
#define OB_BOR_LEVEL_2 FLASH_OPTR_BOR_LEV_1 /*!< Reset level threshold is around 2.2V */ | |||
#define OB_BOR_LEVEL_3 (FLASH_OPTR_BOR_LEV_0 | FLASH_OPTR_BOR_LEV_1) /*!< Reset level threshold is around 2.5V */ | |||
#define OB_BOR_LEVEL_4 FLASH_OPTR_BOR_LEV_2 /*!< Reset level threshold is around 2.8V */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_nRST_STOP FLASH Option Bytes User Reset On Stop | |||
* @{ | |||
*/ | |||
#define OB_STOP_RST 0x00000000U /*!< Reset generated when entering the stop mode */ | |||
#define OB_STOP_NORST FLASH_OPTR_nRST_STOP /*!< No reset generated when entering the stop mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_nRST_STANDBY FLASH Option Bytes User Reset On Standby | |||
* @{ | |||
*/ | |||
#define OB_STANDBY_RST 0x00000000U /*!< Reset generated when entering the standby mode */ | |||
#define OB_STANDBY_NORST FLASH_OPTR_nRST_STDBY /*!< No reset generated when entering the standby mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_nRST_SHUTDOWN FLASH Option Bytes User Reset On Shutdown | |||
* @{ | |||
*/ | |||
#define OB_SHUTDOWN_RST 0x00000000U /*!< Reset generated when entering the shutdown mode */ | |||
#define OB_SHUTDOWN_NORST FLASH_OPTR_nRST_SHDW /*!< No reset generated when entering the shutdown mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_IWDG_SW FLASH Option Bytes User IWDG Type | |||
* @{ | |||
*/ | |||
#define OB_IWDG_HW 0x00000000U /*!< Hardware independent watchdog */ | |||
#define OB_IWDG_SW FLASH_OPTR_IWDG_SW /*!< Software independent watchdog */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_IWDG_STOP FLASH Option Bytes User IWDG Mode On Stop | |||
* @{ | |||
*/ | |||
#define OB_IWDG_STOP_FREEZE 0x00000000U /*!< Independent watchdog counter is frozen in Stop mode */ | |||
#define OB_IWDG_STOP_RUN FLASH_OPTR_IWDG_STOP /*!< Independent watchdog counter is running in Stop mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_IWDG_STANDBY FLASH Option Bytes User IWDG Mode On Standby | |||
* @{ | |||
*/ | |||
#define OB_IWDG_STDBY_FREEZE 0x00000000U /*!< Independent watchdog counter is frozen in Standby mode */ | |||
#define OB_IWDG_STDBY_RUN FLASH_OPTR_IWDG_STDBY /*!< Independent watchdog counter is running in Standby mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_WWDG_SW FLASH Option Bytes User WWDG Type | |||
* @{ | |||
*/ | |||
#define OB_WWDG_HW 0x00000000U /*!< Hardware window watchdog */ | |||
#define OB_WWDG_SW FLASH_OPTR_WWDG_SW /*!< Software window watchdog */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_SRAM2PE FLASH Option Bytes SRAM2 parity check | |||
* @{ | |||
*/ | |||
#define OB_SRAM2_PARITY_ENABLE 0x00000000U /*!< SRAM2 parity check enable */ | |||
#define OB_SRAM2_PARITY_DISABLE FLASH_OPTR_SRAM2PE /*!< SRAM2 parity check disable */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_SRAM2RST FLASH Option Bytes SRAM2 erase when system reset | |||
* @{ | |||
*/ | |||
#define OB_SRAM2_RST_ERASE 0x00000000U /*!< SRAM2 erased when a system reset */ | |||
#define OB_SRAM2_RST_NOT_ERASE FLASH_OPTR_SRAM2RST /*!< SRAM2 is not erased when a system reset */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_nBOOT1 FLASH Option Bytes User BOOT1 Type | |||
* @{ | |||
*/ | |||
#define OB_BOOT1_SRAM 0x00000000U /*!< Embedded SRAM is selected as boot space (if BOOT0=1) */ | |||
#define OB_BOOT1_SYSTEM FLASH_OPTR_nBOOT1 /*!< System memory is selected as boot space (if BOOT0=1) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_nSWBOOT0 FLASH Option Bytes User Software BOOT0 | |||
* @{ | |||
*/ | |||
#define OB_BOOT0_FROM_OB 0x00000000U /*!< BOOT0 taken from the option bit nBOOT0 */ | |||
#define OB_BOOT0_FROM_PIN FLASH_OPTR_nSWBOOT0 /*!< BOOT0 taken from PH3/BOOT0 pin */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_USER_nBOOT0 FLASH Option Bytes User nBOOT0 option bit | |||
* @{ | |||
*/ | |||
#define OB_BOOT0_RESET 0x00000000U /*!< nBOOT0 = 0 */ | |||
#define OB_BOOT0_SET FLASH_OPTR_nBOOT0 /*!< nBOOT0 = 1 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_PCROP_ZONE FLASH PCROP ZONE | |||
* @{ | |||
*/ | |||
#define OB_PCROP_ZONE_A 0x00000001U /*!< PCROP Zone A */ | |||
#define OB_PCROP_ZONE_B 0x00000002U /*!< PCROP Zone B */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_PCROP_RDP FLASH Option Bytes PCROP On RDP Level Type | |||
* @{ | |||
*/ | |||
#define OB_PCROP_RDP_NOT_ERASE 0x00000000U /*!< PCROP area is not erased when the RDP level | |||
is decreased from Level 1 to Level 0 */ | |||
#define OB_PCROP_RDP_ERASE FLASH_PCROP1AER_PCROP_RDP /*!< PCROP area is erased when the RDP level is | |||
decreased from Level 1 to Level 0 (full mass erase) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_OB_SECURITY_MODE Option Bytes FLASH Secure mode | |||
* @{ | |||
*/ | |||
#define SYSTEM_NOT_IN_SECURE_MODE 0x00000000U /*!< Unsecure mode: Security disabled */ | |||
#define SYSTEM_IN_SECURE_MODE FLASH_OPTR_ESE /*!< Secure mode : Security enabled */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup C2_FLASH_OB_BOOT_REGION CPU2 Option Bytes Reset Boot Vector | |||
* @{ | |||
*/ | |||
#define OB_C2_BOOT_FROM_SRAM 0x00000000U /*!< CPU2 boot from Sram */ | |||
#define OB_C2_BOOT_FROM_FLASH FLASH_SRRVR_C2OPT /*!< CPU2 boot from Flash */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_SRAM2A_ADDRESS_RANGE RAM2A address range in secure mode | |||
* @{ | |||
*/ | |||
#define SRAM2A_START_SECURE_ADDR_0 0x20030000U /* When in secure mode 0x20030000 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_1 0x20030400U /* When in secure mode 0x20030400 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_2 0x20030800U /* When in secure mode 0x20030800 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_3 0x20030C00U /* When in secure mode 0x20030C00 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_4 0x20031000U /* When in secure mode 0x20031000 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_5 0x20031400U /* When in secure mode 0x20031400 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_6 0x20031800U /* When in secure mode 0x20031800 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_7 0x20031C00U /* When in secure mode 0x20031C00 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_8 0x20032000U /* When in secure mode 0x20032000 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_9 0x20032400U /* When in secure mode 0x20032400 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_10 0x20032800U /* When in secure mode 0x20032800 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_11 0x20032C00U /* When in secure mode 0x20032C00 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_12 0x20033000U /* When in secure mode 0x20033000 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_13 0x20033400U /* When in secure mode 0x20033400 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_14 0x20033800U /* When in secure mode 0x20033800 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_15 0x20033C00U /* When in secure mode 0x20033C00 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_16 0x20034000U /* When in secure mode 0x20034000 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_17 0x20034400U /* When in secure mode 0x20034400 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_18 0x20034800U /* When in secure mode 0x20034800 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_19 0x20034C00U /* When in secure mode 0x20034C00 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_20 0x20035000U /* When in secure mode 0x20035000 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_21 0x20035400U /* When in secure mode 0x20035400 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_22 0x20035800U /* When in secure mode 0x20035800 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_23 0x20035C00U /* When in secure mode 0x20035C00 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_24 0x20036000U /* When in secure mode 0x20036000 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_25 0x20036400U /* When in secure mode 0x20036400 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_26 0x20036800U /* When in secure mode 0x20036800 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_27 0x20036C00U /* When in secure mode 0x20036C00 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_28 0x20037000U /* When in secure mode 0x20037000 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_29 0x20037400U /* When in secure mode 0x20037400 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_30 0x20037800U /* When in secure mode 0x20037800 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_START_SECURE_ADDR_31 0x20037C00U /* When in secure mode 0x20037C00 - 0x20037FFF is accessible only by M0 Plus */ | |||
#define SRAM2A_FULL_UNSECURE 0x20040000U /* The RAM2A is accessible to M0 Plus and M4 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_SRAM2B_ADDRESS_RANGE RAM2B address range in secure mode | |||
* @{ | |||
*/ | |||
#define SRAM2B_START_SECURE_ADDR_0 0x20038000U /* When in secure mode 0x20038000 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_1 0x20038400U /* When in secure mode 0x20038400 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_2 0x20038800U /* When in secure mode 0x20038800 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_3 0x20038C00U /* When in secure mode 0x20038C00 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_4 0x20039000U /* When in secure mode 0x20039000 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_5 0x20039400U /* When in secure mode 0x20039400 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_6 0x20039800U /* When in secure mode 0x20039800 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_7 0x20039C00U /* When in secure mode 0x20039C00 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_8 0x2003A000U /* When in secure mode 0x2003A000 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_9 0x2003A400U /* When in secure mode 0x2003A400 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_10 0x2003A800U /* When in secure mode 0x2003A800 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_11 0x2003AC00U /* When in secure mode 0x2003AC00 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_12 0x2003B000U /* When in secure mode 0x2003B000 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_13 0x2003B400U /* When in secure mode 0x2003B400 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_14 0x2003B800U /* When in secure mode 0x2003B800 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_15 0x2003BC00U /* When in secure mode 0x2003BC00 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_16 0x2003C000U /* When in secure mode 0x2003C000 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_17 0x2003C400U /* When in secure mode 0x2003C400 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_18 0x2003C800U /* When in secure mode 0x2003C800 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_19 0x2003CC00U /* When in secure mode 0x2003CC00 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_20 0x2003D000U /* When in secure mode 0x2003D000 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_21 0x2003D400U /* When in secure mode 0x2003D400 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_22 0x2003D800U /* When in secure mode 0x2003D800 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_23 0x2003DC00U /* When in secure mode 0x2003DC00 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_24 0x2003E000U /* When in secure mode 0x2003E000 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_25 0x2003E400U /* When in secure mode 0x2003E400 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_26 0x2003E800U /* When in secure mode 0x2003E800 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_27 0x2003EC00U /* When in secure mode 0x2003EC00 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_28 0x2003F000U /* When in secure mode 0x2003F000 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_29 0x2003F400U /* When in secure mode 0x2003F400 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_30 0x2003F800U /* When in secure mode 0x2003F800 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_START_SECURE_ADDR_31 0x2003FC00U /* When in secure mode 0x2003FC00 - 0x2003FFFF is accessible only by M0 Plus */ | |||
#define SRAM2B_FULL_UNSECURE 0x2003FF00U /* The RAM2B is accessible to M0 Plus and M4 */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup FLASH_Exported_Macros FLASH Exported Macros | |||
* @brief macros to control FLASH features | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Set the FLASH Latency. | |||
* @param __LATENCY__ FLASH Latency | |||
* This parameter can be one of the following values : | |||
* @arg @ref FLASH_LATENCY_0 FLASH Zero wait state | |||
* @arg @ref FLASH_LATENCY_1 FLASH One wait state | |||
* @arg @ref FLASH_LATENCY_2 FLASH Two wait states | |||
* @arg @ref FLASH_LATENCY_3 FLASH Three wait states | |||
* @retval None | |||
*/ | |||
#define __HAL_FLASH_SET_LATENCY(__LATENCY__) MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (__LATENCY__)) | |||
/** | |||
* @brief Get the FLASH Latency. | |||
* @retval FLASH Latency | |||
* Returned value can be one of the following values : | |||
* @arg @ref FLASH_LATENCY_0 FLASH Zero wait state | |||
* @arg @ref FLASH_LATENCY_1 FLASH One wait state | |||
* @arg @ref FLASH_LATENCY_2 FLASH Two wait states | |||
* @arg @ref FLASH_LATENCY_3 FLASH Three wait states | |||
*/ | |||
#define __HAL_FLASH_GET_LATENCY() READ_BIT(FLASH->ACR, FLASH_ACR_LATENCY) | |||
/** | |||
* @brief Enable the FLASH prefetch buffer. | |||
* @retval None | |||
*/ | |||
#define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_PRFTEN) | |||
/** | |||
* @brief Disable the FLASH prefetch buffer. | |||
* @retval None | |||
*/ | |||
#define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_PRFTEN) | |||
/** | |||
* @brief Enable the FLASH instruction cache. | |||
* @retval none | |||
*/ | |||
#define __HAL_FLASH_INSTRUCTION_CACHE_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_ICEN) | |||
/** | |||
* @brief Disable the FLASH instruction cache. | |||
* @retval none | |||
*/ | |||
#define __HAL_FLASH_INSTRUCTION_CACHE_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_ICEN) | |||
/** | |||
* @brief Enable the FLASH data cache. | |||
* @retval none | |||
*/ | |||
#define __HAL_FLASH_DATA_CACHE_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_DCEN) | |||
/** | |||
* @brief Disable the FLASH data cache. | |||
* @retval none | |||
*/ | |||
#define __HAL_FLASH_DATA_CACHE_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_DCEN) | |||
/** | |||
* @brief Reset the FLASH instruction Cache. | |||
* @note This function must be used only when the Instruction Cache is disabled. | |||
* @retval None | |||
*/ | |||
#define __HAL_FLASH_INSTRUCTION_CACHE_RESET() do { SET_BIT(FLASH->ACR, FLASH_ACR_ICRST); \ | |||
CLEAR_BIT(FLASH->ACR, FLASH_ACR_ICRST); \ | |||
} while (0) | |||
/** | |||
* @brief Reset the FLASH data Cache. | |||
* @note This function must be used only when the data Cache is disabled. | |||
* @retval None | |||
*/ | |||
#define __HAL_FLASH_DATA_CACHE_RESET() do { SET_BIT(FLASH->ACR, FLASH_ACR_DCRST); \ | |||
CLEAR_BIT(FLASH->ACR, FLASH_ACR_DCRST); \ | |||
} while (0) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup FLASH_Interrupt FLASH Interrupts Macros | |||
* @brief macros to handle FLASH interrupts | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable the specified FLASH interrupt. | |||
* @param __INTERRUPT__ FLASH interrupt | |||
* This parameter can be any combination of the following values: | |||
* @arg @ref FLASH_IT_EOP End of FLASH Operation Interrupt | |||
* @arg @ref FLASH_IT_OPERR Error Interrupt | |||
* @arg @ref FLASH_IT_RDERR PCROP Read Error Interrupt | |||
* @arg @ref FLASH_IT_ECCC ECC Correction Interrupt | |||
* @retval none | |||
*/ | |||
#define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) do { if(((__INTERRUPT__) & FLASH_IT_ECCC) != 0U) { SET_BIT(FLASH->ECCR, FLASH_ECCR_ECCCIE); }\ | |||
if(((__INTERRUPT__) & (~FLASH_IT_ECCC)) != 0U) { SET_BIT(FLASH->CR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\ | |||
} while(0) | |||
/** | |||
* @brief Disable the specified FLASH interrupt. | |||
* @param __INTERRUPT__ FLASH interrupt | |||
* This parameter can be any combination of the following values: | |||
* @arg @ref FLASH_IT_EOP End of FLASH Operation Interrupt | |||
* @arg @ref FLASH_IT_OPERR Error Interrupt | |||
* @arg @ref FLASH_IT_RDERR PCROP Read Error Interrupt | |||
* @arg @ref FLASH_IT_ECCC ECC Correction Interrupt | |||
* @retval none | |||
*/ | |||
#define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) do { if(((__INTERRUPT__) & FLASH_IT_ECCC) != 0U) { CLEAR_BIT(FLASH->ECCR, FLASH_ECCR_ECCCIE); }\ | |||
if(((__INTERRUPT__) & (~FLASH_IT_ECCC)) != 0U) { CLEAR_BIT(FLASH->CR, ((__INTERRUPT__) & (~FLASH_IT_ECCC))); }\ | |||
} while(0) | |||
/** | |||
* @brief Check whether the specified FLASH flag is set or not. | |||
* @param __FLAG__ specifies the FLASH flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref FLASH_FLAG_EOP FLASH End of Operation flag | |||
* @arg @ref FLASH_FLAG_OPERR FLASH Operation error flag | |||
* @arg @ref FLASH_FLAG_PROGERR FLASH Programming error flag | |||
* @arg @ref FLASH_FLAG_WRPERR FLASH Write protection error flag | |||
* @arg @ref FLASH_FLAG_PGAERR FLASH Programming alignment error flag | |||
* @arg @ref FLASH_FLAG_SIZERR FLASH Size error flag | |||
* @arg @ref FLASH_FLAG_PGSERR FLASH Programming sequence error flag | |||
* @arg @ref FLASH_FLAG_MISERR FLASH Fast programming data miss error flag | |||
* @arg @ref FLASH_FLAG_FASTERR FLASH Fast programming error flag | |||
* @arg @ref FLASH_FLAG_OPTNV FLASH User Option OPTVAL indication | |||
* @arg @ref FLASH_FLAG_RDERR FLASH PCROP read error flag | |||
* @arg @ref FLASH_FLAG_OPTVERR FLASH Option validity error flag | |||
* @arg @ref FLASH_FLAG_BSY FLASH write/erase operations in progress flag | |||
* @arg @ref FLASH_FLAG_CFGBSY Programming/erase configuration busy | |||
* @arg @ref FLASH_FLAG_PESD FLASH Programming/erase operation suspended | |||
* @arg @ref FLASH_FLAG_ECCC FLASH one ECC error has been detected and corrected | |||
* @arg @ref FLASH_FLAG_ECCD FLASH two ECC errors have been detected | |||
* @retval The new state of FLASH_FLAG (SET or RESET). | |||
*/ | |||
#define __HAL_FLASH_GET_FLAG(__FLAG__) ((((__FLAG__) & (FLASH_FLAG_ECCC | FLASH_FLAG_ECCD)) != 0U) ? \ | |||
(READ_BIT(FLASH->ECCR, (__FLAG__)) == (__FLAG__)) : \ | |||
(READ_BIT(FLASH->SR, (__FLAG__)) == (__FLAG__))) | |||
/** | |||
* @brief Clear the FLASH's pending flags. | |||
* @param __FLAG__ specifies the FLASH flags to clear. | |||
* This parameter can be any combination of the following values: | |||
* @arg @ref FLASH_FLAG_EOP FLASH End of Operation flag | |||
* @arg @ref FLASH_FLAG_OPERR FLASH Operation error flag | |||
* @arg @ref FLASH_FLAG_PROGERR FLASH Programming error flag | |||
* @arg @ref FLASH_FLAG_WRPERR FLASH Write protection error flag | |||
* @arg @ref FLASH_FLAG_PGAERR FLASH Programming alignment error flag | |||
* @arg @ref FLASH_FLAG_SIZERR FLASH Size error flag | |||
* @arg @ref FLASH_FLAG_PGSERR FLASH Programming sequence error flag | |||
* @arg @ref FLASH_FLAG_MISERR FLASH Fast programming data miss error flag | |||
* @arg @ref FLASH_FLAG_FASTERR FLASH Fast programming error flag | |||
* @arg @ref FLASH_FLAG_RDERR FLASH PCROP read error flag | |||
* @arg @ref FLASH_FLAG_OPTVERR FLASH Option validity error flag | |||
* @arg @ref FLASH_FLAG_ECCC FLASH one ECC error has been detected and corrected | |||
* @arg @ref FLASH_FLAG_ECCD FLASH two ECC errors have been detected | |||
* @arg @ref FLASH_FLAG_ALL_ERRORS FLASH All errors flags | |||
* @retval None | |||
*/ | |||
#define __HAL_FLASH_CLEAR_FLAG(__FLAG__) do { if(((__FLAG__) & (FLASH_FLAG_ECCC | FLASH_FLAG_ECCD)) != 0U) { SET_BIT(FLASH->ECCR, ((__FLAG__) & (FLASH_FLAG_ECCC | FLASH_FLAG_ECCD))); }\ | |||
if(((__FLAG__) & ~(FLASH_FLAG_ECCC | FLASH_FLAG_ECCD)) != 0U) { WRITE_REG(FLASH->SR, ((__FLAG__) & ~(FLASH_FLAG_ECCC | FLASH_FLAG_ECCD))); }\ | |||
} while(0) | |||
/** | |||
* @} | |||
*/ | |||
/* Include FLASH HAL Extended module */ | |||
#include "stm32wbxx_hal_flash_ex.h" | |||
/* Exported variables --------------------------------------------------------*/ | |||
/** @defgroup FLASH_Exported_Variables FLASH Exported Variables | |||
* @{ | |||
*/ | |||
extern FLASH_ProcessTypeDef pFlash; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup FLASH_Exported_Functions | |||
* @{ | |||
*/ | |||
/* Program operation functions ***********************************************/ | |||
/** @addtogroup FLASH_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data); | |||
HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data); | |||
/* FLASH IRQ handler method */ | |||
void HAL_FLASH_IRQHandler(void); | |||
/* Callbacks in non blocking modes */ | |||
void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue); | |||
void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue); | |||
/** | |||
* @} | |||
*/ | |||
/* Peripheral Control functions **********************************************/ | |||
/** @addtogroup FLASH_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_FLASH_Unlock(void); | |||
HAL_StatusTypeDef HAL_FLASH_Lock(void); | |||
/* Option bytes control */ | |||
HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void); | |||
HAL_StatusTypeDef HAL_FLASH_OB_Lock(void); | |||
HAL_StatusTypeDef HAL_FLASH_OB_Launch(void); | |||
/** | |||
* @} | |||
*/ | |||
/* Peripheral State functions ************************************************/ | |||
/** @addtogroup FLASH_Exported_Functions_Group3 | |||
* @{ | |||
*/ | |||
uint32_t HAL_FLASH_GetError(void); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private types --------------------------------------------------------*/ | |||
/** @defgroup FLASH_Private_types FLASH Private Types | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout); | |||
/** | |||
* @} | |||
*/ | |||
/* Private constants --------------------------------------------------------*/ | |||
/** @defgroup FLASH_Private_Constants FLASH Private Constants | |||
* @{ | |||
*/ | |||
#define FLASH_SIZE (((uint32_t)(*((uint16_t *)FLASHSIZE_BASE)) & (0x07FFUL)) << 10U) | |||
#define FLASH_END_ADDR (FLASH_BASE + FLASH_SIZE - 1U) | |||
#define FLASH_BANK_SIZE FLASH_SIZE /*!< FLASH Bank Size */ | |||
#define FLASH_PAGE_SIZE 0x00001000U /*!< FLASH Page Size, 4 KBytes */ | |||
#define FLASH_PAGE_NB 128U | |||
#define FLASH_TIMEOUT_VALUE 1000U /*!< FLASH Execution Timeout, 1 s */ | |||
#define FLASH_PCROP_GRANULARITY_OFFSET 11U /*!< FLASH Code Readout Protection granularity offset */ | |||
#define FLASH_PCROP_GRANULARITY (1UL << FLASH_PCROP_GRANULARITY_OFFSET) /*!< FLASH Code Readout Protection granularity, 2 KBytes */ | |||
#define FLASH_TYPENONE 0x00000000U /*!< No Programmation Procedure On Going */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SRAM_MEMORY_SIZE SRAM memory size | |||
* @{ | |||
*/ | |||
#define SRAM_SECURE_PAGE_GRANULARITY_OFFSET 10U /*!< Secure SRAM2A and SRAM2B Protection granularity offset */ | |||
#define SRAM_SECURE_PAGE_GRANULARITY (1UL << FLASH_PCROP_GRANULARITY_OFFSET) /*!< Secure SRAM2A and SRAM2B Protection granularity, 1KBytes */ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup FLASH_Private_Macros FLASH Private Macros | |||
* @{ | |||
*/ | |||
#define IS_FLASH_MAIN_MEM_ADDRESS(__VALUE__) (((__VALUE__) >= FLASH_BASE) && ((__VALUE__) <= (FLASH_BASE + FLASH_SIZE - 1UL))) | |||
#define IS_FLASH_FAST_PROGRAM_ADDRESS(__VALUE__) (((__VALUE__) >= FLASH_BASE) && ((__VALUE__) <= (FLASH_BASE + FLASH_SIZE - 256UL)) && (((__VALUE__) % 256UL) == 0UL)) | |||
#define IS_FLASH_PROGRAM_MAIN_MEM_ADDRESS(__VALUE__) (((__VALUE__) >= FLASH_BASE) && ((__VALUE__) <= (FLASH_BASE + FLASH_SIZE - 8UL)) && (((__VALUE__) % 8UL) == 0UL)) | |||
#define IS_FLASH_PROGRAM_OTP_ADDRESS(__VALUE__) (((__VALUE__) >= OTP_AREA_BASE) && ((__VALUE__) <= (OTP_AREA_END_ADDR + 1UL - 8UL)) && (((__VALUE__) % 8UL) == 0UL)) | |||
#define IS_FLASH_PROGRAM_ADDRESS(__VALUE__) (IS_FLASH_PROGRAM_MAIN_MEM_ADDRESS(__VALUE__) || IS_FLASH_PROGRAM_OTP_ADDRESS(__VALUE__)) | |||
#define IS_FLASH_PAGE(__VALUE__) ((__VALUE__) < FLASH_PAGE_NB) | |||
#define IS_ADDR_ALIGNED_64BITS(__VALUE__) (((__VALUE__) & 0x7U) == (0x00UL)) | |||
#define IS_FLASH_TYPEERASE(__VALUE__) (((__VALUE__) == FLASH_TYPEERASE_PAGES) || \ | |||
((__VALUE__) == FLASH_TYPEERASE_MASSERASE)) | |||
#define IS_FLASH_TYPEPROGRAM(__VALUE__) (((__VALUE__) == FLASH_TYPEPROGRAM_DOUBLEWORD) || \ | |||
((__VALUE__) == FLASH_TYPEPROGRAM_FAST)) | |||
#define IS_OB_SFSA_START_ADDR(__VALUE__) (((__VALUE__) >= FLASH_BASE) && ((__VALUE__) <= FLASH_END_ADDR) && (((__VALUE__) & ~(uint32_t)0xFFFU) == (__VALUE__))) | |||
#define IS_OB_SBRSA_START_ADDR(__VALUE__) (((__VALUE__) >= SRAM2A_BASE) && ((__VALUE__) <= (SRAM2A_BASE + SRAM2A_SIZE - 1U)) && (((__VALUE__) & ~0x3FFU) == (__VALUE__))) | |||
#define IS_OB_SNBRSA_START_ADDR(__VALUE__) (((__VALUE__) >= SRAM2B_BASE) && ((__VALUE__) <= (SRAM2B_BASE + SRAM2B_SIZE - 1U)) && (((__VALUE__) & ~0x3FFU) == (__VALUE__))) | |||
#define IS_OB_SECURE_MODE(__VALUE__) (((__VALUE__) == SYSTEM_IN_SECURE_MODE) || ((__VALUE__) == SYSTEM_NOT_IN_SECURE_MODE)) | |||
#define IS_OPTIONBYTE(__VALUE__) (((__VALUE__) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER | OPTIONBYTE_PCROP | \ | |||
OPTIONBYTE_IPCC_BUF_ADDR | OPTIONBYTE_C2_BOOT_VECT | OPTIONBYTE_SECURE_MODE))) | |||
#define IS_OB_WRPAREA(__VALUE__) (((__VALUE__) == OB_WRPAREA_BANK1_AREAA) || ((__VALUE__) == OB_WRPAREA_BANK1_AREAB)) | |||
#define IS_OB_RDP_LEVEL(__VALUE__) (((__VALUE__) == OB_RDP_LEVEL_0) ||\ | |||
((__VALUE__) == OB_RDP_LEVEL_1) ||\ | |||
((__VALUE__) == OB_RDP_LEVEL_2)) | |||
#define IS_OB_USER_TYPE(__VALUE__) ((((__VALUE__) & OB_USER_ALL) != 0U) && \ | |||
(((__VALUE__) & ~OB_USER_ALL) == 0U)) | |||
#define IS_OB_USER_CONFIG(__TYPE__, __VALUE__) ((((__TYPE__) & OB_USER_BOR_LEV) == OB_USER_BOR_LEV) \ | |||
? ((((__VALUE__) & ~(OB_USER_ALL & ~OB_USER_BOR_LEV)) == OB_BOR_LEVEL_0) || \ | |||
(((__VALUE__) & ~(OB_USER_ALL & ~OB_USER_BOR_LEV)) == OB_BOR_LEVEL_1) || \ | |||
(((__VALUE__) & ~(OB_USER_ALL & ~OB_USER_BOR_LEV)) == OB_BOR_LEVEL_2) || \ | |||
(((__VALUE__) & ~(OB_USER_ALL & ~OB_USER_BOR_LEV)) == OB_BOR_LEVEL_3) || \ | |||
(((__VALUE__) & ~(OB_USER_ALL & ~OB_USER_BOR_LEV)) == OB_BOR_LEVEL_4)) \ | |||
: ((((__TYPE__) & OB_USER_AGC_TRIM) == OB_USER_AGC_TRIM) \ | |||
? ((((__VALUE__) & ~(OB_USER_ALL & ~OB_USER_AGC_TRIM)) == OB_AGC_TRIM_0) || \ | |||
(((__VALUE__) & ~(OB_USER_ALL & ~OB_USER_AGC_TRIM)) == OB_AGC_TRIM_1) || \ | |||
(((__VALUE__) & ~(OB_USER_ALL & ~OB_USER_AGC_TRIM)) == OB_AGC_TRIM_2) || \ | |||
(((__VALUE__) & ~(OB_USER_ALL & ~OB_USER_AGC_TRIM)) == OB_AGC_TRIM_3) || \ | |||
(((__VALUE__) & ~(OB_USER_ALL & ~OB_USER_AGC_TRIM)) == OB_AGC_TRIM_4) || \ | |||
(((__VALUE__) & ~(OB_USER_ALL & ~OB_USER_AGC_TRIM)) == OB_AGC_TRIM_5) || \ | |||
(((__VALUE__) & ~(OB_USER_ALL & ~OB_USER_AGC_TRIM)) == OB_AGC_TRIM_6) || \ | |||
(((__VALUE__) & ~(OB_USER_ALL & ~OB_USER_AGC_TRIM)) == OB_AGC_TRIM_7)) \ | |||
: ((~(__TYPE__) & (__VALUE__)) == 0U))) | |||
#define IS_OB_USER_AGC_TRIMMING(__VALUE__) (((__VALUE__) == OB_AGC_TRIM_0) || ((__VALUE__) == OB_AGC_TRIM_1) || \ | |||
((__VALUE__) == OB_AGC_TRIM_2) || ((__VALUE__) == OB_AGC_TRIM_3) || \ | |||
((__VALUE__) == OB_AGC_TRIM_4) || ((__VALUE__) == OB_AGC_TRIM_5) || \ | |||
((__VALUE__) == OB_AGC_TRIM_6) || ((__VALUE__) == OB_AGC_TRIM_7)) | |||
#define IS_OB_USER_BOR_LEVEL(__VALUE__) (((__VALUE__) == OB_BOR_LEVEL_0) || ((__VALUE__) == OB_BOR_LEVEL_1) || \ | |||
((__VALUE__) == OB_BOR_LEVEL_2) || ((__VALUE__) == OB_BOR_LEVEL_3) || \ | |||
((__VALUE__) == OB_BOR_LEVEL_4)) | |||
#define IS_OB_PCROP_CONFIG(__VALUE__) (((__VALUE__) & ~(OB_PCROP_ZONE_A | OB_PCROP_ZONE_B | OB_PCROP_RDP_ERASE)) == 0U) | |||
#define IS_OB_IPCC_BUF_ADDR(__VALUE__) (IS_OB_SBRSA_START_ADDR(__VALUE__) || IS_OB_SNBRSA_START_ADDR(__VALUE__)) | |||
#define IS_OB_BOOT_VECTOR_ADDR(__VALUE__) ((((__VALUE__) >= FLASH_BASE) && ((__VALUE__) <= (FLASH_BASE + FLASH_SIZE - 1U))) || \ | |||
(((__VALUE__) >= SRAM1_BASE) && ((__VALUE__) <= (SRAM1_BASE + SRAM1_SIZE - 1U))) || \ | |||
(((__VALUE__) >= SRAM2A_BASE) && ((__VALUE__) <= (SRAM2A_BASE + SRAM2A_SIZE - 1U))) || \ | |||
(((__VALUE__) >= SRAM2B_BASE) && ((__VALUE__) <= (SRAM2B_BASE + SRAM2B_SIZE - 1U)))) | |||
#define IS_OB_BOOT_REGION(__VALUE__) (((__VALUE__) == OB_C2_BOOT_FROM_FLASH) || ((__VALUE__) == OB_C2_BOOT_FROM_SRAM)) | |||
#define IS_OB_SECURE_CONFIG(__VALUE__) (((__VALUE__) & ~(OB_SECURE_CONFIG_MEMORY | OB_SECURE_CONFIG_BOOT_RESET)) == 0U) | |||
#define IS_FLASH_LATENCY(__VALUE__) (((__VALUE__) == FLASH_LATENCY_0) || \ | |||
((__VALUE__) == FLASH_LATENCY_1) || \ | |||
((__VALUE__) == FLASH_LATENCY_2) || \ | |||
((__VALUE__) == FLASH_LATENCY_3)) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_FLASH_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,115 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_flash_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of FLASH HAL Extended module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_FLASH_EX_H | |||
#define STM32WBxx_HAL_FLASH_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup FLASHEx | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup FLASHEx_EMPTY_CHECK FLASHEx Empty Check | |||
* @{ | |||
*/ | |||
#define FLASH_PROG_NOT_EMPTY 0x00000000U /*!< 1st location in Flash is programmed */ | |||
#define FLASH_PROG_EMPTY FLASH_ACR_EMPTY /*!< 1st location in Flash is empty */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup FLASHEx_Exported_Functions | |||
* @{ | |||
*/ | |||
/* Extended Program operation functions *************************************/ | |||
/** @addtogroup FLASHEx_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError); | |||
HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit); | |||
uint32_t HAL_FLASHEx_FlashEmptyCheck(void); | |||
void HAL_FLASHEx_ForceFlashEmpty(uint32_t FlashEmpty); | |||
HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit); | |||
void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit); | |||
void HAL_FLASHEx_SuspendOperation(void); | |||
void HAL_FLASHEx_AllowOperation(void); | |||
uint32_t HAL_FLASHEx_IsOperationSuspended(void); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup FLASHEx_Private_Macros FLASHEx Private Macros | |||
* @{ | |||
*/ | |||
#define IS_FLASH_EMPTY_CHECK(__VALUE__) (((__VALUE__) == FLASH_PROG_EMPTY) || ((__VALUE__) == FLASH_PROG_NOT_EMPTY)) | |||
/** | |||
* @} | |||
*/ | |||
/* Private Functions ---------------------------------------------------------*/ | |||
/** @defgroup FLASHEx_Private_Functions FLASHEx Private Functions | |||
* @{ | |||
*/ | |||
void FLASH_PageErase(uint32_t Page); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_FLASH_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,301 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_gpio.h | |||
* @author MCD Application Team | |||
* @brief Header file of GPIO HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_GPIO_H | |||
#define STM32WBxx_HAL_GPIO_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup GPIO GPIO | |||
* @brief GPIO HAL module driver | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup GPIO_Exported_Types GPIO Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief GPIO Init structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Pin; /*!< Specifies the GPIO pins to be configured. | |||
This parameter can be any value of @ref GPIO_pins */ | |||
uint32_t Mode; /*!< Specifies the operating mode for the selected pins. | |||
This parameter can be a value of @ref GPIO_mode */ | |||
uint32_t Pull; /*!< Specifies the Pull-up or Pull-Down activation for the selected pins. | |||
This parameter can be a value of @ref GPIO_pull */ | |||
uint32_t Speed; /*!< Specifies the speed for the selected pins. | |||
This parameter can be a value of @ref GPIO_speed */ | |||
uint32_t Alternate; /*!< Peripheral to be connected to the selected pins | |||
This parameter can be a value of @ref GPIOEx_Alternate_function_selection */ | |||
}GPIO_InitTypeDef; | |||
/** | |||
* @brief GPIO Bit SET and Bit RESET enumeration | |||
*/ | |||
typedef enum | |||
{ | |||
GPIO_PIN_RESET = 0U, | |||
GPIO_PIN_SET | |||
}GPIO_PinState; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup GPIO_Exported_Constants GPIO Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup GPIO_pins GPIO pins | |||
* @{ | |||
*/ | |||
#define GPIO_PIN_0 ((uint16_t)0x0001) /* Pin 0 selected */ | |||
#define GPIO_PIN_1 ((uint16_t)0x0002) /* Pin 1 selected */ | |||
#define GPIO_PIN_2 ((uint16_t)0x0004) /* Pin 2 selected */ | |||
#define GPIO_PIN_3 ((uint16_t)0x0008) /* Pin 3 selected */ | |||
#define GPIO_PIN_4 ((uint16_t)0x0010) /* Pin 4 selected */ | |||
#define GPIO_PIN_5 ((uint16_t)0x0020) /* Pin 5 selected */ | |||
#define GPIO_PIN_6 ((uint16_t)0x0040) /* Pin 6 selected */ | |||
#define GPIO_PIN_7 ((uint16_t)0x0080) /* Pin 7 selected */ | |||
#define GPIO_PIN_8 ((uint16_t)0x0100) /* Pin 8 selected */ | |||
#define GPIO_PIN_9 ((uint16_t)0x0200) /* Pin 9 selected */ | |||
#define GPIO_PIN_10 ((uint16_t)0x0400) /* Pin 10 selected */ | |||
#define GPIO_PIN_11 ((uint16_t)0x0800) /* Pin 11 selected */ | |||
#define GPIO_PIN_12 ((uint16_t)0x1000) /* Pin 12 selected */ | |||
#define GPIO_PIN_13 ((uint16_t)0x2000) /* Pin 13 selected */ | |||
#define GPIO_PIN_14 ((uint16_t)0x4000) /* Pin 14 selected */ | |||
#define GPIO_PIN_15 ((uint16_t)0x8000) /* Pin 15 selected */ | |||
#define GPIO_PIN_All ((uint16_t)0xFFFF) /* All pins selected */ | |||
#define GPIO_PIN_MASK ((uint32_t)0x0000FFFF) /* PIN mask for assert test */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup GPIO_mode GPIO mode | |||
* @brief GPIO Configuration Mode | |||
* Elements values convention: 0xX0yz00YZ | |||
* - X : GPIO mode or EXTI Mode | |||
* - y : External IT or Event trigger detection | |||
* - z : IO configuration on External IT or Event | |||
* - Y : Output type (Push Pull or Open Drain) | |||
* - Z : IO Direction mode (Input, Output, Alternate or Analog) | |||
* @{ | |||
*/ | |||
#define GPIO_MODE_INPUT (0x00000000u) /*!< Input Floating Mode */ | |||
#define GPIO_MODE_OUTPUT_PP (0x00000001u) /*!< Output Push Pull Mode */ | |||
#define GPIO_MODE_OUTPUT_OD (0x00000011u) /*!< Output Open Drain Mode */ | |||
#define GPIO_MODE_AF_PP (0x00000002u) /*!< Alternate Function Push Pull Mode */ | |||
#define GPIO_MODE_AF_OD (0x00000012u) /*!< Alternate Function Open Drain Mode */ | |||
#define GPIO_MODE_ANALOG (0x00000003u) /*!< Analog Mode */ | |||
#define GPIO_MODE_IT_RISING (0x10110000u) /*!< External Interrupt Mode with Rising edge trigger detection */ | |||
#define GPIO_MODE_IT_FALLING (0x10210000u) /*!< External Interrupt Mode with Falling edge trigger detection */ | |||
#define GPIO_MODE_IT_RISING_FALLING (0x10310000u) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ | |||
#define GPIO_MODE_EVT_RISING (0x10120000u) /*!< External Event Mode with Rising edge trigger detection */ | |||
#define GPIO_MODE_EVT_FALLING (0x10220000u) /*!< External Event Mode with Falling edge trigger detection */ | |||
#define GPIO_MODE_EVT_RISING_FALLING (0x10320000u) /*!< External Event Mode with Rising/Falling edge trigger detection */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup GPIO_speed GPIO speed | |||
* @brief GPIO Output Maximum frequency | |||
* @{ | |||
*/ | |||
#define GPIO_SPEED_FREQ_LOW (0x00000000u) /*!< Low speed */ | |||
#define GPIO_SPEED_FREQ_MEDIUM (0x00000001u) /*!< Medium speed */ | |||
#define GPIO_SPEED_FREQ_HIGH (0x00000002u) /*!< High speed */ | |||
#define GPIO_SPEED_FREQ_VERY_HIGH (0x00000003u) /*!< Very high speed */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup GPIO_pull GPIO pull | |||
* @brief GPIO Pull-Up or Pull-Down Activation | |||
* @{ | |||
*/ | |||
#define GPIO_NOPULL (0x00000000u) /*!< No Pull-up or Pull-down activation */ | |||
#define GPIO_PULLUP (0x00000001u) /*!< Pull-up activation */ | |||
#define GPIO_PULLDOWN (0x00000002u) /*!< Pull-down activation */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup GPIO_Exported_Macros GPIO Exported Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Check whether the specified EXTI line flag is set or not. | |||
* @param __EXTI_LINE__ specifies the EXTI line flag to check. | |||
* This parameter can be GPIO_PIN_x where x can be(0..15) | |||
* @retval The new state of __EXTI_LINE__ (SET or RESET). | |||
*/ | |||
#define __HAL_GPIO_EXTI_GET_FLAG(__EXTI_LINE__) (EXTI->PR1 & (__EXTI_LINE__)) | |||
/** | |||
* @brief Clear the EXTI's line pending flags. | |||
* @param __EXTI_LINE__ specifies the EXTI lines flags to clear. | |||
* This parameter can be any combination of GPIO_PIN_x where x can be (0..15) | |||
* @retval None | |||
*/ | |||
#define __HAL_GPIO_EXTI_CLEAR_FLAG(__EXTI_LINE__) (EXTI->PR1 = (__EXTI_LINE__)) | |||
/** | |||
* @brief Check whether the specified EXTI line is asserted or not. | |||
* @param __EXTI_LINE__ specifies the EXTI line to check. | |||
* This parameter can be GPIO_PIN_x where x can be(0..15) | |||
* @retval The new state of __EXTI_LINE__ (SET or RESET). | |||
*/ | |||
#define __HAL_GPIO_EXTI_GET_IT(__EXTI_LINE__) (EXTI->PR1 & (__EXTI_LINE__)) | |||
/** | |||
* @brief Clear the EXTI's line pending bits. | |||
* @param __EXTI_LINE__ specifies the EXTI lines to clear. | |||
* This parameter can be any combination of GPIO_PIN_x where x can be (0..15) | |||
* @retval None | |||
*/ | |||
#define __HAL_GPIO_EXTI_CLEAR_IT(__EXTI_LINE__) (EXTI->PR1 = (__EXTI_LINE__)) | |||
/** | |||
* @brief Generate a Software interrupt on selected EXTI line. | |||
* @param __EXTI_LINE__ specifies the EXTI line to check. | |||
* This parameter can be GPIO_PIN_x where x can be(0..15) | |||
* @retval None | |||
*/ | |||
#define __HAL_GPIO_EXTI_GENERATE_SWIT(__EXTI_LINE__) (EXTI->SWIER1 |= (__EXTI_LINE__)) | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup GPIO_Private_Macros GPIO Private Macros | |||
* @{ | |||
*/ | |||
#define IS_GPIO_PIN_ACTION(ACTION) (((ACTION) == GPIO_PIN_RESET) || ((ACTION) == GPIO_PIN_SET)) | |||
#define IS_GPIO_PIN(__PIN__) ((((uint32_t)(__PIN__) & GPIO_PIN_MASK) != 0x00u) &&\ | |||
(((uint32_t)(__PIN__) & ~GPIO_PIN_MASK) == 0x00u)) | |||
#define IS_GPIO_MODE(__MODE__) (((__MODE__) == GPIO_MODE_INPUT) ||\ | |||
((__MODE__) == GPIO_MODE_OUTPUT_PP) ||\ | |||
((__MODE__) == GPIO_MODE_OUTPUT_OD) ||\ | |||
((__MODE__) == GPIO_MODE_AF_PP) ||\ | |||
((__MODE__) == GPIO_MODE_AF_OD) ||\ | |||
((__MODE__) == GPIO_MODE_IT_RISING) ||\ | |||
((__MODE__) == GPIO_MODE_IT_FALLING) ||\ | |||
((__MODE__) == GPIO_MODE_IT_RISING_FALLING) ||\ | |||
((__MODE__) == GPIO_MODE_EVT_RISING) ||\ | |||
((__MODE__) == GPIO_MODE_EVT_FALLING) ||\ | |||
((__MODE__) == GPIO_MODE_EVT_RISING_FALLING) ||\ | |||
((__MODE__) == GPIO_MODE_ANALOG)) | |||
#define IS_GPIO_SPEED(__SPEED__) (((__SPEED__) == GPIO_SPEED_FREQ_LOW) ||\ | |||
((__SPEED__) == GPIO_SPEED_FREQ_MEDIUM) ||\ | |||
((__SPEED__) == GPIO_SPEED_FREQ_HIGH) ||\ | |||
((__SPEED__) == GPIO_SPEED_FREQ_VERY_HIGH)) | |||
#define IS_GPIO_PULL(__PULL__) (((__PULL__) == GPIO_NOPULL) ||\ | |||
((__PULL__) == GPIO_PULLUP) || \ | |||
((__PULL__) == GPIO_PULLDOWN)) | |||
/** | |||
* @} | |||
*/ | |||
/* Include GPIO HAL Extended module */ | |||
#include "stm32wbxx_hal_gpio_ex.h" | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup GPIO_Exported_Functions GPIO Exported Functions | |||
* @brief GPIO Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup GPIO_Exported_Functions_Group1 Initialization/de-initialization functions | |||
* @brief Initialization and Configuration functions | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions *****************************/ | |||
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init); | |||
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup GPIO_Exported_Functions_Group2 IO operation functions | |||
* @brief IO operation functions | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); | |||
void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState); | |||
void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); | |||
HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); | |||
void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin); | |||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_GPIO_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,408 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_gpio_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of GPIO HAL Extended module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_GPIO_EX_H | |||
#define STM32WBxx_HAL_GPIO_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup GPIOEx GPIOEx | |||
* @brief GPIO Extended HAL module driver | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup GPIOEx_Alternate_function_selection GPIOEx Alternate function selection | |||
* @{ | |||
*/ | |||
/* The table below gives an overview of the different alternate functions per port. | |||
* For more details refer yourself to the product data sheet. | |||
* | |||
*/ | |||
/* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 | | |||
*_____________________________________________________________________________________________ | |||
* |SYS_AF |TIM |TIM |SPI/SAI/TI|I2C | I2C | RF | USART | | |||
*_____________________________________________________________________________________________ | |||
* PA0 | |TIM2_CH1 | | | | |RF_DTB2 | | | |||
* PA1 | |TIM2_CH2 | | |I2C1_SMBA |SPI1_SCK |RF_DTB3 | | | |||
* PA2 | |TIM2_CH3 | | | | |RF_DTB4 | | | |||
* PA3 | |TIM2_CH4 | |SAI1_CK1 | | |RF_DTB5 | | | |||
* PA4 | | | | | |SPI1_NSS |RF_DTB6 | | | |||
* PA5 | |TIM2_CH1 |TIM2_ETR | | |SPI1_SCK |RF_DTB7 | | | |||
* PA6 | |TIM1_BKIN | | | |SPI1_MISO |RF_DTB8 | | | |||
* PA7 | |TIM1_CH1N | | |I2C3_SCL |SPI1_MOSI |RF_DTB9 | | | |||
* PA8 |MCO |TIM1_CH1 | |SAI1_CK2 | | |RF_DTB12 |USART1_CK | | |||
* PA9 | |TIM2_CH2 | |SAI1_DI2 |I2C1_SCL |SPI2_SCK |RF_DTB13 |USART1_TX | | |||
* PA10| |TIM2_CH3 | |SAI1_DI1 |I2C1_SDA | |RF_DTB14 |USART1_RX | | |||
* PA11| |TIM2_CH4 |TIM1_BKIN2| | |SPI1_MISO |RF_DTB15 |USART1_CTS| | |||
* PA12| |TIM2_ETR | | | |SPI1_MOSI |RF_MISO |USART1_RTS| | |||
* PA13|JTMS_SWDIO| | | | | | | | | |||
* PA14|JTCK_SWCLK|LPTIM1_OUT| | |I2C1_SMBA | | | | | |||
* PA15|JTDI |TIM2_CH1 |TIM2_ETR | | |SPI1_NSS | | | | |||
*______________________________________________________________________________________________ | |||
* PB0 | | | | | | | | | | |||
* PB1 | | | | | | | | | | |||
* PB2 |RTC_OUT |LPTIM1_OUT| | |I2C3_SMBA |SPI1_NSS |RF_DTB10 | | | |||
* PB3 |JTDO |TIM2_CH2 | | | |SPI1_SCK | |USART1_RTS| | |||
* PB4 |NJTRST | | | |I2C3_SDA |SPI1_MISO | |USART1_CTS| | |||
* PB5 | |LPTIM1_IN1| | |I2C1_SMBA |SPI1_MOSI |RF_MOSI |USART1_CK | | |||
* PB6 | |LPTIM1_ETR| | |I2C1_SCL | |RF_SCK |USART1_TX | | |||
* PB7 | |LPTIM1_IN2| |TIM1_BKIN |I2C1_SDA | |RF_DTB11 |USART1_RX | | |||
* PB8 | |TIM1_CH2N | |SAI1_CK1 |I2C1_SCL | |RF_DTB16 | | | |||
* PB9 | |TIM1_CH3N | |SAI1_DI2 |I2C1_SDA |SPI2_NSS | | | | |||
* PB10| |TIM2_CH3 | | |I2C3_SCL |SPI2_SCK |RF_DTB18 | | | |||
* PB11| |TIM2_CH4 | | |I2C3_SDA | |RF_DTB17 | | | |||
* PB12| |TIM1_BKIN | |TIM1_BKIN |I2C3_SMBA |SPI2_NSS | | | | |||
* PB13| |TIM1_CH1N | | |I2C3_SCL |SPI2_SCK | | | | |||
* PB14| |TIM1_CH2N | | |I2C3_SDA |SPI2_MISO | | | | |||
* PB15|RTC_REFIN |TIM1_CH3N | | | |SPI2_MOSI | | | | |||
*______________________________________________________________________________________________ | |||
* PC0 | |LPTIM1_IN1| | |I2C3_SCL | | | | | |||
* PC1 | |LPTIM1_OUT| |SPI2_MOSI |I2C3_SDA | | | | | |||
* PC2 | |LPTIM1_IN2| | | |SPI2_MISO | | | | |||
* PC3 | |LPTIM1_ETR| |SAI1_DI1 | |SPI2_MOSI | | | | |||
* PC4 | | | | | | | | | | |||
* PC5 | | | |SAI1_DI3 | | | | | | |||
* PC6 | | | | | | | | | | |||
* PC7 | | | | | | | | | | |||
* PC8 | | | | | | | | | | |||
* PC9 | | | |TIM1_BKIN | | | | | | |||
* PC10|TRACED1 | | | | | | | | | |||
* PC11| | | | | | | | | | |||
* PC12|TRACED3 | | | | | | | | | |||
* PC13| | | | | | | | | | |||
* PC14| | | | | | |RF_DTB0 | | | |||
* PC15| | | | | | |RF_DTB1 | | | |||
*______________________________________________________________________________________________ | |||
* PD0 | | | | | |SPI2_NSS | | | | |||
* PD1 | | | | | |SPI2_SCK | | | | |||
* PD2 |TRACED2 | | | | | | | | | |||
* PD3 | | | |SPI2_SCK | |SPI2_MISO | | | | |||
* PD4 | | | | | |SPI2_MOSI | | | | |||
* PD5 | | | | | | | | | | |||
* PD6 | | | |SAI1_DI1 | | | | | | |||
* PD7 | | | | | | | | | | |||
* PD8 | | |TIM1_BKIN2| | | | | | | |||
* PD9 |TRACED0 | | | | | | | | | |||
* PD10|TRIG_IO | | | | | | | | | |||
* PD11| | | | | | | | | | |||
* PD12| | | | | | | | | | |||
* PD13| | | | | | | | | | |||
* PD14| |TIM1_CH1 | | | | | | | | |||
* PD15| |TIM1_CH2 | | | | | | | | |||
*______________________________________________________________________________________________ | |||
* PE0 | |TIM1_ETR | | | | | | | | |||
* PE1 | | | | | | | | | | |||
* PE2 |TRACED2 | | |SAI1_CK1 | | | | | | |||
* PE3 | | | | | | | | | | |||
* PE4 | | | | | | | | | | |||
*______________________________________________________________________________________________ | |||
* PH0 | | | | | | | | | | |||
* PH1 | | | | | | | | | | |||
* PE2 | | | | | | | | | | |||
* PH3 | | | | | | |RF_NSS | | | |||
*______________________________________________________________________________________________*/ | |||
/* | AF8 | AF9 | AF10 | AF11 | AF12 | AF13 | AF14 | AF15 | | |||
*_____________________________________________________________________________________________ | |||
* |LPUART1 |TSC |USB/QUADSP|LCD |COMP/TIM |SAI |TIM |EVENTOUT | | |||
*_____________________________________________________________________________________________ | |||
* PA0 | | | | |COMP1_OUT |SAI1_E_CLK|TIM2_ETR |EVENTOUT | | |||
* PA1 | | | |LCD_SEG0 | | | |EVENTOUT | | |||
* PA2 |LPUART1_TX| |QSPI_NCS |LCD_SEG1 |COMP2_OUT | | |EVENTOUT | | |||
* PA3 |LPUART1_RX| |QSPI_CLK |LCD_SEG2 | |SAI1_CLK_A| |EVENTOUT | | |||
* PA4 | | | | | |SAI1_FS_B |LPTIM2_OUT|EVENTOUT | | |||
* PA5 | | | | | | |LPTIM2_ETR|EVENTOUT | | |||
* PA6 |LPUART1_CT| |QSPI_IO3 |LCD_SEG3 |TIM1_BKIN | |TIM16_CH1 |EVENTOUT | | |||
* PA7 | | |QSPI_IO2 |LCD_SEG4 |COMP2_OUT | |TIM17_CH1 |EVENTOUT | | |||
* PA8 | | | |LCD_COM0 | |SAI1_SCK_A|LPTIM2_OUT|EVENTOUT | | |||
* PA9 | | | |LCD_COM1 | |SAI1_FS_A | |EVENTOUT | | |||
* PA10| | |USB_CRS_SY|LCD_COM2 | |SAI1_SD_A |TIM17_BKIN|EVENTOUT | | |||
* PA11| | |USB_DM | |TIM1_BKIN2| | |EVENTOUT | | |||
* PA12| | |USB_DP | | | | |EVENTOUT | | |||
* PA13|IR_OUT | |USB_NOE | | |SAI1_SD_B | |EVENTOUT | | |||
* PA14| | | | | |SAI1_FS_B | |EVENTOUT | | |||
* PA15| |TSC_G3_IO1| |LCD_SEG17 | | | |EVENTOUT | | |||
*______________________________________________________________________________________________ | |||
* PB0 | | | |LCD_SEG5 |COMP1_OUT | | |EVENTOUT | | |||
* PB1 |LPUART1_RT| | |LCD_SEG6 | | |LPTIM2_IN1|EVENTOUT | | |||
* PB2 | | | |LCD_VLCD | |SAI1_E_CLK| |EVENTOUT | | |||
* PB3 | | | |LCD_SEG7 | |SAI1_SCK_B| |EVENTOUT | | |||
* PB4 | |TSC_G2_IO1| |LCD_SEG8 | |SAI1_CLK_B|TIM17_BKIN|EVENTOUT | | |||
* PB5 | |TSC_G2_IO2| |LCD_SEG9 |COMP2_OUT |SAI1_SD_B |TIM16_BKIN|EVENTOUT | | |||
* PB6 | |TSC_G2_IO3| | | |SAI1_FS_B |TIM16_CH1N|EVENTOUT | | |||
* PB7 | |TSC_G2_IO4| |LCD_SEG21 | | |TIM17_CH1N|EVENTOUT | | |||
* PB8 | | |QSPI_IO1 |LCD_SEG16 | |SAI1_CLK_A|TIM16_CH1 |EVENTOUT | | |||
* PB9 |IR_OUT |TSC_G7_IO4|QSPI_IO0 |LCD_COM3 | |SAI1_FS_A |TIM17_CH1 |EVENTOUT | | |||
* PB10|LPUART1_RX|TSC_SYNC |QSPI_CLK |LCD_SEG10 |COMP1_OUT |SAI1_SCK_A| |EVENTOUT | | |||
* PB11|LPUART1_TX| |QSPI_NCS |LCD_SEG11 |COMP2_OUT | | |EVENTOUT | | |||
* PB12|LPUART1_RT|TSC_G1_IO1| |LCD_SEG12 | |SAI1_FS_A | |EVENTOUT | | |||
* PB13|LPUART1_CT|TSC_G1_IO2| |LCD_SEG13 | |SAI1_SCK_A| |EVENTOUT | | |||
* PB14| |TSC_G1_IO3| |LCD_SEG14 | |SAI1_CLK_A| |EVENTOUT | | |||
* PB15| |TSC_G1_IO4| |LCD_SEG15 | |SAI1_SD_A | |EVENTOUT | | |||
*______________________________________________________________________________________________ | |||
* PC0 |LPUART1_RX| | |LCD_SEG18 | | |LPTIM2_IN1|EVENTOUT | | |||
* PC1 |LPUART1_TX| | |LCD_SEG19 | | | |EVENTOUT | | |||
* PC2 | | | |LCD_SEG20 | | | |EVENTOUT | | |||
* PC3 | | | |LCD_VLCD | |SAI1_SD_A |LPTIM2_ETR|EVENTOUT | | |||
* PC4 | | | |LCD_SEG22 | | | |EVENTOUT | | |||
* PC5 | | | |LCD_SEG23 | | | |EVENTOUT | | |||
* PC6 | |TSC_G4_IO1| |LCD_SEG24 | | | |EVENTOUT | | |||
* PC7 | |TSC_G4_IO2| |LCD_SEG25 | | | |EVENTOUT | | |||
* PC8 | |TSC_G4_IO3| |LCD_SEG26 | | | |EVENTOUT | | |||
* PC9 | |TSC_G4_IO4|USB_NOE |LCD_SEG27 | |SAI1_SCK_B| |EVENTOUT | | |||
* PC10| |TSC_G3_IO2| |LCD_Cx_SEx| | | |EVENTOUT | | |||
* PC11| |TSC_G3_IO3| |LCD_Cx_SEx| | | |EVENTOUT | | |||
* PC12| |TSC_G3_IO4| |LCD_Cx_SEx| | | |EVENTOUT | | |||
* PC13| | | | | | | |EVENTOUT | | |||
* PC14| | | | | | | |EVENTOUT | | |||
* PC15| | | | | | | |EVENTOUT | | |||
*______________________________________________________________________________________________ | |||
* PD0 | | | | | | | |EVENTOUT | | |||
* PD1 | | | | | | | |EVENTOUT | | |||
* PD2 | |TSC_SYNC | |LCD_Cx_SEx| | | |EVENTOUT | | |||
* PD3 | | |QSPI_NCS | | | | |EVENTOUT | | |||
* PD4 | |TSC_G5_IO1|QSPI_IO0 | | | | |EVENTOUT | | |||
* PD5 | |TSC_G5_IO2|QSPI_IO1 | | |SAI1_CLK_B| |EVENTOUT | | |||
* PD6 | |TSC_G5_IO3|QSPI_IO2 | | |SAI1_SD_A | |EVENTOUT | | |||
* PD7 | |TSC_G5_IO4|QSPI_IO3 |LCD_SEG39 | | | |EVENTOUT | | |||
* PD8 | | | |LCD_SEG28 | | | |EVENTOUT | | |||
* PD9 | | | |LCD_SEG29 | | | |EVENTOUT | | |||
* PD10| |TSC_G6_IO1| |LCD_SEG30 | | | |EVENTOUT | | |||
* PD11| |TSC_G6_IO2| |LCD_SEG31 | | |LPTIM2_ETR|EVENTOUT | | |||
* PD12| |TSC_G6_IO3| |LCD_SEG32 | | |LPTIM2_IN1|EVENTOUT | | |||
* PD13| |TSC_G6_IO4| |LCD_SEG33 | | |LPTIM2_OUT|EVENTOUT | | |||
* PD14| | | |LCD_SEG34 | | | |EVENTOUT | | |||
* PD15| | | |LCD_SEG35 | | | |EVENTOUT | | |||
*______________________________________________________________________________________________ | |||
* PE0 | |TSC_G7_IO3| |LCD_SEG36 | | |TIM16_CH1 |EVENTOUT | | |||
* PE1 | |TSC_G7_IO2| |LCD_SEG37 | | |TIM17_CH1 |EVENTOUT | | |||
* PE2 | |TSC_G7_IO1| |LCD_SEG38 | |SAI1_CLK_A| |EVENTOUT | | |||
* PE3 | | | | | | | |EVENTOUT | | |||
* PE4 | | | | | | | |EVENTOUT | | |||
*______________________________________________________________________________________________ | |||
* PH0 | | | | | | | |EVENTOUT | | |||
* PH1 | | | | | | | |EVENTOUT | | |||
* PE2 | | | | | | | |EVENTOUT | | |||
* PH3 | | | | | | | |EVENTOUT | | |||
*______________________________________________________________________________________________*/ | |||
/** | |||
* @brief AF 0 selection | |||
*/ | |||
#define GPIO_AF0_MCO ((uint8_t)0x00) /*!< MCO Alternate Function mapping */ | |||
#define GPIO_AF0_LSCO ((uint8_t)0x00) /*!< LSCO Alternate Function mapping */ | |||
#define GPIO_AF0_JTMS_SWDIO ((uint8_t)0x00) /*!< JTMS-SWDIO Alternate Function mapping */ | |||
#define GPIO_AF0_JTCK_SWCLK ((uint8_t)0x00) /*!< JTCK-SWCLK Alternate Function mapping */ | |||
#define GPIO_AF0_JTDI ((uint8_t)0x00) /*!< JTDI Alternate Function mapping */ | |||
#define GPIO_AF0_RTC_OUT ((uint8_t)0x00) /*!< RCT_OUT Alternate Function mapping */ | |||
#define GPIO_AF0_JTD_TRACE ((uint8_t)0x00) /*!< JTDO-TRACESWO Alternate Function mapping */ | |||
#define GPIO_AF0_NJTRST ((uint8_t)0x00) /*!< NJTRST Alternate Function mapping */ | |||
#define GPIO_AF0_RTC_REFIN ((uint8_t)0x00) /*!< RTC_REFIN Alternate Function mapping */ | |||
#define GPIO_AF0_TRACED0 ((uint8_t)0x00) /*!< TRACED0 Alternate Function mapping */ | |||
#define GPIO_AF0_TRACED1 ((uint8_t)0x00) /*!< TRACED1 Alternate Function mapping */ | |||
#define GPIO_AF0_TRACED2 ((uint8_t)0x00) /*!< TRACED2 Alternate Function mapping */ | |||
#define GPIO_AF0_TRACED3 ((uint8_t)0x00) /*!< TRACED3 Alternate Function mapping */ | |||
#define GPIO_AF0_TRIG_INOUT ((uint8_t)0x00) /*!< TRIG_INOUT Alternate Function mapping */ | |||
#define GPIO_AF0_TRACECK ((uint8_t)0x00) /*!< TRACECK Alternate Function mapping */ | |||
#define GPIO_AF0_SYS ((uint8_t)0x00) /*!< System Function mapping */ | |||
/** | |||
* @brief AF 1 selection | |||
*/ | |||
#define GPIO_AF1_TIM1 ((uint8_t)0x01) /*!< TIM1 Alternate Function mapping */ | |||
#define GPIO_AF1_TIM2 ((uint8_t)0x01) /*!< TIM2 Alternate Function mapping */ | |||
#define GPIO_AF1_LPTIM1 ((uint8_t)0x01) /*!< LPTIM1 Alternate Function mapping */ | |||
/** | |||
* @brief AF 2 selection | |||
*/ | |||
#define GPIO_AF2_TIM2 ((uint8_t)0x02) /*!< TIM2 Alternate Function mapping */ | |||
#define GPIO_AF2_TIM1 ((uint8_t)0x02) /*!< TIM1 Alternate Function mapping */ | |||
/** | |||
* @brief AF 3 selection | |||
*/ | |||
#define GPIO_AF3_SAI1 ((uint8_t)0x03) /*!< SAI1_CK1 Alternate Function mapping */ | |||
#define GPIO_AF3_SPI2 ((uint8_t)0x03) /*!< SPI2 Alternate Function mapping */ | |||
#define GPIO_AF3_TIM1 ((uint8_t)0x03) /*!< TIM1 Alternate Function mapping */ | |||
/** | |||
* @brief AF 4 selection | |||
*/ | |||
#define GPIO_AF4_I2C1 ((uint8_t)0x04) /*!< I2C1 Alternate Function mapping */ | |||
#define GPIO_AF4_I2C3 ((uint8_t)0x04) /*!< I2C3 Alternate Function mapping */ | |||
/** | |||
* @brief AF 5 selection | |||
*/ | |||
#define GPIO_AF5_SPI1 ((uint8_t)0x05) /*!< SPI1 Alternate Function mapping */ | |||
#define GPIO_AF5_SPI2 ((uint8_t)0x05) /*!< SPI2 Alternate Function mapping */ | |||
/** | |||
* @brief AF 6 selection | |||
*/ | |||
#define GPIO_AF6_MCO ((uint8_t)0x06) /*!< MCO Alternate Function mapping */ | |||
#define GPIO_AF6_LSCO ((uint8_t)0x06) /*!< LSCO Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB0 ((uint8_t)0x06) /*!< RF_DTB0 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB1 ((uint8_t)0x06) /*!< RF_DTB1 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB2 ((uint8_t)0x06) /*!< RF_DTB2 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB3 ((uint8_t)0x06) /*!< RF_DTB3 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB4 ((uint8_t)0x06) /*!< RF_DTB4 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB5 ((uint8_t)0x06) /*!< RF_DTB5 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB6 ((uint8_t)0x06) /*!< RF_DTB6 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB7 ((uint8_t)0x06) /*!< RF_DTB7 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB8 ((uint8_t)0x06) /*!< RF_DTB8 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB9 ((uint8_t)0x06) /*!< RF_DTB9 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB10 ((uint8_t)0x06) /*!< RF_DTB10 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB11 ((uint8_t)0x06) /*!< RF_DTB11 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB12 ((uint8_t)0x06) /*!< RF_DTB12 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB13 ((uint8_t)0x06) /*!< RF_DTB13 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB14 ((uint8_t)0x06) /*!< RF_DTB14 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB15 ((uint8_t)0x06) /*!< RF_DTB15 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB16 ((uint8_t)0x06) /*!< RF_DTB16 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB17 ((uint8_t)0x06) /*!< RF_DTB17 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_DTB18 ((uint8_t)0x06) /*!< RF_DTB18 Alternate Function mapping */ | |||
#define GPIO_AF6_RF_MISO ((uint8_t)0x06) /*!< RF_MISO Alternate Function mapping */ | |||
#define GPIO_AF6_RF_MOSI ((uint8_t)0x06) /*!< RF_MOSI Alternate Function mapping */ | |||
#define GPIO_AF6_RF_SCK ((uint8_t)0x06) /*!< RF_SCK Alternate Function mapping */ | |||
#define GPIO_AF6_RF_NSS ((uint8_t)0x06) /*!< RF_NSS Alternate Function mapping */ | |||
/** | |||
* @brief AF 7 selection | |||
*/ | |||
#define GPIO_AF7_USART1 ((uint8_t)0x07) /*!< USART1 Alternate Function mapping */ | |||
/** | |||
* @brief AF 8 selection | |||
*/ | |||
#define GPIO_AF8_LPUART1 ((uint8_t)0x08) /*!< LPUART1 Alternate Function mapping */ | |||
#define GPIO_AF8_IR ((uint8_t)0x08) /*!< IR Alternate Function mapping */ | |||
/** | |||
* @brief AF 9 selection | |||
*/ | |||
#define GPIO_AF9_TSC ((uint8_t)0x09) /*!< TSC Alternate Function mapping */ | |||
/** | |||
* @brief AF 10 selection | |||
*/ | |||
#define GPIO_AF10_QUADSPI ((uint8_t)0x0a) /*!< QUADSPI Alternate Function mapping */ | |||
#define GPIO_AF10_USB ((uint8_t)0x0a) /*!< USB Alternate Function mapping */ | |||
/** | |||
* @brief AF 11 selection | |||
*/ | |||
#define GPIO_AF11_LCD ((uint8_t)0x0b) /*!< LCD Alternate Function mapping */ | |||
/** | |||
* @brief AF 12 selection | |||
*/ | |||
#define GPIO_AF12_COMP1 ((uint8_t)0x0c) /*!< COMP1 Alternate Function mapping */ | |||
#define GPIO_AF12_COMP2 ((uint8_t)0x0c) /*!< COMP2 Alternate Function mapping */ | |||
#define GPIO_AF12_TIM1 ((uint8_t)0x0c) /*!< TIM1 Alternate Function mapping */ | |||
/** | |||
* @brief AF 13 selection | |||
*/ | |||
#define GPIO_AF13_SAI1 ((uint8_t)0x0d) /*!< SAI1 Alternate Function mapping */ | |||
/** | |||
* @brief AF 14 selection | |||
*/ | |||
#define GPIO_AF14_TIM2 ((uint8_t)0x0e) /*!< TIM2 Alternate Function mapping */ | |||
#define GPIO_AF14_TIM16 ((uint8_t)0x0e) /*!< TIM16 Alternate Function mapping */ | |||
#define GPIO_AF14_TIM17 ((uint8_t)0x0e) /*!< TIM17 Alternate Function mapping */ | |||
#define GPIO_AF14_LPTIM2 ((uint8_t)0x0e) /*!< LPTIM2 Alternate Function mapping */ | |||
/** | |||
* @brief AF 15 selection | |||
*/ | |||
#define GPIO_AF15_EVENTOUT ((uint8_t)0x0f) /*!< EVENTOUT Alternate Function mapping */ | |||
#define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0f) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup GPIOEx_Exported_Macros GPIOEx Exported Macros | |||
* @{ | |||
*/ | |||
/** @defgroup GPIOEx_Get_Port_Index GPIOEx Get Port Index | |||
* @{ | |||
*/ | |||
#define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0uL :\ | |||
((__GPIOx__) == (GPIOB))? 1uL :\ | |||
((__GPIOx__) == (GPIOC))? 2uL :\ | |||
((__GPIOx__) == (GPIOD))? 3uL :\ | |||
((__GPIOx__) == (GPIOE))? 4uL : 7uL) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_GPIO_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,210 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_hsem.h | |||
* @author MCD Application Team | |||
* @brief Header file of HSEM HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_HSEM_H | |||
#define STM32WBxx_HAL_HSEM_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup HSEM | |||
* @{ | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup HSEM_Exported_Macros HSEM Exported Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief SemID to mask helper Macro. | |||
* @param __SEMID__: semaphore ID from 0 to 31 | |||
* @retval Semaphore Mask. | |||
*/ | |||
#define __HAL_HSEM_SEMID_TO_MASK(__SEMID__) (1 << (__SEMID__)) | |||
/** | |||
* @brief Enables the specified HSEM interrupts. | |||
* @param __SEM_MASK__: semaphores Mask | |||
* @retval None. | |||
*/ | |||
#if defined(DUAL_CORE) | |||
#define __HAL_HSEM_ENABLE_IT(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ | |||
(HSEM->C1IER |= (__SEM_MASK__)) : \ | |||
(HSEM->C2IER |= (__SEM_MASK__))) | |||
#else | |||
#define __HAL_HSEM_ENABLE_IT(__SEM_MASK__) (HSEM->IER |= (__SEM_MASK__)) | |||
#endif /* DUAL_CORE */ | |||
/** | |||
* @brief Disables the specified HSEM interrupts. | |||
* @param __SEM_MASK__: semaphores Mask | |||
* @retval None. | |||
*/ | |||
#if defined(DUAL_CORE) | |||
#define __HAL_HSEM_DISABLE_IT(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ | |||
(HSEM->C1IER &= ~(__SEM_MASK__)) : \ | |||
(HSEM->C2IER &= ~(__SEM_MASK__))) | |||
#else | |||
#define __HAL_HSEM_DISABLE_IT(__SEM_MASK__) (HSEM->IER &= ~(__SEM_MASK__)) | |||
#endif /* DUAL_CORE */ | |||
/** | |||
* @brief Checks whether interrupt has occurred or not for semaphores specified by a mask. | |||
* @param __SEM_MASK__: semaphores Mask | |||
* @retval semaphores Mask : Semaphores where an interrupt occurred. | |||
*/ | |||
#if defined(DUAL_CORE) | |||
#define __HAL_HSEM_GET_IT(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ | |||
((__SEM_MASK__) & HSEM->C1MISR) : \ | |||
((__SEM_MASK__) & HSEM->C2MISR1)) | |||
#else | |||
#define __HAL_HSEM_GET_IT(__SEM_MASK__) ((__SEM_MASK__) & HSEM->MISR) | |||
#endif /* DUAL_CORE */ | |||
/** | |||
* @brief Get the semaphores release status flags. | |||
* @param __SEM_MASK__: semaphores Mask | |||
* @retval semaphores Mask : Semaphores where Release flags rise. | |||
*/ | |||
#if defined(DUAL_CORE) | |||
#define __HAL_HSEM_GET_FLAG(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ | |||
(__SEM_MASK__) & HSEM->C1ISR : \ | |||
(__SEM_MASK__) & HSEM->C2ISR) | |||
#else | |||
#define __HAL_HSEM_GET_FLAG(__SEM_MASK__) ((__SEM_MASK__) & HSEM->ISR) | |||
#endif /* DUAL_CORE */ | |||
/** | |||
* @brief Clears the HSEM Interrupt flags. | |||
* @param __SEM_MASK__: semaphores Mask | |||
* @retval None. | |||
*/ | |||
#if defined(DUAL_CORE) | |||
#define __HAL_HSEM_CLEAR_FLAG(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ | |||
(HSEM->C1ICR |= (__SEM_MASK__)) : \ | |||
(HSEM->C2ICR |= (__SEM_MASK__))) | |||
#else | |||
#define __HAL_HSEM_CLEAR_FLAG(__SEM_MASK__) (HSEM->ICR |= (__SEM_MASK__)) | |||
#endif /* DUAL_CORE */ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup HSEM_Exported_Functions HSEM Exported Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup HSEM_Exported_Functions_Group1 Take and Release functions | |||
* @brief HSEM Take and Release functions | |||
* @{ | |||
*/ | |||
/* HSEM semaphore take (lock) using 2-Step method ****************************/ | |||
HAL_StatusTypeDef HAL_HSEM_Take(uint32_t SemID, uint32_t ProcessID); | |||
/* HSEM semaphore fast take (lock) using 1-Step method ***********************/ | |||
HAL_StatusTypeDef HAL_HSEM_FastTake(uint32_t SemID); | |||
/* HSEM Check semaphore state Taken or not **********************************/ | |||
uint32_t HAL_HSEM_IsSemTaken(uint32_t SemID); | |||
/* HSEM Release **************************************************************/ | |||
void HAL_HSEM_Release(uint32_t SemID, uint32_t ProcessID); | |||
/* HSEM Release All************************************************************/ | |||
void HAL_HSEM_ReleaseAll(uint32_t Key, uint32_t CoreID); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup HSEM_Exported_Functions_Group2 HSEM Set and Get Key functions | |||
* @brief HSEM Set and Get Key functions. | |||
* @{ | |||
*/ | |||
/* HSEM Set Clear Key *********************************************************/ | |||
void HAL_HSEM_SetClearKey(uint32_t Key); | |||
/* HSEM Get Clear Key *********************************************************/ | |||
uint32_t HAL_HSEM_GetClearKey(void); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup HSEM_Exported_Functions_Group3 | |||
* @brief HSEM Notification functions | |||
* @{ | |||
*/ | |||
/* HSEM Activate HSEM Notification (When a semaphore is released) ) *****************/ | |||
void HAL_HSEM_ActivateNotification(uint32_t SemMask); | |||
/* HSEM Deactivate HSEM Notification (When a semaphore is released) ****************/ | |||
void HAL_HSEM_DeactivateNotification(uint32_t SemMask); | |||
/* HSEM Free Callback (When a semaphore is released) *******************************/ | |||
void HAL_HSEM_FreeCallback(uint32_t SemMask); | |||
/* HSEM IRQ Handler **********************************************************/ | |||
void HAL_HSEM_IRQHandler(void); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup HSEM_Private_Macros HSEM Private Macros | |||
* @{ | |||
*/ | |||
#define IS_HSEM_SEMID(__SEMID__) ((__SEMID__) <= HSEM_SEMID_MAX ) | |||
#define IS_HSEM_PROCESSID(__PROCESSID__) ((__PROCESSID__) <= HSEM_PROCESSID_MAX ) | |||
#define IS_HSEM_KEY(__KEY__) ((__KEY__) <= HSEM_CLEAR_KEY_MAX ) | |||
#define IS_HSEM_COREID(__COREID__) (((__COREID__) == HSEM_CPU1_COREID) || \ | |||
((__COREID__) == HSEM_CPU2_COREID)) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_HSEM_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,782 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_i2c.h | |||
* @author MCD Application Team | |||
* @brief Header file of I2C HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_I2C_H | |||
#define STM32WBxx_HAL_I2C_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup I2C | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup I2C_Exported_Types I2C Exported Types | |||
* @{ | |||
*/ | |||
/** @defgroup I2C_Configuration_Structure_definition I2C Configuration Structure definition | |||
* @brief I2C Configuration Structure definition | |||
* @{ | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Timing; /*!< Specifies the I2C_TIMINGR_register value. | |||
This parameter calculated by referring to I2C initialization | |||
section in Reference manual */ | |||
uint32_t OwnAddress1; /*!< Specifies the first device own address. | |||
This parameter can be a 7-bit or 10-bit address. */ | |||
uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode is selected. | |||
This parameter can be a value of @ref I2C_ADDRESSING_MODE */ | |||
uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected. | |||
This parameter can be a value of @ref I2C_DUAL_ADDRESSING_MODE */ | |||
uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected | |||
This parameter can be a 7-bit address. */ | |||
uint32_t OwnAddress2Masks; /*!< Specifies the acknowledge mask address second device own address if dual addressing mode is selected | |||
This parameter can be a value of @ref I2C_OWN_ADDRESS2_MASKS */ | |||
uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected. | |||
This parameter can be a value of @ref I2C_GENERAL_CALL_ADDRESSING_MODE */ | |||
uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected. | |||
This parameter can be a value of @ref I2C_NOSTRETCH_MODE */ | |||
} I2C_InitTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup HAL_state_structure_definition HAL state structure definition | |||
* @brief HAL State structure definition | |||
* @note HAL I2C State value coding follow below described bitmap :\n | |||
* b7-b6 Error information\n | |||
* 00 : No Error\n | |||
* 01 : Abort (Abort user request on going)\n | |||
* 10 : Timeout\n | |||
* 11 : Error\n | |||
* b5 Peripheral initialization status\n | |||
* 0 : Reset (peripheral not initialized)\n | |||
* 1 : Init done (peripheral initialized and ready to use. HAL I2C Init function called)\n | |||
* b4 (not used)\n | |||
* x : Should be set to 0\n | |||
* b3\n | |||
* 0 : Ready or Busy (No Listen mode ongoing)\n | |||
* 1 : Listen (peripheral in Address Listen Mode)\n | |||
* b2 Intrinsic process state\n | |||
* 0 : Ready\n | |||
* 1 : Busy (peripheral busy with some configuration or internal operations)\n | |||
* b1 Rx state\n | |||
* 0 : Ready (no Rx operation ongoing)\n | |||
* 1 : Busy (Rx operation ongoing)\n | |||
* b0 Tx state\n | |||
* 0 : Ready (no Tx operation ongoing)\n | |||
* 1 : Busy (Tx operation ongoing) | |||
* @{ | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_I2C_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */ | |||
HAL_I2C_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use */ | |||
HAL_I2C_STATE_BUSY = 0x24U, /*!< An internal process is ongoing */ | |||
HAL_I2C_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing */ | |||
HAL_I2C_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */ | |||
HAL_I2C_STATE_LISTEN = 0x28U, /*!< Address Listen Mode is ongoing */ | |||
HAL_I2C_STATE_BUSY_TX_LISTEN = 0x29U, /*!< Address Listen Mode and Data Transmission | |||
process is ongoing */ | |||
HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU, /*!< Address Listen Mode and Data Reception | |||
process is ongoing */ | |||
HAL_I2C_STATE_ABORT = 0x60U, /*!< Abort user request ongoing */ | |||
HAL_I2C_STATE_TIMEOUT = 0xA0U, /*!< Timeout state */ | |||
HAL_I2C_STATE_ERROR = 0xE0U /*!< Error */ | |||
} HAL_I2C_StateTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup HAL_mode_structure_definition HAL mode structure definition | |||
* @brief HAL Mode structure definition | |||
* @note HAL I2C Mode value coding follow below described bitmap :\n | |||
* b7 (not used)\n | |||
* x : Should be set to 0\n | |||
* b6\n | |||
* 0 : None\n | |||
* 1 : Memory (HAL I2C communication is in Memory Mode)\n | |||
* b5\n | |||
* 0 : None\n | |||
* 1 : Slave (HAL I2C communication is in Slave Mode)\n | |||
* b4\n | |||
* 0 : None\n | |||
* 1 : Master (HAL I2C communication is in Master Mode)\n | |||
* b3-b2-b1-b0 (not used)\n | |||
* xxxx : Should be set to 0000 | |||
* @{ | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_I2C_MODE_NONE = 0x00U, /*!< No I2C communication on going */ | |||
HAL_I2C_MODE_MASTER = 0x10U, /*!< I2C communication is in Master Mode */ | |||
HAL_I2C_MODE_SLAVE = 0x20U, /*!< I2C communication is in Slave Mode */ | |||
HAL_I2C_MODE_MEM = 0x40U /*!< I2C communication is in Memory Mode */ | |||
} HAL_I2C_ModeTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2C_Error_Code_definition I2C Error Code definition | |||
* @brief I2C Error Code definition | |||
* @{ | |||
*/ | |||
#define HAL_I2C_ERROR_NONE (0x00000000U) /*!< No error */ | |||
#define HAL_I2C_ERROR_BERR (0x00000001U) /*!< BERR error */ | |||
#define HAL_I2C_ERROR_ARLO (0x00000002U) /*!< ARLO error */ | |||
#define HAL_I2C_ERROR_AF (0x00000004U) /*!< ACKF error */ | |||
#define HAL_I2C_ERROR_OVR (0x00000008U) /*!< OVR error */ | |||
#define HAL_I2C_ERROR_DMA (0x00000010U) /*!< DMA transfer error */ | |||
#define HAL_I2C_ERROR_TIMEOUT (0x00000020U) /*!< Timeout error */ | |||
#define HAL_I2C_ERROR_SIZE (0x00000040U) /*!< Size Management error */ | |||
#define HAL_I2C_ERROR_DMA_PARAM (0x00000080U) /*!< DMA Parameter Error */ | |||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1) | |||
#define HAL_I2C_ERROR_INVALID_CALLBACK (0x00000100U) /*!< Invalid Callback error */ | |||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */ | |||
#define HAL_I2C_ERROR_INVALID_PARAM (0x00000200U) /*!< Invalid Parameters error */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2C_handle_Structure_definition I2C handle Structure definition | |||
* @brief I2C handle Structure definition | |||
* @{ | |||
*/ | |||
typedef struct __I2C_HandleTypeDef | |||
{ | |||
I2C_TypeDef *Instance; /*!< I2C registers base address */ | |||
I2C_InitTypeDef Init; /*!< I2C communication parameters */ | |||
uint8_t *pBuffPtr; /*!< Pointer to I2C transfer buffer */ | |||
uint16_t XferSize; /*!< I2C transfer size */ | |||
__IO uint16_t XferCount; /*!< I2C transfer counter */ | |||
__IO uint32_t XferOptions; /*!< I2C sequantial transfer options, this parameter can | |||
be a value of @ref I2C_XFEROPTIONS */ | |||
__IO uint32_t PreviousState; /*!< I2C communication Previous state */ | |||
HAL_StatusTypeDef(*XferISR)(struct __I2C_HandleTypeDef *hi2c, uint32_t ITFlags, uint32_t ITSources); /*!< I2C transfer IRQ handler function pointer */ | |||
DMA_HandleTypeDef *hdmatx; /*!< I2C Tx DMA handle parameters */ | |||
DMA_HandleTypeDef *hdmarx; /*!< I2C Rx DMA handle parameters */ | |||
HAL_LockTypeDef Lock; /*!< I2C locking object */ | |||
__IO HAL_I2C_StateTypeDef State; /*!< I2C communication state */ | |||
__IO HAL_I2C_ModeTypeDef Mode; /*!< I2C communication mode */ | |||
__IO uint32_t ErrorCode; /*!< I2C Error code */ | |||
__IO uint32_t AddrEventCount; /*!< I2C Address Event counter */ | |||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1) | |||
void (* MasterTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Master Tx Transfer completed callback */ | |||
void (* MasterRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Master Rx Transfer completed callback */ | |||
void (* SlaveTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Slave Tx Transfer completed callback */ | |||
void (* SlaveRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Slave Rx Transfer completed callback */ | |||
void (* ListenCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Listen Complete callback */ | |||
void (* MemTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Memory Tx Transfer completed callback */ | |||
void (* MemRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Memory Rx Transfer completed callback */ | |||
void (* ErrorCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Error callback */ | |||
void (* AbortCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Abort callback */ | |||
void (* AddrCallback)(struct __I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode); /*!< I2C Slave Address Match callback */ | |||
void (* MspInitCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Msp Init callback */ | |||
void (* MspDeInitCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Msp DeInit callback */ | |||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */ | |||
} I2C_HandleTypeDef; | |||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1) | |||
/** | |||
* @brief HAL I2C Callback ID enumeration definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_I2C_MASTER_TX_COMPLETE_CB_ID = 0x00U, /*!< I2C Master Tx Transfer completed callback ID */ | |||
HAL_I2C_MASTER_RX_COMPLETE_CB_ID = 0x01U, /*!< I2C Master Rx Transfer completed callback ID */ | |||
HAL_I2C_SLAVE_TX_COMPLETE_CB_ID = 0x02U, /*!< I2C Slave Tx Transfer completed callback ID */ | |||
HAL_I2C_SLAVE_RX_COMPLETE_CB_ID = 0x03U, /*!< I2C Slave Rx Transfer completed callback ID */ | |||
HAL_I2C_LISTEN_COMPLETE_CB_ID = 0x04U, /*!< I2C Listen Complete callback ID */ | |||
HAL_I2C_MEM_TX_COMPLETE_CB_ID = 0x05U, /*!< I2C Memory Tx Transfer callback ID */ | |||
HAL_I2C_MEM_RX_COMPLETE_CB_ID = 0x06U, /*!< I2C Memory Rx Transfer completed callback ID */ | |||
HAL_I2C_ERROR_CB_ID = 0x07U, /*!< I2C Error callback ID */ | |||
HAL_I2C_ABORT_CB_ID = 0x08U, /*!< I2C Abort callback ID */ | |||
HAL_I2C_MSPINIT_CB_ID = 0x09U, /*!< I2C Msp Init callback ID */ | |||
HAL_I2C_MSPDEINIT_CB_ID = 0x0AU /*!< I2C Msp DeInit callback ID */ | |||
} HAL_I2C_CallbackIDTypeDef; | |||
/** | |||
* @brief HAL I2C Callback pointer definition | |||
*/ | |||
typedef void (*pI2C_CallbackTypeDef)(I2C_HandleTypeDef *hi2c); /*!< pointer to an I2C callback function */ | |||
typedef void (*pI2C_AddrCallbackTypeDef)(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode); /*!< pointer to an I2C Address Match callback function */ | |||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup I2C_Exported_Constants I2C Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup I2C_XFEROPTIONS I2C Sequential Transfer Options | |||
* @{ | |||
*/ | |||
#define I2C_FIRST_FRAME ((uint32_t)I2C_SOFTEND_MODE) | |||
#define I2C_FIRST_AND_NEXT_FRAME ((uint32_t)(I2C_RELOAD_MODE | I2C_SOFTEND_MODE)) | |||
#define I2C_NEXT_FRAME ((uint32_t)(I2C_RELOAD_MODE | I2C_SOFTEND_MODE)) | |||
#define I2C_FIRST_AND_LAST_FRAME ((uint32_t)I2C_AUTOEND_MODE) | |||
#define I2C_LAST_FRAME ((uint32_t)I2C_AUTOEND_MODE) | |||
#define I2C_LAST_FRAME_NO_STOP ((uint32_t)I2C_SOFTEND_MODE) | |||
/* List of XferOptions in usage of : | |||
* 1- Restart condition in all use cases (direction change or not) | |||
*/ | |||
#define I2C_OTHER_FRAME (0x000000AAU) | |||
#define I2C_OTHER_AND_LAST_FRAME (0x0000AA00U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2C_ADDRESSING_MODE I2C Addressing Mode | |||
* @{ | |||
*/ | |||
#define I2C_ADDRESSINGMODE_7BIT (0x00000001U) | |||
#define I2C_ADDRESSINGMODE_10BIT (0x00000002U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2C_DUAL_ADDRESSING_MODE I2C Dual Addressing Mode | |||
* @{ | |||
*/ | |||
#define I2C_DUALADDRESS_DISABLE (0x00000000U) | |||
#define I2C_DUALADDRESS_ENABLE I2C_OAR2_OA2EN | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2C_OWN_ADDRESS2_MASKS I2C Own Address2 Masks | |||
* @{ | |||
*/ | |||
#define I2C_OA2_NOMASK ((uint8_t)0x00U) | |||
#define I2C_OA2_MASK01 ((uint8_t)0x01U) | |||
#define I2C_OA2_MASK02 ((uint8_t)0x02U) | |||
#define I2C_OA2_MASK03 ((uint8_t)0x03U) | |||
#define I2C_OA2_MASK04 ((uint8_t)0x04U) | |||
#define I2C_OA2_MASK05 ((uint8_t)0x05U) | |||
#define I2C_OA2_MASK06 ((uint8_t)0x06U) | |||
#define I2C_OA2_MASK07 ((uint8_t)0x07U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2C_GENERAL_CALL_ADDRESSING_MODE I2C General Call Addressing Mode | |||
* @{ | |||
*/ | |||
#define I2C_GENERALCALL_DISABLE (0x00000000U) | |||
#define I2C_GENERALCALL_ENABLE I2C_CR1_GCEN | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2C_NOSTRETCH_MODE I2C No-Stretch Mode | |||
* @{ | |||
*/ | |||
#define I2C_NOSTRETCH_DISABLE (0x00000000U) | |||
#define I2C_NOSTRETCH_ENABLE I2C_CR1_NOSTRETCH | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2C_MEMORY_ADDRESS_SIZE I2C Memory Address Size | |||
* @{ | |||
*/ | |||
#define I2C_MEMADD_SIZE_8BIT (0x00000001U) | |||
#define I2C_MEMADD_SIZE_16BIT (0x00000002U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2C_XFERDIRECTION I2C Transfer Direction Master Point of View | |||
* @{ | |||
*/ | |||
#define I2C_DIRECTION_TRANSMIT (0x00000000U) | |||
#define I2C_DIRECTION_RECEIVE (0x00000001U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2C_RELOAD_END_MODE I2C Reload End Mode | |||
* @{ | |||
*/ | |||
#define I2C_RELOAD_MODE I2C_CR2_RELOAD | |||
#define I2C_AUTOEND_MODE I2C_CR2_AUTOEND | |||
#define I2C_SOFTEND_MODE (0x00000000U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2C_START_STOP_MODE I2C Start or Stop Mode | |||
* @{ | |||
*/ | |||
#define I2C_NO_STARTSTOP (0x00000000U) | |||
#define I2C_GENERATE_STOP (uint32_t)(0x80000000U | I2C_CR2_STOP) | |||
#define I2C_GENERATE_START_READ (uint32_t)(0x80000000U | I2C_CR2_START | I2C_CR2_RD_WRN) | |||
#define I2C_GENERATE_START_WRITE (uint32_t)(0x80000000U | I2C_CR2_START) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2C_Interrupt_configuration_definition I2C Interrupt configuration definition | |||
* @brief I2C Interrupt definition | |||
* Elements values convention: 0xXXXXXXXX | |||
* - XXXXXXXX : Interrupt control mask | |||
* @{ | |||
*/ | |||
#define I2C_IT_ERRI I2C_CR1_ERRIE | |||
#define I2C_IT_TCI I2C_CR1_TCIE | |||
#define I2C_IT_STOPI I2C_CR1_STOPIE | |||
#define I2C_IT_NACKI I2C_CR1_NACKIE | |||
#define I2C_IT_ADDRI I2C_CR1_ADDRIE | |||
#define I2C_IT_RXI I2C_CR1_RXIE | |||
#define I2C_IT_TXI I2C_CR1_TXIE | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2C_Flag_definition I2C Flag definition | |||
* @{ | |||
*/ | |||
#define I2C_FLAG_TXE I2C_ISR_TXE | |||
#define I2C_FLAG_TXIS I2C_ISR_TXIS | |||
#define I2C_FLAG_RXNE I2C_ISR_RXNE | |||
#define I2C_FLAG_ADDR I2C_ISR_ADDR | |||
#define I2C_FLAG_AF I2C_ISR_NACKF | |||
#define I2C_FLAG_STOPF I2C_ISR_STOPF | |||
#define I2C_FLAG_TC I2C_ISR_TC | |||
#define I2C_FLAG_TCR I2C_ISR_TCR | |||
#define I2C_FLAG_BERR I2C_ISR_BERR | |||
#define I2C_FLAG_ARLO I2C_ISR_ARLO | |||
#define I2C_FLAG_OVR I2C_ISR_OVR | |||
#define I2C_FLAG_PECERR I2C_ISR_PECERR | |||
#define I2C_FLAG_TIMEOUT I2C_ISR_TIMEOUT | |||
#define I2C_FLAG_ALERT I2C_ISR_ALERT | |||
#define I2C_FLAG_BUSY I2C_ISR_BUSY | |||
#define I2C_FLAG_DIR I2C_ISR_DIR | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup I2C_Exported_Macros I2C Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset I2C handle state. | |||
* @param __HANDLE__ specifies the I2C Handle. | |||
* @retval None | |||
*/ | |||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1) | |||
#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) do{ \ | |||
(__HANDLE__)->State = HAL_I2C_STATE_RESET; \ | |||
(__HANDLE__)->MspInitCallback = NULL; \ | |||
(__HANDLE__)->MspDeInitCallback = NULL; \ | |||
} while(0) | |||
#else | |||
#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2C_STATE_RESET) | |||
#endif | |||
/** @brief Enable the specified I2C interrupt. | |||
* @param __HANDLE__ specifies the I2C Handle. | |||
* @param __INTERRUPT__ specifies the interrupt source to enable. | |||
* This parameter can be one of the following values: | |||
* @arg @ref I2C_IT_ERRI Errors interrupt enable | |||
* @arg @ref I2C_IT_TCI Transfer complete interrupt enable | |||
* @arg @ref I2C_IT_STOPI STOP detection interrupt enable | |||
* @arg @ref I2C_IT_NACKI NACK received interrupt enable | |||
* @arg @ref I2C_IT_ADDRI Address match interrupt enable | |||
* @arg @ref I2C_IT_RXI RX interrupt enable | |||
* @arg @ref I2C_IT_TXI TX interrupt enable | |||
* | |||
* @retval None | |||
*/ | |||
#define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 |= (__INTERRUPT__)) | |||
/** @brief Disable the specified I2C interrupt. | |||
* @param __HANDLE__ specifies the I2C Handle. | |||
* @param __INTERRUPT__ specifies the interrupt source to disable. | |||
* This parameter can be one of the following values: | |||
* @arg @ref I2C_IT_ERRI Errors interrupt enable | |||
* @arg @ref I2C_IT_TCI Transfer complete interrupt enable | |||
* @arg @ref I2C_IT_STOPI STOP detection interrupt enable | |||
* @arg @ref I2C_IT_NACKI NACK received interrupt enable | |||
* @arg @ref I2C_IT_ADDRI Address match interrupt enable | |||
* @arg @ref I2C_IT_RXI RX interrupt enable | |||
* @arg @ref I2C_IT_TXI TX interrupt enable | |||
* | |||
* @retval None | |||
*/ | |||
#define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 &= (~(__INTERRUPT__))) | |||
/** @brief Check whether the specified I2C interrupt source is enabled or not. | |||
* @param __HANDLE__ specifies the I2C Handle. | |||
* @param __INTERRUPT__ specifies the I2C interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref I2C_IT_ERRI Errors interrupt enable | |||
* @arg @ref I2C_IT_TCI Transfer complete interrupt enable | |||
* @arg @ref I2C_IT_STOPI STOP detection interrupt enable | |||
* @arg @ref I2C_IT_NACKI NACK received interrupt enable | |||
* @arg @ref I2C_IT_ADDRI Address match interrupt enable | |||
* @arg @ref I2C_IT_RXI RX interrupt enable | |||
* @arg @ref I2C_IT_TXI TX interrupt enable | |||
* | |||
* @retval The new state of __INTERRUPT__ (SET or RESET). | |||
*/ | |||
#define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
/** @brief Check whether the specified I2C flag is set or not. | |||
* @param __HANDLE__ specifies the I2C Handle. | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref I2C_FLAG_TXE Transmit data register empty | |||
* @arg @ref I2C_FLAG_TXIS Transmit interrupt status | |||
* @arg @ref I2C_FLAG_RXNE Receive data register not empty | |||
* @arg @ref I2C_FLAG_ADDR Address matched (slave mode) | |||
* @arg @ref I2C_FLAG_AF Acknowledge failure received flag | |||
* @arg @ref I2C_FLAG_STOPF STOP detection flag | |||
* @arg @ref I2C_FLAG_TC Transfer complete (master mode) | |||
* @arg @ref I2C_FLAG_TCR Transfer complete reload | |||
* @arg @ref I2C_FLAG_BERR Bus error | |||
* @arg @ref I2C_FLAG_ARLO Arbitration lost | |||
* @arg @ref I2C_FLAG_OVR Overrun/Underrun | |||
* @arg @ref I2C_FLAG_PECERR PEC error in reception | |||
* @arg @ref I2C_FLAG_TIMEOUT Timeout or Tlow detection flag | |||
* @arg @ref I2C_FLAG_ALERT SMBus alert | |||
* @arg @ref I2C_FLAG_BUSY Bus busy | |||
* @arg @ref I2C_FLAG_DIR Transfer direction (slave mode) | |||
* | |||
* @retval The new state of __FLAG__ (SET or RESET). | |||
*/ | |||
#define I2C_FLAG_MASK (0x0001FFFFU) | |||
#define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) == (__FLAG__)) ? SET : RESET) | |||
/** @brief Clear the I2C pending flags which are cleared by writing 1 in a specific bit. | |||
* @param __HANDLE__ specifies the I2C Handle. | |||
* @param __FLAG__ specifies the flag to clear. | |||
* This parameter can be any combination of the following values: | |||
* @arg @ref I2C_FLAG_TXE Transmit data register empty | |||
* @arg @ref I2C_FLAG_ADDR Address matched (slave mode) | |||
* @arg @ref I2C_FLAG_AF Acknowledge failure received flag | |||
* @arg @ref I2C_FLAG_STOPF STOP detection flag | |||
* @arg @ref I2C_FLAG_BERR Bus error | |||
* @arg @ref I2C_FLAG_ARLO Arbitration lost | |||
* @arg @ref I2C_FLAG_OVR Overrun/Underrun | |||
* @arg @ref I2C_FLAG_PECERR PEC error in reception | |||
* @arg @ref I2C_FLAG_TIMEOUT Timeout or Tlow detection flag | |||
* @arg @ref I2C_FLAG_ALERT SMBus alert | |||
* | |||
* @retval None | |||
*/ | |||
#define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__FLAG__) == I2C_FLAG_TXE) ? ((__HANDLE__)->Instance->ISR |= (__FLAG__)) \ | |||
: ((__HANDLE__)->Instance->ICR = (__FLAG__))) | |||
/** @brief Enable the specified I2C peripheral. | |||
* @param __HANDLE__ specifies the I2C Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_I2C_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE)) | |||
/** @brief Disable the specified I2C peripheral. | |||
* @param __HANDLE__ specifies the I2C Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_I2C_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE)) | |||
/** @brief Generate a Non-Acknowledge I2C peripheral in Slave mode. | |||
* @param __HANDLE__ specifies the I2C Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_I2C_GENERATE_NACK(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR2, I2C_CR2_NACK)) | |||
/** | |||
* @} | |||
*/ | |||
/* Include I2C HAL Extended module */ | |||
#include "stm32wbxx_hal_i2c_ex.h" | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup I2C_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup I2C_Exported_Functions_Group1 Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions******************************/ | |||
HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c); | |||
HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c); | |||
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c); | |||
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c); | |||
/* Callbacks Register/UnRegister functions ***********************************/ | |||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1) | |||
HAL_StatusTypeDef HAL_I2C_RegisterCallback(I2C_HandleTypeDef *hi2c, HAL_I2C_CallbackIDTypeDef CallbackID, pI2C_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_I2C_UnRegisterCallback(I2C_HandleTypeDef *hi2c, HAL_I2C_CallbackIDTypeDef CallbackID); | |||
HAL_StatusTypeDef HAL_I2C_RegisterAddrCallback(I2C_HandleTypeDef *hi2c, pI2C_AddrCallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_I2C_UnRegisterAddrCallback(I2C_HandleTypeDef *hi2c); | |||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup I2C_Exported_Functions_Group2 Input and Output operation functions | |||
* @{ | |||
*/ | |||
/* IO operation functions ****************************************************/ | |||
/******* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout); | |||
/******* Non-Blocking mode: Interrupt */ | |||
HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_I2C_Mem_Write_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_I2C_Mem_Read_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions); | |||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions); | |||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions); | |||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions); | |||
HAL_StatusTypeDef HAL_I2C_EnableListen_IT(I2C_HandleTypeDef *hi2c); | |||
HAL_StatusTypeDef HAL_I2C_DisableListen_IT(I2C_HandleTypeDef *hi2c); | |||
HAL_StatusTypeDef HAL_I2C_Master_Abort_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress); | |||
/******* Non-Blocking mode: DMA */ | |||
HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_I2C_Mem_Write_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions); | |||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions); | |||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions); | |||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup I2C_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks | |||
* @{ | |||
*/ | |||
/******* I2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */ | |||
void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c); | |||
void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c); | |||
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c); | |||
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c); | |||
void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c); | |||
void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c); | |||
void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode); | |||
void HAL_I2C_ListenCpltCallback(I2C_HandleTypeDef *hi2c); | |||
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c); | |||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c); | |||
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c); | |||
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup I2C_Exported_Functions_Group3 Peripheral State, Mode and Error functions | |||
* @{ | |||
*/ | |||
/* Peripheral State, Mode and Error functions *********************************/ | |||
HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c); | |||
HAL_I2C_ModeTypeDef HAL_I2C_GetMode(I2C_HandleTypeDef *hi2c); | |||
uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/** @defgroup I2C_Private_Constants I2C Private Constants | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup I2C_Private_Macro I2C Private Macros | |||
* @{ | |||
*/ | |||
#define IS_I2C_ADDRESSING_MODE(MODE) (((MODE) == I2C_ADDRESSINGMODE_7BIT) || \ | |||
((MODE) == I2C_ADDRESSINGMODE_10BIT)) | |||
#define IS_I2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == I2C_DUALADDRESS_DISABLE) || \ | |||
((ADDRESS) == I2C_DUALADDRESS_ENABLE)) | |||
#define IS_I2C_OWN_ADDRESS2_MASK(MASK) (((MASK) == I2C_OA2_NOMASK) || \ | |||
((MASK) == I2C_OA2_MASK01) || \ | |||
((MASK) == I2C_OA2_MASK02) || \ | |||
((MASK) == I2C_OA2_MASK03) || \ | |||
((MASK) == I2C_OA2_MASK04) || \ | |||
((MASK) == I2C_OA2_MASK05) || \ | |||
((MASK) == I2C_OA2_MASK06) || \ | |||
((MASK) == I2C_OA2_MASK07)) | |||
#define IS_I2C_GENERAL_CALL(CALL) (((CALL) == I2C_GENERALCALL_DISABLE) || \ | |||
((CALL) == I2C_GENERALCALL_ENABLE)) | |||
#define IS_I2C_NO_STRETCH(STRETCH) (((STRETCH) == I2C_NOSTRETCH_DISABLE) || \ | |||
((STRETCH) == I2C_NOSTRETCH_ENABLE)) | |||
#define IS_I2C_MEMADD_SIZE(SIZE) (((SIZE) == I2C_MEMADD_SIZE_8BIT) || \ | |||
((SIZE) == I2C_MEMADD_SIZE_16BIT)) | |||
#define IS_TRANSFER_MODE(MODE) (((MODE) == I2C_RELOAD_MODE) || \ | |||
((MODE) == I2C_AUTOEND_MODE) || \ | |||
((MODE) == I2C_SOFTEND_MODE)) | |||
#define IS_TRANSFER_REQUEST(REQUEST) (((REQUEST) == I2C_GENERATE_STOP) || \ | |||
((REQUEST) == I2C_GENERATE_START_READ) || \ | |||
((REQUEST) == I2C_GENERATE_START_WRITE) || \ | |||
((REQUEST) == I2C_NO_STARTSTOP)) | |||
#define IS_I2C_TRANSFER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == I2C_FIRST_FRAME) || \ | |||
((REQUEST) == I2C_FIRST_AND_NEXT_FRAME) || \ | |||
((REQUEST) == I2C_NEXT_FRAME) || \ | |||
((REQUEST) == I2C_FIRST_AND_LAST_FRAME) || \ | |||
((REQUEST) == I2C_LAST_FRAME) || \ | |||
((REQUEST) == I2C_LAST_FRAME_NO_STOP) || \ | |||
IS_I2C_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST)) | |||
#define IS_I2C_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == I2C_OTHER_FRAME) || \ | |||
((REQUEST) == I2C_OTHER_AND_LAST_FRAME)) | |||
#define I2C_RESET_CR2(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_HEAD10R | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_RD_WRN))) | |||
#define I2C_GET_ADDR_MATCH(__HANDLE__) ((uint16_t)(((__HANDLE__)->Instance->ISR & I2C_ISR_ADDCODE) >> 16U)) | |||
#define I2C_GET_DIR(__HANDLE__) ((uint8_t)(((__HANDLE__)->Instance->ISR & I2C_ISR_DIR) >> 16U)) | |||
#define I2C_GET_STOP_MODE(__HANDLE__) ((__HANDLE__)->Instance->CR2 & I2C_CR2_AUTOEND) | |||
#define I2C_GET_OWN_ADDRESS1(__HANDLE__) ((uint16_t)((__HANDLE__)->Instance->OAR1 & I2C_OAR1_OA1)) | |||
#define I2C_GET_OWN_ADDRESS2(__HANDLE__) ((uint16_t)((__HANDLE__)->Instance->OAR2 & I2C_OAR2_OA2)) | |||
#define IS_I2C_OWN_ADDRESS1(ADDRESS1) ((ADDRESS1) <= 0x000003FFU) | |||
#define IS_I2C_OWN_ADDRESS2(ADDRESS2) ((ADDRESS2) <= (uint16_t)0x00FFU) | |||
#define I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0xFF00U))) >> 8U))) | |||
#define I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FFU)))) | |||
#define I2C_GENERATE_START(__ADDMODE__,__ADDRESS__) (((__ADDMODE__) == I2C_ADDRESSINGMODE_7BIT) ? (uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_START) | (I2C_CR2_AUTOEND)) & (~I2C_CR2_RD_WRN)) : \ | |||
(uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_ADD10) | (I2C_CR2_START)) & (~I2C_CR2_RD_WRN))) | |||
#define I2C_CHECK_FLAG(__ISR__, __FLAG__) ((((__ISR__) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)) ? SET : RESET) | |||
#define I2C_CHECK_IT_SOURCE(__CR1__, __IT__) ((((__CR1__) & (__IT__)) == (__IT__)) ? SET : RESET) | |||
/** | |||
* @} | |||
*/ | |||
/* Private Functions ---------------------------------------------------------*/ | |||
/** @defgroup I2C_Private_Functions I2C Private Functions | |||
* @{ | |||
*/ | |||
/* Private functions are defined in stm32wbxx_hal_i2c.c file */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_I2C_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,151 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_i2c_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of I2C HAL Extended module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_I2C_EX_H | |||
#define STM32WBxx_HAL_I2C_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup I2CEx | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup I2CEx_Exported_Constants I2C Extended Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup I2CEx_Analog_Filter I2C Extended Analog Filter | |||
* @{ | |||
*/ | |||
#define I2C_ANALOGFILTER_ENABLE 0x00000000U | |||
#define I2C_ANALOGFILTER_DISABLE I2C_CR1_ANFOFF | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup I2CEx_FastModePlus I2C Extended Fast Mode Plus | |||
* @{ | |||
*/ | |||
#define I2C_FASTMODEPLUS_PB6 SYSCFG_CFGR1_I2C_PB6_FMP /*!< Enable Fast Mode Plus on PB6 */ | |||
#define I2C_FASTMODEPLUS_PB7 SYSCFG_CFGR1_I2C_PB7_FMP /*!< Enable Fast Mode Plus on PB7 */ | |||
#define I2C_FASTMODEPLUS_PB8 SYSCFG_CFGR1_I2C_PB8_FMP /*!< Enable Fast Mode Plus on PB8 */ | |||
#define I2C_FASTMODEPLUS_PB9 SYSCFG_CFGR1_I2C_PB9_FMP /*!< Enable Fast Mode Plus on PB9 */ | |||
#define I2C_FASTMODEPLUS_I2C1 SYSCFG_CFGR1_I2C1_FMP /*!< Enable Fast Mode Plus on I2C1 pins */ | |||
#define I2C_FASTMODEPLUS_I2C3 SYSCFG_CFGR1_I2C3_FMP /*!< Enable Fast Mode Plus on I2C3 pins */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup I2CEx_Exported_Functions I2C Extended Exported Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup I2CEx_Exported_Functions_Group1 Extended features functions | |||
* @brief Extended features functions | |||
* @{ | |||
*/ | |||
/* Peripheral Control functions ************************************************/ | |||
HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter); | |||
HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter); | |||
HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp(I2C_HandleTypeDef *hi2c); | |||
HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp(I2C_HandleTypeDef *hi2c); | |||
void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus); | |||
void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus); | |||
/* Private constants ---------------------------------------------------------*/ | |||
/** @defgroup I2CEx_Private_Constants I2C Extended Private Constants | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup I2CEx_Private_Macro I2C Extended Private Macros | |||
* @{ | |||
*/ | |||
#define IS_I2C_ANALOG_FILTER(FILTER) (((FILTER) == I2C_ANALOGFILTER_ENABLE) || \ | |||
((FILTER) == I2C_ANALOGFILTER_DISABLE)) | |||
#define IS_I2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000FU) | |||
#define IS_I2C_FASTMODEPLUS(__CONFIG__) ((((__CONFIG__) & (I2C_FASTMODEPLUS_PB6)) == I2C_FASTMODEPLUS_PB6) || \ | |||
(((__CONFIG__) & (I2C_FASTMODEPLUS_PB7)) == I2C_FASTMODEPLUS_PB7) || \ | |||
(((__CONFIG__) & (I2C_FASTMODEPLUS_PB8)) == I2C_FASTMODEPLUS_PB8) || \ | |||
(((__CONFIG__) & (I2C_FASTMODEPLUS_PB9)) == I2C_FASTMODEPLUS_PB9) || \ | |||
(((__CONFIG__) & (I2C_FASTMODEPLUS_I2C1)) == I2C_FASTMODEPLUS_I2C1) || \ | |||
(((__CONFIG__) & (I2C_FASTMODEPLUS_I2C3)) == I2C_FASTMODEPLUS_I2C3)) | |||
/** | |||
* @} | |||
*/ | |||
/* Private Functions ---------------------------------------------------------*/ | |||
/** @defgroup I2CEx_Private_Functions I2C Extended Private Functions | |||
* @{ | |||
*/ | |||
/* Private functions are defined in stm32wbxx_hal_i2c_ex.c file */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_I2C_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,263 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_ipcc.h | |||
* @author MCD Application Team | |||
* @brief Header file of Mailbox HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_IPCC_H | |||
#define STM32WBxx_HAL_IPCC_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup IPCC IPCC | |||
* @brief IPCC HAL module driver | |||
* @{ | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup IPCC_Exported_Constants IPCC Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup IPCC_Channel IPCC Channel | |||
* @{ | |||
*/ | |||
#define IPCC_CHANNEL_1 0x00000000U | |||
#define IPCC_CHANNEL_2 0x00000001U | |||
#define IPCC_CHANNEL_3 0x00000002U | |||
#define IPCC_CHANNEL_4 0x00000003U | |||
#define IPCC_CHANNEL_5 0x00000004U | |||
#define IPCC_CHANNEL_6 0x00000005U | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup IPCC_Exported_Types IPCC Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief HAL IPCC State structures definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_IPCC_STATE_RESET = 0x00U, /*!< IPCC not yet initialized or disabled */ | |||
HAL_IPCC_STATE_READY = 0x01U, /*!< IPCC initialized and ready for use */ | |||
HAL_IPCC_STATE_BUSY = 0x02U /*!< IPCC internal processing is ongoing */ | |||
} HAL_IPCC_StateTypeDef; | |||
/** | |||
* @brief IPCC channel direction structure definition | |||
*/ | |||
typedef enum | |||
{ | |||
IPCC_CHANNEL_DIR_TX = 0x00U, /*!< Channel direction Tx is used by an MCU to transmit */ | |||
IPCC_CHANNEL_DIR_RX = 0x01U /*!< Channel direction Rx is used by an MCU to receive */ | |||
} IPCC_CHANNELDirTypeDef; | |||
/** | |||
* @brief IPCC channel status structure definition | |||
*/ | |||
typedef enum | |||
{ | |||
IPCC_CHANNEL_STATUS_FREE = 0x00U, /*!< Means that a new msg can be posted on that channel */ | |||
IPCC_CHANNEL_STATUS_OCCUPIED = 0x01U /*!< An MCU has posted a msg the other MCU hasn't retrieved */ | |||
} IPCC_CHANNELStatusTypeDef; | |||
/** | |||
* @brief IPCC handle structure definition | |||
*/ | |||
typedef struct __IPCC_HandleTypeDef | |||
{ | |||
IPCC_TypeDef *Instance; /*!< IPCC registers base address */ | |||
void (* ChannelCallbackRx[IPCC_CHANNEL_NUMBER])(struct __IPCC_HandleTypeDef *hipcc, uint32_t ChannelIndex, IPCC_CHANNELDirTypeDef ChannelDir); /*!< Rx Callback registration table */ | |||
void (* ChannelCallbackTx[IPCC_CHANNEL_NUMBER])(struct __IPCC_HandleTypeDef *hipcc, uint32_t ChannelIndex, IPCC_CHANNELDirTypeDef ChannelDir); /*!< Tx Callback registration table */ | |||
uint32_t callbackRequest; /*!< Store information about callback notification by channel */ | |||
__IO HAL_IPCC_StateTypeDef State; /*!< IPCC State: initialized or not */ | |||
} IPCC_HandleTypeDef; | |||
/** | |||
* @brief IPCC callback typedef | |||
*/ | |||
typedef void ChannelCb(IPCC_HandleTypeDef *hipcc, uint32_t ChannelIndex, IPCC_CHANNELDirTypeDef ChannelDir); | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup IPCC_Exported_Macros IPCC Exported Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable the specified interrupt. | |||
* @param __HANDLE__ specifies the IPCC Handle | |||
* @param __CHDIRECTION__ specifies the channels Direction | |||
* This parameter can be one of the following values: | |||
* @arg @ref IPCC_CHANNEL_DIR_TX Transmit channel free interrupt enable | |||
* @arg @ref IPCC_CHANNEL_DIR_RX Receive channel occupied interrupt enable | |||
*/ | |||
#define __HAL_IPCC_ENABLE_IT(__HANDLE__, __CHDIRECTION__) \ | |||
(((__CHDIRECTION__) == IPCC_CHANNEL_DIR_RX) ? \ | |||
((__HANDLE__)->Instance->C1CR |= IPCC_C1CR_RXOIE) : \ | |||
((__HANDLE__)->Instance->C1CR |= IPCC_C1CR_TXFIE)) | |||
/** | |||
* @brief Disable the specified interrupt. | |||
* @param __HANDLE__ specifies the IPCC Handle | |||
* @param __CHDIRECTION__ specifies the channels Direction | |||
* This parameter can be one of the following values: | |||
* @arg @ref IPCC_CHANNEL_DIR_TX Transmit channel free interrupt enable | |||
* @arg @ref IPCC_CHANNEL_DIR_RX Receive channel occupied interrupt enable | |||
*/ | |||
#define __HAL_IPCC_DISABLE_IT(__HANDLE__, __CHDIRECTION__) \ | |||
(((__CHDIRECTION__) == IPCC_CHANNEL_DIR_RX) ? \ | |||
((__HANDLE__)->Instance->C1CR &= ~IPCC_C1CR_RXOIE) : \ | |||
((__HANDLE__)->Instance->C1CR &= ~IPCC_C1CR_TXFIE)) | |||
/** | |||
* @brief Mask the specified interrupt. | |||
* @param __HANDLE__ specifies the IPCC Handle | |||
* @param __CHDIRECTION__ specifies the channels Direction | |||
* This parameter can be one of the following values: | |||
* @arg @ref IPCC_CHANNEL_DIR_TX Transmit channel free interrupt enable | |||
* @arg @ref IPCC_CHANNEL_DIR_RX Receive channel occupied interrupt enable | |||
* @param __CHINDEX__ specifies the channels number: | |||
* This parameter can be one of the following values: | |||
* @arg IPCC_CHANNEL_1: IPCC Channel 1 | |||
* @arg IPCC_CHANNEL_2: IPCC Channel 2 | |||
* @arg IPCC_CHANNEL_3: IPCC Channel 3 | |||
* @arg IPCC_CHANNEL_4: IPCC Channel 4 | |||
* @arg IPCC_CHANNEL_5: IPCC Channel 5 | |||
* @arg IPCC_CHANNEL_6: IPCC Channel 6 | |||
*/ | |||
#define __HAL_IPCC_MASK_CHANNEL_IT(__HANDLE__, __CHDIRECTION__, __CHINDEX__) \ | |||
(((__CHDIRECTION__) == IPCC_CHANNEL_DIR_RX) ? \ | |||
((__HANDLE__)->Instance->C1MR |= (IPCC_C1MR_CH1OM_Msk << (__CHINDEX__))) : \ | |||
((__HANDLE__)->Instance->C1MR |= (IPCC_C1MR_CH1FM_Msk << (__CHINDEX__)))) | |||
/** | |||
* @brief Unmask the specified interrupt. | |||
* @param __HANDLE__ specifies the IPCC Handle | |||
* @param __CHDIRECTION__ specifies the channels Direction | |||
* This parameter can be one of the following values: | |||
* @arg @ref IPCC_CHANNEL_DIR_TX Transmit channel free interrupt enable | |||
* @arg @ref IPCC_CHANNEL_DIR_RX Receive channel occupied interrupt enable | |||
* @param __CHINDEX__ specifies the channels number: | |||
* This parameter can be one of the following values: | |||
* @arg IPCC_CHANNEL_1: IPCC Channel 1 | |||
* @arg IPCC_CHANNEL_2: IPCC Channel 2 | |||
* @arg IPCC_CHANNEL_3: IPCC Channel 3 | |||
* @arg IPCC_CHANNEL_4: IPCC Channel 4 | |||
* @arg IPCC_CHANNEL_5: IPCC Channel 5 | |||
* @arg IPCC_CHANNEL_6: IPCC Channel 6 | |||
*/ | |||
#define __HAL_IPCC_UNMASK_CHANNEL_IT(__HANDLE__, __CHDIRECTION__, __CHINDEX__) \ | |||
(((__CHDIRECTION__) == IPCC_CHANNEL_DIR_RX) ? \ | |||
((__HANDLE__)->Instance->C1MR &= ~(IPCC_C1MR_CH1OM_Msk << (__CHINDEX__))) : \ | |||
((__HANDLE__)->Instance->C1MR &= ~(IPCC_C1MR_CH1FM_Msk << (__CHINDEX__)))) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup IPCC_Exported_Functions IPCC Exported Functions | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions *******************************/ | |||
/** @defgroup IPCC_Exported_Functions_Group1 Initialization and deinitialization functions | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_IPCC_Init(IPCC_HandleTypeDef *hipcc); | |||
HAL_StatusTypeDef HAL_IPCC_DeInit(IPCC_HandleTypeDef *hipcc); | |||
void HAL_IPCC_MspInit(IPCC_HandleTypeDef *hipcc); | |||
void HAL_IPCC_MspDeInit(IPCC_HandleTypeDef *hipcc); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IPCC_Exported_Functions_Group2 Communication functions | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
HAL_StatusTypeDef HAL_IPCC_ActivateNotification(IPCC_HandleTypeDef *hipcc, uint32_t ChannelIndex, IPCC_CHANNELDirTypeDef ChannelDir, ChannelCb cb); | |||
HAL_StatusTypeDef HAL_IPCC_DeActivateNotification(IPCC_HandleTypeDef *hipcc, uint32_t ChannelIndex, IPCC_CHANNELDirTypeDef ChannelDir); | |||
IPCC_CHANNELStatusTypeDef HAL_IPCC_GetChannelStatus(IPCC_HandleTypeDef const *const hipcc, uint32_t ChannelIndex, IPCC_CHANNELDirTypeDef ChannelDir); | |||
HAL_StatusTypeDef HAL_IPCC_NotifyCPU(IPCC_HandleTypeDef const *const hipcc, uint32_t ChannelIndex, IPCC_CHANNELDirTypeDef ChannelDir); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IPCC_Exported_Functions_Group3 Peripheral State and Error functions | |||
* @{ | |||
*/ | |||
/* Peripheral State and Error functions ****************************************/ | |||
HAL_IPCC_StateTypeDef HAL_IPCC_GetState(IPCC_HandleTypeDef const *const hipcc); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IPCC_IRQ_Handler_and_Callbacks Peripheral IRQ Handler and Callbacks | |||
* @{ | |||
*/ | |||
/* IRQHandler and Callbacks used in non blocking modes ************************/ | |||
void HAL_IPCC_TX_IRQHandler(IPCC_HandleTypeDef *const hipcc); | |||
void HAL_IPCC_RX_IRQHandler(IPCC_HandleTypeDef *const hipcc); | |||
void HAL_IPCC_TxCallback(IPCC_HandleTypeDef *hipcc, uint32_t ChannelIndex, IPCC_CHANNELDirTypeDef ChannelDir); | |||
void HAL_IPCC_RxCallback(IPCC_HandleTypeDef *hipcc, uint32_t ChannelIndex, IPCC_CHANNELDirTypeDef ChannelDir); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_IPCC_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,954 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_irda.h | |||
* @author MCD Application Team | |||
* @brief Header file of IRDA HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_IRDA_H | |||
#define STM32WBxx_HAL_IRDA_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup IRDA | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup IRDA_Exported_Types IRDA Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief IRDA Init Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t BaudRate; /*!< This member configures the IRDA communication baud rate. | |||
The baud rate register is computed using the following formula: | |||
Baud Rate Register = ((usart_ker_ckpres) / ((hirda->Init.BaudRate))) | |||
where usart_ker_ckpres is the IRDA input clock divided by a prescaler */ | |||
uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. | |||
This parameter can be a value of @ref IRDA_Word_Length */ | |||
uint32_t Parity; /*!< Specifies the parity mode. | |||
This parameter can be a value of @ref IRDA_Parity | |||
@note When parity is enabled, the computed parity is inserted | |||
at the MSB position of the transmitted data (9th bit when | |||
the word length is set to 9 data bits; 8th bit when the | |||
word length is set to 8 data bits). */ | |||
uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled. | |||
This parameter can be a value of @ref IRDA_Transfer_Mode */ | |||
uint8_t Prescaler; /*!< Specifies the Prescaler value for dividing the UART/USART source clock | |||
to achieve low-power frequency. | |||
@note Prescaler value 0 is forbidden */ | |||
uint16_t PowerMode; /*!< Specifies the IRDA power mode. | |||
This parameter can be a value of @ref IRDA_Low_Power */ | |||
uint32_t ClockPrescaler; /*!< Specifies the prescaler value used to divide the IRDA clock source. | |||
This parameter can be a value of @ref IRDA_ClockPrescaler. */ | |||
} IRDA_InitTypeDef; | |||
/** | |||
* @brief HAL IRDA State definition | |||
* @note HAL IRDA State value is a combination of 2 different substates: gState and RxState (see @ref IRDA_State_Definition). | |||
* - gState contains IRDA state information related to global Handle management | |||
* and also information related to Tx operations. | |||
* gState value coding follow below described bitmap : | |||
* b7-b6 Error information | |||
* 00 : No Error | |||
* 01 : (Not Used) | |||
* 10 : Timeout | |||
* 11 : Error | |||
* b5 IP initilisation status | |||
* 0 : Reset (IP not initialized) | |||
* 1 : Init done (IP not initialized. HAL IRDA Init function already called) | |||
* b4-b3 (not used) | |||
* xx : Should be set to 00 | |||
* b2 Intrinsic process state | |||
* 0 : Ready | |||
* 1 : Busy (IP busy with some configuration or internal operations) | |||
* b1 (not used) | |||
* x : Should be set to 0 | |||
* b0 Tx state | |||
* 0 : Ready (no Tx operation ongoing) | |||
* 1 : Busy (Tx operation ongoing) | |||
* - RxState contains information related to Rx operations. | |||
* RxState value coding follow below described bitmap : | |||
* b7-b6 (not used) | |||
* xx : Should be set to 00 | |||
* b5 IP initilisation status | |||
* 0 : Reset (IP not initialized) | |||
* 1 : Init done (IP not initialized) | |||
* b4-b2 (not used) | |||
* xxx : Should be set to 000 | |||
* b1 Rx state | |||
* 0 : Ready (no Rx operation ongoing) | |||
* 1 : Busy (Rx operation ongoing) | |||
* b0 (not used) | |||
* x : Should be set to 0. | |||
*/ | |||
typedef uint32_t HAL_IRDA_StateTypeDef; | |||
/** | |||
* @brief IRDA clock sources definition | |||
*/ | |||
typedef enum | |||
{ | |||
IRDA_CLOCKSOURCE_PCLK2 = 0x01U, /*!< PCLK2 clock source */ | |||
IRDA_CLOCKSOURCE_HSI = 0x02U, /*!< HSI clock source */ | |||
IRDA_CLOCKSOURCE_SYSCLK = 0x04U, /*!< SYSCLK clock source */ | |||
IRDA_CLOCKSOURCE_LSE = 0x10U, /*!< LSE clock source */ | |||
IRDA_CLOCKSOURCE_UNDEFINED = 0x20U /*!< Undefined clock source */ | |||
} IRDA_ClockSourceTypeDef; | |||
/** | |||
* @brief IRDA handle Structure definition | |||
*/ | |||
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1) | |||
typedef struct __IRDA_HandleTypeDef | |||
#else | |||
typedef struct | |||
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */ | |||
{ | |||
USART_TypeDef *Instance; /*!< USART registers base address */ | |||
IRDA_InitTypeDef Init; /*!< IRDA communication parameters */ | |||
uint8_t *pTxBuffPtr; /*!< Pointer to IRDA Tx transfer Buffer */ | |||
uint16_t TxXferSize; /*!< IRDA Tx Transfer size */ | |||
__IO uint16_t TxXferCount; /*!< IRDA Tx Transfer Counter */ | |||
uint8_t *pRxBuffPtr; /*!< Pointer to IRDA Rx transfer Buffer */ | |||
uint16_t RxXferSize; /*!< IRDA Rx Transfer size */ | |||
__IO uint16_t RxXferCount; /*!< IRDA Rx Transfer Counter */ | |||
uint16_t Mask; /*!< USART RX RDR register mask */ | |||
DMA_HandleTypeDef *hdmatx; /*!< IRDA Tx DMA Handle parameters */ | |||
DMA_HandleTypeDef *hdmarx; /*!< IRDA Rx DMA Handle parameters */ | |||
HAL_LockTypeDef Lock; /*!< Locking object */ | |||
__IO HAL_IRDA_StateTypeDef gState; /*!< IRDA state information related to global Handle management | |||
and also related to Tx operations. | |||
This parameter can be a value of @ref HAL_IRDA_StateTypeDef */ | |||
__IO HAL_IRDA_StateTypeDef RxState; /*!< IRDA state information related to Rx operations. | |||
This parameter can be a value of @ref HAL_IRDA_StateTypeDef */ | |||
uint32_t ErrorCode; /*!< IRDA Error code */ | |||
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1) | |||
void (* TxHalfCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Tx Half Complete Callback */ | |||
void (* TxCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Tx Complete Callback */ | |||
void (* RxHalfCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Rx Half Complete Callback */ | |||
void (* RxCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Rx Complete Callback */ | |||
void (* ErrorCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Error Callback */ | |||
void (* AbortCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Complete Callback */ | |||
void (* AbortTransmitCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Transmit Complete Callback */ | |||
void (* AbortReceiveCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Receive Complete Callback */ | |||
void (* MspInitCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Msp Init callback */ | |||
void (* MspDeInitCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Msp DeInit callback */ | |||
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */ | |||
} IRDA_HandleTypeDef; | |||
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1) | |||
/** | |||
* @brief HAL IRDA Callback ID enumeration definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_IRDA_TX_HALFCOMPLETE_CB_ID = 0x00U, /*!< IRDA Tx Half Complete Callback ID */ | |||
HAL_IRDA_TX_COMPLETE_CB_ID = 0x01U, /*!< IRDA Tx Complete Callback ID */ | |||
HAL_IRDA_RX_HALFCOMPLETE_CB_ID = 0x02U, /*!< IRDA Rx Half Complete Callback ID */ | |||
HAL_IRDA_RX_COMPLETE_CB_ID = 0x03U, /*!< IRDA Rx Complete Callback ID */ | |||
HAL_IRDA_ERROR_CB_ID = 0x04U, /*!< IRDA Error Callback ID */ | |||
HAL_IRDA_ABORT_COMPLETE_CB_ID = 0x05U, /*!< IRDA Abort Complete Callback ID */ | |||
HAL_IRDA_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x06U, /*!< IRDA Abort Transmit Complete Callback ID */ | |||
HAL_IRDA_ABORT_RECEIVE_COMPLETE_CB_ID = 0x07U, /*!< IRDA Abort Receive Complete Callback ID */ | |||
HAL_IRDA_MSPINIT_CB_ID = 0x08U, /*!< IRDA MspInit callback ID */ | |||
HAL_IRDA_MSPDEINIT_CB_ID = 0x09U /*!< IRDA MspDeInit callback ID */ | |||
} HAL_IRDA_CallbackIDTypeDef; | |||
/** | |||
* @brief HAL IRDA Callback pointer definition | |||
*/ | |||
typedef void (*pIRDA_CallbackTypeDef)(IRDA_HandleTypeDef *hirda); /*!< pointer to an IRDA callback function */ | |||
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup IRDA_Exported_Constants IRDA Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup IRDA_State_Definition IRDA State Code Definition | |||
* @{ | |||
*/ | |||
#define HAL_IRDA_STATE_RESET 0x00000000U /*!< Peripheral is not initialized | |||
Value is allowed for gState and RxState */ | |||
#define HAL_IRDA_STATE_READY 0x00000020U /*!< Peripheral Initialized and ready for use | |||
Value is allowed for gState and RxState */ | |||
#define HAL_IRDA_STATE_BUSY 0x00000024U /*!< An internal process is ongoing | |||
Value is allowed for gState only */ | |||
#define HAL_IRDA_STATE_BUSY_TX 0x00000021U /*!< Data Transmission process is ongoing | |||
Value is allowed for gState only */ | |||
#define HAL_IRDA_STATE_BUSY_RX 0x00000022U /*!< Data Reception process is ongoing | |||
Value is allowed for RxState only */ | |||
#define HAL_IRDA_STATE_BUSY_TX_RX 0x00000023U /*!< Data Transmission and Reception process is ongoing | |||
Not to be used for neither gState nor RxState. | |||
Value is result of combination (Or) between gState and RxState values */ | |||
#define HAL_IRDA_STATE_TIMEOUT 0x000000A0U /*!< Timeout state | |||
Value is allowed for gState only */ | |||
#define HAL_IRDA_STATE_ERROR 0x000000E0U /*!< Error | |||
Value is allowed for gState only */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_Error_Definition IRDA Error Code Definition | |||
* @{ | |||
*/ | |||
#define HAL_IRDA_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */ | |||
#define HAL_IRDA_ERROR_PE ((uint32_t)0x00000001U) /*!< Parity error */ | |||
#define HAL_IRDA_ERROR_NE ((uint32_t)0x00000002U) /*!< Noise error */ | |||
#define HAL_IRDA_ERROR_FE ((uint32_t)0x00000004U) /*!< frame error */ | |||
#define HAL_IRDA_ERROR_ORE ((uint32_t)0x00000008U) /*!< Overrun error */ | |||
#define HAL_IRDA_ERROR_DMA ((uint32_t)0x00000010U) /*!< DMA transfer error */ | |||
#define HAL_IRDA_ERROR_BUSY ((uint32_t)0x00000020U) /*!< Busy Error */ | |||
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1) | |||
#define HAL_IRDA_ERROR_INVALID_CALLBACK ((uint32_t)0x00000040U) /*!< Invalid Callback error */ | |||
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_Word_Length IRDA Word Length | |||
* @{ | |||
*/ | |||
#define IRDA_WORDLENGTH_7B USART_CR1_M1 /*!< 7-bit long frame */ | |||
#define IRDA_WORDLENGTH_8B 0x00000000U /*!< 8-bit long frame */ | |||
#define IRDA_WORDLENGTH_9B USART_CR1_M0 /*!< 9-bit long frame */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_Parity IRDA Parity | |||
* @{ | |||
*/ | |||
#define IRDA_PARITY_NONE 0x00000000U /*!< No parity */ | |||
#define IRDA_PARITY_EVEN USART_CR1_PCE /*!< Even parity */ | |||
#define IRDA_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Odd parity */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_Transfer_Mode IRDA Transfer Mode | |||
* @{ | |||
*/ | |||
#define IRDA_MODE_RX USART_CR1_RE /*!< RX mode */ | |||
#define IRDA_MODE_TX USART_CR1_TE /*!< TX mode */ | |||
#define IRDA_MODE_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< RX and TX mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_Low_Power IRDA Low Power | |||
* @{ | |||
*/ | |||
#define IRDA_POWERMODE_NORMAL 0x00000000U /*!< IRDA normal power mode */ | |||
#define IRDA_POWERMODE_LOWPOWER USART_CR3_IRLP /*!< IRDA low power mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_ClockPrescaler Clock Prescaler | |||
* @{ | |||
*/ | |||
#define IRDA_PRESCALER_DIV1 0x00000000U /*!< fclk_pres = fclk */ | |||
#define IRDA_PRESCALER_DIV2 0x00000001U /*!< fclk_pres = fclk/2 */ | |||
#define IRDA_PRESCALER_DIV4 0x00000002U /*!< fclk_pres = fclk/4 */ | |||
#define IRDA_PRESCALER_DIV6 0x00000003U /*!< fclk_pres = fclk/6 */ | |||
#define IRDA_PRESCALER_DIV8 0x00000004U /*!< fclk_pres = fclk/8 */ | |||
#define IRDA_PRESCALER_DIV10 0x00000005U /*!< fclk_pres = fclk/10 */ | |||
#define IRDA_PRESCALER_DIV12 0x00000006U /*!< fclk_pres = fclk/12 */ | |||
#define IRDA_PRESCALER_DIV16 0x00000007U /*!< fclk_pres = fclk/16 */ | |||
#define IRDA_PRESCALER_DIV32 0x00000008U /*!< fclk_pres = fclk/32 */ | |||
#define IRDA_PRESCALER_DIV64 0x00000009U /*!< fclk_pres = fclk/64 */ | |||
#define IRDA_PRESCALER_DIV128 0x0000000AU /*!< fclk_pres = fclk/128 */ | |||
#define IRDA_PRESCALER_DIV256 0x0000000BU /*!< fclk_pres = fclk/256 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_State IRDA State | |||
* @{ | |||
*/ | |||
#define IRDA_STATE_DISABLE 0x00000000U /*!< IRDA disabled */ | |||
#define IRDA_STATE_ENABLE USART_CR1_UE /*!< IRDA enabled */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_Mode IRDA Mode | |||
* @{ | |||
*/ | |||
#define IRDA_MODE_DISABLE 0x00000000U /*!< Associated UART disabled in IRDA mode */ | |||
#define IRDA_MODE_ENABLE USART_CR3_IREN /*!< Associated UART enabled in IRDA mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_One_Bit IRDA One Bit Sampling | |||
* @{ | |||
*/ | |||
#define IRDA_ONE_BIT_SAMPLE_DISABLE 0x00000000U /*!< One-bit sampling disabled */ | |||
#define IRDA_ONE_BIT_SAMPLE_ENABLE USART_CR3_ONEBIT /*!< One-bit sampling enabled */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_DMA_Tx IRDA DMA Tx | |||
* @{ | |||
*/ | |||
#define IRDA_DMA_TX_DISABLE 0x00000000U /*!< IRDA DMA TX disabled */ | |||
#define IRDA_DMA_TX_ENABLE USART_CR3_DMAT /*!< IRDA DMA TX enabled */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_DMA_Rx IRDA DMA Rx | |||
* @{ | |||
*/ | |||
#define IRDA_DMA_RX_DISABLE 0x00000000U /*!< IRDA DMA RX disabled */ | |||
#define IRDA_DMA_RX_ENABLE USART_CR3_DMAR /*!< IRDA DMA RX enabled */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_Request_Parameters IRDA Request Parameters | |||
* @{ | |||
*/ | |||
#define IRDA_AUTOBAUD_REQUEST USART_RQR_ABRRQ /*!< Auto-Baud Rate Request */ | |||
#define IRDA_RXDATA_FLUSH_REQUEST USART_RQR_RXFRQ /*!< Receive Data flush Request */ | |||
#define IRDA_TXDATA_FLUSH_REQUEST USART_RQR_TXFRQ /*!< Transmit data flush Request */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_Flags IRDA Flags | |||
* Elements values convention: 0xXXXX | |||
* - 0xXXXX : Flag mask in the ISR register | |||
* @{ | |||
*/ | |||
#define IRDA_FLAG_REACK USART_ISR_REACK /*!< IRDA receive enable acknowledge flag */ | |||
#define IRDA_FLAG_TEACK USART_ISR_TEACK /*!< IRDA transmit enable acknowledge flag */ | |||
#define IRDA_FLAG_BUSY USART_ISR_BUSY /*!< IRDA busy flag */ | |||
#define IRDA_FLAG_ABRF USART_ISR_ABRF /*!< IRDA auto Baud rate flag */ | |||
#define IRDA_FLAG_ABRE USART_ISR_ABRE /*!< IRDA auto Baud rate error */ | |||
#define IRDA_FLAG_TXE USART_ISR_TXE_TXFNF /*!< IRDA transmit data register empty */ | |||
#define IRDA_FLAG_TC USART_ISR_TC /*!< IRDA transmission complete */ | |||
#define IRDA_FLAG_RXNE USART_ISR_RXNE_RXFNE /*!< IRDA read data register not empty */ | |||
#define IRDA_FLAG_ORE USART_ISR_ORE /*!< IRDA overrun error */ | |||
#define IRDA_FLAG_NE USART_ISR_NE /*!< IRDA noise error */ | |||
#define IRDA_FLAG_FE USART_ISR_FE /*!< IRDA frame error */ | |||
#define IRDA_FLAG_PE USART_ISR_PE /*!< IRDA parity error */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_Interrupt_definition IRDA Interrupts Definition | |||
* Elements values convention: 0000ZZZZ0XXYYYYYb | |||
* - YYYYY : Interrupt source position in the XX register (5bits) | |||
* - XX : Interrupt source register (2bits) | |||
* - 01: CR1 register | |||
* - 10: CR2 register | |||
* - 11: CR3 register | |||
* - ZZZZ : Flag position in the ISR register(4bits) | |||
* @{ | |||
*/ | |||
#define IRDA_IT_PE 0x0028U /*!< IRDA Parity error interruption */ | |||
#define IRDA_IT_TXE 0x0727U /*!< IRDA Transmit data register empty interruption */ | |||
#define IRDA_IT_TC 0x0626U /*!< IRDA Transmission complete interruption */ | |||
#define IRDA_IT_RXNE 0x0525U /*!< IRDA Read data register not empty interruption */ | |||
#define IRDA_IT_IDLE 0x0424U /*!< IRDA Idle interruption */ | |||
/* Elements values convention: 000000000XXYYYYYb | |||
- YYYYY : Interrupt source position in the XX register (5bits) | |||
- XX : Interrupt source register (2bits) | |||
- 01: CR1 register | |||
- 10: CR2 register | |||
- 11: CR3 register */ | |||
#define IRDA_IT_ERR 0x0060U /*!< IRDA Error interruption */ | |||
/* Elements values convention: 0000ZZZZ00000000b | |||
- ZZZZ : Flag position in the ISR register(4bits) */ | |||
#define IRDA_IT_ORE 0x0300U /*!< IRDA Overrun error interruption */ | |||
#define IRDA_IT_NE 0x0200U /*!< IRDA Noise error interruption */ | |||
#define IRDA_IT_FE 0x0100U /*!< IRDA Frame error interruption */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_IT_CLEAR_Flags IRDA Interruption Clear Flags | |||
* @{ | |||
*/ | |||
#define IRDA_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */ | |||
#define IRDA_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */ | |||
#define IRDA_CLEAR_NEF USART_ICR_NECF /*!< Noise Error detected Clear Flag */ | |||
#define IRDA_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */ | |||
#define IRDA_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */ | |||
#define IRDA_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IRDA_Interruption_Mask IRDA interruptions flags mask | |||
* @{ | |||
*/ | |||
#define IRDA_IT_MASK 0x001FU /*!< IRDA Interruptions flags mask */ | |||
#define IRDA_CR_MASK 0x00E0U /*!< IRDA control register mask */ | |||
#define IRDA_CR_POS 5U /*!< IRDA control register position */ | |||
#define IRDA_ISR_MASK 0x1F00U /*!< IRDA ISR register mask */ | |||
#define IRDA_ISR_POS 8U /*!< IRDA ISR register position */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup IRDA_Exported_Macros IRDA Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset IRDA handle state. | |||
* @param __HANDLE__ IRDA handle. | |||
* @retval None | |||
*/ | |||
#if USE_HAL_IRDA_REGISTER_CALLBACKS == 1 | |||
#define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) do{ \ | |||
(__HANDLE__)->gState = HAL_IRDA_STATE_RESET; \ | |||
(__HANDLE__)->RxState = HAL_IRDA_STATE_RESET; \ | |||
(__HANDLE__)->MspInitCallback = NULL; \ | |||
(__HANDLE__)->MspDeInitCallback = NULL; \ | |||
} while(0) | |||
#else | |||
#define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) do{ \ | |||
(__HANDLE__)->gState = HAL_IRDA_STATE_RESET; \ | |||
(__HANDLE__)->RxState = HAL_IRDA_STATE_RESET; \ | |||
} while(0) | |||
#endif /*USE_HAL_IRDA_REGISTER_CALLBACKS */ | |||
/** @brief Flush the IRDA DR register. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) \ | |||
do{ \ | |||
SET_BIT((__HANDLE__)->Instance->RQR, IRDA_RXDATA_FLUSH_REQUEST); \ | |||
SET_BIT((__HANDLE__)->Instance->RQR, IRDA_TXDATA_FLUSH_REQUEST); \ | |||
} while(0) | |||
/** @brief Clear the specified IRDA pending flag. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be any combination of the following values: | |||
* @arg @ref IRDA_CLEAR_PEF | |||
* @arg @ref IRDA_CLEAR_FEF | |||
* @arg @ref IRDA_CLEAR_NEF | |||
* @arg @ref IRDA_CLEAR_OREF | |||
* @arg @ref IRDA_CLEAR_TCF | |||
* @arg @ref IRDA_CLEAR_IDLEF | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) | |||
/** @brief Clear the IRDA PE pending flag. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_PEF) | |||
/** @brief Clear the IRDA FE pending flag. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_FEF) | |||
/** @brief Clear the IRDA NE pending flag. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_NEF) | |||
/** @brief Clear the IRDA ORE pending flag. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_OREF) | |||
/** @brief Clear the IRDA IDLE pending flag. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_FLAG((__HANDLE__), IRDA_CLEAR_IDLEF) | |||
/** @brief Check whether the specified IRDA flag is set or not. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref IRDA_FLAG_REACK Receive enable acknowledge flag | |||
* @arg @ref IRDA_FLAG_TEACK Transmit enable acknowledge flag | |||
* @arg @ref IRDA_FLAG_BUSY Busy flag | |||
* @arg @ref IRDA_FLAG_ABRF Auto Baud rate detection flag | |||
* @arg @ref IRDA_FLAG_ABRE Auto Baud rate detection error flag | |||
* @arg @ref IRDA_FLAG_TXE Transmit data register empty flag | |||
* @arg @ref IRDA_FLAG_TC Transmission Complete flag | |||
* @arg @ref IRDA_FLAG_RXNE Receive data register not empty flag | |||
* @arg @ref IRDA_FLAG_ORE OverRun Error flag | |||
* @arg @ref IRDA_FLAG_NE Noise Error flag | |||
* @arg @ref IRDA_FLAG_FE Framing Error flag | |||
* @arg @ref IRDA_FLAG_PE Parity Error flag | |||
* @retval The new state of __FLAG__ (TRUE or FALSE). | |||
*/ | |||
#define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__)) | |||
/** @brief Enable the specified IRDA interrupt. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @param __INTERRUPT__ specifies the IRDA interrupt source to enable. | |||
* This parameter can be one of the following values: | |||
* @arg @ref IRDA_IT_TXE Transmit Data Register empty interrupt | |||
* @arg @ref IRDA_IT_TC Transmission complete interrupt | |||
* @arg @ref IRDA_IT_RXNE Receive Data register not empty interrupt | |||
* @arg @ref IRDA_IT_IDLE Idle line detection interrupt | |||
* @arg @ref IRDA_IT_PE Parity Error interrupt | |||
* @arg @ref IRDA_IT_ERR Error interrupt(Frame error, noise error, overrun error) | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 1)? ((__HANDLE__)->Instance->CR1 |= ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \ | |||
((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 2)? ((__HANDLE__)->Instance->CR2 |= ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \ | |||
((__HANDLE__)->Instance->CR3 |= ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK)))) | |||
/** @brief Disable the specified IRDA interrupt. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @param __INTERRUPT__ specifies the IRDA interrupt source to disable. | |||
* This parameter can be one of the following values: | |||
* @arg @ref IRDA_IT_TXE Transmit Data Register empty interrupt | |||
* @arg @ref IRDA_IT_TC Transmission complete interrupt | |||
* @arg @ref IRDA_IT_RXNE Receive Data register not empty interrupt | |||
* @arg @ref IRDA_IT_IDLE Idle line detection interrupt | |||
* @arg @ref IRDA_IT_PE Parity Error interrupt | |||
* @arg @ref IRDA_IT_ERR Error interrupt(Frame error, noise error, overrun error) | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \ | |||
((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK))): \ | |||
((__HANDLE__)->Instance->CR3 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & IRDA_IT_MASK)))) | |||
/** @brief Check whether the specified IRDA interrupt has occurred or not. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @param __INTERRUPT__ specifies the IRDA interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref IRDA_IT_TXE Transmit Data Register empty interrupt | |||
* @arg @ref IRDA_IT_TC Transmission complete interrupt | |||
* @arg @ref IRDA_IT_RXNE Receive Data register not empty interrupt | |||
* @arg @ref IRDA_IT_IDLE Idle line detection interrupt | |||
* @arg @ref IRDA_IT_ORE OverRun Error interrupt | |||
* @arg @ref IRDA_IT_NE Noise Error interrupt | |||
* @arg @ref IRDA_IT_FE Framing Error interrupt | |||
* @arg @ref IRDA_IT_PE Parity Error interrupt | |||
* @retval The new state of __IT__ (SET or RESET). | |||
*/ | |||
#define __HAL_IRDA_GET_IT(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->ISR & (0x01U << (((__INTERRUPT__) & IRDA_ISR_MASK)>> IRDA_ISR_POS))) != 0U) ? SET : RESET) | |||
/** @brief Check whether the specified IRDA interrupt source is enabled or not. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @param __INTERRUPT__ specifies the IRDA interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref IRDA_IT_TXE Transmit Data Register empty interrupt | |||
* @arg @ref IRDA_IT_TC Transmission complete interrupt | |||
* @arg @ref IRDA_IT_RXNE Receive Data register not empty interrupt | |||
* @arg @ref IRDA_IT_IDLE Idle line detection interrupt | |||
* @arg @ref IRDA_IT_ERR Framing, overrun or noise error interrupt | |||
* @arg @ref IRDA_IT_PE Parity Error interrupt | |||
* @retval The new state of __IT__ (SET or RESET). | |||
*/ | |||
#define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 0x01U)? (__HANDLE__)->Instance->CR1 : \ | |||
(((((__INTERRUPT__) & IRDA_CR_MASK) >> IRDA_CR_POS) == 0x02U)? (__HANDLE__)->Instance->CR2 : \ | |||
(__HANDLE__)->Instance->CR3)) & ((uint32_t)0x01U << (((uint16_t)(__INTERRUPT__)) & IRDA_IT_MASK))) != 0U) ? SET : RESET) | |||
/** @brief Clear the specified IRDA ISR flag, in setting the proper ICR register flag. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @param __IT_CLEAR__ specifies the interrupt clear register flag that needs to be set | |||
* to clear the corresponding interrupt | |||
* This parameter can be one of the following values: | |||
* @arg @ref IRDA_CLEAR_PEF Parity Error Clear Flag | |||
* @arg @ref IRDA_CLEAR_FEF Framing Error Clear Flag | |||
* @arg @ref IRDA_CLEAR_NEF Noise detected Clear Flag | |||
* @arg @ref IRDA_CLEAR_OREF OverRun Error Clear Flag | |||
* @arg @ref IRDA_CLEAR_TCF Transmission Complete Clear Flag | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__)) | |||
/** @brief Set a specific IRDA request flag. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @param __REQ__ specifies the request flag to set | |||
* This parameter can be one of the following values: | |||
* @arg @ref IRDA_AUTOBAUD_REQUEST Auto-Baud Rate Request | |||
* @arg @ref IRDA_RXDATA_FLUSH_REQUEST Receive Data flush Request | |||
* @arg @ref IRDA_TXDATA_FLUSH_REQUEST Transmit data flush Request | |||
* | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__)) | |||
/** @brief Enable the IRDA one bit sample method. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT) | |||
/** @brief Disable the IRDA one bit sample method. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT)) | |||
/** @brief Enable UART/USART associated to IRDA Handle. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) | |||
/** @brief Disable UART/USART associated to IRDA Handle. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_IRDA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros --------------------------------------------------------*/ | |||
/** @addtogroup IRDA_Private_Macros | |||
* @{ | |||
*/ | |||
/** @brief Compute the mask to apply to retrieve the received data | |||
* according to the word length and to the parity bits activation. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @retval None, the mask to apply to the associated UART RDR register is stored in (__HANDLE__)->Mask field. | |||
*/ | |||
#define IRDA_MASK_COMPUTATION(__HANDLE__) \ | |||
do { \ | |||
if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_9B) \ | |||
{ \ | |||
if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x01FF ; \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x00FF ; \ | |||
} \ | |||
} \ | |||
else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_8B) \ | |||
{ \ | |||
if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x00FF ; \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x007F ; \ | |||
} \ | |||
} \ | |||
else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_7B) \ | |||
{ \ | |||
if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE) \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x007F ; \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x003F ; \ | |||
} \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x0000U; \ | |||
} \ | |||
} while(0) | |||
/** @brief Ensure that IRDA Baud rate is less or equal to maximum value. | |||
* @param __BAUDRATE__ specifies the IRDA Baudrate set by the user. | |||
* @retval True or False | |||
*/ | |||
#define IS_IRDA_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 115201U) | |||
/** @brief Ensure that IRDA prescaler value is strictly larger than 0. | |||
* @param __PRESCALER__ specifies the IRDA prescaler value set by the user. | |||
* @retval True or False | |||
*/ | |||
#define IS_IRDA_PRESCALER(__PRESCALER__) ((__PRESCALER__) > 0U) | |||
/** | |||
* @brief Ensure that IRDA frame length is valid. | |||
* @param __LENGTH__ IRDA frame length. | |||
* @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid) | |||
*/ | |||
#define IS_IRDA_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == IRDA_WORDLENGTH_7B) || \ | |||
((__LENGTH__) == IRDA_WORDLENGTH_8B) || \ | |||
((__LENGTH__) == IRDA_WORDLENGTH_9B)) | |||
/** | |||
* @brief Ensure that IRDA frame parity is valid. | |||
* @param __PARITY__ IRDA frame parity. | |||
* @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid) | |||
*/ | |||
#define IS_IRDA_PARITY(__PARITY__) (((__PARITY__) == IRDA_PARITY_NONE) || \ | |||
((__PARITY__) == IRDA_PARITY_EVEN) || \ | |||
((__PARITY__) == IRDA_PARITY_ODD)) | |||
/** | |||
* @brief Ensure that IRDA communication mode is valid. | |||
* @param __MODE__ IRDA communication mode. | |||
* @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) | |||
*/ | |||
#define IS_IRDA_TX_RX_MODE(__MODE__) ((((__MODE__) & (~((uint32_t)(IRDA_MODE_TX_RX)))) == 0x00U) && ((__MODE__) != 0x00U)) | |||
/** | |||
* @brief Ensure that IRDA power mode is valid. | |||
* @param __MODE__ IRDA power mode. | |||
* @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) | |||
*/ | |||
#define IS_IRDA_POWERMODE(__MODE__) (((__MODE__) == IRDA_POWERMODE_LOWPOWER) || \ | |||
((__MODE__) == IRDA_POWERMODE_NORMAL)) | |||
/** | |||
* @brief Ensure that IRDA clock Prescaler is valid. | |||
* @param __CLOCKPRESCALER__ IRDA clock Prescaler value. | |||
* @retval SET (__CLOCKPRESCALER__ is valid) or RESET (__CLOCKPRESCALER__ is invalid) | |||
*/ | |||
#define IS_IRDA_CLOCKPRESCALER(__CLOCKPRESCALER__) (((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV1) || \ | |||
((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV2) || \ | |||
((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV4) || \ | |||
((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV6) || \ | |||
((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV8) || \ | |||
((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV10) || \ | |||
((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV12) || \ | |||
((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV16) || \ | |||
((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV32) || \ | |||
((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV64) || \ | |||
((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV128) || \ | |||
((__CLOCKPRESCALER__) == IRDA_PRESCALER_DIV256)) | |||
/** | |||
* @brief Ensure that IRDA state is valid. | |||
* @param __STATE__ IRDA state mode. | |||
* @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid) | |||
*/ | |||
#define IS_IRDA_STATE(__STATE__) (((__STATE__) == IRDA_STATE_DISABLE) || \ | |||
((__STATE__) == IRDA_STATE_ENABLE)) | |||
/** | |||
* @brief Ensure that IRDA associated UART/USART mode is valid. | |||
* @param __MODE__ IRDA associated UART/USART mode. | |||
* @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) | |||
*/ | |||
#define IS_IRDA_MODE(__MODE__) (((__MODE__) == IRDA_MODE_DISABLE) || \ | |||
((__MODE__) == IRDA_MODE_ENABLE)) | |||
/** | |||
* @brief Ensure that IRDA sampling rate is valid. | |||
* @param __ONEBIT__ IRDA sampling rate. | |||
* @retval SET (__ONEBIT__ is valid) or RESET (__ONEBIT__ is invalid) | |||
*/ | |||
#define IS_IRDA_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == IRDA_ONE_BIT_SAMPLE_DISABLE) || \ | |||
((__ONEBIT__) == IRDA_ONE_BIT_SAMPLE_ENABLE)) | |||
/** | |||
* @brief Ensure that IRDA DMA TX mode is valid. | |||
* @param __DMATX__ IRDA DMA TX mode. | |||
* @retval SET (__DMATX__ is valid) or RESET (__DMATX__ is invalid) | |||
*/ | |||
#define IS_IRDA_DMA_TX(__DMATX__) (((__DMATX__) == IRDA_DMA_TX_DISABLE) || \ | |||
((__DMATX__) == IRDA_DMA_TX_ENABLE)) | |||
/** | |||
* @brief Ensure that IRDA DMA RX mode is valid. | |||
* @param __DMARX__ IRDA DMA RX mode. | |||
* @retval SET (__DMARX__ is valid) or RESET (__DMARX__ is invalid) | |||
*/ | |||
#define IS_IRDA_DMA_RX(__DMARX__) (((__DMARX__) == IRDA_DMA_RX_DISABLE) || \ | |||
((__DMARX__) == IRDA_DMA_RX_ENABLE)) | |||
/** | |||
* @brief Ensure that IRDA request is valid. | |||
* @param __PARAM__ IRDA request. | |||
* @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid) | |||
*/ | |||
#define IS_IRDA_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == IRDA_AUTOBAUD_REQUEST) || \ | |||
((__PARAM__) == IRDA_RXDATA_FLUSH_REQUEST) || \ | |||
((__PARAM__) == IRDA_TXDATA_FLUSH_REQUEST)) | |||
/** | |||
* @} | |||
*/ | |||
/* Include IRDA HAL Extended module */ | |||
#include "stm32wbxx_hal_irda_ex.h" | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup IRDA_Exported_Functions IRDA Exported Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup IRDA_Exported_Functions_Group1 Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions ****************************/ | |||
HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda); | |||
HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda); | |||
void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda); | |||
void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda); | |||
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1) | |||
/* Callbacks Register/UnRegister functions ***********************************/ | |||
HAL_StatusTypeDef HAL_IRDA_RegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID, pIRDA_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_IRDA_UnRegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID); | |||
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup IRDA_Exported_Functions_Group2 IO operation functions | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda); | |||
HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda); | |||
HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda); | |||
/* Transfer Abort functions */ | |||
HAL_StatusTypeDef HAL_IRDA_Abort(IRDA_HandleTypeDef *hirda); | |||
HAL_StatusTypeDef HAL_IRDA_AbortTransmit(IRDA_HandleTypeDef *hirda); | |||
HAL_StatusTypeDef HAL_IRDA_AbortReceive(IRDA_HandleTypeDef *hirda); | |||
HAL_StatusTypeDef HAL_IRDA_Abort_IT(IRDA_HandleTypeDef *hirda); | |||
HAL_StatusTypeDef HAL_IRDA_AbortTransmit_IT(IRDA_HandleTypeDef *hirda); | |||
HAL_StatusTypeDef HAL_IRDA_AbortReceive_IT(IRDA_HandleTypeDef *hirda); | |||
void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda); | |||
void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda); | |||
void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda); | |||
void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda); | |||
void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda); | |||
void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda); | |||
void HAL_IRDA_AbortCpltCallback(IRDA_HandleTypeDef *hirda); | |||
void HAL_IRDA_AbortTransmitCpltCallback(IRDA_HandleTypeDef *hirda); | |||
void HAL_IRDA_AbortReceiveCpltCallback(IRDA_HandleTypeDef *hirda); | |||
/** | |||
* @} | |||
*/ | |||
/* Peripheral Control functions ************************************************/ | |||
/** @addtogroup IRDA_Exported_Functions_Group4 Peripheral State and Error functions | |||
* @{ | |||
*/ | |||
/* Peripheral State and Error functions ***************************************/ | |||
HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda); | |||
uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_IRDA_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,104 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_irda_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of IRDA HAL Extended module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_IRDA_EX_H | |||
#define STM32WBxx_HAL_IRDA_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup IRDAEx IRDAEx | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup IRDAEx_Private_Macros IRDAEx Private Macros | |||
* @{ | |||
*/ | |||
/** @brief Report the IRDA clock source. | |||
* @param __HANDLE__ specifies the IRDA Handle. | |||
* @param __CLOCKSOURCE__ output variable. | |||
* @retval IRDA clocking source, written in __CLOCKSOURCE__. | |||
*/ | |||
#define IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ | |||
do { \ | |||
if((__HANDLE__)->Instance == USART1) \ | |||
{ \ | |||
switch(__HAL_RCC_GET_USART1_SOURCE()) \ | |||
{ \ | |||
case RCC_USART1CLKSOURCE_PCLK2: \ | |||
(__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK2; \ | |||
break; \ | |||
case RCC_USART1CLKSOURCE_HSI: \ | |||
(__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \ | |||
break; \ | |||
case RCC_USART1CLKSOURCE_SYSCLK: \ | |||
(__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK; \ | |||
break; \ | |||
case RCC_USART1CLKSOURCE_LSE: \ | |||
(__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \ | |||
break; \ | |||
default: \ | |||
(__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \ | |||
break; \ | |||
} \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_UNDEFINED; \ | |||
} \ | |||
} while(0U) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_IRDA_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,241 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_iwdg.h | |||
* @author MCD Application Team | |||
* @brief Header file of IWDG HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_IWDG_H | |||
#define STM32WBxx_HAL_IWDG_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup IWDG IWDG | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup IWDG_Exported_Types IWDG Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief IWDG Init structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Prescaler; /*!< Select the prescaler of the IWDG. | |||
This parameter can be a value of @ref IWDG_Prescaler */ | |||
uint32_t Reload; /*!< Specifies the IWDG down-counter reload value. | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ | |||
uint32_t Window; /*!< Specifies the window value to be compared to the down-counter. | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ | |||
} IWDG_InitTypeDef; | |||
/** | |||
* @brief IWDG Handle Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
IWDG_TypeDef *Instance; /*!< Register base address */ | |||
IWDG_InitTypeDef Init; /*!< IWDG required parameters */ | |||
} IWDG_HandleTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup IWDG_Exported_Constants IWDG Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup IWDG_Prescaler IWDG Prescaler | |||
* @{ | |||
*/ | |||
#define IWDG_PRESCALER_4 0x00000000u /*!< IWDG prescaler set to 4 */ | |||
#define IWDG_PRESCALER_8 IWDG_PR_PR_0 /*!< IWDG prescaler set to 8 */ | |||
#define IWDG_PRESCALER_16 IWDG_PR_PR_1 /*!< IWDG prescaler set to 16 */ | |||
#define IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 32 */ | |||
#define IWDG_PRESCALER_64 IWDG_PR_PR_2 /*!< IWDG prescaler set to 64 */ | |||
#define IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 128 */ | |||
#define IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< IWDG prescaler set to 256 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IWDG_Window_option IWDG Window option | |||
* @{ | |||
*/ | |||
#define IWDG_WINDOW_DISABLE IWDG_WINR_WIN | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup IWDG_Exported_Macros IWDG Exported Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable the IWDG peripheral. | |||
* @param __HANDLE__ IWDG handle | |||
* @retval None | |||
*/ | |||
#define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE) | |||
/** | |||
* @brief Reload IWDG counter with value defined in the reload register | |||
* (write access to IWDG_PR, IWDG_RLR & IWDG_WINR registers disabled). | |||
* @param __HANDLE__ IWDG handle | |||
* @retval None | |||
*/ | |||
#define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup IWDG_Exported_Functions IWDG Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions | |||
* @{ | |||
*/ | |||
/* Initialization/Start functions ********************************************/ | |||
HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IWDG_Exported_Functions_Group2 IO operation functions | |||
* @{ | |||
*/ | |||
/* I/O operation functions ****************************************************/ | |||
HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/** @defgroup IWDG_Private_Constants IWDG Private Constants | |||
* @{ | |||
*/ | |||
/** | |||
* @brief IWDG Key Register BitMask | |||
*/ | |||
#define IWDG_KEY_RELOAD 0x0000AAAAu /*!< IWDG Reload Counter Enable */ | |||
#define IWDG_KEY_ENABLE 0x0000CCCCu /*!< IWDG Peripheral Enable */ | |||
#define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005555u /*!< IWDG KR Write Access Enable */ | |||
#define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000u /*!< IWDG KR Write Access Disable */ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup IWDG_Private_Macros IWDG Private Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers. | |||
* @param __HANDLE__ IWDG handle | |||
* @retval None | |||
*/ | |||
#define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE) | |||
/** | |||
* @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers. | |||
* @param __HANDLE__ IWDG handle | |||
* @retval None | |||
*/ | |||
#define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE) | |||
/** | |||
* @brief Check IWDG prescaler value. | |||
* @param __PRESCALER__ IWDG prescaler value | |||
* @retval None | |||
*/ | |||
#define IS_IWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == IWDG_PRESCALER_4) || \ | |||
((__PRESCALER__) == IWDG_PRESCALER_8) || \ | |||
((__PRESCALER__) == IWDG_PRESCALER_16) || \ | |||
((__PRESCALER__) == IWDG_PRESCALER_32) || \ | |||
((__PRESCALER__) == IWDG_PRESCALER_64) || \ | |||
((__PRESCALER__) == IWDG_PRESCALER_128)|| \ | |||
((__PRESCALER__) == IWDG_PRESCALER_256)) | |||
/** | |||
* @brief Check IWDG reload value. | |||
* @param __RELOAD__ IWDG reload value | |||
* @retval None | |||
*/ | |||
#define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL) | |||
/** | |||
* @brief Check IWDG window value. | |||
* @param __WINDOW__ IWDG window value | |||
* @retval None | |||
*/ | |||
#define IS_IWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= IWDG_WINR_WIN) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_IWDG_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,768 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_lcd.h | |||
* @author MCD Application Team | |||
* @brief Header file of LCD Controller HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_LCD_H | |||
#define STM32WBxx_HAL_LCD_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup LCD | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup LCD_Exported_Types LCD Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief LCD Init structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Prescaler; /*!< Configures the LCD Prescaler. | |||
This parameter can be one value of @ref LCD_Prescaler */ | |||
uint32_t Divider; /*!< Configures the LCD Divider. | |||
This parameter can be one value of @ref LCD_Divider */ | |||
uint32_t Duty; /*!< Configures the LCD Duty. | |||
This parameter can be one value of @ref LCD_Duty */ | |||
uint32_t Bias; /*!< Configures the LCD Bias. | |||
This parameter can be one value of @ref LCD_Bias */ | |||
uint32_t VoltageSource; /*!< Selects the LCD Voltage source. | |||
This parameter can be one value of @ref LCD_Voltage_Source */ | |||
uint32_t Contrast; /*!< Configures the LCD Contrast. | |||
This parameter can be one value of @ref LCD_Contrast */ | |||
uint32_t DeadTime; /*!< Configures the LCD Dead Time. | |||
This parameter can be one value of @ref LCD_DeadTime */ | |||
uint32_t PulseOnDuration; /*!< Configures the LCD Pulse On Duration. | |||
This parameter can be one value of @ref LCD_PulseOnDuration */ | |||
uint32_t HighDrive; /*!< Enable or disable the low resistance divider. | |||
This parameter can be one value of @ref LCD_HighDrive */ | |||
uint32_t BlinkMode; /*!< Configures the LCD Blink Mode. | |||
This parameter can be one value of @ref LCD_BlinkMode */ | |||
uint32_t BlinkFrequency; /*!< Configures the LCD Blink frequency. | |||
This parameter can be one value of @ref LCD_BlinkFrequency */ | |||
uint32_t MuxSegment; /*!< Enable or disable mux segment. | |||
This parameter can be one value of @ref LCD_MuxSegment */ | |||
} LCD_InitTypeDef; | |||
/** | |||
* @brief HAL LCD State structures definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_LCD_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */ | |||
HAL_LCD_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ | |||
HAL_LCD_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ | |||
HAL_LCD_STATE_TIMEOUT = 0x03, /*!< Timeout state */ | |||
HAL_LCD_STATE_ERROR = 0x04 /*!< Error */ | |||
} HAL_LCD_StateTypeDef; | |||
/** | |||
* @brief UART handle Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
LCD_TypeDef *Instance; /* LCD registers base address */ | |||
LCD_InitTypeDef Init; /* LCD communication parameters */ | |||
HAL_LockTypeDef Lock; /* Locking object */ | |||
__IO HAL_LCD_StateTypeDef State; /* LCD communication state */ | |||
__IO uint32_t ErrorCode; /* LCD Error code */ | |||
} LCD_HandleTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup LCD_Exported_Constants LCD Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup LCD_ErrorCode LCD Error Code | |||
* @{ | |||
*/ | |||
#define HAL_LCD_ERROR_NONE (0x00000000U) /*!< No error */ | |||
#define HAL_LCD_ERROR_FCRSF (0x00000001U) /*!< Synchro flag timeout error */ | |||
#define HAL_LCD_ERROR_UDR (0x00000002U) /*!< Update display request flag timeout error */ | |||
#define HAL_LCD_ERROR_UDD (0x00000004U) /*!< Update display done flag timeout error */ | |||
#define HAL_LCD_ERROR_ENS (0x00000008U) /*!< LCD enabled status flag timeout error */ | |||
#define HAL_LCD_ERROR_RDY (0x00000010U) /*!< LCD Booster ready timeout error */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_Prescaler LCD Prescaler | |||
* @{ | |||
*/ | |||
#define LCD_PRESCALER_1 (0x00000000U) /*!< CLKPS = LCDCLK */ | |||
#define LCD_PRESCALER_2 (0x00400000U) /*!< CLKPS = LCDCLK/2 */ | |||
#define LCD_PRESCALER_4 (0x00800000U) /*!< CLKPS = LCDCLK/4 */ | |||
#define LCD_PRESCALER_8 (0x00C00000U) /*!< CLKPS = LCDCLK/8 */ | |||
#define LCD_PRESCALER_16 (0x01000000U) /*!< CLKPS = LCDCLK/16 */ | |||
#define LCD_PRESCALER_32 (0x01400000U) /*!< CLKPS = LCDCLK/32 */ | |||
#define LCD_PRESCALER_64 (0x01800000U) /*!< CLKPS = LCDCLK/64 */ | |||
#define LCD_PRESCALER_128 (0x01C00000U) /*!< CLKPS = LCDCLK/128 */ | |||
#define LCD_PRESCALER_256 (0x02000000U) /*!< CLKPS = LCDCLK/256 */ | |||
#define LCD_PRESCALER_512 (0x02400000U) /*!< CLKPS = LCDCLK/512 */ | |||
#define LCD_PRESCALER_1024 (0x02800000U) /*!< CLKPS = LCDCLK/1024 */ | |||
#define LCD_PRESCALER_2048 (0x02C00000U) /*!< CLKPS = LCDCLK/2048 */ | |||
#define LCD_PRESCALER_4096 (0x03000000U) /*!< CLKPS = LCDCLK/4096 */ | |||
#define LCD_PRESCALER_8192 (0x03400000U) /*!< CLKPS = LCDCLK/8192 */ | |||
#define LCD_PRESCALER_16384 (0x03800000U) /*!< CLKPS = LCDCLK/16384 */ | |||
#define LCD_PRESCALER_32768 (0x03C00000U) /*!< CLKPS = LCDCLK/32768 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_Divider LCD Divider | |||
* @{ | |||
*/ | |||
#define LCD_DIVIDER_16 (0x00000000U) /*!< LCD frequency = CLKPS/16 */ | |||
#define LCD_DIVIDER_17 (0x00040000U) /*!< LCD frequency = CLKPS/17 */ | |||
#define LCD_DIVIDER_18 (0x00080000U) /*!< LCD frequency = CLKPS/18 */ | |||
#define LCD_DIVIDER_19 (0x000C0000U) /*!< LCD frequency = CLKPS/19 */ | |||
#define LCD_DIVIDER_20 (0x00100000U) /*!< LCD frequency = CLKPS/20 */ | |||
#define LCD_DIVIDER_21 (0x00140000U) /*!< LCD frequency = CLKPS/21 */ | |||
#define LCD_DIVIDER_22 (0x00180000U) /*!< LCD frequency = CLKPS/22 */ | |||
#define LCD_DIVIDER_23 (0x001C0000U) /*!< LCD frequency = CLKPS/23 */ | |||
#define LCD_DIVIDER_24 (0x00200000U) /*!< LCD frequency = CLKPS/24 */ | |||
#define LCD_DIVIDER_25 (0x00240000U) /*!< LCD frequency = CLKPS/25 */ | |||
#define LCD_DIVIDER_26 (0x00280000U) /*!< LCD frequency = CLKPS/26 */ | |||
#define LCD_DIVIDER_27 (0x002C0000U) /*!< LCD frequency = CLKPS/27 */ | |||
#define LCD_DIVIDER_28 (0x00300000U) /*!< LCD frequency = CLKPS/28 */ | |||
#define LCD_DIVIDER_29 (0x00340000U) /*!< LCD frequency = CLKPS/29 */ | |||
#define LCD_DIVIDER_30 (0x00380000U) /*!< LCD frequency = CLKPS/30 */ | |||
#define LCD_DIVIDER_31 (0x003C0000U) /*!< LCD frequency = CLKPS/31 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_Duty LCD Duty | |||
* @{ | |||
*/ | |||
#define LCD_DUTY_STATIC (0x00000000U) /*!< Static duty */ | |||
#define LCD_DUTY_1_2 (LCD_CR_DUTY_0) /*!< 1/2 duty */ | |||
#define LCD_DUTY_1_3 (LCD_CR_DUTY_1) /*!< 1/3 duty */ | |||
#define LCD_DUTY_1_4 ((LCD_CR_DUTY_1 | LCD_CR_DUTY_0)) /*!< 1/4 duty */ | |||
#define LCD_DUTY_1_8 (LCD_CR_DUTY_2) /*!< 1/8 duty */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_Bias LCD Bias | |||
* @{ | |||
*/ | |||
#define LCD_BIAS_1_4 (0x00000000U) /*!< 1/4 Bias */ | |||
#define LCD_BIAS_1_2 LCD_CR_BIAS_0 /*!< 1/2 Bias */ | |||
#define LCD_BIAS_1_3 LCD_CR_BIAS_1 /*!< 1/3 Bias */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_Voltage_Source LCD Voltage Source | |||
* @{ | |||
*/ | |||
#define LCD_VOLTAGESOURCE_INTERNAL (0x00000000U) /*!< Internal voltage source for the LCD */ | |||
#define LCD_VOLTAGESOURCE_EXTERNAL LCD_CR_VSEL /*!< External voltage source for the LCD */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_Interrupts LCD Interrupts | |||
* @{ | |||
*/ | |||
#define LCD_IT_SOF LCD_FCR_SOFIE | |||
#define LCD_IT_UDD LCD_FCR_UDDIE | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_PulseOnDuration LCD Pulse On Duration | |||
* @{ | |||
*/ | |||
#define LCD_PULSEONDURATION_0 (0x00000000U) /*!< Pulse ON duration = 0 pulse */ | |||
#define LCD_PULSEONDURATION_1 (LCD_FCR_PON_0) /*!< Pulse ON duration = 1/CK_PS */ | |||
#define LCD_PULSEONDURATION_2 (LCD_FCR_PON_1) /*!< Pulse ON duration = 2/CK_PS */ | |||
#define LCD_PULSEONDURATION_3 (LCD_FCR_PON_1 | LCD_FCR_PON_0) /*!< Pulse ON duration = 3/CK_PS */ | |||
#define LCD_PULSEONDURATION_4 (LCD_FCR_PON_2) /*!< Pulse ON duration = 4/CK_PS */ | |||
#define LCD_PULSEONDURATION_5 (LCD_FCR_PON_2 | LCD_FCR_PON_0) /*!< Pulse ON duration = 5/CK_PS */ | |||
#define LCD_PULSEONDURATION_6 (LCD_FCR_PON_2 | LCD_FCR_PON_1) /*!< Pulse ON duration = 6/CK_PS */ | |||
#define LCD_PULSEONDURATION_7 (LCD_FCR_PON) /*!< Pulse ON duration = 7/CK_PS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_DeadTime LCD Dead Time | |||
* @{ | |||
*/ | |||
#define LCD_DEADTIME_0 (0x00000000U) /*!< No dead Time */ | |||
#define LCD_DEADTIME_1 (LCD_FCR_DEAD_0) /*!< One Phase between different couple of Frame */ | |||
#define LCD_DEADTIME_2 (LCD_FCR_DEAD_1) /*!< Two Phase between different couple of Frame */ | |||
#define LCD_DEADTIME_3 (LCD_FCR_DEAD_1 | LCD_FCR_DEAD_0) /*!< Three Phase between different couple of Frame */ | |||
#define LCD_DEADTIME_4 (LCD_FCR_DEAD_2) /*!< Four Phase between different couple of Frame */ | |||
#define LCD_DEADTIME_5 (LCD_FCR_DEAD_2 | LCD_FCR_DEAD_0) /*!< Five Phase between different couple of Frame */ | |||
#define LCD_DEADTIME_6 (LCD_FCR_DEAD_2 | LCD_FCR_DEAD_1) /*!< Six Phase between different couple of Frame */ | |||
#define LCD_DEADTIME_7 (LCD_FCR_DEAD) /*!< Seven Phase between different couple of Frame */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_BlinkMode LCD Blink Mode | |||
* @{ | |||
*/ | |||
#define LCD_BLINKMODE_OFF (0x00000000U) /*!< Blink disabled */ | |||
#define LCD_BLINKMODE_SEG0_COM0 (LCD_FCR_BLINK_0) /*!< Blink enabled on SEG[0], COM[0] (1 pixel) */ | |||
#define LCD_BLINKMODE_SEG0_ALLCOM (LCD_FCR_BLINK_1) /*!< Blink enabled on SEG[0], all COM (up to | |||
8 pixels according to the programmed duty) */ | |||
#define LCD_BLINKMODE_ALLSEG_ALLCOM (LCD_FCR_BLINK) /*!< Blink enabled on all SEG and all COM (all pixels) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_BlinkFrequency LCD Blink Frequency | |||
* @{ | |||
*/ | |||
#define LCD_BLINKFREQUENCY_DIV8 (0x00000000U) /*!< The Blink frequency = fLCD/8 */ | |||
#define LCD_BLINKFREQUENCY_DIV16 (LCD_FCR_BLINKF_0) /*!< The Blink frequency = fLCD/16 */ | |||
#define LCD_BLINKFREQUENCY_DIV32 (LCD_FCR_BLINKF_1) /*!< The Blink frequency = fLCD/32 */ | |||
#define LCD_BLINKFREQUENCY_DIV64 (LCD_FCR_BLINKF_1 | LCD_FCR_BLINKF_0) /*!< The Blink frequency = fLCD/64 */ | |||
#define LCD_BLINKFREQUENCY_DIV128 (LCD_FCR_BLINKF_2) /*!< The Blink frequency = fLCD/128 */ | |||
#define LCD_BLINKFREQUENCY_DIV256 (LCD_FCR_BLINKF_2 |LCD_FCR_BLINKF_0) /*!< The Blink frequency = fLCD/256 */ | |||
#define LCD_BLINKFREQUENCY_DIV512 (LCD_FCR_BLINKF_2 |LCD_FCR_BLINKF_1) /*!< The Blink frequency = fLCD/512 */ | |||
#define LCD_BLINKFREQUENCY_DIV1024 (LCD_FCR_BLINKF) /*!< The Blink frequency = fLCD/1024 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_Contrast LCD Contrast | |||
* @{ | |||
*/ | |||
#define LCD_CONTRASTLEVEL_0 (0x00000000U) /*!< Maximum Voltage = 2.60V */ | |||
#define LCD_CONTRASTLEVEL_1 (LCD_FCR_CC_0) /*!< Maximum Voltage = 2.73V */ | |||
#define LCD_CONTRASTLEVEL_2 (LCD_FCR_CC_1) /*!< Maximum Voltage = 2.86V */ | |||
#define LCD_CONTRASTLEVEL_3 (LCD_FCR_CC_1 | LCD_FCR_CC_0) /*!< Maximum Voltage = 2.99V */ | |||
#define LCD_CONTRASTLEVEL_4 (LCD_FCR_CC_2) /*!< Maximum Voltage = 3.12V */ | |||
#define LCD_CONTRASTLEVEL_5 (LCD_FCR_CC_2 | LCD_FCR_CC_0) /*!< Maximum Voltage = 3.26V */ | |||
#define LCD_CONTRASTLEVEL_6 (LCD_FCR_CC_2 | LCD_FCR_CC_1) /*!< Maximum Voltage = 3.40V */ | |||
#define LCD_CONTRASTLEVEL_7 (LCD_FCR_CC) /*!< Maximum Voltage = 3.55V */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_RAMRegister LCD RAMRegister | |||
* @{ | |||
*/ | |||
#define LCD_RAM_REGISTER0 (0x00000000U) /*!< LCD RAM Register 0 */ | |||
#define LCD_RAM_REGISTER1 (0x00000001U) /*!< LCD RAM Register 1 */ | |||
#define LCD_RAM_REGISTER2 (0x00000002U) /*!< LCD RAM Register 2 */ | |||
#define LCD_RAM_REGISTER3 (0x00000003U) /*!< LCD RAM Register 3 */ | |||
#define LCD_RAM_REGISTER4 (0x00000004U) /*!< LCD RAM Register 4 */ | |||
#define LCD_RAM_REGISTER5 (0x00000005U) /*!< LCD RAM Register 5 */ | |||
#define LCD_RAM_REGISTER6 (0x00000006U) /*!< LCD RAM Register 6 */ | |||
#define LCD_RAM_REGISTER7 (0x00000007U) /*!< LCD RAM Register 7 */ | |||
#define LCD_RAM_REGISTER8 (0x00000008U) /*!< LCD RAM Register 8 */ | |||
#define LCD_RAM_REGISTER9 (0x00000009U) /*!< LCD RAM Register 9 */ | |||
#define LCD_RAM_REGISTER10 (0x0000000AU) /*!< LCD RAM Register 10 */ | |||
#define LCD_RAM_REGISTER11 (0x0000000BU) /*!< LCD RAM Register 11 */ | |||
#define LCD_RAM_REGISTER12 (0x0000000CU) /*!< LCD RAM Register 12 */ | |||
#define LCD_RAM_REGISTER13 (0x0000000DU) /*!< LCD RAM Register 13 */ | |||
#define LCD_RAM_REGISTER14 (0x0000000EU) /*!< LCD RAM Register 14 */ | |||
#define LCD_RAM_REGISTER15 (0x0000000FU) /*!< LCD RAM Register 15 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_HighDrive LCD High Drive | |||
* @{ | |||
*/ | |||
#define LCD_HIGHDRIVE_DISABLE ((uint32_t)0x00000000) /*!< High drive disabled */ | |||
#define LCD_HIGHDRIVE_ENABLE (LCD_FCR_HD) /*!< High drive enabled */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_MuxSegment LCD Mux Segment | |||
* @{ | |||
*/ | |||
#define LCD_MUXSEGMENT_DISABLE (0x00000000U) /*!< SEG pin multiplexing disabled */ | |||
#define LCD_MUXSEGMENT_ENABLE (LCD_CR_MUX_SEG) /*!< SEG[31:28] are multiplexed with SEG[43:40] */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LCD_Flag_Definition LCD Flags Definition | |||
* @{ | |||
*/ | |||
#define LCD_FLAG_ENS LCD_SR_ENS /*!< LCD enabled status */ | |||
#define LCD_FLAG_SOF LCD_SR_SOF /*!< Start of frame flag */ | |||
#define LCD_FLAG_UDR LCD_SR_UDR /*!< Update display request */ | |||
#define LCD_FLAG_UDD LCD_SR_UDD /*!< Update display done */ | |||
#define LCD_FLAG_RDY LCD_SR_RDY /*!< Ready flag */ | |||
#define LCD_FLAG_FCRSF LCD_SR_FCRSR /*!< LCD Frame Control Register Synchronization flag */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup LCD_Exported_Macros LCD Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset LCD handle state. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LCD_STATE_RESET) | |||
/** @brief Enable the LCD peripheral. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, LCD_CR_LCDEN) | |||
/** @brief Disable the LCD peripheral. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR, LCD_CR_LCDEN) | |||
/** @brief Enable the low resistance divider. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @note Displays with high internal resistance may need a longer drive time to | |||
* achieve satisfactory contrast. This function is useful in this case if | |||
* some additional power consumption can be tolerated. | |||
* @note When this mode is enabled, the PulseOn Duration (PON) have to be | |||
* programmed to 1/CK_PS (LCD_PULSEONDURATION_1). | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_HIGHDRIVER_ENABLE(__HANDLE__) \ | |||
do { \ | |||
SET_BIT((__HANDLE__)->Instance->FCR, LCD_FCR_HD); \ | |||
LCD_WaitForSynchro(__HANDLE__); \ | |||
} while(0) | |||
/** @brief Disable the low resistance divider. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_HIGHDRIVER_DISABLE(__HANDLE__) \ | |||
do { \ | |||
CLEAR_BIT((__HANDLE__)->Instance->FCR, LCD_FCR_HD); \ | |||
LCD_WaitForSynchro(__HANDLE__); \ | |||
} while(0) | |||
/** @brief Enable the voltage output buffer for higher driving capability. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_VOLTAGE_BUFFER_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, LCD_CR_BUFEN) | |||
/** @brief Disable the voltage output buffer for higher driving capability. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_VOLTAGE_BUFFER_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR, LCD_CR_BUFEN) | |||
/** | |||
* @brief Configure the LCD pulse on duration. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @param __DURATION__ specifies the LCD pulse on duration in terms of | |||
* CK_PS (prescaled LCD clock period) pulses. | |||
* This parameter can be one of the following values: | |||
* @arg LCD_PULSEONDURATION_0: 0 pulse | |||
* @arg LCD_PULSEONDURATION_1: Pulse ON duration = 1/CK_PS | |||
* @arg LCD_PULSEONDURATION_2: Pulse ON duration = 2/CK_PS | |||
* @arg LCD_PULSEONDURATION_3: Pulse ON duration = 3/CK_PS | |||
* @arg LCD_PULSEONDURATION_4: Pulse ON duration = 4/CK_PS | |||
* @arg LCD_PULSEONDURATION_5: Pulse ON duration = 5/CK_PS | |||
* @arg LCD_PULSEONDURATION_6: Pulse ON duration = 6/CK_PS | |||
* @arg LCD_PULSEONDURATION_7: Pulse ON duration = 7/CK_PS | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_PULSEONDURATION_CONFIG(__HANDLE__, __DURATION__) \ | |||
do { \ | |||
MODIFY_REG((__HANDLE__)->Instance->FCR, LCD_FCR_PON, (__DURATION__)); \ | |||
LCD_WaitForSynchro(__HANDLE__); \ | |||
} while(0) | |||
/** | |||
* @brief Configure the LCD dead time. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @param __DEADTIME__ specifies the LCD dead time. | |||
* This parameter can be one of the following values: | |||
* @arg LCD_DEADTIME_0: No dead Time | |||
* @arg LCD_DEADTIME_1: One Phase between different couple of Frame | |||
* @arg LCD_DEADTIME_2: Two Phase between different couple of Frame | |||
* @arg LCD_DEADTIME_3: Three Phase between different couple of Frame | |||
* @arg LCD_DEADTIME_4: Four Phase between different couple of Frame | |||
* @arg LCD_DEADTIME_5: Five Phase between different couple of Frame | |||
* @arg LCD_DEADTIME_6: Six Phase between different couple of Frame | |||
* @arg LCD_DEADTIME_7: Seven Phase between different couple of Frame | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_DEADTIME_CONFIG(__HANDLE__, __DEADTIME__) \ | |||
do { \ | |||
MODIFY_REG((__HANDLE__)->Instance->FCR, LCD_FCR_DEAD, (__DEADTIME__)); \ | |||
LCD_WaitForSynchro(__HANDLE__); \ | |||
} while(0) | |||
/** | |||
* @brief Configure the LCD contrast. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @param __CONTRAST__ specifies the LCD Contrast. | |||
* This parameter can be one of the following values: | |||
* @arg LCD_CONTRASTLEVEL_0: Maximum Voltage = 2.60V | |||
* @arg LCD_CONTRASTLEVEL_1: Maximum Voltage = 2.73V | |||
* @arg LCD_CONTRASTLEVEL_2: Maximum Voltage = 2.86V | |||
* @arg LCD_CONTRASTLEVEL_3: Maximum Voltage = 2.99V | |||
* @arg LCD_CONTRASTLEVEL_4: Maximum Voltage = 3.12V | |||
* @arg LCD_CONTRASTLEVEL_5: Maximum Voltage = 3.25V | |||
* @arg LCD_CONTRASTLEVEL_6: Maximum Voltage = 3.38V | |||
* @arg LCD_CONTRASTLEVEL_7: Maximum Voltage = 3.51V | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_CONTRAST_CONFIG(__HANDLE__, __CONTRAST__) \ | |||
do { \ | |||
MODIFY_REG((__HANDLE__)->Instance->FCR, LCD_FCR_CC, (__CONTRAST__)); \ | |||
LCD_WaitForSynchro(__HANDLE__); \ | |||
} while(0) | |||
/** | |||
* @brief Configure the LCD Blink mode and Blink frequency. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @param __BLINKMODE__ specifies the LCD blink mode. | |||
* This parameter can be one of the following values: | |||
* @arg LCD_BLINKMODE_OFF: Blink disabled | |||
* @arg LCD_BLINKMODE_SEG0_COM0: Blink enabled on SEG[0], COM[0] (1 pixel) | |||
* @arg LCD_BLINKMODE_SEG0_ALLCOM: Blink enabled on SEG[0], all COM (up to 8 | |||
* pixels according to the programmed duty) | |||
* @arg LCD_BLINKMODE_ALLSEG_ALLCOM: Blink enabled on all SEG and all COM | |||
* (all pixels) | |||
* @param __BLINKFREQUENCY__ specifies the LCD blink frequency. | |||
* @arg LCD_BLINKFREQUENCY_DIV8: The Blink frequency = fLcd/8 | |||
* @arg LCD_BLINKFREQUENCY_DIV16: The Blink frequency = fLcd/16 | |||
* @arg LCD_BLINKFREQUENCY_DIV32: The Blink frequency = fLcd/32 | |||
* @arg LCD_BLINKFREQUENCY_DIV64: The Blink frequency = fLcd/64 | |||
* @arg LCD_BLINKFREQUENCY_DIV128: The Blink frequency = fLcd/128 | |||
* @arg LCD_BLINKFREQUENCY_DIV256: The Blink frequency = fLcd/256 | |||
* @arg LCD_BLINKFREQUENCY_DIV512: The Blink frequency = fLcd/512 | |||
* @arg LCD_BLINKFREQUENCY_DIV1024: The Blink frequency = fLcd/1024 | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_BLINK_CONFIG(__HANDLE__, __BLINKMODE__, __BLINKFREQUENCY__) \ | |||
do { \ | |||
MODIFY_REG((__HANDLE__)->Instance->FCR, (LCD_FCR_BLINKF | LCD_FCR_BLINK), ((__BLINKMODE__) | (__BLINKFREQUENCY__))); \ | |||
LCD_WaitForSynchro(__HANDLE__); \ | |||
} while(0) | |||
/** @brief Enable the specified LCD interrupt. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @param __INTERRUPT__ specifies the LCD interrupt source to be enabled. | |||
* This parameter can be one of the following values: | |||
* @arg LCD_IT_SOF: Start of Frame Interrupt | |||
* @arg LCD_IT_UDD: Update Display Done Interrupt | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_ENABLE_IT(__HANDLE__, __INTERRUPT__) \ | |||
do { \ | |||
SET_BIT((__HANDLE__)->Instance->FCR, (__INTERRUPT__)); \ | |||
LCD_WaitForSynchro(__HANDLE__); \ | |||
} while(0) | |||
/** @brief Disable the specified LCD interrupt. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @param __INTERRUPT__ specifies the LCD interrupt source to be disabled. | |||
* This parameter can be one of the following values: | |||
* @arg LCD_IT_SOF: Start of Frame Interrupt | |||
* @arg LCD_IT_UDD: Update Display Done Interrupt | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_DISABLE_IT(__HANDLE__, __INTERRUPT__) \ | |||
do { \ | |||
CLEAR_BIT((__HANDLE__)->Instance->FCR, (__INTERRUPT__)); \ | |||
LCD_WaitForSynchro(__HANDLE__); \ | |||
} while(0) | |||
/** @brief Check whether the specified LCD interrupt source is enabled or not. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @param __IT__ specifies the LCD interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg LCD_IT_SOF: Start of Frame Interrupt | |||
* @arg LCD_IT_UDD: Update Display Done Interrupt. | |||
* @note If the device is in STOP mode (PCLK not provided) UDD will not | |||
* generate an interrupt even if UDDIE = 1. | |||
* If the display is not enabled the UDD interrupt will never occur. | |||
* @retval The state of __IT__ (TRUE or FALSE). | |||
*/ | |||
#define __HAL_LCD_GET_IT_SOURCE(__HANDLE__, __IT__) (((__HANDLE__)->Instance->FCR) & (__IT__)) | |||
/** @brief Check whether the specified LCD flag is set or not. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg LCD_FLAG_ENS: LCD Enabled flag. It indicates the LCD controller status. | |||
* @note The ENS bit is set immediately when the LCDEN bit in the LCD_CR | |||
* goes from 0 to 1. On deactivation it reflects the real status of | |||
* LCD so it becomes 0 at the end of the last displayed frame. | |||
* @arg LCD_FLAG_SOF: Start of Frame flag. This flag is set by hardware at | |||
* the beginning of a new frame, at the same time as the display data is | |||
* updated. | |||
* @arg LCD_FLAG_UDR: Update Display Request flag. | |||
* @arg LCD_FLAG_UDD: Update Display Done flag. | |||
* @arg LCD_FLAG_RDY: Step_up converter Ready flag. It indicates the status | |||
* of the step-up converter. | |||
* @arg LCD_FLAG_FCRSF: LCD Frame Control Register Synchronization Flag. | |||
* This flag is set by hardware each time the LCD_FCR register is updated | |||
* in the LCDCLK domain. | |||
* @retval The new state of __FLAG__ (TRUE or FALSE). | |||
*/ | |||
#define __HAL_LCD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) | |||
/** @brief Clear the specified LCD pending flag. | |||
* @param __HANDLE__ specifies the LCD Handle. | |||
* @param __FLAG__ specifies the flag to clear. | |||
* This parameter can be any combination of the following values: | |||
* @arg LCD_FLAG_SOF: Start of Frame Interrupt | |||
* @arg LCD_FLAG_UDD: Update Display Done Interrupt | |||
* @retval None | |||
*/ | |||
#define __HAL_LCD_CLEAR_FLAG(__HANDLE__, __FLAG__) WRITE_REG((__HANDLE__)->Instance->CLR, (__FLAG__)) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions ------------------------------------------------------- */ | |||
/** @addtogroup LCD_Exported_Functions | |||
* @{ | |||
*/ | |||
/* Initialization/de-initialization methods **********************************/ | |||
/** @addtogroup LCD_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_LCD_DeInit(LCD_HandleTypeDef *hlcd); | |||
HAL_StatusTypeDef HAL_LCD_Init(LCD_HandleTypeDef *hlcd); | |||
void HAL_LCD_MspInit(LCD_HandleTypeDef *hlcd); | |||
void HAL_LCD_MspDeInit(LCD_HandleTypeDef *hlcd); | |||
/** | |||
* @} | |||
*/ | |||
/* IO operation methods *******************************************************/ | |||
/** @addtogroup LCD_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_LCD_Write(LCD_HandleTypeDef *hlcd, uint32_t RAMRegisterIndex, uint32_t RAMRegisterMask, uint32_t Data); | |||
HAL_StatusTypeDef HAL_LCD_Clear(LCD_HandleTypeDef *hlcd); | |||
HAL_StatusTypeDef HAL_LCD_UpdateDisplayRequest(LCD_HandleTypeDef *hlcd); | |||
/** | |||
* @} | |||
*/ | |||
/* Peripheral State methods **************************************************/ | |||
/** @addtogroup LCD_Exported_Functions_Group3 | |||
* @{ | |||
*/ | |||
HAL_LCD_StateTypeDef HAL_LCD_GetState(LCD_HandleTypeDef *hlcd); | |||
uint32_t HAL_LCD_GetError(LCD_HandleTypeDef *hlcd); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup LCD_Private_Macros LCD Private Macros | |||
* @{ | |||
*/ | |||
#define IS_LCD_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LCD_PRESCALER_1) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_2) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_4) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_8) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_16) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_32) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_64) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_128) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_256) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_512) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_1024) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_2048) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_4096) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_8192) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_16384) || \ | |||
((__PRESCALER__) == LCD_PRESCALER_32768)) | |||
#define IS_LCD_DIVIDER(__DIVIDER__) (((__DIVIDER__) == LCD_DIVIDER_16) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_17) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_18) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_19) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_20) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_21) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_22) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_23) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_24) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_25) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_26) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_27) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_28) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_29) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_30) || \ | |||
((__DIVIDER__) == LCD_DIVIDER_31)) | |||
#define IS_LCD_DUTY(__DUTY__) (((__DUTY__) == LCD_DUTY_STATIC) || \ | |||
((__DUTY__) == LCD_DUTY_1_2) || \ | |||
((__DUTY__) == LCD_DUTY_1_3) || \ | |||
((__DUTY__) == LCD_DUTY_1_4) || \ | |||
((__DUTY__) == LCD_DUTY_1_8)) | |||
#define IS_LCD_BIAS(__BIAS__) (((__BIAS__) == LCD_BIAS_1_4) || \ | |||
((__BIAS__) == LCD_BIAS_1_2) || \ | |||
((__BIAS__) == LCD_BIAS_1_3)) | |||
#define IS_LCD_VOLTAGE_SOURCE(SOURCE) (((SOURCE) == LCD_VOLTAGESOURCE_INTERNAL) || \ | |||
((SOURCE) == LCD_VOLTAGESOURCE_EXTERNAL)) | |||
#define IS_LCD_PULSE_ON_DURATION(__DURATION__) (((__DURATION__) == LCD_PULSEONDURATION_0) || \ | |||
((__DURATION__) == LCD_PULSEONDURATION_1) || \ | |||
((__DURATION__) == LCD_PULSEONDURATION_2) || \ | |||
((__DURATION__) == LCD_PULSEONDURATION_3) || \ | |||
((__DURATION__) == LCD_PULSEONDURATION_4) || \ | |||
((__DURATION__) == LCD_PULSEONDURATION_5) || \ | |||
((__DURATION__) == LCD_PULSEONDURATION_6) || \ | |||
((__DURATION__) == LCD_PULSEONDURATION_7)) | |||
#define IS_LCD_DEAD_TIME(__TIME__) (((__TIME__) == LCD_DEADTIME_0) || \ | |||
((__TIME__) == LCD_DEADTIME_1) || \ | |||
((__TIME__) == LCD_DEADTIME_2) || \ | |||
((__TIME__) == LCD_DEADTIME_3) || \ | |||
((__TIME__) == LCD_DEADTIME_4) || \ | |||
((__TIME__) == LCD_DEADTIME_5) || \ | |||
((__TIME__) == LCD_DEADTIME_6) || \ | |||
((__TIME__) == LCD_DEADTIME_7)) | |||
#define IS_LCD_BLINK_MODE(__MODE__) (((__MODE__) == LCD_BLINKMODE_OFF) || \ | |||
((__MODE__) == LCD_BLINKMODE_SEG0_COM0) || \ | |||
((__MODE__) == LCD_BLINKMODE_SEG0_ALLCOM) || \ | |||
((__MODE__) == LCD_BLINKMODE_ALLSEG_ALLCOM)) | |||
#define IS_LCD_BLINK_FREQUENCY(__FREQUENCY__) (((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV8) || \ | |||
((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV16) || \ | |||
((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV32) || \ | |||
((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV64) || \ | |||
((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV128) || \ | |||
((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV256) || \ | |||
((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV512) || \ | |||
((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV1024)) | |||
#define IS_LCD_CONTRAST(__CONTRAST__) (((__CONTRAST__) == LCD_CONTRASTLEVEL_0) || \ | |||
((__CONTRAST__) == LCD_CONTRASTLEVEL_1) || \ | |||
((__CONTRAST__) == LCD_CONTRASTLEVEL_2) || \ | |||
((__CONTRAST__) == LCD_CONTRASTLEVEL_3) || \ | |||
((__CONTRAST__) == LCD_CONTRASTLEVEL_4) || \ | |||
((__CONTRAST__) == LCD_CONTRASTLEVEL_5) || \ | |||
((__CONTRAST__) == LCD_CONTRASTLEVEL_6) || \ | |||
((__CONTRAST__) == LCD_CONTRASTLEVEL_7)) | |||
#define IS_LCD_RAM_REGISTER(__REGISTER__) (((__REGISTER__) == LCD_RAM_REGISTER0) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER1) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER2) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER3) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER4) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER5) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER6) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER7) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER8) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER9) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER10) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER11) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER12) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER13) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER14) || \ | |||
((__REGISTER__) == LCD_RAM_REGISTER15)) | |||
#define IS_LCD_HIGH_DRIVE(__VALUE__) (((__VALUE__) == LCD_HIGHDRIVE_DISABLE) || \ | |||
((__VALUE__) == LCD_HIGHDRIVE_ENABLE)) | |||
#define IS_LCD_MUX_SEGMENT(__VALUE__) (((__VALUE__) == LCD_MUXSEGMENT_ENABLE) || \ | |||
((__VALUE__) == LCD_MUXSEGMENT_DISABLE)) | |||
/** | |||
* @} | |||
*/ | |||
/* Private functions ---------------------------------------------------------*/ | |||
/** @addtogroup LCD_Private_Functions | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef LCD_WaitForSynchro(LCD_HandleTypeDef *hlcd); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_LCD_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,760 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_lptim.h | |||
* @author MCD Application Team | |||
* @brief Header file of LPTIM HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_LPTIM_H | |||
#define STM32WBxx_HAL_LPTIM_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
#if defined (LPTIM1) || defined (LPTIM2) | |||
/** @addtogroup LPTIM | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup LPTIM_Exported_Types LPTIM Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief LPTIM Clock configuration definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Source; /*!< Selects the clock source. | |||
This parameter can be a value of @ref LPTIM_Clock_Source */ | |||
uint32_t Prescaler; /*!< Specifies the counter clock Prescaler. | |||
This parameter can be a value of @ref LPTIM_Clock_Prescaler */ | |||
} LPTIM_ClockConfigTypeDef; | |||
/** | |||
* @brief LPTIM Clock configuration definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Polarity; /*!< Selects the polarity of the active edge for the counter unit | |||
if the ULPTIM input is selected. | |||
Note: This parameter is used only when Ultra low power clock source is used. | |||
Note: If the polarity is configured on 'both edges', an auxiliary clock | |||
(one of the Low power oscillator) must be active. | |||
This parameter can be a value of @ref LPTIM_Clock_Polarity */ | |||
uint32_t SampleTime; /*!< Selects the clock sampling time to configure the clock glitch filter. | |||
Note: This parameter is used only when Ultra low power clock source is used. | |||
This parameter can be a value of @ref LPTIM_Clock_Sample_Time */ | |||
} LPTIM_ULPClockConfigTypeDef; | |||
/** | |||
* @brief LPTIM Trigger configuration definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Source; /*!< Selects the Trigger source. | |||
This parameter can be a value of @ref LPTIM_Trigger_Source */ | |||
uint32_t ActiveEdge; /*!< Selects the Trigger active edge. | |||
Note: This parameter is used only when an external trigger is used. | |||
This parameter can be a value of @ref LPTIM_External_Trigger_Polarity */ | |||
uint32_t SampleTime; /*!< Selects the trigger sampling time to configure the clock glitch filter. | |||
Note: This parameter is used only when an external trigger is used. | |||
This parameter can be a value of @ref LPTIM_Trigger_Sample_Time */ | |||
} LPTIM_TriggerConfigTypeDef; | |||
/** | |||
* @brief LPTIM Initialization Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
LPTIM_ClockConfigTypeDef Clock; /*!< Specifies the clock parameters */ | |||
LPTIM_ULPClockConfigTypeDef UltraLowPowerClock; /*!< Specifies the Ultra Low Power clock parameters */ | |||
LPTIM_TriggerConfigTypeDef Trigger; /*!< Specifies the Trigger parameters */ | |||
uint32_t OutputPolarity; /*!< Specifies the Output polarity. | |||
This parameter can be a value of @ref LPTIM_Output_Polarity */ | |||
uint32_t UpdateMode; /*!< Specifies whether the update of the autoreload and the compare | |||
values is done immediately or after the end of current period. | |||
This parameter can be a value of @ref LPTIM_Updating_Mode */ | |||
uint32_t CounterSource; /*!< Specifies whether the counter is incremented each internal event | |||
or each external event. | |||
This parameter can be a value of @ref LPTIM_Counter_Source */ | |||
uint32_t Input1Source; /*!< Specifies source selected for input1 (GPIO or comparator output). | |||
This parameter can be a value of @ref LPTIM_Input1_Source */ | |||
uint32_t Input2Source; /*!< Specifies source selected for input2 (GPIO or comparator output). | |||
Note: This parameter is used only for encoder feature so is used only | |||
for LPTIM1 instance. | |||
This parameter can be a value of @ref LPTIM_Input2_Source */ | |||
} LPTIM_InitTypeDef; | |||
/** | |||
* @brief HAL LPTIM State structure definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_LPTIM_STATE_RESET = 0x00U, /*!< Peripheral not yet initialized or disabled */ | |||
HAL_LPTIM_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */ | |||
HAL_LPTIM_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */ | |||
HAL_LPTIM_STATE_TIMEOUT = 0x03U, /*!< Timeout state */ | |||
HAL_LPTIM_STATE_ERROR = 0x04U /*!< Internal Process is ongoing */ | |||
} HAL_LPTIM_StateTypeDef; | |||
/** | |||
* @brief LPTIM handle Structure definition | |||
*/ | |||
#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1) | |||
typedef struct __LPTIM_HandleTypeDef | |||
#else | |||
typedef struct | |||
#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */ | |||
{ | |||
LPTIM_TypeDef *Instance; /*!< Register base address */ | |||
LPTIM_InitTypeDef Init; /*!< LPTIM required parameters */ | |||
HAL_StatusTypeDef Status; /*!< LPTIM peripheral status */ | |||
HAL_LockTypeDef Lock; /*!< LPTIM locking object */ | |||
__IO HAL_LPTIM_StateTypeDef State; /*!< LPTIM peripheral state */ | |||
#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1) | |||
void (* MspInitCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Base Msp Init Callback */ | |||
void (* MspDeInitCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Base Msp DeInit Callback */ | |||
void (* CompareMatchCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Compare match Callback */ | |||
void (* AutoReloadMatchCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Auto-reload match Callback */ | |||
void (* TriggerCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< External trigger event detection Callback */ | |||
void (* CompareWriteCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Compare register write complete Callback */ | |||
void (* AutoReloadWriteCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Auto-reload register write complete Callback */ | |||
void (* DirectionUpCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Up-counting direction change Callback */ | |||
void (* DirectionDownCallback)(struct __LPTIM_HandleTypeDef *hlptim); /*!< Down-counting direction change Callback */ | |||
#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */ | |||
} LPTIM_HandleTypeDef; | |||
#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1) | |||
/** | |||
* @brief HAL LPTIM Callback ID enumeration definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_LPTIM_MSPINIT_CB_ID = 0x00U, /*!< LPTIM Base Msp Init Callback ID */ | |||
HAL_LPTIM_MSPDEINIT_CB_ID = 0x01U, /*!< LPTIM Base Msp DeInit Callback ID */ | |||
HAL_LPTIM_COMPARE_MATCH_CB_ID = 0x02U, /*!< Compare match Callback ID */ | |||
HAL_LPTIM_AUTORELOAD_MATCH_CB_ID = 0x03U, /*!< Auto-reload match Callback ID */ | |||
HAL_LPTIM_TRIGGER_CB_ID = 0x04U, /*!< External trigger event detection Callback ID */ | |||
HAL_LPTIM_COMPARE_WRITE_CB_ID = 0x05U, /*!< Compare register write complete Callback ID */ | |||
HAL_LPTIM_AUTORELOAD_WRITE_CB_ID = 0x06U, /*!< Auto-reload register write complete Callback ID */ | |||
HAL_LPTIM_DIRECTION_UP_CB_ID = 0x07U, /*!< Up-counting direction change Callback ID */ | |||
HAL_LPTIM_DIRECTION_DOWN_CB_ID = 0x08U, /*!< Down-counting direction change Callback ID */ | |||
} HAL_LPTIM_CallbackIDTypeDef; | |||
/** | |||
* @brief HAL TIM Callback pointer definition | |||
*/ | |||
typedef void (*pLPTIM_CallbackTypeDef)(LPTIM_HandleTypeDef *hlptim); /*!< pointer to the LPTIM callback function */ | |||
#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup LPTIM_Exported_Constants LPTIM Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup LPTIM_Clock_Source LPTIM Clock Source | |||
* @{ | |||
*/ | |||
#define LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC 0x00000000U | |||
#define LPTIM_CLOCKSOURCE_ULPTIM LPTIM_CFGR_CKSEL | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LPTIM_Clock_Prescaler LPTIM Clock Prescaler | |||
* @{ | |||
*/ | |||
#define LPTIM_PRESCALER_DIV1 0x00000000U | |||
#define LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0 | |||
#define LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1 | |||
#define LPTIM_PRESCALER_DIV8 (LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_1) | |||
#define LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2 | |||
#define LPTIM_PRESCALER_DIV32 (LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_2) | |||
#define LPTIM_PRESCALER_DIV64 (LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_2) | |||
#define LPTIM_PRESCALER_DIV128 LPTIM_CFGR_PRESC | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LPTIM_Output_Polarity LPTIM Output Polarity | |||
* @{ | |||
*/ | |||
#define LPTIM_OUTPUTPOLARITY_HIGH 0x00000000U | |||
#define LPTIM_OUTPUTPOLARITY_LOW LPTIM_CFGR_WAVPOL | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LPTIM_Clock_Sample_Time LPTIM Clock Sample Time | |||
* @{ | |||
*/ | |||
#define LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION 0x00000000U | |||
#define LPTIM_CLOCKSAMPLETIME_2TRANSITIONS LPTIM_CFGR_CKFLT_0 | |||
#define LPTIM_CLOCKSAMPLETIME_4TRANSITIONS LPTIM_CFGR_CKFLT_1 | |||
#define LPTIM_CLOCKSAMPLETIME_8TRANSITIONS LPTIM_CFGR_CKFLT | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LPTIM_Clock_Polarity LPTIM Clock Polarity | |||
* @{ | |||
*/ | |||
#define LPTIM_CLOCKPOLARITY_RISING 0x00000000U | |||
#define LPTIM_CLOCKPOLARITY_FALLING LPTIM_CFGR_CKPOL_0 | |||
#define LPTIM_CLOCKPOLARITY_RISING_FALLING LPTIM_CFGR_CKPOL_1 | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LPTIM_Trigger_Source LPTIM Trigger Source | |||
* @{ | |||
*/ | |||
#define LPTIM_TRIGSOURCE_SOFTWARE 0x0000FFFFU | |||
#define LPTIM_TRIGSOURCE_0 0x00000000U | |||
#define LPTIM_TRIGSOURCE_1 LPTIM_CFGR_TRIGSEL_0 | |||
#define LPTIM_TRIGSOURCE_2 LPTIM_CFGR_TRIGSEL_1 | |||
#define LPTIM_TRIGSOURCE_3 (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_1) | |||
#define LPTIM_TRIGSOURCE_4 LPTIM_CFGR_TRIGSEL_2 | |||
#define LPTIM_TRIGSOURCE_5 (LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_2) | |||
#define LPTIM_TRIGSOURCE_6 (LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_2) | |||
#define LPTIM_TRIGSOURCE_7 LPTIM_CFGR_TRIGSEL | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LPTIM_External_Trigger_Polarity LPTIM External Trigger Polarity | |||
* @{ | |||
*/ | |||
#define LPTIM_ACTIVEEDGE_RISING LPTIM_CFGR_TRIGEN_0 | |||
#define LPTIM_ACTIVEEDGE_FALLING LPTIM_CFGR_TRIGEN_1 | |||
#define LPTIM_ACTIVEEDGE_RISING_FALLING LPTIM_CFGR_TRIGEN | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LPTIM_Trigger_Sample_Time LPTIM Trigger Sample Time | |||
* @{ | |||
*/ | |||
#define LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION 0x00000000U | |||
#define LPTIM_TRIGSAMPLETIME_2TRANSITIONS LPTIM_CFGR_TRGFLT_0 | |||
#define LPTIM_TRIGSAMPLETIME_4TRANSITIONS LPTIM_CFGR_TRGFLT_1 | |||
#define LPTIM_TRIGSAMPLETIME_8TRANSITIONS LPTIM_CFGR_TRGFLT | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LPTIM_Updating_Mode LPTIM Updating Mode | |||
* @{ | |||
*/ | |||
#define LPTIM_UPDATE_IMMEDIATE 0x00000000U | |||
#define LPTIM_UPDATE_ENDOFPERIOD LPTIM_CFGR_PRELOAD | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LPTIM_Counter_Source LPTIM Counter Source | |||
* @{ | |||
*/ | |||
#define LPTIM_COUNTERSOURCE_INTERNAL 0x00000000U | |||
#define LPTIM_COUNTERSOURCE_EXTERNAL LPTIM_CFGR_COUNTMODE | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LPTIM_Input1_Source LPTIM Input1 Source | |||
* @{ | |||
*/ | |||
#define LPTIM_INPUT1SOURCE_GPIO 0x00000000U /*!< For LPTIM1 and LPTIM2 */ | |||
#define LPTIM_INPUT1SOURCE_COMP1 LPTIM_OR_OR_0 /*!< For LPTIM1 and LPTIM2 */ | |||
#define LPTIM_INPUT1SOURCE_COMP2 LPTIM_OR_OR_1 /*!< For LPTIM2 */ | |||
#define LPTIM_INPUT1SOURCE_COMP1_COMP2 LPTIM_OR_OR /*!< For LPTIM2 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LPTIM_Input2_Source LPTIM Input2 Source | |||
* @{ | |||
*/ | |||
#define LPTIM_INPUT2SOURCE_GPIO 0x00000000U /*!< For LPTIM1 */ | |||
#define LPTIM_INPUT2SOURCE_COMP2 LPTIM_OR_OR_1 /*!< For LPTIM1 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LPTIM_Flag_Definition LPTIM Flags Definition | |||
* @{ | |||
*/ | |||
#define LPTIM_FLAG_DOWN LPTIM_ISR_DOWN | |||
#define LPTIM_FLAG_UP LPTIM_ISR_UP | |||
#define LPTIM_FLAG_ARROK LPTIM_ISR_ARROK | |||
#define LPTIM_FLAG_CMPOK LPTIM_ISR_CMPOK | |||
#define LPTIM_FLAG_EXTTRIG LPTIM_ISR_EXTTRIG | |||
#define LPTIM_FLAG_ARRM LPTIM_ISR_ARRM | |||
#define LPTIM_FLAG_CMPM LPTIM_ISR_CMPM | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup LPTIM_Interrupts_Definition LPTIM Interrupts Definition | |||
* @{ | |||
*/ | |||
#define LPTIM_IT_DOWN LPTIM_IER_DOWNIE | |||
#define LPTIM_IT_UP LPTIM_IER_UPIE | |||
#define LPTIM_IT_ARROK LPTIM_IER_ARROKIE | |||
#define LPTIM_IT_CMPOK LPTIM_IER_CMPOKIE | |||
#define LPTIM_IT_EXTTRIG LPTIM_IER_EXTTRIGIE | |||
#define LPTIM_IT_ARRM LPTIM_IER_ARRMIE | |||
#define LPTIM_IT_CMPM LPTIM_IER_CMPMIE | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup LPTIM_Exported_Macros LPTIM Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset LPTIM handle state. | |||
* @param __HANDLE__ LPTIM handle | |||
* @retval None | |||
*/ | |||
#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1) | |||
#define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) do { \ | |||
(__HANDLE__)->State = HAL_LPTIM_STATE_RESET; \ | |||
(__HANDLE__)->MspInitCallback = NULL; \ | |||
(__HANDLE__)->MspDeInitCallback = NULL; \ | |||
} while(0) | |||
#else | |||
#define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LPTIM_STATE_RESET) | |||
#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */ | |||
/** | |||
* @brief Enable the LPTIM peripheral. | |||
* @param __HANDLE__ LPTIM handle | |||
* @retval None | |||
*/ | |||
#define __HAL_LPTIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (LPTIM_CR_ENABLE)) | |||
/** | |||
* @brief Disable the LPTIM peripheral. | |||
* @param __HANDLE__ LPTIM handle | |||
* @note The following sequence is required to solve LPTIM disable HW limitation. | |||
* Please check Errata Sheet ES0335 for more details under "MCU may remain | |||
* stuck in LPTIM interrupt when entering Stop mode" section. | |||
* @retval None | |||
*/ | |||
#define __HAL_LPTIM_DISABLE(__HANDLE__) LPTIM_Disable(__HANDLE__) | |||
/** | |||
* @brief Start the LPTIM peripheral in Continuous mode. | |||
* @param __HANDLE__ LPTIM handle | |||
* @retval None | |||
*/ | |||
#define __HAL_LPTIM_START_CONTINUOUS(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_CNTSTRT) | |||
/** | |||
* @brief Start the LPTIM peripheral in single mode. | |||
* @param __HANDLE__ LPTIM handle | |||
* @retval None | |||
*/ | |||
#define __HAL_LPTIM_START_SINGLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_SNGSTRT) | |||
/** | |||
* @brief Reset the LPTIM Counter register in synchronous mode. | |||
* @param __HANDLE__ LPTIM handle | |||
* @retval None | |||
*/ | |||
#define __HAL_LPTIM_RESET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_COUNTRST) | |||
/** | |||
* @brief Reset after read of the LPTIM Counter register in asynchronous mode. | |||
* @param __HANDLE__ LPTIM handle | |||
* @retval None | |||
*/ | |||
#define __HAL_LPTIM_RESET_COUNTER_AFTERREAD(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_RSTARE) | |||
/** | |||
* @brief Write the passed parameter in the Autoreload register. | |||
* @param __HANDLE__ LPTIM handle | |||
* @param __VALUE__ Autoreload value | |||
* @retval None | |||
*/ | |||
#define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->ARR = (__VALUE__)) | |||
/** | |||
* @brief Write the passed parameter in the Compare register. | |||
* @param __HANDLE__ LPTIM handle | |||
* @param __VALUE__ Compare value | |||
* @retval None | |||
*/ | |||
#define __HAL_LPTIM_COMPARE_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->CMP = (__VALUE__)) | |||
/** | |||
* @brief Check whether the specified LPTIM flag is set or not. | |||
* @param __HANDLE__ LPTIM handle | |||
* @param __FLAG__ LPTIM flag to check | |||
* This parameter can be a value of: | |||
* @arg LPTIM_FLAG_DOWN : Counter direction change up Flag. | |||
* @arg LPTIM_FLAG_UP : Counter direction change down to up Flag. | |||
* @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag. | |||
* @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag. | |||
* @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag. | |||
* @arg LPTIM_FLAG_ARRM : Autoreload match Flag. | |||
* @arg LPTIM_FLAG_CMPM : Compare match Flag. | |||
* @retval The state of the specified flag (SET or RESET). | |||
*/ | |||
#define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__)) | |||
/** | |||
* @brief Clear the specified LPTIM flag. | |||
* @param __HANDLE__ LPTIM handle. | |||
* @param __FLAG__ LPTIM flag to clear. | |||
* This parameter can be a value of: | |||
* @arg LPTIM_FLAG_DOWN : Counter direction change up Flag. | |||
* @arg LPTIM_FLAG_UP : Counter direction change down to up Flag. | |||
* @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag. | |||
* @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag. | |||
* @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag. | |||
* @arg LPTIM_FLAG_ARRM : Autoreload match Flag. | |||
* @arg LPTIM_FLAG_CMPM : Compare match Flag. | |||
* @retval None. | |||
*/ | |||
#define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) | |||
/** | |||
* @brief Enable the specified LPTIM interrupt. | |||
* @param __HANDLE__ LPTIM handle. | |||
* @param __INTERRUPT__ LPTIM interrupt to set. | |||
* This parameter can be a value of: | |||
* @arg LPTIM_IT_DOWN : Counter direction change up Interrupt. | |||
* @arg LPTIM_IT_UP : Counter direction change down to up Interrupt. | |||
* @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt. | |||
* @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt. | |||
* @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt. | |||
* @arg LPTIM_IT_ARRM : Autoreload match Interrupt. | |||
* @arg LPTIM_IT_CMPM : Compare match Interrupt. | |||
* @retval None. | |||
*/ | |||
#define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__)) | |||
/** | |||
* @brief Disable the specified LPTIM interrupt. | |||
* @param __HANDLE__ LPTIM handle. | |||
* @param __INTERRUPT__ LPTIM interrupt to set. | |||
* This parameter can be a value of: | |||
* @arg LPTIM_IT_DOWN : Counter direction change up Interrupt. | |||
* @arg LPTIM_IT_UP : Counter direction change down to up Interrupt. | |||
* @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt. | |||
* @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt. | |||
* @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt. | |||
* @arg LPTIM_IT_ARRM : Autoreload match Interrupt. | |||
* @arg LPTIM_IT_CMPM : Compare match Interrupt. | |||
* @retval None. | |||
*/ | |||
#define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__))) | |||
/** | |||
* @brief Check whether the specified LPTIM interrupt source is enabled or not. | |||
* @param __HANDLE__ LPTIM handle. | |||
* @param __INTERRUPT__ LPTIM interrupt to check. | |||
* This parameter can be a value of: | |||
* @arg LPTIM_IT_DOWN : Counter direction change up Interrupt. | |||
* @arg LPTIM_IT_UP : Counter direction change down to up Interrupt. | |||
* @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt. | |||
* @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt. | |||
* @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt. | |||
* @arg LPTIM_IT_ARRM : Autoreload match Interrupt. | |||
* @arg LPTIM_IT_CMPM : Compare match Interrupt. | |||
* @retval Interrupt status. | |||
*/ | |||
#define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions | |||
* @{ | |||
*/ | |||
/* Initialization/de-initialization functions ********************************/ | |||
HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim); | |||
HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim); | |||
/* MSP functions *************************************************************/ | |||
void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim); | |||
void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim); | |||
/* Start/Stop operation functions *********************************************/ | |||
/* ################################# PWM Mode ################################*/ | |||
/* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); | |||
HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim); | |||
/* Non-Blocking mode: Interrupt */ | |||
HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); | |||
HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim); | |||
/* ############################# One Pulse Mode ##############################*/ | |||
/* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); | |||
HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim); | |||
/* Non-Blocking mode: Interrupt */ | |||
HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); | |||
HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim); | |||
/* ############################## Set once Mode ##############################*/ | |||
/* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); | |||
HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim); | |||
/* Non-Blocking mode: Interrupt */ | |||
HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse); | |||
HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim); | |||
/* ############################### Encoder Mode ##############################*/ | |||
/* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period); | |||
HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim); | |||
/* Non-Blocking mode: Interrupt */ | |||
HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period); | |||
HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim); | |||
/* ############################# Time out Mode ##############################*/ | |||
/* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim); | |||
/* Non-Blocking mode: Interrupt */ | |||
HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim); | |||
/* ############################## Counter Mode ###############################*/ | |||
/* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period); | |||
HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim); | |||
/* Non-Blocking mode: Interrupt */ | |||
HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period); | |||
HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim); | |||
/* Reading operation functions ************************************************/ | |||
uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim); | |||
uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim); | |||
uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim); | |||
/* LPTIM IRQ functions *******************************************************/ | |||
void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim); | |||
/* CallBack functions ********************************************************/ | |||
void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim); | |||
void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim); | |||
void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim); | |||
void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim); | |||
void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim); | |||
void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim); | |||
void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim); | |||
/* Callbacks Register/UnRegister functions ***********************************/ | |||
#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1) | |||
HAL_StatusTypeDef HAL_LPTIM_RegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID, pLPTIM_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_LPTIM_UnRegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID); | |||
#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */ | |||
/* Peripheral State functions ************************************************/ | |||
HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim); | |||
/** | |||
* @} | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/** @defgroup LPTIM_Private_Types LPTIM Private Types | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/** @defgroup LPTIM_Private_Variables LPTIM Private Variables | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/** @defgroup LPTIM_Private_Constants LPTIM Private Constants | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup LPTIM_Private_Macros LPTIM Private Macros | |||
* @{ | |||
*/ | |||
#define IS_LPTIM_CLOCK_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \ | |||
((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC)) | |||
#define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LPTIM_PRESCALER_DIV1 ) || \ | |||
((__PRESCALER__) == LPTIM_PRESCALER_DIV2 ) || \ | |||
((__PRESCALER__) == LPTIM_PRESCALER_DIV4 ) || \ | |||
((__PRESCALER__) == LPTIM_PRESCALER_DIV8 ) || \ | |||
((__PRESCALER__) == LPTIM_PRESCALER_DIV16 ) || \ | |||
((__PRESCALER__) == LPTIM_PRESCALER_DIV32 ) || \ | |||
((__PRESCALER__) == LPTIM_PRESCALER_DIV64 ) || \ | |||
((__PRESCALER__) == LPTIM_PRESCALER_DIV128)) | |||
#define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) == LPTIM_PRESCALER_DIV1) | |||
#define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \ | |||
((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH)) | |||
#define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \ | |||
((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS) || \ | |||
((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS) || \ | |||
((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS)) | |||
#define IS_LPTIM_CLOCK_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING) || \ | |||
((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \ | |||
((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING)) | |||
#define IS_LPTIM_TRG_SOURCE(__TRIG__) (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \ | |||
((__TRIG__) == LPTIM_TRIGSOURCE_0) || \ | |||
((__TRIG__) == LPTIM_TRIGSOURCE_1) || \ | |||
((__TRIG__) == LPTIM_TRIGSOURCE_2) || \ | |||
((__TRIG__) == LPTIM_TRIGSOURCE_3) || \ | |||
((__TRIG__) == LPTIM_TRIGSOURCE_4) || \ | |||
((__TRIG__) == LPTIM_TRIGSOURCE_5) || \ | |||
((__TRIG__) == LPTIM_TRIGSOURCE_6) || \ | |||
((__TRIG__) == LPTIM_TRIGSOURCE_7)) | |||
#define IS_LPTIM_EXT_TRG_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING ) || \ | |||
((__POLARITY__) == LPTIM_ACTIVEEDGE_FALLING ) || \ | |||
((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING_FALLING )) | |||
#define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION) || \ | |||
((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS ) || \ | |||
((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS ) || \ | |||
((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS )) | |||
#define IS_LPTIM_UPDATE_MODE(__MODE__) (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \ | |||
((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD)) | |||
#define IS_LPTIM_COUNTER_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \ | |||
((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL)) | |||
#define IS_LPTIM_AUTORELOAD(__AUTORELOAD__) ((__AUTORELOAD__) <= 0x0000FFFFUL) | |||
#define IS_LPTIM_COMPARE(__COMPARE__) ((__COMPARE__) <= 0x0000FFFFUL) | |||
#define IS_LPTIM_PERIOD(__PERIOD__) ((__PERIOD__) <= 0x0000FFFFUL) | |||
#define IS_LPTIM_PULSE(__PULSE__) ((__PULSE__) <= 0x0000FFFFUL) | |||
#define IS_LPTIM_INPUT1_SOURCE(__INSTANCE__, __SOURCE__) \ | |||
((((__INSTANCE__) == LPTIM1) && \ | |||
(((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) || \ | |||
((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1))) \ | |||
|| \ | |||
(((__INSTANCE__) == LPTIM2) && \ | |||
(((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) || \ | |||
((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1) || \ | |||
((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP2) || \ | |||
((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1_COMP2)))) | |||
#define IS_LPTIM_INPUT2_SOURCE(__INSTANCE__, __SOURCE__) \ | |||
(((__INSTANCE__) == LPTIM1) && \ | |||
(((__SOURCE__) == LPTIM_INPUT2SOURCE_GPIO) || \ | |||
((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP2))) | |||
/** | |||
* @} | |||
*/ | |||
/* Private functions ---------------------------------------------------------*/ | |||
/** @defgroup LPTIM_Private_Functions LPTIM Private Functions | |||
* @{ | |||
*/ | |||
void LPTIM_Disable(LPTIM_HandleTypeDef *lptim); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* LPTIM1 || LPTIM2 */ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_LPTIM_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,941 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_pcd.h | |||
* @author MCD Application Team | |||
* @brief Header file of PCD HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_PCD_H | |||
#define STM32WBxx_HAL_PCD_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_ll_usb.h" | |||
#if defined (USB) | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup PCD | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup PCD_Exported_Types PCD Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief PCD State structure definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_PCD_STATE_RESET = 0x00, | |||
HAL_PCD_STATE_READY = 0x01, | |||
HAL_PCD_STATE_ERROR = 0x02, | |||
HAL_PCD_STATE_BUSY = 0x03, | |||
HAL_PCD_STATE_TIMEOUT = 0x04 | |||
} PCD_StateTypeDef; | |||
/* Device LPM suspend state */ | |||
typedef enum | |||
{ | |||
LPM_L0 = 0x00, /* on */ | |||
LPM_L1 = 0x01, /* LPM L1 sleep */ | |||
LPM_L2 = 0x02, /* suspend */ | |||
LPM_L3 = 0x03, /* off */ | |||
} PCD_LPM_StateTypeDef; | |||
typedef enum | |||
{ | |||
PCD_LPM_L0_ACTIVE = 0x00, /* on */ | |||
PCD_LPM_L1_ACTIVE = 0x01, /* LPM L1 sleep */ | |||
} PCD_LPM_MsgTypeDef; | |||
typedef enum | |||
{ | |||
PCD_BCD_ERROR = 0xFF, | |||
PCD_BCD_CONTACT_DETECTION = 0xFE, | |||
PCD_BCD_STD_DOWNSTREAM_PORT = 0xFD, | |||
PCD_BCD_CHARGING_DOWNSTREAM_PORT = 0xFC, | |||
PCD_BCD_DEDICATED_CHARGING_PORT = 0xFB, | |||
PCD_BCD_DISCOVERY_COMPLETED = 0x00, | |||
} PCD_BCD_MsgTypeDef; | |||
typedef USB_TypeDef PCD_TypeDef; | |||
typedef USB_CfgTypeDef PCD_InitTypeDef; | |||
typedef USB_EPTypeDef PCD_EPTypeDef; | |||
/** | |||
* @brief PCD Handle Structure definition | |||
*/ | |||
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | |||
typedef struct __PCD_HandleTypeDef | |||
#else | |||
typedef struct | |||
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | |||
{ | |||
PCD_TypeDef *Instance; /*!< Register base address */ | |||
PCD_InitTypeDef Init; /*!< PCD required parameters */ | |||
__IO uint8_t USB_Address; /*!< USB Address */ | |||
PCD_EPTypeDef IN_ep[8]; /*!< IN endpoint parameters */ | |||
PCD_EPTypeDef OUT_ep[8]; /*!< OUT endpoint parameters */ | |||
HAL_LockTypeDef Lock; /*!< PCD peripheral status */ | |||
__IO PCD_StateTypeDef State; /*!< PCD communication state */ | |||
__IO uint32_t ErrorCode; /*!< PCD Error code */ | |||
uint32_t Setup[12]; /*!< Setup packet buffer */ | |||
PCD_LPM_StateTypeDef LPM_State; /*!< LPM State */ | |||
uint32_t BESL; | |||
uint32_t lpm_active; /*!< Enable or disable the Link Power Management . | |||
This parameter can be set to ENABLE or DISABLE */ | |||
uint32_t battery_charging_active; /*!< Enable or disable Battery charging. | |||
This parameter can be set to ENABLE or DISABLE */ | |||
void *pData; /*!< Pointer to upper stack Handler */ | |||
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | |||
void (* SOFCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD SOF callback */ | |||
void (* SetupStageCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Setup Stage callback */ | |||
void (* ResetCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Reset callback */ | |||
void (* SuspendCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Suspend callback */ | |||
void (* ResumeCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Resume callback */ | |||
void (* ConnectCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Connect callback */ | |||
void (* DisconnectCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Disconnect callback */ | |||
void (* DataOutStageCallback)(struct __PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< USB OTG PCD Data OUT Stage callback */ | |||
void (* DataInStageCallback)(struct __PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< USB OTG PCD Data IN Stage callback */ | |||
void (* ISOOUTIncompleteCallback)(struct __PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< USB OTG PCD ISO OUT Incomplete callback */ | |||
void (* ISOINIncompleteCallback)(struct __PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< USB OTG PCD ISO IN Incomplete callback */ | |||
void (* BCDCallback)(struct __PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); /*!< USB OTG PCD BCD callback */ | |||
void (* LPMCallback)(struct __PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); /*!< USB OTG PCD LPM callback */ | |||
void (* MspInitCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Msp Init callback */ | |||
void (* MspDeInitCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Msp DeInit callback */ | |||
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | |||
} PCD_HandleTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Include PCD HAL Extended module */ | |||
#include "stm32wbxx_hal_pcd_ex.h" | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup PCD_Exported_Constants PCD Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup PCD_Speed PCD Speed | |||
* @{ | |||
*/ | |||
#define PCD_SPEED_FULL 2U | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PCD_PHY_Module PCD PHY Module | |||
* @{ | |||
*/ | |||
#define PCD_PHY_ULPI 1U | |||
#define PCD_PHY_EMBEDDED 2U | |||
#define PCD_PHY_UTMI 3U | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PCD_Error_Code_definition PCD Error Code definition | |||
* @brief PCD Error Code definition | |||
* @{ | |||
*/ | |||
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | |||
#define HAL_PCD_ERROR_INVALID_CALLBACK (0x00000010U) /*!< Invalid Callback error */ | |||
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup PCD_Exported_Macros PCD Exported Macros | |||
* @brief macros to handle interrupts and specific clock configurations | |||
* @{ | |||
*/ | |||
#define __HAL_PCD_ENABLE(__HANDLE__) (void)USB_EnableGlobalInt ((__HANDLE__)->Instance) | |||
#define __HAL_PCD_DISABLE(__HANDLE__) (void)USB_DisableGlobalInt ((__HANDLE__)->Instance) | |||
#define __HAL_PCD_GET_FLAG(__HANDLE__, __INTERRUPT__) ((USB_ReadInterrupts((__HANDLE__)->Instance) & (__INTERRUPT__)) == (__INTERRUPT__)) | |||
#define __HAL_PCD_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->ISTR) &= ~(__INTERRUPT__)) | |||
#define __HAL_USB_WAKEUP_EXTI_ENABLE_IT() EXTI->IMR1 |= USB_WAKEUP_EXTI_LINE | |||
#define __HAL_USB_WAKEUP_EXTI_DISABLE_IT() EXTI->IMR1 &= ~(USB_WAKEUP_EXTI_LINE) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup PCD_Exported_Functions PCD Exported Functions | |||
* @{ | |||
*/ | |||
/* Initialization/de-initialization functions ********************************/ | |||
/** @addtogroup PCD_Exported_Functions_Group1 Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd); | |||
HAL_StatusTypeDef HAL_PCD_DeInit(PCD_HandleTypeDef *hpcd); | |||
void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd); | |||
void HAL_PCD_MspDeInit(PCD_HandleTypeDef *hpcd); | |||
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | |||
/** @defgroup HAL_PCD_Callback_ID_enumeration_definition HAL USB OTG PCD Callback ID enumeration definition | |||
* @brief HAL USB OTG PCD Callback ID enumeration definition | |||
* @{ | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_PCD_SOF_CB_ID = 0x01, /*!< USB PCD SOF callback ID */ | |||
HAL_PCD_SETUPSTAGE_CB_ID = 0x02, /*!< USB PCD Setup Stage callback ID */ | |||
HAL_PCD_RESET_CB_ID = 0x03, /*!< USB PCD Reset callback ID */ | |||
HAL_PCD_SUSPEND_CB_ID = 0x04, /*!< USB PCD Suspend callback ID */ | |||
HAL_PCD_RESUME_CB_ID = 0x05, /*!< USB PCD Resume callback ID */ | |||
HAL_PCD_CONNECT_CB_ID = 0x06, /*!< USB PCD Connect callback ID */ | |||
HAL_PCD_DISCONNECT_CB_ID = 0x07, /*!< USB PCD Disconnect callback ID */ | |||
HAL_PCD_MSPINIT_CB_ID = 0x08, /*!< USB PCD MspInit callback ID */ | |||
HAL_PCD_MSPDEINIT_CB_ID = 0x09 /*!< USB PCD MspDeInit callback ID */ | |||
} HAL_PCD_CallbackIDTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup HAL_PCD_Callback_pointer_definition HAL USB OTG PCD Callback pointer definition | |||
* @brief HAL USB OTG PCD Callback pointer definition | |||
* @{ | |||
*/ | |||
typedef void (*pPCD_CallbackTypeDef)(PCD_HandleTypeDef *hpcd); /*!< pointer to a common USB OTG PCD callback function */ | |||
typedef void (*pPCD_DataOutStageCallbackTypeDef)(PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< pointer to USB OTG PCD Data OUT Stage callback */ | |||
typedef void (*pPCD_DataInStageCallbackTypeDef)(PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< pointer to USB OTG PCD Data IN Stage callback */ | |||
typedef void (*pPCD_IsoOutIncpltCallbackTypeDef)(PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< pointer to USB OTG PCD ISO OUT Incomplete callback */ | |||
typedef void (*pPCD_IsoInIncpltCallbackTypeDef)(PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< pointer to USB OTG PCD ISO IN Incomplete callback */ | |||
typedef void (*pPCD_LpmCallbackTypeDef)(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); /*!< pointer to USB OTG PCD LPM callback */ | |||
typedef void (*pPCD_BcdCallbackTypeDef)(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); /*!< pointer to USB OTG PCD BCD callback */ | |||
/** | |||
* @} | |||
*/ | |||
HAL_StatusTypeDef HAL_PCD_RegisterCallback(PCD_HandleTypeDef *hpcd, HAL_PCD_CallbackIDTypeDef CallbackID, pPCD_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_PCD_UnRegisterCallback(PCD_HandleTypeDef *hpcd, HAL_PCD_CallbackIDTypeDef CallbackID); | |||
HAL_StatusTypeDef HAL_PCD_RegisterDataOutStageCallback(PCD_HandleTypeDef *hpcd, pPCD_DataOutStageCallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_PCD_UnRegisterDataOutStageCallback(PCD_HandleTypeDef *hpcd); | |||
HAL_StatusTypeDef HAL_PCD_RegisterDataInStageCallback(PCD_HandleTypeDef *hpcd, pPCD_DataInStageCallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_PCD_UnRegisterDataInStageCallback(PCD_HandleTypeDef *hpcd); | |||
HAL_StatusTypeDef HAL_PCD_RegisterIsoOutIncpltCallback(PCD_HandleTypeDef *hpcd, pPCD_IsoOutIncpltCallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_PCD_UnRegisterIsoOutIncpltCallback(PCD_HandleTypeDef *hpcd); | |||
HAL_StatusTypeDef HAL_PCD_RegisterIsoInIncpltCallback(PCD_HandleTypeDef *hpcd, pPCD_IsoInIncpltCallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_PCD_UnRegisterIsoInIncpltCallback(PCD_HandleTypeDef *hpcd); | |||
HAL_StatusTypeDef HAL_PCD_RegisterBcdCallback(PCD_HandleTypeDef *hpcd, pPCD_BcdCallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_PCD_UnRegisterBcdCallback(PCD_HandleTypeDef *hpcd); | |||
HAL_StatusTypeDef HAL_PCD_RegisterLpmCallback(PCD_HandleTypeDef *hpcd, pPCD_LpmCallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_PCD_UnRegisterLpmCallback(PCD_HandleTypeDef *hpcd); | |||
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/* I/O operation functions ***************************************************/ | |||
/* Non-Blocking mode: Interrupt */ | |||
/** @addtogroup PCD_Exported_Functions_Group2 Input and Output operation functions | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_PCD_Start(PCD_HandleTypeDef *hpcd); | |||
HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd); | |||
void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd); | |||
void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd); | |||
void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd); | |||
void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd); | |||
void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd); | |||
void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd); | |||
void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd); | |||
void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd); | |||
void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); | |||
void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); | |||
void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); | |||
void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); | |||
/** | |||
* @} | |||
*/ | |||
/* Peripheral Control functions **********************************************/ | |||
/** @addtogroup PCD_Exported_Functions_Group3 Peripheral Control functions | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_PCD_DevConnect(PCD_HandleTypeDef *hpcd); | |||
HAL_StatusTypeDef HAL_PCD_DevDisconnect(PCD_HandleTypeDef *hpcd); | |||
HAL_StatusTypeDef HAL_PCD_SetAddress(PCD_HandleTypeDef *hpcd, uint8_t address); | |||
HAL_StatusTypeDef HAL_PCD_EP_Open(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint16_t ep_mps, uint8_t ep_type); | |||
HAL_StatusTypeDef HAL_PCD_EP_Close(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); | |||
HAL_StatusTypeDef HAL_PCD_EP_Receive(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len); | |||
HAL_StatusTypeDef HAL_PCD_EP_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len); | |||
uint32_t HAL_PCD_EP_GetRxCount(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); | |||
HAL_StatusTypeDef HAL_PCD_EP_SetStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); | |||
HAL_StatusTypeDef HAL_PCD_EP_ClrStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); | |||
HAL_StatusTypeDef HAL_PCD_EP_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); | |||
HAL_StatusTypeDef HAL_PCD_ActivateRemoteWakeup(PCD_HandleTypeDef *hpcd); | |||
HAL_StatusTypeDef HAL_PCD_DeActivateRemoteWakeup(PCD_HandleTypeDef *hpcd); | |||
/** | |||
* @} | |||
*/ | |||
/* Peripheral State functions ************************************************/ | |||
/** @addtogroup PCD_Exported_Functions_Group4 Peripheral State functions | |||
* @{ | |||
*/ | |||
PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/** @defgroup PCD_Private_Constants PCD Private Constants | |||
* @{ | |||
*/ | |||
/** @defgroup USB_EXTI_Line_Interrupt USB EXTI line interrupt | |||
* @{ | |||
*/ | |||
#define USB_WAKEUP_EXTI_LINE (0x1U << 28) /*!< USB FS EXTI Line WakeUp Interrupt */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PCD_EP0_MPS PCD EP0 MPS | |||
* @{ | |||
*/ | |||
#define PCD_EP0MPS_64 DEP0CTL_MPS_64 | |||
#define PCD_EP0MPS_32 DEP0CTL_MPS_32 | |||
#define PCD_EP0MPS_16 DEP0CTL_MPS_16 | |||
#define PCD_EP0MPS_08 DEP0CTL_MPS_8 | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PCD_ENDP PCD ENDP | |||
* @{ | |||
*/ | |||
#define PCD_ENDP0 0U | |||
#define PCD_ENDP1 1U | |||
#define PCD_ENDP2 2U | |||
#define PCD_ENDP3 3U | |||
#define PCD_ENDP4 4U | |||
#define PCD_ENDP5 5U | |||
#define PCD_ENDP6 6U | |||
#define PCD_ENDP7 7U | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PCD_ENDP_Kind PCD Endpoint Kind | |||
* @{ | |||
*/ | |||
#define PCD_SNG_BUF 0U | |||
#define PCD_DBL_BUF 1U | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup PCD_Private_Macros PCD Private Macros | |||
* @{ | |||
*/ | |||
/******************** Bit definition for USB_COUNTn_RX register *************/ | |||
#define USB_CNTRX_NBLK_MSK (0x1FU << 10) | |||
#define USB_CNTRX_BLSIZE (0x1U << 15) | |||
/* SetENDPOINT */ | |||
#define PCD_SET_ENDPOINT(USBx, bEpNum, wRegValue) (*(__IO uint16_t *)(&(USBx)->EP0R + ((bEpNum) * 2U)) = (uint16_t)(wRegValue)) | |||
/* GetENDPOINT */ | |||
#define PCD_GET_ENDPOINT(USBx, bEpNum) (*(__IO uint16_t *)(&(USBx)->EP0R + ((bEpNum) * 2U))) | |||
/* ENDPOINT transfer */ | |||
#define USB_EP0StartXfer USB_EPStartXfer | |||
/** | |||
* @brief sets the type in the endpoint register(bits EP_TYPE[1:0]) | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @param wType Endpoint Type. | |||
* @retval None | |||
*/ | |||
#define PCD_SET_EPTYPE(USBx, bEpNum, wType) (PCD_SET_ENDPOINT((USBx), (bEpNum), \ | |||
((PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EP_T_MASK) | (wType) | USB_EP_CTR_TX | USB_EP_CTR_RX))) | |||
/** | |||
* @brief gets the type in the endpoint register(bits EP_TYPE[1:0]) | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval Endpoint Type | |||
*/ | |||
#define PCD_GET_EPTYPE(USBx, bEpNum) (PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EP_T_FIELD) | |||
/** | |||
* @brief free buffer used from the application realizing it to the line | |||
* toggles bit SW_BUF in the double buffered endpoint register | |||
* @param USBx USB device. | |||
* @param bEpNum, bDir | |||
* @retval None | |||
*/ | |||
#define PCD_FreeUserBuffer(USBx, bEpNum, bDir) do { \ | |||
if ((bDir) == 0U) \ | |||
{ \ | |||
/* OUT double buffered endpoint */ \ | |||
PCD_TX_DTOG((USBx), (bEpNum)); \ | |||
} \ | |||
else if ((bDir) == 1U) \ | |||
{ \ | |||
/* IN double buffered endpoint */ \ | |||
PCD_RX_DTOG((USBx), (bEpNum)); \ | |||
} \ | |||
} while(0) | |||
/** | |||
* @brief sets the status for tx transfer (bits STAT_TX[1:0]). | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @param wState new state | |||
* @retval None | |||
*/ | |||
#define PCD_SET_EP_TX_STATUS(USBx, bEpNum, wState) do { \ | |||
register uint16_t _wRegVal; \ | |||
\ | |||
_wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPTX_DTOGMASK; \ | |||
/* toggle first bit ? */ \ | |||
if ((USB_EPTX_DTOG1 & (wState))!= 0U) \ | |||
{ \ | |||
_wRegVal ^= USB_EPTX_DTOG1; \ | |||
} \ | |||
/* toggle second bit ? */ \ | |||
if ((USB_EPTX_DTOG2 & (wState))!= 0U) \ | |||
{ \ | |||
_wRegVal ^= USB_EPTX_DTOG2; \ | |||
} \ | |||
PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX | USB_EP_CTR_TX)); \ | |||
} while(0) /* PCD_SET_EP_TX_STATUS */ | |||
/** | |||
* @brief sets the status for rx transfer (bits STAT_TX[1:0]) | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @param wState new state | |||
* @retval None | |||
*/ | |||
#define PCD_SET_EP_RX_STATUS(USBx, bEpNum,wState) do { \ | |||
register uint16_t _wRegVal; \ | |||
\ | |||
_wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPRX_DTOGMASK; \ | |||
/* toggle first bit ? */ \ | |||
if ((USB_EPRX_DTOG1 & (wState))!= 0U) \ | |||
{ \ | |||
_wRegVal ^= USB_EPRX_DTOG1; \ | |||
} \ | |||
/* toggle second bit ? */ \ | |||
if ((USB_EPRX_DTOG2 & (wState))!= 0U) \ | |||
{ \ | |||
_wRegVal ^= USB_EPRX_DTOG2; \ | |||
} \ | |||
PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX | USB_EP_CTR_TX)); \ | |||
} while(0) /* PCD_SET_EP_RX_STATUS */ | |||
/** | |||
* @brief sets the status for rx & tx (bits STAT_TX[1:0] & STAT_RX[1:0]) | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @param wStaterx new state. | |||
* @param wStatetx new state. | |||
* @retval None | |||
*/ | |||
#define PCD_SET_EP_TXRX_STATUS(USBx, bEpNum, wStaterx, wStatetx) do { \ | |||
register uint16_t _wRegVal; \ | |||
\ | |||
_wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & (USB_EPRX_DTOGMASK | USB_EPTX_STAT); \ | |||
/* toggle first bit ? */ \ | |||
if ((USB_EPRX_DTOG1 & (wStaterx))!= 0U) \ | |||
{ \ | |||
_wRegVal ^= USB_EPRX_DTOG1; \ | |||
} \ | |||
/* toggle second bit ? */ \ | |||
if ((USB_EPRX_DTOG2 & (wStaterx))!= 0U) \ | |||
{ \ | |||
_wRegVal ^= USB_EPRX_DTOG2; \ | |||
} \ | |||
/* toggle first bit ? */ \ | |||
if ((USB_EPTX_DTOG1 & (wStatetx))!= 0U) \ | |||
{ \ | |||
_wRegVal ^= USB_EPTX_DTOG1; \ | |||
} \ | |||
/* toggle second bit ? */ \ | |||
if ((USB_EPTX_DTOG2 & (wStatetx))!= 0U) \ | |||
{ \ | |||
_wRegVal ^= USB_EPTX_DTOG2; \ | |||
} \ | |||
\ | |||
PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX | USB_EP_CTR_TX)); \ | |||
} while(0) /* PCD_SET_EP_TXRX_STATUS */ | |||
/** | |||
* @brief gets the status for tx/rx transfer (bits STAT_TX[1:0] | |||
* /STAT_RX[1:0]) | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval status | |||
*/ | |||
#define PCD_GET_EP_TX_STATUS(USBx, bEpNum) ((uint16_t)PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPTX_STAT) | |||
#define PCD_GET_EP_RX_STATUS(USBx, bEpNum) ((uint16_t)PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPRX_STAT) | |||
/** | |||
* @brief sets directly the VALID tx/rx-status into the endpoint register | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval None | |||
*/ | |||
#define PCD_SET_EP_TX_VALID(USBx, bEpNum) (PCD_SET_EP_TX_STATUS((USBx), (bEpNum), USB_EP_TX_VALID)) | |||
#define PCD_SET_EP_RX_VALID(USBx, bEpNum) (PCD_SET_EP_RX_STATUS((USBx), (bEpNum), USB_EP_RX_VALID)) | |||
/** | |||
* @brief checks stall condition in an endpoint. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval TRUE = endpoint in stall condition. | |||
*/ | |||
#define PCD_GET_EP_TX_STALL_STATUS(USBx, bEpNum) (PCD_GET_EP_TX_STATUS((USBx), (bEpNum)) \ | |||
== USB_EP_TX_STALL) | |||
#define PCD_GET_EP_RX_STALL_STATUS(USBx, bEpNum) (PCD_GET_EP_RX_STATUS((USBx), (bEpNum)) \ | |||
== USB_EP_RX_STALL) | |||
/** | |||
* @brief set & clear EP_KIND bit. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval None | |||
*/ | |||
#define PCD_SET_EP_KIND(USBx, bEpNum) do { \ | |||
register uint16_t _wRegVal; \ | |||
\ | |||
_wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPREG_MASK; \ | |||
\ | |||
PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX | USB_EP_CTR_TX | USB_EP_KIND)); \ | |||
} while(0) /* PCD_SET_EP_KIND */ | |||
#define PCD_CLEAR_EP_KIND(USBx, bEpNum) do { \ | |||
register uint16_t _wRegVal; \ | |||
\ | |||
_wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPKIND_MASK; \ | |||
\ | |||
PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX | USB_EP_CTR_TX)); \ | |||
} while(0) /* PCD_CLEAR_EP_KIND */ | |||
/** | |||
* @brief Sets/clears directly STATUS_OUT bit in the endpoint register. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval None | |||
*/ | |||
#define PCD_SET_OUT_STATUS(USBx, bEpNum) PCD_SET_EP_KIND((USBx), (bEpNum)) | |||
#define PCD_CLEAR_OUT_STATUS(USBx, bEpNum) PCD_CLEAR_EP_KIND((USBx), (bEpNum)) | |||
/** | |||
* @brief Sets/clears directly EP_KIND bit in the endpoint register. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval None | |||
*/ | |||
#define PCD_SET_EP_DBUF(USBx, bEpNum) PCD_SET_EP_KIND((USBx), (bEpNum)) | |||
#define PCD_CLEAR_EP_DBUF(USBx, bEpNum) PCD_CLEAR_EP_KIND((USBx), (bEpNum)) | |||
/** | |||
* @brief Clears bit CTR_RX / CTR_TX in the endpoint register. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval None | |||
*/ | |||
#define PCD_CLEAR_RX_EP_CTR(USBx, bEpNum) do { \ | |||
register uint16_t _wRegVal; \ | |||
\ | |||
_wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & (0x7FFFU & USB_EPREG_MASK); \ | |||
\ | |||
PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_TX)); \ | |||
} while(0) /* PCD_CLEAR_RX_EP_CTR */ | |||
#define PCD_CLEAR_TX_EP_CTR(USBx, bEpNum) do { \ | |||
register uint16_t _wRegVal; \ | |||
\ | |||
_wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & (0xFF7FU & USB_EPREG_MASK); \ | |||
\ | |||
PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX)); \ | |||
} while(0) /* PCD_CLEAR_TX_EP_CTR */ | |||
/** | |||
* @brief Toggles DTOG_RX / DTOG_TX bit in the endpoint register. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval None | |||
*/ | |||
#define PCD_RX_DTOG(USBx, bEpNum) do { \ | |||
register uint16_t _wEPVal; \ | |||
\ | |||
_wEPVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPREG_MASK; \ | |||
\ | |||
PCD_SET_ENDPOINT((USBx), (bEpNum), (_wEPVal | USB_EP_CTR_RX | USB_EP_CTR_TX | USB_EP_DTOG_RX)); \ | |||
} while(0) /* PCD_RX_DTOG */ | |||
#define PCD_TX_DTOG(USBx, bEpNum) do { \ | |||
register uint16_t _wEPVal; \ | |||
\ | |||
_wEPVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPREG_MASK; \ | |||
\ | |||
PCD_SET_ENDPOINT((USBx), (bEpNum), (_wEPVal | USB_EP_CTR_RX | USB_EP_CTR_TX | USB_EP_DTOG_TX)); \ | |||
} while(0) /* PCD_TX_DTOG */ | |||
/** | |||
* @brief Clears DTOG_RX / DTOG_TX bit in the endpoint register. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval None | |||
*/ | |||
#define PCD_CLEAR_RX_DTOG(USBx, bEpNum) do { \ | |||
register uint16_t _wRegVal; \ | |||
\ | |||
_wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)); \ | |||
\ | |||
if ((_wRegVal & USB_EP_DTOG_RX) != 0U)\ | |||
{ \ | |||
PCD_RX_DTOG((USBx), (bEpNum)); \ | |||
} \ | |||
} while(0) /* PCD_CLEAR_RX_DTOG */ | |||
#define PCD_CLEAR_TX_DTOG(USBx, bEpNum) do { \ | |||
register uint16_t _wRegVal; \ | |||
\ | |||
_wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)); \ | |||
\ | |||
if ((_wRegVal & USB_EP_DTOG_TX) != 0U)\ | |||
{ \ | |||
PCD_TX_DTOG((USBx), (bEpNum)); \ | |||
} \ | |||
} while(0) /* PCD_CLEAR_TX_DTOG */ | |||
/** | |||
* @brief Sets address in an endpoint register. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @param bAddr Address. | |||
* @retval None | |||
*/ | |||
#define PCD_SET_EP_ADDRESS(USBx, bEpNum, bAddr) do { \ | |||
register uint16_t _wRegVal; \ | |||
\ | |||
_wRegVal = (PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPREG_MASK) | (bAddr); \ | |||
\ | |||
PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX | USB_EP_CTR_TX)); \ | |||
} while(0) /* PCD_SET_EP_ADDRESS */ | |||
/** | |||
* @brief Gets address in an endpoint register. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval None | |||
*/ | |||
#define PCD_GET_EP_ADDRESS(USBx, bEpNum) ((uint8_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPADDR_FIELD)) | |||
#define PCD_EP_TX_CNT(USBx, bEpNum) ((uint16_t *)((((uint32_t)(USBx)->BTABLE + ((uint32_t)(bEpNum) * 8U) + 2U) * PMA_ACCESS) + ((uint32_t)(USBx) + 0x400U))) | |||
#define PCD_EP_RX_CNT(USBx, bEpNum) ((uint16_t *)((((uint32_t)(USBx)->BTABLE + ((uint32_t)(bEpNum) * 8U) + 6U) * PMA_ACCESS) + ((uint32_t)(USBx) + 0x400U))) | |||
/** | |||
* @brief sets address of the tx/rx buffer. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @param wAddr address to be set (must be word aligned). | |||
* @retval None | |||
*/ | |||
#define PCD_SET_EP_TX_ADDRESS(USBx, bEpNum, wAddr) do { \ | |||
register uint16_t *_wRegVal; \ | |||
register uint32_t _wRegBase = (uint32_t)USBx; \ | |||
\ | |||
_wRegBase += (uint32_t)(USBx)->BTABLE; \ | |||
_wRegVal = (uint16_t *)(_wRegBase + 0x400U + (((uint32_t)(bEpNum) * 8U) * PMA_ACCESS)); \ | |||
*_wRegVal = ((wAddr) >> 1) << 1; \ | |||
} while(0) /* PCD_SET_EP_TX_ADDRESS */ | |||
#define PCD_SET_EP_RX_ADDRESS(USBx, bEpNum, wAddr) do { \ | |||
register uint16_t *_wRegVal; \ | |||
register uint32_t _wRegBase = (uint32_t)USBx; \ | |||
\ | |||
_wRegBase += (uint32_t)(USBx)->BTABLE; \ | |||
_wRegVal = (uint16_t *)(_wRegBase + 0x400U + ((((uint32_t)(bEpNum) * 8U) + 4U) * PMA_ACCESS)); \ | |||
*_wRegVal = ((wAddr) >> 1) << 1; \ | |||
} while(0) /* PCD_SET_EP_RX_ADDRESS */ | |||
/** | |||
* @brief Gets address of the tx/rx buffer. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval address of the buffer. | |||
*/ | |||
#define PCD_GET_EP_TX_ADDRESS(USBx, bEpNum) ((uint16_t)*PCD_EP_TX_ADDRESS((USBx), (bEpNum))) | |||
#define PCD_GET_EP_RX_ADDRESS(USBx, bEpNum) ((uint16_t)*PCD_EP_RX_ADDRESS((USBx), (bEpNum))) | |||
/** | |||
* @brief Sets counter of rx buffer with no. of blocks. | |||
* @param pdwReg Register pointer | |||
* @param wCount Counter. | |||
* @param wNBlocks no. of Blocks. | |||
* @retval None | |||
*/ | |||
#define PCD_CALC_BLK32(pdwReg, wCount, wNBlocks) do { \ | |||
(wNBlocks) = (wCount) >> 5; \ | |||
*(pdwReg) = (uint16_t)(((wNBlocks) << 10) | USB_CNTRX_BLSIZE); \ | |||
} while(0) /* PCD_CALC_BLK32 */ | |||
#define PCD_CALC_BLK2(pdwReg, wCount, wNBlocks) do { \ | |||
(wNBlocks) = (wCount) >> 1; \ | |||
if (((wCount) & 0x1U) != 0U) \ | |||
{ \ | |||
(wNBlocks)++; \ | |||
} \ | |||
*(pdwReg) = (uint16_t)((wNBlocks) << 10); \ | |||
} while(0) /* PCD_CALC_BLK2 */ | |||
#define PCD_SET_EP_CNT_RX_REG(pdwReg, wCount) do { \ | |||
uint32_t wNBlocks; \ | |||
if ((wCount) == 0U) \ | |||
{ \ | |||
*(pdwReg) &= (uint16_t)~USB_CNTRX_NBLK_MSK; \ | |||
*(pdwReg) |= USB_CNTRX_BLSIZE; \ | |||
} \ | |||
else if((wCount) < 62U) \ | |||
{ \ | |||
PCD_CALC_BLK2((pdwReg), (wCount), wNBlocks); \ | |||
} \ | |||
else \ | |||
{ \ | |||
PCD_CALC_BLK32((pdwReg),(wCount), wNBlocks); \ | |||
} \ | |||
} while(0) /* PCD_SET_EP_CNT_RX_REG */ | |||
#define PCD_SET_EP_RX_DBUF0_CNT(USBx, bEpNum, wCount) do { \ | |||
register uint32_t _wRegBase = (uint32_t)(USBx); \ | |||
uint16_t *pdwReg; \ | |||
\ | |||
_wRegBase += (uint32_t)(USBx)->BTABLE; \ | |||
pdwReg = (uint16_t *)(_wRegBase + 0x400U + ((((uint32_t)(bEpNum) * 8U) + 2U) * PMA_ACCESS)); \ | |||
PCD_SET_EP_CNT_RX_REG(pdwReg, (wCount)); \ | |||
} while(0) | |||
/** | |||
* @brief sets counter for the tx/rx buffer. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @param wCount Counter value. | |||
* @retval None | |||
*/ | |||
#define PCD_SET_EP_TX_CNT(USBx, bEpNum, wCount) do { \ | |||
register uint32_t _wRegBase = (uint32_t)(USBx); \ | |||
uint16_t *_wRegVal; \ | |||
\ | |||
_wRegBase += (uint32_t)(USBx)->BTABLE; \ | |||
_wRegVal = (uint16_t *)(_wRegBase + 0x400U + ((((uint32_t)(bEpNum) * 8U) + 2U) * PMA_ACCESS)); \ | |||
*_wRegVal = (uint16_t)(wCount); \ | |||
} while(0) | |||
#define PCD_SET_EP_RX_CNT(USBx, bEpNum, wCount) do { \ | |||
register uint32_t _wRegBase = (uint32_t)(USBx); \ | |||
uint16_t *_wRegVal; \ | |||
\ | |||
_wRegBase += (uint32_t)(USBx)->BTABLE; \ | |||
_wRegVal = (uint16_t *)(_wRegBase + 0x400U + ((((uint32_t)(bEpNum) * 8U) + 6U) * PMA_ACCESS)); \ | |||
PCD_SET_EP_CNT_RX_REG(_wRegVal, (wCount)); \ | |||
} while(0) | |||
/** | |||
* @brief gets counter of the tx buffer. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval Counter value | |||
*/ | |||
#define PCD_GET_EP_TX_CNT(USBx, bEpNum) ((uint32_t)(*PCD_EP_TX_CNT((USBx), (bEpNum))) & 0x3ffU) | |||
#define PCD_GET_EP_RX_CNT(USBx, bEpNum) ((uint32_t)(*PCD_EP_RX_CNT((USBx), (bEpNum))) & 0x3ffU) | |||
/** | |||
* @brief Sets buffer 0/1 address in a double buffer endpoint. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @param wBuf0Addr buffer 0 address. | |||
* @retval Counter value | |||
*/ | |||
#define PCD_SET_EP_DBUF0_ADDR(USBx, bEpNum, wBuf0Addr) do { \ | |||
PCD_SET_EP_TX_ADDRESS((USBx), (bEpNum), (wBuf0Addr)); \ | |||
} while(0) /* PCD_SET_EP_DBUF0_ADDR */ | |||
#define PCD_SET_EP_DBUF1_ADDR(USBx, bEpNum, wBuf1Addr) do { \ | |||
PCD_SET_EP_RX_ADDRESS((USBx), (bEpNum), (wBuf1Addr)); \ | |||
} while(0) /* PCD_SET_EP_DBUF1_ADDR */ | |||
/** | |||
* @brief Sets addresses in a double buffer endpoint. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @param wBuf0Addr: buffer 0 address. | |||
* @param wBuf1Addr = buffer 1 address. | |||
* @retval None | |||
*/ | |||
#define PCD_SET_EP_DBUF_ADDR(USBx, bEpNum, wBuf0Addr, wBuf1Addr) do { \ | |||
PCD_SET_EP_DBUF0_ADDR((USBx), (bEpNum), (wBuf0Addr)); \ | |||
PCD_SET_EP_DBUF1_ADDR((USBx), (bEpNum), (wBuf1Addr)); \ | |||
} while(0) /* PCD_SET_EP_DBUF_ADDR */ | |||
/** | |||
* @brief Gets buffer 0/1 address of a double buffer endpoint. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval None | |||
*/ | |||
#define PCD_GET_EP_DBUF0_ADDR(USBx, bEpNum) (PCD_GET_EP_TX_ADDRESS((USBx), (bEpNum))) | |||
#define PCD_GET_EP_DBUF1_ADDR(USBx, bEpNum) (PCD_GET_EP_RX_ADDRESS((USBx), (bEpNum))) | |||
/** | |||
* @brief Gets buffer 0/1 address of a double buffer endpoint. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @param bDir endpoint dir EP_DBUF_OUT = OUT | |||
* EP_DBUF_IN = IN | |||
* @param wCount: Counter value | |||
* @retval None | |||
*/ | |||
#define PCD_SET_EP_DBUF0_CNT(USBx, bEpNum, bDir, wCount) do { \ | |||
if ((bDir) == 0U) \ | |||
/* OUT endpoint */ \ | |||
{ \ | |||
PCD_SET_EP_RX_DBUF0_CNT((USBx), (bEpNum), (wCount)); \ | |||
} \ | |||
else \ | |||
{ \ | |||
if ((bDir) == 1U) \ | |||
{ \ | |||
/* IN endpoint */ \ | |||
PCD_SET_EP_TX_CNT((USBx), (bEpNum), (wCount)); \ | |||
} \ | |||
} \ | |||
} while(0) /* SetEPDblBuf0Count*/ | |||
#define PCD_SET_EP_DBUF1_CNT(USBx, bEpNum, bDir, wCount) do { \ | |||
register uint32_t _wBase = (uint32_t)(USBx); \ | |||
uint16_t *_wEPRegVal; \ | |||
\ | |||
if ((bDir) == 0U) \ | |||
{ \ | |||
/* OUT endpoint */ \ | |||
PCD_SET_EP_RX_CNT((USBx), (bEpNum), (wCount)); \ | |||
} \ | |||
else \ | |||
{ \ | |||
if ((bDir) == 1U) \ | |||
{ \ | |||
/* IN endpoint */ \ | |||
_wBase += (uint32_t)(USBx)->BTABLE; \ | |||
_wEPRegVal = (uint16_t *)(_wBase + 0x400U + ((((uint32_t)(bEpNum) * 8U) + 6U) * PMA_ACCESS)); \ | |||
*_wEPRegVal = (uint16_t)(wCount); \ | |||
} \ | |||
} \ | |||
} while(0) /* SetEPDblBuf1Count */ | |||
#define PCD_SET_EP_DBUF_CNT(USBx, bEpNum, bDir, wCount) do { \ | |||
PCD_SET_EP_DBUF0_CNT((USBx), (bEpNum), (bDir), (wCount)); \ | |||
PCD_SET_EP_DBUF1_CNT((USBx), (bEpNum), (bDir), (wCount)); \ | |||
} while(0) /* PCD_SET_EP_DBUF_CNT */ | |||
/** | |||
* @brief Gets buffer 0/1 rx/tx counter for double buffering. | |||
* @param USBx USB peripheral instance register address. | |||
* @param bEpNum Endpoint Number. | |||
* @retval None | |||
*/ | |||
#define PCD_GET_EP_DBUF0_CNT(USBx, bEpNum) (PCD_GET_EP_TX_CNT((USBx), (bEpNum))) | |||
#define PCD_GET_EP_DBUF1_CNT(USBx, bEpNum) (PCD_GET_EP_RX_CNT((USBx), (bEpNum))) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* defined (USB) */ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_PCD_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,93 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_pcd_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of PCD HAL Extension module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_PCD_EX_H | |||
#define STM32WBxx_HAL_PCD_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
#if defined (USB) | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup PCDEx | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, | |||
uint16_t ep_addr, | |||
uint16_t ep_kind, | |||
uint32_t pmaadress); | |||
HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd); | |||
HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd); | |||
HAL_StatusTypeDef HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef *hpcd); | |||
HAL_StatusTypeDef HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef *hpcd); | |||
void HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef *hpcd); | |||
void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); | |||
void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* defined (USB) */ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_PCD_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,558 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_pka.h | |||
* @author MCD Application Team | |||
* @brief Header file of PKA HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_PKA_H | |||
#define STM32WBxx_HAL_PKA_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
#if defined(PKA) && defined(HAL_PKA_MODULE_ENABLED) | |||
/** @addtogroup PKA | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup PKA_Exported_Types PKA Exported Types | |||
* @{ | |||
*/ | |||
/** @defgroup HAL_state_structure_definition HAL state structure definition | |||
* @brief HAL State structures definition | |||
* @{ | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_PKA_STATE_RESET = 0x00U, /*!< PKA not yet initialized or disabled */ | |||
HAL_PKA_STATE_READY = 0x01U, /*!< PKA initialized and ready for use */ | |||
HAL_PKA_STATE_BUSY = 0x02U, /*!< PKA internal processing is ongoing */ | |||
HAL_PKA_STATE_ERROR = 0x03U, /*!< PKA error state */ | |||
} | |||
HAL_PKA_StateTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
#if (USE_HAL_PKA_REGISTER_CALLBACKS == 1) | |||
/** @defgroup HAL_callback_id HAL callback ID enumeration | |||
* @{ | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_PKA_OPERATION_COMPLETE_CB_ID = 0x00U, /*!< PKA End of operation callback ID */ | |||
HAL_PKA_ERROR_CB_ID = 0x01U, /*!< PKA Error callback ID */ | |||
HAL_PKA_MSPINIT_CB_ID = 0x02U, /*!< PKA Msp Init callback ID */ | |||
HAL_PKA_MSPDEINIT_CB_ID = 0x03U /*!< PKA Msp DeInit callback ID */ | |||
} HAL_PKA_CallbackIDTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
#endif /* USE_HAL_PKA_REGISTER_CALLBACKS */ | |||
/** @defgroup PKA_Error_Code_definition PKA Error Code definition | |||
* @brief PKA Error Code definition | |||
* @{ | |||
*/ | |||
#define HAL_PKA_ERROR_NONE (0x00000000U) | |||
#define HAL_PKA_ERROR_ADDRERR (0x00000001U) | |||
#define HAL_PKA_ERROR_RAMERR (0x00000002U) | |||
#define HAL_PKA_ERROR_TIMEOUT (0x00000004U) | |||
#define HAL_PKA_ERROR_OPERATION (0x00000008U) | |||
#if (USE_HAL_PKA_REGISTER_CALLBACKS == 1) | |||
#define HAL_PKA_ERROR_INVALID_CALLBACK (0x00000010U) /*!< Invalid Callback error */ | |||
#endif /* USE_HAL_PKA_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PKA_handle_Structure_definition PKA handle Structure definition | |||
* @brief PKA handle Structure definition | |||
* @{ | |||
*/ | |||
typedef struct __PKA_HandleTypeDef | |||
{ | |||
PKA_TypeDef *Instance; /*!< Register base address */ | |||
__IO HAL_PKA_StateTypeDef State; /*!< PKA state */ | |||
__IO uint32_t ErrorCode; /*!< PKA Error code */ | |||
#if (USE_HAL_PKA_REGISTER_CALLBACKS == 1) | |||
void (* OperationCpltCallback)(struct __PKA_HandleTypeDef *hpka); /*!< PKA End of operation callback */ | |||
void (* ErrorCallback)(struct __PKA_HandleTypeDef *hpka); /*!< PKA Error callback */ | |||
void (* MspInitCallback)(struct __PKA_HandleTypeDef *hpka); /*!< PKA Msp Init callback */ | |||
void (* MspDeInitCallback)(struct __PKA_HandleTypeDef *hpka); /*!< PKA Msp DeInit callback */ | |||
#endif /* USE_HAL_PKA_REGISTER_CALLBACKS */ | |||
} PKA_HandleTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
#if (USE_HAL_PKA_REGISTER_CALLBACKS == 1) | |||
/** @defgroup PKA_Callback_definition PKA Callback pointer definition | |||
* @brief PKA Callback pointer definition | |||
* @{ | |||
*/ | |||
typedef void (*pPKA_CallbackTypeDef)(PKA_HandleTypeDef *hpka); /*!< Pointer to a PKA callback function */ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* USE_HAL_PKA_REGISTER_CALLBACKS */ | |||
/** @defgroup PKA_Operation PKA operation structure definition | |||
* @brief Input and output data definition | |||
* @{ | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t scalarMulSize; /*!< Number of element in scalarMul array */ | |||
uint32_t modulusSize; /*!< Number of element in modulus, coefA, pointX and pointY arrays */ | |||
uint32_t coefSign; /*!< Curve coefficient a sign */ | |||
const uint8_t *coefA; /*!< Pointer to curve coefficient |a| (Array of modulusSize elements) */ | |||
const uint8_t *modulus; /*!< Pointer to curve modulus value p (Array of modulusSize elements) */ | |||
const uint8_t *pointX; /*!< Pointer to point P coordinate xP (Array of modulusSize elements) */ | |||
const uint8_t *pointY; /*!< Pointer to point P coordinate yP (Array of modulusSize elements) */ | |||
const uint8_t *scalarMul; /*!< Pointer to scalar multiplier k (Array of scalarMulSize elements) */ | |||
const uint32_t *pMontgomeryParam; /*!< Pointer to Montgomery parameter (Array of modulusSize/4 elements) */ | |||
} PKA_ECCMulFastModeInTypeDef; | |||
typedef struct | |||
{ | |||
uint32_t scalarMulSize; /*!< Number of element in scalarMul array */ | |||
uint32_t modulusSize; /*!< Number of element in modulus, coefA, pointX and pointY arrays */ | |||
uint32_t coefSign; /*!< Curve coefficient a sign */ | |||
const uint8_t *coefA; /*!< Pointer to curve coefficient |a| (Array of modulusSize elements) */ | |||
const uint8_t *modulus; /*!< Pointer to curve modulus value p (Array of modulusSize elements) */ | |||
const uint8_t *pointX; /*!< Pointer to point P coordinate xP (Array of modulusSize elements) */ | |||
const uint8_t *pointY; /*!< Pointer to point P coordinate yP (Array of modulusSize elements) */ | |||
const uint8_t *scalarMul; /*!< Pointer to scalar multiplier k (Array of scalarMulSize elements) */ | |||
} PKA_ECCMulInTypeDef; | |||
typedef struct | |||
{ | |||
uint32_t modulusSize; /*!< Number of element in coefA, coefB, modulus, pointX and pointY arrays */ | |||
uint32_t coefSign; /*!< Curve coefficient a sign */ | |||
const uint8_t *coefA; /*!< Pointer to curve coefficient |a| (Array of modulusSize elements) */ | |||
const uint8_t *coefB; /*!< Pointer to curve coefficient b (Array of modulusSize elements) */ | |||
const uint8_t *modulus; /*!< Pointer to curve modulus value p (Array of modulusSize elements) */ | |||
const uint8_t *pointX; /*!< Pointer to point P coordinate xP (Array of modulusSize elements) */ | |||
const uint8_t *pointY; /*!< Pointer to point P coordinate yP (Array of modulusSize elements) */ | |||
} PKA_PointCheckInTypeDef; | |||
typedef struct | |||
{ | |||
uint32_t size; /*!< Number of element in popA array */ | |||
const uint8_t *pOpDp; /*!< Pointer to operand dP (Array of size/2 elements) */ | |||
const uint8_t *pOpDq; /*!< Pointer to operand dQ (Array of size/2 elements) */ | |||
const uint8_t *pOpQinv; /*!< Pointer to operand qinv (Array of size/2 elements) */ | |||
const uint8_t *pPrimeP; /*!< Pointer to prime p (Array of size/2 elements) */ | |||
const uint8_t *pPrimeQ; /*!< Pointer to prime Q (Array of size/2 elements) */ | |||
const uint8_t *popA; /*!< Pointer to operand A (Array of size elements) */ | |||
} PKA_RSACRTExpInTypeDef; | |||
typedef struct | |||
{ | |||
uint32_t primeOrderSize; /*!< Number of element in primeOrder array */ | |||
uint32_t modulusSize; /*!< Number of element in modulus array */ | |||
uint32_t coefSign; /*!< Curve coefficient a sign */ | |||
const uint8_t *coef; /*!< Pointer to curve coefficient |a| (Array of modulusSize elements) */ | |||
const uint8_t *modulus; /*!< Pointer to curve modulus value p (Array of modulusSize elements) */ | |||
const uint8_t *basePointX; /*!< Pointer to curve base point xG (Array of modulusSize elements) */ | |||
const uint8_t *basePointY; /*!< Pointer to curve base point yG (Array of modulusSize elements) */ | |||
const uint8_t *pPubKeyCurvePtX; /*!< Pointer to public-key curve point xQ (Array of modulusSize elements) */ | |||
const uint8_t *pPubKeyCurvePtY; /*!< Pointer to public-key curve point yQ (Array of modulusSize elements) */ | |||
const uint8_t *RSign; /*!< Pointer to signature part r (Array of primeOrderSize elements) */ | |||
const uint8_t *SSign; /*!< Pointer to signature part s (Array of primeOrderSize elements) */ | |||
const uint8_t *hash; /*!< Pointer to hash of the message e (Array of primeOrderSize elements) */ | |||
const uint8_t *primeOrder; /*!< Pointer to order of the curve n (Array of primeOrderSize elements) */ | |||
} PKA_ECDSAVerifInTypeDef; | |||
typedef struct | |||
{ | |||
uint32_t primeOrderSize; /*!< Number of element in primeOrder array */ | |||
uint32_t modulusSize; /*!< Number of element in modulus array */ | |||
uint32_t coefSign; /*!< Curve coefficient a sign */ | |||
const uint8_t *coef; /*!< Pointer to curve coefficient |a| (Array of modulusSize elements) */ | |||
const uint8_t *modulus; /*!< Pointer to curve modulus value p (Array of modulusSize elements) */ | |||
const uint8_t *integer; /*!< Pointer to random integer k (Array of primeOrderSize elements) */ | |||
const uint8_t *basePointX; /*!< Pointer to curve base point xG (Array of modulusSize elements) */ | |||
const uint8_t *basePointY; /*!< Pointer to curve base point yG (Array of modulusSize elements) */ | |||
const uint8_t *hash; /*!< Pointer to hash of the message (Array of primeOrderSize elements) */ | |||
const uint8_t *privateKey; /*!< Pointer to private key d (Array of primeOrderSize elements) */ | |||
const uint8_t *primeOrder; /*!< Pointer to order of the curve n (Array of primeOrderSize elements) */ | |||
} PKA_ECDSASignInTypeDef; | |||
typedef struct | |||
{ | |||
uint8_t *RSign; /*!< Pointer to signature part r (Array of modulusSize elements) */ | |||
uint8_t *SSign; /*!< Pointer to signature part s (Array of modulusSize elements) */ | |||
} PKA_ECDSASignOutTypeDef; | |||
typedef struct | |||
{ | |||
uint8_t *ptX; /*!< Pointer to point P coordinate xP (Array of modulusSize elements) */ | |||
uint8_t *ptY; /*!< Pointer to point P coordinate yP (Array of modulusSize elements) */ | |||
} PKA_ECDSASignOutExtParamTypeDef, PKA_ECCMulOutTypeDef; | |||
typedef struct | |||
{ | |||
uint32_t expSize; /*!< Number of element in pExp array */ | |||
uint32_t OpSize; /*!< Number of element in pOp1 and pMod arrays */ | |||
const uint8_t *pExp; /*!< Pointer to Exponent (Array of expSize elements) */ | |||
const uint8_t *pOp1; /*!< Pointer to Operand (Array of OpSize elements) */ | |||
const uint8_t *pMod; /*!< Pointer to modulus (Array of OpSize elements) */ | |||
} PKA_ModExpInTypeDef; | |||
typedef struct | |||
{ | |||
uint32_t expSize; /*!< Number of element in pExp and pMontgomeryParam arrays */ | |||
uint32_t OpSize; /*!< Number of element in pOp1 and pMod arrays */ | |||
const uint8_t *pExp; /*!< Pointer to Exponent (Array of expSize elements) */ | |||
const uint8_t *pOp1; /*!< Pointer to Operand (Array of OpSize elements) */ | |||
const uint8_t *pMod; /*!< Pointer to modulus (Array of OpSize elements) */ | |||
const uint32_t *pMontgomeryParam; /*!< Pointer to Montgomery parameter (Array of expSize/4 elements) */ | |||
} PKA_ModExpFastModeInTypeDef; | |||
typedef struct | |||
{ | |||
uint32_t size; /*!< Number of element in pOp1 array */ | |||
const uint8_t *pOp1; /*!< Pointer to Operand (Array of size elements) */ | |||
} PKA_MontgomeryParamInTypeDef; | |||
typedef struct | |||
{ | |||
uint32_t size; /*!< Number of element in pOp1 and pOp2 arrays */ | |||
const uint32_t *pOp1; /*!< Pointer to Operand 1 (Array of size elements) */ | |||
const uint32_t *pOp2; /*!< Pointer to Operand 2 (Array of size elements) */ | |||
} PKA_AddInTypeDef, PKA_SubInTypeDef, PKA_MulInTypeDef, PKA_CmpInTypeDef; | |||
typedef struct | |||
{ | |||
uint32_t size; /*!< Number of element in pOp1 array */ | |||
const uint32_t *pOp1; /*!< Pointer to Operand 1 (Array of size elements) */ | |||
const uint8_t *pMod; /*!< Pointer to modulus value n (Array of size*4 elements) */ | |||
} PKA_ModInvInTypeDef; | |||
typedef struct | |||
{ | |||
uint32_t OpSize; /*!< Number of element in pOp1 array */ | |||
uint32_t modSize; /*!< Number of element in pMod array */ | |||
const uint32_t *pOp1; /*!< Pointer to Operand 1 (Array of OpSize elements) */ | |||
const uint8_t *pMod; /*!< Pointer to modulus value n (Array of modSize elements) */ | |||
} PKA_ModRedInTypeDef; | |||
typedef struct | |||
{ | |||
uint32_t size; /*!< Number of element in pOp1 and pOp2 arrays */ | |||
const uint32_t *pOp1; /*!< Pointer to Operand 1 (Array of size elements) */ | |||
const uint32_t *pOp2; /*!< Pointer to Operand 2 (Array of size elements) */ | |||
const uint8_t *pOp3; /*!< Pointer to Operand 3 (Array of size*4 elements) */ | |||
} PKA_ModAddInTypeDef, PKA_ModSubInTypeDef, PKA_MontgomeryMulInTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup PKA_Exported_Constants PKA Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup PKA_Mode PKA mode | |||
* @{ | |||
*/ | |||
#define PKA_MODE_MONTGOMERY_PARAM (0x00000001U) | |||
#define PKA_MODE_MODULAR_EXP (0x00000000U) | |||
#define PKA_MODE_MODULAR_EXP_FAST_MODE (0x00000002U) | |||
#define PKA_MODE_ECC_MUL (0x00000020U) | |||
#define PKA_MODE_ECC_MUL_FAST_MODE (0x00000022U) | |||
#define PKA_MODE_ECDSA_SIGNATURE (0x00000024U) | |||
#define PKA_MODE_ECDSA_VERIFICATION (0x00000026U) | |||
#define PKA_MODE_POINT_CHECK (0x00000028U) | |||
#define PKA_MODE_RSA_CRT_EXP (0x00000007U) | |||
#define PKA_MODE_MODULAR_INV (0x00000008U) | |||
#define PKA_MODE_ARITHMETIC_ADD (0x00000009U) | |||
#define PKA_MODE_ARITHMETIC_SUB (0x0000000AU) | |||
#define PKA_MODE_ARITHMETIC_MUL (0x0000000BU) | |||
#define PKA_MODE_COMPARISON (0x0000000CU) | |||
#define PKA_MODE_MODULAR_RED (0x0000000DU) | |||
#define PKA_MODE_MODULAR_ADD (0x0000000EU) | |||
#define PKA_MODE_MODULAR_SUB (0x0000000FU) | |||
#define PKA_MODE_MONTGOMERY_MUL (0x00000010U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PKA_Interrupt_configuration_definition PKA Interrupt configuration definition | |||
* @brief PKA Interrupt definition | |||
* @{ | |||
*/ | |||
#define PKA_IT_PROCEND PKA_CR_PROCENDIE | |||
#define PKA_IT_ADDRERR PKA_CR_ADDRERRIE | |||
#define PKA_IT_RAMERR PKA_CR_RAMERRIE | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PKA_Flag_definition PKA Flag definition | |||
* @{ | |||
*/ | |||
#define PKA_FLAG_PROCEND PKA_SR_PROCENDF | |||
#define PKA_FLAG_ADDRERR PKA_SR_ADDRERRF | |||
#define PKA_FLAG_RAMERR PKA_SR_RAMERRF | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup PKA_Exported_Macros PKA Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset PKA handle state. | |||
* @param __HANDLE__ specifies the PKA Handle | |||
* @retval None | |||
*/ | |||
#if (USE_HAL_PKA_REGISTER_CALLBACKS == 1) | |||
#define __HAL_PKA_RESET_HANDLE_STATE(__HANDLE__) do{ \ | |||
(__HANDLE__)->State = HAL_PKA_STATE_RESET; \ | |||
(__HANDLE__)->MspInitCallback = NULL; \ | |||
(__HANDLE__)->MspDeInitCallback = NULL; \ | |||
} while(0) | |||
#else | |||
#define __HAL_PKA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_PKA_STATE_RESET) | |||
#endif | |||
/** @brief Enable the specified PKA interrupt. | |||
* @param __HANDLE__ specifies the PKA Handle | |||
* @param __INTERRUPT__ specifies the interrupt source to enable. | |||
* This parameter can be one of the following values: | |||
* @arg @ref PKA_IT_PROCEND End Of Operation interrupt enable | |||
* @arg @ref PKA_IT_ADDRERR Address error interrupt enable | |||
* @arg @ref PKA_IT_RAMERR RAM error interrupt enable | |||
* @retval None | |||
*/ | |||
#define __HAL_PKA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) | |||
/** @brief Disable the specified PKA interrupt. | |||
* @param __HANDLE__ specifies the PKA Handle | |||
* @param __INTERRUPT__ specifies the interrupt source to disable. | |||
* This parameter can be one of the following values: | |||
* @arg @ref PKA_IT_PROCEND End Of Operation interrupt enable | |||
* @arg @ref PKA_IT_ADDRERR Address error interrupt enable | |||
* @arg @ref PKA_IT_RAMERR RAM error interrupt enable | |||
* @retval None | |||
*/ | |||
#define __HAL_PKA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= (~(__INTERRUPT__))) | |||
/** @brief Check whether the specified PKA interrupt source is enabled or not. | |||
* @param __HANDLE__ specifies the PKA Handle | |||
* @param __INTERRUPT__ specifies the PKA interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref PKA_IT_PROCEND End Of Operation interrupt enable | |||
* @arg @ref PKA_IT_ADDRERR Address error interrupt enable | |||
* @arg @ref PKA_IT_RAMERR RAM error interrupt enable | |||
* @retval The new state of __INTERRUPT__ (SET or RESET) | |||
*/ | |||
#define __HAL_PKA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
/** @brief Check whether the specified PKA flag is set or not. | |||
* @param __HANDLE__ specifies the PKA Handle | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref PKA_FLAG_PROCEND End Of Operation | |||
* @arg @ref PKA_FLAG_ADDRERR Address error | |||
* @arg @ref PKA_FLAG_RAMERR RAM error | |||
* @retval The new state of __FLAG__ (SET or RESET) | |||
*/ | |||
#define __HAL_PKA_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) ? SET : RESET) | |||
/** @brief Clear the PKA pending flags which are cleared by writing 1 in a specific bit. | |||
* @param __HANDLE__ specifies the PKA Handle | |||
* @param __FLAG__ specifies the flag to clear. | |||
* This parameter can be any combination of the following values: | |||
* @arg @ref PKA_FLAG_PROCEND End Of Operation | |||
* @arg @ref PKA_FLAG_ADDRERR Address error | |||
* @arg @ref PKA_FLAG_RAMERR RAM error | |||
* @retval None | |||
*/ | |||
#define __HAL_PKA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CLRFR = (__FLAG__)) | |||
/** @brief Enable the specified PKA peripheral. | |||
* @param __HANDLE__ specifies the PKA Handle | |||
* @retval None | |||
*/ | |||
#define __HAL_PKA_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR, PKA_CR_EN)) | |||
/** @brief Disable the specified PKA peripheral. | |||
* @param __HANDLE__ specifies the PKA Handle | |||
* @retval None | |||
*/ | |||
#define __HAL_PKA_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR, PKA_CR_EN)) | |||
/** @brief Start a PKA operation. | |||
* @param __HANDLE__ specifies the PKA Handle | |||
* @retval None | |||
*/ | |||
#define __HAL_PKA_START(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR, PKA_CR_START)) | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros --------------------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup PKA_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup PKA_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions *****************************/ | |||
HAL_StatusTypeDef HAL_PKA_Init(PKA_HandleTypeDef *hpka); | |||
HAL_StatusTypeDef HAL_PKA_DeInit(PKA_HandleTypeDef *hpka); | |||
void HAL_PKA_MspInit(PKA_HandleTypeDef *hpka); | |||
void HAL_PKA_MspDeInit(PKA_HandleTypeDef *hpka); | |||
#if (USE_HAL_PKA_REGISTER_CALLBACKS == 1) | |||
/* Callbacks Register/UnRegister functions ***********************************/ | |||
HAL_StatusTypeDef HAL_PKA_RegisterCallback(PKA_HandleTypeDef *hpka, HAL_PKA_CallbackIDTypeDef CallbackID, pPKA_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_PKA_UnRegisterCallback(PKA_HandleTypeDef *hpka, HAL_PKA_CallbackIDTypeDef CallbackID); | |||
#endif /* USE_HAL_PKA_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup PKA_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
/* High Level Functions *******************************************************/ | |||
HAL_StatusTypeDef HAL_PKA_ModExp(PKA_HandleTypeDef *hpka, PKA_ModExpInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_ModExp_IT(PKA_HandleTypeDef *hpka, PKA_ModExpInTypeDef *in); | |||
HAL_StatusTypeDef HAL_PKA_ModExpFastMode(PKA_HandleTypeDef *hpka, PKA_ModExpFastModeInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_ModExpFastMode_IT(PKA_HandleTypeDef *hpka, PKA_ModExpFastModeInTypeDef *in); | |||
void HAL_PKA_ModExp_GetResult(PKA_HandleTypeDef *hpka, uint8_t *pRes); | |||
HAL_StatusTypeDef HAL_PKA_ECDSASign(PKA_HandleTypeDef *hpka, PKA_ECDSASignInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_ECDSASign_IT(PKA_HandleTypeDef *hpka, PKA_ECDSASignInTypeDef *in); | |||
void HAL_PKA_ECDSASign_GetResult(PKA_HandleTypeDef *hpka, PKA_ECDSASignOutTypeDef *out, PKA_ECDSASignOutExtParamTypeDef *outExt); | |||
HAL_StatusTypeDef HAL_PKA_ECDSAVerif(PKA_HandleTypeDef *hpka, PKA_ECDSAVerifInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_ECDSAVerif_IT(PKA_HandleTypeDef *hpka, PKA_ECDSAVerifInTypeDef *in); | |||
uint32_t HAL_PKA_ECDSAVerif_IsValidSignature(PKA_HandleTypeDef const *const hpka); | |||
HAL_StatusTypeDef HAL_PKA_RSACRTExp(PKA_HandleTypeDef *hpka, PKA_RSACRTExpInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_RSACRTExp_IT(PKA_HandleTypeDef *hpka, PKA_RSACRTExpInTypeDef *in); | |||
void HAL_PKA_RSACRTExp_GetResult(PKA_HandleTypeDef *hpka, uint8_t *pRes); | |||
HAL_StatusTypeDef HAL_PKA_PointCheck(PKA_HandleTypeDef *hpka, PKA_PointCheckInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_PointCheck_IT(PKA_HandleTypeDef *hpka, PKA_PointCheckInTypeDef *in); | |||
uint32_t HAL_PKA_PointCheck_IsOnCurve(PKA_HandleTypeDef const *const hpka); | |||
HAL_StatusTypeDef HAL_PKA_ECCMul(PKA_HandleTypeDef *hpka, PKA_ECCMulInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_ECCMul_IT(PKA_HandleTypeDef *hpka, PKA_ECCMulInTypeDef *in); | |||
HAL_StatusTypeDef HAL_PKA_ECCMulFastMode(PKA_HandleTypeDef *hpka, PKA_ECCMulFastModeInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_ECCMulFastMode_IT(PKA_HandleTypeDef *hpka, PKA_ECCMulFastModeInTypeDef *in); | |||
void HAL_PKA_ECCMul_GetResult(PKA_HandleTypeDef *hpka, PKA_ECCMulOutTypeDef *out); | |||
HAL_StatusTypeDef HAL_PKA_Add(PKA_HandleTypeDef *hpka, PKA_AddInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_Add_IT(PKA_HandleTypeDef *hpka, PKA_AddInTypeDef *in); | |||
HAL_StatusTypeDef HAL_PKA_Sub(PKA_HandleTypeDef *hpka, PKA_SubInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_Sub_IT(PKA_HandleTypeDef *hpka, PKA_SubInTypeDef *in); | |||
HAL_StatusTypeDef HAL_PKA_Cmp(PKA_HandleTypeDef *hpka, PKA_CmpInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_Cmp_IT(PKA_HandleTypeDef *hpka, PKA_CmpInTypeDef *in); | |||
HAL_StatusTypeDef HAL_PKA_Mul(PKA_HandleTypeDef *hpka, PKA_MulInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_Mul_IT(PKA_HandleTypeDef *hpka, PKA_MulInTypeDef *in); | |||
HAL_StatusTypeDef HAL_PKA_ModAdd(PKA_HandleTypeDef *hpka, PKA_ModAddInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_ModAdd_IT(PKA_HandleTypeDef *hpka, PKA_ModAddInTypeDef *in); | |||
HAL_StatusTypeDef HAL_PKA_ModSub(PKA_HandleTypeDef *hpka, PKA_ModSubInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_ModSub_IT(PKA_HandleTypeDef *hpka, PKA_ModSubInTypeDef *in); | |||
HAL_StatusTypeDef HAL_PKA_ModInv(PKA_HandleTypeDef *hpka, PKA_ModInvInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_ModInv_IT(PKA_HandleTypeDef *hpka, PKA_ModInvInTypeDef *in); | |||
HAL_StatusTypeDef HAL_PKA_ModRed(PKA_HandleTypeDef *hpka, PKA_ModRedInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_ModRed_IT(PKA_HandleTypeDef *hpka, PKA_ModRedInTypeDef *in); | |||
HAL_StatusTypeDef HAL_PKA_MontgomeryMul(PKA_HandleTypeDef *hpka, PKA_MontgomeryMulInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_MontgomeryMul_IT(PKA_HandleTypeDef *hpka, PKA_MontgomeryMulInTypeDef *in); | |||
void HAL_PKA_Arithmetic_GetResult(PKA_HandleTypeDef *hpka, uint32_t *pRes); | |||
HAL_StatusTypeDef HAL_PKA_MontgomeryParam(PKA_HandleTypeDef *hpka, PKA_MontgomeryParamInTypeDef *in, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_PKA_MontgomeryParam_IT(PKA_HandleTypeDef *hpka, PKA_MontgomeryParamInTypeDef *in); | |||
void HAL_PKA_MontgomeryParam_GetResult(PKA_HandleTypeDef *hpka, uint32_t *pRes); | |||
HAL_StatusTypeDef HAL_PKA_Abort(PKA_HandleTypeDef *hpka); | |||
void HAL_PKA_RAMReset(PKA_HandleTypeDef *hpka); | |||
void HAL_PKA_OperationCpltCallback(PKA_HandleTypeDef *hpka); | |||
void HAL_PKA_ErrorCallback(PKA_HandleTypeDef *hpka); | |||
void HAL_PKA_IRQHandler(PKA_HandleTypeDef *hpka); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup PKA_Exported_Functions_Group3 | |||
* @{ | |||
*/ | |||
/* Peripheral State and Error functions ***************************************/ | |||
HAL_PKA_StateTypeDef HAL_PKA_GetState(PKA_HandleTypeDef *hpka); | |||
uint32_t HAL_PKA_GetError(PKA_HandleTypeDef *hpka); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* defined(PKA) && defined(HAL_PKA_MODULE_ENABLED) */ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_PKA_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,498 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_pwr.h | |||
* @author MCD Application Team | |||
* @brief Header file of PWR HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_PWR_H | |||
#define STM32WBxx_HAL_PWR_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/* Include low level driver */ | |||
#include "stm32wbxx_ll_pwr.h" | |||
#include "stm32wbxx_ll_exti.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup PWR PWR | |||
* @brief PWR HAL module driver | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup PWR_Exported_Types PWR Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief PWR PVD configuration structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level. | |||
This parameter can be a value of @ref PWR_PVD_detection_level. */ | |||
uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins. | |||
This parameter can be a value of @ref PWR_PVD_Mode. */ | |||
}PWR_PVDTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup PWR_Exported_Constants PWR Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup PWR_PVD_detection_level Power Voltage Detector Level selection | |||
* @note Refer datasheet for selection voltage value | |||
* @{ | |||
*/ | |||
#define PWR_PVDLEVEL_0 (0x00000000U) /*!< PVD threshold around 2.0 V */ | |||
#define PWR_PVDLEVEL_1 ( PWR_CR2_PLS_0) /*!< PVD threshold around 2.2 V */ | |||
#define PWR_PVDLEVEL_2 ( PWR_CR2_PLS_1 ) /*!< PVD threshold around 2.4 V */ | |||
#define PWR_PVDLEVEL_3 ( PWR_CR2_PLS_1 | PWR_CR2_PLS_0) /*!< PVD threshold around 2.5 V */ | |||
#define PWR_PVDLEVEL_4 (PWR_CR2_PLS_2 ) /*!< PVD threshold around 2.6 V */ | |||
#define PWR_PVDLEVEL_5 (PWR_CR2_PLS_2 | PWR_CR2_PLS_0) /*!< PVD threshold around 2.8 V */ | |||
#define PWR_PVDLEVEL_6 (PWR_CR2_PLS_2 | PWR_CR2_PLS_1 ) /*!< PVD threshold around 2.9 V */ | |||
#define PWR_PVDLEVEL_7 (PWR_CR2_PLS_2 | PWR_CR2_PLS_1 | PWR_CR2_PLS_0) /*!< External input analog voltage (compared internally to VREFINT) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWR_PVD_Mode PWR PVD interrupt and event mode | |||
* @{ | |||
*/ | |||
/* Note: On STM32WB serie, power PVD event is not available on AIEC lines */ | |||
/* (only interruption is available through AIEC line 16). */ | |||
#define PWR_PVD_MODE_NORMAL (0x00000000U) /*!< Basic mode is used */ | |||
#define PWR_PVD_MODE_IT_RISING (PVD_MODE_IT | PVD_RISING_EDGE) /*!< External Interrupt Mode with Rising edge trigger detection */ | |||
#define PWR_PVD_MODE_IT_FALLING (PVD_MODE_IT | PVD_FALLING_EDGE) /*!< External Interrupt Mode with Falling edge trigger detection */ | |||
#define PWR_PVD_MODE_IT_RISING_FALLING (PVD_MODE_IT | PVD_RISING_FALLING_EDGE) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ | |||
/** | |||
* @} | |||
*/ | |||
/* Note: On STM32WB serie, power PVD event is not available on AIEC lines */ | |||
/* (only interruption is available through AIEC line 16). */ | |||
/** @defgroup PWR_Low_Power_Mode_Selection PWR Low Power Mode Selection | |||
* @{ | |||
*/ | |||
#define PWR_LOWPOWERMODE_STOP0 (0x00000000u) /*!< Stop 0: stop mode with main regulator */ | |||
#define PWR_LOWPOWERMODE_STOP1 (PWR_CR1_LPMS_0) /*!< Stop 1: stop mode with low power regulator */ | |||
#define PWR_LOWPOWERMODE_STOP2 (PWR_CR1_LPMS_1) /*!< Stop 2: stop mode with low power regulator and VDD12I interruptible digital core domain supply OFF (less peripherals activated than low power mode stop 1 to reduce power consumption)*/ | |||
#define PWR_LOWPOWERMODE_STANDBY (PWR_CR1_LPMS_0 | PWR_CR1_LPMS_1) /*!< Standby mode */ | |||
#define PWR_LOWPOWERMODE_SHUTDOWN (PWR_CR1_LPMS_2) /*!< Shutdown mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWR_Regulator_state_in_SLEEP_STOP_mode PWR regulator mode | |||
* @{ | |||
*/ | |||
#define PWR_MAINREGULATOR_ON (0x00000000U) /*!< Regulator in main mode */ | |||
#define PWR_LOWPOWERREGULATOR_ON (PWR_CR1_LPR) /*!< Regulator in low-power mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry | |||
* @{ | |||
*/ | |||
#define PWR_SLEEPENTRY_WFI ((uint8_t)0x01) /*!< Wait For Interruption instruction to enter Sleep mode */ | |||
#define PWR_SLEEPENTRY_WFE ((uint8_t)0x02) /*!< Wait For Event instruction to enter Sleep mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWR_STOP_mode_entry PWR STOP mode entry | |||
* @{ | |||
*/ | |||
#define PWR_STOPENTRY_WFI ((uint8_t)0x01) /*!< Wait For Interruption instruction to enter Stop mode */ | |||
#define PWR_STOPENTRY_WFE ((uint8_t)0x02) /*!< Wait For Event instruction to enter Stop mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private define ------------------------------------------------------------*/ | |||
/** @defgroup PWR_Private_Defines PWR Private Defines | |||
* @{ | |||
*/ | |||
/** @defgroup PWR_PVD_EXTI_LINE PWR PVD external interrupt line | |||
* @{ | |||
*/ | |||
#define PWR_EXTI_LINE_PVD (LL_EXTI_LINE_16) /*!< External interrupt line 16 Connected to the PWR PVD */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWR_PVD_Mode_Mask PWR PVD Mode Mask | |||
* @{ | |||
*/ | |||
/* Note: On STM32WB serie, power PVD event is not available on AIEC lines */ | |||
/* (only interruption is available through AIEC line 16). */ | |||
#define PVD_MODE_IT (0x00010000U) /*!< Mask for interruption yielded by PVD threshold crossing */ | |||
#define PVD_RISING_EDGE (0x00000001U) /*!< Mask for rising edge set as PVD trigger */ | |||
#define PVD_FALLING_EDGE (0x00000002U) /*!< Mask for falling edge set as PVD trigger */ | |||
#define PVD_RISING_FALLING_EDGE (0x00000003U) /*!< Mask for rising and falling edges set as PVD trigger */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup PWR_Exported_Macros PWR Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Check whether or not a specific PWR flag is set. | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be one of the following values: | |||
* | |||
* /--------------------------------SR1-------------------------------/ | |||
* @arg @ref PWR_FLAG_WUF1 Wake Up Flag 1. Indicates that a wakeup event | |||
* was received from the WKUP pin 1. | |||
* @arg @ref PWR_FLAG_WUF2 Wake Up Flag 2. Indicates that a wakeup event | |||
* was received from the WKUP pin 2. | |||
* @arg @ref PWR_FLAG_WUF3 Wake Up Flag 3. Indicates that a wakeup event | |||
* was received from the WKUP pin 3. | |||
* @arg @ref PWR_FLAG_WUF4 Wake Up Flag 4. Indicates that a wakeup event | |||
* was received from the WKUP pin 4. | |||
* @arg @ref PWR_FLAG_WUF5 Wake Up Flag 5. Indicates that a wakeup event | |||
* was received from the WKUP pin 5. | |||
* | |||
* @arg @ref PWR_FLAG_BHWF BLE_Host WakeUp Flag | |||
* @arg @ref PWR_FLAG_FRCBYPI SMPS Forced in Bypass Interrupt Flag | |||
* @arg @ref PWR_FLAG_RFPHASEI Radio Phase Interrupt Flag | |||
* @arg @ref PWR_FLAG_BLEACTI BLE Activity Interrupt Flag | |||
* @arg @ref PWR_FLAG_802ACTI 802.15.4 Activity Interrupt Flag | |||
* @arg @ref PWR_FLAG_HOLDC2I CPU2 on-Hold Interrupt Flag | |||
* @arg @ref PWR_FLAG_WUFI Wake-Up Flag Internal. Set when a wakeup is detected on | |||
* the internal wakeup line. | |||
* | |||
* @arg @ref PWR_FLAG_SMPSRDYF SMPS Ready Flag | |||
* @arg @ref PWR_FLAG_SMPSBYPF SMPS Bypass Flag | |||
* | |||
* /--------------------------------SR2-------------------------------/ | |||
* @arg @ref PWR_FLAG_REGLPS Low Power Regulator Started. Indicates whether or not the | |||
* low-power regulator is ready. | |||
* @arg @ref PWR_FLAG_REGLPF Low Power Regulator Flag. Indicates whether the | |||
* regulator is ready in main mode or is in low-power mode. | |||
* | |||
* @arg @ref PWR_FLAG_VOSF Voltage Scaling Flag. Indicates whether the regulator is ready | |||
* in the selected voltage range or is still changing to the required voltage level. | |||
* @arg @ref PWR_FLAG_PVDO Power Voltage Detector Output. Indicates whether VDD voltage is | |||
* below or above the selected PVD threshold. | |||
* | |||
* @arg @ref PWR_FLAG_PVMO1 Peripheral Voltage Monitoring Output 1. Indicates whether VDDUSB voltage is | |||
* is below or above PVM1 threshold (applicable when USB feature is supported). | |||
* @arg @ref PWR_FLAG_PVMO3 Peripheral Voltage Monitoring Output 3. Indicates whether VDDA voltage is | |||
* is below or above PVM3 threshold. | |||
* | |||
* /----------------------------EXTSCR--------------------------/ | |||
* @arg @ref PWR_FLAG_STOP System Stop Flag for CPU1. | |||
* @arg @ref PWR_FLAG_SB System Standby Flag for CPU1. | |||
* | |||
* @arg @ref PWR_FLAG_C2STOP System Stop Flag for CPU2. | |||
* @arg @ref PWR_FLAG_C2SB System Standby Flag for CPU2. | |||
* | |||
* @arg @ref PWR_FLAG_CRITICAL_RF_PHASE Critical radio system phase flag. | |||
* | |||
* @arg @ref PWR_FLAG_C1DEEPSLEEP CPU1 DeepSleep Flag. | |||
* @arg @ref PWR_FLAG_C2DEEPSLEEP CPU2 DeepSleep Flag. | |||
* | |||
* @retval The new state of __FLAG__ (TRUE or FALSE). | |||
*/ | |||
#define __HAL_PWR_GET_FLAG(__FLAG__) ( ((((uint8_t)(__FLAG__)) >> 5U) == 1U) ?\ | |||
(PWR->SR1 & (1U << ((__FLAG__) & 31U))) :\ | |||
((((((uint8_t)(__FLAG__)) >> 5U) == 2U)) ?\ | |||
(PWR->SR2 & (1U << ((__FLAG__) & 31U))) :\ | |||
(PWR->EXTSCR & (1U << ((__FLAG__) & 31U))) ) ) | |||
/** @brief Clear a specific PWR flag. | |||
* @note Clearing of flags {PWR_FLAG_STOP, PWR_FLAG_SB} | |||
* and flags {PWR_FLAG_C2STOP, PWR_FLAG_C2SB} are grouped: | |||
* clearing of one flag also clears the other one. | |||
* @param __FLAG__ specifies the flag to clear. | |||
* This parameter can be one of the following values: | |||
* | |||
* /--------------------------------SCR (SRR)------------------------------/ | |||
* @arg @ref PWR_FLAG_WUF1 Wake Up Flag 1. Indicates that a wakeup event | |||
* was received from the WKUP pin 1. | |||
* @arg @ref PWR_FLAG_WUF2 Wake Up Flag 2. Indicates that a wakeup event | |||
* was received from the WKUP pin 2. | |||
* @arg @ref PWR_FLAG_WUF3 Wake Up Flag 3. Indicates that a wakeup event | |||
* was received from the WKUP pin 3. | |||
* @arg @ref PWR_FLAG_WUF4 Wake Up Flag 4. Indicates that a wakeup event | |||
* was received from the WKUP pin 4. | |||
* @arg @ref PWR_FLAG_WUF5 Wake Up Flag 5. Indicates that a wakeup event | |||
* was received from the WKUP pin 5. | |||
* @arg @ref PWR_FLAG_WU Encompasses all five Wake Up Flags. | |||
* | |||
* @arg @ref PWR_FLAG_BHWF Clear BLE_Host Wakeup Flag. | |||
* @arg @ref PWR_FLAG_FRCBYPI Clear SMPS Forced in Bypass Interrupt Flag. | |||
* @arg @ref PWR_FLAG_RFPHASEI RF Phase Interrupt Clear. | |||
* @arg @ref PWR_FLAG_BLEACTI BLE Activity Interrupt Clear. | |||
* @arg @ref PWR_FLAG_802ACTI 802.15.4. Activity Interrupt Clear. | |||
* @arg @ref PWR_FLAG_HOLDC2I CPU2 on-Hold Interrupt Clear. | |||
* | |||
* /----------------------------EXTSCR--------------------------/ | |||
* @arg @ref PWR_FLAG_STOP System Stop Flag for CPU1. | |||
* @arg @ref PWR_FLAG_SB System Standby Flag for CPU1. | |||
* | |||
* @arg @ref PWR_FLAG_C2STOP System Stop Flag for CPU2. | |||
* @arg @ref PWR_FLAG_C2SB System Standby Flag for CPU2. | |||
* | |||
* @arg @ref PWR_FLAG_CRITICAL_RF_PHASE RF phase Flag. | |||
* | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_CLEAR_FLAG(__FLAG__) ( ((((uint8_t)(__FLAG__)) >> 5U) == 1U) ?\ | |||
( (((uint8_t)(__FLAG__)) == PWR_FLAG_WU) ?\ | |||
(PWR->SCR = (__FLAG__)) : (PWR->SCR = (1U << ((__FLAG__) & 31U))) ) :\ | |||
( (((uint8_t)(__FLAG__)) == PWR_FLAG_CRITICAL_RF_PHASE) ?\ | |||
SET_BIT (PWR->EXTSCR, PWR_EXTSCR_CCRPF) : ( ((((uint8_t)((__FLAG__)) & 31U) <= PWR_EXTSCR_C1STOPF_Pos) ?\ | |||
SET_BIT (PWR->EXTSCR, PWR_EXTSCR_C1CSSF): SET_BIT (PWR->EXTSCR, PWR_EXTSCR_C2CSSF)) ) )) | |||
/** | |||
* @brief Enable the PVD Extended Interrupt C1 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVD_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(PWR_EXTI_LINE_PVD) | |||
/** | |||
* @brief Enable the PVD Extended Interrupt C2 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVD_EXTIC2_ENABLE_IT() LL_C2_EXTI_EnableIT_0_31(PWR_EXTI_LINE_PVD) | |||
/** | |||
* @brief Disable the PVD Extended Interrupt C1 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVD_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(PWR_EXTI_LINE_PVD) | |||
/** | |||
* @brief Disable the PVD Extended Interrupt C2 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVD_EXTIC2_DISABLE_IT() LL_C2_EXTI_DisableIT_0_31(PWR_EXTI_LINE_PVD) | |||
/* Note: On STM32WB serie, power PVD event is not available on AIEC lines */ | |||
/* (only interruption is available through AIEC line 16). */ | |||
/** | |||
* @brief Enable the PVD Extended Interrupt Rising Trigger. | |||
* @note PVD flag polarity is inverted compared to EXTI line, therefore | |||
* EXTI rising and falling logic edges are inverted versus PVD voltage edges. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(PWR_EXTI_LINE_PVD) | |||
/** | |||
* @brief Disable the PVD Extended Interrupt Rising Trigger. | |||
* @note PVD flag polarity is inverted compared to EXTI line, therefore | |||
* EXTI rising and falling logic edges are inverted versus PVD voltage edges. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableFallingTrig_0_31(PWR_EXTI_LINE_PVD) | |||
/** | |||
* @brief Enable the PVD Extended Interrupt Falling Trigger. | |||
* @note PVD flag polarity is inverted compared to EXTI line, therefore | |||
* EXTI rising and falling logic edges are inverted versus PVD voltage edges. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(PWR_EXTI_LINE_PVD) | |||
/** | |||
* @brief Disable the PVD Extended Interrupt Falling Trigger. | |||
* @note PVD flag polarity is inverted compared to EXTI line, therefore | |||
* EXTI rising and falling logic edges are inverted versus PVD voltage edges. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableRisingTrig_0_31(PWR_EXTI_LINE_PVD) | |||
/** | |||
* @brief Enable the PVD Extended Interrupt Rising & Falling Trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() \ | |||
do { \ | |||
__HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE(); \ | |||
__HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE(); \ | |||
} while(0) | |||
/** | |||
* @brief Disable the PVD Extended Interrupt Rising & Falling Trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() \ | |||
do { \ | |||
__HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE(); \ | |||
__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE(); \ | |||
} while(0) | |||
/** | |||
* @brief Generate a Software interrupt on selected EXTI line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(PWR_EXTI_LINE_PVD) | |||
/** | |||
* @brief Check whether or not the PVD EXTI interrupt flag is set. | |||
* @retval EXTI PVD Line Status. | |||
*/ | |||
#define __HAL_PWR_PVD_EXTI_GET_FLAG() LL_EXTI_ReadFlag_0_31(PWR_EXTI_LINE_PVD) | |||
/** | |||
* @brief Clear the PVD EXTI interrupt flag. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(PWR_EXTI_LINE_PVD) | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros --------------------------------------------------------*/ | |||
/** @defgroup PWR_Private_Macros PWR Private Macros | |||
* @{ | |||
*/ | |||
#define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \ | |||
((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \ | |||
((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \ | |||
((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7)) | |||
#define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_NORMAL) ||\ | |||
((MODE) == PWR_PVD_MODE_IT_RISING) ||\ | |||
((MODE) == PWR_PVD_MODE_IT_FALLING) ||\ | |||
((MODE) == PWR_PVD_MODE_IT_RISING_FALLING)) | |||
#define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \ | |||
((REGULATOR) == PWR_LOWPOWERREGULATOR_ON)) | |||
#define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || \ | |||
((ENTRY) == PWR_SLEEPENTRY_WFE)) | |||
#define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || \ | |||
((ENTRY) == PWR_STOPENTRY_WFE)) | |||
/** | |||
* @} | |||
*/ | |||
/* Include PWR HAL Extended module */ | |||
#include "stm32wbxx_hal_pwr_ex.h" | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup PWR_Exported_Functions PWR Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions *******************************/ | |||
void HAL_PWR_DeInit(void); | |||
void HAL_PWR_EnableBkUpAccess(void); | |||
void HAL_PWR_DisableBkUpAccess(void); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWR_Exported_Functions_Group2 Peripheral Control functions | |||
* @{ | |||
*/ | |||
/* Peripheral Control functions ************************************************/ | |||
HAL_StatusTypeDef HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD); | |||
void HAL_PWR_EnablePVD(void); | |||
void HAL_PWR_DisablePVD(void); | |||
/* WakeUp pins configuration functions ****************************************/ | |||
void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinPolarity); | |||
void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx); | |||
/* Low Power modes configuration functions ************************************/ | |||
void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry); | |||
void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry); | |||
void HAL_PWR_EnterSTANDBYMode(void); | |||
void HAL_PWR_PVDCallback(void); | |||
void HAL_PWR_EnableSleepOnExit(void); | |||
void HAL_PWR_DisableSleepOnExit(void); | |||
void HAL_PWR_EnableSEVOnPend(void); | |||
void HAL_PWR_DisableSEVOnPend(void); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_PWR_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,886 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_pwr_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of PWR HAL Extended module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_PWR_EX_H | |||
#define STM32WBxx_HAL_PWR_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup PWREx PWREx | |||
* @brief PWR Extended HAL module driver | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup PWREx_Exported_Types PWR Extended Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief PWR PVM configuration structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t PVMType; /*!< PVMType: Specifies which voltage is monitored and against which threshold. | |||
This parameter can be a value of @ref PWREx_PVM_Type. | |||
@arg @ref PWR_PVM_1 Peripheral Voltage Monitoring 1 enable: VDDUSB versus 1.2 V (applicable when USB feature is supported). | |||
@arg @ref PWR_PVM_3 Peripheral Voltage Monitoring 3 enable: VDDA versus 1.62 V. | |||
*/ | |||
uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins. | |||
This parameter can be a value of @ref PWREx_PVM_Mode. */ | |||
uint32_t WakeupTarget; /*!< Specifies the Wakeup Target | |||
This parameter can be a value of @ref PWREx_WakeUpTarget_Definition */ | |||
}PWR_PVMTypeDef; | |||
/** | |||
* @brief PWR SMPS step down configuration structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t StartupCurrent; /*!< SMPS step down converter supply startup current selection. | |||
This parameter can be a value of @ref PWREx_SMPS_STARTUP_CURRENT. */ | |||
uint32_t OutputVoltage; /*!< SMPS step down converter output voltage scaling voltage level. | |||
This parameter can be a value of @ref PWREx_SMPS_OUTPUT_VOLTAGE_LEVEL */ | |||
}PWR_SMPSTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup PWREx_Exported_Constants PWR Extended Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup PWREx_WUP_Polarity Shift to apply to retrieve polarity information from PWR_WAKEUP_PINy_xxx constants | |||
* @{ | |||
*/ | |||
#define PWR_WUP_POLARITY_SHIFT 0x05U /*!< Internal constant used to retrieve wakeup pin polarity */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_WakeUp_Pins PWR wake-up pins | |||
* @{ | |||
*/ | |||
#define PWR_WAKEUP_PIN1_HIGH PWR_CR3_EWUP1 /*!< Wakeup pin 1 (with high level polarity) */ | |||
#define PWR_WAKEUP_PIN2_HIGH PWR_CR3_EWUP2 /*!< Wakeup pin 2 (with high level polarity) */ | |||
#define PWR_WAKEUP_PIN3_HIGH PWR_CR3_EWUP3 /*!< Wakeup pin 3 (with high level polarity) */ | |||
#define PWR_WAKEUP_PIN4_HIGH PWR_CR3_EWUP4 /*!< Wakeup pin 4 (with high level polarity) */ | |||
#define PWR_WAKEUP_PIN5_HIGH PWR_CR3_EWUP5 /*!< Wakeup pin 5 (with high level polarity) */ | |||
#define PWR_WAKEUP_PIN1_LOW ((PWR_CR4_WP1<<PWR_WUP_POLARITY_SHIFT) | PWR_CR3_EWUP1) /*!< Wakeup pin 1 (with low level polarity) */ | |||
#define PWR_WAKEUP_PIN2_LOW ((PWR_CR4_WP2<<PWR_WUP_POLARITY_SHIFT) | PWR_CR3_EWUP2) /*!< Wakeup pin 2 (with low level polarity) */ | |||
#define PWR_WAKEUP_PIN3_LOW ((PWR_CR4_WP3<<PWR_WUP_POLARITY_SHIFT) | PWR_CR3_EWUP3) /*!< Wakeup pin 3 (with low level polarity) */ | |||
#define PWR_WAKEUP_PIN4_LOW ((PWR_CR4_WP4<<PWR_WUP_POLARITY_SHIFT) | PWR_CR3_EWUP4) /*!< Wakeup pin 4 (with low level polarity) */ | |||
#define PWR_WAKEUP_PIN5_LOW ((PWR_CR4_WP5<<PWR_WUP_POLARITY_SHIFT) | PWR_CR3_EWUP5) /*!< Wakeup pin 5 (with low level polarity) */ | |||
/** | |||
* @} | |||
*/ | |||
/* Literals kept for legacy purpose */ | |||
#define PWR_WAKEUP_PIN1 PWR_CR3_EWUP1 /*!< Wakeup pin 1 (with high level polarity) */ | |||
#define PWR_WAKEUP_PIN2 PWR_CR3_EWUP2 /*!< Wakeup pin 2 (with high level polarity) */ | |||
#define PWR_WAKEUP_PIN3 PWR_CR3_EWUP3 /*!< Wakeup pin 3 (with high level polarity) */ | |||
#define PWR_WAKEUP_PIN4 PWR_CR3_EWUP4 /*!< Wakeup pin 4 (with high level polarity) */ | |||
#define PWR_WAKEUP_PIN5 PWR_CR3_EWUP5 /*!< Wakeup pin 5 (with high level polarity) */ | |||
/** @defgroup PWREx_PIN_Polarity PWREx Pin Polarity configuration | |||
* @{ | |||
*/ | |||
#define PWR_PIN_POLARITY_HIGH 0x00000000U | |||
#define PWR_PIN_POLARITY_LOW 0x00000001U | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_PVM_Type Peripheral Voltage Monitoring type | |||
* @{ | |||
*/ | |||
#define PWR_PVM_1 PWR_CR2_PVME1 /*!< Peripheral Voltage Monitoring 1 enable: VDDUSB versus 1.2 V (applicable when USB feature is supported) */ | |||
#define PWR_PVM_3 PWR_CR2_PVME3 /*!< Peripheral Voltage Monitoring 3 enable: VDDA versus 1.62 V */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_PVM_Mode PWR PVM interrupt and event mode | |||
* @{ | |||
*/ | |||
#define PWR_PVM_MODE_NORMAL (0x00000000U) /*!< basic mode is used */ | |||
#define PWR_PVM_MODE_IT_RISING (PVM_MODE_IT | PVM_RISING_EDGE) /*!< External Interrupt Mode with Rising edge trigger detection */ | |||
#define PWR_PVM_MODE_IT_FALLING (PVM_MODE_IT | PVM_FALLING_EDGE) /*!< External Interrupt Mode with Falling edge trigger detection */ | |||
#define PWR_PVM_MODE_IT_RISING_FALLING (PVM_MODE_IT | PVM_RISING_FALLING_EDGE) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ | |||
#define PWR_PVM_MODE_EVENT_RISING (PVM_MODE_EVT | PVM_RISING_EDGE) /*!< Event Mode with Rising edge trigger detection */ | |||
#define PWR_PVM_MODE_EVENT_FALLING (PVM_MODE_EVT | PVM_FALLING_EDGE) /*!< Event Mode with Falling edge trigger detection */ | |||
#define PWR_PVM_MODE_EVENT_RISING_FALLING (PVM_MODE_EVT | PVM_RISING_FALLING_EDGE) /*!< Event Mode with Rising/Falling edge trigger detection */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_Flash_PowerDown Flash Power Down modes | |||
* @{ | |||
*/ | |||
#define PWR_FLASHPD_LPRUN PWR_CR1_FPDR /*!< Enable Flash power down in low power run mode */ | |||
#define PWR_FLASHPD_LPSLEEP PWR_CR1_FPDS /*!< Enable Flash power down in low power sleep mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_Regulator_Voltage_Scale PWR Regulator voltage scale | |||
* @{ | |||
*/ | |||
#define PWR_REGULATOR_VOLTAGE_SCALE1 PWR_CR1_VOS_0 /*!< Regulator voltage output range 1 mode, typical output voltage at 1.2 V, system frequency up to 64 MHz */ | |||
#define PWR_REGULATOR_VOLTAGE_SCALE2 PWR_CR1_VOS_1 /*!< Regulator voltage output range 2 mode, typical output voltage at 1.0 V, system frequency up to 16 MHz */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_VBAT_Battery_Charging_Selection PWR battery charging resistor selection | |||
* @{ | |||
*/ | |||
#define PWR_BATTERY_CHARGING_RESISTOR_5 (0x00000000U) /*!< VBAT charging through a 5 kOhms resistor */ | |||
#define PWR_BATTERY_CHARGING_RESISTOR_1_5 PWR_CR4_VBRS /*!< VBAT charging through a 1.5 kOhms resistor */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_VBAT_Battery_Charging PWR battery charging | |||
* @{ | |||
*/ | |||
#define PWR_BATTERY_CHARGING_DISABLE (0x00000000U) | |||
#define PWR_BATTERY_CHARGING_ENABLE PWR_CR4_VBE | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_GPIO_Bit_Number GPIO bit number for I/O setting in standby/shutdown mode | |||
* @{ | |||
*/ | |||
#define PWR_GPIO_BIT_0 PWR_PUCRC_PC0 /*!< GPIO port I/O pin 0 */ | |||
#define PWR_GPIO_BIT_1 PWR_PUCRC_PC1 /*!< GPIO port I/O pin 1 */ | |||
#define PWR_GPIO_BIT_2 PWR_PUCRC_PC2 /*!< GPIO port I/O pin 2 */ | |||
#define PWR_GPIO_BIT_3 PWR_PUCRC_PC3 /*!< GPIO port I/O pin 3 */ | |||
#define PWR_GPIO_BIT_4 PWR_PUCRC_PC4 /*!< GPIO port I/O pin 4 */ | |||
#define PWR_GPIO_BIT_5 PWR_PUCRC_PC5 /*!< GPIO port I/O pin 5 */ | |||
#define PWR_GPIO_BIT_6 PWR_PUCRC_PC6 /*!< GPIO port I/O pin 6 */ | |||
#define PWR_GPIO_BIT_7 PWR_PUCRC_PC7 /*!< GPIO port I/O pin 7 */ | |||
#define PWR_GPIO_BIT_8 PWR_PUCRC_PC8 /*!< GPIO port I/O pin 8 */ | |||
#define PWR_GPIO_BIT_9 PWR_PUCRC_PC9 /*!< GPIO port I/O pin 9 */ | |||
#define PWR_GPIO_BIT_10 PWR_PUCRC_PC10 /*!< GPIO port I/O pin 10 */ | |||
#define PWR_GPIO_BIT_11 PWR_PUCRC_PC11 /*!< GPIO port I/O pin 11 */ | |||
#define PWR_GPIO_BIT_12 PWR_PUCRC_PC12 /*!< GPIO port I/O pin 12 */ | |||
#define PWR_GPIO_BIT_13 PWR_PUCRC_PC13 /*!< GPIO port I/O pin 14 */ | |||
#define PWR_GPIO_BIT_14 PWR_PDCRC_PC14 /*!< GPIO port I/O pin 14 */ | |||
#define PWR_GPIO_BIT_15 PWR_PUCRC_PC15 /*!< GPIO port I/O pin 15 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_GPIO GPIO port | |||
* @{ | |||
*/ | |||
#define PWR_GPIO_A 0x00000000U /*!< GPIO port A */ | |||
#define PWR_GPIO_B 0x00000001U /*!< GPIO port B */ | |||
#define PWR_GPIO_C 0x00000002U /*!< GPIO port C */ | |||
#define PWR_GPIO_D 0x00000003U /*!< GPIO port D */ | |||
#define PWR_GPIO_E 0x00000004U /*!< GPIO port E */ | |||
#define PWR_GPIO_H 0x00000007U /*!< GPIO port H */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_BOR_CONFIGURATION BOR configuration | |||
* @{ | |||
*/ | |||
#define PWR_BOR_SYSTEM_RESET (LL_PWR_BOR_SYSTEM_RESET) /*!< BOR will generate a system reset */ | |||
#define PWR_BOR_SMPS_FORCE_BYPASS (LL_PWR_BOR_SMPS_FORCE_BYPASS) /*!< BOR will for SMPS step down converter in bypass mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_SMPS_OPERATING_MODES SMPS step down converter operating modes | |||
* @{ | |||
*/ | |||
/* Note: Literals values are defined from register SR2 bits SMPSF and SMPSBF */ | |||
/* but they are also used as register CR5 bits SMPSEN and SMPSBEN, */ | |||
/* as used by all SMPS operating mode functions targetting different */ | |||
/* registers: */ | |||
/* "LL_PWR_SMPS_SetMode()", "LL_PWR_SMPS_GetMode()" */ | |||
/* and "LL_PWR_SMPS_GetEffectiveMode()". */ | |||
#define PWR_SMPS_BYPASS (PWR_SR2_SMPSBF) /*!< SMPS step down in bypass mode */ | |||
#define PWR_SMPS_STEP_DOWN (PWR_SR2_SMPSF) /*!< SMPS step down in step down mode if system low power mode is run, LP run or stop0. If system low power mode is stop1, stop2, standby, shutdown, then SMPS is forced in mode open to preserve energy stored in decoupling capacitor as long as possible. */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_SMPS_STARTUP_CURRENT SMPS step down converter supply startup current selection | |||
* @{ | |||
*/ | |||
#define PWR_SMPS_STARTUP_CURRENT_80MA (0x00000000U) /*!< SMPS step down converter supply startup current 80mA */ | |||
#define PWR_SMPS_STARTUP_CURRENT_100MA ( PWR_CR5_SMPSSC_0) /*!< SMPS step down converter supply startup current 100mA */ | |||
#define PWR_SMPS_STARTUP_CURRENT_120MA ( PWR_CR5_SMPSSC_1 ) /*!< SMPS step down converter supply startup current 120mA */ | |||
#define PWR_SMPS_STARTUP_CURRENT_140MA ( PWR_CR5_SMPSSC_1 | PWR_CR5_SMPSSC_0) /*!< SMPS step down converter supply startup current 140mA */ | |||
#define PWR_SMPS_STARTUP_CURRENT_160MA (PWR_CR5_SMPSSC_2 ) /*!< SMPS step down converter supply startup current 160mA */ | |||
#define PWR_SMPS_STARTUP_CURRENT_180MA (PWR_CR5_SMPSSC_2 | PWR_CR5_SMPSSC_0) /*!< SMPS step down converter supply startup current 180mA */ | |||
#define PWR_SMPS_STARTUP_CURRENT_200MA (PWR_CR5_SMPSSC_2 | PWR_CR5_SMPSSC_1 ) /*!< SMPS step down converter supply startup current 200mA */ | |||
#define PWR_SMPS_STARTUP_CURRENT_220MA (PWR_CR5_SMPSSC_2 | PWR_CR5_SMPSSC_1 | PWR_CR5_SMPSSC_0) /*!< SMPS step down converter supply startup current 220mA */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_SMPS_OUTPUT_VOLTAGE_LEVEL SMPS step down converter output voltage scaling voltage level | |||
* @{ | |||
*/ | |||
/* Note: SMPS voltage is trimmed during device production to control | |||
the actual voltage level variation from device to device. */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V20 (0x00000000U) /*!< SMPS step down converter supply output voltage 1.20V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V25 ( PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.25V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V30 ( PWR_CR5_SMPSVOS_1 ) /*!< SMPS step down converter supply output voltage 1.30V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V35 ( PWR_CR5_SMPSVOS_1 | PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.35V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V40 ( PWR_CR5_SMPSVOS_2 ) /*!< SMPS step down converter supply output voltage 1.40V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V45 ( PWR_CR5_SMPSVOS_2 | PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.45V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V50 ( PWR_CR5_SMPSVOS_2 | PWR_CR5_SMPSVOS_1 ) /*!< SMPS step down converter supply output voltage 1.50V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V55 ( PWR_CR5_SMPSVOS_2 | PWR_CR5_SMPSVOS_1 | PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.55V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V60 (PWR_CR5_SMPSVOS_3 ) /*!< SMPS step down converter supply output voltage 1.60V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V65 (PWR_CR5_SMPSVOS_3 | PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.65V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V70 (PWR_CR5_SMPSVOS_3 | PWR_CR5_SMPSVOS_1 ) /*!< SMPS step down converter supply output voltage 1.70V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V75 (PWR_CR5_SMPSVOS_3 | PWR_CR5_SMPSVOS_1 | PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.75V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V80 (PWR_CR5_SMPSVOS_3 | PWR_CR5_SMPSVOS_2 ) /*!< SMPS step down converter supply output voltage 1.80V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V85 (PWR_CR5_SMPSVOS_3 | PWR_CR5_SMPSVOS_2 | PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.85V */ | |||
#define PWR_SMPS_OUTPUT_VOLTAGE_1V90 (PWR_CR5_SMPSVOS_3 | PWR_CR5_SMPSVOS_2 | PWR_CR5_SMPSVOS_1 ) /*!< SMPS step down converter supply output voltage 1.90V */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_Flag PWR Status Flags | |||
* Elements values convention: 0000 0000 0XXY YYYYb | |||
* - Y YYYY : Flag position in the XX register (5 bits) | |||
* - XX : Status register (2 bits) | |||
* - 01: SR1 register | |||
* - 10: SR2 register | |||
* - 11: C2_SCR register | |||
* The only exception is PWR_FLAG_WUF, encompassing all | |||
* wake-up flags and set to PWR_SR1_WUF. | |||
* @{ | |||
*/ | |||
/*--------------------------------SR1-------------------------------*/ | |||
#define PWR_FLAG_WUF1 (0x0020U) /*!< Wakeup event on wakeup pin 1 */ | |||
#define PWR_FLAG_WUF2 (0x0021U) /*!< Wakeup event on wakeup pin 2 */ | |||
#define PWR_FLAG_WUF3 (0x0022U) /*!< Wakeup event on wakeup pin 3 */ | |||
#define PWR_FLAG_WUF4 (0x0023U) /*!< Wakeup event on wakeup pin 4 */ | |||
#define PWR_FLAG_WUF5 (0x0024U) /*!< Wakeup event on wakeup pin 5 */ | |||
#define PWR_FLAG_WU PWR_SR1_WUF /*!< Encompass wakeup event on all wakeup pins */ | |||
#define PWR_FLAG_BHWF (0x0028U) /*!< BLE_Host WakeUp Flag */ | |||
#define PWR_FLAG_FRCBYPI (0x0029U) /*!< SMPS Forced in Bypass Interrupt Flag */ | |||
#define PWR_FLAG_RFPHASEI (0x002BU) /*!< Radio Phase Interrupt Flag */ | |||
#define PWR_FLAG_BLEACTI (0x002CU) /*!< BLE Activity Interrupt Flag */ | |||
#define PWR_FLAG_802ACTI (0x002DU) /*!< 802.15.4 Activity Interrupt Flag */ | |||
#define PWR_FLAG_HOLDC2I (0x002EU) /*!< CPU2 on-Hold Interrupt Flag */ | |||
#define PWR_FLAG_WUFI (0x002FU) /*!< Wakeup on internal wakeup line */ | |||
/*--------------------------------SR2-------------------------------*/ | |||
#define PWR_FLAG_SMPSRDYF (0x0040U) /*!< SMPS Ready Flag */ | |||
#define PWR_FLAG_SMPSBYPF (0x0041U) /*!< SMPS Bypass Flag */ | |||
#define PWR_FLAG_REGLPS (0x0048U) /*!< Low-power regulator start flag */ | |||
#define PWR_FLAG_REGLPF (0x0049U) /*!< Low-power regulator flag */ | |||
#define PWR_FLAG_VOSF (0x004AU) /*!< Voltage scaling flag */ | |||
#define PWR_FLAG_PVDO (0x004BU) /*!< Power Voltage Detector output flag */ | |||
#define PWR_FLAG_PVMO1 (0x004CU) /*!< Power Voltage Monitoring 1 output flag */ | |||
#define PWR_FLAG_PVMO3 (0x004EU) /*!< Power Voltage Monitoring 3 output flag */ | |||
/*------------------------------EXTSCR---------------------------*/ | |||
#define PWR_FLAG_SB (0x0068U) /*!< System Standby flag for CPU1 */ | |||
#define PWR_FLAG_STOP (0x0069U) /*!< System Stop flag for CPU1 */ | |||
#define PWR_FLAG_C2SB (0x006AU) /*!< System Standby flag for CPU2 */ | |||
#define PWR_FLAG_C2STOP (0x006BU) /*!< System Stop flag for CPU2 */ | |||
#define PWR_FLAG_CRITICAL_RF_PHASE (0x006DU) /*!< Critical radio system phase flag */ | |||
#define PWR_FLAG_C1DEEPSLEEP (0x006EU) /*!< CPU1 DeepSleep Flag */ | |||
#define PWR_FLAG_C2DEEPSLEEP (0x006FU) /*!< CPU2 DeepSleep Flag */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_WakeUpTarget_Definition PWR Wakeup Target Definition | |||
* @{ | |||
*/ | |||
#define PWR_WAKEUPTARGET_CPU1 (0x00000001U) | |||
#define PWR_WAKEUPTARGET_CPU2 (0x00000002U) | |||
#define PWR_WAKEUPTARGET_ALL_CPU (PWR_WAKEUPTARGET_CPU1 | PWR_WAKEUPTARGET_CPU2) | |||
#define PWR_WAKEUPTARGET_RF (0x00000004U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWREx_Core_Select PWREx Core definition | |||
* @{ | |||
*/ | |||
#define PWR_CORE_CPU1 (0x00000000U) | |||
#define PWR_CORE_CPU2 (0x00000001U) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private define ------------------------------------------------------------*/ | |||
/** @defgroup PWR_Private_Defines PWR Private Defines | |||
* @{ | |||
*/ | |||
/** @defgroup PWREx_PVM_EXTI_LINE PWR PVM external interrupts lines | |||
* @{ | |||
*/ | |||
#define PWR_EXTI_LINE_PVM1 (LL_EXTI_LINE_31) /*!< External interrupt line 31 Connected to PVM1 */ | |||
#define PWR_EXTI_LINE_PVM3 (LL_EXTI_LINE_33) /*!< External interrupt line 33 Connected to PVM3 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PWR_PVM_Mode_Mask PWR PVM Mode Mask | |||
* @{ | |||
*/ | |||
/* Note: On STM32WB serie, power PVD event is not available on AIEC lines */ | |||
/* (only interruption is available through AIEC line 16). */ | |||
#define PVM_MODE_IT (0x00010000U) /*!< Mask for interruption yielded by PVM threshold crossing */ | |||
#define PVM_MODE_EVT (0x00020000U) /*!< Mask for event yielded by PVM threshold crossing */ | |||
#define PVM_RISING_EDGE (0x00000001U) /*!< Mask for rising edge set as PVM trigger */ | |||
#define PVM_FALLING_EDGE (0x00000002U) /*!< Mask for falling edge set as PVM trigger */ | |||
#define PVM_RISING_FALLING_EDGE (0x00000003U) /*!< Mask for rising and falling edges set as PVM trigger */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup PWREx_Exported_Macros PWR Extended Exported Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable the PVM1 Extended Interrupt C1 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Enable the PVM1 Extended Interrupt C2 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTIC2_ENABLE_IT() LL_C2_EXTI_EnableIT_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Disable the PVM1 Extended Interrupt C1 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Disable the PVM1 Extended Interrupt C2 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTIC2_DISABLE_IT() LL_C2_EXTI_DisableIT_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Enable the PVM1 Event C1 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Enable the PVM1 Event C2 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTIC2_ENABLE_EVENT() LL_C2_EXTI_EnableEvent_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Disable the PVM1 Event C1 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Disable the PVM1 Event C2 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTIC2_DISABLE_EVENT() LL_C2_EXTI_DisableEvent_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Enable the PVM1 Extended Interrupt Rising Trigger. | |||
* @note PVM1 flag polarity is inverted compared to EXTI line, therefore | |||
* EXTI rising and falling logic edges are inverted versus PVM1 voltage edges. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Disable the PVM1 Extended Interrupt Rising Trigger. | |||
* @note PVM1 flag polarity is inverted compared to EXTI line, therefore | |||
* EXTI rising and falling logic edges are inverted versus PVM1 voltage edges. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Enable the PVM1 Extended Interrupt Falling Trigger. | |||
* @note PVM1 flag polarity is inverted compared to EXTI line, therefore | |||
* EXTI rising and falling logic edges are inverted versus PVM1 voltage edges. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Disable the PVM1 Extended Interrupt Falling Trigger. | |||
* @note PVM1 flag polarity is inverted compared to EXTI line, therefore | |||
* EXTI rising and falling logic edges are inverted versus PVM1 voltage edges. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief PVM1 EXTI line configuration: set rising & falling edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTI_ENABLE_RISING_FALLING_EDGE() \ | |||
do { \ | |||
__HAL_PWR_PVM1_EXTI_ENABLE_RISING_EDGE(); \ | |||
__HAL_PWR_PVM1_EXTI_ENABLE_FALLING_EDGE(); \ | |||
} while(0) | |||
/** | |||
* @brief Disable the PVM1 Extended Interrupt Rising & Falling Trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTI_DISABLE_RISING_FALLING_EDGE() \ | |||
do { \ | |||
__HAL_PWR_PVM1_EXTI_DISABLE_RISING_EDGE(); \ | |||
__HAL_PWR_PVM1_EXTI_DISABLE_FALLING_EDGE(); \ | |||
} while(0) | |||
/** | |||
* @brief Generate a Software interrupt on selected EXTI line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Check whether the specified PVM1 EXTI interrupt flag is set or not. | |||
* @retval EXTI PVM1 Line Status. | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTI_GET_FLAG() LL_EXTI_ReadFlag_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Clear the PVM1 EXTI flag. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM1_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(PWR_EXTI_LINE_PVM1) | |||
/** | |||
* @brief Enable the PVM3 Extended Interrupt C1 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTI_ENABLE_IT() LL_EXTI_EnableIT_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Enable the PVM3 Extended Interrupt C2 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTIC2_ENABLE_IT() LL_C2_EXTI_EnableIT_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Disable the PVM3 Extended Interrupt C1 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTI_DISABLE_IT() LL_EXTI_DisableIT_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Disable the PVM3 Extended Interrupt C2 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTIC2_DISABLE_IT() LL_C2_EXTI_DisableIT_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Enable the PVM3 Event C1 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Enable the PVM3 Event C2 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTIC2_ENABLE_EVENT() LL_C2_EXTI_EnableEvent_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Disable the PVM3 Event C1 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Disable the PVM3 Event C2 Line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTIC2_DISABLE_EVENT() LL_C2_EXTI_DisableEvent_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Enable the PVM3 Extended Interrupt Rising Trigger. | |||
* @note PVM3 flag polarity is inverted compared to EXTI line, therefore | |||
* EXTI rising and falling logic edges are inverted versus PVM3 voltage edges. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Disable the PVM3 Extended Interrupt Rising Trigger. | |||
* @note PVM3 flag polarity is inverted compared to EXTI line, therefore | |||
* EXTI rising and falling logic edges are inverted versus PVM3 voltage edges. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Enable the PVM3 Extended Interrupt Falling Trigger. | |||
* @note PVM3 flag polarity is inverted compared to EXTI line, therefore | |||
* EXTI rising and falling logic edges are inverted versus PVM3 voltage edges. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Disable the PVM3 Extended Interrupt Falling Trigger. | |||
* @note PVM3 flag polarity is inverted compared to EXTI line, therefore | |||
* EXTI rising and falling logic edges are inverted versus PVM3 voltage edges. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief PVM3 EXTI line configuration: set rising & falling edge trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTI_ENABLE_RISING_FALLING_EDGE() \ | |||
do { \ | |||
__HAL_PWR_PVM3_EXTI_ENABLE_RISING_EDGE(); \ | |||
__HAL_PWR_PVM3_EXTI_ENABLE_FALLING_EDGE(); \ | |||
} while(0) | |||
/** | |||
* @brief Disable the PVM3 Extended Interrupt Rising & Falling Trigger. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTI_DISABLE_RISING_FALLING_EDGE() \ | |||
do { \ | |||
__HAL_PWR_PVM3_EXTI_DISABLE_RISING_EDGE(); \ | |||
__HAL_PWR_PVM3_EXTI_DISABLE_FALLING_EDGE(); \ | |||
} while(0) | |||
/** | |||
* @brief Generate a Software interrupt on selected EXTI line. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Check whether the specified PVM3 EXTI interrupt flag is set or not. | |||
* @retval EXTI PVM3 Line Status. | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTI_GET_FLAG() LL_EXTI_ReadFlag_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Clear the PVM3 EXTI flag. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_PVM3_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_32_63(PWR_EXTI_LINE_PVM3) | |||
/** | |||
* @brief Configure the main internal regulator output voltage. | |||
* @param __REGULATOR__ specifies the regulator output voltage to achieve | |||
* a tradeoff between performance and power consumption. | |||
* This parameter can be one of the following values: | |||
* @arg @ref PWR_REGULATOR_VOLTAGE_SCALE1 Regulator voltage output range 1 mode, | |||
* typical output voltage at 1.2 V, | |||
* system frequency up to 64 MHz. | |||
* @arg @ref PWR_REGULATOR_VOLTAGE_SCALE2 Regulator voltage output range 2 mode, | |||
* typical output voltage at 1.0 V, | |||
* system frequency up to 16 MHz. | |||
* @note This macro is similar to HAL_PWREx_ControlVoltageScaling() API but doesn't check | |||
* whether or not VOSF flag is cleared when moving from range 2 to range 1. User | |||
* may resort to __HAL_PWR_GET_FLAG() macro to check VOSF bit resetting. | |||
* @retval None | |||
*/ | |||
#define __HAL_PWR_VOLTAGESCALING_CONFIG(__REGULATOR__) do { \ | |||
__IO uint32_t tmpreg; \ | |||
MODIFY_REG(PWR->CR1, PWR_CR1_VOS, (__REGULATOR__)); \ | |||
/* Delay after an RCC peripheral clock enabling */ \ | |||
tmpreg = READ_BIT(PWR->CR1, PWR_CR1_VOS); \ | |||
UNUSED(tmpreg); \ | |||
} while(0) | |||
/** | |||
* @brief Wakeup BLE controller from its sleep mode | |||
* @note This bit is automatically reset when 802.15.4 controller | |||
* exit its sleep mode. | |||
* @retval None | |||
*/ | |||
#define __HAL_C2_PWR_WAKEUP_BLE() LL_C2_PWR_WakeUp_BLE() | |||
/** | |||
* @brief Wakeup 802.15.4 controller from its sleep mode | |||
* @note This bit is automatically reset when 802.15.4 controller | |||
* exit its sleep mode. | |||
* @retval None | |||
*/ | |||
#define __HAL_C2_PWR_WAKEUP_802_15_4() LL_C2_PWR_WakeUp_802_15_4() | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros --------------------------------------------------------*/ | |||
/** @addtogroup PWREx_Private_Macros PWR Extended Private Macros | |||
* @{ | |||
*/ | |||
#define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1_HIGH) || \ | |||
((PIN) == PWR_WAKEUP_PIN2_HIGH) || \ | |||
((PIN) == PWR_WAKEUP_PIN3_HIGH) || \ | |||
((PIN) == PWR_WAKEUP_PIN4_HIGH) || \ | |||
((PIN) == PWR_WAKEUP_PIN5_HIGH) || \ | |||
((PIN) == PWR_WAKEUP_PIN1_LOW) || \ | |||
((PIN) == PWR_WAKEUP_PIN2_LOW) || \ | |||
((PIN) == PWR_WAKEUP_PIN3_LOW) || \ | |||
((PIN) == PWR_WAKEUP_PIN4_LOW) || \ | |||
((PIN) == PWR_WAKEUP_PIN5_LOW)) | |||
#define IS_PWR_WAKEUP_PIN_POLARITY(POLARITY) (((POLARITY) == PWR_PIN_POLARITY_HIGH) || \ | |||
((POLARITY) == PWR_PIN_POLARITY_LOW)) | |||
#define IS_PWR_PVM_TYPE(TYPE) (((TYPE) == PWR_PVM_1) ||\ | |||
((TYPE) == PWR_PVM_3)) | |||
#define IS_PWR_PVM_MODE(MODE) (((MODE) == PWR_PVM_MODE_NORMAL) ||\ | |||
((MODE) == PWR_PVM_MODE_IT_RISING) ||\ | |||
((MODE) == PWR_PVM_MODE_IT_FALLING) ||\ | |||
((MODE) == PWR_PVM_MODE_IT_RISING_FALLING) ||\ | |||
((MODE) == PWR_PVM_MODE_EVENT_RISING) ||\ | |||
((MODE) == PWR_PVM_MODE_EVENT_FALLING) ||\ | |||
((MODE) == PWR_PVM_MODE_EVENT_RISING_FALLING)) | |||
#define IS_PWR_FLASH_POWERDOWN(__MODE__) ((((__MODE__) & (PWR_FLASHPD_LPRUN | PWR_FLASHPD_LPSLEEP)) != 0x00u) && \ | |||
(((__MODE__) & ~(PWR_FLASHPD_LPRUN | PWR_FLASHPD_LPSLEEP)) == 0x00u)) | |||
#define IS_PWR_VOLTAGE_SCALING_RANGE(RANGE) (((RANGE) == PWR_REGULATOR_VOLTAGE_SCALE1) || \ | |||
((RANGE) == PWR_REGULATOR_VOLTAGE_SCALE2)) | |||
#define IS_PWR_BATTERY_RESISTOR_SELECT(RESISTOR) (((RESISTOR) == PWR_BATTERY_CHARGING_RESISTOR_5) ||\ | |||
((RESISTOR) == PWR_BATTERY_CHARGING_RESISTOR_1_5)) | |||
#define IS_PWR_BATTERY_CHARGING(CHARGING) (((CHARGING) == PWR_BATTERY_CHARGING_DISABLE) ||\ | |||
((CHARGING) == PWR_BATTERY_CHARGING_ENABLE)) | |||
#define IS_PWR_GPIO_BIT_NUMBER(BIT_NUMBER) (((BIT_NUMBER) & GPIO_PIN_MASK) != (uint32_t)0x00) | |||
#define IS_PWR_GPIO(GPIO) (((GPIO) == PWR_GPIO_A) ||\ | |||
((GPIO) == PWR_GPIO_B) ||\ | |||
((GPIO) == PWR_GPIO_C) ||\ | |||
((GPIO) == PWR_GPIO_D) ||\ | |||
((GPIO) == PWR_GPIO_E) ||\ | |||
((GPIO) == PWR_GPIO_H)) | |||
#define IS_PWR_SMPS_MODE(SMPS_MODE) (((SMPS_MODE) == PWR_SMPS_BYPASS) ||\ | |||
((SMPS_MODE) == PWR_SMPS_STEP_DOWN)) | |||
#define IS_PWR_SMPS_STARTUP_CURRENT(SMPS_STARTUP_CURRENT) (((SMPS_STARTUP_CURRENT) == PWR_SMPS_STARTUP_CURRENT_80MA) ||\ | |||
((SMPS_STARTUP_CURRENT) == PWR_SMPS_STARTUP_CURRENT_100MA) ||\ | |||
((SMPS_STARTUP_CURRENT) == PWR_SMPS_STARTUP_CURRENT_120MA) ||\ | |||
((SMPS_STARTUP_CURRENT) == PWR_SMPS_STARTUP_CURRENT_140MA) ||\ | |||
((SMPS_STARTUP_CURRENT) == PWR_SMPS_STARTUP_CURRENT_160MA) ||\ | |||
((SMPS_STARTUP_CURRENT) == PWR_SMPS_STARTUP_CURRENT_180MA) ||\ | |||
((SMPS_STARTUP_CURRENT) == PWR_SMPS_STARTUP_CURRENT_200MA) ||\ | |||
((SMPS_STARTUP_CURRENT) == PWR_SMPS_STARTUP_CURRENT_220MA)) | |||
#define IS_PWR_SMPS_OUTPUT_VOLTAGE(SMPS_OUTPUT_VOLTAGE) (((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V20) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V25) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V30) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V35) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V40) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V45) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V50) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V55) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V60) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V65) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V70) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V75) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V80) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V85) ||\ | |||
((SMPS_OUTPUT_VOLTAGE) == PWR_SMPS_OUTPUT_VOLTAGE_1V90)) | |||
#define IS_PWR_CORE(CPU) (((CPU) == PWR_CORE_CPU1) || ((CPU) == PWR_CORE_CPU2)) | |||
#define IS_PWR_CORE_HOLD_RELEASE(CPU) ((CPU) == PWR_CORE_CPU2) | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup PWREx_Exported_Functions PWR Extended Exported Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup PWREx_Exported_Functions_Group1 Extended Peripheral Control functions | |||
* @{ | |||
*/ | |||
/* Peripheral Control functions **********************************************/ | |||
uint32_t HAL_PWREx_GetVoltageRange(void); | |||
HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling(uint32_t VoltageScaling); | |||
void HAL_PWREx_EnableBatteryCharging(uint32_t ResistorSelection); | |||
void HAL_PWREx_DisableBatteryCharging(void); | |||
void HAL_PWREx_EnableVddUSB(void); | |||
void HAL_PWREx_DisableVddUSB(void); | |||
void HAL_PWREx_EnableInternalWakeUpLine(void); | |||
void HAL_PWREx_DisableInternalWakeUpLine(void); | |||
void HAL_PWREx_EnableBORH_SMPSBypassIT(void); | |||
void HAL_PWREx_DisableBORH_SMPSBypassIT(void); | |||
void HAL_PWREx_EnableRFPhaseIT(void); | |||
void HAL_PWREx_DisableRFPhaseIT(void); | |||
void HAL_PWREx_EnableBLEActivityIT(void); | |||
void HAL_PWREx_DisableBLEActivityIT(void); | |||
void HAL_PWREx_Enable802ActivityIT(void); | |||
void HAL_PWREx_Disable802ActivityIT(void); | |||
void HAL_PWREx_EnableHOLDC2IT(void); | |||
void HAL_PWREx_DisableHOLDC2IT(void); | |||
void HAL_PWREx_HoldCore(uint32_t CPU); | |||
void HAL_PWREx_ReleaseCore(uint32_t CPU); | |||
HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber); | |||
HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber); | |||
HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber); | |||
HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber); | |||
void HAL_PWREx_EnablePullUpPullDownConfig(void); | |||
void HAL_PWREx_DisablePullUpPullDownConfig(void); | |||
void HAL_PWREx_SetBORConfig(uint32_t BORConfiguration); | |||
uint32_t HAL_PWREx_GetBORConfig(void); | |||
void HAL_PWREx_EnableSRAMRetention(void); | |||
void HAL_PWREx_DisableSRAMRetention(void); | |||
void HAL_PWREx_EnableFlashPowerDown(uint32_t PowerMode); | |||
void HAL_PWREx_DisableFlashPowerDown(uint32_t PowerMode); | |||
void HAL_PWREx_EnablePVM1(void); | |||
void HAL_PWREx_DisablePVM1(void); | |||
void HAL_PWREx_EnablePVM3(void); | |||
void HAL_PWREx_DisablePVM3(void); | |||
HAL_StatusTypeDef HAL_PWREx_ConfigPVM(PWR_PVMTypeDef *sConfigPVM); | |||
HAL_StatusTypeDef HAL_PWREx_ConfigSMPS(PWR_SMPSTypeDef *sConfigSMPS); | |||
void HAL_PWREx_SMPS_SetMode(uint32_t OperatingMode); | |||
uint32_t HAL_PWREx_SMPS_GetEffectiveMode(void); | |||
/* WakeUp pins configuration functions ****************************************/ | |||
void HAL_PWREx_EnableWakeUpPin(uint32_t WakeUpPinPolarity, uint32_t wakeupTarget); | |||
uint32_t HAL_PWREx_GetWakeupFlag(uint32_t WakeUpFlag); | |||
HAL_StatusTypeDef HAL_PWREx_ClearWakeupFlag(uint32_t WakeUpFlag); | |||
/* Low Power modes configuration functions ************************************/ | |||
void HAL_PWREx_EnableLowPowerRunMode(void); | |||
HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void); | |||
void HAL_PWREx_EnterSTOP0Mode(uint8_t STOPEntry); | |||
void HAL_PWREx_EnterSTOP1Mode(uint8_t STOPEntry); | |||
void HAL_PWREx_EnterSTOP2Mode(uint8_t STOPEntry); | |||
void HAL_PWREx_EnterSHUTDOWNMode(void); | |||
void HAL_PWREx_PVD_PVM_IRQHandler(void); | |||
void HAL_PWREx_PVM1Callback(void); | |||
void HAL_PWREx_PVM3Callback(void); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_PWR_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,708 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_qspi.h | |||
* @author MCD Application Team | |||
* @brief Header file of QSPI HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© COPYRIGHT(c) 2019 STMicroelectronics</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_QSPI_H | |||
#define STM32WBxx_HAL_QSPI_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
#if defined(QUADSPI) || defined(QUADSPI1) || defined(QUADSPI2) | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup QSPI | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup QSPI_Exported_Types QSPI Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief QSPI Init structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t ClockPrescaler; /* Specifies the prescaler factor for generating clock based on the AHB clock. | |||
This parameter can be a number between 0 and 255 */ | |||
uint32_t FifoThreshold; /* Specifies the threshold number of bytes in the FIFO (used only in indirect mode) | |||
This parameter can be a value between 1 and 16 */ | |||
uint32_t SampleShifting; /* Specifies the Sample Shift. The data is sampled 1/2 clock cycle delay later to | |||
take in account external signal delays. (It should be QSPI_SAMPLE_SHIFTING_NONE in DDR mode) | |||
This parameter can be a value of @ref QSPI_SampleShifting */ | |||
uint32_t FlashSize; /* Specifies the Flash Size. FlashSize+1 is effectively the number of address bits | |||
required to address the flash memory. The flash capacity can be up to 4GB | |||
(addressed using 32 bits) in indirect mode, but the addressable space in | |||
memory-mapped mode is limited to 256MB | |||
This parameter can be a number between 0 and 31 */ | |||
uint32_t ChipSelectHighTime; /* Specifies the Chip Select High Time. ChipSelectHighTime+1 defines the minimum number | |||
of clock cycles which the chip select must remain high between commands. | |||
This parameter can be a value of @ref QSPI_ChipSelectHighTime */ | |||
uint32_t ClockMode; /* Specifies the Clock Mode. It indicates the level that clock takes between commands. | |||
This parameter can be a value of @ref QSPI_ClockMode */ | |||
}QSPI_InitTypeDef; | |||
/** | |||
* @brief HAL QSPI State structures definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_QSPI_STATE_RESET = 0x00U, /*!< Peripheral not initialized */ | |||
HAL_QSPI_STATE_READY = 0x01U, /*!< Peripheral initialized and ready for use */ | |||
HAL_QSPI_STATE_BUSY = 0x02U, /*!< Peripheral in indirect mode and busy */ | |||
HAL_QSPI_STATE_BUSY_INDIRECT_TX = 0x12U, /*!< Peripheral in indirect mode with transmission ongoing */ | |||
HAL_QSPI_STATE_BUSY_INDIRECT_RX = 0x22U, /*!< Peripheral in indirect mode with reception ongoing */ | |||
HAL_QSPI_STATE_BUSY_AUTO_POLLING = 0x42U, /*!< Peripheral in auto polling mode ongoing */ | |||
HAL_QSPI_STATE_BUSY_MEM_MAPPED = 0x82U, /*!< Peripheral in memory mapped mode ongoing */ | |||
HAL_QSPI_STATE_ABORT = 0x08U, /*!< Peripheral with abort request ongoing */ | |||
HAL_QSPI_STATE_ERROR = 0x04U /*!< Peripheral in error */ | |||
}HAL_QSPI_StateTypeDef; | |||
/** | |||
* @brief QSPI Handle Structure definition | |||
*/ | |||
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1) | |||
typedef struct __QSPI_HandleTypeDef | |||
#else | |||
typedef struct | |||
#endif | |||
{ | |||
QUADSPI_TypeDef *Instance; /* QSPI registers base address */ | |||
QSPI_InitTypeDef Init; /* QSPI communication parameters */ | |||
uint8_t *pTxBuffPtr; /* Pointer to QSPI Tx transfer Buffer */ | |||
__IO uint32_t TxXferSize; /* QSPI Tx Transfer size */ | |||
__IO uint32_t TxXferCount; /* QSPI Tx Transfer Counter */ | |||
uint8_t *pRxBuffPtr; /* Pointer to QSPI Rx transfer Buffer */ | |||
__IO uint32_t RxXferSize; /* QSPI Rx Transfer size */ | |||
__IO uint32_t RxXferCount; /* QSPI Rx Transfer Counter */ | |||
DMA_HandleTypeDef *hdma; /* QSPI Rx/Tx DMA Handle parameters */ | |||
__IO HAL_LockTypeDef Lock; /* Locking object */ | |||
__IO HAL_QSPI_StateTypeDef State; /* QSPI communication state */ | |||
__IO uint32_t ErrorCode; /* QSPI Error code */ | |||
uint32_t Timeout; /* Timeout for the QSPI memory access */ | |||
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1) | |||
void (* ErrorCallback) (struct __QSPI_HandleTypeDef *hqspi); | |||
void (* AbortCpltCallback) (struct __QSPI_HandleTypeDef *hqspi); | |||
void (* FifoThresholdCallback)(struct __QSPI_HandleTypeDef *hqspi); | |||
void (* CmdCpltCallback) (struct __QSPI_HandleTypeDef *hqspi); | |||
void (* RxCpltCallback) (struct __QSPI_HandleTypeDef *hqspi); | |||
void (* TxCpltCallback) (struct __QSPI_HandleTypeDef *hqspi); | |||
void (* RxHalfCpltCallback) (struct __QSPI_HandleTypeDef *hqspi); | |||
void (* TxHalfCpltCallback) (struct __QSPI_HandleTypeDef *hqspi); | |||
void (* StatusMatchCallback) (struct __QSPI_HandleTypeDef *hqspi); | |||
void (* TimeOutCallback) (struct __QSPI_HandleTypeDef *hqspi); | |||
void (* MspInitCallback) (struct __QSPI_HandleTypeDef *hqspi); | |||
void (* MspDeInitCallback) (struct __QSPI_HandleTypeDef *hqspi); | |||
#endif | |||
}QSPI_HandleTypeDef; | |||
/** | |||
* @brief QSPI Command structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Instruction; /* Specifies the Instruction to be sent | |||
This parameter can be a value (8-bit) between 0x00 and 0xFF */ | |||
uint32_t Address; /* Specifies the Address to be sent (Size from 1 to 4 bytes according AddressSize) | |||
This parameter can be a value (32-bits) between 0x0 and 0xFFFFFFFF */ | |||
uint32_t AlternateBytes; /* Specifies the Alternate Bytes to be sent (Size from 1 to 4 bytes according AlternateBytesSize) | |||
This parameter can be a value (32-bits) between 0x0 and 0xFFFFFFFF */ | |||
uint32_t AddressSize; /* Specifies the Address Size | |||
This parameter can be a value of @ref QSPI_AddressSize */ | |||
uint32_t AlternateBytesSize; /* Specifies the Alternate Bytes Size | |||
This parameter can be a value of @ref QSPI_AlternateBytesSize */ | |||
uint32_t DummyCycles; /* Specifies the Number of Dummy Cycles. | |||
This parameter can be a number between 0 and 31 */ | |||
uint32_t InstructionMode; /* Specifies the Instruction Mode | |||
This parameter can be a value of @ref QSPI_InstructionMode */ | |||
uint32_t AddressMode; /* Specifies the Address Mode | |||
This parameter can be a value of @ref QSPI_AddressMode */ | |||
uint32_t AlternateByteMode; /* Specifies the Alternate Bytes Mode | |||
This parameter can be a value of @ref QSPI_AlternateBytesMode */ | |||
uint32_t DataMode; /* Specifies the Data Mode (used for dummy cycles and data phases) | |||
This parameter can be a value of @ref QSPI_DataMode */ | |||
uint32_t NbData; /* Specifies the number of data to transfer. (This is the number of bytes) | |||
This parameter can be any value between 0 and 0xFFFFFFFF (0 means undefined length | |||
until end of memory)*/ | |||
uint32_t DdrMode; /* Specifies the double data rate mode for address, alternate byte and data phase | |||
This parameter can be a value of @ref QSPI_DdrMode */ | |||
uint32_t SIOOMode; /* Specifies the send instruction only once mode | |||
This parameter can be a value of @ref QSPI_SIOOMode */ | |||
}QSPI_CommandTypeDef; | |||
/** | |||
* @brief QSPI Auto Polling mode configuration structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Match; /* Specifies the value to be compared with the masked status register to get a match. | |||
This parameter can be any value between 0 and 0xFFFFFFFF */ | |||
uint32_t Mask; /* Specifies the mask to be applied to the status bytes received. | |||
This parameter can be any value between 0 and 0xFFFFFFFF */ | |||
uint32_t Interval; /* Specifies the number of clock cycles between two read during automatic polling phases. | |||
This parameter can be any value between 0 and 0xFFFF */ | |||
uint32_t StatusBytesSize; /* Specifies the size of the status bytes received. | |||
This parameter can be any value between 1 and 4 */ | |||
uint32_t MatchMode; /* Specifies the method used for determining a match. | |||
This parameter can be a value of @ref QSPI_MatchMode */ | |||
uint32_t AutomaticStop; /* Specifies if automatic polling is stopped after a match. | |||
This parameter can be a value of @ref QSPI_AutomaticStop */ | |||
}QSPI_AutoPollingTypeDef; | |||
/** | |||
* @brief QSPI Memory Mapped mode configuration structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t TimeOutPeriod; /* Specifies the number of clock to wait when the FIFO is full before to release the chip select. | |||
This parameter can be any value between 0 and 0xFFFF */ | |||
uint32_t TimeOutActivation; /* Specifies if the timeout counter is enabled to release the chip select. | |||
This parameter can be a value of @ref QSPI_TimeOutActivation */ | |||
}QSPI_MemoryMappedTypeDef; | |||
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1) | |||
/** | |||
* @brief HAL QSPI Callback ID enumeration definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_QSPI_ERROR_CB_ID = 0x00U, /*!< QSPI Error Callback ID */ | |||
HAL_QSPI_ABORT_CB_ID = 0x01U, /*!< QSPI Abort Callback ID */ | |||
HAL_QSPI_FIFO_THRESHOLD_CB_ID = 0x02U, /*!< QSPI FIFO Threshold Callback ID */ | |||
HAL_QSPI_CMD_CPLT_CB_ID = 0x03U, /*!< QSPI Command Complete Callback ID */ | |||
HAL_QSPI_RX_CPLT_CB_ID = 0x04U, /*!< QSPI Rx Complete Callback ID */ | |||
HAL_QSPI_TX_CPLT_CB_ID = 0x05U, /*!< QSPI Tx Complete Callback ID */ | |||
HAL_QSPI_RX_HALF_CPLT_CB_ID = 0x06U, /*!< QSPI Rx Half Complete Callback ID */ | |||
HAL_QSPI_TX_HALF_CPLT_CB_ID = 0x07U, /*!< QSPI Tx Half Complete Callback ID */ | |||
HAL_QSPI_STATUS_MATCH_CB_ID = 0x08U, /*!< QSPI Status Match Callback ID */ | |||
HAL_QSPI_TIMEOUT_CB_ID = 0x09U, /*!< QSPI Timeout Callback ID */ | |||
HAL_QSPI_MSP_INIT_CB_ID = 0x0AU, /*!< QSPI MspInit Callback ID */ | |||
HAL_QSPI_MSP_DEINIT_CB_ID = 0x0B0 /*!< QSPI MspDeInit Callback ID */ | |||
}HAL_QSPI_CallbackIDTypeDef; | |||
/** | |||
* @brief HAL QSPI Callback pointer definition | |||
*/ | |||
typedef void (*pQSPI_CallbackTypeDef)(QSPI_HandleTypeDef *hqspi); | |||
#endif | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup QSPI_Exported_Constants QSPI Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup QSPI_ErrorCode QSPI Error Code | |||
* @{ | |||
*/ | |||
#define HAL_QSPI_ERROR_NONE 0x00000000U /*!< No error */ | |||
#define HAL_QSPI_ERROR_TIMEOUT 0x00000001U /*!< Timeout error */ | |||
#define HAL_QSPI_ERROR_TRANSFER 0x00000002U /*!< Transfer error */ | |||
#define HAL_QSPI_ERROR_DMA 0x00000004U /*!< DMA transfer error */ | |||
#define HAL_QSPI_ERROR_INVALID_PARAM 0x00000008U /*!< Invalid parameters error */ | |||
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1) | |||
#define HAL_QSPI_ERROR_INVALID_CALLBACK 0x00000010U /*!< Invalid callback error */ | |||
#endif | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_SampleShifting QSPI Sample Shifting | |||
* @{ | |||
*/ | |||
#define QSPI_SAMPLE_SHIFTING_NONE 0x00000000U /*!<No clock cycle shift to sample data*/ | |||
#define QSPI_SAMPLE_SHIFTING_HALFCYCLE ((uint32_t)QUADSPI_CR_SSHIFT) /*!<1/2 clock cycle shift to sample data*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_ChipSelectHighTime QSPI ChipSelect High Time | |||
* @{ | |||
*/ | |||
#define QSPI_CS_HIGH_TIME_1_CYCLE 0x00000000U /*!<nCS stay high for at least 1 clock cycle between commands*/ | |||
#define QSPI_CS_HIGH_TIME_2_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_0) /*!<nCS stay high for at least 2 clock cycles between commands*/ | |||
#define QSPI_CS_HIGH_TIME_3_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_1) /*!<nCS stay high for at least 3 clock cycles between commands*/ | |||
#define QSPI_CS_HIGH_TIME_4_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_0 | QUADSPI_DCR_CSHT_1) /*!<nCS stay high for at least 4 clock cycles between commands*/ | |||
#define QSPI_CS_HIGH_TIME_5_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_2) /*!<nCS stay high for at least 5 clock cycles between commands*/ | |||
#define QSPI_CS_HIGH_TIME_6_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_2 | QUADSPI_DCR_CSHT_0) /*!<nCS stay high for at least 6 clock cycles between commands*/ | |||
#define QSPI_CS_HIGH_TIME_7_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_2 | QUADSPI_DCR_CSHT_1) /*!<nCS stay high for at least 7 clock cycles between commands*/ | |||
#define QSPI_CS_HIGH_TIME_8_CYCLE ((uint32_t)QUADSPI_DCR_CSHT) /*!<nCS stay high for at least 8 clock cycles between commands*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_ClockMode QSPI Clock Mode | |||
* @{ | |||
*/ | |||
#define QSPI_CLOCK_MODE_0 0x00000000U /*!<Clk stays low while nCS is released*/ | |||
#define QSPI_CLOCK_MODE_3 ((uint32_t)QUADSPI_DCR_CKMODE) /*!<Clk goes high while nCS is released*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_AddressSize QSPI Address Size | |||
* @{ | |||
*/ | |||
#define QSPI_ADDRESS_8_BITS 0x00000000U /*!<8-bit address*/ | |||
#define QSPI_ADDRESS_16_BITS ((uint32_t)QUADSPI_CCR_ADSIZE_0) /*!<16-bit address*/ | |||
#define QSPI_ADDRESS_24_BITS ((uint32_t)QUADSPI_CCR_ADSIZE_1) /*!<24-bit address*/ | |||
#define QSPI_ADDRESS_32_BITS ((uint32_t)QUADSPI_CCR_ADSIZE) /*!<32-bit address*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_AlternateBytesSize QSPI Alternate Bytes Size | |||
* @{ | |||
*/ | |||
#define QSPI_ALTERNATE_BYTES_8_BITS 0x00000000U /*!<8-bit alternate bytes*/ | |||
#define QSPI_ALTERNATE_BYTES_16_BITS ((uint32_t)QUADSPI_CCR_ABSIZE_0) /*!<16-bit alternate bytes*/ | |||
#define QSPI_ALTERNATE_BYTES_24_BITS ((uint32_t)QUADSPI_CCR_ABSIZE_1) /*!<24-bit alternate bytes*/ | |||
#define QSPI_ALTERNATE_BYTES_32_BITS ((uint32_t)QUADSPI_CCR_ABSIZE) /*!<32-bit alternate bytes*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_InstructionMode QSPI Instruction Mode | |||
* @{ | |||
*/ | |||
#define QSPI_INSTRUCTION_NONE 0x00000000U /*!<No instruction*/ | |||
#define QSPI_INSTRUCTION_1_LINE ((uint32_t)QUADSPI_CCR_IMODE_0) /*!<Instruction on a single line*/ | |||
#define QSPI_INSTRUCTION_2_LINES ((uint32_t)QUADSPI_CCR_IMODE_1) /*!<Instruction on two lines*/ | |||
#define QSPI_INSTRUCTION_4_LINES ((uint32_t)QUADSPI_CCR_IMODE) /*!<Instruction on four lines*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_AddressMode QSPI Address Mode | |||
* @{ | |||
*/ | |||
#define QSPI_ADDRESS_NONE 0x00000000U /*!<No address*/ | |||
#define QSPI_ADDRESS_1_LINE ((uint32_t)QUADSPI_CCR_ADMODE_0) /*!<Address on a single line*/ | |||
#define QSPI_ADDRESS_2_LINES ((uint32_t)QUADSPI_CCR_ADMODE_1) /*!<Address on two lines*/ | |||
#define QSPI_ADDRESS_4_LINES ((uint32_t)QUADSPI_CCR_ADMODE) /*!<Address on four lines*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_AlternateBytesMode QSPI Alternate Bytes Mode | |||
* @{ | |||
*/ | |||
#define QSPI_ALTERNATE_BYTES_NONE 0x00000000U /*!<No alternate bytes*/ | |||
#define QSPI_ALTERNATE_BYTES_1_LINE ((uint32_t)QUADSPI_CCR_ABMODE_0) /*!<Alternate bytes on a single line*/ | |||
#define QSPI_ALTERNATE_BYTES_2_LINES ((uint32_t)QUADSPI_CCR_ABMODE_1) /*!<Alternate bytes on two lines*/ | |||
#define QSPI_ALTERNATE_BYTES_4_LINES ((uint32_t)QUADSPI_CCR_ABMODE) /*!<Alternate bytes on four lines*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_DataMode QSPI Data Mode | |||
* @{ | |||
*/ | |||
#define QSPI_DATA_NONE 0x00000000U /*!<No data*/ | |||
#define QSPI_DATA_1_LINE ((uint32_t)QUADSPI_CCR_DMODE_0) /*!<Data on a single line*/ | |||
#define QSPI_DATA_2_LINES ((uint32_t)QUADSPI_CCR_DMODE_1) /*!<Data on two lines*/ | |||
#define QSPI_DATA_4_LINES ((uint32_t)QUADSPI_CCR_DMODE) /*!<Data on four lines*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_DdrMode QSPI DDR Mode | |||
* @{ | |||
*/ | |||
#define QSPI_DDR_MODE_DISABLE 0x00000000U /*!<Double data rate mode disabled*/ | |||
#define QSPI_DDR_MODE_ENABLE ((uint32_t)QUADSPI_CCR_DDRM) /*!<Double data rate mode enabled*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_SIOOMode QSPI Send Instruction Mode | |||
* @{ | |||
*/ | |||
#define QSPI_SIOO_INST_EVERY_CMD 0x00000000U /*!<Send instruction on every transaction*/ | |||
#define QSPI_SIOO_INST_ONLY_FIRST_CMD ((uint32_t)QUADSPI_CCR_SIOO) /*!<Send instruction only for the first command*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_MatchMode QSPI Match Mode | |||
* @{ | |||
*/ | |||
#define QSPI_MATCH_MODE_AND 0x00000000U /*!<AND match mode between unmasked bits*/ | |||
#define QSPI_MATCH_MODE_OR ((uint32_t)QUADSPI_CR_PMM) /*!<OR match mode between unmasked bits*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_AutomaticStop QSPI Automatic Stop | |||
* @{ | |||
*/ | |||
#define QSPI_AUTOMATIC_STOP_DISABLE 0x00000000U /*!<AutoPolling stops only with abort or QSPI disabling*/ | |||
#define QSPI_AUTOMATIC_STOP_ENABLE ((uint32_t)QUADSPI_CR_APMS) /*!<AutoPolling stops as soon as there is a match*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_TimeOutActivation QSPI Timeout Activation | |||
* @{ | |||
*/ | |||
#define QSPI_TIMEOUT_COUNTER_DISABLE 0x00000000U /*!<Timeout counter disabled, nCS remains active*/ | |||
#define QSPI_TIMEOUT_COUNTER_ENABLE ((uint32_t)QUADSPI_CR_TCEN) /*!<Timeout counter enabled, nCS released when timeout expires*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_Flags QSPI Flags | |||
* @{ | |||
*/ | |||
#define QSPI_FLAG_BUSY QUADSPI_SR_BUSY /*!<Busy flag: operation is ongoing*/ | |||
#define QSPI_FLAG_TO QUADSPI_SR_TOF /*!<Timeout flag: timeout occurs in memory-mapped mode*/ | |||
#define QSPI_FLAG_SM QUADSPI_SR_SMF /*!<Status match flag: received data matches in autopolling mode*/ | |||
#define QSPI_FLAG_FT QUADSPI_SR_FTF /*!<Fifo threshold flag: Fifo threshold reached or data left after read from memory is complete*/ | |||
#define QSPI_FLAG_TC QUADSPI_SR_TCF /*!<Transfer complete flag: programmed number of data have been transferred or the transfer has been aborted*/ | |||
#define QSPI_FLAG_TE QUADSPI_SR_TEF /*!<Transfer error flag: invalid address is being accessed*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_Interrupts QSPI Interrupts | |||
* @{ | |||
*/ | |||
#define QSPI_IT_TO QUADSPI_CR_TOIE /*!<Interrupt on the timeout flag*/ | |||
#define QSPI_IT_SM QUADSPI_CR_SMIE /*!<Interrupt on the status match flag*/ | |||
#define QSPI_IT_FT QUADSPI_CR_FTIE /*!<Interrupt on the fifo threshold flag*/ | |||
#define QSPI_IT_TC QUADSPI_CR_TCIE /*!<Interrupt on the transfer complete flag*/ | |||
#define QSPI_IT_TE QUADSPI_CR_TEIE /*!<Interrupt on the transfer error flag*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup QSPI_Timeout_definition QSPI Timeout definition | |||
* @brief QSPI Timeout definition | |||
* @{ | |||
*/ | |||
#define HAL_QPSI_TIMEOUT_DEFAULT_VALUE 5000U /* 5 s */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup QSPI_Exported_Macros QSPI Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset QSPI handle state. | |||
* @param __HANDLE__ : QSPI handle. | |||
* @retval None | |||
*/ | |||
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1) | |||
#define __HAL_QSPI_RESET_HANDLE_STATE(__HANDLE__) do { \ | |||
(__HANDLE__)->State = HAL_QSPI_STATE_RESET; \ | |||
(__HANDLE__)->MspInitCallback = NULL; \ | |||
(__HANDLE__)->MspDeInitCallback = NULL; \ | |||
} while(0) | |||
#else | |||
#define __HAL_QSPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_QSPI_STATE_RESET) | |||
#endif | |||
/** @brief Enable the QSPI peripheral. | |||
* @param __HANDLE__ : specifies the QSPI Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_QSPI_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, QUADSPI_CR_EN) | |||
/** @brief Disable the QSPI peripheral. | |||
* @param __HANDLE__ : specifies the QSPI Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_QSPI_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR, QUADSPI_CR_EN) | |||
/** @brief Enable the specified QSPI interrupt. | |||
* @param __HANDLE__ : specifies the QSPI Handle. | |||
* @param __INTERRUPT__ : specifies the QSPI interrupt source to enable. | |||
* This parameter can be one of the following values: | |||
* @arg QSPI_IT_TO: QSPI Timeout interrupt | |||
* @arg QSPI_IT_SM: QSPI Status match interrupt | |||
* @arg QSPI_IT_FT: QSPI FIFO threshold interrupt | |||
* @arg QSPI_IT_TC: QSPI Transfer complete interrupt | |||
* @arg QSPI_IT_TE: QSPI Transfer error interrupt | |||
* @retval None | |||
*/ | |||
#define __HAL_QSPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__)) | |||
/** @brief Disable the specified QSPI interrupt. | |||
* @param __HANDLE__ : specifies the QSPI Handle. | |||
* @param __INTERRUPT__ : specifies the QSPI interrupt source to disable. | |||
* This parameter can be one of the following values: | |||
* @arg QSPI_IT_TO: QSPI Timeout interrupt | |||
* @arg QSPI_IT_SM: QSPI Status match interrupt | |||
* @arg QSPI_IT_FT: QSPI FIFO threshold interrupt | |||
* @arg QSPI_IT_TC: QSPI Transfer complete interrupt | |||
* @arg QSPI_IT_TE: QSPI Transfer error interrupt | |||
* @retval None | |||
*/ | |||
#define __HAL_QSPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__)) | |||
/** @brief Check whether the specified QSPI interrupt source is enabled or not. | |||
* @param __HANDLE__ : specifies the QSPI Handle. | |||
* @param __INTERRUPT__ : specifies the QSPI interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg QSPI_IT_TO: QSPI Timeout interrupt | |||
* @arg QSPI_IT_SM: QSPI Status match interrupt | |||
* @arg QSPI_IT_FT: QSPI FIFO threshold interrupt | |||
* @arg QSPI_IT_TC: QSPI Transfer complete interrupt | |||
* @arg QSPI_IT_TE: QSPI Transfer error interrupt | |||
* @retval The new state of __INTERRUPT__ (TRUE or FALSE). | |||
*/ | |||
#define __HAL_QSPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (READ_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__)) == (__INTERRUPT__)) | |||
/** | |||
* @brief Check whether the selected QSPI flag is set or not. | |||
* @param __HANDLE__ : specifies the QSPI Handle. | |||
* @param __FLAG__ : specifies the QSPI flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg QSPI_FLAG_BUSY: QSPI Busy flag | |||
* @arg QSPI_FLAG_TO: QSPI Timeout flag | |||
* @arg QSPI_FLAG_SM: QSPI Status match flag | |||
* @arg QSPI_FLAG_FT: QSPI FIFO threshold flag | |||
* @arg QSPI_FLAG_TC: QSPI Transfer complete flag | |||
* @arg QSPI_FLAG_TE: QSPI Transfer error flag | |||
* @retval None | |||
*/ | |||
#define __HAL_QSPI_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BIT((__HANDLE__)->Instance->SR, (__FLAG__)) != 0U) ? SET : RESET) | |||
/** @brief Clears the specified QSPI's flag status. | |||
* @param __HANDLE__ : specifies the QSPI Handle. | |||
* @param __FLAG__ : specifies the QSPI clear register flag that needs to be set | |||
* This parameter can be one of the following values: | |||
* @arg QSPI_FLAG_TO: QSPI Timeout flag | |||
* @arg QSPI_FLAG_SM: QSPI Status match flag | |||
* @arg QSPI_FLAG_TC: QSPI Transfer complete flag | |||
* @arg QSPI_FLAG_TE: QSPI Transfer error flag | |||
* @retval None | |||
*/ | |||
#define __HAL_QSPI_CLEAR_FLAG(__HANDLE__, __FLAG__) WRITE_REG((__HANDLE__)->Instance->FCR, (__FLAG__)) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup QSPI_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup QSPI_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
/* Initialization/de-initialization functions ********************************/ | |||
HAL_StatusTypeDef HAL_QSPI_Init (QSPI_HandleTypeDef *hqspi); | |||
HAL_StatusTypeDef HAL_QSPI_DeInit (QSPI_HandleTypeDef *hqspi); | |||
void HAL_QSPI_MspInit (QSPI_HandleTypeDef *hqspi); | |||
void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup QSPI_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
/* QSPI IRQ handler method */ | |||
void HAL_QSPI_IRQHandler(QSPI_HandleTypeDef *hqspi); | |||
/* QSPI indirect mode */ | |||
HAL_StatusTypeDef HAL_QSPI_Command (QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_QSPI_Transmit (QSPI_HandleTypeDef *hqspi, uint8_t *pData, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_QSPI_Receive (QSPI_HandleTypeDef *hqspi, uint8_t *pData, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_QSPI_Command_IT (QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd); | |||
HAL_StatusTypeDef HAL_QSPI_Transmit_IT (QSPI_HandleTypeDef *hqspi, uint8_t *pData); | |||
HAL_StatusTypeDef HAL_QSPI_Receive_IT (QSPI_HandleTypeDef *hqspi, uint8_t *pData); | |||
HAL_StatusTypeDef HAL_QSPI_Transmit_DMA (QSPI_HandleTypeDef *hqspi, uint8_t *pData); | |||
HAL_StatusTypeDef HAL_QSPI_Receive_DMA (QSPI_HandleTypeDef *hqspi, uint8_t *pData); | |||
/* QSPI status flag polling mode */ | |||
HAL_StatusTypeDef HAL_QSPI_AutoPolling (QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_AutoPollingTypeDef *cfg, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_QSPI_AutoPolling_IT(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_AutoPollingTypeDef *cfg); | |||
/* QSPI memory-mapped mode */ | |||
HAL_StatusTypeDef HAL_QSPI_MemoryMapped(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_MemoryMappedTypeDef *cfg); | |||
/* Callback functions in non-blocking modes ***********************************/ | |||
void HAL_QSPI_ErrorCallback (QSPI_HandleTypeDef *hqspi); | |||
void HAL_QSPI_AbortCpltCallback (QSPI_HandleTypeDef *hqspi); | |||
void HAL_QSPI_FifoThresholdCallback(QSPI_HandleTypeDef *hqspi); | |||
/* QSPI indirect mode */ | |||
void HAL_QSPI_CmdCpltCallback (QSPI_HandleTypeDef *hqspi); | |||
void HAL_QSPI_RxCpltCallback (QSPI_HandleTypeDef *hqspi); | |||
void HAL_QSPI_TxCpltCallback (QSPI_HandleTypeDef *hqspi); | |||
void HAL_QSPI_RxHalfCpltCallback (QSPI_HandleTypeDef *hqspi); | |||
void HAL_QSPI_TxHalfCpltCallback (QSPI_HandleTypeDef *hqspi); | |||
/* QSPI status flag polling mode */ | |||
void HAL_QSPI_StatusMatchCallback (QSPI_HandleTypeDef *hqspi); | |||
/* QSPI memory-mapped mode */ | |||
void HAL_QSPI_TimeOutCallback (QSPI_HandleTypeDef *hqspi); | |||
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1) | |||
/* QSPI callback registering/unregistering */ | |||
HAL_StatusTypeDef HAL_QSPI_RegisterCallback (QSPI_HandleTypeDef *hqspi, HAL_QSPI_CallbackIDTypeDef CallbackId, pQSPI_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_QSPI_UnRegisterCallback (QSPI_HandleTypeDef *hqspi, HAL_QSPI_CallbackIDTypeDef CallbackId); | |||
#endif | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup QSPI_Exported_Functions_Group3 | |||
* @{ | |||
*/ | |||
/* Peripheral Control and State functions ************************************/ | |||
HAL_QSPI_StateTypeDef HAL_QSPI_GetState (QSPI_HandleTypeDef *hqspi); | |||
uint32_t HAL_QSPI_GetError (QSPI_HandleTypeDef *hqspi); | |||
HAL_StatusTypeDef HAL_QSPI_Abort (QSPI_HandleTypeDef *hqspi); | |||
HAL_StatusTypeDef HAL_QSPI_Abort_IT (QSPI_HandleTypeDef *hqspi); | |||
void HAL_QSPI_SetTimeout (QSPI_HandleTypeDef *hqspi, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_QSPI_SetFifoThreshold(QSPI_HandleTypeDef *hqspi, uint32_t Threshold); | |||
uint32_t HAL_QSPI_GetFifoThreshold(QSPI_HandleTypeDef *hqspi); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* End of exported functions -------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup QSPI_Private_Macros QSPI Private Macros | |||
* @{ | |||
*/ | |||
#define IS_QSPI_CLOCK_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFU) | |||
#define IS_QSPI_FIFO_THRESHOLD(THR) (((THR) > 0U) && ((THR) <= 16U)) | |||
#define IS_QSPI_SSHIFT(SSHIFT) (((SSHIFT) == QSPI_SAMPLE_SHIFTING_NONE) || \ | |||
((SSHIFT) == QSPI_SAMPLE_SHIFTING_HALFCYCLE)) | |||
#define IS_QSPI_FLASH_SIZE(FSIZE) (((FSIZE) <= 31U)) | |||
#define IS_QSPI_CS_HIGH_TIME(CSHTIME) (((CSHTIME) == QSPI_CS_HIGH_TIME_1_CYCLE) || \ | |||
((CSHTIME) == QSPI_CS_HIGH_TIME_2_CYCLE) || \ | |||
((CSHTIME) == QSPI_CS_HIGH_TIME_3_CYCLE) || \ | |||
((CSHTIME) == QSPI_CS_HIGH_TIME_4_CYCLE) || \ | |||
((CSHTIME) == QSPI_CS_HIGH_TIME_5_CYCLE) || \ | |||
((CSHTIME) == QSPI_CS_HIGH_TIME_6_CYCLE) || \ | |||
((CSHTIME) == QSPI_CS_HIGH_TIME_7_CYCLE) || \ | |||
((CSHTIME) == QSPI_CS_HIGH_TIME_8_CYCLE)) | |||
#define IS_QSPI_CLOCK_MODE(CLKMODE) (((CLKMODE) == QSPI_CLOCK_MODE_0) || \ | |||
((CLKMODE) == QSPI_CLOCK_MODE_3)) | |||
#define IS_QSPI_INSTRUCTION(INSTRUCTION) ((INSTRUCTION) <= 0xFFU) | |||
#define IS_QSPI_ADDRESS_SIZE(ADDR_SIZE) (((ADDR_SIZE) == QSPI_ADDRESS_8_BITS) || \ | |||
((ADDR_SIZE) == QSPI_ADDRESS_16_BITS) || \ | |||
((ADDR_SIZE) == QSPI_ADDRESS_24_BITS) || \ | |||
((ADDR_SIZE) == QSPI_ADDRESS_32_BITS)) | |||
#define IS_QSPI_ALTERNATE_BYTES_SIZE(SIZE) (((SIZE) == QSPI_ALTERNATE_BYTES_8_BITS) || \ | |||
((SIZE) == QSPI_ALTERNATE_BYTES_16_BITS) || \ | |||
((SIZE) == QSPI_ALTERNATE_BYTES_24_BITS) || \ | |||
((SIZE) == QSPI_ALTERNATE_BYTES_32_BITS)) | |||
#define IS_QSPI_DUMMY_CYCLES(DCY) ((DCY) <= 31U) | |||
#define IS_QSPI_INSTRUCTION_MODE(MODE) (((MODE) == QSPI_INSTRUCTION_NONE) || \ | |||
((MODE) == QSPI_INSTRUCTION_1_LINE) || \ | |||
((MODE) == QSPI_INSTRUCTION_2_LINES) || \ | |||
((MODE) == QSPI_INSTRUCTION_4_LINES)) | |||
#define IS_QSPI_ADDRESS_MODE(MODE) (((MODE) == QSPI_ADDRESS_NONE) || \ | |||
((MODE) == QSPI_ADDRESS_1_LINE) || \ | |||
((MODE) == QSPI_ADDRESS_2_LINES) || \ | |||
((MODE) == QSPI_ADDRESS_4_LINES)) | |||
#define IS_QSPI_ALTERNATE_BYTES_MODE(MODE) (((MODE) == QSPI_ALTERNATE_BYTES_NONE) || \ | |||
((MODE) == QSPI_ALTERNATE_BYTES_1_LINE) || \ | |||
((MODE) == QSPI_ALTERNATE_BYTES_2_LINES) || \ | |||
((MODE) == QSPI_ALTERNATE_BYTES_4_LINES)) | |||
#define IS_QSPI_DATA_MODE(MODE) (((MODE) == QSPI_DATA_NONE) || \ | |||
((MODE) == QSPI_DATA_1_LINE) || \ | |||
((MODE) == QSPI_DATA_2_LINES) || \ | |||
((MODE) == QSPI_DATA_4_LINES)) | |||
#define IS_QSPI_DDR_MODE(DDR_MODE) (((DDR_MODE) == QSPI_DDR_MODE_DISABLE) || \ | |||
((DDR_MODE) == QSPI_DDR_MODE_ENABLE)) | |||
#define IS_QSPI_SIOO_MODE(SIOO_MODE) (((SIOO_MODE) == QSPI_SIOO_INST_EVERY_CMD) || \ | |||
((SIOO_MODE) == QSPI_SIOO_INST_ONLY_FIRST_CMD)) | |||
#define IS_QSPI_INTERVAL(INTERVAL) ((INTERVAL) <= QUADSPI_PIR_INTERVAL) | |||
#define IS_QSPI_STATUS_BYTES_SIZE(SIZE) (((SIZE) >= 1U) && ((SIZE) <= 4U)) | |||
#define IS_QSPI_MATCH_MODE(MODE) (((MODE) == QSPI_MATCH_MODE_AND) || \ | |||
((MODE) == QSPI_MATCH_MODE_OR)) | |||
#define IS_QSPI_AUTOMATIC_STOP(APMS) (((APMS) == QSPI_AUTOMATIC_STOP_DISABLE) || \ | |||
((APMS) == QSPI_AUTOMATIC_STOP_ENABLE)) | |||
#define IS_QSPI_TIMEOUT_ACTIVATION(TCEN) (((TCEN) == QSPI_TIMEOUT_COUNTER_DISABLE) || \ | |||
((TCEN) == QSPI_TIMEOUT_COUNTER_ENABLE)) | |||
#define IS_QSPI_TIMEOUT_PERIOD(PERIOD) ((PERIOD) <= 0xFFFFU) | |||
/** | |||
* @} | |||
*/ | |||
/* End of private macros -----------------------------------------------------*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* defined(QUADSPI) || defined(QUADSPI1) || defined(QUADSPI2) */ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_QSPI_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,378 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_rng.h | |||
* @author MCD Application Team | |||
* @brief Header file of RNG HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_RNG_H | |||
#define STM32WBxx_HAL_RNG_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
#if defined (RNG) | |||
/** @defgroup RNG RNG | |||
* @brief RNG HAL module driver | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup RNG_Exported_Types RNG Exported Types | |||
* @{ | |||
*/ | |||
/** @defgroup RNG_Exported_Types_Group1 RNG Init Structure definition | |||
* @{ | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t ClockErrorDetection; /*!< CED Clock error detection */ | |||
} RNG_InitTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RNG_Exported_Types_Group2 RNG State Structure definition | |||
* @{ | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_RNG_STATE_RESET = 0x00U, /*!< RNG not yet initialized or disabled */ | |||
HAL_RNG_STATE_READY = 0x01U, /*!< RNG initialized and ready for use */ | |||
HAL_RNG_STATE_BUSY = 0x02U, /*!< RNG internal process is ongoing */ | |||
HAL_RNG_STATE_TIMEOUT = 0x03U, /*!< RNG timeout state */ | |||
HAL_RNG_STATE_ERROR = 0x04U /*!< RNG error state */ | |||
} HAL_RNG_StateTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RNG_Exported_Types_Group3 RNG Handle Structure definition | |||
* @{ | |||
*/ | |||
#if (USE_HAL_RNG_REGISTER_CALLBACKS == 1) | |||
typedef struct __RNG_HandleTypeDef | |||
#else | |||
typedef struct | |||
#endif /* (USE_HAL_RNG_REGISTER_CALLBACKS) */ | |||
{ | |||
RNG_TypeDef *Instance; /*!< Register base address */ | |||
RNG_InitTypeDef Init; /*!< RNG configuration parameters */ | |||
HAL_LockTypeDef Lock; /*!< RNG locking object */ | |||
__IO HAL_RNG_StateTypeDef State; /*!< RNG communication state */ | |||
__IO uint32_t ErrorCode; /*!< RNG Error code */ | |||
uint32_t RandomNumber; /*!< Last Generated RNG Data */ | |||
#if (USE_HAL_RNG_REGISTER_CALLBACKS == 1) | |||
void (* ReadyDataCallback)(struct __RNG_HandleTypeDef *hrng, uint32_t random32bit); /*!< RNG Data Ready Callback */ | |||
void (* ErrorCallback)(struct __RNG_HandleTypeDef *hrng); /*!< RNG Error Callback */ | |||
void (* MspInitCallback)(struct __RNG_HandleTypeDef *hrng); /*!< RNG Msp Init callback */ | |||
void (* MspDeInitCallback)(struct __RNG_HandleTypeDef *hrng); /*!< RNG Msp DeInit callback */ | |||
#endif /* USE_HAL_RNG_REGISTER_CALLBACKS */ | |||
} RNG_HandleTypeDef; | |||
#if (USE_HAL_RNG_REGISTER_CALLBACKS == 1) | |||
/** | |||
* @brief HAL RNG Callback ID enumeration definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_RNG_ERROR_CB_ID = 0x00U, /*!< RNG Error Callback ID */ | |||
HAL_RNG_MSPINIT_CB_ID = 0x01U, /*!< RNG MspInit callback ID */ | |||
HAL_RNG_MSPDEINIT_CB_ID = 0x02U /*!< RNG MspDeInit callback ID */ | |||
} HAL_RNG_CallbackIDTypeDef; | |||
/** | |||
* @brief HAL RNG Callback pointer definition | |||
*/ | |||
typedef void (*pRNG_CallbackTypeDef)(RNG_HandleTypeDef *hrng); /*!< pointer to a common RNG callback function */ | |||
typedef void (*pRNG_ReadyDataCallbackTypeDef)(RNG_HandleTypeDef *hrng, uint32_t random32bit); /*!< pointer to an RNG Data Ready specific callback function */ | |||
#endif /* USE_HAL_RNG_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup RNG_Exported_Constants RNG Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup RNG_Exported_Constants_Group1 RNG Interrupt definition | |||
* @{ | |||
*/ | |||
#define RNG_IT_DRDY RNG_SR_DRDY /*!< Data Ready interrupt */ | |||
#define RNG_IT_CEI RNG_SR_CEIS /*!< Clock error interrupt */ | |||
#define RNG_IT_SEI RNG_SR_SEIS /*!< Seed error interrupt */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RNG_Exported_Constants_Group2 RNG Flag definition | |||
* @{ | |||
*/ | |||
#define RNG_FLAG_DRDY RNG_SR_DRDY /*!< Data ready */ | |||
#define RNG_FLAG_CECS RNG_SR_CECS /*!< Clock error current status */ | |||
#define RNG_FLAG_SECS RNG_SR_SECS /*!< Seed error current status */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RNG_Exported_Constants_Group3 RNG Clock Error Detection | |||
* @{ | |||
*/ | |||
#define RNG_CED_ENABLE 0x00000000U /*!< Clock error detection Enabled */ | |||
#define RNG_CED_DISABLE RNG_CR_CED /*!< Clock error detection Disabled */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RNG_Error_Definition RNG Error Definition | |||
* @{ | |||
*/ | |||
#define HAL_RNG_ERROR_NONE 0x00000000U /*!< No error */ | |||
#if (USE_HAL_RNG_REGISTER_CALLBACKS == 1) | |||
#define HAL_RNG_ERROR_INVALID_CALLBACK 0x00000001U /*!< Invalid Callback error */ | |||
#endif /* USE_HAL_RNG_REGISTER_CALLBACKS */ | |||
#define HAL_RNG_ERROR_TIMEOUT 0x00000002U /*!< Timeout error */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup RNG_Exported_Macros RNG Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset RNG handle state | |||
* @param __HANDLE__ RNG Handle | |||
* @retval None | |||
*/ | |||
#if (USE_HAL_RNG_REGISTER_CALLBACKS == 1) | |||
#define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) do{ \ | |||
(__HANDLE__)->State = HAL_RNG_STATE_RESET; \ | |||
(__HANDLE__)->MspInitCallback = NULL; \ | |||
(__HANDLE__)->MspDeInitCallback = NULL; \ | |||
} while(0U) | |||
#else | |||
#define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RNG_STATE_RESET) | |||
#endif /*USE_HAL_RNG_REGISTER_CALLBACKS */ | |||
/** | |||
* @brief Enables the RNG peripheral. | |||
* @param __HANDLE__ RNG Handle | |||
* @retval None | |||
*/ | |||
#define __HAL_RNG_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_RNGEN) | |||
/** | |||
* @brief Disables the RNG peripheral. | |||
* @param __HANDLE__ RNG Handle | |||
* @retval None | |||
*/ | |||
#define __HAL_RNG_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_RNGEN) | |||
/** | |||
* @brief Check the selected RNG flag status. | |||
* @param __HANDLE__ RNG Handle | |||
* @param __FLAG__ RNG flag | |||
* This parameter can be one of the following values: | |||
* @arg RNG_FLAG_DRDY: Data ready | |||
* @arg RNG_FLAG_CECS: Clock error current status | |||
* @arg RNG_FLAG_SECS: Seed error current status | |||
* @retval The new state of __FLAG__ (SET or RESET). | |||
*/ | |||
#define __HAL_RNG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) | |||
/** | |||
* @brief Clears the selected RNG flag status. | |||
* @param __HANDLE__ RNG handle | |||
* @param __FLAG__ RNG flag to clear | |||
* @note WARNING: This is a dummy macro for HAL code alignment, | |||
* flags RNG_FLAG_DRDY, RNG_FLAG_CECS and RNG_FLAG_SECS are read-only. | |||
* @retval None | |||
*/ | |||
#define __HAL_RNG_CLEAR_FLAG(__HANDLE__, __FLAG__) /* dummy macro */ | |||
/** | |||
* @brief Enables the RNG interrupts. | |||
* @param __HANDLE__ RNG Handle | |||
* @retval None | |||
*/ | |||
#define __HAL_RNG_ENABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_IE) | |||
/** | |||
* @brief Disables the RNG interrupts. | |||
* @param __HANDLE__ RNG Handle | |||
* @retval None | |||
*/ | |||
#define __HAL_RNG_DISABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_IE) | |||
/** | |||
* @brief Checks whether the specified RNG interrupt has occurred or not. | |||
* @param __HANDLE__ RNG Handle | |||
* @param __INTERRUPT__ specifies the RNG interrupt status flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg RNG_IT_DRDY: Data ready interrupt | |||
* @arg RNG_IT_CEI: Clock error interrupt | |||
* @arg RNG_IT_SEI: Seed error interrupt | |||
* @retval The new state of __INTERRUPT__ (SET or RESET). | |||
*/ | |||
#define __HAL_RNG_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__)) | |||
/** | |||
* @brief Clear the RNG interrupt status flags. | |||
* @param __HANDLE__ RNG Handle | |||
* @param __INTERRUPT__ specifies the RNG interrupt status flag to clear. | |||
* This parameter can be one of the following values: | |||
* @arg RNG_IT_CEI: Clock error interrupt | |||
* @arg RNG_IT_SEI: Seed error interrupt | |||
* @note RNG_IT_DRDY flag is read-only, reading RNG_DR register automatically clears RNG_IT_DRDY. | |||
* @retval None | |||
*/ | |||
#define __HAL_RNG_CLEAR_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR) = ~(__INTERRUPT__)) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup RNG_Exported_Functions RNG Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup RNG_Exported_Functions_Group1 Initialization and configuration functions | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng); | |||
HAL_StatusTypeDef HAL_RNG_DeInit(RNG_HandleTypeDef *hrng); | |||
void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng); | |||
void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng); | |||
/* Callbacks Register/UnRegister functions ***********************************/ | |||
#if (USE_HAL_RNG_REGISTER_CALLBACKS == 1) | |||
HAL_StatusTypeDef HAL_RNG_RegisterCallback(RNG_HandleTypeDef *hrng, HAL_RNG_CallbackIDTypeDef CallbackID, pRNG_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_RNG_UnRegisterCallback(RNG_HandleTypeDef *hrng, HAL_RNG_CallbackIDTypeDef CallbackID); | |||
HAL_StatusTypeDef HAL_RNG_RegisterReadyDataCallback(RNG_HandleTypeDef *hrng, pRNG_ReadyDataCallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_RNG_UnRegisterReadyDataCallback(RNG_HandleTypeDef *hrng); | |||
#endif /* USE_HAL_RNG_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RNG_Exported_Functions_Group2 Peripheral Control functions | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber(RNG_HandleTypeDef *hrng, uint32_t *random32bit); | |||
HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber_IT(RNG_HandleTypeDef *hrng); | |||
uint32_t HAL_RNG_ReadLastRandomNumber(RNG_HandleTypeDef *hrng); | |||
void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng); | |||
void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng); | |||
void HAL_RNG_ReadyDataCallback(RNG_HandleTypeDef *hrng, uint32_t random32bit); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RNG_Exported_Functions_Group3 Peripheral State functions | |||
* @{ | |||
*/ | |||
HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng); | |||
uint32_t HAL_RNG_GetError(RNG_HandleTypeDef *hrng); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup RNG_Private_Macros RNG Private Macros | |||
* @{ | |||
*/ | |||
#define IS_RNG_IT(IT) (((IT) == RNG_IT_CEI) || \ | |||
((IT) == RNG_IT_SEI)) | |||
#define IS_RNG_FLAG(FLAG) (((FLAG) == RNG_FLAG_DRDY) || \ | |||
((FLAG) == RNG_FLAG_CECS) || \ | |||
((FLAG) == RNG_FLAG_SECS)) | |||
/** | |||
* @brief Verify the RNG Clock Error Detection mode. | |||
* @param __MODE__ RNG Clock Error Detection mode | |||
* @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) | |||
*/ | |||
#define IS_RNG_CED(__MODE__) (((__MODE__) == RNG_CED_ENABLE) || \ | |||
((__MODE__) == RNG_CED_DISABLE)) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* RNG */ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_RNG_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,981 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_rtc.h | |||
* @author MCD Application Team | |||
* @brief Header file of RTC HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_RTC_H | |||
#define STM32WBxx_HAL_RTC_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/* Include low level driver */ | |||
#include "stm32wbxx_ll_exti.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup RTC RTC | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup RTC_Exported_Types RTC Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief HAL State structures definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */ | |||
HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */ | |||
HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */ | |||
HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */ | |||
HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */ | |||
}HAL_RTCStateTypeDef; | |||
/** | |||
* @brief RTC Configuration Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t HourFormat; /*!< Specifies the RTC Hour Format. | |||
This parameter can be a value of @ref RTC_Hour_Formats */ | |||
uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value. | |||
This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */ | |||
uint32_t SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value. | |||
This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */ | |||
uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC output. | |||
This parameter can be a value of @ref RTCEx_Output_selection_Definitions */ | |||
uint32_t OutPutRemap; /*!< Specifies the remap for RTC output. | |||
This parameter can be a value of @ref RTC_Output_ALARM_OUT_Remap */ | |||
uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal. | |||
This parameter can be a value of @ref RTC_Output_Polarity_Definitions */ | |||
uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode. | |||
This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */ | |||
}RTC_InitTypeDef; | |||
/** | |||
* @brief RTC Time structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint8_t Hours; /*!< Specifies the RTC Time Hour. | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected. | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */ | |||
uint8_t Minutes; /*!< Specifies the RTC Time Minutes. | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ | |||
uint8_t Seconds; /*!< Specifies the RTC Time Seconds. | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ | |||
uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time. | |||
This parameter can be a value of @ref RTC_AM_PM_Definitions */ | |||
uint32_t SubSeconds; /*!< Specifies the RTC_SSR RTC Sub Second register content. | |||
This parameter corresponds to a time unit range between [0-1] Second | |||
with [1 Sec / SecondFraction +1] granularity */ | |||
uint32_t SecondFraction; /*!< Specifies the range or granularity of Sub Second register content | |||
corresponding to Synchronous pre-scaler factor value (PREDIV_S) | |||
This parameter corresponds to a time unit range between [0-1] Second | |||
with [1 Sec / SecondFraction +1] granularity. | |||
This field will be used only by HAL_RTC_GetTime function */ | |||
uint32_t DayLightSaving; /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment. | |||
This parameter can be a value of @ref RTC_DayLightSaving_Definitions */ | |||
uint32_t StoreOperation; /*!< Specifies RTC_StoreOperation value to be written in the BCK bit | |||
in CR register to store the operation. | |||
This parameter can be a value of @ref RTC_StoreOperation_Definitions */ | |||
}RTC_TimeTypeDef; | |||
/** | |||
* @brief RTC Date structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay. | |||
This parameter can be a value of @ref RTC_WeekDay_Definitions */ | |||
uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format). | |||
This parameter can be a value of @ref RTC_Month_Date_Definitions */ | |||
uint8_t Date; /*!< Specifies the RTC Date. | |||
This parameter must be a number between Min_Data = 1 and Max_Data = 31 */ | |||
uint8_t Year; /*!< Specifies the RTC Date Year. | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 99 */ | |||
}RTC_DateTypeDef; | |||
/** | |||
* @brief RTC Alarm structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */ | |||
uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks. | |||
This parameter can be a value of @ref RTC_AlarmMask_Definitions */ | |||
uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks. | |||
This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */ | |||
uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay. | |||
This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */ | |||
uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay. | |||
If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range. | |||
If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */ | |||
uint32_t Alarm; /*!< Specifies the alarm . | |||
This parameter can be a value of @ref RTC_Alarms_Definitions */ | |||
}RTC_AlarmTypeDef; | |||
/** | |||
* @brief RTC Handle Structure definition | |||
*/ | |||
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) | |||
typedef struct __RTC_HandleTypeDef | |||
#else | |||
typedef struct | |||
#endif | |||
{ | |||
RTC_TypeDef *Instance; /*!< Register base address */ | |||
RTC_InitTypeDef Init; /*!< RTC required parameters */ | |||
HAL_LockTypeDef Lock; /*!< RTC locking object */ | |||
__IO HAL_RTCStateTypeDef State; /*!< Time communication state */ | |||
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) | |||
void (* AlarmAEventCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC Alarm A Event callback */ | |||
void (* AlarmBEventCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC Alarm B Event callback */ | |||
void (* TimeStampEventCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC TimeStamp Event callback */ | |||
void (* WakeUpTimerEventCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC WakeUpTimer Event callback */ | |||
void (* Tamper1EventCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC Tamper 1 Event callback */ | |||
void (* Tamper2EventCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC Tamper 2 Event callback */ | |||
void (* Tamper3EventCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC Tamper 3 Event callback */ | |||
void (* MspInitCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC Msp Init callback */ | |||
void (* MspDeInitCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC Msp DeInit callback */ | |||
#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */ | |||
}RTC_HandleTypeDef; | |||
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) | |||
/** | |||
* @brief HAL LPTIM Callback ID enumeration definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_RTC_ALARM_A_EVENT_CB_ID = 0x00U, /*!< RTC Alarm A Event Callback ID */ | |||
HAL_RTC_ALARM_B_EVENT_CB_ID = 0x01U, /*!< RTC Alarm B Event Callback ID */ | |||
HAL_RTC_TIMESTAMP_EVENT_CB_ID = 0x02U, /*!< RTC TimeStamp Event Callback ID */ | |||
HAL_RTC_WAKEUPTIMER_EVENT_CB_ID = 0x03U, /*!< RTC WakeUp Timer Event Callback ID */ | |||
HAL_RTC_TAMPER1_EVENT_CB_ID = 0x04U, /*!< RTC Tamper 1 Callback ID */ | |||
HAL_RTC_TAMPER2_EVENT_CB_ID = 0x05U, /*!< RTC Tamper 2 Callback ID */ | |||
HAL_RTC_TAMPER3_EVENT_CB_ID = 0x06U, /*!< RTC Tamper 3 Callback ID */ | |||
HAL_RTC_MSPINIT_CB_ID = 0x0EU, /*!< RTC Msp Init callback ID */ | |||
HAL_RTC_MSPDEINIT_CB_ID = 0x0FU /*!< RTC Msp DeInit callback ID */ | |||
}HAL_RTC_CallbackIDTypeDef; | |||
/** | |||
* @brief HAL RTC Callback pointer definition | |||
*/ | |||
typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef * hrtc); /*!< pointer to an RTC callback function */ | |||
#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup RTC_Exported_Constants RTC Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup RTC_Hour_Formats RTC Hour Formats | |||
* @{ | |||
*/ | |||
#define RTC_HOURFORMAT_24 ((uint32_t)0x00000000U) | |||
#define RTC_HOURFORMAT_12 ((uint32_t)RTC_CR_FMT) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions | |||
* @{ | |||
*/ | |||
#define RTC_OUTPUT_POLARITY_HIGH ((uint32_t)0x00000000U) | |||
#define RTC_OUTPUT_POLARITY_LOW ((uint32_t)RTC_CR_POL) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT | |||
* @{ | |||
*/ | |||
#define RTC_OUTPUT_TYPE_OPENDRAIN ((uint32_t)0x00000000U) | |||
#define RTC_OUTPUT_TYPE_PUSHPULL ((uint32_t)RTC_OR_ALARMOUTTYPE) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_Output_ALARM_OUT_Remap RTC Output ALARM OUT Remap | |||
* @{ | |||
*/ | |||
#define RTC_OUTPUT_REMAP_NONE ((uint32_t)0x00000000U) | |||
#define RTC_OUTPUT_REMAP_POS1 ((uint32_t)RTC_OR_OUT_RMP) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions | |||
* @{ | |||
*/ | |||
#define RTC_HOURFORMAT12_AM ((uint8_t)0x00U) | |||
#define RTC_HOURFORMAT12_PM ((uint8_t)0x40U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_DayLightSaving_Definitions RTC DayLightSaving Definitions | |||
* @{ | |||
*/ | |||
#define RTC_DAYLIGHTSAVING_SUB1H ((uint32_t)RTC_CR_SUB1H) | |||
#define RTC_DAYLIGHTSAVING_ADD1H ((uint32_t)RTC_CR_ADD1H) | |||
#define RTC_DAYLIGHTSAVING_NONE ((uint32_t)0x00000000U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_StoreOperation_Definitions RTC StoreOperation Definitions | |||
* @{ | |||
*/ | |||
#define RTC_STOREOPERATION_RESET ((uint32_t)0x00000000U) | |||
#define RTC_STOREOPERATION_SET ((uint32_t)RTC_CR_BKP) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions | |||
* @{ | |||
*/ | |||
#define RTC_FORMAT_BIN ((uint32_t)0x000000000U) | |||
#define RTC_FORMAT_BCD ((uint32_t)0x000000001U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions | |||
* @{ | |||
*/ | |||
/* Coded in BCD format */ | |||
#define RTC_MONTH_JANUARY ((uint8_t)0x01U) | |||
#define RTC_MONTH_FEBRUARY ((uint8_t)0x02U) | |||
#define RTC_MONTH_MARCH ((uint8_t)0x03U) | |||
#define RTC_MONTH_APRIL ((uint8_t)0x04U) | |||
#define RTC_MONTH_MAY ((uint8_t)0x05U) | |||
#define RTC_MONTH_JUNE ((uint8_t)0x06U) | |||
#define RTC_MONTH_JULY ((uint8_t)0x07U) | |||
#define RTC_MONTH_AUGUST ((uint8_t)0x08U) | |||
#define RTC_MONTH_SEPTEMBER ((uint8_t)0x09U) | |||
#define RTC_MONTH_OCTOBER ((uint8_t)0x10U) | |||
#define RTC_MONTH_NOVEMBER ((uint8_t)0x11U) | |||
#define RTC_MONTH_DECEMBER ((uint8_t)0x12U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions | |||
* @{ | |||
*/ | |||
#define RTC_WEEKDAY_MONDAY ((uint8_t)0x01U) | |||
#define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02U) | |||
#define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03U) | |||
#define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04U) | |||
#define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05U) | |||
#define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06U) | |||
#define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_AlarmDateWeekDay_Definitions RTC AlarmDateWeekDay Definitions | |||
* @{ | |||
*/ | |||
#define RTC_ALARMDATEWEEKDAYSEL_DATE ((uint32_t)0x00000000U) | |||
#define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_AlarmMask_Definitions RTC AlarmMask Definitions | |||
* @{ | |||
*/ | |||
#define RTC_ALARMMASK_NONE ((uint32_t)0x00000000U) | |||
#define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4 | |||
#define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3 | |||
#define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2 | |||
#define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1 | |||
#define RTC_ALARMMASK_ALL ((uint32_t) (RTC_ALARMMASK_NONE | \ | |||
RTC_ALARMMASK_DATEWEEKDAY | \ | |||
RTC_ALARMMASK_HOURS | \ | |||
RTC_ALARMMASK_MINUTES | \ | |||
RTC_ALARMMASK_SECONDS)) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions | |||
* @{ | |||
*/ | |||
#define RTC_ALARM_A RTC_CR_ALRAE | |||
#define RTC_ALARM_B RTC_CR_ALRBE | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions | |||
* @{ | |||
*/ | |||
#define RTC_ALARMSUBSECONDMASK_ALL ((uint32_t)0x00000000U) /*!< All Alarm SS fields are masked. | |||
There is no comparison on sub seconds | |||
for Alarm */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14_1 RTC_ALRMASSR_MASKSS_0 /*!< SS[14:1] are don't care in Alarm | |||
comparison. Only SS[0] is compared. */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14_2 RTC_ALRMASSR_MASKSS_1 /*!< SS[14:2] are don't care in Alarm | |||
comparison. Only SS[1:0] are compared */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14_3 ((uint32_t) (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1)) /*!< SS[14:3] are don't care in Alarm | |||
comparison. Only SS[2:0] are compared */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14_4 RTC_ALRMASSR_MASKSS_2 /*!< SS[14:4] are don't care in Alarm | |||
comparison. Only SS[3:0] are compared */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14_5 ((uint32_t) (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2)) /*!< SS[14:5] are don't care in Alarm | |||
comparison. Only SS[4:0] are compared */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14_6 ((uint32_t) (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)) /*!< SS[14:6] are don't care in Alarm | |||
comparison. Only SS[5:0] are compared */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14_7 ((uint32_t) (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)) /*!< SS[14:7] are don't care in Alarm | |||
` comparison. Only SS[6:0] are compared */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14_8 RTC_ALRMASSR_MASKSS_3 /*!< SS[14:8] are don't care in Alarm | |||
comparison. Only SS[7:0] are compared */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14_9 ((uint32_t) (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3)) /*!< SS[14:9] are don't care in Alarm | |||
comparison. Only SS[8:0] are compared */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14_10 ((uint32_t) (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)) /*!< SS[14:10] are don't care in Alarm | |||
comparison. Only SS[9:0] are compared */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14_11 ((uint32_t) (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)) /*!< SS[14:11] are don't care in Alarm | |||
comparison. Only SS[10:0] are compared */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14_12 ((uint32_t) (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)) /*!< SS[14:12] are don't care in Alarm | |||
comparison.Only SS[11:0] are compared */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14_13 ((uint32_t) (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)) /*!< SS[14:13] are don't care in Alarm | |||
comparison. Only SS[12:0] are compared */ | |||
#define RTC_ALARMSUBSECONDMASK_SS14 ((uint32_t) (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)) /*!< SS[14] is don't care in Alarm | |||
comparison.Only SS[13:0] are compared */ | |||
#define RTC_ALARMSUBSECONDMASK_NONE RTC_ALRMASSR_MASKSS /*!< SS[14:0] are compared and must match | |||
to activate alarm. */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions | |||
* @{ | |||
*/ | |||
#define RTC_IT_TS ((uint32_t)RTC_CR_TSIE) /*!< Enable Timestamp Interrupt */ | |||
#define RTC_IT_WUT ((uint32_t)RTC_CR_WUTIE) /*!< Enable Wakeup timer Interrupt */ | |||
#define RTC_IT_ALRA ((uint32_t)RTC_CR_ALRAIE) /*!< Enable Alarm A Interrupt */ | |||
#define RTC_IT_ALRB ((uint32_t)RTC_CR_ALRBIE) /*!< Enable Alarm B Interrupt */ | |||
#define RTC_IT_TAMP ((uint32_t)RTC_TAMPCR_TAMPIE) /*!< Enable all Tamper Interrupt */ | |||
#if defined(RTC_TAMPER1_SUPPORT) | |||
#define RTC_IT_TAMP1 ((uint32_t)RTC_TAMPCR_TAMP1IE) /*!< Enable Tamper 1 Interrupt */ | |||
#endif | |||
#define RTC_IT_TAMP2 ((uint32_t)RTC_TAMPCR_TAMP2IE) /*!< Enable Tamper 2 Interrupt */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_Flags_Definitions RTC Flags Definitions | |||
* @{ | |||
*/ | |||
#define RTC_FLAG_RECALPF ((uint32_t)RTC_ISR_RECALPF) | |||
#define RTC_FLAG_TAMP2F ((uint32_t)RTC_ISR_TAMP2F) | |||
#if defined(RTC_TAMPER1_SUPPORT) | |||
#define RTC_FLAG_TAMP1F ((uint32_t)RTC_ISR_TAMP1F) | |||
#endif | |||
#define RTC_FLAG_TSOVF ((uint32_t)RTC_ISR_TSOVF) | |||
#define RTC_FLAG_TSF ((uint32_t)RTC_ISR_TSF) | |||
#if defined(RTC_ISR_ITSF) | |||
#define RTC_FLAG_ITSF ((uint32_t)RTC_ISR_ITSF) | |||
#endif | |||
#define RTC_FLAG_WUTF ((uint32_t)RTC_ISR_WUTF) | |||
#define RTC_FLAG_ALRBF ((uint32_t)RTC_ISR_ALRBF) | |||
#define RTC_FLAG_ALRAF ((uint32_t)RTC_ISR_ALRAF) | |||
#define RTC_FLAG_INITF ((uint32_t)RTC_ISR_INITF) | |||
#define RTC_FLAG_RSF ((uint32_t)RTC_ISR_RSF) | |||
#define RTC_FLAG_INITS ((uint32_t)RTC_ISR_INITS) | |||
#define RTC_FLAG_SHPF ((uint32_t)RTC_ISR_SHPF) | |||
#define RTC_FLAG_WUTWF ((uint32_t)RTC_ISR_WUTWF) | |||
#define RTC_FLAG_ALRBWF ((uint32_t)RTC_ISR_ALRBWF) | |||
#define RTC_FLAG_ALRAWF ((uint32_t)RTC_ISR_ALRAWF) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup RTC_Exported_Macros RTC Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset RTC handle state | |||
* @param __HANDLE__ RTC handle. | |||
* @retval None | |||
*/ | |||
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) | |||
#define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\ | |||
(__HANDLE__)->State = HAL_RTC_STATE_RESET;\ | |||
(__HANDLE__)->MspInitCallback = NULL;\ | |||
(__HANDLE__)->MspDeInitCallback = NULL;\ | |||
}while(0) | |||
#else | |||
#define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET) | |||
#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ | |||
/** | |||
* @brief Disable the write protection for RTC registers. | |||
* @param __HANDLE__ specifies the RTC handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \ | |||
do{ \ | |||
(__HANDLE__)->Instance->WPR = 0xCAU; \ | |||
(__HANDLE__)->Instance->WPR = 0x53U; \ | |||
} while(0U) | |||
/** | |||
* @brief Enable the write protection for RTC registers. | |||
* @param __HANDLE__ specifies the RTC handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \ | |||
do{ \ | |||
(__HANDLE__)->Instance->WPR = 0xFFU; \ | |||
} while(0U) | |||
/** | |||
* @brief Enable the RTC ALARMA peripheral. | |||
* @param __HANDLE__ specifies the RTC handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE)) | |||
/** | |||
* @brief Disable the RTC ALARMA peripheral. | |||
* @param __HANDLE__ specifies the RTC handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE)) | |||
/** | |||
* @brief Enable the RTC ALARMB peripheral. | |||
* @param __HANDLE__ specifies the RTC handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE)) | |||
/** | |||
* @brief Disable the RTC ALARMB peripheral. | |||
* @param __HANDLE__ specifies the RTC handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE)) | |||
/** | |||
* @brief Enable the RTC Alarm interrupt. | |||
* @param __HANDLE__ specifies the RTC handle. | |||
* @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. | |||
* This parameter can be any combination of the following values: | |||
* @arg RTC_IT_ALRA: Alarm A interrupt | |||
* @arg RTC_IT_ALRB: Alarm B interrupt | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) | |||
/** | |||
* @brief Disable the RTC Alarm interrupt. | |||
* @param __HANDLE__ specifies the RTC handle. | |||
* @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. | |||
* This parameter can be any combination of the following values: | |||
* @arg RTC_IT_ALRA: Alarm A interrupt | |||
* @arg RTC_IT_ALRB: Alarm B interrupt | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) | |||
/** | |||
* @brief Check whether the specified RTC Alarm interrupt has occurred or not. | |||
* @param __HANDLE__ specifies the RTC handle. | |||
* @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check. | |||
* This parameter can be: | |||
* @arg RTC_IT_ALRA: Alarm A interrupt | |||
* @arg RTC_IT_ALRB: Alarm B interrupt | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR)& ((__INTERRUPT__)>> 4U)) != 0U)? 1U : 0U) | |||
/** | |||
* @brief Check whether the specified RTC Alarm interrupt has been enabled or not. | |||
* @param __HANDLE__ specifies the RTC handle. | |||
* @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check. | |||
* This parameter can be: | |||
* @arg RTC_IT_ALRA: Alarm A interrupt | |||
* @arg RTC_IT_ALRB: Alarm B interrupt | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U) | |||
/** | |||
* @brief Get the selected RTC Alarm's flag status. | |||
* @param __HANDLE__ specifies the RTC handle. | |||
* @param __FLAG__ specifies the RTC Alarm Flag sources to check. | |||
* This parameter can be: | |||
* @arg RTC_FLAG_ALRAF | |||
* @arg RTC_FLAG_ALRBF | |||
* @arg RTC_FLAG_ALRAWF | |||
* @arg RTC_FLAG_ALRBWF | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U)? 1U : 0U) | |||
/** | |||
* @brief Clear the RTC Alarm's pending flags. | |||
* @param __HANDLE__ specifies the RTC handle. | |||
* @param __FLAG__ specifies the RTC Alarm Flag sources to clear. | |||
* This parameter can be: | |||
* @arg RTC_FLAG_ALRAF | |||
* @arg RTC_FLAG_ALRBF | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT) | ((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) | |||
/** | |||
* @brief Enable interrupt on the RTC Alarm associated Exti line by core 1. | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT) | |||
/** | |||
* @brief Enable interrupt on the RTC Alarm associated Exti line by core 2. | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTIC2_ENABLE_IT() (EXTI->C2IMR1 |= RTC_EXTI_LINE_ALARM_EVENT) | |||
/** | |||
* @brief Disable interrupt on the RTC Alarm associated Exti line by core 1. | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) | |||
/** | |||
* @brief Disable interrupt on the RTC Alarm associated Exti line by core 2. | |||
* @retval None | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTIC2_DISABLE_IT() (EXTI->C2IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) | |||
/** | |||
* @brief Enable event on the RTC Alarm associated Exti line by core 1. | |||
* @retval None. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT) | |||
/** | |||
* @brief Enable event on the RTC Alarm associated Exti line by core 2. | |||
* @retval None. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTIC2_ENABLE_EVENT() (EXTI->C2EMR1 |= RTC_EXTI_LINE_ALARM_EVENT) | |||
/** | |||
* @brief Disable event on the RTC Alarm associated Exti line by core 1. | |||
* @retval None. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) | |||
/** | |||
* @brief Disable event on the RTC Alarm associated Exti line by core 2. | |||
* @retval None. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTIC2_DISABLE_EVENT() (EXTI->C2EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) | |||
/*----------------------------*/ | |||
/** | |||
* @brief Enable falling edge trigger on the RTC Alarm associated Exti line. | |||
* @retval None. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_ALARM_EVENT) | |||
/** | |||
* @brief Disable falling edge trigger on the RTC Alarm associated Exti line. | |||
* @retval None. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) | |||
/** | |||
* @brief Enable rising edge trigger on the RTC Alarm associated Exti line. | |||
* @retval None. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_ALARM_EVENT) | |||
/** | |||
* @brief Disable rising edge trigger on the RTC Alarm associated Exti line. | |||
* @retval None. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) | |||
/** | |||
* @brief Enable rising & falling edge trigger on the RTC Alarm associated Exti line. | |||
* @retval None. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ | |||
__HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \ | |||
__HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \ | |||
} while(0U) | |||
/** | |||
* @brief Disable rising & falling edge trigger on the RTC Alarm associated Exti line. | |||
* @retval None. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ | |||
__HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE(); \ | |||
__HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \ | |||
} while(0U) | |||
/** | |||
* @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or notby core 1. | |||
* @retval Line Status. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR1 & RTC_EXTI_LINE_ALARM_EVENT) | |||
/** | |||
* @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not by core 2. | |||
* @retval Line Status. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTIC2_GET_FLAG() (EXTI->PR2 & RTC_EXTI_LINE_ALARM_EVENT) | |||
/** | |||
* @brief Clear the RTC Alarm associated Exti line flag. | |||
* @retval None. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR1 = (RTC_EXTI_LINE_ALARM_EVENT)) | |||
/** | |||
* @brief Clear the RTC Alarm associated Exti line flag. | |||
* @retval None. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTIC2_CLEAR_FLAG() (EXTI->PR2 = (RTC_EXTI_LINE_ALARM_EVENT)) | |||
/*----------------------------*/ | |||
/** | |||
* @brief Generate a Software interrupt on RTC Alarm associated Exti line. | |||
* @retval None. | |||
*/ | |||
#define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_ALARM_EVENT) | |||
/*----------------------------*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Include RTC HAL Extended module */ | |||
#include "stm32wbxx_hal_rtc_ex.h" | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup RTC_Exported_Functions RTC Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions ****************************/ | |||
HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc); | |||
HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc); | |||
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc); | |||
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc); | |||
/* Callbacks Register/UnRegister functions ***********************************/ | |||
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) | |||
HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID); | |||
#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_Exported_Functions_Group2 RTC Time and Date functions | |||
* @{ | |||
*/ | |||
/* RTC Time and Date functions ************************************************/ | |||
HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); | |||
HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); | |||
HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); | |||
HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_Exported_Functions_Group3 RTC Alarm functions | |||
* @{ | |||
*/ | |||
/* RTC Alarm functions ********************************************************/ | |||
HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); | |||
HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); | |||
HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm); | |||
HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format); | |||
void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc); | |||
HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); | |||
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_Exported_Functions_Group4 Peripheral Control functions | |||
* @{ | |||
*/ | |||
/* Peripheral Control functions ***********************************************/ | |||
HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RTC_Exported_Functions_Group5 Peripheral State functions | |||
* @{ | |||
*/ | |||
/* Peripheral State functions *************************************************/ | |||
HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/** @defgroup RTC_Private_Constants RTC Private Constants | |||
* @{ | |||
*/ | |||
/* Masks Definition */ | |||
#define RTC_TR_RESERVED_MASK ((uint32_t) (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | \ | |||
RTC_TR_MNT | RTC_TR_MNU| RTC_TR_ST | \ | |||
RTC_TR_SU)) | |||
#define RTC_DR_RESERVED_MASK ((uint32_t) (RTC_DR_YT | RTC_DR_YU | RTC_DR_WDU | \ | |||
RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | \ | |||
RTC_DR_DU)) | |||
#define RTC_INIT_MASK ((uint32_t)0xFFFFFFFFU) | |||
#define RTC_RSF_MASK ((uint32_t)~(RTC_ISR_INIT | RTC_ISR_RSF)) | |||
#define RTC_TIMEOUT_VALUE 1000U | |||
#define RTC_EXTI_LINE_ALARM_EVENT (LL_EXTI_LINE_17) /*!< External interrupt line connected to the RTC Alarm event */ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup RTC_Private_Macros RTC Private Macros | |||
* @{ | |||
*/ | |||
/** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters | |||
* @{ | |||
*/ | |||
#define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \ | |||
((FORMAT) == RTC_HOURFORMAT_24)) | |||
#define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \ | |||
((POL) == RTC_OUTPUT_POLARITY_LOW)) | |||
#define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \ | |||
((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL)) | |||
#define IS_RTC_OUTPUT_REMAP(REMAP) (((REMAP) == RTC_OUTPUT_REMAP_NONE) || \ | |||
((REMAP) == RTC_OUTPUT_REMAP_POS1)) | |||
#define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || \ | |||
((PM) == RTC_HOURFORMAT12_PM)) | |||
#define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \ | |||
((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \ | |||
((SAVE) == RTC_DAYLIGHTSAVING_NONE)) | |||
#define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \ | |||
((OPERATION) == RTC_STOREOPERATION_SET)) | |||
#define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || ((FORMAT) == RTC_FORMAT_BCD)) | |||
#define IS_RTC_YEAR(YEAR) ((YEAR) <= (uint32_t)99U) | |||
#define IS_RTC_MONTH(MONTH) (((MONTH) >= (uint32_t)1U) && ((MONTH) <= (uint32_t)12U)) | |||
#define IS_RTC_DATE(DATE) (((DATE) >= (uint32_t)1U) && ((DATE) <= (uint32_t)31U)) | |||
#define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ | |||
((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ | |||
((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ | |||
((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ | |||
((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ | |||
((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ | |||
((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) | |||
#define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) >(uint32_t)0U) && ((DATE) <= (uint32_t)31U)) | |||
#define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ | |||
((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ | |||
((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ | |||
((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ | |||
((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ | |||
((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ | |||
((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) | |||
#define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \ | |||
((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY)) | |||
#define IS_RTC_ALARM_MASK(MASK) (((MASK) & ~(RTC_ALARMMASK_ALL)) == 0U) | |||
#define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || ((ALARM) == RTC_ALARM_B)) | |||
#define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS) | |||
#define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == RTC_ALARMSUBSECONDMASK_ALL) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14_1) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14_2) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14_3) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14_4) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14_5) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14_6) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14_7) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14_8) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14_9) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14_10) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14_11) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14_12) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14_13) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_SS14) || \ | |||
((MASK) == RTC_ALARMSUBSECONDMASK_NONE)) | |||
#define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= (uint32_t)0x7FU) | |||
#define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= (uint32_t)0x7FFFU) | |||
#define IS_RTC_HOUR12(HOUR) (((HOUR) > (uint32_t)0U) && ((HOUR) <= (uint32_t)12U)) | |||
#define IS_RTC_HOUR24(HOUR) ((HOUR) <= (uint32_t)23U) | |||
#define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= (uint32_t)59U) | |||
#define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= (uint32_t)59U) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private functions -------------------------------------------------------------*/ | |||
/** @defgroup RTC_Private_Functions RTC Private Functions | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef* hrtc); | |||
uint8_t RTC_ByteToBcd2(uint8_t Value); | |||
uint8_t RTC_Bcd2ToByte(uint8_t Value); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_RTC_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,961 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_sai.h | |||
* @author MCD Application Team | |||
* @brief Header file of SAI HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_SAI_H | |||
#define STM32WBxx_HAL_SAI_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup SAI | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup SAI_Exported_Types SAI Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief HAL State structures definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_SAI_STATE_RESET = 0x00U, /*!< SAI not yet initialized or disabled */ | |||
HAL_SAI_STATE_READY = 0x01U, /*!< SAI initialized and ready for use */ | |||
HAL_SAI_STATE_BUSY = 0x02U, /*!< SAI internal process is ongoing */ | |||
HAL_SAI_STATE_BUSY_TX = 0x12U, /*!< Data transmission process is ongoing */ | |||
HAL_SAI_STATE_BUSY_RX = 0x22U, /*!< Data reception process is ongoing */ | |||
} HAL_SAI_StateTypeDef; | |||
/** | |||
* @brief SAI Callback prototype | |||
*/ | |||
typedef void (*SAIcallback)(void); | |||
/** @defgroup SAI_PDM_Structure_definition SAI PDM Structure definition | |||
* @brief SAI PDM Init structure definition | |||
* @{ | |||
*/ | |||
typedef struct | |||
{ | |||
FunctionalState Activation; /*!< Enable/disable PDM interface */ | |||
uint32_t MicPairsNbr; /*!< Specifies the number of microphone pairs used. | |||
This parameter must be a number between Min_Data = 1 and Max_Data = 3. */ | |||
uint32_t ClockEnable; /*!< Specifies which clock must be enabled. | |||
This parameter can be a values combination of @ref SAI_PDM_ClockEnable */ | |||
} SAI_PdmInitTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Init_Structure_definition SAI Init Structure definition | |||
* @brief SAI Init Structure definition | |||
* @{ | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t AudioMode; /*!< Specifies the SAI Block audio Mode. | |||
This parameter can be a value of @ref SAI_Block_Mode */ | |||
uint32_t Synchro; /*!< Specifies SAI Block synchronization | |||
This parameter can be a value of @ref SAI_Block_Synchronization */ | |||
uint32_t SynchroExt; /*!< Specifies SAI external output synchronization, this setup is common | |||
for BlockA and BlockB | |||
This parameter can be a value of @ref SAI_Block_SyncExt | |||
@note If both audio blocks of same SAI are used, this parameter has | |||
to be set to the same value for each audio block */ | |||
uint32_t MckOutput; /*!< Specifies whether master clock output will be generated or not. | |||
This parameter can be a value of @ref SAI_Block_MckOutput */ | |||
uint32_t OutputDrive; /*!< Specifies when SAI Block outputs are driven. | |||
This parameter can be a value of @ref SAI_Block_Output_Drive | |||
@note This value has to be set before enabling the audio block | |||
but after the audio block configuration. */ | |||
uint32_t NoDivider; /*!< Specifies whether master clock will be divided or not. | |||
This parameter can be a value of @ref SAI_Block_NoDivider | |||
@note If bit NODIV in the SAI_xCR1 register is cleared, the frame length | |||
should be aligned to a number equal to a power of 2, from 8 to 256. | |||
If bit NODIV in the SAI_xCR1 register is set, the frame length can | |||
take any of the values from 8 to 256. */ | |||
uint32_t FIFOThreshold; /*!< Specifies SAI Block FIFO threshold. | |||
This parameter can be a value of @ref SAI_Block_Fifo_Threshold */ | |||
uint32_t AudioFrequency; /*!< Specifies the audio frequency sampling. | |||
This parameter can be a value of @ref SAI_Audio_Frequency */ | |||
uint32_t Mckdiv; /*!< Specifies the master clock divider. | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 63. | |||
@note This parameter is used only if AudioFrequency is set to | |||
SAI_AUDIO_FREQUENCY_MCKDIV otherwise it is internally computed. */ | |||
uint32_t MckOverSampling; /*!< Specifies the master clock oversampling. | |||
This parameter can be a value of @ref SAI_Block_Mck_OverSampling */ | |||
uint32_t MonoStereoMode; /*!< Specifies if the mono or stereo mode is selected. | |||
This parameter can be a value of @ref SAI_Mono_Stereo_Mode */ | |||
uint32_t CompandingMode; /*!< Specifies the companding mode type. | |||
This parameter can be a value of @ref SAI_Block_Companding_Mode */ | |||
uint32_t TriState; /*!< Specifies the companding mode type. | |||
This parameter can be a value of @ref SAI_TRIState_Management */ | |||
SAI_PdmInitTypeDef PdmInit; /*!< Specifies the PDM configuration. */ | |||
/* This part of the structure is automatically filled if your are using the high level initialisation | |||
function HAL_SAI_InitProtocol */ | |||
uint32_t Protocol; /*!< Specifies the SAI Block protocol. | |||
This parameter can be a value of @ref SAI_Block_Protocol */ | |||
uint32_t DataSize; /*!< Specifies the SAI Block data size. | |||
This parameter can be a value of @ref SAI_Block_Data_Size */ | |||
uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. | |||
This parameter can be a value of @ref SAI_Block_MSB_LSB_transmission */ | |||
uint32_t ClockStrobing; /*!< Specifies the SAI Block clock strobing edge sensitivity. | |||
This parameter can be a value of @ref SAI_Block_Clock_Strobing */ | |||
} SAI_InitTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Frame_Structure_definition SAI Frame Structure definition | |||
* @brief SAI Frame Init structure definition | |||
* @{ | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t FrameLength; /*!< Specifies the Frame length, the number of SCK clocks for each audio frame. | |||
This parameter must be a number between Min_Data = 8 and Max_Data = 256. | |||
@note If master clock MCLK_x pin is declared as an output, the frame length | |||
should be aligned to a number equal to power of 2 in order to keep | |||
in an audio frame, an integer number of MCLK pulses by bit Clock. */ | |||
uint32_t ActiveFrameLength; /*!< Specifies the Frame synchronization active level length. | |||
This Parameter specifies the length in number of bit clock (SCK + 1) | |||
of the active level of FS signal in audio frame. | |||
This parameter must be a number between Min_Data = 1 and Max_Data = 128 */ | |||
uint32_t FSDefinition; /*!< Specifies the Frame synchronization definition. | |||
This parameter can be a value of @ref SAI_Block_FS_Definition */ | |||
uint32_t FSPolarity; /*!< Specifies the Frame synchronization Polarity. | |||
This parameter can be a value of @ref SAI_Block_FS_Polarity */ | |||
uint32_t FSOffset; /*!< Specifies the Frame synchronization Offset. | |||
This parameter can be a value of @ref SAI_Block_FS_Offset */ | |||
} SAI_FrameInitTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Slot_Structure_definition SAI Slot Structure definition | |||
* @brief SAI Block Slot Init Structure definition | |||
* @{ | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t FirstBitOffset; /*!< Specifies the position of first data transfer bit in the slot. | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 24 */ | |||
uint32_t SlotSize; /*!< Specifies the Slot Size. | |||
This parameter can be a value of @ref SAI_Block_Slot_Size */ | |||
uint32_t SlotNumber; /*!< Specifies the number of slot in the audio frame. | |||
This parameter must be a number between Min_Data = 1 and Max_Data = 16 */ | |||
uint32_t SlotActive; /*!< Specifies the slots in audio frame that will be activated. | |||
This parameter can be a value of @ref SAI_Block_Slot_Active */ | |||
} SAI_SlotInitTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Handle_Structure_definition SAI Handle Structure definition | |||
* @brief SAI handle Structure definition | |||
* @{ | |||
*/ | |||
typedef struct __SAI_HandleTypeDef | |||
{ | |||
SAI_Block_TypeDef *Instance; /*!< SAI Blockx registers base address */ | |||
SAI_InitTypeDef Init; /*!< SAI communication parameters */ | |||
SAI_FrameInitTypeDef FrameInit; /*!< SAI Frame configuration parameters */ | |||
SAI_SlotInitTypeDef SlotInit; /*!< SAI Slot configuration parameters */ | |||
uint8_t *pBuffPtr; /*!< Pointer to SAI transfer Buffer */ | |||
uint16_t XferSize; /*!< SAI transfer size */ | |||
uint16_t XferCount; /*!< SAI transfer counter */ | |||
DMA_HandleTypeDef *hdmatx; /*!< SAI Tx DMA handle parameters */ | |||
DMA_HandleTypeDef *hdmarx; /*!< SAI Rx DMA handle parameters */ | |||
SAIcallback mutecallback; /*!< SAI mute callback */ | |||
void (*InterruptServiceRoutine)(struct __SAI_HandleTypeDef *hsai); /* function pointer for IRQ handler */ | |||
HAL_LockTypeDef Lock; /*!< SAI locking object */ | |||
__IO HAL_SAI_StateTypeDef State; /*!< SAI communication state */ | |||
__IO uint32_t ErrorCode; /*!< SAI Error code */ | |||
#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1) | |||
void (*RxCpltCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI receive complete callback */ | |||
void (*RxHalfCpltCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI receive half complete callback */ | |||
void (*TxCpltCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI transmit complete callback */ | |||
void (*TxHalfCpltCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI transmit half complete callback */ | |||
void (*ErrorCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI error callback */ | |||
void (*MspInitCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI MSP init callback */ | |||
void (*MspDeInitCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI MSP de-init callback */ | |||
#endif | |||
} SAI_HandleTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1) | |||
/** | |||
* @brief SAI callback ID enumeration definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_SAI_RX_COMPLETE_CB_ID = 0x00U, /*!< SAI receive complete callback ID */ | |||
HAL_SAI_RX_HALFCOMPLETE_CB_ID = 0x01U, /*!< SAI receive half complete callback ID */ | |||
HAL_SAI_TX_COMPLETE_CB_ID = 0x02U, /*!< SAI transmit complete callback ID */ | |||
HAL_SAI_TX_HALFCOMPLETE_CB_ID = 0x03U, /*!< SAI transmit half complete callback ID */ | |||
HAL_SAI_ERROR_CB_ID = 0x04U, /*!< SAI error callback ID */ | |||
HAL_SAI_MSPINIT_CB_ID = 0x05U, /*!< SAI MSP init callback ID */ | |||
HAL_SAI_MSPDEINIT_CB_ID = 0x06U /*!< SAI MSP de-init callback ID */ | |||
} HAL_SAI_CallbackIDTypeDef; | |||
/** | |||
* @brief SAI callback pointer definition | |||
*/ | |||
typedef void (*pSAI_CallbackTypeDef)(SAI_HandleTypeDef *hsai); | |||
#endif | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup SAI_Exported_Constants SAI Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup SAI_Error_Code SAI Error Code | |||
* @{ | |||
*/ | |||
#define HAL_SAI_ERROR_NONE 0x00000000U /*!< No error */ | |||
#define HAL_SAI_ERROR_OVR 0x00000001U /*!< Overrun Error */ | |||
#define HAL_SAI_ERROR_UDR 0x00000002U /*!< Underrun error */ | |||
#define HAL_SAI_ERROR_AFSDET 0x00000004U /*!< Anticipated Frame synchronisation detection */ | |||
#define HAL_SAI_ERROR_LFSDET 0x00000008U /*!< Late Frame synchronisation detection */ | |||
#define HAL_SAI_ERROR_CNREADY 0x00000010U /*!< codec not ready */ | |||
#define HAL_SAI_ERROR_WCKCFG 0x00000020U /*!< Wrong clock configuration */ | |||
#define HAL_SAI_ERROR_TIMEOUT 0x00000040U /*!< Timeout error */ | |||
#define HAL_SAI_ERROR_DMA 0x00000080U /*!< DMA error */ | |||
#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1) | |||
#define HAL_SAI_ERROR_INVALID_CALLBACK 0x00000100U /*!< Invalid callback error */ | |||
#endif | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_SyncExt SAI External synchronisation | |||
* @{ | |||
*/ | |||
#define SAI_SYNCEXT_DISABLE 0U | |||
#define SAI_SYNCEXT_OUTBLOCKA_ENABLE 1U | |||
#define SAI_SYNCEXT_OUTBLOCKB_ENABLE 2U | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_MckOutput SAI Block Master Clock Output | |||
* @{ | |||
*/ | |||
#define SAI_MCK_OUTPUT_DISABLE 0x00000000U | |||
#define SAI_MCK_OUTPUT_ENABLE SAI_xCR1_MCKEN | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Protocol SAI Supported protocol | |||
* @{ | |||
*/ | |||
#define SAI_I2S_STANDARD 0U | |||
#define SAI_I2S_MSBJUSTIFIED 1U | |||
#define SAI_I2S_LSBJUSTIFIED 2U | |||
#define SAI_PCM_LONG 3U | |||
#define SAI_PCM_SHORT 4U | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Protocol_DataSize SAI protocol data size | |||
* @{ | |||
*/ | |||
#define SAI_PROTOCOL_DATASIZE_16BIT 0U | |||
#define SAI_PROTOCOL_DATASIZE_16BITEXTENDED 1U | |||
#define SAI_PROTOCOL_DATASIZE_24BIT 2U | |||
#define SAI_PROTOCOL_DATASIZE_32BIT 3U | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Audio_Frequency SAI Audio Frequency | |||
* @{ | |||
*/ | |||
#define SAI_AUDIO_FREQUENCY_192K 192000U | |||
#define SAI_AUDIO_FREQUENCY_96K 96000U | |||
#define SAI_AUDIO_FREQUENCY_48K 48000U | |||
#define SAI_AUDIO_FREQUENCY_44K 44100U | |||
#define SAI_AUDIO_FREQUENCY_32K 32000U | |||
#define SAI_AUDIO_FREQUENCY_22K 22050U | |||
#define SAI_AUDIO_FREQUENCY_16K 16000U | |||
#define SAI_AUDIO_FREQUENCY_11K 11025U | |||
#define SAI_AUDIO_FREQUENCY_8K 8000U | |||
#define SAI_AUDIO_FREQUENCY_MCKDIV 0U | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Mck_OverSampling SAI Block Master Clock OverSampling | |||
* @{ | |||
*/ | |||
#define SAI_MCK_OVERSAMPLING_DISABLE 0x00000000U | |||
#define SAI_MCK_OVERSAMPLING_ENABLE SAI_xCR1_OSR | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_PDM_ClockEnable SAI PDM Clock Enable | |||
* @{ | |||
*/ | |||
#define SAI_PDM_CLOCK1_ENABLE SAI_PDMCR_CKEN1 | |||
#define SAI_PDM_CLOCK2_ENABLE SAI_PDMCR_CKEN2 | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Mode SAI Block Mode | |||
* @{ | |||
*/ | |||
#define SAI_MODEMASTER_TX 0x00000000U | |||
#define SAI_MODEMASTER_RX SAI_xCR1_MODE_0 | |||
#define SAI_MODESLAVE_TX SAI_xCR1_MODE_1 | |||
#define SAI_MODESLAVE_RX (SAI_xCR1_MODE_1 | SAI_xCR1_MODE_0) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Protocol SAI Block Protocol | |||
* @{ | |||
*/ | |||
#define SAI_FREE_PROTOCOL 0x00000000U | |||
#define SAI_SPDIF_PROTOCOL SAI_xCR1_PRTCFG_0 | |||
#define SAI_AC97_PROTOCOL SAI_xCR1_PRTCFG_1 | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Data_Size SAI Block Data Size | |||
* @{ | |||
*/ | |||
#define SAI_DATASIZE_8 SAI_xCR1_DS_1 | |||
#define SAI_DATASIZE_10 (SAI_xCR1_DS_1 | SAI_xCR1_DS_0) | |||
#define SAI_DATASIZE_16 SAI_xCR1_DS_2 | |||
#define SAI_DATASIZE_20 (SAI_xCR1_DS_2 | SAI_xCR1_DS_0) | |||
#define SAI_DATASIZE_24 (SAI_xCR1_DS_2 | SAI_xCR1_DS_1) | |||
#define SAI_DATASIZE_32 (SAI_xCR1_DS_2 | SAI_xCR1_DS_1 | SAI_xCR1_DS_0) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_MSB_LSB_transmission SAI Block MSB LSB transmission | |||
* @{ | |||
*/ | |||
#define SAI_FIRSTBIT_MSB 0x00000000U | |||
#define SAI_FIRSTBIT_LSB SAI_xCR1_LSBFIRST | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Clock_Strobing SAI Block Clock Strobing | |||
* @{ | |||
*/ | |||
#define SAI_CLOCKSTROBING_FALLINGEDGE 0U | |||
#define SAI_CLOCKSTROBING_RISINGEDGE 1U | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Synchronization SAI Block Synchronization | |||
* @{ | |||
*/ | |||
#define SAI_ASYNCHRONOUS 0U /*!< Asynchronous */ | |||
#define SAI_SYNCHRONOUS 1U /*!< Synchronous with other block of same SAI */ | |||
#define SAI_SYNCHRONOUS_EXT_SAI1 2U /*!< Synchronous with other SAI, SAI1 */ | |||
#define SAI_SYNCHRONOUS_EXT_SAI2 3U /*!< Synchronous with other SAI, SAI2 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Output_Drive SAI Block Output Drive | |||
* @{ | |||
*/ | |||
#define SAI_OUTPUTDRIVE_DISABLE 0x00000000U | |||
#define SAI_OUTPUTDRIVE_ENABLE SAI_xCR1_OUTDRIV | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_NoDivider SAI Block NoDivider | |||
* @{ | |||
*/ | |||
#define SAI_MASTERDIVIDER_ENABLE 0x00000000U | |||
#define SAI_MASTERDIVIDER_DISABLE SAI_xCR1_NODIV | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_FS_Definition SAI Block FS Definition | |||
* @{ | |||
*/ | |||
#define SAI_FS_STARTFRAME 0x00000000U | |||
#define SAI_FS_CHANNEL_IDENTIFICATION SAI_xFRCR_FSDEF | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_FS_Polarity SAI Block FS Polarity | |||
* @{ | |||
*/ | |||
#define SAI_FS_ACTIVE_LOW 0x00000000U | |||
#define SAI_FS_ACTIVE_HIGH SAI_xFRCR_FSPOL | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_FS_Offset SAI Block FS Offset | |||
* @{ | |||
*/ | |||
#define SAI_FS_FIRSTBIT 0x00000000U | |||
#define SAI_FS_BEFOREFIRSTBIT SAI_xFRCR_FSOFF | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Slot_Size SAI Block Slot Size | |||
* @{ | |||
*/ | |||
#define SAI_SLOTSIZE_DATASIZE 0x00000000U | |||
#define SAI_SLOTSIZE_16B SAI_xSLOTR_SLOTSZ_0 | |||
#define SAI_SLOTSIZE_32B SAI_xSLOTR_SLOTSZ_1 | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Slot_Active SAI Block Slot Active | |||
* @{ | |||
*/ | |||
#define SAI_SLOT_NOTACTIVE 0x00000000U | |||
#define SAI_SLOTACTIVE_0 0x00000001U | |||
#define SAI_SLOTACTIVE_1 0x00000002U | |||
#define SAI_SLOTACTIVE_2 0x00000004U | |||
#define SAI_SLOTACTIVE_3 0x00000008U | |||
#define SAI_SLOTACTIVE_4 0x00000010U | |||
#define SAI_SLOTACTIVE_5 0x00000020U | |||
#define SAI_SLOTACTIVE_6 0x00000040U | |||
#define SAI_SLOTACTIVE_7 0x00000080U | |||
#define SAI_SLOTACTIVE_8 0x00000100U | |||
#define SAI_SLOTACTIVE_9 0x00000200U | |||
#define SAI_SLOTACTIVE_10 0x00000400U | |||
#define SAI_SLOTACTIVE_11 0x00000800U | |||
#define SAI_SLOTACTIVE_12 0x00001000U | |||
#define SAI_SLOTACTIVE_13 0x00002000U | |||
#define SAI_SLOTACTIVE_14 0x00004000U | |||
#define SAI_SLOTACTIVE_15 0x00008000U | |||
#define SAI_SLOTACTIVE_ALL 0x0000FFFFU | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Mono_Stereo_Mode SAI Mono Stereo Mode | |||
* @{ | |||
*/ | |||
#define SAI_STEREOMODE 0x00000000U | |||
#define SAI_MONOMODE SAI_xCR1_MONO | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_TRIState_Management SAI TRIState Management | |||
* @{ | |||
*/ | |||
#define SAI_OUTPUT_NOTRELEASED 0x00000000U | |||
#define SAI_OUTPUT_RELEASED SAI_xCR2_TRIS | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Fifo_Threshold SAI Block Fifo Threshold | |||
* @{ | |||
*/ | |||
#define SAI_FIFOTHRESHOLD_EMPTY 0x00000000U | |||
#define SAI_FIFOTHRESHOLD_1QF SAI_xCR2_FTH_0 | |||
#define SAI_FIFOTHRESHOLD_HF SAI_xCR2_FTH_1 | |||
#define SAI_FIFOTHRESHOLD_3QF (SAI_xCR2_FTH_1 | SAI_xCR2_FTH_0) | |||
#define SAI_FIFOTHRESHOLD_FULL SAI_xCR2_FTH_2 | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Companding_Mode SAI Block Companding Mode | |||
* @{ | |||
*/ | |||
#define SAI_NOCOMPANDING 0x00000000U | |||
#define SAI_ULAW_1CPL_COMPANDING SAI_xCR2_COMP_1 | |||
#define SAI_ALAW_1CPL_COMPANDING (SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0) | |||
#define SAI_ULAW_2CPL_COMPANDING (SAI_xCR2_COMP_1 | SAI_xCR2_CPL) | |||
#define SAI_ALAW_2CPL_COMPANDING (SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0 | SAI_xCR2_CPL) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Mute_Value SAI Block Mute Value | |||
* @{ | |||
*/ | |||
#define SAI_ZERO_VALUE 0x00000000U | |||
#define SAI_LAST_SENT_VALUE SAI_xCR2_MUTEVAL | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Interrupts_Definition SAI Block Interrupts Definition | |||
* @{ | |||
*/ | |||
#define SAI_IT_OVRUDR SAI_xIMR_OVRUDRIE | |||
#define SAI_IT_MUTEDET SAI_xIMR_MUTEDETIE | |||
#define SAI_IT_WCKCFG SAI_xIMR_WCKCFGIE | |||
#define SAI_IT_FREQ SAI_xIMR_FREQIE | |||
#define SAI_IT_CNRDY SAI_xIMR_CNRDYIE | |||
#define SAI_IT_AFSDET SAI_xIMR_AFSDETIE | |||
#define SAI_IT_LFSDET SAI_xIMR_LFSDETIE | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Flags_Definition SAI Block Flags Definition | |||
* @{ | |||
*/ | |||
#define SAI_FLAG_OVRUDR SAI_xSR_OVRUDR | |||
#define SAI_FLAG_MUTEDET SAI_xSR_MUTEDET | |||
#define SAI_FLAG_WCKCFG SAI_xSR_WCKCFG | |||
#define SAI_FLAG_FREQ SAI_xSR_FREQ | |||
#define SAI_FLAG_CNRDY SAI_xSR_CNRDY | |||
#define SAI_FLAG_AFSDET SAI_xSR_AFSDET | |||
#define SAI_FLAG_LFSDET SAI_xSR_LFSDET | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SAI_Block_Fifo_Status_Level SAI Block Fifo Status Level | |||
* @{ | |||
*/ | |||
#define SAI_FIFOSTATUS_EMPTY 0x00000000U | |||
#define SAI_FIFOSTATUS_LESS1QUARTERFULL 0x00010000U | |||
#define SAI_FIFOSTATUS_1QUARTERFULL 0x00020000U | |||
#define SAI_FIFOSTATUS_HALFFULL 0x00030000U | |||
#define SAI_FIFOSTATUS_3QUARTERFULL 0x00040000U | |||
#define SAI_FIFOSTATUS_FULL 0x00050000U | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup SAI_Exported_Macros SAI Exported Macros | |||
* @brief macros to handle interrupts and specific configurations | |||
* @{ | |||
*/ | |||
/** @brief Reset SAI handle state. | |||
* @param __HANDLE__ specifies the SAI Handle. | |||
* @retval None | |||
*/ | |||
#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1) | |||
#define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) do{ \ | |||
(__HANDLE__)->State = HAL_SAI_STATE_RESET; \ | |||
(__HANDLE__)->MspInitCallback = NULL; \ | |||
(__HANDLE__)->MspDeInitCallback = NULL; \ | |||
} while(0) | |||
#else | |||
#define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SAI_STATE_RESET) | |||
#endif | |||
/** @brief Enable the specified SAI interrupts. | |||
* @param __HANDLE__ specifies the SAI Handle. | |||
* @param __INTERRUPT__ specifies the interrupt source to enable or disable. | |||
* This parameter can be one of the following values: | |||
* @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable | |||
* @arg SAI_IT_MUTEDET: Mute detection interrupt enable | |||
* @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable | |||
* @arg SAI_IT_FREQ: FIFO request interrupt enable | |||
* @arg SAI_IT_CNRDY: Codec not ready interrupt enable | |||
* @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable | |||
* @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enable | |||
* @retval None | |||
*/ | |||
#define __HAL_SAI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__)) | |||
/** @brief Disable the specified SAI interrupts. | |||
* @param __HANDLE__ specifies the SAI Handle. | |||
* @param __INTERRUPT__ specifies the interrupt source to enable or disable. | |||
* This parameter can be one of the following values: | |||
* @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable | |||
* @arg SAI_IT_MUTEDET: Mute detection interrupt enable | |||
* @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable | |||
* @arg SAI_IT_FREQ: FIFO request interrupt enable | |||
* @arg SAI_IT_CNRDY: Codec not ready interrupt enable | |||
* @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable | |||
* @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enable | |||
* @retval None | |||
*/ | |||
#define __HAL_SAI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR &= (~(__INTERRUPT__))) | |||
/** @brief Check whether the specified SAI interrupt source is enabled or not. | |||
* @param __HANDLE__ specifies the SAI Handle. | |||
* @param __INTERRUPT__ specifies the SAI interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable | |||
* @arg SAI_IT_MUTEDET: Mute detection interrupt enable | |||
* @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable | |||
* @arg SAI_IT_FREQ: FIFO request interrupt enable | |||
* @arg SAI_IT_CNRDY: Codec not ready interrupt enable | |||
* @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable | |||
* @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enable | |||
* @retval The new state of __INTERRUPT__ (TRUE or FALSE). | |||
*/ | |||
#define __HAL_SAI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
/** @brief Check whether the specified SAI flag is set or not. | |||
* @param __HANDLE__ specifies the SAI Handle. | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg SAI_FLAG_OVRUDR: Overrun underrun flag. | |||
* @arg SAI_FLAG_MUTEDET: Mute detection flag. | |||
* @arg SAI_FLAG_WCKCFG: Wrong Clock Configuration flag. | |||
* @arg SAI_FLAG_FREQ: FIFO request flag. | |||
* @arg SAI_FLAG_CNRDY: Codec not ready flag. | |||
* @arg SAI_FLAG_AFSDET: Anticipated frame synchronization detection flag. | |||
* @arg SAI_FLAG_LFSDET: Late frame synchronization detection flag. | |||
* @retval The new state of __FLAG__ (TRUE or FALSE). | |||
*/ | |||
#define __HAL_SAI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) | |||
/** @brief Clear the specified SAI pending flag. | |||
* @param __HANDLE__ specifies the SAI Handle. | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be any combination of the following values: | |||
* @arg SAI_FLAG_OVRUDR: Clear Overrun underrun | |||
* @arg SAI_FLAG_MUTEDET: Clear Mute detection | |||
* @arg SAI_FLAG_WCKCFG: Clear Wrong Clock Configuration | |||
* @arg SAI_FLAG_FREQ: Clear FIFO request | |||
* @arg SAI_FLAG_CNRDY: Clear Codec not ready | |||
* @arg SAI_FLAG_AFSDET: Clear Anticipated frame synchronization detection | |||
* @arg SAI_FLAG_LFSDET: Clear Late frame synchronization detection | |||
* | |||
* @retval None | |||
*/ | |||
#define __HAL_SAI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CLRFR = (__FLAG__)) | |||
/** @brief Enable SAI. | |||
* @param __HANDLE__ specifies the SAI Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_SAI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SAI_xCR1_SAIEN) | |||
/** @brief Disable SAI. | |||
* @param __HANDLE__ specifies the SAI Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_SAI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SAI_xCR1_SAIEN) | |||
/** | |||
* @} | |||
*/ | |||
/* Include SAI HAL Extension module */ | |||
#include "stm32wbxx_hal_sai_ex.h" | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup SAI_Exported_Functions | |||
* @{ | |||
*/ | |||
/* Initialization/de-initialization functions ********************************/ | |||
/** @addtogroup SAI_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_SAI_InitProtocol(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot); | |||
HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai); | |||
HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai); | |||
void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai); | |||
void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai); | |||
#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1) | |||
/* SAI callbacks register/unregister functions ********************************/ | |||
HAL_StatusTypeDef HAL_SAI_RegisterCallback(SAI_HandleTypeDef *hsai, | |||
HAL_SAI_CallbackIDTypeDef CallbackID, | |||
pSAI_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_SAI_UnRegisterCallback(SAI_HandleTypeDef *hsai, | |||
HAL_SAI_CallbackIDTypeDef CallbackID); | |||
#endif | |||
/** | |||
* @} | |||
*/ | |||
/* I/O operation functions ***************************************************/ | |||
/** @addtogroup SAI_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
/* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
/* Non-Blocking mode: Interrupt */ | |||
HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size); | |||
/* Non-Blocking mode: DMA */ | |||
HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai); | |||
HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai); | |||
HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai); | |||
/* Abort function */ | |||
HAL_StatusTypeDef HAL_SAI_Abort(SAI_HandleTypeDef *hsai); | |||
/* Mute management */ | |||
HAL_StatusTypeDef HAL_SAI_EnableTxMuteMode(SAI_HandleTypeDef *hsai, uint16_t val); | |||
HAL_StatusTypeDef HAL_SAI_DisableTxMuteMode(SAI_HandleTypeDef *hsai); | |||
HAL_StatusTypeDef HAL_SAI_EnableRxMuteMode(SAI_HandleTypeDef *hsai, SAIcallback callback, uint16_t counter); | |||
HAL_StatusTypeDef HAL_SAI_DisableRxMuteMode(SAI_HandleTypeDef *hsai); | |||
/* SAI IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */ | |||
void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai); | |||
void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai); | |||
void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai); | |||
void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai); | |||
void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai); | |||
void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup SAI_Exported_Functions_Group3 | |||
* @{ | |||
*/ | |||
/* Peripheral State functions ************************************************/ | |||
HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai); | |||
uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup SAI_Private_Macros SAI Private Macros | |||
* @{ | |||
*/ | |||
#define IS_SAI_BLOCK_SYNCEXT(STATE) (((STATE) == SAI_SYNCEXT_DISABLE) ||\ | |||
((STATE) == SAI_SYNCEXT_OUTBLOCKA_ENABLE) ||\ | |||
((STATE) == SAI_SYNCEXT_OUTBLOCKB_ENABLE)) | |||
#define IS_SAI_SUPPORTED_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_I2S_STANDARD) ||\ | |||
((PROTOCOL) == SAI_I2S_MSBJUSTIFIED) ||\ | |||
((PROTOCOL) == SAI_I2S_LSBJUSTIFIED) ||\ | |||
((PROTOCOL) == SAI_PCM_LONG) ||\ | |||
((PROTOCOL) == SAI_PCM_SHORT)) | |||
#define IS_SAI_PROTOCOL_DATASIZE(DATASIZE) (((DATASIZE) == SAI_PROTOCOL_DATASIZE_16BIT) ||\ | |||
((DATASIZE) == SAI_PROTOCOL_DATASIZE_16BITEXTENDED) ||\ | |||
((DATASIZE) == SAI_PROTOCOL_DATASIZE_24BIT) ||\ | |||
((DATASIZE) == SAI_PROTOCOL_DATASIZE_32BIT)) | |||
#define IS_SAI_AUDIO_FREQUENCY(AUDIO) (((AUDIO) == SAI_AUDIO_FREQUENCY_192K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_96K) || \ | |||
((AUDIO) == SAI_AUDIO_FREQUENCY_48K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_44K) || \ | |||
((AUDIO) == SAI_AUDIO_FREQUENCY_32K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_22K) || \ | |||
((AUDIO) == SAI_AUDIO_FREQUENCY_16K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_11K) || \ | |||
((AUDIO) == SAI_AUDIO_FREQUENCY_8K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_MCKDIV)) | |||
#define IS_SAI_BLOCK_MCK_OVERSAMPLING(VALUE) (((VALUE) == SAI_MCK_OVERSAMPLING_DISABLE) || \ | |||
((VALUE) == SAI_MCK_OVERSAMPLING_ENABLE)) | |||
#define IS_SAI_PDM_MIC_PAIRS_NUMBER(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 3U)) | |||
#define IS_SAI_PDM_CLOCK_ENABLE(CLOCK) (((CLOCK) != 0U) && \ | |||
(((CLOCK) & ~(SAI_PDM_CLOCK1_ENABLE | SAI_PDM_CLOCK2_ENABLE)) == 0U)) | |||
#define IS_SAI_BLOCK_MODE(MODE) (((MODE) == SAI_MODEMASTER_TX) || \ | |||
((MODE) == SAI_MODEMASTER_RX) || \ | |||
((MODE) == SAI_MODESLAVE_TX) || \ | |||
((MODE) == SAI_MODESLAVE_RX)) | |||
#define IS_SAI_BLOCK_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_FREE_PROTOCOL) || \ | |||
((PROTOCOL) == SAI_AC97_PROTOCOL) || \ | |||
((PROTOCOL) == SAI_SPDIF_PROTOCOL)) | |||
#define IS_SAI_BLOCK_DATASIZE(DATASIZE) (((DATASIZE) == SAI_DATASIZE_8) || \ | |||
((DATASIZE) == SAI_DATASIZE_10) || \ | |||
((DATASIZE) == SAI_DATASIZE_16) || \ | |||
((DATASIZE) == SAI_DATASIZE_20) || \ | |||
((DATASIZE) == SAI_DATASIZE_24) || \ | |||
((DATASIZE) == SAI_DATASIZE_32)) | |||
#define IS_SAI_BLOCK_FIRST_BIT(BIT) (((BIT) == SAI_FIRSTBIT_MSB) || \ | |||
((BIT) == SAI_FIRSTBIT_LSB)) | |||
#define IS_SAI_BLOCK_CLOCK_STROBING(CLOCK) (((CLOCK) == SAI_CLOCKSTROBING_FALLINGEDGE) || \ | |||
((CLOCK) == SAI_CLOCKSTROBING_RISINGEDGE)) | |||
#define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_ASYNCHRONOUS) || \ | |||
((SYNCHRO) == SAI_SYNCHRONOUS) || \ | |||
((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI1) || \ | |||
((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI2)) | |||
#define IS_SAI_BLOCK_MCK_OUTPUT(VALUE) (((VALUE) == SAI_MCK_OUTPUT_ENABLE) || \ | |||
((VALUE) == SAI_MCK_OUTPUT_DISABLE)) | |||
#define IS_SAI_BLOCK_OUTPUT_DRIVE(DRIVE) (((DRIVE) == SAI_OUTPUTDRIVE_DISABLE) || \ | |||
((DRIVE) == SAI_OUTPUTDRIVE_ENABLE)) | |||
#define IS_SAI_BLOCK_NODIVIDER(NODIVIDER) (((NODIVIDER) == SAI_MASTERDIVIDER_ENABLE) || \ | |||
((NODIVIDER) == SAI_MASTERDIVIDER_DISABLE)) | |||
#define IS_SAI_BLOCK_MUTE_COUNTER(COUNTER) ((COUNTER) <= 63U) | |||
#define IS_SAI_BLOCK_MUTE_VALUE(VALUE) (((VALUE) == SAI_ZERO_VALUE) || \ | |||
((VALUE) == SAI_LAST_SENT_VALUE)) | |||
#define IS_SAI_BLOCK_COMPANDING_MODE(MODE) (((MODE) == SAI_NOCOMPANDING) || \ | |||
((MODE) == SAI_ULAW_1CPL_COMPANDING) || \ | |||
((MODE) == SAI_ALAW_1CPL_COMPANDING) || \ | |||
((MODE) == SAI_ULAW_2CPL_COMPANDING) || \ | |||
((MODE) == SAI_ALAW_2CPL_COMPANDING)) | |||
#define IS_SAI_BLOCK_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == SAI_FIFOTHRESHOLD_EMPTY) || \ | |||
((THRESHOLD) == SAI_FIFOTHRESHOLD_1QF) || \ | |||
((THRESHOLD) == SAI_FIFOTHRESHOLD_HF) || \ | |||
((THRESHOLD) == SAI_FIFOTHRESHOLD_3QF) || \ | |||
((THRESHOLD) == SAI_FIFOTHRESHOLD_FULL)) | |||
#define IS_SAI_BLOCK_TRISTATE_MANAGEMENT(STATE) (((STATE) == SAI_OUTPUT_NOTRELEASED) ||\ | |||
((STATE) == SAI_OUTPUT_RELEASED)) | |||
#define IS_SAI_MONO_STEREO_MODE(MODE) (((MODE) == SAI_MONOMODE) ||\ | |||
((MODE) == SAI_STEREOMODE)) | |||
#define IS_SAI_SLOT_ACTIVE(ACTIVE) ((ACTIVE) <= SAI_SLOTACTIVE_ALL) | |||
#define IS_SAI_BLOCK_SLOT_NUMBER(NUMBER) ((1U <= (NUMBER)) && ((NUMBER) <= 16U)) | |||
#define IS_SAI_BLOCK_SLOT_SIZE(SIZE) (((SIZE) == SAI_SLOTSIZE_DATASIZE) || \ | |||
((SIZE) == SAI_SLOTSIZE_16B) || \ | |||
((SIZE) == SAI_SLOTSIZE_32B)) | |||
#define IS_SAI_BLOCK_FIRSTBIT_OFFSET(OFFSET) ((OFFSET) <= 24U) | |||
#define IS_SAI_BLOCK_FS_OFFSET(OFFSET) (((OFFSET) == SAI_FS_FIRSTBIT) || \ | |||
((OFFSET) == SAI_FS_BEFOREFIRSTBIT)) | |||
#define IS_SAI_BLOCK_FS_POLARITY(POLARITY) (((POLARITY) == SAI_FS_ACTIVE_LOW) || \ | |||
((POLARITY) == SAI_FS_ACTIVE_HIGH)) | |||
#define IS_SAI_BLOCK_FS_DEFINITION(DEFINITION) (((DEFINITION) == SAI_FS_STARTFRAME) || \ | |||
((DEFINITION) == SAI_FS_CHANNEL_IDENTIFICATION)) | |||
#define IS_SAI_BLOCK_MASTER_DIVIDER(DIVIDER) ((DIVIDER) <= 63U) | |||
#define IS_SAI_BLOCK_FRAME_LENGTH(LENGTH) ((8U <= (LENGTH)) && ((LENGTH) <= 256U)) | |||
#define IS_SAI_BLOCK_ACTIVE_FRAME(LENGTH) ((1U <= (LENGTH)) && ((LENGTH) <= 128U)) | |||
/** | |||
* @} | |||
*/ | |||
/* Private functions ---------------------------------------------------------*/ | |||
/** @defgroup SAI_Private_Functions SAI Private Functions | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_SAI_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,105 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_sai_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of SAI HAL extended module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_SAI_EX_H | |||
#define STM32WBxx_HAL_SAI_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup SAIEx | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup SAIEx_Exported_Types SAIEx Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief PDM microphone delay structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t MicPair; /*!< Specifies which pair of microphones is selected. | |||
This parameter must be a number between Min_Data = 1 and Max_Data = 3. */ | |||
uint32_t LeftDelay; /*!< Specifies the delay in PDM clock unit to apply on left microphone. | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 7. */ | |||
uint32_t RightDelay; /*!< Specifies the delay in PDM clock unit to apply on right microphone. | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 7. */ | |||
} SAIEx_PdmMicDelayParamTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup SAIEx_Exported_Functions SAIEx Extended Exported Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup SAIEx_Exported_Functions_Group1 Peripheral Control functions | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_SAIEx_ConfigPdmMicDelay(SAI_HandleTypeDef *hsai, SAIEx_PdmMicDelayParamTypeDef *pdmMicDelay); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @addtogroup SAIEx_Private_Macros SAIEx Extended Private Macros | |||
* @{ | |||
*/ | |||
#define IS_SAI_PDM_MIC_DELAY(VALUE) ((VALUE) <= 7U) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_SAI_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,343 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_smartcard_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of SMARTCARD HAL Extended module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_SMARTCARD_EX_H | |||
#define STM32WBxx_HAL_SMARTCARD_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup SMARTCARDEx | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @addtogroup SMARTCARDEx_Exported_Constants SMARTCARD Extended Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup SMARTCARDEx_Transmission_Completion_Indication SMARTCARD Transmission Completion Indication | |||
* @{ | |||
*/ | |||
#define SMARTCARD_TCBGT SMARTCARD_IT_TCBGT /*!< SMARTCARD transmission complete before guard time */ | |||
#define SMARTCARD_TC SMARTCARD_IT_TC /*!< SMARTCARD transmission complete (flag raised when guard time has elapsed) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMARTCARDEx_Advanced_Features_Initialization_Type SMARTCARD advanced feature initialization type | |||
* @{ | |||
*/ | |||
#define SMARTCARD_ADVFEATURE_NO_INIT 0x00000000U /*!< No advanced feature initialization */ | |||
#define SMARTCARD_ADVFEATURE_TXINVERT_INIT 0x00000001U /*!< TX pin active level inversion */ | |||
#define SMARTCARD_ADVFEATURE_RXINVERT_INIT 0x00000002U /*!< RX pin active level inversion */ | |||
#define SMARTCARD_ADVFEATURE_DATAINVERT_INIT 0x00000004U /*!< Binary data inversion */ | |||
#define SMARTCARD_ADVFEATURE_SWAP_INIT 0x00000008U /*!< TX/RX pins swap */ | |||
#define SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT 0x00000010U /*!< RX overrun disable */ | |||
#define SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT 0x00000020U /*!< DMA disable on Reception Error */ | |||
#define SMARTCARD_ADVFEATURE_MSBFIRST_INIT 0x00000080U /*!< Most significant bit sent/received first */ | |||
#define SMARTCARD_ADVFEATURE_TXCOMPLETION 0x00000100U /*!< TX completion indication before of after guard time */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMARTCARDEx_FIFO_mode SMARTCARDEx FIFO mode | |||
* @brief SMARTCARD FIFO mode | |||
* @{ | |||
*/ | |||
#define SMARTCARD_FIFOMODE_DISABLE 0x00000000U /*!< FIFO mode disable */ | |||
#define SMARTCARD_FIFOMODE_ENABLE USART_CR1_FIFOEN /*!< FIFO mode enable */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMARTCARDEx_TXFIFO_threshold_level SMARTCARDEx TXFIFO threshold level | |||
* @brief SMARTCARD TXFIFO level | |||
* @{ | |||
*/ | |||
#define SMARTCARD_TXFIFO_THRESHOLD_1_8 0x00000000U /*!< TXFIFO reaches 1/8 of its depth */ | |||
#define SMARTCARD_TXFIFO_THRESHOLD_1_4 USART_CR3_TXFTCFG_0 /*!< TXFIFO reaches 1/4 of its depth */ | |||
#define SMARTCARD_TXFIFO_THRESHOLD_1_2 USART_CR3_TXFTCFG_1 /*!< TXFIFO reaches 1/2 of its depth */ | |||
#define SMARTCARD_TXFIFO_THRESHOLD_3_4 (USART_CR3_TXFTCFG_0|USART_CR3_TXFTCFG_1) /*!< TXFIFO reaches 3/4 of its depth */ | |||
#define SMARTCARD_TXFIFO_THRESHOLD_7_8 USART_CR3_TXFTCFG_2 /*!< TXFIFO reaches 7/8 of its depth */ | |||
#define SMARTCARD_TXFIFO_THRESHOLD_8_8 (USART_CR3_TXFTCFG_2|USART_CR3_TXFTCFG_0) /*!< TXFIFO becomes empty */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMARTCARDEx_RXFIFO_threshold_level SMARTCARDEx RXFIFO threshold level | |||
* @brief SMARTCARD RXFIFO level | |||
* @{ | |||
*/ | |||
#define SMARTCARD_RXFIFO_THRESHOLD_1_8 0x00000000U /*!< RXFIFO FIFO reaches 1/8 of its depth */ | |||
#define SMARTCARD_RXFIFO_THRESHOLD_1_4 USART_CR3_RXFTCFG_0 /*!< RXFIFO FIFO reaches 1/4 of its depth */ | |||
#define SMARTCARD_RXFIFO_THRESHOLD_1_2 USART_CR3_RXFTCFG_1 /*!< RXFIFO FIFO reaches 1/2 of its depth */ | |||
#define SMARTCARD_RXFIFO_THRESHOLD_3_4 (USART_CR3_RXFTCFG_0|USART_CR3_RXFTCFG_1) /*!< RXFIFO FIFO reaches 3/4 of its depth */ | |||
#define SMARTCARD_RXFIFO_THRESHOLD_7_8 USART_CR3_RXFTCFG_2 /*!< RXFIFO FIFO reaches 7/8 of its depth */ | |||
#define SMARTCARD_RXFIFO_THRESHOLD_8_8 (USART_CR3_RXFTCFG_2|USART_CR3_RXFTCFG_0) /*!< RXFIFO FIFO becomes full */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMARTCARDEx_Flags SMARTCARD Flags | |||
* Elements values convention: 0xXXXX | |||
* - 0xXXXX : Flag mask in the ISR register | |||
* @{ | |||
*/ | |||
#define SMARTCARD_FLAG_TCBGT USART_ISR_TCBGT /*!< SMARTCARD transmission complete before guard time completion */ | |||
#define SMARTCARD_FLAG_REACK USART_ISR_REACK /*!< SMARTCARD receive enable acknowledge flag */ | |||
#define SMARTCARD_FLAG_TEACK USART_ISR_TEACK /*!< SMARTCARD transmit enable acknowledge flag */ | |||
#define SMARTCARD_FLAG_BUSY USART_ISR_BUSY /*!< SMARTCARD busy flag */ | |||
#define SMARTCARD_FLAG_EOBF USART_ISR_EOBF /*!< SMARTCARD end of block flag */ | |||
#define SMARTCARD_FLAG_RTOF USART_ISR_RTOF /*!< SMARTCARD receiver timeout flag */ | |||
#define SMARTCARD_FLAG_TXE USART_ISR_TXE_TXFNF /*!< SMARTCARD transmit data register empty */ | |||
#define SMARTCARD_FLAG_TXFNF USART_ISR_TXE_TXFNF /*!< SMARTCARD TXFIFO not full */ | |||
#define SMARTCARD_FLAG_TC USART_ISR_TC /*!< SMARTCARD transmission complete */ | |||
#define SMARTCARD_FLAG_RXNE USART_ISR_RXNE_RXFNE /*!< SMARTCARD read data register not empty */ | |||
#define SMARTCARD_FLAG_RXFNE USART_ISR_RXNE_RXFNE /*!< SMARTCARD RXFIFO not empty */ | |||
#define SMARTCARD_FLAG_IDLE USART_ISR_IDLE /*!< SMARTCARD idle line detection */ | |||
#define SMARTCARD_FLAG_ORE USART_ISR_ORE /*!< SMARTCARD overrun error */ | |||
#define SMARTCARD_FLAG_NE USART_ISR_NE /*!< SMARTCARD noise error */ | |||
#define SMARTCARD_FLAG_FE USART_ISR_FE /*!< SMARTCARD frame error */ | |||
#define SMARTCARD_FLAG_PE USART_ISR_PE /*!< SMARTCARD parity error */ | |||
#define SMARTCARD_FLAG_TXFE USART_ISR_TXFE /*!< SMARTCARD TXFIFO Empty flag */ | |||
#define SMARTCARD_FLAG_RXFF USART_ISR_RXFF /*!< SMARTCARD RXFIFO Full flag */ | |||
#define SMARTCARD_FLAG_RXFT USART_ISR_RXFT /*!< SMARTCARD RXFIFO threshold flag */ | |||
#define SMARTCARD_FLAG_TXFT USART_ISR_TXFT /*!< SMARTCARD TXFIFO threshold flag */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMARTCARDEx_Interrupt_definition SMARTCARD Interrupts Definition | |||
* Elements values convention: 000ZZZZZ0XXYYYYYb | |||
* - YYYYY : Interrupt source position in the XX register (5 bits) | |||
* - XX : Interrupt source register (2 bits) | |||
* - 01: CR1 register | |||
* - 10: CR2 register | |||
* - 11: CR3 register | |||
* - ZZZZZ : Flag position in the ISR register(5 bits) | |||
* @{ | |||
*/ | |||
#define SMARTCARD_IT_PE 0x0028U /*!< SMARTCARD parity error interruption */ | |||
#define SMARTCARD_IT_TXE 0x0727U /*!< SMARTCARD transmit data register empty interruption */ | |||
#define SMARTCARD_IT_TXFNF 0x0727U /*!< SMARTCARD TX FIFO not full interruption */ | |||
#define SMARTCARD_IT_TC 0x0626U /*!< SMARTCARD transmission complete interruption */ | |||
#define SMARTCARD_IT_RXNE 0x0525U /*!< SMARTCARD read data register not empty interruption */ | |||
#define SMARTCARD_IT_RXFNE 0x0525U /*!< SMARTCARD RXFIFO not empty interruption */ | |||
#define SMARTCARD_IT_IDLE 0x0424U /*!< SMARTCARD idle line detection interruption */ | |||
#define SMARTCARD_IT_ERR 0x0060U /*!< SMARTCARD error interruption */ | |||
#define SMARTCARD_IT_ORE 0x0300U /*!< SMARTCARD overrun error interruption */ | |||
#define SMARTCARD_IT_NE 0x0200U /*!< SMARTCARD noise error interruption */ | |||
#define SMARTCARD_IT_FE 0x0100U /*!< SMARTCARD frame error interruption */ | |||
#define SMARTCARD_IT_EOB 0x0C3BU /*!< SMARTCARD end of block interruption */ | |||
#define SMARTCARD_IT_RTO 0x0B3AU /*!< SMARTCARD receiver timeout interruption */ | |||
#define SMARTCARD_IT_TCBGT 0x1978U /*!< SMARTCARD transmission complete before guard time completion interruption */ | |||
#define SMARTCARD_IT_RXFF 0x183FU /*!< SMARTCARD RXFIFO full interruption */ | |||
#define SMARTCARD_IT_TXFE 0x173EU /*!< SMARTCARD TXFIFO empty interruption */ | |||
#define SMARTCARD_IT_RXFT 0x1A7CU /*!< SMARTCARD RXFIFO threshold reached interruption */ | |||
#define SMARTCARD_IT_TXFT 0x1B77U /*!< SMARTCARD TXFIFO threshold reached interruption */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMARTCARDEx_IT_CLEAR_Flags SMARTCARD Interruption Clear Flags | |||
* @{ | |||
*/ | |||
#define SMARTCARD_CLEAR_PEF USART_ICR_PECF /*!< SMARTCARD parity error clear flag */ | |||
#define SMARTCARD_CLEAR_FEF USART_ICR_FECF /*!< SMARTCARD framing error clear flag */ | |||
#define SMARTCARD_CLEAR_NEF USART_ICR_NECF /*!< SMARTCARD noise error detected clear flag */ | |||
#define SMARTCARD_CLEAR_OREF USART_ICR_ORECF /*!< SMARTCARD overrun error clear flag */ | |||
#define SMARTCARD_CLEAR_IDLEF USART_ICR_IDLECF /*!< SMARTCARD idle line detected clear flag */ | |||
#define SMARTCARD_CLEAR_TXFECF USART_ICR_TXFECF /*!< TXFIFO empty Clear Flag */ | |||
#define SMARTCARD_CLEAR_TCF USART_ICR_TCCF /*!< SMARTCARD transmission complete clear flag */ | |||
#define SMARTCARD_CLEAR_TCBGTF USART_ICR_TCBGTCF /*!< SMARTCARD transmission complete before guard time completion clear flag */ | |||
#define SMARTCARD_CLEAR_RTOF USART_ICR_RTOCF /*!< SMARTCARD receiver time out clear flag */ | |||
#define SMARTCARD_CLEAR_EOBF USART_ICR_EOBCF /*!< SMARTCARD end of block clear flag */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup SMARTCARDEx_Private_Macros SMARTCARD Extended Private Macros | |||
* @{ | |||
*/ | |||
/** @brief Set the Transmission Completion flag | |||
* @param __HANDLE__ specifies the SMARTCARD Handle. | |||
* @note If TCBGT (Transmission Complete Before Guard Time) flag is not available or if | |||
* AdvancedInit.TxCompletionIndication is not already filled, the latter is forced | |||
* to SMARTCARD_TC (transmission completion indication when guard time has elapsed). | |||
* @retval None | |||
*/ | |||
#define SMARTCARD_TRANSMISSION_COMPLETION_SETTING(__HANDLE__) \ | |||
do { \ | |||
if (HAL_IS_BIT_CLR((__HANDLE__)->AdvancedInit.AdvFeatureInit, SMARTCARD_ADVFEATURE_TXCOMPLETION)) \ | |||
{ \ | |||
(__HANDLE__)->AdvancedInit.TxCompletionIndication = SMARTCARD_TC; \ | |||
} \ | |||
else \ | |||
{ \ | |||
assert_param(IS_SMARTCARD_TRANSMISSION_COMPLETION((__HANDLE__)->AdvancedInit.TxCompletionIndication)); \ | |||
} \ | |||
} while(0U) | |||
/** @brief Return the transmission completion flag. | |||
* @param __HANDLE__ specifies the SMARTCARD Handle. | |||
* @note Based on AdvancedInit.TxCompletionIndication setting, return TC or TCBGT flag. | |||
* When TCBGT flag (Transmission Complete Before Guard Time) is not available, TC flag is | |||
* reported. | |||
* @retval Transmission completion flag | |||
*/ | |||
#define SMARTCARD_TRANSMISSION_COMPLETION_FLAG(__HANDLE__) \ | |||
(((__HANDLE__)->AdvancedInit.TxCompletionIndication == SMARTCARD_TC) ? (SMARTCARD_FLAG_TC) : (SMARTCARD_FLAG_TCBGT)) | |||
/** | |||
* @brief Ensure that SMARTCARD frame transmission completion used flag is valid. | |||
* @param __TXCOMPLETE__ SMARTCARD frame transmission completion used flag. | |||
* @retval SET (__TXCOMPLETE__ is valid) or RESET (__TXCOMPLETE__ is invalid) | |||
*/ | |||
#define IS_SMARTCARD_TRANSMISSION_COMPLETION(__TXCOMPLETE__) (((__TXCOMPLETE__) == SMARTCARD_TCBGT) ||\ | |||
((__TXCOMPLETE__) == SMARTCARD_TC)) | |||
/** | |||
* @brief Ensure that SMARTCARD FIFO mode is valid. | |||
* @param __STATE__ SMARTCARD FIFO mode. | |||
* @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid) | |||
*/ | |||
#define IS_SMARTCARD_FIFOMODE_STATE(__STATE__) (((__STATE__) == SMARTCARD_FIFOMODE_DISABLE ) || \ | |||
((__STATE__) == SMARTCARD_FIFOMODE_ENABLE)) | |||
/** | |||
* @brief Ensure that SMARTCARD TXFIFO threshold level is valid. | |||
* @param __THRESHOLD__ SMARTCARD TXFIFO threshold level. | |||
* @retval SET (__THRESHOLD__ is valid) or RESET (__THRESHOLD__ is invalid) | |||
*/ | |||
#define IS_SMARTCARD_TXFIFO_THRESHOLD(__THRESHOLD__) (((__THRESHOLD__) == SMARTCARD_TXFIFO_THRESHOLD_1_8) || \ | |||
((__THRESHOLD__) == SMARTCARD_TXFIFO_THRESHOLD_1_4) || \ | |||
((__THRESHOLD__) == SMARTCARD_TXFIFO_THRESHOLD_1_2) || \ | |||
((__THRESHOLD__) == SMARTCARD_TXFIFO_THRESHOLD_3_4) || \ | |||
((__THRESHOLD__) == SMARTCARD_TXFIFO_THRESHOLD_7_8) || \ | |||
((__THRESHOLD__) == SMARTCARD_TXFIFO_THRESHOLD_8_8)) | |||
/** | |||
* @brief Ensure that SMARTCARD RXFIFO threshold level is valid. | |||
* @param __THRESHOLD__ SMARTCARD RXFIFO threshold level. | |||
* @retval SET (__THRESHOLD__ is valid) or RESET (__THRESHOLD__ is invalid) | |||
*/ | |||
#define IS_SMARTCARD_RXFIFO_THRESHOLD(__THRESHOLD__) (((__THRESHOLD__) == SMARTCARD_RXFIFO_THRESHOLD_1_8) || \ | |||
((__THRESHOLD__) == SMARTCARD_RXFIFO_THRESHOLD_1_4) || \ | |||
((__THRESHOLD__) == SMARTCARD_RXFIFO_THRESHOLD_1_2) || \ | |||
((__THRESHOLD__) == SMARTCARD_RXFIFO_THRESHOLD_3_4) || \ | |||
((__THRESHOLD__) == SMARTCARD_RXFIFO_THRESHOLD_7_8) || \ | |||
((__THRESHOLD__) == SMARTCARD_RXFIFO_THRESHOLD_8_8)) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup SMARTCARDEx_Exported_Functions | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions ****************************/ | |||
/* IO operation methods *******************************************************/ | |||
/** @addtogroup SMARTCARDEx_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
/* Peripheral Control functions ***********************************************/ | |||
void HAL_SMARTCARDEx_BlockLength_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t BlockLength); | |||
void HAL_SMARTCARDEx_TimeOut_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint32_t TimeOutValue); | |||
HAL_StatusTypeDef HAL_SMARTCARDEx_EnableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard); | |||
HAL_StatusTypeDef HAL_SMARTCARDEx_DisableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard); | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup SMARTCARDEx_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
void HAL_SMARTCARDEx_RxFifoFullCallback(SMARTCARD_HandleTypeDef *hsmartcard); | |||
void HAL_SMARTCARDEx_TxFifoEmptyCallback(SMARTCARD_HandleTypeDef *hsmartcard); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup SMARTCARDEx_Exported_Functions_Group3 | |||
* @{ | |||
*/ | |||
/* Peripheral Control functions ***********************************************/ | |||
HAL_StatusTypeDef HAL_SMARTCARDEx_EnableFifoMode(SMARTCARD_HandleTypeDef *hsmartcard); | |||
HAL_StatusTypeDef HAL_SMARTCARDEx_DisableFifoMode(SMARTCARD_HandleTypeDef *hsmartcard); | |||
HAL_StatusTypeDef HAL_SMARTCARDEx_SetTxFifoThreshold(SMARTCARD_HandleTypeDef *hsmartcard, uint32_t Threshold); | |||
HAL_StatusTypeDef HAL_SMARTCARDEx_SetRxFifoThreshold(SMARTCARD_HandleTypeDef *hsmartcard, uint32_t Threshold); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private functions ---------------------------------------------------------*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_SMARTCARD_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,743 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_smbus.h | |||
* @author MCD Application Team | |||
* @brief Header file of SMBUS HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_SMBUS_H | |||
#define STM32WBxx_HAL_SMBUS_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup SMBUS | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup SMBUS_Exported_Types SMBUS Exported Types | |||
* @{ | |||
*/ | |||
/** @defgroup SMBUS_Configuration_Structure_definition SMBUS Configuration Structure definition | |||
* @brief SMBUS Configuration Structure definition | |||
* @{ | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Timing; /*!< Specifies the SMBUS_TIMINGR_register value. | |||
This parameter calculated by referring to SMBUS initialization | |||
section in Reference manual */ | |||
uint32_t AnalogFilter; /*!< Specifies if Analog Filter is enable or not. | |||
This parameter can be a value of @ref SMBUS_Analog_Filter */ | |||
uint32_t OwnAddress1; /*!< Specifies the first device own address. | |||
This parameter can be a 7-bit or 10-bit address. */ | |||
uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode for master is selected. | |||
This parameter can be a value of @ref SMBUS_addressing_mode */ | |||
uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected. | |||
This parameter can be a value of @ref SMBUS_dual_addressing_mode */ | |||
uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected | |||
This parameter can be a 7-bit address. */ | |||
uint32_t OwnAddress2Masks; /*!< Specifies the acknoledge mask address second device own address if dual addressing mode is selected | |||
This parameter can be a value of @ref SMBUS_own_address2_masks. */ | |||
uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected. | |||
This parameter can be a value of @ref SMBUS_general_call_addressing_mode. */ | |||
uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected. | |||
This parameter can be a value of @ref SMBUS_nostretch_mode */ | |||
uint32_t PacketErrorCheckMode; /*!< Specifies if Packet Error Check mode is selected. | |||
This parameter can be a value of @ref SMBUS_packet_error_check_mode */ | |||
uint32_t PeripheralMode; /*!< Specifies which mode of Periphal is selected. | |||
This parameter can be a value of @ref SMBUS_peripheral_mode */ | |||
uint32_t SMBusTimeout; /*!< Specifies the content of the 32 Bits SMBUS_TIMEOUT_register value. | |||
(Enable bits and different timeout values) | |||
This parameter calculated by referring to SMBUS initialization | |||
section in Reference manual */ | |||
} SMBUS_InitTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup HAL_state_definition HAL state definition | |||
* @brief HAL State definition | |||
* @{ | |||
*/ | |||
#define HAL_SMBUS_STATE_RESET (0x00000000U) /*!< SMBUS not yet initialized or disabled */ | |||
#define HAL_SMBUS_STATE_READY (0x00000001U) /*!< SMBUS initialized and ready for use */ | |||
#define HAL_SMBUS_STATE_BUSY (0x00000002U) /*!< SMBUS internal process is ongoing */ | |||
#define HAL_SMBUS_STATE_MASTER_BUSY_TX (0x00000012U) /*!< Master Data Transmission process is ongoing */ | |||
#define HAL_SMBUS_STATE_MASTER_BUSY_RX (0x00000022U) /*!< Master Data Reception process is ongoing */ | |||
#define HAL_SMBUS_STATE_SLAVE_BUSY_TX (0x00000032U) /*!< Slave Data Transmission process is ongoing */ | |||
#define HAL_SMBUS_STATE_SLAVE_BUSY_RX (0x00000042U) /*!< Slave Data Reception process is ongoing */ | |||
#define HAL_SMBUS_STATE_TIMEOUT (0x00000003U) /*!< Timeout state */ | |||
#define HAL_SMBUS_STATE_ERROR (0x00000004U) /*!< Reception process is ongoing */ | |||
#define HAL_SMBUS_STATE_LISTEN (0x00000008U) /*!< Address Listen Mode is ongoing */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_Error_Code_definition SMBUS Error Code definition | |||
* @brief SMBUS Error Code definition | |||
* @{ | |||
*/ | |||
#define HAL_SMBUS_ERROR_NONE (0x00000000U) /*!< No error */ | |||
#define HAL_SMBUS_ERROR_BERR (0x00000001U) /*!< BERR error */ | |||
#define HAL_SMBUS_ERROR_ARLO (0x00000002U) /*!< ARLO error */ | |||
#define HAL_SMBUS_ERROR_ACKF (0x00000004U) /*!< ACKF error */ | |||
#define HAL_SMBUS_ERROR_OVR (0x00000008U) /*!< OVR error */ | |||
#define HAL_SMBUS_ERROR_HALTIMEOUT (0x00000010U) /*!< Timeout error */ | |||
#define HAL_SMBUS_ERROR_BUSTIMEOUT (0x00000020U) /*!< Bus Timeout error */ | |||
#define HAL_SMBUS_ERROR_ALERT (0x00000040U) /*!< Alert error */ | |||
#define HAL_SMBUS_ERROR_PECERR (0x00000080U) /*!< PEC error */ | |||
#if (USE_HAL_SMBUS_REGISTER_CALLBACKS == 1) | |||
#define HAL_SMBUS_ERROR_INVALID_CALLBACK (0x00000100U) /*!< Invalid Callback error */ | |||
#endif /* USE_HAL_SMBUS_REGISTER_CALLBACKS */ | |||
#define HAL_SMBUS_ERROR_INVALID_PARAM (0x00000200U) /*!< Invalid Parameters error */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_handle_Structure_definition SMBUS handle Structure definition | |||
* @brief SMBUS handle Structure definition | |||
* @{ | |||
*/ | |||
typedef struct __SMBUS_HandleTypeDef | |||
{ | |||
I2C_TypeDef *Instance; /*!< SMBUS registers base address */ | |||
SMBUS_InitTypeDef Init; /*!< SMBUS communication parameters */ | |||
uint8_t *pBuffPtr; /*!< Pointer to SMBUS transfer buffer */ | |||
uint16_t XferSize; /*!< SMBUS transfer size */ | |||
__IO uint16_t XferCount; /*!< SMBUS transfer counter */ | |||
__IO uint32_t XferOptions; /*!< SMBUS transfer options */ | |||
__IO uint32_t PreviousState; /*!< SMBUS communication Previous state */ | |||
HAL_LockTypeDef Lock; /*!< SMBUS locking object */ | |||
__IO uint32_t State; /*!< SMBUS communication state */ | |||
__IO uint32_t ErrorCode; /*!< SMBUS Error code */ | |||
#if (USE_HAL_SMBUS_REGISTER_CALLBACKS == 1) | |||
void (* MasterTxCpltCallback)(struct __SMBUS_HandleTypeDef *hsmbus); /*!< SMBUS Master Tx Transfer completed callback */ | |||
void (* MasterRxCpltCallback)(struct __SMBUS_HandleTypeDef *hsmbus); /*!< SMBUS Master Rx Transfer completed callback */ | |||
void (* SlaveTxCpltCallback)(struct __SMBUS_HandleTypeDef *hsmbus); /*!< SMBUS Slave Tx Transfer completed callback */ | |||
void (* SlaveRxCpltCallback)(struct __SMBUS_HandleTypeDef *hsmbus); /*!< SMBUS Slave Rx Transfer completed callback */ | |||
void (* ListenCpltCallback)(struct __SMBUS_HandleTypeDef *hsmbus); /*!< SMBUS Listen Complete callback */ | |||
void (* ErrorCallback)(struct __SMBUS_HandleTypeDef *hsmbus); /*!< SMBUS Error callback */ | |||
void (* AddrCallback)(struct __SMBUS_HandleTypeDef *hsmbus, uint8_t TransferDirection, uint16_t AddrMatchCode); /*!< SMBUS Slave Address Match callback */ | |||
void (* MspInitCallback)(struct __SMBUS_HandleTypeDef *hsmbus); /*!< SMBUS Msp Init callback */ | |||
void (* MspDeInitCallback)(struct __SMBUS_HandleTypeDef *hsmbus); /*!< SMBUS Msp DeInit callback */ | |||
#endif /* USE_HAL_SMBUS_REGISTER_CALLBACKS */ | |||
} SMBUS_HandleTypeDef; | |||
#if (USE_HAL_SMBUS_REGISTER_CALLBACKS == 1) | |||
/** | |||
* @brief HAL SMBUS Callback ID enumeration definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_SMBUS_MASTER_TX_COMPLETE_CB_ID = 0x00U, /*!< SMBUS Master Tx Transfer completed callback ID */ | |||
HAL_SMBUS_MASTER_RX_COMPLETE_CB_ID = 0x01U, /*!< SMBUS Master Rx Transfer completed callback ID */ | |||
HAL_SMBUS_SLAVE_TX_COMPLETE_CB_ID = 0x02U, /*!< SMBUS Slave Tx Transfer completed callback ID */ | |||
HAL_SMBUS_SLAVE_RX_COMPLETE_CB_ID = 0x03U, /*!< SMBUS Slave Rx Transfer completed callback ID */ | |||
HAL_SMBUS_LISTEN_COMPLETE_CB_ID = 0x04U, /*!< SMBUS Listen Complete callback ID */ | |||
HAL_SMBUS_ERROR_CB_ID = 0x05U, /*!< SMBUS Error callback ID */ | |||
HAL_SMBUS_MSPINIT_CB_ID = 0x06U, /*!< SMBUS Msp Init callback ID */ | |||
HAL_SMBUS_MSPDEINIT_CB_ID = 0x07U /*!< SMBUS Msp DeInit callback ID */ | |||
} HAL_SMBUS_CallbackIDTypeDef; | |||
/** | |||
* @brief HAL SMBUS Callback pointer definition | |||
*/ | |||
typedef void (*pSMBUS_CallbackTypeDef)(SMBUS_HandleTypeDef *hsmbus); /*!< pointer to an SMBUS callback function */ | |||
typedef void (*pSMBUS_AddrCallbackTypeDef)(SMBUS_HandleTypeDef *hsmbus, uint8_t TransferDirection, uint16_t AddrMatchCode); /*!< pointer to an SMBUS Address Match callback function */ | |||
#endif /* USE_HAL_SMBUS_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup SMBUS_Exported_Constants SMBUS Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup SMBUS_Analog_Filter SMBUS Analog Filter | |||
* @{ | |||
*/ | |||
#define SMBUS_ANALOGFILTER_ENABLE (0x00000000U) | |||
#define SMBUS_ANALOGFILTER_DISABLE I2C_CR1_ANFOFF | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_addressing_mode SMBUS addressing mode | |||
* @{ | |||
*/ | |||
#define SMBUS_ADDRESSINGMODE_7BIT (0x00000001U) | |||
#define SMBUS_ADDRESSINGMODE_10BIT (0x00000002U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_dual_addressing_mode SMBUS dual addressing mode | |||
* @{ | |||
*/ | |||
#define SMBUS_DUALADDRESS_DISABLE (0x00000000U) | |||
#define SMBUS_DUALADDRESS_ENABLE I2C_OAR2_OA2EN | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_own_address2_masks SMBUS ownaddress2 masks | |||
* @{ | |||
*/ | |||
#define SMBUS_OA2_NOMASK ((uint8_t)0x00U) | |||
#define SMBUS_OA2_MASK01 ((uint8_t)0x01U) | |||
#define SMBUS_OA2_MASK02 ((uint8_t)0x02U) | |||
#define SMBUS_OA2_MASK03 ((uint8_t)0x03U) | |||
#define SMBUS_OA2_MASK04 ((uint8_t)0x04U) | |||
#define SMBUS_OA2_MASK05 ((uint8_t)0x05U) | |||
#define SMBUS_OA2_MASK06 ((uint8_t)0x06U) | |||
#define SMBUS_OA2_MASK07 ((uint8_t)0x07U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_general_call_addressing_mode SMBUS general call addressing mode | |||
* @{ | |||
*/ | |||
#define SMBUS_GENERALCALL_DISABLE (0x00000000U) | |||
#define SMBUS_GENERALCALL_ENABLE I2C_CR1_GCEN | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_nostretch_mode SMBUS nostretch mode | |||
* @{ | |||
*/ | |||
#define SMBUS_NOSTRETCH_DISABLE (0x00000000U) | |||
#define SMBUS_NOSTRETCH_ENABLE I2C_CR1_NOSTRETCH | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_packet_error_check_mode SMBUS packet error check mode | |||
* @{ | |||
*/ | |||
#define SMBUS_PEC_DISABLE (0x00000000U) | |||
#define SMBUS_PEC_ENABLE I2C_CR1_PECEN | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_peripheral_mode SMBUS peripheral mode | |||
* @{ | |||
*/ | |||
#define SMBUS_PERIPHERAL_MODE_SMBUS_HOST I2C_CR1_SMBHEN | |||
#define SMBUS_PERIPHERAL_MODE_SMBUS_SLAVE (0x00000000U) | |||
#define SMBUS_PERIPHERAL_MODE_SMBUS_SLAVE_ARP I2C_CR1_SMBDEN | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_ReloadEndMode_definition SMBUS ReloadEndMode definition | |||
* @{ | |||
*/ | |||
#define SMBUS_SOFTEND_MODE (0x00000000U) | |||
#define SMBUS_RELOAD_MODE I2C_CR2_RELOAD | |||
#define SMBUS_AUTOEND_MODE I2C_CR2_AUTOEND | |||
#define SMBUS_SENDPEC_MODE I2C_CR2_PECBYTE | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_StartStopMode_definition SMBUS StartStopMode definition | |||
* @{ | |||
*/ | |||
#define SMBUS_NO_STARTSTOP (0x00000000U) | |||
#define SMBUS_GENERATE_STOP (uint32_t)(0x80000000U | I2C_CR2_STOP) | |||
#define SMBUS_GENERATE_START_READ (uint32_t)(0x80000000U | I2C_CR2_START | I2C_CR2_RD_WRN) | |||
#define SMBUS_GENERATE_START_WRITE (uint32_t)(0x80000000U | I2C_CR2_START) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_XferOptions_definition SMBUS XferOptions definition | |||
* @{ | |||
*/ | |||
/* List of XferOptions in usage of : | |||
* 1- Restart condition when direction change | |||
* 2- No Restart condition in other use cases | |||
*/ | |||
#define SMBUS_FIRST_FRAME SMBUS_SOFTEND_MODE | |||
#define SMBUS_NEXT_FRAME ((uint32_t)(SMBUS_RELOAD_MODE | SMBUS_SOFTEND_MODE)) | |||
#define SMBUS_FIRST_AND_LAST_FRAME_NO_PEC SMBUS_AUTOEND_MODE | |||
#define SMBUS_LAST_FRAME_NO_PEC SMBUS_AUTOEND_MODE | |||
#define SMBUS_FIRST_AND_LAST_FRAME_WITH_PEC ((uint32_t)(SMBUS_AUTOEND_MODE | SMBUS_SENDPEC_MODE)) | |||
#define SMBUS_LAST_FRAME_WITH_PEC ((uint32_t)(SMBUS_AUTOEND_MODE | SMBUS_SENDPEC_MODE)) | |||
/* List of XferOptions in usage of : | |||
* 1- Restart condition in all use cases (direction change or not) | |||
*/ | |||
#define SMBUS_OTHER_FRAME_NO_PEC (0x000000AAU) | |||
#define SMBUS_OTHER_FRAME_WITH_PEC (0x0000AA00U) | |||
#define SMBUS_OTHER_AND_LAST_FRAME_NO_PEC (0x00AA0000U) | |||
#define SMBUS_OTHER_AND_LAST_FRAME_WITH_PEC (0xAA000000U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_Interrupt_configuration_definition SMBUS Interrupt configuration definition | |||
* @brief SMBUS Interrupt definition | |||
* Elements values convention: 0xXXXXXXXX | |||
* - XXXXXXXX : Interrupt control mask | |||
* @{ | |||
*/ | |||
#define SMBUS_IT_ERRI I2C_CR1_ERRIE | |||
#define SMBUS_IT_TCI I2C_CR1_TCIE | |||
#define SMBUS_IT_STOPI I2C_CR1_STOPIE | |||
#define SMBUS_IT_NACKI I2C_CR1_NACKIE | |||
#define SMBUS_IT_ADDRI I2C_CR1_ADDRIE | |||
#define SMBUS_IT_RXI I2C_CR1_RXIE | |||
#define SMBUS_IT_TXI I2C_CR1_TXIE | |||
#define SMBUS_IT_TX (SMBUS_IT_ERRI | SMBUS_IT_TCI | SMBUS_IT_STOPI | SMBUS_IT_NACKI | SMBUS_IT_TXI) | |||
#define SMBUS_IT_RX (SMBUS_IT_ERRI | SMBUS_IT_TCI | SMBUS_IT_NACKI | SMBUS_IT_RXI) | |||
#define SMBUS_IT_ALERT (SMBUS_IT_ERRI) | |||
#define SMBUS_IT_ADDR (SMBUS_IT_ADDRI | SMBUS_IT_STOPI | SMBUS_IT_NACKI) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SMBUS_Flag_definition SMBUS Flag definition | |||
* @brief Flag definition | |||
* Elements values convention: 0xXXXXYYYY | |||
* - XXXXXXXX : Flag mask | |||
* @{ | |||
*/ | |||
#define SMBUS_FLAG_TXE I2C_ISR_TXE | |||
#define SMBUS_FLAG_TXIS I2C_ISR_TXIS | |||
#define SMBUS_FLAG_RXNE I2C_ISR_RXNE | |||
#define SMBUS_FLAG_ADDR I2C_ISR_ADDR | |||
#define SMBUS_FLAG_AF I2C_ISR_NACKF | |||
#define SMBUS_FLAG_STOPF I2C_ISR_STOPF | |||
#define SMBUS_FLAG_TC I2C_ISR_TC | |||
#define SMBUS_FLAG_TCR I2C_ISR_TCR | |||
#define SMBUS_FLAG_BERR I2C_ISR_BERR | |||
#define SMBUS_FLAG_ARLO I2C_ISR_ARLO | |||
#define SMBUS_FLAG_OVR I2C_ISR_OVR | |||
#define SMBUS_FLAG_PECERR I2C_ISR_PECERR | |||
#define SMBUS_FLAG_TIMEOUT I2C_ISR_TIMEOUT | |||
#define SMBUS_FLAG_ALERT I2C_ISR_ALERT | |||
#define SMBUS_FLAG_BUSY I2C_ISR_BUSY | |||
#define SMBUS_FLAG_DIR I2C_ISR_DIR | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros ------------------------------------------------------------*/ | |||
/** @defgroup SMBUS_Exported_Macros SMBUS Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset SMBUS handle state. | |||
* @param __HANDLE__ specifies the SMBUS Handle. | |||
* @retval None | |||
*/ | |||
#if (USE_HAL_SMBUS_REGISTER_CALLBACKS == 1) | |||
#define __HAL_SMBUS_RESET_HANDLE_STATE(__HANDLE__) do{ \ | |||
(__HANDLE__)->State = HAL_SMBUS_STATE_RESET; \ | |||
(__HANDLE__)->MspInitCallback = NULL; \ | |||
(__HANDLE__)->MspDeInitCallback = NULL; \ | |||
} while(0) | |||
#else | |||
#define __HAL_SMBUS_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SMBUS_STATE_RESET) | |||
#endif | |||
/** @brief Enable the specified SMBUS interrupts. | |||
* @param __HANDLE__ specifies the SMBUS Handle. | |||
* @param __INTERRUPT__ specifies the interrupt source to enable. | |||
* This parameter can be one of the following values: | |||
* @arg @ref SMBUS_IT_ERRI Errors interrupt enable | |||
* @arg @ref SMBUS_IT_TCI Transfer complete interrupt enable | |||
* @arg @ref SMBUS_IT_STOPI STOP detection interrupt enable | |||
* @arg @ref SMBUS_IT_NACKI NACK received interrupt enable | |||
* @arg @ref SMBUS_IT_ADDRI Address match interrupt enable | |||
* @arg @ref SMBUS_IT_RXI RX interrupt enable | |||
* @arg @ref SMBUS_IT_TXI TX interrupt enable | |||
* | |||
* @retval None | |||
*/ | |||
#define __HAL_SMBUS_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 |= (__INTERRUPT__)) | |||
/** @brief Disable the specified SMBUS interrupts. | |||
* @param __HANDLE__ specifies the SMBUS Handle. | |||
* @param __INTERRUPT__ specifies the interrupt source to disable. | |||
* This parameter can be one of the following values: | |||
* @arg @ref SMBUS_IT_ERRI Errors interrupt enable | |||
* @arg @ref SMBUS_IT_TCI Transfer complete interrupt enable | |||
* @arg @ref SMBUS_IT_STOPI STOP detection interrupt enable | |||
* @arg @ref SMBUS_IT_NACKI NACK received interrupt enable | |||
* @arg @ref SMBUS_IT_ADDRI Address match interrupt enable | |||
* @arg @ref SMBUS_IT_RXI RX interrupt enable | |||
* @arg @ref SMBUS_IT_TXI TX interrupt enable | |||
* | |||
* @retval None | |||
*/ | |||
#define __HAL_SMBUS_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 &= (~(__INTERRUPT__))) | |||
/** @brief Check whether the specified SMBUS interrupt source is enabled or not. | |||
* @param __HANDLE__ specifies the SMBUS Handle. | |||
* @param __INTERRUPT__ specifies the SMBUS interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref SMBUS_IT_ERRI Errors interrupt enable | |||
* @arg @ref SMBUS_IT_TCI Transfer complete interrupt enable | |||
* @arg @ref SMBUS_IT_STOPI STOP detection interrupt enable | |||
* @arg @ref SMBUS_IT_NACKI NACK received interrupt enable | |||
* @arg @ref SMBUS_IT_ADDRI Address match interrupt enable | |||
* @arg @ref SMBUS_IT_RXI RX interrupt enable | |||
* @arg @ref SMBUS_IT_TXI TX interrupt enable | |||
* | |||
* @retval The new state of __IT__ (SET or RESET). | |||
*/ | |||
#define __HAL_SMBUS_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
/** @brief Check whether the specified SMBUS flag is set or not. | |||
* @param __HANDLE__ specifies the SMBUS Handle. | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref SMBUS_FLAG_TXE Transmit data register empty | |||
* @arg @ref SMBUS_FLAG_TXIS Transmit interrupt status | |||
* @arg @ref SMBUS_FLAG_RXNE Receive data register not empty | |||
* @arg @ref SMBUS_FLAG_ADDR Address matched (slave mode) | |||
* @arg @ref SMBUS_FLAG_AF NACK received flag | |||
* @arg @ref SMBUS_FLAG_STOPF STOP detection flag | |||
* @arg @ref SMBUS_FLAG_TC Transfer complete (master mode) | |||
* @arg @ref SMBUS_FLAG_TCR Transfer complete reload | |||
* @arg @ref SMBUS_FLAG_BERR Bus error | |||
* @arg @ref SMBUS_FLAG_ARLO Arbitration lost | |||
* @arg @ref SMBUS_FLAG_OVR Overrun/Underrun | |||
* @arg @ref SMBUS_FLAG_PECERR PEC error in reception | |||
* @arg @ref SMBUS_FLAG_TIMEOUT Timeout or Tlow detection flag | |||
* @arg @ref SMBUS_FLAG_ALERT SMBus alert | |||
* @arg @ref SMBUS_FLAG_BUSY Bus busy | |||
* @arg @ref SMBUS_FLAG_DIR Transfer direction (slave mode) | |||
* | |||
* @retval The new state of __FLAG__ (SET or RESET). | |||
*/ | |||
#define SMBUS_FLAG_MASK (0x0001FFFFU) | |||
#define __HAL_SMBUS_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & ((__FLAG__) & SMBUS_FLAG_MASK)) == ((__FLAG__) & SMBUS_FLAG_MASK)) ? SET : RESET) | |||
/** @brief Clear the SMBUS pending flags which are cleared by writing 1 in a specific bit. | |||
* @param __HANDLE__ specifies the SMBUS Handle. | |||
* @param __FLAG__ specifies the flag to clear. | |||
* This parameter can be any combination of the following values: | |||
* @arg @ref SMBUS_FLAG_ADDR Address matched (slave mode) | |||
* @arg @ref SMBUS_FLAG_AF NACK received flag | |||
* @arg @ref SMBUS_FLAG_STOPF STOP detection flag | |||
* @arg @ref SMBUS_FLAG_BERR Bus error | |||
* @arg @ref SMBUS_FLAG_ARLO Arbitration lost | |||
* @arg @ref SMBUS_FLAG_OVR Overrun/Underrun | |||
* @arg @ref SMBUS_FLAG_PECERR PEC error in reception | |||
* @arg @ref SMBUS_FLAG_TIMEOUT Timeout or Tlow detection flag | |||
* @arg @ref SMBUS_FLAG_ALERT SMBus alert | |||
* | |||
* @retval None | |||
*/ | |||
#define __HAL_SMBUS_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) | |||
/** @brief Enable the specified SMBUS peripheral. | |||
* @param __HANDLE__ specifies the SMBUS Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_SMBUS_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE)) | |||
/** @brief Disable the specified SMBUS peripheral. | |||
* @param __HANDLE__ specifies the SMBUS Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_SMBUS_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE)) | |||
/** @brief Generate a Non-Acknowledge SMBUS peripheral in Slave mode. | |||
* @param __HANDLE__ specifies the SMBUS Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_SMBUS_GENERATE_NACK(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR2, I2C_CR2_NACK)) | |||
/** | |||
* @} | |||
*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup SMBUS_Private_Macro SMBUS Private Macros | |||
* @{ | |||
*/ | |||
#define IS_SMBUS_ANALOG_FILTER(FILTER) (((FILTER) == SMBUS_ANALOGFILTER_ENABLE) || \ | |||
((FILTER) == SMBUS_ANALOGFILTER_DISABLE)) | |||
#define IS_SMBUS_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000FU) | |||
#define IS_SMBUS_ADDRESSING_MODE(MODE) (((MODE) == SMBUS_ADDRESSINGMODE_7BIT) || \ | |||
((MODE) == SMBUS_ADDRESSINGMODE_10BIT)) | |||
#define IS_SMBUS_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == SMBUS_DUALADDRESS_DISABLE) || \ | |||
((ADDRESS) == SMBUS_DUALADDRESS_ENABLE)) | |||
#define IS_SMBUS_OWN_ADDRESS2_MASK(MASK) (((MASK) == SMBUS_OA2_NOMASK) || \ | |||
((MASK) == SMBUS_OA2_MASK01) || \ | |||
((MASK) == SMBUS_OA2_MASK02) || \ | |||
((MASK) == SMBUS_OA2_MASK03) || \ | |||
((MASK) == SMBUS_OA2_MASK04) || \ | |||
((MASK) == SMBUS_OA2_MASK05) || \ | |||
((MASK) == SMBUS_OA2_MASK06) || \ | |||
((MASK) == SMBUS_OA2_MASK07)) | |||
#define IS_SMBUS_GENERAL_CALL(CALL) (((CALL) == SMBUS_GENERALCALL_DISABLE) || \ | |||
((CALL) == SMBUS_GENERALCALL_ENABLE)) | |||
#define IS_SMBUS_NO_STRETCH(STRETCH) (((STRETCH) == SMBUS_NOSTRETCH_DISABLE) || \ | |||
((STRETCH) == SMBUS_NOSTRETCH_ENABLE)) | |||
#define IS_SMBUS_PEC(PEC) (((PEC) == SMBUS_PEC_DISABLE) || \ | |||
((PEC) == SMBUS_PEC_ENABLE)) | |||
#define IS_SMBUS_PERIPHERAL_MODE(MODE) (((MODE) == SMBUS_PERIPHERAL_MODE_SMBUS_HOST) || \ | |||
((MODE) == SMBUS_PERIPHERAL_MODE_SMBUS_SLAVE) || \ | |||
((MODE) == SMBUS_PERIPHERAL_MODE_SMBUS_SLAVE_ARP)) | |||
#define IS_SMBUS_TRANSFER_MODE(MODE) (((MODE) == SMBUS_RELOAD_MODE) || \ | |||
((MODE) == SMBUS_AUTOEND_MODE) || \ | |||
((MODE) == SMBUS_SOFTEND_MODE) || \ | |||
((MODE) == SMBUS_SENDPEC_MODE) || \ | |||
((MODE) == (SMBUS_RELOAD_MODE | SMBUS_SENDPEC_MODE)) || \ | |||
((MODE) == (SMBUS_AUTOEND_MODE | SMBUS_SENDPEC_MODE)) || \ | |||
((MODE) == (SMBUS_AUTOEND_MODE | SMBUS_RELOAD_MODE)) || \ | |||
((MODE) == (SMBUS_AUTOEND_MODE | SMBUS_SENDPEC_MODE | SMBUS_RELOAD_MODE ))) | |||
#define IS_SMBUS_TRANSFER_REQUEST(REQUEST) (((REQUEST) == SMBUS_GENERATE_STOP) || \ | |||
((REQUEST) == SMBUS_GENERATE_START_READ) || \ | |||
((REQUEST) == SMBUS_GENERATE_START_WRITE) || \ | |||
((REQUEST) == SMBUS_NO_STARTSTOP)) | |||
#define IS_SMBUS_TRANSFER_OPTIONS_REQUEST(REQUEST) (IS_SMBUS_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST) || \ | |||
((REQUEST) == SMBUS_FIRST_FRAME) || \ | |||
((REQUEST) == SMBUS_NEXT_FRAME) || \ | |||
((REQUEST) == SMBUS_FIRST_AND_LAST_FRAME_NO_PEC) || \ | |||
((REQUEST) == SMBUS_LAST_FRAME_NO_PEC) || \ | |||
((REQUEST) == SMBUS_FIRST_AND_LAST_FRAME_WITH_PEC) || \ | |||
((REQUEST) == SMBUS_LAST_FRAME_WITH_PEC)) | |||
#define IS_SMBUS_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == SMBUS_OTHER_FRAME_NO_PEC) || \ | |||
((REQUEST) == SMBUS_OTHER_AND_LAST_FRAME_NO_PEC) || \ | |||
((REQUEST) == SMBUS_OTHER_FRAME_WITH_PEC) || \ | |||
((REQUEST) == SMBUS_OTHER_AND_LAST_FRAME_WITH_PEC)) | |||
#define SMBUS_RESET_CR1(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= (uint32_t)~((uint32_t)(I2C_CR1_SMBHEN | I2C_CR1_SMBDEN | I2C_CR1_PECEN))) | |||
#define SMBUS_RESET_CR2(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_HEAD10R | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_RD_WRN))) | |||
#define SMBUS_GENERATE_START(__ADDMODE__,__ADDRESS__) (((__ADDMODE__) == SMBUS_ADDRESSINGMODE_7BIT) ? (uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_START) | (I2C_CR2_AUTOEND)) & (~I2C_CR2_RD_WRN)) : \ | |||
(uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_ADD10) | (I2C_CR2_START)) & (~I2C_CR2_RD_WRN))) | |||
#define SMBUS_GET_ADDR_MATCH(__HANDLE__) (((__HANDLE__)->Instance->ISR & I2C_ISR_ADDCODE) >> 17U) | |||
#define SMBUS_GET_DIR(__HANDLE__) (((__HANDLE__)->Instance->ISR & I2C_ISR_DIR) >> 16U) | |||
#define SMBUS_GET_STOP_MODE(__HANDLE__) ((__HANDLE__)->Instance->CR2 & I2C_CR2_AUTOEND) | |||
#define SMBUS_GET_PEC_MODE(__HANDLE__) ((__HANDLE__)->Instance->CR2 & I2C_CR2_PECBYTE) | |||
#define SMBUS_GET_ALERT_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR1 & I2C_CR1_ALERTEN) | |||
#define SMBUS_CHECK_FLAG(__ISR__, __FLAG__) ((((__ISR__) & ((__FLAG__) & SMBUS_FLAG_MASK)) == ((__FLAG__) & SMBUS_FLAG_MASK)) ? SET : RESET) | |||
#define SMBUS_CHECK_IT_SOURCE(__CR1__, __IT__) ((((__CR1__) & (__IT__)) == (__IT__)) ? SET : RESET) | |||
#define IS_SMBUS_OWN_ADDRESS1(ADDRESS1) ((ADDRESS1) <= 0x000003FFU) | |||
#define IS_SMBUS_OWN_ADDRESS2(ADDRESS2) ((ADDRESS2) <= (uint16_t)0x00FFU) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup SMBUS_Exported_Functions SMBUS Exported Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup SMBUS_Exported_Functions_Group1 Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions ****************************/ | |||
HAL_StatusTypeDef HAL_SMBUS_Init(SMBUS_HandleTypeDef *hsmbus); | |||
HAL_StatusTypeDef HAL_SMBUS_DeInit(SMBUS_HandleTypeDef *hsmbus); | |||
void HAL_SMBUS_MspInit(SMBUS_HandleTypeDef *hsmbus); | |||
void HAL_SMBUS_MspDeInit(SMBUS_HandleTypeDef *hsmbus); | |||
HAL_StatusTypeDef HAL_SMBUS_ConfigAnalogFilter(SMBUS_HandleTypeDef *hsmbus, uint32_t AnalogFilter); | |||
HAL_StatusTypeDef HAL_SMBUS_ConfigDigitalFilter(SMBUS_HandleTypeDef *hsmbus, uint32_t DigitalFilter); | |||
/* Callbacks Register/UnRegister functions ***********************************/ | |||
#if (USE_HAL_SMBUS_REGISTER_CALLBACKS == 1) | |||
HAL_StatusTypeDef HAL_SMBUS_RegisterCallback(SMBUS_HandleTypeDef *hsmbus, HAL_SMBUS_CallbackIDTypeDef CallbackID, pSMBUS_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_SMBUS_UnRegisterCallback(SMBUS_HandleTypeDef *hsmbus, HAL_SMBUS_CallbackIDTypeDef CallbackID); | |||
HAL_StatusTypeDef HAL_SMBUS_RegisterAddrCallback(SMBUS_HandleTypeDef *hsmbus, pSMBUS_AddrCallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_SMBUS_UnRegisterAddrCallback(SMBUS_HandleTypeDef *hsmbus); | |||
#endif /* USE_HAL_SMBUS_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup SMBUS_Exported_Functions_Group2 Input and Output operation functions | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
/** @addtogroup Blocking_mode_Polling Blocking mode Polling | |||
* @{ | |||
*/ | |||
/******* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_SMBUS_IsDeviceReady(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup Non-Blocking_mode_Interrupt Non-Blocking mode Interrupt | |||
* @{ | |||
*/ | |||
/******* Non-Blocking mode: Interrupt */ | |||
HAL_StatusTypeDef HAL_SMBUS_Master_Transmit_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions); | |||
HAL_StatusTypeDef HAL_SMBUS_Master_Receive_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions); | |||
HAL_StatusTypeDef HAL_SMBUS_Master_Abort_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress); | |||
HAL_StatusTypeDef HAL_SMBUS_Slave_Transmit_IT(SMBUS_HandleTypeDef *hsmbus, uint8_t *pData, uint16_t Size, uint32_t XferOptions); | |||
HAL_StatusTypeDef HAL_SMBUS_Slave_Receive_IT(SMBUS_HandleTypeDef *hsmbus, uint8_t *pData, uint16_t Size, uint32_t XferOptions); | |||
HAL_StatusTypeDef HAL_SMBUS_EnableAlert_IT(SMBUS_HandleTypeDef *hsmbus); | |||
HAL_StatusTypeDef HAL_SMBUS_DisableAlert_IT(SMBUS_HandleTypeDef *hsmbus); | |||
HAL_StatusTypeDef HAL_SMBUS_EnableListen_IT(SMBUS_HandleTypeDef *hsmbus); | |||
HAL_StatusTypeDef HAL_SMBUS_DisableListen_IT(SMBUS_HandleTypeDef *hsmbus); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup SMBUS_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks | |||
* @{ | |||
*/ | |||
/******* SMBUS IRQHandler and Callbacks used in non blocking modes (Interrupt) */ | |||
void HAL_SMBUS_EV_IRQHandler(SMBUS_HandleTypeDef *hsmbus); | |||
void HAL_SMBUS_ER_IRQHandler(SMBUS_HandleTypeDef *hsmbus); | |||
void HAL_SMBUS_MasterTxCpltCallback(SMBUS_HandleTypeDef *hsmbus); | |||
void HAL_SMBUS_MasterRxCpltCallback(SMBUS_HandleTypeDef *hsmbus); | |||
void HAL_SMBUS_SlaveTxCpltCallback(SMBUS_HandleTypeDef *hsmbus); | |||
void HAL_SMBUS_SlaveRxCpltCallback(SMBUS_HandleTypeDef *hsmbus); | |||
void HAL_SMBUS_AddrCallback(SMBUS_HandleTypeDef *hsmbus, uint8_t TransferDirection, uint16_t AddrMatchCode); | |||
void HAL_SMBUS_ListenCpltCallback(SMBUS_HandleTypeDef *hsmbus); | |||
void HAL_SMBUS_ErrorCallback(SMBUS_HandleTypeDef *hsmbus); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup SMBUS_Exported_Functions_Group3 Peripheral State and Errors functions | |||
* @{ | |||
*/ | |||
/* Peripheral State and Errors functions **************************************************/ | |||
uint32_t HAL_SMBUS_GetState(SMBUS_HandleTypeDef *hsmbus); | |||
uint32_t HAL_SMBUS_GetError(SMBUS_HandleTypeDef *hsmbus); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private Functions ---------------------------------------------------------*/ | |||
/** @defgroup SMBUS_Private_Functions SMBUS Private Functions | |||
* @{ | |||
*/ | |||
/* Private functions are defined in stm32wbxx_hal_smbus.c file */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_SMBUS_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,846 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_spi.h | |||
* @author MCD Application Team | |||
* @brief Header file of SPI HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_SPI_H | |||
#define STM32WBxx_HAL_SPI_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup SPI | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup SPI_Exported_Types SPI Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief SPI Configuration Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Mode; /*!< Specifies the SPI operating mode. | |||
This parameter can be a value of @ref SPI_Mode */ | |||
uint32_t Direction; /*!< Specifies the SPI bidirectional mode state. | |||
This parameter can be a value of @ref SPI_Direction */ | |||
uint32_t DataSize; /*!< Specifies the SPI data size. | |||
This parameter can be a value of @ref SPI_Data_Size */ | |||
uint32_t CLKPolarity; /*!< Specifies the serial clock steady state. | |||
This parameter can be a value of @ref SPI_Clock_Polarity */ | |||
uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture. | |||
This parameter can be a value of @ref SPI_Clock_Phase */ | |||
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_Slave_Select_management */ | |||
uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be | |||
used to configure the transmit and receive SCK clock. | |||
This parameter can be a value of @ref SPI_BaudRate_Prescaler | |||
@note The communication clock is derived from the master | |||
clock. The slave clock does not need to be set. */ | |||
uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. | |||
This parameter can be a value of @ref SPI_MSB_LSB_transmission */ | |||
uint32_t TIMode; /*!< Specifies if the TI mode is enabled or not. | |||
This parameter can be a value of @ref SPI_TI_mode */ | |||
uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not. | |||
This parameter can be a value of @ref SPI_CRC_Calculation */ | |||
uint32_t CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. | |||
This parameter must be an odd number between Min_Data = 1 and Max_Data = 65535 */ | |||
uint32_t CRCLength; /*!< Specifies the CRC Length used for the CRC calculation. | |||
CRC Length is only used with Data8 and Data16, not other data size | |||
This parameter can be a value of @ref SPI_CRC_length */ | |||
uint32_t NSSPMode; /*!< Specifies whether the NSSP signal is enabled or not . | |||
This parameter can be a value of @ref SPI_NSSP_Mode | |||
This mode is activated by the NSSP bit in the SPIx_CR2 register and | |||
it takes effect only if the SPI interface is configured as Motorola SPI | |||
master (FRF=0) with capture on the first edge (SPIx_CR1 CPHA = 0, | |||
CPOL setting is ignored).. */ | |||
} SPI_InitTypeDef; | |||
/** | |||
* @brief HAL SPI State structure definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_SPI_STATE_RESET = 0x00U, /*!< Peripheral not Initialized */ | |||
HAL_SPI_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */ | |||
HAL_SPI_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */ | |||
HAL_SPI_STATE_BUSY_TX = 0x03U, /*!< Data Transmission process is ongoing */ | |||
HAL_SPI_STATE_BUSY_RX = 0x04U, /*!< Data Reception process is ongoing */ | |||
HAL_SPI_STATE_BUSY_TX_RX = 0x05U, /*!< Data Transmission and Reception process is ongoing */ | |||
HAL_SPI_STATE_ERROR = 0x06U, /*!< SPI error state */ | |||
HAL_SPI_STATE_ABORT = 0x07U /*!< SPI abort is ongoing */ | |||
} HAL_SPI_StateTypeDef; | |||
/** | |||
* @brief SPI handle Structure definition | |||
*/ | |||
typedef struct __SPI_HandleTypeDef | |||
{ | |||
SPI_TypeDef *Instance; /*!< SPI registers base address */ | |||
SPI_InitTypeDef Init; /*!< SPI communication parameters */ | |||
uint8_t *pTxBuffPtr; /*!< Pointer to SPI Tx transfer Buffer */ | |||
uint16_t TxXferSize; /*!< SPI Tx Transfer size */ | |||
__IO uint16_t TxXferCount; /*!< SPI Tx Transfer Counter */ | |||
uint8_t *pRxBuffPtr; /*!< Pointer to SPI Rx transfer Buffer */ | |||
uint16_t RxXferSize; /*!< SPI Rx Transfer size */ | |||
__IO uint16_t RxXferCount; /*!< SPI Rx Transfer Counter */ | |||
uint32_t CRCSize; /*!< SPI CRC size used for the transfer */ | |||
void (*RxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Rx ISR */ | |||
void (*TxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Tx ISR */ | |||
DMA_HandleTypeDef *hdmatx; /*!< SPI Tx DMA Handle parameters */ | |||
DMA_HandleTypeDef *hdmarx; /*!< SPI Rx DMA Handle parameters */ | |||
HAL_LockTypeDef Lock; /*!< Locking object */ | |||
__IO HAL_SPI_StateTypeDef State; /*!< SPI communication state */ | |||
__IO uint32_t ErrorCode; /*!< SPI Error code */ | |||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U) | |||
void (* TxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Tx Completed callback */ | |||
void (* RxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Rx Completed callback */ | |||
void (* TxRxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI TxRx Completed callback */ | |||
void (* TxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Tx Half Completed callback */ | |||
void (* RxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Rx Half Completed callback */ | |||
void (* TxRxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI TxRx Half Completed callback */ | |||
void (* ErrorCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Error callback */ | |||
void (* AbortCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Abort callback */ | |||
void (* MspInitCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Msp Init callback */ | |||
void (* MspDeInitCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Msp DeInit callback */ | |||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */ | |||
} SPI_HandleTypeDef; | |||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U) | |||
/** | |||
* @brief HAL SPI Callback ID enumeration definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_SPI_TX_COMPLETE_CB_ID = 0x00U, /*!< SPI Tx Completed callback ID */ | |||
HAL_SPI_RX_COMPLETE_CB_ID = 0x01U, /*!< SPI Rx Completed callback ID */ | |||
HAL_SPI_TX_RX_COMPLETE_CB_ID = 0x02U, /*!< SPI TxRx Completed callback ID */ | |||
HAL_SPI_TX_HALF_COMPLETE_CB_ID = 0x03U, /*!< SPI Tx Half Completed callback ID */ | |||
HAL_SPI_RX_HALF_COMPLETE_CB_ID = 0x04U, /*!< SPI Rx Half Completed callback ID */ | |||
HAL_SPI_TX_RX_HALF_COMPLETE_CB_ID = 0x05U, /*!< SPI TxRx Half Completed callback ID */ | |||
HAL_SPI_ERROR_CB_ID = 0x06U, /*!< SPI Error callback ID */ | |||
HAL_SPI_ABORT_CB_ID = 0x07U, /*!< SPI Abort callback ID */ | |||
HAL_SPI_MSPINIT_CB_ID = 0x08U, /*!< SPI Msp Init callback ID */ | |||
HAL_SPI_MSPDEINIT_CB_ID = 0x09U /*!< SPI Msp DeInit callback ID */ | |||
} HAL_SPI_CallbackIDTypeDef; | |||
/** | |||
* @brief HAL SPI Callback pointer definition | |||
*/ | |||
typedef void (*pSPI_CallbackTypeDef)(SPI_HandleTypeDef *hspi); /*!< pointer to an SPI callback function */ | |||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup SPI_Exported_Constants SPI Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup SPI_Error_Code SPI Error Code | |||
* @{ | |||
*/ | |||
#define HAL_SPI_ERROR_NONE (0x00000000U) /*!< No error */ | |||
#define HAL_SPI_ERROR_MODF (0x00000001U) /*!< MODF error */ | |||
#define HAL_SPI_ERROR_CRC (0x00000002U) /*!< CRC error */ | |||
#define HAL_SPI_ERROR_OVR (0x00000004U) /*!< OVR error */ | |||
#define HAL_SPI_ERROR_FRE (0x00000008U) /*!< FRE error */ | |||
#define HAL_SPI_ERROR_DMA (0x00000010U) /*!< DMA transfer error */ | |||
#define HAL_SPI_ERROR_FLAG (0x00000020U) /*!< Error on RXNE/TXE/BSY/FTLVL/FRLVL Flag */ | |||
#define HAL_SPI_ERROR_ABORT (0x00000040U) /*!< Error during SPI Abort procedure */ | |||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U) | |||
#define HAL_SPI_ERROR_INVALID_CALLBACK (0x00000080U) /*!< Invalid Callback error */ | |||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_Mode SPI Mode | |||
* @{ | |||
*/ | |||
#define SPI_MODE_SLAVE (0x00000000U) | |||
#define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_Direction SPI Direction Mode | |||
* @{ | |||
*/ | |||
#define SPI_DIRECTION_2LINES (0x00000000U) | |||
#define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY | |||
#define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_Data_Size SPI Data Size | |||
* @{ | |||
*/ | |||
#define SPI_DATASIZE_4BIT (0x00000300U) | |||
#define SPI_DATASIZE_5BIT (0x00000400U) | |||
#define SPI_DATASIZE_6BIT (0x00000500U) | |||
#define SPI_DATASIZE_7BIT (0x00000600U) | |||
#define SPI_DATASIZE_8BIT (0x00000700U) | |||
#define SPI_DATASIZE_9BIT (0x00000800U) | |||
#define SPI_DATASIZE_10BIT (0x00000900U) | |||
#define SPI_DATASIZE_11BIT (0x00000A00U) | |||
#define SPI_DATASIZE_12BIT (0x00000B00U) | |||
#define SPI_DATASIZE_13BIT (0x00000C00U) | |||
#define SPI_DATASIZE_14BIT (0x00000D00U) | |||
#define SPI_DATASIZE_15BIT (0x00000E00U) | |||
#define SPI_DATASIZE_16BIT (0x00000F00U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_Clock_Polarity SPI Clock Polarity | |||
* @{ | |||
*/ | |||
#define SPI_POLARITY_LOW (0x00000000U) | |||
#define SPI_POLARITY_HIGH SPI_CR1_CPOL | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_Clock_Phase SPI Clock Phase | |||
* @{ | |||
*/ | |||
#define SPI_PHASE_1EDGE (0x00000000U) | |||
#define SPI_PHASE_2EDGE SPI_CR1_CPHA | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_Slave_Select_management SPI Slave Select Management | |||
* @{ | |||
*/ | |||
#define SPI_NSS_SOFT SPI_CR1_SSM | |||
#define SPI_NSS_HARD_INPUT (0x00000000U) | |||
#define SPI_NSS_HARD_OUTPUT (SPI_CR2_SSOE << 16U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_NSSP_Mode SPI NSS Pulse Mode | |||
* @{ | |||
*/ | |||
#define SPI_NSS_PULSE_ENABLE SPI_CR2_NSSP | |||
#define SPI_NSS_PULSE_DISABLE (0x00000000U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler | |||
* @{ | |||
*/ | |||
#define SPI_BAUDRATEPRESCALER_2 (0x00000000U) | |||
#define SPI_BAUDRATEPRESCALER_4 (SPI_CR1_BR_0) | |||
#define SPI_BAUDRATEPRESCALER_8 (SPI_CR1_BR_1) | |||
#define SPI_BAUDRATEPRESCALER_16 (SPI_CR1_BR_1 | SPI_CR1_BR_0) | |||
#define SPI_BAUDRATEPRESCALER_32 (SPI_CR1_BR_2) | |||
#define SPI_BAUDRATEPRESCALER_64 (SPI_CR1_BR_2 | SPI_CR1_BR_0) | |||
#define SPI_BAUDRATEPRESCALER_128 (SPI_CR1_BR_2 | SPI_CR1_BR_1) | |||
#define SPI_BAUDRATEPRESCALER_256 (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB Transmission | |||
* @{ | |||
*/ | |||
#define SPI_FIRSTBIT_MSB (0x00000000U) | |||
#define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_TI_mode SPI TI Mode | |||
* @{ | |||
*/ | |||
#define SPI_TIMODE_DISABLE (0x00000000U) | |||
#define SPI_TIMODE_ENABLE SPI_CR2_FRF | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_CRC_Calculation SPI CRC Calculation | |||
* @{ | |||
*/ | |||
#define SPI_CRCCALCULATION_DISABLE (0x00000000U) | |||
#define SPI_CRCCALCULATION_ENABLE SPI_CR1_CRCEN | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_CRC_length SPI CRC Length | |||
* @{ | |||
* This parameter can be one of the following values: | |||
* SPI_CRC_LENGTH_DATASIZE: aligned with the data size | |||
* SPI_CRC_LENGTH_8BIT : CRC 8bit | |||
* SPI_CRC_LENGTH_16BIT : CRC 16bit | |||
*/ | |||
#define SPI_CRC_LENGTH_DATASIZE (0x00000000U) | |||
#define SPI_CRC_LENGTH_8BIT (0x00000001U) | |||
#define SPI_CRC_LENGTH_16BIT (0x00000002U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_FIFO_reception_threshold SPI FIFO Reception Threshold | |||
* @{ | |||
* This parameter can be one of the following values: | |||
* SPI_RXFIFO_THRESHOLD or SPI_RXFIFO_THRESHOLD_QF : | |||
* RXNE event is generated if the FIFO | |||
* level is greater or equal to 1/4(8-bits). | |||
* SPI_RXFIFO_THRESHOLD_HF: RXNE event is generated if the FIFO | |||
* level is greater or equal to 1/2(16 bits). */ | |||
#define SPI_RXFIFO_THRESHOLD SPI_CR2_FRXTH | |||
#define SPI_RXFIFO_THRESHOLD_QF SPI_CR2_FRXTH | |||
#define SPI_RXFIFO_THRESHOLD_HF (0x00000000U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_Interrupt_definition SPI Interrupt Definition | |||
* @{ | |||
*/ | |||
#define SPI_IT_TXE SPI_CR2_TXEIE | |||
#define SPI_IT_RXNE SPI_CR2_RXNEIE | |||
#define SPI_IT_ERR SPI_CR2_ERRIE | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_Flags_definition SPI Flags Definition | |||
* @{ | |||
*/ | |||
#define SPI_FLAG_RXNE SPI_SR_RXNE /* SPI status flag: Rx buffer not empty flag */ | |||
#define SPI_FLAG_TXE SPI_SR_TXE /* SPI status flag: Tx buffer empty flag */ | |||
#define SPI_FLAG_BSY SPI_SR_BSY /* SPI status flag: Busy flag */ | |||
#define SPI_FLAG_CRCERR SPI_SR_CRCERR /* SPI Error flag: CRC error flag */ | |||
#define SPI_FLAG_MODF SPI_SR_MODF /* SPI Error flag: Mode fault flag */ | |||
#define SPI_FLAG_OVR SPI_SR_OVR /* SPI Error flag: Overrun flag */ | |||
#define SPI_FLAG_FRE SPI_SR_FRE /* SPI Error flag: TI mode frame format error flag */ | |||
#define SPI_FLAG_FTLVL SPI_SR_FTLVL /* SPI fifo transmission level */ | |||
#define SPI_FLAG_FRLVL SPI_SR_FRLVL /* SPI fifo reception level */ | |||
#define SPI_FLAG_MASK (SPI_SR_RXNE | SPI_SR_TXE | SPI_SR_BSY | SPI_SR_CRCERR | SPI_SR_MODF | SPI_SR_OVR | SPI_SR_FRE | SPI_SR_FTLVL | SPI_SR_FRLVL) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_transmission_fifo_status_level SPI Transmission FIFO Status Level | |||
* @{ | |||
*/ | |||
#define SPI_FTLVL_EMPTY (0x00000000U) | |||
#define SPI_FTLVL_QUARTER_FULL (0x00000800U) | |||
#define SPI_FTLVL_HALF_FULL (0x00001000U) | |||
#define SPI_FTLVL_FULL (0x00001800U) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup SPI_reception_fifo_status_level SPI Reception FIFO Status Level | |||
* @{ | |||
*/ | |||
#define SPI_FRLVL_EMPTY (0x00000000U) | |||
#define SPI_FRLVL_QUARTER_FULL (0x00000200U) | |||
#define SPI_FRLVL_HALF_FULL (0x00000400U) | |||
#define SPI_FRLVL_FULL (0x00000600U) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup SPI_Exported_Macros SPI Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset SPI handle state. | |||
* @param __HANDLE__ specifies the SPI Handle. | |||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
* @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) | |||
#else | |||
#define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET) | |||
#endif | |||
/** @brief Enable the specified SPI interrupts. | |||
* @param __HANDLE__ specifies the SPI Handle. | |||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
* @param __INTERRUPT__ specifies the interrupt source to enable. | |||
* This parameter can be one of the following values: | |||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable | |||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable | |||
* @arg SPI_IT_ERR: Error interrupt enable | |||
* @retval None | |||
*/ | |||
#define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__)) | |||
/** @brief Disable the specified SPI interrupts. | |||
* @param __HANDLE__ specifies the SPI handle. | |||
* This parameter can be SPIx where x: 1, 2, or 3 to select the SPI peripheral. | |||
* @param __INTERRUPT__ specifies the interrupt source to disable. | |||
* This parameter can be one of the following values: | |||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable | |||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable | |||
* @arg SPI_IT_ERR: Error interrupt enable | |||
* @retval None | |||
*/ | |||
#define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__)) | |||
/** @brief Check whether the specified SPI interrupt source is enabled or not. | |||
* @param __HANDLE__ specifies the SPI Handle. | |||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
* @param __INTERRUPT__ specifies the SPI interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable | |||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable | |||
* @arg SPI_IT_ERR: Error interrupt enable | |||
* @retval The new state of __IT__ (TRUE or FALSE). | |||
*/ | |||
#define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
/** @brief Check whether the specified SPI flag is set or not. | |||
* @param __HANDLE__ specifies the SPI Handle. | |||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg SPI_FLAG_RXNE: Receive buffer not empty flag | |||
* @arg SPI_FLAG_TXE: Transmit buffer empty flag | |||
* @arg SPI_FLAG_CRCERR: CRC error flag | |||
* @arg SPI_FLAG_MODF: Mode fault flag | |||
* @arg SPI_FLAG_OVR: Overrun flag | |||
* @arg SPI_FLAG_BSY: Busy flag | |||
* @arg SPI_FLAG_FRE: Frame format error flag | |||
* @arg SPI_FLAG_FTLVL: SPI fifo transmission level | |||
* @arg SPI_FLAG_FRLVL: SPI fifo reception level | |||
* @retval The new state of __FLAG__ (TRUE or FALSE). | |||
*/ | |||
#define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) | |||
/** @brief Clear the SPI CRCERR pending flag. | |||
* @param __HANDLE__ specifies the SPI Handle. | |||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
* @retval None | |||
*/ | |||
#define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = (uint16_t)(~SPI_FLAG_CRCERR)) | |||
/** @brief Clear the SPI MODF pending flag. | |||
* @param __HANDLE__ specifies the SPI Handle. | |||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
* @retval None | |||
*/ | |||
#define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) \ | |||
do{ \ | |||
__IO uint32_t tmpreg_modf = 0x00U; \ | |||
tmpreg_modf = (__HANDLE__)->Instance->SR; \ | |||
CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE); \ | |||
UNUSED(tmpreg_modf); \ | |||
} while(0U) | |||
/** @brief Clear the SPI OVR pending flag. | |||
* @param __HANDLE__ specifies the SPI Handle. | |||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
* @retval None | |||
*/ | |||
#define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) \ | |||
do{ \ | |||
__IO uint32_t tmpreg_ovr = 0x00U; \ | |||
tmpreg_ovr = (__HANDLE__)->Instance->DR; \ | |||
tmpreg_ovr = (__HANDLE__)->Instance->SR; \ | |||
UNUSED(tmpreg_ovr); \ | |||
} while(0U) | |||
/** @brief Clear the SPI FRE pending flag. | |||
* @param __HANDLE__ specifies the SPI Handle. | |||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
* @retval None | |||
*/ | |||
#define __HAL_SPI_CLEAR_FREFLAG(__HANDLE__) \ | |||
do{ \ | |||
__IO uint32_t tmpreg_fre = 0x00U; \ | |||
tmpreg_fre = (__HANDLE__)->Instance->SR; \ | |||
UNUSED(tmpreg_fre); \ | |||
}while(0U) | |||
/** @brief Enable the SPI peripheral. | |||
* @param __HANDLE__ specifies the SPI Handle. | |||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
* @retval None | |||
*/ | |||
#define __HAL_SPI_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE) | |||
/** @brief Disable the SPI peripheral. | |||
* @param __HANDLE__ specifies the SPI Handle. | |||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
* @retval None | |||
*/ | |||
#define __HAL_SPI_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE) | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup SPI_Private_Macros SPI Private Macros | |||
* @{ | |||
*/ | |||
/** @brief Set the SPI transmit-only mode. | |||
* @param __HANDLE__ specifies the SPI Handle. | |||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
* @retval None | |||
*/ | |||
#define SPI_1LINE_TX(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE) | |||
/** @brief Set the SPI receive-only mode. | |||
* @param __HANDLE__ specifies the SPI Handle. | |||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
* @retval None | |||
*/ | |||
#define SPI_1LINE_RX(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE) | |||
/** @brief Reset the CRC calculation of the SPI. | |||
* @param __HANDLE__ specifies the SPI Handle. | |||
* 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) | |||
/** @brief Check whether the specified SPI flag is set or not. | |||
* @param __SR__ copy of SPI SR regsiter. | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg SPI_FLAG_RXNE: Receive buffer not empty flag | |||
* @arg SPI_FLAG_TXE: Transmit buffer empty flag | |||
* @arg SPI_FLAG_CRCERR: CRC error flag | |||
* @arg SPI_FLAG_MODF: Mode fault flag | |||
* @arg SPI_FLAG_OVR: Overrun flag | |||
* @arg SPI_FLAG_BSY: Busy flag | |||
* @arg SPI_FLAG_FRE: Frame format error flag | |||
* @arg SPI_FLAG_FTLVL: SPI fifo transmission level | |||
* @arg SPI_FLAG_FRLVL: SPI fifo reception level | |||
* @retval SET or RESET. | |||
*/ | |||
#define SPI_CHECK_FLAG(__SR__, __FLAG__) ((((__SR__) & ((__FLAG__) & SPI_FLAG_MASK)) == ((__FLAG__) & SPI_FLAG_MASK)) ? SET : RESET) | |||
/** @brief Check whether the specified SPI Interrupt is set or not. | |||
* @param __CR2__ copy of SPI CR2 regsiter. | |||
* @param __INTERRUPT__ specifies the SPI interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable | |||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable | |||
* @arg SPI_IT_ERR: Error interrupt enable | |||
* @retval SET or RESET. | |||
*/ | |||
#define SPI_CHECK_IT_SOURCE(__CR2__, __INTERRUPT__) ((((__CR2__) & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
/** @brief Checks if SPI Mode parameter is in allowed range. | |||
* @param __MODE__ specifies the SPI Mode. | |||
* This parameter can be a value of @ref SPI_Mode | |||
* @retval None | |||
*/ | |||
#define IS_SPI_MODE(__MODE__) (((__MODE__) == SPI_MODE_SLAVE) || \ | |||
((__MODE__) == SPI_MODE_MASTER)) | |||
/** @brief Checks if SPI Direction Mode parameter is in allowed range. | |||
* @param __MODE__ specifies the SPI Direction Mode. | |||
* This parameter can be a value of @ref SPI_Direction | |||
* @retval None | |||
*/ | |||
#define IS_SPI_DIRECTION(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \ | |||
((__MODE__) == SPI_DIRECTION_2LINES_RXONLY) || \ | |||
((__MODE__) == SPI_DIRECTION_1LINE)) | |||
/** @brief Checks if SPI Direction Mode parameter is 2 lines. | |||
* @param __MODE__ specifies the SPI Direction Mode. | |||
* @retval None | |||
*/ | |||
#define IS_SPI_DIRECTION_2LINES(__MODE__) ((__MODE__) == SPI_DIRECTION_2LINES) | |||
/** @brief Checks if SPI Direction Mode parameter is 1 or 2 lines. | |||
* @param __MODE__ specifies the SPI Direction Mode. | |||
* @retval None | |||
*/ | |||
#define IS_SPI_DIRECTION_2LINES_OR_1LINE(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \ | |||
((__MODE__) == SPI_DIRECTION_1LINE)) | |||
/** @brief Checks if SPI Data Size parameter is in allowed range. | |||
* @param __DATASIZE__ specifies the SPI Data Size. | |||
* This parameter can be a value of @ref SPI_Data_Size | |||
* @retval None | |||
*/ | |||
#define IS_SPI_DATASIZE(__DATASIZE__) (((__DATASIZE__) == SPI_DATASIZE_16BIT) || \ | |||
((__DATASIZE__) == SPI_DATASIZE_15BIT) || \ | |||
((__DATASIZE__) == SPI_DATASIZE_14BIT) || \ | |||
((__DATASIZE__) == SPI_DATASIZE_13BIT) || \ | |||
((__DATASIZE__) == SPI_DATASIZE_12BIT) || \ | |||
((__DATASIZE__) == SPI_DATASIZE_11BIT) || \ | |||
((__DATASIZE__) == SPI_DATASIZE_10BIT) || \ | |||
((__DATASIZE__) == SPI_DATASIZE_9BIT) || \ | |||
((__DATASIZE__) == SPI_DATASIZE_8BIT) || \ | |||
((__DATASIZE__) == SPI_DATASIZE_7BIT) || \ | |||
((__DATASIZE__) == SPI_DATASIZE_6BIT) || \ | |||
((__DATASIZE__) == SPI_DATASIZE_5BIT) || \ | |||
((__DATASIZE__) == SPI_DATASIZE_4BIT)) | |||
/** @brief Checks if SPI Serial clock steady state parameter is in allowed range. | |||
* @param __CPOL__ specifies the SPI serial clock steady state. | |||
* This parameter can be a value of @ref SPI_Clock_Polarity | |||
* @retval None | |||
*/ | |||
#define IS_SPI_CPOL(__CPOL__) (((__CPOL__) == SPI_POLARITY_LOW) || \ | |||
((__CPOL__) == SPI_POLARITY_HIGH)) | |||
/** @brief Checks if SPI Clock Phase parameter is in allowed range. | |||
* @param __CPHA__ specifies the SPI Clock Phase. | |||
* This parameter can be a value of @ref SPI_Clock_Phase | |||
* @retval None | |||
*/ | |||
#define IS_SPI_CPHA(__CPHA__) (((__CPHA__) == SPI_PHASE_1EDGE) || \ | |||
((__CPHA__) == SPI_PHASE_2EDGE)) | |||
/** @brief Checks if SPI Slave Select parameter is in allowed range. | |||
* @param __NSS__ specifies the SPI Slave Select management parameter. | |||
* This parameter can be a value of @ref SPI_Slave_Select_management | |||
* @retval None | |||
*/ | |||
#define IS_SPI_NSS(__NSS__) (((__NSS__) == SPI_NSS_SOFT) || \ | |||
((__NSS__) == SPI_NSS_HARD_INPUT) || \ | |||
((__NSS__) == SPI_NSS_HARD_OUTPUT)) | |||
/** @brief Checks if SPI NSS Pulse parameter is in allowed range. | |||
* @param __NSSP__ specifies the SPI NSS Pulse Mode parameter. | |||
* This parameter can be a value of @ref SPI_NSSP_Mode | |||
* @retval None | |||
*/ | |||
#define IS_SPI_NSSP(__NSSP__) (((__NSSP__) == SPI_NSS_PULSE_ENABLE) || \ | |||
((__NSSP__) == SPI_NSS_PULSE_DISABLE)) | |||
/** @brief Checks if SPI Baudrate prescaler parameter is in allowed range. | |||
* @param __PRESCALER__ specifies the SPI Baudrate prescaler. | |||
* This parameter can be a value of @ref SPI_BaudRate_Prescaler | |||
* @retval None | |||
*/ | |||
#define IS_SPI_BAUDRATE_PRESCALER(__PRESCALER__) (((__PRESCALER__) == SPI_BAUDRATEPRESCALER_2) || \ | |||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_4) || \ | |||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_8) || \ | |||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_16) || \ | |||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_32) || \ | |||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_64) || \ | |||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_128) || \ | |||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_256)) | |||
/** @brief Checks if SPI MSB LSB transmission parameter is in allowed range. | |||
* @param __BIT__ specifies the SPI MSB LSB transmission (whether data transfer starts from MSB or LSB bit). | |||
* This parameter can be a value of @ref SPI_MSB_LSB_transmission | |||
* @retval None | |||
*/ | |||
#define IS_SPI_FIRST_BIT(__BIT__) (((__BIT__) == SPI_FIRSTBIT_MSB) || \ | |||
((__BIT__) == SPI_FIRSTBIT_LSB)) | |||
/** @brief Checks if SPI TI mode parameter is in allowed range. | |||
* @param __MODE__ specifies the SPI TI mode. | |||
* This parameter can be a value of @ref SPI_TI_mode | |||
* @retval None | |||
*/ | |||
#define IS_SPI_TIMODE(__MODE__) (((__MODE__) == SPI_TIMODE_DISABLE) || \ | |||
((__MODE__) == SPI_TIMODE_ENABLE)) | |||
/** @brief Checks if SPI CRC calculation enabled state is in allowed range. | |||
* @param __CALCULATION__ specifies the SPI CRC calculation enable state. | |||
* This parameter can be a value of @ref SPI_CRC_Calculation | |||
* @retval None | |||
*/ | |||
#define IS_SPI_CRC_CALCULATION(__CALCULATION__) (((__CALCULATION__) == SPI_CRCCALCULATION_DISABLE) || \ | |||
((__CALCULATION__) == SPI_CRCCALCULATION_ENABLE)) | |||
/** @brief Checks if SPI CRC length is in allowed range. | |||
* @param __LENGTH__ specifies the SPI CRC length. | |||
* This parameter can be a value of @ref SPI_CRC_length | |||
* @retval None | |||
*/ | |||
#define IS_SPI_CRC_LENGTH(__LENGTH__) (((__LENGTH__) == SPI_CRC_LENGTH_DATASIZE) ||\ | |||
((__LENGTH__) == SPI_CRC_LENGTH_8BIT) || \ | |||
((__LENGTH__) == SPI_CRC_LENGTH_16BIT)) | |||
/** @brief Checks if SPI polynomial value to be used for the CRC calculation, is in allowed range. | |||
* @param __POLYNOMIAL__ specifies the SPI polynomial value to be used for the CRC calculation. | |||
* This parameter must be a number between Min_Data = 0 and Max_Data = 65535 | |||
* @retval None | |||
*/ | |||
#define IS_SPI_CRC_POLYNOMIAL(__POLYNOMIAL__) (((__POLYNOMIAL__) >= 0x1U) && ((__POLYNOMIAL__) <= 0xFFFFU) && (((__POLYNOMIAL__)&0x1U) != 0U)) | |||
/** @brief Checks if DMA handle is valid. | |||
* @param __HANDLE__ specifies a DMA Handle. | |||
* @retval None | |||
*/ | |||
#define IS_SPI_DMA_HANDLE(__HANDLE__) ((__HANDLE__) != NULL) | |||
/** | |||
* @} | |||
*/ | |||
/* Include SPI HAL Extended module */ | |||
#include "stm32wbxx_hal_spi_ex.h" | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup SPI_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup SPI_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
/* Initialization/de-initialization functions ********************************/ | |||
HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi); | |||
HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi); | |||
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi); | |||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi); | |||
/* Callbacks Register/UnRegister functions ***********************************/ | |||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U) | |||
HAL_StatusTypeDef HAL_SPI_RegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_CallbackIDTypeDef CallbackID, pSPI_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_SPI_UnRegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_CallbackIDTypeDef CallbackID); | |||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup SPI_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
/* 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_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_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, | |||
uint16_t Size); | |||
HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, 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, | |||
uint16_t Size); | |||
HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi); | |||
HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi); | |||
HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi); | |||
/* Transfer Abort functions */ | |||
HAL_StatusTypeDef HAL_SPI_Abort(SPI_HandleTypeDef *hspi); | |||
HAL_StatusTypeDef HAL_SPI_Abort_IT(SPI_HandleTypeDef *hspi); | |||
void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi); | |||
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi); | |||
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi); | |||
void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi); | |||
void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi); | |||
void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi); | |||
void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi); | |||
void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi); | |||
void HAL_SPI_AbortCpltCallback(SPI_HandleTypeDef *hspi); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup SPI_Exported_Functions_Group3 | |||
* @{ | |||
*/ | |||
/* Peripheral State and Error functions ***************************************/ | |||
HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi); | |||
uint32_t HAL_SPI_GetError(SPI_HandleTypeDef *hspi); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_SPI_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,75 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_spi_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of SPI HAL Extended module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_SPI_EX_H | |||
#define STM32WBxx_HAL_SPI_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup SPIEx | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup SPIEx_Exported_Functions | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions ****************************/ | |||
/* IO operation functions *****************************************************/ | |||
/** @addtogroup SPIEx_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(SPI_HandleTypeDef *hspi); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_SPI_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,371 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_tim_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of TIM HAL Extended module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_TIM_EX_H | |||
#define STM32WBxx_HAL_TIM_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup TIMEx | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup TIMEx_Exported_Types TIM Extended Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief TIM Hall sensor Configuration Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal. | |||
This parameter can be a value of @ref TIM_Input_Capture_Polarity */ | |||
uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler. | |||
This parameter can be a value of @ref TIM_Input_Capture_Prescaler */ | |||
uint32_t IC1Filter; /*!< Specifies the input capture filter. | |||
This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */ | |||
uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register. | |||
This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ | |||
} TIM_HallSensor_InitTypeDef; | |||
/** | |||
* @brief TIM Break/Break2 input configuration | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Source; /*!< Specifies the source of the timer break input. | |||
This parameter can be a value of @ref TIMEx_Break_Input_Source */ | |||
uint32_t Enable; /*!< Specifies whether or not the break input source is enabled. | |||
This parameter can be a value of @ref TIMEx_Break_Input_Source_Enable */ | |||
uint32_t Polarity; /*!< Specifies the break input source polarity. | |||
This parameter can be a value of @ref TIMEx_Break_Input_Source_Polarity */ | |||
} | |||
TIMEx_BreakInputConfigTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* End of exported types -----------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup TIMEx_Remap TIM Extended Remapping | |||
* @{ | |||
*/ | |||
#define TIM_TIM1_ETR_GPIO 0x00000000U /* !< TIM1_ETR is not connected to I/O */ | |||
#define TIM_TIM1_ETR_ADC1_AWD1 TIM1_OR_ETR_ADC1_RMP_0 /* !< TIM1_ETR is connected to ADC1 AWD1 */ | |||
#define TIM_TIM1_ETR_ADC1_AWD2 TIM1_OR_ETR_ADC1_RMP_1 /* !< TIM1_ETR is connected to ADC1 AWD2 */ | |||
#define TIM_TIM1_ETR_ADC1_AWD3 (TIM1_OR_ETR_ADC1_RMP_0 | TIM1_OR_ETR_ADC1_RMP_1) /* !< TIM1_ETR is connected to ADC1 AWD3 */ | |||
#define TIM_TIM1_ETR_COMP1 TIM1_AF1_ETRSEL_0 /* !< TIM1_ETR is connected to COMP1 output */ | |||
#define TIM_TIM1_ETR_COMP2 TIM1_AF1_ETRSEL_1 /* !< TIM1_ETR is connected to COMP2 output */ | |||
#define TIM_TIM1_TI1_GPIO 0x00000000U /* !< TIM1 Input capture 1 is connected to I/0 */ | |||
#define TIM_TIM1_TI1_COMP1 TIM1_OR_TI1_RMP /* !< TIM1 Input capture 1is connected to COMP1 OUT */ | |||
#define TIM_TIM2_ITR_NC 0x00000000U /* !< TIM2 Internal trigger ITR is not connected */ | |||
#define TIM_TIM2_ITR_USB TIM2_OR_ITR1_RMP /* !< TIM2 Internal trigger ITR is connected to USBFS SOF */ | |||
#define TIM_TIM2_ETR_GPIO 0x00000000U /* !< TIM2 External trigger ETR is connected to I/O */ | |||
#define TIM_TIM2_ETR_LSE TIM2_OR_ETR_RMP /* !< TIM2 External trigger ETR is connected to LSE */ | |||
#define TIM_TIM2_ETR_COMP1 TIM2_AF1_ETRSEL_0 /* !< TIM2_ETR is connected to COMP1 output */ | |||
#define TIM_TIM2_ETR_COMP2 TIM2_AF1_ETRSEL_1 /* !< TIM2_ETR is connected to COMP2 output */ | |||
#define TIM_TIM2_TI4_GPIO 0x00000000U /* !< TIM2_TI4 is connected to I/O */ | |||
#define TIM_TIM2_TI4_COMP1 TIM2_OR_TI4_RMP_0 /* !< TIM2_TI4 is connected to COMP1 OUT */ | |||
#define TIM_TIM2_TI4_COMP2 TIM2_OR_TI4_RMP_1 /* !< TIM2_TI4 is connected to COMP1 OUT */ | |||
#define TIM_TIM2_TI4_COMP1_COMP2 (TIM2_OR_TI4_RMP_0 | TIM2_OR_TI4_RMP_1) /* !< TIM2_TI4 is connected to COMP1 and COMP2 OUT */ | |||
#define TIM_TIM16_TI1_GPIO 0x00000000U /* !< TIM16_TI1 is connected to I/O */ | |||
#define TIM_TIM16_TI1_LSI TIM16_OR_TI1_RMP_0 /* !< TIM16_TI1 is connected to LSI Clock */ | |||
#define TIM_TIM16_TI1_LSE TIM16_OR_TI1_RMP_1 /* !< TIM16_TI1 is connected to LSE Clock */ | |||
#define TIM_TIM16_TI1_RTC (TIM16_OR_TI1_RMP_0 | TIM16_OR_TI1_RMP_1) /* !< TIM16_TI1 is connected to RTC */ | |||
#define TIM_TIM17_TI1_GPIO 0x00000000U /* !< TIM17_TI1 is connected to I/O */ | |||
#define TIM_TIM17_TI1_MSI TIM17_OR_TI1_RMP_0 /* !< TIM17_TI1 is connected to MSI */ | |||
#define TIM_TIM17_TI1_HSE TIM17_OR_TI1_RMP_1 /* !< TIM17_TI1 is connected to HSE/32 */ | |||
#define TIM_TIM17_TI1_MCO (TIM17_OR_TI1_RMP_0 | TIM17_OR_TI1_RMP_1) /* !< TIM17_TI1 is connected to MCO */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TIMEx_Break_Input TIM Extended Break input | |||
* @{ | |||
*/ | |||
#define TIM_BREAKINPUT_BRK 0x00000001U /* !< Timer break input */ | |||
#define TIM_BREAKINPUT_BRK2 0x00000002U /* !< Timer break2 input */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TIMEx_Break_Input_Source TIM Extended Break input source | |||
* @{ | |||
*/ | |||
#define TIM_BREAKINPUTSOURCE_BKIN 0x00000001U /* !< An external source (GPIO) is connected to the BKIN pin */ | |||
#define TIM_BREAKINPUTSOURCE_COMP1 0x00000002U /* !< The COMP1 output is connected to the break input */ | |||
#define TIM_BREAKINPUTSOURCE_COMP2 0x00000004U /* !< The COMP2 output is connected to the break input */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TIMEx_Break_Input_Source_Enable TIM Extended Break input source enabling | |||
* @{ | |||
*/ | |||
#define TIM_BREAKINPUTSOURCE_DISABLE 0x00000000U /* !< Break input source is disabled */ | |||
#define TIM_BREAKINPUTSOURCE_ENABLE 0x00000001U /* !< Break input source is enabled */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TIMEx_Break_Input_Source_Polarity TIM Extended Break input polarity | |||
* @{ | |||
*/ | |||
#define TIM_BREAKINPUTSOURCE_POLARITY_LOW 0x00000001U /* !< Break input source is active low */ | |||
#define TIM_BREAKINPUTSOURCE_POLARITY_HIGH 0x00000000U /* !< Break input source is active_high */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* End of exported constants -------------------------------------------------*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* End of exported macro -----------------------------------------------------*/ | |||
/* Private macro -------------------------------------------------------------*/ | |||
/** @defgroup TIMEx_Private_Macros TIM Extended Private Macros | |||
* @{ | |||
*/ | |||
#define IS_TIM_REMAP(__INSTANCE__, __REMAP__) \ | |||
((((__INSTANCE__) == TIM1) && ((((__REMAP__) & 0xFFFE3FECU) == 0x00000000U))) \ | |||
|| (((__INSTANCE__) == TIM2) && ((((__REMAP__) & 0xFFFE3FF0U) == 0x00000000U))) \ | |||
|| (((__INSTANCE__) == TIM16) && ((((__REMAP__) & 0xFFFFFFFCU) == 0x00000000U))) \ | |||
|| (((__INSTANCE__) == TIM17) && ((((__REMAP__) & 0xFFFFFFFCU) == 0x00000000U)))) | |||
#define IS_TIM_BREAKINPUT(__BREAKINPUT__) \ | |||
(((__BREAKINPUT__) == TIM_BREAKINPUT_BRK) || \ | |||
((__BREAKINPUT__) == TIM_BREAKINPUT_BRK2)) | |||
#define IS_TIM_BREAKINPUTSOURCE(__SOURCE__) \ | |||
(((__SOURCE__) == TIM_BREAKINPUTSOURCE_BKIN) || \ | |||
((__SOURCE__) == TIM_BREAKINPUTSOURCE_COMP1) || \ | |||
((__SOURCE__) == TIM_BREAKINPUTSOURCE_COMP2)) | |||
#define IS_TIM_BREAKINPUTSOURCE_STATE(__STATE__) \ | |||
(((__STATE__) == TIM_BREAKINPUTSOURCE_DISABLE) || \ | |||
((__STATE__) == TIM_BREAKINPUTSOURCE_ENABLE)) | |||
#define IS_TIM_BREAKINPUTSOURCE_POLARITY(__POLARITY__) \ | |||
(((__POLARITY__) == TIM_BREAKINPUTSOURCE_POLARITY_LOW) || \ | |||
((__POLARITY__) == TIM_BREAKINPUTSOURCE_POLARITY_HIGH)) | |||
/** | |||
* @} | |||
*/ | |||
/* End of private macro ------------------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions | |||
* @brief Timer Hall Sensor functions | |||
* @{ | |||
*/ | |||
/* Timer Hall Sensor functions **********************************************/ | |||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef *sConfig); | |||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim); | |||
void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim); | |||
void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim); | |||
/* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim); | |||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim); | |||
/* Non-Blocking mode: Interrupt */ | |||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim); | |||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim); | |||
/* Non-Blocking mode: DMA */ | |||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length); | |||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions | |||
* @brief Timer Complementary Output Compare functions | |||
* @{ | |||
*/ | |||
/* Timer Complementary Output Compare functions *****************************/ | |||
/* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel); | |||
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel); | |||
/* Non-Blocking mode: Interrupt */ | |||
HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel); | |||
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel); | |||
/* Non-Blocking mode: DMA */ | |||
HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length); | |||
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions | |||
* @brief Timer Complementary PWM functions | |||
* @{ | |||
*/ | |||
/* Timer Complementary PWM functions ****************************************/ | |||
/* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel); | |||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel); | |||
/* Non-Blocking mode: Interrupt */ | |||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel); | |||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel); | |||
/* Non-Blocking mode: DMA */ | |||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length); | |||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions | |||
* @brief Timer Complementary One Pulse functions | |||
* @{ | |||
*/ | |||
/* Timer Complementary One Pulse functions **********************************/ | |||
/* Blocking mode: Polling */ | |||
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel); | |||
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel); | |||
/* Non-Blocking mode: Interrupt */ | |||
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel); | |||
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions | |||
* @brief Peripheral Control functions | |||
* @{ | |||
*/ | |||
/* Extended Control functions ************************************************/ | |||
HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger, | |||
uint32_t CommutationSource); | |||
HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger, | |||
uint32_t CommutationSource); | |||
HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger, | |||
uint32_t CommutationSource); | |||
HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim, | |||
TIM_MasterConfigTypeDef *sMasterConfig); | |||
HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim, | |||
TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig); | |||
HAL_StatusTypeDef HAL_TIMEx_ConfigBreakInput(TIM_HandleTypeDef *htim, uint32_t BreakInput, | |||
TIMEx_BreakInputConfigTypeDef *sBreakInputConfig); | |||
HAL_StatusTypeDef HAL_TIMEx_GroupChannel5(TIM_HandleTypeDef *htim, uint32_t Channels); | |||
HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions | |||
* @brief Extended Callbacks functions | |||
* @{ | |||
*/ | |||
/* Extended Callback **********************************************************/ | |||
void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim); | |||
void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim); | |||
void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim); | |||
void HAL_TIMEx_Break2Callback(TIM_HandleTypeDef *htim); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions | |||
* @brief Extended Peripheral State functions | |||
* @{ | |||
*/ | |||
/* Extended Peripheral State functions ***************************************/ | |||
HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* End of exported functions -------------------------------------------------*/ | |||
/* Private functions----------------------------------------------------------*/ | |||
/** @addtogroup TIMEx_Private_Functions TIMEx Private Functions | |||
* @{ | |||
*/ | |||
void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma); | |||
void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma); | |||
/** | |||
* @} | |||
*/ | |||
/* End of private functions --------------------------------------------------*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_TIM_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,761 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_tsc.h | |||
* @author MCD Application Team | |||
* @brief Header file of TSC HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_TSC_H | |||
#define STM32WBxx_HAL_TSC_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup TSC | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup TSC_Exported_Types TSC Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief TSC state structure definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_TSC_STATE_RESET = 0x00UL, /*!< TSC registers have their reset value */ | |||
HAL_TSC_STATE_READY = 0x01UL, /*!< TSC registers are initialized or acquisition is completed with success */ | |||
HAL_TSC_STATE_BUSY = 0x02UL, /*!< TSC initialization or acquisition is on-going */ | |||
HAL_TSC_STATE_ERROR = 0x03UL /*!< Acquisition is completed with max count error */ | |||
} HAL_TSC_StateTypeDef; | |||
/** | |||
* @brief TSC group status structure definition | |||
*/ | |||
typedef enum | |||
{ | |||
TSC_GROUP_ONGOING = 0x00UL, /*!< Acquisition on group is on-going or not started */ | |||
TSC_GROUP_COMPLETED = 0x01UL /*!< Acquisition on group is completed with success (no max count error) */ | |||
} TSC_GroupStatusTypeDef; | |||
/** | |||
* @brief TSC init structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t CTPulseHighLength; /*!< Charge-transfer high pulse length | |||
This parameter can be a value of @ref TSC_CTPulseHL_Config */ | |||
uint32_t CTPulseLowLength; /*!< Charge-transfer low pulse length | |||
This parameter can be a value of @ref TSC_CTPulseLL_Config */ | |||
FunctionalState SpreadSpectrum; /*!< Spread spectrum activation | |||
This parameter can be set to ENABLE or DISABLE. */ | |||
uint32_t SpreadSpectrumDeviation; /*!< Spread spectrum deviation | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 127 */ | |||
uint32_t SpreadSpectrumPrescaler; /*!< Spread spectrum prescaler | |||
This parameter can be a value of @ref TSC_SpreadSpec_Prescaler */ | |||
uint32_t PulseGeneratorPrescaler; /*!< Pulse generator prescaler | |||
This parameter can be a value of @ref TSC_PulseGenerator_Prescaler */ | |||
uint32_t MaxCountValue; /*!< Max count value | |||
This parameter can be a value of @ref TSC_MaxCount_Value */ | |||
uint32_t IODefaultMode; /*!< IO default mode | |||
This parameter can be a value of @ref TSC_IO_Default_Mode */ | |||
uint32_t SynchroPinPolarity; /*!< Synchro pin polarity | |||
This parameter can be a value of @ref TSC_Synchro_Pin_Polarity */ | |||
uint32_t AcquisitionMode; /*!< Acquisition mode | |||
This parameter can be a value of @ref TSC_Acquisition_Mode */ | |||
FunctionalState MaxCountInterrupt;/*!< Max count interrupt activation | |||
This parameter can be set to ENABLE or DISABLE. */ | |||
uint32_t ChannelIOs; /*!< Channel IOs mask */ | |||
uint32_t ShieldIOs; /*!< Shield IOs mask */ | |||
uint32_t SamplingIOs; /*!< Sampling IOs mask */ | |||
} TSC_InitTypeDef; | |||
/** | |||
* @brief TSC IOs configuration structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t ChannelIOs; /*!< Channel IOs mask */ | |||
uint32_t ShieldIOs; /*!< Shield IOs mask */ | |||
uint32_t SamplingIOs; /*!< Sampling IOs mask */ | |||
} TSC_IOConfigTypeDef; | |||
/** | |||
* @brief TSC handle Structure definition | |||
*/ | |||
typedef struct __TSC_HandleTypeDef | |||
{ | |||
TSC_TypeDef *Instance; /*!< Register base address */ | |||
TSC_InitTypeDef Init; /*!< Initialization parameters */ | |||
__IO HAL_TSC_StateTypeDef State; /*!< Peripheral state */ | |||
HAL_LockTypeDef Lock; /*!< Lock feature */ | |||
__IO uint32_t ErrorCode; /*!< I2C Error code */ | |||
#if (USE_HAL_TSC_REGISTER_CALLBACKS == 1) | |||
void (* ConvCpltCallback)(struct __TSC_HandleTypeDef *htsc); /*!< TSC Conversion complete callback */ | |||
void (* ErrorCallback)(struct __TSC_HandleTypeDef *htsc); /*!< TSC Error callback */ | |||
void (* MspInitCallback)(struct __TSC_HandleTypeDef *htsc); /*!< TSC Msp Init callback */ | |||
void (* MspDeInitCallback)(struct __TSC_HandleTypeDef *htsc); /*!< TSC Msp DeInit callback */ | |||
#endif /* USE_HAL_TSC_REGISTER_CALLBACKS */ | |||
} TSC_HandleTypeDef; | |||
enum | |||
{ | |||
TSC_GROUP1_IDX = 0x00UL, | |||
TSC_GROUP2_IDX, | |||
TSC_GROUP3_IDX, | |||
TSC_GROUP4_IDX, | |||
TSC_GROUP5_IDX, | |||
TSC_GROUP6_IDX, | |||
TSC_GROUP7_IDX, | |||
TSC_NB_OF_GROUPS | |||
}; | |||
#if (USE_HAL_TSC_REGISTER_CALLBACKS == 1) | |||
/** | |||
* @brief HAL TSC Callback ID enumeration definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_TSC_CONV_COMPLETE_CB_ID = 0x00UL, /*!< TSC Conversion completed callback ID */ | |||
HAL_TSC_ERROR_CB_ID = 0x01UL, /*!< TSC Error callback ID */ | |||
HAL_TSC_MSPINIT_CB_ID = 0x02UL, /*!< TSC Msp Init callback ID */ | |||
HAL_TSC_MSPDEINIT_CB_ID = 0x03UL /*!< TSC Msp DeInit callback ID */ | |||
} HAL_TSC_CallbackIDTypeDef; | |||
/** | |||
* @brief HAL TSC Callback pointer definition | |||
*/ | |||
typedef void (*pTSC_CallbackTypeDef)(TSC_HandleTypeDef *htsc); /*!< pointer to an TSC callback function */ | |||
#endif /* USE_HAL_TSC_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup TSC_Exported_Constants TSC Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup TSC_Error_Code_definition TSC Error Code definition | |||
* @brief TSC Error Code definition | |||
* @{ | |||
*/ | |||
#define HAL_TSC_ERROR_NONE 0x00000000UL /*!< No error */ | |||
#if (USE_HAL_TSC_REGISTER_CALLBACKS == 1) | |||
#define HAL_TSC_ERROR_INVALID_CALLBACK 0x00000001UL /*!< Invalid Callback error */ | |||
#endif /* USE_HAL_TSC_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TSC_CTPulseHL_Config CTPulse High Length | |||
* @{ | |||
*/ | |||
#define TSC_CTPH_1CYCLE 0x00000000UL /*!< Charge transfer pulse high during 1 cycle (PGCLK) */ | |||
#define TSC_CTPH_2CYCLES TSC_CR_CTPH_0 /*!< Charge transfer pulse high during 2 cycles (PGCLK) */ | |||
#define TSC_CTPH_3CYCLES TSC_CR_CTPH_1 /*!< Charge transfer pulse high during 3 cycles (PGCLK) */ | |||
#define TSC_CTPH_4CYCLES (TSC_CR_CTPH_1 | TSC_CR_CTPH_0) /*!< Charge transfer pulse high during 4 cycles (PGCLK) */ | |||
#define TSC_CTPH_5CYCLES TSC_CR_CTPH_2 /*!< Charge transfer pulse high during 5 cycles (PGCLK) */ | |||
#define TSC_CTPH_6CYCLES (TSC_CR_CTPH_2 | TSC_CR_CTPH_0) /*!< Charge transfer pulse high during 6 cycles (PGCLK) */ | |||
#define TSC_CTPH_7CYCLES (TSC_CR_CTPH_2 | TSC_CR_CTPH_1) /*!< Charge transfer pulse high during 7 cycles (PGCLK) */ | |||
#define TSC_CTPH_8CYCLES (TSC_CR_CTPH_2 | TSC_CR_CTPH_1 | TSC_CR_CTPH_0) /*!< Charge transfer pulse high during 8 cycles (PGCLK) */ | |||
#define TSC_CTPH_9CYCLES TSC_CR_CTPH_3 /*!< Charge transfer pulse high during 9 cycles (PGCLK) */ | |||
#define TSC_CTPH_10CYCLES (TSC_CR_CTPH_3 | TSC_CR_CTPH_0) /*!< Charge transfer pulse high during 10 cycles (PGCLK) */ | |||
#define TSC_CTPH_11CYCLES (TSC_CR_CTPH_3 | TSC_CR_CTPH_1) /*!< Charge transfer pulse high during 11 cycles (PGCLK) */ | |||
#define TSC_CTPH_12CYCLES (TSC_CR_CTPH_3 | TSC_CR_CTPH_1 | TSC_CR_CTPH_0) /*!< Charge transfer pulse high during 12 cycles (PGCLK) */ | |||
#define TSC_CTPH_13CYCLES (TSC_CR_CTPH_3 | TSC_CR_CTPH_2) /*!< Charge transfer pulse high during 13 cycles (PGCLK) */ | |||
#define TSC_CTPH_14CYCLES (TSC_CR_CTPH_3 | TSC_CR_CTPH_2 | TSC_CR_CTPH_0) /*!< Charge transfer pulse high during 14 cycles (PGCLK) */ | |||
#define TSC_CTPH_15CYCLES (TSC_CR_CTPH_3 | TSC_CR_CTPH_2 | TSC_CR_CTPH_1) /*!< Charge transfer pulse high during 15 cycles (PGCLK) */ | |||
#define TSC_CTPH_16CYCLES (TSC_CR_CTPH_3 | TSC_CR_CTPH_2 | TSC_CR_CTPH_1 | TSC_CR_CTPH_0) /*!< Charge transfer pulse high during 16 cycles (PGCLK) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TSC_CTPulseLL_Config CTPulse Low Length | |||
* @{ | |||
*/ | |||
#define TSC_CTPL_1CYCLE 0x00000000UL /*!< Charge transfer pulse low during 1 cycle (PGCLK) */ | |||
#define TSC_CTPL_2CYCLES TSC_CR_CTPL_0 /*!< Charge transfer pulse low during 2 cycles (PGCLK) */ | |||
#define TSC_CTPL_3CYCLES TSC_CR_CTPL_1 /*!< Charge transfer pulse low during 3 cycles (PGCLK) */ | |||
#define TSC_CTPL_4CYCLES (TSC_CR_CTPL_1 | TSC_CR_CTPL_0) /*!< Charge transfer pulse low during 4 cycles (PGCLK) */ | |||
#define TSC_CTPL_5CYCLES TSC_CR_CTPL_2 /*!< Charge transfer pulse low during 5 cycles (PGCLK) */ | |||
#define TSC_CTPL_6CYCLES (TSC_CR_CTPL_2 | TSC_CR_CTPL_0) /*!< Charge transfer pulse low during 6 cycles (PGCLK) */ | |||
#define TSC_CTPL_7CYCLES (TSC_CR_CTPL_2 | TSC_CR_CTPL_1) /*!< Charge transfer pulse low during 7 cycles (PGCLK) */ | |||
#define TSC_CTPL_8CYCLES (TSC_CR_CTPL_2 | TSC_CR_CTPL_1 | TSC_CR_CTPL_0) /*!< Charge transfer pulse low during 8 cycles (PGCLK) */ | |||
#define TSC_CTPL_9CYCLES TSC_CR_CTPL_3 /*!< Charge transfer pulse low during 9 cycles (PGCLK) */ | |||
#define TSC_CTPL_10CYCLES (TSC_CR_CTPL_3 | TSC_CR_CTPL_0) /*!< Charge transfer pulse low during 10 cycles (PGCLK) */ | |||
#define TSC_CTPL_11CYCLES (TSC_CR_CTPL_3 | TSC_CR_CTPL_1) /*!< Charge transfer pulse low during 11 cycles (PGCLK) */ | |||
#define TSC_CTPL_12CYCLES (TSC_CR_CTPL_3 | TSC_CR_CTPL_1 | TSC_CR_CTPL_0) /*!< Charge transfer pulse low during 12 cycles (PGCLK) */ | |||
#define TSC_CTPL_13CYCLES (TSC_CR_CTPL_3 | TSC_CR_CTPL_2) /*!< Charge transfer pulse low during 13 cycles (PGCLK) */ | |||
#define TSC_CTPL_14CYCLES (TSC_CR_CTPL_3 | TSC_CR_CTPL_2 | TSC_CR_CTPL_0) /*!< Charge transfer pulse low during 14 cycles (PGCLK) */ | |||
#define TSC_CTPL_15CYCLES (TSC_CR_CTPL_3 | TSC_CR_CTPL_2 | TSC_CR_CTPL_1) /*!< Charge transfer pulse low during 15 cycles (PGCLK) */ | |||
#define TSC_CTPL_16CYCLES (TSC_CR_CTPL_3 | TSC_CR_CTPL_2 | TSC_CR_CTPL_1 | TSC_CR_CTPL_0) /*!< Charge transfer pulse low during 16 cycles (PGCLK) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TSC_SpreadSpec_Prescaler Spread Spectrum Prescaler | |||
* @{ | |||
*/ | |||
#define TSC_SS_PRESC_DIV1 0x00000000UL /*!< Spread Spectrum Prescaler Div1 */ | |||
#define TSC_SS_PRESC_DIV2 TSC_CR_SSPSC /*!< Spread Spectrum Prescaler Div2 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TSC_PulseGenerator_Prescaler Pulse Generator Prescaler | |||
* @{ | |||
*/ | |||
#define TSC_PG_PRESC_DIV1 0x00000000UL /*!< Pulse Generator HCLK Div1 */ | |||
#define TSC_PG_PRESC_DIV2 TSC_CR_PGPSC_0 /*!< Pulse Generator HCLK Div2 */ | |||
#define TSC_PG_PRESC_DIV4 TSC_CR_PGPSC_1 /*!< Pulse Generator HCLK Div4 */ | |||
#define TSC_PG_PRESC_DIV8 (TSC_CR_PGPSC_1 | TSC_CR_PGPSC_0) /*!< Pulse Generator HCLK Div8 */ | |||
#define TSC_PG_PRESC_DIV16 TSC_CR_PGPSC_2 /*!< Pulse Generator HCLK Div16 */ | |||
#define TSC_PG_PRESC_DIV32 (TSC_CR_PGPSC_2 | TSC_CR_PGPSC_0) /*!< Pulse Generator HCLK Div32 */ | |||
#define TSC_PG_PRESC_DIV64 (TSC_CR_PGPSC_2 | TSC_CR_PGPSC_1) /*!< Pulse Generator HCLK Div64 */ | |||
#define TSC_PG_PRESC_DIV128 (TSC_CR_PGPSC_2 | TSC_CR_PGPSC_1 | TSC_CR_PGPSC_0) /*!< Pulse Generator HCLK Div128 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TSC_MaxCount_Value Max Count Value | |||
* @{ | |||
*/ | |||
#define TSC_MCV_255 0x00000000UL /*!< 255 maximum number of charge transfer pulses */ | |||
#define TSC_MCV_511 TSC_CR_MCV_0 /*!< 511 maximum number of charge transfer pulses */ | |||
#define TSC_MCV_1023 TSC_CR_MCV_1 /*!< 1023 maximum number of charge transfer pulses */ | |||
#define TSC_MCV_2047 (TSC_CR_MCV_1 | TSC_CR_MCV_0) /*!< 2047 maximum number of charge transfer pulses */ | |||
#define TSC_MCV_4095 TSC_CR_MCV_2 /*!< 4095 maximum number of charge transfer pulses */ | |||
#define TSC_MCV_8191 (TSC_CR_MCV_2 | TSC_CR_MCV_0) /*!< 8191 maximum number of charge transfer pulses */ | |||
#define TSC_MCV_16383 (TSC_CR_MCV_2 | TSC_CR_MCV_1) /*!< 16383 maximum number of charge transfer pulses */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TSC_IO_Default_Mode IO Default Mode | |||
* @{ | |||
*/ | |||
#define TSC_IODEF_OUT_PP_LOW 0x00000000UL /*!< I/Os are forced to output push-pull low */ | |||
#define TSC_IODEF_IN_FLOAT TSC_CR_IODEF /*!< I/Os are in input floating */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TSC_Synchro_Pin_Polarity Synchro Pin Polarity | |||
* @{ | |||
*/ | |||
#define TSC_SYNC_POLARITY_FALLING 0x00000000UL /*!< Falling edge only */ | |||
#define TSC_SYNC_POLARITY_RISING TSC_CR_SYNCPOL /*!< Rising edge and high level */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TSC_Acquisition_Mode Acquisition Mode | |||
* @{ | |||
*/ | |||
#define TSC_ACQ_MODE_NORMAL 0x00000000UL /*!< Normal acquisition mode (acquisition starts as soon as START bit is set) */ | |||
#define TSC_ACQ_MODE_SYNCHRO TSC_CR_AM /*!< Synchronized acquisition mode (acquisition starts if START bit is set and when the selected signal is detected on the SYNC input pin) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TSC_interrupts_definition Interrupts definition | |||
* @{ | |||
*/ | |||
#define TSC_IT_EOA TSC_IER_EOAIE /*!< End of acquisition interrupt enable */ | |||
#define TSC_IT_MCE TSC_IER_MCEIE /*!< Max count error interrupt enable */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TSC_flags_definition Flags definition | |||
* @{ | |||
*/ | |||
#define TSC_FLAG_EOA TSC_ISR_EOAF /*!< End of acquisition flag */ | |||
#define TSC_FLAG_MCE TSC_ISR_MCEF /*!< Max count error flag */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup TSC_Group_definition Group definition | |||
* @{ | |||
*/ | |||
#define TSC_GROUP1 (0x1UL << TSC_GROUP1_IDX) | |||
#define TSC_GROUP2 (0x1UL << TSC_GROUP2_IDX) | |||
#define TSC_GROUP3 (0x1UL << TSC_GROUP3_IDX) | |||
#define TSC_GROUP4 (0x1UL << TSC_GROUP4_IDX) | |||
#define TSC_GROUP5 (0x1UL << TSC_GROUP5_IDX) | |||
#define TSC_GROUP6 (0x1UL << TSC_GROUP6_IDX) | |||
#define TSC_GROUP7 (0x1UL << TSC_GROUP7_IDX) | |||
#define TSC_GROUP1_IO1 TSC_IOCCR_G1_IO1 /*!< TSC Group1 IO1 */ | |||
#define TSC_GROUP1_IO2 TSC_IOCCR_G1_IO2 /*!< TSC Group1 IO2 */ | |||
#define TSC_GROUP1_IO3 TSC_IOCCR_G1_IO3 /*!< TSC Group1 IO3 */ | |||
#define TSC_GROUP1_IO4 TSC_IOCCR_G1_IO4 /*!< TSC Group1 IO4 */ | |||
#define TSC_GROUP2_IO1 TSC_IOCCR_G2_IO1 /*!< TSC Group2 IO1 */ | |||
#define TSC_GROUP2_IO2 TSC_IOCCR_G2_IO2 /*!< TSC Group2 IO2 */ | |||
#define TSC_GROUP2_IO3 TSC_IOCCR_G2_IO3 /*!< TSC Group2 IO3 */ | |||
#define TSC_GROUP2_IO4 TSC_IOCCR_G2_IO4 /*!< TSC Group2 IO4 */ | |||
#define TSC_GROUP3_IO1 TSC_IOCCR_G3_IO1 /*!< TSC Group3 IO1 */ | |||
#define TSC_GROUP3_IO2 TSC_IOCCR_G3_IO2 /*!< TSC Group3 IO2 */ | |||
#define TSC_GROUP3_IO3 TSC_IOCCR_G3_IO3 /*!< TSC Group3 IO3 */ | |||
#define TSC_GROUP3_IO4 TSC_IOCCR_G3_IO4 /*!< TSC Group3 IO4 */ | |||
#define TSC_GROUP4_IO1 TSC_IOCCR_G4_IO1 /*!< TSC Group4 IO1 */ | |||
#define TSC_GROUP4_IO2 TSC_IOCCR_G4_IO2 /*!< TSC Group4 IO2 */ | |||
#define TSC_GROUP4_IO3 TSC_IOCCR_G4_IO3 /*!< TSC Group4 IO3 */ | |||
#define TSC_GROUP4_IO4 TSC_IOCCR_G4_IO4 /*!< TSC Group4 IO4 */ | |||
#define TSC_GROUP5_IO1 TSC_IOCCR_G5_IO1 /*!< TSC Group5 IO1 */ | |||
#define TSC_GROUP5_IO2 TSC_IOCCR_G5_IO2 /*!< TSC Group5 IO2 */ | |||
#define TSC_GROUP5_IO3 TSC_IOCCR_G5_IO3 /*!< TSC Group5 IO3 */ | |||
#define TSC_GROUP5_IO4 TSC_IOCCR_G5_IO4 /*!< TSC Group5 IO4 */ | |||
#define TSC_GROUP6_IO1 TSC_IOCCR_G6_IO1 /*!< TSC Group6 IO1 */ | |||
#define TSC_GROUP6_IO2 TSC_IOCCR_G6_IO2 /*!< TSC Group6 IO2 */ | |||
#define TSC_GROUP6_IO3 TSC_IOCCR_G6_IO3 /*!< TSC Group6 IO3 */ | |||
#define TSC_GROUP6_IO4 TSC_IOCCR_G6_IO4 /*!< TSC Group6 IO4 */ | |||
#define TSC_GROUP7_IO1 TSC_IOCCR_G7_IO1 /*!< TSC Group7 IO1 */ | |||
#define TSC_GROUP7_IO2 TSC_IOCCR_G7_IO2 /*!< TSC Group7 IO2 */ | |||
#define TSC_GROUP7_IO3 TSC_IOCCR_G7_IO3 /*!< TSC Group7 IO3 */ | |||
#define TSC_GROUP7_IO4 TSC_IOCCR_G7_IO4 /*!< TSC Group7 IO4 */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup TSC_Exported_Macros TSC Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset TSC handle state. | |||
* @param __HANDLE__ TSC handle | |||
* @retval None | |||
*/ | |||
#if (USE_HAL_TSC_REGISTER_CALLBACKS == 1) | |||
#define __HAL_TSC_RESET_HANDLE_STATE(__HANDLE__) do{ \ | |||
(__HANDLE__)->State = HAL_TSC_STATE_RESET; \ | |||
(__HANDLE__)->MspInitCallback = NULL; \ | |||
(__HANDLE__)->MspDeInitCallback = NULL; \ | |||
} while(0) | |||
#else | |||
#define __HAL_TSC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_TSC_STATE_RESET) | |||
#endif | |||
/** | |||
* @brief Enable the TSC peripheral. | |||
* @param __HANDLE__ TSC handle | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= TSC_CR_TSCE) | |||
/** | |||
* @brief Disable the TSC peripheral. | |||
* @param __HANDLE__ TSC handle | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= (~TSC_CR_TSCE)) | |||
/** | |||
* @brief Start acquisition. | |||
* @param __HANDLE__ TSC handle | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_START_ACQ(__HANDLE__) ((__HANDLE__)->Instance->CR |= TSC_CR_START) | |||
/** | |||
* @brief Stop acquisition. | |||
* @param __HANDLE__ TSC handle | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_STOP_ACQ(__HANDLE__) ((__HANDLE__)->Instance->CR &= (~TSC_CR_START)) | |||
/** | |||
* @brief Set IO default mode to output push-pull low. | |||
* @param __HANDLE__ TSC handle | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_SET_IODEF_OUTPPLOW(__HANDLE__) ((__HANDLE__)->Instance->CR &= (~TSC_CR_IODEF)) | |||
/** | |||
* @brief Set IO default mode to input floating. | |||
* @param __HANDLE__ TSC handle | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_SET_IODEF_INFLOAT(__HANDLE__) ((__HANDLE__)->Instance->CR |= TSC_CR_IODEF) | |||
/** | |||
* @brief Set synchronization polarity to falling edge. | |||
* @param __HANDLE__ TSC handle | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_SET_SYNC_POL_FALL(__HANDLE__) ((__HANDLE__)->Instance->CR &= (~TSC_CR_SYNCPOL)) | |||
/** | |||
* @brief Set synchronization polarity to rising edge and high level. | |||
* @param __HANDLE__ TSC handle | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_SET_SYNC_POL_RISE_HIGH(__HANDLE__) ((__HANDLE__)->Instance->CR |= TSC_CR_SYNCPOL) | |||
/** | |||
* @brief Enable TSC interrupt. | |||
* @param __HANDLE__ TSC handle | |||
* @param __INTERRUPT__ TSC interrupt | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__)) | |||
/** | |||
* @brief Disable TSC interrupt. | |||
* @param __HANDLE__ TSC handle | |||
* @param __INTERRUPT__ TSC interrupt | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__))) | |||
/** @brief Check whether the specified TSC interrupt source is enabled or not. | |||
* @param __HANDLE__ TSC Handle | |||
* @param __INTERRUPT__ TSC interrupt | |||
* @retval SET or RESET | |||
*/ | |||
#define __HAL_TSC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
/** | |||
* @brief Check whether the specified TSC flag is set or not. | |||
* @param __HANDLE__ TSC handle | |||
* @param __FLAG__ TSC flag | |||
* @retval SET or RESET | |||
*/ | |||
#define __HAL_TSC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__)) ? SET : RESET) | |||
/** | |||
* @brief Clear the TSC's pending flag. | |||
* @param __HANDLE__ TSC handle | |||
* @param __FLAG__ TSC flag | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) | |||
/** | |||
* @brief Enable schmitt trigger hysteresis on a group of IOs. | |||
* @param __HANDLE__ TSC handle | |||
* @param __GX_IOY_MASK__ IOs mask | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_ENABLE_HYSTERESIS(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOHCR |= (__GX_IOY_MASK__)) | |||
/** | |||
* @brief Disable schmitt trigger hysteresis on a group of IOs. | |||
* @param __HANDLE__ TSC handle | |||
* @param __GX_IOY_MASK__ IOs mask | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_DISABLE_HYSTERESIS(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOHCR &= (~(__GX_IOY_MASK__))) | |||
/** | |||
* @brief Open analog switch on a group of IOs. | |||
* @param __HANDLE__ TSC handle | |||
* @param __GX_IOY_MASK__ IOs mask | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_OPEN_ANALOG_SWITCH(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOASCR &= (~(__GX_IOY_MASK__))) | |||
/** | |||
* @brief Close analog switch on a group of IOs. | |||
* @param __HANDLE__ TSC handle | |||
* @param __GX_IOY_MASK__ IOs mask | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_CLOSE_ANALOG_SWITCH(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOASCR |= (__GX_IOY_MASK__)) | |||
/** | |||
* @brief Enable a group of IOs in channel mode. | |||
* @param __HANDLE__ TSC handle | |||
* @param __GX_IOY_MASK__ IOs mask | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_ENABLE_CHANNEL(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOCCR |= (__GX_IOY_MASK__)) | |||
/** | |||
* @brief Disable a group of channel IOs. | |||
* @param __HANDLE__ TSC handle | |||
* @param __GX_IOY_MASK__ IOs mask | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_DISABLE_CHANNEL(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOCCR &= (~(__GX_IOY_MASK__))) | |||
/** | |||
* @brief Enable a group of IOs in sampling mode. | |||
* @param __HANDLE__ TSC handle | |||
* @param __GX_IOY_MASK__ IOs mask | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_ENABLE_SAMPLING(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOSCR |= (__GX_IOY_MASK__)) | |||
/** | |||
* @brief Disable a group of sampling IOs. | |||
* @param __HANDLE__ TSC handle | |||
* @param __GX_IOY_MASK__ IOs mask | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_DISABLE_SAMPLING(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOSCR &= (~(__GX_IOY_MASK__))) | |||
/** | |||
* @brief Enable acquisition groups. | |||
* @param __HANDLE__ TSC handle | |||
* @param __GX_MASK__ Groups mask | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_ENABLE_GROUP(__HANDLE__, __GX_MASK__) ((__HANDLE__)->Instance->IOGCSR |= (__GX_MASK__)) | |||
/** | |||
* @brief Disable acquisition groups. | |||
* @param __HANDLE__ TSC handle | |||
* @param __GX_MASK__ Groups mask | |||
* @retval None | |||
*/ | |||
#define __HAL_TSC_DISABLE_GROUP(__HANDLE__, __GX_MASK__) ((__HANDLE__)->Instance->IOGCSR &= (~(__GX_MASK__))) | |||
/** @brief Gets acquisition group status. | |||
* @param __HANDLE__ TSC Handle | |||
* @param __GX_INDEX__ Group index | |||
* @retval SET or RESET | |||
*/ | |||
#define __HAL_TSC_GET_GROUP_STATUS(__HANDLE__, __GX_INDEX__) \ | |||
((((__HANDLE__)->Instance->IOGCSR & (uint32_t)(1UL << (((__GX_INDEX__) & 0xFUL) + 16UL))) == (uint32_t)(1UL << (((__GX_INDEX__) & 0xFUL) + 16UL))) ? TSC_GROUP_COMPLETED : TSC_GROUP_ONGOING) | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup TSC_Private_Macros TSC Private Macros | |||
* @{ | |||
*/ | |||
#define IS_TSC_CTPH(__VALUE__) (((__VALUE__) == TSC_CTPH_1CYCLE) || \ | |||
((__VALUE__) == TSC_CTPH_2CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_3CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_4CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_5CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_6CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_7CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_8CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_9CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_10CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_11CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_12CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_13CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_14CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_15CYCLES) || \ | |||
((__VALUE__) == TSC_CTPH_16CYCLES)) | |||
#define IS_TSC_CTPL(__VALUE__) (((__VALUE__) == TSC_CTPL_1CYCLE) || \ | |||
((__VALUE__) == TSC_CTPL_2CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_3CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_4CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_5CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_6CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_7CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_8CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_9CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_10CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_11CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_12CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_13CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_14CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_15CYCLES) || \ | |||
((__VALUE__) == TSC_CTPL_16CYCLES)) | |||
#define IS_TSC_SS(__VALUE__) (((FunctionalState)(__VALUE__) == DISABLE) || ((FunctionalState)(__VALUE__) == ENABLE)) | |||
#define IS_TSC_SSD(__VALUE__) (((__VALUE__) == 0UL) || (((__VALUE__) > 0UL) && ((__VALUE__) < 128UL))) | |||
#define IS_TSC_SS_PRESC(__VALUE__) (((__VALUE__) == TSC_SS_PRESC_DIV1) || ((__VALUE__) == TSC_SS_PRESC_DIV2)) | |||
#define IS_TSC_PG_PRESC(__VALUE__) (((__VALUE__) == TSC_PG_PRESC_DIV1) || \ | |||
((__VALUE__) == TSC_PG_PRESC_DIV2) || \ | |||
((__VALUE__) == TSC_PG_PRESC_DIV4) || \ | |||
((__VALUE__) == TSC_PG_PRESC_DIV8) || \ | |||
((__VALUE__) == TSC_PG_PRESC_DIV16) || \ | |||
((__VALUE__) == TSC_PG_PRESC_DIV32) || \ | |||
((__VALUE__) == TSC_PG_PRESC_DIV64) || \ | |||
((__VALUE__) == TSC_PG_PRESC_DIV128)) | |||
#define IS_TSC_MCV(__VALUE__) (((__VALUE__) == TSC_MCV_255) || \ | |||
((__VALUE__) == TSC_MCV_511) || \ | |||
((__VALUE__) == TSC_MCV_1023) || \ | |||
((__VALUE__) == TSC_MCV_2047) || \ | |||
((__VALUE__) == TSC_MCV_4095) || \ | |||
((__VALUE__) == TSC_MCV_8191) || \ | |||
((__VALUE__) == TSC_MCV_16383)) | |||
#define IS_TSC_IODEF(__VALUE__) (((__VALUE__) == TSC_IODEF_OUT_PP_LOW) || ((__VALUE__) == TSC_IODEF_IN_FLOAT)) | |||
#define IS_TSC_SYNC_POL(__VALUE__) (((__VALUE__) == TSC_SYNC_POLARITY_FALLING) || ((__VALUE__) == TSC_SYNC_POLARITY_RISING)) | |||
#define IS_TSC_ACQ_MODE(__VALUE__) (((__VALUE__) == TSC_ACQ_MODE_NORMAL) || ((__VALUE__) == TSC_ACQ_MODE_SYNCHRO)) | |||
#define IS_TSC_MCE_IT(__VALUE__) (((FunctionalState)(__VALUE__) == DISABLE) || ((FunctionalState)(__VALUE__) == ENABLE)) | |||
#define IS_TSC_GROUP_INDEX(__VALUE__) (((__VALUE__) == 0UL) || (((__VALUE__) > 0UL) && ((__VALUE__) < (uint32_t)TSC_NB_OF_GROUPS))) | |||
#define IS_TSC_GROUP(__VALUE__) ((((__VALUE__) & TSC_GROUP1_IO1) == TSC_GROUP1_IO1) ||\ | |||
(((__VALUE__) & TSC_GROUP1_IO2) == TSC_GROUP1_IO2) ||\ | |||
(((__VALUE__) & TSC_GROUP1_IO3) == TSC_GROUP1_IO3) ||\ | |||
(((__VALUE__) & TSC_GROUP1_IO4) == TSC_GROUP1_IO4) ||\ | |||
(((__VALUE__) & TSC_GROUP2_IO1) == TSC_GROUP2_IO1) ||\ | |||
(((__VALUE__) & TSC_GROUP2_IO2) == TSC_GROUP2_IO2) ||\ | |||
(((__VALUE__) & TSC_GROUP2_IO3) == TSC_GROUP2_IO3) ||\ | |||
(((__VALUE__) & TSC_GROUP2_IO4) == TSC_GROUP2_IO4) ||\ | |||
(((__VALUE__) & TSC_GROUP3_IO1) == TSC_GROUP3_IO1) ||\ | |||
(((__VALUE__) & TSC_GROUP3_IO2) == TSC_GROUP3_IO2) ||\ | |||
(((__VALUE__) & TSC_GROUP3_IO3) == TSC_GROUP3_IO3) ||\ | |||
(((__VALUE__) & TSC_GROUP3_IO4) == TSC_GROUP3_IO4) ||\ | |||
(((__VALUE__) & TSC_GROUP4_IO1) == TSC_GROUP4_IO1) ||\ | |||
(((__VALUE__) & TSC_GROUP4_IO2) == TSC_GROUP4_IO2) ||\ | |||
(((__VALUE__) & TSC_GROUP4_IO3) == TSC_GROUP4_IO3) ||\ | |||
(((__VALUE__) & TSC_GROUP4_IO4) == TSC_GROUP4_IO4) ||\ | |||
(((__VALUE__) & TSC_GROUP5_IO1) == TSC_GROUP5_IO1) ||\ | |||
(((__VALUE__) & TSC_GROUP5_IO2) == TSC_GROUP5_IO2) ||\ | |||
(((__VALUE__) & TSC_GROUP5_IO3) == TSC_GROUP5_IO3) ||\ | |||
(((__VALUE__) & TSC_GROUP5_IO4) == TSC_GROUP5_IO4) ||\ | |||
(((__VALUE__) & TSC_GROUP6_IO1) == TSC_GROUP6_IO1) ||\ | |||
(((__VALUE__) & TSC_GROUP6_IO2) == TSC_GROUP6_IO2) ||\ | |||
(((__VALUE__) & TSC_GROUP6_IO3) == TSC_GROUP6_IO3) ||\ | |||
(((__VALUE__) & TSC_GROUP6_IO4) == TSC_GROUP6_IO4) ||\ | |||
(((__VALUE__) & TSC_GROUP7_IO1) == TSC_GROUP7_IO1) ||\ | |||
(((__VALUE__) & TSC_GROUP7_IO2) == TSC_GROUP7_IO2) ||\ | |||
(((__VALUE__) & TSC_GROUP7_IO3) == TSC_GROUP7_IO3) ||\ | |||
(((__VALUE__) & TSC_GROUP7_IO4) == TSC_GROUP7_IO4)) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup TSC_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup TSC_Exported_Functions_Group1 Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions *****************************/ | |||
HAL_StatusTypeDef HAL_TSC_Init(TSC_HandleTypeDef *htsc); | |||
HAL_StatusTypeDef HAL_TSC_DeInit(TSC_HandleTypeDef *htsc); | |||
void HAL_TSC_MspInit(TSC_HandleTypeDef *htsc); | |||
void HAL_TSC_MspDeInit(TSC_HandleTypeDef *htsc); | |||
/* Callbacks Register/UnRegister functions ***********************************/ | |||
#if (USE_HAL_TSC_REGISTER_CALLBACKS == 1) | |||
HAL_StatusTypeDef HAL_TSC_RegisterCallback(TSC_HandleTypeDef *htsc, HAL_TSC_CallbackIDTypeDef CallbackID, pTSC_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_TSC_UnRegisterCallback(TSC_HandleTypeDef *htsc, HAL_TSC_CallbackIDTypeDef CallbackID); | |||
#endif /* USE_HAL_TSC_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup TSC_Exported_Functions_Group2 Input and Output operation functions | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
HAL_StatusTypeDef HAL_TSC_Start(TSC_HandleTypeDef *htsc); | |||
HAL_StatusTypeDef HAL_TSC_Start_IT(TSC_HandleTypeDef *htsc); | |||
HAL_StatusTypeDef HAL_TSC_Stop(TSC_HandleTypeDef *htsc); | |||
HAL_StatusTypeDef HAL_TSC_Stop_IT(TSC_HandleTypeDef *htsc); | |||
HAL_StatusTypeDef HAL_TSC_PollForAcquisition(TSC_HandleTypeDef *htsc); | |||
TSC_GroupStatusTypeDef HAL_TSC_GroupGetStatus(TSC_HandleTypeDef *htsc, uint32_t gx_index); | |||
uint32_t HAL_TSC_GroupGetValue(TSC_HandleTypeDef *htsc, uint32_t gx_index); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup TSC_Exported_Functions_Group3 Peripheral Control functions | |||
* @{ | |||
*/ | |||
/* Peripheral Control functions ***********************************************/ | |||
HAL_StatusTypeDef HAL_TSC_IOConfig(TSC_HandleTypeDef *htsc, TSC_IOConfigTypeDef *config); | |||
HAL_StatusTypeDef HAL_TSC_IODischarge(TSC_HandleTypeDef *htsc, FunctionalState choice); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup TSC_Exported_Functions_Group4 Peripheral State and Errors functions | |||
* @{ | |||
*/ | |||
/* Peripheral State and Error functions ***************************************/ | |||
HAL_TSC_StateTypeDef HAL_TSC_GetState(TSC_HandleTypeDef *htsc); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup TSC_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks | |||
* @{ | |||
*/ | |||
/******* TSC IRQHandler and Callbacks used in Interrupt mode */ | |||
void HAL_TSC_IRQHandler(TSC_HandleTypeDef *htsc); | |||
void HAL_TSC_ConvCpltCallback(TSC_HandleTypeDef *htsc); | |||
void HAL_TSC_ErrorCallback(TSC_HandleTypeDef *htsc); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_TSC_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,353 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_uart_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of UART HAL Extended module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_UART_EX_H | |||
#define STM32WBxx_HAL_UART_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup UARTEx | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup UARTEx_Exported_Types UARTEx Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief UART wake up from stop mode parameters | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t WakeUpEvent; /*!< Specifies which event will activate the Wakeup from Stop mode flag (WUF). | |||
This parameter can be a value of @ref UART_WakeUp_from_Stop_Selection. | |||
If set to UART_WAKEUP_ON_ADDRESS, the two other fields below must | |||
be filled up. */ | |||
uint16_t AddressLength; /*!< Specifies whether the address is 4 or 7-bit long. | |||
This parameter can be a value of @ref UARTEx_WakeUp_Address_Length. */ | |||
uint8_t Address; /*!< UART/USART node address (7-bit long max). */ | |||
} UART_WakeUpTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup UARTEx_Exported_Constants UARTEx Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup UARTEx_Word_Length UARTEx Word Length | |||
* @{ | |||
*/ | |||
#define UART_WORDLENGTH_7B USART_CR1_M1 /*!< 7-bit long UART frame */ | |||
#define UART_WORDLENGTH_8B 0x00000000U /*!< 8-bit long UART frame */ | |||
#define UART_WORDLENGTH_9B USART_CR1_M0 /*!< 9-bit long UART frame */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup UARTEx_WakeUp_Address_Length UARTEx WakeUp Address Length | |||
* @{ | |||
*/ | |||
#define UART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit long wake-up address */ | |||
#define UART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit long wake-up address */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup UARTEx_FIFO_mode UARTEx FIFO mode | |||
* @brief UART FIFO mode | |||
* @{ | |||
*/ | |||
#define UART_FIFOMODE_DISABLE 0x00000000U /*!< FIFO mode disable */ | |||
#define UART_FIFOMODE_ENABLE USART_CR1_FIFOEN /*!< FIFO mode enable */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup UARTEx_TXFIFO_threshold_level UARTEx TXFIFO threshold level | |||
* @brief UART TXFIFO threshold level | |||
* @{ | |||
*/ | |||
#define UART_TXFIFO_THRESHOLD_1_8 0x00000000U /*!< TXFIFO reaches 1/8 of its depth */ | |||
#define UART_TXFIFO_THRESHOLD_1_4 USART_CR3_TXFTCFG_0 /*!< TXFIFO reaches 1/4 of its depth */ | |||
#define UART_TXFIFO_THRESHOLD_1_2 USART_CR3_TXFTCFG_1 /*!< TXFIFO reaches 1/2 of its depth */ | |||
#define UART_TXFIFO_THRESHOLD_3_4 (USART_CR3_TXFTCFG_0|USART_CR3_TXFTCFG_1) /*!< TXFIFO reaches 3/4 of its depth */ | |||
#define UART_TXFIFO_THRESHOLD_7_8 USART_CR3_TXFTCFG_2 /*!< TXFIFO reaches 7/8 of its depth */ | |||
#define UART_TXFIFO_THRESHOLD_8_8 (USART_CR3_TXFTCFG_2|USART_CR3_TXFTCFG_0) /*!< TXFIFO becomes empty */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup UARTEx_RXFIFO_threshold_level UARTEx RXFIFO threshold level | |||
* @brief UART RXFIFO threshold level | |||
* @{ | |||
*/ | |||
#define UART_RXFIFO_THRESHOLD_1_8 0x00000000U /*!< RXFIFO FIFO reaches 1/8 of its depth */ | |||
#define UART_RXFIFO_THRESHOLD_1_4 USART_CR3_RXFTCFG_0 /*!< RXFIFO FIFO reaches 1/4 of its depth */ | |||
#define UART_RXFIFO_THRESHOLD_1_2 USART_CR3_RXFTCFG_1 /*!< RXFIFO FIFO reaches 1/2 of its depth */ | |||
#define UART_RXFIFO_THRESHOLD_3_4 (USART_CR3_RXFTCFG_0|USART_CR3_RXFTCFG_1) /*!< RXFIFO FIFO reaches 3/4 of its depth */ | |||
#define UART_RXFIFO_THRESHOLD_7_8 USART_CR3_RXFTCFG_2 /*!< RXFIFO FIFO reaches 7/8 of its depth */ | |||
#define UART_RXFIFO_THRESHOLD_8_8 (USART_CR3_RXFTCFG_2|USART_CR3_RXFTCFG_0) /*!< RXFIFO FIFO becomes full */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup UARTEx_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup UARTEx_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions ****************************/ | |||
HAL_StatusTypeDef HAL_RS485Ex_Init(UART_HandleTypeDef *huart, uint32_t Polarity, uint32_t AssertionTime, uint32_t DeassertionTime); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup UARTEx_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart); | |||
void HAL_UARTEx_RxFifoFullCallback(UART_HandleTypeDef *huart); | |||
void HAL_UARTEx_TxFifoEmptyCallback(UART_HandleTypeDef *huart); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup UARTEx_Exported_Functions_Group3 | |||
* @{ | |||
*/ | |||
/* Peripheral Control functions **********************************************/ | |||
HAL_StatusTypeDef HAL_UARTEx_StopModeWakeUpSourceConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection); | |||
HAL_StatusTypeDef HAL_UARTEx_EnableStopMode(UART_HandleTypeDef *huart); | |||
HAL_StatusTypeDef HAL_UARTEx_DisableStopMode(UART_HandleTypeDef *huart); | |||
HAL_StatusTypeDef HAL_MultiProcessorEx_AddressLength_Set(UART_HandleTypeDef *huart, uint32_t AddressLength); | |||
HAL_StatusTypeDef HAL_UARTEx_EnableFifoMode(UART_HandleTypeDef *huart); | |||
HAL_StatusTypeDef HAL_UARTEx_DisableFifoMode(UART_HandleTypeDef *huart); | |||
HAL_StatusTypeDef HAL_UARTEx_SetTxFifoThreshold(UART_HandleTypeDef *huart, uint32_t Threshold); | |||
HAL_StatusTypeDef HAL_UARTEx_SetRxFifoThreshold(UART_HandleTypeDef *huart, uint32_t Threshold); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup UARTEx_Private_Macros UARTEx Private Macros | |||
* @{ | |||
*/ | |||
/** @brief Report the UART clock source. | |||
* @param __HANDLE__ specifies the UART Handle. | |||
* @param __CLOCKSOURCE__ output variable. | |||
* @retval UART clocking source, written in __CLOCKSOURCE__. | |||
*/ | |||
#define UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ | |||
do { \ | |||
if((__HANDLE__)->Instance == USART1) \ | |||
{ \ | |||
switch(__HAL_RCC_GET_USART1_SOURCE()) \ | |||
{ \ | |||
case RCC_USART1CLKSOURCE_PCLK2: \ | |||
(__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK2; \ | |||
break; \ | |||
case RCC_USART1CLKSOURCE_HSI: \ | |||
(__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \ | |||
break; \ | |||
case RCC_USART1CLKSOURCE_SYSCLK: \ | |||
(__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \ | |||
break; \ | |||
case RCC_USART1CLKSOURCE_LSE: \ | |||
(__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \ | |||
break; \ | |||
default: \ | |||
(__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \ | |||
break; \ | |||
} \ | |||
} \ | |||
else if((__HANDLE__)->Instance == LPUART1) \ | |||
{ \ | |||
switch(__HAL_RCC_GET_LPUART1_SOURCE()) \ | |||
{ \ | |||
case RCC_LPUART1CLKSOURCE_PCLK1: \ | |||
(__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \ | |||
break; \ | |||
case RCC_LPUART1CLKSOURCE_HSI: \ | |||
(__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \ | |||
break; \ | |||
case RCC_LPUART1CLKSOURCE_SYSCLK: \ | |||
(__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \ | |||
break; \ | |||
case RCC_LPUART1CLKSOURCE_LSE: \ | |||
(__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \ | |||
break; \ | |||
default: \ | |||
(__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \ | |||
break; \ | |||
} \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \ | |||
} \ | |||
} while(0U) | |||
/** @brief Report the UART mask to apply to retrieve the received data | |||
* according to the word length and to the parity bits activation. | |||
* @note If PCE = 1, the parity bit is not included in the data extracted | |||
* by the reception API(). | |||
* This masking operation is not carried out in the case of | |||
* DMA transfers. | |||
* @param __HANDLE__ specifies the UART Handle. | |||
* @retval None, the mask to apply to UART RDR register is stored in (__HANDLE__)->Mask field. | |||
*/ | |||
#define UART_MASK_COMPUTATION(__HANDLE__) \ | |||
do { \ | |||
if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_9B) \ | |||
{ \ | |||
if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x01FFU ; \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x00FFU ; \ | |||
} \ | |||
} \ | |||
else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_8B) \ | |||
{ \ | |||
if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x00FFU ; \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x007FU ; \ | |||
} \ | |||
} \ | |||
else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_7B) \ | |||
{ \ | |||
if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x007FU ; \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x003FU ; \ | |||
} \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x0000U; \ | |||
} \ | |||
} while(0U) | |||
/** | |||
* @brief Ensure that UART frame length is valid. | |||
* @param __LENGTH__ UART frame length. | |||
* @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid) | |||
*/ | |||
#define IS_UART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == UART_WORDLENGTH_7B) || \ | |||
((__LENGTH__) == UART_WORDLENGTH_8B) || \ | |||
((__LENGTH__) == UART_WORDLENGTH_9B)) | |||
/** | |||
* @brief Ensure that UART wake-up address length is valid. | |||
* @param __ADDRESS__ UART wake-up address length. | |||
* @retval SET (__ADDRESS__ is valid) or RESET (__ADDRESS__ is invalid) | |||
*/ | |||
#define IS_UART_ADDRESSLENGTH_DETECT(__ADDRESS__) (((__ADDRESS__) == UART_ADDRESS_DETECT_4B) || \ | |||
((__ADDRESS__) == UART_ADDRESS_DETECT_7B)) | |||
/** | |||
* @brief Ensure that UART TXFIFO threshold level is valid. | |||
* @param __THRESHOLD__ UART TXFIFO threshold level. | |||
* @retval SET (__THRESHOLD__ is valid) or RESET (__THRESHOLD__ is invalid) | |||
*/ | |||
#define IS_UART_TXFIFO_THRESHOLD(__THRESHOLD__) (((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_1_8) || \ | |||
((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_1_4) || \ | |||
((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_1_2) || \ | |||
((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_3_4) || \ | |||
((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_7_8) || \ | |||
((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_8_8)) | |||
/** | |||
* @brief Ensure that UART RXFIFO threshold level is valid. | |||
* @param __THRESHOLD__ UART RXFIFO threshold level. | |||
* @retval SET (__THRESHOLD__ is valid) or RESET (__THRESHOLD__ is invalid) | |||
*/ | |||
#define IS_UART_RXFIFO_THRESHOLD(__THRESHOLD__) (((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_1_8) || \ | |||
((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_1_4) || \ | |||
((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_1_2) || \ | |||
((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_3_4) || \ | |||
((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_7_8) || \ | |||
((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_8_8)) | |||
/** | |||
* @} | |||
*/ | |||
/* Private functions ---------------------------------------------------------*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_UART_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,932 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_usart.h | |||
* @author MCD Application Team | |||
* @brief Header file of USART HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_USART_H | |||
#define STM32WBxx_HAL_USART_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup USART | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup USART_Exported_Types USART Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief USART Init Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t BaudRate; /*!< This member configures the Usart communication baud rate. | |||
The baud rate is computed using the following formula: | |||
Baud Rate Register[15:4] = ((2 * fclk_pres) / ((huart->Init.BaudRate)))[15:4] | |||
Baud Rate Register[3] = 0 | |||
Baud Rate Register[2:0] = (((2 * fclk_pres) / ((huart->Init.BaudRate)))[3:0]) >> 1 | |||
where fclk_pres is the USART input clock frequency (fclk) divided by a prescaler. | |||
@note Oversampling by 8 is systematically applied to achieve high baud rates. */ | |||
uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. | |||
This parameter can be a value of @ref USARTEx_Word_Length. */ | |||
uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. | |||
This parameter can be a value of @ref USART_Stop_Bits. */ | |||
uint32_t Parity; /*!< Specifies the parity mode. | |||
This parameter can be a value of @ref USART_Parity | |||
@note When parity is enabled, the computed parity is inserted | |||
at the MSB position of the transmitted data (9th bit when | |||
the word length is set to 9 data bits; 8th bit when the | |||
word length is set to 8 data bits). */ | |||
uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled. | |||
This parameter can be a value of @ref USART_Mode. */ | |||
uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock. | |||
This parameter can be a value of @ref USART_Clock_Polarity. */ | |||
uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made. | |||
This parameter can be a value of @ref USART_Clock_Phase. */ | |||
uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted | |||
data bit (MSB) has to be output on the SCLK pin in synchronous mode. | |||
This parameter can be a value of @ref USART_Last_Bit. */ | |||
uint32_t ClockPrescaler; /*!< Specifies the prescaler value used to divide the USART clock source. | |||
This parameter can be a value of @ref USART_ClockPrescaler. */ | |||
} USART_InitTypeDef; | |||
/** | |||
* @brief HAL USART State structures definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_USART_STATE_RESET = 0x00U, /*!< Peripheral is not initialized */ | |||
HAL_USART_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */ | |||
HAL_USART_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */ | |||
HAL_USART_STATE_BUSY_TX = 0x12U, /*!< Data Transmission process is ongoing */ | |||
HAL_USART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */ | |||
HAL_USART_STATE_BUSY_TX_RX = 0x32U, /*!< Data Transmission Reception process is ongoing */ | |||
HAL_USART_STATE_TIMEOUT = 0x03U, /*!< Timeout state */ | |||
HAL_USART_STATE_ERROR = 0x04U /*!< Error */ | |||
} HAL_USART_StateTypeDef; | |||
/** | |||
* @brief USART clock sources definitions | |||
*/ | |||
typedef enum | |||
{ | |||
USART_CLOCKSOURCE_PCLK2 = 0x01U, /*!< PCLK2 clock source */ | |||
USART_CLOCKSOURCE_HSI = 0x02U, /*!< HSI clock source */ | |||
USART_CLOCKSOURCE_SYSCLK = 0x04U, /*!< SYSCLK clock source */ | |||
USART_CLOCKSOURCE_LSE = 0x08U, /*!< LSE clock source */ | |||
USART_CLOCKSOURCE_UNDEFINED = 0x10U /*!< Undefined clock source */ | |||
} USART_ClockSourceTypeDef; | |||
/** | |||
* @brief USART handle Structure definition | |||
*/ | |||
typedef struct __USART_HandleTypeDef | |||
{ | |||
USART_TypeDef *Instance; /*!< USART registers base address */ | |||
USART_InitTypeDef Init; /*!< USART communication parameters */ | |||
uint8_t *pTxBuffPtr; /*!< Pointer to USART Tx transfer Buffer */ | |||
uint16_t TxXferSize; /*!< USART Tx Transfer size */ | |||
__IO uint16_t TxXferCount; /*!< USART Tx Transfer Counter */ | |||
uint8_t *pRxBuffPtr; /*!< Pointer to USART Rx transfer Buffer */ | |||
uint16_t RxXferSize; /*!< USART Rx Transfer size */ | |||
__IO uint16_t RxXferCount; /*!< USART Rx Transfer Counter */ | |||
uint16_t Mask; /*!< USART Rx RDR register mask */ | |||
uint16_t NbRxDataToProcess; /*!< Number of data to process during RX ISR execution */ | |||
uint16_t NbTxDataToProcess; /*!< Number of data to process during TX ISR execution */ | |||
uint32_t SlaveMode; /*!< Enable/Disable UART SPI Slave Mode. This parameter can be a value | |||
of @ref USARTEx_Slave_Mode */ | |||
uint32_t FifoMode; /*!< Specifies if the FIFO mode will be used. This parameter can be a value | |||
of @ref USARTEx_FIFO_mode. */ | |||
void (*RxISR)(struct __USART_HandleTypeDef *husart); /*!< Function pointer on Rx IRQ handler */ | |||
void (*TxISR)(struct __USART_HandleTypeDef *husart); /*!< Function pointer on Tx IRQ handler */ | |||
DMA_HandleTypeDef *hdmatx; /*!< USART Tx DMA Handle parameters */ | |||
DMA_HandleTypeDef *hdmarx; /*!< USART Rx DMA Handle parameters */ | |||
HAL_LockTypeDef Lock; /*!< Locking object */ | |||
__IO HAL_USART_StateTypeDef State; /*!< USART communication state */ | |||
__IO uint32_t ErrorCode; /*!< USART Error code */ | |||
#if (USE_HAL_USART_REGISTER_CALLBACKS == 1) | |||
void (* TxHalfCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Tx Half Complete Callback */ | |||
void (* TxCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Tx Complete Callback */ | |||
void (* RxHalfCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Rx Half Complete Callback */ | |||
void (* RxCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Rx Complete Callback */ | |||
void (* TxRxCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Tx Rx Complete Callback */ | |||
void (* ErrorCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Error Callback */ | |||
void (* AbortCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Abort Complete Callback */ | |||
void (* RxFifoFullCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Rx Fifo Full Callback */ | |||
void (* TxFifoEmptyCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Tx Fifo Empty Callback */ | |||
void (* MspInitCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Msp Init callback */ | |||
void (* MspDeInitCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Msp DeInit callback */ | |||
#endif /* USE_HAL_USART_REGISTER_CALLBACKS */ | |||
} USART_HandleTypeDef; | |||
#if (USE_HAL_USART_REGISTER_CALLBACKS == 1) | |||
/** | |||
* @brief HAL USART Callback ID enumeration definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_USART_TX_HALFCOMPLETE_CB_ID = 0x00U, /*!< USART Tx Half Complete Callback ID */ | |||
HAL_USART_TX_COMPLETE_CB_ID = 0x01U, /*!< USART Tx Complete Callback ID */ | |||
HAL_USART_RX_HALFCOMPLETE_CB_ID = 0x02U, /*!< USART Rx Half Complete Callback ID */ | |||
HAL_USART_RX_COMPLETE_CB_ID = 0x03U, /*!< USART Rx Complete Callback ID */ | |||
HAL_USART_TX_RX_COMPLETE_CB_ID = 0x04U, /*!< USART Tx Rx Complete Callback ID */ | |||
HAL_USART_ERROR_CB_ID = 0x05U, /*!< USART Error Callback ID */ | |||
HAL_USART_ABORT_COMPLETE_CB_ID = 0x06U, /*!< USART Abort Complete Callback ID */ | |||
HAL_USART_RX_FIFO_FULL_CB_ID = 0x07U, /*!< USART Rx Fifo Full Callback ID */ | |||
HAL_USART_TX_FIFO_EMPTY_CB_ID = 0x08U, /*!< USART Tx Fifo Empty Callback ID */ | |||
HAL_USART_MSPINIT_CB_ID = 0x09U, /*!< USART MspInit callback ID */ | |||
HAL_USART_MSPDEINIT_CB_ID = 0x0AU /*!< USART MspDeInit callback ID */ | |||
} HAL_USART_CallbackIDTypeDef; | |||
/** | |||
* @brief HAL USART Callback pointer definition | |||
*/ | |||
typedef void (*pUSART_CallbackTypeDef)(USART_HandleTypeDef *husart); /*!< pointer to an USART callback function */ | |||
#endif /* USE_HAL_USART_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup USART_Exported_Constants USART Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup USART_Error_Definition USART Error Definition | |||
* @{ | |||
*/ | |||
#define HAL_USART_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */ | |||
#define HAL_USART_ERROR_PE ((uint32_t)0x00000001U) /*!< Parity error */ | |||
#define HAL_USART_ERROR_NE ((uint32_t)0x00000002U) /*!< Noise error */ | |||
#define HAL_USART_ERROR_FE ((uint32_t)0x00000004U) /*!< frame error */ | |||
#define HAL_USART_ERROR_ORE ((uint32_t)0x00000008U) /*!< Overrun error */ | |||
#define HAL_USART_ERROR_DMA ((uint32_t)0x00000010U) /*!< DMA transfer error */ | |||
#define HAL_USART_ERROR_UDR ((uint32_t)0x00000020U) /*!< SPI slave underrun error */ | |||
#if (USE_HAL_USART_REGISTER_CALLBACKS == 1) | |||
#define HAL_USART_ERROR_INVALID_CALLBACK ((uint32_t)0x00000040U) /*!< Invalid Callback error */ | |||
#endif /* USE_HAL_USART_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_Stop_Bits USART Number of Stop Bits | |||
* @{ | |||
*/ | |||
#define USART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< USART frame with 0.5 stop bit */ | |||
#define USART_STOPBITS_1 0x00000000U /*!< USART frame with 1 stop bit */ | |||
#define USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< USART frame with 1.5 stop bits */ | |||
#define USART_STOPBITS_2 USART_CR2_STOP_1 /*!< USART frame with 2 stop bits */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_Parity USART Parity | |||
* @{ | |||
*/ | |||
#define USART_PARITY_NONE 0x00000000U /*!< No parity */ | |||
#define USART_PARITY_EVEN USART_CR1_PCE /*!< Even parity */ | |||
#define USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Odd parity */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_Mode USART Mode | |||
* @{ | |||
*/ | |||
#define USART_MODE_RX USART_CR1_RE /*!< RX mode */ | |||
#define USART_MODE_TX USART_CR1_TE /*!< TX mode */ | |||
#define USART_MODE_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< RX and TX mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_Over_Sampling USART Over Sampling | |||
* @{ | |||
*/ | |||
#define USART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */ | |||
#define USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_Clock USART Clock | |||
* @{ | |||
*/ | |||
#define USART_CLOCK_DISABLE 0x00000000U /*!< USART clock disable */ | |||
#define USART_CLOCK_ENABLE USART_CR2_CLKEN /*!< USART clock enable */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_Clock_Polarity USART Clock Polarity | |||
* @{ | |||
*/ | |||
#define USART_POLARITY_LOW 0x00000000U /*!< Driver enable signal is active high */ | |||
#define USART_POLARITY_HIGH USART_CR2_CPOL /*!< Driver enable signal is active low */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_Clock_Phase USART Clock Phase | |||
* @{ | |||
*/ | |||
#define USART_PHASE_1EDGE 0x00000000U /*!< USART frame phase on first clock transition */ | |||
#define USART_PHASE_2EDGE USART_CR2_CPHA /*!< USART frame phase on second clock transition */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_Last_Bit USART Last Bit | |||
* @{ | |||
*/ | |||
#define USART_LASTBIT_DISABLE 0x00000000U /*!< USART frame last data bit clock pulse not output to SCLK pin */ | |||
#define USART_LASTBIT_ENABLE USART_CR2_LBCL /*!< USART frame last data bit clock pulse output to SCLK pin */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_ClockPrescaler USART Clock Prescaler | |||
* @{ | |||
*/ | |||
#define USART_PRESCALER_DIV1 0x00000000U /*!< fclk_pres = fclk */ | |||
#define USART_PRESCALER_DIV2 0x00000001U /*!< fclk_pres = fclk/2 */ | |||
#define USART_PRESCALER_DIV4 0x00000002U /*!< fclk_pres = fclk/4 */ | |||
#define USART_PRESCALER_DIV6 0x00000003U /*!< fclk_pres = fclk/6 */ | |||
#define USART_PRESCALER_DIV8 0x00000004U /*!< fclk_pres = fclk/8 */ | |||
#define USART_PRESCALER_DIV10 0x00000005U /*!< fclk_pres = fclk/10 */ | |||
#define USART_PRESCALER_DIV12 0x00000006U /*!< fclk_pres = fclk/12 */ | |||
#define USART_PRESCALER_DIV16 0x00000007U /*!< fclk_pres = fclk/16 */ | |||
#define USART_PRESCALER_DIV32 0x00000008U /*!< fclk_pres = fclk/32 */ | |||
#define USART_PRESCALER_DIV64 0x00000009U /*!< fclk_pres = fclk/64 */ | |||
#define USART_PRESCALER_DIV128 0x0000000AU /*!< fclk_pres = fclk/128 */ | |||
#define USART_PRESCALER_DIV256 0x0000000BU /*!< fclk_pres = fclk/256 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_Request_Parameters USART Request Parameters | |||
* @{ | |||
*/ | |||
#define USART_RXDATA_FLUSH_REQUEST USART_RQR_RXFRQ /*!< Receive Data flush Request */ | |||
#define USART_TXDATA_FLUSH_REQUEST USART_RQR_TXFRQ /*!< Transmit data flush Request */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_Flags USART Flags | |||
* Elements values convention: 0xXXXX | |||
* - 0xXXXX : Flag mask in the ISR register | |||
* @{ | |||
*/ | |||
#define USART_FLAG_TXFT USART_ISR_TXFT /*!< USART TXFIFO threshold flag */ | |||
#define USART_FLAG_RXFT USART_ISR_RXFT /*!< USART RXFIFO threshold flag */ | |||
#define USART_FLAG_RXFF USART_ISR_RXFF /*!< USART RXFIFO Full flag */ | |||
#define USART_FLAG_TXFE USART_ISR_TXFE /*!< USART TXFIFO Empty flag */ | |||
#define USART_FLAG_REACK USART_ISR_REACK /*!< USART receive enable acknowledge flag */ | |||
#define USART_FLAG_TEACK USART_ISR_TEACK /*!< USART transmit enable acknowledge flag */ | |||
#define USART_FLAG_BUSY USART_ISR_BUSY /*!< USART busy flag */ | |||
#define USART_FLAG_UDR USART_ISR_UDR /*!< SPI slave underrun error flag */ | |||
#define USART_FLAG_TXE USART_ISR_TXE_TXFNF /*!< USART transmit data register empty */ | |||
#define USART_FLAG_TXFNF USART_ISR_TXE_TXFNF /*!< USART TXFIFO not full */ | |||
#define USART_FLAG_TC USART_ISR_TC /*!< USART transmission complete */ | |||
#define USART_FLAG_RXNE USART_ISR_RXNE_RXFNE /*!< USART read data register not empty */ | |||
#define USART_FLAG_RXFNE USART_ISR_RXNE_RXFNE /*!< USART RXFIFO not empty */ | |||
#define USART_FLAG_IDLE USART_ISR_IDLE /*!< USART idle flag */ | |||
#define USART_FLAG_ORE USART_ISR_ORE /*!< USART overrun error */ | |||
#define USART_FLAG_NE USART_ISR_NE /*!< USART noise error */ | |||
#define USART_FLAG_FE USART_ISR_FE /*!< USART frame error */ | |||
#define USART_FLAG_PE USART_ISR_PE /*!< USART parity error */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_Interrupt_definition USART Interrupts Definition | |||
* Elements values convention: 0000ZZZZ0XXYYYYYb | |||
* - YYYYY : Interrupt source position in the XX register (5bits) | |||
* - XX : Interrupt source register (2bits) | |||
* - 01: CR1 register | |||
* - 10: CR2 register | |||
* - 11: CR3 register | |||
* - ZZZZ : Flag position in the ISR register(4bits) | |||
* @{ | |||
*/ | |||
#define USART_IT_PE 0x0028U /*!< USART parity error interruption */ | |||
#define USART_IT_TXE 0x0727U /*!< USART transmit data register empty interruption */ | |||
#define USART_IT_TXFNF 0x0727U /*!< USART TX FIFO not full interruption */ | |||
#define USART_IT_TC 0x0626U /*!< USART transmission complete interruption */ | |||
#define USART_IT_RXNE 0x0525U /*!< USART read data register not empty interruption */ | |||
#define USART_IT_RXFNE 0x0525U /*!< USART RXFIFO not empty interruption */ | |||
#define USART_IT_IDLE 0x0424U /*!< USART idle interruption */ | |||
#define USART_IT_ERR 0x0060U /*!< USART error interruption */ | |||
#define USART_IT_ORE 0x0300U /*!< USART overrun error interruption */ | |||
#define USART_IT_NE 0x0200U /*!< USART noise error interruption */ | |||
#define USART_IT_FE 0x0100U /*!< USART frame error interruption */ | |||
#define USART_IT_RXFF 0x183FU /*!< USART RXFIFO full interruption */ | |||
#define USART_IT_TXFE 0x173EU /*!< USART TXFIFO empty interruption */ | |||
#define USART_IT_RXFT 0x1A7CU /*!< USART RXFIFO threshold reached interruption */ | |||
#define USART_IT_TXFT 0x1B77U /*!< USART TXFIFO threshold reached interruption */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_IT_CLEAR_Flags USART Interruption Clear Flags | |||
* @{ | |||
*/ | |||
#define USART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */ | |||
#define USART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */ | |||
#define USART_CLEAR_NEF USART_ICR_NECF /*!< Noise Error detected Clear Flag */ | |||
#define USART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */ | |||
#define USART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */ | |||
#define USART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */ | |||
#define USART_CLEAR_UDRF USART_ICR_UDRCF /*!< SPI slave underrun error Clear Flag */ | |||
#define USART_CLEAR_TXFECF USART_ICR_TXFECF /*!< TXFIFO Empty Clear Flag */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USART_Interruption_Mask USART Interruption Flags Mask | |||
* @{ | |||
*/ | |||
#define USART_IT_MASK 0x001FU /*!< USART interruptions flags mask */ | |||
#define USART_CR_MASK 0x00E0U /*!< USART control register mask */ | |||
#define USART_CR_POS 5U /*!< USART control register position */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros -----------------------------------------------------------*/ | |||
/** @defgroup USART_Exported_Macros USART Exported Macros | |||
* @{ | |||
*/ | |||
/** @brief Reset USART handle state. | |||
* @param __HANDLE__ USART handle. | |||
* @retval None | |||
*/ | |||
#if (USE_HAL_USART_REGISTER_CALLBACKS == 1) | |||
#define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) do{ \ | |||
(__HANDLE__)->State = HAL_USART_STATE_RESET; \ | |||
(__HANDLE__)->MspInitCallback = NULL; \ | |||
(__HANDLE__)->MspDeInitCallback = NULL; \ | |||
} while(0U) | |||
#else | |||
#define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET) | |||
#endif /* USE_HAL_USART_REGISTER_CALLBACKS */ | |||
/** @brief Check whether the specified USART flag is set or not. | |||
* @param __HANDLE__ specifies the USART Handle | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref USART_FLAG_TXFT TXFIFO threshold flag | |||
* @arg @ref USART_FLAG_RXFT RXFIFO threshold flag | |||
* @arg @ref USART_FLAG_RXFF RXFIFO Full flag | |||
* @arg @ref USART_FLAG_TXFE TXFIFO Empty flag | |||
* @arg @ref USART_FLAG_REACK Receive enable acknowledge flag | |||
* @arg @ref USART_FLAG_TEACK Transmit enable acknowledge flag | |||
* @arg @ref USART_FLAG_BUSY Busy flag | |||
* @arg @ref USART_FLAG_UDR SPI slave underrun error flag | |||
* @arg @ref USART_FLAG_TXE Transmit data register empty flag | |||
* @arg @ref USART_FLAG_TXFNF TXFIFO not full flag | |||
* @arg @ref USART_FLAG_TC Transmission Complete flag | |||
* @arg @ref USART_FLAG_RXNE Receive data register not empty flag | |||
* @arg @ref USART_FLAG_RXFNE RXFIFO not empty flag | |||
* @arg @ref USART_FLAG_IDLE Idle Line detection flag | |||
* @arg @ref USART_FLAG_ORE OverRun Error flag | |||
* @arg @ref USART_FLAG_NE Noise Error flag | |||
* @arg @ref USART_FLAG_FE Framing Error flag | |||
* @arg @ref USART_FLAG_PE Parity Error flag | |||
* @retval The new state of __FLAG__ (TRUE or FALSE). | |||
*/ | |||
#define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__)) | |||
/** @brief Clear the specified USART pending flag. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be any combination of the following values: | |||
* @arg @ref USART_CLEAR_PEF Parity Error Clear Flag | |||
* @arg @ref USART_CLEAR_FEF Framing Error Clear Flag | |||
* @arg @ref USART_CLEAR_NEF Noise detected Clear Flag | |||
* @arg @ref USART_CLEAR_OREF Overrun Error Clear Flag | |||
* @arg @ref USART_CLEAR_IDLEF IDLE line detected Clear Flag | |||
* @arg @ref USART_CLEAR_TXFECF TXFIFO empty clear Flag | |||
* @arg @ref USART_CLEAR_TCF Transmission Complete Clear Flag | |||
* @arg @ref USART_CLEAR_UDRF SPI slave underrun error Clear Flag | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) | |||
/** @brief Clear the USART PE pending flag. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_CLEAR_PEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_PEF) | |||
/** @brief Clear the USART FE pending flag. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_CLEAR_FEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_FEF) | |||
/** @brief Clear the USART NE pending flag. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_CLEAR_NEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_NEF) | |||
/** @brief Clear the USART ORE pending flag. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_CLEAR_OREFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_OREF) | |||
/** @brief Clear the USART IDLE pending flag. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_IDLEF) | |||
/** @brief Clear the USART TX FIFO empty clear flag. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_CLEAR_TXFECF(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_TXFECF) | |||
/** @brief Clear SPI slave underrun error flag. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_CLEAR_UDRFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_UDRF) | |||
/** @brief Enable the specified USART interrupt. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @param __INTERRUPT__ specifies the USART interrupt source to enable. | |||
* This parameter can be one of the following values: | |||
* @arg @ref USART_IT_RXFF RXFIFO Full interrupt | |||
* @arg @ref USART_IT_TXFE TXFIFO Empty interrupt | |||
* @arg @ref USART_IT_RXFT RXFIFO threshold interrupt | |||
* @arg @ref USART_IT_TXFT TXFIFO threshold interrupt | |||
* @arg @ref USART_IT_TXE Transmit Data Register empty interrupt | |||
* @arg @ref USART_IT_TXFNF TX FIFO not full interrupt | |||
* @arg @ref USART_IT_TC Transmission complete interrupt | |||
* @arg @ref USART_IT_RXNE Receive Data register not empty interrupt | |||
* @arg @ref USART_IT_RXFNE RXFIFO not empty interrupt | |||
* @arg @ref USART_IT_IDLE Idle line detection interrupt | |||
* @arg @ref USART_IT_PE Parity Error interrupt | |||
* @arg @ref USART_IT_ERR Error interrupt(Frame error, noise error, overrun error) | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & USART_CR_MASK) >> USART_CR_POS) == 1U)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__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)))) | |||
/** @brief Disable the specified USART interrupt. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @param __INTERRUPT__ specifies the USART interrupt source to disable. | |||
* This parameter can be one of the following values: | |||
* @arg @ref USART_IT_RXFF RXFIFO Full interrupt | |||
* @arg @ref USART_IT_TXFE TXFIFO Empty interrupt | |||
* @arg @ref USART_IT_RXFT RXFIFO threshold interrupt | |||
* @arg @ref USART_IT_TXFT TXFIFO threshold interrupt | |||
* @arg @ref USART_IT_TXE Transmit Data Register empty interrupt | |||
* @arg @ref USART_IT_TXFNF TX FIFO not full interrupt | |||
* @arg @ref USART_IT_TC Transmission complete interrupt | |||
* @arg @ref USART_IT_RXNE Receive Data register not empty interrupt | |||
* @arg @ref USART_IT_RXFNE RXFIFO not empty interrupt | |||
* @arg @ref USART_IT_IDLE Idle line detection interrupt | |||
* @arg @ref USART_IT_PE Parity Error interrupt | |||
* @arg @ref USART_IT_ERR Error interrupt(Frame error, noise error, overrun error) | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & USART_CR_MASK) >> USART_CR_POS) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__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)))) | |||
/** @brief Check whether the specified USART interrupt has occurred or not. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @param __INTERRUPT__ specifies the USART interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref USART_IT_RXFF RXFIFO Full interrupt | |||
* @arg @ref USART_IT_TXFE TXFIFO Empty interrupt | |||
* @arg @ref USART_IT_RXFT RXFIFO threshold interrupt | |||
* @arg @ref USART_IT_TXFT TXFIFO threshold interrupt | |||
* @arg @ref USART_IT_TXE Transmit Data Register empty interrupt | |||
* @arg @ref USART_IT_TXFNF TX FIFO not full interrupt | |||
* @arg @ref USART_IT_TC Transmission complete interrupt | |||
* @arg @ref USART_IT_RXNE Receive Data register not empty interrupt | |||
* @arg @ref USART_IT_RXFNE RXFIFO not empty interrupt | |||
* @arg @ref USART_IT_IDLE Idle line detection interrupt | |||
* @arg @ref USART_IT_ORE OverRun Error interrupt | |||
* @arg @ref USART_IT_NE Noise Error interrupt | |||
* @arg @ref USART_IT_FE Framing Error interrupt | |||
* @arg @ref USART_IT_PE Parity Error interrupt | |||
* @retval The new state of __INTERRUPT__ (SET or RESET). | |||
*/ | |||
#define __HAL_USART_GET_IT(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__INTERRUPT__)>> 0x08))) != RESET) ? SET : RESET) | |||
/** @brief Check whether the specified USART interrupt source is enabled or not. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @param __INTERRUPT__ specifies the USART interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg @ref USART_IT_RXFF RXFIFO Full interrupt | |||
* @arg @ref USART_IT_TXFE TXFIFO Empty interrupt | |||
* @arg @ref USART_IT_RXFT RXFIFO threshold interrupt | |||
* @arg @ref USART_IT_TXFT TXFIFO threshold interrupt | |||
* @arg @ref USART_IT_TXE Transmit Data Register empty interrupt | |||
* @arg @ref USART_IT_TXFNF TX FIFO not full interrupt | |||
* @arg @ref USART_IT_TC Transmission complete interrupt | |||
* @arg @ref USART_IT_RXNE Receive Data register not empty interrupt | |||
* @arg @ref USART_IT_RXFNE RXFIFO not empty interrupt | |||
* @arg @ref USART_IT_IDLE Idle line detection interrupt | |||
* @arg @ref USART_IT_ORE OverRun Error interrupt | |||
* @arg @ref USART_IT_NE Noise Error interrupt | |||
* @arg @ref USART_IT_FE Framing Error interrupt | |||
* @arg @ref USART_IT_PE Parity Error interrupt | |||
* @retval The new state of __INTERRUPT__ (SET or RESET). | |||
*/ | |||
#define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((((uint8_t)(__INTERRUPT__)) >> 0x05U) == 0x01U) ? (__HANDLE__)->Instance->CR1 : \ | |||
(((((uint8_t)(__INTERRUPT__)) >> 0x05U) == 0x02U) ? (__HANDLE__)->Instance->CR2 : \ | |||
(__HANDLE__)->Instance->CR3)) & (0x01U << (((uint16_t)(__INTERRUPT__)) & USART_IT_MASK))) != RESET) ? SET : RESET) | |||
/** @brief Clear the specified USART ISR flag, in setting the proper ICR register flag. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @param __IT_CLEAR__ specifies the interrupt clear register flag that needs to be set | |||
* to clear the corresponding interrupt. | |||
* This parameter can be one of the following values: | |||
* @arg @ref USART_CLEAR_PEF Parity Error Clear Flag | |||
* @arg @ref USART_CLEAR_FEF Framing Error Clear Flag | |||
* @arg @ref USART_CLEAR_NEF Noise detected Clear Flag | |||
* @arg @ref USART_CLEAR_OREF Overrun Error Clear Flag | |||
* @arg @ref USART_CLEAR_IDLEF IDLE line detected Clear Flag | |||
* @arg @ref USART_CLEAR_TXFECF TXFIFO empty clear Flag | |||
* @arg @ref USART_CLEAR_TCF Transmission Complete Clear Flag | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__)) | |||
/** @brief Set a specific USART request flag. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @param __REQ__ specifies the request flag to set. | |||
* This parameter can be one of the following values: | |||
* @arg @ref USART_RXDATA_FLUSH_REQUEST Receive Data flush Request | |||
* @arg @ref USART_TXDATA_FLUSH_REQUEST Transmit data flush Request | |||
* | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (__REQ__)) | |||
/** @brief Enable the USART one bit sample method. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT) | |||
/** @brief Disable the USART one bit sample method. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= ~USART_CR3_ONEBIT) | |||
/** @brief Enable USART. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) | |||
/** @brief Disable USART. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @retval None | |||
*/ | |||
#define __HAL_USART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros --------------------------------------------------------*/ | |||
/** @defgroup USART_Private_Macros USART Private Macros | |||
* @{ | |||
*/ | |||
/** @brief Get USART clock division factor from clock prescaler value. | |||
* @param __CLOCKPRESCALER__ USART prescaler value. | |||
* @retval USART clock division factor | |||
*/ | |||
#define USART_GET_DIV_FACTOR(__CLOCKPRESCALER__) \ | |||
(((__CLOCKPRESCALER__) == USART_PRESCALER_DIV1) ? 1U : \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV2) ? 2U : \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV4) ? 4U : \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV6) ? 6U : \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV8) ? 8U : \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV10) ? 10U : \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV12) ? 12U : \ | |||
((__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) | |||
/** @brief BRR division operation to set BRR register in 8-bit oversampling mode. | |||
* @param __PCLK__ USART clock. | |||
* @param __BAUD__ Baud rate set by the user. | |||
* @param __CLOCKPRESCALER__ UART prescaler value. | |||
* @retval Division result | |||
*/ | |||
#define USART_DIV_SAMPLING8(__PCLK__, __BAUD__, __CLOCKPRESCALER__) (((((__PCLK__)/USART_GET_DIV_FACTOR(__CLOCKPRESCALER__))*2U) + ((__BAUD__)/2U)) / (__BAUD__)) | |||
/** @brief Report the USART clock source. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @param __CLOCKSOURCE__ output variable. | |||
* @retval the USART clocking source, written in __CLOCKSOURCE__. | |||
*/ | |||
#define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \ | |||
do { \ | |||
if((__HANDLE__)->Instance == USART1) \ | |||
{ \ | |||
switch(__HAL_RCC_GET_USART1_SOURCE()) \ | |||
{ \ | |||
case RCC_USART1CLKSOURCE_PCLK2: \ | |||
(__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK2; \ | |||
break; \ | |||
case RCC_USART1CLKSOURCE_HSI: \ | |||
(__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \ | |||
break; \ | |||
case RCC_USART1CLKSOURCE_SYSCLK: \ | |||
(__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \ | |||
break; \ | |||
case RCC_USART1CLKSOURCE_LSE: \ | |||
(__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \ | |||
break; \ | |||
default: \ | |||
(__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ | |||
break; \ | |||
} \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \ | |||
} \ | |||
} while(0U) | |||
/** @brief Check USART Baud rate. | |||
* @param __BAUDRATE__ Baudrate specified by the user. | |||
* The maximum Baud Rate is derived from the maximum clock on WB (i.e. 64 MHz) | |||
* divided by the smallest oversampling used on the USART (i.e. 8) | |||
* @retval SET (__BAUDRATE__ is valid) or RESET (__BAUDRATE__ is invalid) */ | |||
#define IS_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) <= 8000000U) | |||
/** | |||
* @brief Ensure that USART frame number of stop bits is valid. | |||
* @param __STOPBITS__ USART frame number of stop bits. | |||
* @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid) | |||
*/ | |||
#define IS_USART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == USART_STOPBITS_0_5) || \ | |||
((__STOPBITS__) == USART_STOPBITS_1) || \ | |||
((__STOPBITS__) == USART_STOPBITS_1_5) || \ | |||
((__STOPBITS__) == USART_STOPBITS_2)) | |||
/** | |||
* @brief Ensure that USART frame parity is valid. | |||
* @param __PARITY__ USART frame parity. | |||
* @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid) | |||
*/ | |||
#define IS_USART_PARITY(__PARITY__) (((__PARITY__) == USART_PARITY_NONE) || \ | |||
((__PARITY__) == USART_PARITY_EVEN) || \ | |||
((__PARITY__) == USART_PARITY_ODD)) | |||
/** | |||
* @brief Ensure that USART communication mode is valid. | |||
* @param __MODE__ USART communication mode. | |||
* @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) | |||
*/ | |||
#define IS_USART_MODE(__MODE__) ((((__MODE__) & 0xFFFFFFF3U) == 0x00U) && ((__MODE__) != 0x00U)) | |||
/** | |||
* @brief Ensure that USART oversampling is valid. | |||
* @param __SAMPLING__ USART oversampling. | |||
* @retval SET (__SAMPLING__ is valid) or RESET (__SAMPLING__ is invalid) | |||
*/ | |||
#define IS_USART_OVERSAMPLING(__SAMPLING__) (((__SAMPLING__) == USART_OVERSAMPLING_16) || \ | |||
((__SAMPLING__) == USART_OVERSAMPLING_8)) | |||
/** | |||
* @brief Ensure that USART clock state is valid. | |||
* @param __CLOCK__ USART clock state. | |||
* @retval SET (__CLOCK__ is valid) or RESET (__CLOCK__ is invalid) | |||
*/ | |||
#define IS_USART_CLOCK(__CLOCK__) (((__CLOCK__) == USART_CLOCK_DISABLE) || \ | |||
((__CLOCK__) == USART_CLOCK_ENABLE)) | |||
/** | |||
* @brief Ensure that USART frame polarity is valid. | |||
* @param __CPOL__ USART frame polarity. | |||
* @retval SET (__CPOL__ is valid) or RESET (__CPOL__ is invalid) | |||
*/ | |||
#define IS_USART_POLARITY(__CPOL__) (((__CPOL__) == USART_POLARITY_LOW) || ((__CPOL__) == USART_POLARITY_HIGH)) | |||
/** | |||
* @brief Ensure that USART frame phase is valid. | |||
* @param __CPHA__ USART frame phase. | |||
* @retval SET (__CPHA__ is valid) or RESET (__CPHA__ is invalid) | |||
*/ | |||
#define IS_USART_PHASE(__CPHA__) (((__CPHA__) == USART_PHASE_1EDGE) || ((__CPHA__) == USART_PHASE_2EDGE)) | |||
/** | |||
* @brief Ensure that USART frame last bit clock pulse setting is valid. | |||
* @param __LASTBIT__ USART frame last bit clock pulse setting. | |||
* @retval SET (__LASTBIT__ is valid) or RESET (__LASTBIT__ is invalid) | |||
*/ | |||
#define IS_USART_LASTBIT(__LASTBIT__) (((__LASTBIT__) == USART_LASTBIT_DISABLE) || \ | |||
((__LASTBIT__) == USART_LASTBIT_ENABLE)) | |||
/** | |||
* @brief Ensure that USART request parameter is valid. | |||
* @param __PARAM__ USART request parameter. | |||
* @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid) | |||
*/ | |||
#define IS_USART_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == USART_RXDATA_FLUSH_REQUEST) || \ | |||
((__PARAM__) == USART_TXDATA_FLUSH_REQUEST)) | |||
/** | |||
* @brief Ensure that USART Prescaler is valid. | |||
* @param __CLOCKPRESCALER__ USART Prescaler value. | |||
* @retval SET (__CLOCKPRESCALER__ is valid) or RESET (__CLOCKPRESCALER__ is invalid) | |||
*/ | |||
#define IS_USART_PRESCALER(__CLOCKPRESCALER__) (((__CLOCKPRESCALER__) == USART_PRESCALER_DIV1) || \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV2) || \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV4) || \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV6) || \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV8) || \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV10) || \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV12) || \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV16) || \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV32) || \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV64) || \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV128) || \ | |||
((__CLOCKPRESCALER__) == USART_PRESCALER_DIV256)) | |||
/** | |||
* @} | |||
*/ | |||
/* Include USART HAL Extended module */ | |||
#include "stm32wbxx_hal_usart_ex.h" | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup USART_Exported_Functions USART Exported Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup USART_Exported_Functions_Group1 Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
/* Initialization and de-initialization functions ****************************/ | |||
HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart); | |||
HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart); | |||
void HAL_USART_MspInit(USART_HandleTypeDef *husart); | |||
void HAL_USART_MspDeInit(USART_HandleTypeDef *husart); | |||
/* Callbacks Register/UnRegister functions ***********************************/ | |||
#if (USE_HAL_USART_REGISTER_CALLBACKS == 1) | |||
HAL_StatusTypeDef HAL_USART_RegisterCallback(USART_HandleTypeDef *husart, HAL_USART_CallbackIDTypeDef CallbackID, pUSART_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_USART_UnRegisterCallback(USART_HandleTypeDef *husart, HAL_USART_CallbackIDTypeDef CallbackID); | |||
#endif /* USE_HAL_USART_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup USART_Exported_Functions_Group2 IO operation functions | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); | |||
HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); | |||
HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart); | |||
HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart); | |||
HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart); | |||
/* Transfer Abort functions */ | |||
HAL_StatusTypeDef HAL_USART_Abort(USART_HandleTypeDef *husart); | |||
HAL_StatusTypeDef HAL_USART_Abort_IT(USART_HandleTypeDef *husart); | |||
void HAL_USART_IRQHandler(USART_HandleTypeDef *husart); | |||
void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart); | |||
void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart); | |||
void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart); | |||
void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart); | |||
void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart); | |||
void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart); | |||
void HAL_USART_AbortCpltCallback(USART_HandleTypeDef *husart); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup USART_Exported_Functions_Group4 Peripheral State and Error functions | |||
* @{ | |||
*/ | |||
/* Peripheral State and Error functions ***************************************/ | |||
HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart); | |||
uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_USART_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,285 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_usart_ex.h | |||
* @author MCD Application Team | |||
* @brief Header file of USART HAL Extended module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_USART_EX_H | |||
#define STM32WBxx_HAL_USART_EX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup USARTEx | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup USARTEx_Exported_Constants USARTEx Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup USARTEx_Word_Length USARTEx Word Length | |||
* @{ | |||
*/ | |||
#define USART_WORDLENGTH_7B ((uint32_t)USART_CR1_M1) /*!< 7-bit long USART frame */ | |||
#define USART_WORDLENGTH_8B 0x00000000U /*!< 8-bit long USART frame */ | |||
#define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M0) /*!< 9-bit long USART frame */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USARTEx_Slave_Select_management USARTEx Slave Select Management | |||
* @{ | |||
*/ | |||
#define USART_NSS_HARD 0x00000000U /*!< SPI slave selection depends on NSS input pin */ | |||
#define USART_NSS_SOFT USART_CR2_DIS_NSS /*!< SPI slave is always selected and NSS input pin is ignored */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USARTEx_Slave_Mode USARTEx Synchronous Slave mode enable | |||
* @brief USART SLAVE mode | |||
* @{ | |||
*/ | |||
#define USART_SLAVEMODE_DISABLE 0x00000000U /*!< USART SPI Slave Mode Enable */ | |||
#define USART_SLAVEMODE_ENABLE USART_CR2_SLVEN /*!< USART SPI Slave Mode Disable */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USARTEx_FIFO_mode USARTEx FIFO mode | |||
* @brief USART FIFO mode | |||
* @{ | |||
*/ | |||
#define USART_FIFOMODE_DISABLE 0x00000000U /*!< FIFO mode disable */ | |||
#define USART_FIFOMODE_ENABLE USART_CR1_FIFOEN /*!< FIFO mode enable */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USARTEx_TXFIFO_threshold_level USARTEx TXFIFO threshold level | |||
* @brief USART TXFIFO level | |||
* @{ | |||
*/ | |||
#define USART_TXFIFO_THRESHOLD_1_8 0x00000000U /*!< TXFIFO reaches 1/8 of its depth */ | |||
#define USART_TXFIFO_THRESHOLD_1_4 USART_CR3_TXFTCFG_0 /*!< TXFIFO reaches 1/4 of its depth */ | |||
#define USART_TXFIFO_THRESHOLD_1_2 USART_CR3_TXFTCFG_1 /*!< TXFIFO reaches 1/2 of its depth */ | |||
#define USART_TXFIFO_THRESHOLD_3_4 (USART_CR3_TXFTCFG_0|USART_CR3_TXFTCFG_1) /*!< TXFIFO reaches 3/4 of its depth */ | |||
#define USART_TXFIFO_THRESHOLD_7_8 USART_CR3_TXFTCFG_2 /*!< TXFIFO reaches 7/8 of its depth */ | |||
#define USART_TXFIFO_THRESHOLD_8_8 (USART_CR3_TXFTCFG_2|USART_CR3_TXFTCFG_0) /*!< TXFIFO becomes empty */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USARTEx_RXFIFO_threshold_level USARTEx RXFIFO threshold level | |||
* @brief USART RXFIFO level | |||
* @{ | |||
*/ | |||
#define USART_RXFIFO_THRESHOLD_1_8 0x00000000U /*!< RXFIFO FIFO reaches 1/8 of its depth */ | |||
#define USART_RXFIFO_THRESHOLD_1_4 USART_CR3_RXFTCFG_0 /*!< RXFIFO FIFO reaches 1/4 of its depth */ | |||
#define USART_RXFIFO_THRESHOLD_1_2 USART_CR3_RXFTCFG_1 /*!< RXFIFO FIFO reaches 1/2 of its depth */ | |||
#define USART_RXFIFO_THRESHOLD_3_4 (USART_CR3_RXFTCFG_0|USART_CR3_RXFTCFG_1) /*!< RXFIFO FIFO reaches 3/4 of its depth */ | |||
#define USART_RXFIFO_THRESHOLD_7_8 USART_CR3_RXFTCFG_2 /*!< RXFIFO FIFO reaches 7/8 of its depth */ | |||
#define USART_RXFIFO_THRESHOLD_8_8 (USART_CR3_RXFTCFG_2|USART_CR3_RXFTCFG_0) /*!< RXFIFO FIFO becomes full */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup USARTEx_Private_Macros USARTEx Private Macros | |||
* @{ | |||
*/ | |||
/** @brief Compute the USART mask to apply to retrieve the received data | |||
* according to the word length and to the parity bits activation. | |||
* @note If PCE = 1, the parity bit is not included in the data extracted | |||
* by the reception API(). | |||
* This masking operation is not carried out in the case of | |||
* DMA transfers. | |||
* @param __HANDLE__ specifies the USART Handle. | |||
* @retval None, the mask to apply to USART RDR register is stored in (__HANDLE__)->Mask field. | |||
*/ | |||
#define USART_MASK_COMPUTATION(__HANDLE__) \ | |||
do { \ | |||
if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_9B) \ | |||
{ \ | |||
if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x01FFU; \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x00FFU; \ | |||
} \ | |||
} \ | |||
else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_8B) \ | |||
{ \ | |||
if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x00FFU; \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x007FU; \ | |||
} \ | |||
} \ | |||
else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_7B) \ | |||
{ \ | |||
if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x007FU; \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x003FU; \ | |||
} \ | |||
} \ | |||
else \ | |||
{ \ | |||
(__HANDLE__)->Mask = 0x0000U; \ | |||
} \ | |||
} while(0U) | |||
/** | |||
* @brief Ensure that USART frame length is valid. | |||
* @param __LENGTH__ USART frame length. | |||
* @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid) | |||
*/ | |||
#define IS_USART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == USART_WORDLENGTH_7B) || \ | |||
((__LENGTH__) == USART_WORDLENGTH_8B) || \ | |||
((__LENGTH__) == USART_WORDLENGTH_9B)) | |||
/** | |||
* @brief Ensure that USART Negative Slave Select (NSS) pin management is valid. | |||
* @param __NSS__ USART Negative Slave Select pin management. | |||
* @retval SET (__NSS__ is valid) or RESET (__NSS__ is invalid) | |||
*/ | |||
#define IS_USART_NSS(__NSS__) (((__NSS__) == USART_NSS_HARD) || \ | |||
((__NSS__) == USART_NSS_SOFT)) | |||
/** | |||
* @brief Ensure that USART Slave Mode is valid. | |||
* @param __STATE__ USART Slave Mode. | |||
* @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid) | |||
*/ | |||
#define IS_USART_SLAVEMODE(__STATE__) (((__STATE__) == USART_SLAVEMODE_DISABLE ) || \ | |||
((__STATE__) == USART_SLAVEMODE_ENABLE)) | |||
/** | |||
* @brief Ensure that USART FIFO mode is valid. | |||
* @param __STATE__ USART FIFO mode. | |||
* @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid) | |||
*/ | |||
#define IS_USART_FIFO_MODE_STATE(__STATE__) (((__STATE__) == USART_FIFOMODE_DISABLE ) || \ | |||
((__STATE__) == USART_FIFOMODE_ENABLE)) | |||
/** | |||
* @brief Ensure that USART TXFIFO threshold level is valid. | |||
* @param __THRESHOLD__ USART TXFIFO threshold level. | |||
* @retval SET (__THRESHOLD__ is valid) or RESET (__THRESHOLD__ is invalid) | |||
*/ | |||
#define IS_USART_TXFIFO_THRESHOLD(__THRESHOLD__) (((__THRESHOLD__) == USART_TXFIFO_THRESHOLD_1_8) || \ | |||
((__THRESHOLD__) == USART_TXFIFO_THRESHOLD_1_4) || \ | |||
((__THRESHOLD__) == USART_TXFIFO_THRESHOLD_1_2) || \ | |||
((__THRESHOLD__) == USART_TXFIFO_THRESHOLD_3_4) || \ | |||
((__THRESHOLD__) == USART_TXFIFO_THRESHOLD_7_8) || \ | |||
((__THRESHOLD__) == USART_TXFIFO_THRESHOLD_8_8)) | |||
/** | |||
* @brief Ensure that USART RXFIFO threshold level is valid. | |||
* @param __THRESHOLD__ USART RXFIFO threshold level. | |||
* @retval SET (__THRESHOLD__ is valid) or RESET (__THRESHOLD__ is invalid) | |||
*/ | |||
#define IS_USART_RXFIFO_THRESHOLD(__THRESHOLD__) (((__THRESHOLD__) == USART_RXFIFO_THRESHOLD_1_8) || \ | |||
((__THRESHOLD__) == USART_RXFIFO_THRESHOLD_1_4) || \ | |||
((__THRESHOLD__) == USART_RXFIFO_THRESHOLD_1_2) || \ | |||
((__THRESHOLD__) == USART_RXFIFO_THRESHOLD_3_4) || \ | |||
((__THRESHOLD__) == USART_RXFIFO_THRESHOLD_7_8) || \ | |||
((__THRESHOLD__) == USART_RXFIFO_THRESHOLD_8_8)) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup USARTEx_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup USARTEx_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
/* IO operation functions *****************************************************/ | |||
void HAL_USARTEx_RxFifoFullCallback(USART_HandleTypeDef *husart); | |||
void HAL_USARTEx_TxFifoEmptyCallback(USART_HandleTypeDef *husart); | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup USARTEx_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
/* Peripheral Control functions ***********************************************/ | |||
HAL_StatusTypeDef HAL_USARTEx_EnableSlaveMode(USART_HandleTypeDef *husart); | |||
HAL_StatusTypeDef HAL_USARTEx_DisableSlaveMode(USART_HandleTypeDef *husart); | |||
HAL_StatusTypeDef HAL_USARTEx_ConfigNSS(USART_HandleTypeDef *husart, uint32_t NSSConfig); | |||
HAL_StatusTypeDef HAL_USARTEx_EnableFifoMode(USART_HandleTypeDef *husart); | |||
HAL_StatusTypeDef HAL_USARTEx_DisableFifoMode(USART_HandleTypeDef *husart); | |||
HAL_StatusTypeDef HAL_USARTEx_SetTxFifoThreshold(USART_HandleTypeDef *husart, uint32_t Threshold); | |||
HAL_StatusTypeDef HAL_USARTEx_SetRxFifoThreshold(USART_HandleTypeDef *husart, uint32_t Threshold); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_USART_EX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,307 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_wwdg.h | |||
* @author MCD Application Team | |||
* @brief Header file of WWDG HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_HAL_WWDG_H | |||
#define STM32WBxx_HAL_WWDG_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup WWDG | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup WWDG_Exported_Types WWDG Exported Types | |||
* @{ | |||
*/ | |||
/** | |||
* @brief WWDG Init structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Prescaler; /*!< Specifies the prescaler value of the WWDG. | |||
This parameter can be a value of @ref WWDG_Prescaler */ | |||
uint32_t Window; /*!< Specifies the WWDG window value to be compared to the downcounter. | |||
This parameter must be a number Min_Data = 0x40 and Max_Data = 0x7F */ | |||
uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value. | |||
This parameter must be a number between Min_Data = 0x40 and Max_Data = 0x7F */ | |||
uint32_t EWIMode ; /*!< Specifies if WWDG Early Wakeup Interupt is enable or not. | |||
This parameter can be a value of @ref WWDG_EWI_Mode */ | |||
} WWDG_InitTypeDef; | |||
/** | |||
* @brief WWDG handle Structure definition | |||
*/ | |||
#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) | |||
typedef struct __WWDG_HandleTypeDef | |||
#else | |||
typedef struct | |||
#endif | |||
{ | |||
WWDG_TypeDef *Instance; /*!< Register base address */ | |||
WWDG_InitTypeDef Init; /*!< WWDG required parameters */ | |||
#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) | |||
void (* EwiCallback)(struct __WWDG_HandleTypeDef *hwwdg); /*!< WWDG Early WakeUp Interrupt callback */ | |||
void (* MspInitCallback)(struct __WWDG_HandleTypeDef *hwwdg); /*!< WWDG Msp Init callback */ | |||
#endif | |||
} WWDG_HandleTypeDef; | |||
#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) | |||
/** | |||
* @brief HAL WWDG common Callback ID enumeration definition | |||
*/ | |||
typedef enum | |||
{ | |||
HAL_WWDG_EWI_CB_ID = 0x00u, /*!< WWDG EWI callback ID */ | |||
HAL_WWDG_MSPINIT_CB_ID = 0x01u, /*!< WWDG MspInit callback ID */ | |||
}HAL_WWDG_CallbackIDTypeDef; | |||
/** | |||
* @brief HAL WWDG Callback pointer definition | |||
*/ | |||
typedef void (*pWWDG_CallbackTypeDef)(WWDG_HandleTypeDef * hppp); /*!< pointer to a WWDG common callback functions */ | |||
#endif | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup WWDG_Exported_Constants WWDG Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup WWDG_Interrupt_definition WWDG Interrupt definition | |||
* @{ | |||
*/ | |||
#define WWDG_IT_EWI WWDG_CFR_EWI /*!< Early wakeup interrupt */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup WWDG_Flag_definition WWDG Flag definition | |||
* @brief WWDG Flag definition | |||
* @{ | |||
*/ | |||
#define WWDG_FLAG_EWIF WWDG_SR_EWIF /*!< Early wakeup interrupt flag */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup WWDG_Prescaler WWDG Prescaler | |||
* @{ | |||
*/ | |||
#define WWDG_PRESCALER_1 0x00000000u /*!< WWDG counter clock = (PCLK1/4096)/1 */ | |||
#define WWDG_PRESCALER_2 WWDG_CFR_WDGTB_0 /*!< WWDG counter clock = (PCLK1/4096)/2 */ | |||
#define WWDG_PRESCALER_4 WWDG_CFR_WDGTB_1 /*!< WWDG counter clock = (PCLK1/4096)/4 */ | |||
#define WWDG_PRESCALER_8 (WWDG_CFR_WDGTB_1 | WWDG_CFR_WDGTB_0) /*!< WWDG counter clock = (PCLK1/4096)/8 */ | |||
#define WWDG_PRESCALER_16 WWDG_CFR_WDGTB_2 /*!< WWDG counter clock = (PCLK1/4096)/16 */ | |||
#define WWDG_PRESCALER_32 (WWDG_CFR_WDGTB_2 | WWDG_CFR_WDGTB_0) /*!< WWDG counter clock = (PCLK1/4096)/32 */ | |||
#define WWDG_PRESCALER_64 (WWDG_CFR_WDGTB_2 | WWDG_CFR_WDGTB_1) /*!< WWDG counter clock = (PCLK1/4096)/64 */ | |||
#define WWDG_PRESCALER_128 WWDG_CFR_WDGTB /*!< WWDG counter clock = (PCLK1/4096)/128 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup WWDG_EWI_Mode WWDG Early Wakeup Interrupt Mode | |||
* @{ | |||
*/ | |||
#define WWDG_EWI_DISABLE 0x00000000u /*!< EWI Disable */ | |||
#define WWDG_EWI_ENABLE WWDG_CFR_EWI /*!< EWI Enable */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup WWDG_Private_Macros WWDG Private Macros | |||
* @{ | |||
*/ | |||
#define IS_WWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == WWDG_PRESCALER_1) || \ | |||
((__PRESCALER__) == WWDG_PRESCALER_2) || \ | |||
((__PRESCALER__) == WWDG_PRESCALER_4) || \ | |||
((__PRESCALER__) == WWDG_PRESCALER_8) || \ | |||
((__PRESCALER__) == WWDG_PRESCALER_16) || \ | |||
((__PRESCALER__) == WWDG_PRESCALER_32) || \ | |||
((__PRESCALER__) == WWDG_PRESCALER_64) || \ | |||
((__PRESCALER__) == WWDG_PRESCALER_128)) | |||
#define IS_WWDG_WINDOW(__WINDOW__) (((__WINDOW__) >= WWDG_CFR_W_6) && ((__WINDOW__) <= WWDG_CFR_W)) | |||
#define IS_WWDG_COUNTER(__COUNTER__) (((__COUNTER__) >= WWDG_CR_T_6) && ((__COUNTER__) <= WWDG_CR_T)) | |||
#define IS_WWDG_EWI_MODE(__MODE__) (((__MODE__) == WWDG_EWI_ENABLE) || \ | |||
((__MODE__) == WWDG_EWI_DISABLE)) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macros ------------------------------------------------------------*/ | |||
/** @defgroup WWDG_Exported_Macros WWDG Exported Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable the WWDG peripheral. | |||
* @param __HANDLE__ WWDG handle | |||
* @retval None | |||
*/ | |||
#define __HAL_WWDG_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, WWDG_CR_WDGA) | |||
/** | |||
* @brief Enable the WWDG early wakeup interrupt. | |||
* @param __HANDLE__: WWDG handle | |||
* @param __INTERRUPT__ specifies the interrupt to enable. | |||
* This parameter can be one of the following values: | |||
* @arg WWDG_IT_EWI: Early wakeup interrupt | |||
* @note Once enabled this interrupt cannot be disabled except by a system reset. | |||
* @retval None | |||
*/ | |||
#define __HAL_WWDG_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CFR, (__INTERRUPT__)) | |||
/** | |||
* @brief Check whether the selected WWDG interrupt has occurred or not. | |||
* @param __HANDLE__ WWDG handle | |||
* @param __INTERRUPT__ specifies the it to check. | |||
* This parameter can be one of the following values: | |||
* @arg WWDG_FLAG_EWIF: Early wakeup interrupt IT | |||
* @retval The new state of WWDG_FLAG (SET or RESET). | |||
*/ | |||
#define __HAL_WWDG_GET_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_GET_FLAG((__HANDLE__),(__INTERRUPT__)) | |||
/** @brief Clear the WWDG interrupt pending bits. | |||
* bits to clear the selected interrupt pending bits. | |||
* @param __HANDLE__ WWDG handle | |||
* @param __INTERRUPT__ specifies the interrupt pending bit to clear. | |||
* This parameter can be one of the following values: | |||
* @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag | |||
*/ | |||
#define __HAL_WWDG_CLEAR_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_CLEAR_FLAG((__HANDLE__), (__INTERRUPT__)) | |||
/** | |||
* @brief Check whether the specified WWDG flag is set or not. | |||
* @param __HANDLE__ WWDG handle | |||
* @param __FLAG__ specifies the flag to check. | |||
* This parameter can be one of the following values: | |||
* @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag | |||
* @retval The new state of WWDG_FLAG (SET or RESET). | |||
*/ | |||
#define __HAL_WWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) | |||
/** | |||
* @brief Clear the WWDG's pending flags. | |||
* @param __HANDLE__ WWDG handle | |||
* @param __FLAG__ specifies the flag to clear. | |||
* This parameter can be one of the following values: | |||
* @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag | |||
* @retval None | |||
*/ | |||
#define __HAL_WWDG_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) | |||
/** @brief Check whether the specified WWDG interrupt source is enabled or not. | |||
* @param __HANDLE__ WWDG Handle. | |||
* @param __INTERRUPT__ specifies the WWDG interrupt source to check. | |||
* This parameter can be one of the following values: | |||
* @arg WWDG_IT_EWI: Early Wakeup Interrupt | |||
* @retval state of __INTERRUPT__ (TRUE or FALSE). | |||
*/ | |||
#define __HAL_WWDG_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CFR & (__INTERRUPT__)) == (__INTERRUPT__)) | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup WWDG_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup WWDG_Exported_Functions_Group1 | |||
* @{ | |||
*/ | |||
/* Initialization/de-initialization functions **********************************/ | |||
HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg); | |||
void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg); | |||
/* Callbacks Register/UnRegister functions ***********************************/ | |||
#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) | |||
HAL_StatusTypeDef HAL_WWDG_RegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID, pWWDG_CallbackTypeDef pCallback); | |||
HAL_StatusTypeDef HAL_WWDG_UnRegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID); | |||
#endif | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup WWDG_Exported_Functions_Group2 | |||
* @{ | |||
*/ | |||
/* I/O operation functions ******************************************************/ | |||
HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg); | |||
void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg); | |||
void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef *hwwdg); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_HAL_WWDG_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,762 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_ll_comp.h | |||
* @author MCD Application Team | |||
* @brief Header file of COMP LL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_LL_COMP_H | |||
#define STM32WBxx_LL_COMP_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx.h" | |||
/** @addtogroup STM32WBxx_LL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup COMP_LL COMP | |||
* @{ | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/** @defgroup COMP_LL_Private_Constants COMP Private Constants | |||
* @{ | |||
*/ | |||
/* COMP registers bits positions */ | |||
#define LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS (30UL) /* Value equivalent to POSITION_VAL(COMP_CSR_VALUE) */ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
#if defined(USE_FULL_LL_DRIVER) | |||
/** @defgroup COMP_LL_ES_INIT COMP Exported Init structure | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Structure definition of some features of COMP instance. | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t PowerMode; /*!< Set comparator operating mode to adjust power and speed. | |||
This parameter can be a value of @ref COMP_LL_EC_POWERMODE | |||
This feature can be modified afterwards using unitary function @ref LL_COMP_SetPowerMode(). */ | |||
uint32_t InputPlus; /*!< Set comparator input plus (non-inverting input). | |||
This parameter can be a value of @ref COMP_LL_EC_INPUT_PLUS | |||
This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputPlus(). */ | |||
uint32_t InputMinus; /*!< Set comparator input minus (inverting input). | |||
This parameter can be a value of @ref COMP_LL_EC_INPUT_MINUS | |||
This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputMinus(). */ | |||
uint32_t InputHysteresis; /*!< Set comparator hysteresis mode of the input minus. | |||
This parameter can be a value of @ref COMP_LL_EC_INPUT_HYSTERESIS | |||
This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputHysteresis(). */ | |||
uint32_t OutputPolarity; /*!< Set comparator output polarity. | |||
This parameter can be a value of @ref COMP_LL_EC_OUTPUT_POLARITY | |||
This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputPolarity(). */ | |||
uint32_t OutputBlankingSource; /*!< Set comparator blanking source. | |||
This parameter can be a value of @ref COMP_LL_EC_OUTPUT_BLANKING_SOURCE | |||
This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputBlankingSource(). */ | |||
} LL_COMP_InitTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
#endif /* USE_FULL_LL_DRIVER */ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup COMP_LL_Exported_Constants COMP Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup COMP_LL_EC_COMMON_WINDOWMODE Comparator common modes - Window mode | |||
* @{ | |||
*/ | |||
#define LL_COMP_WINDOWMODE_DISABLE (0x00000000UL) /*!< Window mode disable: Comparators 1 and 2 are independent */ | |||
#define LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_WINMODE) /*!< Window mode enable: Comparators instances pair COMP1 and COMP2 have their input plus connected together. The common input is COMP1 input plus (COMP2 input plus is no more accessible). */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_LL_EC_POWERMODE Comparator modes - Power mode | |||
* @{ | |||
*/ | |||
#define LL_COMP_POWERMODE_HIGHSPEED (0x00000000UL) /*!< COMP power mode to high speed */ | |||
#define LL_COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_PWRMODE_0) /*!< COMP power mode to medium speed */ | |||
#define LL_COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_PWRMODE_1 | COMP_CSR_PWRMODE_0) /*!< COMP power mode to ultra-low power */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_LL_EC_INPUT_PLUS Comparator inputs - Input plus (input non-inverting) selection | |||
* @{ | |||
*/ | |||
#define LL_COMP_INPUT_PLUS_IO1 (0x00000000UL) /*!< Comparator input plus connected to IO1 (pin PC5 for COMP1, pin PB4 for COMP2) */ | |||
#define LL_COMP_INPUT_PLUS_IO2 (COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PB6 for COMP2) */ | |||
#define LL_COMP_INPUT_PLUS_IO3 (COMP_CSR_INPSEL_1) /*!< Comparator input plus connected to IO3 (pin PA1 for COMP1, pin PA3 for COMP2) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_LL_EC_INPUT_MINUS Comparator inputs - Input minus (input inverting) selection | |||
* @{ | |||
*/ | |||
#define LL_COMP_INPUT_MINUS_1_4VREFINT ( COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/4 VrefInt */ | |||
#define LL_COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/2 VrefInt */ | |||
#define LL_COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 3/4 VrefInt */ | |||
#define LL_COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN ) /*!< Comparator input minus connected to VrefInt */ | |||
#define LL_COMP_INPUT_MINUS_IO1 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 ) /*!< Comparator input minus connected to IO1 (pin PA9 for COMP1, pin PB3 for COMP2) */ | |||
#define LL_COMP_INPUT_MINUS_IO2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO2 (pin PC4 for COMP1, pin PB7 for COMP2) */ | |||
#define LL_COMP_INPUT_MINUS_IO3 ( COMP_CSR_INMESEL_0 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO3 (pin PA0 for COMP1, pin PA2 for COMP2) */ | |||
#define LL_COMP_INPUT_MINUS_IO4 (COMP_CSR_INMESEL_1 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO4 (pin PA4 for COMP1, pin PA4 for COMP2) */ | |||
#define LL_COMP_INPUT_MINUS_IO5 (COMP_CSR_INMESEL_1 | COMP_CSR_INMESEL_0 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO5 (pin PA5 for COMP1, pin PA5 for COMP2) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_LL_EC_INPUT_HYSTERESIS Comparator input - Hysteresis | |||
* @{ | |||
*/ | |||
#define LL_COMP_HYSTERESIS_NONE (0x00000000UL) /*!< No hysteresis */ | |||
#define LL_COMP_HYSTERESIS_LOW ( COMP_CSR_HYST_0) /*!< Hysteresis level low */ | |||
#define LL_COMP_HYSTERESIS_MEDIUM (COMP_CSR_HYST_1 ) /*!< Hysteresis level medium */ | |||
#define LL_COMP_HYSTERESIS_HIGH (COMP_CSR_HYST_1 | COMP_CSR_HYST_0) /*!< Hysteresis level high */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_LL_EC_OUTPUT_POLARITY Comparator output - Output polarity | |||
* @{ | |||
*/ | |||
#define LL_COMP_OUTPUTPOL_NONINVERTED (0x00000000UL) /*!< COMP output polarity is not inverted: comparator output is high when the plus (non-inverting) input is at a higher voltage than the minus (inverting) input */ | |||
#define LL_COMP_OUTPUTPOL_INVERTED (COMP_CSR_POLARITY) /*!< COMP output polarity is inverted: comparator output is low when the plus (non-inverting) input is at a lower voltage than the minus (inverting) input */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_LL_EC_OUTPUT_BLANKING_SOURCE Comparator output - Blanking source | |||
* @{ | |||
*/ | |||
#define LL_COMP_BLANKINGSRC_NONE (0x00000000UL) /*!<Comparator output without blanking */ | |||
/* Note: Output blanking source common to all COMP instances */ | |||
#define LL_COMP_BLANKINGSRC_TIM1_OC5 (COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM1 OC5 (common to all COMP instances: COMP1, COMP2) */ | |||
#define LL_COMP_BLANKINGSRC_TIM2_OC3 (COMP_CSR_BLANKING_1) /*!< Comparator output blanking source TIM2 OC3 (common to all COMP instances: COMP1, COMP2) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_LL_EC_OUTPUT_LEVEL Comparator output - Output level | |||
* @{ | |||
*/ | |||
#define LL_COMP_OUTPUT_LEVEL_LOW (0x00000000UL) /*!< Comparator output level low (if the polarity is not inverted, otherwise to be complemented) */ | |||
#define LL_COMP_OUTPUT_LEVEL_HIGH (0x00000001UL) /*!< Comparator output level high (if the polarity is not inverted, otherwise to be complemented) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_LL_EC_HW_DELAYS Definitions of COMP hardware constraints delays | |||
* @note Only COMP peripheral HW delays are defined in COMP LL driver driver, | |||
* not timeout values. | |||
* For details on delays values, refer to descriptions in source code | |||
* above each literal definition. | |||
* @{ | |||
*/ | |||
/* Delay for comparator startup time. */ | |||
/* Note: Delay required to reach propagation delay specification. */ | |||
/* Literal set to maximum value (refer to device datasheet, */ | |||
/* parameter "tSTART"). */ | |||
/* Unit: us */ | |||
#define LL_COMP_DELAY_STARTUP_US ( 80UL) /*!< Delay for COMP startup time */ | |||
/* Delay for comparator voltage scaler stabilization time. */ | |||
/* Note: Voltage scaler is used when selecting comparator input */ | |||
/* based on VrefInt: VrefInt or subdivision of VrefInt. */ | |||
/* Literal set to maximum value (refer to device datasheet, */ | |||
/* parameter "tSTART_SCALER"). */ | |||
/* Unit: us */ | |||
#define LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US ( 200UL) /*!< Delay for COMP voltage scaler stabilization time */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup COMP_LL_Exported_Macros COMP Exported Macros | |||
* @{ | |||
*/ | |||
/** @defgroup COMP_LL_EM_WRITE_READ Common write and read registers macro | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Write a value in COMP register | |||
* @param __INSTANCE__ comparator instance | |||
* @param __REG__ Register to be written | |||
* @param __VALUE__ Value to be written in the register | |||
* @retval None | |||
*/ | |||
#define LL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, (__VALUE__)) | |||
/** | |||
* @brief Read a value in COMP register | |||
* @param __INSTANCE__ comparator instance | |||
* @param __REG__ Register to be read | |||
* @retval Register value | |||
*/ | |||
#define LL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG((__INSTANCE__)->__REG__) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_LL_EM_HELPER_MACRO COMP helper macro | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Helper macro to select the COMP common instance | |||
* to which is belonging the selected COMP instance. | |||
* @note COMP common register instance can be used to | |||
* set parameters common to several COMP instances. | |||
* Refer to functions having argument "COMPxy_COMMON" as parameter. | |||
* @param __COMPx__ COMP instance | |||
* @retval COMP common instance or value "0" if there is no COMP common instance. | |||
*/ | |||
#define __LL_COMP_COMMON_INSTANCE(__COMPx__) \ | |||
(COMP12_COMMON) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup COMP_LL_Exported_Functions COMP Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup COMP_LL_EF_Configuration_comparator_common Configuration of COMP hierarchical scope: common to several COMP instances | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Set window mode of a pair of comparators instances | |||
* (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>). | |||
* @rmtoll CSR WINMODE LL_COMP_SetCommonWindowMode | |||
* @param COMPxy_COMMON Comparator common instance | |||
* (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() ) | |||
* @param WindowMode This parameter can be one of the following values: | |||
* @arg @ref LL_COMP_WINDOWMODE_DISABLE | |||
* @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON, uint32_t WindowMode) | |||
{ | |||
/* Note: On this STM32 serie, window mode can be set only */ | |||
/* from COMP instance: COMP2. */ | |||
MODIFY_REG(COMPxy_COMMON->CSR, COMP_CSR_WINMODE, WindowMode); | |||
} | |||
/** | |||
* @brief Get window mode of a pair of comparators instances | |||
* (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>). | |||
* @rmtoll CSR WINMODE LL_COMP_GetCommonWindowMode | |||
* @param COMPxy_COMMON Comparator common instance | |||
* (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() ) | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_COMP_WINDOWMODE_DISABLE | |||
* @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON | |||
*/ | |||
__STATIC_INLINE uint32_t LL_COMP_GetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON) | |||
{ | |||
return (uint32_t)(READ_BIT(COMPxy_COMMON->CSR, COMP_CSR_WINMODE)); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_LL_EF_Configuration_comparator_modes Configuration of comparator modes | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Set comparator instance operating mode to adjust power and speed. | |||
* @rmtoll CSR PWRMODE LL_COMP_SetPowerMode | |||
* @param COMPx Comparator instance | |||
* @param PowerMode This parameter can be one of the following values: | |||
* @arg @ref LL_COMP_POWERMODE_HIGHSPEED | |||
* @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED | |||
* @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_COMP_SetPowerMode(COMP_TypeDef *COMPx, uint32_t PowerMode) | |||
{ | |||
MODIFY_REG(COMPx->CSR, COMP_CSR_PWRMODE, PowerMode); | |||
} | |||
/** | |||
* @brief Get comparator instance operating mode to adjust power and speed. | |||
* @rmtoll CSR PWRMODE LL_COMP_GetPowerMode | |||
* @param COMPx Comparator instance | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_COMP_POWERMODE_HIGHSPEED | |||
* @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED | |||
* @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER | |||
*/ | |||
__STATIC_INLINE uint32_t LL_COMP_GetPowerMode(COMP_TypeDef *COMPx) | |||
{ | |||
return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_PWRMODE)); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_LL_EF_Configuration_comparator_inputs Configuration of comparator inputs | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Set comparator inputs minus (inverting) and plus (non-inverting). | |||
* @note In case of comparator input selected to be connected to IO: | |||
* GPIO pins are specific to each comparator instance. | |||
* Refer to description of parameters or to reference manual. | |||
* @note On this STM32 serie, scaler bridge is configurable: | |||
* to optimize power consumption, this function enables the | |||
* voltage scaler bridge only when required | |||
* (when selecting comparator input based on VrefInt: VrefInt or | |||
* subdivision of VrefInt). | |||
* - For scaler bridge power consumption values, | |||
* refer to device datasheet, parameter "IDDA(SCALER)". | |||
* - Voltage scaler requires a delay for voltage stabilization. | |||
* Refer to device datasheet, parameter "tSTART_SCALER". | |||
* - Scaler bridge is common for all comparator instances, | |||
* therefore if at least one of the comparator instance | |||
* is requiring the scaler bridge, it remains enabled. | |||
* @rmtoll CSR INMSEL LL_COMP_ConfigInputs\n | |||
* CSR INPSEL LL_COMP_ConfigInputs\n | |||
* CSR BRGEN LL_COMP_ConfigInputs\n | |||
* CSR SCALEN LL_COMP_ConfigInputs | |||
* @param COMPx Comparator instance | |||
* @param InputMinus This parameter can be one of the following values: | |||
* @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT | |||
* @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT | |||
* @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT | |||
* @arg @ref LL_COMP_INPUT_MINUS_VREFINT | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO1 | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO2 | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO3 | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO4 | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO5 | |||
* @param InputPlus This parameter can be one of the following values: | |||
* @arg @ref LL_COMP_INPUT_PLUS_IO1 | |||
* @arg @ref LL_COMP_INPUT_PLUS_IO2 | |||
* @arg @ref LL_COMP_INPUT_PLUS_IO3 (*) | |||
* | |||
* (*) Parameter not available on all devices. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_COMP_ConfigInputs(COMP_TypeDef *COMPx, uint32_t InputMinus, uint32_t InputPlus) | |||
{ | |||
MODIFY_REG(COMPx->CSR, | |||
COMP_CSR_INMESEL | COMP_CSR_INMSEL | COMP_CSR_INPSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN, | |||
InputMinus | InputPlus); | |||
} | |||
/** | |||
* @brief Set comparator input plus (non-inverting). | |||
* @note In case of comparator input selected to be connected to IO: | |||
* GPIO pins are specific to each comparator instance. | |||
* Refer to description of parameters or to reference manual. | |||
* @rmtoll CSR INPSEL LL_COMP_SetInputPlus | |||
* @param COMPx Comparator instance | |||
* @param InputPlus This parameter can be one of the following values: | |||
* @arg @ref LL_COMP_INPUT_PLUS_IO1 | |||
* @arg @ref LL_COMP_INPUT_PLUS_IO2 | |||
* @arg @ref LL_COMP_INPUT_PLUS_IO3 (*) | |||
* | |||
* (*) Parameter not available on all devices. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_COMP_SetInputPlus(COMP_TypeDef *COMPx, uint32_t InputPlus) | |||
{ | |||
MODIFY_REG(COMPx->CSR, COMP_CSR_INPSEL, InputPlus); | |||
} | |||
/** | |||
* @brief Get comparator input plus (non-inverting). | |||
* @note In case of comparator input selected to be connected to IO: | |||
* GPIO pins are specific to each comparator instance. | |||
* Refer to description of parameters or to reference manual. | |||
* @rmtoll CSR INPSEL LL_COMP_GetInputPlus | |||
* @param COMPx Comparator instance | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_COMP_INPUT_PLUS_IO1 | |||
* @arg @ref LL_COMP_INPUT_PLUS_IO2 | |||
* @arg @ref LL_COMP_INPUT_PLUS_IO3 (*) | |||
* | |||
* (*) Parameter not available on all devices. | |||
*/ | |||
__STATIC_INLINE uint32_t LL_COMP_GetInputPlus(COMP_TypeDef *COMPx) | |||
{ | |||
return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INPSEL)); | |||
} | |||
/** | |||
* @brief Set comparator input minus (inverting). | |||
* @note In case of comparator input selected to be connected to IO: | |||
* GPIO pins are specific to each comparator instance. | |||
* Refer to description of parameters or to reference manual. | |||
* @note On this STM32 serie, scaler bridge is configurable: | |||
* to optimize power consumption, this function enables the | |||
* voltage scaler bridge only when required | |||
* (when selecting comparator input based on VrefInt: VrefInt or | |||
* subdivision of VrefInt). | |||
* - For scaler bridge power consumption values, | |||
* refer to device datasheet, parameter "IDDA(SCALER)". | |||
* - Voltage scaler requires a delay for voltage stabilization. | |||
* Refer to device datasheet, parameter "tSTART_SCALER". | |||
* - Scaler bridge is common for all comparator instances, | |||
* therefore if at least one of the comparator instance | |||
* is requiring the scaler bridge, it remains enabled. | |||
* @rmtoll CSR INMSEL LL_COMP_SetInputMinus\n | |||
* CSR BRGEN LL_COMP_SetInputMinus\n | |||
* CSR SCALEN LL_COMP_SetInputMinus | |||
* @param COMPx Comparator instance | |||
* @param InputMinus This parameter can be one of the following values: | |||
* @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT | |||
* @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT | |||
* @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT | |||
* @arg @ref LL_COMP_INPUT_MINUS_VREFINT | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO1 | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO2 | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO3 | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO4 | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO5 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_COMP_SetInputMinus(COMP_TypeDef *COMPx, uint32_t InputMinus) | |||
{ | |||
MODIFY_REG(COMPx->CSR, COMP_CSR_INMESEL | COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN, InputMinus); | |||
} | |||
/** | |||
* @brief Get comparator input minus (inverting). | |||
* @note In case of comparator input selected to be connected to IO: | |||
* GPIO pins are specific to each comparator instance. | |||
* Refer to description of parameters or to reference manual. | |||
* @rmtoll CSR INMSEL LL_COMP_GetInputMinus\n | |||
* CSR BRGEN LL_COMP_GetInputMinus\n | |||
* CSR SCALEN LL_COMP_GetInputMinus | |||
* @param COMPx Comparator instance | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT | |||
* @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT | |||
* @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT | |||
* @arg @ref LL_COMP_INPUT_MINUS_VREFINT | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO1 | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO2 | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO3 | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO4 | |||
* @arg @ref LL_COMP_INPUT_MINUS_IO5 | |||
*/ | |||
__STATIC_INLINE uint32_t LL_COMP_GetInputMinus(COMP_TypeDef *COMPx) | |||
{ | |||
return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INMESEL | COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN)); | |||
} | |||
/** | |||
* @brief Set comparator instance hysteresis mode of the input minus (inverting input). | |||
* @rmtoll CSR HYST LL_COMP_SetInputHysteresis | |||
* @param COMPx Comparator instance | |||
* @param InputHysteresis This parameter can be one of the following values: | |||
* @arg @ref LL_COMP_HYSTERESIS_NONE | |||
* @arg @ref LL_COMP_HYSTERESIS_LOW | |||
* @arg @ref LL_COMP_HYSTERESIS_MEDIUM | |||
* @arg @ref LL_COMP_HYSTERESIS_HIGH | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_COMP_SetInputHysteresis(COMP_TypeDef *COMPx, uint32_t InputHysteresis) | |||
{ | |||
MODIFY_REG(COMPx->CSR, COMP_CSR_HYST, InputHysteresis); | |||
} | |||
/** | |||
* @brief Get comparator instance hysteresis mode of the minus (inverting) input. | |||
* @rmtoll CSR HYST LL_COMP_GetInputHysteresis | |||
* @param COMPx Comparator instance | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_COMP_HYSTERESIS_NONE | |||
* @arg @ref LL_COMP_HYSTERESIS_LOW | |||
* @arg @ref LL_COMP_HYSTERESIS_MEDIUM | |||
* @arg @ref LL_COMP_HYSTERESIS_HIGH | |||
*/ | |||
__STATIC_INLINE uint32_t LL_COMP_GetInputHysteresis(COMP_TypeDef *COMPx) | |||
{ | |||
return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_HYST)); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_LL_EF_Configuration_comparator_output Configuration of comparator output | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Set comparator instance output polarity. | |||
* @rmtoll CSR POLARITY LL_COMP_SetOutputPolarity | |||
* @param COMPx Comparator instance | |||
* @param OutputPolarity This parameter can be one of the following values: | |||
* @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED | |||
* @arg @ref LL_COMP_OUTPUTPOL_INVERTED | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t OutputPolarity) | |||
{ | |||
MODIFY_REG(COMPx->CSR, COMP_CSR_POLARITY, OutputPolarity); | |||
} | |||
/** | |||
* @brief Get comparator instance output polarity. | |||
* @rmtoll CSR POLARITY LL_COMP_GetOutputPolarity | |||
* @param COMPx Comparator instance | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED | |||
* @arg @ref LL_COMP_OUTPUTPOL_INVERTED | |||
*/ | |||
__STATIC_INLINE uint32_t LL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx) | |||
{ | |||
return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_POLARITY)); | |||
} | |||
/** | |||
* @brief Set comparator instance blanking source. | |||
* @note Blanking source may be specific to each comparator instance. | |||
* Refer to description of parameters or to reference manual. | |||
* @note Availability of parameters of blanking source from timer | |||
* depends on timers availability on the selected device. | |||
* @rmtoll CSR BLANKING LL_COMP_SetOutputBlankingSource | |||
* @param COMPx Comparator instance | |||
* @param BlankingSource This parameter can be one of the following values: | |||
* @arg @ref LL_COMP_BLANKINGSRC_NONE | |||
* @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5 (1) | |||
* @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3 (1) | |||
* | |||
* (1) Parameter availability depending on timer availability | |||
* on the selected device. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_COMP_SetOutputBlankingSource(COMP_TypeDef *COMPx, uint32_t BlankingSource) | |||
{ | |||
MODIFY_REG(COMPx->CSR, COMP_CSR_BLANKING, BlankingSource); | |||
} | |||
/** | |||
* @brief Get comparator instance blanking source. | |||
* @note Availability of parameters of blanking source from timer | |||
* depends on timers availability on the selected device. | |||
* @note Blanking source may be specific to each comparator instance. | |||
* Refer to description of parameters or to reference manual. | |||
* @rmtoll CSR BLANKING LL_COMP_GetOutputBlankingSource | |||
* @param COMPx Comparator instance | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_COMP_BLANKINGSRC_NONE | |||
* @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5 (1) | |||
* @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3 (1) | |||
* | |||
* (1) Parameter availability depending on timer availability | |||
* on the selected device. | |||
*/ | |||
__STATIC_INLINE uint32_t LL_COMP_GetOutputBlankingSource(COMP_TypeDef *COMPx) | |||
{ | |||
return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_BLANKING)); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_LL_EF_Operation Operation on comparator instance | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable comparator instance. | |||
* @note After enable from off state, comparator requires a delay | |||
* to reach reach propagation delay specification. | |||
* Refer to device datasheet, parameter "tSTART". | |||
* @rmtoll CSR EN LL_COMP_Enable | |||
* @param COMPx Comparator instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_COMP_Enable(COMP_TypeDef *COMPx) | |||
{ | |||
SET_BIT(COMPx->CSR, COMP_CSR_EN); | |||
} | |||
/** | |||
* @brief Disable comparator instance. | |||
* @rmtoll CSR EN LL_COMP_Disable | |||
* @param COMPx Comparator instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_COMP_Disable(COMP_TypeDef *COMPx) | |||
{ | |||
CLEAR_BIT(COMPx->CSR, COMP_CSR_EN); | |||
} | |||
/** | |||
* @brief Get comparator enable state | |||
* (0: COMP is disabled, 1: COMP is enabled) | |||
* @rmtoll CSR EN LL_COMP_IsEnabled | |||
* @param COMPx Comparator instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_COMP_IsEnabled(COMP_TypeDef *COMPx) | |||
{ | |||
return ((READ_BIT(COMPx->CSR, COMP_CSR_EN) == (COMP_CSR_EN)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Lock comparator instance. | |||
* @note Once locked, comparator configuration can be accessed in read-only. | |||
* @note The only way to unlock the comparator is a device hardware reset. | |||
* @rmtoll CSR LOCK LL_COMP_Lock | |||
* @param COMPx Comparator instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_COMP_Lock(COMP_TypeDef *COMPx) | |||
{ | |||
SET_BIT(COMPx->CSR, COMP_CSR_LOCK); | |||
} | |||
/** | |||
* @brief Get comparator lock state | |||
* (0: COMP is unlocked, 1: COMP is locked). | |||
* @note Once locked, comparator configuration can be accessed in read-only. | |||
* @note The only way to unlock the comparator is a device hardware reset. | |||
* @rmtoll CSR LOCK LL_COMP_IsLocked | |||
* @param COMPx Comparator instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx) | |||
{ | |||
return ((READ_BIT(COMPx->CSR, COMP_CSR_LOCK) == (COMP_CSR_LOCK)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Read comparator instance output level. | |||
* @note The comparator output level depends on the selected polarity | |||
* (Refer to function @ref LL_COMP_SetOutputPolarity()). | |||
* If the comparator polarity is not inverted: | |||
* - Comparator output is low when the input plus | |||
* is at a lower voltage than the input minus | |||
* - Comparator output is high when the input plus | |||
* is at a higher voltage than the input minus | |||
* If the comparator polarity is inverted: | |||
* - Comparator output is high when the input plus | |||
* is at a lower voltage than the input minus | |||
* - Comparator output is low when the input plus | |||
* is at a higher voltage than the input minus | |||
* @rmtoll CSR VALUE LL_COMP_ReadOutputLevel | |||
* @param COMPx Comparator instance | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_COMP_OUTPUT_LEVEL_LOW | |||
* @arg @ref LL_COMP_OUTPUT_LEVEL_HIGH | |||
*/ | |||
__STATIC_INLINE uint32_t LL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx) | |||
{ | |||
return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_VALUE) | |||
>> LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
#if defined(USE_FULL_LL_DRIVER) | |||
/** @defgroup COMP_LL_EF_Init Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx); | |||
ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct); | |||
void LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct); | |||
/** | |||
* @} | |||
*/ | |||
#endif /* USE_FULL_LL_DRIVER */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_LL_COMP_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,639 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_ll_cortex.h | |||
* @author MCD Application Team | |||
* @brief Header file of CORTEX LL module. | |||
@verbatim | |||
============================================================================== | |||
##### How to use this driver ##### | |||
============================================================================== | |||
[..] | |||
The LL CORTEX driver contains a set of generic APIs that can be | |||
used by user: | |||
(+) SYSTICK configuration used by @ref LL_mDelay and @ref LL_Init1msTick | |||
functions | |||
(+) Low power mode configuration (SCB register of Cortex-MCU) | |||
(+) MPU API to configure and enable regions | |||
(+) API to access to MCU info (CPUID register) | |||
(+) API to enable fault handler (SHCSR accesses) | |||
@endverbatim | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_LL_CORTEX_H | |||
#define STM32WBxx_LL_CORTEX_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx.h" | |||
/** @addtogroup STM32WBxx_LL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup CORTEX_LL CORTEX | |||
* @{ | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup CORTEX_LL_Exported_Constants CORTEX Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup CORTEX_LL_EC_CLKSOURCE_HCLK SYSTICK Clock Source | |||
* @{ | |||
*/ | |||
#define LL_SYSTICK_CLKSOURCE_HCLK_DIV8 0x00000000U /*!< AHB clock divided by 8 selected as SysTick clock source.*/ | |||
#define LL_SYSTICK_CLKSOURCE_HCLK SysTick_CTRL_CLKSOURCE_Msk /*!< AHB clock selected as SysTick clock source. */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_LL_EC_FAULT Handler Fault type | |||
* @{ | |||
*/ | |||
#define LL_HANDLER_FAULT_USG SCB_SHCSR_USGFAULTENA_Msk /*!< Usage fault */ | |||
#define LL_HANDLER_FAULT_BUS SCB_SHCSR_BUSFAULTENA_Msk /*!< Bus fault */ | |||
#define LL_HANDLER_FAULT_MEM SCB_SHCSR_MEMFAULTENA_Msk /*!< Memory management fault */ | |||
/** | |||
* @} | |||
*/ | |||
#if __MPU_PRESENT | |||
/** @defgroup CORTEX_LL_EC_CTRL_HFNMI_PRIVDEF MPU Control | |||
* @{ | |||
*/ | |||
#define LL_MPU_CTRL_HFNMI_PRIVDEF_NONE 0x00000000U /*!< Disable NMI and privileged SW access */ | |||
#define LL_MPU_CTRL_HARDFAULT_NMI MPU_CTRL_HFNMIENA_Msk /*!< Enables the operation of MPU during hard fault, NMI, and FAULTMASK handlers */ | |||
#define LL_MPU_CTRL_PRIVILEGED_DEFAULT MPU_CTRL_PRIVDEFENA_Msk /*!< Enable privileged software access to default memory map */ | |||
#define LL_MPU_CTRL_HFNMI_PRIVDEF (MPU_CTRL_HFNMIENA_Msk | MPU_CTRL_PRIVDEFENA_Msk) /*!< Enable NMI and privileged SW access */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_LL_EC_REGION MPU Region Number | |||
* @{ | |||
*/ | |||
#define LL_MPU_REGION_NUMBER0 0x00U /*!< REGION Number 0 */ | |||
#define LL_MPU_REGION_NUMBER1 0x01U /*!< REGION Number 1 */ | |||
#define LL_MPU_REGION_NUMBER2 0x02U /*!< REGION Number 2 */ | |||
#define LL_MPU_REGION_NUMBER3 0x03U /*!< REGION Number 3 */ | |||
#define LL_MPU_REGION_NUMBER4 0x04U /*!< REGION Number 4 */ | |||
#define LL_MPU_REGION_NUMBER5 0x05U /*!< REGION Number 5 */ | |||
#define LL_MPU_REGION_NUMBER6 0x06U /*!< REGION Number 6 */ | |||
#define LL_MPU_REGION_NUMBER7 0x07U /*!< REGION Number 7 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_LL_EC_REGION_SIZE MPU Region Size | |||
* @{ | |||
*/ | |||
#define LL_MPU_REGION_SIZE_32B (0x04U << MPU_RASR_SIZE_Pos) /*!< 32B Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_64B (0x05U << MPU_RASR_SIZE_Pos) /*!< 64B Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_128B (0x06U << MPU_RASR_SIZE_Pos) /*!< 128B Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_256B (0x07U << MPU_RASR_SIZE_Pos) /*!< 256B Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_512B (0x08U << MPU_RASR_SIZE_Pos) /*!< 512B Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_1KB (0x09U << MPU_RASR_SIZE_Pos) /*!< 1KB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_2KB (0x0AU << MPU_RASR_SIZE_Pos) /*!< 2KB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_4KB (0x0BU << MPU_RASR_SIZE_Pos) /*!< 4KB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_8KB (0x0CU << MPU_RASR_SIZE_Pos) /*!< 8KB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_16KB (0x0DU << MPU_RASR_SIZE_Pos) /*!< 16KB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_32KB (0x0EU << MPU_RASR_SIZE_Pos) /*!< 32KB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_64KB (0x0FU << MPU_RASR_SIZE_Pos) /*!< 64KB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_128KB (0x10U << MPU_RASR_SIZE_Pos) /*!< 128KB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_256KB (0x11U << MPU_RASR_SIZE_Pos) /*!< 256KB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_512KB (0x12U << MPU_RASR_SIZE_Pos) /*!< 512KB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_1MB (0x13U << MPU_RASR_SIZE_Pos) /*!< 1MB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_2MB (0x14U << MPU_RASR_SIZE_Pos) /*!< 2MB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_4MB (0x15U << MPU_RASR_SIZE_Pos) /*!< 4MB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_8MB (0x16U << MPU_RASR_SIZE_Pos) /*!< 8MB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_16MB (0x17U << MPU_RASR_SIZE_Pos) /*!< 16MB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_32MB (0x18U << MPU_RASR_SIZE_Pos) /*!< 32MB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_64MB (0x19U << MPU_RASR_SIZE_Pos) /*!< 64MB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_128MB (0x1AU << MPU_RASR_SIZE_Pos) /*!< 128MB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_256MB (0x1BU << MPU_RASR_SIZE_Pos) /*!< 256MB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_512MB (0x1CU << MPU_RASR_SIZE_Pos) /*!< 512MB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_1GB (0x1DU << MPU_RASR_SIZE_Pos) /*!< 1GB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_2GB (0x1EU << MPU_RASR_SIZE_Pos) /*!< 2GB Size of the MPU protection region */ | |||
#define LL_MPU_REGION_SIZE_4GB (0x1FU << MPU_RASR_SIZE_Pos) /*!< 4GB Size of the MPU protection region */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_LL_EC_REGION_PRIVILEDGES MPU Region Privileges | |||
* @{ | |||
*/ | |||
#define LL_MPU_REGION_NO_ACCESS (0x00U << MPU_RASR_AP_Pos) /*!< No access*/ | |||
#define LL_MPU_REGION_PRIV_RW (0x01U << MPU_RASR_AP_Pos) /*!< RW privileged (privileged access only)*/ | |||
#define LL_MPU_REGION_PRIV_RW_URO (0x02U << MPU_RASR_AP_Pos) /*!< RW privileged - RO user (Write in a user program generates a fault) */ | |||
#define LL_MPU_REGION_FULL_ACCESS (0x03U << MPU_RASR_AP_Pos) /*!< RW privileged & user (Full access) */ | |||
#define LL_MPU_REGION_PRIV_RO (0x05U << MPU_RASR_AP_Pos) /*!< RO privileged (privileged read only)*/ | |||
#define LL_MPU_REGION_PRIV_RO_URO (0x06U << MPU_RASR_AP_Pos) /*!< RO privileged & user (read only) */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_LL_EC_TEX MPU TEX Level | |||
* @{ | |||
*/ | |||
#define LL_MPU_TEX_LEVEL0 (0x00U << MPU_RASR_TEX_Pos) /*!< b000 for TEX bits */ | |||
#define LL_MPU_TEX_LEVEL1 (0x01U << MPU_RASR_TEX_Pos) /*!< b001 for TEX bits */ | |||
#define LL_MPU_TEX_LEVEL2 (0x02U << MPU_RASR_TEX_Pos) /*!< b010 for TEX bits */ | |||
#define LL_MPU_TEX_LEVEL4 (0x04U << MPU_RASR_TEX_Pos) /*!< b100 for TEX bits */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_LL_EC_INSTRUCTION_ACCESS MPU Instruction Access | |||
* @{ | |||
*/ | |||
#define LL_MPU_INSTRUCTION_ACCESS_ENABLE 0x00U /*!< Instruction fetches enabled */ | |||
#define LL_MPU_INSTRUCTION_ACCESS_DISABLE MPU_RASR_XN_Msk /*!< Instruction fetches disabled*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_LL_EC_SHAREABLE_ACCESS MPU Shareable Access | |||
* @{ | |||
*/ | |||
#define LL_MPU_ACCESS_SHAREABLE MPU_RASR_S_Msk /*!< Shareable memory attribute */ | |||
#define LL_MPU_ACCESS_NOT_SHAREABLE 0x00U /*!< Not Shareable memory attribute */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_LL_EC_CACHEABLE_ACCESS MPU Cacheable Access | |||
* @{ | |||
*/ | |||
#define LL_MPU_ACCESS_CACHEABLE MPU_RASR_C_Msk /*!< Cacheable memory attribute */ | |||
#define LL_MPU_ACCESS_NOT_CACHEABLE 0x00U /*!< Not Cacheable memory attribute */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_LL_EC_BUFFERABLE_ACCESS MPU Bufferable Access | |||
* @{ | |||
*/ | |||
#define LL_MPU_ACCESS_BUFFERABLE MPU_RASR_B_Msk /*!< Bufferable memory attribute */ | |||
#define LL_MPU_ACCESS_NOT_BUFFERABLE 0x00U /*!< Not Bufferable memory attribute */ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* __MPU_PRESENT */ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup CORTEX_LL_Exported_Functions CORTEX Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup CORTEX_LL_EF_SYSTICK SYSTICK | |||
* @{ | |||
*/ | |||
/** | |||
* @brief This function checks if the Systick counter flag is active or not. | |||
* @note It can be used in timeout function on application side. | |||
* @rmtoll STK_CTRL COUNTFLAG LL_SYSTICK_IsActiveCounterFlag | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_SYSTICK_IsActiveCounterFlag(void) | |||
{ | |||
return (((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == (SysTick_CTRL_COUNTFLAG_Msk)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Configures the SysTick clock source | |||
* @rmtoll STK_CTRL CLKSOURCE LL_SYSTICK_SetClkSource | |||
* @param Source This parameter can be one of the following values: | |||
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8 | |||
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_SYSTICK_SetClkSource(uint32_t Source) | |||
{ | |||
if (Source == LL_SYSTICK_CLKSOURCE_HCLK) | |||
{ | |||
SET_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK); | |||
} | |||
else | |||
{ | |||
CLEAR_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK); | |||
} | |||
} | |||
/** | |||
* @brief Get the SysTick clock source | |||
* @rmtoll STK_CTRL CLKSOURCE LL_SYSTICK_GetClkSource | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8 | |||
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK | |||
*/ | |||
__STATIC_INLINE uint32_t LL_SYSTICK_GetClkSource(void) | |||
{ | |||
return READ_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK); | |||
} | |||
/** | |||
* @brief Enable SysTick exception request | |||
* @rmtoll STK_CTRL TICKINT LL_SYSTICK_EnableIT | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_SYSTICK_EnableIT(void) | |||
{ | |||
SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk); | |||
} | |||
/** | |||
* @brief Disable SysTick exception request | |||
* @rmtoll STK_CTRL TICKINT LL_SYSTICK_DisableIT | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_SYSTICK_DisableIT(void) | |||
{ | |||
CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk); | |||
} | |||
/** | |||
* @brief Checks if the SYSTICK interrupt is enabled or disabled. | |||
* @rmtoll STK_CTRL TICKINT LL_SYSTICK_IsEnabledIT | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_SYSTICK_IsEnabledIT(void) | |||
{ | |||
return ((READ_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk) == (SysTick_CTRL_TICKINT_Msk)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_LL_EF_LOW_POWER_MODE LOW POWER MODE | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Processor uses sleep as its low power mode | |||
* @rmtoll SCB_SCR SLEEPDEEP LL_LPM_EnableSleep | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_LPM_EnableSleep(void) | |||
{ | |||
/* Clear SLEEPDEEP bit of Cortex System Control Register */ | |||
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk)); | |||
} | |||
/** | |||
* @brief Processor uses deep sleep as its low power mode | |||
* @rmtoll SCB_SCR SLEEPDEEP LL_LPM_EnableDeepSleep | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_LPM_EnableDeepSleep(void) | |||
{ | |||
/* Set SLEEPDEEP bit of Cortex System Control Register */ | |||
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk)); | |||
} | |||
/** | |||
* @brief Configures sleep-on-exit when returning from Handler mode to Thread mode. | |||
* @note Setting this bit to 1 enables an interrupt-driven application to avoid returning to an | |||
* empty main application. | |||
* @rmtoll SCB_SCR SLEEPONEXIT LL_LPM_EnableSleepOnExit | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_LPM_EnableSleepOnExit(void) | |||
{ | |||
/* Set SLEEPONEXIT bit of Cortex System Control Register */ | |||
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk)); | |||
} | |||
/** | |||
* @brief Do not sleep when returning to Thread mode. | |||
* @rmtoll SCB_SCR SLEEPONEXIT LL_LPM_DisableSleepOnExit | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_LPM_DisableSleepOnExit(void) | |||
{ | |||
/* Clear SLEEPONEXIT bit of Cortex System Control Register */ | |||
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk)); | |||
} | |||
/** | |||
* @brief Enabled events and all interrupts, including disabled interrupts, can wakeup the | |||
* processor. | |||
* @rmtoll SCB_SCR SEVEONPEND LL_LPM_EnableEventOnPend | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_LPM_EnableEventOnPend(void) | |||
{ | |||
/* Set SEVEONPEND bit of Cortex System Control Register */ | |||
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk)); | |||
} | |||
/** | |||
* @brief Only enabled interrupts or events can wakeup the processor, disabled interrupts are | |||
* excluded | |||
* @rmtoll SCB_SCR SEVEONPEND LL_LPM_DisableEventOnPend | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_LPM_DisableEventOnPend(void) | |||
{ | |||
/* Clear SEVEONPEND bit of Cortex System Control Register */ | |||
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk)); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_LL_EF_HANDLER HANDLER | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable a fault in System handler control register (SHCSR) | |||
* @rmtoll SCB_SHCSR MEMFAULTENA LL_HANDLER_EnableFault | |||
* @param Fault This parameter can be a combination of the following values: | |||
* @arg @ref LL_HANDLER_FAULT_USG | |||
* @arg @ref LL_HANDLER_FAULT_BUS | |||
* @arg @ref LL_HANDLER_FAULT_MEM | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_HANDLER_EnableFault(uint32_t Fault) | |||
{ | |||
/* Enable the system handler fault */ | |||
SET_BIT(SCB->SHCSR, Fault); | |||
} | |||
/** | |||
* @brief Disable a fault in System handler control register (SHCSR) | |||
* @rmtoll SCB_SHCSR MEMFAULTENA LL_HANDLER_DisableFault | |||
* @param Fault This parameter can be a combination of the following values: | |||
* @arg @ref LL_HANDLER_FAULT_USG | |||
* @arg @ref LL_HANDLER_FAULT_BUS | |||
* @arg @ref LL_HANDLER_FAULT_MEM | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_HANDLER_DisableFault(uint32_t Fault) | |||
{ | |||
/* Disable the system handler fault */ | |||
CLEAR_BIT(SCB->SHCSR, Fault); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CORTEX_LL_EF_MCU_INFO MCU INFO | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Get Implementer code | |||
* @rmtoll SCB_CPUID IMPLEMENTER LL_CPUID_GetImplementer | |||
* @retval Value should be equal to 0x41 for ARM | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CPUID_GetImplementer(void) | |||
{ | |||
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_IMPLEMENTER_Msk) >> SCB_CPUID_IMPLEMENTER_Pos); | |||
} | |||
/** | |||
* @brief Get Variant number (The r value in the rnpn product revision identifier) | |||
* @rmtoll SCB_CPUID VARIANT LL_CPUID_GetVariant | |||
* @retval Value between 0 and 255 (0x0: revision 0) | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CPUID_GetVariant(void) | |||
{ | |||
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_VARIANT_Msk) >> SCB_CPUID_VARIANT_Pos); | |||
} | |||
/** | |||
* @brief Get Constant number | |||
* @rmtoll SCB_CPUID ARCHITECTURE LL_CPUID_GetConstant | |||
* @retval Value should be equal to 0xF for Cortex-M4 devices | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CPUID_GetConstant(void) | |||
{ | |||
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_ARCHITECTURE_Msk) >> SCB_CPUID_ARCHITECTURE_Pos); | |||
} | |||
/** | |||
* @brief Get Part number | |||
* @rmtoll SCB_CPUID PARTNO LL_CPUID_GetParNo | |||
* @retval Value should be equal to 0xC24 for Cortex-M4 | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CPUID_GetParNo(void) | |||
{ | |||
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_PARTNO_Msk) >> SCB_CPUID_PARTNO_Pos); | |||
} | |||
/** | |||
* @brief Get Revision number (The p value in the rnpn product revision identifier, indicates patch release) | |||
* @rmtoll SCB_CPUID REVISION LL_CPUID_GetRevision | |||
* @retval Value between 0 and 255 (0x1: patch 1) | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CPUID_GetRevision(void) | |||
{ | |||
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_REVISION_Msk) >> SCB_CPUID_REVISION_Pos); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
#if __MPU_PRESENT | |||
/** @defgroup CORTEX_LL_EF_MPU MPU | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable MPU with input options | |||
* @rmtoll MPU_CTRL ENABLE LL_MPU_Enable | |||
* @param Options This parameter can be one of the following values: | |||
* @arg @ref LL_MPU_CTRL_HFNMI_PRIVDEF_NONE | |||
* @arg @ref LL_MPU_CTRL_HARDFAULT_NMI | |||
* @arg @ref LL_MPU_CTRL_PRIVILEGED_DEFAULT | |||
* @arg @ref LL_MPU_CTRL_HFNMI_PRIVDEF | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_MPU_Enable(uint32_t Options) | |||
{ | |||
/* Enable the MPU*/ | |||
WRITE_REG(MPU->CTRL, (MPU_CTRL_ENABLE_Msk | Options)); | |||
/* Ensure MPU settings take effects */ | |||
__DSB(); | |||
/* Sequence instruction fetches using update settings */ | |||
__ISB(); | |||
} | |||
/** | |||
* @brief Disable MPU | |||
* @rmtoll MPU_CTRL ENABLE LL_MPU_Disable | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_MPU_Disable(void) | |||
{ | |||
/* Make sure outstanding transfers are done */ | |||
__DMB(); | |||
/* Disable MPU*/ | |||
WRITE_REG(MPU->CTRL, 0U); | |||
} | |||
/** | |||
* @brief Check if MPU is enabled or not | |||
* @rmtoll MPU_CTRL ENABLE LL_MPU_IsEnabled | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_MPU_IsEnabled(void) | |||
{ | |||
return ((READ_BIT(MPU->CTRL, MPU_CTRL_ENABLE_Msk) == (MPU_CTRL_ENABLE_Msk)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Enable a MPU region | |||
* @rmtoll MPU_RASR ENABLE LL_MPU_EnableRegion | |||
* @param Region This parameter can be one of the following values: | |||
* @arg @ref LL_MPU_REGION_NUMBER0 | |||
* @arg @ref LL_MPU_REGION_NUMBER1 | |||
* @arg @ref LL_MPU_REGION_NUMBER2 | |||
* @arg @ref LL_MPU_REGION_NUMBER3 | |||
* @arg @ref LL_MPU_REGION_NUMBER4 | |||
* @arg @ref LL_MPU_REGION_NUMBER5 | |||
* @arg @ref LL_MPU_REGION_NUMBER6 | |||
* @arg @ref LL_MPU_REGION_NUMBER7 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_MPU_EnableRegion(uint32_t Region) | |||
{ | |||
/* Set Region number */ | |||
WRITE_REG(MPU->RNR, Region); | |||
/* Enable the MPU region */ | |||
SET_BIT(MPU->RASR, MPU_RASR_ENABLE_Msk); | |||
} | |||
/** | |||
* @brief Configure and enable a region | |||
* @rmtoll MPU_RNR REGION LL_MPU_ConfigRegion\n | |||
* MPU_RBAR REGION LL_MPU_ConfigRegion\n | |||
* MPU_RBAR ADDR LL_MPU_ConfigRegion\n | |||
* MPU_RASR XN LL_MPU_ConfigRegion\n | |||
* MPU_RASR AP LL_MPU_ConfigRegion\n | |||
* MPU_RASR S LL_MPU_ConfigRegion\n | |||
* MPU_RASR C LL_MPU_ConfigRegion\n | |||
* MPU_RASR B LL_MPU_ConfigRegion\n | |||
* MPU_RASR SIZE LL_MPU_ConfigRegion | |||
* @param Region This parameter can be one of the following values: | |||
* @arg @ref LL_MPU_REGION_NUMBER0 | |||
* @arg @ref LL_MPU_REGION_NUMBER1 | |||
* @arg @ref LL_MPU_REGION_NUMBER2 | |||
* @arg @ref LL_MPU_REGION_NUMBER3 | |||
* @arg @ref LL_MPU_REGION_NUMBER4 | |||
* @arg @ref LL_MPU_REGION_NUMBER5 | |||
* @arg @ref LL_MPU_REGION_NUMBER6 | |||
* @arg @ref LL_MPU_REGION_NUMBER7 | |||
* @param Address Value of region base address | |||
* @param SubRegionDisable Sub-region disable value between Min_Data = 0x00 and Max_Data = 0xFF | |||
* @param Attributes This parameter can be a combination of the following values: | |||
* @arg @ref LL_MPU_REGION_SIZE_32B or @ref LL_MPU_REGION_SIZE_64B or @ref LL_MPU_REGION_SIZE_128B or @ref LL_MPU_REGION_SIZE_256B or @ref LL_MPU_REGION_SIZE_512B | |||
* or @ref LL_MPU_REGION_SIZE_1KB or @ref LL_MPU_REGION_SIZE_2KB or @ref LL_MPU_REGION_SIZE_4KB or @ref LL_MPU_REGION_SIZE_8KB or @ref LL_MPU_REGION_SIZE_16KB | |||
* or @ref LL_MPU_REGION_SIZE_32KB or @ref LL_MPU_REGION_SIZE_64KB or @ref LL_MPU_REGION_SIZE_128KB or @ref LL_MPU_REGION_SIZE_256KB or @ref LL_MPU_REGION_SIZE_512KB | |||
* or @ref LL_MPU_REGION_SIZE_1MB or @ref LL_MPU_REGION_SIZE_2MB or @ref LL_MPU_REGION_SIZE_4MB or @ref LL_MPU_REGION_SIZE_8MB or @ref LL_MPU_REGION_SIZE_16MB | |||
* or @ref LL_MPU_REGION_SIZE_32MB or @ref LL_MPU_REGION_SIZE_64MB or @ref LL_MPU_REGION_SIZE_128MB or @ref LL_MPU_REGION_SIZE_256MB or @ref LL_MPU_REGION_SIZE_512MB | |||
* or @ref LL_MPU_REGION_SIZE_1GB or @ref LL_MPU_REGION_SIZE_2GB or @ref LL_MPU_REGION_SIZE_4GB | |||
* @arg @ref LL_MPU_REGION_NO_ACCESS or @ref LL_MPU_REGION_PRIV_RW or @ref LL_MPU_REGION_PRIV_RW_URO or @ref LL_MPU_REGION_FULL_ACCESS | |||
* or @ref LL_MPU_REGION_PRIV_RO or @ref LL_MPU_REGION_PRIV_RO_URO | |||
* @arg @ref LL_MPU_TEX_LEVEL0 or @ref LL_MPU_TEX_LEVEL1 or @ref LL_MPU_TEX_LEVEL2 or @ref LL_MPU_TEX_LEVEL4 | |||
* @arg @ref LL_MPU_INSTRUCTION_ACCESS_ENABLE or @ref LL_MPU_INSTRUCTION_ACCESS_DISABLE | |||
* @arg @ref LL_MPU_ACCESS_SHAREABLE or @ref LL_MPU_ACCESS_NOT_SHAREABLE | |||
* @arg @ref LL_MPU_ACCESS_CACHEABLE or @ref LL_MPU_ACCESS_NOT_CACHEABLE | |||
* @arg @ref LL_MPU_ACCESS_BUFFERABLE or @ref LL_MPU_ACCESS_NOT_BUFFERABLE | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_MPU_ConfigRegion(uint32_t Region, uint32_t SubRegionDisable, uint32_t Address, uint32_t Attributes) | |||
{ | |||
/* Set Region number */ | |||
WRITE_REG(MPU->RNR, Region); | |||
/* Set base address */ | |||
WRITE_REG(MPU->RBAR, (Address & 0xFFFFFFE0U)); | |||
/* Configure MPU */ | |||
WRITE_REG(MPU->RASR, (MPU_RASR_ENABLE_Msk | Attributes | (SubRegionDisable << MPU_RASR_SRD_Pos))); | |||
} | |||
/** | |||
* @brief Disable a region | |||
* @rmtoll MPU_RNR REGION LL_MPU_DisableRegion\n | |||
* MPU_RASR ENABLE LL_MPU_DisableRegion | |||
* @param Region This parameter can be one of the following values: | |||
* @arg @ref LL_MPU_REGION_NUMBER0 | |||
* @arg @ref LL_MPU_REGION_NUMBER1 | |||
* @arg @ref LL_MPU_REGION_NUMBER2 | |||
* @arg @ref LL_MPU_REGION_NUMBER3 | |||
* @arg @ref LL_MPU_REGION_NUMBER4 | |||
* @arg @ref LL_MPU_REGION_NUMBER5 | |||
* @arg @ref LL_MPU_REGION_NUMBER6 | |||
* @arg @ref LL_MPU_REGION_NUMBER7 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_MPU_DisableRegion(uint32_t Region) | |||
{ | |||
/* Set Region number */ | |||
WRITE_REG(MPU->RNR, Region); | |||
/* Disable the MPU region */ | |||
CLEAR_BIT(MPU->RASR, MPU_RASR_ENABLE_Msk); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
#endif /* __MPU_PRESENT */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_LL_CORTEX_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,464 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_ll_crc.h | |||
* @author MCD Application Team | |||
* @brief Header file of CRC LL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_LL_CRC_H | |||
#define STM32WBxx_LL_CRC_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx.h" | |||
/** @addtogroup STM32WBxx_LL_Driver | |||
* @{ | |||
*/ | |||
#if defined(CRC) | |||
/** @defgroup CRC_LL CRC | |||
* @{ | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup CRC_LL_Exported_Constants CRC Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup CRC_LL_EC_POLYLENGTH Polynomial length | |||
* @{ | |||
*/ | |||
#define LL_CRC_POLYLENGTH_32B 0x00000000U /*!< 32 bits Polynomial size */ | |||
#define LL_CRC_POLYLENGTH_16B CRC_CR_POLYSIZE_0 /*!< 16 bits Polynomial size */ | |||
#define LL_CRC_POLYLENGTH_8B CRC_CR_POLYSIZE_1 /*!< 8 bits Polynomial size */ | |||
#define LL_CRC_POLYLENGTH_7B (CRC_CR_POLYSIZE_1 | CRC_CR_POLYSIZE_0) /*!< 7 bits Polynomial size */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_LL_EC_INDATA_REVERSE Input Data Reverse | |||
* @{ | |||
*/ | |||
#define LL_CRC_INDATA_REVERSE_NONE 0x00000000U /*!< Input Data bit order not affected */ | |||
#define LL_CRC_INDATA_REVERSE_BYTE CRC_CR_REV_IN_0 /*!< Input Data bit reversal done by byte */ | |||
#define LL_CRC_INDATA_REVERSE_HALFWORD CRC_CR_REV_IN_1 /*!< Input Data bit reversal done by half-word */ | |||
#define LL_CRC_INDATA_REVERSE_WORD (CRC_CR_REV_IN_1 | CRC_CR_REV_IN_0) /*!< Input Data bit reversal done by word */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_LL_EC_OUTDATA_REVERSE Output Data Reverse | |||
* @{ | |||
*/ | |||
#define LL_CRC_OUTDATA_REVERSE_NONE 0x00000000U /*!< Output Data bit order not affected */ | |||
#define LL_CRC_OUTDATA_REVERSE_BIT CRC_CR_REV_OUT /*!< Output Data bit reversal done by bit */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_LL_EC_Default_Polynomial_Value Default CRC generating polynomial value | |||
* @brief Normal representation of this polynomial value is | |||
* X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 +X^8 + X^7 + X^5 + X^4 + X^2 + X + 1 . | |||
* @{ | |||
*/ | |||
#define LL_CRC_DEFAULT_CRC32_POLY 0x04C11DB7U /*!< Default CRC generating polynomial value */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_LL_EC_Default_InitValue Default CRC computation initialization value | |||
* @{ | |||
*/ | |||
#define LL_CRC_DEFAULT_CRC_INITVALUE 0xFFFFFFFFU /*!< Default CRC computation initialization value */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup CRC_LL_Exported_Macros CRC Exported Macros | |||
* @{ | |||
*/ | |||
/** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Write a value in CRC register | |||
* @param __INSTANCE__ CRC Instance | |||
* @param __REG__ Register to be written | |||
* @param __VALUE__ Value to be written in the register | |||
* @retval None | |||
*/ | |||
#define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, __VALUE__) | |||
/** | |||
* @brief Read a value in CRC register | |||
* @param __INSTANCE__ CRC Instance | |||
* @param __REG__ Register to be read | |||
* @retval Register value | |||
*/ | |||
#define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup CRC_LL_Exported_Functions CRC Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup CRC_LL_EF_Configuration CRC Configuration functions | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Reset the CRC calculation unit. | |||
* @note If Programmable Initial CRC value feature | |||
* is available, also set the Data Register to the value stored in the | |||
* CRC_INIT register, otherwise, reset Data Register to its default value. | |||
* @rmtoll CR RESET LL_CRC_ResetCRCCalculationUnit | |||
* @param CRCx CRC Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx) | |||
{ | |||
SET_BIT(CRCx->CR, CRC_CR_RESET); | |||
} | |||
/** | |||
* @brief Configure size of the polynomial. | |||
* @rmtoll CR POLYSIZE LL_CRC_SetPolynomialSize | |||
* @param CRCx CRC Instance | |||
* @param PolySize This parameter can be one of the following values: | |||
* @arg @ref LL_CRC_POLYLENGTH_32B | |||
* @arg @ref LL_CRC_POLYLENGTH_16B | |||
* @arg @ref LL_CRC_POLYLENGTH_8B | |||
* @arg @ref LL_CRC_POLYLENGTH_7B | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRC_SetPolynomialSize(CRC_TypeDef *CRCx, uint32_t PolySize) | |||
{ | |||
MODIFY_REG(CRCx->CR, CRC_CR_POLYSIZE, PolySize); | |||
} | |||
/** | |||
* @brief Return size of the polynomial. | |||
* @rmtoll CR POLYSIZE LL_CRC_GetPolynomialSize | |||
* @param CRCx CRC Instance | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_CRC_POLYLENGTH_32B | |||
* @arg @ref LL_CRC_POLYLENGTH_16B | |||
* @arg @ref LL_CRC_POLYLENGTH_8B | |||
* @arg @ref LL_CRC_POLYLENGTH_7B | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRC_GetPolynomialSize(CRC_TypeDef *CRCx) | |||
{ | |||
return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_POLYSIZE)); | |||
} | |||
/** | |||
* @brief Configure the reversal of the bit order of the input data | |||
* @rmtoll CR REV_IN LL_CRC_SetInputDataReverseMode | |||
* @param CRCx CRC Instance | |||
* @param ReverseMode This parameter can be one of the following values: | |||
* @arg @ref LL_CRC_INDATA_REVERSE_NONE | |||
* @arg @ref LL_CRC_INDATA_REVERSE_BYTE | |||
* @arg @ref LL_CRC_INDATA_REVERSE_HALFWORD | |||
* @arg @ref LL_CRC_INDATA_REVERSE_WORD | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRC_SetInputDataReverseMode(CRC_TypeDef *CRCx, uint32_t ReverseMode) | |||
{ | |||
MODIFY_REG(CRCx->CR, CRC_CR_REV_IN, ReverseMode); | |||
} | |||
/** | |||
* @brief Return type of reversal for input data bit order | |||
* @rmtoll CR REV_IN LL_CRC_GetInputDataReverseMode | |||
* @param CRCx CRC Instance | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_CRC_INDATA_REVERSE_NONE | |||
* @arg @ref LL_CRC_INDATA_REVERSE_BYTE | |||
* @arg @ref LL_CRC_INDATA_REVERSE_HALFWORD | |||
* @arg @ref LL_CRC_INDATA_REVERSE_WORD | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRC_GetInputDataReverseMode(CRC_TypeDef *CRCx) | |||
{ | |||
return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_REV_IN)); | |||
} | |||
/** | |||
* @brief Configure the reversal of the bit order of the Output data | |||
* @rmtoll CR REV_OUT LL_CRC_SetOutputDataReverseMode | |||
* @param CRCx CRC Instance | |||
* @param ReverseMode This parameter can be one of the following values: | |||
* @arg @ref LL_CRC_OUTDATA_REVERSE_NONE | |||
* @arg @ref LL_CRC_OUTDATA_REVERSE_BIT | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRC_SetOutputDataReverseMode(CRC_TypeDef *CRCx, uint32_t ReverseMode) | |||
{ | |||
MODIFY_REG(CRCx->CR, CRC_CR_REV_OUT, ReverseMode); | |||
} | |||
/** | |||
* @brief Configure the reversal of the bit order of the Output data | |||
* @rmtoll CR REV_OUT LL_CRC_GetOutputDataReverseMode | |||
* @param CRCx CRC Instance | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_CRC_OUTDATA_REVERSE_NONE | |||
* @arg @ref LL_CRC_OUTDATA_REVERSE_BIT | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRC_GetOutputDataReverseMode(CRC_TypeDef *CRCx) | |||
{ | |||
return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_REV_OUT)); | |||
} | |||
/** | |||
* @brief Initialize the Programmable initial CRC value. | |||
* @note If the CRC size is less than 32 bits, the least significant bits | |||
* are used to write the correct value | |||
* @note LL_CRC_DEFAULT_CRC_INITVALUE could be used as value for InitCrc parameter. | |||
* @rmtoll INIT INIT LL_CRC_SetInitialData | |||
* @param CRCx CRC Instance | |||
* @param InitCrc Value to be programmed in Programmable initial CRC value register | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRC_SetInitialData(CRC_TypeDef *CRCx, uint32_t InitCrc) | |||
{ | |||
WRITE_REG(CRCx->INIT, InitCrc); | |||
} | |||
/** | |||
* @brief Return current Initial CRC value. | |||
* @note If the CRC size is less than 32 bits, the least significant bits | |||
* are used to read the correct value | |||
* @rmtoll INIT INIT LL_CRC_GetInitialData | |||
* @param CRCx CRC Instance | |||
* @retval Value programmed in Programmable initial CRC value register | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRC_GetInitialData(CRC_TypeDef *CRCx) | |||
{ | |||
return (uint32_t)(READ_REG(CRCx->INIT)); | |||
} | |||
/** | |||
* @brief Initialize the Programmable polynomial value | |||
* (coefficients of the polynomial to be used for CRC calculation). | |||
* @note LL_CRC_DEFAULT_CRC32_POLY could be used as value for PolynomCoef parameter. | |||
* @note Please check Reference Manual and existing Errata Sheets, | |||
* regarding possible limitations for Polynomial values usage. | |||
* For example, for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65 | |||
* @rmtoll POL POL LL_CRC_SetPolynomialCoef | |||
* @param CRCx CRC Instance | |||
* @param PolynomCoef Value to be programmed in Programmable Polynomial value register | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRC_SetPolynomialCoef(CRC_TypeDef *CRCx, uint32_t PolynomCoef) | |||
{ | |||
WRITE_REG(CRCx->POL, PolynomCoef); | |||
} | |||
/** | |||
* @brief Return current Programmable polynomial value | |||
* @note Please check Reference Manual and existing Errata Sheets, | |||
* regarding possible limitations for Polynomial values usage. | |||
* For example, for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65 | |||
* @rmtoll POL POL LL_CRC_GetPolynomialCoef | |||
* @param CRCx CRC Instance | |||
* @retval Value programmed in Programmable Polynomial value register | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRC_GetPolynomialCoef(CRC_TypeDef *CRCx) | |||
{ | |||
return (uint32_t)(READ_REG(CRCx->POL)); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_LL_EF_Data_Management Data_Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Write given 32-bit data to the CRC calculator | |||
* @rmtoll DR DR LL_CRC_FeedData32 | |||
* @param CRCx CRC Instance | |||
* @param InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData) | |||
{ | |||
WRITE_REG(CRCx->DR, InData); | |||
} | |||
/** | |||
* @brief Write given 16-bit data to the CRC calculator | |||
* @rmtoll DR DR LL_CRC_FeedData16 | |||
* @param CRCx CRC Instance | |||
* @param InData 16 bit value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFF | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRC_FeedData16(CRC_TypeDef *CRCx, uint16_t InData) | |||
{ | |||
__IO uint16_t *pReg; | |||
pReg = (__IO uint16_t *)(__IO void *)(&CRCx->DR); /* Derogation MisraC2012 R.11.5 */ | |||
*pReg = InData; | |||
} | |||
/** | |||
* @brief Write given 8-bit data to the CRC calculator | |||
* @rmtoll DR DR LL_CRC_FeedData8 | |||
* @param CRCx CRC Instance | |||
* @param InData 8 bit value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFF | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRC_FeedData8(CRC_TypeDef *CRCx, uint8_t InData) | |||
{ | |||
*(uint8_t __IO *)(&CRCx->DR) = (uint8_t) InData; | |||
} | |||
/** | |||
* @brief Return current CRC calculation result. 32 bits value is returned. | |||
* @rmtoll DR DR LL_CRC_ReadData32 | |||
* @param CRCx CRC Instance | |||
* @retval Current CRC calculation result as stored in CRC_DR register (32 bits). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx) | |||
{ | |||
return (uint32_t)(READ_REG(CRCx->DR)); | |||
} | |||
/** | |||
* @brief Return current CRC calculation result. 16 bits value is returned. | |||
* @note This function is expected to be used in a 16 bits CRC polynomial size context. | |||
* @rmtoll DR DR LL_CRC_ReadData16 | |||
* @param CRCx CRC Instance | |||
* @retval Current CRC calculation result as stored in CRC_DR register (16 bits). | |||
*/ | |||
__STATIC_INLINE uint16_t LL_CRC_ReadData16(CRC_TypeDef *CRCx) | |||
{ | |||
return (uint16_t)READ_REG(CRCx->DR); | |||
} | |||
/** | |||
* @brief Return current CRC calculation result. 8 bits value is returned. | |||
* @note This function is expected to be used in a 8 bits CRC polynomial size context. | |||
* @rmtoll DR DR LL_CRC_ReadData8 | |||
* @param CRCx CRC Instance | |||
* @retval Current CRC calculation result as stored in CRC_DR register (8 bits). | |||
*/ | |||
__STATIC_INLINE uint8_t LL_CRC_ReadData8(CRC_TypeDef *CRCx) | |||
{ | |||
return (uint8_t)READ_REG(CRCx->DR); | |||
} | |||
/** | |||
* @brief Return current CRC calculation result. 7 bits value is returned. | |||
* @note This function is expected to be used in a 7 bits CRC polynomial size context. | |||
* @rmtoll DR DR LL_CRC_ReadData7 | |||
* @param CRCx CRC Instance | |||
* @retval Current CRC calculation result as stored in CRC_DR register (7 bits). | |||
*/ | |||
__STATIC_INLINE uint8_t LL_CRC_ReadData7(CRC_TypeDef *CRCx) | |||
{ | |||
return (uint8_t)(READ_REG(CRCx->DR) & 0x7FU); | |||
} | |||
/** | |||
* @brief Return data stored in the Independent Data(IDR) register. | |||
* @note This register can be used as a temporary storage location for one 32-bit long data. | |||
* @rmtoll IDR IDR LL_CRC_Read_IDR | |||
* @param CRCx CRC Instance | |||
* @retval Value stored in CRC_IDR register (General-purpose 32-bit data register). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx) | |||
{ | |||
return (uint32_t)(READ_REG(CRCx->IDR)); | |||
} | |||
/** | |||
* @brief Store data in the Independent Data(IDR) register. | |||
* @note This register can be used as a temporary storage location for one 32-bit long data. | |||
* @rmtoll IDR IDR LL_CRC_Write_IDR | |||
* @param CRCx CRC Instance | |||
* @param InData value to be stored in CRC_IDR register (32-bit) between Min_Data=0 and Max_Data=0xFFFFFFFF | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData) | |||
{ | |||
*((uint32_t __IO *)(&CRCx->IDR)) = (uint32_t) InData; | |||
} | |||
/** | |||
* @} | |||
*/ | |||
#if defined(USE_FULL_LL_DRIVER) | |||
/** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx); | |||
/** | |||
* @} | |||
*/ | |||
#endif /* USE_FULL_LL_DRIVER */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* defined(CRC) */ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_LL_CRC_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,798 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_ll_crs.h | |||
* @author MCD Application Team | |||
* @brief Header file of CRS LL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_LL_CRS_H | |||
#define STM32WBxx_LL_CRS_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx.h" | |||
/** @addtogroup STM32WBxx_LL_Driver | |||
* @{ | |||
*/ | |||
#if defined(CRS) | |||
/** @defgroup CRS_LL CRS | |||
* @{ | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/** @defgroup CRS_LL_Private_Constants CRS Private Constants | |||
* @{ | |||
*/ | |||
/* Defines used for the bit position in the register and perform offsets*/ | |||
#define CRS_POSITION_TRIM (CRS_CR_TRIM_Pos) /* bit position in CR reg */ | |||
#define CRS_POSITION_FECAP (CRS_ISR_FECAP_Pos) /* bit position in ISR reg */ | |||
#define CRS_POSITION_FELIM (CRS_CFGR_FELIM_Pos) /* bit position in CFGR reg */ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup CRS_LL_Exported_Constants CRS Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup CRS_LL_EC_GET_FLAG Get Flags Defines | |||
* @brief Flags defines which can be used with LL_CRS_ReadReg function | |||
* @{ | |||
*/ | |||
#define LL_CRS_ISR_SYNCOKF CRS_ISR_SYNCOKF | |||
#define LL_CRS_ISR_SYNCWARNF CRS_ISR_SYNCWARNF | |||
#define LL_CRS_ISR_ERRF CRS_ISR_ERRF | |||
#define LL_CRS_ISR_ESYNCF CRS_ISR_ESYNCF | |||
#define LL_CRS_ISR_SYNCERR CRS_ISR_SYNCERR | |||
#define LL_CRS_ISR_SYNCMISS CRS_ISR_SYNCMISS | |||
#define LL_CRS_ISR_TRIMOVF CRS_ISR_TRIMOVF | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRS_LL_EC_IT IT Defines | |||
* @brief IT defines which can be used with LL_CRS_ReadReg and LL_CRS_WriteReg functions | |||
* @{ | |||
*/ | |||
#define LL_CRS_CR_SYNCOKIE CRS_CR_SYNCOKIE | |||
#define LL_CRS_CR_SYNCWARNIE CRS_CR_SYNCWARNIE | |||
#define LL_CRS_CR_ERRIE CRS_CR_ERRIE | |||
#define LL_CRS_CR_ESYNCIE CRS_CR_ESYNCIE | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRS_LL_EC_SYNC_DIV Synchronization Signal Divider | |||
* @{ | |||
*/ | |||
#define LL_CRS_SYNC_DIV_1 0x00000000U /*!< Synchro Signal not divided (default) */ | |||
#define LL_CRS_SYNC_DIV_2 CRS_CFGR_SYNCDIV_0 /*!< Synchro Signal divided by 2 */ | |||
#define LL_CRS_SYNC_DIV_4 CRS_CFGR_SYNCDIV_1 /*!< Synchro Signal divided by 4 */ | |||
#define LL_CRS_SYNC_DIV_8 (CRS_CFGR_SYNCDIV_1 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 8 */ | |||
#define LL_CRS_SYNC_DIV_16 CRS_CFGR_SYNCDIV_2 /*!< Synchro Signal divided by 16 */ | |||
#define LL_CRS_SYNC_DIV_32 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 32 */ | |||
#define LL_CRS_SYNC_DIV_64 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_1) /*!< Synchro Signal divided by 64 */ | |||
#define LL_CRS_SYNC_DIV_128 CRS_CFGR_SYNCDIV /*!< Synchro Signal divided by 128 */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRS_LL_EC_SYNC_SOURCE Synchronization Signal Source | |||
* @{ | |||
*/ | |||
#define LL_CRS_SYNC_SOURCE_GPIO 0x00000000U /*!< Synchro Signal soucre GPIO */ | |||
#define LL_CRS_SYNC_SOURCE_LSE CRS_CFGR_SYNCSRC_0 /*!< Synchro Signal source LSE */ | |||
#define LL_CRS_SYNC_SOURCE_USB CRS_CFGR_SYNCSRC_1 /*!< Synchro Signal source USB SOF (default)*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRS_LL_EC_SYNC_POLARITY Synchronization Signal Polarity | |||
* @{ | |||
*/ | |||
#define LL_CRS_SYNC_POLARITY_RISING 0x00000000U /*!< Synchro Active on rising edge (default) */ | |||
#define LL_CRS_SYNC_POLARITY_FALLING CRS_CFGR_SYNCPOL /*!< Synchro Active on falling edge */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRS_LL_EC_FREQERRORDIR Frequency Error Direction | |||
* @{ | |||
*/ | |||
#define LL_CRS_FREQ_ERROR_DIR_UP 0x00000000U /*!< Upcounting direction, the actual frequency is above the target */ | |||
#define LL_CRS_FREQ_ERROR_DIR_DOWN CRS_ISR_FEDIR /*!< Downcounting direction, the actual frequency is below the target */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRS_LL_EC_DEFAULTVALUES Default Values | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Reset value of the RELOAD field | |||
* @note The reset value of the RELOAD field corresponds to a target frequency of 48 MHz | |||
* and a synchronization signal frequency of 1 kHz (SOF signal from USB) | |||
*/ | |||
#define LL_CRS_RELOADVALUE_DEFAULT 0x0000BB7FU | |||
/** | |||
* @brief Reset value of Frequency error limit. | |||
*/ | |||
#define LL_CRS_ERRORLIMIT_DEFAULT 0x00000022U | |||
/** | |||
* @brief Reset value of the HSI48 Calibration field | |||
* @note The default value is 32, which corresponds to the middle of the trimming interval. | |||
* The trimming step is around 67 kHz between two consecutive TRIM steps. | |||
* A higher TRIM value corresponds to a higher output frequency | |||
*/ | |||
#define LL_CRS_HSI48CALIBRATION_DEFAULT 0x00000020U | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup CRS_LL_Exported_Macros CRS Exported Macros | |||
* @{ | |||
*/ | |||
/** @defgroup CRS_LL_EM_WRITE_READ Common Write and read registers Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Write a value in CRS register | |||
* @param __INSTANCE__ CRS Instance | |||
* @param __REG__ Register to be written | |||
* @param __VALUE__ Value to be written in the register | |||
* @retval None | |||
*/ | |||
#define LL_CRS_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) | |||
/** | |||
* @brief Read a value in CRS register | |||
* @param __INSTANCE__ CRS Instance | |||
* @param __REG__ Register to be read | |||
* @retval Register value | |||
*/ | |||
#define LL_CRS_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRS_LL_EM_Exported_Macros_Calculate_Reload Exported_Macros_Calculate_Reload | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Macro to calculate reload value to be set in CRS register according to target and sync frequencies | |||
* @note The RELOAD value should be selected according to the ratio between | |||
* the target frequency and the frequency of the synchronization source after | |||
* prescaling. It is then decreased by one in order to reach the expected | |||
* synchronization on the zero value. The formula is the following: | |||
* RELOAD = (fTARGET / fSYNC) -1 | |||
* @param __FTARGET__ Target frequency (value in Hz) | |||
* @param __FSYNC__ Synchronization signal frequency (value in Hz) | |||
* @retval Reload value (in Hz) | |||
*/ | |||
#define __LL_CRS_CALC_CALCULATE_RELOADVALUE(__FTARGET__, __FSYNC__) (((__FTARGET__) / (__FSYNC__)) - 1U) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup CRS_LL_Exported_Functions CRS Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup CRS_LL_EF_Configuration Configuration | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable Frequency error counter | |||
* @note When this bit is set, the CRS_CFGR register is write-protected and cannot be modified | |||
* @rmtoll CR CEN LL_CRS_EnableFreqErrorCounter | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_EnableFreqErrorCounter(void) | |||
{ | |||
SET_BIT(CRS->CR, CRS_CR_CEN); | |||
} | |||
/** | |||
* @brief Disable Frequency error counter | |||
* @rmtoll CR CEN LL_CRS_DisableFreqErrorCounter | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_DisableFreqErrorCounter(void) | |||
{ | |||
CLEAR_BIT(CRS->CR, CRS_CR_CEN); | |||
} | |||
/** | |||
* @brief Check if Frequency error counter is enabled or not | |||
* @rmtoll CR CEN LL_CRS_IsEnabledFreqErrorCounter | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_IsEnabledFreqErrorCounter(void) | |||
{ | |||
return ((READ_BIT(CRS->CR, CRS_CR_CEN) == (CRS_CR_CEN)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Enable Automatic trimming counter | |||
* @rmtoll CR AUTOTRIMEN LL_CRS_EnableAutoTrimming | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_EnableAutoTrimming(void) | |||
{ | |||
SET_BIT(CRS->CR, CRS_CR_AUTOTRIMEN); | |||
} | |||
/** | |||
* @brief Disable Automatic trimming counter | |||
* @rmtoll CR AUTOTRIMEN LL_CRS_DisableAutoTrimming | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_DisableAutoTrimming(void) | |||
{ | |||
CLEAR_BIT(CRS->CR, CRS_CR_AUTOTRIMEN); | |||
} | |||
/** | |||
* @brief Check if Automatic trimming is enabled or not | |||
* @rmtoll CR AUTOTRIMEN LL_CRS_IsEnabledAutoTrimming | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_IsEnabledAutoTrimming(void) | |||
{ | |||
return ((READ_BIT(CRS->CR, CRS_CR_AUTOTRIMEN) == (CRS_CR_AUTOTRIMEN)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Set HSI48 oscillator smooth trimming | |||
* @note When the AUTOTRIMEN bit is set, this field is controlled by hardware and is read-only | |||
* @rmtoll CR TRIM LL_CRS_SetHSI48SmoothTrimming | |||
* @param Value a number between Min_Data = 0 and Max_Data = 63 | |||
* @note Default value can be set thanks to @ref LL_CRS_HSI48CALIBRATION_DEFAULT | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_SetHSI48SmoothTrimming(uint32_t Value) | |||
{ | |||
MODIFY_REG(CRS->CR, CRS_CR_TRIM, Value << CRS_POSITION_TRIM); | |||
} | |||
/** | |||
* @brief Get HSI48 oscillator smooth trimming | |||
* @rmtoll CR TRIM LL_CRS_GetHSI48SmoothTrimming | |||
* @retval a number between Min_Data = 0 and Max_Data = 63 | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_GetHSI48SmoothTrimming(void) | |||
{ | |||
return (uint32_t)(READ_BIT(CRS->CR, CRS_CR_TRIM) >> CRS_POSITION_TRIM); | |||
} | |||
/** | |||
* @brief Set counter reload value | |||
* @rmtoll CFGR RELOAD LL_CRS_SetReloadCounter | |||
* @param Value a number between Min_Data = 0 and Max_Data = 0xFFFF | |||
* @note Default value can be set thanks to @ref LL_CRS_RELOADVALUE_DEFAULT | |||
* Otherwise it can be calculated in using macro @ref __LL_CRS_CALC_CALCULATE_RELOADVALUE (_FTARGET_, _FSYNC_) | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_SetReloadCounter(uint32_t Value) | |||
{ | |||
MODIFY_REG(CRS->CFGR, CRS_CFGR_RELOAD, Value); | |||
} | |||
/** | |||
* @brief Get counter reload value | |||
* @rmtoll CFGR RELOAD LL_CRS_GetReloadCounter | |||
* @retval a number between Min_Data = 0 and Max_Data = 0xFFFF | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_GetReloadCounter(void) | |||
{ | |||
return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_RELOAD)); | |||
} | |||
/** | |||
* @brief Set frequency error limit | |||
* @rmtoll CFGR FELIM LL_CRS_SetFreqErrorLimit | |||
* @param Value a number between Min_Data = 0 and Max_Data = 255 | |||
* @note Default value can be set thanks to @ref LL_CRS_ERRORLIMIT_DEFAULT | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_SetFreqErrorLimit(uint32_t Value) | |||
{ | |||
MODIFY_REG(CRS->CFGR, CRS_CFGR_FELIM, Value << CRS_POSITION_FELIM); | |||
} | |||
/** | |||
* @brief Get frequency error limit | |||
* @rmtoll CFGR FELIM LL_CRS_GetFreqErrorLimit | |||
* @retval A number between Min_Data = 0 and Max_Data = 255 | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorLimit(void) | |||
{ | |||
return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_FELIM) >> CRS_POSITION_FELIM); | |||
} | |||
/** | |||
* @brief Set division factor for SYNC signal | |||
* @rmtoll CFGR SYNCDIV LL_CRS_SetSyncDivider | |||
* @param Divider This parameter can be one of the following values: | |||
* @arg @ref LL_CRS_SYNC_DIV_1 | |||
* @arg @ref LL_CRS_SYNC_DIV_2 | |||
* @arg @ref LL_CRS_SYNC_DIV_4 | |||
* @arg @ref LL_CRS_SYNC_DIV_8 | |||
* @arg @ref LL_CRS_SYNC_DIV_16 | |||
* @arg @ref LL_CRS_SYNC_DIV_32 | |||
* @arg @ref LL_CRS_SYNC_DIV_64 | |||
* @arg @ref LL_CRS_SYNC_DIV_128 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_SetSyncDivider(uint32_t Divider) | |||
{ | |||
MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCDIV, Divider); | |||
} | |||
/** | |||
* @brief Get division factor for SYNC signal | |||
* @rmtoll CFGR SYNCDIV LL_CRS_GetSyncDivider | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_CRS_SYNC_DIV_1 | |||
* @arg @ref LL_CRS_SYNC_DIV_2 | |||
* @arg @ref LL_CRS_SYNC_DIV_4 | |||
* @arg @ref LL_CRS_SYNC_DIV_8 | |||
* @arg @ref LL_CRS_SYNC_DIV_16 | |||
* @arg @ref LL_CRS_SYNC_DIV_32 | |||
* @arg @ref LL_CRS_SYNC_DIV_64 | |||
* @arg @ref LL_CRS_SYNC_DIV_128 | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_GetSyncDivider(void) | |||
{ | |||
return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCDIV)); | |||
} | |||
/** | |||
* @brief Set SYNC signal source | |||
* @rmtoll CFGR SYNCSRC LL_CRS_SetSyncSignalSource | |||
* @param Source This parameter can be one of the following values: | |||
* @arg @ref LL_CRS_SYNC_SOURCE_GPIO | |||
* @arg @ref LL_CRS_SYNC_SOURCE_LSE | |||
* @arg @ref LL_CRS_SYNC_SOURCE_USB | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_SetSyncSignalSource(uint32_t Source) | |||
{ | |||
MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCSRC, Source); | |||
} | |||
/** | |||
* @brief Get SYNC signal source | |||
* @rmtoll CFGR SYNCSRC LL_CRS_GetSyncSignalSource | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_CRS_SYNC_SOURCE_GPIO | |||
* @arg @ref LL_CRS_SYNC_SOURCE_LSE | |||
* @arg @ref LL_CRS_SYNC_SOURCE_USB | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_GetSyncSignalSource(void) | |||
{ | |||
return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCSRC)); | |||
} | |||
/** | |||
* @brief Set input polarity for the SYNC signal source | |||
* @rmtoll CFGR SYNCPOL LL_CRS_SetSyncPolarity | |||
* @param Polarity This parameter can be one of the following values: | |||
* @arg @ref LL_CRS_SYNC_POLARITY_RISING | |||
* @arg @ref LL_CRS_SYNC_POLARITY_FALLING | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_SetSyncPolarity(uint32_t Polarity) | |||
{ | |||
MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCPOL, Polarity); | |||
} | |||
/** | |||
* @brief Get input polarity for the SYNC signal source | |||
* @rmtoll CFGR SYNCPOL LL_CRS_GetSyncPolarity | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_CRS_SYNC_POLARITY_RISING | |||
* @arg @ref LL_CRS_SYNC_POLARITY_FALLING | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_GetSyncPolarity(void) | |||
{ | |||
return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCPOL)); | |||
} | |||
/** | |||
* @brief Configure CRS for the synchronization | |||
* @rmtoll CR TRIM LL_CRS_ConfigSynchronization\n | |||
* CFGR RELOAD LL_CRS_ConfigSynchronization\n | |||
* CFGR FELIM LL_CRS_ConfigSynchronization\n | |||
* CFGR SYNCDIV LL_CRS_ConfigSynchronization\n | |||
* CFGR SYNCSRC LL_CRS_ConfigSynchronization\n | |||
* CFGR SYNCPOL LL_CRS_ConfigSynchronization | |||
* @param HSI48CalibrationValue a number between Min_Data = 0 and Max_Data = 63 | |||
* @param ErrorLimitValue a number between Min_Data = 0 and Max_Data = 0xFFFF | |||
* @param ReloadValue a number between Min_Data = 0 and Max_Data = 255 | |||
* @param Settings This parameter can be a combination of the following values: | |||
* @arg @ref LL_CRS_SYNC_DIV_1 or @ref LL_CRS_SYNC_DIV_2 or @ref LL_CRS_SYNC_DIV_4 or @ref LL_CRS_SYNC_DIV_8 | |||
* or @ref LL_CRS_SYNC_DIV_16 or @ref LL_CRS_SYNC_DIV_32 or @ref LL_CRS_SYNC_DIV_64 or @ref LL_CRS_SYNC_DIV_128 | |||
* @arg @ref LL_CRS_SYNC_SOURCE_GPIO or @ref LL_CRS_SYNC_SOURCE_LSE or @ref LL_CRS_SYNC_SOURCE_USB | |||
* @arg @ref LL_CRS_SYNC_POLARITY_RISING or @ref LL_CRS_SYNC_POLARITY_FALLING | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_ConfigSynchronization(uint32_t HSI48CalibrationValue, uint32_t ErrorLimitValue, uint32_t ReloadValue, uint32_t Settings) | |||
{ | |||
MODIFY_REG(CRS->CR, CRS_CR_TRIM, HSI48CalibrationValue); | |||
MODIFY_REG(CRS->CFGR, | |||
CRS_CFGR_RELOAD | CRS_CFGR_FELIM | CRS_CFGR_SYNCDIV | CRS_CFGR_SYNCSRC | CRS_CFGR_SYNCPOL, | |||
ReloadValue | (ErrorLimitValue << CRS_POSITION_FELIM) | Settings); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRS_LL_EF_CRS_Management CRS_Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Generate software SYNC event | |||
* @rmtoll CR SWSYNC LL_CRS_GenerateEvent_SWSYNC | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_GenerateEvent_SWSYNC(void) | |||
{ | |||
SET_BIT(CRS->CR, CRS_CR_SWSYNC); | |||
} | |||
/** | |||
* @brief Get the frequency error direction latched in the time of the last | |||
* SYNC event | |||
* @rmtoll ISR FEDIR LL_CRS_GetFreqErrorDirection | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_CRS_FREQ_ERROR_DIR_UP | |||
* @arg @ref LL_CRS_FREQ_ERROR_DIR_DOWN | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorDirection(void) | |||
{ | |||
return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FEDIR)); | |||
} | |||
/** | |||
* @brief Get the frequency error counter value latched in the time of the last SYNC event | |||
* @rmtoll ISR FECAP LL_CRS_GetFreqErrorCapture | |||
* @retval A number between Min_Data = 0x0000 and Max_Data = 0xFFFF | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorCapture(void) | |||
{ | |||
return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FECAP) >> CRS_POSITION_FECAP); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRS_LL_EF_FLAG_Management FLAG_Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Check if SYNC event OK signal occurred or not | |||
* @rmtoll ISR SYNCOKF LL_CRS_IsActiveFlag_SYNCOK | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCOK(void) | |||
{ | |||
return ((READ_BIT(CRS->ISR, CRS_ISR_SYNCOKF) == (CRS_ISR_SYNCOKF)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Check if SYNC warning signal occurred or not | |||
* @rmtoll ISR SYNCWARNF LL_CRS_IsActiveFlag_SYNCWARN | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCWARN(void) | |||
{ | |||
return ((READ_BIT(CRS->ISR, CRS_ISR_SYNCWARNF) == (CRS_ISR_SYNCWARNF)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Check if Synchronization or trimming error signal occurred or not | |||
* @rmtoll ISR ERRF LL_CRS_IsActiveFlag_ERR | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ERR(void) | |||
{ | |||
return ((READ_BIT(CRS->ISR, CRS_ISR_ERRF) == (CRS_ISR_ERRF)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Check if Expected SYNC signal occurred or not | |||
* @rmtoll ISR ESYNCF LL_CRS_IsActiveFlag_ESYNC | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ESYNC(void) | |||
{ | |||
return ((READ_BIT(CRS->ISR, CRS_ISR_ESYNCF) == (CRS_ISR_ESYNCF)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Check if SYNC error signal occurred or not | |||
* @rmtoll ISR SYNCERR LL_CRS_IsActiveFlag_SYNCERR | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCERR(void) | |||
{ | |||
return ((READ_BIT(CRS->ISR, CRS_ISR_SYNCERR) == (CRS_ISR_SYNCERR)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Check if SYNC missed error signal occurred or not | |||
* @rmtoll ISR SYNCMISS LL_CRS_IsActiveFlag_SYNCMISS | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCMISS(void) | |||
{ | |||
return ((READ_BIT(CRS->ISR, CRS_ISR_SYNCMISS) == (CRS_ISR_SYNCMISS)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Check if Trimming overflow or underflow occurred or not | |||
* @rmtoll ISR TRIMOVF LL_CRS_IsActiveFlag_TRIMOVF | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_TRIMOVF(void) | |||
{ | |||
return ((READ_BIT(CRS->ISR, CRS_ISR_TRIMOVF) == (CRS_ISR_TRIMOVF)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Clear the SYNC event OK flag | |||
* @rmtoll ICR SYNCOKC LL_CRS_ClearFlag_SYNCOK | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_ClearFlag_SYNCOK(void) | |||
{ | |||
WRITE_REG(CRS->ICR, CRS_ICR_SYNCOKC); | |||
} | |||
/** | |||
* @brief Clear the SYNC warning flag | |||
* @rmtoll ICR SYNCWARNC LL_CRS_ClearFlag_SYNCWARN | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_ClearFlag_SYNCWARN(void) | |||
{ | |||
WRITE_REG(CRS->ICR, CRS_ICR_SYNCWARNC); | |||
} | |||
/** | |||
* @brief Clear TRIMOVF, SYNCMISS and SYNCERR bits and consequently also | |||
* the ERR flag | |||
* @rmtoll ICR ERRC LL_CRS_ClearFlag_ERR | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_ClearFlag_ERR(void) | |||
{ | |||
WRITE_REG(CRS->ICR, CRS_ICR_ERRC); | |||
} | |||
/** | |||
* @brief Clear Expected SYNC flag | |||
* @rmtoll ICR ESYNCC LL_CRS_ClearFlag_ESYNC | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_ClearFlag_ESYNC(void) | |||
{ | |||
WRITE_REG(CRS->ICR, CRS_ICR_ESYNCC); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRS_LL_EF_IT_Management IT_Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable SYNC event OK interrupt | |||
* @rmtoll CR SYNCOKIE LL_CRS_EnableIT_SYNCOK | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_EnableIT_SYNCOK(void) | |||
{ | |||
SET_BIT(CRS->CR, CRS_CR_SYNCOKIE); | |||
} | |||
/** | |||
* @brief Disable SYNC event OK interrupt | |||
* @rmtoll CR SYNCOKIE LL_CRS_DisableIT_SYNCOK | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_DisableIT_SYNCOK(void) | |||
{ | |||
CLEAR_BIT(CRS->CR, CRS_CR_SYNCOKIE); | |||
} | |||
/** | |||
* @brief Check if SYNC event OK interrupt is enabled or not | |||
* @rmtoll CR SYNCOKIE LL_CRS_IsEnabledIT_SYNCOK | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCOK(void) | |||
{ | |||
return ((READ_BIT(CRS->CR, CRS_CR_SYNCOKIE) == (CRS_CR_SYNCOKIE)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Enable SYNC warning interrupt | |||
* @rmtoll CR SYNCWARNIE LL_CRS_EnableIT_SYNCWARN | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_EnableIT_SYNCWARN(void) | |||
{ | |||
SET_BIT(CRS->CR, CRS_CR_SYNCWARNIE); | |||
} | |||
/** | |||
* @brief Disable SYNC warning interrupt | |||
* @rmtoll CR SYNCWARNIE LL_CRS_DisableIT_SYNCWARN | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_DisableIT_SYNCWARN(void) | |||
{ | |||
CLEAR_BIT(CRS->CR, CRS_CR_SYNCWARNIE); | |||
} | |||
/** | |||
* @brief Check if SYNC warning interrupt is enabled or not | |||
* @rmtoll CR SYNCWARNIE LL_CRS_IsEnabledIT_SYNCWARN | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCWARN(void) | |||
{ | |||
return ((READ_BIT(CRS->CR, CRS_CR_SYNCWARNIE) == (CRS_CR_SYNCWARNIE)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Enable Synchronization or trimming error interrupt | |||
* @rmtoll CR ERRIE LL_CRS_EnableIT_ERR | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_EnableIT_ERR(void) | |||
{ | |||
SET_BIT(CRS->CR, CRS_CR_ERRIE); | |||
} | |||
/** | |||
* @brief Disable Synchronization or trimming error interrupt | |||
* @rmtoll CR ERRIE LL_CRS_DisableIT_ERR | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_DisableIT_ERR(void) | |||
{ | |||
CLEAR_BIT(CRS->CR, CRS_CR_ERRIE); | |||
} | |||
/** | |||
* @brief Check if Synchronization or trimming error interrupt is enabled or not | |||
* @rmtoll CR ERRIE LL_CRS_IsEnabledIT_ERR | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ERR(void) | |||
{ | |||
return ((READ_BIT(CRS->CR, CRS_CR_ERRIE) == (CRS_CR_ERRIE)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Enable Expected SYNC interrupt | |||
* @rmtoll CR ESYNCIE LL_CRS_EnableIT_ESYNC | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_EnableIT_ESYNC(void) | |||
{ | |||
SET_BIT(CRS->CR, CRS_CR_ESYNCIE); | |||
} | |||
/** | |||
* @brief Disable Expected SYNC interrupt | |||
* @rmtoll CR ESYNCIE LL_CRS_DisableIT_ESYNC | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_CRS_DisableIT_ESYNC(void) | |||
{ | |||
CLEAR_BIT(CRS->CR, CRS_CR_ESYNCIE); | |||
} | |||
/** | |||
* @brief Check if Expected SYNC interrupt is enabled or not | |||
* @rmtoll CR ESYNCIE LL_CRS_IsEnabledIT_ESYNC | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ESYNC(void) | |||
{ | |||
return ((READ_BIT(CRS->CR, CRS_CR_ESYNCIE) == (CRS_CR_ESYNCIE)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
#if defined(USE_FULL_LL_DRIVER) | |||
/** @defgroup CRS_LL_EF_Init Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
ErrorStatus LL_CRS_DeInit(void); | |||
/** | |||
* @} | |||
*/ | |||
#endif /* USE_FULL_LL_DRIVER */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* defined(CRS) */ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_LL_CRS_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,991 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_ll_gpio.h | |||
* @author MCD Application Team | |||
* @brief Header file of GPIO LL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_LL_GPIO_H | |||
#define STM32WBxx_LL_GPIO_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx.h" | |||
/** @addtogroup STM32WBxx_LL_Driver | |||
* @{ | |||
*/ | |||
#if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOH) | |||
/** @defgroup GPIO_LL GPIO | |||
* @{ | |||
*/ | |||
/** MISRA C:2012 deviation rule has been granted for following rules: | |||
* Rule-18.1_d - Medium: Array pointer `GPIOx' is accessed with index [..,..] | |||
* which may be out of array bounds [..,UNKNOWN] in following APIs: | |||
* LL_GPIO_GetAFPin_0_7 | |||
* LL_GPIO_SetAFPin_0_7 | |||
* LL_GPIO_SetAFPin_8_15 | |||
* LL_GPIO_GetAFPin_8_15 | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
#if defined(USE_FULL_LL_DRIVER) | |||
/** @defgroup GPIO_LL_Private_Macros GPIO Private Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /*USE_FULL_LL_DRIVER*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
#if defined(USE_FULL_LL_DRIVER) | |||
/** @defgroup GPIO_LL_ES_INIT GPIO Exported Init structures | |||
* @{ | |||
*/ | |||
/** | |||
* @brief LL GPIO Init Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Pin; /*!< Specifies the GPIO pins to be configured. | |||
This parameter can be any value of @ref GPIO_LL_EC_PIN */ | |||
uint32_t Mode; /*!< Specifies the operating mode for the selected pins. | |||
This parameter can be a value of @ref GPIO_LL_EC_MODE. | |||
GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinMode().*/ | |||
uint32_t Speed; /*!< Specifies the speed for the selected pins. | |||
This parameter can be a value of @ref GPIO_LL_EC_SPEED. | |||
GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinSpeed().*/ | |||
uint32_t OutputType; /*!< Specifies the operating output type for the selected pins. | |||
This parameter can be a value of @ref GPIO_LL_EC_OUTPUT. | |||
GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinOutputType().*/ | |||
uint32_t Pull; /*!< Specifies the operating Pull-up/Pull down for the selected pins. | |||
This parameter can be a value of @ref GPIO_LL_EC_PULL. | |||
GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinPull().*/ | |||
uint32_t Alternate; /*!< Specifies the Peripheral to be connected to the selected pins. | |||
This parameter can be a value of @ref GPIO_LL_EC_AF. | |||
GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetAFPin_0_7() and LL_GPIO_SetAFPin_8_15().*/ | |||
} LL_GPIO_InitTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
#endif /* USE_FULL_LL_DRIVER */ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup GPIO_LL_Exported_Constants GPIO Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup GPIO_LL_EC_PIN PIN | |||
* @{ | |||
*/ | |||
#define LL_GPIO_PIN_0 GPIO_BSRR_BS0 /*!< Select pin 0 */ | |||
#define LL_GPIO_PIN_1 GPIO_BSRR_BS1 /*!< Select pin 1 */ | |||
#define LL_GPIO_PIN_2 GPIO_BSRR_BS2 /*!< Select pin 2 */ | |||
#define LL_GPIO_PIN_3 GPIO_BSRR_BS3 /*!< Select pin 3 */ | |||
#define LL_GPIO_PIN_4 GPIO_BSRR_BS4 /*!< Select pin 4 */ | |||
#define LL_GPIO_PIN_5 GPIO_BSRR_BS5 /*!< Select pin 5 */ | |||
#define LL_GPIO_PIN_6 GPIO_BSRR_BS6 /*!< Select pin 6 */ | |||
#define LL_GPIO_PIN_7 GPIO_BSRR_BS7 /*!< Select pin 7 */ | |||
#define LL_GPIO_PIN_8 GPIO_BSRR_BS8 /*!< Select pin 8 */ | |||
#define LL_GPIO_PIN_9 GPIO_BSRR_BS9 /*!< Select pin 9 */ | |||
#define LL_GPIO_PIN_10 GPIO_BSRR_BS10 /*!< Select pin 10 */ | |||
#define LL_GPIO_PIN_11 GPIO_BSRR_BS11 /*!< Select pin 11 */ | |||
#define LL_GPIO_PIN_12 GPIO_BSRR_BS12 /*!< Select pin 12 */ | |||
#define LL_GPIO_PIN_13 GPIO_BSRR_BS13 /*!< Select pin 13 */ | |||
#define LL_GPIO_PIN_14 GPIO_BSRR_BS14 /*!< Select pin 14 */ | |||
#define LL_GPIO_PIN_15 GPIO_BSRR_BS15 /*!< Select pin 15 */ | |||
#define LL_GPIO_PIN_ALL (GPIO_BSRR_BS0 | GPIO_BSRR_BS1 | GPIO_BSRR_BS2 | \ | |||
GPIO_BSRR_BS3 | GPIO_BSRR_BS4 | GPIO_BSRR_BS5 | \ | |||
GPIO_BSRR_BS6 | GPIO_BSRR_BS7 | GPIO_BSRR_BS8 | \ | |||
GPIO_BSRR_BS9 | GPIO_BSRR_BS10 | GPIO_BSRR_BS11 | \ | |||
GPIO_BSRR_BS12 | GPIO_BSRR_BS13 | GPIO_BSRR_BS14 | \ | |||
GPIO_BSRR_BS15) /*!< Select all pins */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup GPIO_LL_EC_MODE Mode | |||
* @{ | |||
*/ | |||
#define LL_GPIO_MODE_INPUT (0x00000000U) /*!< Select input mode */ | |||
#define LL_GPIO_MODE_OUTPUT GPIO_MODER_MODE0_0 /*!< Select output mode */ | |||
#define LL_GPIO_MODE_ALTERNATE GPIO_MODER_MODE0_1 /*!< Select alternate function mode */ | |||
#define LL_GPIO_MODE_ANALOG GPIO_MODER_MODE0 /*!< Select analog mode */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup GPIO_LL_EC_OUTPUT Output Type | |||
* @{ | |||
*/ | |||
#define LL_GPIO_OUTPUT_PUSHPULL (0x00000000U) /*!< Select push-pull as output type */ | |||
#define LL_GPIO_OUTPUT_OPENDRAIN GPIO_OTYPER_OT0 /*!< Select open-drain as output type */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup GPIO_LL_EC_SPEED Output Speed | |||
* @{ | |||
*/ | |||
#define LL_GPIO_SPEED_FREQ_LOW (0x00000000U) /*!< Select I/O low output speed */ | |||
#define LL_GPIO_SPEED_FREQ_MEDIUM GPIO_OSPEEDR_OSPEED0_0 /*!< Select I/O medium output speed */ | |||
#define LL_GPIO_SPEED_FREQ_HIGH GPIO_OSPEEDR_OSPEED0_1 /*!< Select I/O fast output speed */ | |||
#define LL_GPIO_SPEED_FREQ_VERY_HIGH GPIO_OSPEEDR_OSPEED0 /*!< Select I/O high output speed */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup GPIO_LL_EC_PULL Pull Up Pull Down | |||
* @{ | |||
*/ | |||
#define LL_GPIO_PULL_NO (0x00000000U) /*!< Select I/O no pull */ | |||
#define LL_GPIO_PULL_UP GPIO_PUPDR_PUPD0_0 /*!< Select I/O pull up */ | |||
#define LL_GPIO_PULL_DOWN GPIO_PUPDR_PUPD0_1 /*!< Select I/O pull down */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup GPIO_LL_EC_AF Alternate Function | |||
* @{ | |||
*/ | |||
#define LL_GPIO_AF_0 (0x0000000U) /*!< Select alternate function 0 */ | |||
#define LL_GPIO_AF_1 (0x0000001U) /*!< Select alternate function 1 */ | |||
#define LL_GPIO_AF_2 (0x0000002U) /*!< Select alternate function 2 */ | |||
#define LL_GPIO_AF_3 (0x0000003U) /*!< Select alternate function 3 */ | |||
#define LL_GPIO_AF_4 (0x0000004U) /*!< Select alternate function 4 */ | |||
#define LL_GPIO_AF_5 (0x0000005U) /*!< Select alternate function 5 */ | |||
#define LL_GPIO_AF_6 (0x0000006U) /*!< Select alternate function 6 */ | |||
#define LL_GPIO_AF_7 (0x0000007U) /*!< Select alternate function 7 */ | |||
#define LL_GPIO_AF_8 (0x0000008U) /*!< Select alternate function 8 */ | |||
#define LL_GPIO_AF_9 (0x0000009U) /*!< Select alternate function 9 */ | |||
#define LL_GPIO_AF_10 (0x000000AU) /*!< Select alternate function 10 */ | |||
#define LL_GPIO_AF_11 (0x000000BU) /*!< Select alternate function 11 */ | |||
#define LL_GPIO_AF_12 (0x000000CU) /*!< Select alternate function 12 */ | |||
#define LL_GPIO_AF_13 (0x000000DU) /*!< Select alternate function 13 */ | |||
#define LL_GPIO_AF_14 (0x000000EU) /*!< Select alternate function 14 */ | |||
#define LL_GPIO_AF_15 (0x000000FU) /*!< Select alternate function 15 */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup GPIO_LL_Exported_Macros GPIO Exported Macros | |||
* @{ | |||
*/ | |||
/** @defgroup GPIO_LL_EM_WRITE_READ Common Write and read registers Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Write a value in GPIO register | |||
* @param __INSTANCE__ GPIO Instance | |||
* @param __REG__ Register to be written | |||
* @param __VALUE__ Value to be written in the register | |||
* @retval None | |||
*/ | |||
#define LL_GPIO_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) | |||
/** | |||
* @brief Read a value in GPIO register | |||
* @param __INSTANCE__ GPIO Instance | |||
* @param __REG__ Register to be read | |||
* @retval Register value | |||
*/ | |||
#define LL_GPIO_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup GPIO_LL_Exported_Functions GPIO Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup GPIO_LL_EF_Port_Configuration Port Configuration | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Configure gpio mode for a dedicated pin on dedicated port. | |||
* @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog. | |||
* @note Warning: only one pin can be passed as parameter. | |||
* @rmtoll MODER MODEy LL_GPIO_SetPinMode | |||
* @param GPIOx GPIO Port | |||
* @param Pin This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @param Mode This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_MODE_INPUT | |||
* @arg @ref LL_GPIO_MODE_OUTPUT | |||
* @arg @ref LL_GPIO_MODE_ALTERNATE | |||
* @arg @ref LL_GPIO_MODE_ANALOG | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_GPIO_SetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Mode) | |||
{ | |||
MODIFY_REG(GPIOx->MODER, (GPIO_MODER_MODE0 << (POSITION_VAL(Pin) * 2U)), (Mode << (POSITION_VAL(Pin) * 2U))); | |||
} | |||
/** | |||
* @brief Return gpio mode for a dedicated pin on dedicated port. | |||
* @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog. | |||
* @note Warning: only one pin can be passed as parameter. | |||
* @rmtoll MODER MODEy LL_GPIO_GetPinMode | |||
* @param GPIOx GPIO Port | |||
* @param Pin This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_GPIO_MODE_INPUT | |||
* @arg @ref LL_GPIO_MODE_OUTPUT | |||
* @arg @ref LL_GPIO_MODE_ALTERNATE | |||
* @arg @ref LL_GPIO_MODE_ANALOG | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GPIO_GetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin) | |||
{ | |||
return (uint32_t)(READ_BIT(GPIOx->MODER, | |||
(GPIO_MODER_MODE0 << (POSITION_VAL(Pin) * 2U))) >> (POSITION_VAL(Pin) * 2U)); | |||
} | |||
/** | |||
* @brief Configure gpio output type for several pins on dedicated port. | |||
* @note Output type as to be set when gpio pin is in output or | |||
* alternate modes. Possible type are Push-pull or Open-drain. | |||
* @rmtoll OTYPER OTy LL_GPIO_SetPinOutputType | |||
* @param GPIOx GPIO Port | |||
* @param PinMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @arg @ref LL_GPIO_PIN_ALL | |||
* @param OutputType This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_OUTPUT_PUSHPULL | |||
* @arg @ref LL_GPIO_OUTPUT_OPENDRAIN | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_GPIO_SetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t PinMask, uint32_t OutputType) | |||
{ | |||
MODIFY_REG(GPIOx->OTYPER, PinMask, (PinMask * OutputType)); | |||
} | |||
/** | |||
* @brief Return gpio output type for several pins on dedicated port. | |||
* @note Output type as to be set when gpio pin is in output or | |||
* alternate modes. Possible type are Push-pull or Open-drain. | |||
* @note Warning: only one pin can be passed as parameter. | |||
* @rmtoll OTYPER OTy LL_GPIO_GetPinOutputType | |||
* @param GPIOx GPIO Port | |||
* @param Pin This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @arg @ref LL_GPIO_PIN_ALL | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_GPIO_OUTPUT_PUSHPULL | |||
* @arg @ref LL_GPIO_OUTPUT_OPENDRAIN | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GPIO_GetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t Pin) | |||
{ | |||
return (uint32_t)(READ_BIT(GPIOx->OTYPER, Pin) >> POSITION_VAL(Pin)); | |||
} | |||
/** | |||
* @brief Configure gpio speed for a dedicated pin on dedicated port. | |||
* @note I/O speed can be Low, Medium, Fast or High speed. | |||
* @note Warning: only one pin can be passed as parameter. | |||
* @note Refer to datasheet for frequency specifications and the power | |||
* supply and load conditions for each speed. | |||
* @rmtoll OSPEEDR OSPEEDy LL_GPIO_SetPinSpeed | |||
* @param GPIOx GPIO Port | |||
* @param Pin This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @param Speed This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_SPEED_FREQ_LOW | |||
* @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM | |||
* @arg @ref LL_GPIO_SPEED_FREQ_HIGH | |||
* @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_GPIO_SetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Speed) | |||
{ | |||
MODIFY_REG(GPIOx->OSPEEDR, (GPIO_OSPEEDR_OSPEED0 << (POSITION_VAL(Pin) * 2U)), | |||
(Speed << (POSITION_VAL(Pin) * 2U))); | |||
} | |||
/** | |||
* @brief Return gpio speed for a dedicated pin on dedicated port. | |||
* @note I/O speed can be Low, Medium, Fast or High speed. | |||
* @note Warning: only one pin can be passed as parameter. | |||
* @note Refer to datasheet for frequency specifications and the power | |||
* supply and load conditions for each speed. | |||
* @rmtoll OSPEEDR OSPEEDy LL_GPIO_GetPinSpeed | |||
* @param GPIOx GPIO Port | |||
* @param Pin This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_GPIO_SPEED_FREQ_LOW | |||
* @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM | |||
* @arg @ref LL_GPIO_SPEED_FREQ_HIGH | |||
* @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GPIO_GetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin) | |||
{ | |||
return (uint32_t)(READ_BIT(GPIOx->OSPEEDR, | |||
(GPIO_OSPEEDR_OSPEED0 << (POSITION_VAL(Pin) * 2U))) >> (POSITION_VAL(Pin) * 2U)); | |||
} | |||
/** | |||
* @brief Configure gpio pull-up or pull-down for a dedicated pin on a dedicated port. | |||
* @note Warning: only one pin can be passed as parameter. | |||
* @rmtoll PUPDR PUPDy LL_GPIO_SetPinPull | |||
* @param GPIOx GPIO Port | |||
* @param Pin This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @param Pull This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_PULL_NO | |||
* @arg @ref LL_GPIO_PULL_UP | |||
* @arg @ref LL_GPIO_PULL_DOWN | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_GPIO_SetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Pull) | |||
{ | |||
MODIFY_REG(GPIOx->PUPDR, (GPIO_PUPDR_PUPD0 << (POSITION_VAL(Pin) * 2U)), (Pull << (POSITION_VAL(Pin) * 2U))); | |||
} | |||
/** | |||
* @brief Return gpio pull-up or pull-down for a dedicated pin on a dedicated port | |||
* @note Warning: only one pin can be passed as parameter. | |||
* @rmtoll PUPDR PUPDy LL_GPIO_GetPinPull | |||
* @param GPIOx GPIO Port | |||
* @param Pin This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_GPIO_PULL_NO | |||
* @arg @ref LL_GPIO_PULL_UP | |||
* @arg @ref LL_GPIO_PULL_DOWN | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GPIO_GetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin) | |||
{ | |||
return (uint32_t)(READ_BIT(GPIOx->PUPDR, | |||
(GPIO_PUPDR_PUPD0 << (POSITION_VAL(Pin) * 2U))) >> (POSITION_VAL(Pin) * 2U)); | |||
} | |||
/** | |||
* @brief Configure gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port. | |||
* @note Possible values are from AF0 to AF15 depending on target. | |||
* @note Warning: only one pin can be passed as parameter. | |||
* @rmtoll AFRL AFSELy LL_GPIO_SetAFPin_0_7 | |||
* @param GPIOx GPIO Port | |||
* @param Pin This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @param Alternate This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_AF_0 | |||
* @arg @ref LL_GPIO_AF_1 | |||
* @arg @ref LL_GPIO_AF_2 | |||
* @arg @ref LL_GPIO_AF_3 | |||
* @arg @ref LL_GPIO_AF_4 | |||
* @arg @ref LL_GPIO_AF_5 | |||
* @arg @ref LL_GPIO_AF_6 | |||
* @arg @ref LL_GPIO_AF_7 | |||
* @arg @ref LL_GPIO_AF_8 | |||
* @arg @ref LL_GPIO_AF_9 | |||
* @arg @ref LL_GPIO_AF_10 | |||
* @arg @ref LL_GPIO_AF_11 | |||
* @arg @ref LL_GPIO_AF_12 | |||
* @arg @ref LL_GPIO_AF_13 | |||
* @arg @ref LL_GPIO_AF_14 | |||
* @arg @ref LL_GPIO_AF_15 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_GPIO_SetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate) | |||
{ | |||
MODIFY_REG(GPIOx->AFR[0], (GPIO_AFRL_AFSEL0 << (POSITION_VAL(Pin) * 4U)), | |||
(Alternate << (POSITION_VAL(Pin) * 4U))); | |||
} | |||
/** | |||
* @brief Return gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port. | |||
* @rmtoll AFRL AFSELy LL_GPIO_GetAFPin_0_7 | |||
* @param GPIOx GPIO Port | |||
* @param Pin This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_GPIO_AF_0 | |||
* @arg @ref LL_GPIO_AF_1 | |||
* @arg @ref LL_GPIO_AF_2 | |||
* @arg @ref LL_GPIO_AF_3 | |||
* @arg @ref LL_GPIO_AF_4 | |||
* @arg @ref LL_GPIO_AF_5 | |||
* @arg @ref LL_GPIO_AF_6 | |||
* @arg @ref LL_GPIO_AF_7 | |||
* @arg @ref LL_GPIO_AF_8 | |||
* @arg @ref LL_GPIO_AF_9 | |||
* @arg @ref LL_GPIO_AF_10 | |||
* @arg @ref LL_GPIO_AF_11 | |||
* @arg @ref LL_GPIO_AF_12 | |||
* @arg @ref LL_GPIO_AF_13 | |||
* @arg @ref LL_GPIO_AF_14 | |||
* @arg @ref LL_GPIO_AF_15 | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GPIO_GetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin) | |||
{ | |||
return (uint32_t)(READ_BIT(GPIOx->AFR[0], | |||
(GPIO_AFRL_AFSEL0 << (POSITION_VAL(Pin) * 4U))) >> (POSITION_VAL(Pin) * 4U)); | |||
} | |||
/** | |||
* @brief Configure gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port. | |||
* @note Possible values are from AF0 to AF15 depending on target. | |||
* @note Warning: only one pin can be passed as parameter. | |||
* @rmtoll AFRH AFSELy LL_GPIO_SetAFPin_8_15 | |||
* @param GPIOx GPIO Port | |||
* @param Pin This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @param Alternate This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_AF_0 | |||
* @arg @ref LL_GPIO_AF_1 | |||
* @arg @ref LL_GPIO_AF_2 | |||
* @arg @ref LL_GPIO_AF_3 | |||
* @arg @ref LL_GPIO_AF_4 | |||
* @arg @ref LL_GPIO_AF_5 | |||
* @arg @ref LL_GPIO_AF_6 | |||
* @arg @ref LL_GPIO_AF_7 | |||
* @arg @ref LL_GPIO_AF_8 | |||
* @arg @ref LL_GPIO_AF_9 | |||
* @arg @ref LL_GPIO_AF_10 | |||
* @arg @ref LL_GPIO_AF_11 | |||
* @arg @ref LL_GPIO_AF_12 | |||
* @arg @ref LL_GPIO_AF_13 | |||
* @arg @ref LL_GPIO_AF_14 | |||
* @arg @ref LL_GPIO_AF_15 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_GPIO_SetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate) | |||
{ | |||
MODIFY_REG(GPIOx->AFR[1], (GPIO_AFRH_AFSEL8 << (POSITION_VAL(Pin >> 8U) * 4U)), | |||
(Alternate << (POSITION_VAL(Pin >> 8U) * 4U))); | |||
} | |||
/** | |||
* @brief Return gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port. | |||
* @note Possible values are from AF0 to AF15 depending on target. | |||
* @rmtoll AFRH AFSELy LL_GPIO_GetAFPin_8_15 | |||
* @param GPIOx GPIO Port | |||
* @param Pin This parameter can be one of the following values: | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_GPIO_AF_0 | |||
* @arg @ref LL_GPIO_AF_1 | |||
* @arg @ref LL_GPIO_AF_2 | |||
* @arg @ref LL_GPIO_AF_3 | |||
* @arg @ref LL_GPIO_AF_4 | |||
* @arg @ref LL_GPIO_AF_5 | |||
* @arg @ref LL_GPIO_AF_6 | |||
* @arg @ref LL_GPIO_AF_7 | |||
* @arg @ref LL_GPIO_AF_8 | |||
* @arg @ref LL_GPIO_AF_9 | |||
* @arg @ref LL_GPIO_AF_10 | |||
* @arg @ref LL_GPIO_AF_11 | |||
* @arg @ref LL_GPIO_AF_12 | |||
* @arg @ref LL_GPIO_AF_13 | |||
* @arg @ref LL_GPIO_AF_14 | |||
* @arg @ref LL_GPIO_AF_15 | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GPIO_GetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin) | |||
{ | |||
return (uint32_t)(READ_BIT(GPIOx->AFR[1], | |||
(GPIO_AFRH_AFSEL8 << (POSITION_VAL(Pin >> 8U) * 4U))) >> (POSITION_VAL(Pin >> 8U) * 4U)); | |||
} | |||
/** | |||
* @brief Lock configuration of several pins for a dedicated port. | |||
* @note When the lock sequence has been applied on a port bit, the | |||
* value of this port bit can no longer be modified until the | |||
* next reset. | |||
* @note Each lock bit freezes a specific configuration register | |||
* (control and alternate function registers). | |||
* @rmtoll LCKR LCKK LL_GPIO_LockPin | |||
* @param GPIOx GPIO Port | |||
* @param PinMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @arg @ref LL_GPIO_PIN_ALL | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint32_t PinMask) | |||
{ | |||
__IO uint32_t temp; | |||
WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask); | |||
WRITE_REG(GPIOx->LCKR, PinMask); | |||
WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask); | |||
/* Read LCKK register. This read is mandatory to complete key lock sequence */ | |||
temp = READ_REG(GPIOx->LCKR); | |||
(void) temp; | |||
} | |||
/** | |||
* @brief Return 1 if all pins passed as parameter, of a dedicated port, are locked. else Return 0. | |||
* @rmtoll LCKR LCKy LL_GPIO_IsPinLocked | |||
* @param GPIOx GPIO Port | |||
* @param PinMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @arg @ref LL_GPIO_PIN_ALL | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GPIO_IsPinLocked(GPIO_TypeDef *GPIOx, uint32_t PinMask) | |||
{ | |||
return ((READ_BIT(GPIOx->LCKR, PinMask) == (PinMask)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Return 1 if one of the pin of a dedicated port is locked. else return 0. | |||
* @rmtoll LCKR LCKK LL_GPIO_IsAnyPinLocked | |||
* @param GPIOx GPIO Port | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GPIO_IsAnyPinLocked(GPIO_TypeDef *GPIOx) | |||
{ | |||
return ((READ_BIT(GPIOx->LCKR, GPIO_LCKR_LCKK) == (GPIO_LCKR_LCKK)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup GPIO_LL_EF_Data_Access Data Access | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Return full input data register value for a dedicated port. | |||
* @rmtoll IDR IDy LL_GPIO_ReadInputPort | |||
* @param GPIOx GPIO Port | |||
* @retval Input data register value of port | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GPIO_ReadInputPort(GPIO_TypeDef *GPIOx) | |||
{ | |||
return (uint32_t)(READ_REG(GPIOx->IDR)); | |||
} | |||
/** | |||
* @brief Return if input data level for several pins of dedicated port is high or low. | |||
* @rmtoll IDR IDy LL_GPIO_IsInputPinSet | |||
* @param GPIOx GPIO Port | |||
* @param PinMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @arg @ref LL_GPIO_PIN_ALL | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GPIO_IsInputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask) | |||
{ | |||
return ((READ_BIT(GPIOx->IDR, PinMask) == (PinMask)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Write output data register for the port. | |||
* @rmtoll ODR ODy LL_GPIO_WriteOutputPort | |||
* @param GPIOx GPIO Port | |||
* @param PortValue Level value for each pin of the port | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_GPIO_WriteOutputPort(GPIO_TypeDef *GPIOx, uint32_t PortValue) | |||
{ | |||
WRITE_REG(GPIOx->ODR, PortValue); | |||
} | |||
/** | |||
* @brief Return full output data register value for a dedicated port. | |||
* @rmtoll ODR ODy LL_GPIO_ReadOutputPort | |||
* @param GPIOx GPIO Port | |||
* @retval Output data register value of port | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GPIO_ReadOutputPort(GPIO_TypeDef *GPIOx) | |||
{ | |||
return (uint32_t)(READ_REG(GPIOx->ODR)); | |||
} | |||
/** | |||
* @brief Return if input data level for several pins of dedicated port is high or low. | |||
* @rmtoll ODR ODy LL_GPIO_IsOutputPinSet | |||
* @param GPIOx GPIO Port | |||
* @param PinMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @arg @ref LL_GPIO_PIN_ALL | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GPIO_IsOutputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask) | |||
{ | |||
return ((READ_BIT(GPIOx->ODR, PinMask) == (PinMask)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Set several pins to high level on dedicated gpio port. | |||
* @rmtoll BSRR BSy LL_GPIO_SetOutputPin | |||
* @param GPIOx GPIO Port | |||
* @param PinMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @arg @ref LL_GPIO_PIN_ALL | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_GPIO_SetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask) | |||
{ | |||
WRITE_REG(GPIOx->BSRR, PinMask); | |||
} | |||
/** | |||
* @brief Set several pins to low level on dedicated gpio port. | |||
* @rmtoll BRR BRy LL_GPIO_ResetOutputPin | |||
* @param GPIOx GPIO Port | |||
* @param PinMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @arg @ref LL_GPIO_PIN_ALL | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_GPIO_ResetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask) | |||
{ | |||
WRITE_REG(GPIOx->BRR, PinMask); | |||
} | |||
/** | |||
* @brief Toggle data value for several pin of dedicated port. | |||
* @rmtoll ODR ODy LL_GPIO_TogglePin | |||
* @param GPIOx GPIO Port | |||
* @param PinMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_GPIO_PIN_0 | |||
* @arg @ref LL_GPIO_PIN_1 | |||
* @arg @ref LL_GPIO_PIN_2 | |||
* @arg @ref LL_GPIO_PIN_3 | |||
* @arg @ref LL_GPIO_PIN_4 | |||
* @arg @ref LL_GPIO_PIN_5 | |||
* @arg @ref LL_GPIO_PIN_6 | |||
* @arg @ref LL_GPIO_PIN_7 | |||
* @arg @ref LL_GPIO_PIN_8 | |||
* @arg @ref LL_GPIO_PIN_9 | |||
* @arg @ref LL_GPIO_PIN_10 | |||
* @arg @ref LL_GPIO_PIN_11 | |||
* @arg @ref LL_GPIO_PIN_12 | |||
* @arg @ref LL_GPIO_PIN_13 | |||
* @arg @ref LL_GPIO_PIN_14 | |||
* @arg @ref LL_GPIO_PIN_15 | |||
* @arg @ref LL_GPIO_PIN_ALL | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint32_t PinMask) | |||
{ | |||
WRITE_REG(GPIOx->ODR, READ_REG(GPIOx->ODR) ^ PinMask); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
#if defined(USE_FULL_LL_DRIVER) | |||
/** @defgroup GPIO_LL_EF_Init Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx); | |||
ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct); | |||
void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct); | |||
/** | |||
* @} | |||
*/ | |||
#endif /* USE_FULL_LL_DRIVER */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOH) */ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_LL_GPIO_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,879 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_ll_hsem.h | |||
* @author MCD Application Team | |||
* @brief Header file of HSEM LL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_LL_HSEM_H | |||
#define STM32WBxx_LL_HSEM_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx.h" | |||
/** @addtogroup STM32WBxx_LL_Driver | |||
* @{ | |||
*/ | |||
#if defined(HSEM) | |||
/** @defgroup HSEM_LL HSEM | |||
* @{ | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup HSEM_LL_Exported_Constants HSEM Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup HSEM_LL_EC_COREID COREID Defines | |||
* @{ | |||
*/ | |||
#define LL_HSEM_COREID_NONE 0U | |||
#define LL_HSEM_COREID_CPU1 HSEM_CR_COREID_CPU1 | |||
#define LL_HSEM_COREID_CPU2 HSEM_CR_COREID_CPU2 | |||
#define LL_HSEM_COREID HSEM_CR_COREID_CURRENT | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup HSEM_LL_EC_GET_FLAG Get Flags Defines | |||
* @brief Flags defines which can be used with LL_HSEM_ReadReg function | |||
* @{ | |||
*/ | |||
#define LL_HSEM_SEMAPHORE_0 HSEM_C1IER_ISE0 | |||
#define LL_HSEM_SEMAPHORE_1 HSEM_C1IER_ISE1 | |||
#define LL_HSEM_SEMAPHORE_2 HSEM_C1IER_ISE2 | |||
#define LL_HSEM_SEMAPHORE_3 HSEM_C1IER_ISE3 | |||
#define LL_HSEM_SEMAPHORE_4 HSEM_C1IER_ISE4 | |||
#define LL_HSEM_SEMAPHORE_5 HSEM_C1IER_ISE5 | |||
#define LL_HSEM_SEMAPHORE_6 HSEM_C1IER_ISE6 | |||
#define LL_HSEM_SEMAPHORE_7 HSEM_C1IER_ISE7 | |||
#define LL_HSEM_SEMAPHORE_8 HSEM_C1IER_ISE8 | |||
#define LL_HSEM_SEMAPHORE_9 HSEM_C1IER_ISE9 | |||
#define LL_HSEM_SEMAPHORE_10 HSEM_C1IER_ISE10 | |||
#define LL_HSEM_SEMAPHORE_11 HSEM_C1IER_ISE11 | |||
#define LL_HSEM_SEMAPHORE_12 HSEM_C1IER_ISE12 | |||
#define LL_HSEM_SEMAPHORE_13 HSEM_C1IER_ISE13 | |||
#define LL_HSEM_SEMAPHORE_14 HSEM_C1IER_ISE14 | |||
#define LL_HSEM_SEMAPHORE_15 HSEM_C1IER_ISE15 | |||
#define LL_HSEM_SEMAPHORE_16 HSEM_C1IER_ISE16 | |||
#define LL_HSEM_SEMAPHORE_17 HSEM_C1IER_ISE17 | |||
#define LL_HSEM_SEMAPHORE_18 HSEM_C1IER_ISE18 | |||
#define LL_HSEM_SEMAPHORE_19 HSEM_C1IER_ISE19 | |||
#define LL_HSEM_SEMAPHORE_20 HSEM_C1IER_ISE20 | |||
#define LL_HSEM_SEMAPHORE_21 HSEM_C1IER_ISE21 | |||
#define LL_HSEM_SEMAPHORE_22 HSEM_C1IER_ISE22 | |||
#define LL_HSEM_SEMAPHORE_23 HSEM_C1IER_ISE23 | |||
#define LL_HSEM_SEMAPHORE_24 HSEM_C1IER_ISE24 | |||
#define LL_HSEM_SEMAPHORE_25 HSEM_C1IER_ISE25 | |||
#define LL_HSEM_SEMAPHORE_26 HSEM_C1IER_ISE26 | |||
#define LL_HSEM_SEMAPHORE_27 HSEM_C1IER_ISE27 | |||
#define LL_HSEM_SEMAPHORE_28 HSEM_C1IER_ISE28 | |||
#define LL_HSEM_SEMAPHORE_29 HSEM_C1IER_ISE29 | |||
#define LL_HSEM_SEMAPHORE_30 HSEM_C1IER_ISE30 | |||
#define LL_HSEM_SEMAPHORE_31 HSEM_C1IER_ISE31 | |||
#define LL_HSEM_SEMAPHORE_ALL 0xFFFFFFFFU | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup HSEM_LL_Exported_Macros HSEM Exported Macros | |||
* @{ | |||
*/ | |||
/** @defgroup HSEM_LL_EM_WRITE_READ Common Write and read registers Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Write a value in HSEM register | |||
* @param __INSTANCE__ HSEM Instance | |||
* @param __REG__ Register to be written | |||
* @param __VALUE__ Value to be written in the register | |||
* @retval None | |||
*/ | |||
#define LL_HSEM_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) | |||
/** | |||
* @brief Read a value in HSEM register | |||
* @param __INSTANCE__ HSEM Instance | |||
* @param __REG__ Register to be read | |||
* @retval Register value | |||
*/ | |||
#define LL_HSEM_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup HSEM_LL_Exported_Functions HSEM Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup HSEM_LL_EF_Data_Management Data_Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Return 1 if the semaphore is locked, else return 0. | |||
* @rmtoll R LOCK LL_HSEM_IsSemaphoreLocked | |||
* @param HSEMx HSEM Instance. | |||
* @param Semaphore Semaphore number. Value between Min_Data=0 and Max_Data=31 | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_HSEM_IsSemaphoreLocked(HSEM_TypeDef *HSEMx, uint32_t Semaphore) | |||
{ | |||
return ((READ_BIT(HSEMx->R[Semaphore], HSEM_R_LOCK) == (HSEM_R_LOCK_Msk)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Get core id. | |||
* @rmtoll R COREID LL_HSEM_GetCoreId | |||
* @param HSEMx HSEM Instance. | |||
* @param Semaphore Semaphore number. Value between Min_Data=0 and Max_Data=31 | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_HSEM_COREID_NONE | |||
* @arg @ref LL_HSEM_COREID_CPU1 | |||
* @arg @ref LL_HSEM_COREID_CPU2 | |||
*/ | |||
__STATIC_INLINE uint32_t LL_HSEM_GetCoreId(HSEM_TypeDef *HSEMx, uint32_t Semaphore) | |||
{ | |||
return (uint32_t)(READ_BIT(HSEMx->R[Semaphore], HSEM_R_COREID_Msk)); | |||
} | |||
/** | |||
* @brief Get process id. | |||
* @rmtoll R PROCID LL_HSEM_GetProcessId | |||
* @param HSEMx HSEM Instance. | |||
* @param Semaphore Semaphore number. Value between Min_Data=0 and Max_Data=31 | |||
* @retval Process number. Value between Min_Data=0 and Max_Data=255 | |||
*/ | |||
__STATIC_INLINE uint32_t LL_HSEM_GetProcessId(HSEM_TypeDef *HSEMx, uint32_t Semaphore) | |||
{ | |||
return (uint32_t)(READ_BIT(HSEMx->R[Semaphore], HSEM_R_PROCID_Msk)); | |||
} | |||
/** | |||
* @brief Get the lock by writing in R register. | |||
* @note The R register has to be read to determined if the lock is taken. | |||
* @rmtoll R LOCK LL_HSEM_SetLock | |||
* @rmtoll R COREID LL_HSEM_SetLock | |||
* @rmtoll R PROCID LL_HSEM_SetLock | |||
* @param HSEMx HSEM Instance. | |||
* @param Semaphore Semaphore number. Value between Min_Data=0 and Max_Data=31 | |||
* @param process Process id. Value between Min_Data=0 and Max_Data=255 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_HSEM_SetLock(HSEM_TypeDef *HSEMx, uint32_t Semaphore, uint32_t process) | |||
{ | |||
WRITE_REG(HSEMx->R[Semaphore], (HSEM_R_LOCK | LL_HSEM_COREID | process)); | |||
} | |||
/** | |||
* @brief Get the lock with 2-step lock. | |||
* @rmtoll R LOCK LL_HSEM_2StepLock | |||
* @rmtoll R COREID LL_HSEM_2StepLock | |||
* @rmtoll R PROCID LL_HSEM_2StepLock | |||
* @param HSEMx HSEM Instance. | |||
* @param Semaphore Semaphore number. Value between Min_Data=0 and Max_Data=31 | |||
* @param process Process id. Value between Min_Data=0 and Max_Data=255 | |||
* @retval 1 lock fail, 0 lock successful or already locked by same process and core | |||
*/ | |||
__STATIC_INLINE uint32_t LL_HSEM_2StepLock(HSEM_TypeDef *HSEMx, uint32_t Semaphore, uint32_t process) | |||
{ | |||
WRITE_REG(HSEMx->R[Semaphore], (HSEM_R_LOCK | LL_HSEM_COREID | process)); | |||
return ((HSEMx->R[Semaphore] != (HSEM_R_LOCK | LL_HSEM_COREID | process)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Get the lock with 1-step lock. | |||
* @rmtoll RLR LOCK LL_HSEM_1StepLock | |||
* @rmtoll RLR COREID LL_HSEM_1StepLock | |||
* @rmtoll RLR PROCID LL_HSEM_1StepLock | |||
* @param HSEMx HSEM Instance. | |||
* @param Semaphore Semaphore number. Value between Min_Data=0 and Max_Data=31 | |||
* @retval 1 lock fail, 0 lock successful or already locked by same core | |||
*/ | |||
__STATIC_INLINE uint32_t LL_HSEM_1StepLock(HSEM_TypeDef *HSEMx, uint32_t Semaphore) | |||
{ | |||
return ((HSEMx->RLR[Semaphore] != (HSEM_R_LOCK | LL_HSEM_COREID)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Release the lock of the semaphore. | |||
* @note In case of LL_HSEM_1StepLock usage to lock a semaphore, the process is 0. | |||
* @rmtoll R LOCK LL_HSEM_ReleaseLock | |||
* @param HSEMx HSEM Instance. | |||
* @param Semaphore Semaphore number. Value between Min_Data=0 and Max_Data=31 | |||
* @param process Process number. Value between Min_Data=0 and Max_Data=255 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_HSEM_ReleaseLock(HSEM_TypeDef *HSEMx, uint32_t Semaphore, uint32_t process) | |||
{ | |||
WRITE_REG(HSEMx->R[Semaphore], (LL_HSEM_COREID | process)); | |||
} | |||
/** | |||
* @brief Get the lock status of the semaphore. | |||
* @rmtoll R LOCK LL_HSEM_GetStatus | |||
* @param HSEMx HSEM Instance. | |||
* @param Semaphore Semaphore number. Value between Min_Data=0 and Max_Data=31 | |||
* @retval 0 semaphore is free, 1 semaphore is locked */ | |||
__STATIC_INLINE uint32_t LL_HSEM_GetStatus(HSEM_TypeDef *HSEMx, uint32_t Semaphore) | |||
{ | |||
return ((HSEMx->R[Semaphore] != 0U) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Set the key. | |||
* @rmtoll KEYR KEY LL_HSEM_SetKey | |||
* @param HSEMx HSEM Instance. | |||
* @param key Key value. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_HSEM_SetKey(HSEM_TypeDef *HSEMx, uint32_t key) | |||
{ | |||
WRITE_REG(HSEMx->KEYR, key << HSEM_KEYR_KEY_Pos); | |||
} | |||
/** | |||
* @brief Get the key. | |||
* @rmtoll KEYR KEY LL_HSEM_GetKey | |||
* @param HSEMx HSEM Instance. | |||
* @retval key to unlock all semaphore from the same core | |||
*/ | |||
__STATIC_INLINE uint32_t LL_HSEM_GetKey(HSEM_TypeDef *HSEMx) | |||
{ | |||
return (uint32_t)(READ_BIT(HSEMx->KEYR, HSEM_KEYR_KEY) >> HSEM_KEYR_KEY_Pos); | |||
} | |||
/** | |||
* @brief Release all semaphore with the same core id. | |||
* @rmtoll CR KEY LL_HSEM_ResetAllLock | |||
* @param HSEMx HSEM Instance. | |||
* @param key Key value. | |||
* @param core This parameter can be one of the following values: | |||
* @arg @ref LL_HSEM_COREID_CPU1 | |||
* @arg @ref LL_HSEM_COREID_CPU2 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_HSEM_ResetAllLock(HSEM_TypeDef *HSEMx, uint32_t key, uint32_t core) | |||
{ | |||
WRITE_REG(HSEMx->CR, (key << HSEM_CR_KEY_Pos) | core); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup HSEM_LL_EF_IT_Management IT_Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable interrupt. | |||
* @rmtoll C1IER ISEM LL_HSEM_EnableIT_C1IER | |||
* @param HSEMx HSEM Instance. | |||
* @param SemaphoreMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_HSEM_SEMAPHORE_0 | |||
* @arg @ref LL_HSEM_SEMAPHORE_1 | |||
* @arg @ref LL_HSEM_SEMAPHORE_2 | |||
* @arg @ref LL_HSEM_SEMAPHORE_3 | |||
* @arg @ref LL_HSEM_SEMAPHORE_4 | |||
* @arg @ref LL_HSEM_SEMAPHORE_5 | |||
* @arg @ref LL_HSEM_SEMAPHORE_6 | |||
* @arg @ref LL_HSEM_SEMAPHORE_7 | |||
* @arg @ref LL_HSEM_SEMAPHORE_8 | |||
* @arg @ref LL_HSEM_SEMAPHORE_9 | |||
* @arg @ref LL_HSEM_SEMAPHORE_10 | |||
* @arg @ref LL_HSEM_SEMAPHORE_11 | |||
* @arg @ref LL_HSEM_SEMAPHORE_12 | |||
* @arg @ref LL_HSEM_SEMAPHORE_13 | |||
* @arg @ref LL_HSEM_SEMAPHORE_14 | |||
* @arg @ref LL_HSEM_SEMAPHORE_15 | |||
* @arg @ref LL_HSEM_SEMAPHORE_16 | |||
* @arg @ref LL_HSEM_SEMAPHORE_17 | |||
* @arg @ref LL_HSEM_SEMAPHORE_18 | |||
* @arg @ref LL_HSEM_SEMAPHORE_19 | |||
* @arg @ref LL_HSEM_SEMAPHORE_20 | |||
* @arg @ref LL_HSEM_SEMAPHORE_21 | |||
* @arg @ref LL_HSEM_SEMAPHORE_22 | |||
* @arg @ref LL_HSEM_SEMAPHORE_23 | |||
* @arg @ref LL_HSEM_SEMAPHORE_24 | |||
* @arg @ref LL_HSEM_SEMAPHORE_25 | |||
* @arg @ref LL_HSEM_SEMAPHORE_26 | |||
* @arg @ref LL_HSEM_SEMAPHORE_27 | |||
* @arg @ref LL_HSEM_SEMAPHORE_28 | |||
* @arg @ref LL_HSEM_SEMAPHORE_29 | |||
* @arg @ref LL_HSEM_SEMAPHORE_30 | |||
* @arg @ref LL_HSEM_SEMAPHORE_31 | |||
* @arg @ref LL_HSEM_SEMAPHORE_ALL | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_HSEM_EnableIT_C1IER(HSEM_TypeDef *HSEMx, uint32_t SemaphoreMask) | |||
{ | |||
SET_BIT(HSEMx->C1IER, SemaphoreMask); | |||
} | |||
/** | |||
* @brief Disable interrupt. | |||
* @rmtoll C1IER ISEM LL_HSEM_DisableIT_C1IER | |||
* @param HSEMx HSEM Instance. | |||
* @param SemaphoreMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_HSEM_SEMAPHORE_0 | |||
* @arg @ref LL_HSEM_SEMAPHORE_1 | |||
* @arg @ref LL_HSEM_SEMAPHORE_2 | |||
* @arg @ref LL_HSEM_SEMAPHORE_3 | |||
* @arg @ref LL_HSEM_SEMAPHORE_4 | |||
* @arg @ref LL_HSEM_SEMAPHORE_5 | |||
* @arg @ref LL_HSEM_SEMAPHORE_6 | |||
* @arg @ref LL_HSEM_SEMAPHORE_7 | |||
* @arg @ref LL_HSEM_SEMAPHORE_8 | |||
* @arg @ref LL_HSEM_SEMAPHORE_9 | |||
* @arg @ref LL_HSEM_SEMAPHORE_10 | |||
* @arg @ref LL_HSEM_SEMAPHORE_11 | |||
* @arg @ref LL_HSEM_SEMAPHORE_12 | |||
* @arg @ref LL_HSEM_SEMAPHORE_13 | |||
* @arg @ref LL_HSEM_SEMAPHORE_14 | |||
* @arg @ref LL_HSEM_SEMAPHORE_15 | |||
* @arg @ref LL_HSEM_SEMAPHORE_16 | |||
* @arg @ref LL_HSEM_SEMAPHORE_17 | |||
* @arg @ref LL_HSEM_SEMAPHORE_18 | |||
* @arg @ref LL_HSEM_SEMAPHORE_19 | |||
* @arg @ref LL_HSEM_SEMAPHORE_20 | |||
* @arg @ref LL_HSEM_SEMAPHORE_21 | |||
* @arg @ref LL_HSEM_SEMAPHORE_22 | |||
* @arg @ref LL_HSEM_SEMAPHORE_23 | |||
* @arg @ref LL_HSEM_SEMAPHORE_24 | |||
* @arg @ref LL_HSEM_SEMAPHORE_25 | |||
* @arg @ref LL_HSEM_SEMAPHORE_26 | |||
* @arg @ref LL_HSEM_SEMAPHORE_27 | |||
* @arg @ref LL_HSEM_SEMAPHORE_28 | |||
* @arg @ref LL_HSEM_SEMAPHORE_29 | |||
* @arg @ref LL_HSEM_SEMAPHORE_30 | |||
* @arg @ref LL_HSEM_SEMAPHORE_31 | |||
* @arg @ref LL_HSEM_SEMAPHORE_ALL | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_HSEM_DisableIT_C1IER(HSEM_TypeDef *HSEMx, uint32_t SemaphoreMask) | |||
{ | |||
CLEAR_BIT(HSEMx->C1IER, SemaphoreMask); | |||
} | |||
/** | |||
* @brief Check if interrupt is enabled. | |||
* @rmtoll C1IER ISEM LL_HSEM_IsEnabledIT_C1IER | |||
* @param HSEMx HSEM Instance. | |||
* @param SemaphoreMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_HSEM_SEMAPHORE_0 | |||
* @arg @ref LL_HSEM_SEMAPHORE_1 | |||
* @arg @ref LL_HSEM_SEMAPHORE_2 | |||
* @arg @ref LL_HSEM_SEMAPHORE_3 | |||
* @arg @ref LL_HSEM_SEMAPHORE_4 | |||
* @arg @ref LL_HSEM_SEMAPHORE_5 | |||
* @arg @ref LL_HSEM_SEMAPHORE_6 | |||
* @arg @ref LL_HSEM_SEMAPHORE_7 | |||
* @arg @ref LL_HSEM_SEMAPHORE_8 | |||
* @arg @ref LL_HSEM_SEMAPHORE_9 | |||
* @arg @ref LL_HSEM_SEMAPHORE_10 | |||
* @arg @ref LL_HSEM_SEMAPHORE_11 | |||
* @arg @ref LL_HSEM_SEMAPHORE_12 | |||
* @arg @ref LL_HSEM_SEMAPHORE_13 | |||
* @arg @ref LL_HSEM_SEMAPHORE_14 | |||
* @arg @ref LL_HSEM_SEMAPHORE_15 | |||
* @arg @ref LL_HSEM_SEMAPHORE_16 | |||
* @arg @ref LL_HSEM_SEMAPHORE_17 | |||
* @arg @ref LL_HSEM_SEMAPHORE_18 | |||
* @arg @ref LL_HSEM_SEMAPHORE_19 | |||
* @arg @ref LL_HSEM_SEMAPHORE_20 | |||
* @arg @ref LL_HSEM_SEMAPHORE_21 | |||
* @arg @ref LL_HSEM_SEMAPHORE_22 | |||
* @arg @ref LL_HSEM_SEMAPHORE_23 | |||
* @arg @ref LL_HSEM_SEMAPHORE_24 | |||
* @arg @ref LL_HSEM_SEMAPHORE_25 | |||
* @arg @ref LL_HSEM_SEMAPHORE_26 | |||
* @arg @ref LL_HSEM_SEMAPHORE_27 | |||
* @arg @ref LL_HSEM_SEMAPHORE_28 | |||
* @arg @ref LL_HSEM_SEMAPHORE_29 | |||
* @arg @ref LL_HSEM_SEMAPHORE_30 | |||
* @arg @ref LL_HSEM_SEMAPHORE_31 | |||
* @arg @ref LL_HSEM_SEMAPHORE_ALL | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_HSEM_IsEnabledIT_C1IER(HSEM_TypeDef *HSEMx, uint32_t SemaphoreMask) | |||
{ | |||
return ((READ_BIT(HSEMx->C1IER, SemaphoreMask) == (SemaphoreMask)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Enable interrupt. | |||
* @rmtoll C2IER ISEM LL_HSEM_EnableIT_C2IER | |||
* @param HSEMx HSEM Instance. | |||
* @param SemaphoreMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_HSEM_SEMAPHORE_0 | |||
* @arg @ref LL_HSEM_SEMAPHORE_1 | |||
* @arg @ref LL_HSEM_SEMAPHORE_2 | |||
* @arg @ref LL_HSEM_SEMAPHORE_3 | |||
* @arg @ref LL_HSEM_SEMAPHORE_4 | |||
* @arg @ref LL_HSEM_SEMAPHORE_5 | |||
* @arg @ref LL_HSEM_SEMAPHORE_6 | |||
* @arg @ref LL_HSEM_SEMAPHORE_7 | |||
* @arg @ref LL_HSEM_SEMAPHORE_8 | |||
* @arg @ref LL_HSEM_SEMAPHORE_9 | |||
* @arg @ref LL_HSEM_SEMAPHORE_10 | |||
* @arg @ref LL_HSEM_SEMAPHORE_11 | |||
* @arg @ref LL_HSEM_SEMAPHORE_12 | |||
* @arg @ref LL_HSEM_SEMAPHORE_13 | |||
* @arg @ref LL_HSEM_SEMAPHORE_14 | |||
* @arg @ref LL_HSEM_SEMAPHORE_15 | |||
* @arg @ref LL_HSEM_SEMAPHORE_16 | |||
* @arg @ref LL_HSEM_SEMAPHORE_17 | |||
* @arg @ref LL_HSEM_SEMAPHORE_18 | |||
* @arg @ref LL_HSEM_SEMAPHORE_19 | |||
* @arg @ref LL_HSEM_SEMAPHORE_20 | |||
* @arg @ref LL_HSEM_SEMAPHORE_21 | |||
* @arg @ref LL_HSEM_SEMAPHORE_22 | |||
* @arg @ref LL_HSEM_SEMAPHORE_23 | |||
* @arg @ref LL_HSEM_SEMAPHORE_24 | |||
* @arg @ref LL_HSEM_SEMAPHORE_25 | |||
* @arg @ref LL_HSEM_SEMAPHORE_26 | |||
* @arg @ref LL_HSEM_SEMAPHORE_27 | |||
* @arg @ref LL_HSEM_SEMAPHORE_28 | |||
* @arg @ref LL_HSEM_SEMAPHORE_29 | |||
* @arg @ref LL_HSEM_SEMAPHORE_30 | |||
* @arg @ref LL_HSEM_SEMAPHORE_31 | |||
* @arg @ref LL_HSEM_SEMAPHORE_ALL | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_HSEM_EnableIT_C2IER(HSEM_TypeDef *HSEMx, uint32_t SemaphoreMask) | |||
{ | |||
SET_BIT(HSEMx->C2IER, SemaphoreMask); | |||
} | |||
/** | |||
* @brief Disable interrupt. | |||
* @rmtoll C2IER ISEM LL_HSEM_DisableIT_C2IER | |||
* @param HSEMx HSEM Instance. | |||
* @param SemaphoreMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_HSEM_SEMAPHORE_0 | |||
* @arg @ref LL_HSEM_SEMAPHORE_1 | |||
* @arg @ref LL_HSEM_SEMAPHORE_2 | |||
* @arg @ref LL_HSEM_SEMAPHORE_3 | |||
* @arg @ref LL_HSEM_SEMAPHORE_4 | |||
* @arg @ref LL_HSEM_SEMAPHORE_5 | |||
* @arg @ref LL_HSEM_SEMAPHORE_6 | |||
* @arg @ref LL_HSEM_SEMAPHORE_7 | |||
* @arg @ref LL_HSEM_SEMAPHORE_8 | |||
* @arg @ref LL_HSEM_SEMAPHORE_9 | |||
* @arg @ref LL_HSEM_SEMAPHORE_10 | |||
* @arg @ref LL_HSEM_SEMAPHORE_11 | |||
* @arg @ref LL_HSEM_SEMAPHORE_12 | |||
* @arg @ref LL_HSEM_SEMAPHORE_13 | |||
* @arg @ref LL_HSEM_SEMAPHORE_14 | |||
* @arg @ref LL_HSEM_SEMAPHORE_15 | |||
* @arg @ref LL_HSEM_SEMAPHORE_16 | |||
* @arg @ref LL_HSEM_SEMAPHORE_17 | |||
* @arg @ref LL_HSEM_SEMAPHORE_18 | |||
* @arg @ref LL_HSEM_SEMAPHORE_19 | |||
* @arg @ref LL_HSEM_SEMAPHORE_20 | |||
* @arg @ref LL_HSEM_SEMAPHORE_21 | |||
* @arg @ref LL_HSEM_SEMAPHORE_22 | |||
* @arg @ref LL_HSEM_SEMAPHORE_23 | |||
* @arg @ref LL_HSEM_SEMAPHORE_24 | |||
* @arg @ref LL_HSEM_SEMAPHORE_25 | |||
* @arg @ref LL_HSEM_SEMAPHORE_26 | |||
* @arg @ref LL_HSEM_SEMAPHORE_27 | |||
* @arg @ref LL_HSEM_SEMAPHORE_28 | |||
* @arg @ref LL_HSEM_SEMAPHORE_29 | |||
* @arg @ref LL_HSEM_SEMAPHORE_30 | |||
* @arg @ref LL_HSEM_SEMAPHORE_31 | |||
* @arg @ref LL_HSEM_SEMAPHORE_ALL | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_HSEM_DisableIT_C2IER(HSEM_TypeDef *HSEMx, uint32_t SemaphoreMask) | |||
{ | |||
CLEAR_BIT(HSEMx->C2IER, SemaphoreMask); | |||
} | |||
/** | |||
* @brief Check if interrupt is enabled. | |||
* @rmtoll C2IER ISEM LL_HSEM_IsEnabledIT_C2IER | |||
* @param HSEMx HSEM Instance. | |||
* @param SemaphoreMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_HSEM_SEMAPHORE_0 | |||
* @arg @ref LL_HSEM_SEMAPHORE_1 | |||
* @arg @ref LL_HSEM_SEMAPHORE_2 | |||
* @arg @ref LL_HSEM_SEMAPHORE_3 | |||
* @arg @ref LL_HSEM_SEMAPHORE_4 | |||
* @arg @ref LL_HSEM_SEMAPHORE_5 | |||
* @arg @ref LL_HSEM_SEMAPHORE_6 | |||
* @arg @ref LL_HSEM_SEMAPHORE_7 | |||
* @arg @ref LL_HSEM_SEMAPHORE_8 | |||
* @arg @ref LL_HSEM_SEMAPHORE_9 | |||
* @arg @ref LL_HSEM_SEMAPHORE_10 | |||
* @arg @ref LL_HSEM_SEMAPHORE_11 | |||
* @arg @ref LL_HSEM_SEMAPHORE_12 | |||
* @arg @ref LL_HSEM_SEMAPHORE_13 | |||
* @arg @ref LL_HSEM_SEMAPHORE_14 | |||
* @arg @ref LL_HSEM_SEMAPHORE_15 | |||
* @arg @ref LL_HSEM_SEMAPHORE_16 | |||
* @arg @ref LL_HSEM_SEMAPHORE_17 | |||
* @arg @ref LL_HSEM_SEMAPHORE_18 | |||
* @arg @ref LL_HSEM_SEMAPHORE_19 | |||
* @arg @ref LL_HSEM_SEMAPHORE_20 | |||
* @arg @ref LL_HSEM_SEMAPHORE_21 | |||
* @arg @ref LL_HSEM_SEMAPHORE_22 | |||
* @arg @ref LL_HSEM_SEMAPHORE_23 | |||
* @arg @ref LL_HSEM_SEMAPHORE_24 | |||
* @arg @ref LL_HSEM_SEMAPHORE_25 | |||
* @arg @ref LL_HSEM_SEMAPHORE_26 | |||
* @arg @ref LL_HSEM_SEMAPHORE_27 | |||
* @arg @ref LL_HSEM_SEMAPHORE_28 | |||
* @arg @ref LL_HSEM_SEMAPHORE_29 | |||
* @arg @ref LL_HSEM_SEMAPHORE_30 | |||
* @arg @ref LL_HSEM_SEMAPHORE_31 | |||
* @arg @ref LL_HSEM_SEMAPHORE_ALL | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_HSEM_IsEnabledIT_C2IER(HSEM_TypeDef *HSEMx, uint32_t SemaphoreMask) | |||
{ | |||
return ((READ_BIT(HSEMx->C2IER, SemaphoreMask) == (SemaphoreMask)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup HSEM_LL_EF_FLAG_Management FLAG_Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Clear interrupt status. | |||
* @rmtoll C1ICR ISEM LL_HSEM_ClearFlag_C1ICR | |||
* @param HSEMx HSEM Instance. | |||
* @param SemaphoreMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_HSEM_SEMAPHORE_0 | |||
* @arg @ref LL_HSEM_SEMAPHORE_1 | |||
* @arg @ref LL_HSEM_SEMAPHORE_2 | |||
* @arg @ref LL_HSEM_SEMAPHORE_3 | |||
* @arg @ref LL_HSEM_SEMAPHORE_4 | |||
* @arg @ref LL_HSEM_SEMAPHORE_5 | |||
* @arg @ref LL_HSEM_SEMAPHORE_6 | |||
* @arg @ref LL_HSEM_SEMAPHORE_7 | |||
* @arg @ref LL_HSEM_SEMAPHORE_8 | |||
* @arg @ref LL_HSEM_SEMAPHORE_9 | |||
* @arg @ref LL_HSEM_SEMAPHORE_10 | |||
* @arg @ref LL_HSEM_SEMAPHORE_11 | |||
* @arg @ref LL_HSEM_SEMAPHORE_12 | |||
* @arg @ref LL_HSEM_SEMAPHORE_13 | |||
* @arg @ref LL_HSEM_SEMAPHORE_14 | |||
* @arg @ref LL_HSEM_SEMAPHORE_15 | |||
* @arg @ref LL_HSEM_SEMAPHORE_16 | |||
* @arg @ref LL_HSEM_SEMAPHORE_17 | |||
* @arg @ref LL_HSEM_SEMAPHORE_18 | |||
* @arg @ref LL_HSEM_SEMAPHORE_19 | |||
* @arg @ref LL_HSEM_SEMAPHORE_20 | |||
* @arg @ref LL_HSEM_SEMAPHORE_21 | |||
* @arg @ref LL_HSEM_SEMAPHORE_22 | |||
* @arg @ref LL_HSEM_SEMAPHORE_23 | |||
* @arg @ref LL_HSEM_SEMAPHORE_24 | |||
* @arg @ref LL_HSEM_SEMAPHORE_25 | |||
* @arg @ref LL_HSEM_SEMAPHORE_26 | |||
* @arg @ref LL_HSEM_SEMAPHORE_27 | |||
* @arg @ref LL_HSEM_SEMAPHORE_28 | |||
* @arg @ref LL_HSEM_SEMAPHORE_29 | |||
* @arg @ref LL_HSEM_SEMAPHORE_30 | |||
* @arg @ref LL_HSEM_SEMAPHORE_31 | |||
* @arg @ref LL_HSEM_SEMAPHORE_ALL | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_HSEM_ClearFlag_C1ICR(HSEM_TypeDef *HSEMx, uint32_t SemaphoreMask) | |||
{ | |||
WRITE_REG(HSEMx->C1ICR, SemaphoreMask); | |||
} | |||
/** | |||
* @brief Get interrupt status from ISR register. | |||
* @rmtoll C1ISR ISEM LL_HSEM_IsActiveFlag_C1ISR | |||
* @param HSEMx HSEM Instance. | |||
* @param SemaphoreMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_HSEM_SEMAPHORE_0 | |||
* @arg @ref LL_HSEM_SEMAPHORE_1 | |||
* @arg @ref LL_HSEM_SEMAPHORE_2 | |||
* @arg @ref LL_HSEM_SEMAPHORE_3 | |||
* @arg @ref LL_HSEM_SEMAPHORE_4 | |||
* @arg @ref LL_HSEM_SEMAPHORE_5 | |||
* @arg @ref LL_HSEM_SEMAPHORE_6 | |||
* @arg @ref LL_HSEM_SEMAPHORE_7 | |||
* @arg @ref LL_HSEM_SEMAPHORE_8 | |||
* @arg @ref LL_HSEM_SEMAPHORE_9 | |||
* @arg @ref LL_HSEM_SEMAPHORE_10 | |||
* @arg @ref LL_HSEM_SEMAPHORE_11 | |||
* @arg @ref LL_HSEM_SEMAPHORE_12 | |||
* @arg @ref LL_HSEM_SEMAPHORE_13 | |||
* @arg @ref LL_HSEM_SEMAPHORE_14 | |||
* @arg @ref LL_HSEM_SEMAPHORE_15 | |||
* @arg @ref LL_HSEM_SEMAPHORE_16 | |||
* @arg @ref LL_HSEM_SEMAPHORE_17 | |||
* @arg @ref LL_HSEM_SEMAPHORE_18 | |||
* @arg @ref LL_HSEM_SEMAPHORE_19 | |||
* @arg @ref LL_HSEM_SEMAPHORE_20 | |||
* @arg @ref LL_HSEM_SEMAPHORE_21 | |||
* @arg @ref LL_HSEM_SEMAPHORE_22 | |||
* @arg @ref LL_HSEM_SEMAPHORE_23 | |||
* @arg @ref LL_HSEM_SEMAPHORE_24 | |||
* @arg @ref LL_HSEM_SEMAPHORE_25 | |||
* @arg @ref LL_HSEM_SEMAPHORE_26 | |||
* @arg @ref LL_HSEM_SEMAPHORE_27 | |||
* @arg @ref LL_HSEM_SEMAPHORE_28 | |||
* @arg @ref LL_HSEM_SEMAPHORE_29 | |||
* @arg @ref LL_HSEM_SEMAPHORE_30 | |||
* @arg @ref LL_HSEM_SEMAPHORE_31 | |||
* @arg @ref LL_HSEM_SEMAPHORE_ALL | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_HSEM_IsActiveFlag_C1ISR(HSEM_TypeDef *HSEMx, uint32_t SemaphoreMask) | |||
{ | |||
return ((READ_BIT(HSEMx->C1ISR, SemaphoreMask) == (SemaphoreMask)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Get interrupt status from MISR register. | |||
* @rmtoll C1MISR ISEM LL_HSEM_IsActiveFlag_C1MISR | |||
* @param HSEMx HSEM Instance. | |||
* @param SemaphoreMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_HSEM_SEMAPHORE_0 | |||
* @arg @ref LL_HSEM_SEMAPHORE_1 | |||
* @arg @ref LL_HSEM_SEMAPHORE_2 | |||
* @arg @ref LL_HSEM_SEMAPHORE_3 | |||
* @arg @ref LL_HSEM_SEMAPHORE_4 | |||
* @arg @ref LL_HSEM_SEMAPHORE_5 | |||
* @arg @ref LL_HSEM_SEMAPHORE_6 | |||
* @arg @ref LL_HSEM_SEMAPHORE_7 | |||
* @arg @ref LL_HSEM_SEMAPHORE_8 | |||
* @arg @ref LL_HSEM_SEMAPHORE_9 | |||
* @arg @ref LL_HSEM_SEMAPHORE_10 | |||
* @arg @ref LL_HSEM_SEMAPHORE_11 | |||
* @arg @ref LL_HSEM_SEMAPHORE_12 | |||
* @arg @ref LL_HSEM_SEMAPHORE_13 | |||
* @arg @ref LL_HSEM_SEMAPHORE_14 | |||
* @arg @ref LL_HSEM_SEMAPHORE_15 | |||
* @arg @ref LL_HSEM_SEMAPHORE_16 | |||
* @arg @ref LL_HSEM_SEMAPHORE_17 | |||
* @arg @ref LL_HSEM_SEMAPHORE_18 | |||
* @arg @ref LL_HSEM_SEMAPHORE_19 | |||
* @arg @ref LL_HSEM_SEMAPHORE_20 | |||
* @arg @ref LL_HSEM_SEMAPHORE_21 | |||
* @arg @ref LL_HSEM_SEMAPHORE_22 | |||
* @arg @ref LL_HSEM_SEMAPHORE_23 | |||
* @arg @ref LL_HSEM_SEMAPHORE_24 | |||
* @arg @ref LL_HSEM_SEMAPHORE_25 | |||
* @arg @ref LL_HSEM_SEMAPHORE_26 | |||
* @arg @ref LL_HSEM_SEMAPHORE_27 | |||
* @arg @ref LL_HSEM_SEMAPHORE_28 | |||
* @arg @ref LL_HSEM_SEMAPHORE_29 | |||
* @arg @ref LL_HSEM_SEMAPHORE_30 | |||
* @arg @ref LL_HSEM_SEMAPHORE_31 | |||
* @arg @ref LL_HSEM_SEMAPHORE_ALL | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_HSEM_IsActiveFlag_C1MISR(HSEM_TypeDef *HSEMx, uint32_t SemaphoreMask) | |||
{ | |||
return ((READ_BIT(HSEMx->C1MISR, SemaphoreMask) == (SemaphoreMask)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Clear interrupt status. | |||
* @rmtoll C2ICR ISEM LL_HSEM_ClearFlag_C2ICR | |||
* @param HSEMx HSEM Instance. | |||
* @param SemaphoreMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_HSEM_SEMAPHORE_0 | |||
* @arg @ref LL_HSEM_SEMAPHORE_1 | |||
* @arg @ref LL_HSEM_SEMAPHORE_2 | |||
* @arg @ref LL_HSEM_SEMAPHORE_3 | |||
* @arg @ref LL_HSEM_SEMAPHORE_4 | |||
* @arg @ref LL_HSEM_SEMAPHORE_5 | |||
* @arg @ref LL_HSEM_SEMAPHORE_6 | |||
* @arg @ref LL_HSEM_SEMAPHORE_7 | |||
* @arg @ref LL_HSEM_SEMAPHORE_8 | |||
* @arg @ref LL_HSEM_SEMAPHORE_9 | |||
* @arg @ref LL_HSEM_SEMAPHORE_10 | |||
* @arg @ref LL_HSEM_SEMAPHORE_11 | |||
* @arg @ref LL_HSEM_SEMAPHORE_12 | |||
* @arg @ref LL_HSEM_SEMAPHORE_13 | |||
* @arg @ref LL_HSEM_SEMAPHORE_14 | |||
* @arg @ref LL_HSEM_SEMAPHORE_15 | |||
* @arg @ref LL_HSEM_SEMAPHORE_16 | |||
* @arg @ref LL_HSEM_SEMAPHORE_17 | |||
* @arg @ref LL_HSEM_SEMAPHORE_18 | |||
* @arg @ref LL_HSEM_SEMAPHORE_19 | |||
* @arg @ref LL_HSEM_SEMAPHORE_20 | |||
* @arg @ref LL_HSEM_SEMAPHORE_21 | |||
* @arg @ref LL_HSEM_SEMAPHORE_22 | |||
* @arg @ref LL_HSEM_SEMAPHORE_23 | |||
* @arg @ref LL_HSEM_SEMAPHORE_24 | |||
* @arg @ref LL_HSEM_SEMAPHORE_25 | |||
* @arg @ref LL_HSEM_SEMAPHORE_26 | |||
* @arg @ref LL_HSEM_SEMAPHORE_27 | |||
* @arg @ref LL_HSEM_SEMAPHORE_28 | |||
* @arg @ref LL_HSEM_SEMAPHORE_29 | |||
* @arg @ref LL_HSEM_SEMAPHORE_30 | |||
* @arg @ref LL_HSEM_SEMAPHORE_31 | |||
* @arg @ref LL_HSEM_SEMAPHORE_ALL | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_HSEM_ClearFlag_C2ICR(HSEM_TypeDef *HSEMx, uint32_t SemaphoreMask) | |||
{ | |||
WRITE_REG(HSEMx->C2ICR, SemaphoreMask); | |||
} | |||
/** | |||
* @brief Get interrupt status from ISR register. | |||
* @rmtoll C2ISR ISEM LL_HSEM_IsActiveFlag_C2ISR | |||
* @param HSEMx HSEM Instance. | |||
* @param SemaphoreMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_HSEM_SEMAPHORE_0 | |||
* @arg @ref LL_HSEM_SEMAPHORE_1 | |||
* @arg @ref LL_HSEM_SEMAPHORE_2 | |||
* @arg @ref LL_HSEM_SEMAPHORE_3 | |||
* @arg @ref LL_HSEM_SEMAPHORE_4 | |||
* @arg @ref LL_HSEM_SEMAPHORE_5 | |||
* @arg @ref LL_HSEM_SEMAPHORE_6 | |||
* @arg @ref LL_HSEM_SEMAPHORE_7 | |||
* @arg @ref LL_HSEM_SEMAPHORE_8 | |||
* @arg @ref LL_HSEM_SEMAPHORE_9 | |||
* @arg @ref LL_HSEM_SEMAPHORE_10 | |||
* @arg @ref LL_HSEM_SEMAPHORE_11 | |||
* @arg @ref LL_HSEM_SEMAPHORE_12 | |||
* @arg @ref LL_HSEM_SEMAPHORE_13 | |||
* @arg @ref LL_HSEM_SEMAPHORE_14 | |||
* @arg @ref LL_HSEM_SEMAPHORE_15 | |||
* @arg @ref LL_HSEM_SEMAPHORE_16 | |||
* @arg @ref LL_HSEM_SEMAPHORE_17 | |||
* @arg @ref LL_HSEM_SEMAPHORE_18 | |||
* @arg @ref LL_HSEM_SEMAPHORE_19 | |||
* @arg @ref LL_HSEM_SEMAPHORE_20 | |||
* @arg @ref LL_HSEM_SEMAPHORE_21 | |||
* @arg @ref LL_HSEM_SEMAPHORE_22 | |||
* @arg @ref LL_HSEM_SEMAPHORE_23 | |||
* @arg @ref LL_HSEM_SEMAPHORE_24 | |||
* @arg @ref LL_HSEM_SEMAPHORE_25 | |||
* @arg @ref LL_HSEM_SEMAPHORE_26 | |||
* @arg @ref LL_HSEM_SEMAPHORE_27 | |||
* @arg @ref LL_HSEM_SEMAPHORE_28 | |||
* @arg @ref LL_HSEM_SEMAPHORE_29 | |||
* @arg @ref LL_HSEM_SEMAPHORE_30 | |||
* @arg @ref LL_HSEM_SEMAPHORE_31 | |||
* @arg @ref LL_HSEM_SEMAPHORE_ALL | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_HSEM_IsActiveFlag_C2ISR(HSEM_TypeDef *HSEMx, uint32_t SemaphoreMask) | |||
{ | |||
return ((READ_BIT(HSEMx->C2ISR, SemaphoreMask) == (SemaphoreMask)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Get interrupt status from MISR register. | |||
* @rmtoll C2MISR ISEM LL_HSEM_IsActiveFlag_C2MISR | |||
* @param HSEMx HSEM Instance. | |||
* @param SemaphoreMask This parameter can be a combination of the following values: | |||
* @arg @ref LL_HSEM_SEMAPHORE_0 | |||
* @arg @ref LL_HSEM_SEMAPHORE_1 | |||
* @arg @ref LL_HSEM_SEMAPHORE_2 | |||
* @arg @ref LL_HSEM_SEMAPHORE_3 | |||
* @arg @ref LL_HSEM_SEMAPHORE_4 | |||
* @arg @ref LL_HSEM_SEMAPHORE_5 | |||
* @arg @ref LL_HSEM_SEMAPHORE_6 | |||
* @arg @ref LL_HSEM_SEMAPHORE_7 | |||
* @arg @ref LL_HSEM_SEMAPHORE_8 | |||
* @arg @ref LL_HSEM_SEMAPHORE_9 | |||
* @arg @ref LL_HSEM_SEMAPHORE_10 | |||
* @arg @ref LL_HSEM_SEMAPHORE_11 | |||
* @arg @ref LL_HSEM_SEMAPHORE_12 | |||
* @arg @ref LL_HSEM_SEMAPHORE_13 | |||
* @arg @ref LL_HSEM_SEMAPHORE_14 | |||
* @arg @ref LL_HSEM_SEMAPHORE_15 | |||
* @arg @ref LL_HSEM_SEMAPHORE_16 | |||
* @arg @ref LL_HSEM_SEMAPHORE_17 | |||
* @arg @ref LL_HSEM_SEMAPHORE_18 | |||
* @arg @ref LL_HSEM_SEMAPHORE_19 | |||
* @arg @ref LL_HSEM_SEMAPHORE_20 | |||
* @arg @ref LL_HSEM_SEMAPHORE_21 | |||
* @arg @ref LL_HSEM_SEMAPHORE_22 | |||
* @arg @ref LL_HSEM_SEMAPHORE_23 | |||
* @arg @ref LL_HSEM_SEMAPHORE_24 | |||
* @arg @ref LL_HSEM_SEMAPHORE_25 | |||
* @arg @ref LL_HSEM_SEMAPHORE_26 | |||
* @arg @ref LL_HSEM_SEMAPHORE_27 | |||
* @arg @ref LL_HSEM_SEMAPHORE_28 | |||
* @arg @ref LL_HSEM_SEMAPHORE_29 | |||
* @arg @ref LL_HSEM_SEMAPHORE_30 | |||
* @arg @ref LL_HSEM_SEMAPHORE_31 | |||
* @arg @ref LL_HSEM_SEMAPHORE_ALL | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_HSEM_IsActiveFlag_C2MISR(HSEM_TypeDef *HSEMx, uint32_t SemaphoreMask) | |||
{ | |||
return ((READ_BIT(HSEMx->C2MISR, SemaphoreMask) == (SemaphoreMask)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* defined(HSEM) */ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* __STM32WBxx_LL_HSEM_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,723 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_ll_ipcc.h | |||
* @author MCD Application Team | |||
* @brief Header file of IPCC LL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_LL_IPCC_H | |||
#define STM32WBxx_LL_IPCC_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx.h" | |||
/** @addtogroup STM32WBxx_LL_Driver | |||
* @{ | |||
*/ | |||
#if defined(IPCC) | |||
/** @defgroup IPCC_LL IPCC | |||
* @{ | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup IPCC_LL_Exported_Constants IPCC Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup IPCC_LL_EC_GET_FLAG Get Flags Defines | |||
* @brief Flags defines which can be used with LL_IPCC_ReadReg function | |||
* @{ | |||
*/ | |||
#define LL_IPCC_C1TOC2SR_CH1F IPCC_C1TOC2SR_CH1F_Msk /*!< C1 transmit to C2 receive Channel1 status flag before masking */ | |||
#define LL_IPCC_C1TOC2SR_CH2F IPCC_C1TOC2SR_CH2F_Msk /*!< C1 transmit to C2 receive Channel2 status flag before masking */ | |||
#define LL_IPCC_C1TOC2SR_CH3F IPCC_C1TOC2SR_CH3F_Msk /*!< C1 transmit to C2 receive Channel3 status flag before masking */ | |||
#define LL_IPCC_C1TOC2SR_CH4F IPCC_C1TOC2SR_CH4F_Msk /*!< C1 transmit to C2 receive Channel4 status flag before masking */ | |||
#define LL_IPCC_C1TOC2SR_CH5F IPCC_C1TOC2SR_CH5F_Msk /*!< C1 transmit to C2 receive Channel5 status flag before masking */ | |||
#define LL_IPCC_C1TOC2SR_CH6F IPCC_C1TOC2SR_CH6F_Msk /*!< C1 transmit to C2 receive Channel6 status flag before masking */ | |||
#define LL_IPCC_C2TOC1SR_CH1F IPCC_C2TOC1SR_CH1F_Msk /*!< C2 transmit to C1 receive Channel1 status flag before masking */ | |||
#define LL_IPCC_C2TOC1SR_CH2F IPCC_C2TOC1SR_CH2F_Msk /*!< C2 transmit to C1 receive Channel2 status flag before masking */ | |||
#define LL_IPCC_C2TOC1SR_CH3F IPCC_C2TOC1SR_CH3F_Msk /*!< C2 transmit to C1 receive Channel3 status flag before masking */ | |||
#define LL_IPCC_C2TOC1SR_CH4F IPCC_C2TOC1SR_CH4F_Msk /*!< C2 transmit to C1 receive Channel4 status flag before masking */ | |||
#define LL_IPCC_C2TOC1SR_CH5F IPCC_C2TOC1SR_CH5F_Msk /*!< C2 transmit to C1 receive Channel5 status flag before masking */ | |||
#define LL_IPCC_C2TOC1SR_CH6F IPCC_C2TOC1SR_CH6F_Msk /*!< C2 transmit to C1 receive Channel6 status flag before masking */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IPCC_LL_EC_Channel Channel | |||
* @{ | |||
*/ | |||
#define LL_IPCC_CHANNEL_1 (0x00000001U) /*!< IPCC Channel 1 */ | |||
#define LL_IPCC_CHANNEL_2 (0x00000002U) /*!< IPCC Channel 2 */ | |||
#define LL_IPCC_CHANNEL_3 (0x00000004U) /*!< IPCC Channel 3 */ | |||
#define LL_IPCC_CHANNEL_4 (0x00000008U) /*!< IPCC Channel 4 */ | |||
#define LL_IPCC_CHANNEL_5 (0x00000010U) /*!< IPCC Channel 5 */ | |||
#define LL_IPCC_CHANNEL_6 (0x00000020U) /*!< IPCC Channel 6 */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup IPCC_LL_Exported_Macros IPCC Exported Macros | |||
* @{ | |||
*/ | |||
/** @defgroup IPCC_LL_EM_WRITE_READ Common Write and read registers Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Write a value in IPCC register | |||
* @param __INSTANCE__ IPCC Instance | |||
* @param __REG__ Register to be written | |||
* @param __VALUE__ Value to be written in the register | |||
* @retval None | |||
*/ | |||
#define LL_IPCC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) | |||
/** | |||
* @brief Read a value in IPCC register | |||
* @param __INSTANCE__ IPCC Instance | |||
* @param __REG__ Register to be read | |||
* @retval Register value | |||
*/ | |||
#define LL_IPCC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup IPCC_LL_Exported_Functions IPCC Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup IPCC_LL_EF_IT_Management IT_Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable Transmit channel free interrupt for processor 1. | |||
* @rmtoll C1CR TXFIE LL_C1_IPCC_EnableIT_TXF | |||
* @param IPCCx IPCC Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C1_IPCC_EnableIT_TXF(IPCC_TypeDef *IPCCx) | |||
{ | |||
SET_BIT(IPCCx->C1CR, IPCC_C1CR_TXFIE); | |||
} | |||
/** | |||
* @brief Disable Transmit channel free interrupt for processor 1. | |||
* @rmtoll C1CR TXFIE LL_C1_IPCC_DisableIT_TXF | |||
* @param IPCCx IPCC Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C1_IPCC_DisableIT_TXF(IPCC_TypeDef *IPCCx) | |||
{ | |||
CLEAR_BIT(IPCCx->C1CR, IPCC_C1CR_TXFIE); | |||
} | |||
/** | |||
* @brief Check if Transmit channel free interrupt for processor 1 is enabled. | |||
* @rmtoll C1CR TXFIE LL_C1_IPCC_IsEnabledIT_TXF | |||
* @param IPCCx IPCC Instance. | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_C1_IPCC_IsEnabledIT_TXF(IPCC_TypeDef const *const IPCCx) | |||
{ | |||
return ((READ_BIT(IPCCx->C1CR, IPCC_C1CR_TXFIE) == (IPCC_C1CR_TXFIE)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Enable Receive channel occupied interrupt for processor 1. | |||
* @rmtoll C1CR RXOIE LL_C1_IPCC_EnableIT_RXO | |||
* @param IPCCx IPCC Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C1_IPCC_EnableIT_RXO(IPCC_TypeDef *IPCCx) | |||
{ | |||
SET_BIT(IPCCx->C1CR, IPCC_C1CR_RXOIE); | |||
} | |||
/** | |||
* @brief Disable Receive channel occupied interrupt for processor 1. | |||
* @rmtoll C1CR RXOIE LL_C1_IPCC_DisableIT_RXO | |||
* @param IPCCx IPCC Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C1_IPCC_DisableIT_RXO(IPCC_TypeDef *IPCCx) | |||
{ | |||
CLEAR_BIT(IPCCx->C1CR, IPCC_C1CR_RXOIE); | |||
} | |||
/** | |||
* @brief Check if Receive channel occupied interrupt for processor 1 is enabled. | |||
* @rmtoll C1CR RXOIE LL_C1_IPCC_IsEnabledIT_RXO | |||
* @param IPCCx IPCC Instance. | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_C1_IPCC_IsEnabledIT_RXO(IPCC_TypeDef const *const IPCCx) | |||
{ | |||
return ((READ_BIT(IPCCx->C1CR, IPCC_C1CR_RXOIE) == (IPCC_C1CR_RXOIE)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Enable Transmit channel free interrupt for processor 2. | |||
* @rmtoll C2CR TXFIE LL_C2_IPCC_EnableIT_TXF | |||
* @param IPCCx IPCC Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C2_IPCC_EnableIT_TXF(IPCC_TypeDef *IPCCx) | |||
{ | |||
SET_BIT(IPCCx->C2CR, IPCC_C2CR_TXFIE); | |||
} | |||
/** | |||
* @brief Disable Transmit channel free interrupt for processor 2. | |||
* @rmtoll C2CR TXFIE LL_C2_IPCC_DisableIT_TXF | |||
* @param IPCCx IPCC Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C2_IPCC_DisableIT_TXF(IPCC_TypeDef *IPCCx) | |||
{ | |||
CLEAR_BIT(IPCCx->C2CR, IPCC_C2CR_TXFIE); | |||
} | |||
/** | |||
* @brief Check if Transmit channel free interrupt for processor 2 is enabled. | |||
* @rmtoll C2CR TXFIE LL_C2_IPCC_IsEnabledIT_TXF | |||
* @param IPCCx IPCC Instance. | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_C2_IPCC_IsEnabledIT_TXF(IPCC_TypeDef const *const IPCCx) | |||
{ | |||
return ((READ_BIT(IPCCx->C2CR, IPCC_C2CR_TXFIE) == (IPCC_C2CR_TXFIE)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Enable Receive channel occupied interrupt for processor 2. | |||
* @rmtoll C2CR RXOIE LL_C2_IPCC_EnableIT_RXO | |||
* @param IPCCx IPCC Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C2_IPCC_EnableIT_RXO(IPCC_TypeDef *IPCCx) | |||
{ | |||
SET_BIT(IPCCx->C2CR, IPCC_C2CR_RXOIE); | |||
} | |||
/** | |||
* @brief Disable Receive channel occupied interrupt for processor 2. | |||
* @rmtoll C2CR RXOIE LL_C2_IPCC_DisableIT_RXO | |||
* @param IPCCx IPCC Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C2_IPCC_DisableIT_RXO(IPCC_TypeDef *IPCCx) | |||
{ | |||
CLEAR_BIT(IPCCx->C2CR, IPCC_C2CR_RXOIE); | |||
} | |||
/** | |||
* @brief Check if Receive channel occupied interrupt for processor 2 is enabled. | |||
* @rmtoll C2CR RXOIE LL_C2_IPCC_IsEnabledIT_RXO | |||
* @param IPCCx IPCC Instance. | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_C2_IPCC_IsEnabledIT_RXO(IPCC_TypeDef const *const IPCCx) | |||
{ | |||
return ((READ_BIT(IPCCx->C2CR, IPCC_C2CR_RXOIE) == (IPCC_C2CR_RXOIE)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IPCC_LL_EF_Configuration Configuration | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Unmask transmit channel free interrupt for processor 1. | |||
* @rmtoll C1MR CH1FM LL_C1_IPCC_EnableTransmitChannel\n | |||
* C1MR CH2FM LL_C1_IPCC_EnableTransmitChannel\n | |||
* C1MR CH3FM LL_C1_IPCC_EnableTransmitChannel\n | |||
* C1MR CH4FM LL_C1_IPCC_EnableTransmitChannel\n | |||
* C1MR CH5FM LL_C1_IPCC_EnableTransmitChannel\n | |||
* C1MR CH6FM LL_C1_IPCC_EnableTransmitChannel | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be a combination of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C1_IPCC_EnableTransmitChannel(IPCC_TypeDef *IPCCx, uint32_t Channel) | |||
{ | |||
CLEAR_BIT(IPCCx->C1MR, Channel << IPCC_C1MR_CH1FM_Pos); | |||
} | |||
/** | |||
* @brief Mask transmit channel free interrupt for processor 1. | |||
* @rmtoll C1MR CH1FM LL_C1_IPCC_DisableTransmitChannel\n | |||
* C1MR CH2FM LL_C1_IPCC_DisableTransmitChannel\n | |||
* C1MR CH3FM LL_C1_IPCC_DisableTransmitChannel\n | |||
* C1MR CH4FM LL_C1_IPCC_DisableTransmitChannel\n | |||
* C1MR CH5FM LL_C1_IPCC_DisableTransmitChannel\n | |||
* C1MR CH6FM LL_C1_IPCC_DisableTransmitChannel | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be a combination of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C1_IPCC_DisableTransmitChannel(IPCC_TypeDef *IPCCx, uint32_t Channel) | |||
{ | |||
SET_BIT(IPCCx->C1MR, Channel << IPCC_C1MR_CH1FM_Pos); | |||
} | |||
/** | |||
* @brief Check if Transmit channel free interrupt for processor 1 is masked. | |||
* @rmtoll C1MR CH1FM LL_C1_IPCC_IsEnabledTransmitChannel\n | |||
* C1MR CH2FM LL_C1_IPCC_IsEnabledTransmitChannel\n | |||
* C1MR CH3FM LL_C1_IPCC_IsEnabledTransmitChannel\n | |||
* C1MR CH4FM LL_C1_IPCC_IsEnabledTransmitChannel\n | |||
* C1MR CH5FM LL_C1_IPCC_IsEnabledTransmitChannel\n | |||
* C1MR CH6FM LL_C1_IPCC_IsEnabledTransmitChannel | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be one of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_C1_IPCC_IsEnabledTransmitChannel(IPCC_TypeDef const *const IPCCx, uint32_t Channel) | |||
{ | |||
return ((READ_BIT(IPCCx->C1MR, Channel << IPCC_C1MR_CH1FM_Pos) != (Channel << IPCC_C1MR_CH1FM_Pos)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Unmask receive channel occupied interrupt for processor 1. | |||
* @rmtoll C1MR CH1OM LL_C1_IPCC_EnableReceiveChannel\n | |||
* C1MR CH2OM LL_C1_IPCC_EnableReceiveChannel\n | |||
* C1MR CH3OM LL_C1_IPCC_EnableReceiveChannel\n | |||
* C1MR CH4OM LL_C1_IPCC_EnableReceiveChannel\n | |||
* C1MR CH5OM LL_C1_IPCC_EnableReceiveChannel\n | |||
* C1MR CH6OM LL_C1_IPCC_EnableReceiveChannel | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be a combination of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C1_IPCC_EnableReceiveChannel(IPCC_TypeDef *IPCCx, uint32_t Channel) | |||
{ | |||
CLEAR_BIT(IPCCx->C1MR, Channel); | |||
} | |||
/** | |||
* @brief Mask receive channel occupied interrupt for processor 1. | |||
* @rmtoll C1MR CH1OM LL_C1_IPCC_DisableReceiveChannel\n | |||
* C1MR CH2OM LL_C1_IPCC_DisableReceiveChannel\n | |||
* C1MR CH3OM LL_C1_IPCC_DisableReceiveChannel\n | |||
* C1MR CH4OM LL_C1_IPCC_DisableReceiveChannel\n | |||
* C1MR CH5OM LL_C1_IPCC_DisableReceiveChannel\n | |||
* C1MR CH6OM LL_C1_IPCC_DisableReceiveChannel | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be a combination of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C1_IPCC_DisableReceiveChannel(IPCC_TypeDef *IPCCx, uint32_t Channel) | |||
{ | |||
SET_BIT(IPCCx->C1MR, Channel); | |||
} | |||
/** | |||
* @brief Check if Receive channel occupied interrupt for processor 1 is masked. | |||
* @rmtoll C1MR CH1OM LL_C1_IPCC_IsEnabledReceiveChannel\n | |||
* C1MR CH2OM LL_C1_IPCC_IsEnabledReceiveChannel\n | |||
* C1MR CH3OM LL_C1_IPCC_IsEnabledReceiveChannel\n | |||
* C1MR CH4OM LL_C1_IPCC_IsEnabledReceiveChannel\n | |||
* C1MR CH5OM LL_C1_IPCC_IsEnabledReceiveChannel\n | |||
* C1MR CH6OM LL_C1_IPCC_IsEnabledReceiveChannel | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be one of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_C1_IPCC_IsEnabledReceiveChannel(IPCC_TypeDef const *const IPCCx, uint32_t Channel) | |||
{ | |||
return ((READ_BIT(IPCCx->C1MR, Channel) != (Channel)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Unmask transmit channel free interrupt for processor 2. | |||
* @rmtoll C2MR CH1FM LL_C2_IPCC_EnableTransmitChannel\n | |||
* C2MR CH2FM LL_C2_IPCC_EnableTransmitChannel\n | |||
* C2MR CH3FM LL_C2_IPCC_EnableTransmitChannel\n | |||
* C2MR CH4FM LL_C2_IPCC_EnableTransmitChannel\n | |||
* C2MR CH5FM LL_C2_IPCC_EnableTransmitChannel\n | |||
* C2MR CH6FM LL_C2_IPCC_EnableTransmitChannel | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be a combination of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C2_IPCC_EnableTransmitChannel(IPCC_TypeDef *IPCCx, uint32_t Channel) | |||
{ | |||
CLEAR_BIT(IPCCx->C2MR, Channel << IPCC_C2MR_CH1FM_Pos); | |||
} | |||
/** | |||
* @brief Mask transmit channel free interrupt for processor 2. | |||
* @rmtoll C2MR CH1FM LL_C2_IPCC_DisableTransmitChannel\n | |||
* C2MR CH2FM LL_C2_IPCC_DisableTransmitChannel\n | |||
* C2MR CH3FM LL_C2_IPCC_DisableTransmitChannel\n | |||
* C2MR CH4FM LL_C2_IPCC_DisableTransmitChannel\n | |||
* C2MR CH5FM LL_C2_IPCC_DisableTransmitChannel\n | |||
* C2MR CH6FM LL_C2_IPCC_DisableTransmitChannel | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be a combination of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C2_IPCC_DisableTransmitChannel(IPCC_TypeDef *IPCCx, uint32_t Channel) | |||
{ | |||
SET_BIT(IPCCx->C2MR, Channel << (IPCC_C2MR_CH1FM_Pos)); | |||
} | |||
/** | |||
* @brief Check if Transmit channel free interrupt for processor 2 is masked. | |||
* @rmtoll C2MR CH1FM LL_C2_IPCC_IsEnabledTransmitChannel\n | |||
* C2MR CH2FM LL_C2_IPCC_IsEnabledTransmitChannel\n | |||
* C2MR CH3FM LL_C2_IPCC_IsEnabledTransmitChannel\n | |||
* C2MR CH4FM LL_C2_IPCC_IsEnabledTransmitChannel\n | |||
* C2MR CH5FM LL_C2_IPCC_IsEnabledTransmitChannel\n | |||
* C2MR CH6FM LL_C2_IPCC_IsEnabledTransmitChannel | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be one of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_C2_IPCC_IsEnabledTransmitChannel(IPCC_TypeDef const *const IPCCx, uint32_t Channel) | |||
{ | |||
return ((READ_BIT(IPCCx->C2MR, Channel << IPCC_C2MR_CH1FM_Pos) != (Channel << IPCC_C2MR_CH1FM_Pos)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Unmask receive channel occupied interrupt for processor 2. | |||
* @rmtoll C2MR CH1OM LL_C2_IPCC_EnableReceiveChannel\n | |||
* C2MR CH2OM LL_C2_IPCC_EnableReceiveChannel\n | |||
* C2MR CH3OM LL_C2_IPCC_EnableReceiveChannel\n | |||
* C2MR CH4OM LL_C2_IPCC_EnableReceiveChannel\n | |||
* C2MR CH5OM LL_C2_IPCC_EnableReceiveChannel\n | |||
* C2MR CH6OM LL_C2_IPCC_EnableReceiveChannel | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be a combination of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C2_IPCC_EnableReceiveChannel(IPCC_TypeDef *IPCCx, uint32_t Channel) | |||
{ | |||
CLEAR_BIT(IPCCx->C2MR, Channel); | |||
} | |||
/** | |||
* @brief Mask receive channel occupied interrupt for processor 1. | |||
* @rmtoll C2MR CH1OM LL_C2_IPCC_DisableReceiveChannel\n | |||
* C2MR CH2OM LL_C2_IPCC_DisableReceiveChannel\n | |||
* C2MR CH3OM LL_C2_IPCC_DisableReceiveChannel\n | |||
* C2MR CH4OM LL_C2_IPCC_DisableReceiveChannel\n | |||
* C2MR CH5OM LL_C2_IPCC_DisableReceiveChannel\n | |||
* C2MR CH6OM LL_C2_IPCC_DisableReceiveChannel | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be a combination of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C2_IPCC_DisableReceiveChannel(IPCC_TypeDef *IPCCx, uint32_t Channel) | |||
{ | |||
SET_BIT(IPCCx->C2MR, Channel); | |||
} | |||
/** | |||
* @brief Check if Receive channel occupied interrupt for processor 2 is masked. | |||
* @rmtoll C2MR CH1OM LL_C2_IPCC_IsEnabledReceiveChannel\n | |||
* C2MR CH2OM LL_C2_IPCC_IsEnabledReceiveChannel\n | |||
* C2MR CH3OM LL_C2_IPCC_IsEnabledReceiveChannel\n | |||
* C2MR CH4OM LL_C2_IPCC_IsEnabledReceiveChannel\n | |||
* C2MR CH5OM LL_C2_IPCC_IsEnabledReceiveChannel\n | |||
* C2MR CH6OM LL_C2_IPCC_IsEnabledReceiveChannel | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be one of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_C2_IPCC_IsEnabledReceiveChannel(IPCC_TypeDef const *const IPCCx, uint32_t Channel) | |||
{ | |||
return ((READ_BIT(IPCCx->C2MR, Channel) != (Channel)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IPCC_LL_EF_FLAG_Management FLAG_Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Clear IPCC receive channel status for processor 1. | |||
* @note Associated with IPCC_C2TOC1SR.CHxF | |||
* @rmtoll C1SCR CH1C LL_C1_IPCC_ClearFlag_CHx\n | |||
* C1SCR CH2C LL_C1_IPCC_ClearFlag_CHx\n | |||
* C1SCR CH3C LL_C1_IPCC_ClearFlag_CHx\n | |||
* C1SCR CH4C LL_C1_IPCC_ClearFlag_CHx\n | |||
* C1SCR CH5C LL_C1_IPCC_ClearFlag_CHx\n | |||
* C1SCR CH6C LL_C1_IPCC_ClearFlag_CHx | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be a combination of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C1_IPCC_ClearFlag_CHx(IPCC_TypeDef *IPCCx, uint32_t Channel) | |||
{ | |||
WRITE_REG(IPCCx->C1SCR, Channel); | |||
} | |||
/** | |||
* @brief Set IPCC transmit channel status for processor 1. | |||
* @note Associated with IPCC_C1TOC2SR.CHxF | |||
* @rmtoll C1SCR CH1S LL_C1_IPCC_SetFlag_CHx\n | |||
* C1SCR CH2S LL_C1_IPCC_SetFlag_CHx\n | |||
* C1SCR CH3S LL_C1_IPCC_SetFlag_CHx\n | |||
* C1SCR CH4S LL_C1_IPCC_SetFlag_CHx\n | |||
* C1SCR CH5S LL_C1_IPCC_SetFlag_CHx\n | |||
* C1SCR CH6S LL_C1_IPCC_SetFlag_CHx | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be a combination of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C1_IPCC_SetFlag_CHx(IPCC_TypeDef *IPCCx, uint32_t Channel) | |||
{ | |||
WRITE_REG(IPCCx->C1SCR, Channel << IPCC_C1SCR_CH1S_Pos); | |||
} | |||
/** | |||
* @brief Get channel status for processor 1. | |||
* @rmtoll C1TOC2SR CH1F LL_C1_IPCC_IsActiveFlag_CHx\n | |||
* C1TOC2SR CH2F LL_C1_IPCC_IsActiveFlag_CHx\n | |||
* C1TOC2SR CH3F LL_C1_IPCC_IsActiveFlag_CHx\n | |||
* C1TOC2SR CH4F LL_C1_IPCC_IsActiveFlag_CHx\n | |||
* C1TOC2SR CH5F LL_C1_IPCC_IsActiveFlag_CHx\n | |||
* C1TOC2SR CH6F LL_C1_IPCC_IsActiveFlag_CHx | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be one of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_C1_IPCC_IsActiveFlag_CHx(IPCC_TypeDef const *const IPCCx, uint32_t Channel) | |||
{ | |||
return ((READ_BIT(IPCCx->C1TOC2SR, Channel) == (Channel)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Clear IPCC receive channel status for processor 2. | |||
* @note Associated with IPCC_C1TOC2SR.CHxF | |||
* @rmtoll C2SCR CH1C LL_C2_IPCC_ClearFlag_CHx\n | |||
* C2SCR CH2C LL_C2_IPCC_ClearFlag_CHx\n | |||
* C2SCR CH3C LL_C2_IPCC_ClearFlag_CHx\n | |||
* C2SCR CH4C LL_C2_IPCC_ClearFlag_CHx\n | |||
* C2SCR CH5C LL_C2_IPCC_ClearFlag_CHx\n | |||
* C2SCR CH6C LL_C2_IPCC_ClearFlag_CHx | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be a combination of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C2_IPCC_ClearFlag_CHx(IPCC_TypeDef *IPCCx, uint32_t Channel) | |||
{ | |||
WRITE_REG(IPCCx->C2SCR, Channel); | |||
} | |||
/** | |||
* @brief Set IPCC transmit channel status for processor 2. | |||
* @note Associated with IPCC_C2TOC1SR.CHxF | |||
* @rmtoll C2SCR CH1S LL_C2_IPCC_SetFlag_CHx\n | |||
* C2SCR CH2S LL_C2_IPCC_SetFlag_CHx\n | |||
* C2SCR CH3S LL_C2_IPCC_SetFlag_CHx\n | |||
* C2SCR CH4S LL_C2_IPCC_SetFlag_CHx\n | |||
* C2SCR CH5S LL_C2_IPCC_SetFlag_CHx\n | |||
* C2SCR CH6S LL_C2_IPCC_SetFlag_CHx | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be a combination of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_C2_IPCC_SetFlag_CHx(IPCC_TypeDef *IPCCx, uint32_t Channel) | |||
{ | |||
WRITE_REG(IPCCx->C2SCR, Channel << IPCC_C2SCR_CH1S_Pos); | |||
} | |||
/** | |||
* @brief Get channel status for processor 2. | |||
* @rmtoll C2TOC1SR CH1F LL_C2_IPCC_IsActiveFlag_CHx\n | |||
* C2TOC1SR CH2F LL_C2_IPCC_IsActiveFlag_CHx\n | |||
* C2TOC1SR CH3F LL_C2_IPCC_IsActiveFlag_CHx\n | |||
* C2TOC1SR CH4F LL_C2_IPCC_IsActiveFlag_CHx\n | |||
* C2TOC1SR CH5F LL_C2_IPCC_IsActiveFlag_CHx\n | |||
* C2TOC1SR CH6F LL_C2_IPCC_IsActiveFlag_CHx | |||
* @param IPCCx IPCC Instance. | |||
* @param Channel This parameter can be one of the following values: | |||
* @arg @ref LL_IPCC_CHANNEL_1 | |||
* @arg @ref LL_IPCC_CHANNEL_2 | |||
* @arg @ref LL_IPCC_CHANNEL_3 | |||
* @arg @ref LL_IPCC_CHANNEL_4 | |||
* @arg @ref LL_IPCC_CHANNEL_5 | |||
* @arg @ref LL_IPCC_CHANNEL_6 | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_C2_IPCC_IsActiveFlag_CHx(IPCC_TypeDef const *const IPCCx, uint32_t Channel) | |||
{ | |||
return ((READ_BIT(IPCCx->C2TOC1SR, Channel) == (Channel)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* defined(IPCC) */ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_LL_IPCC_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,342 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_ll_iwdg.h | |||
* @author MCD Application Team | |||
* @brief Header file of IWDG LL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_LL_IWDG_H | |||
#define STM32WBxx_LL_IWDG_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx.h" | |||
/** @addtogroup STM32WBxx_LL_Driver | |||
* @{ | |||
*/ | |||
#if defined(IWDG) | |||
/** @defgroup IWDG_LL IWDG | |||
* @{ | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/** @defgroup IWDG_LL_Private_Constants IWDG Private Constants | |||
* @{ | |||
*/ | |||
#define LL_IWDG_KEY_RELOAD 0x0000AAAAU /*!< IWDG Reload Counter Enable */ | |||
#define LL_IWDG_KEY_ENABLE 0x0000CCCCU /*!< IWDG Peripheral Enable */ | |||
#define LL_IWDG_KEY_WR_ACCESS_ENABLE 0x00005555U /*!< IWDG KR Write Access Enable */ | |||
#define LL_IWDG_KEY_WR_ACCESS_DISABLE 0x00000000U /*!< IWDG KR Write Access Disable */ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup IWDG_LL_Exported_Constants IWDG Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup IWDG_LL_EC_GET_FLAG Get Flags Defines | |||
* @brief Flags defines which can be used with LL_IWDG_ReadReg function | |||
* @{ | |||
*/ | |||
#define LL_IWDG_SR_PVU IWDG_SR_PVU /*!< Watchdog prescaler value update */ | |||
#define LL_IWDG_SR_RVU IWDG_SR_RVU /*!< Watchdog counter reload value update */ | |||
#define LL_IWDG_SR_WVU IWDG_SR_WVU /*!< Watchdog counter window value update */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IWDG_LL_EC_PRESCALER Prescaler Divider | |||
* @{ | |||
*/ | |||
#define LL_IWDG_PRESCALER_4 0x00000000U /*!< Divider by 4 */ | |||
#define LL_IWDG_PRESCALER_8 (IWDG_PR_PR_0) /*!< Divider by 8 */ | |||
#define LL_IWDG_PRESCALER_16 (IWDG_PR_PR_1) /*!< Divider by 16 */ | |||
#define LL_IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< Divider by 32 */ | |||
#define LL_IWDG_PRESCALER_64 (IWDG_PR_PR_2) /*!< Divider by 64 */ | |||
#define LL_IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< Divider by 128 */ | |||
#define LL_IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< Divider by 256 */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup IWDG_LL_Exported_Macros IWDG Exported Macros | |||
* @{ | |||
*/ | |||
/** @defgroup IWDG_LL_EM_WRITE_READ Common Write and read registers Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Write a value in IWDG register | |||
* @param __INSTANCE__ IWDG Instance | |||
* @param __REG__ Register to be written | |||
* @param __VALUE__ Value to be written in the register | |||
* @retval None | |||
*/ | |||
#define LL_IWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) | |||
/** | |||
* @brief Read a value in IWDG register | |||
* @param __INSTANCE__ IWDG Instance | |||
* @param __REG__ Register to be read | |||
* @retval Register value | |||
*/ | |||
#define LL_IWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup IWDG_LL_Exported_Functions IWDG Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup IWDG_LL_EF_Configuration Configuration | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Start the Independent Watchdog | |||
* @note Except if the hardware watchdog option is selected | |||
* @rmtoll KR KEY LL_IWDG_Enable | |||
* @param IWDGx IWDG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_IWDG_Enable(IWDG_TypeDef *IWDGx) | |||
{ | |||
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_ENABLE); | |||
} | |||
/** | |||
* @brief Reloads IWDG counter with value defined in the reload register | |||
* @rmtoll KR KEY LL_IWDG_ReloadCounter | |||
* @param IWDGx IWDG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_IWDG_ReloadCounter(IWDG_TypeDef *IWDGx) | |||
{ | |||
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_RELOAD); | |||
} | |||
/** | |||
* @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers | |||
* @rmtoll KR KEY LL_IWDG_EnableWriteAccess | |||
* @param IWDGx IWDG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_IWDG_EnableWriteAccess(IWDG_TypeDef *IWDGx) | |||
{ | |||
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_ENABLE); | |||
} | |||
/** | |||
* @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers | |||
* @rmtoll KR KEY LL_IWDG_DisableWriteAccess | |||
* @param IWDGx IWDG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_IWDG_DisableWriteAccess(IWDG_TypeDef *IWDGx) | |||
{ | |||
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_DISABLE); | |||
} | |||
/** | |||
* @brief Select the prescaler of the IWDG | |||
* @rmtoll PR PR LL_IWDG_SetPrescaler | |||
* @param IWDGx IWDG Instance | |||
* @param Prescaler This parameter can be one of the following values: | |||
* @arg @ref LL_IWDG_PRESCALER_4 | |||
* @arg @ref LL_IWDG_PRESCALER_8 | |||
* @arg @ref LL_IWDG_PRESCALER_16 | |||
* @arg @ref LL_IWDG_PRESCALER_32 | |||
* @arg @ref LL_IWDG_PRESCALER_64 | |||
* @arg @ref LL_IWDG_PRESCALER_128 | |||
* @arg @ref LL_IWDG_PRESCALER_256 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_IWDG_SetPrescaler(IWDG_TypeDef *IWDGx, uint32_t Prescaler) | |||
{ | |||
WRITE_REG(IWDGx->PR, IWDG_PR_PR & Prescaler); | |||
} | |||
/** | |||
* @brief Get the selected prescaler of the IWDG | |||
* @rmtoll PR PR LL_IWDG_GetPrescaler | |||
* @param IWDGx IWDG Instance | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_IWDG_PRESCALER_4 | |||
* @arg @ref LL_IWDG_PRESCALER_8 | |||
* @arg @ref LL_IWDG_PRESCALER_16 | |||
* @arg @ref LL_IWDG_PRESCALER_32 | |||
* @arg @ref LL_IWDG_PRESCALER_64 | |||
* @arg @ref LL_IWDG_PRESCALER_128 | |||
* @arg @ref LL_IWDG_PRESCALER_256 | |||
*/ | |||
__STATIC_INLINE uint32_t LL_IWDG_GetPrescaler(IWDG_TypeDef *IWDGx) | |||
{ | |||
return (READ_REG(IWDGx->PR)); | |||
} | |||
/** | |||
* @brief Specify the IWDG down-counter reload value | |||
* @rmtoll RLR RL LL_IWDG_SetReloadCounter | |||
* @param IWDGx IWDG Instance | |||
* @param Counter Value between Min_Data=0 and Max_Data=0x0FFF | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_IWDG_SetReloadCounter(IWDG_TypeDef *IWDGx, uint32_t Counter) | |||
{ | |||
WRITE_REG(IWDGx->RLR, IWDG_RLR_RL & Counter); | |||
} | |||
/** | |||
* @brief Get the specified IWDG down-counter reload value | |||
* @rmtoll RLR RL LL_IWDG_GetReloadCounter | |||
* @param IWDGx IWDG Instance | |||
* @retval Value between Min_Data=0 and Max_Data=0x0FFF | |||
*/ | |||
__STATIC_INLINE uint32_t LL_IWDG_GetReloadCounter(IWDG_TypeDef *IWDGx) | |||
{ | |||
return (READ_REG(IWDGx->RLR)); | |||
} | |||
/** | |||
* @brief Specify high limit of the window value to be compared to the down-counter. | |||
* @rmtoll WINR WIN LL_IWDG_SetWindow | |||
* @param IWDGx IWDG Instance | |||
* @param Window Value between Min_Data=0 and Max_Data=0x0FFF | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_IWDG_SetWindow(IWDG_TypeDef *IWDGx, uint32_t Window) | |||
{ | |||
WRITE_REG(IWDGx->WINR, IWDG_WINR_WIN & Window); | |||
} | |||
/** | |||
* @brief Get the high limit of the window value specified. | |||
* @rmtoll WINR WIN LL_IWDG_GetWindow | |||
* @param IWDGx IWDG Instance | |||
* @retval Value between Min_Data=0 and Max_Data=0x0FFF | |||
*/ | |||
__STATIC_INLINE uint32_t LL_IWDG_GetWindow(IWDG_TypeDef *IWDGx) | |||
{ | |||
return (READ_REG(IWDGx->WINR)); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup IWDG_LL_EF_FLAG_Management FLAG_Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Check if flag Prescaler Value Update is set or not | |||
* @rmtoll SR PVU LL_IWDG_IsActiveFlag_PVU | |||
* @param IWDGx IWDG Instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_PVU(IWDG_TypeDef *IWDGx) | |||
{ | |||
return ((READ_BIT(IWDGx->SR, IWDG_SR_PVU) == (IWDG_SR_PVU)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Check if flag Reload Value Update is set or not | |||
* @rmtoll SR RVU LL_IWDG_IsActiveFlag_RVU | |||
* @param IWDGx IWDG Instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_RVU(IWDG_TypeDef *IWDGx) | |||
{ | |||
return ((READ_BIT(IWDGx->SR, IWDG_SR_RVU) == (IWDG_SR_RVU)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Check if flag Window Value Update is set or not | |||
* @rmtoll SR WVU LL_IWDG_IsActiveFlag_WVU | |||
* @param IWDGx IWDG Instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_WVU(IWDG_TypeDef *IWDGx) | |||
{ | |||
return ((READ_BIT(IWDGx->SR, IWDG_SR_WVU) == (IWDG_SR_WVU)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Check if all flags Prescaler, Reload & Window Value Update are reset or not | |||
* @rmtoll SR PVU LL_IWDG_IsReady\n | |||
* SR WVU LL_IWDG_IsReady\n | |||
* SR RVU LL_IWDG_IsReady | |||
* @param IWDGx IWDG Instance | |||
* @retval State of bits (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_IWDG_IsReady(IWDG_TypeDef *IWDGx) | |||
{ | |||
return ((READ_BIT(IWDGx->SR, IWDG_SR_PVU | IWDG_SR_RVU | IWDG_SR_WVU) == 0U) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* IWDG */ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_LL_IWDG_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,532 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_ll_pka.h | |||
* @author MCD Application Team | |||
* @brief Header file of PKA LL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_LL_PKA_H | |||
#define STM32WBxx_LL_PKA_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx.h" | |||
/** @addtogroup STM32WBxx_LL_Driver | |||
* @{ | |||
*/ | |||
#if defined(PKA) | |||
/** @defgroup PKA_LL PKA | |||
* @{ | |||
*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
#if defined(USE_FULL_LL_DRIVER) | |||
/** @defgroup PKA_LL_ES_INIT PKA Exported Init structure | |||
* @{ | |||
*/ | |||
/** | |||
* @brief PKA Init structures definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t Mode; /*!< Specifies the PKA operation mode. | |||
This parameter can be a value of @ref PKA_LL_EC_MODE. | |||
This feature can be modified afterwards using unitary function @ref LL_PKA_SetMode(). */ | |||
} LL_PKA_InitTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
#endif /* USE_FULL_LL_DRIVER */ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup PKA_LL_Exported_Constants PKA Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup PKA_LL_EC_GET_FLAG Get Flags Defines | |||
* @brief Flags defines which can be used with LL_PKA_ReadReg function | |||
* @{ | |||
*/ | |||
#define LL_PKA_SR_ADDRERRF PKA_SR_ADDRERRF | |||
#define LL_PKA_SR_RAMERRF PKA_SR_RAMERRF | |||
#define LL_PKA_SR_PROCENDF PKA_SR_PROCENDF | |||
#define LL_PKA_SR_BUSY PKA_SR_BUSY | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PKA_LL_EC_IT IT Defines | |||
* @brief IT defines which can be used with LL_PKA_ReadReg and LL_PKA_WriteReg functions | |||
* @{ | |||
*/ | |||
#define LL_PKA_CR_ADDRERRIE PKA_CR_ADDRERRIE | |||
#define LL_PKA_CR_RAMERRIE PKA_CR_RAMERRIE | |||
#define LL_PKA_CR_PROCENDIE PKA_CR_PROCENDIE | |||
#define LL_PKA_CLRFR_PROCENDFC PKA_CLRFR_PROCENDFC | |||
#define LL_PKA_CLRFR_RAMERRFC PKA_CLRFR_RAMERRFC | |||
#define LL_PKA_CLRFR_ADDRERRFC PKA_CLRFR_ADDRERRFC | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PKA_LL_EC_MODE Operation Mode | |||
* @brief List of opearation mode. | |||
* @{ | |||
*/ | |||
#define LL_PKA_MODE_MONTGOMERY_PARAM_MOD_EXP ((uint32_t)0x00000000U) /*!< Compute Montgomery parameter and modular exponentiation */ | |||
#define LL_PKA_MODE_MONTGOMERY_PARAM ((uint32_t)0x00000001U) /*!< Compute Montgomery parameter only */ | |||
#define LL_PKA_MODE_MODULAR_EXP ((uint32_t)0x00000002U) /*!< Compute modular exponentiation only (Montgomery parameter should be loaded) */ | |||
#define LL_PKA_MODE_MONTGOMERY_PARAM_ECC ((uint32_t)0x00000020U) /*!< Compute Montgomery parameter and compute ECC kP operation */ | |||
#define LL_PKA_MODE_ECC_KP_PRIMITIVE ((uint32_t)0x00000022U) /*!< Compute the ECC kP primitive only (Montgomery parameter should be loaded) */ | |||
#define LL_PKA_MODE_ECDSA_SIGNATURE ((uint32_t)0x00000024U) /*!< ECDSA signature */ | |||
#define LL_PKA_MODE_ECDSA_VERIFICATION ((uint32_t)0x00000026U) /*!< ECDSA verification */ | |||
#define LL_PKA_MODE_POINT_CHECK ((uint32_t)0x00000028U) /*!< Point check */ | |||
#define LL_PKA_MODE_RSA_CRT_EXP ((uint32_t)0x00000007U) /*!< RSA CRT exponentiation */ | |||
#define LL_PKA_MODE_MODULAR_INV ((uint32_t)0x00000008U) /*!< Modular inversion */ | |||
#define LL_PKA_MODE_ARITHMETIC_ADD ((uint32_t)0x00000009U) /*!< Arithmetic addition */ | |||
#define LL_PKA_MODE_ARITHMETIC_SUB ((uint32_t)0x0000000AU) /*!< Arithmetic subtraction */ | |||
#define LL_PKA_MODE_ARITHMETIC_MUL ((uint32_t)0x0000000BU) /*!< Arithmetic multiplication */ | |||
#define LL_PKA_MODE_COMPARISON ((uint32_t)0x0000000CU) /*!< Comparison */ | |||
#define LL_PKA_MODE_MODULAR_REDUC ((uint32_t)0x0000000DU) /*!< Modular reduction */ | |||
#define LL_PKA_MODE_MODULAR_ADD ((uint32_t)0x0000000EU) /*!< Modular addition */ | |||
#define LL_PKA_MODE_MODULAR_SUB ((uint32_t)0x0000000FU) /*!< Modular subtraction */ | |||
#define LL_PKA_MODE_MONTGOMERY_MUL ((uint32_t)0x00000010U) /*!< Montgomery multiplication */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup PKA_LL_Exported_Macros PKA Exported Macros | |||
* @{ | |||
*/ | |||
/** @defgroup PKA_LL_EM_WRITE_READ Common Write and read registers Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Write a value in PKA register | |||
* @param __INSTANCE__ PKA Instance | |||
* @param __REG__ Register to be written | |||
* @param __VALUE__ Value to be written in the register | |||
* @retval None | |||
*/ | |||
#define LL_PKA_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) | |||
/** | |||
* @brief Read a value in PKA register | |||
* @param __INSTANCE__ PKA Instance | |||
* @param __REG__ Register to be read | |||
* @retval Register value | |||
*/ | |||
#define LL_PKA_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup PKA_LL_Exported_Functions PKA Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup PKA_LL_EF_Configuration Configuration | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Configure PKA peripheral. | |||
* @brief Set PKA operating mode. | |||
* @rmtoll CR MODE LL_PKA_Config | |||
* @param PKAx PKA Instance. | |||
* @param Mode This parameter can be one of the following values: | |||
* @arg @ref LL_PKA_MODE_MONTGOMERY_PARAM_MOD_EXP | |||
* @arg @ref LL_PKA_MODE_MONTGOMERY_PARAM | |||
* @arg @ref LL_PKA_MODE_MODULAR_EXP | |||
* @arg @ref LL_PKA_MODE_MONTGOMERY_PARAM_ECC | |||
* @arg @ref LL_PKA_MODE_ECC_KP_PRIMITIVE | |||
* @arg @ref LL_PKA_MODE_ECDSA_SIGNATURE | |||
* @arg @ref LL_PKA_MODE_ECDSA_VERIFICATION | |||
* @arg @ref LL_PKA_MODE_POINT_CHECK | |||
* @arg @ref LL_PKA_MODE_RSA_CRT_EXP | |||
* @arg @ref LL_PKA_MODE_MODULAR_INV | |||
* @arg @ref LL_PKA_MODE_ARITHMETIC_ADD | |||
* @arg @ref LL_PKA_MODE_ARITHMETIC_SUB | |||
* @arg @ref LL_PKA_MODE_ARITHMETIC_MUL | |||
* @arg @ref LL_PKA_MODE_COMPARISON | |||
* @arg @ref LL_PKA_MODE_MODULAR_REDUC | |||
* @arg @ref LL_PKA_MODE_MODULAR_ADD | |||
* @arg @ref LL_PKA_MODE_MODULAR_SUB | |||
* @arg @ref LL_PKA_MODE_MONTGOMERY_MUL | |||
*/ | |||
__STATIC_INLINE void LL_PKA_Config(PKA_TypeDef *PKAx, uint32_t Mode) | |||
{ | |||
MODIFY_REG(PKAx->CR, (PKA_CR_MODE), (Mode << PKA_CR_MODE_Pos)); | |||
} | |||
/** | |||
* @brief Enable PKA peripheral. | |||
* @rmtoll CR EN LL_PKA_Enable | |||
* @param PKAx PKA Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_PKA_Enable(PKA_TypeDef *PKAx) | |||
{ | |||
SET_BIT(PKAx->CR, PKA_CR_EN); | |||
} | |||
/** | |||
* @brief Disable PKA peripheral. | |||
* @rmtoll CR EN LL_PKA_Disable | |||
* @param PKAx PKA Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_PKA_Disable(PKA_TypeDef *PKAx) | |||
{ | |||
CLEAR_BIT(PKAx->CR, PKA_CR_EN); | |||
} | |||
/** | |||
* @brief Check if the PKA peripheral is enabled or disabled. | |||
* @rmtoll CR EN LL_PKA_IsEnabled | |||
* @param PKAx PKA Instance. | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_PKA_IsEnabled(PKA_TypeDef *PKAx) | |||
{ | |||
return ((READ_BIT(PKAx->CR, PKA_CR_EN) == (PKA_CR_EN)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Set PKA operating mode. | |||
* @rmtoll CR MODE LL_PKA_SetMode | |||
* @param PKAx PKA Instance. | |||
* @param Mode This parameter can be one of the following values: | |||
* @arg @ref LL_PKA_MODE_MONTGOMERY_PARAM_MOD_EXP | |||
* @arg @ref LL_PKA_MODE_MONTGOMERY_PARAM | |||
* @arg @ref LL_PKA_MODE_MODULAR_EXP | |||
* @arg @ref LL_PKA_MODE_MONTGOMERY_PARAM_ECC | |||
* @arg @ref LL_PKA_MODE_ECC_KP_PRIMITIVE | |||
* @arg @ref LL_PKA_MODE_ECDSA_SIGNATURE | |||
* @arg @ref LL_PKA_MODE_ECDSA_VERIFICATION | |||
* @arg @ref LL_PKA_MODE_POINT_CHECK | |||
* @arg @ref LL_PKA_MODE_RSA_CRT_EXP | |||
* @arg @ref LL_PKA_MODE_MODULAR_INV | |||
* @arg @ref LL_PKA_MODE_ARITHMETIC_ADD | |||
* @arg @ref LL_PKA_MODE_ARITHMETIC_SUB | |||
* @arg @ref LL_PKA_MODE_ARITHMETIC_MUL | |||
* @arg @ref LL_PKA_MODE_COMPARISON | |||
* @arg @ref LL_PKA_MODE_MODULAR_REDUC | |||
* @arg @ref LL_PKA_MODE_MODULAR_ADD | |||
* @arg @ref LL_PKA_MODE_MODULAR_SUB | |||
* @arg @ref LL_PKA_MODE_MONTGOMERY_MUL | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_PKA_SetMode(PKA_TypeDef *PKAx, uint32_t Mode) | |||
{ | |||
MODIFY_REG(PKAx->CR, PKA_CR_MODE, Mode << PKA_CR_MODE_Pos); | |||
} | |||
/** | |||
* @brief Get PKA operating mode. | |||
* @rmtoll CR MODE LL_PKA_GetMode | |||
* @param PKAx PKA Instance. | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_PKA_MODE_MONTGOMERY_PARAM_MOD_EXP | |||
* @arg @ref LL_PKA_MODE_MONTGOMERY_PARAM | |||
* @arg @ref LL_PKA_MODE_MODULAR_EXP | |||
* @arg @ref LL_PKA_MODE_MONTGOMERY_PARAM_ECC | |||
* @arg @ref LL_PKA_MODE_ECC_KP_PRIMITIVE | |||
* @arg @ref LL_PKA_MODE_ECDSA_SIGNATURE | |||
* @arg @ref LL_PKA_MODE_ECDSA_VERIFICATION | |||
* @arg @ref LL_PKA_MODE_POINT_CHECK | |||
* @arg @ref LL_PKA_MODE_RSA_CRT_EXP | |||
* @arg @ref LL_PKA_MODE_MODULAR_INV | |||
* @arg @ref LL_PKA_MODE_ARITHMETIC_ADD | |||
* @arg @ref LL_PKA_MODE_ARITHMETIC_SUB | |||
* @arg @ref LL_PKA_MODE_ARITHMETIC_MUL | |||
* @arg @ref LL_PKA_MODE_COMPARISON | |||
* @arg @ref LL_PKA_MODE_MODULAR_REDUC | |||
* @arg @ref LL_PKA_MODE_MODULAR_ADD | |||
* @arg @ref LL_PKA_MODE_MODULAR_SUB | |||
* @arg @ref LL_PKA_MODE_MONTGOMERY_MUL | |||
*/ | |||
__STATIC_INLINE uint32_t LL_PKA_GetMode(PKA_TypeDef *PKAx) | |||
{ | |||
return (uint32_t)(READ_BIT(PKAx->CR, PKA_CR_MODE) >> PKA_CR_MODE_Pos); | |||
} | |||
/** | |||
* @brief Start the operation selected using LL_PKA_SetMode. | |||
* @rmtoll CR START LL_PKA_Start | |||
* @param PKAx PKA Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_PKA_Start(PKA_TypeDef *PKAx) | |||
{ | |||
SET_BIT(PKAx->CR, PKA_CR_START); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PKA_LL_EF_IT_Management IT_Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable address error interrupt. | |||
* @rmtoll CR ADDRERRIE LL_PKA_EnableIT_ADDRERR | |||
* @param PKAx PKA Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_PKA_EnableIT_ADDRERR(PKA_TypeDef *PKAx) | |||
{ | |||
SET_BIT(PKAx->CR, PKA_CR_ADDRERRIE); | |||
} | |||
/** | |||
* @brief Enable RAM error interrupt. | |||
* @rmtoll CR RAMERRIE LL_PKA_EnableIT_RAMERR | |||
* @param PKAx PKA Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_PKA_EnableIT_RAMERR(PKA_TypeDef *PKAx) | |||
{ | |||
SET_BIT(PKAx->CR, PKA_CR_RAMERRIE); | |||
} | |||
/** | |||
* @brief Enable end of operation interrupt. | |||
* @rmtoll CR PROCENDIE LL_PKA_EnableIT_PROCEND | |||
* @param PKAx PKA Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_PKA_EnableIT_PROCEND(PKA_TypeDef *PKAx) | |||
{ | |||
SET_BIT(PKAx->CR, PKA_CR_PROCENDIE); | |||
} | |||
/** | |||
* @brief Disable address error interrupt. | |||
* @rmtoll CR ADDRERRIE LL_PKA_DisableIT_ADDERR | |||
* @param PKAx PKA Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_PKA_DisableIT_ADDERR(PKA_TypeDef *PKAx) | |||
{ | |||
CLEAR_BIT(PKAx->CR, PKA_CR_ADDRERRIE); | |||
} | |||
/** | |||
* @brief Disable RAM error interrupt. | |||
* @rmtoll CR RAMERRIE LL_PKA_DisableIT_RAMERR | |||
* @param PKAx PKA Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_PKA_DisableIT_RAMERR(PKA_TypeDef *PKAx) | |||
{ | |||
CLEAR_BIT(PKAx->CR, PKA_CR_RAMERRIE); | |||
} | |||
/** | |||
* @brief Disable End of operation interrupt. | |||
* @rmtoll CR PROCENDIE LL_PKA_DisableIT_PROCEND | |||
* @param PKAx PKA Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_PKA_DisableIT_PROCEND(PKA_TypeDef *PKAx) | |||
{ | |||
CLEAR_BIT(PKAx->CR, PKA_CR_PROCENDIE); | |||
} | |||
/** | |||
* @brief Check if address error interrupt is enabled. | |||
* @rmtoll CR ADDRERRIE LL_PKA_IsEnabledIT_ADDRERR | |||
* @param PKAx PKA Instance. | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_PKA_IsEnabledIT_ADDRERR(PKA_TypeDef *PKAx) | |||
{ | |||
return ((READ_BIT(PKAx->CR, PKA_CR_ADDRERRIE) == (PKA_CR_ADDRERRIE)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Check if RAM error interrupt is enabled. | |||
* @rmtoll CR RAMERRIE LL_PKA_IsEnabledIT_RAMERR | |||
* @param PKAx PKA Instance. | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_PKA_IsEnabledIT_RAMERR(PKA_TypeDef *PKAx) | |||
{ | |||
return ((READ_BIT(PKAx->CR, PKA_CR_RAMERRIE) == (PKA_CR_RAMERRIE)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Check if end of operation interrupt is enabled. | |||
* @rmtoll CR PROCENDIE LL_PKA_IsEnabledIT_PROCEND | |||
* @param PKAx PKA Instance. | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_PKA_IsEnabledIT_PROCEND(PKA_TypeDef *PKAx) | |||
{ | |||
return ((READ_BIT(PKAx->CR, PKA_CR_PROCENDIE) == (PKA_CR_PROCENDIE)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup PKA_LL_EF_FLAG_Management PKA flag management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Get PKA address error flag. | |||
* @rmtoll SR ADDRERRF LL_PKA_IsActiveFlag_ADDRERR | |||
* @param PKAx PKA Instance. | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_PKA_IsActiveFlag_ADDRERR(PKA_TypeDef *PKAx) | |||
{ | |||
return ((READ_BIT(PKAx->SR, PKA_SR_ADDRERRF) == (PKA_SR_ADDRERRF)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Get PKA RAM error flag. | |||
* @rmtoll SR RAMERRF LL_PKA_IsActiveFlag_RAMERR | |||
* @param PKAx PKA Instance. | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_PKA_IsActiveFlag_RAMERR(PKA_TypeDef *PKAx) | |||
{ | |||
return ((READ_BIT(PKAx->SR, PKA_SR_RAMERRF) == (PKA_SR_RAMERRF)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Get PKA end of operation flag. | |||
* @rmtoll SR PROCENDF LL_PKA_IsActiveFlag_PROCEND | |||
* @param PKAx PKA Instance. | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_PKA_IsActiveFlag_PROCEND(PKA_TypeDef *PKAx) | |||
{ | |||
return ((READ_BIT(PKAx->SR, PKA_SR_PROCENDF) == (PKA_SR_PROCENDF)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Get PKA busy flag. | |||
* @rmtoll SR BUSY LL_PKA_IsActiveFlag_BUSY | |||
* @param PKAx PKA Instance. | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_PKA_IsActiveFlag_BUSY(PKA_TypeDef *PKAx) | |||
{ | |||
return ((READ_BIT(PKAx->SR, PKA_SR_BUSY) == (PKA_SR_BUSY)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Clear PKA address error flag. | |||
* @rmtoll CLRFR ADDRERRFC LL_PKA_ClearFlag_ADDERR | |||
* @param PKAx PKA Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_PKA_ClearFlag_ADDERR(PKA_TypeDef *PKAx) | |||
{ | |||
SET_BIT(PKAx->CLRFR, PKA_CLRFR_ADDRERRFC); | |||
} | |||
/** | |||
* @brief Clear PKA RAM error flag. | |||
* @rmtoll CLRFR RAMERRFC LL_PKA_ClearFlag_RAMERR | |||
* @param PKAx PKA Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_PKA_ClearFlag_RAMERR(PKA_TypeDef *PKAx) | |||
{ | |||
SET_BIT(PKAx->CLRFR, PKA_CLRFR_RAMERRFC); | |||
} | |||
/** | |||
* @brief Clear PKA end of operation flag. | |||
* @rmtoll CLRFR PROCENDFC LL_PKA_ClearFlag_PROCEND | |||
* @param PKAx PKA Instance. | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_PKA_ClearFlag_PROCEND(PKA_TypeDef *PKAx) | |||
{ | |||
SET_BIT(PKAx->CLRFR, PKA_CLRFR_PROCENDFC); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
#if defined(USE_FULL_LL_DRIVER) | |||
/** @defgroup PKA_LL_EF_Init Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
ErrorStatus LL_PKA_DeInit(PKA_TypeDef *PKAx); | |||
ErrorStatus LL_PKA_Init(PKA_TypeDef *PKAx, LL_PKA_InitTypeDef *PKA_InitStruct); | |||
void LL_PKA_StructInit(LL_PKA_InitTypeDef *PKA_InitStruct); | |||
/** | |||
* @} | |||
*/ | |||
#endif /* USE_FULL_LL_DRIVER */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* defined(PKA) */ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_LL_PKA_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,401 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_ll_rng.h | |||
* @author MCD Application Team | |||
* @brief Header file of RNG LL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_LL_RNG_H | |||
#define STM32WBxx_LL_RNG_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx.h" | |||
/** @addtogroup STM32WBxx_LL_Driver | |||
* @{ | |||
*/ | |||
#if defined (RNG) | |||
/** @defgroup RNG_LL RNG | |||
* @{ | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
#if defined(USE_FULL_LL_DRIVER) | |||
/** @defgroup RNG_LL_ES_Init_Struct RNG Exported Init structures | |||
* @{ | |||
*/ | |||
/** | |||
* @brief LL RNG Init Structure Definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t ClockErrorDetection; /*!< Clock error detection. | |||
This parameter can be one value of @ref RNG_LL_CED. | |||
This parameter can be modified using unitary functions @ref LL_RNG_EnableClkErrorDetect(). */ | |||
} LL_RNG_InitTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
#endif /* USE_FULL_LL_DRIVER */ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup RNG_LL_Exported_Constants RNG Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup RNG_LL_CED Clock Error Detection | |||
* @{ | |||
*/ | |||
#define LL_RNG_CED_ENABLE 0x00000000U /*!< Clock error detection enabled */ | |||
#define LL_RNG_CED_DISABLE RNG_CR_CED /*!< Clock error detection disabled */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RNG_LL_EC_GET_FLAG Get Flags Defines | |||
* @brief Flags defines which can be used with LL_RNG_ReadReg function | |||
* @{ | |||
*/ | |||
#define LL_RNG_SR_DRDY RNG_SR_DRDY /*!< Register contains valid random data */ | |||
#define LL_RNG_SR_CECS RNG_SR_CECS /*!< Clock error current status */ | |||
#define LL_RNG_SR_SECS RNG_SR_SECS /*!< Seed error current status */ | |||
#define LL_RNG_SR_CEIS RNG_SR_CEIS /*!< Clock error interrupt status */ | |||
#define LL_RNG_SR_SEIS RNG_SR_SEIS /*!< Seed error interrupt status */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RNG_LL_EC_IT IT Defines | |||
* @brief IT defines which can be used with LL_RNG_ReadReg and LL_RNG_WriteReg macros | |||
* @{ | |||
*/ | |||
#define LL_RNG_CR_IE RNG_CR_IE /*!< RNG Interrupt enable */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup RNG_LL_Exported_Macros RNG Exported Macros | |||
* @{ | |||
*/ | |||
/** @defgroup RNG_LL_EM_WRITE_READ Common Write and read registers Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Write a value in RNG register | |||
* @param __INSTANCE__ RNG Instance | |||
* @param __REG__ Register to be written | |||
* @param __VALUE__ Value to be written in the register | |||
* @retval None | |||
*/ | |||
#define LL_RNG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) | |||
/** | |||
* @brief Read a value in RNG register | |||
* @param __INSTANCE__ RNG Instance | |||
* @param __REG__ Register to be read | |||
* @retval Register value | |||
*/ | |||
#define LL_RNG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup RNG_LL_Exported_Functions RNG Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup RNG_LL_EF_Configuration RNG Configuration functions | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable Random Number Generation | |||
* @rmtoll CR RNGEN LL_RNG_Enable | |||
* @param RNGx RNG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_RNG_Enable(RNG_TypeDef *RNGx) | |||
{ | |||
SET_BIT(RNGx->CR, RNG_CR_RNGEN); | |||
} | |||
/** | |||
* @brief Disable Random Number Generation | |||
* @rmtoll CR RNGEN LL_RNG_Disable | |||
* @param RNGx RNG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_RNG_Disable(RNG_TypeDef *RNGx) | |||
{ | |||
CLEAR_BIT(RNGx->CR, RNG_CR_RNGEN); | |||
} | |||
/** | |||
* @brief Check if Random Number Generator is enabled | |||
* @rmtoll CR RNGEN 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_RNGEN) == (RNG_CR_RNGEN)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Enable Clock Error Detection | |||
* @rmtoll CR CED LL_RNG_EnableClkErrorDetect | |||
* @param RNGx RNG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_RNG_EnableClkErrorDetect(RNG_TypeDef *RNGx) | |||
{ | |||
CLEAR_BIT(RNGx->CR, RNG_CR_CED); | |||
} | |||
/** | |||
* @brief Disable RNG Clock Error Detection | |||
* @rmtoll CR CED LL_RNG_DisableClkErrorDetect | |||
* @param RNGx RNG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_RNG_DisableClkErrorDetect(RNG_TypeDef *RNGx) | |||
{ | |||
SET_BIT(RNGx->CR, RNG_CR_CED); | |||
} | |||
/** | |||
* @brief Check if RNG Clock Error Detection is enabled | |||
* @rmtoll CR CED LL_RNG_IsEnabledClkErrorDetect | |||
* @param RNGx RNG Instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_RNG_IsEnabledClkErrorDetect(RNG_TypeDef *RNGx) | |||
{ | |||
return ((READ_BIT(RNGx->CR, RNG_CR_CED) != (RNG_CR_CED)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RNG_LL_EF_FLAG_Management FLAG Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Indicate if the RNG Data ready Flag is set or not | |||
* @rmtoll SR DRDY LL_RNG_IsActiveFlag_DRDY | |||
* @param RNGx RNG Instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_DRDY(RNG_TypeDef *RNGx) | |||
{ | |||
return ((READ_BIT(RNGx->SR, RNG_SR_DRDY) == (RNG_SR_DRDY)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Indicate if the Clock Error Current Status Flag is set or not | |||
* @rmtoll SR CECS LL_RNG_IsActiveFlag_CECS | |||
* @param RNGx RNG Instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CECS(RNG_TypeDef *RNGx) | |||
{ | |||
return ((READ_BIT(RNGx->SR, RNG_SR_CECS) == (RNG_SR_CECS)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Indicate if the Seed Error Current Status Flag is set or not | |||
* @rmtoll SR SECS LL_RNG_IsActiveFlag_SECS | |||
* @param RNGx RNG Instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SECS(RNG_TypeDef *RNGx) | |||
{ | |||
return ((READ_BIT(RNGx->SR, RNG_SR_SECS) == (RNG_SR_SECS)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Indicate if the Clock Error Interrupt Status Flag is set or not | |||
* @rmtoll SR CEIS LL_RNG_IsActiveFlag_CEIS | |||
* @param RNGx RNG Instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CEIS(RNG_TypeDef *RNGx) | |||
{ | |||
return ((READ_BIT(RNGx->SR, RNG_SR_CEIS) == (RNG_SR_CEIS)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Indicate if the Seed Error Interrupt Status Flag is set or not | |||
* @rmtoll SR SEIS LL_RNG_IsActiveFlag_SEIS | |||
* @param RNGx RNG Instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SEIS(RNG_TypeDef *RNGx) | |||
{ | |||
return ((READ_BIT(RNGx->SR, RNG_SR_SEIS) == (RNG_SR_SEIS)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Clear Clock Error interrupt Status (CEIS) Flag | |||
* @rmtoll SR CEIS LL_RNG_ClearFlag_CEIS | |||
* @param RNGx RNG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_RNG_ClearFlag_CEIS(RNG_TypeDef *RNGx) | |||
{ | |||
WRITE_REG(RNGx->SR, ~RNG_SR_CEIS); | |||
} | |||
/** | |||
* @brief Clear Seed Error interrupt Status (SEIS) Flag | |||
* @rmtoll SR SEIS LL_RNG_ClearFlag_SEIS | |||
* @param RNGx RNG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_RNG_ClearFlag_SEIS(RNG_TypeDef *RNGx) | |||
{ | |||
WRITE_REG(RNGx->SR, ~RNG_SR_SEIS); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RNG_LL_EF_IT_Management IT Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable Random Number Generator Interrupt | |||
* (applies for either Seed error, Clock Error or Data ready interrupts) | |||
* @rmtoll CR IE LL_RNG_EnableIT | |||
* @param RNGx RNG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_RNG_EnableIT(RNG_TypeDef *RNGx) | |||
{ | |||
SET_BIT(RNGx->CR, RNG_CR_IE); | |||
} | |||
/** | |||
* @brief Disable Random Number Generator Interrupt | |||
* (applies for either Seed error, Clock Error or Data ready interrupts) | |||
* @rmtoll CR IE LL_RNG_DisableIT | |||
* @param RNGx RNG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_RNG_DisableIT(RNG_TypeDef *RNGx) | |||
{ | |||
CLEAR_BIT(RNGx->CR, RNG_CR_IE); | |||
} | |||
/** | |||
* @brief Check if Random Number Generator Interrupt is enabled | |||
* (applies for either Seed error, Clock Error or Data ready interrupts) | |||
* @rmtoll CR IE LL_RNG_IsEnabledIT | |||
* @param RNGx RNG Instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_RNG_IsEnabledIT(RNG_TypeDef *RNGx) | |||
{ | |||
return ((READ_BIT(RNGx->CR, RNG_CR_IE) == (RNG_CR_IE)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup RNG_LL_EF_Data_Management Data Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Return32-bit Random Number value | |||
* @rmtoll DR RNDATA LL_RNG_ReadRandData32 | |||
* @param RNGx RNG Instance | |||
* @retval Generated 32-bit random value | |||
*/ | |||
__STATIC_INLINE uint32_t LL_RNG_ReadRandData32(RNG_TypeDef *RNGx) | |||
{ | |||
return (uint32_t)(READ_REG(RNGx->DR)); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
#if defined(USE_FULL_LL_DRIVER) | |||
/** @defgroup RNG_LL_EF_Init Initialization and de-initialization functions | |||
* @{ | |||
*/ | |||
ErrorStatus LL_RNG_Init(RNG_TypeDef *RNGx, LL_RNG_InitTypeDef *RNG_InitStruct); | |||
void LL_RNG_StructInit(LL_RNG_InitTypeDef *RNG_InitStruct); | |||
ErrorStatus LL_RNG_DeInit(RNG_TypeDef *RNGx); | |||
/** | |||
* @} | |||
*/ | |||
#endif /* USE_FULL_LL_DRIVER */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* RNG */ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* __STM32WBxx_LL_RNG_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,229 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_ll_usb.h | |||
* @author MCD Application Team | |||
* @brief Header file of USB Low Layer HAL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_LL_USB_H | |||
#define STM32WBxx_LL_USB_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal_def.h" | |||
#if defined (USB) | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup USB_LL | |||
* @{ | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** | |||
* @brief USB Mode definition | |||
*/ | |||
typedef enum | |||
{ | |||
USB_DEVICE_MODE = 0 | |||
} USB_ModeTypeDef; | |||
/** | |||
* @brief USB Initialization Structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t dev_endpoints; /*!< Device Endpoints number. | |||
This parameter depends on the used USB core. | |||
This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ | |||
uint32_t speed; /*!< USB Core speed. | |||
This parameter can be any value of @ref USB_Core_Speed */ | |||
uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. */ | |||
uint32_t phy_itface; /*!< Select the used PHY interface. | |||
This parameter can be any value of @ref USB_Core_PHY */ | |||
uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */ | |||
uint32_t low_power_enable; /*!< Enable or disable Low Power mode */ | |||
uint32_t lpm_enable; /*!< Enable or disable Battery charging. */ | |||
uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */ | |||
} USB_CfgTypeDef; | |||
typedef struct | |||
{ | |||
uint8_t num; /*!< Endpoint number | |||
This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ | |||
uint8_t is_in; /*!< Endpoint direction | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ | |||
uint8_t is_stall; /*!< Endpoint stall condition | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ | |||
uint8_t type; /*!< Endpoint type | |||
This parameter can be any value of @ref USB_EP_Type */ | |||
uint8_t data_pid_start; /*!< Initial data PID | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ | |||
uint16_t pmaadress; /*!< PMA Address | |||
This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ | |||
uint16_t pmaaddr0; /*!< PMA Address0 | |||
This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ | |||
uint16_t pmaaddr1; /*!< PMA Address1 | |||
This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ | |||
uint8_t doublebuffer; /*!< Double buffer enable | |||
This parameter can be 0 or 1 */ | |||
uint16_t tx_fifo_num; /*!< This parameter is not required by USB Device FS peripheral, it is used | |||
only by USB OTG FS peripheral | |||
This parameter is added to ensure compatibility across USB peripherals */ | |||
uint32_t maxpacket; /*!< Endpoint Max packet size | |||
This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ | |||
uint8_t *xfer_buff; /*!< Pointer to transfer buffer */ | |||
uint32_t xfer_len; /*!< Current transfer length */ | |||
uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */ | |||
} USB_EPTypeDef; | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup PCD_Exported_Constants PCD Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS | |||
* @{ | |||
*/ | |||
#define DEP0CTL_MPS_64 0U | |||
#define DEP0CTL_MPS_32 1U | |||
#define DEP0CTL_MPS_16 2U | |||
#define DEP0CTL_MPS_8 3U | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup USB_LL_EP_Type USB Low Layer EP Type | |||
* @{ | |||
*/ | |||
#define EP_TYPE_CTRL 0U | |||
#define EP_TYPE_ISOC 1U | |||
#define EP_TYPE_BULK 2U | |||
#define EP_TYPE_INTR 3U | |||
#define EP_TYPE_MSK 3U | |||
/** | |||
* @} | |||
*/ | |||
#define BTABLE_ADDRESS 0x000U | |||
#define PMA_ACCESS 1U | |||
#define EP_ADDR_MSK 0x7U | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions | |||
* @{ | |||
*/ | |||
HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg); | |||
HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg); | |||
HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx); | |||
HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx); | |||
HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode); | |||
HAL_StatusTypeDef USB_SetDevSpeed(USB_TypeDef *USBx, uint8_t speed); | |||
HAL_StatusTypeDef USB_FlushRxFifo(USB_TypeDef *USBx); | |||
HAL_StatusTypeDef USB_FlushTxFifo(USB_TypeDef *USBx, uint32_t num); | |||
HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); | |||
HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); | |||
HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep); | |||
HAL_StatusTypeDef USB_WritePacket(USB_TypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len); | |||
void *USB_ReadPacket(USB_TypeDef *USBx, uint8_t *dest, uint16_t len); | |||
HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx, USB_EPTypeDef *ep); | |||
HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx, USB_EPTypeDef *ep); | |||
HAL_StatusTypeDef USB_SetDevAddress(USB_TypeDef *USBx, uint8_t address); | |||
HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx); | |||
HAL_StatusTypeDef USB_DevDisconnect(USB_TypeDef *USBx); | |||
HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx); | |||
HAL_StatusTypeDef USB_EP0_OutStart(USB_TypeDef *USBx, uint8_t *psetup); | |||
uint32_t USB_ReadInterrupts(USB_TypeDef *USBx); | |||
uint32_t USB_ReadDevAllOutEpInterrupt(USB_TypeDef *USBx); | |||
uint32_t USB_ReadDevOutEPInterrupt(USB_TypeDef *USBx, uint8_t epnum); | |||
uint32_t USB_ReadDevAllInEpInterrupt(USB_TypeDef *USBx); | |||
uint32_t USB_ReadDevInEPInterrupt(USB_TypeDef *USBx, uint8_t epnum); | |||
void USB_ClearInterrupts(USB_TypeDef *USBx, uint32_t interrupt); | |||
HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx); | |||
HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx); | |||
void USB_WritePMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes); | |||
void USB_ReadPMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* defined (USB) */ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_LL_USB_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,318 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_ll_utils.h | |||
* @author MCD Application Team | |||
* @brief Header file of UTILS LL module. | |||
@verbatim | |||
============================================================================== | |||
##### How to use this driver ##### | |||
============================================================================== | |||
[..] | |||
The LL UTILS driver contains a set of generic APIs that can be | |||
used by user: | |||
(+) Device electronic signature | |||
(+) Timing functions | |||
(+) PLL configuration functions | |||
@endverbatim | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_LL_UTILS_H | |||
#define STM32WBxx_LL_UTILS_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx.h" | |||
/** @addtogroup STM32WBxx_LL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup UTILS_LL UTILS | |||
* @{ | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/** @defgroup UTILS_LL_Private_Constants UTILS Private Constants | |||
* @{ | |||
*/ | |||
/* Max delay can be used in LL_mDelay */ | |||
#define LL_MAX_DELAY 0xFFFFFFFFU | |||
/** | |||
* @brief Unique device ID register base address | |||
*/ | |||
#define UID_BASE_ADDRESS UID_BASE | |||
/** | |||
* @brief Flash size data register base address | |||
*/ | |||
#define FLASHSIZE_BASE_ADDRESS FLASHSIZE_BASE | |||
/** | |||
* @brief Package data register base address | |||
*/ | |||
#define PACKAGE_BASE_ADDRESS PACKAGE_BASE | |||
/** | |||
* @} | |||
*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/** @defgroup UTILS_LL_Private_Macros UTILS Private Macros | |||
* @{ | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/** @defgroup UTILS_LL_ES_INIT UTILS Exported structures | |||
* @{ | |||
*/ | |||
/** | |||
* @brief UTILS PLL structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t PLLM; /*!< Division factor for PLL VCO input clock. | |||
This parameter can be a value of @ref RCC_LL_EC_PLLM_DIV | |||
This feature can be modified afterwards using unitary function | |||
@ref LL_RCC_PLL_ConfigDomain_SYS(). */ | |||
uint32_t PLLN; /*!< Multiplication factor for PLL VCO output clock. | |||
This parameter must be a number between Min_Data = 8 and Max_Data = 86 | |||
This feature can be modified afterwards using unitary function | |||
@ref LL_RCC_PLL_ConfigDomain_SYS(). */ | |||
uint32_t PLLR; /*!< Division for the main system clock. | |||
This parameter can be a value of @ref RCC_LL_EC_PLLR_DIV | |||
This feature can be modified afterwards using unitary function | |||
@ref LL_RCC_PLL_ConfigDomain_SYS(). */ | |||
} LL_UTILS_PLLInitTypeDef; | |||
/** | |||
* @brief UTILS System, AHB and APB buses clock configuration structure definition | |||
*/ | |||
typedef struct | |||
{ | |||
uint32_t CPU1CLKDivider; /*!< The CPU1 clock (HCLK1) divider. This clock is derived from the system clock (SYSCLK). | |||
This parameter can be a value of @ref RCC_LL_EC_SYSCLK_DIV | |||
This feature can be modified afterwards using unitary function | |||
@ref LL_RCC_SetAHBPrescaler(). */ | |||
uint32_t CPU2CLKDivider; /*!< The CPU2 clock (HCLK2) divider. This clock is derived from the system clock (SYSCLK). | |||
This parameter can be a value of @ref RCC_LL_EC_SYSCLK_DIV | |||
This feature can be modified afterwards using unitary function | |||
@ref LL_C2_RCC_SetAHBPrescaler(). */ | |||
uint32_t AHB4CLKDivider; /*!< The AHBS clock (HCLK4) divider. This clock is derived from the system clock (SYSCLK). | |||
This parameter can be a value of @ref RCC_LL_EC_SYSCLK_DIV | |||
This feature can be modified afterwards using unitary function | |||
@ref LL_RCC_SetAHB4Prescaler(). */ | |||
uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK1). | |||
This parameter can be a value of @ref RCC_LL_EC_APB1_DIV | |||
This feature can be modified afterwards using unitary function | |||
@ref LL_RCC_SetAPB1Prescaler(). */ | |||
uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK1). | |||
This parameter can be a value of @ref RCC_LL_EC_APB2_DIV | |||
This feature can be modified afterwards using unitary function | |||
@ref LL_RCC_SetAPB2Prescaler(). */ | |||
} LL_UTILS_ClkInitTypeDef; | |||
/** | |||
* @} | |||
*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup UTILS_LL_Exported_Constants UTILS Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup UTILS_EC_HSE_BYPASS HSE Bypass activation | |||
* @{ | |||
*/ | |||
#define LL_UTILS_HSEBYPASS_OFF 0x00000000U /*!< HSE Bypass is not enabled */ | |||
#define LL_UTILS_HSEBYPASS_ON 0x00000001U /*!< HSE Bypass is enabled */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup UTILS_EC_PACKAGETYPE PACKAGE TYPE | |||
* @{ | |||
*/ | |||
#define LL_UTILS_PACKAGETYPE_CSP100 0x00000011U /*!< CSP100 package type */ | |||
#define LL_UTILS_PACKAGETYPE_CSP100_C 0x00000012U /*!< CSP100 package type w/ capfree LDO */ | |||
#define LL_UTILS_PACKAGETYPE_QFN68 0x00000013U /*!< QFN68 package type */ | |||
#define LL_UTILS_PACKAGETYPE_QFN68_C 0x00000014U /*!< QFN68 package type w/ capfree LDO */ | |||
#define LL_UTILS_PACKAGETYPE_QFN48 0x0000000AU /*!< QFN48 package type */ | |||
#define LL_UTILS_PACKAGETYPE_QFN48_C 0x00000015U /*!< QFN48 package type w/ capfree LDO */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup UTILS_LL_Exported_Functions UTILS Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup UTILS_EF_DEVICE_ELECTRONIC_SIGNATURE DEVICE ELECTRONIC SIGNATURE | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Get Word0 of the unique device identifier (UID based on 96 bits) | |||
* @retval UID[31:0]: X and Y coordinates on the wafer expressed in BCD format | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GetUID_Word0(void) | |||
{ | |||
return (uint32_t)(READ_REG(*((uint32_t *)UID_BASE_ADDRESS))); | |||
} | |||
/** | |||
* @brief Get Word1 of the unique device identifier (UID based on 96 bits) | |||
* @retval UID[63:32]: Wafer number (UID[39:32]) & LOT_NUM[23:0] (UID[63:40]) | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GetUID_Word1(void) | |||
{ | |||
return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 4U)))); | |||
} | |||
/** | |||
* @brief Get Word2 of the unique device identifier (UID based on 96 bits) | |||
* @retval UID[95:64]: Lot number (ASCII encoded) - LOT_NUM[55:24] | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GetUID_Word2(void) | |||
{ | |||
return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 8U)))); | |||
} | |||
/** | |||
* @brief Get Flash memory size | |||
* @note This bitfield indicates the size of the device Flash memory expressed in | |||
* Kbytes. As an example, 0x040 corresponds to 64 Kbytes. | |||
* @retval FLASH_SIZE[15:0]: Flash memory size | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GetFlashSize(void) | |||
{ | |||
return (uint32_t)(READ_REG(*((uint32_t *)FLASHSIZE_BASE_ADDRESS)) & 0x0000FFFFUL); | |||
} | |||
/** | |||
* @brief Get Package type | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_UTILS_PACKAGETYPE_CSP100 | |||
* @arg @ref LL_UTILS_PACKAGETYPE_CSP100_C | |||
* @arg @ref LL_UTILS_PACKAGETYPE_QFN68 | |||
* @arg @ref LL_UTILS_PACKAGETYPE_QFN68_C | |||
* @arg @ref LL_UTILS_PACKAGETYPE_QFN48 | |||
* @arg @ref LL_UTILS_PACKAGETYPE_QFN48_C | |||
* | |||
*/ | |||
__STATIC_INLINE uint32_t LL_GetPackageType(void) | |||
{ | |||
return (uint32_t)(READ_REG(*((uint32_t *)PACKAGE_BASE_ADDRESS)) & 0x1FU); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup UTILS_LL_EF_DELAY DELAY | |||
* @{ | |||
*/ | |||
/** | |||
* @brief This function configures the Cortex-M SysTick source of the time base. | |||
* @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro or function @ref LL_RCC_GetSystemClocksFreq (HCLK1_Frequency field)) | |||
* @note When a RTOS is used, it is recommended to avoid changing the SysTick | |||
* configuration by calling this function, for a delay use rather osDelay RTOS service. | |||
* @param Ticks Number of ticks | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks) | |||
{ | |||
/* Configure the SysTick to have interrupt in 1ms time base */ | |||
SysTick->LOAD = (uint32_t)((HCLKFrequency / Ticks) - 1UL); /* set reload register */ | |||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ | |||
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | | |||
SysTick_CTRL_ENABLE_Msk; /* Enable the Systick Timer */ | |||
} | |||
void LL_Init1msTick(uint32_t HCLKFrequency); | |||
void LL_mDelay(uint32_t Delay); | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup UTILS_EF_SYSTEM SYSTEM | |||
* @{ | |||
*/ | |||
void LL_SetSystemCoreClock(uint32_t HCLKFrequency); | |||
ErrorStatus LL_PLL_ConfigSystemClock_MSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, | |||
LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); | |||
ErrorStatus LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, | |||
LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); | |||
ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEBypass, | |||
LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_LL_UTILS_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,331 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_ll_wwdg.h | |||
* @author MCD Application Team | |||
* @brief Header file of WWDG LL module. | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Define to prevent recursive inclusion -------------------------------------*/ | |||
#ifndef STM32WBxx_LL_WWDG_H | |||
#define STM32WBxx_LL_WWDG_H | |||
#ifdef __cplusplus | |||
extern "C" { | |||
#endif | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx.h" | |||
/** @addtogroup STM32WBxx_LL_Driver | |||
* @{ | |||
*/ | |||
#if defined (WWDG) | |||
/** @defgroup WWDG_LL WWDG | |||
* @{ | |||
*/ | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/* Exported types ------------------------------------------------------------*/ | |||
/* Exported constants --------------------------------------------------------*/ | |||
/** @defgroup WWDG_LL_Exported_Constants WWDG Exported Constants | |||
* @{ | |||
*/ | |||
/** @defgroup WWDG_LL_EC_IT IT Defines | |||
* @brief IT defines which can be used with LL_WWDG_ReadReg and LL_WWDG_WriteReg functions | |||
* @{ | |||
*/ | |||
#define LL_WWDG_CFR_EWI WWDG_CFR_EWI | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup WWDG_LL_EC_PRESCALER PRESCALER | |||
* @{ | |||
*/ | |||
#define LL_WWDG_PRESCALER_1 0x00000000u /*!< WWDG counter clock = (PCLK1/4096)/1 */ | |||
#define LL_WWDG_PRESCALER_2 WWDG_CFR_WDGTB_0 /*!< WWDG counter clock = (PCLK1/4096)/2 */ | |||
#define LL_WWDG_PRESCALER_4 WWDG_CFR_WDGTB_1 /*!< WWDG counter clock = (PCLK1/4096)/4 */ | |||
#define LL_WWDG_PRESCALER_8 (WWDG_CFR_WDGTB_0 | WWDG_CFR_WDGTB_1) /*!< WWDG counter clock = (PCLK1/4096)/8 */ | |||
#define LL_WWDG_PRESCALER_16 WWDG_CFR_WDGTB_2 /*!< WWDG counter clock = (PCLK1/4096)/16 */ | |||
#define LL_WWDG_PRESCALER_32 (WWDG_CFR_WDGTB_2 | WWDG_CFR_WDGTB_0) /*!< WWDG counter clock = (PCLK1/4096)/32 */ | |||
#define LL_WWDG_PRESCALER_64 (WWDG_CFR_WDGTB_2 | WWDG_CFR_WDGTB_1) /*!< WWDG counter clock = (PCLK1/4096)/64 */ | |||
#define LL_WWDG_PRESCALER_128 (WWDG_CFR_WDGTB_2 | WWDG_CFR_WDGTB_1 | WWDG_CFR_WDGTB_0) /*!< WWDG counter clock = (PCLK1/4096)/128 */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported macro ------------------------------------------------------------*/ | |||
/** @defgroup WWDG_LL_Exported_Macros WWDG Exported Macros | |||
* @{ | |||
*/ | |||
/** @defgroup WWDG_LL_EM_WRITE_READ Common Write and read registers macros | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Write a value in WWDG register | |||
* @param __INSTANCE__ WWDG Instance | |||
* @param __REG__ Register to be written | |||
* @param __VALUE__ Value to be written in the register | |||
* @retval None | |||
*/ | |||
#define LL_WWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) | |||
/** | |||
* @brief Read a value in WWDG register | |||
* @param __INSTANCE__ WWDG Instance | |||
* @param __REG__ Register to be read | |||
* @retval Register value | |||
*/ | |||
#define LL_WWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup WWDG_LL_Exported_Functions WWDG Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup WWDG_LL_EF_Configuration Configuration | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable Window Watchdog. The watchdog is always disabled after a reset. | |||
* @note It is enabled by setting the WDGA bit in the WWDG_CR register, | |||
* then it cannot be disabled again except by a reset. | |||
* This bit is set by software and only cleared by hardware after a reset. | |||
* When WDGA = 1, the watchdog can generate a reset. | |||
* @rmtoll CR WDGA LL_WWDG_Enable | |||
* @param WWDGx WWDG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_WWDG_Enable(WWDG_TypeDef *WWDGx) | |||
{ | |||
SET_BIT(WWDGx->CR, WWDG_CR_WDGA); | |||
} | |||
/** | |||
* @brief Checks if Window Watchdog is enabled | |||
* @rmtoll CR WDGA LL_WWDG_IsEnabled | |||
* @param WWDGx WWDG Instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_WWDG_IsEnabled(WWDG_TypeDef *WWDGx) | |||
{ | |||
return ((READ_BIT(WWDGx->CR, WWDG_CR_WDGA) == (WWDG_CR_WDGA)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Set the Watchdog counter value to provided value (7-bits T[6:0]) | |||
* @note When writing to the WWDG_CR register, always write 1 in the MSB b6 to avoid generating an immediate reset | |||
* This counter is decremented every (4096 x 2expWDGTB) PCLK cycles | |||
* A reset is produced when it rolls over from 0x40 to 0x3F (bit T6 becomes cleared) | |||
* Setting the counter lower then 0x40 causes an immediate reset (if WWDG enabled) | |||
* @rmtoll CR T LL_WWDG_SetCounter | |||
* @param WWDGx WWDG Instance | |||
* @param Counter 0..0x7F (7 bit counter value) | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_WWDG_SetCounter(WWDG_TypeDef *WWDGx, uint32_t Counter) | |||
{ | |||
MODIFY_REG(WWDGx->CR, WWDG_CR_T, Counter); | |||
} | |||
/** | |||
* @brief Return current Watchdog Counter Value (7 bits counter value) | |||
* @rmtoll CR T LL_WWDG_GetCounter | |||
* @param WWDGx WWDG Instance | |||
* @retval 7 bit Watchdog Counter value | |||
*/ | |||
__STATIC_INLINE uint32_t LL_WWDG_GetCounter(WWDG_TypeDef *WWDGx) | |||
{ | |||
return (READ_BIT(WWDGx->CR, WWDG_CR_T)); | |||
} | |||
/** | |||
* @brief Set the time base of the prescaler (WDGTB). | |||
* @note Prescaler is used to apply ratio on PCLK clock, so that Watchdog counter | |||
* is decremented every (4096 x 2expWDGTB) PCLK cycles | |||
* @rmtoll CFR WDGTB LL_WWDG_SetPrescaler | |||
* @param WWDGx WWDG Instance | |||
* @param Prescaler This parameter can be one of the following values: | |||
* @arg @ref LL_WWDG_PRESCALER_1 | |||
* @arg @ref LL_WWDG_PRESCALER_2 | |||
* @arg @ref LL_WWDG_PRESCALER_4 | |||
* @arg @ref LL_WWDG_PRESCALER_8 | |||
* @arg @ref LL_WWDG_PRESCALER_16 | |||
* @arg @ref LL_WWDG_PRESCALER_32 | |||
* @arg @ref LL_WWDG_PRESCALER_64 | |||
* @arg @ref LL_WWDG_PRESCALER_128 | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_WWDG_SetPrescaler(WWDG_TypeDef *WWDGx, uint32_t Prescaler) | |||
{ | |||
MODIFY_REG(WWDGx->CFR, WWDG_CFR_WDGTB, Prescaler); | |||
} | |||
/** | |||
* @brief Return current Watchdog Prescaler Value | |||
* @rmtoll CFR WDGTB LL_WWDG_GetPrescaler | |||
* @param WWDGx WWDG Instance | |||
* @retval Returned value can be one of the following values: | |||
* @arg @ref LL_WWDG_PRESCALER_1 | |||
* @arg @ref LL_WWDG_PRESCALER_2 | |||
* @arg @ref LL_WWDG_PRESCALER_4 | |||
* @arg @ref LL_WWDG_PRESCALER_8 | |||
* @arg @ref LL_WWDG_PRESCALER_16 | |||
* @arg @ref LL_WWDG_PRESCALER_32 | |||
* @arg @ref LL_WWDG_PRESCALER_64 | |||
* @arg @ref LL_WWDG_PRESCALER_128 | |||
*/ | |||
__STATIC_INLINE uint32_t LL_WWDG_GetPrescaler(WWDG_TypeDef *WWDGx) | |||
{ | |||
return (READ_BIT(WWDGx->CFR, WWDG_CFR_WDGTB)); | |||
} | |||
/** | |||
* @brief Set the Watchdog Window value to be compared to the downcounter (7-bits W[6:0]). | |||
* @note This window value defines when write in the WWDG_CR register | |||
* to program Watchdog counter is allowed. | |||
* Watchdog counter value update must occur only when the counter value | |||
* is lower than the Watchdog window register value. | |||
* Otherwise, a MCU reset is generated if the 7-bit Watchdog counter value | |||
* (in the control register) is refreshed before the downcounter has reached | |||
* the watchdog window register value. | |||
* Physically is possible to set the Window lower then 0x40 but it is not recommended. | |||
* To generate an immediate reset, it is possible to set the Counter lower than 0x40. | |||
* @rmtoll CFR W LL_WWDG_SetWindow | |||
* @param WWDGx WWDG Instance | |||
* @param Window 0x00..0x7F (7 bit Window value) | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_WWDG_SetWindow(WWDG_TypeDef *WWDGx, uint32_t Window) | |||
{ | |||
MODIFY_REG(WWDGx->CFR, WWDG_CFR_W, Window); | |||
} | |||
/** | |||
* @brief Return current Watchdog Window Value (7 bits value) | |||
* @rmtoll CFR W LL_WWDG_GetWindow | |||
* @param WWDGx WWDG Instance | |||
* @retval 7 bit Watchdog Window value | |||
*/ | |||
__STATIC_INLINE uint32_t LL_WWDG_GetWindow(WWDG_TypeDef *WWDGx) | |||
{ | |||
return (READ_BIT(WWDGx->CFR, WWDG_CFR_W)); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup WWDG_LL_EF_FLAG_Management FLAG_Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Indicates if the WWDG Early Wakeup Interrupt Flag is set or not. | |||
* @note This bit is set by hardware when the counter has reached the value 0x40. | |||
* It must be cleared by software by writing 0. | |||
* A write of 1 has no effect. This bit is also set if the interrupt is not enabled. | |||
* @rmtoll SR EWIF LL_WWDG_IsActiveFlag_EWKUP | |||
* @param WWDGx WWDG Instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_WWDG_IsActiveFlag_EWKUP(WWDG_TypeDef *WWDGx) | |||
{ | |||
return ((READ_BIT(WWDGx->SR, WWDG_SR_EWIF) == (WWDG_SR_EWIF)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @brief Clear WWDG Early Wakeup Interrupt Flag (EWIF) | |||
* @rmtoll SR EWIF LL_WWDG_ClearFlag_EWKUP | |||
* @param WWDGx WWDG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_WWDG_ClearFlag_EWKUP(WWDG_TypeDef *WWDGx) | |||
{ | |||
WRITE_REG(WWDGx->SR, ~WWDG_SR_EWIF); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup WWDG_LL_EF_IT_Management IT_Management | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable the Early Wakeup Interrupt. | |||
* @note When set, an interrupt occurs whenever the counter reaches value 0x40. | |||
* This interrupt is only cleared by hardware after a reset | |||
* @rmtoll CFR EWI LL_WWDG_EnableIT_EWKUP | |||
* @param WWDGx WWDG Instance | |||
* @retval None | |||
*/ | |||
__STATIC_INLINE void LL_WWDG_EnableIT_EWKUP(WWDG_TypeDef *WWDGx) | |||
{ | |||
SET_BIT(WWDGx->CFR, WWDG_CFR_EWI); | |||
} | |||
/** | |||
* @brief Check if Early Wakeup Interrupt is enabled | |||
* @rmtoll CFR EWI LL_WWDG_IsEnabledIT_EWKUP | |||
* @param WWDGx WWDG Instance | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
__STATIC_INLINE uint32_t LL_WWDG_IsEnabledIT_EWKUP(WWDG_TypeDef *WWDGx) | |||
{ | |||
return ((READ_BIT(WWDGx->CFR, WWDG_CFR_EWI) == (WWDG_CFR_EWI)) ? 1UL : 0UL); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* WWDG */ | |||
/** | |||
* @} | |||
*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
#endif /* STM32WBxx_LL_WWDG_H */ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,812 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal.c | |||
* @author MCD Application Team | |||
* @brief HAL module driver. | |||
* This is the common part of the HAL initialization | |||
* | |||
@verbatim | |||
============================================================================== | |||
##### How to use this driver ##### | |||
============================================================================== | |||
[..] | |||
The common HAL driver contains a set of generic and common APIs that can be | |||
used by the PPP peripheral drivers and the user to start using the HAL. | |||
[..] | |||
The HAL contains two APIs' categories: | |||
(+) Common HAL APIs | |||
(+) Services HAL APIs | |||
@endverbatim | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup HAL | |||
* @brief HAL module driver | |||
* @{ | |||
*/ | |||
#ifdef HAL_MODULE_ENABLED | |||
/* Private typedef -----------------------------------------------------------*/ | |||
/* Private define ------------------------------------------------------------*/ | |||
/** @defgroup HAL_Private_Constants HAL Private Constants | |||
* @{ | |||
*/ | |||
/** | |||
* @brief STM32WBxx HAL Driver version number | |||
*/ | |||
#define __STM32WBxx_HAL_VERSION_MAIN (0x01U) /*!< [31:24] main version */ | |||
#define __STM32WBxx_HAL_VERSION_SUB1 (0x01U) /*!< [23:16] sub1 version */ | |||
#define __STM32WBxx_HAL_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ | |||
#define __STM32WBxx_HAL_VERSION_RC (0x00U) /*!< [7:0] release candidate */ | |||
#define __STM32WBxx_HAL_VERSION ((__STM32WBxx_HAL_VERSION_MAIN << 24U)\ | |||
|(__STM32WBxx_HAL_VERSION_SUB1 << 16U)\ | |||
|(__STM32WBxx_HAL_VERSION_SUB2 << 8U )\ | |||
|(__STM32WBxx_HAL_VERSION_RC)) | |||
#define VREFBUF_TIMEOUT_VALUE 10U /* 10 ms */ | |||
/** | |||
* @} | |||
*/ | |||
/* Private macro -------------------------------------------------------------*/ | |||
/* Exported variables ---------------------------------------------------------*/ | |||
/** @defgroup HAL_Exported_Variables HAL Exported Variables | |||
* @{ | |||
*/ | |||
__IO uint32_t uwTick; | |||
uint32_t uwTickPrio = (1UL << __NVIC_PRIO_BITS); /* Invalid PRIO */ | |||
uint32_t uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */ | |||
/** | |||
* @} | |||
*/ | |||
/* Private function prototypes -----------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup HAL_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup HAL_Exported_Functions_Group1 | |||
* @brief HAL Initialization and Configuration functions | |||
* | |||
@verbatim | |||
=============================================================================== | |||
##### HAL Initialization and Configuration functions ##### | |||
=============================================================================== | |||
[..] This section provides functions allowing to: | |||
(+) Initialize the Flash interface the NVIC allocation and initial time base | |||
clock configuration. | |||
(+) De-initialize common part of the HAL. | |||
(+) Configure the time base source to have 1ms time base with a dedicated | |||
Tick interrupt priority. | |||
(++) SysTick timer is used by default as source of time base, but user | |||
can eventually implement his proper time base source (a general purpose | |||
timer for example or other time source), keeping in mind that Time base | |||
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and | |||
handled in milliseconds basis. | |||
(++) Time base configuration function (HAL_InitTick ()) is called automatically | |||
at the beginning of the program after reset by HAL_Init() or at any time | |||
when clock is configured, by HAL_RCC_ClockConfig(). | |||
(++) Source of time base is configured to generate interrupts at regular | |||
time intervals. Care must be taken if HAL_Delay() is called from a | |||
peripheral ISR process, the Tick interrupt line must have higher priority | |||
(numerically lower) than the peripheral interrupt. Otherwise the caller | |||
ISR process will be blocked. | |||
(++) functions affecting time base configurations are declared as __weak | |||
to make override possible in case of other implementations in user file. | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief This function is used to initialize the HAL Library; it must be the first | |||
* instruction to be executed in the main program (before to call any other | |||
* HAL function), it performs the following: | |||
* Configure the Flash prefetch, instruction and Data caches. | |||
* Configures the SysTick to generate an interrupt each 1 millisecond, | |||
* which is clocked by the MSI (at this stage, the clock is not yet | |||
* configured and thus the system is running from the internal MSI at 4 MHz). | |||
* Set NVIC Group Priority to 4. | |||
* Calls the HAL_MspInit() callback function defined in user file | |||
* "stm32wbxx_hal_msp.c" to do the global low level hardware initialization | |||
* | |||
* @note SysTick is used as time base for the HAL_Delay() function, the application | |||
* need to ensure that the SysTick time base is always set to 1 millisecond | |||
* to have correct HAL operation. | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_Init(void) | |||
{ | |||
HAL_StatusTypeDef status = HAL_OK; | |||
/* Configure Flash prefetch, Instruction cache, Data cache */ | |||
/* Default configuration at reset is: */ | |||
/* - Prefetch disabled */ | |||
/* - Instruction cache enabled */ | |||
/* - Data cache enabled */ | |||
#if (INSTRUCTION_CACHE_ENABLE == 0U) | |||
__HAL_FLASH_INSTRUCTION_CACHE_DISABLE(); | |||
#endif /* INSTRUCTION_CACHE_ENABLE */ | |||
#if (DATA_CACHE_ENABLE == 0U) | |||
__HAL_FLASH_DATA_CACHE_DISABLE(); | |||
#endif /* DATA_CACHE_ENABLE */ | |||
#if (PREFETCH_ENABLE != 0U) | |||
__HAL_FLASH_PREFETCH_BUFFER_ENABLE(); | |||
#endif /* PREFETCH_ENABLE */ | |||
/* Set Interrupt Group Priority */ | |||
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); | |||
/* Use SysTick as time base source and configure 1ms tick (default clock after Reset is MSI) */ | |||
if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
else | |||
{ | |||
/* Init the low level hardware */ | |||
HAL_MspInit(); | |||
} | |||
/* Return function status */ | |||
return status; | |||
} | |||
/** | |||
* @brief This function de-Initializes common part of the HAL and stops the source of time base. | |||
* @note This function is optional. | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_DeInit(void) | |||
{ | |||
/* Reset of all peripherals */ | |||
__HAL_RCC_APB1_FORCE_RESET(); | |||
__HAL_RCC_APB1_RELEASE_RESET(); | |||
__HAL_RCC_APB2_FORCE_RESET(); | |||
__HAL_RCC_APB2_RELEASE_RESET(); | |||
__HAL_RCC_APB3_FORCE_RESET(); | |||
__HAL_RCC_APB3_RELEASE_RESET(); | |||
__HAL_RCC_AHB1_FORCE_RESET(); | |||
__HAL_RCC_AHB1_RELEASE_RESET(); | |||
__HAL_RCC_AHB2_FORCE_RESET(); | |||
__HAL_RCC_AHB2_RELEASE_RESET(); | |||
__HAL_RCC_AHB3_FORCE_RESET(); | |||
__HAL_RCC_AHB3_RELEASE_RESET(); | |||
/* De-Init the low level hardware */ | |||
HAL_MspDeInit(); | |||
/* Return function status */ | |||
return HAL_OK; | |||
} | |||
/** | |||
* @brief Initialize the MSP. | |||
* @retval None | |||
*/ | |||
__weak void HAL_MspInit(void) | |||
{ | |||
/* NOTE : This function should not be modified, when the callback is needed, | |||
the HAL_MspInit could be implemented in the user file | |||
*/ | |||
} | |||
/** | |||
* @brief DeInitializes the MSP. | |||
* @retval None | |||
*/ | |||
__weak void HAL_MspDeInit(void) | |||
{ | |||
/* NOTE : This function should not be modified, when the callback is needed, | |||
the HAL_MspDeInit could be implemented in the user file | |||
*/ | |||
} | |||
/** | |||
* @brief This function configures the source of the time base: | |||
* The time source is configured to have 1ms time base with a dedicated | |||
* Tick interrupt priority. | |||
* @note This function is called automatically at the beginning of program after | |||
* reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig(). | |||
* @note In the default implementation, SysTick timer is the source of time base. | |||
* It is used to generate interrupts at regular time intervals. | |||
* Care must be taken if HAL_Delay() is called from a peripheral ISR process, | |||
* The SysTick interrupt must have higher priority (numerically lower) | |||
* than the peripheral interrupt. Otherwise the caller ISR process will be blocked. | |||
* The function is declared as __weak to be overwritten in case of other | |||
* implementation in user file. | |||
* @param TickPriority Tick interrupt priority. | |||
* @retval HAL status | |||
*/ | |||
__weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) | |||
{ | |||
HAL_StatusTypeDef status = HAL_OK; | |||
if (uwTickFreq != 0U) | |||
{ | |||
/*Configure the SysTick to have interrupt in 1ms time basis*/ | |||
if (HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/ (1000U /uwTickFreq)) == 0U) | |||
{ | |||
/* Configure the SysTick IRQ priority */ | |||
if (TickPriority < (1UL << __NVIC_PRIO_BITS)) | |||
{ | |||
HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U); | |||
uwTickPrio = TickPriority; | |||
} | |||
else | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
} | |||
else | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
} | |||
else | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
/* Return function status */ | |||
return status; | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup HAL_Exported_Functions_Group2 | |||
* @brief HAL Control functions | |||
* | |||
@verbatim | |||
=============================================================================== | |||
##### HAL Control functions ##### | |||
=============================================================================== | |||
[..] This section provides functions allowing to: | |||
(+) Provide a tick value in millisecond | |||
(+) Provide a blocking delay in millisecond | |||
(+) Suspend the time base source interrupt | |||
(+) Resume the time base source interrupt | |||
(+) Get the HAL API driver version | |||
(+) Get the device revision identifier | |||
(+) Get the device identifier | |||
(+) Get the unique device identifier | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief This function is called to increment a global variable "uwTick" | |||
* used as application time base. | |||
* @note In the default implementation, this variable is incremented each 1ms | |||
* in SysTick ISR. | |||
* @note This function is declared as __weak to be overwritten in case of other | |||
* implementations in user file. | |||
* @retval None | |||
*/ | |||
__weak void HAL_IncTick(void) | |||
{ | |||
uwTick += (uint32_t)uwTickFreq; | |||
} | |||
/** | |||
* @brief Provides a tick value in millisecond. | |||
* @note This function is declared as __weak to be overwritten in case of other | |||
* implementations in user file. | |||
* @retval tick value | |||
*/ | |||
__weak uint32_t HAL_GetTick(void) | |||
{ | |||
return uwTick; | |||
} | |||
/** | |||
* @brief This function returns a tick priority. | |||
* @retval tick priority | |||
*/ | |||
uint32_t HAL_GetTickPrio(void) | |||
{ | |||
return uwTickPrio; | |||
} | |||
/** | |||
* @brief Set new tick Freq. | |||
* @retval Status | |||
*/ | |||
HAL_StatusTypeDef HAL_SetTickFreq(uint32_t Freq) | |||
{ | |||
HAL_StatusTypeDef status = HAL_OK; | |||
assert_param(IS_TICKFREQ(Freq)); | |||
if (uwTickFreq != Freq) | |||
{ | |||
uwTickFreq = Freq; | |||
/* Apply the new tick Freq */ | |||
status = HAL_InitTick(uwTickPrio); | |||
} | |||
return status; | |||
} | |||
/** | |||
* @brief Return tick frequency. | |||
* @retval tick period in Hz | |||
*/ | |||
uint32_t HAL_GetTickFreq(void) | |||
{ | |||
return uwTickFreq; | |||
} | |||
/** | |||
* @brief This function provides minimum delay (in milliseconds) based | |||
* on variable incremented. | |||
* @note In the default implementation , SysTick timer is the source of time base. | |||
* It is used to generate interrupts at regular time intervals where uwTick | |||
* is incremented. | |||
* @note This function is declared as __weak to be overwritten in case of other | |||
* implementations in user file. | |||
* @param Delay specifies the delay time length, in milliseconds. | |||
* @retval None | |||
*/ | |||
__weak void HAL_Delay(uint32_t Delay) | |||
{ | |||
uint32_t tickstart = HAL_GetTick(); | |||
uint32_t wait = Delay; | |||
/* Add a freq to guarantee minimum wait */ | |||
if (wait < HAL_MAX_DELAY) | |||
{ | |||
wait += (uint32_t)(uwTickFreq); | |||
} | |||
while ((HAL_GetTick() - tickstart) < wait) | |||
{ | |||
} | |||
} | |||
/** | |||
* @brief Suspend Tick increment. | |||
* @note In the default implementation , SysTick timer is the source of time base. It is | |||
* used to generate interrupts at regular time intervals. Once HAL_SuspendTick() | |||
* is called, the SysTick interrupt will be disabled and so Tick increment | |||
* is suspended. | |||
* @note This function is declared as __weak to be overwritten in case of other | |||
* implementations in user file. | |||
* @retval None | |||
*/ | |||
__weak void HAL_SuspendTick(void) | |||
{ | |||
/* Disable SysTick Interrupt */ | |||
CLEAR_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk); | |||
} | |||
/** | |||
* @brief Resume Tick increment. | |||
* @note In the default implementation , SysTick timer is the source of time base. It is | |||
* used to generate interrupts at regular time intervals. Once HAL_ResumeTick() | |||
* is called, the SysTick interrupt will be enabled and so Tick increment | |||
* is resumed. | |||
* @note This function is declared as __weak to be overwritten in case of other | |||
* implementations in user file. | |||
* @retval None | |||
*/ | |||
__weak void HAL_ResumeTick(void) | |||
{ | |||
/* Enable SysTick Interrupt */ | |||
SET_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk); | |||
} | |||
/** | |||
* @brief Returns the HAL revision | |||
* @retval version : 0xXYZR (8bits for each decimal, R for RC) | |||
*/ | |||
uint32_t HAL_GetHalVersion(void) | |||
{ | |||
return __STM32WBxx_HAL_VERSION; | |||
} | |||
/** | |||
* @brief Returns the device revision identifier. | |||
* @retval Device revision identifier | |||
*/ | |||
uint32_t HAL_GetREVID(void) | |||
{ | |||
return(LL_DBGMCU_GetRevisionID()); | |||
} | |||
/** | |||
* @brief Returns the device identifier. | |||
* @retval Device identifier | |||
*/ | |||
uint32_t HAL_GetDEVID(void) | |||
{ | |||
return(LL_DBGMCU_GetDeviceID()); | |||
} | |||
/** | |||
* @brief Return the first word of the unique device identifier (UID based on 96 bits) | |||
* @retval Device identifier | |||
*/ | |||
uint32_t HAL_GetUIDw0(void) | |||
{ | |||
return(READ_REG(*((uint32_t *)UID_BASE))); | |||
} | |||
/** | |||
* @brief Return the second word of the unique device identifier (UID based on 96 bits) | |||
* @retval Device identifier | |||
*/ | |||
uint32_t HAL_GetUIDw1(void) | |||
{ | |||
return(READ_REG(*((uint32_t *)(UID_BASE + 4U)))); | |||
} | |||
/** | |||
* @brief Return the third word of the unique device identifier (UID based on 96 bits) | |||
* @retval Device identifier | |||
*/ | |||
uint32_t HAL_GetUIDw2(void) | |||
{ | |||
return(READ_REG(*((uint32_t *)(UID_BASE + 8U)))); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup HAL_Exported_Functions_Group3 | |||
* @brief HAL Debug functions | |||
* | |||
@verbatim | |||
=============================================================================== | |||
##### HAL Debug functions ##### | |||
=============================================================================== | |||
[..] This section provides functions allowing to: | |||
(+) Enable/Disable Debug module during SLEEP mode | |||
(+) Enable/Disable Debug module during STOP mode | |||
(+) Enable/Disable Debug module during STANDBY mode | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enable the Debug Module during SLEEP mode | |||
* @retval None | |||
*/ | |||
void HAL_DBGMCU_EnableDBGSleepMode(void) | |||
{ | |||
LL_DBGMCU_EnableDBGSleepMode(); | |||
} | |||
/** | |||
* @brief Disable the Debug Module during SLEEP mode | |||
* @retval None | |||
*/ | |||
void HAL_DBGMCU_DisableDBGSleepMode(void) | |||
{ | |||
LL_DBGMCU_DisableDBGSleepMode(); | |||
} | |||
/** | |||
* @brief Enable the Debug Module during STOP mode | |||
* @retval None | |||
*/ | |||
void HAL_DBGMCU_EnableDBGStopMode(void) | |||
{ | |||
LL_DBGMCU_EnableDBGStopMode(); | |||
} | |||
/** | |||
* @brief Disable the Debug Module during STOP mode | |||
* @retval None | |||
*/ | |||
void HAL_DBGMCU_DisableDBGStopMode(void) | |||
{ | |||
LL_DBGMCU_DisableDBGStopMode(); | |||
} | |||
/** | |||
* @brief Enable the Debug Module during STANDBY mode | |||
* @retval None | |||
*/ | |||
void HAL_DBGMCU_EnableDBGStandbyMode(void) | |||
{ | |||
LL_DBGMCU_EnableDBGStandbyMode(); | |||
} | |||
/** | |||
* @brief Disable the Debug Module during STANDBY mode | |||
* @retval None | |||
*/ | |||
void HAL_DBGMCU_DisableDBGStandbyMode(void) | |||
{ | |||
LL_DBGMCU_DisableDBGStandbyMode(); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup HAL_Exported_Functions_Group4 HAL System Configuration functions | |||
* @brief HAL System Configuration functions | |||
* | |||
@verbatim | |||
=============================================================================== | |||
##### HAL system configuration functions ##### | |||
=============================================================================== | |||
[..] This section provides functions allowing to: | |||
(+) Start a hardware SRAM2 erase operation | |||
(+) Disable CPU2 SRAM fetch (execution) | |||
(+) Configure the Voltage reference buffer | |||
(+) Enable/Disable the Voltage reference buffer | |||
(+) Enable/Disable the I/O analog switch voltage booster | |||
(+) Enable/Disable the access for security IP (AES1, AES2, PKA, RNG) | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Start a hardware SRAM2 erase operation. | |||
* @note As long as SRAM2 is not erased the SRAM2ER bit will be set. | |||
* This bit is automatically reset at the end of the SRAM2 erase operation. | |||
* @retval None | |||
*/ | |||
void HAL_SYSCFG_SRAM2Erase(void) | |||
{ | |||
/* unlock the write protection of the SRAM2ER bit */ | |||
__HAL_SYSCFG_SRAM2_WRP_UNLOCK(); | |||
/* Starts a hardware SRAM2 erase operation*/ | |||
__HAL_SYSCFG_SRAM2_ERASE(); | |||
} | |||
/** | |||
* @brief Disable CPU2 SRAM fetch (execution) (This bit can be set by Firmware | |||
* and will only be reset by a Hardware reset, including a reset after Standby.) | |||
* @note Firmware writing 0 has no effect. | |||
* @retval None | |||
*/ | |||
void HAL_SYSCFG_DisableSRAMFetch(void) | |||
{ | |||
LL_SYSCFG_DisableSRAMFetch(); | |||
} | |||
/** | |||
* @brief Check if CPU2 SRAM fetch is enabled | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
uint32_t HAL_SYSCFG_IsEnabledSRAMFetch(void) | |||
{ | |||
return (LL_SYSCFG_IsEnabledSRAMFetch()); | |||
} | |||
/** | |||
* @brief Configure the internal voltage reference buffer voltage scale. | |||
* @param VoltageScaling specifies the output voltage to achieve | |||
* This parameter can be one of the following values: | |||
* @arg @ref SYSCFG_VREFBUF_VOLTAGE_SCALE0 : VREF_OUT1 around 2.048 V. | |||
* This requires VDDA equal to or higher than 2.4 V. | |||
* @arg @ref SYSCFG_VREFBUF_VOLTAGE_SCALE1 : VREF_OUT1 around 2.5 V. | |||
* This requires VDDA equal to or higher than 2.8 V. | |||
* @retval None | |||
*/ | |||
void HAL_SYSCFG_VREFBUF_VoltageScalingConfig(uint32_t VoltageScaling) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_SYSCFG_VREFBUF_VOLTAGE_SCALE(VoltageScaling)); | |||
LL_VREFBUF_SetVoltageScaling(VoltageScaling); | |||
} | |||
/** | |||
* @brief Configure the internal voltage reference buffer high impedance mode. | |||
* @param Mode specifies the high impedance mode | |||
* This parameter can be one of the following values: | |||
* @arg @ref SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE : VREF+ pin is internally connect to VREFINT output. | |||
* @arg @ref SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE : VREF+ pin is high impedance. | |||
* @retval HAL_OK/HAL_TIMEOUT | |||
*/ | |||
void HAL_SYSCFG_VREFBUF_HighImpedanceConfig(uint32_t Mode) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_SYSCFG_VREFBUF_HIGH_IMPEDANCE(Mode)); | |||
MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_HIZ, Mode); | |||
} | |||
/** | |||
* @brief Tune the Internal Voltage Reference buffer (VREFBUF). | |||
* @param TrimmingValue specifies trimming code for VREFBUF calibration | |||
* This parameter can be a number between Min_Data = 0x00 and Max_Data = 0x3F | |||
* @retval None | |||
*/ | |||
void HAL_SYSCFG_VREFBUF_TrimmingConfig(uint32_t TrimmingValue) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_SYSCFG_VREFBUF_TRIMMING(TrimmingValue)); | |||
LL_VREFBUF_SetTrimming(TrimmingValue); | |||
} | |||
/** | |||
* @brief Enable the Internal Voltage Reference buffer (VREFBUF). | |||
* @retval HAL_OK/HAL_TIMEOUT | |||
*/ | |||
HAL_StatusTypeDef HAL_SYSCFG_EnableVREFBUF(void) | |||
{ | |||
uint32_t tickstart; | |||
LL_VREFBUF_Enable(); | |||
/* Get Start Tick*/ | |||
tickstart = HAL_GetTick(); | |||
/* Wait for VRR bit */ | |||
while(READ_BIT(VREFBUF->CSR, VREFBUF_CSR_VRR) == 0U) | |||
{ | |||
if((HAL_GetTick() - tickstart) > VREFBUF_TIMEOUT_VALUE) | |||
{ | |||
return HAL_TIMEOUT; | |||
} | |||
} | |||
return HAL_OK; | |||
} | |||
/** | |||
* @brief Disable the Internal Voltage Reference buffer (VREFBUF). | |||
* | |||
* @retval None | |||
*/ | |||
void HAL_SYSCFG_DisableVREFBUF(void) | |||
{ | |||
LL_VREFBUF_Disable(); | |||
} | |||
/** | |||
* @brief Enable the I/O analog switch voltage booster | |||
* | |||
* @retval None | |||
*/ | |||
void HAL_SYSCFG_EnableIOBooster(void) | |||
{ | |||
LL_SYSCFG_EnableAnalogBooster(); | |||
} | |||
/** | |||
* @brief Disable the I/O analog switch voltage booster | |||
* | |||
* @retval None | |||
*/ | |||
void HAL_SYSCFG_DisableIOBooster(void) | |||
{ | |||
LL_SYSCFG_DisableAnalogBooster(); | |||
} | |||
/** | |||
* @brief Enable the I/O analog switch supplied by VDD | |||
* @note To be used when I/O analog switch voltage booster is not enabled | |||
* @retval None | |||
*/ | |||
void HAL_SYSCFG_EnableIOVdd(void) | |||
{ | |||
LL_SYSCFG_EnableAnalogGpioSwitch(); | |||
} | |||
/** | |||
* @brief Disable the I/O analog switch supplied by VDD | |||
* | |||
* @retval None | |||
*/ | |||
void HAL_SYSCFG_DisableIOVdd(void) | |||
{ | |||
LL_SYSCFG_DisableAnalogGpioSwitch(); | |||
} | |||
/** | |||
* @brief Enable the access for security IP | |||
* @note When the system is secure (ESE = 1), this register provides write access security and can | |||
* only be written by the CPU2. A write access from the CPU1 will be ignored and a bus error | |||
* is generated. | |||
* @param SecurityAccess This parameter can be a combination of the following values: | |||
* @arg @ref HAL_SYSCFG_SECURE_ACCESS_AES1 | |||
* @arg @ref HAL_SYSCFG_SECURE_ACCESS_AES2 | |||
* @arg @ref HAL_SYSCFG_SECURE_ACCESS_PKA | |||
* @arg @ref HAL_SYSCFG_SECURE_ACCESS_RNG | |||
* @retval None | |||
*/ | |||
void HAL_SYSCFG_EnableSecurityAccess(uint32_t SecurityAccess) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_SYSCFG_SECURITY_ACCESS(SecurityAccess)); | |||
LL_SYSCFG_EnableSecurityAccess(SecurityAccess); | |||
} | |||
/** | |||
* @brief Disable the access for security IP | |||
* @note When the system is secure (ESE = 1), this register provides write access security and can | |||
* only be written by the CPU2. A write access from the CPU1 will be ignored and a bus error | |||
* is generated. | |||
* @param SecurityAccess This parameter can be a combination of the following values: | |||
* @arg @ref HAL_SYSCFG_SECURE_ACCESS_AES1 | |||
* @arg @ref HAL_SYSCFG_SECURE_ACCESS_AES2 | |||
* @arg @ref HAL_SYSCFG_SECURE_ACCESS_PKA | |||
* @arg @ref HAL_SYSCFG_SECURE_ACCESS_RNG | |||
* @retval None | |||
*/ | |||
void HAL_SYSCFG_DisableSecurityAccess(uint32_t SecurityAccess) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_SYSCFG_SECURITY_ACCESS(SecurityAccess)); | |||
LL_SYSCFG_DisableSecurityAccess(SecurityAccess); | |||
} | |||
/** | |||
* @brief Indicate if access for security IP is enabled | |||
* @param SecurityAccess This parameter can be one of the following values: | |||
* @arg @ref HAL_SYSCFG_SECURE_ACCESS_AES1 | |||
* @arg @ref HAL_SYSCFG_SECURE_ACCESS_AES2 | |||
* @arg @ref HAL_SYSCFG_SECURE_ACCESS_PKA | |||
* @arg @ref HAL_SYSCFG_SECURE_ACCESS_RNG | |||
* @retval State of bit (1 or 0). | |||
*/ | |||
uint32_t HAL_SYSCFG_IsEnabledSecurityAccess(uint32_t SecurityAccess) | |||
{ | |||
return (LL_SYSCFG_IsEnabledSecurityAccess(SecurityAccess)); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* HAL_MODULE_ENABLED */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,992 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_comp.c | |||
* @author MCD Application Team | |||
* @brief COMP HAL module driver. | |||
* This file provides firmware functions to manage the following | |||
* functionalities of the COMP peripheral: | |||
* + Initialization and de-initialization functions | |||
* + Start/Stop operation functions in polling mode | |||
* + Start/Stop operation functions in interrupt mode (through EXTI interrupt) | |||
* + Peripheral control functions | |||
* + Peripheral state functions | |||
* | |||
@verbatim | |||
================================================================================ | |||
##### COMP Peripheral features ##### | |||
================================================================================ | |||
[..] | |||
The STM32WBxx device family integrates two analog comparators instances: | |||
COMP1, COMP2. | |||
(#) Comparators input minus (inverting input) and input plus (non inverting input) | |||
can be set to internal references or to GPIO pins | |||
(refer to GPIO list in reference manual). | |||
(#) Comparators output level is available using HAL_COMP_GetOutputLevel() | |||
and can be redirected to other peripherals: GPIO pins (in mode | |||
alternate functions for comparator), timers. | |||
(refer to GPIO list in reference manual). | |||
(#) The comparators have interrupt capability through the EXTI controller | |||
with wake-up from sleep and stop modes. | |||
(#) Pairs of comparators instances can be combined in window mode | |||
(2 consecutive instances odd and even COMP<x> and COMP<x+1>). | |||
From the corresponding IRQ handler, the right interrupt source can be retrieved | |||
using macro __HAL_COMP_COMPx_EXTI_GET_FLAG(). | |||
##### How to use this driver ##### | |||
================================================================================ | |||
[..] | |||
This driver provides functions to configure and program the comparator instances | |||
of STM32WBxx devices. | |||
To use the comparator, perform the following steps: | |||
(#) Initialize the COMP low level resources by implementing the HAL_COMP_MspInit(): | |||
(++) Configure the GPIO connected to comparator inputs plus and minus in analog mode | |||
using HAL_GPIO_Init(). | |||
(++) If needed, configure the GPIO connected to comparator output in alternate function mode | |||
using HAL_GPIO_Init(). | |||
(++) If required enable the COMP interrupt by configuring and enabling EXTI line in Interrupt mode and | |||
selecting the desired sensitivity level using HAL_GPIO_Init() function. After that enable the comparator | |||
interrupt vector using HAL_NVIC_EnableIRQ() function. | |||
(#) Configure the comparator using HAL_COMP_Init() function: | |||
(++) Select the input minus (inverting input) | |||
(++) Select the input plus (non-inverting input) | |||
(++) Select the hysteresis | |||
(++) Select the blanking source | |||
(++) Select the output polarity | |||
(++) Select the power mode | |||
(++) Select the window mode | |||
-@@- HAL_COMP_Init() calls internally __HAL_RCC_SYSCFG_CLK_ENABLE() | |||
to enable internal control clock of the comparators. | |||
However, this is a legacy strategy. In future STM32 families, | |||
COMP clock enable must be implemented by user in "HAL_COMP_MspInit()". | |||
Therefore, for compatibility anticipation, it is recommended to | |||
implement __HAL_RCC_SYSCFG_CLK_ENABLE() in "HAL_COMP_MspInit()". | |||
(#) Reconfiguration on-the-fly of comparator can be done by calling again | |||
function HAL_COMP_Init() with new input structure parameters values. | |||
(#) Enable the comparator using HAL_COMP_Start() function. | |||
(#) Use HAL_COMP_TriggerCallback() or HAL_COMP_GetOutputLevel() functions | |||
to manage comparator outputs (events and output level). | |||
(#) Disable the comparator using HAL_COMP_Stop() function. | |||
(#) De-initialize the comparator using HAL_COMP_DeInit() function. | |||
(#) For safety purpose, comparator configuration can be locked using HAL_COMP_Lock() function. | |||
The only way to unlock the comparator is a device hardware reset. | |||
*** Callback registration *** | |||
============================================= | |||
[..] | |||
The compilation flag USE_HAL_COMP_REGISTER_CALLBACKS, when set to 1, | |||
allows the user to configure dynamically the driver callbacks. | |||
Use Functions @ref HAL_COMP_RegisterCallback() | |||
to register an interrupt callback. | |||
[..] | |||
Function @ref HAL_COMP_RegisterCallback() allows to register following callbacks: | |||
(+) TriggerCallback : callback for COMP trigger. | |||
(+) MspInitCallback : callback for Msp Init. | |||
(+) MspDeInitCallback : callback for Msp DeInit. | |||
This function takes as parameters the HAL peripheral handle, the Callback ID | |||
and a pointer to the user callback function. | |||
[..] | |||
Use function @ref HAL_COMP_UnRegisterCallback to reset a callback to the default | |||
weak function. | |||
[..] | |||
@ref HAL_COMP_UnRegisterCallback takes as parameters the HAL peripheral handle, | |||
and the Callback ID. | |||
This function allows to reset following callbacks: | |||
(+) TriggerCallback : callback for COMP trigger. | |||
(+) MspInitCallback : callback for Msp Init. | |||
(+) MspDeInitCallback : callback for Msp DeInit. | |||
[..] | |||
By default, after the @ref HAL_COMP_Init() and when the state is @ref HAL_COMP_STATE_RESET | |||
all callbacks are set to the corresponding weak functions: | |||
example @ref HAL_COMP_TriggerCallback(). | |||
Exception done for MspInit and MspDeInit functions that are | |||
reset to the legacy weak functions in the @ref HAL_COMP_Init()/ @ref HAL_COMP_DeInit() only when | |||
these callbacks are null (not registered beforehand). | |||
[..] | |||
If MspInit or MspDeInit are not null, the @ref HAL_COMP_Init()/ @ref HAL_COMP_DeInit() | |||
keep and use the user MspInit/MspDeInit callbacks (registered beforehand) whatever the state. | |||
[..] | |||
Callbacks can be registered/unregistered in @ref HAL_COMP_STATE_READY state only. | |||
Exception done MspInit/MspDeInit functions that can be registered/unregistered | |||
in @ref HAL_COMP_STATE_READY or @ref HAL_COMP_STATE_RESET state, | |||
thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit. | |||
[..] | |||
Then, the user first registers the MspInit/MspDeInit user callbacks | |||
using @ref HAL_COMP_RegisterCallback() before calling @ref HAL_COMP_DeInit() | |||
or @ref HAL_COMP_Init() function. | |||
[..] | |||
When the compilation flag USE_HAL_COMP_REGISTER_CALLBACKS is set to 0 or | |||
not defined, the callback registration feature is not available and all callbacks | |||
are set to the corresponding weak functions. | |||
@endverbatim | |||
****************************************************************************** | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
#ifdef HAL_COMP_MODULE_ENABLED | |||
/** @defgroup COMP COMP | |||
* @brief COMP HAL module driver | |||
* @{ | |||
*/ | |||
/* Private typedef -----------------------------------------------------------*/ | |||
/* Private define ------------------------------------------------------------*/ | |||
/** @addtogroup COMP_Private_Constants | |||
* @{ | |||
*/ | |||
/* Delay for COMP startup time. */ | |||
/* Note: Delay required to reach propagation delay specification. */ | |||
/* Literal set to maximum value (refer to device datasheet, */ | |||
/* parameter "tSTART"). */ | |||
/* Unit: us */ | |||
#define COMP_DELAY_STARTUP_US (80UL) /*!< Delay for COMP startup time */ | |||
/* Delay for COMP voltage scaler stabilization time. */ | |||
/* Literal set to maximum value (refer to device datasheet, */ | |||
/* parameter "tSTART_SCALER"). */ | |||
/* Unit: us */ | |||
#define COMP_DELAY_VOLTAGE_SCALER_STAB_US (200UL) /*!< Delay for COMP voltage scaler stabilization time */ | |||
#define COMP_OUTPUT_LEVEL_BITOFFSET_POS (30UL) | |||
/** | |||
* @} | |||
*/ | |||
/* Private macro -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private function prototypes -----------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup COMP_Exported_Functions COMP Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup COMP_Exported_Functions_Group1 Initialization/de-initialization functions | |||
* @brief Initialization and de-initialization functions. | |||
* | |||
@verbatim | |||
=============================================================================== | |||
##### Initialization and de-initialization functions ##### | |||
=============================================================================== | |||
[..] This section provides functions to initialize and de-initialize comparators | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Initialize the COMP according to the specified | |||
* parameters in the COMP_InitTypeDef and initialize the associated handle. | |||
* @note If the selected comparator is locked, initialization can't be performed. | |||
* To unlock the configuration, perform a system reset. | |||
* @param hcomp COMP handle | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp) | |||
{ | |||
uint32_t tmp_csr; | |||
uint32_t exti_line; | |||
uint32_t comp_voltage_scaler_initialized; /* Value "0" if comparator voltage scaler is not initialized */ | |||
__IO uint32_t wait_loop_index = 0UL; | |||
HAL_StatusTypeDef status = HAL_OK; | |||
/* Check the COMP handle allocation and lock status */ | |||
if(hcomp == NULL) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
else if(__HAL_COMP_IS_LOCKED(hcomp)) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
else | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); | |||
assert_param(IS_COMP_INPUT_PLUS(hcomp->Instance, hcomp->Init.InputPlus)); | |||
assert_param(IS_COMP_INPUT_MINUS(hcomp->Instance, hcomp->Init.InputMinus)); | |||
assert_param(IS_COMP_OUTPUTPOL(hcomp->Init.OutputPol)); | |||
assert_param(IS_COMP_POWERMODE(hcomp->Init.Mode)); | |||
assert_param(IS_COMP_HYSTERESIS(hcomp->Init.Hysteresis)); | |||
assert_param(IS_COMP_BLANKINGSRC_INSTANCE(hcomp->Instance, hcomp->Init.BlankingSrce)); | |||
assert_param(IS_COMP_TRIGGERMODE(hcomp->Init.TriggerMode)); | |||
assert_param(IS_COMP_WINDOWMODE(hcomp->Init.WindowMode)); | |||
if(hcomp->State == HAL_COMP_STATE_RESET) | |||
{ | |||
/* Allocate lock resource and initialize it */ | |||
hcomp->Lock = HAL_UNLOCKED; | |||
/* Set COMP error code to none */ | |||
COMP_CLEAR_ERRORCODE(hcomp); | |||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) | |||
/* Init the COMP Callback settings */ | |||
hcomp->TriggerCallback = HAL_COMP_TriggerCallback; /* Legacy weak callback */ | |||
if (hcomp->MspInitCallback == NULL) | |||
{ | |||
hcomp->MspInitCallback = HAL_COMP_MspInit; /* Legacy weak MspInit */ | |||
} | |||
/* Init the low level hardware */ | |||
/* Note: Internal control clock of the comparators must */ | |||
/* be enabled in "HAL_COMP_MspInit()" */ | |||
/* using "__HAL_RCC_SYSCFG_CLK_ENABLE()". */ | |||
hcomp->MspInitCallback(hcomp); | |||
#else | |||
/* Init the low level hardware */ | |||
/* Note: Internal control clock of the comparators must */ | |||
/* be enabled in "HAL_COMP_MspInit()" */ | |||
/* using "__HAL_RCC_SYSCFG_CLK_ENABLE()". */ | |||
HAL_COMP_MspInit(hcomp); | |||
#endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ | |||
} | |||
/* Memorize voltage scaler state before initialization */ | |||
comp_voltage_scaler_initialized = READ_BIT(hcomp->Instance->CSR, COMP_CSR_SCALEN); | |||
/* Set COMP parameters */ | |||
tmp_csr = ( hcomp->Init.InputMinus | |||
| hcomp->Init.InputPlus | |||
| hcomp->Init.BlankingSrce | |||
| hcomp->Init.Hysteresis | |||
| hcomp->Init.OutputPol | |||
| hcomp->Init.Mode | |||
); | |||
/* Set parameters in COMP register */ | |||
/* Note: Update all bits except read-only, lock and enable bits */ | |||
MODIFY_REG(hcomp->Instance->CSR, | |||
COMP_CSR_PWRMODE | COMP_CSR_INMSEL | COMP_CSR_INPSEL | | |||
COMP_CSR_WINMODE | COMP_CSR_POLARITY | COMP_CSR_HYST | | |||
COMP_CSR_BLANKING | COMP_CSR_BRGEN | COMP_CSR_SCALEN | COMP_CSR_INMESEL, | |||
tmp_csr | |||
); | |||
/* Set window mode */ | |||
/* Note: Window mode bit is located into 1 out of the 2 pairs of COMP */ | |||
/* instances. Therefore, this function can update another COMP */ | |||
/* instance that the one currently selected. */ | |||
if(hcomp->Init.WindowMode == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON) | |||
{ | |||
SET_BIT(COMP12_COMMON->CSR, COMP_CSR_WINMODE); | |||
} | |||
else | |||
{ | |||
CLEAR_BIT(COMP12_COMMON->CSR, COMP_CSR_WINMODE); | |||
} | |||
/* Delay for COMP scaler bridge voltage stabilization */ | |||
/* Apply the delay if voltage scaler bridge is required and not already enabled */ | |||
if ((READ_BIT(hcomp->Instance->CSR, COMP_CSR_SCALEN) != 0UL) && | |||
(comp_voltage_scaler_initialized == 0UL) ) | |||
{ | |||
/* Wait loop initialization and execution */ | |||
/* Note: Variable divided by 2 to compensate partially */ | |||
/* CPU processing cycles, scaling in us split to not */ | |||
/* exceed 32 bits register capacity and handle low frequency. */ | |||
wait_loop_index = ((COMP_DELAY_VOLTAGE_SCALER_STAB_US / 10UL) * (SystemCoreClock / (100000UL * 2UL))); | |||
while(wait_loop_index != 0UL) | |||
{ | |||
wait_loop_index--; | |||
} | |||
} | |||
/* Get the EXTI line corresponding to the selected COMP instance */ | |||
exti_line = COMP_GET_EXTI_LINE(hcomp->Instance); | |||
/* Manage EXTI settings */ | |||
if((hcomp->Init.TriggerMode & (COMP_EXTI_IT | COMP_EXTI_EVENT)) != 0UL) | |||
{ | |||
/* Configure EXTI rising edge */ | |||
if((hcomp->Init.TriggerMode & COMP_EXTI_RISING) != 0UL) | |||
{ | |||
LL_EXTI_EnableRisingTrig_0_31(exti_line); | |||
} | |||
else | |||
{ | |||
LL_EXTI_DisableRisingTrig_0_31(exti_line); | |||
} | |||
/* Configure EXTI falling edge */ | |||
if((hcomp->Init.TriggerMode & COMP_EXTI_FALLING) != 0UL) | |||
{ | |||
LL_EXTI_EnableFallingTrig_0_31(exti_line); | |||
} | |||
else | |||
{ | |||
LL_EXTI_DisableFallingTrig_0_31(exti_line); | |||
} | |||
/* Clear COMP EXTI pending bit (if any) */ | |||
LL_EXTI_ClearFlag_0_31(exti_line); | |||
/* Configure EXTI event mode */ | |||
if((hcomp->Init.TriggerMode & COMP_EXTI_EVENT) != 0UL) | |||
{ | |||
LL_EXTI_EnableEvent_0_31(exti_line); | |||
} | |||
else | |||
{ | |||
LL_EXTI_DisableEvent_0_31(exti_line); | |||
} | |||
/* Configure EXTI interrupt mode */ | |||
if((hcomp->Init.TriggerMode & COMP_EXTI_IT) != 0UL) | |||
{ | |||
LL_EXTI_EnableIT_0_31(exti_line); | |||
} | |||
else | |||
{ | |||
LL_EXTI_DisableIT_0_31(exti_line); | |||
} | |||
} | |||
else | |||
{ | |||
/* Disable EXTI event mode */ | |||
LL_EXTI_DisableEvent_0_31(exti_line); | |||
/* Disable EXTI interrupt mode */ | |||
LL_EXTI_DisableIT_0_31(exti_line); | |||
} | |||
/* Set HAL COMP handle state */ | |||
/* Note: Transition from state reset to state ready, */ | |||
/* otherwise (coming from state ready or busy) no state update. */ | |||
if (hcomp->State == HAL_COMP_STATE_RESET) | |||
{ | |||
hcomp->State = HAL_COMP_STATE_READY; | |||
} | |||
} | |||
return status; | |||
} | |||
/** | |||
* @brief DeInitialize the COMP peripheral. | |||
* @note Deinitialization cannot be performed if the COMP configuration is locked. | |||
* To unlock the configuration, perform a system reset. | |||
* @param hcomp COMP handle | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_COMP_DeInit(COMP_HandleTypeDef *hcomp) | |||
{ | |||
HAL_StatusTypeDef status = HAL_OK; | |||
/* Check the COMP handle allocation and lock status */ | |||
if(hcomp == NULL) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
else if(__HAL_COMP_IS_LOCKED(hcomp)) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
else | |||
{ | |||
/* Check the parameter */ | |||
assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); | |||
/* Set COMP_CSR register to reset value */ | |||
WRITE_REG(hcomp->Instance->CSR, 0x00000000UL); | |||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) | |||
if (hcomp->MspDeInitCallback == NULL) | |||
{ | |||
hcomp->MspDeInitCallback = HAL_COMP_MspDeInit; /* Legacy weak MspDeInit */ | |||
} | |||
/* DeInit the low level hardware: GPIO, RCC clock, NVIC */ | |||
hcomp->MspDeInitCallback(hcomp); | |||
#else | |||
/* DeInit the low level hardware: GPIO, RCC clock, NVIC */ | |||
HAL_COMP_MspDeInit(hcomp); | |||
#endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ | |||
/* Set HAL COMP handle state */ | |||
hcomp->State = HAL_COMP_STATE_RESET; | |||
/* Release Lock */ | |||
__HAL_UNLOCK(hcomp); | |||
} | |||
return status; | |||
} | |||
/** | |||
* @brief Initialize the COMP MSP. | |||
* @param hcomp COMP handle | |||
* @retval None | |||
*/ | |||
__weak void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp) | |||
{ | |||
/* Prevent unused argument(s) compilation warning */ | |||
UNUSED(hcomp); | |||
/* NOTE : This function should not be modified, when the callback is needed, | |||
the HAL_COMP_MspInit could be implemented in the user file | |||
*/ | |||
} | |||
/** | |||
* @brief DeInitialize the COMP MSP. | |||
* @param hcomp COMP handle | |||
* @retval None | |||
*/ | |||
__weak void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp) | |||
{ | |||
/* Prevent unused argument(s) compilation warning */ | |||
UNUSED(hcomp); | |||
/* NOTE : This function should not be modified, when the callback is needed, | |||
the HAL_COMP_MspDeInit could be implemented in the user file | |||
*/ | |||
} | |||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) | |||
/** | |||
* @brief Register a User COMP Callback | |||
* To be used instead of the weak predefined callback | |||
* @param hcomp Pointer to a COMP_HandleTypeDef structure that contains | |||
* the configuration information for the specified COMP. | |||
* @param CallbackID ID of the callback to be registered | |||
* This parameter can be one of the following values: | |||
* @arg @ref HAL_COMP_TRIGGER_CB_ID Trigger callback ID | |||
* @arg @ref HAL_COMP_MSPINIT_CB_ID MspInit callback ID | |||
* @arg @ref HAL_COMP_MSPDEINIT_CB_ID MspDeInit callback ID | |||
* @param pCallback pointer to the Callback function | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_COMP_RegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID, pCOMP_CallbackTypeDef pCallback) | |||
{ | |||
HAL_StatusTypeDef status = HAL_OK; | |||
if (pCallback == NULL) | |||
{ | |||
/* Update the error code */ | |||
hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; | |||
return HAL_ERROR; | |||
} | |||
if (HAL_COMP_STATE_READY == hcomp->State) | |||
{ | |||
switch (CallbackID) | |||
{ | |||
case HAL_COMP_TRIGGER_CB_ID : | |||
hcomp->TriggerCallback = pCallback; | |||
break; | |||
case HAL_COMP_MSPINIT_CB_ID : | |||
hcomp->MspInitCallback = pCallback; | |||
break; | |||
case HAL_COMP_MSPDEINIT_CB_ID : | |||
hcomp->MspDeInitCallback = pCallback; | |||
break; | |||
default : | |||
/* Update the error code */ | |||
hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; | |||
/* Return error status */ | |||
status = HAL_ERROR; | |||
break; | |||
} | |||
} | |||
else if (HAL_COMP_STATE_RESET == hcomp->State) | |||
{ | |||
switch (CallbackID) | |||
{ | |||
case HAL_COMP_MSPINIT_CB_ID : | |||
hcomp->MspInitCallback = pCallback; | |||
break; | |||
case HAL_COMP_MSPDEINIT_CB_ID : | |||
hcomp->MspDeInitCallback = pCallback; | |||
break; | |||
default : | |||
/* Update the error code */ | |||
hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; | |||
/* Return error status */ | |||
status = HAL_ERROR; | |||
break; | |||
} | |||
} | |||
else | |||
{ | |||
/* Update the error code */ | |||
hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; | |||
/* Return error status */ | |||
status = HAL_ERROR; | |||
} | |||
return status; | |||
} | |||
/** | |||
* @brief Unregister a COMP Callback | |||
* COMP callback is redirected to the weak predefined callback | |||
* @param hcomp Pointer to a COMP_HandleTypeDef structure that contains | |||
* the configuration information for the specified COMP. | |||
* @param CallbackID ID of the callback to be unregistered | |||
* This parameter can be one of the following values: | |||
* @arg @ref HAL_COMP_TRIGGER_CB_ID Trigger callback ID | |||
* @arg @ref HAL_COMP_MSPINIT_CB_ID MspInit callback ID | |||
* @arg @ref HAL_COMP_MSPDEINIT_CB_ID MspDeInit callback ID | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID) | |||
{ | |||
HAL_StatusTypeDef status = HAL_OK; | |||
if (HAL_COMP_STATE_READY == hcomp->State) | |||
{ | |||
switch (CallbackID) | |||
{ | |||
case HAL_COMP_TRIGGER_CB_ID : | |||
hcomp->TriggerCallback = HAL_COMP_TriggerCallback; /* Legacy weak callback */ | |||
break; | |||
case HAL_COMP_MSPINIT_CB_ID : | |||
hcomp->MspInitCallback = HAL_COMP_MspInit; /* Legacy weak MspInit */ | |||
break; | |||
case HAL_COMP_MSPDEINIT_CB_ID : | |||
hcomp->MspDeInitCallback = HAL_COMP_MspDeInit; /* Legacy weak MspDeInit */ | |||
break; | |||
default : | |||
/* Update the error code */ | |||
hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; | |||
/* Return error status */ | |||
status = HAL_ERROR; | |||
break; | |||
} | |||
} | |||
else if (HAL_COMP_STATE_RESET == hcomp->State) | |||
{ | |||
switch (CallbackID) | |||
{ | |||
case HAL_COMP_MSPINIT_CB_ID : | |||
hcomp->MspInitCallback = HAL_COMP_MspInit; /* Legacy weak MspInit */ | |||
break; | |||
case HAL_COMP_MSPDEINIT_CB_ID : | |||
hcomp->MspDeInitCallback = HAL_COMP_MspDeInit; /* Legacy weak MspDeInit */ | |||
break; | |||
default : | |||
/* Update the error code */ | |||
hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; | |||
/* Return error status */ | |||
status = HAL_ERROR; | |||
break; | |||
} | |||
} | |||
else | |||
{ | |||
/* Update the error code */ | |||
hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; | |||
/* Return error status */ | |||
status = HAL_ERROR; | |||
} | |||
return status; | |||
} | |||
#endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_Exported_Functions_Group2 Start-Stop operation functions | |||
* @brief Start-Stop operation functions. | |||
* | |||
@verbatim | |||
=============================================================================== | |||
##### IO operation functions ##### | |||
=============================================================================== | |||
[..] This section provides functions allowing to: | |||
(+) Start a comparator instance. | |||
(+) Stop a comparator instance. | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Start the comparator. | |||
* @param hcomp COMP handle | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp) | |||
{ | |||
__IO uint32_t wait_loop_index = 0UL; | |||
HAL_StatusTypeDef status = HAL_OK; | |||
/* Check the COMP handle allocation and lock status */ | |||
if(hcomp == NULL) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
else if(__HAL_COMP_IS_LOCKED(hcomp)) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
else | |||
{ | |||
/* Check the parameter */ | |||
assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); | |||
if(hcomp->State == HAL_COMP_STATE_READY) | |||
{ | |||
/* Enable the selected comparator */ | |||
SET_BIT(hcomp->Instance->CSR, COMP_CSR_EN); | |||
/* Set HAL COMP handle state */ | |||
hcomp->State = HAL_COMP_STATE_BUSY; | |||
/* Delay for COMP startup time */ | |||
/* Wait loop initialization and execution */ | |||
/* Note: Variable divided by 2 to compensate partially */ | |||
/* CPU processing cycles, scaling in us split to not */ | |||
/* exceed 32 bits register capacity and handle low frequency. */ | |||
wait_loop_index = ((COMP_DELAY_STARTUP_US / 10UL) * (SystemCoreClock / (100000UL * 2UL))); | |||
while(wait_loop_index != 0UL) | |||
{ | |||
wait_loop_index--; | |||
} | |||
} | |||
else | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
} | |||
return status; | |||
} | |||
/** | |||
* @brief Stop the comparator. | |||
* @param hcomp COMP handle | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp) | |||
{ | |||
HAL_StatusTypeDef status = HAL_OK; | |||
/* Check the COMP handle allocation and lock status */ | |||
if(hcomp == NULL) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
else if(__HAL_COMP_IS_LOCKED(hcomp)) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
else | |||
{ | |||
/* Check the parameter */ | |||
assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); | |||
/* Check compliant states: HAL_COMP_STATE_READY or HAL_COMP_STATE_BUSY */ | |||
/* (all states except HAL_COMP_STATE_RESET and except locked status. */ | |||
if(hcomp->State != HAL_COMP_STATE_RESET) | |||
{ | |||
/* Disable the selected comparator */ | |||
CLEAR_BIT(hcomp->Instance->CSR, COMP_CSR_EN); | |||
/* Set HAL COMP handle state */ | |||
hcomp->State = HAL_COMP_STATE_READY; | |||
} | |||
else | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
} | |||
return status; | |||
} | |||
/** | |||
* @brief Comparator IRQ handler. | |||
* @param hcomp COMP handle | |||
* @retval None | |||
*/ | |||
void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp) | |||
{ | |||
/* Get the EXTI line corresponding to the selected COMP instance */ | |||
uint32_t exti_line = COMP_GET_EXTI_LINE(hcomp->Instance); | |||
/* Check COMP EXTI flag */ | |||
if(LL_EXTI_IsActiveFlag_0_31(exti_line) != 0UL) | |||
{ | |||
/* Check whether comparator is in independent or window mode */ | |||
if(READ_BIT(COMP12_COMMON->CSR, COMP_CSR_WINMODE) != 0UL) | |||
{ | |||
/* Clear COMP EXTI line pending bit of the pair of comparators */ | |||
/* in window mode. */ | |||
/* Note: Pair of comparators in window mode can both trig IRQ when */ | |||
/* input voltage is changing from "out of window" area */ | |||
/* (low or high ) to the other "out of window" area (high or low).*/ | |||
/* Both flags must be cleared to call comparator trigger */ | |||
/* callback is called once. */ | |||
LL_EXTI_ClearFlag_0_31((COMP_EXTI_LINE_COMP1 | COMP_EXTI_LINE_COMP2)); | |||
} | |||
else | |||
{ | |||
/* Clear COMP EXTI line pending bit */ | |||
LL_EXTI_ClearFlag_0_31(exti_line); | |||
} | |||
/* COMP trigger user callback */ | |||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) | |||
hcomp->TriggerCallback(hcomp); | |||
#else | |||
HAL_COMP_TriggerCallback(hcomp); | |||
#endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ | |||
} | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_Exported_Functions_Group3 Peripheral Control functions | |||
* @brief Management functions. | |||
* | |||
@verbatim | |||
=============================================================================== | |||
##### Peripheral Control functions ##### | |||
=============================================================================== | |||
[..] | |||
This subsection provides a set of functions allowing to control the comparators. | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Lock the selected comparator configuration. | |||
* @note A system reset is required to unlock the comparator configuration. | |||
* @note Locking the comparator from reset state is possible | |||
* if __HAL_RCC_SYSCFG_CLK_ENABLE() is being called before. | |||
* @param hcomp COMP handle | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp) | |||
{ | |||
HAL_StatusTypeDef status = HAL_OK; | |||
/* Check the COMP handle allocation and lock status */ | |||
if(hcomp == NULL) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
else if(__HAL_COMP_IS_LOCKED(hcomp)) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
else | |||
{ | |||
/* Check the parameter */ | |||
assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); | |||
/* Set HAL COMP handle state */ | |||
switch(hcomp->State) | |||
{ | |||
case HAL_COMP_STATE_RESET: | |||
hcomp->State = HAL_COMP_STATE_RESET_LOCKED; | |||
break; | |||
case HAL_COMP_STATE_READY: | |||
hcomp->State = HAL_COMP_STATE_READY_LOCKED; | |||
break; | |||
default: /* HAL_COMP_STATE_BUSY */ | |||
hcomp->State = HAL_COMP_STATE_BUSY_LOCKED; | |||
break; | |||
} | |||
} | |||
if(status == HAL_OK) | |||
{ | |||
/* Set the lock bit corresponding to selected comparator */ | |||
__HAL_COMP_LOCK(hcomp); | |||
} | |||
return status; | |||
} | |||
/** | |||
* @brief Return the output level (high or low) of the selected comparator. | |||
* The output level depends on the selected polarity. | |||
* If the polarity is not inverted: | |||
* - Comparator output is low when the input plus is at a lower | |||
* voltage than the input minus | |||
* - Comparator output is high when the input plus is at a higher | |||
* voltage than the input minus | |||
* If the polarity is inverted: | |||
* - Comparator output is high when the input plus is at a lower | |||
* voltage than the input minus | |||
* - Comparator output is low when the input plus is at a higher | |||
* voltage than the input minus | |||
* @param hcomp COMP handle | |||
* @retval Returns the selected comparator output level: | |||
* @arg COMP_OUTPUT_LEVEL_LOW | |||
* @arg COMP_OUTPUT_LEVEL_HIGH | |||
* | |||
*/ | |||
uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp) | |||
{ | |||
/* Check the parameter */ | |||
assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); | |||
return (uint32_t)(READ_BIT(hcomp->Instance->CSR, COMP_CSR_VALUE) | |||
>> COMP_OUTPUT_LEVEL_BITOFFSET_POS); | |||
} | |||
/** | |||
* @brief Comparator trigger callback. | |||
* @param hcomp COMP handle | |||
* @retval None | |||
*/ | |||
__weak void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp) | |||
{ | |||
/* Prevent unused argument(s) compilation warning */ | |||
UNUSED(hcomp); | |||
/* NOTE : This function should not be modified, when the callback is needed, | |||
the HAL_COMP_TriggerCallback should be implemented in the user file | |||
*/ | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup COMP_Exported_Functions_Group4 Peripheral State functions | |||
* @brief Peripheral State functions. | |||
* | |||
@verbatim | |||
=============================================================================== | |||
##### Peripheral State functions ##### | |||
=============================================================================== | |||
[..] | |||
This subsection permit to get in run-time the status of the peripheral. | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Return the COMP handle state. | |||
* @param hcomp COMP handle | |||
* @retval HAL state | |||
*/ | |||
HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp) | |||
{ | |||
/* Check the COMP handle allocation */ | |||
if(hcomp == NULL) | |||
{ | |||
return HAL_COMP_STATE_RESET; | |||
} | |||
/* Check the parameter */ | |||
assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); | |||
/* Return HAL COMP handle state */ | |||
return hcomp->State; | |||
} | |||
/** | |||
* @brief Return the COMP error code. | |||
* @param hcomp COMP handle | |||
* @retval COMP error code | |||
*/ | |||
uint32_t HAL_COMP_GetError(COMP_HandleTypeDef *hcomp) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); | |||
return hcomp->ErrorCode; | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* HAL_COMP_MODULE_ENABLED */ | |||
/** | |||
* @} | |||
*/ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,482 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_cortex.c | |||
* @author MCD Application Team | |||
* @brief CORTEX HAL module driver. | |||
* This file provides firmware functions to manage the following | |||
* functionalities of the CORTEX: | |||
* + Initialization and Configuration functions | |||
* + Peripheral Control functions | |||
* | |||
@verbatim | |||
============================================================================== | |||
##### How to use this driver ##### | |||
============================================================================== | |||
[..] | |||
*** How to configure Interrupts using CORTEX HAL driver *** | |||
=========================================================== | |||
[..] | |||
This section provides functions allowing to configure the NVIC interrupts (IRQ). | |||
The Cortex M0+ exceptions are managed by CMSIS functions. | |||
(#) Enable and Configure the priority of the selected IRQ Channels. | |||
The priority can be 0..3. | |||
-@- Lower priority values gives higher priority. | |||
-@- Priority Order: | |||
(#@) Lowest priority. | |||
(#@) Lowest hardware priority (IRQn position). | |||
(#) Configure the priority of the selected IRQ Channels using HAL_NVIC_SetPriority() | |||
(#) Enable the selected IRQ Channels using HAL_NVIC_EnableIRQ() | |||
-@- Negative value of IRQn_Type are not allowed. | |||
*** How to configure Systick using CORTEX HAL driver *** | |||
======================================================== | |||
[..] | |||
Setup SysTick Timer for time base. | |||
(+) The HAL_SYSTICK_Config()function calls the SysTick_Config() function which | |||
is a CMSIS function that: | |||
(++) Configures the SysTick Reload register with value passed as function parameter. | |||
(++) Configures the SysTick IRQ priority to the lowest value (0x03). | |||
(++) Resets the SysTick Counter register. | |||
(++) Configures the SysTick Counter clock source to be Core Clock Source (HCLK). | |||
(++) Enables the SysTick Interrupt. | |||
(++) Starts the SysTick Counter. | |||
(+) You can change the SysTick Clock source to be HCLK_Div8 by calling the macro | |||
__HAL_CORTEX_SYSTICKCLK_CONFIG(SYSTICK_CLKSOURCE_HCLK_DIV8) just after the | |||
HAL_SYSTICK_Config() function call. The __HAL_CORTEX_SYSTICKCLK_CONFIG() macro is defined | |||
inside the stm32wbxx_hal_cortex.h file. | |||
(+) You can change the SysTick IRQ priority by calling the | |||
HAL_NVIC_SetPriority(SysTick_IRQn,...) function just after the HAL_SYSTICK_Config() function | |||
call. The HAL_NVIC_SetPriority() call the NVIC_SetPriority() function which is a CMSIS function. | |||
(+) To adjust the SysTick time base, use the following formula: | |||
Reload Value = SysTick Counter Clock (Hz) x Desired Time base (s) | |||
(++) Reload Value is the parameter to be passed for HAL_SYSTICK_Config() function | |||
(++) Reload Value should not exceed 0xFFFFFF | |||
@endverbatim | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup CORTEX | |||
* @{ | |||
*/ | |||
#ifdef HAL_CORTEX_MODULE_ENABLED | |||
/* Private types -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private constants ---------------------------------------------------------*/ | |||
/* Private macros ------------------------------------------------------------*/ | |||
/* Private function prototypes -----------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @addtogroup CORTEX_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @addtogroup CORTEX_Exported_Functions_Group1 | |||
* @brief Initialization and Configuration functions | |||
* | |||
@verbatim | |||
============================================================================== | |||
##### Initialization and Configuration functions ##### | |||
============================================================================== | |||
[..] | |||
This section provides the CORTEX HAL driver functions allowing to configure Interrupts | |||
Systick functionalities | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Set the priority grouping field (pre-emption priority and subpriority) | |||
* using the required unlock sequence. | |||
* @param PriorityGroup The priority grouping bits length. | |||
* This parameter can be one of the following values: | |||
* @arg NVIC_PRIORITYGROUP_0: 0 bit for pre-emption priority, | |||
* 4 bits for subpriority | |||
* @arg NVIC_PRIORITYGROUP_1: 1 bit for pre-emption priority, | |||
* 3 bits for subpriority | |||
* @arg NVIC_PRIORITYGROUP_2: 2 bits for pre-emption priority, | |||
* 2 bits for subpriority | |||
* @arg NVIC_PRIORITYGROUP_3: 3 bits for pre-emption priority, | |||
* 1 bit for subpriority | |||
* @arg NVIC_PRIORITYGROUP_4: 4 bits for pre-emption priority, | |||
* 0 bit for subpriority | |||
* @note When the NVIC_PriorityGroup_0 is selected, IRQ pre-emption is no more possible. | |||
* The pending IRQ priority will be managed only by the subpriority. | |||
* @retval None | |||
*/ | |||
void HAL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_NVIC_PRIORITY_GROUP(PriorityGroup)); | |||
/* Set the PRIGROUP[10:8] bits according to the PriorityGroup parameter value */ | |||
NVIC_SetPriorityGrouping(PriorityGroup); | |||
} | |||
/** | |||
* @brief Set the priority of an interrupt. | |||
* @param IRQn External interrupt number. | |||
* This parameter can be an enumerator of IRQn_Type enumeration | |||
* (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32wbxxxx.h)) | |||
* @param PreemptPriority The pre-emption priority for the IRQn channel. | |||
* This parameter can be a value between 0 and 15 | |||
* A lower priority value indicates a higher priority | |||
* @param SubPriority the subpriority level for the IRQ channel. | |||
* This parameter can be a value between 0 and 15 | |||
* A lower priority value indicates a higher priority. | |||
* @retval None | |||
*/ | |||
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority) | |||
{ | |||
uint32_t prioritygroup; | |||
/* Check the parameters */ | |||
assert_param(IS_NVIC_SUB_PRIORITY(SubPriority)); | |||
assert_param(IS_NVIC_PREEMPTION_PRIORITY(PreemptPriority)); | |||
prioritygroup = NVIC_GetPriorityGrouping(); | |||
NVIC_SetPriority(IRQn, NVIC_EncodePriority(prioritygroup, PreemptPriority, SubPriority)); | |||
} | |||
/** | |||
* @brief Enable a device specific interrupt in the NVIC interrupt controller. | |||
* @param IRQn External interrupt number. | |||
* This parameter can be an enumerator of IRQn_Type enumeration | |||
* (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32wbxxxx.h)) | |||
* @retval None | |||
*/ | |||
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_NVIC_DEVICE_IRQ(IRQn)); | |||
/* Enable interrupt */ | |||
NVIC_EnableIRQ(IRQn); | |||
} | |||
/** | |||
* @brief Disable a device specific interrupt in the NVIC interrupt controller. | |||
* @param IRQn External interrupt number. | |||
* This parameter can be an enumerator of IRQn_Type enumeration | |||
* (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32wbxxxx.h)) | |||
* @retval None | |||
*/ | |||
void HAL_NVIC_DisableIRQ(IRQn_Type IRQn) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_NVIC_DEVICE_IRQ(IRQn)); | |||
/* Disable interrupt */ | |||
NVIC_DisableIRQ(IRQn); | |||
} | |||
/** | |||
* @brief Initiate a system reset request to reset the MCU. | |||
* @retval None | |||
*/ | |||
void HAL_NVIC_SystemReset(void) | |||
{ | |||
/* System Reset */ | |||
NVIC_SystemReset(); | |||
} | |||
/** | |||
* @brief Initialize the System Timer with interrupt enabled and start the System Tick Timer (SysTick): | |||
* Counter is in free running mode to generate periodic interrupts. | |||
* @param TicksNumb Specifies the ticks Number of ticks between two interrupts. | |||
* @retval status: - 0 Function succeeded. | |||
* - 1 Function failed. | |||
*/ | |||
uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb) | |||
{ | |||
return SysTick_Config(TicksNumb); | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup CORTEX_Exported_Functions_Group2 | |||
* @brief Cortex control functions | |||
* | |||
@verbatim | |||
============================================================================== | |||
##### Peripheral Control functions ##### | |||
============================================================================== | |||
[..] | |||
This subsection provides a set of functions allowing to control the CORTEX | |||
(NVIC, SYSTICK, MPU) functionalities. | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Get the priority grouping field from the NVIC Interrupt Controller. | |||
* @retval Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field) | |||
*/ | |||
uint32_t HAL_NVIC_GetPriorityGrouping(void) | |||
{ | |||
/* Get the PRIGROUP[10:8] field value */ | |||
return NVIC_GetPriorityGrouping(); | |||
} | |||
/** | |||
* @brief Get the priority of an interrupt. | |||
* @param IRQn External interrupt number. | |||
* This parameter can be an enumerator of IRQn_Type enumeration | |||
* (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32wbxxxx.h)) | |||
* @param PriorityGroup the priority grouping bits length. | |||
* This parameter can be one of the following values: | |||
* @arg NVIC_PRIORITYGROUP_0: 0 bit for pre-emption priority, | |||
* 4 bits for subpriority | |||
* @arg NVIC_PRIORITYGROUP_1: 1 bit for pre-emption priority, | |||
* 3 bits for subpriority | |||
* @arg NVIC_PRIORITYGROUP_2: 2 bits for pre-emption priority, | |||
* 2 bits for subpriority | |||
* @arg NVIC_PRIORITYGROUP_3: 3 bits for pre-emption priority, | |||
* 1 bit for subpriority | |||
* @arg NVIC_PRIORITYGROUP_4: 4 bits for pre-emption priority, | |||
* 0 bit for subpriority | |||
* @param pPreemptPriority Pointer on the Preemptive priority value (starting from 0). | |||
* @param pSubPriority Pointer on the Subpriority value (starting from 0). | |||
* @retval None | |||
*/ | |||
void HAL_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t *pPreemptPriority, uint32_t *pSubPriority) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_NVIC_PRIORITY_GROUP(PriorityGroup)); | |||
/* Get priority for Cortex-M system or device specific interrupts */ | |||
NVIC_DecodePriority(NVIC_GetPriority(IRQn), PriorityGroup, pPreemptPriority, pSubPriority); | |||
} | |||
/** | |||
* @brief Set Pending bit of an external interrupt. | |||
* @param IRQn External interrupt number | |||
* This parameter can be an enumerator of IRQn_Type enumeration | |||
* (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32wbxxxx.h)) | |||
* @retval None | |||
*/ | |||
void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_NVIC_DEVICE_IRQ(IRQn)); | |||
/* Set interrupt pending */ | |||
NVIC_SetPendingIRQ(IRQn); | |||
} | |||
/** | |||
* @brief Get Pending Interrupt (read the pending register in the NVIC | |||
* and return the pending bit for the specified interrupt). | |||
* @param IRQn External interrupt number. | |||
* This parameter can be an enumerator of IRQn_Type enumeration | |||
* (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32wbxxxx.h)) | |||
* @retval status: - 0 Interrupt status is not pending. | |||
* - 1 Interrupt status is pending. | |||
*/ | |||
uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_NVIC_DEVICE_IRQ(IRQn)); | |||
/* Return 1 if pending else 0 */ | |||
return NVIC_GetPendingIRQ(IRQn); | |||
} | |||
/** | |||
* @brief Clear the pending bit of an external interrupt. | |||
* @param IRQn External interrupt number. | |||
* This parameter can be an enumerator of IRQn_Type enumeration | |||
* (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32wbxxxx.h)) | |||
* @retval None | |||
*/ | |||
void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_NVIC_DEVICE_IRQ(IRQn)); | |||
/* Clear pending interrupt */ | |||
NVIC_ClearPendingIRQ(IRQn); | |||
} | |||
/** | |||
* @brief Configure the SysTick clock source. | |||
* @param CLKSource specifies the SysTick clock source. | |||
* This parameter can be one of the following values: | |||
* @arg SYSTICK_CLKSOURCE_HCLK_DIV8: AHB clock divided by 8 selected as SysTick clock source. | |||
* @arg SYSTICK_CLKSOURCE_HCLK: AHB clock selected as SysTick clock source. | |||
* @retval None | |||
*/ | |||
void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_SYSTICK_CLK_SOURCE(CLKSource)); | |||
if (CLKSource == SYSTICK_CLKSOURCE_HCLK) | |||
{ | |||
SysTick->CTRL |= SYSTICK_CLKSOURCE_HCLK; | |||
} | |||
else | |||
{ | |||
SysTick->CTRL &= ~SYSTICK_CLKSOURCE_HCLK; | |||
} | |||
} | |||
/** | |||
* @brief Handle SYSTICK interrupt request. | |||
* @retval None | |||
*/ | |||
void HAL_SYSTICK_IRQHandler(void) | |||
{ | |||
HAL_SYSTICK_Callback(); | |||
} | |||
/** | |||
* @brief SYSTICK callback. | |||
* @retval None | |||
*/ | |||
__weak void HAL_SYSTICK_Callback(void) | |||
{ | |||
/* NOTE : This function should not be modified, when the callback is needed, | |||
the HAL_SYSTICK_Callback could be implemented in the user file | |||
*/ | |||
} | |||
#if (__MPU_PRESENT == 1U) | |||
/** | |||
* @brief Disables the MPU | |||
* @retval None | |||
*/ | |||
void HAL_MPU_Disable(void) | |||
{ | |||
/* Make sure outstanding transfers are done */ | |||
__DMB(); | |||
/* Disable fault exceptions */ | |||
SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; | |||
/* Disable the MPU and clear the control register*/ | |||
MPU->CTRL = 0U; | |||
} | |||
/** | |||
* @brief Enable the MPU. | |||
* @param MPU_Control: Specifies the control mode of the MPU during hard fault, | |||
* NMI, FAULTMASK and privileged access to the default memory | |||
* This parameter can be one of the following values: | |||
* @arg MPU_HFNMI_PRIVDEF_NONE | |||
* @arg MPU_HARDFAULT_NMI | |||
* @arg MPU_PRIVILEGED_DEFAULT | |||
* @arg MPU_HFNMI_PRIVDEF | |||
* @retval None | |||
*/ | |||
void HAL_MPU_Enable(uint32_t MPU_Control) | |||
{ | |||
/* Enable the MPU */ | |||
MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; | |||
/* Enable fault exceptions */ | |||
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; | |||
/* Ensure MPU setting take effects */ | |||
__DSB(); | |||
__ISB(); | |||
} | |||
/** | |||
* @brief Initialize and configure the Region and the memory to be protected. | |||
* @param MPU_Init Pointer to a MPU_Region_InitTypeDef structure that contains | |||
* the initialization and configuration information. | |||
* @retval None | |||
*/ | |||
void HAL_MPU_ConfigRegion(MPU_Region_InitTypeDef *MPU_Init) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_MPU_REGION_NUMBER(MPU_Init->Number)); | |||
assert_param(IS_MPU_REGION_ENABLE(MPU_Init->Enable)); | |||
/* Set the Region number */ | |||
MPU->RNR = MPU_Init->Number; | |||
if ((MPU_Init->Enable) != 0U) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_MPU_INSTRUCTION_ACCESS(MPU_Init->DisableExec)); | |||
assert_param(IS_MPU_REGION_PERMISSION_ATTRIBUTE(MPU_Init->AccessPermission)); | |||
assert_param(IS_MPU_TEX_LEVEL(MPU_Init->TypeExtField)); | |||
assert_param(IS_MPU_ACCESS_SHAREABLE(MPU_Init->IsShareable)); | |||
assert_param(IS_MPU_ACCESS_CACHEABLE(MPU_Init->IsCacheable)); | |||
assert_param(IS_MPU_ACCESS_BUFFERABLE(MPU_Init->IsBufferable)); | |||
assert_param(IS_MPU_SUB_REGION_DISABLE(MPU_Init->SubRegionDisable)); | |||
assert_param(IS_MPU_REGION_SIZE(MPU_Init->Size)); | |||
MPU->RBAR = MPU_Init->BaseAddress; | |||
MPU->RASR = ((uint32_t)MPU_Init->DisableExec << MPU_RASR_XN_Pos) | | |||
((uint32_t)MPU_Init->AccessPermission << MPU_RASR_AP_Pos) | | |||
((uint32_t)MPU_Init->TypeExtField << MPU_RASR_TEX_Pos) | | |||
((uint32_t)MPU_Init->IsShareable << MPU_RASR_S_Pos) | | |||
((uint32_t)MPU_Init->IsCacheable << MPU_RASR_C_Pos) | | |||
((uint32_t)MPU_Init->IsBufferable << MPU_RASR_B_Pos) | | |||
((uint32_t)MPU_Init->SubRegionDisable << MPU_RASR_SRD_Pos) | | |||
((uint32_t)MPU_Init->Size << MPU_RASR_SIZE_Pos) | | |||
((uint32_t)MPU_Init->Enable << MPU_RASR_ENABLE_Pos); | |||
} | |||
else | |||
{ | |||
MPU->RBAR = 0x00U; | |||
MPU->RASR = 0x00U; | |||
} | |||
} | |||
#endif /* __MPU_PRESENT */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* HAL_CORTEX_MODULE_ENABLED */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,518 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_crc.c | |||
* @author MCD Application Team | |||
* @brief CRC HAL module driver. | |||
* This file provides firmware functions to manage the following | |||
* functionalities of the Cyclic Redundancy Check (CRC) peripheral: | |||
* + Initialization and de-initialization functions | |||
* + Peripheral Control functions | |||
* + Peripheral State functions | |||
* | |||
@verbatim | |||
=============================================================================== | |||
##### How to use this driver ##### | |||
=============================================================================== | |||
[..] | |||
(+) Enable CRC AHB clock using __HAL_RCC_CRC_CLK_ENABLE(); | |||
(+) Initialize CRC calculator | |||
(++) specify generating polynomial (peripheral default or non-default one) | |||
(++) specify initialization value (peripheral default or non-default one) | |||
(++) specify input data format | |||
(++) specify input or output data inversion mode if any | |||
(+) Use HAL_CRC_Accumulate() function to compute the CRC value of the | |||
input data buffer starting with the previously computed CRC as | |||
initialization value | |||
(+) Use HAL_CRC_Calculate() function to compute the CRC value of the | |||
input data buffer starting with the defined initialization value | |||
(default or non-default) to initiate CRC calculation | |||
@endverbatim | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup CRC CRC | |||
* @brief CRC HAL module driver. | |||
* @{ | |||
*/ | |||
#ifdef HAL_CRC_MODULE_ENABLED | |||
/* Private typedef -----------------------------------------------------------*/ | |||
/* Private define ------------------------------------------------------------*/ | |||
/* Private macro -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private function prototypes -----------------------------------------------*/ | |||
/** @defgroup CRC_Private_Functions CRC Private Functions | |||
* @{ | |||
*/ | |||
static uint32_t CRC_Handle_8(CRC_HandleTypeDef *hcrc, uint8_t pBuffer[], uint32_t BufferLength); | |||
static uint32_t CRC_Handle_16(CRC_HandleTypeDef *hcrc, uint16_t pBuffer[], uint32_t BufferLength); | |||
/** | |||
* @} | |||
*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup CRC_Exported_Functions CRC Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions | |||
* @brief Initialization and Configuration functions. | |||
* | |||
@verbatim | |||
=============================================================================== | |||
##### Initialization and de-initialization functions ##### | |||
=============================================================================== | |||
[..] This section provides functions allowing to: | |||
(+) Initialize the CRC according to the specified parameters | |||
in the CRC_InitTypeDef and create the associated handle | |||
(+) DeInitialize the CRC peripheral | |||
(+) Initialize the CRC MSP (MCU Specific Package) | |||
(+) DeInitialize the CRC MSP | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Initialize the CRC according to the specified | |||
* parameters in the CRC_InitTypeDef and create the associated handle. | |||
* @param hcrc CRC handle | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc) | |||
{ | |||
/* Check the CRC handle allocation */ | |||
if (hcrc == NULL) | |||
{ | |||
return HAL_ERROR; | |||
} | |||
/* Check the parameters */ | |||
assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance)); | |||
if (hcrc->State == HAL_CRC_STATE_RESET) | |||
{ | |||
/* Allocate lock resource and initialize it */ | |||
hcrc->Lock = HAL_UNLOCKED; | |||
/* Init the low level hardware */ | |||
HAL_CRC_MspInit(hcrc); | |||
} | |||
hcrc->State = HAL_CRC_STATE_BUSY; | |||
/* check whether or not non-default generating polynomial has been | |||
* picked up by user */ | |||
assert_param(IS_DEFAULT_POLYNOMIAL(hcrc->Init.DefaultPolynomialUse)); | |||
if (hcrc->Init.DefaultPolynomialUse == DEFAULT_POLYNOMIAL_ENABLE) | |||
{ | |||
/* initialize peripheral with default generating polynomial */ | |||
WRITE_REG(hcrc->Instance->POL, DEFAULT_CRC32_POLY); | |||
MODIFY_REG(hcrc->Instance->CR, CRC_CR_POLYSIZE, CRC_POLYLENGTH_32B); | |||
} | |||
else | |||
{ | |||
/* initialize CRC peripheral with generating polynomial defined by user */ | |||
if (HAL_CRCEx_Polynomial_Set(hcrc, hcrc->Init.GeneratingPolynomial, hcrc->Init.CRCLength) != HAL_OK) | |||
{ | |||
return HAL_ERROR; | |||
} | |||
} | |||
/* check whether or not non-default CRC initial value has been | |||
* picked up by user */ | |||
assert_param(IS_DEFAULT_INIT_VALUE(hcrc->Init.DefaultInitValueUse)); | |||
if (hcrc->Init.DefaultInitValueUse == DEFAULT_INIT_VALUE_ENABLE) | |||
{ | |||
WRITE_REG(hcrc->Instance->INIT, DEFAULT_CRC_INITVALUE); | |||
} | |||
else | |||
{ | |||
WRITE_REG(hcrc->Instance->INIT, hcrc->Init.InitValue); | |||
} | |||
/* set input data inversion mode */ | |||
assert_param(IS_CRC_INPUTDATA_INVERSION_MODE(hcrc->Init.InputDataInversionMode)); | |||
MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_IN, hcrc->Init.InputDataInversionMode); | |||
/* set output data inversion mode */ | |||
assert_param(IS_CRC_OUTPUTDATA_INVERSION_MODE(hcrc->Init.OutputDataInversionMode)); | |||
MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_OUT, hcrc->Init.OutputDataInversionMode); | |||
/* makes sure the input data format (bytes, halfwords or words stream) | |||
* is properly specified by user */ | |||
assert_param(IS_CRC_INPUTDATA_FORMAT(hcrc->InputDataFormat)); | |||
/* Change CRC peripheral state */ | |||
hcrc->State = HAL_CRC_STATE_READY; | |||
/* Return function status */ | |||
return HAL_OK; | |||
} | |||
/** | |||
* @brief DeInitialize the CRC peripheral. | |||
* @param hcrc CRC handle | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc) | |||
{ | |||
/* Check the CRC handle allocation */ | |||
if (hcrc == NULL) | |||
{ | |||
return HAL_ERROR; | |||
} | |||
/* Check the parameters */ | |||
assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance)); | |||
/* Check the CRC peripheral state */ | |||
if (hcrc->State == HAL_CRC_STATE_BUSY) | |||
{ | |||
return HAL_BUSY; | |||
} | |||
/* Change CRC peripheral state */ | |||
hcrc->State = HAL_CRC_STATE_BUSY; | |||
/* Reset CRC calculation unit */ | |||
__HAL_CRC_DR_RESET(hcrc); | |||
/* Reset IDR register content */ | |||
CLEAR_BIT(hcrc->Instance->IDR, CRC_IDR_IDR); | |||
/* DeInit the low level hardware */ | |||
HAL_CRC_MspDeInit(hcrc); | |||
/* Change CRC peripheral state */ | |||
hcrc->State = HAL_CRC_STATE_RESET; | |||
/* Process unlocked */ | |||
__HAL_UNLOCK(hcrc); | |||
/* Return function status */ | |||
return HAL_OK; | |||
} | |||
/** | |||
* @brief Initializes the CRC MSP. | |||
* @param hcrc CRC handle | |||
* @retval None | |||
*/ | |||
__weak void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc) | |||
{ | |||
/* Prevent unused argument(s) compilation warning */ | |||
UNUSED(hcrc); | |||
/* NOTE : This function should not be modified, when the callback is needed, | |||
the HAL_CRC_MspInit can be implemented in the user file | |||
*/ | |||
} | |||
/** | |||
* @brief DeInitialize the CRC MSP. | |||
* @param hcrc CRC handle | |||
* @retval None | |||
*/ | |||
__weak void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc) | |||
{ | |||
/* Prevent unused argument(s) compilation warning */ | |||
UNUSED(hcrc); | |||
/* NOTE : This function should not be modified, when the callback is needed, | |||
the HAL_CRC_MspDeInit can be implemented in the user file | |||
*/ | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions | |||
* @brief management functions. | |||
* | |||
@verbatim | |||
=============================================================================== | |||
##### Peripheral Control functions ##### | |||
=============================================================================== | |||
[..] This section provides functions allowing to: | |||
(+) compute the 7, 8, 16 or 32-bit CRC value of an 8, 16 or 32-bit data buffer | |||
using combination of the previous CRC value and the new one. | |||
[..] or | |||
(+) compute the 7, 8, 16 or 32-bit CRC value of an 8, 16 or 32-bit data buffer | |||
independently of the previous CRC value. | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Compute the 7, 8, 16 or 32-bit CRC value of an 8, 16 or 32-bit data buffer | |||
* starting with the previously computed CRC as initialization value. | |||
* @param hcrc CRC handle | |||
* @param pBuffer pointer to the input data buffer, exact input data format is | |||
* provided by hcrc->InputDataFormat. | |||
* @param BufferLength input data buffer length (number of bytes if pBuffer | |||
* type is * uint8_t, number of half-words if pBuffer type is * uint16_t, | |||
* number of words if pBuffer type is * uint32_t). | |||
* @note By default, the API expects a uint32_t pointer as input buffer parameter. | |||
* Input buffer pointers with other types simply need to be cast in uint32_t | |||
* and the API will internally adjust its input data processing based on the | |||
* handle field hcrc->InputDataFormat. | |||
* @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits) | |||
*/ | |||
uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength) | |||
{ | |||
uint32_t index; /* CRC input data buffer index */ | |||
uint32_t temp = 0U; /* CRC output (read from hcrc->Instance->DR register) */ | |||
/* Change CRC peripheral state */ | |||
hcrc->State = HAL_CRC_STATE_BUSY; | |||
switch (hcrc->InputDataFormat) | |||
{ | |||
case CRC_INPUTDATA_FORMAT_WORDS: | |||
/* Enter Data to the CRC calculator */ | |||
for (index = 0U; index < BufferLength; index++) | |||
{ | |||
hcrc->Instance->DR = pBuffer[index]; | |||
} | |||
temp = hcrc->Instance->DR; | |||
break; | |||
case CRC_INPUTDATA_FORMAT_BYTES: | |||
temp = CRC_Handle_8(hcrc, (uint8_t *)pBuffer, BufferLength); | |||
break; | |||
case CRC_INPUTDATA_FORMAT_HALFWORDS: | |||
temp = CRC_Handle_16(hcrc, (uint16_t *)(void *)pBuffer, BufferLength); /* Derogation MisraC2012 R.11.5 */ | |||
break; | |||
default: | |||
break; | |||
} | |||
/* Change CRC peripheral state */ | |||
hcrc->State = HAL_CRC_STATE_READY; | |||
/* Return the CRC computed value */ | |||
return temp; | |||
} | |||
/** | |||
* @brief Compute the 7, 8, 16 or 32-bit CRC value of an 8, 16 or 32-bit data buffer | |||
* starting with hcrc->Instance->INIT as initialization value. | |||
* @param hcrc CRC handle | |||
* @param pBuffer pointer to the input data buffer, exact input data format is | |||
* provided by hcrc->InputDataFormat. | |||
* @param BufferLength input data buffer length (number of bytes if pBuffer | |||
* type is * uint8_t, number of half-words if pBuffer type is * uint16_t, | |||
* number of words if pBuffer type is * uint32_t). | |||
* @note By default, the API expects a uint32_t pointer as input buffer parameter. | |||
* Input buffer pointers with other types simply need to be cast in uint32_t | |||
* and the API will internally adjust its input data processing based on the | |||
* handle field hcrc->InputDataFormat. | |||
* @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits) | |||
*/ | |||
uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength) | |||
{ | |||
uint32_t index; /* CRC input data buffer index */ | |||
uint32_t temp = 0U; /* CRC output (read from hcrc->Instance->DR register) */ | |||
/* Change CRC peripheral state */ | |||
hcrc->State = HAL_CRC_STATE_BUSY; | |||
/* Reset CRC Calculation Unit (hcrc->Instance->INIT is | |||
* written in hcrc->Instance->DR) */ | |||
__HAL_CRC_DR_RESET(hcrc); | |||
switch (hcrc->InputDataFormat) | |||
{ | |||
case CRC_INPUTDATA_FORMAT_WORDS: | |||
/* Enter 32-bit input data to the CRC calculator */ | |||
for (index = 0U; index < BufferLength; index++) | |||
{ | |||
hcrc->Instance->DR = pBuffer[index]; | |||
} | |||
temp = hcrc->Instance->DR; | |||
break; | |||
case CRC_INPUTDATA_FORMAT_BYTES: | |||
/* Specific 8-bit input data handling */ | |||
temp = CRC_Handle_8(hcrc, (uint8_t *)pBuffer, BufferLength); | |||
break; | |||
case CRC_INPUTDATA_FORMAT_HALFWORDS: | |||
/* Specific 16-bit input data handling */ | |||
temp = CRC_Handle_16(hcrc, (uint16_t *)(void *)pBuffer, BufferLength); /* Derogation MisraC2012 R.11.5 */ | |||
break; | |||
default: | |||
break; | |||
} | |||
/* Change CRC peripheral state */ | |||
hcrc->State = HAL_CRC_STATE_READY; | |||
/* Return the CRC computed value */ | |||
return temp; | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions | |||
* @brief Peripheral State functions. | |||
* | |||
@verbatim | |||
=============================================================================== | |||
##### Peripheral State functions ##### | |||
=============================================================================== | |||
[..] | |||
This subsection permits to get in run-time the status of the peripheral. | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Return the CRC handle state. | |||
* @param hcrc CRC handle | |||
* @retval HAL state | |||
*/ | |||
HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc) | |||
{ | |||
/* Return CRC handle state */ | |||
return hcrc->State; | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/** @addtogroup CRC_Private_Functions | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Enter 8-bit input data to the CRC calculator. | |||
* Specific data handling to optimize processing time. | |||
* @param hcrc CRC handle | |||
* @param pBuffer pointer to the input data buffer | |||
* @param BufferLength input data buffer length | |||
* @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits) | |||
*/ | |||
static uint32_t CRC_Handle_8(CRC_HandleTypeDef *hcrc, uint8_t pBuffer[], uint32_t BufferLength) | |||
{ | |||
uint32_t i; /* input data buffer index */ | |||
uint16_t data; | |||
__IO uint16_t *pReg; | |||
/* Processing time optimization: 4 bytes are entered in a row with a single word write, | |||
* last bytes must be carefully fed to the CRC calculator to ensure a correct type | |||
* handling by the peripheral */ | |||
for (i = 0U; i < (BufferLength / 4U); i++) | |||
{ | |||
hcrc->Instance->DR = ((uint32_t)pBuffer[4U * i] << 24U) | \ | |||
((uint32_t)pBuffer[(4U * i) + 1U] << 16U) | \ | |||
((uint32_t)pBuffer[(4U * i) + 2U] << 8U) | \ | |||
(uint32_t)pBuffer[(4U * i) + 3U]; | |||
} | |||
/* last bytes specific handling */ | |||
if ((BufferLength % 4U) != 0U) | |||
{ | |||
if ((BufferLength % 4U) == 1U) | |||
{ | |||
*(__IO uint8_t *)(__IO void *)(&hcrc->Instance->DR) = pBuffer[4U * i]; /* Derogation MisraC2012 R.11.5 */ | |||
} | |||
if ((BufferLength % 4U) == 2U) | |||
{ | |||
data = ((uint16_t)(pBuffer[4U * i]) << 8U) | (uint16_t)pBuffer[(4U * i) + 1U]; | |||
pReg = (__IO uint16_t *)(__IO void *)(&hcrc->Instance->DR); /* Derogation MisraC2012 R.11.5 */ | |||
*pReg = data; | |||
} | |||
if ((BufferLength % 4U) == 3U) | |||
{ | |||
data = ((uint16_t)(pBuffer[4U * i]) << 8U) | (uint16_t)pBuffer[(4U * i) + 1U]; | |||
pReg = (__IO uint16_t *)(__IO void *)(&hcrc->Instance->DR); /* Derogation MisraC2012 R.11.5 */ | |||
*pReg = data; | |||
*(__IO uint8_t *)(__IO void *)(&hcrc->Instance->DR) = pBuffer[(4U * i) + 2U]; /* Derogation MisraC2012 R.11.5 */ | |||
} | |||
} | |||
/* Return the CRC computed value */ | |||
return hcrc->Instance->DR; | |||
} | |||
/** | |||
* @brief Enter 16-bit input data to the CRC calculator. | |||
* Specific data handling to optimize processing time. | |||
* @param hcrc CRC handle | |||
* @param pBuffer pointer to the input data buffer | |||
* @param BufferLength input data buffer length | |||
* @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits) | |||
*/ | |||
static uint32_t CRC_Handle_16(CRC_HandleTypeDef *hcrc, uint16_t pBuffer[], uint32_t BufferLength) | |||
{ | |||
uint32_t i; /* input data buffer index */ | |||
__IO uint16_t *pReg; | |||
/* Processing time optimization: 2 HalfWords are entered in a row with a single word write, | |||
* in case of odd length, last HalfWord must be carefully fed to the CRC calculator to ensure | |||
* a correct type handling by the peripheral */ | |||
for (i = 0U; i < (BufferLength / 2U); i++) | |||
{ | |||
hcrc->Instance->DR = ((uint32_t)pBuffer[2U * i] << 16U) | (uint32_t)pBuffer[(2U * i) + 1U]; | |||
} | |||
if ((BufferLength % 2U) != 0U) | |||
{ | |||
pReg = (__IO uint16_t *)(__IO void *)(&hcrc->Instance->DR); /* Derogation MisraC2012 R.11.5 */ | |||
*pReg = pBuffer[2U * i]; | |||
} | |||
/* Return the CRC computed value */ | |||
return hcrc->Instance->DR; | |||
} | |||
/** | |||
* @} | |||
*/ | |||
#endif /* HAL_CRC_MODULE_ENABLED */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,225 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_crc_ex.c | |||
* @author MCD Application Team | |||
* @brief Extended CRC HAL module driver. | |||
* This file provides firmware functions to manage the extended | |||
* functionalities of the CRC peripheral. | |||
* | |||
@verbatim | |||
================================================================================ | |||
##### How to use this driver ##### | |||
================================================================================ | |||
[..] | |||
(+) Set user-defined generating polynomial thru HAL_CRCEx_Polynomial_Set() | |||
(+) Configure Input or Output data inversion | |||
@endverbatim | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @defgroup CRCEx CRCEx | |||
* @brief CRC Extended HAL module driver | |||
* @{ | |||
*/ | |||
#ifdef HAL_CRC_MODULE_ENABLED | |||
/* Private typedef -----------------------------------------------------------*/ | |||
/* Private define ------------------------------------------------------------*/ | |||
/* Private macro -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private function prototypes -----------------------------------------------*/ | |||
/* Exported functions --------------------------------------------------------*/ | |||
/** @defgroup CRCEx_Exported_Functions CRC Extended Exported Functions | |||
* @{ | |||
*/ | |||
/** @defgroup CRCEx_Exported_Functions_Group1 Extended Initialization/de-initialization functions | |||
* @brief Extended Initialization and Configuration functions. | |||
* | |||
@verbatim | |||
=============================================================================== | |||
##### Extended configuration functions ##### | |||
=============================================================================== | |||
[..] This section provides functions allowing to: | |||
(+) Configure the generating polynomial | |||
(+) Configure the input data inversion | |||
(+) Configure the output data inversion | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief Initialize the CRC polynomial if different from default one. | |||
* @param hcrc CRC handle | |||
* @param Pol CRC generating polynomial (7, 8, 16 or 32-bit long). | |||
* This parameter is written in normal representation, e.g. | |||
* @arg for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65 | |||
* @arg for a polynomial of degree 16, X^16 + X^12 + X^5 + 1 is written 0x1021 | |||
* @param PolyLength CRC polynomial length. | |||
* This parameter can be one of the following values: | |||
* @arg @ref CRC_POLYLENGTH_7B 7-bit long CRC (generating polynomial of degree 7) | |||
* @arg @ref CRC_POLYLENGTH_8B 8-bit long CRC (generating polynomial of degree 8) | |||
* @arg @ref CRC_POLYLENGTH_16B 16-bit long CRC (generating polynomial of degree 16) | |||
* @arg @ref CRC_POLYLENGTH_32B 32-bit long CRC (generating polynomial of degree 32) | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_CRCEx_Polynomial_Set(CRC_HandleTypeDef *hcrc, uint32_t Pol, uint32_t PolyLength) | |||
{ | |||
HAL_StatusTypeDef status = HAL_OK; | |||
uint32_t msb = 31U; /* polynomial degree is 32 at most, so msb is initialized to max value */ | |||
/* Check the parameters */ | |||
assert_param(IS_CRC_POL_LENGTH(PolyLength)); | |||
/* check polynomial definition vs polynomial size: | |||
* polynomial length must be aligned with polynomial | |||
* definition. HAL_ERROR is reported if Pol degree is | |||
* larger than that indicated by PolyLength. | |||
* Look for MSB position: msb will contain the degree of | |||
* the second to the largest polynomial member. E.g., for | |||
* X^7 + X^6 + X^5 + X^2 + 1, msb = 6. */ | |||
while ((msb-- > 0U) && ((Pol & ((uint32_t)(0x1U) << (msb & 0x1FU))) == 0U)) | |||
{ | |||
} | |||
switch (PolyLength) | |||
{ | |||
case CRC_POLYLENGTH_7B: | |||
if (msb >= HAL_CRC_LENGTH_7B) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
break; | |||
case CRC_POLYLENGTH_8B: | |||
if (msb >= HAL_CRC_LENGTH_8B) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
break; | |||
case CRC_POLYLENGTH_16B: | |||
if (msb >= HAL_CRC_LENGTH_16B) | |||
{ | |||
status = HAL_ERROR; | |||
} | |||
break; | |||
case CRC_POLYLENGTH_32B: | |||
/* no polynomial definition vs. polynomial length issue possible */ | |||
break; | |||
default: | |||
status = HAL_ERROR; | |||
break; | |||
} | |||
if (status == HAL_OK) | |||
{ | |||
/* set generating polynomial */ | |||
WRITE_REG(hcrc->Instance->POL, Pol); | |||
/* set generating polynomial size */ | |||
MODIFY_REG(hcrc->Instance->CR, CRC_CR_POLYSIZE, PolyLength); | |||
} | |||
/* Return function status */ | |||
return status; | |||
} | |||
/** | |||
* @brief Set the Reverse Input data mode. | |||
* @param hcrc CRC handle | |||
* @param InputReverseMode Input Data inversion mode. | |||
* This parameter can be one of the following values: | |||
* @arg @ref CRC_INPUTDATA_INVERSION_NONE no change in bit order (default value) | |||
* @arg @ref CRC_INPUTDATA_INVERSION_BYTE Byte-wise bit reversal | |||
* @arg @ref CRC_INPUTDATA_INVERSION_HALFWORD HalfWord-wise bit reversal | |||
* @arg @ref CRC_INPUTDATA_INVERSION_WORD Word-wise bit reversal | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_CRCEx_Input_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t InputReverseMode) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_CRC_INPUTDATA_INVERSION_MODE(InputReverseMode)); | |||
/* Change CRC peripheral state */ | |||
hcrc->State = HAL_CRC_STATE_BUSY; | |||
/* set input data inversion mode */ | |||
MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_IN, InputReverseMode); | |||
/* Change CRC peripheral state */ | |||
hcrc->State = HAL_CRC_STATE_READY; | |||
/* Return function status */ | |||
return HAL_OK; | |||
} | |||
/** | |||
* @brief Set the Reverse Output data mode. | |||
* @param hcrc CRC handle | |||
* @param OutputReverseMode Output Data inversion mode. | |||
* This parameter can be one of the following values: | |||
* @arg @ref CRC_OUTPUTDATA_INVERSION_DISABLE no CRC inversion (default value) | |||
* @arg @ref CRC_OUTPUTDATA_INVERSION_ENABLE bit-level inversion (e.g. for a 8-bit CRC: 0xB5 becomes 0xAD) | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_CRCEx_Output_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t OutputReverseMode) | |||
{ | |||
/* Check the parameters */ | |||
assert_param(IS_CRC_OUTPUTDATA_INVERSION_MODE(OutputReverseMode)); | |||
/* Change CRC peripheral state */ | |||
hcrc->State = HAL_CRC_STATE_BUSY; | |||
/* set output data inversion mode */ | |||
MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_OUT, OutputReverseMode); | |||
/* Change CRC peripheral state */ | |||
hcrc->State = HAL_CRC_STATE_READY; | |||
/* Return function status */ | |||
return HAL_OK; | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* HAL_CRC_MODULE_ENABLED */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,382 @@ | |||
/** | |||
****************************************************************************** | |||
* @file stm32wbxx_hal_cryp_ex.c | |||
* @author MCD Application Team | |||
* @brief CRYPEx HAL module driver. | |||
* This file provides firmware functions to manage the extended | |||
* functionalities of the Cryptography (CRYP) peripheral. | |||
* | |||
****************************************************************************** | |||
* @attention | |||
* | |||
* <h2><center>© Copyright (c) 2019 STMicroelectronics. | |||
* All rights reserved.</center></h2> | |||
* | |||
* This software component is licensed by ST under BSD 3-Clause license, | |||
* the "License"; You may not use this file except in compliance with the | |||
* License. You may obtain a copy of the License at: | |||
* opensource.org/licenses/BSD-3-Clause | |||
* | |||
****************************************************************************** | |||
*/ | |||
/* Includes ------------------------------------------------------------------*/ | |||
#include "stm32wbxx_hal.h" | |||
/** @addtogroup STM32WBxx_HAL_Driver | |||
* @{ | |||
*/ | |||
/** @addtogroup CRYPEx | |||
* @{ | |||
*/ | |||
#ifdef HAL_CRYP_MODULE_ENABLED | |||
/* Private typedef -----------------------------------------------------------*/ | |||
/* Private define ------------------------------------------------------------*/ | |||
/** @addtogroup CRYPEx_Private_Defines | |||
* @{ | |||
*/ | |||
#define CRYP_PHASE_INIT 0x00000000U /*!< GCM/GMAC (or CCM) init phase */ | |||
#define CRYP_PHASE_HEADER AES_CR_GCMPH_0 /*!< GCM/GMAC or CCM header phase */ | |||
#define CRYP_PHASE_PAYLOAD AES_CR_GCMPH_1 /*!< GCM(/CCM) payload phase */ | |||
#define CRYP_PHASE_FINAL AES_CR_GCMPH /*!< GCM/GMAC or CCM final phase */ | |||
#define CRYP_OPERATINGMODE_ENCRYPT 0x00000000U /*!< Encryption mode */ | |||
#define CRYP_OPERATINGMODE_KEYDERIVATION AES_CR_MODE_0 /*!< Key derivation mode only used when performing ECB and CBC decryptions */ | |||
#define CRYP_OPERATINGMODE_DECRYPT AES_CR_MODE_1 /*!< Decryption */ | |||
#define CRYP_OPERATINGMODE_KEYDERIVATION_DECRYPT AES_CR_MODE /*!< Key derivation and decryption only used when performing ECB and CBC decryptions */ | |||
#define CRYPEx_PHASE_PROCESS 0x02U /*!< CRYP peripheral is in processing phase */ | |||
#define CRYPEx_PHASE_FINAL 0x03U /*!< CRYP peripheral is in final phase this is relevant only with CCM and GCM modes */ | |||
/* CTR0 information to use in CCM algorithm */ | |||
#define CRYP_CCM_CTR0_0 0x07FFFFFFU | |||
#define CRYP_CCM_CTR0_3 0xFFFFFF00U | |||
/** | |||
* @} | |||
*/ | |||
/* Private macro -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
/* Private function prototypes -----------------------------------------------*/ | |||
/* Exported functions---------------------------------------------------------*/ | |||
/** @addtogroup CRYPEx_Exported_Functions | |||
* @{ | |||
*/ | |||
/** @defgroup CRYPEx_Exported_Functions_Group1 Extended AES processing functions | |||
* @brief Extended processing functions. | |||
* | |||
@verbatim | |||
============================================================================== | |||
##### Extended AES processing functions ##### | |||
============================================================================== | |||
[..] This section provides functions allowing to generate the authentication | |||
TAG in Polling mode | |||
(#)HAL_CRYPEx_AESGCM_GenerateAuthTAG | |||
(#)HAL_CRYPEx_AESCCM_GenerateAuthTAG | |||
they should be used after Encrypt/Decrypt operation. | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief generate the GCM authentication TAG. | |||
* @param hcryp pointer to a CRYP_HandleTypeDef structure that contains | |||
* the configuration information for CRYP module | |||
* @param AuthTag Pointer to the authentication buffer | |||
* @param Timeout Timeout duration | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_CRYPEx_AESGCM_GenerateAuthTAG(CRYP_HandleTypeDef *hcryp, uint32_t *AuthTag, uint32_t Timeout) | |||
{ | |||
uint32_t tickstart; | |||
uint64_t headerlength = (uint64_t)hcryp->Init.HeaderSize * 32U; /* Header length in bits */ | |||
uint64_t inputlength = (uint64_t)hcryp->SizesSum * 8U; /* input length in bits */ | |||
uint32_t tagaddr = (uint32_t)AuthTag; | |||
if (hcryp->State == HAL_CRYP_STATE_READY) | |||
{ | |||
/* Process locked */ | |||
__HAL_LOCK(hcryp); | |||
/* Change the CRYP peripheral state */ | |||
hcryp->State = HAL_CRYP_STATE_BUSY; | |||
/* Check if initialization phase has already been performed */ | |||
if (hcryp->Phase == CRYPEx_PHASE_PROCESS) | |||
{ | |||
/* Change the CRYP phase */ | |||
hcryp->Phase = CRYPEx_PHASE_FINAL; | |||
} | |||
else /* Initialization phase has not been performed*/ | |||
{ | |||
/* Disable the Peripheral */ | |||
__HAL_CRYP_DISABLE(hcryp); | |||
/* Sequence error code field */ | |||
hcryp->ErrorCode |= HAL_CRYP_ERROR_AUTH_TAG_SEQUENCE; | |||
/* Change the CRYP peripheral state */ | |||
hcryp->State = HAL_CRYP_STATE_READY; | |||
/* Process unlocked */ | |||
__HAL_UNLOCK(hcryp); | |||
return HAL_ERROR; | |||
} | |||
/* Select final phase */ | |||
MODIFY_REG(hcryp->Instance->CR, AES_CR_GCMPH, CRYP_PHASE_FINAL); | |||
/* Set the encrypt operating mode*/ | |||
MODIFY_REG(hcryp->Instance->CR, AES_CR_MODE, CRYP_OPERATINGMODE_ENCRYPT); | |||
/*TinyAES peripheral from V3.1.1 : data has to be inserted normally (no swapping)*/ | |||
/* Write into the AES_DINR register the number of bits in header (64 bits) | |||
followed by the number of bits in the payload */ | |||
hcryp->Instance->DINR = 0U; | |||
hcryp->Instance->DINR = (uint32_t)(headerlength); | |||
hcryp->Instance->DINR = 0U; | |||
hcryp->Instance->DINR = (uint32_t)(inputlength); | |||
/* Wait for CCF flag to be raised */ | |||
tickstart = HAL_GetTick(); | |||
while (HAL_IS_BIT_CLR(hcryp->Instance->SR, AES_SR_CCF)) | |||
{ | |||
/* Check for the Timeout */ | |||
if (Timeout != HAL_MAX_DELAY) | |||
{ | |||
if (((HAL_GetTick() - tickstart) > Timeout)||(Timeout == 0U)) | |||
{ | |||
/* Disable the CRYP peripheral clock */ | |||
__HAL_CRYP_DISABLE(hcryp); | |||
/* Change state */ | |||
hcryp->ErrorCode |= HAL_CRYP_ERROR_TIMEOUT; | |||
hcryp->State = HAL_CRYP_STATE_READY; | |||
/* Process unlocked */ | |||
__HAL_UNLOCK(hcryp); | |||
return HAL_ERROR; | |||
} | |||
} | |||
} | |||
/* Read the authentication TAG in the output FIFO */ | |||
*(uint32_t *)(tagaddr) = hcryp->Instance->DOUTR; | |||
tagaddr += 4U; | |||
*(uint32_t *)(tagaddr) = hcryp->Instance->DOUTR; | |||
tagaddr += 4U; | |||
*(uint32_t *)(tagaddr) = hcryp->Instance->DOUTR; | |||
tagaddr += 4U; | |||
*(uint32_t *)(tagaddr) = hcryp->Instance->DOUTR; | |||
/* Clear CCF flag */ | |||
__HAL_CRYP_CLEAR_FLAG(hcryp, CRYP_CCF_CLEAR); | |||
/* Disable the peripheral */ | |||
__HAL_CRYP_DISABLE(hcryp); | |||
/* Change the CRYP peripheral state */ | |||
hcryp->State = HAL_CRYP_STATE_READY; | |||
/* Process unlocked */ | |||
__HAL_UNLOCK(hcryp); | |||
} | |||
else | |||
{ | |||
/* Busy error code field */ | |||
hcryp->ErrorCode |= HAL_CRYP_ERROR_BUSY; | |||
return HAL_ERROR; | |||
} | |||
/* Return function status */ | |||
return HAL_OK; | |||
} | |||
/** | |||
* @brief AES CCM Authentication TAG generation. | |||
* @param hcryp pointer to a CRYP_HandleTypeDef structure that contains | |||
* the configuration information for CRYP module | |||
* @param AuthTag Pointer to the authentication buffer | |||
* @param Timeout Timeout duration | |||
* @retval HAL status | |||
*/ | |||
HAL_StatusTypeDef HAL_CRYPEx_AESCCM_GenerateAuthTAG(CRYP_HandleTypeDef *hcryp, uint32_t *AuthTag, uint32_t Timeout) | |||
{ | |||
uint32_t tagaddr = (uint32_t)AuthTag; | |||
uint32_t tickstart; | |||
if (hcryp->State == HAL_CRYP_STATE_READY) | |||
{ | |||
/* Process locked */ | |||
__HAL_LOCK(hcryp); | |||
/* Disable interrupts in case they were kept enabled to proceed | |||
a single message in several iterations */ | |||
__HAL_CRYP_DISABLE_IT(hcryp, CRYP_IT_CCFIE | CRYP_IT_ERRIE); | |||
/* Change the CRYP peripheral state */ | |||
hcryp->State = HAL_CRYP_STATE_BUSY; | |||
/* Check if initialization phase has already been performed */ | |||
if (hcryp->Phase == CRYPEx_PHASE_PROCESS) | |||
{ | |||
/* Change the CRYP phase */ | |||
hcryp->Phase = CRYPEx_PHASE_FINAL; | |||
} | |||
else /* Initialization phase has not been performed*/ | |||
{ | |||
/* Disable the peripheral */ | |||
__HAL_CRYP_DISABLE(hcryp); | |||
/* Sequence error code field */ | |||
hcryp->ErrorCode |= HAL_CRYP_ERROR_AUTH_TAG_SEQUENCE; | |||
/* Change the CRYP peripheral state */ | |||
hcryp->State = HAL_CRYP_STATE_READY; | |||
/* Process unlocked */ | |||
__HAL_UNLOCK(hcryp); | |||
return HAL_ERROR; | |||
} | |||
/* Select final phase */ | |||
MODIFY_REG(hcryp->Instance->CR, AES_CR_GCMPH, CRYP_PHASE_FINAL); | |||
/* Set encrypt operating mode*/ | |||
MODIFY_REG(hcryp->Instance->CR, AES_CR_MODE, CRYP_OPERATINGMODE_ENCRYPT); | |||
/* Wait for CCF flag to be raised */ | |||
tickstart = HAL_GetTick(); | |||
while (HAL_IS_BIT_CLR(hcryp->Instance->SR, AES_SR_CCF)) | |||
{ | |||
/* Check for the Timeout */ | |||
if (Timeout != HAL_MAX_DELAY) | |||
{ | |||
if (((HAL_GetTick() - tickstart) > Timeout) ||(Timeout == 0U)) | |||
{ | |||
/* Disable the CRYP peripheral Clock */ | |||
__HAL_CRYP_DISABLE(hcryp); | |||
/* Change state */ | |||
hcryp->ErrorCode |= HAL_CRYP_ERROR_TIMEOUT; | |||
hcryp->State = HAL_CRYP_STATE_READY; | |||
/* Process unlocked */ | |||
__HAL_UNLOCK(hcryp); | |||
return HAL_ERROR; | |||
} | |||
} | |||
} | |||
/* Read the authentication TAG in the output FIFO */ | |||
*(uint32_t *)(tagaddr) = hcryp->Instance->DOUTR; | |||
tagaddr += 4U; | |||
*(uint32_t *)(tagaddr) = hcryp->Instance->DOUTR; | |||
tagaddr += 4U; | |||
*(uint32_t *)(tagaddr) = hcryp->Instance->DOUTR; | |||
tagaddr += 4U; | |||
*(uint32_t *)(tagaddr) = hcryp->Instance->DOUTR; | |||
/* Clear CCF Flag */ | |||
__HAL_CRYP_CLEAR_FLAG(hcryp, CRYP_CCF_CLEAR); | |||
/* Change the CRYP peripheral state */ | |||
hcryp->State = HAL_CRYP_STATE_READY; | |||
/* Process unlocked */ | |||
__HAL_UNLOCK(hcryp); | |||
/* Disable CRYP */ | |||
__HAL_CRYP_DISABLE(hcryp); | |||
} | |||
else | |||
{ | |||
/* Busy error code field */ | |||
hcryp->ErrorCode = HAL_CRYP_ERROR_BUSY; | |||
return HAL_ERROR; | |||
} | |||
/* Return function status */ | |||
return HAL_OK; | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** @defgroup CRYPEx_Exported_Functions_Group2 Extended AES Key Derivations functions | |||
* @brief Extended Key Derivations functions. | |||
* | |||
@verbatim | |||
============================================================================== | |||
##### Key Derivation functions ##### | |||
============================================================================== | |||
[..] This section provides functions allowing to Enable or Disable the | |||
the AutoKeyDerivation parameter in CRYP_HandleTypeDef structure | |||
These function are allowed only in TinyAES peripheral. | |||
@endverbatim | |||
* @{ | |||
*/ | |||
/** | |||
* @brief AES enable key derivation functions | |||
* @param hcryp pointer to a CRYP_HandleTypeDef structure. | |||
*/ | |||
void HAL_CRYPEx_EnableAutoKeyDerivation(CRYP_HandleTypeDef *hcryp) | |||
{ | |||
if (hcryp->State == HAL_CRYP_STATE_READY) | |||
{ | |||
hcryp->AutoKeyDerivation = ENABLE; | |||
} | |||
else | |||
{ | |||
/* Busy error code field */ | |||
hcryp->ErrorCode = HAL_CRYP_ERROR_BUSY; | |||
} | |||
} | |||
/** | |||
* @brief AES disable key derivation functions | |||
* @param hcryp pointer to a CRYP_HandleTypeDef structure. | |||
*/ | |||
void HAL_CRYPEx_DisableAutoKeyDerivation(CRYP_HandleTypeDef *hcryp) | |||
{ | |||
if (hcryp->State == HAL_CRYP_STATE_READY) | |||
{ | |||
hcryp->AutoKeyDerivation = DISABLE; | |||
} | |||
else | |||
{ | |||
/* Busy error code field */ | |||
hcryp->ErrorCode = HAL_CRYP_ERROR_BUSY; | |||
} | |||
} | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
#endif /* HAL_CRYP_MODULE_ENABLED */ | |||
/** | |||
* @} | |||
*/ | |||
/** | |||
* @} | |||
*/ | |||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |