STM8L15x Standard Peripherals Drivers: stm8l15x_gpio.h Source File

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

stm8l15x_gpio.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm8l15x_gpio.h
00004   * @author  MCD Application Team
00005   * @version V1.5.0
00006   * @date    13-May-2011
00007   * @brief   This file contains all the functions prototypes for the GPIO firmware
00008   *          library.
00009   ******************************************************************************
00010   * @attention
00011   *
00012   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00013   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00014   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00015   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00016   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00017   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00018   *
00019   * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
00020   ******************************************************************************  
00021   */
00022 
00023 /* Define to prevent recursive inclusion -------------------------------------*/
00024 #ifndef __STM8L15x_GPIO_H
00025 #define __STM8L15x_GPIO_H
00026 
00027 /* Includes ------------------------------------------------------------------*/
00028 #include "stm8l15x.h"
00029 
00030 /** @addtogroup STM8L15x_StdPeriph_Driver
00031   * @{
00032   */
00033   
00034 /** @addtogroup I2C
00035   * @{
00036   */
00037 
00038 /* Exported types ------------------------------------------------------------*/
00039 
00040 /** @addtogroup GPIO_Exported_Types
00041   * @{
00042   */
00043 
00044 /**
00045   * @defgroup GPIO_Modes
00046   *
00047   * @brief
00048   *     
00049   * Bits definitions:
00050   * - Bit 7: 0 = INPUT mode
00051   *          1 = OUTPUT mode
00052   *          1 = PULL-UP (input) or PUSH-PULL (output)
00053   * - Bit 5: 0 = No external interrupt (input) or No slope control (output)
00054   *          1 = External interrupt (input) or Slow control enabled (output)
00055   * - Bit 4: 0 = Low level (output)
00056   *          1 = High level (output push-pull) or HI-Z (output open-drain)
00057   * @{
00058   */
00059 typedef enum
00060 {
00061   GPIO_Mode_In_FL_No_IT      = (uint8_t)0x00,   /*!< Input floating, no external interrupt */
00062   GPIO_Mode_In_PU_No_IT      = (uint8_t)0x40,   /*!< Input pull-up, no external interrupt */
00063   GPIO_Mode_In_FL_IT         = (uint8_t)0x20,   /*!< Input floating, external interrupt */
00064   GPIO_Mode_In_PU_IT         = (uint8_t)0x60,   /*!< Input pull-up, external interrupt */
00065   GPIO_Mode_Out_OD_Low_Fast  = (uint8_t)0xA0,   /*!< Output open-drain, low level, 10MHz */
00066   GPIO_Mode_Out_PP_Low_Fast  = (uint8_t)0xE0,   /*!< Output push-pull, low level, 10MHz */
00067   GPIO_Mode_Out_OD_Low_Slow  = (uint8_t)0x80,   /*!< Output open-drain, low level, 2MHz */
00068   GPIO_Mode_Out_PP_Low_Slow  = (uint8_t)0xC0,   /*!< Output push-pull, low level, 2MHz */
00069   GPIO_Mode_Out_OD_HiZ_Fast  = (uint8_t)0xB0,   /*!< Output open-drain, high-impedance level, 10MHz */
00070   GPIO_Mode_Out_PP_High_Fast = (uint8_t)0xF0,   /*!< Output push-pull, high level, 10MHz */
00071   GPIO_Mode_Out_OD_HiZ_Slow  = (uint8_t)0x90,   /*!< Output open-drain, high-impedance level, 2MHz */
00072   GPIO_Mode_Out_PP_High_Slow = (uint8_t)0xD0    /*!< Output push-pull, high level, 2MHz */
00073 }GPIO_Mode_TypeDef;
00074 
00075 /**
00076   * @}
00077   */
00078   
00079 /** @defgroup GPIO_Pin
00080   * @{
00081   */
00082 
00083 typedef enum
00084 {
00085   GPIO_Pin_0    = ((uint8_t)0x01),   /*!< Pin 0 selected */
00086   GPIO_Pin_1    = ((uint8_t)0x02),   /*!< Pin 1 selected */
00087   GPIO_Pin_2    = ((uint8_t)0x04),   /*!< Pin 2 selected */
00088   GPIO_Pin_3    = ((uint8_t)0x08),   /*!< Pin 3 selected */
00089   GPIO_Pin_4    = ((uint8_t)0x10),   /*!< Pin 4 selected */
00090   GPIO_Pin_5    = ((uint8_t)0x20),   /*!< Pin 5 selected */
00091   GPIO_Pin_6    = ((uint8_t)0x40),   /*!< Pin 6 selected */
00092   GPIO_Pin_7    = ((uint8_t)0x80),   /*!< Pin 7 selected */
00093   GPIO_Pin_LNib = ((uint8_t)0x0F),   /*!< Low nibble pins selected */
00094   GPIO_Pin_HNib = ((uint8_t)0xF0),   /*!< High nibble pins selected */
00095   GPIO_Pin_All  = ((uint8_t)0xFF)    /*!< All pins selected */
00096 }GPIO_Pin_TypeDef;
00097 
00098 /**
00099   * @}
00100   */
00101   
00102 /**
00103   * @}
00104   */
00105   
00106 /* Exported constants --------------------------------------------------------*/
00107 /* Exported macros -----------------------------------------------------------*/
00108 
00109 /** @addtogroup GPIO_Exported_Macros
00110   * @{
00111   */
00112 
00113 /**
00114   * @brief Macro used by the assert function to check the different functions parameters.
00115   */
00116 
00117 /**
00118   * @brief Macro used by the assert function in order to check the different
00119   * values of GPIOMode_TypeDef.
00120   */
00121 #define IS_GPIO_MODE(MODE) \
00122   (((MODE) == GPIO_Mode_In_FL_No_IT)       || \
00123    ((MODE) == GPIO_Mode_In_PU_No_IT)       || \
00124    ((MODE) == GPIO_Mode_In_FL_IT)          || \
00125    ((MODE) == GPIO_Mode_In_PU_IT)          || \
00126    ((MODE) == GPIO_Mode_Out_OD_Low_Fast)   || \
00127    ((MODE) == GPIO_Mode_Out_PP_Low_Fast)   || \
00128    ((MODE) == GPIO_Mode_Out_OD_Low_Slow)   || \
00129    ((MODE) == GPIO_Mode_Out_PP_Low_Slow)   || \
00130    ((MODE) == GPIO_Mode_Out_OD_HiZ_Fast)   || \
00131    ((MODE) == GPIO_Mode_Out_PP_High_Fast)  || \
00132    ((MODE) == GPIO_Mode_Out_OD_HiZ_Slow)   || \
00133    ((MODE) == GPIO_Mode_Out_PP_High_Slow))
00134 
00135 /**
00136   * @brief Macro used by the assert function in order to check the different
00137   * values of GPIO_Pins.
00138   */
00139 #define IS_GPIO_PIN(PIN) ((PIN) != (uint8_t)0x00)
00140 
00141 /**
00142   * @}
00143   */
00144 
00145 
00146 /* Exported functions ------------------------------------------------------- */
00147 /* Initialization and Configuration *******************************************/
00148 void GPIO_DeInit(GPIO_TypeDef* GPIOx);
00149 void GPIO_Init(GPIO_TypeDef* GPIOx, uint8_t GPIO_Pin, GPIO_Mode_TypeDef GPIO_Mode);
00150 void GPIO_ExternalPullUpConfig(GPIO_TypeDef* GPIOx, uint8_t GPIO_Pin, FunctionalState NewState);
00151 
00152 /* GPIO Read and Write ********************************************************/
00153 void GPIO_Write(GPIO_TypeDef* GPIOx, uint8_t GPIO_PortVal);
00154 void GPIO_WriteBit(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, BitAction GPIO_BitVal);
00155 void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint8_t GPIO_Pin);
00156 void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint8_t GPIO_Pin);
00157 void GPIO_ToggleBits(GPIO_TypeDef* GPIOx, uint8_t GPIO_Pin);
00158 uint8_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
00159 uint8_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
00160 BitStatus GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin);
00161 BitStatus GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin);
00162 
00163 #endif /* __STM8L15x_GPIO_H */
00164 
00165 /**
00166   * @}
00167   */
00168   
00169 /**
00170   * @}
00171   */
00172 
00173 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com