Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
stm32f429i_discovery_io.c
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f429i_discovery_io.c 00004 * @author MCD Application Team 00005 * @version V2.1.2 00006 * @date 02-March-2015 00007 * @brief This file provides a set of functions needed to manage the STMPE811 00008 * IO Expander device mounted on STM32F429I-Discovery Kit. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00013 * 00014 * Redistribution and use in source and binary forms, with or without modification, 00015 * are permitted provided that the following conditions are met: 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00022 * may be used to endorse or promote products derived from this software 00023 * without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00028 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00029 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00031 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00033 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00034 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************** 00037 */ 00038 00039 /* Includes ------------------------------------------------------------------*/ 00040 #include "stm32f429i_discovery_io.h" 00041 00042 /** @addtogroup BSP 00043 * @{ 00044 */ 00045 00046 /** @addtogroup STM32F429I_DISCOVERY 00047 * @{ 00048 */ 00049 00050 /** @defgroup STM32F429I_DISCOVERY_IO 00051 * @{ 00052 */ 00053 00054 /** @defgroup STM32F429I_DISCOVERY_IO_Private_Types_Definitions 00055 * @{ 00056 */ 00057 /** 00058 * @} 00059 */ 00060 00061 /** @defgroup STM32F429I_DISCOVERY_IO_Private_Defines 00062 * @{ 00063 */ 00064 /** 00065 * @} 00066 */ 00067 00068 /** @defgroup STM32F429I_DISCOVERY_IO_Private_Macros 00069 * @{ 00070 */ 00071 /** 00072 * @} 00073 */ 00074 00075 00076 /** @defgroup STM32F429I_DISCOVERY_IO_Private_Variables 00077 * @{ 00078 */ 00079 static IO_DrvTypeDef *IoDrv; 00080 00081 /** 00082 * @} 00083 */ 00084 00085 00086 /** @defgroup STM32F429I_DISCOVERY_IO_Private_Function_Prototypes 00087 * @{ 00088 */ 00089 /** 00090 * @} 00091 */ 00092 00093 /** @defgroup STM32F429I_DISCOVERY_IO_Private_Functions 00094 * @{ 00095 */ 00096 00097 /** 00098 * @brief Initializes and configures the IO functionalities and configures all 00099 * necessary hardware resources (GPIOs, clocks..). 00100 * @note BSP_IO_Init() is using HAL_Delay() function to ensure that stmpe811 00101 * IO Expander is correctly reset. HAL_Delay() function provides accurate 00102 * delay (in milliseconds) based on variable incremented in SysTick ISR. 00103 * This implies that if BSP_IO_Init() is called from a peripheral ISR process, 00104 * then the SysTick interrupt must have higher priority (numerically lower) 00105 * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. 00106 * @param None 00107 * @retval IO_OK if all initializations done correctly. Other value if error. 00108 */ 00109 uint8_t BSP_IO_Init(void) 00110 { 00111 uint8_t ret = IO_ERROR; 00112 00113 /* Read ID and verify the IO expander is ready */ 00114 if(stmpe811_io_drv.ReadID(IO_I2C_ADDRESS) == STMPE811_ID) 00115 { 00116 /* Initialize the IO driver structure */ 00117 IoDrv = &stmpe811_io_drv; 00118 ret = IO_OK; 00119 } 00120 00121 if(ret == IO_OK) 00122 { 00123 IoDrv->Init(IO_I2C_ADDRESS); 00124 IoDrv->Start(IO_I2C_ADDRESS, IO_PIN_ALL); 00125 } 00126 return ret; 00127 } 00128 00129 /** 00130 * @brief Gets the selected pins IT status. 00131 * @param IoPin: The selected pins to check the status. 00132 * This parameter could be any combination of the IO pins. 00133 * @retval Status of IO Pin checked. 00134 */ 00135 uint8_t BSP_IO_ITGetStatus(uint16_t IoPin) 00136 { 00137 /* Return the IO Pin IT status */ 00138 return (IoDrv->ITStatus(IO_I2C_ADDRESS, IoPin)); 00139 } 00140 00141 /** 00142 * @brief Clears all the IO IT pending bits 00143 * @param None 00144 * @retval None 00145 */ 00146 void BSP_IO_ITClear(void) 00147 { 00148 /* Clear all IO IT pending bits */ 00149 IoDrv->ClearIT(IO_I2C_ADDRESS, IO_PIN_ALL); 00150 } 00151 00152 /** 00153 * @brief Configures the IO pin(s) according to IO mode structure value. 00154 * @param IoPin: IO pin(s) to be configured. 00155 * This parameter could be any combination of the following values: 00156 * @arg STMPE811_PIN_x: where x can be from 0 to 7. 00157 * @param IoMode: The IO pin mode to configure, could be one of the following values: 00158 * @arg IO_MODE_INPUT 00159 * @arg IO_MODE_OUTPUT 00160 * @arg IO_MODE_IT_RISING_EDGE 00161 * @arg IO_MODE_IT_FALLING_EDGE 00162 * @arg IO_MODE_IT_LOW_LEVEL 00163 * @arg IO_MODE_IT_HIGH_LEVEL 00164 * @retval None 00165 */ 00166 void BSP_IO_ConfigPin(uint16_t IoPin, IO_ModeTypedef IoMode) 00167 { 00168 /* Configure the selected IO pin(s) mode */ 00169 IoDrv->Config(IO_I2C_ADDRESS, IoPin, IoMode); 00170 } 00171 00172 /** 00173 * @brief Sets the selected pins state. 00174 * @param IoPin: The selected pins to write. 00175 * This parameter could be any combination of the IO pins. 00176 * @param PinState: the new pins state to write 00177 * @retval None 00178 */ 00179 void BSP_IO_WritePin(uint16_t IoPin, uint8_t PinState) 00180 { 00181 /* Set the Pin state */ 00182 IoDrv->WritePin(IO_I2C_ADDRESS, IoPin, PinState); 00183 } 00184 00185 /** 00186 * @brief Gets the selected pins current state. 00187 * @param IoPin: The selected pins to read. 00188 * This parameter could be any combination of the IO pins. 00189 * @retval The current pins state 00190 */ 00191 uint16_t BSP_IO_ReadPin(uint16_t IoPin) 00192 { 00193 return(IoDrv->ReadPin(IO_I2C_ADDRESS, IoPin)); 00194 } 00195 00196 /** 00197 * @brief Toggles the selected pins state. 00198 * @param IoPin: The selected pins to toggle. 00199 * This parameter could be any combination of the IO pins. 00200 * @retval None 00201 */ 00202 void BSP_IO_TogglePin(uint16_t IoPin) 00203 { 00204 /* Toggle the current pin state */ 00205 if(IoDrv->ReadPin(IO_I2C_ADDRESS, IoPin) == 1 /* Set */) 00206 { 00207 IoDrv->WritePin(IO_I2C_ADDRESS, IoPin, 0 /* Reset */); 00208 } 00209 else 00210 { 00211 IoDrv->WritePin(IO_I2C_ADDRESS, IoPin, 1 /* Set */); 00212 } 00213 } 00214 00215 /** 00216 * @} 00217 */ 00218 00219 /** 00220 * @} 00221 */ 00222 00223 /** 00224 * @} 00225 */ 00226 00227 /** 00228 * @} 00229 */ 00230 00231 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Wed Jul 13 2022 21:23:00 by
