STM8S/A Standard Peripherals Drivers: stm8s_gpio.h Source File

STM8S/A

stm8s_gpio.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm8s_gpio.h
00004   * @author  MCD Application Team
00005   * @version V2.3.0
00006   * @date    16-June-2017
00007   * @brief   This file contains all functions prototype and macros for the GPIO 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 /* Define to prevent recursive inclusion -------------------------------------*/
00029 #ifndef __STM8S_GPIO_H
00030 #define __STM8S_GPIO_H
00031 
00032 /* Includes ------------------------------------------------------------------*/
00033 #include "stm8s.h"
00034 
00035 /* Exported variables ------------------------------------------------------- */
00036 /* Exported types ------------------------------------------------------------*/
00037 
00038 /** @addtogroup GPIO_Exported_Types
00039   * @{
00040   */
00041 
00042 /**
00043   * @brief  GPIO modes
00044   *
00045   * Bits definitions:
00046   * - Bit 7: 0 = INPUT mode
00047   *          1 = OUTPUT mode
00048   *          1 = PULL-UP (input) or PUSH-PULL (output)
00049   * - Bit 5: 0 = No external interrupt (input) or No slope control (output)
00050   *          1 = External interrupt (input) or Slow control enabled (output)
00051   * - Bit 4: 0 = Low level (output)
00052   *          1 = High level (output push-pull) or HI-Z (output open-drain)
00053   */
00054 typedef enum
00055 {
00056   GPIO_MODE_IN_FL_NO_IT      = (uint8_t)0x00,  /*!< Input floating, no external interrupt */
00057   GPIO_MODE_IN_PU_NO_IT      = (uint8_t)0x40,  /*!< Input pull-up, no external interrupt */
00058   GPIO_MODE_IN_FL_IT         = (uint8_t)0x20,  /*!< Input floating, external interrupt */
00059   GPIO_MODE_IN_PU_IT         = (uint8_t)0x60,  /*!< Input pull-up, external interrupt */
00060   GPIO_MODE_OUT_OD_LOW_FAST  = (uint8_t)0xA0,  /*!< Output open-drain, low level, 10MHz */
00061   GPIO_MODE_OUT_PP_LOW_FAST  = (uint8_t)0xE0,  /*!< Output push-pull, low level, 10MHz */
00062   GPIO_MODE_OUT_OD_LOW_SLOW  = (uint8_t)0x80,  /*!< Output open-drain, low level, 2MHz */
00063   GPIO_MODE_OUT_PP_LOW_SLOW  = (uint8_t)0xC0,  /*!< Output push-pull, low level, 2MHz */
00064   GPIO_MODE_OUT_OD_HIZ_FAST  = (uint8_t)0xB0,  /*!< Output open-drain, high-impedance level,10MHz */
00065   GPIO_MODE_OUT_PP_HIGH_FAST = (uint8_t)0xF0,  /*!< Output push-pull, high level, 10MHz */
00066   GPIO_MODE_OUT_OD_HIZ_SLOW  = (uint8_t)0x90,  /*!< Output open-drain, high-impedance level, 2MHz */
00067   GPIO_MODE_OUT_PP_HIGH_SLOW = (uint8_t)0xD0   /*!< Output push-pull, high level, 2MHz */
00068 }GPIO_Mode_TypeDef;
00069 
00070 /**
00071   * @brief  Definition of the GPIO pins. Used by the @ref GPIO_Init function in
00072   * order to select the pins to be initialized.
00073   */
00074 
00075 typedef enum
00076 {
00077   GPIO_PIN_0    = ((uint8_t)0x01),  /*!< Pin 0 selected */
00078   GPIO_PIN_1    = ((uint8_t)0x02),  /*!< Pin 1 selected */
00079   GPIO_PIN_2    = ((uint8_t)0x04),  /*!< Pin 2 selected */
00080   GPIO_PIN_3    = ((uint8_t)0x08),   /*!< Pin 3 selected */
00081   GPIO_PIN_4    = ((uint8_t)0x10),  /*!< Pin 4 selected */
00082   GPIO_PIN_5    = ((uint8_t)0x20),  /*!< Pin 5 selected */
00083   GPIO_PIN_6    = ((uint8_t)0x40),  /*!< Pin 6 selected */
00084   GPIO_PIN_7    = ((uint8_t)0x80),  /*!< Pin 7 selected */
00085   GPIO_PIN_LNIB = ((uint8_t)0x0F),  /*!< Low nibble pins selected */
00086   GPIO_PIN_HNIB = ((uint8_t)0xF0),  /*!< High nibble pins selected */
00087   GPIO_PIN_ALL  = ((uint8_t)0xFF)   /*!< All pins selected */
00088 }GPIO_Pin_TypeDef;
00089 
00090 /**
00091   * @}
00092   */
00093 
00094 /* Exported constants --------------------------------------------------------*/
00095 /* Exported macros -----------------------------------------------------------*/
00096 /* Private macros ------------------------------------------------------------*/
00097 
00098 /** @addtogroup GPIO_Private_Macros
00099   * @{
00100   */
00101 
00102 /**
00103   * @brief  Macro used by the assert function to check the different functions parameters.
00104   */
00105 
00106 /**
00107   * @brief  Macro used by the assert function in order to check the different
00108   * values of GPIOMode_TypeDef.
00109   */
00110 #define IS_GPIO_MODE_OK(MODE) \
00111   (((MODE) == GPIO_MODE_IN_FL_NO_IT)    || \
00112    ((MODE) == GPIO_MODE_IN_PU_NO_IT)    || \
00113    ((MODE) == GPIO_MODE_IN_FL_IT)       || \
00114    ((MODE) == GPIO_MODE_IN_PU_IT)       || \
00115    ((MODE) == GPIO_MODE_OUT_OD_LOW_FAST)  || \
00116    ((MODE) == GPIO_MODE_OUT_PP_LOW_FAST)  || \
00117    ((MODE) == GPIO_MODE_OUT_OD_LOW_SLOW)  || \
00118    ((MODE) == GPIO_MODE_OUT_PP_LOW_SLOW)  || \
00119    ((MODE) == GPIO_MODE_OUT_OD_HIZ_FAST)  || \
00120    ((MODE) == GPIO_MODE_OUT_PP_HIGH_FAST)  || \
00121    ((MODE) == GPIO_MODE_OUT_OD_HIZ_SLOW)  || \
00122    ((MODE) == GPIO_MODE_OUT_PP_HIGH_SLOW))
00123 
00124 /**
00125   * @brief  Macro used by the assert function in order to check the different
00126   * values of GPIO_Pins.
00127   */
00128 #define IS_GPIO_PIN_OK(PIN)  ((PIN) != (uint8_t)0x00)
00129 
00130 /**
00131   * @}
00132   */
00133 
00134 /* Exported functions ------------------------------------------------------- */
00135 /** @addtogroup GPIO_Exported_Functions
00136   * @{
00137   */
00138 
00139 void GPIO_DeInit(GPIO_TypeDef* GPIOx);
00140 void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, GPIO_Mode_TypeDef GPIO_Mode);
00141 void GPIO_Write(GPIO_TypeDef* GPIOx, uint8_t PortVal);
00142 void GPIO_WriteHigh(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins);
00143 void GPIO_WriteLow(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins);
00144 void GPIO_WriteReverse(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins);
00145 uint8_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
00146 uint8_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
00147 BitStatus GPIO_ReadInputPin(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin);
00148 void GPIO_ExternalPullUpConfig(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, FunctionalState NewState);
00149 /**
00150   * @}
00151   */
00152 
00153 #endif /* __STM8L_GPIO_H */
00154 
00155 
00156 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM8 Standard Peripherals Library: Footer

 

 

 

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