Additional font macro

Dependents:   EspSerial

Committer:
SomeRandomBloke
Date:
Fri Feb 05 09:20:30 2016 +0000
Revision:
1:a6fd0931a9e9
Parent:
0:e1d164542663
Added additional font macro

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:e1d164542663 1 /**
bcostm 0:e1d164542663 2 ******************************************************************************
bcostm 0:e1d164542663 3 * @file stm32f429i_discovery_io.c
bcostm 0:e1d164542663 4 * @author MCD Application Team
bcostm 0:e1d164542663 5 * @version V2.1.2
bcostm 0:e1d164542663 6 * @date 02-March-2015
bcostm 0:e1d164542663 7 * @brief This file provides a set of functions needed to manage the STMPE811
bcostm 0:e1d164542663 8 * IO Expander device mounted on STM32F429I-Discovery Kit.
bcostm 0:e1d164542663 9 ******************************************************************************
bcostm 0:e1d164542663 10 * @attention
bcostm 0:e1d164542663 11 *
bcostm 0:e1d164542663 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
bcostm 0:e1d164542663 13 *
bcostm 0:e1d164542663 14 * Redistribution and use in source and binary forms, with or without modification,
bcostm 0:e1d164542663 15 * are permitted provided that the following conditions are met:
bcostm 0:e1d164542663 16 * 1. Redistributions of source code must retain the above copyright notice,
bcostm 0:e1d164542663 17 * this list of conditions and the following disclaimer.
bcostm 0:e1d164542663 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
bcostm 0:e1d164542663 19 * this list of conditions and the following disclaimer in the documentation
bcostm 0:e1d164542663 20 * and/or other materials provided with the distribution.
bcostm 0:e1d164542663 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bcostm 0:e1d164542663 22 * may be used to endorse or promote products derived from this software
bcostm 0:e1d164542663 23 * without specific prior written permission.
bcostm 0:e1d164542663 24 *
bcostm 0:e1d164542663 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bcostm 0:e1d164542663 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bcostm 0:e1d164542663 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bcostm 0:e1d164542663 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bcostm 0:e1d164542663 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bcostm 0:e1d164542663 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bcostm 0:e1d164542663 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bcostm 0:e1d164542663 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bcostm 0:e1d164542663 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bcostm 0:e1d164542663 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bcostm 0:e1d164542663 35 *
bcostm 0:e1d164542663 36 ******************************************************************************
bcostm 0:e1d164542663 37 */
bcostm 0:e1d164542663 38
bcostm 0:e1d164542663 39 /* Includes ------------------------------------------------------------------*/
bcostm 0:e1d164542663 40 #include "stm32f429i_discovery_io.h"
bcostm 0:e1d164542663 41
bcostm 0:e1d164542663 42 /** @addtogroup BSP
bcostm 0:e1d164542663 43 * @{
bcostm 0:e1d164542663 44 */
bcostm 0:e1d164542663 45
bcostm 0:e1d164542663 46 /** @addtogroup STM32F429I_DISCOVERY
bcostm 0:e1d164542663 47 * @{
bcostm 0:e1d164542663 48 */
bcostm 0:e1d164542663 49
bcostm 0:e1d164542663 50 /** @defgroup STM32F429I_DISCOVERY_IO
bcostm 0:e1d164542663 51 * @{
bcostm 0:e1d164542663 52 */
bcostm 0:e1d164542663 53
bcostm 0:e1d164542663 54 /** @defgroup STM32F429I_DISCOVERY_IO_Private_Types_Definitions
bcostm 0:e1d164542663 55 * @{
bcostm 0:e1d164542663 56 */
bcostm 0:e1d164542663 57 /**
bcostm 0:e1d164542663 58 * @}
bcostm 0:e1d164542663 59 */
bcostm 0:e1d164542663 60
bcostm 0:e1d164542663 61 /** @defgroup STM32F429I_DISCOVERY_IO_Private_Defines
bcostm 0:e1d164542663 62 * @{
bcostm 0:e1d164542663 63 */
bcostm 0:e1d164542663 64 /**
bcostm 0:e1d164542663 65 * @}
bcostm 0:e1d164542663 66 */
bcostm 0:e1d164542663 67
bcostm 0:e1d164542663 68 /** @defgroup STM32F429I_DISCOVERY_IO_Private_Macros
bcostm 0:e1d164542663 69 * @{
bcostm 0:e1d164542663 70 */
bcostm 0:e1d164542663 71 /**
bcostm 0:e1d164542663 72 * @}
bcostm 0:e1d164542663 73 */
bcostm 0:e1d164542663 74
bcostm 0:e1d164542663 75
bcostm 0:e1d164542663 76 /** @defgroup STM32F429I_DISCOVERY_IO_Private_Variables
bcostm 0:e1d164542663 77 * @{
bcostm 0:e1d164542663 78 */
bcostm 0:e1d164542663 79 static IO_DrvTypeDef *IoDrv;
bcostm 0:e1d164542663 80
bcostm 0:e1d164542663 81 /**
bcostm 0:e1d164542663 82 * @}
bcostm 0:e1d164542663 83 */
bcostm 0:e1d164542663 84
bcostm 0:e1d164542663 85
bcostm 0:e1d164542663 86 /** @defgroup STM32F429I_DISCOVERY_IO_Private_Function_Prototypes
bcostm 0:e1d164542663 87 * @{
bcostm 0:e1d164542663 88 */
bcostm 0:e1d164542663 89 /**
bcostm 0:e1d164542663 90 * @}
bcostm 0:e1d164542663 91 */
bcostm 0:e1d164542663 92
bcostm 0:e1d164542663 93 /** @defgroup STM32F429I_DISCOVERY_IO_Private_Functions
bcostm 0:e1d164542663 94 * @{
bcostm 0:e1d164542663 95 */
bcostm 0:e1d164542663 96
bcostm 0:e1d164542663 97 /**
bcostm 0:e1d164542663 98 * @brief Initializes and configures the IO functionalities and configures all
bcostm 0:e1d164542663 99 * necessary hardware resources (GPIOs, clocks..).
bcostm 0:e1d164542663 100 * @note BSP_IO_Init() is using HAL_Delay() function to ensure that stmpe811
bcostm 0:e1d164542663 101 * IO Expander is correctly reset. HAL_Delay() function provides accurate
bcostm 0:e1d164542663 102 * delay (in milliseconds) based on variable incremented in SysTick ISR.
bcostm 0:e1d164542663 103 * This implies that if BSP_IO_Init() is called from a peripheral ISR process,
bcostm 0:e1d164542663 104 * then the SysTick interrupt must have higher priority (numerically lower)
bcostm 0:e1d164542663 105 * than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
bcostm 0:e1d164542663 106 * @param None
bcostm 0:e1d164542663 107 * @retval IO_OK if all initializations done correctly. Other value if error.
bcostm 0:e1d164542663 108 */
bcostm 0:e1d164542663 109 uint8_t BSP_IO_Init(void)
bcostm 0:e1d164542663 110 {
bcostm 0:e1d164542663 111 uint8_t ret = IO_ERROR;
bcostm 0:e1d164542663 112
bcostm 0:e1d164542663 113 /* Read ID and verify the IO expander is ready */
bcostm 0:e1d164542663 114 if(stmpe811_io_drv.ReadID(IO_I2C_ADDRESS) == STMPE811_ID)
bcostm 0:e1d164542663 115 {
bcostm 0:e1d164542663 116 /* Initialize the IO driver structure */
bcostm 0:e1d164542663 117 IoDrv = &stmpe811_io_drv;
bcostm 0:e1d164542663 118 ret = IO_OK;
bcostm 0:e1d164542663 119 }
bcostm 0:e1d164542663 120
bcostm 0:e1d164542663 121 if(ret == IO_OK)
bcostm 0:e1d164542663 122 {
bcostm 0:e1d164542663 123 IoDrv->Init(IO_I2C_ADDRESS);
bcostm 0:e1d164542663 124 IoDrv->Start(IO_I2C_ADDRESS, IO_PIN_ALL);
bcostm 0:e1d164542663 125 }
bcostm 0:e1d164542663 126 return ret;
bcostm 0:e1d164542663 127 }
bcostm 0:e1d164542663 128
bcostm 0:e1d164542663 129 /**
bcostm 0:e1d164542663 130 * @brief Gets the selected pins IT status.
bcostm 0:e1d164542663 131 * @param IoPin: The selected pins to check the status.
bcostm 0:e1d164542663 132 * This parameter could be any combination of the IO pins.
bcostm 0:e1d164542663 133 * @retval Status of IO Pin checked.
bcostm 0:e1d164542663 134 */
bcostm 0:e1d164542663 135 uint8_t BSP_IO_ITGetStatus(uint16_t IoPin)
bcostm 0:e1d164542663 136 {
bcostm 0:e1d164542663 137 /* Return the IO Pin IT status */
bcostm 0:e1d164542663 138 return (IoDrv->ITStatus(IO_I2C_ADDRESS, IoPin));
bcostm 0:e1d164542663 139 }
bcostm 0:e1d164542663 140
bcostm 0:e1d164542663 141 /**
bcostm 0:e1d164542663 142 * @brief Clears all the IO IT pending bits
bcostm 0:e1d164542663 143 * @param None
bcostm 0:e1d164542663 144 * @retval None
bcostm 0:e1d164542663 145 */
bcostm 0:e1d164542663 146 void BSP_IO_ITClear(void)
bcostm 0:e1d164542663 147 {
bcostm 0:e1d164542663 148 /* Clear all IO IT pending bits */
bcostm 0:e1d164542663 149 IoDrv->ClearIT(IO_I2C_ADDRESS, IO_PIN_ALL);
bcostm 0:e1d164542663 150 }
bcostm 0:e1d164542663 151
bcostm 0:e1d164542663 152 /**
bcostm 0:e1d164542663 153 * @brief Configures the IO pin(s) according to IO mode structure value.
bcostm 0:e1d164542663 154 * @param IoPin: IO pin(s) to be configured.
bcostm 0:e1d164542663 155 * This parameter could be any combination of the following values:
bcostm 0:e1d164542663 156 * @arg STMPE811_PIN_x: where x can be from 0 to 7.
bcostm 0:e1d164542663 157 * @param IoMode: The IO pin mode to configure, could be one of the following values:
bcostm 0:e1d164542663 158 * @arg IO_MODE_INPUT
bcostm 0:e1d164542663 159 * @arg IO_MODE_OUTPUT
bcostm 0:e1d164542663 160 * @arg IO_MODE_IT_RISING_EDGE
bcostm 0:e1d164542663 161 * @arg IO_MODE_IT_FALLING_EDGE
bcostm 0:e1d164542663 162 * @arg IO_MODE_IT_LOW_LEVEL
bcostm 0:e1d164542663 163 * @arg IO_MODE_IT_HIGH_LEVEL
bcostm 0:e1d164542663 164 * @retval None
bcostm 0:e1d164542663 165 */
bcostm 0:e1d164542663 166 void BSP_IO_ConfigPin(uint16_t IoPin, IO_ModeTypedef IoMode)
bcostm 0:e1d164542663 167 {
bcostm 0:e1d164542663 168 /* Configure the selected IO pin(s) mode */
bcostm 0:e1d164542663 169 IoDrv->Config(IO_I2C_ADDRESS, IoPin, IoMode);
bcostm 0:e1d164542663 170 }
bcostm 0:e1d164542663 171
bcostm 0:e1d164542663 172 /**
bcostm 0:e1d164542663 173 * @brief Sets the selected pins state.
bcostm 0:e1d164542663 174 * @param IoPin: The selected pins to write.
bcostm 0:e1d164542663 175 * This parameter could be any combination of the IO pins.
bcostm 0:e1d164542663 176 * @param PinState: the new pins state to write
bcostm 0:e1d164542663 177 * @retval None
bcostm 0:e1d164542663 178 */
bcostm 0:e1d164542663 179 void BSP_IO_WritePin(uint16_t IoPin, uint8_t PinState)
bcostm 0:e1d164542663 180 {
bcostm 0:e1d164542663 181 /* Set the Pin state */
bcostm 0:e1d164542663 182 IoDrv->WritePin(IO_I2C_ADDRESS, IoPin, PinState);
bcostm 0:e1d164542663 183 }
bcostm 0:e1d164542663 184
bcostm 0:e1d164542663 185 /**
bcostm 0:e1d164542663 186 * @brief Gets the selected pins current state.
bcostm 0:e1d164542663 187 * @param IoPin: The selected pins to read.
bcostm 0:e1d164542663 188 * This parameter could be any combination of the IO pins.
bcostm 0:e1d164542663 189 * @retval The current pins state
bcostm 0:e1d164542663 190 */
bcostm 0:e1d164542663 191 uint16_t BSP_IO_ReadPin(uint16_t IoPin)
bcostm 0:e1d164542663 192 {
bcostm 0:e1d164542663 193 return(IoDrv->ReadPin(IO_I2C_ADDRESS, IoPin));
bcostm 0:e1d164542663 194 }
bcostm 0:e1d164542663 195
bcostm 0:e1d164542663 196 /**
bcostm 0:e1d164542663 197 * @brief Toggles the selected pins state.
bcostm 0:e1d164542663 198 * @param IoPin: The selected pins to toggle.
bcostm 0:e1d164542663 199 * This parameter could be any combination of the IO pins.
bcostm 0:e1d164542663 200 * @retval None
bcostm 0:e1d164542663 201 */
bcostm 0:e1d164542663 202 void BSP_IO_TogglePin(uint16_t IoPin)
bcostm 0:e1d164542663 203 {
bcostm 0:e1d164542663 204 /* Toggle the current pin state */
bcostm 0:e1d164542663 205 if(IoDrv->ReadPin(IO_I2C_ADDRESS, IoPin) == 1 /* Set */)
bcostm 0:e1d164542663 206 {
bcostm 0:e1d164542663 207 IoDrv->WritePin(IO_I2C_ADDRESS, IoPin, 0 /* Reset */);
bcostm 0:e1d164542663 208 }
bcostm 0:e1d164542663 209 else
bcostm 0:e1d164542663 210 {
bcostm 0:e1d164542663 211 IoDrv->WritePin(IO_I2C_ADDRESS, IoPin, 1 /* Set */);
bcostm 0:e1d164542663 212 }
bcostm 0:e1d164542663 213 }
bcostm 0:e1d164542663 214
bcostm 0:e1d164542663 215 /**
bcostm 0:e1d164542663 216 * @}
bcostm 0:e1d164542663 217 */
bcostm 0:e1d164542663 218
bcostm 0:e1d164542663 219 /**
bcostm 0:e1d164542663 220 * @}
bcostm 0:e1d164542663 221 */
bcostm 0:e1d164542663 222
bcostm 0:e1d164542663 223 /**
bcostm 0:e1d164542663 224 * @}
bcostm 0:e1d164542663 225 */
bcostm 0:e1d164542663 226
bcostm 0:e1d164542663 227 /**
bcostm 0:e1d164542663 228 * @}
bcostm 0:e1d164542663 229 */
bcostm 0:e1d164542663 230
bcostm 0:e1d164542663 231 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/