Rajath Ravi / Mbed 2 deprecated ravi_blinkycode

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers stm32f4xx_exti_mort.c Source File

stm32f4xx_exti_mort.c

00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_exti.c
00004   * @author  MCD Application Team
00005   * @version V1.8.0
00006   * @date    04-November-2016
00007   * @brief   This file provides firmware functions to manage the following 
00008   *          functionalities of the EXTI_MORT peripheral:
00009   *           + Initialization and Configuration
00010   *           + Interrupts and flags management
00011   *
00012 @verbatim  
00013 
00014  ===============================================================================
00015                               ##### EXTI_MORT features #####
00016  ===============================================================================
00017 
00018  [..] External interrupt/event lines are mapped as following:
00019    (#) All available GPIO pins are connected to the 16 external 
00020        interrupt/event lines from EXTI0 to EXTI15.
00021    (#) EXTI_MORT line 16 is connected to the PVD Output
00022    (#) EXTI_MORT line 17 is connected to the RTC Alarm event
00023    (#) EXTI_MORT line 18 is connected to the USB OTG FS Wakeup from suspend event
00024    (#) EXTI_MORT line 19 is connected to the Ethernet Wakeup event
00025    (#) EXTI_MORT line 20 is connected to the USB OTG HS (configured in FS) Wakeup event 
00026    (#) EXTI_MORT line 21 is connected to the RTC Tamper and Time Stamp events
00027    (#) EXTI_MORT line 22 is connected to the RTC Wakeup event
00028    (#) EXTI_MORT line 23 is connected to the LPTIM Wakeup event 
00029 
00030                        ##### How to use this driver #####
00031  ===============================================================================
00032  
00033  [..] In order to use an I/O pin as an external interrupt source, follow steps 
00034       below:
00035    (#) Configure the I/O in input mode using GPIO_Init()
00036    (#) Select the input source pin for the EXTI_MORT line using SYSCFG_EXTILineConfig()
00037    (#) Select the mode(interrupt, event) and configure the trigger 
00038        selection (Rising, falling or both) using EXTI_Init_mort()
00039    (#) Configure NVIC IRQ channel mapped to the EXTI_MORT line using NVIC_Init()
00040 
00041  [..]     
00042    (@) SYSCFG APB clock must be enabled to get write access to SYSCFG_EXTICRx
00043        registers using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
00044 
00045 @endverbatim
00046   *
00047   ******************************************************************************
00048   * @attention
00049   *
00050   * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
00051   *
00052   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
00053   * You may not use this file except in compliance with the License.
00054   * You may obtain a copy of the License at:
00055   *
00056   *        http://www.st.com/software_license_agreement_liberty_v2
00057   *
00058   * Unless required by applicable law or agreed to in writing, software 
00059   * distributed under the License is distributed on an "AS IS" BASIS, 
00060   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00061   * See the License for the specific language governing permissions and
00062   * limitations under the License.
00063   *
00064   ******************************************************************************
00065   */
00066 
00067 /* Includes ------------------------------------------------------------------*/
00068 #include "stm32f4xx_exti_mort.h"
00069 
00070 /** @addtogroup STM32F4xx_StdPeriph_Driver
00071   * @{
00072   */
00073 
00074 /** @defgroup EXTI_MORT 
00075   * @brief EXTI_MORT driver modules
00076   * @{
00077   */
00078 
00079 /* Private typedef -----------------------------------------------------------*/
00080 /* Private define ------------------------------------------------------------*/
00081 
00082 #define EXTI_LINENONE_MORT    ((uint32_t)0x00000)  /* No interrupt selected */
00083 
00084 /* Private macro -------------------------------------------------------------*/
00085 /* Private variables ---------------------------------------------------------*/
00086 /* Private function prototypes -----------------------------------------------*/
00087 /* Private functions ---------------------------------------------------------*/
00088 
00089 /** @defgroup EXTI_Private_Functions
00090   * @{
00091   */
00092 
00093 /** @defgroup EXTI_Group1 Initialization and Configuration functions
00094  *  @brief   Initialization and Configuration functions 
00095  *
00096 @verbatim   
00097  ===============================================================================
00098              ##### Initialization and Configuration functions #####
00099  ===============================================================================
00100 
00101 @endverbatim
00102   * @{
00103   */
00104 
00105 /**
00106   * @brief  Deinitializes the EXTI_MORT peripheral registers to their default reset values.
00107   * @param  None
00108   * @retval None
00109   */
00110 void EXTI_DeInit_mort(void)
00111 {
00112   EXTI_MORT->IMR = 0x00000000;
00113   EXTI_MORT->EMR = 0x00000000;
00114   EXTI_MORT->RTSR = 0x00000000;
00115   EXTI_MORT->FTSR = 0x00000000;
00116   EXTI_MORT->PR = 0x007FFFFF;
00117 }
00118 
00119 /**
00120   * @brief  Initializes the EXTI_MORT peripheral according to the specified
00121   *         parameters in the EXTI_InitStruct.
00122   * @param  EXTI_InitStruct: pointer to a EXTI_InitTypeDef_mort structure
00123   *         that contains the configuration information for the EXTI_MORT peripheral.
00124   * @retval None
00125   */
00126 void EXTI_Init_mort(EXTI_InitTypeDef_mort* EXTI_InitStruct)
00127 {
00128   uint32_t tmp = 0;
00129 
00130   /* Check the parameters */
00131   assert_param(IS_EXTI_MODE_MORT(EXTI_InitStruct->EXTI_Mode));
00132   assert_param(IS_EXTI_TRIGGER_MORT(EXTI_InitStruct->EXTI_Trigger));
00133   assert_param(IS_EXTI_LINE_MORT(EXTI_InitStruct->EXTI_Line));  
00134   assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd));
00135 
00136   tmp = (uint32_t)EXTI_BASE_MORT;
00137      
00138   if (EXTI_InitStruct->EXTI_LineCmd != DISABLE)
00139   {
00140     /* Clear EXTI_MORT line configuration */
00141     EXTI_MORT->IMR &= ~EXTI_InitStruct->EXTI_Line;
00142     EXTI_MORT->EMR &= ~EXTI_InitStruct->EXTI_Line;
00143     
00144     tmp += EXTI_InitStruct->EXTI_Mode;
00145 
00146     *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
00147 
00148     /* Clear Rising Falling edge configuration */
00149     EXTI_MORT->RTSR &= ~EXTI_InitStruct->EXTI_Line;
00150     EXTI_MORT->FTSR &= ~EXTI_InitStruct->EXTI_Line;
00151     
00152     /* Select the trigger for the selected external interrupts */
00153     if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling)
00154     {
00155       /* Rising Falling edge */
00156       EXTI_MORT->RTSR |= EXTI_InitStruct->EXTI_Line;
00157       EXTI_MORT->FTSR |= EXTI_InitStruct->EXTI_Line;
00158     }
00159     else
00160     {
00161       tmp = (uint32_t)EXTI_BASE_MORT;
00162       tmp += EXTI_InitStruct->EXTI_Trigger;
00163 
00164       *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
00165     }
00166   }
00167   else
00168   {
00169     tmp += EXTI_InitStruct->EXTI_Mode;
00170 
00171     /* Disable the selected external lines */
00172     *(__IO uint32_t *) tmp &= ~EXTI_InitStruct->EXTI_Line;
00173   }
00174 }
00175 
00176 /**
00177   * @brief  Fills each EXTI_InitStruct member with its reset value.
00178   * @param  EXTI_InitStruct: pointer to a EXTI_InitTypeDef_mort structure which will
00179   *         be initialized.
00180   * @retval None
00181   */
00182 void EXTI_StructInit_mort(EXTI_InitTypeDef_mort* EXTI_InitStruct)
00183 {
00184   EXTI_InitStruct->EXTI_Line = EXTI_LINENONE_MORT;
00185   EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt;
00186   EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling;
00187   EXTI_InitStruct->EXTI_LineCmd = DISABLE;
00188 }
00189 
00190 /**
00191   * @brief  Generates a Software interrupt on selected EXTI_MORT line.
00192   * @param  EXTI_Line: specifies the EXTI_MORT line on which the software interrupt
00193   *         will be generated.
00194   *         This parameter can be any combination of EXTI_Linex where x can be (0..22)
00195   * @retval None
00196   */
00197 void EXTI_GenerateSWInterrupt_mort(uint32_t EXTI_Line)
00198 {
00199   /* Check the parameters */
00200   assert_param(IS_EXTI_LINE_MORT(EXTI_Line));
00201   
00202   EXTI_MORT->SWIER |= EXTI_Line;
00203 }
00204 
00205 /**
00206   * @}
00207   */
00208 
00209 /** @defgroup EXTI_Group2 Interrupts and flags management functions
00210  *  @brief   Interrupts and flags management functions 
00211  *
00212 @verbatim   
00213  ===============================================================================
00214              ##### Interrupts and flags management functions #####
00215  ===============================================================================
00216 
00217 @endverbatim
00218   * @{
00219   */
00220 
00221 /**
00222   * @brief  Checks whether the specified EXTI_MORT line flag is set or not.
00223   * @param  EXTI_Line: specifies the EXTI_MORT line flag to check.
00224   *          This parameter can be EXTI_Linex where x can be(0..22)
00225   * @retval The new state of EXTI_Line (SET or RESET).
00226   */
00227 FlagStatus EXTI_GetFlagStatus_mort(uint32_t EXTI_Line)
00228 {
00229   FlagStatus bitstatus = RESET;
00230   /* Check the parameters */
00231   assert_param(IS_GET_EXTI_LINE_MORT(EXTI_Line));
00232   
00233   if ((EXTI_MORT->PR & EXTI_Line) != (uint32_t)RESET)
00234   {
00235     bitstatus = SET;
00236   }
00237   else
00238   {
00239     bitstatus = RESET;
00240   }
00241   return bitstatus;
00242 }
00243 
00244 /**
00245   * @brief  Clears the EXTI_MORT's line pending flags.
00246   * @param  EXTI_Line: specifies the EXTI_MORT lines flags to clear.
00247   *          This parameter can be any combination of EXTI_Linex where x can be (0..22)
00248   * @retval None
00249   */
00250 void EXTI_ClearFlag_mort(uint32_t EXTI_Line)
00251 {
00252   /* Check the parameters */
00253   assert_param(IS_EXTI_LINE_MORT(EXTI_Line));
00254   
00255   EXTI_MORT->PR = EXTI_Line;
00256 }
00257 
00258 /**
00259   * @brief  Checks whether the specified EXTI_MORT line is asserted or not.
00260   * @param  EXTI_Line: specifies the EXTI_MORT line to check.
00261   *          This parameter can be EXTI_Linex where x can be(0..22)
00262   * @retval The new state of EXTI_Line (SET or RESET).
00263   */
00264 ITStatus EXTI_GetITStatus_mort(uint32_t EXTI_Line)
00265 {
00266   FlagStatus bitstatus = RESET;
00267   /* Check the parameters */
00268   assert_param(IS_GET_EXTI_LINE_MORT(EXTI_Line));
00269   
00270   if ((EXTI_MORT->PR & EXTI_Line) != (uint32_t)RESET)
00271   {
00272     bitstatus = SET;
00273   }
00274   else
00275   {
00276     bitstatus = RESET;
00277   }
00278   return bitstatus;
00279   
00280 }
00281 
00282 /**
00283   * @brief  Clears the EXTI_MORT's line pending bits.
00284   * @param  EXTI_Line: specifies the EXTI_MORT lines to clear.
00285   *          This parameter can be any combination of EXTI_Linex where x can be (0..22)
00286   * @retval None
00287   */
00288 void EXTI_ClearITPendingBit_mort(uint32_t EXTI_Line)
00289 {
00290   /* Check the parameters */
00291   assert_param(IS_EXTI_LINE_MORT(EXTI_Line));
00292   
00293   EXTI_MORT->PR = EXTI_Line;
00294 }
00295 
00296 /**
00297   * @}
00298   */
00299 
00300 /**
00301   * @}
00302   */
00303 
00304 /**
00305   * @}
00306   */
00307 
00308 /**
00309   * @}
00310   */
00311 
00312 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
00313 
00314 
00315 
00316 
00317 
00318