diff --git a/Makefile.opts.sample b/Makefile.opts.sample
index e88b89f..64ed67b 100644
--- a/Makefile.opts.sample
+++ b/Makefile.opts.sample
@@ -29,13 +29,6 @@ MCU_SUBTYPE=stm32f446xx
#MCU_SUBTYPE=stm32l1xx_mdp
#MCU_SUBTYPE=stm32l1xx_hd
-#MCU=stm32w108xx
-#MCU_SUBTYPE=stm32w108c8
-#MCU_SUBTYPE=stm32w108cc
-#MCU_SUBTYPE=stm32w108cz
-#MCU_SUBTYPE=stm32w108db
-#MCU_SUBTYPE=stm32w108hz
-
#MCU=stm32f30x
#MCU=stm32f37x
diff --git a/libs/CMSIS/Device/ST/STM32W108xx/Include/stm32w108xx.h b/libs/CMSIS/Device/ST/STM32W108xx/Include/stm32w108xx.h
deleted file mode 100644
index 311fa5a..0000000
--- a/libs/CMSIS/Device/ST/STM32W108xx/Include/stm32w108xx.h
+++ /dev/null
@@ -1,1967 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32w108xx.h
- * @author MCD Application Team
- * @version V1.0.1
- * @date 30-November-2012
- * @brief CMSIS Cortex-M3 Device Peripheral Access Layer Header File.
- * This file contains all the peripheral register's definitions, bits
- * definitions and memory mapping for STM32W108xx devices.
- *
- * 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 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_STDPERIPH_DRIVER"
- * - To change few application-specific parameters such as the HSE
- * crystal frequency
- * - Data structures and the address mapping for all peripherals
- * - Peripheral's registers declarations and bits definition
- * - Macros to access peripheral’s registers hardware
- *
- ******************************************************************************
- * @attention
- *
- *
First official release
-for STM32W108xx devices running on MBxxx
-boards
-
Development
-Toolchains
- IAR Embedded
-Workbench for ARM (EWARM) toolchain V6.40
-
-
License
-
Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this package except in compliance with the License. You may obtain a copy of the License at:
Unless
-required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
-the License for the specific language governing permissions and
-limitations under the License.
-
-
-
For
-complete documentation on STMicroelectronics Microcontrollers visit www.st.com
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/libs/CMSIS/Device/ST/STM32W108xx/Source/Templates/TrueSTUDIO/startup_stm32w108xx.s b/libs/CMSIS/Device/ST/STM32W108xx/Source/Templates/TrueSTUDIO/startup_stm32w108xx.s
deleted file mode 100644
index 79ff9eb..0000000
--- a/libs/CMSIS/Device/ST/STM32W108xx/Source/Templates/TrueSTUDIO/startup_stm32w108xx.s
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
- ******************************************************************************
- * @file : startup_stm32w108xx.s
- * Author : MCD Application Team
- * Version : V0.0.1RC1
- * Date : 18-April-2012
- * @brief : stm32w108xx Devices vector table for Atollic TrueSTUDIO toolchain.
- * This module performs:
- * - Set the initial SP
- * - Set the initial PC == Reset_Handler,
- * - Set the vector table entries with the exceptions ISR address
- * - Configure the clock system
- * - Branches to main in the C library (which eventually
- * calls main()).
- * After Reset the cortex-m3 processor is in Thread mode,
- * priority is Privileged, and the Stack is set to Main.
- ******************************************************************************
- * @attention
- *
- *
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
- .syntax unified
- .cpu cortex-m3
- .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
-
-.equ BootRAM, 0xF108F85F
-/**
- * @brief This is the code that gets called when the processor first
- * starts execution following a reset event. Only the absolutely
- * necessary set is performed, after which the application
- * supplied main() routine is called.
- * @param None
- * @retval : None
-*/
-
- .section .text.Reset_Handler
- .weak Reset_Handler
- .type Reset_Handler, %function
-Reset_Handler:
-
-/* Copy the data segment initializers from flash to SRAM */
- movs r1, #0
- b LoopCopyDataInit
-
-CopyDataInit:
- ldr r3, =_sidata
- ldr r3, [r3, r1]
- str r3, [r0, r1]
- adds r1, r1, #4
-
-LoopCopyDataInit:
- ldr r0, =_sdata
- ldr r3, =_edata
- adds r2, r0, r1
- cmp r2, r3
- bcc CopyDataInit
- ldr r2, =_sbss
- b LoopFillZerobss
-/* Zero fill the bss segment. */
-FillZerobss:
- movs r3, #0
- str r3, [r2], #4
-
-LoopFillZerobss:
- ldr r3, = _ebss
- cmp r2, r3
- bcc FillZerobss
-/* Call the clock system intitialization function.*/
- bl SystemInit
-/* Call the application's entry point.*/
- bl main
- bx lr
-.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 M3. 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 TIM1_IRQHandler
- .word TIM2_IRQHandler
- .word MNG_IRQHandler
- .word BASEBAND_IRQHandler
- .word SLPTIM_IRQHandler
- .word SC1_IRQHandler
- .word SC2_IRQHandler
- .word SECURITY_IRQHandler
- .word MAC_TIM_IRQHandler
- .word MAC_TR_IRQHandler
- .word MAC_RE_IRQHandler
- .word ADC_IRQHandler
- .word EXTIA_IRQHandler
- .word EXTIB_IRQHandler
- .word EXTIC_IRQHandler
- .word EXTID_IRQHandler
- .word DEBUG_IRQHandler
- .word BootRAM /* @0x108. This is for boot in RAM mode for
- stm32w108xx devices. */
-
-/*******************************************************************************
-*
-* 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 TIM1_IRQHandler
- .thumb_set TIM1_IRQHandler,Default_Handler
-
- .weak TIM2_IRQHandler
- .thumb_set TIM2_IRQHandler,Default_Handler
-
- .weak MNG_IRQHandler
- .thumb_set MNG_IRQHandler,Default_Handler
-
- .weak BASEBAND_IRQHandler
- .thumb_set BASEBAND_IRQHandler,Default_Handler
-
- .weak SLPTIM_IRQHandler
- .thumb_set SLPTIM_IRQHandler,Default_Handler
-
- .weak SC1_IRQHandler
- .thumb_set SC1_IRQHandler,Default_Handler
-
- .weak SC2_IRQHandler
- .thumb_set SC2_IRQHandler,Default_Handler
-
- .weak SECURITY_IRQHandler
- .thumb_set SECURITY_IRQHandler,Default_Handler
-
- .weak MAC_TIM_IRQHandler
- .thumb_set MAC_TIM_IRQHandler,Default_Handler
-
- .weak MAC_TR_IRQHandler
- .thumb_set MAC_TR_IRQHandler,Default_Handler
-
- .weak MAC_RE_IRQHandler
- .thumb_set MAC_RE_IRQHandler,Default_Handler
-
- .weak ADC_IRQHandler
- .thumb_set ADC_IRQHandler,Default_Handler
-
- .weak EXTIA_IRQHandler
- .thumb_set EXTIA_IRQHandler,Default_Handler
-
- .weak EXTIB_IRQHandler
- .thumb_set EXTIB_IRQHandler,Default_Handler
-
- .weak EXTIC_IRQHandler
- .thumb_set EXTIC_IRQHandler,Default_Handler
-
- .weak EXTID_IRQHandler
- .thumb_set EXTID_IRQHandler,Default_Handler
-
- .weak DEBUG_IRQHandler
- .thumb_set DEBUG_IRQHandler,Default_Handler
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\ No newline at end of file
diff --git a/libs/CMSIS/Device/ST/STM32W108xx/Source/Templates/iar/startup_stm32w108xx.s b/libs/CMSIS/Device/ST/STM32W108xx/Source/Templates/iar/startup_stm32w108xx.s
deleted file mode 100644
index fe6e397..0000000
--- a/libs/CMSIS/Device/ST/STM32W108xx/Source/Templates/iar/startup_stm32w108xx.s
+++ /dev/null
@@ -1,261 +0,0 @@
-;/******************** (C) COPYRIGHT 2012 STMicroelectronics ********************
-;* File Name : startup_stm32w108xx.s
-;* Author : MCD Application Team
-;* Version : V1.0.1
-;* Date : 30-November-2012
-;* Description : STM32W108xx RF High Performance Devices vector table for *
-;* 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.
-;* After Reset the Cortex-M3 processor is in Thread mode,
-;* priority is Privileged, and the Stack is set to Main.
-;********************************************************************************
-;* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
-;* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
-;* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
-;* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
-;* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
-;* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
-;*******************************************************************************/
-;
-;
-; 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 TIM1_IRQHandler ; Timer 1 Interrupt
- DCD TIM2_IRQHandler ; Timer 2 Interrupt
- DCD MNG_IRQHandler ; Management Peripheral Interrupt
- DCD BASEBAND_IRQHandler ; Base Band Interrupt
- DCD SLPTIM_IRQHandler ; Sleep Timer Interrupt
- DCD SC1_IRQHandler ; Serial Controller 1 Interrupt
- DCD SC2_IRQHandler ; Serial Controller 2 Interrupt
- DCD SECURITY_IRQHandler ; Security Interrupt
- DCD MAC_TIM_IRQHandler ; MAC Timer Interrupt
- DCD MAC_TR_IRQHandler ; MAC Transmit Interrupt
- DCD MAC_RE_IRQHandler ; MAC Receive Interrupt
- DCD ADC_IRQHandler ; ADC Interrupt
- DCD EXTIA_IRQHandler ; EXTIA Interrupt
- DCD EXTIB_IRQHandler ; EXTIB Interrupt
- DCD EXTIC_IRQHandler ; EXTIC Interrupt
- DCD EXTID_IRQHandler ; EXTID Interrupt
- DCD DEBUG_IRQHandler ; Debug Interrupt
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;; Default interrupt handlers.
-;;
- THUMB
-
- PUBWEAK Reset_Handler
- SECTION .text:CODE:REORDER(2)
-Reset_Handler
- LDR R0, =SystemInit
- BLX R0
- LDR R0, =__iar_program_start
- BX R0
-
- PUBWEAK NMI_Handler
- SECTION .text:CODE:REORDER(1)
-NMI_Handler
- B NMI_Handler
-
-
- PUBWEAK HardFault_Handler
- SECTION .text:CODE:REORDER(1)
-HardFault_Handler
- B HardFault_Handler
-
-
- PUBWEAK MemManage_Handler
- SECTION .text:CODE:REORDER(1)
-MemManage_Handler
- B MemManage_Handler
-
-
- PUBWEAK BusFault_Handler
- SECTION .text:CODE:REORDER(1)
-BusFault_Handler
- B BusFault_Handler
-
-
- PUBWEAK UsageFault_Handler
- SECTION .text:CODE:REORDER(1)
-UsageFault_Handler
- B UsageFault_Handler
-
-
- PUBWEAK SVC_Handler
- SECTION .text:CODE:REORDER(1)
-SVC_Handler
- B SVC_Handler
-
-
- PUBWEAK DebugMon_Handler
- SECTION .text:CODE:REORDER(1)
-DebugMon_Handler
- B DebugMon_Handler
-
-
- PUBWEAK PendSV_Handler
- SECTION .text:CODE:REORDER(1)
-PendSV_Handler
- B PendSV_Handler
-
-
- PUBWEAK SysTick_Handler
- SECTION .text:CODE:REORDER(1)
-SysTick_Handler
- B SysTick_Handler
-
-
- PUBWEAK TIM1_IRQHandler
- SECTION .text:CODE:REORDER(1)
-TIM1_IRQHandler
- B TIM1_IRQHandler
-
-
- PUBWEAK TIM2_IRQHandler
- SECTION .text:CODE:REORDER(1)
-TIM2_IRQHandler
- B TIM2_IRQHandler
-
-
- PUBWEAK MNG_IRQHandler
- SECTION .text:CODE:REORDER(1)
-MNG_IRQHandler
- B MNG_IRQHandler
-
-
- PUBWEAK BASEBAND_IRQHandler
- SECTION .text:CODE:REORDER(1)
-BASEBAND_IRQHandler
- B BASEBAND_IRQHandler
-
-
- PUBWEAK SLPTIM_IRQHandler
- SECTION .text:CODE:REORDER(1)
-SLPTIM_IRQHandler
- B SLPTIM_IRQHandler
-
-
- PUBWEAK SC1_IRQHandler
- SECTION .text:CODE:REORDER(1)
-SC1_IRQHandler
- B SC1_IRQHandler
-
-
- PUBWEAK SC2_IRQHandler
- SECTION .text:CODE:REORDER(1)
-SC2_IRQHandler
- B SC2_IRQHandler
-
-
- PUBWEAK SECURITY_IRQHandler
- SECTION .text:CODE:REORDER(1)
-SECURITY_IRQHandler
- B SECURITY_IRQHandler
-
-
- PUBWEAK MAC_TIM_IRQHandler
- SECTION .text:CODE:REORDER(1)
-MAC_TIM_IRQHandler
- B MAC_TIM_IRQHandler
-
-
- PUBWEAK MAC_TR_IRQHandler
- SECTION .text:CODE:REORDER(1)
-MAC_TR_IRQHandler
- B MAC_TR_IRQHandler
-
-
- PUBWEAK MAC_RE_IRQHandler
- SECTION .text:CODE:REORDER(1)
-MAC_RE_IRQHandler
- B MAC_RE_IRQHandler
-
-
- PUBWEAK ADC_IRQHandler
- SECTION .text:CODE:REORDER(1)
-ADC_IRQHandler
- B ADC_IRQHandler
-
-
- PUBWEAK EXTIA_IRQHandler
- SECTION .text:CODE:REORDER(1)
-EXTIA_IRQHandler
- B EXTIA_IRQHandler
-
-
- PUBWEAK EXTIB_IRQHandler
- SECTION .text:CODE:REORDER(1)
-EXTIB_IRQHandler
- B EXTIB_IRQHandler
-
-
- PUBWEAK EXTIC_IRQHandler
- SECTION .text:CODE:REORDER(1)
-EXTIC_IRQHandler
- B EXTIC_IRQHandler
-
-
- PUBWEAK EXTID_IRQHandler
- SECTION .text:CODE:REORDER(1)
-EXTID_IRQHandler
- B EXTID_IRQHandler
-
-
- PUBWEAK DEBUG_IRQHandler
- SECTION .text:CODE:REORDER(1)
-DEBUG_IRQHandler
- B DEBUG_IRQHandler
-
- END
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/libs/CMSIS/Device/ST/STM32W108xx/Source/Templates/system_stm32w108xx.c b/libs/CMSIS/Device/ST/STM32W108xx/Source/Templates/system_stm32w108xx.c
deleted file mode 100644
index db84132..0000000
--- a/libs/CMSIS/Device/ST/STM32W108xx/Source/Templates/system_stm32w108xx.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/**
- ******************************************************************************
- * @file system_stm32w108xx.c
- * @author MCD Application Team
- * @version V1.0.1
- * @date 30-November-2012
- * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File.
- *
- * 1. This file provides two functions and one global variable to be called from
- * user application:
- * - SystemInit(): Setups the system clock (System clock source).
- * This function is called at startup just after reset and
- * before branch to main program. This call is made inside
- * the "startup_stm32w108xx.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.
- *
- * 2. After each device reset the HSI (12 MHz) is used as system clock source.
- * Then SystemInit() function is called, in "startup_stm32w108xx.s" file, to
- * configure the system clock before to branch to main program.
- *
- * 3. If the system clock source selected by user fails to startup, the SystemInit()
- * function will do nothing and HSI still used as system clock source. User can
- * add some code to deal with this issue inside the SetSysClock() function.
- *
- * 4. The default value of HSE crystal is set to 24MHz, refer to "HSE_VALUE" define
- * in "stm32w108xx.h" file. When HSE is used as system clock source, directly or
- * through PLL, and you are using different crystal you have to adapt the HSE
- * value to your own configuration.
- *
- * 5. This file configures the system clock as follows:
- *=============================================================================
- * System Clock Configuration
- *=============================================================================
- * System Clock source | HSE
- *-----------------------------------------------------------------------------
- * SYSCLK | 24000000 Hz
- *-----------------------------------------------------------------------------
- * HCLK | 24000000 Hz
- *-----------------------------------------------------------------------------
- * FCLK | 12000000 Hz
- *-----------------------------------------------------------------------------
- * PCLK = SYSCLK/2 | 12000000 Hz
- *-----------------------------------------------------------------------------
- * HSE Frequency | 24000000 Hz
- *-----------------------------------------------------------------------------
- * VDD | 3.3 V
- *-----------------------------------------------------------------------------
- * Flash Latency | 1 WS
- *-----------------------------------------------------------------------------
- *=============================================================================
- ******************************************************************************
- * @attention
- *
- *
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
-/** @addtogroup CMSIS
- * @{
- */
-
-/** @addtogroup stm32w108xx_system
- * @{
- */
-
-/** @addtogroup STM32W108xx_System_Private_Includes
- * @{
- */
-
-#include "stm32w108xx.h"
-
-/**
- * @}
- */
-
-/** @addtogroup STM32W108xx_System_Private_TypesDefinitions
- * @{
- */
-
-/**
- * @}
- */
-
-/** @addtogroup STM32W108xx_System_Private_Defines
- * @{
- */
-/**
- * @}
- */
-
-/** @addtogroup STM32W108xx_System_Private_Macros
- * @{
- */
-
-/**
- * @}
- */
-
-/** @addtogroup STM32W108xx_System_Private_Variables
- * @{
- */
-uint32_t SystemCoreClock = 24000000;
-/**
- * @}
- */
-
-/** @addtogroup STM32W108xx_System_Private_FunctionPrototypes
- * @{
- */
-
-static void SetSysClock(void);
-
-/**
- * @}
- */
-
-/** @addtogroup STM32W108xx_System_Private_Functions
- * @{
- */
-
-/**
- * @brief Setup the microcontroller system.
- * Initialize the Embedded Flash Interface, the PLL and update the
- * SystemCoreClock variable.
- * @param None
- * @retval None
- */
-void SystemInit (void)
-{
- /* reset the CLK_HSECR2 register */
- CLK->HSECR2 &= (uint32_t)0x00000000;
-
- /* reset the CLK_CPUCR register */
- CLK->CPUCR &= (uint32_t)0x00000000;
-
- /* Configure the System clock frequency */
- SetSysClock();
-}
-
-/**
- * @brief Update SystemCoreClock according to Clock Register Values
- * @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 HSI, SystemCoreClock will contain the HSI_VALUE(*)
- *
- * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
- *
- * (*) HSI_VALUE is a constant defined in stm32w108xx.h file (default value
- * 12 MHz) but the real value may vary depending on the variations
- * in voltage and temperature.
- *
- * (**) HSE_VALUE is a constant defined in stm32w108xx.h file (default value
- * 24 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 = 0;
-
- /* Get SYSCLK source -------------------------------------------------------*/
- tmp = (CLK->HSECR2) & (uint32_t)0x0000003;
-
- if (tmp == 0x0000003) /* HSE used as system clock */
- {
- SystemCoreClock = HSE_VALUE;
- }
- else /* HSI used as system clock */
- {
- SystemCoreClock = HSI_VALUE;
- }
-}
-
-/**
- * @brief Configures the System clock frequency,
- * @note This function should be called only once the CLOCK configuration
- * is reset to the default reset state (done in SystemInit() function).
- * @param None
- * @retval None
- */
-static void SetSysClock(void)
-{
- __IO uint32_t StartUpCounter = 0;
-
- /* Enable HSE */
- CLK->HSECR2 |= CLK_HSECR2_EN;
-
- /* Wait till HSE is ready and if Time out is reached exit */
- do
- {
- StartUpCounter++;
- } while(StartUpCounter != HSE_STARTUP_TIMEOUT);
-
- /* Select HSE system clock */
- CLK->HSECR2 |= CLK_HSECR2_SW1;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/libs/STM32W108xx_StdPeriph_Driver/Release_Notes.html b/libs/STM32W108xx_StdPeriph_Driver/Release_Notes.html
deleted file mode 100644
index f77bb75..0000000
--- a/libs/STM32W108xx_StdPeriph_Driver/Release_Notes.html
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
-
-
-
-Release Notes for STM32W108xx Standard Peripherals Library Drivers
-
-
-
-
-
-
-
- First official release for STM32W108xx devices running on MBxxx boards
Development Toolchains
IAR Embedded Workbench for ARM (EWARM) toolchain V6.40
-
License
Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this package except in compliance with the License. You may obtain a copy of the License at:
Unless
-required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
-the License for the specific language governing permissions and
-limitations under the License.
-
-
For
-complete documentation on STM32(CORTEX M3) 32-Bit Microcontrollers
-visit www.st.com/STM32
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/libs/STM32W108xx_StdPeriph_Driver/inc/stm32w108xx_adc.h b/libs/STM32W108xx_StdPeriph_Driver/inc/stm32w108xx_adc.h
deleted file mode 100644
index 9e122fe..0000000
--- a/libs/STM32W108xx_StdPeriph_Driver/inc/stm32w108xx_adc.h
+++ /dev/null
@@ -1,366 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32w108xx_adc.h
- * @author MCD Application Team
- * @version V1.0.1
- * @date 30-November-2012
- * @brief This file contains all the functions prototypes for the ADC firmware
- * library.
- ******************************************************************************
- * @attention
- *
- *
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32w108xx_clk.h"
-
-/** @addtogroup STM32W108xx_StdPeriph_Driver
- * @{
- */
-
-/** @defgroup CLK
- * @brief CLK driver modules
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private defines -----------------------------------------------------------*/
-#define SLOWRC_PERIOD_SETTLE_TIME 4250
-#define SLOWRC_PERIOD_SAMPLES 8
-#define CLK1K_NUMERATOR 384000000
-
-#define FASTRC_PERIOD_SETTLE_TIME 128
-
-/* CLK_HSECR2 register Mask */
-#define CLK_HSECR2_Mask ((uint32_t)0x00000003)
-
-/* Private macros ------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/** @defgroup CLK_Private_Functions
- * @{
- */
-
-/** @defgroup CLK_Group1 Internal and external clocks
- * @brief Internal and external clocks configuration functions
- *
-@verbatim
- ===============================================================================
- ##### Internal-external clocks configuration functions #####
- ===============================================================================
- [..] This section provides functions allowing to configure the internal/external clocks,
-
- (#) HSI (high-frequency RC oscillator (OSCHF)), is used as the default system clock
- source when power is applied to the core domain. The nominal frequency coming
- out of reset is 12 MHz.
- (#) HSE (high-frequency crystal oscillator), 24 MHz crystal oscillator
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Resets the CLOCK configuration to the default reset state.
- * @note The default reset state of the clock configuration is given below:
- * HSI ON and used as system clock source
- * @param None
- * @retval None
- */
-void CLK_DeInit(void)
-{
- CLK->SLEEPCR = 0x00000002;
- CLK->LSI10KCR = 0x00000000;
- CLK->LSI1KCR = 0x00005000;
- CLK->HSECR1 = 0x0000000F;
- CLK->HSICR = 0x00000017;
- CLK->PERIODCR = 0x00000000;
- CLK->DITHERCR = 0x00000000;
- CLK->HSECR2 = 0x00000000;
- CLK->CPUCR = 0x00000000;
-}
-
-/**
- * @brief Calibrate the low speed internal clock (LSI) to be close to 10KHZ in
- * order to generate 1KHZ clock.
- * @param None
- * @retval None
- */
-void CLK_InternalCalibrateLSI(void)
-{
- uint8_t i = 0;
- uint32_t average = 0;
- int16_t delta = 0;
- uint32_t period = 0;
- __IO uint32_t StartUpCounter = 0;
- __IO uint32_t LSI10KCR_RESET = 0x0, LSI1KCR_RESET = 0x5000;
-
- /* The slowest frequency for the 10kHz RC source is 8kHz (125us). The PERIODSR
- register updates every 16 cycles, so to be safe 17 cycles = 2125us. But,
- we need twice this maximum time because the period measurement runs
- asynchronously, and the value of LSI10KCR is changed immediately before
- the delay.
- SLOWRC_PERIOD_SETTLE_TIME 4250
- The CLK_PERIOD register measures the number of 12MHz clock cycles that
- occur in 16 cycles of the SlowRC clock. This is meant to smooth out the the
- noise inherently present in the analog RC source. While these 16 cycles
- smooths out most noise, there is still some jitter in the bottom bits of
- PERIODSR. To further smooth out the noise, we take several readings of
- PERIODSR and average them out. Testing has shown that the bottom 3 and 4
- bits of PERIODSR contain most of the jitter. Averaging 8 samples will
- smooth out 3 bits of jitter and provide a realiable and stable reading useful
- in the calculations, while taking much less time than 16 or 32 samples.
- SLOWRC_PERIOD_SAMPLES 8
- The register LSI1KCR is a fractional divider that divides the 10kHz analog
- source with the goal of generating a 1024Hz, clk1k output.
- 10000Hz / LSI1KCR = 1024Hz.
- Since the PERIODSR register measures the number of 12MHz cycles in 16
- cycles of the RC:
- 16 * 12000000
- ------------- = ~10kHz
- PERIODSR
- and
- ~10kHz / 1024 = X
- where X is the fractional number that belongs in LSI1KCR. Since the
- integer portion of LSI1KCR is bits 15:11 and the fractional is 10:0,
- multiplying X by 2048 (bit shift left by 11) generates the proper LSI1KCR
- register value.
-
- Putting this all together:
- 16 * 12000000 * 2048 384000000
- -------------------- = ------------ = LSI1KCR
- PERIODSR * 1024 PERIODSR
-
- CLK1K_NUMERATOR 384000000 */
-
- /* ---- STEP 1: coarsely tune SlowRC in analog section to ~10kHz ---- */
- /* To operate properly across the full temperature and voltage range,
- the RC source in the analog section needs to be first coarsely tuned
- to 10kHz. The LSI10KCR register, which is 2's compliment, provides 16
- steps at ~400Hz per step yielding approximate frequences of 8kHz at 7
- and 15kHz at -8. */
- /* Start with our reset values for TUNE and CAL */
- CLK->PERIODCR = 0; /* measure SlowRC */
- CLK->LSI10KCR = LSI10KCR_RESET;
- CLK->LSI1KCR = LSI1KCR_RESET;
-
- /* wait for the PERIODSR register to properly update */
- do
- {
- StartUpCounter++;
- } while(StartUpCounter != SLOWRC_PERIOD_SETTLE_TIME);
-
- /* Measure the current PERIODSR to obtain a baseline
- For 10kHz, the ideal PERIODSR value is 19200. Calculate the PERIOD delta.
- It's possible for a chip's 10kHz source RC to be too far out of range
- for the LSI10KCR to bring it back to 10kHz. Therefore, we have to
- ensure that our delta correction does not exceed the tune range so
- tune has to be capped to the end of the vailable range so it does not
- wrap. Even if we cannot achieve 10kHz, the 1kHz calibration can still
- properly correct to 1kHz.
- Each LSI10KCR step yields a PERIODSR delta of *approximately* 800.
- Calculate how many steps we are off. While dividing by 800 may seem
- like an ugly calculation, the precision of the result is worth the small
- bit of code and time needed to do a divide. */
- period = CLK->PERIODSR;
-
- /* Round to the nearest integer */
- delta = (19200+400) - period;
- delta /= 800;
-
- /* LSI10KCR is a 4 bit signed number. cap the delta to 7/-8 */
- if(delta > 7) {
- delta = 7;
- }
- if(delta < -8) {
- delta = -8;
- }
- CLK->LSI10KCR = delta;
-
- /* Wait for PERIOD to update before taking another sample */
- StartUpCounter = 0;
- do
- {
- StartUpCounter++;
- } while(StartUpCounter != SLOWRC_PERIOD_SETTLE_TIME);
-
- /* The analog section should now be producing an output of ~10kHz */
-
- /* ---- STEP 2: fine tune the SlowRC to 1024Hz ---- */
- /* Our goal is to generate a 1024Hz source. The register LSI1KCR is a
- fractional divider that divides the 10kHz analog source and generates
- the clk1k output. At reset, the default value is 0x5000 which yields a
- division of 10.000. By averaging several samples of CLK_PERIOD, we
- can then calculate the proper divisor need for LSI1KCR to make 1024Hz. */
- for(i=0;iPERIODSR;
- }
-
- /* Calculate the average, with proper rounding */
- average = (average+(SLOWRC_PERIOD_SAMPLES/2))/SLOWRC_PERIOD_SAMPLES;
-
- /* Using an average period sample, calculate the clk1k divisor */
- CLK->LSI1KCR = (uint16_t)(CLK1K_NUMERATOR/average);
-
- /* The SlowRC timer is now producing a 1024Hz tick (+/-2Hz). */
-}
-
-/**
- * @brief Calibrate the high speed internal clock (HSI) to be close to 12MHZ.
- * @note To calibrate the HSI, the high speed external clock (HSE) must be the
- * system clock.
- * @param None
- * @retval None
- */
-void CLK_InternalCalibrateHSI(void)
-{
- __IO uint32_t StartUpCounter = 0, CLK_PERIOD = 0;
- __IO int32_t newTune = -16;
- /* ---- coarsely tune FastRC in analog section to ~12MHz ---- */
- /* The slowest frequency for the FastRC source is 4MHz (250ns). The PERIODSR
- register updates every 256 cycles, so to be safe 257 cycles = 64us. But,
- we need twice this maximum time because the period measurement runs
- asynchronously, and the value of HSICR1 is changed immediately before
- the delay.
- The CLK_PERIODSR register measures the number of 12MHz cycles in 256
- cycles of OSCHF:
-
- 256 * 12000000
- ------------- = ~12MHz
- CLK_PERIOD
-
- The RC source in the analog section needs to be coarsely tuned
- to 12MHz. The HSICR1 register, which is 2's compliment, provides 32
- steps at ~0.5MHz per step yielding approximate frequences of 4MHz at 15
- and 20MHz at -16. */
-
- CLK->PERIODCR = 1; /* Measure FastRC */
-
- /* Start at the fastest possible frequency */
- CLK->HSICR = newTune;
-
- /* Wait for the PERIOD register to properly update */
- do
- {
- StartUpCounter++;
- } while(StartUpCounter != FASTRC_PERIOD_SETTLE_TIME);
-
- /* For 12MHz, the ideal CLK_PERIOD is 256. Tune the frequency down until
- the period is <= 256, which says the frequency is as close to 12MHz as
- possible (without going over 12MHz)
- Start at the fastest possible frequency (-16) and increase to the slowest
- possible (15). When CLK_PERIOD is <=256 or we run out of tune values,
- we're done. */
- for(;newTune<16;newTune++)
- {
- StartUpCounter = 0;
- /* Decrease frequency by one step (by increasing tune value) */
- CLK->HSICR = newTune;
-
- /* Wait for the PERIOD register to properly update */
- do
- {
- StartUpCounter++;
- } while(StartUpCounter != FASTRC_PERIOD_SETTLE_TIME);
-
- /* Kickout if we're tuned */
- CLK_PERIOD = CLK->PERIODSR;
- if(CLK_PERIOD >= 256) {
- break;
- }
- }
- /* The analog section should now be producing an output of 11.5MHz - 12.0MHz */
-}
-
-/**
- * @brief Configures the clock mode to use:
- * @param MODE: specifies the frequency mode to use.
- * This parameter can be one of the following values:
- * @arg MODE0: Normal CPU, SCLK =12MHZ, PCLK=6MHZ, Flash Program/Erase Inactive =6Mhz,
- * FlashProgram/Erase Active = 12Mhz.
- * @arg MODE1: Fast CPU, SCLK =12MHZ, PCLK=6MHZ, Flash Program/Erase Inactive =12Mhz,
- * FlashProgram/Erase Active = 12Mhz.
- * @arg MODE2: Normal CPU, SCLK =24MHZ, PCLK=12MHZ, Flash Program/Erase Inactive =12Mhz,
- * FlashProgram/Erase Active = 12Mhz.
- * @arg MODE3: Fast CPU, SCLK =24MHZ, PCLK=12MHZ, Flash Program/Erase Inactive =24Mhz,
- * FlashProgram/Erase Active = 12Mhz.
- * @retval None
- */
-void CLK_Config(uint8_t MODE)
-{
- __IO uint32_t StartUpCounter = 0;
-
- /* Check the parameters */
- assert_param(IS_CLK_MODE(MODE));
-
- switch (MODE)
- {
- case CLK_MODE0: /* HSI used as system clock : Normal CPU*/
- CLK->HSECR2 &= ~CLK_HSECR2_SW1;
- CLK->CPUCR &= ~CLK_CPUCR_SW2;
- break;
-
- case CLK_MODE1: /* HSI used as system clock : Fast CPU */
- CLK->HSECR2 &= ~CLK_HSECR2_SW1;
- CLK->CPUCR |= CLK_CPUCR_SW2;
- break;
-
- case CLK_MODE2: /* HSE used as system clock : Normal CPU*/
- /* Enable HSE */
- CLK->HSECR2 |= CLK_HSECR2_EN;
-
- /* Wait till HSE is ready and if Time out is reached exit */
- do
- {
- StartUpCounter++;
- } while(StartUpCounter != HSE_STARTUP_TIMEOUT);
-
- CLK->HSECR2 |= CLK_HSECR2_SW1;
- CLK->CPUCR &= ~CLK_CPUCR_SW2;
- break;
-
- case CLK_MODE3: /* HSE used as system clock : Fast CPU*/
- /* Enable HSE */
- CLK->HSECR2 |= CLK_HSECR2_EN;
-
- /* Wait till HSE is ready and if Time out is reached exit */
- do
- {
- StartUpCounter++;
- } while(StartUpCounter != HSE_STARTUP_TIMEOUT);
-
- CLK->HSECR2 |= CLK_HSECR2_SW1;
- CLK->CPUCR |= CLK_CPUCR_SW2;
- break;
- default: /* HSI used as system clock */
- CLK->HSECR2 &= ~CLK_HSECR2_SW1;
- CLK->CPUCR &= ~CLK_CPUCR_SW2;
- break;
- }
-}
-
-/**
- * @brief Enables or disables the External High Speed oscillator (HSE).
- * @note After enabling HSE the user should wait for HSE_STARTUP_TIMEOUT
- * @note to be sure that the clok is stabilized.
- * @param NewState: new state of the HSE.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void CLK_HSECmd(FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- CLK->HSECR2 |= CLK_HSECR2_EN;
- }
- else
- {
- CLK->HSECR2 = 0x00;
- }
-}
-
-/**
- * @brief Enables or disables the specified SLPTIM clock.
- * @param CLK_SLPTIM: specifies the SLPTIM clock to be enabled or disabled.
- * This parameter can be any combination of the following values:
- * @arg SLPTIM_CLK_32KH: 32kHz external XTAL
- * @arg SLPTIM_CLK_10KH: 10kHz internal RC (during deep sleep)
- * @param NewState: new state of the SLPTIM clock.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void CLK_SLPTIMClockConfig(uint32_t CLK_SLPTIM, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_SLPTIM_GET_CLK(CLK_SLPTIM));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- if (CLK_SLPTIM == SLPTIM_CLK_32KH)
- {
- CLK->SLEEPCR &= 0x0;
- }
- /* Enable the clock */
- CLK->SLEEPCR |= (uint32_t)CLK_SLPTIM;
- }
- else
- {
- /* Disable the clock */
- CLK->SLEEPCR &= (uint32_t)~CLK_SLPTIM;
- }
-}
-
-/**
- * @brief Calibration of CLK1K clock.
- * @param CALINT: specifies the divider value integer portion.
- * This parameter can be a value between 0x0 and 0x1F.
- * @param CALFRAC: specifies the divider value fractional portion.
- * This parameter can be a value between 0x0 and 0x7FF.
- * @retval None.
- */
-void CLK_1KClockCalibration(uint32_t CALINT, uint32_t CALFRAC)
-{
- uint32_t tmpclk1k;
- /* Check the parameters */
- assert_param(IS_LSI1KCRINT(CALINT));
- assert_param(IS_LSI1KCRFRAC(CALFRAC));
-
- CLK->LSI1KCR = 0x00000000;
-
- /* set the divider value integer portion */
- tmpclk1k = (uint32_t)(CALINT <<11);
-
- /* set the divider value fractional portion */
- tmpclk1k |= CALFRAC;
-
- CLK->LSI1KCR = tmpclk1k;
-}
-
-/**
- * @brief Set tune value for CLKRC clock.
- * @param TUNE_VALUE: specifies the tune value for CLKRC clock.
- * This parameter can be a value between 0x0 and 0xF.
- * @retval None.
- */
-void CLK_RCTuneConfig(uint32_t TUNE_VALUE)
-{
- /* Check the parameters */
- assert_param(IS_CLK_TUNE_VALUE(TUNE_VALUE));
-
- CLK->LSI10KCR = 0x00000000;
-
- /* set the tune value for CLKRC */
- CLK->LSI10KCR = TUNE_VALUE;
-}
-
-/**
- * @brief Select the clock period to be measured.
- * @param CLK_MEASURED: specifies the clock for which the period will be measured.
- * This parameter can be :
- * @arg MEASURE_CLKRC: Measure CLKRC.
- * @arg MEASURE_OSCHF: Measure OSCHF.
- * @arg MEASURE_TUNEFILT: Measure TUNE_FILTER_RESULT.
- * @retval None.
- */
-void CLK_MeasurePeriod(uint32_t CLK_MEASURED)
-{
- /* Check the parameters */
- assert_param(IS_CLK_MEASURE(CLK_MEASURED));
-
- CLK->PERIODCR = CLK_MEASURED;
-}
-
-/**
- * @brief Returns the clock period measured depend on clock selected.
- *@note measured period is equal to:
- * 16 x Clock period in clk12m cycles (CLKRC/TUNE_FILTER_RESULT modes)
- * 256 x clock period in clk12m cycles (OSCHF mode)
- * @param None.
- * @retval None.
- */
-uint32_t CLK_GetMeasurePeriod(void)
-{
- return CLK->PERIODSR;
-}
-
-/**
- * @brief Returns the clock source used as system clock.
- * @param None
- * @retval The clock source used as system clock. The returned value can
- * be one of the following:
- * - 0x00,0x01,0x10: HSI used as system clock
- * - 0x03: HSE used as system clock
- */
-uint32_t CLK_GetClocksFreq(void)
-{
- uint32_t tmp = 0;
- uint32_t clockvalue = 0;
- /* Get SYSCLK source -------------------------------------------------------*/
- tmp = CLK->HSECR2 & CLK_HSECR2_Mask;
-
- switch (tmp)
- {
- case 0x00:
- case 0x02: /* HSI used as system clock */
- clockvalue = (uint32_t)HSI_VALUE;
- break;
- case 0x03: /* HSE used as system clock */
- clockvalue = (uint32_t)HSE_VALUE;
- break;
-
- default: /* HSI used as system clock */
- clockvalue = (uint32_t)HSI_VALUE;
- break;
- }
- return clockvalue;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_exti.c b/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_exti.c
deleted file mode 100644
index e080135..0000000
--- a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_exti.c
+++ /dev/null
@@ -1,238 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32w108xx_exti.c
- * @author MCD Application Team
- * @version V1.0.1
- * @date 30-November-2012
- * @brief This file provides firmware functions to manage the following
- * functionalities of the EXTI peripheral:
- * + Initialization and Configuration
- * + Interrupts and flags management
- *
- * @verbatim
- *
- ==============================================================================
- ##### EXTI features #####
- ==============================================================================
- [..] External interrupt/event lines are mapped as following:
- (#) All available GPIO pins are connected to the 4 external
- interrupt/event lines from EXTIA to EXTID.
- (#) EXTIA and EXTIB have fixed pins assignement (PB0 and PB6).
- (#) EXTIC and EXTID can use any GPIO pin.
-
- ##### How to use this driver #####
- ==============================================================================
- [..] In order to use an I/O pin as an external interrupt source, follow
- steps below:
- (#) Configure the I/O in input mode using GPIO_Init()
- (#) Select the mode(interrupt, event) and configure the trigger selection
- using EXTI_Init().
- (#) Configure NVIC IRQ channel mapped to the EXTI line using NVIC_Init().
-
- @endverbatim
- *
- ******************************************************************************
- * @attention
- *
- *
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32w108xx_gpio.h"
-
-/** @addtogroup STM32W108xx_StdPeriph_Driver
- * @{
- */
-
-/** @defgroup GPIO
- * @brief GPIO driver modules
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-
-/** @defgroup GPIO_Private_Functions
- * @{
- */
-
-/** @defgroup GPIO_Group1 Initialization and Configuration
- * @brief Initialization and Configuration
- *
-@verbatim
- ===============================================================================
- Initialization and Configuration
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Deinitializes the GPIOx peripheral registers to their default reset values.
- * @param GPIOx: where x can be (A..C) to select the GPIO peripheral.
- * @retval None
- */
-void GPIO_DeInit(GPIO_TypeDef* GPIOx)
-{
- /* Check the parameters */
- assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
-
- GPIOx->CRL = 0x00004444;
- GPIOx->CRH = 0x00004444;
- GPIOx->IDR = 0x00000000;
- GPIOx->ODR = 0x00000000;
- GPIOx->BSR = 0x00000000;
- GPIOx->BRR = 0x00000000;
-
- GPIO_DBG->PCTRACECR = 0x00000000;
- GPIO_DBG->DBGCR = 0x00000010;
-}
-
-/**
- * @brief Initializes the GPIOx peripheral according to the specified
- * parameters in the GPIO_InitStruct.
- * @param GPIOx: where x can be (A, B or C) to select the GPIO peripheral.
- * @param GPIO_InitStruct: pointer to a GPIO_InitTypeDef structure that
- * contains the configuration information for the specified GPIO
- * peripheral.
- * GPIO_Pin: selects the pin to be configured: GPIO_Pin_0 -> GPIO_Pin_7
- * GPIO_Mode: selects the mode of the pin:
- * - GPIO Analog Mode: GPIO_Mode_AN
- * - GPIO Output Mode PP: GPIO_Mode_OUT_PP
- * - GPIO Input Mode NOPULL: GPIO_Mode_IN
- * - GPIO Output Mode OD: GPIO_Mode_OUT_OD
- * - GPIO Input Mode PuPd: GPIO_Mode_IN_PUD
- * - GPIO Alternate function Mode PP: GPIO_Mode_AF_PP
- * - GPIO Alternate function Mode SPI SCLK PP: GPIO_Mode_AF_PP_SPI
- * - GPIO Alternate function Mode OD: GPIO_Mode_AF_OD
- * @retval None
- */
-void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
-{
- uint32_t currentmode = 0x00, currentpin = 0x00, pinpos = 0x00, pos = 0x00;
- uint32_t tmpreg = 0x00, pinmask = 0x00;
- /* Check the parameters */
- assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
- assert_param(IS_GPIO_MODE(GPIO_InitStruct->GPIO_Mode));
- assert_param(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin));
-
- /*---------------------------- GPIO Mode Configuration -----------------------*/
- currentmode = ((uint32_t)GPIO_InitStruct->GPIO_Mode) & ((uint32_t)0x0F);
-
- /*---------------------------- GPIO CRL Configuration ------------------------*/
- /* Configure the four low port pins */
- if (((uint32_t)GPIO_InitStruct->GPIO_Pin & ((uint32_t)0x0F)) != 0x00)
- {
- tmpreg = GPIOx->CRL;
- for (pinpos = 0x00; pinpos < 0x04; pinpos++)
- {
- pos = ((uint32_t)0x01) << pinpos;
- /* Get the port pins position */
- currentpin = (GPIO_InitStruct->GPIO_Pin) & pos;
- if (currentpin == pos)
- {
- pos = pinpos << 2;
- /* Clear the corresponding low control register bits */
- pinmask = ((uint32_t)0x0F) << pos;
- tmpreg &= ~pinmask;
- /* Write the mode configuration in the corresponding bits */
- tmpreg |= (currentmode << pos);
- }
- }
- GPIOx->CRL = tmpreg;
- }
- /*---------------------------- GPIO CRH Configuration ------------------------*/
- /* Configure the four high port pins */
- if (GPIO_InitStruct->GPIO_Pin > 0x0F)
- {
- tmpreg = GPIOx->CRH;
- for (pinpos = 0x00; pinpos < 0x04; pinpos++)
- {
- pos = (((uint32_t)0x01) << (pinpos + 0x04));
- /* Get the port pins position */
- currentpin = ((GPIO_InitStruct->GPIO_Pin) & pos);
- if (currentpin == pos)
- {
- pos = pinpos << 2;
- /* Clear the corresponding high control register bits */
- pinmask = ((uint32_t)0x0F) << pos;
- tmpreg &= ~pinmask;
- /* Write the mode configuration in the corresponding bits */
- tmpreg |= (currentmode << pos);
- }
- }
- GPIOx->CRH = tmpreg;
- }
-}
-
-/**
- * @brief Fills each GPIO_InitStruct member with its default value.
- * @param GPIO_InitStruct : pointer to a GPIO_InitTypeDef structure which will
- * be initialized.
- * @retval None
- */
-void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct)
-{
- /* Reset GPIO init structure parameters values */
- GPIO_InitStruct->GPIO_Pin = GPIO_Pin_All;
- GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN;
-}
-
-/**
- * @}
- */
-
-/** @defgroup GPIO_Group2 GPIO Read and Write
- * @brief GPIO Read and Write
- *
-@verbatim
- ===============================================================================
- GPIO Read and Write
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Reads the specified input port pin.
- * @param GPIOx: where x can be (A, B or C) to select the GPIO peripheral.
- * @param GPIO_Pin: specifies the port bit to read.
- * This parameter can be GPIO_Pin_x where x can be (0..7).
- * @retval The input port pin value.
- */
-uint32_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint32_t GPIO_Pin)
-{
- uint32_t bitstatus = 0x00;
- /* Check the parameters */
- assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
- assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
-
- if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)Bit_RESET)
- {
- bitstatus = (uint32_t)Bit_SET;
- }
- else
- {
- bitstatus = (uint32_t)Bit_RESET;
- }
- return bitstatus;
-}
-
-/**
- * @brief Reads the specified GPIO input data port.
- * @param GPIOx: where x can be (A..C) to select the GPIO peripheral.
- * @retval GPIO input data port value.
- */
-uint32_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx)
-{
- /* Check the parameters */
- assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
-
- return ((uint32_t)GPIOx->IDR);
-}
-
-/**
- * @brief Reads the specified output data port bit.
- * @param GPIOx: where x can be (A, B or C) to select the GPIO peripheral.
- * @param GPIO_Pin: Specifies the port bit to read.
- * This parameter can be GPIO_Pin_x where x can be (0..7).
- * @retval The output port pin value.
- */
-uint32_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint32_t GPIO_Pin)
-{
- uint32_t bitstatus = 0x00;
-
- /* Check the parameters */
- assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
- assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
-
- if ((GPIOx->ODR & GPIO_Pin) != (uint32_t)Bit_RESET)
- {
- bitstatus = (uint32_t)Bit_SET;
- }
- else
- {
- bitstatus = (uint32_t)Bit_RESET;
- }
- return bitstatus;
-}
-
-/**
- * @brief Reads the specified GPIO output data port.
- * @param GPIOx: where x can be (A, B or C) to select the GPIO peripheral.
- * @retval GPIO output data port value.
- */
-uint32_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx)
-{
- /* Check the parameters */
- assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
-
- return ((uint32_t)GPIOx->ODR);
-}
-
-/**
- * @brief Sets the selected data port bits.
- * @param GPIOx: where x can be (A, B or C) to select the GPIO peripheral.
- * @param GPIO_Pin: specifies the port bits to be written.
- * This parameter can be any combination of GPIO_Pin_x where x can be (0..7).
- * @note This functions uses GPIOx_SET register to allow atomic read/modify
- * accesses. In this way, there is no risk of an IRQ occurring between
- * the read and the modify access.
- * @retval None
- */
-void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint32_t GPIO_Pin)
-{
- /* Check the parameters */
- assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
- assert_param(IS_GPIO_PIN(GPIO_Pin));
-
- GPIOx->BSR = GPIO_Pin;
-}
-
-/**
- * @brief Clears the selected data port bits.
- * @param GPIOx: where x can be (A, B or C) to select the GPIO peripheral.
- * @param GPIO_Pin: specifies the port bits to be written.
- * This parameter can be any combination of GPIO_Pin_x where x can be (0..7).
- * @note This functions uses GPIOx_CLR register to allow atomic read/modify
- * accesses. In this way, there is no risk of an IRQ occurring between
- * the read and the modify access.
- * @retval None
- */
-void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint32_t GPIO_Pin)
-{
- /* Check the parameters */
- assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
- assert_param(IS_GPIO_PIN(GPIO_Pin));
-
- GPIOx->BRR = GPIO_Pin;
-}
-
-/**
- * @brief Sets or clears the selected data port bit.
- * @param GPIOx: where x can be (A, B or C) to select the GPIO peripheral.
- * @param GPIO_Pin: specifies the port bit to be written.
- * This parameter can be one of GPIO_Pin_x where x can be (0..7).
- * @param BitVal: specifies the value to be written to the selected bit.
- * This parameter can be one of the BitAction enum values:
- * @arg Bit_RESET: to clear the port pin
- * @arg Bit_SET: to set the port pin
- * @retval None
- */
-void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint32_t GPIO_Pin, BitAction BitVal)
-{
- /* Check the parameters */
- assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
- assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
- assert_param(IS_GPIO_BIT_ACTION(BitVal));
-
- if (BitVal != Bit_RESET)
- {
- GPIOx->BSR = GPIO_Pin;
- }
- else
- {
- GPIOx->BRR = GPIO_Pin ;
- }
-}
-
-/**
- * @brief Writes data to the specified GPIO data port.
- * @param GPIOx: where x can be (A, B or C) to select the GPIO peripheral.
- * @param PortVal: specifies the value to be written to the port output data
- * register.
- * @retval None
- */
-void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal)
-{
- /* Check the parameters */
- assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
-
- GPIOx->ODR = PortVal;
-}
-/**
- * @}
- */
-
-/** @defgroup GPIO_Group3 GPIO Wake and Debug Configuration
- * @brief GPIO Wake and Debug Configuration
- *
-@verbatim
- ===============================================================================
- Debug Configuration
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Selects PC_TRACE source on bb_debug GPIO pins.
- * @param PCTRACE_SEL: specifies the PC_TRACE source on bb_debug GPIO pins.
- * This parameter can be :
- * @arg GPIO_BBDEBUG: bb debug.
- * @arg GPIO_PCTRACE: pc trace.
- * @retval None.
- */
-void GPIO_PCTraceConfig(uint32_t PCTRACE_SEL)
-{
- /* Check the parameters */
- assert_param(IS_GPIO_PCTRACE(PCTRACE_SEL));
-
- GPIO_DBG->PCTRACECR = PCTRACE_SEL;
-}
-
-/**
- * @brief Enables or disables the debug interface.
- * @param NewState: new state of the debug interface.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void GPIO_DebugInterfaceCmd(FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Clear the DEBUGDIS bit to Enable the debug interface */
- GPIO_DBG->DBGCR &= (uint32_t)~GPIO_DBGCR_DBGDIS;
-
- }
- else
- {
- /* Set the DEBUGDIS bit to Disable the debug interface */
- GPIO_DBG->DBGCR |= (uint32_t)GPIO_DBGCR_DBGDIS;
- }
-}
-
-/**
- * @brief Enables or Disable REG_EN override of PA7's normal GPIO configuration.
- * @param NewState: new state of the REG_EN.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void GPIO_ExternalOverrideCmd(FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- /* Clear the GPIO_EXTREGEN bit to Enable the debug interface */
- GPIO_DBG->DBGCR &= (uint32_t)~GPIO_DBGCR_EXTREGEN;
-
- }
- else
- {
- /* Set the GPIO_EXTREGEN bit to Disable the debug interface */
- GPIO_DBG->DBGCR |= (uint32_t)GPIO_DBGCR_EXTREGEN;
- }
-}
-
-/**
- * @brief Checks whether the specified GPIO debug flag is set or not.
- * @param GPIO_DBGFLAG: specifies the flag to check.
- * This parameter can be one of the following values:
- * @arg GPIO_DBGSR_SWEN: Serial Wire interface flag
- * @arg GPIO_DBGSR_FORCEDBG: Debugger interface flag
- * @arg GPIO_DBGSR_BOOTMODE: nBOOTMODE signal sampled at the end of reset flag
- * @retval The new state of GPIO_DBGFLAG (SET or RESET).
- */
-FlagStatus GPIO_GetDebugFlagStatus(uint16_t GPIO_DBGFLAG)
-{
- FlagStatus bitstatus = RESET;
-
- /* Check the parameters */
- assert_param(IS_GPIO_GET_DBGFLAG(GPIO_DBGFLAG));
-
- /* Check the status of the specified GPIO debug flag */
- if ((GPIO_DBG->DBGSR & GPIO_DBGFLAG) != (uint32_t)RESET)
- {
- /* GPIO_DBGFLAG is set */
- bitstatus = SET;
- }
- else
- {
- /* GPIO_DBGFLAG is reset */
- bitstatus = RESET;
- }
- /* Return the GPIO_DBGFLAG status */
- return bitstatus;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_misc.c b/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_misc.c
deleted file mode 100644
index 3b8c27c..0000000
--- a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_misc.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32w108xx_misc.c
- * @author MCD Application Team
- * @version V1.0.1
- * @date 30-November-2012
- * @brief This file provides all the miscellaneous firmware functions (add-on
- * to CMSIS functions).
- ******************************************************************************
- * @attention
- *
- *
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32w108xx_misc.h"
-
-/** @addtogroup STM32W108xx_StdPeriph_Driver
- * @{
- */
-
-/** @defgroup MISC
- * @brief MISC driver modules
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-#define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
-
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/** @defgroup MISC_Private_Functions
- * @{
- */
-
-/**
- *
-@verbatim
- *******************************************************************************
- ##### Interrupts configuration functions #####
- *******************************************************************************
- [..] This section provide functions allowing to configure the NVIC interrupts
- (IRQ).The Cortex-M3 exceptions are managed by CMSIS functions.
- (#) Configure the NVIC Priority Grouping using NVIC_PriorityGroupConfig()
- function according to the following table.
- The table below gives the allowed values of the preemption priority
- and subpriority according to the Priority Grouping configuration
- performed by NVIC_PriorityGroupConfig function.
- ============================================================================================================================
- NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description
- ============================================================================================================================
- NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for preemption priority
- | | | 4 bits for subpriority
- ----------------------------------------------------------------------------------------------------------------------------
- NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for preemption priority
- | | | 3 bits for subpriority
- ----------------------------------------------------------------------------------------------------------------------------
- NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for preemption priority
- | | | 2 bits for subpriority
- ----------------------------------------------------------------------------------------------------------------------------
- NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for preemption priority
- | | | 1 bits for subpriority
- ----------------------------------------------------------------------------------------------------------------------------
- NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for preemption priority
- | | | 0 bits for subpriority
- ============================================================================================================================
-
-
- (#) Enable and Configure the priority of the selected IRQ Channels.
-
- -@- When the NVIC_PriorityGroup_0 is selected, it will no any nested interrupt,
- the IRQ priority will be managed only by subpriority.
- The sub-priority is only used to sort pending exception priorities,
- and does not affect active exceptions.
- -@- Lower priority values gives higher priority.
- -@- Priority Order:
- (#@) Lowest Preemption priority.
- (#@) Lowest Subpriority.
- (#@) Lowest hardware priority (IRQn position).
-
-@endverbatim
-*/
-
-/**
- * @brief Configures the priority grouping: preemption priority and subpriority.
- * @param NVIC_PriorityGroup: specifies the priority grouping bits length.
- * This parameter can be one of the following values:
- * @arg NVIC_PriorityGroup_0: 0 bits for preemption priority
- * 4 bits for subpriority.
- * @note When NVIC_PriorityGroup_0 is selected, it will no be any nested
- * interrupt. This interrupts priority is managed only with subpriority.
- * @arg NVIC_PriorityGroup_1: 1 bits for preemption priority.
- * 3 bits for subpriority.
- * @arg NVIC_PriorityGroup_2: 2 bits for preemption priority.
- * 2 bits for subpriority.
- * @arg NVIC_PriorityGroup_3: 3 bits for preemption priority.
- * 1 bits for subpriority.
- * @arg NVIC_PriorityGroup_4: 4 bits for preemption priority.
- * 0 bits for subpriority.
- * @retval None
- */
-void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
-{
- /* Check the parameters */
- assert_param(IS_NVIC_PRIORITY_GROUP(NVIC_PriorityGroup));
-
- /* Set the PRIGROUP[10:8] bits according to NVIC_PriorityGroup value */
- SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup;
-}
-
-/**
- * @brief Initializes the NVIC peripheral according to the specified
- * parameters in the NVIC_InitStruct.
- * @note To configure interrupts priority correctly, the NVIC_PriorityGroupConfig()
- * function should be called before.
- * @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains
- * the configuration information for the specified NVIC peripheral.
- * @retval None
- */
-void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct)
-{
- uint8_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F;
-
- /* Check the parameters */
- assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd));
- assert_param(IS_NVIC_PREEMPTION_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority));
- assert_param(IS_NVIC_SUB_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelSubPriority));
-
- if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE)
- {
- /* Compute the Corresponding IRQ Priority --------------------------------*/
- tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08;
- tmppre = (0x4 - tmppriority);
- tmpsub = tmpsub >> tmppriority;
-
- tmppriority = (uint32_t)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre;
- tmppriority |= (uint8_t)((NVIC_InitStruct->NVIC_IRQChannelSubPriority) & tmpsub);
- tmppriority = tmppriority << 0x04;
-
- NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority;
-
- /* Enable the Selected IRQ Channels --------------------------------------*/
- NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
- (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
- }
- else
- {
- /* Disable the Selected IRQ Channels -------------------------------------*/
- NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
- (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
- }
-}
-
-/**
- * @brief Sets the vector table location and Offset.
- * @param NVIC_VectTab: specifies if the vector table is in RAM or FLASH memory.
- * This parameter can be one of the following values:
- * @arg NVIC_VectTab_RAM: Vector Table in internal SRAM.
- * @arg NVIC_VectTab_FLASH: Vector Table in internal FLASH.
- * @param Offset: Vector Table base offset field. This value must be a multiple of 0x200.
- * @retval None
- */
-void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset)
-{
- /* Check the parameters */
- assert_param(IS_NVIC_VECTTAB(NVIC_VectTab));
- assert_param(IS_NVIC_OFFSET(Offset));
-
- SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80);
-}
-
-/**
- * @brief Selects the condition for the system to enter low power mode.
- * @param LowPowerMode: Specifies the new mode for the system to enter low power mode.
- * This parameter can be one of the following values:
- * @arg NVIC_LP_SEVONPEND: Low Power SEV on Pend.
- * @arg NVIC_LP_SLEEPDEEP: Low Power DEEPSLEEP request.
- * @arg NVIC_LP_SLEEPONEXIT: Low Power Sleep on Exit.
- * @param NewState: new state of LP condition.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_NVIC_LP(LowPowerMode));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- SCB->SCR |= LowPowerMode;
- }
- else
- {
- SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode);
- }
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_pwr.c b/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_pwr.c
deleted file mode 100644
index 6be77d7..0000000
--- a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_pwr.c
+++ /dev/null
@@ -1,548 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32w108xx_pwr.c
- * @author MCD Application Team
- * @version V1.0.1
- * @date 30-November-2012
- * @brief This file provides firmware functions to manage the following
- * functionalities of the power management (PWR):
- * + Voltage Regulator control
- * + WakeUp Pin/Source Configuration
- * + DeepSleep mode
- * + WakeUp status
- *
- * @verbatim
- ===============================================================================
- ##### How to use this driver #####
- ===============================================================================
- [..] This driver provides the Low level functions to manage the low level power
- registers. These functions are split in 4 groups
-
- (#) Voltage Regulator control functions: this group includes the
- management of following features using PWR_VREGInit() function:
- (++) Configure the regulator Trim values
- (++) Enable/Disable VREF, V1.8 and V1.2 voltage regulators
-
- (#) WakeUp Pin/Source Configuration functions: this group includes all
- needed to configure an interrupt as WakeUp source:
- (++) To control the GPIO pin to WakeUp the system from low power mode use the
- PWR_GPIOWakeUpPinCmd() function.
- (++) To configure the WakeUp method to wake the system from low power mode use
- the PWR_WakeUpSourceConfig() function.
- (++) To command the WakeUp source filter use PWR_WakeUpFilterConfig() function.
-
- (#) DeepSleep mode functions: this group includes the deep sleep feature
- configuration:
- (++) To freeze the GPIO state before entering in low power mode use
- the PWR_FreezestateLVoutput() function.
- (++) To control the deep sleep mode 0 when debugger is attached use
- the PWR_DeepSleepMode0Cmd() function.
- (++) To Wake the core from deep sleep 0 the WakeUp source filter use
- PWR_CoreWake() function.
- (++) To Disable the system access to the ACK bit in the CSYSPWRUPACKSR use
- PWR_InhibitCSYSPWRUPACK() function.
-
- (#) WakeUp Status functions: this group includes the required functions to
- manage the WakeUp interrupt status:
- (++) When the system wake up from low power mode use PWR_GetFlagStatus()
- to check witch interrupt is the source for WakeUp.
- (++) After check the user should clear the WakeUp source in the low power
- status register using PWR_ClearFlag() function.
-
- @endverbatim
- *
- ******************************************************************************
- * @attention
- *
- *
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32w108xx_pwr.h"
-
-/** @addtogroup STM32W108xx_StdPeriph_Driver
- * @{
- */
-
-/** @defgroup POWER_MANAGEMENT
- * @brief PWR driver modules
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/** @defgroup PWR_Private_Functions
- * @{
- */
-
-/** @defgroup PWR_Group1 Voltage Regulator control
- * @brief Voltage regulator VREF, V1.8 and V1.2 control
- *
-@verbatim
- ===============================================================================
- ##### Voltage Regulator control function #####
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Deinitializes the PWR peripheral registers to their default reset values.
- * @param None
- * @retval None
- */
-void PWR_DeInit(void)
-{
- PWR->DSLEEPCR1 = 0x00000000;
- PWR->DSLEEPCR2 = 0x00000001;
- PWR->VREGCR = 0x00000207;
- PWR->WAKECR1 = 0x00000200;
- PWR->WAKECR2 = 0x00000000;
- PWR->WAKESR = 0x000003FF;
- PWR->CSYSPWRUPACKCR = 0x00000000;
- PWR->WAKEPAR = 0x00000000;
- PWR->WAKEPBR = 0x00000000;
- PWR->WAKEPCR = 0x00000000;
- PWR->WAKEFILTR = 0x00000000;
-}
-
-/**
- * @brief Fills each VREG_InitStruct member with its default value.
- * @param VREG_InitStruct: pointer to a PWR_VREG_InitTypeDef structure
- * which will be initialized.
- * @retval None
- */
-void PWR_VREGStructInit(PWR_VREG_InitTypeDef* VREG_InitStruct)
-{
- /* VREG_InitStruct members default value */
- VREG_InitStruct->PWR_VREFCmd = POWER_ENABLE; /* by default enable */
- VREG_InitStruct->PWR_1V8Cmd = POWER_ENABLE; /* by default enable */
- VREG_InitStruct->PWR_1V8TRIM = 4;
- VREG_InitStruct->PWR_1V2Cmd = POWER_ENABLE; /* by default enable */
- VREG_InitStruct->PWR_1V2TRIM = 7;
-}
-
-/**
- * @brief Initializes the VREG peripheral according to the specified
- * parameters in the VREG_InitStruct.
- * @param VREG_InitStruct: pointer to a PWR_VREG_InitTypeDef structure
- * that contains the configuration information for the specified VREG.
- * @retval None
- */
-void PWR_VREGInit(PWR_VREG_InitTypeDef* VREG_InitStruct)
-{
- uint32_t temp = 0;
-
- /* Check the parameters */
- assert_param(IS_POWER_FUNCTIONAL_STATE(VREG_InitStruct->PWR_VREFCmd));
- assert_param(IS_POWER_FUNCTIONAL_STATE(VREG_InitStruct->PWR_1V8Cmd));
- assert_param(IS_TRIM_VALUE(VREG_InitStruct->PWR_1V8TRIM));
- assert_param(IS_POWER_FUNCTIONAL_STATE(VREG_InitStruct->PWR_1V2Cmd));
- assert_param(IS_TRIM_VALUE(VREG_InitStruct->PWR_1V2TRIM));
-
- temp = (uint32_t)(((VREG_InitStruct->PWR_1V8TRIM) << 7) | (VREG_InitStruct->PWR_1V2TRIM));
-
- /* Check the new VREF status */
- if (VREG_InitStruct->PWR_VREFCmd == POWER_DISABLE)
- {
- /* Disable VREF */
- temp |= PWR_VREGCR_VREFEN;
- }
-
- /* Check the new 1V8 status */
- if (VREG_InitStruct->PWR_1V8Cmd == POWER_DISABLE)
- {
- /* Disable 1V8 */
- temp |= PWR_VREGCR_1V8EN;
- }
-
- /* Check the new 1V2 status */
- if (VREG_InitStruct->PWR_1V2Cmd == POWER_DISABLE)
- {
- /* Disable 1V2 */
- temp |= PWR_VREGCR_1V2EN;
- }
-
- /* Set the new VREG configuration */
- PWR->VREGCR = temp;
-}
-
-/**
- * @}
- */
-
-/** @defgroup PWR_Group2 WakeUp Pin/Source Configuration
- * @brief Low Power mode source WakeUp and method configuration
- *
-@verbatim
- ===============================================================================
- ##### WakeUp Pin-Source Configuration function #####
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Enables or disables the GPIO WakeUp pin.
- * @param GPIOx: where x can be (A, B or C) to select the GPIO peripheral.
- * @param GPIO_Pin: specifies the port bit to be written.
- * This parameter can be one of GPIO_Pin_x where x can be (0..7).
- * @param NewState: new state of the GPIO WakeUp pin source.
- * This parameter can be: ENABLE or DISABLE.
- * @note The GPIO WakeUp monitoring should be enabled before enabling the GPIO WakeUp pin.
- * To enable the GPIO WakeUp monitoring use PWR_WakeUpSourceConfig() function.
- * @retval None
- */
-void PWR_GPIOWakeUpPinCmd(GPIO_TypeDef* GPIOx, uint32_t GPIO_Pin, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
- assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (GPIOx == GPIOA)
- {
- if (NewState != DISABLE)
- {
- PWR->WAKEPAR |= (uint32_t)GPIO_Pin;
- }
- else
- {
- PWR->WAKEPAR &= (uint32_t)~GPIO_Pin;
- }
- }
- else if (GPIOx == GPIOB)
- {
- if (NewState != DISABLE)
- {
- PWR->WAKEPBR |= (uint32_t)GPIO_Pin;
- }
- else
- {
- PWR->WAKEPBR &= (uint32_t)~GPIO_Pin;
- }
- }
- else
- {
- if (GPIOx == GPIOC)
- {
- if (NewState != DISABLE)
- {
- PWR->WAKEPCR |= (uint32_t)GPIO_Pin;
- }
- else
- {
- PWR->WAKEPCR &= (uint32_t)~GPIO_Pin;
- }
- }
- }
-}
-
-/**
- * @brief Enables or disables the WakeUp source filter.
- * @param PWR_WakeUpSource: specifies the selected PWR WakeUp source.
- * This parameter can be one of the following values:
- * @arg PWR_WAKEFILTER_GPIO: filter active on GPIO monitoring.
- * @arg PWR_WAKEFILTER_SC1: filter active on SC1.
- * @arg PWR_WAKEFILTER_SC2: filter active on SC2.
- * @arg PWR_WAKEFILTER_IRQD: filter active on IRQD.
- * @param NewState: new state of the WakeUp source.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void PWR_WakeUpFilterConfig(uint32_t PWR_WakeUpSource, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_PWR_WAKEUPFILTERSOURCE(PWR_WakeUpSource));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable the dedicated WakeUp filter by setting the dedicated bit in the
- WAKEFILTR register */
- PWR->WAKEFILTR |= PWR_WakeUpSource;
- }
- else
- {
- /* Disable the dedicated WakeUp filter by clearing the dedicated bit in the WAKEFILTR register */
- PWR->WAKEFILTR &= (uint32_t)~((uint32_t)PWR_WakeUpSource);
- }
-}
-
-/**
- * @brief Enables or disables the WakeUp method form low power mode.
- * @param PWR_WakeUpSource: specifies the selected PWR wakeup method.
- * This parameter can be one of the following values:
- * @arg PWR_WAKEUP_CSYSPWRRUPREQ: Wake up active on CSYSPWRUPREQ event.
- * @arg PWR_WAKEUP_CPWRRUPREQ: Wake up active on CPWRRUPREQ event.
- * @arg PWR_WAKEUP_CORE: Wake up active on COREWAKE event.
- * @arg PWR_WAKEUP_WRAP: Wake up active on sleep timer compare wrap/overflow event.
- * @arg PWR_WAKEUP_COMPB: Wake up active on sleep timer compare B event.
- * @arg PWR_WAKEUP_COMPA: Wake up active on sleep timer compare A event.
- * @arg PWR_WAKEUP_IRQD: Wake up active on falling/rising edge of pin PC0.
- * @arg PWR_WAKEUP_SC2: Wake up active on falling/rising edge of pin PA2 for SC2.
- * @arg PWR_WAKEUP_SC1: Wake up active on falling/rising edge of pin PB2 for SC12.
- * @arg PWR_WAKEUP_MON: Wake up active on GPIO monitoring.
- * @param NewState: new state of the WakeUp source.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void PWR_WakeUpSourceConfig(uint32_t PWR_WakeUpSource, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_PWR_WAKEUPSOURCE(PWR_WakeUpSource));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable the WakeUp from low power method by setting the dedicated bit in the WAKECR1 register */
- PWR->WAKECR1 |= PWR_WakeUpSource;
- }
- else
- {
- /* Disable the WakeUp from low power method by clearing the dedicated bit in the WAKECR1 register */
- PWR->WAKECR1 &= (uint32_t)~((uint32_t)PWR_WakeUpSource);
- }
-}
-
-/**
- * @}
- */
-
-/** @defgroup PWR_Group3 DeepSleep mode
- * @brief control the DeepSleep mode features
- *
-@verbatim
- ===============================================================================
- ##### DeepSleep mode function #####
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Enables or disables the freeze GPIO state LV output.
- * @param NewState: new freeze state of the GPIO state LV output.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void PWR_FreezestateLVoutput(FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable freeze GPIO state LV output by setting the LVFREEZE bit in the DSLEEPCR1 register */
- PWR->DSLEEPCR1 |= PWR_DSLEEPCR1_LVFREEZE;
- }
- else
- {
- /* Disable freeze GPIO state LV output from low power method by clearing the LVFREEZE bit in the DSLEEPCR1 register */
- PWR->DSLEEPCR1 &= (uint32_t)~((uint32_t)PWR_DSLEEPCR1_LVFREEZE);
- }
-}
-
-/**
- * @brief Enables or disables the deep sleep mode 0 when debugger is attached.
- * @param NewState: new freeze state of the GPIO state LV output.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void PWR_DeepSleepMode0Cmd(FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable deep sleep mode 0 if debugger attached by setting the MODE bit in the DSLEEPCR2 register */
- PWR->DSLEEPCR2 |= PWR_DSLEEPCR2_MODE;
- }
- else
- {
- /* Disable deep sleep mode 0 if debugger by clearing the MODE bit in the DSLEEPCR2 register */
- PWR->DSLEEPCR2 &= (uint32_t)~((uint32_t)PWR_DSLEEPCR2_MODE);
- }
-}
-
-/**
- * @brief Wake core form a deep sleep 0.
- * @param None
- * @retval None
- */
-void PWR_CoreWake(void)
-{
- /* Wake core from deep sleep 0 by setting the COREWAKE bit in the WAKECR2 register */
- PWR->WAKECR2 |= PWR_WAKECR2_COREWAKE;
-}
-
-/**
- * @brief Disables the cortex-M3 system access to the ACK bit in the CSYSPWRUPACKSR register.
- * @param None
- * @retval None
- */
-void PWR_InhibitCSYSPWRUPACK(void)
-{
- /* Disable the system access to the ACK bit in the CSYSPWRUPACKSR by setting
- the INHIBIT bit in the CSYSPWRUPACKCR register */
- PWR->CSYSPWRUPACKCR |= PWR_CSYSPWRUPACKCR_INHIBIT;
-}
-
-/**
- * @}
- */
-
-/** @defgroup PWR_Group4 WakeUp status
- * @brief Control the low power WakeUp source status
- *
-@verbatim
- ===============================================================================
- ##### WakeUp status function #####
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Checks whether the specified PWR flag is set or not.
- * @param PWR_FLAG: specifies the low power wake up flag to check.
- * This parameter can be one of the following values:
- * @arg PWR_FLAG_CSYSPWRRUPREQ: Wake up done using the DAP access to SYS registers flag
- * @arg PWR_FLAG_CPWRRUPREQ: Wake up done using the DAP access to DBG registers flag
- * @arg PWR_FLAG_CORE: Wake up done using debug port activity flag
- * @arg PWR_FLAG_WRAP: Wake up done using sleep timer wrap flag
- * @arg PWR_FLAG_COMPB: Wake up done using sleep timer compare B flag
- * @arg PWR_FLAG_COMPA: Wake up done using sleep timer compare A flag
- * @arg PWR_FLAG_IRQD: Wake up done using external interrupt IRQD flag
- * @arg PWR_FLAG_SC2: Wake up done using serial controller 2 (PA2) flag
- * @arg PWR_FLAG_SC1: Wake up done using serial controller 1 (PB2) flag
- * @arg PWR_FLAG_MON: Wake up done using GPIO monitoring flag
- * @arg PWR_FLAG_CPWRUPREQ: REQ flag in the CPWRUPREQSR register
- * @arg PWR_FLAG_CSYSPWRUPREQ: REQ flag in the CSYSPWRUPREQSR register
- * @arg PWR_FLAG_CSYSPWRUPREQ: ACK flag in the CSYSPWRUPREQSR register
- * @retval The new state of PWR_FLAG (SET or RESET).
- */
-FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG)
-{
- FlagStatus bitstatus = RESET;
-
- /* Check the parameters */
- assert_param(IS_PWR_GET_FLAG(PWR_FLAG));
-
- /* Check the REQ flag in the CPWRUPREQSR register */
- if (PWR_FLAG == PWR_FLAG_CPWRUPREQ)
- {
- if ((PWR->CPWRUPREQSR & 0x00000001) != (uint32_t)RESET)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- }
- /* Check the REQ flag in the CSYSPWRUPREQSR register */
- else if (PWR_FLAG == PWR_FLAG_CSYSPWRUPREQ)
- {
- if ((PWR->CSYSPWRUPREQSR & 0x00000001) != (uint32_t)RESET)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- }
- /* Check the ACK flag in the CSYSPWRUPACKSR register */
- else if (PWR_FLAG == PWR_FLAG_CSYSPWRUPREQ)
- {
- if ((PWR->CSYSPWRUPACKSR & 0x00000001) != (uint32_t)RESET)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- }
- /* Check the Wake up flag in the WAKESR register */
- else
- {
- if ((PWR->WAKESR & PWR_FLAG) != (uint32_t)RESET)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- }
- return bitstatus;
-}
-
-/**
- * @brief Clears the PWR pending flags.
- * @param PWR_FLAG: specifies the low power wake up flag to clear.
- * This parameter can be one of the following values:
- * @arg PWR_FLAG_CSYSPWRRUPREQ: Wake up done using the DAP access to SYS registers flag
- * @arg PWR_FLAG_CPWRRUPREQ: Wake up done using the DAP access to DBG registers flag
- * @arg PWR_FLAG_CORE: Wake up done using debug port activity flag
- * @arg PWR_FLAG_WRAP: Wake up done using sleep timer wrap flag
- * @arg PWR_FLAG_COMPB: Wake up done using sleep timer compare B flag
- * @arg PWR_FLAG_COMPA: Wake up done using sleep timer compare A flag
- * @arg PWR_FLAG_IRQD: Wake up done using external interrupt IRQD flag
- * @arg PWR_FLAG_SC2: Wake up done using serial controller 2 (PA2) flag
- * @arg PWR_FLAG_SC1: Wake up done using serial controller 1 (PB2) flag
- * @arg PWR_FLAG_MON: Wake up done using GPIO monitoring flag
- * @retval The new state of PWR_FLAG (SET or RESET).
- */
-void PWR_ClearFlag(uint32_t PWR_FLAG)
-{
- /* Check the parameters */
- assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG));
-
- PWR->WAKESR = PWR_FLAG;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_rst.c b/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_rst.c
deleted file mode 100644
index 10713b0..0000000
--- a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_rst.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32w108xx_rst.c
- * @author MCD Application Team
- * @version V1.0.1
- * @date 30-November-2012
- * @brief This file provides firmware functions to manage the following
- * functionalities of the RST peripheral
- *
- * @verbatim
- *
- ===============================================================================
- ##### RST specific features #####
- ===============================================================================
- [..] This driver provide the information about reset source
-
- [..] The reset can be due to:
- (#) Core lockup
- (#) Option byte load failure (may be set with other bits
- (#) Wake-up from Deep Sleep
- (#) Software reset
- (#) Watchdog expiration
- (#) External reset pin signal
- (#) The application of a Core power supply (or previously failed)
- (#) Normal power applied
-
-
- @endverbatim
- *
- ******************************************************************************
- * @attention
- *
- *
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32w108xx_rst.h"
-
-/** @addtogroup STM32W108xx_StdPeriph_Driver
- * @{
- */
-
-/** @defgroup RESET
- * @brief RST driver modules
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private defines -----------------------------------------------------------*/
-/* Private macros ------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/** @defgroup RST_Private_Functions
- * @{
- */
-
-/** @defgroup RST_Group1
- * @brief Reset event sources
- *
-@verbatim
- ===============================================================================
- ##### RST EVENT SOURCES #####
- ===============================================================================
- [..] This section provides function allowing to get reset event source
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Checks whether the specified RST flag is set or not.
- * @param RST_FLAG: specifies the RST_FLAG flag to check.
- * This parameter can be one of the following values:
- * @arg RST_FLAG_PWRHV: Normal power applied
- * @arg RST_FLAG_PWRLV: The application of a Core power supply (or previously failed)
- * @arg RST_FLAG_PIN: External reset pin signal.
- * @arg RST_FLAG_WDG: Watchdog expiration
- * @arg RST_FLAG_SWRST: Software reset.
- * @arg RST_FLAG_WKUP: Wake-up from Deep Sleep
- * @arg RST_FLAG_OBFAIL: Option byte load failure (may be set with other bits)
- * @arg RST_FLAG_LKUP: Core lockup
- *
- * @retval The new state of RST_FLAG (SET or RESET)
- */
-FlagStatus RST_GetFlagStatus(uint32_t RST_FLAG)
-{
- FlagStatus bitstatus = RESET;
- /* Check the parameters */
- assert_param(IS_RST_FLAG(RST_FLAG));
-
- if ((RST->SR & RST_FLAG) != (uint32_t)RESET)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_sc.c b/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_sc.c
deleted file mode 100644
index 25b2acd..0000000
--- a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_sc.c
+++ /dev/null
@@ -1,1844 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32w108xx_sc.c
- * @author MCD Application Team
- * @version V1.0.1
- * @date 30-November-2012
- * @brief This file provides firmware functions to manage the following
- * functionalities of the Serial Controller (SC):
- * + Universal Asynchronous Receiver/Transmitter communication
- * + Serial Peripheral Interface communication
- * + Inter-Integrated Circuit communication
- * + DMA transfers management in UART and SPI modes
- *
- * @verbatim
- *
- ===============================================================================
- ##### How to use this driver #####
- ===============================================================================
- (#) Peripherals GPIO Configuration:
- (++) Select the desired pin GPIO_InitStruct->GPIO_Pin according to the
- defined Initialization and Configuration Tables for each serial control
- modes (UART, SPI master, SPI Salve and I2C).
- (++) Refer to the Initialization and Configuration Tables to configure
- the GPIO_InitStruct->GPIO_Mode
- (++) Call GPIO_Init() function.
- (#) For the I2C mode Program the clock rate using the I2C_Init() function.
- (#) For the SPI mode Program the Polarity, Phase, First Data, Clcok rate
- and the Peripheral Mode rate using the SPI_Init() function.
- (#) For the UART mode Program the Baud Rate, Word Length , Stop Bit, Parity and Hardware
- flow control using the UART_Init() function.
- (#) Enable the PPP using the PPP_Cmd() function.
- (#) For UART Mode set pull-up resistors on Tx and Rx pins using GPIO_SetBits() function.
- (#) Enable the NVIC and the corresponding interrupt using the function.
- PPP_ITConfig() if you need to use interrupt mode.
- (#) When using the DMA mode
- (++) Configure the DMA using SC_DMA_Init() function.
- (++) Active the needed channel Request using SC_DMA_ChannelLoadEnable() function.
-
- [..]
- (@) PPP can be UART, SPI or I2C.
- (@) The DMA is not support for I2C mode.
-
- @endverbatim
- *
- ******************************************************************************
- * @attention
- *
- *
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32w108xx_sc.h"
-
-/** @addtogroup STM32W108xx_StdPeriph_Driver
- * @{
- */
-
-/** @defgroup SERIAL_CONTROLLER
- * @brief SC driver modules
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* I2C ADD0 mask */
-#define OAR1_ADD0_Set ((uint8_t)0x01)
-#define OAR1_ADD0_Reset ((uint8_t)0xFE)
-#define SPICR_CLEAR_MASK ((uint32_t)0xFFFFFFE8)
-
-/* Private macro -------------------------------------------------------------*/
-#define ABS(x) ((x) > 0) ? (x) : (-(x))
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/** @defgroup SC_Private_Functions
- * @{
- */
-
-/** @defgroup SC_Group1 Universal Asynchronous Receiver/Transmitter communication
- * @brief universal asynchronous receiver transmitter functions
- *
-@verbatim
- ===============================================================================
- ##### Universal Asynchronous Receiver-Transmitter functions #####
- ===============================================================================
- [..] This section provides a set of functions allowing to handles the Universal
- Asynchronous Receiver Transmitter communication.
-
- (@) Only SC1 include an universal asynchronous receiver transmitter (UART) controller.
-
-*** Initialization and Configuration ***
- =======================================
- [..] The GPIO pins that can be assigned to UART interface are listed in the following table:
- +------------------------------------------------------+
- |Parameter | Direction | GPIO configuration | SC1 pin |
- |----------|-----------|--------------------|----------|
- | TXD | Out | Alternate Output | PB1 |
- | | | (push-pull) | |
- |----------|-----------|-------------------------------|
- | RXD | In | Input | PB2 |
- |----------|-----------|--------------------|----------|
- | nCTS | In | Input | PB3 |
- |----------|-----------|-------------------------------|
- | nRTS | Out | Alternate Output | PB4 |
- | | | (push-pull) | |
- +------------------------------------------------------+
-
- [..] For the asynchronous mode these parameters can be configured:
- (+) Baud Rate.
- (+) Word Length.
- (+) Stop Bit.
- (+) Parity: If the parity is enabled, then the MSB bit of the data written
- in the data register is transmitted but is changed by the parity bit.
- Depending on the frame length defined by the M bit (7-bits or 8-bits),
- the possible UART frame formats are as listed in the following table:
-
- +-------------------------------------------------------------+
- | M bit | PCE bit | UART frame |
- |---------------------|---------------------------------------|
- | 0 | 0 | | SB | 7 bit data | STB | |
- |---------|-----------|---------------------------------------|
- | 0 | 1 | | SB | 7 bit data | PB | STB | |
- |---------|-----------|---------------------------------------|
- | 1 | 0 | | SB | 8 bit data | STB | |
- |---------|-----------|---------------------------------------|
- | 1 | 1 | | SB | 8 bit data | PB | STB | |
- +-------------------------------------------------------------+
-
- (+) Hardware flow control.
- [..] The UART_Init() function follows the UART asynchronous configuration
- procedure (details for the procedure is available in datasheet.
-
-*** Data transfers ***
- =====================
- [..] In reception, data are received and then stored into an internal Rx buffer while
- In transmission, data are first stored into an internal Tx buffer before being
- transmitted.
-
- [..] The read access of the SCx_DR register can be done using
- UART_ReceiveData() function and returns the Rx buffered value. Whereas a write
- access to the SCx_DR can be done using UART_SendData() function and stores
- the written data into Tx buffer.
-
- *** Interrupts and flags management ***
- =======================================
- [..] This subsection provides also a set of functions allowing to configure the
- UART Interrupts sources, Requests and check or clear the flags or pending bits status.
- The user should identify which mode will be used in his application to
- manage the communication: Polling mode, Interrupt mode or DMA mode(refer SC_Group4).
-
- [..] In Polling Mode, the UART communication can be managed by these flags:
- (#) UART_FLAG_TXE: to indicate the status of the transmit buffer register.
- (#) UART_FLAG_RXNE: to indicate the status of the receive buffer register.
- (#) UART_FLAG_IDLE: to indicate the status of the Idle Line.
- (#) UART_FLAG_CTS: to indicate the status of the nCTS line.
- (#) UART_FLAG_FE: to indicate if a frame error occur.
- (#) UART_FLAG_PE: to indicate if a parity error occur.
- (#) UART_FLAG_OVR: to indicate if an Overrun error occur.
- [..] In this mode it is advised to use the following functions:
- (+) FlagStatus UART_GetFlagStatus(SC_UART_TypeDef* SCx_UART, uint32_t UART_FLAG).
- [..] In this mode all the UART flags are cleared by hardware.
-
- [..] In Interrupt Mode, the UART communication can be managed by 7 interrupt
- sources and 7 pending bits:
- (+) Pending Bits:
- (##) UART_IT_PE: to indicate the status of Parity Error interrupt.
- (##) UART_IT_FE: to indicate the status of Framing Error interrupt.
- (##) UART_IT_UND: to indicate the status of UnderRun Error interrupt.
- (##) UART_IT_OVR: to indicate the status of OverRun Error interrupt.
- (##) UART_IT_IDLE: to indicate the status of IDLE line detected interrupt.
- (##) UART_IT_TXE: to indicate the status of the Transmit data register empty interrupt.
- (##) UART_IT_RXNE: to indicate the status of the Data Register not empty interrupt.
-
- (+) Interrupt Source:
- (##) UART_IT_PE: specifies the interrupt source forParity Error pending interrupt.
- (##) UART_IT_FE: specifies the interrupt source for Framing Error pending interrupt.
- (##) UART_IT_UND: specifies the interrupt source for UnderRun Error pending interrupt.
- (##) UART_IT_OVR: specifies the interrupt source for OverRun Error pending interrupt.
- (##) UART_IT_IDLE: specifies the interrupt source for IDLE line detected pending interrupt.
- (##) UART_IT_TXE: specifies the interrupt source for the Transmit data register empty pending interrupt.
- (##) UART_IT_RXNE: specifies the interrupt source for the Data Register not empty pending interrupt.
- -@@- These parameters are coded in order to use them as interrupt source
- or as pending bits.
- [..] In this Mode it is advised to use the following functions:
- (+) void UART_ITConfig(SC_IT_TypeDef* SCx_IT, uint32_t UART_IT, FunctionalState NewState).
- (+) ITStatus UART_GetITStatus(SC_IT_TypeDef* SCx_IT, uint32_t UART_IT).
- (+) void UART_ClearITPendingBit(SC_IT_TypeDef* SCx_IT, uint32_t UART_IT).
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Deinitializes the SCx_UART peripheral registers to their default reset values.
- * @param SCx_UART: where x can be 1 to select the Serial controller peripheral.
- * @retval None
- */
-void UART_DeInit(SC_UART_TypeDef* SCx_UART)
-{
- /* Check the parameters */
- assert_param(IS_UART_PERIPH(SCx_UART));
-
- SCx_UART->CR = 0;
- SCx_UART->UARTCR = 0;
- SCx_UART->UARTBRR1 = 0;
- SCx_UART->UARTBRR2 = 0;
-}
-
-/**
- * @brief Initializes the SC1_UART peripheral according to the specified
- * parameters in the UART_InitStruct .
- * @param SCx_UART: where x can be 1 to select the Serial controller peripheral.
- * @param UART_InitStruct: pointer to a UART_InitTypeDef structure
- * that contains the configuration information for the specified SC1_UART peripheral.
- * @retval None
- */
-void UART_Init(SC_UART_TypeDef* SCx_UART, UART_InitTypeDef* UART_InitStruct)
-{
- int32_t temp1, temp2 = 0;
- uint32_t clockfrequency = 0;
- uint32_t N = 0;
-
- /* Check the parameters */
- assert_param(IS_UART_PERIPH(SCx_UART));
- assert_param(IS_UART_BAUDRATE(UART_InitStruct->UART_BaudRate));
- assert_param(IS_UART_WORD_LENGTH(UART_InitStruct->UART_WordLength));
- assert_param(IS_UART_STOPBITS(UART_InitStruct->UART_StopBits));
- assert_param(IS_UART_PARITY(UART_InitStruct->UART_Parity));
- assert_param(IS_UART_HARDWARE_FLOW_CONTROL(UART_InitStruct->UART_HardwareFlowControl));
-
- /* Disable the selected UART by clearing the MODE bits in the CR register */
- SCx_UART->CR &= (uint16_t)~((uint16_t)SC_CR_MODE);
-
- /*---------------------------- UARTCR Configuration ------------------------*/
- /* Configure the USART Word Length, Parity and mode ------------------------*/
- /* Set STOP bit according to USART_StopBits value */
- /* Set the M bits according to UART_WordLength value */
- /* Set PCE and PS bits according to USART_Parity value */
- /* Set HFCE and AHFCE bits according to UART_HardwareFlowControl value */
- SCx_UART->UARTCR = (uint32_t)(UART_InitStruct->UART_WordLength | UART_InitStruct->UART_Parity |
- UART_InitStruct->UART_StopBits | UART_InitStruct->UART_HardwareFlowControl);
- /*---------------------------- UART BRR Configuration ----------------------*/
- /* Configure the UART Baud Rate --------------------------------------------*/
- clockfrequency = CLK_GetClocksFreq();
- N = (uint16_t)(clockfrequency/(2*(UART_InitStruct->UART_BaudRate)));
-
- /* Write to UART BRR1 */
- SCx_UART->UARTBRR1 &= (uint32_t)~SC_UARTBRR1_N;
- SCx_UART->UARTBRR1 |= (uint32_t)N;
-
- temp1 = (int32_t)(clockfrequency/(2*N));
- temp2 = (int32_t)(clockfrequency/(2*N +1));
-
- temp1 = ABS((int32_t)((int32_t)temp1 - (int32_t)UART_InitStruct->UART_BaudRate));
- temp2 = ABS((int32_t)((int32_t)temp2 - (int32_t)UART_InitStruct->UART_BaudRate));
-
- /* Check the baud rate error and write to UART BRR2 */
- if(temp1 > temp2)
- {
- SCx_UART->UARTBRR2 |= (uint32_t)SC_UARTBRR1_F;
- }
- else
- {
- SCx_UART->UARTBRR2 &=(uint32_t)~SC_UARTBRR1_F;
- }
-}
-
-/**
- * @brief Fills each UART_InitStruct member with its default value.
- * @param UART_InitStruct: pointer to a UART_InitTypeDef structure
- * which will be initialized.
- * @retval None
- */
-void UART_StructInit(UART_InitTypeDef* UART_InitStruct)
-{
- /* UART_InitStruct members default value */
- UART_InitStruct->UART_BaudRate = 115200;
- UART_InitStruct->UART_WordLength = UART_WordLength_8b;
- UART_InitStruct->UART_StopBits = UART_StopBits_1;
- UART_InitStruct->UART_Parity = UART_Parity_No;
- UART_InitStruct->UART_HardwareFlowControl = UART_HardwareFlowControl_Disable;
-}
-
-/**
- * @brief Enables or disables the RTS assertion for the specified SC1_UART peripheral.
- * @param SCx_UART: where x can be 1 to select the Serial controller peripheral.
- * @param NewState: new state of the SC1_UART peripheral.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void UART_RTSAssertionCmd(SC_UART_TypeDef* SCx_UART, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_UART_PERIPH(SCx_UART));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* The RTS signal is asserted by setting the nRTS bit in the UARTCR register */
- SCx_UART->UARTCR |= SC_UARTCR_nRTS;
- }
- else
- {
- /* The RTS signal is deasserted by clearing the nRTS bit in the UARTCR register */
- SCx_UART->UARTCR &= (uint16_t)~((uint16_t)SC_UARTCR_nRTS);
- }
-}
-
-/**
- * @brief Enables or disables the specified SC1_UART peripheral.
- * @param SCx_UART: where x can be 1 to select the Serial controller peripheral.
- * @param NewState: new state of the SC1_UART peripheral.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void UART_Cmd(SC_UART_TypeDef* SCx_UART, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_UART_PERIPH(SCx_UART));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable the selected UART by setting the MODE bit 0 in the CR register */
- SCx_UART->CR &= (uint16_t)~((uint16_t)SC_CR_MODE);
- SCx_UART->CR |= SC_CR_MODE_0;
- }
- else
- {
- /* Disable the selected UART by clearing the MODE bits in the CR register */
- SCx_UART->CR &= (uint16_t)~((uint16_t)SC_CR_MODE);
- }
-}
-
-/**
- * @brief Enables or disables the specified SCx_UART interrupts.
- * @param SCx_IT: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param UART_IT: specifies the SCx_UART interrupt source to be enabled or disabled.
- * This parameter can be one of the following values:
- * @arg UART_IT_PE: Parity error interrupt mask
- * @arg UART_IT_FE: Frame error interrupt mask
- * @arg UART_IT_UND: Underrun interrupt mask (to be checked)
- * @arg UART_IT_OVR: Overrun interrupt mask
- * @arg UART_IT_IDLE: Idle line detected interrupt mask
- * @arg UART_IT_TXE: Transmit data register empty interrupt mask
- * @arg UART_IT_RXNE: Data Register not empty interrupt mask
- * @param NewState: new state of the specified SCx_UART interrupt source.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void UART_ITConfig(SC_IT_TypeDef* SCx_IT, uint32_t UART_IT, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_UART_IT_PERIPH(SCx_IT));
- assert_param(IS_UART_IT(UART_IT));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable the selected UART interrupt */
- SCx_IT->IER |= UART_IT;
- }
- else
- {
- /* Disable the selected UART interrupt */
- SCx_IT->IER &= (uint16_t)~((uint16_t)UART_IT);
- }
-}
-
-/**
- * @brief Trigger event configuration to handle the specified SCx_UART interrupt.
- * @param SCx_IT: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param UART_IT: specifies the SCx_UART interrupt to be configured.
- * This parameter can be one of the following values:
- * @arg UART_IT_IDLE: Idle line detected interrupt
- * @arg UART_IT_TXE: Transmit data register empty interrupt
- * @arg UART_IT_RXNE: Data Register not empty interrupt
- * @param TriggerEvent: Trigger event configuration of the specified SCx_UART interrupt.
- * This parameter can be one of the following values:
- * @arg SC_TriggerEvent_Edge: The specified SCx_UART interrupt will be generated on edge
- * @arg SC_TriggerEvent_Level: The specified SCx_UART interrupt will be generated on level
- * @retval None
- */
-void UART_TriggerEventConfig(SC_IT_TypeDef* SCx_IT, uint32_t UART_IT, uint32_t TriggerEvent)
-{
- /* Check the parameters */
- assert_param(IS_UART_IT_PERIPH(SCx_IT));
- assert_param(IS_UART_TRIGGEREVENT_IT(UART_IT));
- assert_param(IS_SC_TRIGGEREVENT(TriggerEvent));
-
- if (TriggerEvent != SC_TriggerEvent_Edge)
- {
- /* The UART_IT interrupt will be handled on level */
- SCx_IT->ICR |= UART_IT;
- }
- else
- {
- /* The UART_IT interrupt will be handled on edge */
- SCx_IT->ICR &= (uint16_t)~((uint16_t)UART_IT);
- }
-}
-
-/**
- * @brief Transmits a Data through the SC1_UART peripheral.
- * @param SCx_UART: where x can be 1 to select the Serial controller peripheral.
- * @param Data: Data to be transmitted.
- * @retval None
- */
-void UART_SendData(SC_UART_TypeDef* SCx_UART, uint8_t Data)
-{
- uint32_t scxbase = 0x00;
-
- /* Check the parameters */
- assert_param(IS_UART_PERIPH(SCx_UART));
-
- scxbase = (uint32_t)SCx_UART;
-
- *(__IO uint32_t *) scxbase = Data;
-}
-
-/**
- * @brief Returns the most recent received data by the SC1_UART peripheral.
- * @param SCx_UART: where x can be 1 to select the Serial controller peripheral.
- * @retval The value of the received data.
- */
-uint8_t UART_ReceiveData(SC_UART_TypeDef* SCx_UART)
-{
- uint32_t scxbase = 0x00;
-
- /* Check the parameters */
- assert_param(IS_UART_PERIPH(SCx_UART));
-
- scxbase = (uint32_t)SCx_UART;
-
- return *(__IO uint32_t *) scxbase;
-}
-
-/**
- * @brief Checks whether the specified SC1_UART flag is set or not.
- * @param SCx_UART: where x can be 1 to select the Serial controller peripheral.
- * @param UART_FLAG: specifies the SCx_UART flag to check.
- * This parameter can be one of the following values:
- * @arg UART_FLAG_CTS: Clear to send flag.
- * @arg UART_FLAG_RXNE: Receive data register not empty flag.
- * @arg UART_FLAG_TXE: Transmit data register empty flag.
- * @arg UART_FLAG_ORE: OverRun Error flag.
- * @arg UART_FLAG_FE: Framing Error flag.
- * @arg UART_FLAG_PE: Parity Error flag.
- * @arg UART_FLAG_IDLE: Idle Line detection flag.
- * @retval The new state of UART_FLAG (SET or RESET).
- */
-FlagStatus UART_GetFlagStatus(SC_UART_TypeDef* SCx_UART, uint32_t UART_FLAG)
-{
- FlagStatus bitstatus = RESET;
-
- /* Check the parameters */
- assert_param(IS_UART_PERIPH(SCx_UART));
- assert_param(IS_UART_GET_FLAG(UART_FLAG));
-
- if ((SCx_UART->UARTSR & UART_FLAG) != (uint32_t)RESET)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
-}
-
-/**
- * @brief Checks whether the specified SC1_UART pending interrupt is set or not.
- * @param SCx_IT: where x can be 1 to select the Serial controller peripheral.
- * @param UART_IT: specifies the pending interrupt to check.
- * This parameter can be one of the following values:
- * @arg UART_IT_PE: Parity error interrupt pending
- * @arg UART_IT_FE: Frame error interrupt pending
- * @arg UART_IT_UND: Underrun interrupt pending (to be checked)
- * @arg UART_IT_OVR: Overrun interrupt pending
- * @arg UART_IT_IDLE: Idle line detected interrupt pending
- * @arg UART_IT_TXE: Transmit data register empty interrupt pending
- * @arg UART_IT_RXNE: Data Register not empty interrupt pending
- * @retval The new state of UART_IT (SET or RESET).
- */
-ITStatus UART_GetITStatus(SC_IT_TypeDef* SCx_IT, uint32_t UART_IT)
-{
- ITStatus bitstatus = RESET;
- uint32_t enablestatus = 0;
- /* Check the parameters */
- assert_param(IS_UART_IT_PERIPH(SCx_IT));
- assert_param(IS_UART_IT(UART_IT));
-
- enablestatus = (uint32_t)(SCx_IT->IER & UART_IT);
- if (((SCx_IT->ISR & UART_IT) != (uint32_t)RESET) && enablestatus)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
-}
-
-/**
- * @brief Clears the SC1_UART interrupt pending bits.
- * @param SCx_IT: where x can be 1 to select the Serial controller peripheral.
- * @param UART_IT: specifies the pending interrupt to check.
- * This parameter can be one of the following values:
- * @arg UART_IT_PE: Parity error interrupt pending
- * @arg UART_IT_FE: Frame error interrupt pending
- * @arg UART_IT_UND: Underrun interrupt pending (to be checked)
- * @arg UART_IT_OVR: Overrun interrupt pending
- * @arg UART_IT_IDLE: Idle line detected interrupt pending
- * @arg UART_IT_TXE: Transmit data register empty interrupt pending
- * @arg UART_IT_RXNE: Data Register not empty interrupt pending
- * @retval None
- */
-void UART_ClearITPendingBit(SC_IT_TypeDef* SCx_IT, uint32_t UART_IT)
-{
- /* Check the parameters */
- assert_param(IS_UART_IT_PERIPH(SCx_IT));
- assert_param(IS_UART_IT(UART_IT));
-
- SCx_IT->ISR = UART_IT;
-}
-
-/**
- * @}
- */
-
-/** @defgroup SC_Group2 Serial peripheral interface communication
- * @brief serial peripheral interface functions
- *
-@verbatim
- ===============================================================================
- ##### Serial Peripheral Interface functions #####
- ===============================================================================
- [..] This section provides a set of functions allowing to handles the serial peripheral
- interface communication.
-
- (@) The SC1 and SC2 include an Serial Peripheral Interface (SPI) master/slave controller.
-
-*** Initialization and Configuration ***
- =======================================
- [..] The GPIO pins that can be assigned to SPI interface are listed in the following tables:
- (##) SPI Master Mode:
- +-----------------------------------------------------------------+
- |Parameter | Direction | GPIO configuration | SC1 pin | SC2 pin |
- |----------|-----------|--------------------|----------|----------|
- | MOSI | Out | Alternate Output | PB1 | PA0 |
- | | | (push-pull) | | |
- |----------|-----------|-------------------------------|----------|
- | MISO | In | Input | PB2 | PA1 |
- |----------|-----------|--------------------|----------|----------|
- | SCLK | Out | Alternate Output | PB3 | PA2 |
- | | | (push-pull) | | |
- | | | Special SCLK mode | | |
- +-----------------------------------------------------------------+
- (##) SPI Slave Mode:
- +-----------------------------------------------------------------+
- |Parameter | Direction | GPIO configuration | SC1 pin | SC2 pin |
- |----------|-----------|--------------------|----------|----------|
- | MOSI | In | Input | PB2 | PA0 |
- |----------|-----------|-------------------------------|----------|
- | MISO | Out | Alternate Output | PB1 | PA1 |
- | | | (push-pull) | | |
- |----------|-----------|--------------------|----------|----------|
- | SCLK | In | Input | PB3 | PA2 |
- |----------|-----------|--------------------|----------|----------|
- | nSSEL | In | Input | PB4 | PA3 |
- +-----------------------------------------------------------------+
- [..] For the Serial Peripheral Interface mode these parameters can be configured:
- (+) Mode.
- (+) Data Size.
- (+) Polarity.
- (+) Phase.
- (+) Baud Rate
- (+) First Bit Transmission
- [..] The SPI_Init() function follows the SPI configuration procedures for Master mode
- and Slave mode (details for these procedures are available in datasheet).
-
-*** Data transfers ***
- =====================
-
- [..] In reception, data are received and then stored into an internal Rx buffer while
- In transmission, data are first stored into an internal Tx buffer before being
- transmitted.
-
- [..] The read access of the SCx_DR register can be done using SPI_ReceiveData()
- function and returns the Rx buffered value. Whereas a write access to the SCx_DR
- can be done using SPI_SendData() function and stores the written data into
- Tx buffer.
-
- *** Interrupts and flags management ***
- =======================================
- [..] This subsection provides also a set of functions allowing to configure the
- SPI Interrupts sources, Requests and check or clear the flags or pending bits status.
- The user should identify which mode will be used in his application to
- manage the communication: Polling mode, Interrupt mode or DMA mode(refer SC_Group4).
-
- [..] In Polling Mode, the SPI communication can be managed by these flags:
- (#) SPI_FLAG_TXE: to indicate the status of the transmit buffer register.
- (#) SPI_FLAG_RXNE: to indicate the status of the receive buffer register.
- (#) SPI_FLAG_IDLE: to indicate the status of the Idle Line.
- (#) SPI_FLAG_OVR: to indicate if an Overrun error occur.
- [..] In this Mode it is advised to use the following functions:
- (+) FlagStatus SPI_GetFlagStatus(SC_SPI_TypeDef* SCx_SPI, uint32_t SPI_FLAG).
- [..] In this mode all the SPI flags are cleared by hardware.
-
- [..] In Interrupt Mode, the SPI communication can be managed by 5 interrupt
- sources and 5 pending bits:
- (+) Pending Bits:
- (##) SPI_IT_UND: to indicate the status of UnderRun Error interrupt.
- (##) SPI_IT_OVR: to indicate the status of OverRun Error interrupt.
- (##) SPI_IT_IDLE: to indicate the status of IDLE line detected interrupt.
- (##) SPI_IT_TXE: to indicate the status of the Transmit data register empty interrupt.
- (##) SPI_IT_RXNE: to indicate the status of the Data Register not empty interrupt.
-
- (+) Interrupt Source:
- (##) SPI_IT_UND: specifies the interrupt source for UnderRun Error pending interrupt.
- (##) SPI_IT_OVR: specifies the interrupt source for OverRun Error pending interrupt.
- (##) SPI_IT_IDLE: specifies the interrupt source for IDLE line detected pending interrupt.
- (##) SPI_IT_TXE: specifies the interrupt source for the Transmit data register empty pending interrupt.
- (##) SPI_IT_RXNE: specifies the interrupt source for the Data Register not empty pending interrupt.
- -@@- These parameters are coded in order to use them as interrupt
- source or as pending bits.
- [..] In this mode it is advised to use the following functions:
- (+) void SPI_ITConfig(SC_IT_TypeDef* SCx_IT, uint32_t SPI_IT, FunctionalState NewState).
- (+) ITStatus SPI_GetITStatus(SC_IT_TypeDef* SCx_IT, uint32_t SPI_IT).
- (+) void SPI_ClearITPendingBit(SC_IT_TypeDef* SCx_IT, uint32_t SPI_IT).
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Deinitializes the SCx_SPI peripheral registers to their default reset values.
- * @param SCx_SPI: where x can be 1 or 2 to select the Serial controller peripheral.
- * @retval None
- */
-void SPI_DeInit(SC_SPI_TypeDef* SCx_SPI)
-{
- /* Check the parameters */
- assert_param(IS_SPI_PERIPH(SCx_SPI));
-
- SCx_SPI->CR = 0;
- SCx_SPI->SPICR = 0;
- SCx_SPI->CRR1 = 0;
- SCx_SPI->CRR2 = 0;
-}
-
-/**
- * @brief Initializes the SCx_SPI peripheral according to the specified
- * parameters in the SPI_InitStruct.
- * @param SCx_SPI: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param SPI_InitStruct: pointer to a SPI_InitTypeDef structure that
- * contains the configuration information for the specified SPI peripheral.
- * @retval None
- */
-void SPI_Init(SC_SPI_TypeDef* SCx_SPI, SPI_InitTypeDef* SPI_InitStruct)
-{
- uint32_t tmpreg = 0;
- uint8_t expvalue = 0, linvalue = 0, tmpexp = 0, tmplin = 0, idx = 0;
- uint32_t tempclockrate = 0, clockrate = 0, power = 0;
-
- /* Check the SPI parameters */
- assert_param(IS_SPI_PERIPH(SCx_SPI));
- assert_param(IS_SPI_MODE(SPI_InitStruct->SPI_Mode));
- assert_param(IS_SPI_CPOL(SPI_InitStruct->SPI_CPOL));
- assert_param(IS_SPI_CPHA(SPI_InitStruct->SPI_CPHA));
- assert_param(IS_SPI_CLOCK_RATE(SPI_InitStruct->SPI_ClockRate));
- assert_param(IS_SPI_FIRST_BIT(SPI_InitStruct->SPI_FirstBit));
-
- /* Get the SCx SPICR register value */
- tmpreg = SCx_SPI->SPICR;
-
- /* Clear Mode, LSBFirst, CPOL and CPHA bits */
- tmpreg &= SPICR_CLEAR_MASK;
- /*---------------------------- SCx_SPICR Configuration ---------------------*/
- /* Set MSTR bits according to SPI_Mode values */
- /* Set LSBFirst bit according to SPI_FirstBit value */
- /* Set CPOL bit according to SPI_CPOL value */
- /* Set CPHA bit according to SPI_CPHA value */
- tmpreg |= (uint32_t)((uint32_t)SPI_InitStruct->SPI_Mode | (uint32_t)SPI_InitStruct->SPI_CPOL |
- (uint32_t)SPI_InitStruct->SPI_CPHA | (uint32_t)SPI_InitStruct->SPI_FirstBit);
- /* Write to SCx SPICR register */
- SCx_SPI->SPICR = tmpreg;
-
- /*---------------------------- SCx_CRRx Configuration ----------------------*/
- for(linvalue = 0x00; linvalue < 16; linvalue++)
- {
- for(expvalue = 0x00; expvalue < 16; expvalue++)
- {
- power = 0x01;
- for (idx=1; idx <= expvalue; idx++)
- {
- power*=2;
- }
- tempclockrate = power * (uint32_t)(linvalue + 1);
-
- if (tempclockrate == ((uint32_t)((uint32_t)CLK_GetClocksFreq()/(uint32_t)(2*(SPI_InitStruct->SPI_ClockRate)))))
- {
- SCx_SPI->CRR1 = (uint32_t)linvalue;
- SCx_SPI->CRR2 = (uint32_t)expvalue;
- }
- else
- {
- /* Check the clock rate error and write to CRRx */
- if((ABS((int32_t)tempclockrate - (int32_t)(CLK_GetClocksFreq()/(2*(SPI_InitStruct->SPI_ClockRate))))) < (ABS((int32_t)clockrate - (int32_t)(CLK_GetClocksFreq()/(2*(SPI_InitStruct->SPI_ClockRate))))))
- {
- clockrate = tempclockrate;
- tmplin = linvalue;
- tmpexp = expvalue;
- }
- }
- }
- }
-
- SCx_SPI->CRR1 = (uint32_t)tmplin;
- SCx_SPI->CRR2 = (uint32_t)tmpexp;
-}
-
-/**
- * @brief Fills each SPI_InitStruct member with its default value.
- * @param SPI_InitStruct: pointer to a SPI_InitTypeDef structure which will be initialized.
- * @retval None
- */
-void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct)
-{
- /*--------------- Reset SPI init structure parameters values ---------------*/
- /* Initialize the SPI_Mode member */
- SPI_InitStruct->SPI_Mode = SPI_Mode_Slave;
- /* Initialize the SPI_CPOL member */
- SPI_InitStruct->SPI_CPOL = SPI_CPOL_Low;
- /* Initialize the SPI_CPHA member */
- SPI_InitStruct->SPI_CPHA = SPI_CPHA_1Edge;
- /* Initialize the SPI_ClockRate member */
- SPI_InitStruct->SPI_ClockRate = 3000000;
- /* Initialize the SPI_FirstBit member */
- SPI_InitStruct->SPI_FirstBit = SPI_FirstBit_MSB;
-}
-
-/**
- * @brief Configures the Receiver driven mode for the selected SCx_SPI (Master mode only).
- * @param SCx_SPI: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param SPI_ReceiverMode: specifies the Receiver driven mode to be configured.
- * This parameter can be one of the following values:
- * @arg SPI_ReceiverMode_TxDataReady: Initiate transactions when transmit data is available
- * @arg SPI_ReceiverMode_RxFIFOFree: Initiate transactions when receive buffer has space
- * @retval None
- */
-void SPI_ReceiverModeConfig(SC_SPI_TypeDef* SCx_SPI, uint32_t SPI_ReceiverMode)
-{
- /* Check the parameters */
- assert_param(IS_SPI_PERIPH(SCx_SPI));
- assert_param(IS_SPI_RECEIVER_DRIVEN_MODE(SPI_ReceiverMode));
-
- /* Clear RXMODE bit */
- SCx_SPI->SPICR &= (uint16_t)~((uint16_t)SC_SPICR_RXMODE);
-
- /* Set new RXMODE bit value */
- SCx_SPI->SPICR |= SPI_ReceiverMode;
-}
-
-/**
- * @brief Enables or disables the last byte repeat transmission feature
- * for the specified SCx_SPI peripheral (Slave mode only).
- * @param SCx_SPI: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param NewState: new state of the SCx_SPI peripheral.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void SPI_LastByteRepeatCmd(SC_SPI_TypeDef* SCx_SPI, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_SPI_PERIPH(SCx_SPI));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable the last byte repeat feature for the selected SPI by setting
- the RPTEN bit 0 in the SPICR register */
- SCx_SPI->SPICR |= SC_SPICR_RPTEN;
- }
- else
- {
- /* Disable the last byte repeat feature for the selected SPI by clearing
- the RPTEN bit in the SPICR register */
- SCx_SPI->SPICR &= (uint16_t)~((uint16_t)SC_SPICR_RPTEN);
- }
-}
-
-/**
- * @brief Enables or disables the specified SCx_SPI peripheral.
- * @param SCx_SPI: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param NewState: new state of the SCx_SPI peripheral.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void SPI_Cmd(SC_SPI_TypeDef* SCx_SPI, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_SPI_PERIPH(SCx_SPI));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable the selected SPI by setting the MODE bit 0 in the CR register */
- SCx_SPI->CR &= (uint16_t)~((uint16_t)SC_CR_MODE);
- SCx_SPI->CR |= SC_CR_MODE_1;
- }
- else
- {
- /* Disable the selected SPI by clearing the MODE bits in the CR register */
- SCx_SPI->CR &= (uint16_t)~((uint16_t)SC_CR_MODE);
- }
-}
-
-/**
- * @brief Enables or disables the specified SCx_SPI interrupts.
- * @param SCx_IT: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param SPI_IT: specifies the SCx_SPI interrupt source to be enabled or disabled.
- * This parameter can be one of the following values:
- * @arg SPI_IT_UND: Underrun interrupt mask
- * @arg SPI_IT_OVR: Overrun interrupt mask
- * @arg SPI_IT_IDLE: Idle line detected interrupt mask
- * @arg SPI_IT_TXE: Transmit data register empty interrupt mask
- * @arg SPI_IT_RXNE: Data Register not empty interrupt mask
- * @param NewState: new state of the specified SCx_SPI interrupt source.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void SPI_ITConfig(SC_IT_TypeDef* SCx_IT, uint32_t SPI_IT, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_I2C_SPI_DMA_IT_PERIPH(SCx_IT));
- assert_param(IS_SPI_IT(SPI_IT));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable the selected SPI interrupt */
- SCx_IT->IER |= SPI_IT;
- }
- else
- {
- /* Disable the selected SPI interrupt */
- SCx_IT->IER &= (uint16_t)~((uint16_t)SPI_IT);
- }
-}
-
-/**
- * @brief Trigger event configuration to handle the specified SCx_SPI interrupt.
- * @param SCx_IT: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param SPI_IT: specifies the SCx_SPI interrupt to be configured.
- * This parameter can be one of the following values:
- * @arg SPI_IT_IDLE: Idle line detected interrupt
- * @arg SPI_IT_TXE: Transmit data register empty interrupt
- * @arg SPI_IT_RXNE: Data Register not empty interrupt
- * @param TriggerEvent: Trigger event configuration of the specified SCx_SPI interrupt.
- * This parameter can be one of the following values:
- * @arg SC_TriggerEvent_Edge: The specified SCx_SPI interrupt will be generated on edge
- * @arg SC_TriggerEvent_Level: The specified SCx_SPI interrupt will be generated on level
- * @retval None
- */
-void SPI_TriggerEventConfig(SC_IT_TypeDef* SCx_IT, uint32_t SPI_IT, uint32_t TriggerEvent)
-{
- /* Check the parameters */
- assert_param(IS_I2C_SPI_DMA_IT_PERIPH(SCx_IT));
- assert_param(IS_SPI_TRIGGEREVENT_IT(SPI_IT));
- assert_param(IS_SC_TRIGGEREVENT(TriggerEvent));
-
- if (TriggerEvent != SC_TriggerEvent_Edge)
- {
- /* The SPI_IT interrupt will be handled on level */
- SCx_IT->ICR |= SPI_IT;
- }
- else
- {
- /* The SPI_IT interrupt will be handled on edge */
- SCx_IT->ICR &= (uint16_t)~((uint16_t)SPI_IT);
- }
-}
-
-/**
- * @brief Transmits a Data through the SCx_SPI peripheral.
- * @param SCx_SPI: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param Data: Data to be transmitted.
- * @retval None
- */
-void SPI_SendData(SC_SPI_TypeDef* SCx_SPI, uint8_t Data)
-{
- uint32_t scxbase = 0x00;
-
- /* Check the parameters */
- assert_param(IS_SPI_PERIPH(SCx_SPI));
-
- scxbase = (uint32_t)SCx_SPI;
-
- *(__IO uint32_t *) scxbase = Data;
-}
-
-/**
- * @brief Returns the most recent received data by the SCx_SPI peripheral.
- * @param SCx_SPI: where x can be 1 or 2 to select the Serial controller peripheral.
- * @retval The value of the received data.
- */
-uint8_t SPI_ReceiveData(SC_SPI_TypeDef* SCx_SPI)
-{
- uint32_t scxbase = 0x00;
-
- /* Check the parameters */
- assert_param(IS_SPI_PERIPH(SCx_SPI));
-
- scxbase = (uint32_t)SCx_SPI;
-
- return *(__IO uint32_t *) scxbase;
-}
-
-/**
- * @brief Checks whether the specified SCx_SPI flag is set or not.
- * @param SCx_SPI: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param SPI_FLAG: specifies the SCx_SPI flag to check.
- * This parameter can be one of the following values:
- * @arg SPI_FLAG_OVR: OverRun Error flag.
- * @arg SPI_FLAG_TXE: Transmit data register empty flag.
- * @arg SPI_FLAG_RXNE: Receive data register not empty flag.
- * @arg SPI_FLAG_IDLE: IDLE line flag.
- * @retval The new state of SPI_FLAG (SET or RESET).
- */
-FlagStatus SPI_GetFlagStatus(SC_SPI_TypeDef* SCx_SPI, uint32_t SPI_FLAG)
-{
- FlagStatus bitstatus = RESET;
-
- /* Check the parameters */
- assert_param(IS_SPI_PERIPH(SCx_SPI));
- assert_param(IS_SPI_GET_FLAG(SPI_FLAG));
-
- if ((SCx_SPI->SPISR & SPI_FLAG) != (uint32_t)RESET)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
-}
-
-/**
- * @brief Checks whether the specified SCx_SPI pending interrupt is set or not.
- * @param SCx_IT: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param SPI_IT: specifies the SCx_SPI pending interrupt to check.
- * This parameter can be one of the following values:
- * @arg SPI_IT_UND: Underrun interrupt pending
- * @arg SPI_IT_OVR: Overrun interrupt pending
- * @arg SPI_IT_IDLE: Idle line detected interrupt pending
- * @arg SPI_IT_TXE: Transmit data register empty interrupt pending
- * @arg SPI_IT_RXNE: Data Register not empty interrupt pending
- * @retval The new state of SPI_IT (SET or RESET).
- */
-ITStatus SPI_GetITStatus(SC_IT_TypeDef* SCx_IT, uint32_t SPI_IT)
-{
- ITStatus bitstatus = RESET;
- uint32_t enablestatus = 0;
-
- /* Check the parameters */
- assert_param(IS_I2C_SPI_DMA_IT_PERIPH(SCx_IT));
- assert_param(IS_SPI_IT(SPI_IT));
-
- enablestatus = (uint32_t)(SCx_IT->IER & SPI_IT);
- if (((SCx_IT->ISR & SPI_IT) != (uint32_t)RESET) && enablestatus)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
-}
-
-/**
- * @brief Clears the SCx_SPI interrupt pending bits.
- * @param SCx_IT: where x can be 1 to select the Serial controller peripheral.
- * @param SPI_IT: specifies the SCx_SPI pending interrupt to check.
- * This parameter can be one of the following values:
- * @arg SPI_IT_UND: Underrun interrupt pending
- * @arg SPI_IT_OVR: Overrun interrupt pending
- * @arg SPI_IT_IDLE: Idle line detected interrupt pending
- * @arg SPI_IT_TXE: Transmit data register empty interrupt pending
- * @arg SPI_IT_RXNE: Data Register not empty interrupt pending
- * @retval None
- */
-void SPI_ClearITPendingBit(SC_IT_TypeDef* SCx_IT, uint32_t SPI_IT)
-{
- /* Check the parameters */
- assert_param(IS_I2C_SPI_DMA_IT_PERIPH(SCx_IT));
- assert_param(IS_SPI_IT(SPI_IT));
-
- SCx_IT->ISR = SPI_IT;
-}
-
-/**
- * @}
- */
-
-/** @defgroup SC_Group3 Inter-Integrated Circuit communication
- * @brief inter-integrated circuit functions
- *
-@verbatim
- ===============================================================================
- ##### Inter-Integrated Circuit functions #####
- ===============================================================================
- [..] This section provides a set of functions allowing to handles the Inter-Integrated
- Circuit communication.
-
- (@) The SC1 and SC2 include an Inter-integrated circuit interface (I2C) master controller.
-
-*** Initialization and Configuration ***
- =======================================
-
- [..] The GPIO pins that can be assigned to I2C interface are listed in the following table:
- +------------------------------------------------------------------+
- |Parameter | Direction | GPIO configuration | SC1 pin | SC2 pin |
- |----------|-----------|--------------------|----------|-----------|
- | SDA | In/Out | Alternate Output | PB1 | PA1 |
- | | | (open drain) | | |
- |----------|-----------|-------------------------------------------|
- | SCL | In/Out | Alternate Output | PB2 | PA2 |
- | | | (open drain) | | |
- +------------------------------------------------------------------+
-
- [..] For the Inter-Integrated Circuit mode only the Baud Rate parameter can be configured:
-
- [..] The I2C_Init() function follows the I2C configuration procedure (this procedure
- is available in datasheet).
-
- [..] The generate START and STOP can be done respectively using I2C_GenerateSTART() and
- I2C_GenerateSTOP() functions.
-
- [..] The command for the ACK generation can be done I2C_AcknowledgeConfig() function.
-
-*** Data transfers ***
- =====================
- [..] To initiate a transmit segment, write the data to the SCx_DR data register,
- then set the BTE bit in the SCx_I2CCR1 register, and finally wait until
- the BTE bit is clear and the BTF bit in the SCx_I2CSR register, these steps
- can be done using I2C_SendData() function. Alternatively to initiate the reception
- set the BRE bit in the SCx_I2CCR1 register and keep waiting until the BRE bit
- is clear and the BTF bit in the SCx_I2CSR register is set then read the
- Rx buffered value, these steps can be done using I2C_ReceiveData() function.
-
- [..] The Master transmit address byte to select the slave device in transmitter
- or in receiver mode can be done using the I2C_Send7bitAddress() function
-
- *** Interrupts and flags management ***
- =======================================
- [..] This subsection provides also a set of functions allowing to configure the
- I2C Interrupts sources, Requests and check or clear the flags or pending bits status.
- The user should identify which mode will be used in his application to
- manage the communication: Polling mode, Interrupt mode.
-
- [..] In Polling Mode, the I2C communication can be managed by 4 flags:
- (#) I2C_FLAG_NACK: to indicate the status of the not acknowledge flag.
- (#) I2C_FLAG_BTF: to indicate the status of the byte transfer finished flag.
- (#) I2C_FLAG_BRF: to indicate the status of the byte receive finished flag.
- (#) I2C_FLAG_CMDFIN: to indicate the status of the command finished flag.
-
- [..] In this Mode it is advised to use the following functions:
- (+) FlagStatus I2C_GetFlagStatus(SC_I2C_TypeDef* SCx_I2C, uint32_t I2C_FLAG).
- [..] In this mode all the I2C flags are cleared by hardware.
-
- *** Interrupt Mode ***
- ======================
- [..] In Interrupt Mode, the I2C communication can be managed by 4 interrupt sources
- and 4 pending bits:
-
- [..] Interrupt Source:
- (#) I2C_IT_NACK: specifies the interrupt source for the not acknowledge interrupt.
- (#) I2C_IT_CMDFIN: specifies the interrupt source for the command finished interrupt.
- (#) I2C_IT_BTF: specifies the interrupt source for the byte transfer finished interrupt.
- (#) I2C_IT_BRF: specifies the interrupt source for the byte receive finished interrupt.
-
- [..] Pending Bits:
- (#) I2C_IT_NACK: to indicate the status of not acknowledge pending interrupt.
- (#) I2C_IT_CMDFIN: to indicate the status of command finished pending interrupt.
- (#) I2C_IT_BTF: to indicate the status of byte transfer finished pending interrupt.
- (#) I2C_IT_BRF: to indicate the status of byte receive finished pending interrupt.
-
- [..] In this Mode it is advised to use the following functions:
- (+) void I2C_ClearITPendingBit(SC_IT_TypeDef* SCx_IT, uint32_t I2C_IT).
- (+) ITStatus I2C_GetITStatus(SC_IT_TypeDef* SCx_IT, uint32_t I2C_IT).
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Deinitializes the SCx_I2C peripheral registers to their default reset values.
- * @param SCx_I2C: where x can be 1 or 2 to select the Serial controller peripheral.
- * @retval None
- */
-void I2C_DeInit(SC_I2C_TypeDef* SCx_I2C)
-{
- /* Check the parameters */
- assert_param(IS_I2C_PERIPH(SCx_I2C));
-
- SCx_I2C->CR = 0;
- SCx_I2C->I2CCR1 = 0;
- SCx_I2C->I2CCR2 = 0;
- SCx_I2C->CRR1 = 0;
- SCx_I2C->CRR2 = 0;
-}
-
-/**
- * @brief Initializes the SCx_I2C peripheral according to the specified
- * parameters in the I2C_InitStruct.
- * @param SCx_I2C: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param I2C_InitStruct: pointer to a I2C_InitTypeDef structure that
- * contains the configuration information for the specified SCx_I2C peripheral.
- * @retval None
- */
-void I2C_Init(SC_I2C_TypeDef* SCx_I2C, I2C_InitTypeDef* I2C_InitStruct)
-{
- uint8_t expvalue = 0, lin = 0, tmpexp = 0, tmplin = 0, idx = 0;
- uint32_t tempclockrate = 0, clockrate = 0, power = 0;
-
- /* Check the parameters */
- assert_param(IS_I2C_PERIPH(SCx_I2C));
- assert_param(IS_I2C_CLOCK_RATE(I2C_InitStruct->I2C_ClockRate));
-
- /*---------------------------- SCx_CRRx Configuration ----------------------*/
- /*---------------------------- SCx_CRRx Configuration ----------------------*/
- for(lin = 0x00; lin < 16; lin++)
- {
- for(expvalue = 0x00; expvalue < 16; expvalue++)
- {
- power = 0x01;
- for (idx=1; idx <= expvalue; idx++)
- {
- power*=2;
- }
- tempclockrate = power * (uint32_t)(lin + 1);
-
- if (tempclockrate == ((uint32_t)((uint32_t)CLK_GetClocksFreq()/(uint32_t)(2*(I2C_InitStruct->I2C_ClockRate)))))
- {
- SCx_I2C->CRR1 = (uint32_t)lin;
- SCx_I2C->CRR2 = (uint32_t)expvalue;
- }
- else
- {
- /* Check the clock rate error and write to CRRx */
- if((ABS((int32_t)tempclockrate - (int32_t)(CLK_GetClocksFreq()/(2*(I2C_InitStruct->I2C_ClockRate))))) < (ABS((int32_t)clockrate - (int32_t)(CLK_GetClocksFreq()/(2*(I2C_InitStruct->I2C_ClockRate))))))
- {
- clockrate = tempclockrate;
- tmplin = lin;
- tmpexp = expvalue;
- }
- }
- }
- }
-
- SCx_I2C->CRR1 = (uint32_t)tmplin;
- SCx_I2C->CRR2 = (uint32_t)tmpexp;
-}
-
-/**
- * @brief Fills each I2C_InitStruct member with its default value.
- * @param I2C_InitStruct: pointer to a I2C_InitTypeDef structure which will be initialized.
- * @retval None
- */
-void I2C_StructInit(I2C_InitTypeDef* I2C_InitStruct)
-{
- /*--------------- Reset I2C init structure parameters values ---------------*/
-
- /* Initialize the I2C_ClockRate member */
- I2C_InitStruct->I2C_ClockRate = 400000;
-}
-
-/**
- * @brief Generates SCx_I2C communication START condition.
- * @param SCx_I2C: where x can be 1 or 2 to select the Serial controller peripheral.
- * @retval None
- */
-void I2C_GenerateSTART(SC_I2C_TypeDef* SCx_I2C)
-{
- /* Check the parameters */
- assert_param(IS_I2C_PERIPH(SCx_I2C));
-
- /* Generate a START condition */
- SCx_I2C->I2CCR1 |= SC_I2CCR1_START;
-}
-
-/**
- * @brief Generates SCx_I2C communication STOP condition.
- * @param SCx_I2C: where x can be 1 or 2 to select the Serial controller peripheral.
- * @retval None
- */
-void I2C_GenerateSTOP(SC_I2C_TypeDef* SCx_I2C)
-{
- /* Check the parameters */
- assert_param(IS_I2C_PERIPH(SCx_I2C));
-
- /* Generate a STOP condition */
- SCx_I2C->I2CCR1 |= SC_I2CCR1_STOP;
-}
-
-/**
- * @brief Generates SCx_I2C communication Acknowledge.
- * @param SCx_I2C: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param NewState: new state of the Acknowledge.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void I2C_AcknowledgeConfig(SC_I2C_TypeDef* SCx_I2C, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_I2C_PERIPH(SCx_I2C));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable ACK generation */
- SCx_I2C->I2CCR2 |= SC_I2CCR2_ACK;
- }
- else
- {
- /* Enable NACK generation */
- SCx_I2C->I2CCR2 &= (uint32_t)~((uint32_t)SC_I2CCR2_ACK);
- }
-}
-
-/**
- * @brief Transmits the address byte to select the slave device.
- * @param SCx_I2C: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param Address: specifies the slave address which will be transmitted
- * @param I2C_Direction: specifies whether the SCx_I2C device will be a
- * Transmitter or a Receiver. This parameter can be one of the following values
- * @arg I2C_Direction_Transmitter: Transmitter mode
- * @arg I2C_Direction_Receiver: Receiver mode
- * @retval None.
- */
-void I2C_Send7bitAddress(SC_I2C_TypeDef* SCx_I2C, uint8_t Address, uint8_t I2C_Direction)
-{
- uint32_t scxbase = 0x00;
- /* Check the parameters */
- assert_param(IS_I2C_PERIPH(SCx_I2C));
- assert_param(IS_I2C_DIRECTION(I2C_Direction));
- /* Test on the direction to set/reset the read/write bit */
- if (I2C_Direction != I2C_Direction_Transmitter)
- {
- /* Set the address bit0 for read */
- Address |= OAR1_ADD0_Set;
- }
- else
- {
- /* Reset the address bit0 for write */
- Address &= OAR1_ADD0_Reset;
- }
-
- scxbase = (uint32_t)SCx_I2C;
- /* Send the address */
- *(__IO uint32_t *) scxbase = Address;
-
- /* Enable the byte Send */
- SCx_I2C->I2CCR1 |= SC_I2CCR1_BTE;
-
- while ((SCx_I2C->I2CCR1 & SC_I2CCR1_BTE) != 0x00)
- {}
-}
-
-/**
- * @brief Transmits a Data through the SCx_I2C peripheral.
- * @param SCx_I2C: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param Data: Data to be transmitted.
- * @retval None
- */
-void I2C_SendData(SC_I2C_TypeDef* SCx_I2C, uint8_t Data)
-{
- uint32_t scxbase = 0x00;
-
- /* Check the parameters */
- assert_param(IS_I2C_PERIPH(SCx_I2C));
-
- scxbase = (uint32_t)SCx_I2C;
-
- *(__IO uint32_t *) scxbase = Data;
-
- /* Enable the byte Send */
- SCx_I2C->I2CCR1 |= SC_I2CCR1_BTE;
-
- while ((SCx_I2C->I2CCR1 & SC_I2CCR1_BTE) != 0x00)
- {}
- while ((SCx_I2C->I2CSR & SC_I2CSR_BTF) == 0x00)
- {}
-}
-
-/**
- * @brief Returns the most recent received data by the SCx_I2C peripheral.
- * @param SCx_I2C: where x can be 1 or 2 to select the Serial controller peripheral.
- * @retval The value of the received data.
- */
-uint8_t I2C_ReceiveData(SC_I2C_TypeDef* SCx_I2C)
-{
- uint32_t scxbase = 0x00;
-
- /* Check the parameters */
- assert_param(IS_I2C_PERIPH(SCx_I2C));
-
- scxbase = (uint32_t)SCx_I2C;
-
- /* Enable the byte Receive */
- SCx_I2C->I2CCR1 |= SC_I2CCR1_BRE;
-
- while ((SCx_I2C->I2CCR1 & SC_I2CCR1_BRE) != 0x00)
- {}
- while ((SCx_I2C->I2CSR & SC_I2CSR_BRF) == 0x00)
- {}
-
- return *(__IO uint32_t *) scxbase;
-}
-
-/**
- * @brief Enables or disables the specified SCx_I2C peripheral.
- * @param SCx_I2C: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param NewState: new state of the SCx_I2C peripheral.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void I2C_Cmd(SC_I2C_TypeDef* SCx_I2C, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_I2C_PERIPH(SCx_I2C));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable the selected I2C by setting the MODE bits in the CR register */
- SCx_I2C->CR |= SC_CR_MODE;
- }
- else
- {
- /* Disable the selected I2C by clearing the MODE bits in the CR register */
- SCx_I2C->CR &= (uint16_t)~((uint16_t)SC_CR_MODE);
- }
-}
-
-/**
- * @brief Enables or disables the specified SCx_I2C interrupts.
- * @param SCx_IT: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param I2C_IT: specifies the SCx_I2C interrupt source to be enabled or disabled.
- * This parameter can be one of the following values:
- * @arg I2C_IT_NACK: Not acknowledge interrupt mask
- * @arg I2C_IT_CMDFIN: Command finished interrupt mask
- * @arg I2C_IT_BTF: Byte transfer finished interrupt mask
- * @arg I2C_IT_BRF: Byte receive finished interrupt mask
- * @param NewState: new state of the specified SCx_I2C interrupt source.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void I2C_ITConfig(SC_IT_TypeDef* SCx_IT, uint32_t I2C_IT, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_I2C_SPI_DMA_IT_PERIPH(SCx_IT));
- assert_param(IS_I2C_IT(I2C_IT));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable the selected I2C interrupt */
- SCx_IT->IER |= I2C_IT;
- }
- else
- {
- /* Disable the selected I2C interrupt */
- SCx_IT->IER &= (uint16_t)~((uint16_t)I2C_IT);
- }
-}
-
-/**
- * @brief Checks whether the specified I2C flag is set or not.
- * @param SCx_I2C: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param I2C_FLAG: specifies the SCx_I2C flag to check.
- * This parameter can be one of the following values:
- * @arg I2C_FLAG_NACK: Not acknowledge flag
- * @arg I2C_FLAG_BTF: Byte transfer finished flag
- * @arg I2C_FLAG_BRF: Byte receive finished flag
- * @arg I2C_FLAG_CMDFIN: Command finished flag
- * @retval The new state of I2C_FLAG (SET or RESET).
- */
-FlagStatus I2C_GetFlagStatus(SC_I2C_TypeDef* SCx_I2C, uint32_t I2C_FLAG)
-{
- FlagStatus bitstatus = RESET;
-
- /* Check the parameters */
- assert_param(IS_I2C_PERIPH(SCx_I2C));
- assert_param(IS_I2C_GET_FLAG(I2C_FLAG));
-
- if ((SCx_I2C->I2CSR & I2C_FLAG) != (uint32_t)RESET)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
-}
-
-/**
- * @brief Checks whether the specified SCx_I2C pending interrupt is set or not.
- * @param SCx_IT: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param I2C_IT: specifies the SCx_I2C interrupt pending to check.
- * This parameter can be one of the following values:
- * @arg I2C_IT_NACK: Not acknowledge interrupt pending
- * @arg I2C_IT_CMDFIN: Command finished interrupt pending
- * @arg I2C_IT_BTF: Byte transfer finished interrupt pending
- * @arg I2C_IT_BRF: Byte receive finished interrupt pending
- * @retval The new state of I2C_IT (SET or RESET).
- */
-ITStatus I2C_GetITStatus(SC_IT_TypeDef* SCx_IT, uint32_t I2C_IT)
-{
- ITStatus bitstatus = RESET;
- uint32_t enablestatus = 0;
-
- /* Check the parameters */
- assert_param(IS_I2C_SPI_DMA_IT_PERIPH(SCx_IT));
- assert_param(IS_I2C_IT(I2C_IT));
-
- enablestatus = (uint32_t)(SCx_IT->IER & I2C_IT);
- if (((SCx_IT->ISR & I2C_IT) != (uint32_t)RESET) && enablestatus)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
-}
-
-/**
- * @brief Clears the SCx_I2C interrupt pending bits.
- * @param SCx_IT: where x can be 1 to select the Serial controller peripheral.
- * @param I2C_IT: specifies the SCx_I2C interrupt pending to check.
- * This parameter can be one of the following values:
- * @arg I2C_IT_NACK: Not acknowledge interrupt pending
- * @arg I2C_IT_CMDFIN: Command finished interrupt pending
- * @arg I2C_IT_BTF: Byte transfer finished interrupt pending
- * @arg I2C_IT_BRF: Byte receive finished interrupt pending
- * @retval None
- */
-void I2C_ClearITPendingBit(SC_IT_TypeDef* SCx_IT, uint32_t I2C_IT)
-{
- /* Check the parameters */
- assert_param(IS_I2C_SPI_DMA_IT_PERIPH(SCx_IT));
- assert_param(IS_I2C_IT(I2C_IT));
-
- SCx_IT->ISR = I2C_IT;
-}
-
-/**
- * @}
- */
-
-/** @defgroup SC_Group4 DMA transfers management
- * @brief DMA transfers management functions
- *
-@verbatim
- ===============================================================================
- ##### DMA transfers management functions #####
- ===============================================================================
- [..] This section provides a set of functions that can be used only in DMA mode.
-
- (@) The SC1 and SC2 include a DMA controller that can be used to manage the UART
- and SPI communications.
-
-*** Initialization and Configuration ***
- =======================================
- [..] For the DMA mode these parameters can be configured:
- (+) Begin address buffer A.
- (+) End address buffer A.
- (+) Begin address buffer B.
- (+) End address buffer B.
-
- [..] The DMA_Init() function follows the DMA configuration procedure.
-
-*** Data transfers ***
- =====================
- [..] In DMA Mode, the UART and SPI communications can be managed by 4 DMA Channel
- requests:
- (#) DMA_ChannelLoad_BTx: specifies the DMA transmit channel buffer B transfer request.
- (#) DMA_ChannelLoad_ATx: specifies the DMA transmit channel buffer A transfer request.
- (#) DMA_ChannelLoad_BRx: specifies the DMA receive channel buffer B transfer request.
- (#) DMA_ChannelLoad_ARx: specifies the DMA receive channel buffer A transfer request.
- [..] In this Mode it is advised to use the following function to load and enables the specified DMA channel:
- (+) void SC_DMA_ChannelLoadEnable(SC_DMA_TypeDef* SCx_DMA, uint32_t Channelxy).
-
-*** Interrupts and flags management ***
- =======================================
- [..] This subsection provides also a set of functions allowing to configure the
- DMA Interrupts sources, Requests and check or clear the flags or pending bits status.
- The user should identify which mode will be used in his application to
- manage the communication: Polling mode, Interrupt mode.
-
- [..] In Polling Mode, the DMA communication can be managed by 4 flags:
- (#) DMA_FLAG_RXAACK: to indicate the status of the DMA receive buffer A acknowledge flag.
- (#) DMA_FLAG_RXBACK: to indicate the status of the DMA receive buffer B acknowledge flag.
- (#) DMA_FLAG_TXAACK: to indicate the status of the DMA transmit buffer A acknowledge flag.
- (#) DMA_FLAG_TXBACK: to indicate the status of the DMA transmit buffer B acknowledge flag.
- (#) DMA_FLAG_OVRA: to indicate the status of the DMA buffer B overrun flag.
- (#) DMA_FLAG_OVRB: to indicate the status of the DMA buffer B overrun flag.
- (#) DMA_FLAG_PEA: to indicate the status of the DMA Parity error A flag.
- (#) DMA_FLAG_PEB: to indicate the status of the DMA Parity error B flag.
- (#) DMA_FLAG_FEA: to indicate the status of the DMA Frame error A flag.
- (#) DMA_FLAG_FEB: to indicate the status of the DMA Frame error B flag.
- (#) DMA_FLAG_NSSS: to indicate the status of the status of the receive count flag.
- [..] In this Mode it is advised to use the following functions:
- (+) FlagStatus SC_DMA_GetFlagStatus(SC_DMA_TypeDef* SCx_DMA, uint32_t DMA_FLAG).
- [..] In this mode all the DMA flags are cleared by hardware.
-
- *** Interrupt Mode ***
- ======================
- [..] In Interrupt Mode, the DMA communication can be managed by 4 interrupt sources
- and 4 pending bits:
-
- [..] Interrupt Source:
- (#) DMA_IT_TXULODB: specifies the interrupt source for the transmit buffer B unloaded interrupt.
- (#) DMA_IT_TXULODA: specifies the interrupt source for the transmit buffer A unloaded interrupt.
- (#) DMA_IT_RXULODB: specifies the interrupt source for the receive buffer B unloaded interrupt.
- (#) DMA_IT_RXULODA: specifies the interrupt source for the receive buffer A unloaded interrupt.
-
- [..] Pending Bits:
- (#) DMA_IT_TXULODB: to indicate the status of transmit buffer B unloaded pending interrupt.
- (#) DMA_IT_TXULODA: to indicate the status of transmit buffer A unloaded pending interrupt.
- (#) DMA_IT_RXULODB: to indicate the status of receive buffer B unloaded pending interrupt.
- (#) DMA_IT_RXULODA: to indicate the status of receive buffer A unloaded pending interrupt.
-
- [..] In this Mode it is advised to use the following functions:
- (+) ITStatus SC_DMA_GetITStatus(SC_IT_TypeDef* SCx_IT, uint32_t DMA_IT).
- (+) SC_DMA_ClearITPendingBit(SC_IT_TypeDef* SCx_IT, uint32_t DMA_IT).
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Reset the specified SCx_DMA Channely buffer addresses.
- * @param SCx_DMA: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param Channely: specifies the SCx_DMA channel to be enabled.
- * This parameter can be one of the following values:
- * @arg DMA_ChannelReset_Tx: DMA reset transmit channels mask
- * @arg DMA_ChannelReset_Rx: DMA reset receive channels mask
- * @retval None
- */
-void SC_DMA_ChannelReset(SC_DMA_TypeDef* SCx_DMA, uint32_t Channely)
-{
- /* Check the parameters */
- assert_param(IS_DMA_PERIPH(SCx_DMA));
- assert_param(IS_DMA_CHANNEL_RESET(Channely));
-
- /* Reset the selected SCx_DMA Channelx */
- SCx_DMA->DMACR |= Channely;
-}
-
-/**
- * @brief Initializes the SCx_DMA Channely according to the specified
- * parameters in the DMA_InitStruct.
- * @param SCx_DMA_Channely: where x can be 1 or 2 to select the SCx_DMA and
- * y can be Tx or Rx to select the SCx_DMA Channel.
- * @param SC_DMA_InitStruct: pointer to a DMA_InitTypeDef structure that
- * contains the configuration information for the specified DMA Channel.
- * @retval None
- */
-void SC_DMA_Init(SC_DMA_Channel_TypeDef* SCx_DMA_Channely, SC_DMA_InitTypeDef* SC_DMA_InitStruct)
-{
- /* Check the parameters */
- assert_param(IS_DMA_CHANNEL_PERIPH(SCx_DMA_Channely));
- assert_param(IS_DMA_VALID_ADDRESS(SC_DMA_InitStruct->DMA_BeginAddrA));
- assert_param(IS_DMA_VALID_ADDRESS(SC_DMA_InitStruct->DMA_EndAddrA));
- assert_param(IS_DMA_VALID_ADDRESS(SC_DMA_InitStruct->DMA_BeginAddrB));
- assert_param(IS_DMA_VALID_ADDRESS(SC_DMA_InitStruct->DMA_EndAddrB));
-
-/*---------------------- SCx_DMA Channely DMABEGADDAR Configuration ----------*/
- /* Write to SCx_DMA Channely Begin address A register */
- SCx_DMA_Channely->DMABEGADDAR = SC_DMA_InitStruct->DMA_BeginAddrA;
-
- /*---------------------- SCx_DMA Channely DMAENDADDAR Configuration --------*/
- /* Write to SCx_DMA Channely end address A register */
- SCx_DMA_Channely->DMAENDADDAR = SC_DMA_InitStruct->DMA_EndAddrA;
-
- /*---------------------- SCx_DMA Channely DMABEGADDBR Configuration --------*/
- /* Write to SCx_DMA Channely Begin address B register */
- SCx_DMA_Channely->DMABEGADDBR = SC_DMA_InitStruct->DMA_BeginAddrB;
-
- /*---------------------- SCx_DMA Channely DMAENDADDBR Configuration --------*/
- /* Write to SCx_DMA Channely end address B register */
- SCx_DMA_Channely->DMAENDADDBR = SC_DMA_InitStruct->DMA_EndAddrB;
-}
-
-/**
- * @brief Fills each DMA_InitStruct member with its default value.
- * @param SC_DMA_InitStruct: pointer to a DMA_InitTypeDef structure which will be initialized.
- * @retval None
- */
-void SC_DMA_StructInit(SC_DMA_InitTypeDef* SC_DMA_InitStruct)
-{
- /*--------------- Reset DMA init structure parameters values ---------------*/
- /* Initialize the SCx_DMA_Channely begin address A member */
- SC_DMA_InitStruct->DMA_BeginAddrA = 0x20000000;
- /* Initialize the SCx_DMA_Channely end address A member */
- SC_DMA_InitStruct->DMA_EndAddrA = 0x20000000;
- /* Initialize the SCx_DMA_Channely begin address B member */
- SC_DMA_InitStruct->DMA_BeginAddrB = 0x20000000;
- /* Initialize the SCx_DMA_Channely end address B member */
- SC_DMA_InitStruct->DMA_EndAddrB = 0x20000000;
-}
-
-/**
- * @brief Enables or disables the specified SCx_DMA interrupts.
- * @param SCx_IT: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param DMA_IT: specifies the SCx_DMA interrupt source to be enabled or disabled.
- * This parameter can be one of the following values:
- * @arg DMA_IT_TXULODB: DMA transmit buffer B unloaded interrupt mask
- * @arg DMA_IT_TXULODA: DMA transmit buffer A unloaded interrupt mask
- * @arg DMA_IT_RXULODB: DMA receive buffer B unloaded interrupt mask
- * @arg DMA_IT_RXULODA: DMA receive buffer A unloaded interrupt mask
- * @param NewState: new state of the specified SCx_DMA interrupt source.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void SC_DMA_ITConfig(SC_IT_TypeDef* SCx_IT, uint32_t DMA_IT, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_I2C_SPI_DMA_IT_PERIPH(SCx_IT));
- assert_param(IS_DMA_IT(DMA_IT));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable the selected DMA interrupt */
- SCx_IT->IER |= DMA_IT;
- }
- else
- {
- /* Disable the selected DMA interrupt */
- SCx_IT->IER &= (uint16_t)~((uint16_t)DMA_IT);
- }
-}
-
-/**
- * @brief Load and Enables the specified SCx_DMA Channelxy buffers addresses.
- * @param SCx_DMA: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param Channelxy: specifies the SCx_DMA channel to be enabled.
- * This parameter can be one of the following values:
- * @arg DMA_ChannelLoad_BTx: DMA transmit channel buffer B mask
- * @arg DMA_ChannelLoad_ATx: DMA transmit channel buffer A mask
- * @arg DMA_ChannelLoad_BRx: DMA receive channel buffer B mask
- * @arg DMA_ChannelLoad_ARx: DMA receive channel buffer A mask
- * @retval None
- */
-void SC_DMA_ChannelLoadEnable(SC_DMA_TypeDef* SCx_DMA, uint32_t Channelxy)
-{
- /* Check the parameters */
- assert_param(IS_DMA_PERIPH(SCx_DMA));
- assert_param(IS_DMA_CHANNEL_LOAD(Channelxy));
-
- /* Load the selected SCx_DMA Channelxy buffer addresses and allow the DMA controller
- to start processing */
- SCx_DMA->DMACR |= Channelxy;
-}
-
-/**
- * @brief Returns the most recent value for the specific SCx_DMA counter register.
- * @param SCx_DMA: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param Counter: specifies the SCx_DMA counter register to be read.
- * This parameter can be one of the following values:
- * @arg DMA_Counter_RXCNTA: DMA receive counter A register
- * @arg DMA_Counter_RXCNTB: DMA receive counter B register
- * @arg DMA_Counter_TXCNT: DMA transmit counter register
- * @arg DMA_Counter_RXCNTSAVED: DMA receive counter saved register
- * @retval The DMA register counter value.
- */
-uint32_t SC_DMA_GetCounter(SC_DMA_TypeDef* SCx_DMA, uint32_t Counter)
-{
- uint32_t scxbase = 0x00;
-
- /* Check the parameters */
- assert_param(IS_DMA_PERIPH(SCx_DMA));
- assert_param(IS_DMA_COUNTER(Counter));
-
- scxbase = (uint32_t)SCx_DMA;
- scxbase += Counter;
-
- return *(__IO uint32_t *) scxbase;
-}
-
-/**
- * @brief Returns the specified SCx_DMA receive error register.
- * @param SCx_DMA: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param RegisterError: specifies the SCx_DMA receiver error register to be read.
- * This parameter can be one of the following values:
- * @arg DMA_ReceiverError_CNTA: DMA receive error register A
- * @arg DMA_ReceiverError_CNTB: DMA receive error register B
- * @retval The DMA receive error register value.
- */
-uint32_t SC_DMA_GetReceiverErrorOffset(SC_DMA_TypeDef* SCx_DMA, uint32_t RegisterError)
-{
- uint32_t scxbase = 0x00;
-
- /* Check the parameters */
- assert_param(IS_DMA_PERIPH(SCx_DMA));
- assert_param(IS_DMA_RECEIVER_ERROR(RegisterError));
-
- scxbase = (uint32_t)SCx_DMA;
- scxbase += RegisterError;
-
- return *(__IO uint32_t *) scxbase;
-}
-
-/**
- * @brief Checks whether the specified DMA flag is set or not.
- * @param SCx_DMA: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param DMA_FLAG: specifies the SCx_DMA flag to check.
- * This parameter can be one of the following values:
- * @arg DMA_FLAG_RXAACK: DMA receive buffer A acknowledge flag
- * @arg DMA_FLAG_RXBACK: DMA receive buffer B acknowledge flag
- * @arg DMA_FLAG_TXAACK: DMA transmit buffer A acknowledge flag
- * @arg DMA_FLAG_TXBACK: DMA transmit buffer B acknowledge flag
- * @arg DMA_FLAG_OVRA: DMA buffer B overrun flag
- * @arg DMA_FLAG_OVRB: DMA buffer B overrun flag
- * @arg DMA_FLAG_PEA: DMA Parity error A flag
- * @arg DMA_FLAG_PEB: DMA Parity error B flag
- * @arg DMA_FLAG_FEA: DMA Frame error A flag
- * @arg DMA_FLAG_FEB: DMA Frame error B flag
- * @arg DMA_FLAG_NSSS: DMA Status of the receive count flag
- * @retval The new state of DMA_FLAG (SET or RESET).
- */
-FlagStatus SC_DMA_GetFlagStatus(SC_DMA_TypeDef* SCx_DMA, uint32_t DMA_FLAG)
-{
- FlagStatus bitstatus = RESET;
-
- /* Check the parameters */
- assert_param(IS_DMA_PERIPH(SCx_DMA));
- assert_param(IS_DMA_FLAG(DMA_FLAG));
-
- if ((SCx_DMA->DMASR & DMA_FLAG) != (uint32_t)RESET)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
-}
-
-/**
- * @brief Checks whether the specified SCx_DMA pending interrupt is set or not.
- * @param SCx_IT: where x can be 1 or 2 to select the Serial controller peripheral.
- * @param DMA_IT: specifies the SCx_DMA interrupt pending to check.
- * This parameter can be one of the following values:
- * @arg DMA_IT_TXULODB: DMA transmit buffer B unloaded interrupt pending
- * @arg DMA_IT_TXULODA: DMA transmit buffer A unloaded interrupt pending
- * @arg DMA_IT_RXULODB: DMA receive buffer B unloaded interrupt pending
- * @arg DMA_IT_RXULODA: DMA receive buffer A unloaded interrupt pending
- * @retval The new state of DMA_IT (SET or RESET).
- */
-ITStatus SC_DMA_GetITStatus(SC_IT_TypeDef* SCx_IT, uint32_t DMA_IT)
-{
- ITStatus bitstatus = RESET;
- uint32_t enablestatus = 0;
-
- /* Check the parameters */
- assert_param(IS_I2C_SPI_DMA_IT_PERIPH(SCx_IT));
- assert_param(IS_DMA_IT(DMA_IT));
-
- enablestatus = (uint32_t)(SCx_IT->IER & DMA_IT);
- if (((SCx_IT->ISR & DMA_IT) != (uint32_t)RESET) && enablestatus)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
-}
-
-/**
- * @brief Clears the SCx_DMA interrupt pending bits.
- * @param SCx_IT: where x can be 1 to select the Serial controller peripheral.
- * @param DMA_IT: specifies the SCx_DMA interrupt pending to check.
- * This parameter can be one of the following values:
- * @arg DMA_IT_TXULODB: DMA transmit buffer B unloaded interrupt pending
- * @arg DMA_IT_TXULODA: DMA transmit buffer A unloaded interrupt pending
- * @arg DMA_IT_RXULODB: DMA receive buffer B unloaded interrupt pending
- * @arg DMA_IT_RXULODA: DMA receive buffer A unloaded interrupt pending
- * @retval None
- */
-void SC_DMA_ClearITPendingBit(SC_IT_TypeDef* SCx_IT, uint32_t DMA_IT)
-{
- /* Check the parameters */
- assert_param(IS_I2C_SPI_DMA_IT_PERIPH(SCx_IT));
- assert_param(IS_DMA_IT(DMA_IT));
-
- SCx_IT->ISR = DMA_IT;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_slptim.c b/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_slptim.c
deleted file mode 100644
index 299a062..0000000
--- a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_slptim.c
+++ /dev/null
@@ -1,445 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32w108xx_slptim.c
- * @author MCD Application Team
- * @version V1.0.1
- * @date 30-November-2012
- * @brief This file provides firmware functions to manage the Sleep Timer
- * peripheral.
- *
- * @verbatim
- *
- ===============================================================================
- ##### SLPTIM features #####
- ===============================================================================
- [..] The sleep timer is dedicated to system timing and waking from sleep at
- specific times.
- [..] The sleep timer can use either the calibrated 1 kHz reference(CLK1K),
- or the 32 kHz crystal clock (CLK32K). The default clock source is
- the internal 1 kHz clock.
- [..] The sleep timer has a prescaler that allows for very long periods of
- sleep to be timed.
- [..] The timer provides two compare outputs and wrap detection, all of which
- can be used to generate an interrupt or a wake up event.
- [..] The sleep timer is paused when the debugger halts the ARM Cortex-M3.
-
-
- ##### How to use this driver #####
- ===============================================================================
- [..] This driver provides functions to configure and program the Sleep Timer
- These functions are split in 2 groups:
- (#) SLPTIM management functions: this group includes all needed functions
- to configure the Sleep Timer.
- (++) Enable/Disable the counter.
- (++) Get counter.
- (++) Select clock to be used as reference.
- (++) Set/Get compare (A or B) values.
- (#) Interrupts and flags management functions: this group includes all needed
- functions to manage interrupts:
- (++) Enables or disables the specified SLPTIM interrupts.
- (++) Checks whether the specified SLPTIM flag is set or not.
- (++) Clears the specified SLPTIM flag.
-
- @endverbatim
- *
- ******************************************************************************
- * @attention
- *
- *
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32w108xx_tim.h"
-
-/** @addtogroup STM32W108xx_StdPeriph_Driver
- * @{
- */
-/** @defgroup TIM
- * @brief TIM driver modules
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-
-/* ---------------------- TIM registers bit mask ------------------------ */
-#define SMCR_ETR_MASK ((uint32_t)0x00FF)
-#define CCMR_OFFSET ((uint32_t)0x0018)
-#define CCER_CCE_SET ((uint32_t)0x0001)
-#define TIM_ClockMask_Disable ((uint32_t)0x0000)
-#define TIM_ClockMask_Enable ((uint32_t)0x0004)
-
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-
-static void TI1_Config(TIM_TypeDef* TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
- uint32_t TIM_ICFilter);
-static void TI2_Config(TIM_TypeDef* TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
- uint32_t TIM_ICFilter);
-static void TI3_Config(TIM_TypeDef* TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
- uint32_t TIM_ICFilter);
-static void TI4_Config(TIM_TypeDef* TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
- uint32_t TIM_ICFilter);
-/* Private functions ---------------------------------------------------------*/
-
-/** @defgroup TIM_Private_Functions
- * @{
- */
-
-/** @defgroup TIM_Group1 TimeBase management functions
- * @brief TimeBase management functions
- *
- @verbatim
- ===============================================================================
- ##### TimeBase management functions #####
- ===============================================================================
- *** TIM Driver: how to use it in Timing(Time base) Mode ***
- ===============================================================================
- [..] To use the Timer in Timing(Time base) mode, the following steps are
- mandatory:
- (#) Fill the TIM_TimeBaseInitStruct with the desired parameters.
- (#) Call TIM_TimeBaseInit(TIMx, &TIM_TimeBaseInitStruct) to configure
- the Time Base unit with the corresponding configuration.
- (#) Enable the NVIC if you need to generate the update interrupt.
- (#) Enable the corresponding interrupt using the function
- TIM_ITConfig(TIMx, TIM_IT_Update).
- (#) Call the TIM_Cmd(ENABLE) function to enable the TIM counter.
- [..]
- (@) All other functions can be used seperatly to modify, if needed,
- a specific feature of the Timer.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Deinitializes the TIMx peripheral registers to their default reset values.
- * @param TIMx: where x can be 1 and 2 to select the TIM peripheral.
- * @retval None
- *
- */
-void TIM_DeInit(TIM_TypeDef* TIMx)
-{
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
-
- TIMx->CR1 = 0x00000000;
- TIMx->CR2 = 0x00000000;
- TIMx->SMCR = 0x00000000;
- TIMx->EGR = 0x00000000;
- TIMx->CCMR2 = 0x00000000;
- TIMx->CCER = 0x00000000;
- TIMx->CNT = 0x00000000;
- TIMx->PSC = 0x00000000;
- TIMx->ARR = 0x0000FFFF;
- TIMx->CCMR1 = 0x00000000;
- TIMx->CCR3 = 0x00000000;
- TIMx->CCR4 = 0x00000000;
- TIMx->CCR1 = 0x00000000;
- TIMx->CCR2 = 0x00000000;
- TIMx->OR = 0x00000000;
-
- if (TIMx == TIM1)
- {
- TIM1_IT->IER = 0x00000000;
- TIM1_IT->ISR |= 0x0000005F;
- TIM1_IT->IMR |= 0x00001E00;
- }
- else
- {
- if (TIMx == TIM2)
- {
- TIM2_IT->IER = 0x00000000;
- TIM2_IT->ISR |= 0x0000005F;
- TIM2_IT->IMR |= 0x00001E00;
- }
- }
-}
-
-/**
- * @brief Initializes the TIMx Time Base Unit peripheral according to
- * the specified parameters in the TIM_TimeBaseInitStruct.
- * @param TIMx: where x can be 1 and 2 to select the TIM
- * peripheral.
- * @param TIM_TimeBaseInitStruct: pointer to a TIM_TimeBaseInitTypeDef
- * structure that contains the configuration information for
- * the specified TIM peripheral.
- * @retval None
- */
-void TIM_TimeBaseInit(TIM_TypeDef* TIMx, TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct)
-{
- uint32_t tmpcr1 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_COUNTER_MODE(TIM_TimeBaseInitStruct->TIM_CounterMode));
-
- tmpcr1 = TIMx->CR1;
-
- /* Select the Counter Mode */
- tmpcr1 &= (uint32_t)(~((uint32_t)(TIM_CR1_DIR | TIM_CR1_CMS)));
- tmpcr1 |= (uint32_t)TIM_TimeBaseInitStruct->TIM_CounterMode;
-
-
-
- TIMx->CR1 = tmpcr1;
-
- /* Set the Autoreload value */
- TIMx->ARR = TIM_TimeBaseInitStruct->TIM_Period ;
-
- /* Set the Prescaler value */
- TIMx->PSC = TIM_TimeBaseInitStruct->TIM_Prescaler;
-
- /* Generate an update event to reload the Prescaler and the Repetition counter
- values immediately */
- TIMx->EGR = TIM_PSCReloadMode_Immediate;
-}
-
-/**
- * @brief Fills each TIM_TimeBaseInitStruct member with its default value.
- * @param TIM_TimeBaseInitStruct : pointer to a TIM_TimeBaseInitTypeDef
- * structure which will be initialized.
- * @retval None
- */
-void TIM_TimeBaseStructInit(TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct)
-{
- /* Set the default configuration */
- TIM_TimeBaseInitStruct->TIM_Period = 0xFFFF;
- TIM_TimeBaseInitStruct->TIM_Prescaler = 0x0000;
- TIM_TimeBaseInitStruct->TIM_CounterMode = TIM_CounterMode_Up;
-}
-
-/**
- * @brief Configures the TIMx Prescaler.
- * @param TIMx: where x can be 1 and 2 to select the TIM peripheral.
- * @param Prescaler: specifies the Prescaler Register value
- * @param TIM_PSCReloadMode: specifies the TIM Prescaler Reload mode
- * This parameter can be one of the following values:
- * @arg TIM_PSCReloadMode_Update: The Prescaler is loaded at the update event.
- * @arg TIM_PSCReloadMode_Immediate: The Prescaler is loaded immediatly.
- * @retval None
- */
-void TIM_PrescalerConfig(TIM_TypeDef* TIMx, uint32_t Prescaler, uint32_t TIM_PSCReloadMode)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_PRESCALER_RELOAD(TIM_PSCReloadMode));
-
- /* Set the Prescaler value */
- TIMx->PSC = Prescaler;
- /* Set or reset the UG Bit */
- TIMx->EGR = TIM_PSCReloadMode;
-}
-
-/**
- * @brief Specifies the TIMx Counter Mode to be used.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_CounterMode: specifies the Counter Mode to be used
- * This parameter can be one of the following values:
- * @arg TIM_CounterMode_Up: TIM Up Counting Mode
- * @arg TIM_CounterMode_Down: TIM Down Counting Mode
- * @arg TIM_CounterMode_CenterAligned1: TIM Center Aligned Mode1
- * @arg TIM_CounterMode_CenterAligned2: TIM Center Aligned Mode2
- * @arg TIM_CounterMode_CenterAligned3: TIM Center Aligned Mode3
- * @retval None
- */
-void TIM_CounterModeConfig(TIM_TypeDef* TIMx, uint32_t TIM_CounterMode)
-{
- uint32_t tmpcr1 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_COUNTER_MODE(TIM_CounterMode));
-
- tmpcr1 = TIMx->CR1;
- /* Reset the CMS and DIR Bits */
- tmpcr1 &= (uint32_t)(~((uint32_t)(TIM_CR1_DIR | TIM_CR1_CMS)));
- /* Set the Counter Mode */
- tmpcr1 |= TIM_CounterMode;
- /* Write to TIMx CR1 register */
- TIMx->CR1 = tmpcr1;
-}
-
-/**
- * @brief Sets the TIMx Counter Register value
- * @param TIMx: where x can be 1 and 2 to select the TIM
- * peripheral.
- * @param Counter: specifies the Counter register new value.
- * @retval None
- */
-void TIM_SetCounter(TIM_TypeDef* TIMx, uint32_t Counter)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
-
- /* Set the Counter Register value */
- TIMx->CNT = Counter;
-}
-
-/**
- * @brief Sets the TIMx Autoreload Register value
- * @param TIMx: where x can be 1 and 2 to select the TIM peripheral.
- * @param Autoreload: specifies the Autoreload register new value.
- * @retval None
- */
-void TIM_SetAutoreload(TIM_TypeDef* TIMx, uint32_t Autoreload)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
-
- /* Set the Autoreload Register value */
- TIMx->ARR = Autoreload;
-}
-
-/**
- * @brief Gets the TIMx Counter value.
- * @param TIMx: where x can be 1 and 2 to select the TIM
- * peripheral.
- * @retval Counter Register value.
- */
-uint32_t TIM_GetCounter(TIM_TypeDef* TIMx)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
-
- /* Get the Counter Register value */
- return TIMx->CNT;
-}
-
-/**
- * @brief Gets the TIMx Prescaler value.
- * @param TIMx: where x can be 1 and 2 to select the TIM
- * peripheral.
- * @retval Prescaler Register value.
- */
-uint32_t TIM_GetPrescaler(TIM_TypeDef* TIMx)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
-
- /* Get the Prescaler Register value */
- return TIMx->PSC;
-}
-
-/**
- * @brief Enables or Disables the TIMx Update event.
- * @param TIMx: where x can be 1 and 2 to select the TIM
- * peripheral.
- * @param NewState: new state of the TIMx UDIS bit
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void TIM_UpdateDisableConfig(TIM_TypeDef* TIMx, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Set the Update Disable Bit */
- TIMx->CR1 |= TIM_CR1_UDIS;
- }
- else
- {
- /* Reset the Update Disable Bit */
- TIMx->CR1 &= (uint32_t)~((uint32_t)TIM_CR1_UDIS);
- }
-}
-
-/**
- * @brief Configures the TIMx Update Request Interrupt source.
- * @param TIMx: where x can be 1 and 2 to select the TIM
- * peripheral.
- * @param TIM_UpdateSource: specifies the Update source.
- * This parameter can be one of the following values:
- * @arg TIM_UpdateSource_Regular: Source of update is the counter overflow/underflow
- or the setting of UG bit, or an update generation
- through the slave mode controller.
- * @arg TIM_UpdateSource_Global: Source of update is counter overflow/underflow.
- * @retval None
- */
-void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint32_t TIM_UpdateSource)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));
-
- if (TIM_UpdateSource != TIM_UpdateSource_Global)
- {
- /* Set the URS Bit */
- TIMx->CR1 |= TIM_CR1_URS;
- }
- else
- {
- /* Reset the URS Bit */
- TIMx->CR1 &= (uint32_t)~((uint32_t)TIM_CR1_URS);
- }
-}
-
-/**
- * @brief Enables or disables TIMx peripheral Preload register on ARR.
- * @param TIMx: where x can be 1 and 2 to select the TIM
- * peripheral.
- * @param NewState: new state of the TIMx peripheral Preload register
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void TIM_ARRPreloadConfig(TIM_TypeDef* TIMx, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Set the ARR Preload Bit */
- TIMx->CR1 |= TIM_CR1_ARPE;
- }
- else
- {
- /* Reset the ARR Preload Bit */
- TIMx->CR1 &= (uint32_t)~((uint32_t)TIM_CR1_ARPE);
- }
-}
-
-/**
- * @brief Selects the TIMx's One Pulse Mode.
- * @param TIMx: where x can be 1 and 2 to select the TIM
- * peripheral.
- * @param TIM_OPMode: specifies the OPM Mode to be used.
- * This parameter can be one of the following values:
- * @arg TIM_OPMode_Single
- * @arg TIM_OPMode_Repetitive
- * @retval None
- */
-void TIM_SelectOnePulseMode(TIM_TypeDef* TIMx, uint32_t TIM_OPMode)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OPM_MODE(TIM_OPMode));
-
- /* Reset the OPM Bit */
- TIMx->CR1 &= (uint32_t)~((uint32_t)TIM_CR1_OPM);
- /* Configure the OPM Mode */
- TIMx->CR1 |= TIM_OPMode;
-}
-
-
-/**
- * @brief Enables or disables the specified TIM peripheral.
- * @param TIMx: where x can be 1 and 2 and 17to select the TIMx
- * peripheral.
- * @param NewState: new state of the TIMx peripheral.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void TIM_Cmd(TIM_TypeDef* TIMx, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable the TIM Counter */
- TIMx->CR1 |= TIM_CR1_CEN;
- }
- else
- {
- /* Disable the TIM Counter */
- TIMx->CR1 &= (uint32_t)(~((uint32_t)TIM_CR1_CEN));
- }
-}
-
-/**
- * @}
- */
-
-/** @defgroup TIM_Group2 Output Compare management functions
- * @brief Output Compare management functions
- *
-@verbatim
- ===============================================================================
- ##### Output Compare management functions #####
- ===============================================================================
- *** TIM Driver: how to use it in Output Compare Mode ***
- ===============================================================================
- [..] To use the Timer in Output Compare mode, the following steps are mandatory:
- (#) Configure the TIM pins by configuring the corresponding GPIO pins
- (#) Configure the Time base unit as described in the first part of this
- driver, if needed, else the Timer will run with the default
- configuration:
- (++) Autoreload value = 0xFFFF.
- (++) Prescaler value = 0x0000.
- (++) Counter mode = Up counting.
- (#) Fill the TIM_OCInitStruct with the desired parameters including:
- (++) The TIM Output Compare mode: TIM_OCMode.
- (++) TIM Output State: TIM_OutputState.
- (++) TIM Pulse value: TIM_Pulse.
- (++) TIM Output Compare Polarity : TIM_OCPolarity.
- (#) Call TIM_OCxInit(TIMx, &TIM_OCInitStruct) to configure the desired
- channel with the corresponding configuration.
- (#) Call the TIM_Cmd(ENABLE) function to enable the TIM counter.
- [..]
- (@) All other functions can be used separately to modify, if needed,
- a specific feature of the Timer.
- (@) In case of PWM mode, this function is mandatory:
- TIM_OCxPreloadConfig(TIMx, TIM_OCPreload_ENABLE).
- (@) If the corresponding interrupt are needed, the user should:
- (#@) Enable the NVIC to use the TIM interrupts.
- (#@) Enable the corresponding interrupt using the function
- TIM_ITConfig(TIMx, TIM_IT_CCx).
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Initializes the TIMx Channel1 according to the specified
- * parameters in the TIM_OCInitStruct.
- * @param TIMx: where x can be 1 and 2 to select the TIM peripheral.
- * @param TIM_OCInitStruct: pointer to a TIM_OCInitTypeDef structure
- * that contains the configuration information for the specified TIM
- * peripheral.
- * @retval None
- */
-void TIM_OC1Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct)
-{
- uint32_t tmpccmrx = 0, tmpccer = 0, tmpcr2 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OC_MODE(TIM_OCInitStruct->TIM_OCMode));
- assert_param(IS_TIM_OUTPUT_STATE(TIM_OCInitStruct->TIM_OutputState));
- assert_param(IS_TIM_OC_POLARITY(TIM_OCInitStruct->TIM_OCPolarity));
- /* Disable the Channel 1: Reset the CC1E Bit */
- TIMx->CCER &= (uint32_t)(~(uint32_t)TIM_CCER_CC1E);
- /* Get the TIMx CCER register value */
- tmpccer = TIMx->CCER;
- /* Get the TIMx CR2 register value */
- tmpcr2 = TIMx->CR2;
-
- /* Get the TIMx CCMR1 register value */
- tmpccmrx = TIMx->CCMR1;
-
- /* Reset the Output Compare Mode Bits */
- tmpccmrx &= (uint32_t)(~((uint32_t)TIM_CCMR1_OC1M));
- tmpccmrx &= (uint32_t)(~((uint32_t)TIM_CCMR1_CC1S));
-
- /* Select the Output Compare Mode */
- tmpccmrx |= TIM_OCInitStruct->TIM_OCMode;
-
- /* Reset the Output Polarity level */
- tmpccer &= (uint32_t)(~((uint32_t)TIM_CCER_CC1P));
- /* Set the Output Compare Polarity */
- tmpccer |= TIM_OCInitStruct->TIM_OCPolarity;
-
- /* Set the Output State */
- tmpccer |= TIM_OCInitStruct->TIM_OutputState;
-
- /* Write to TIMx CR2 */
- TIMx->CR2 = tmpcr2;
-
- /* Write to TIMx CCMR1 */
- TIMx->CCMR1 = tmpccmrx;
-
- /* Set the Capture Compare Register value */
- TIMx->CCR1 = TIM_OCInitStruct->TIM_Pulse;
-
- /* Write to TIMx CCER */
- TIMx->CCER = tmpccer;
-}
-
-/**
- * @brief Initializes the TIMx Channel2 according to the specified
- * parameters in the TIM_OCInitStruct.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCInitStruct: pointer to a TIM_OCInitTypeDef structure
- * that contains the configuration information for the specified TIM
- * peripheral.
- * @retval None
- */
-void TIM_OC2Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct)
-{
- uint32_t tmpccmrx = 0, tmpccer = 0, tmpcr2 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OC_MODE(TIM_OCInitStruct->TIM_OCMode));
- assert_param(IS_TIM_OUTPUT_STATE(TIM_OCInitStruct->TIM_OutputState));
- assert_param(IS_TIM_OC_POLARITY(TIM_OCInitStruct->TIM_OCPolarity));
- /* Disable the Channel 2: Reset the CC2E Bit */
- TIMx->CCER &= (uint32_t)(~((uint32_t)TIM_CCER_CC2E));
-
- /* Get the TIMx CCER register value */
- tmpccer = TIMx->CCER;
- /* Get the TIMx CR2 register value */
- tmpcr2 = TIMx->CR2;
-
- /* Get the TIMx CCMR1 register value */
- tmpccmrx = TIMx->CCMR1;
-
- /* Reset the Output Compare mode and Capture/Compare selection Bits */
- tmpccmrx &= (uint32_t)(~((uint32_t)TIM_CCMR1_OC2M));
- tmpccmrx &= (uint32_t)(~((uint32_t)TIM_CCMR1_CC2S));
-
- /* Select the Output Compare Mode */
- tmpccmrx |= (uint32_t)(TIM_OCInitStruct->TIM_OCMode << 8);
-
- /* Reset the Output Polarity level */
- tmpccer &= (uint32_t)(~((uint32_t)TIM_CCER_CC2P));
- /* Set the Output Compare Polarity */
- tmpccer |= (uint32_t)(TIM_OCInitStruct->TIM_OCPolarity << 4);
-
- /* Set the Output State */
- tmpccer |= (uint32_t)(TIM_OCInitStruct->TIM_OutputState << 4);
-
- /* Write to TIMx CR2 */
- TIMx->CR2 = tmpcr2;
-
- /* Write to TIMx CCMR1 */
- TIMx->CCMR1 = tmpccmrx;
-
- /* Set the Capture Compare Register value */
- TIMx->CCR2 = TIM_OCInitStruct->TIM_Pulse;
-
- /* Write to TIMx CCER */
- TIMx->CCER = tmpccer;
-}
-
-/**
- * @brief Initializes the TIMx Channel3 according to the specified
- * parameters in the TIM_OCInitStruct.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCInitStruct: pointer to a TIM_OCInitTypeDef structure
- * that contains the configuration information for the specified TIM
- * peripheral.
- * @retval None
- */
-void TIM_OC3Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct)
-{
- uint32_t tmpccmrx = 0, tmpccer = 0, tmpcr2 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OC_MODE(TIM_OCInitStruct->TIM_OCMode));
- assert_param(IS_TIM_OUTPUT_STATE(TIM_OCInitStruct->TIM_OutputState));
- assert_param(IS_TIM_OC_POLARITY(TIM_OCInitStruct->TIM_OCPolarity));
- /* Disable the Channel 2: Reset the CC2E Bit */
- TIMx->CCER &= (uint32_t)(~((uint32_t)TIM_CCER_CC3E));
-
- /* Get the TIMx CCER register value */
- tmpccer = TIMx->CCER;
- /* Get the TIMx CR2 register value */
- tmpcr2 = TIMx->CR2;
-
- /* Get the TIMx CCMR2 register value */
- tmpccmrx = TIMx->CCMR2;
-
- /* Reset the Output Compare mode and Capture/Compare selection Bits */
- tmpccmrx &= (uint32_t)(~((uint32_t)TIM_CCMR2_OC3M));
- tmpccmrx &= (uint32_t)(~((uint32_t)TIM_CCMR2_CC3S));
- /* Select the Output Compare Mode */
- tmpccmrx |= TIM_OCInitStruct->TIM_OCMode;
-
- /* Reset the Output Polarity level */
- tmpccer &= (uint32_t)(~((uint32_t)TIM_CCER_CC3P));
- /* Set the Output Compare Polarity */
- tmpccer |= (uint32_t)(TIM_OCInitStruct->TIM_OCPolarity << 8);
-
- /* Set the Output State */
- tmpccer |= (uint32_t)(TIM_OCInitStruct->TIM_OutputState << 8);
-
- /* Write to TIMx CR2 */
- TIMx->CR2 = tmpcr2;
-
- /* Write to TIMx CCMR2 */
- TIMx->CCMR2 = tmpccmrx;
-
- /* Set the Capture Compare Register value */
- TIMx->CCR3 = TIM_OCInitStruct->TIM_Pulse;
-
- /* Write to TIMx CCER */
- TIMx->CCER = tmpccer;
-}
-
-/**
- * @brief Initializes the TIMx Channel4 according to the specified
- * parameters in the TIM_OCInitStruct.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCInitStruct: pointer to a TIM_OCInitTypeDef structure
- * that contains the configuration information for the specified TIM
- * peripheral.
- * @retval None
- */
-void TIM_OC4Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct)
-{
- uint32_t tmpccmrx = 0, tmpccer = 0, tmpcr2 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OC_MODE(TIM_OCInitStruct->TIM_OCMode));
- assert_param(IS_TIM_OUTPUT_STATE(TIM_OCInitStruct->TIM_OutputState));
- assert_param(IS_TIM_OC_POLARITY(TIM_OCInitStruct->TIM_OCPolarity));
- /* Disable the Channel 2: Reset the CC4E Bit */
- TIMx->CCER &= (uint32_t)(~((uint32_t)TIM_CCER_CC4E));
-
- /* Get the TIMx CCER register value */
- tmpccer = TIMx->CCER;
- /* Get the TIMx CR2 register value */
- tmpcr2 = TIMx->CR2;
-
- /* Get the TIMx CCMR2 register value */
- tmpccmrx = TIMx->CCMR2;
-
- /* Reset the Output Compare mode and Capture/Compare selection Bits */
- tmpccmrx &= (uint32_t)(~((uint32_t)TIM_CCMR2_OC4M));
- tmpccmrx &= (uint32_t)(~((uint32_t)TIM_CCMR2_CC4S));
-
- /* Select the Output Compare Mode */
- tmpccmrx |= (uint32_t)(TIM_OCInitStruct->TIM_OCMode << 8);
-
- /* Reset the Output Polarity level */
- tmpccer &= (uint32_t)(~((uint32_t)TIM_CCER_CC4P));
- /* Set the Output Compare Polarity */
- tmpccer |= (uint32_t)(TIM_OCInitStruct->TIM_OCPolarity << 12);
-
- /* Set the Output State */
- tmpccer |= (uint32_t)(TIM_OCInitStruct->TIM_OutputState << 12);
-
- /* Write to TIMx CR2 */
- TIMx->CR2 = tmpcr2;
-
- /* Write to TIMx CCMR2 */
- TIMx->CCMR2 = tmpccmrx;
-
- /* Set the Capture Compare Register value */
- TIMx->CCR4 = TIM_OCInitStruct->TIM_Pulse;
-
- /* Write to TIMx CCER */
- TIMx->CCER = tmpccer;
-}
-
-/**
- * @brief Fills each TIM_OCInitStruct member with its default value.
- * @param TIM_OCInitStruct : pointer to a TIM_OCInitTypeDef structure which will
- * be initialized.
- * @retval None
- */
-void TIM_OCStructInit(TIM_OCInitTypeDef* TIM_OCInitStruct)
-{
- /* Set the default configuration */
- TIM_OCInitStruct->TIM_OCMode = TIM_OCMode_Timing;
- TIM_OCInitStruct->TIM_OutputState = TIM_OutputState_Disable;
- TIM_OCInitStruct->TIM_Pulse = 0x0000000;
- TIM_OCInitStruct->TIM_OCPolarity = TIM_OCPolarity_High;
-}
-
-/**
- * @brief Selects the TIM Output Compare Mode.
- * @note This function disables the selected channel before changing the Output
- * Compare Mode.
- * User has to enable this channel using TIM_CCxCmd and TIM_CCxNCmd functions.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_Channel: specifies the TIM Channel
- * This parameter can be one of the following values:
- * @arg TIM_Channel_1: TIM Channel 1
- * @arg TIM_Channel_2: TIM Channel 2
- * @arg TIM_Channel_3: TIM Channel 3
- * @arg TIM_Channel_4: TIM Channel 4
- * @param TIM_OCMode: specifies the TIM Output Compare Mode.
- * This parameter can be one of the following values:
- * @arg TIM_OCMode_Timing
- * @arg TIM_OCMode_Active
- * @arg TIM_OCMode_Toggle
- * @arg TIM_OCMode_PWM1
- * @arg TIM_OCMode_PWM2
- * @arg TIM_ForcedAction_Active
- * @arg TIM_ForcedAction_InActive
- * @retval None
- */
-void TIM_SelectOCxM(TIM_TypeDef* TIMx, uint32_t TIM_Channel, uint32_t TIM_OCMode)
-{
- uint32_t tmp = 0;
- uint32_t tmp1 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OCM(TIM_OCMode));
-
- tmp = (uint32_t) TIMx;
- tmp += CCMR_OFFSET;
-
- tmp1 = CCER_CCE_SET << (uint32_t)TIM_Channel;
-
- /* Disable the Channel: Reset the CCxE Bit */
- TIMx->CCER &= (uint32_t) ~tmp1;
-
- if((TIM_Channel == TIM_Channel_1) ||(TIM_Channel == TIM_Channel_3))
- {
- tmp += (TIM_Channel>>1);
-
- /* Reset the OCxM bits in the CCMRx register */
- *(__IO uint32_t *) tmp &= (uint32_t)~((uint32_t)TIM_CCMR1_OC1M);
-
- /* Configure the OCxM bits in the CCMRx register */
- *(__IO uint32_t *) tmp |= TIM_OCMode;
- }
- else
- {
- tmp += (uint32_t)(TIM_Channel - (uint32_t)4)>> (uint32_t)1;
-
- /* Reset the OCxM bits in the CCMRx register */
- *(__IO uint32_t *) tmp &= (uint32_t)~((uint32_t)TIM_CCMR1_OC2M);
-
- /* Configure the OCxM bits in the CCMRx register */
- *(__IO uint32_t *) tmp |= (uint32_t)(TIM_OCMode << 8);
- }
-}
-
-/**
- * @brief Sets the TIMx Capture Compare1 Register value
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param Compare1: specifies the Capture Compare1 register new value.
- * @retval None
- */
-void TIM_SetCompare1(TIM_TypeDef* TIMx, uint32_t Compare1)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
-
- /* Set the Capture Compare1 Register value */
- TIMx->CCR1 = Compare1;
-}
-
-/**
- * @brief Sets the TIMx Capture Compare2 Register value
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param Compare2: specifies the Capture Compare2 register new value.
- * @retval None
- */
-void TIM_SetCompare2(TIM_TypeDef* TIMx, uint32_t Compare2)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
-
- /* Set the Capture Compare2 Register value */
- TIMx->CCR2 = Compare2;
-}
-
-/**
- * @brief Sets the TIMx Capture Compare3 Register value
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param Compare3: specifies the Capture Compare3 register new value.
- * @retval None
- */
-void TIM_SetCompare3(TIM_TypeDef* TIMx, uint32_t Compare3)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
-
- /* Set the Capture Compare3 Register value */
- TIMx->CCR3 = Compare3;
-}
-
-/**
- * @brief Sets the TIMx Capture Compare4 Register value
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param Compare4: specifies the Capture Compare4 register new value.
- * @retval None
- */
-void TIM_SetCompare4(TIM_TypeDef* TIMx, uint32_t Compare4)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
-
- /* Set the Capture Compare4 Register value */
- TIMx->CCR4 = Compare4;
-}
-
-/**
- * @brief Forces the TIMx output 1 waveform to active or inactive level.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ForcedAction: specifies the forced Action to be set to the output waveform.
- * This parameter can be one of the following values:
- * @arg TIM_ForcedAction_Active: Force active level on OC1REF
- * @arg TIM_ForcedAction_InActive: Force inactive level on OC1REF.
- * @retval None
- */
-void TIM_ForcedOC1Config(TIM_TypeDef* TIMx, uint32_t TIM_ForcedAction)
-{
- uint32_t tmpccmr1 = 0;
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
- tmpccmr1 = TIMx->CCMR1;
- /* Reset the OC1M Bits */
- tmpccmr1 &= (uint32_t)~((uint32_t)TIM_CCMR1_OC1M);
- /* Configure The Forced output Mode */
- tmpccmr1 |= TIM_ForcedAction;
- /* Write to TIMx CCMR1 register */
- TIMx->CCMR1 = tmpccmr1;
-}
-
-/**
- * @brief Forces the TIMx output 2 waveform to active or inactive level.
- * @param TIMx: where x can be 1 or 2 to select the TIM
- * peripheral.
- * @param TIM_ForcedAction: specifies the forced Action to be set to the output waveform.
- * This parameter can be one of the following values:
- * @arg TIM_ForcedAction_Active: Force active level on OC2REF
- * @arg TIM_ForcedAction_InActive: Force inactive level on OC2REF.
- * @retval None
- */
-void TIM_ForcedOC2Config(TIM_TypeDef* TIMx, uint32_t TIM_ForcedAction)
-{
- uint32_t tmpccmr1 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
-
- tmpccmr1 = TIMx->CCMR1;
- /* Reset the OC2M Bits */
- tmpccmr1 &= (uint32_t)~((uint32_t)TIM_CCMR1_OC2M);
- /* Configure The Forced output Mode */
- tmpccmr1 |= (uint32_t)(TIM_ForcedAction << 8);
- /* Write to TIMx CCMR1 register */
- TIMx->CCMR1 = tmpccmr1;
-}
-
-/**
- * @brief Forces the TIMx output 3 waveform to active or inactive level.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ForcedAction: specifies the forced Action to be set to the output waveform.
- * This parameter can be one of the following values:
- * @arg TIM_ForcedAction_Active: Force active level on OC3REF
- * @arg TIM_ForcedAction_InActive: Force inactive level on OC3REF.
- * @retval None
- */
-void TIM_ForcedOC3Config(TIM_TypeDef* TIMx, uint32_t TIM_ForcedAction)
-{
- uint32_t tmpccmr2 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
-
- tmpccmr2 = TIMx->CCMR2;
- /* Reset the OC1M Bits */
- tmpccmr2 &= (uint32_t)~((uint32_t)TIM_CCMR2_OC3M);
- /* Configure The Forced output Mode */
- tmpccmr2 |= TIM_ForcedAction;
- /* Write to TIMx CCMR2 register */
- TIMx->CCMR2 = tmpccmr2;
-}
-
-/**
- * @brief Forces the TIMx output 4 waveform to active or inactive level.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ForcedAction: specifies the forced Action to be set to the output waveform.
- * This parameter can be one of the following values:
- * @arg TIM_ForcedAction_Active: Force active level on OC4REF
- * @arg TIM_ForcedAction_InActive: Force inactive level on OC4REF.
- * @retval None
- */
-void TIM_ForcedOC4Config(TIM_TypeDef* TIMx, uint32_t TIM_ForcedAction)
-{
- uint32_t tmpccmr2 = 0;
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
-
- tmpccmr2 = TIMx->CCMR2;
- /* Reset the OC2M Bits */
- tmpccmr2 &= (uint32_t)~((uint32_t)TIM_CCMR2_OC4M);
- /* Configure The Forced output Mode */
- tmpccmr2 |= (uint32_t)(TIM_ForcedAction << 8);
- /* Write to TIMx CCMR2 register */
- TIMx->CCMR2 = tmpccmr2;
-}
-
-/**
- * @brief Enables or disables the TIMx peripheral Preload register on CCR1.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCPreload: new state of the TIMx peripheral Preload register
- * This parameter can be one of the following values:
- * @arg TIM_OCPreload_Enable
- * @arg TIM_OCPreload_Disable
- * @retval None
- */
-void TIM_OC1PreloadConfig(TIM_TypeDef* TIMx, uint32_t TIM_OCPreload)
-{
- uint32_t tmpccmr1 = 0;
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
-
- tmpccmr1 = TIMx->CCMR1;
- /* Reset the OC1PE Bit */
- tmpccmr1 &= (uint32_t)~((uint32_t)TIM_CCMR1_OC1PE);
- /* Enable or Disable the Output Compare Preload feature */
- tmpccmr1 |= TIM_OCPreload;
- /* Write to TIMx CCMR1 register */
- TIMx->CCMR1 = tmpccmr1;
-}
-
-/**
- * @brief Enables or disables the TIMx peripheral Preload register on CCR2.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCPreload: new state of the TIMx peripheral Preload register
- * This parameter can be one of the following values:
- * @arg TIM_OCPreload_Enable
- * @arg TIM_OCPreload_Disable
- * @retval None
- */
-void TIM_OC2PreloadConfig(TIM_TypeDef* TIMx, uint32_t TIM_OCPreload)
-{
- uint32_t tmpccmr1 = 0;
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
-
- tmpccmr1 = TIMx->CCMR1;
- /* Reset the OC2PE Bit */
- tmpccmr1 &= (uint32_t)~((uint32_t)TIM_CCMR1_OC2PE);
- /* Enable or Disable the Output Compare Preload feature */
- tmpccmr1 |= (uint32_t)(TIM_OCPreload << 8);
- /* Write to TIMx CCMR1 register */
- TIMx->CCMR1 = tmpccmr1;
-}
-
-/**
- * @brief Enables or disables the TIMx peripheral Preload register on CCR3.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCPreload: new state of the TIMx peripheral Preload register
- * This parameter can be one of the following values:
- * @arg TIM_OCPreload_Enable
- * @arg TIM_OCPreload_Disable
- * @retval None
- */
-void TIM_OC3PreloadConfig(TIM_TypeDef* TIMx, uint32_t TIM_OCPreload)
-{
- uint32_t tmpccmr2 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
-
- tmpccmr2 = TIMx->CCMR2;
- /* Reset the OC3PE Bit */
- tmpccmr2 &= (uint32_t)~((uint32_t)TIM_CCMR2_OC3PE);
- /* Enable or Disable the Output Compare Preload feature */
- tmpccmr2 |= TIM_OCPreload;
- /* Write to TIMx CCMR2 register */
- TIMx->CCMR2 = tmpccmr2;
-}
-
-/**
- * @brief Enables or disables the TIMx peripheral Preload register on CCR4.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCPreload: new state of the TIMx peripheral Preload register
- * This parameter can be one of the following values:
- * @arg TIM_OCPreload_Enable
- * @arg TIM_OCPreload_Disable
- * @retval None
- */
-void TIM_OC4PreloadConfig(TIM_TypeDef* TIMx, uint32_t TIM_OCPreload)
-{
- uint32_t tmpccmr2 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
-
- tmpccmr2 = TIMx->CCMR2;
- /* Reset the OC4PE Bit */
- tmpccmr2 &= (uint32_t)~((uint32_t)TIM_CCMR2_OC4PE);
- /* Enable or Disable the Output Compare Preload feature */
- tmpccmr2 |= (uint32_t)(TIM_OCPreload << 8);
- /* Write to TIMx CCMR2 register */
- TIMx->CCMR2 = tmpccmr2;
-}
-
-/**
- * @brief Configures the TIMx Output Compare 1 Fast feature.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCFast: new state of the Output Compare Fast Enable Bit.
- * This parameter can be one of the following values:
- * @arg TIM_OCFast_Enable: TIM output compare fast enable
- * @arg TIM_OCFast_Disable: TIM output compare fast disable
- * @retval None
- */
-void TIM_OC1FastConfig(TIM_TypeDef* TIMx, uint32_t TIM_OCFast)
-{
- uint32_t tmpccmr1 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
-
- /* Get the TIMx CCMR1 register value */
- tmpccmr1 = TIMx->CCMR1;
- /* Reset the OC1FE Bit */
- tmpccmr1 &= (uint32_t)~((uint32_t)TIM_CCMR1_OC1FE);
- /* Enable or Disable the Output Compare Fast Bit */
- tmpccmr1 |= TIM_OCFast;
- /* Write to TIMx CCMR1 */
- TIMx->CCMR1 = tmpccmr1;
-}
-
-/**
- * @brief Configures the TIMx Output Compare 2 Fast feature.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCFast: new state of the Output Compare Fast Enable Bit.
- * This parameter can be one of the following values:
- * @arg TIM_OCFast_Enable: TIM output compare fast enable
- * @arg TIM_OCFast_Disable: TIM output compare fast disable
- * @retval None
- */
-void TIM_OC2FastConfig(TIM_TypeDef* TIMx, uint32_t TIM_OCFast)
-{
- uint32_t tmpccmr1 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
-
- /* Get the TIMx CCMR1 register value */
- tmpccmr1 = TIMx->CCMR1;
- /* Reset the OC2FE Bit */
- tmpccmr1 &= (uint32_t)~((uint32_t)TIM_CCMR1_OC2FE);
- /* Enable or Disable the Output Compare Fast Bit */
- tmpccmr1 |= (uint32_t)(TIM_OCFast << 8);
- /* Write to TIMx CCMR1 */
- TIMx->CCMR1 = tmpccmr1;
-}
-
-/**
- * @brief Configures the TIMx Output Compare 3 Fast feature.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCFast: new state of the Output Compare Fast Enable Bit.
- * This parameter can be one of the following values:
- * @arg TIM_OCFast_Enable: TIM output compare fast enable
- * @arg TIM_OCFast_Disable: TIM output compare fast disable
- * @retval None
- */
-void TIM_OC3FastConfig(TIM_TypeDef* TIMx, uint32_t TIM_OCFast)
-{
- uint32_t tmpccmr2 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
-
- /* Get the TIMx CCMR2 register value */
- tmpccmr2 = TIMx->CCMR2;
- /* Reset the OC3FE Bit */
- tmpccmr2 &= (uint32_t)~((uint32_t)TIM_CCMR2_OC3FE);
- /* Enable or Disable the Output Compare Fast Bit */
- tmpccmr2 |= TIM_OCFast;
- /* Write to TIMx CCMR2 */
- TIMx->CCMR2 = tmpccmr2;
-}
-
-/**
- * @brief Configures the TIMx Output Compare 4 Fast feature.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCFast: new state of the Output Compare Fast Enable Bit.
- * This parameter can be one of the following values:
- * @arg TIM_OCFast_Enable: TIM output compare fast enable
- * @arg TIM_OCFast_Disable: TIM output compare fast disable
- * @retval None
- */
-void TIM_OC4FastConfig(TIM_TypeDef* TIMx, uint32_t TIM_OCFast)
-{
- uint32_t tmpccmr2 = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
-
- /* Get the TIMx CCMR2 register value */
- tmpccmr2 = TIMx->CCMR2;
- /* Reset the OC4FE Bit */
- tmpccmr2 &= (uint32_t)~((uint32_t)TIM_CCMR2_OC4FE);
- /* Enable or Disable the Output Compare Fast Bit */
- tmpccmr2 |= (uint32_t)(TIM_OCFast << 8);
- /* Write to TIMx CCMR2 */
- TIMx->CCMR2 = tmpccmr2;
-}
-
-/**
- * @brief Configures the TIMx channel 1 polarity.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCPolarity: specifies the OC1 Polarity
- * This parmeter can be one of the following values:
- * @arg TIM_OCPolarity_High: Output Compare active high
- * @arg TIM_OCPolarity_Low: Output Compare active low
- * @retval None
- */
-void TIM_OC1PolarityConfig(TIM_TypeDef* TIMx, uint32_t TIM_OCPolarity)
-{
- uint32_t tmpccer = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OC_POLARITY(TIM_OCPolarity));
-
- tmpccer = TIMx->CCER;
- /* Set or Reset the CC1P Bit */
- tmpccer &= (uint32_t)~((uint32_t)TIM_CCER_CC1P);
- tmpccer |= TIM_OCPolarity;
- /* Write to TIMx CCER register */
- TIMx->CCER = tmpccer;
-}
-
-/**
- * @brief Configures the TIMx channel 2 polarity.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCPolarity: specifies the OC2 Polarity
- * This parmeter can be one of the following values:
- * @arg TIM_OCPolarity_High: Output Compare active high
- * @arg TIM_OCPolarity_Low: Output Compare active low
- * @retval None
- */
-void TIM_OC2PolarityConfig(TIM_TypeDef* TIMx, uint32_t TIM_OCPolarity)
-{
- uint32_t tmpccer = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OC_POLARITY(TIM_OCPolarity));
-
- tmpccer = TIMx->CCER;
- /* Set or Reset the CC2P Bit */
- tmpccer &= (uint32_t)~((uint32_t)TIM_CCER_CC2P);
- tmpccer |= (uint32_t)(TIM_OCPolarity << 4);
- /* Write to TIMx CCER register */
- TIMx->CCER = tmpccer;
-}
-
-/**
- * @brief Configures the TIMx channel 3 polarity.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCPolarity: specifies the OC3 Polarity
- * This parmeter can be one of the following values:
- * @arg TIM_OCPolarity_High: Output Compare active high
- * @arg TIM_OCPolarity_Low: Output Compare active low
- * @retval None
- */
-void TIM_OC3PolarityConfig(TIM_TypeDef* TIMx, uint32_t TIM_OCPolarity)
-{
- uint32_t tmpccer = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OC_POLARITY(TIM_OCPolarity));
-
- tmpccer = TIMx->CCER;
- /* Set or Reset the CC3P Bit */
- tmpccer &= (uint32_t)~((uint32_t)TIM_CCER_CC3P);
- tmpccer |= (uint32_t)(TIM_OCPolarity << 8);
- /* Write to TIMx CCER register */
- TIMx->CCER = tmpccer;
-}
-
-/**
- * @brief Configures the TIMx channel 4 polarity.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_OCPolarity: specifies the OC4 Polarity
- * This parmeter can be one of the following values:
- * @arg TIM_OCPolarity_High: Output Compare active high
- * @arg TIM_OCPolarity_Low: Output Compare active low
- * @retval None
- */
-void TIM_OC4PolarityConfig(TIM_TypeDef* TIMx, uint32_t TIM_OCPolarity)
-{
- uint32_t tmpccer = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_OC_POLARITY(TIM_OCPolarity));
-
- tmpccer = TIMx->CCER;
- /* Set or Reset the CC4P Bit */
- tmpccer &= (uint32_t)~((uint32_t)TIM_CCER_CC4P);
- tmpccer |= (uint32_t)(TIM_OCPolarity << 12);
- /* Write to TIMx CCER register */
- TIMx->CCER = tmpccer;
-}
-
-/**
- * @brief Enables or disables the TIM Capture Compare Channel x.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_Channel: specifies the TIM Channel
- * This parameter can be one of the following values:
- * @arg TIM_Channel_1: TIM Channel 1
- * @arg TIM_Channel_2: TIM Channel 2
- * @arg TIM_Channel_3: TIM Channel 3
- * @arg TIM_Channel_4: TIM Channel 4
- * @param TIM_CCx: specifies the TIM Channel CCxE bit new state.
- * This parameter can be: TIM_CCx_Enable or TIM_CCx_Disable.
- * @retval None
- */
-void TIM_CCxCmd(TIM_TypeDef* TIMx, uint32_t TIM_Channel, uint32_t TIM_CCx)
-{
- uint32_t tmp = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_CCX(TIM_CCx));
-
- tmp = CCER_CCE_SET << TIM_Channel;
-
- /* Reset the CCxE Bit */
- TIMx->CCER &= (uint32_t)~ tmp;
-
- /* Set or reset the CCxE Bit */
- TIMx->CCER |= (uint32_t)(TIM_CCx << TIM_Channel);
-}
-
-/**
- * @}
- */
-
-/** @defgroup TIM_Group3 Input Capture management functions
- * @brief Input Capture management functions
- *
-@verbatim
- ===============================================================================
- ##### Input Capture management functions #####
- ===============================================================================
-
- *** TIM Driver: how to use it in Input Capture Mode ***
- ===============================================================================
- [..] To use the Timer in Input Capture mode, the following steps are mandatory:
- (#) Configure the TIM pins by configuring the corresponding GPIO pins.
- (#) Configure the Time base unit as described in the first part of this
- driver, if needed, else the Timer will run with the default configuration:
- (++) Autoreload value = 0xFFFF.
- (++) Prescaler value = 0x0000.
- (++) Counter mode = Up counting.
- (#) Fill the TIM_ICInitStruct with the desired parameters including:
- (++) TIM Channel: TIM_Channel.
- (++) TIM Input Capture polarity: TIM_ICPolarity.
- (++) TIM Input Capture selection: TIM_ICSelection.
- (++) TIM Input Capture Prescaler: TIM_ICPrescaler.
- (++) TIM Input CApture filter value: TIM_ICFilter.
- (#) Call TIM_ICInit(TIMx, &TIM_ICInitStruct) to configure the desired
- channel with the corresponding configuration and to measure only
- frequency or duty cycle of the input signal,or, Call
- TIM_PWMIConfig(TIMx, &TIM_ICInitStruct) to configure the desired
- channels with the corresponding configuration and to measure the
- frequency and the duty cycle of the input signal.
- (#) Enable the NVIC to read the measured frequency.
- (#) Enable the corresponding interrupt to read
- the Captured value, using the function TIM_ITConfig(TIMx, TIM_IT_CCx).
- (#) Call the TIM_Cmd(ENABLE) function to enable the TIM counter.
- (#) Use TIM_GetCapturex(TIMx); to read the captured value.
- [..]
- (@) All other functions can be used separately to modify, if needed,
- a specific feature of the Timer.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Initializes the TIM peripheral according to the specified
- * parameters in the TIM_ICInitStruct.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ICInitStruct: pointer to a TIM_ICInitTypeDef structure
- * that contains the configuration information for the specified TIM
- * peripheral.
- * @retval None
- */
-void TIM_ICInit(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_CHANNEL(TIM_ICInitStruct->TIM_Channel));
- assert_param(IS_TIM_IC_SELECTION(TIM_ICInitStruct->TIM_ICSelection));
- assert_param(IS_TIM_IC_PRESCALER(TIM_ICInitStruct->TIM_ICPrescaler));
- assert_param(IS_TIM_IC_FILTER(TIM_ICInitStruct->TIM_ICFilter));
- assert_param(IS_TIM_IC_POLARITY(TIM_ICInitStruct->TIM_ICPolarity));
-
- if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_1)
- {
- /* TI1 Configuration */
- TI1_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity,
- TIM_ICInitStruct->TIM_ICSelection,
- TIM_ICInitStruct->TIM_ICFilter);
- /* Set the Input Capture Prescaler value */
- TIM_SetIC1Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
- }
- else if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_2)
- {
- /* TI2 Configuration */
- TI2_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity,
- TIM_ICInitStruct->TIM_ICSelection,
- TIM_ICInitStruct->TIM_ICFilter);
- /* Set the Input Capture Prescaler value */
- TIM_SetIC2Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
- }
- else if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_3)
- {
- /* TI3 Configuration */
- TI3_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity,
- TIM_ICInitStruct->TIM_ICSelection,
- TIM_ICInitStruct->TIM_ICFilter);
- /* Set the Input Capture Prescaler value */
- TIM_SetIC3Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
- }
- else
- {
- /* TI4 Configuration */
- TI4_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity,
- TIM_ICInitStruct->TIM_ICSelection,
- TIM_ICInitStruct->TIM_ICFilter);
- /* Set the Input Capture Prescaler value */
- TIM_SetIC4Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
- }
-}
-
-/**
- * @brief Fills each TIM_ICInitStruct member with its default value.
- * @param TIM_ICInitStruct : pointer to a TIM_ICInitTypeDef structure which will
- * be initialized.
- * @retval None
- */
-void TIM_ICStructInit(TIM_ICInitTypeDef* TIM_ICInitStruct)
-{
- /* Set the default configuration */
- TIM_ICInitStruct->TIM_Channel = TIM_Channel_1;
- TIM_ICInitStruct->TIM_ICPolarity = TIM_ICPolarity_Rising;
- TIM_ICInitStruct->TIM_ICSelection = TIM_ICSelection_DirectTI;
- TIM_ICInitStruct->TIM_ICPrescaler = TIM_ICPSC_DIV1;
- TIM_ICInitStruct->TIM_ICFilter = 0x00;
-}
-
-/**
- * @brief Configures the TIM peripheral according to the specified
- * parameters in the TIM_ICInitStruct to measure an external PWM signal.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ICInitStruct: pointer to a TIM_ICInitTypeDef structure
- * that contains the configuration information for the specified TIM
- * peripheral.
- * @retval None
- */
-void TIM_PWMIConfig(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct)
-{
- uint32_t icoppositepolarity = TIM_ICPolarity_Rising;
- uint32_t icoppositeselection = TIM_ICSelection_DirectTI;
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- /* Select the Opposite Input Polarity */
- if (TIM_ICInitStruct->TIM_ICPolarity == TIM_ICPolarity_Rising)
- {
- icoppositepolarity = TIM_ICPolarity_Falling;
- }
- else
- {
- icoppositepolarity = TIM_ICPolarity_Rising;
- }
- /* Select the Opposite Input */
- if (TIM_ICInitStruct->TIM_ICSelection == TIM_ICSelection_DirectTI)
- {
- icoppositeselection = TIM_ICSelection_IndirectTI;
- }
- else
- {
- icoppositeselection = TIM_ICSelection_DirectTI;
- }
- if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_1)
- {
- /* TI1 Configuration */
- TI1_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity, TIM_ICInitStruct->TIM_ICSelection,
- TIM_ICInitStruct->TIM_ICFilter);
- /* Set the Input Capture Prescaler value */
- TIM_SetIC1Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
- /* TI2 Configuration */
- TI2_Config(TIMx, icoppositepolarity, icoppositeselection, TIM_ICInitStruct->TIM_ICFilter);
- /* Set the Input Capture Prescaler value */
- TIM_SetIC2Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
- }
- else
- {
- /* TI2 Configuration */
- TI2_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity, TIM_ICInitStruct->TIM_ICSelection,
- TIM_ICInitStruct->TIM_ICFilter);
- /* Set the Input Capture Prescaler value */
- TIM_SetIC2Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
- /* TI1 Configuration */
- TI1_Config(TIMx, icoppositepolarity, icoppositeselection, TIM_ICInitStruct->TIM_ICFilter);
- /* Set the Input Capture Prescaler value */
- TIM_SetIC1Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
- }
-}
-
-/**
- * @brief Gets the TIMx Input Capture 1 value.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @retval Capture Compare 1 Register value.
- */
-uint32_t TIM_GetCapture1(TIM_TypeDef* TIMx)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
-
- /* Get the Capture 1 Register value */
- return TIMx->CCR1;
-}
-
-/**
- * @brief Gets the TIMx Input Capture 2 value.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @retval Capture Compare 2 Register value.
- */
-uint32_t TIM_GetCapture2(TIM_TypeDef* TIMx)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
-
- /* Get the Capture 2 Register value */
- return TIMx->CCR2;
-}
-
-/**
- * @brief Gets the TIMx Input Capture 3 value.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @retval Capture Compare 3 Register value.
- */
-uint32_t TIM_GetCapture3(TIM_TypeDef* TIMx)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
-
- /* Get the Capture 3 Register value */
- return TIMx->CCR3;
-}
-
-/**
- * @brief Gets the TIMx Input Capture 4 value.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @retval Capture Compare 4 Register value.
- */
-uint32_t TIM_GetCapture4(TIM_TypeDef* TIMx)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
-
- /* Get the Capture 4 Register value */
- return TIMx->CCR4;
-}
-
-/**
- * @brief Sets the TIMx Input Capture 1 prescaler.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ICPSC: specifies the Input Capture1 prescaler new value.
- * This parameter can be one of the following values:
- * @arg TIM_ICPSC_DIV1: no prescaler
- * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
- * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
- * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
- * @retval None
- */
-void TIM_SetIC1Prescaler(TIM_TypeDef* TIMx, uint32_t TIM_ICPSC)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_IC_PRESCALER(TIM_ICPSC));
-
- /* Reset the IC1PSC Bits */
- TIMx->CCMR1 &= (uint32_t)~((uint32_t)TIM_CCMR1_IC1PSC);
- /* Set the IC1PSC value */
- TIMx->CCMR1 |= TIM_ICPSC;
-}
-
-/**
- * @brief Sets the TIMx Input Capture 2 prescaler.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ICPSC: specifies the Input Capture2 prescaler new value.
- * This parameter can be one of the following values:
- * @arg TIM_ICPSC_DIV1: no prescaler
- * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
- * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
- * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
- * @retval None
- */
-void TIM_SetIC2Prescaler(TIM_TypeDef* TIMx, uint32_t TIM_ICPSC)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_IC_PRESCALER(TIM_ICPSC));
-
- /* Reset the IC2PSC Bits */
- TIMx->CCMR1 &= (uint32_t)~((uint32_t)TIM_CCMR1_IC2PSC);
- /* Set the IC2PSC value */
- TIMx->CCMR1 |= (uint32_t)(TIM_ICPSC << 8);
-}
-
-/**
- * @brief Sets the TIMx Input Capture 3 prescaler.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ICPSC: specifies the Input Capture3 prescaler new value.
- * This parameter can be one of the following values:
- * @arg TIM_ICPSC_DIV1: no prescaler
- * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
- * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
- * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
- * @retval None
- */
-void TIM_SetIC3Prescaler(TIM_TypeDef* TIMx, uint32_t TIM_ICPSC)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_IC_PRESCALER(TIM_ICPSC));
-
- /* Reset the IC3PSC Bits */
- TIMx->CCMR2 &= (uint32_t)~((uint32_t)TIM_CCMR2_IC3PSC);
- /* Set the IC3PSC value */
- TIMx->CCMR2 |= TIM_ICPSC;
-}
-
-/**
- * @brief Sets the TIMx Input Capture 4 prescaler.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ICPSC: specifies the Input Capture4 prescaler new value.
- * This parameter can be one of the following values:
- * @arg TIM_ICPSC_DIV1: no prescaler
- * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
- * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
- * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
- * @retval None
- */
-void TIM_SetIC4Prescaler(TIM_TypeDef* TIMx, uint32_t TIM_ICPSC)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_IC_PRESCALER(TIM_ICPSC));
-
- /* Reset the IC4PSC Bits */
- TIMx->CCMR2 &= (uint32_t)~((uint32_t)TIM_CCMR2_IC4PSC);
- /* Set the IC4PSC value */
- TIMx->CCMR2 |= (uint32_t)(TIM_ICPSC << 8);
-}
-
-/**
- * @}
- */
-
-/** @defgroup TIM_Group4 Interrupts and flags management functions
- * @brief Interrupts and flags management functions
- *
-@verbatim
- ===============================================================================
- ##### Interrupts and flags management functions #####
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Enables or disables the specified TIM interrupts.
- * @param TIMx_IT: where x can be 1 or 2 to select the TIMx peripheral.
- * @param TIM_ITRPT: specifies the TIM interrupts sources to be enabled or disabled.
- * This parameter can be any combination of the following values:
- * @arg TIM_IT_Update: TIM update Interrupt source
- * @arg TIM_IT_CC1: TIM Capture Compare 1 Interrupt source
- * @arg TIM_IT_CC2: TIM Capture Compare 2 Interrupt source
- * @arg TIM_IT_CC3: TIM Capture Compare 3 Interrupt source
- * @arg TIM_IT_CC4: TIM Capture Compare 4 Interrupt source
- * @arg TIM_IT_Trigger: TIM Trigger Interrupt source
- * @param NewState: new state of the TIM interrupts.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void TIM_ITConfig(TIM_IT_TypeDef* TIMx_IT, uint32_t TIM_ITRPT, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_TIM_IT_ALL_PERIPH(TIMx_IT));
- assert_param(IS_TIM_ITRPT(TIM_ITRPT));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable the Interrupt sources */
- TIMx_IT->IER |= TIM_ITRPT;
- }
- else
- {
- /* Disable the Interrupt sources */
- TIMx_IT->IER &= (uint32_t)~TIM_ITRPT;
- }
-}
-
-/**
- * @brief Configures the TIMx event to be generate by software.
- * @param TIMx: where x can be 1 or 2 to select the
- * TIM peripheral.
- * @param TIM_EventSource: specifies the event source.
- * This parameter can be one or more of the following values:
- * @arg TIM_EventSource_Update: Timer update Event source
- * @arg TIM_EventSource_CC1: Timer Capture Compare 1 Event source
- * @arg TIM_EventSource_CC2: Timer Capture Compare 2 Event source
- * @arg TIM_EventSource_CC3: Timer Capture Compare 3 Event source
- * @arg TIM_EventSource_CC4: Timer Capture Compare 4 Event source
- * @arg TIM_EventSource_Trigger: Timer Trigger Event source
- * @retval None
- */
-void TIM_GenerateEvent(TIM_TypeDef* TIMx, uint32_t TIM_EventSource)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_EVENT_SOURCE(TIM_EventSource));
- /* Set the event sources */
- TIMx->EGR = TIM_EventSource;
-}
-
-/**
- * @brief Checks whether the TIM interrupt has occurred or not.
- * @param TIMx_IT: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ITRPT: specifies the TIM interrupt source to check.
- * This parameter can be one of the following values:
- * @arg TIM_IT_Update: TIM update Interrupt source
- * @arg TIM_IT_CC1: TIM Capture Compare 1 Interrupt source
- * @arg TIM_IT_CC2: TIM Capture Compare 2 Interrupt source
- * @arg TIM_IT_CC3: TIM Capture Compare 3 Interrupt source
- * @arg TIM_IT_CC4: TIM Capture Compare 4 Interrupt source
- * @arg TIM_IT_Trigger: TIM Trigger Interrupt source
- * @retval The new state of the TIM_IT(SET or RESET).
- */
-ITStatus TIM_GetITStatus(TIM_IT_TypeDef* TIMx_IT, uint32_t TIM_ITRPT)
-{
- ITStatus bitstatus = RESET;
- uint32_t itstatus = 0x0, itenable = 0x0;
-
- /* Check the parameters */
- assert_param(IS_TIM_IT_ALL_PERIPH(TIMx_IT));
- assert_param(IS_TIM_GET_IT(TIM_ITRPT));
-
-
- itstatus = TIMx_IT->ISR & TIM_ITRPT;
- itenable = TIMx_IT->IER & TIM_ITRPT;
-
- if ((itstatus != (uint32_t)RESET) && (itenable != (uint32_t)RESET))
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
-}
-
-/**
- * @brief Clears the TIMx's interrupt pending bits.
- * @param TIMx_IT: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ITRPT: specifies the pending bit to clear.
- * This parameter can be any combination of the following values:
- * @arg TIM_IT_Update: TIM1 update Interrupt source
- * @arg TIM_IT_CC1: TIM Capture Compare 1 Interrupt source
- * @arg TIM_IT_CC2: TIM Capture Compare 2 Interrupt source
- * @arg TIM_IT_CC3: TIM Capture Compare 3 Interrupt source
- * @arg TIM_IT_CC4: TIM Capture Compare 4 Interrupt source
- * @arg TIM_IT_Trigger: TIM Trigger Interrupt source
- * @retval None
- */
-void TIM_ClearITPendingBit(TIM_IT_TypeDef* TIMx_IT, uint32_t TIM_ITRPT)
-{
- /* Check the parameters */
- assert_param(IS_TIM_IT_ALL_PERIPH(TIMx_IT));
- assert_param(IS_TIM_ITRPT(TIM_ITRPT));
-
- /* Clear the IT pending Bit */
-
- TIMx_IT->ISR = TIM_ITRPT;
-}
-
-/**
- * @}
- */
-
-/** @defgroup TIM_Group5 Clocks management functions
- * @brief Clocks management functions
- *
-@verbatim
- ===============================================================================
- ##### Clocks management functions #####
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Configures the TIMx internal Clock
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @retval None
- */
-void TIM_InternalClockConfig(TIM_TypeDef* TIMx)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- /* Disable slave mode to clock the prescaler directly with the internal clock */
- TIMx->SMCR &= (uint32_t)(~((uint32_t)TIM_SMCR_SMS));
-}
-
-/**
- * @brief Configures the TIMx Internal Trigger as External Clock
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_InputTriggerSource: Trigger source.
- * This parameter can only be:
- * @arg TIM_TS_ITR0: Internal Trigger 0
- * @retval None
- */
-void TIM_ITRxExternalClockConfig(TIM_TypeDef* TIMx, uint32_t TIM_InputTriggerSource)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_INTERNAL_TRIGGER_SELECTION(TIM_InputTriggerSource));
- /* Select the Internal Trigger */
- TIM_SelectInputTrigger(TIMx, TIM_InputTriggerSource);
- /* Select the External clock mode1 */
- TIMx->SMCR |= TIM_SlaveMode_External1;
-}
-
-/**
- * @brief Configures the TIMx Trigger as External Clock
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_TIxExternalCLKSource: Trigger source.
- * This parameter can be one of the following values:
- * @arg TIM_TIxExternalCLK1Source_TI1ED: TI1 Edge Detector
- * @arg TIM_TIxExternalCLK1Source_TI1: Filtered Timer Input 1
- * @arg TIM_TIxExternalCLK1Source_TI2: Filtered Timer Input 2
- * @param TIM_ICPolarity: specifies the TIx Polarity.
- * This parameter can be one of the following values:
- * @arg TIM_ICPolarity_Rising
- * @arg TIM_ICPolarity_Falling
- * @param ICFilter : specifies the filter value.
- * This parameter must be a value between 0x0 and 0xF.
- * @retval None
- */
-void TIM_TIxExternalClockConfig(TIM_TypeDef* TIMx, uint32_t TIM_TIxExternalCLKSource,
- uint32_t TIM_ICPolarity, uint32_t ICFilter)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_IC_POLARITY(TIM_ICPolarity));
- assert_param(IS_TIM_IC_FILTER(ICFilter));
-
- /* Configure the Timer Input Clock Source */
- if (TIM_TIxExternalCLKSource == TIM_TIxExternalCLK1Source_TI2)
- {
- TI2_Config(TIMx, TIM_ICPolarity, TIM_ICSelection_DirectTI, ICFilter);
- }
- else
- {
- TI1_Config(TIMx, TIM_ICPolarity, TIM_ICSelection_DirectTI, ICFilter);
- }
- /* Select the Trigger source */
- TIM_SelectInputTrigger(TIMx, TIM_TIxExternalCLKSource);
- /* Select the External clock mode1 */
- TIMx->SMCR |= TIM_SlaveMode_External1;
-}
-
-/**
- * @brief Configures the External clock Mode1
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ExtTRGPrescaler: The external Trigger Prescaler.
- * This parameter can be one of the following values:
- * @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF.
- * @arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2.
- * @arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4.
- * @arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8.
- * @param TIM_ExtTRGPolarity: The external Trigger Polarity.
- * This parameter can be one of the following values:
- * @arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active.
- * @arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active.
- * @param ExtTRGFilter: External Trigger Filter.
- * This parameter must be a value between 0x00 and 0x0F
- * @retval None
- */
-void TIM_ETRClockMode1Config(TIM_TypeDef* TIMx, uint32_t TIM_ExtTRGPrescaler, uint32_t TIM_ExtTRGPolarity,
- uint32_t ExtTRGFilter)
-{
- uint32_t tmpsmcr = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_EXT_PRESCALER(TIM_ExtTRGPrescaler));
- assert_param(IS_TIM_EXT_POLARITY(TIM_ExtTRGPolarity));
- assert_param(IS_TIM_EXT_FILTER(ExtTRGFilter));
-
- /* Configure the ETR Clock source */
- TIM_ETRConfig(TIMx, TIM_ExtTRGPrescaler, TIM_ExtTRGPolarity, ExtTRGFilter);
-
- /* Get the TIMx SMCR register value */
- tmpsmcr = TIMx->SMCR;
- /* Reset the SMS Bits */
- tmpsmcr &= (uint32_t)(~((uint32_t)TIM_SMCR_SMS));
- /* Select the External clock mode1 */
- tmpsmcr |= TIM_SlaveMode_External1;
- /* Select the Trigger selection : ETRF */
- tmpsmcr &= (uint32_t)(~((uint32_t)TIM_SMCR_TS));
- tmpsmcr |= TIM_TS_ETRF;
- /* Write to TIMx SMCR */
- TIMx->SMCR = tmpsmcr;
-}
-
-/**
- * @brief Configures the External clock Mode2
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ExtTRGPrescaler: The external Trigger Prescaler.
- * This parameter can be one of the following values:
- * @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF.
- * @arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2.
- * @arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4.
- * @arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8.
- * @param TIM_ExtTRGPolarity: The external Trigger Polarity.
- * This parameter can be one of the following values:
- * @arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active.
- * @arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active.
- * @param ExtTRGFilter: External Trigger Filter.
- * This parameter must be a value between 0x00 and 0x0F
- * @retval None
- */
-void TIM_ETRClockMode2Config(TIM_TypeDef* TIMx, uint32_t TIM_ExtTRGPrescaler,
- uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_EXT_PRESCALER(TIM_ExtTRGPrescaler));
- assert_param(IS_TIM_EXT_POLARITY(TIM_ExtTRGPolarity));
- assert_param(IS_TIM_EXT_FILTER(ExtTRGFilter));
-
- /* Configure the ETR Clock source */
- TIM_ETRConfig(TIMx, TIM_ExtTRGPrescaler, TIM_ExtTRGPolarity, ExtTRGFilter);
- /* Enable the External clock mode2 */
- TIMx->SMCR |= TIM_SMCR_ECE;
-}
-
-/**
- * @}
- */
-
-/** @defgroup TIM_Group6 Synchronization management functions
- * @brief Synchronization management functions
- *
-@verbatim
- ===============================================================================
- ##### Synchronization management functions #####
- ===============================================================================
- *** TIM Driver: how to use it in synchronization Mode ***
- ===============================================================================
- [..] Case of two/several Timers
- (#) Configure the Master Timers using the following functions:
- (++) void TIM_SelectOutputTrigger(TIM_TypeDef* TIMx,
- uint32_t TIM_TRGOSource).
- (++) void TIM_SelectMasterSlaveMode(TIM_TypeDef* TIMx,
- uint32_t TIM_MasterSlaveMode);
- (#) Configure the Slave Timers using the following functions:
- (++) void TIM_SelectInputTrigger(TIM_TypeDef* TIMx,
- uint32_t TIM_InputTriggerSource);
- (++) void TIM_SelectSlaveMode(TIM_TypeDef* TIMx, uint32_t TIM_SlaveMode);
- [..] Case of Timers and external trigger(ETR pin)
- (#) Configure the Etrenal trigger using this function:
- (++) void TIM_ETRConfig(TIM_TypeDef* TIMx, uint32_t TIM_ExtTRGPrescaler,
- uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter);
- (#) Configure the Slave Timers using the following functions:
- (++) void TIM_SelectInputTrigger(TIM_TypeDef* TIMx,
- uint32_t TIM_InputTriggerSource);
- (++) void TIM_SelectSlaveMode(TIM_TypeDef* TIMx, uint32_t TIM_SlaveMode);
-
-@endverbatim
- * @{
- */
-/**
- * @brief Selects the Input Trigger source
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_InputTriggerSource: The Input Trigger source.
- * This parameter can be one of the following values:
- * @arg TIM_TS_ITR0: Internal Trigger 0
- * @arg TIM_TS_TI1F_ED: TI1 Edge Detector
- * @arg TIM_TS_TI1FP1: Filtered Timer Input 1
- * @arg TIM_TS_TI2FP2: Filtered Timer Input 2
- * @arg TIM_TS_ETRF: External Trigger input
- * @retval None
- */
-void TIM_SelectInputTrigger(TIM_TypeDef* TIMx, uint32_t TIM_InputTriggerSource)
-{
- uint32_t tmpsmcr = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_TRIGGER_SELECTION(TIM_InputTriggerSource));
-
- /* Get the TIMx SMCR register value */
- tmpsmcr = TIMx->SMCR;
- /* Reset the TS Bits */
- tmpsmcr &= (uint32_t)(~((uint32_t)TIM_SMCR_TS));
- /* Set the Input Trigger source */
- tmpsmcr |= TIM_InputTriggerSource;
- /* Write to TIMx SMCR */
- TIMx->SMCR = tmpsmcr;
-}
-
-/**
- * @brief Selects the TIMx Trigger Output Mode.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_TRGOSource: specifies the Trigger Output source.
- * This paramter can be one of the following values:
- *
- * For all TIMx
- * @arg TIM_TRGOSource_Reset: The UG bit in the TIM_EGR register is used as the trigger output (TRGO).
- * @arg TIM_TRGOSource_Enable: The Counter Enable CEN is used as the trigger output (TRGO).
- * @arg TIM_TRGOSource_Update: The update event is selected as the trigger output (TRGO).
- * @arg TIM_TRGOSource_OC1: The trigger output sends a positive pulse when the CC1IF flag
- * is to be set, as soon as a capture or compare match occurs (TRGO).
- * @arg TIM_TRGOSource_OC1Ref: OC1REF signal is used as the trigger output (TRGO).
- * @arg TIM_TRGOSource_OC2Ref: OC2REF signal is used as the trigger output (TRGO).
- * @arg TIM_TRGOSource_OC3Ref: OC3REF signal is used as the trigger output (TRGO).
- * @arg TIM_TRGOSource_OC4Ref: OC4REF signal is used as the trigger output (TRGO).
- *
- * @retval None
- */
-void TIM_SelectOutputTrigger(TIM_TypeDef* TIMx, uint32_t TIM_TRGOSource)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_TRGO_SOURCE(TIM_TRGOSource));
-
- /* Reset the MMS Bits */
- TIMx->CR2 &= (uint32_t)~((uint32_t)TIM_CR2_MMS);
- /* Select the TRGO source */
- TIMx->CR2 |= TIM_TRGOSource;
-}
-
-/**
- * @brief Selects the TIMx Slave Mode.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_SlaveMode: specifies the Timer Slave Mode.
- * This paramter can be one of the following values:
- * @arg TIM_SlaveMode_Reset: Rising edge of the selected trigger signal (TRGI) re-initializes
- * the counter and triggers an update of the registers.
- * @arg TIM_SlaveMode_Gated: The counter clock is enabled when the trigger signal (TRGI) is high.
- * @arg TIM_SlaveMode_Trigger: The counter starts at a rising edge of the trigger TRGI.
- * @arg TIM_SlaveMode_External1: Rising edges of the selected trigger (TRGI) clock the counter.
- * @retval None
- */
-void TIM_SelectSlaveMode(TIM_TypeDef* TIMx, uint32_t TIM_SlaveMode)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_SLAVE_MODE(TIM_SlaveMode));
-
- /* Reset the SMS Bits */
- TIMx->SMCR &= (uint32_t)~((uint32_t)TIM_SMCR_SMS);
- /* Select the Slave Mode */
- TIMx->SMCR |= TIM_SlaveMode;
-}
-
-/**
- * @brief Sets or Resets the TIMx Master/Slave Mode.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_MasterSlaveMode: specifies the Timer Master Slave Mode.
- * This paramter can be one of the following values:
- * @arg TIM_MasterSlaveMode_Enable: synchronization between the current timer
- * and its slaves (through TRGO).
- * @arg TIM_MasterSlaveMode_Disable: No action
- * @retval None
- */
-void TIM_SelectMasterSlaveMode(TIM_TypeDef* TIMx, uint32_t TIM_MasterSlaveMode)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_MSM_STATE(TIM_MasterSlaveMode));
-
- /* Reset the MSM Bit */
- TIMx->SMCR &= (uint32_t)~((uint32_t)TIM_SMCR_MSM);
-
- /* Set or Reset the MSM Bit */
- TIMx->SMCR |= TIM_MasterSlaveMode;
-}
-
-/**
- * @brief Configures the TIMx External Trigger (ETR).
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ExtTRGPrescaler: The external Trigger Prescaler.
- * This parameter can be one of the following values:
- * @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF.
- * @arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2.
- * @arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4.
- * @arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8.
- * @param TIM_ExtTRGPolarity: The external Trigger Polarity.
- * This parameter can be one of the following values:
- * @arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active.
- * @arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active.
- * @param ExtTRGFilter: External Trigger Filter.
- * This parameter must be a value between 0x00 and 0x0F
- * @retval None
- */
-void TIM_ETRConfig(TIM_TypeDef* TIMx, uint32_t TIM_ExtTRGPrescaler, uint32_t TIM_ExtTRGPolarity,
- uint32_t ExtTRGFilter)
-{
- uint32_t tmpsmcr = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_EXT_PRESCALER(TIM_ExtTRGPrescaler));
- assert_param(IS_TIM_EXT_POLARITY(TIM_ExtTRGPolarity));
- assert_param(IS_TIM_EXT_FILTER(ExtTRGFilter));
-
- tmpsmcr = TIMx->SMCR;
- /* Reset the ETR Bits */
- tmpsmcr &= SMCR_ETR_MASK;
- /* Set the Prescaler, the Filter value and the Polarity */
- tmpsmcr |= (uint32_t)(TIM_ExtTRGPrescaler | (uint32_t)(TIM_ExtTRGPolarity | (uint32_t)(ExtTRGFilter << (uint32_t)8)));
- /* Write to TIMx SMCR */
- TIMx->SMCR = tmpsmcr;
-}
-
-/**
- * @}
- */
-
-/** @defgroup TIM_Group7 Specific interface management functions
- * @brief Specific interface management functions
- *
-@verbatim
- ===============================================================================
- ##### Specific interface management functions #####
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Configures the TIMx Encoder Interface.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_EncoderMode: specifies the TIMx Encoder Mode.
- * This parameter can be one of the following values:
- * @arg TIM_EncoderMode_TI1: Counter counts on TI1FP1 edge depending on TI2FP2 level.
- * @arg TIM_EncoderMode_TI2: Counter counts on TI2FP2 edge depending on TI1FP1 level.
- * @arg TIM_EncoderMode_TI12: Counter counts on both TI1FP1 and TI2FP2 edges depending
- * on the level of the other input.
- * @param TIM_IC1Polarity: specifies the IC1 Polarity
- * This parmeter can be one of the following values:
- * @arg TIM_ICPolarity_Falling: IC Falling edge.
- * @arg TIM_ICPolarity_Rising: IC Rising edge.
- * @param TIM_IC2Polarity: specifies the IC2 Polarity
- * This parmeter can be one of the following values:
- * @arg TIM_ICPolarity_Falling: IC Falling edge.
- * @arg TIM_ICPolarity_Rising: IC Rising edge.
- * @retval None
- */
-void TIM_EncoderInterfaceConfig(TIM_TypeDef* TIMx, uint32_t TIM_EncoderMode,
- uint32_t TIM_IC1Polarity, uint32_t TIM_IC2Polarity)
-{
- uint32_t tmpsmcr = 0;
- uint32_t tmpccmr1 = 0;
- uint32_t tmpccer = 0;
-
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_ENCODER_MODE(TIM_EncoderMode));
- assert_param(IS_TIM_IC_POLARITY(TIM_IC1Polarity));
- assert_param(IS_TIM_IC_POLARITY(TIM_IC2Polarity));
-
- /* Get the TIMx SMCR register value */
- tmpsmcr = TIMx->SMCR;
- /* Get the TIMx CCMR1 register value */
- tmpccmr1 = TIMx->CCMR1;
- /* Get the TIMx CCER register value */
- tmpccer = TIMx->CCER;
- /* Set the encoder Mode */
- tmpsmcr &= (uint32_t)(~((uint32_t)TIM_SMCR_SMS));
- tmpsmcr |= TIM_EncoderMode;
- /* Select the Capture Compare 1 and the Capture Compare 2 as input */
- tmpccmr1 &= (uint32_t)(((uint32_t)~((uint32_t)TIM_CCMR1_CC1S)) & (uint32_t)(~((uint32_t)TIM_CCMR1_CC2S)));
- tmpccmr1 |= TIM_CCMR1_CC1S_0 | TIM_CCMR1_CC2S_0;
- /* Set the TI1 and the TI2 Polarities */
- tmpccer &= (uint32_t)(((uint32_t)~((uint32_t)TIM_CCER_CC1P)) & ((uint32_t)~((uint32_t)TIM_CCER_CC2P)));
- tmpccer |= (uint32_t)(TIM_IC1Polarity | (uint32_t)(TIM_IC2Polarity << (uint32_t)4));
- /* Write to TIMx SMCR */
- TIMx->SMCR = tmpsmcr;
- /* Write to TIMx CCMR1 */
- TIMx->CCMR1 = tmpccmr1;
- /* Write to TIMx CCER */
- TIMx->CCER = tmpccer;
-}
-
-/**
- * @brief Enables or disables the TIMx's Hall sensor interface.
- * @param TIMx: where x can be 1, 2 or 3 to select the TIM peripheral.
- * @param NewState: new state of the TIMx Hall sensor interface.
- * This parameter can be: ENABLE or DISABLE.
- * @retval None
- */
-void TIM_SelectHallSensor(TIM_TypeDef* TIMx, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Set the TI1S Bit */
- TIMx->CR2 |= TIM_CR2_TI1S;
- }
- else
- {
- /* Reset the TI1S Bit */
- TIMx->CR2 &= (uint32_t)~((uint32_t)TIM_CR2_TI1S);
- }
-}
-
-/**
- * @}
- */
-
-/** @defgroup TIM_Group8 Specific remapping management function
- * @brief Specific remapping management function
- *
-@verbatim
- ===============================================================================
- ##### Specific remapping management function #####
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Selects the TIMx Extenal trigger used in external clock mode 2.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param NewState: new state of the TIMx CLKMSKEN bit
- * This parameter can be: ENABLE or DISABLE.
- * @retval : None
- */
-void TIM_ClockMaskConfig(TIM_TypeDef* TIMx, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Enable the clock mask */
- TIMx->OR |= TIM_ClockMask_Enable;
- }
- else
- {
- /* Disable the clock mask */
- TIMx->OR &= TIM_ClockMask_Disable;
- }
-}
-
-/**
- * @brief Selects the TIMx Extenal trigger used in external clock mode 2.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_EXTRIGCLK: specifies the TIM input reampping source.
- * This parameter can be one of the following values:
- * @arg TIM_EXTRIGPCLK: PCLK.
- * @arg TIM_EXTRIG1KHCLK: calibrated 1 kHz clock.
- * @arg TIM_EXTRIG32KHCLK: 32 kHz reference clock (if available).
- * @arg TIM_EXTRIGTIMxCLK: TIMxCLK pin.
- * @retval : None
- */
-void TIM_SelectExternalTriggerClock(TIM_TypeDef* TIMx, uint32_t TIM_EXTRIGCLK)
-{
- /* Check the parameters */
- assert_param(IS_TIM_ALL_PERIPH(TIMx));
- assert_param(IS_TIM_EXTRIGCLK(TIM_EXTRIGCLK));
-
- /* Set the Timer remapping configuration */
- TIMx->OR |= TIM_EXTRIGCLK;
-}
-
-/**
- * @brief Configures the TIM2 Remapping input Capabilities.
- * @param TIMx: where x can be 2 to select the TIM peripheral.
- * @param TIM_Remap: specifies the TIM input reampping source.
- * This parameter can be one of the following values:
- * @arg TIM_REMAPC1: TIM2 Channel 1 is connected to GPIOA (PA0) or to GPIOB (PB1).
- * @arg TIM_REMAPC2: TIM2 Channel 2 is connected to GPIOA (PA3) or to GPIOB (PB2).
- * @arg TIM_REMAPC3: TIM2 Channel 3 is connected to GPIOA (PA1) or to GPIOB (PB3).
- * @arg TIM_REMAPC4: TIM2 Channel 4 is connected to GPIOA (PA2) or to GPIOB (PB4).
- * @param NewState: new state of the TIMx TIM2_OR_REMAPCy bit (y can be 1..4).
- * This parameter can be: ENABLE or DISABLE.
- * @retval : None
- */
-void TIM_RemapCmd(TIM_TypeDef* TIMx, uint32_t TIM_Remap, FunctionalState NewState)
-{
- /* Check the parameters */
- assert_param(IS_TIM_LIST1_PERIPH(TIMx));
- assert_param(IS_TIM_REMAP(TIM_Remap));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
- /* Set the Timer remapping configuration */
- TIMx->OR |= TIM_Remap;
- }
- else
- {
- TIMx->OR &= (uint32_t)~TIM_Remap;
- }
-}
-
-/**
- * @}
- */
-
-/**
- * @brief Configure the TI1 as Input.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ICPolarity : The Input Polarity.
- * This parameter can be one of the following values:
- * @arg TIM_ICPolarity_Rising:
- * @arg TIM_ICPolarity_Falling:
- * @param TIM_ICSelection: specifies the input to be used.
- * This parameter can be one of the following values:
- * @arg TIM_ICSelection_DirectTI: TIM Input 1 is selected to be connected to IC1.
- * @arg TIM_ICSelection_IndirectTI: TIM Input 1 is selected to be connected to IC2.
- * @arg TIM_ICSelection_TRGI: TIM Input 1 is selected to be connected to TRGI.
- * @param TIM_ICFilter: Specifies the Input Capture Filter.
- * This parameter must be a value between 0x00 and 0x0F.
- * @retval None
- */
-static void TI1_Config(TIM_TypeDef* TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
- uint32_t TIM_ICFilter)
-{
-
- uint32_t tmpccmr1 = 0, tmpccer = 0;
- /* Disable the Channel 1: Reset the CC1E Bit */
- TIMx->CCER &= (uint32_t)~((uint32_t)TIM_CCER_CC1E);
- tmpccmr1 = TIMx->CCMR1;
- tmpccer = TIMx->CCER;
- /* Select the Input and set the filter */
- tmpccmr1 &= (uint32_t)(((uint32_t)~((uint32_t)TIM_CCMR1_CC1S)) & ((uint32_t)~((uint32_t)TIM_CCMR1_IC1F)));
- tmpccmr1 |= (uint32_t)(TIM_ICSelection | (uint32_t)(TIM_ICFilter << (uint32_t)4));
-
- /* Select the Polarity and set the CC1E Bit */
- tmpccer &= (uint32_t)~((uint32_t)(TIM_CCER_CC1P));
- tmpccer |= (uint32_t)(TIM_ICPolarity | (uint32_t)TIM_CCER_CC1E);
- /* Write to TIMx CCMR1 and CCER registers */
- TIMx->CCMR1 = tmpccmr1;
- TIMx->CCER = tmpccer;
-}
-
-/**
- * @brief Configure the TI2 as Input.
- * @param TIMx: where x can be 1 or 2 to select the TIM peripheral.
- * @param TIM_ICPolarity : The Input Polarity.
- * This parameter can be one of the following values:
- * @arg TIM_ICPolarity_Rising
- * @arg TIM_ICPolarity_Falling
- * @param TIM_ICSelection: specifies the input to be used.
- * This parameter can be one of the following values:
- * @arg TIM_ICSelection_DirectTI: TIM Input 2 is selected to be connected to IC2.
- * @arg TIM_ICSelection_IndirectTI: TIM Input 2 is selected to be connected to IC1.
- * @arg TIM_ICSelection_TRGI: TIM Input 2 is selected to be connected to TRGI.
- * @param TIM_ICFilter: Specifies the Input Capture Filter.
- * This parameter must be a value between 0x00 and 0x0F.
- * @retval None
- */
-static void TI2_Config(TIM_TypeDef* TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
- uint32_t TIM_ICFilter)
-{
- uint32_t tmpccmr1 = 0, tmpccer = 0, tmp = 0;
- /* Disable the Channel 2: Reset the CC2E Bit */
- TIMx->CCER &= (uint32_t)~((uint32_t)TIM_CCER_CC2E);
- tmpccmr1 = TIMx->CCMR1;
- tmpccer = TIMx->CCER;
- tmp = (uint32_t)(TIM_ICPolarity << 4);
- /* Select the Input and set the filter */
- tmpccmr1 &= (uint32_t)(((uint32_t)~((uint32_t)TIM_CCMR1_CC2S)) & ((uint32_t)~((uint32_t)TIM_CCMR1_IC2F)));
- tmpccmr1 |= (uint32_t)(TIM_ICFilter << 12);
- tmpccmr1 |= (uint32_t)(TIM_ICSelection << 8);
- /* Select the Polarity and set the CC2E Bit */
- tmpccer &= (uint32_t)~((uint32_t)(TIM_CCER_CC2P));
- tmpccer |= (uint32_t)(tmp | (uint32_t)TIM_CCER_CC2E);
- /* Write to TIMx CCMR1 and CCER registers */
- TIMx->CCMR1 = tmpccmr1 ;
- TIMx->CCER = tmpccer;
-}
-
-/**
- * @brief Configure the TI3 as Input.
- * @param TIMx: where x can be 1, 2 or 3 to select the TIM peripheral.
- * @param TIM_ICPolarity : The Input Polarity.
- * This parameter can be one of the following values:
- * @arg TIM_ICPolarity_Rising
- * @arg TIM_ICPolarity_Falling
- * @param TIM_ICSelection: specifies the input to be used.
- * This parameter can be one of the following values:
- * @arg TIM_ICSelection_DirectTI: TIM Input 3 is selected to be connected to IC3.
- * @arg TIM_ICSelection_IndirectTI: TIM Input 3 is selected to be connected to IC4.
- * @arg TIM_ICSelection_TRGI: TIM Input 3 is selected to be connected to TRGI.
- * @param TIM_ICFilter: Specifies the Input Capture Filter.
- * This parameter must be a value between 0x00 and 0x0F.
- * @retval None
- */
-static void TI3_Config(TIM_TypeDef* TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
- uint32_t TIM_ICFilter)
-{
- uint32_t tmpccmr2 = 0, tmpccer = 0, tmp = 0;
- /* Disable the Channel 3: Reset the CC3E Bit */
- TIMx->CCER &= (uint32_t)~((uint32_t)TIM_CCER_CC3E);
- tmpccmr2 = TIMx->CCMR2;
- tmpccer = TIMx->CCER;
- tmp = (uint32_t)(TIM_ICPolarity << 8);
- /* Select the Input and set the filter */
- tmpccmr2 &= (uint32_t)(((uint32_t)~((uint32_t)TIM_CCMR2_CC3S)) & ((uint32_t)~((uint32_t)TIM_CCMR2_IC3F)));
- tmpccmr2 |= (uint32_t)(TIM_ICSelection | (uint32_t)(TIM_ICFilter << (uint32_t)4));
- /* Select the Polarity and set the CC3E Bit */
- tmpccer &= (uint32_t)~((uint32_t)(TIM_CCER_CC3P));
- tmpccer |= (uint32_t)(tmp | (uint32_t)TIM_CCER_CC3E);
- /* Write to TIMx CCMR2 and CCER registers */
- TIMx->CCMR2 = tmpccmr2;
- TIMx->CCER = tmpccer;
-}
-
-/**
- * @brief Configure the TI4 as Input.
- * @param TIMx: where x can be 1, 2 or 3 to select the TIM peripheral.
- * @param TIM_ICPolarity : The Input Polarity.
- * This parameter can be one of the following values:
- * @arg TIM_ICPolarity_Rising
- * @arg TIM_ICPolarity_Falling
- * @param TIM_ICSelection: specifies the input to be used.
- * This parameter can be one of the following values:
- * @arg TIM_ICSelection_DirectTI: TIM Input 4 is selected to be connected to IC4.
- * @arg TIM_ICSelection_IndirectTI: TIM Input 4 is selected to be connected to IC3.
- * @arg TIM_ICSelection_TRGI: TIM Input 4 is selected to be connected to TRGI.
- * @param TIM_ICFilter: Specifies the Input Capture Filter.
- * This parameter must be a value between 0x00 and 0x0F.
- * @retval None
- */
-static void TI4_Config(TIM_TypeDef* TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
- uint32_t TIM_ICFilter)
-{
- uint32_t tmpccmr2 = 0, tmpccer = 0, tmp = 0;
-
- /* Disable the Channel 4: Reset the CC4E Bit */
- TIMx->CCER &= (uint32_t)~((uint32_t)TIM_CCER_CC4E);
- tmpccmr2 = TIMx->CCMR2;
- tmpccer = TIMx->CCER;
- tmp = (uint32_t)(TIM_ICPolarity << 12);
- /* Select the Input and set the filter */
- tmpccmr2 &= (uint32_t)((uint32_t)(~(uint32_t)TIM_CCMR2_CC4S) & ((uint32_t)~((uint32_t)TIM_CCMR2_IC4F)));
- tmpccmr2 |= (uint32_t)(TIM_ICSelection << 8);
- tmpccmr2 |= (uint32_t)(TIM_ICFilter << 12);
- /* Select the Polarity and set the CC4E Bit */
- tmpccer &= (uint32_t)~((uint32_t)(TIM_CCER_CC3P));
- tmpccer |= (uint32_t)(tmp | (uint32_t)TIM_CCER_CC4E);
- /* Write to TIMx CCMR2 and CCER registers */
- TIMx->CCMR2 = tmpccmr2;
- TIMx->CCER = tmpccer;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_wdg.c b/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_wdg.c
deleted file mode 100644
index 037f5a6..0000000
--- a/libs/STM32W108xx_StdPeriph_Driver/src/stm32w108xx_wdg.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32w108xx_wdg.c
- * @author MCD Application Team
- * @version V1.0.1
- * @date 30-November-2012
- * @brief This file provides firmware functions to use the watchdog (WDG) peripheral
- *
- * @verbatim
- *
-================================================================================
- ##### WDG features #####
-================================================================================
- [..] The watchdog timer uses the calibrated 1 kHz clock (CLK1K) as its reference
- and provides a nominal 2.048 s timeout. A low water mark interrupt occurs
- at 1.760 s and triggers an NMI to the Cortex-M3 NVIC as an early warning.
- When enabled, periodically reset the watchdog timer before it expires.
-
- [..] By default, the WDG is disabled at power up of the always-on power domain.
-
- [..] The watchdog timer can be paused when the debugger halts the core.
-
- ##### How to use this driver #####
-================================================================================
- [..] This driver allows to use WDG peripheral.
- [..] Start the WDG using WDG_Cmd() function.
- [..] Restart the WDG timer using WDG_ReloadCounter() function.
- [..] Specifies the staus of WDG timer during debug mode using WDG_DebugConfig() function.
-
-
- @endverbatim
- *
- ******************************************************************************
- * @attention
- *
- *