STM8S/A Standard Peripherals Drivers: stm8s_exti.c Source File

STM8S/A

stm8s_exti.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm8s_exti.c
00004   * @author  MCD Application Team
00005   * @version V2.3.0
00006   * @date    16-June-2017
00007   * @brief   This file contains all the functions for the EXTI peripheral.
00008    ******************************************************************************
00009   * @attention
00010   *
00011   * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
00012   *
00013   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
00014   * You may not use this file except in compliance with the License.
00015   * You may obtain a copy of the License at:
00016   *
00017   *        http://www.st.com/software_license_agreement_liberty_v2
00018   *
00019   * Unless required by applicable law or agreed to in writing, software 
00020   * distributed under the License is distributed on an "AS IS" BASIS, 
00021   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00022   * See the License for the specific language governing permissions and
00023   * limitations under the License.
00024   *
00025   ******************************************************************************
00026   */
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm8s_exti.h"
00030 
00031 /** @addtogroup STM8S_StdPeriph_Driver
00032   * @{
00033   */
00034 /* Private typedef -----------------------------------------------------------*/
00035 /* Private define ------------------------------------------------------------*/
00036 /* Private macro -------------------------------------------------------------*/
00037 /* Private variables ---------------------------------------------------------*/
00038 /* Private function prototypes -----------------------------------------------*/
00039 /* Private functions ---------------------------------------------------------*/
00040 
00041 /* Public functions ----------------------------------------------------------*/
00042 
00043 /**
00044   * @addtogroup EXTI_Public_Functions
00045   * @{
00046   */
00047 
00048 /**
00049   * @brief  Deinitializes the external interrupt control registers to their default reset value.
00050   * @param  None
00051   * @retval None
00052   */
00053 void EXTI_DeInit(void)
00054 {
00055   EXTI->CR1 = EXTI_CR1_RESET_VALUE;
00056   EXTI->CR2 = EXTI_CR2_RESET_VALUE;
00057 }
00058 
00059 /**
00060   * @brief  Set the external interrupt sensitivity of the selected port.
00061   * @warning
00062   * - The modification of external interrupt sensitivity is only possible when the interrupts are disabled.
00063   * - The normal behavior is to disable the interrupts before calling this function, and re-enable them after.
00064   * @param   Port The port number to access.
00065   * @param   SensitivityValue The external interrupt sensitivity value to set.
00066   * @retval None
00067   * @par Required preconditions:
00068   * Global interrupts must be disabled before calling this function.
00069   */
00070 void EXTI_SetExtIntSensitivity(EXTI_Port_TypeDef Port, EXTI_Sensitivity_TypeDef SensitivityValue)
00071 {
00072   /* Check function parameters */
00073   assert_param(IS_EXTI_PORT_OK(Port));
00074   assert_param(IS_EXTI_SENSITIVITY_OK(SensitivityValue));
00075   
00076   /* Set external interrupt sensitivity */
00077   switch (Port)
00078   {
00079   case EXTI_PORT_GPIOA:
00080     EXTI->CR1 &= (uint8_t)(~EXTI_CR1_PAIS);
00081     EXTI->CR1 |= (uint8_t)(SensitivityValue);
00082     break;
00083   case EXTI_PORT_GPIOB:
00084     EXTI->CR1 &= (uint8_t)(~EXTI_CR1_PBIS);
00085     EXTI->CR1 |= (uint8_t)((uint8_t)(SensitivityValue) << 2);
00086     break;
00087   case EXTI_PORT_GPIOC:
00088     EXTI->CR1 &= (uint8_t)(~EXTI_CR1_PCIS);
00089     EXTI->CR1 |= (uint8_t)((uint8_t)(SensitivityValue) << 4);
00090     break;
00091   case EXTI_PORT_GPIOD:
00092     EXTI->CR1 &= (uint8_t)(~EXTI_CR1_PDIS);
00093     EXTI->CR1 |= (uint8_t)((uint8_t)(SensitivityValue) << 6);
00094     break;
00095   case EXTI_PORT_GPIOE:
00096     EXTI->CR2 &= (uint8_t)(~EXTI_CR2_PEIS);
00097     EXTI->CR2 |= (uint8_t)(SensitivityValue);
00098     break;
00099   default:
00100     break;
00101   }
00102 }
00103 
00104 /**
00105   * @brief  Set the TLI interrupt sensitivity.
00106   * @param   SensitivityValue The TLI interrupt sensitivity value.
00107   * @retval None
00108   * @par Required preconditions:
00109   * Global interrupts must be disabled before calling this function.
00110   */
00111 void EXTI_SetTLISensitivity(EXTI_TLISensitivity_TypeDef SensitivityValue)
00112 {
00113   /* Check function parameters */
00114   assert_param(IS_EXTI_TLISENSITIVITY_OK(SensitivityValue));
00115   
00116   /* Set TLI interrupt sensitivity */
00117   EXTI->CR2 &= (uint8_t)(~EXTI_CR2_TLIS);
00118   EXTI->CR2 |= (uint8_t)(SensitivityValue);
00119 }
00120 
00121 /**
00122   * @brief  Get the external interrupt sensitivity of the selected port.
00123   * @param   Port The port number to access.
00124   * @retval EXTI_Sensitivity_TypeDef The external interrupt sensitivity of the selected port.
00125   */
00126 EXTI_Sensitivity_TypeDef EXTI_GetExtIntSensitivity(EXTI_Port_TypeDef Port)
00127 {
00128   uint8_t value = 0;
00129   
00130   /* Check function parameters */
00131   assert_param(IS_EXTI_PORT_OK(Port));
00132   
00133   switch (Port)
00134   {
00135   case EXTI_PORT_GPIOA:
00136     value = (uint8_t)(EXTI->CR1 & EXTI_CR1_PAIS);
00137     break;
00138   case EXTI_PORT_GPIOB:
00139     value = (uint8_t)((uint8_t)(EXTI->CR1 & EXTI_CR1_PBIS) >> 2);
00140     break;
00141   case EXTI_PORT_GPIOC:
00142     value = (uint8_t)((uint8_t)(EXTI->CR1 & EXTI_CR1_PCIS) >> 4);
00143     break;
00144   case EXTI_PORT_GPIOD:
00145     value = (uint8_t)((uint8_t)(EXTI->CR1 & EXTI_CR1_PDIS) >> 6);
00146     break;
00147   case EXTI_PORT_GPIOE:
00148     value = (uint8_t)(EXTI->CR2 & EXTI_CR2_PEIS);
00149     break;
00150   default:
00151     break;
00152   }
00153   
00154   return((EXTI_Sensitivity_TypeDef)value);
00155 }
00156 
00157 /**
00158   * @brief  Get the TLI interrupt sensitivity.
00159   * @param  None
00160   * @retval EXTI_TLISensitivity_TypeDef The TLI interrupt sensitivity read.
00161   */
00162 EXTI_TLISensitivity_TypeDef EXTI_GetTLISensitivity(void)
00163 {
00164   uint8_t value = 0;
00165   
00166   /* Get TLI interrupt sensitivity */
00167   value = (uint8_t)(EXTI->CR2 & EXTI_CR2_TLIS);
00168   
00169   return((EXTI_TLISensitivity_TypeDef)value);
00170 }
00171 
00172 /**
00173   * @}
00174   */
00175   
00176 /**
00177   * @}
00178   */
00179   
00180 
00181 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM8 Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM8 8-bit Microcontrollers platform visit www.st.com