Wakeup Light with touch user interface, anti-aliased Font, SD card access and RTC usage on STM32F746NG-DISCO board

Dependencies:   BSP_DISCO_F746NG_patch_fixed LCD_DISCO_F746NG TS_DISCO_F746NG FATFileSystem TinyJpgDec_interwork mbed-src

Committer:
the_sz
Date:
Sun Feb 21 04:26:17 2016 +0000
Revision:
14:2044ad5cd3fe
Parent:
12:a89096944f20
all fonts are working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
the_sz 12:a89096944f20 1 /**
the_sz 12:a89096944f20 2 * @author Tilen Majerle
the_sz 12:a89096944f20 3 * @email tilen@majerle.eu
the_sz 12:a89096944f20 4 * @website http://stm32f4-discovery.com
the_sz 12:a89096944f20 5 * @link http://stm32f4-discovery.com/2015/07/hal-library-1-5-gpio-library-for-stm32fxxx/
the_sz 12:a89096944f20 6 * @version v1.0
the_sz 12:a89096944f20 7 * @ide Keil uVision
the_sz 12:a89096944f20 8 * @license GNU GPL v3
the_sz 12:a89096944f20 9 * @brief GPIO Library for STM32F4xx and STM32F7xx devices
the_sz 12:a89096944f20 10 *
the_sz 12:a89096944f20 11 \verbatim
the_sz 12:a89096944f20 12 ----------------------------------------------------------------------
the_sz 12:a89096944f20 13 Copyright (C) Tilen Majerle, 2015
the_sz 12:a89096944f20 14
the_sz 12:a89096944f20 15 This program is free software: you can redistribute it and/or modify
the_sz 12:a89096944f20 16 it under the terms of the GNU General Public License as published by
the_sz 12:a89096944f20 17 the Free Software Foundation, either version 3 of the License, or
the_sz 12:a89096944f20 18 any later version.
the_sz 12:a89096944f20 19
the_sz 12:a89096944f20 20 This program is distributed in the hope that it will be useful,
the_sz 12:a89096944f20 21 but WITHOUT ANY WARRANTY; without even the implied warranty of
the_sz 12:a89096944f20 22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
the_sz 12:a89096944f20 23 GNU General Public License for more details.
the_sz 12:a89096944f20 24
the_sz 12:a89096944f20 25 You should have received a copy of the GNU General Public License
the_sz 12:a89096944f20 26 along with this program. If not, see <http://www.gnu.org/licenses/>.
the_sz 12:a89096944f20 27 ----------------------------------------------------------------------
the_sz 12:a89096944f20 28 \endverbatim
the_sz 12:a89096944f20 29 */
the_sz 12:a89096944f20 30 #ifndef TM_GPIO_H
the_sz 12:a89096944f20 31 #define TM_GPIO_H 100
the_sz 12:a89096944f20 32
the_sz 12:a89096944f20 33 /* C++ detection */
the_sz 12:a89096944f20 34 #ifdef __cplusplus
the_sz 12:a89096944f20 35 extern "C" {
the_sz 12:a89096944f20 36 #endif
the_sz 12:a89096944f20 37
the_sz 12:a89096944f20 38 /**
the_sz 12:a89096944f20 39 * @addtogroup TM_STM32Fxxx_HAL_Libraries
the_sz 12:a89096944f20 40 * @{
the_sz 12:a89096944f20 41 */
the_sz 12:a89096944f20 42
the_sz 12:a89096944f20 43 /**
the_sz 12:a89096944f20 44 * @defgroup TM_GPIO
the_sz 12:a89096944f20 45 * @brief TM GPIO Library for STM32Fxxx
the_sz 12:a89096944f20 46 * @{
the_sz 12:a89096944f20 47 *
the_sz 12:a89096944f20 48 * GPIO library can be used for GPIO pins.
the_sz 12:a89096944f20 49 *
the_sz 12:a89096944f20 50 * It features fast initialization methods as well pin input/output methods.
the_sz 12:a89096944f20 51 *
the_sz 12:a89096944f20 52 * It can be used as replacement for STD/HAL drivers GPIO library.
the_sz 12:a89096944f20 53 *
the_sz 12:a89096944f20 54 * \par Changelog
the_sz 12:a89096944f20 55 *
the_sz 12:a89096944f20 56 \verbatim
the_sz 12:a89096944f20 57 Version 1.0
the_sz 12:a89096944f20 58 - Initial release
the_sz 12:a89096944f20 59 \endverbatim
the_sz 12:a89096944f20 60 *
the_sz 12:a89096944f20 61 * \par Dependencies
the_sz 12:a89096944f20 62 *
the_sz 12:a89096944f20 63 \verbatim
the_sz 12:a89096944f20 64 - STM32Fxxx HAL
the_sz 12:a89096944f20 65 - defines.h
the_sz 12:a89096944f20 66 \endverbatim
the_sz 12:a89096944f20 67 */
the_sz 12:a89096944f20 68 #include "stm32fxxx_hal.h"
the_sz 12:a89096944f20 69 #include "defines.h"
the_sz 12:a89096944f20 70
the_sz 12:a89096944f20 71 /**
the_sz 12:a89096944f20 72 * @defgroup TM_GPIO_Macros
the_sz 12:a89096944f20 73 * @brief GPIO Library macros
the_sz 12:a89096944f20 74 * @{
the_sz 12:a89096944f20 75 */
the_sz 12:a89096944f20 76
the_sz 12:a89096944f20 77 /**
the_sz 12:a89096944f20 78 * @brief GPIO Pins declarations
the_sz 12:a89096944f20 79 * @note For HAL drivers compatibility
the_sz 12:a89096944f20 80 */
the_sz 12:a89096944f20 81
the_sz 12:a89096944f20 82 #ifndef GPIO_PIN_0
the_sz 12:a89096944f20 83 #define GPIO_PIN_0 ((uint16_t)0x0001)
the_sz 12:a89096944f20 84 #define GPIO_PIN_1 ((uint16_t)0x0002)
the_sz 12:a89096944f20 85 #define GPIO_PIN_2 ((uint16_t)0x0004)
the_sz 12:a89096944f20 86 #define GPIO_PIN_3 ((uint16_t)0x0008)
the_sz 12:a89096944f20 87 #define GPIO_PIN_4 ((uint16_t)0x0010)
the_sz 12:a89096944f20 88 #define GPIO_PIN_5 ((uint16_t)0x0020)
the_sz 12:a89096944f20 89 #define GPIO_PIN_6 ((uint16_t)0x0040)
the_sz 12:a89096944f20 90 #define GPIO_PIN_7 ((uint16_t)0x0080)
the_sz 12:a89096944f20 91 #define GPIO_PIN_8 ((uint16_t)0x0100)
the_sz 12:a89096944f20 92 #define GPIO_PIN_9 ((uint16_t)0x0200)
the_sz 12:a89096944f20 93 #define GPIO_PIN_10 ((uint16_t)0x0400)
the_sz 12:a89096944f20 94 #define GPIO_PIN_11 ((uint16_t)0x0800)
the_sz 12:a89096944f20 95 #define GPIO_PIN_12 ((uint16_t)0x1000)
the_sz 12:a89096944f20 96 #define GPIO_PIN_13 ((uint16_t)0x2000)
the_sz 12:a89096944f20 97 #define GPIO_PIN_14 ((uint16_t)0x4000)
the_sz 12:a89096944f20 98 #define GPIO_PIN_15 ((uint16_t)0x8000)
the_sz 12:a89096944f20 99 #define GPIO_PIN_ALL ((uint16_t)0xFFFF)
the_sz 12:a89096944f20 100 #endif
the_sz 12:a89096944f20 101
the_sz 12:a89096944f20 102 /**
the_sz 12:a89096944f20 103 * @brief GPIO Pins declarations
the_sz 12:a89096944f20 104 * @note For STD Periph drivers compatibility
the_sz 12:a89096944f20 105 */
the_sz 12:a89096944f20 106
the_sz 12:a89096944f20 107 #ifndef GPIO_Pin_0
the_sz 12:a89096944f20 108 #define GPIO_Pin_0 ((uint16_t)0x0001)
the_sz 12:a89096944f20 109 #define GPIO_Pin_1 ((uint16_t)0x0002)
the_sz 12:a89096944f20 110 #define GPIO_Pin_2 ((uint16_t)0x0004)
the_sz 12:a89096944f20 111 #define GPIO_Pin_3 ((uint16_t)0x0008)
the_sz 12:a89096944f20 112 #define GPIO_Pin_4 ((uint16_t)0x0010)
the_sz 12:a89096944f20 113 #define GPIO_Pin_5 ((uint16_t)0x0020)
the_sz 12:a89096944f20 114 #define GPIO_Pin_6 ((uint16_t)0x0040)
the_sz 12:a89096944f20 115 #define GPIO_Pin_7 ((uint16_t)0x0080)
the_sz 12:a89096944f20 116 #define GPIO_Pin_8 ((uint16_t)0x0100)
the_sz 12:a89096944f20 117 #define GPIO_Pin_9 ((uint16_t)0x0200)
the_sz 12:a89096944f20 118 #define GPIO_Pin_10 ((uint16_t)0x0400)
the_sz 12:a89096944f20 119 #define GPIO_Pin_11 ((uint16_t)0x0800)
the_sz 12:a89096944f20 120 #define GPIO_Pin_12 ((uint16_t)0x1000)
the_sz 12:a89096944f20 121 #define GPIO_Pin_13 ((uint16_t)0x2000)
the_sz 12:a89096944f20 122 #define GPIO_Pin_14 ((uint16_t)0x4000)
the_sz 12:a89096944f20 123 #define GPIO_Pin_15 ((uint16_t)0x8000)
the_sz 12:a89096944f20 124 #define GPIO_Pin_All ((uint16_t)0xFFFF)
the_sz 12:a89096944f20 125 #endif
the_sz 12:a89096944f20 126
the_sz 12:a89096944f20 127 /**
the_sz 12:a89096944f20 128 * @}
the_sz 12:a89096944f20 129 */
the_sz 12:a89096944f20 130
the_sz 12:a89096944f20 131 /**
the_sz 12:a89096944f20 132 * @defgroup TM_GPIO_Typedefs
the_sz 12:a89096944f20 133 * @brief GPIO Typedefs used for GPIO library for initialization purposes
the_sz 12:a89096944f20 134 * @{
the_sz 12:a89096944f20 135 */
the_sz 12:a89096944f20 136
the_sz 12:a89096944f20 137 /**
the_sz 12:a89096944f20 138 * @brief GPIO Mode enumeration
the_sz 12:a89096944f20 139 */
the_sz 12:a89096944f20 140 typedef enum {
the_sz 12:a89096944f20 141 TM_GPIO_Mode_IN = 0x00, /*!< GPIO Pin as General Purpose Input */
the_sz 12:a89096944f20 142 TM_GPIO_Mode_OUT = 0x01, /*!< GPIO Pin as General Purpose Output */
the_sz 12:a89096944f20 143 TM_GPIO_Mode_AF = 0x02, /*!< GPIO Pin as Alternate Function */
the_sz 12:a89096944f20 144 TM_GPIO_Mode_AN = 0x03, /*!< GPIO Pin as Analog input/output */
the_sz 12:a89096944f20 145 } TM_GPIO_Mode_t;
the_sz 12:a89096944f20 146
the_sz 12:a89096944f20 147 /**
the_sz 12:a89096944f20 148 * @brief GPIO Output type enumeration
the_sz 12:a89096944f20 149 */
the_sz 12:a89096944f20 150 typedef enum {
the_sz 12:a89096944f20 151 TM_GPIO_OType_PP = 0x00, /*!< GPIO Output Type Push-Pull */
the_sz 12:a89096944f20 152 TM_GPIO_OType_OD = 0x01 /*!< GPIO Output Type Open-Drain */
the_sz 12:a89096944f20 153 } TM_GPIO_OType_t;
the_sz 12:a89096944f20 154
the_sz 12:a89096944f20 155 /**
the_sz 12:a89096944f20 156 * @brief GPIO Speed enumeration
the_sz 12:a89096944f20 157 */
the_sz 12:a89096944f20 158 typedef enum {
the_sz 12:a89096944f20 159 TM_GPIO_Speed_Low = 0x00, /*!< GPIO Speed Low */
the_sz 12:a89096944f20 160 TM_GPIO_Speed_Medium = 0x01, /*!< GPIO Speed Medium */
the_sz 12:a89096944f20 161 TM_GPIO_Speed_Fast = 0x02, /*!< GPIO Speed Fast, not available on STM32F0xx devices */
the_sz 12:a89096944f20 162 TM_GPIO_Speed_High = 0x03 /*!< GPIO Speed High */
the_sz 12:a89096944f20 163 } TM_GPIO_Speed_t;
the_sz 12:a89096944f20 164
the_sz 12:a89096944f20 165 /**
the_sz 12:a89096944f20 166 * @brief GPIO pull resistors enumeration
the_sz 12:a89096944f20 167 */
the_sz 12:a89096944f20 168 typedef enum {
the_sz 12:a89096944f20 169 TM_GPIO_PuPd_NOPULL = 0x00, /*!< No pull resistor */
the_sz 12:a89096944f20 170 TM_GPIO_PuPd_UP = 0x01, /*!< Pull up resistor enabled */
the_sz 12:a89096944f20 171 TM_GPIO_PuPd_DOWN = 0x02 /*!< Pull down resistor enabled */
the_sz 12:a89096944f20 172 } TM_GPIO_PuPd_t;
the_sz 12:a89096944f20 173
the_sz 12:a89096944f20 174 /**
the_sz 12:a89096944f20 175 * @} TM_GPIO_Typedefs
the_sz 12:a89096944f20 176 */
the_sz 12:a89096944f20 177
the_sz 12:a89096944f20 178 /**
the_sz 12:a89096944f20 179 * @defgroup TM_GPIO_Functions
the_sz 12:a89096944f20 180 * @brief GPIO Functions
the_sz 12:a89096944f20 181 * @{
the_sz 12:a89096944f20 182 */
the_sz 12:a89096944f20 183
the_sz 12:a89096944f20 184 /**
the_sz 12:a89096944f20 185 * @brief Initializes GPIO pins(s)
the_sz 12:a89096944f20 186 * @note This function also enables clock for GPIO port
the_sz 12:a89096944f20 187 * @param GPIOx: Pointer to GPIOx port you will use for initialization
the_sz 12:a89096944f20 188 * @param GPIO_Pin: GPIO pin(s) you will use for initialization
the_sz 12:a89096944f20 189 * @param GPIO_Mode: Select GPIO mode. This parameter can be a value of @ref TM_GPIO_Mode_t enumeration
the_sz 12:a89096944f20 190 * @param GPIO_OType: Select GPIO Output type. This parameter can be a value of @ref TM_GPIO_OType_t enumeration
the_sz 12:a89096944f20 191 * @param GPIO_PuPd: Select GPIO pull resistor. This parameter can be a value of @ref TM_GPIO_PuPd_t enumeration
the_sz 12:a89096944f20 192 * @param GPIO_Speed: Select GPIO speed. This parameter can be a value of @ref TM_GPIO_Speed_t enumeration
the_sz 12:a89096944f20 193 * @retval None
the_sz 12:a89096944f20 194 */
the_sz 12:a89096944f20 195 void TM_GPIO_Init(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, TM_GPIO_Mode_t GPIO_Mode, TM_GPIO_OType_t GPIO_OType, TM_GPIO_PuPd_t GPIO_PuPd, TM_GPIO_Speed_t GPIO_Speed);
the_sz 12:a89096944f20 196
the_sz 12:a89096944f20 197 /**
the_sz 12:a89096944f20 198 * @brief Initializes GPIO pins(s) as alternate function
the_sz 12:a89096944f20 199 * @note This function also enables clock for GPIO port
the_sz 12:a89096944f20 200 * @param GPIOx: Pointer to GPIOx port you will use for initialization
the_sz 12:a89096944f20 201 * @param GPIO_Pin: GPIO pin(s) you will use for initialization
the_sz 12:a89096944f20 202 * @param GPIO_OType: Select GPIO Output type. This parameter can be a value of @ref TM_GPIO_OType_t enumeration
the_sz 12:a89096944f20 203 * @param GPIO_PuPd: Select GPIO pull resistor. This parameter can be a value of @ref TM_GPIO_PuPd_t enumeration
the_sz 12:a89096944f20 204 * @param GPIO_Speed: Select GPIO speed. This parameter can be a value of @ref TM_GPIO_Speed_t enumeration
the_sz 12:a89096944f20 205 * @param Alternate: Alternate function you will use
the_sz 12:a89096944f20 206 * @retval None
the_sz 12:a89096944f20 207 */
the_sz 12:a89096944f20 208 void TM_GPIO_InitAlternate(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, TM_GPIO_OType_t GPIO_OType, TM_GPIO_PuPd_t GPIO_PuPd, TM_GPIO_Speed_t GPIO_Speed, uint8_t Alternate);
the_sz 12:a89096944f20 209
the_sz 12:a89096944f20 210 /**
the_sz 12:a89096944f20 211 * @brief Deinitializes pin(s)
the_sz 12:a89096944f20 212 * @note Pins(s) will be set as analog mode to get low power consumption
the_sz 12:a89096944f20 213 * @param GPIOx: GPIOx PORT where you want to set pin as input
the_sz 12:a89096944f20 214 * @param GPIO_Pin: Select GPIO pin(s). You can select more pins with | (OR) operator to set them as input
the_sz 12:a89096944f20 215 * @retval None
the_sz 12:a89096944f20 216 */
the_sz 12:a89096944f20 217 void TM_GPIO_DeInit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
the_sz 12:a89096944f20 218
the_sz 12:a89096944f20 219 /**
the_sz 12:a89096944f20 220 * @brief Sets pin(s) as input
the_sz 12:a89096944f20 221 * @note Pins HAVE to be initialized first using @ref TM_GPIO_Init() or @ref TM_GPIO_InitAlternate() function
the_sz 12:a89096944f20 222 * @note This is just an option for fast input mode
the_sz 12:a89096944f20 223 * @param GPIOx: GPIOx PORT where you want to set pin as input
the_sz 12:a89096944f20 224 * @param GPIO_Pin: Select GPIO pin(s). You can select more pins with | (OR) operator to set them as input
the_sz 12:a89096944f20 225 * @retval None
the_sz 12:a89096944f20 226 */
the_sz 12:a89096944f20 227 void TM_GPIO_SetPinAsInput(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
the_sz 12:a89096944f20 228
the_sz 12:a89096944f20 229 /**
the_sz 12:a89096944f20 230 * @brief Sets pin(s) as output
the_sz 12:a89096944f20 231 * @note Pins HAVE to be initialized first using @ref TM_GPIO_Init() or @ref TM_GPIO_InitAlternate() function
the_sz 12:a89096944f20 232 * @note This is just an option for fast output mode
the_sz 12:a89096944f20 233 * @param GPIOx: GPIOx PORT where you want to set pin as output
the_sz 12:a89096944f20 234 * @param GPIO_Pin: Select GPIO pin(s). You can select more pins with | (OR) operator to set them as output
the_sz 12:a89096944f20 235 * @retval None
the_sz 12:a89096944f20 236 */
the_sz 12:a89096944f20 237 void TM_GPIO_SetPinAsOutput(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
the_sz 12:a89096944f20 238
the_sz 12:a89096944f20 239 /**
the_sz 12:a89096944f20 240 * @brief Sets pin(s) as analog
the_sz 12:a89096944f20 241 * @note Pins HAVE to be initialized first using @ref TM_GPIO_Init() or @ref TM_GPIO_InitAlternate() function
the_sz 12:a89096944f20 242 * @note This is just an option for fast analog mode
the_sz 12:a89096944f20 243 * @param GPIOx: GPIOx PORT where you want to set pin as analog
the_sz 12:a89096944f20 244 * @param GPIO_Pin: Select GPIO pin(s). You can select more pins with | (OR) operator to set them as analog
the_sz 12:a89096944f20 245 * @retval None
the_sz 12:a89096944f20 246 */
the_sz 12:a89096944f20 247 void TM_GPIO_SetPinAsAnalog(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
the_sz 12:a89096944f20 248
the_sz 12:a89096944f20 249 /**
the_sz 12:a89096944f20 250 * @brief Sets pin(s) as alternate function
the_sz 12:a89096944f20 251 * @note For proper alternate function, you should first init pin using @ref TM_GPIO_InitAlternate() function.
the_sz 12:a89096944f20 252 * This functions is only used for changing GPIO mode
the_sz 12:a89096944f20 253 * @param GPIOx: GPIOx PORT where you want to set pin as alternate
the_sz 12:a89096944f20 254 * @param GPIO_Pin: Select GPIO pin(s). You can select more pins with | (OR) operator to set them as alternate
the_sz 12:a89096944f20 255 * @retval None
the_sz 12:a89096944f20 256 */
the_sz 12:a89096944f20 257 void TM_GPIO_SetPinAsAlternate(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
the_sz 12:a89096944f20 258
the_sz 12:a89096944f20 259 /**
the_sz 12:a89096944f20 260 * @brief Sets pull resistor settings to GPIO pin(s)
the_sz 12:a89096944f20 261 * @note Pins HAVE to be initialized first using @ref TM_GPIO_Init() or @ref TM_GPIO_InitAlternate() function
the_sz 12:a89096944f20 262 * @param *GPIOx: GPIOx PORT where you want to select pull resistor
the_sz 12:a89096944f20 263 * @param GPIO_Pin: Select GPIO pin(s). You can select more pins with | (OR) operator to set them as output
the_sz 12:a89096944f20 264 * @param GPIO_PuPd: Pull resistor option. This parameter can be a value of @ref TM_GPIO_PuPd_t enumeration
the_sz 12:a89096944f20 265 * @retval None
the_sz 12:a89096944f20 266 */
the_sz 12:a89096944f20 267 void TM_GPIO_SetPullResistor(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, TM_GPIO_PuPd_t GPIO_PuPd);
the_sz 12:a89096944f20 268
the_sz 12:a89096944f20 269 /**
the_sz 12:a89096944f20 270 * @brief Sets pin(s) low
the_sz 12:a89096944f20 271 * @note Defined as macro to get maximum speed using register access
the_sz 12:a89096944f20 272 * @param GPIOx: GPIOx PORT where you want to set pin low
the_sz 12:a89096944f20 273 * @param GPIO_Pin: Select GPIO pin(s). You can select more pins with | (OR) operator to set them low
the_sz 12:a89096944f20 274 * @retval None
the_sz 12:a89096944f20 275 */
the_sz 12:a89096944f20 276 #define TM_GPIO_SetPinLow(GPIOx, GPIO_Pin) ((GPIOx)->BSRR = (uint32_t)((GPIO_Pin) << 16))
the_sz 12:a89096944f20 277
the_sz 12:a89096944f20 278 /**
the_sz 12:a89096944f20 279 * @brief Sets pin(s) high
the_sz 12:a89096944f20 280 * @note Defined as macro to get maximum speed using register access
the_sz 12:a89096944f20 281 * @param GPIOx: GPIOx PORT where you want to set pin high
the_sz 12:a89096944f20 282 * @param GPIO_Pin: Select GPIO pin(s). You can select more pins with | (OR) operator to set them high
the_sz 12:a89096944f20 283 * @retval None
the_sz 12:a89096944f20 284 */
the_sz 12:a89096944f20 285 #define TM_GPIO_SetPinHigh(GPIOx, GPIO_Pin) ((GPIOx)->BSRR = (uint32_t)(GPIO_Pin))
the_sz 12:a89096944f20 286
the_sz 12:a89096944f20 287 /**
the_sz 12:a89096944f20 288 * @brief Sets pin(s) value
the_sz 12:a89096944f20 289 * @note Defined as macro to get maximum speed using register access
the_sz 12:a89096944f20 290 * @param GPIOx: GPIOx PORT where you want to set pin value
the_sz 12:a89096944f20 291 * @param GPIO_Pin: Select GPIO pin(s). You can select more pins with | (OR) operator to set them value
the_sz 12:a89096944f20 292 * @param val: If parameter is 0 then pin will be low, otherwise high
the_sz 12:a89096944f20 293 * @retval None
the_sz 12:a89096944f20 294 */
the_sz 12:a89096944f20 295 #define TM_GPIO_SetPinValue(GPIOx, GPIO_Pin, val) ((val) ? TM_GPIO_SetPinHigh(GPIOx, GPIO_Pin) : TM_GPIO_SetPinLow(GPIOx, GPIO_Pin))
the_sz 12:a89096944f20 296
the_sz 12:a89096944f20 297 /**
the_sz 12:a89096944f20 298 * @brief Toggles pin(s)
the_sz 12:a89096944f20 299 * @note Defined as macro to get maximum speed using register access
the_sz 12:a89096944f20 300 * @param GPIOx: GPIOx PORT where you want to toggle pin value
the_sz 12:a89096944f20 301 * @param GPIO_Pin: Select GPIO pin(s). You can select more pins with | (OR) operator to toggle them all at a time
the_sz 12:a89096944f20 302 * @retval None
the_sz 12:a89096944f20 303 */
the_sz 12:a89096944f20 304 #define TM_GPIO_TogglePinValue(GPIOx, GPIO_Pin) ((GPIOx)->ODR ^= (GPIO_Pin))
the_sz 12:a89096944f20 305
the_sz 12:a89096944f20 306 /**
the_sz 12:a89096944f20 307 * @brief Sets value to entire GPIO PORT
the_sz 12:a89096944f20 308 * @note Defined as macro to get maximum speed using register access
the_sz 12:a89096944f20 309 * @param GPIOx: GPIOx PORT where you want to set value
the_sz 12:a89096944f20 310 * @param value: Value for GPIO OUTPUT data
the_sz 12:a89096944f20 311 * @retval None
the_sz 12:a89096944f20 312 */
the_sz 12:a89096944f20 313 #define TM_GPIO_SetPortValue(GPIOx, value) ((GPIOx)->ODR = (value))
the_sz 12:a89096944f20 314
the_sz 12:a89096944f20 315 /**
the_sz 12:a89096944f20 316 * @brief Gets input data bit
the_sz 12:a89096944f20 317 * @note Defined as macro to get maximum speed using register access
the_sz 12:a89096944f20 318 * @param GPIOx: GPIOx PORT where you want to read input bit value
the_sz 12:a89096944f20 319 * @param GPIO_Pin: GPIO pin where you want to read value
the_sz 12:a89096944f20 320 * @retval 1 in case pin is high, or 0 if low
the_sz 12:a89096944f20 321 */
the_sz 12:a89096944f20 322 #define TM_GPIO_GetInputPinValue(GPIOx, GPIO_Pin) (((GPIOx)->IDR & (GPIO_Pin)) == 0 ? 0 : 1)
the_sz 12:a89096944f20 323
the_sz 12:a89096944f20 324 /**
the_sz 12:a89096944f20 325 * @brief Gets output data bit
the_sz 12:a89096944f20 326 * @note Defined as macro to get maximum speed using register access
the_sz 12:a89096944f20 327 * @param GPIOx: GPIOx PORT where you want to read output bit value
the_sz 12:a89096944f20 328 * @param GPIO_Pin: GPIO pin where you want to read value
the_sz 12:a89096944f20 329 * @retval 1 in case pin is high, or 0 if low
the_sz 12:a89096944f20 330 */
the_sz 12:a89096944f20 331 #define TM_GPIO_GetOutputPinValue(GPIOx, GPIO_Pin) (((GPIOx)->ODR & (GPIO_Pin)) == 0 ? 0 : 1)
the_sz 12:a89096944f20 332
the_sz 12:a89096944f20 333 /**
the_sz 12:a89096944f20 334 * @brief Gets input value from entire GPIO PORT
the_sz 12:a89096944f20 335 * @note Defined as macro to get maximum speed using register access
the_sz 12:a89096944f20 336 * @param GPIOx: GPIOx PORT where you want to read input data value
the_sz 12:a89096944f20 337 * @retval Entire PORT INPUT register
the_sz 12:a89096944f20 338 */
the_sz 12:a89096944f20 339 #define TM_GPIO_GetPortInputValue(GPIOx) ((GPIOx)->IDR)
the_sz 12:a89096944f20 340
the_sz 12:a89096944f20 341 /**
the_sz 12:a89096944f20 342 * @brief Gets output value from entire GPIO PORT
the_sz 12:a89096944f20 343 * @note Defined as macro to get maximum speed using register access
the_sz 12:a89096944f20 344 * @param GPIOx: GPIOx PORT where you want to read output data value
the_sz 12:a89096944f20 345 * @retval Entire PORT OUTPUT register
the_sz 12:a89096944f20 346 */
the_sz 12:a89096944f20 347 #define TM_GPIO_GetPortOutputValue(GPIOx) ((GPIOx)->ODR)
the_sz 12:a89096944f20 348
the_sz 12:a89096944f20 349 /**
the_sz 12:a89096944f20 350 * @brief Gets port source from desired GPIOx PORT
the_sz 12:a89096944f20 351 * @note Meant for private use, unless you know what are you doing
the_sz 12:a89096944f20 352 * @param GPIOx: GPIO PORT for calculating port source
the_sz 12:a89096944f20 353 * @retval Calculated port source for GPIO
the_sz 12:a89096944f20 354 */
the_sz 12:a89096944f20 355 uint16_t TM_GPIO_GetPortSource(GPIO_TypeDef* GPIOx);
the_sz 12:a89096944f20 356
the_sz 12:a89096944f20 357 /**
the_sz 12:a89096944f20 358 * @brief Gets pin source from desired GPIO pin
the_sz 12:a89096944f20 359 * @note Meant for private use, unless you know what are you doing
the_sz 12:a89096944f20 360 * @param GPIO_Pin: GPIO pin for calculating port source
the_sz 12:a89096944f20 361 * @retval Calculated pin source for GPIO pin
the_sz 12:a89096944f20 362 */
the_sz 12:a89096944f20 363 uint16_t TM_GPIO_GetPinSource(uint16_t GPIO_Pin);
the_sz 12:a89096944f20 364
the_sz 12:a89096944f20 365 /**
the_sz 12:a89096944f20 366 * @brief Locks GPIOx register for future changes
the_sz 12:a89096944f20 367 * @note You are not able to config GPIO registers until new MCU reset occurs
the_sz 12:a89096944f20 368 * @param *GPIOx: GPIOx PORT where you want to lock config registers
the_sz 12:a89096944f20 369 * @param GPIO_Pin: GPIO pin(s) where you want to lock config registers
the_sz 12:a89096944f20 370 * @retval None
the_sz 12:a89096944f20 371 */
the_sz 12:a89096944f20 372 void TM_GPIO_Lock(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
the_sz 12:a89096944f20 373
the_sz 12:a89096944f20 374 /**
the_sz 12:a89096944f20 375 * @brief Gets bit separated pins which were used at least once in library and were not deinitialized
the_sz 12:a89096944f20 376 * @param *GPIOx: Pointer to GPIOx peripheral where to check used GPIO pins
the_sz 12:a89096944f20 377 * @retval Bit values for used pins
the_sz 12:a89096944f20 378 */
the_sz 12:a89096944f20 379 uint16_t TM_GPIO_GetUsedPins(GPIO_TypeDef* GPIOx);
the_sz 12:a89096944f20 380
the_sz 12:a89096944f20 381 /**
the_sz 12:a89096944f20 382 * @brief Gets bit separated pins which were not used at in library or were deinitialized
the_sz 12:a89096944f20 383 * @param *GPIOx: Pointer to GPIOx peripheral where to check used GPIO pins
the_sz 12:a89096944f20 384 * @retval Bit values for free pins
the_sz 12:a89096944f20 385 */
the_sz 12:a89096944f20 386 uint16_t TM_GPIO_GetFreePins(GPIO_TypeDef* GPIOx);
the_sz 12:a89096944f20 387
the_sz 12:a89096944f20 388 /**
the_sz 12:a89096944f20 389 * @}
the_sz 12:a89096944f20 390 */
the_sz 12:a89096944f20 391 /**
the_sz 12:a89096944f20 392 * @}
the_sz 12:a89096944f20 393 */
the_sz 12:a89096944f20 394 /**
the_sz 12:a89096944f20 395 * @}
the_sz 12:a89096944f20 396 */
the_sz 12:a89096944f20 397
the_sz 12:a89096944f20 398 /* C++ detection */
the_sz 12:a89096944f20 399 #ifdef __cplusplus
the_sz 12:a89096944f20 400 }
the_sz 12:a89096944f20 401 #endif
the_sz 12:a89096944f20 402
the_sz 12:a89096944f20 403 #endif