BSP Drivers
Dependencies: CMSIS_STM32L4xx CMSIS_DSP_401 STM32L4xx_HAL_Driver
Disco/stm32l476g_discovery.h@4:a1219ef3537f, 2015-11-22 (annotated)
- Committer:
- EricLew
- Date:
- Sun Nov 22 21:15:34 2015 +0000
- Revision:
- 4:a1219ef3537f
- Parent:
- 0:ad9dfc0179dc
11/22/2015
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
EricLew | 0:ad9dfc0179dc | 1 | /** |
EricLew | 0:ad9dfc0179dc | 2 | ****************************************************************************** |
EricLew | 0:ad9dfc0179dc | 3 | * @file stm32l476g_discovery.h |
EricLew | 0:ad9dfc0179dc | 4 | * @author MCD Application Team |
EricLew | 0:ad9dfc0179dc | 5 | * @version V1.0.1 |
EricLew | 0:ad9dfc0179dc | 6 | * @date 16-September-2015 |
EricLew | 0:ad9dfc0179dc | 7 | * @brief This file contains definitions for STM32L476G_DISCOVERY's LEDs, |
EricLew | 0:ad9dfc0179dc | 8 | * push-buttons hardware resources (MB1184). |
EricLew | 0:ad9dfc0179dc | 9 | ****************************************************************************** |
EricLew | 0:ad9dfc0179dc | 10 | * @attention |
EricLew | 0:ad9dfc0179dc | 11 | * |
EricLew | 0:ad9dfc0179dc | 12 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
EricLew | 0:ad9dfc0179dc | 13 | * |
EricLew | 0:ad9dfc0179dc | 14 | * Redistribution and use in source and binary forms, with or without modification, |
EricLew | 0:ad9dfc0179dc | 15 | * are permitted provided that the following conditions are met: |
EricLew | 0:ad9dfc0179dc | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
EricLew | 0:ad9dfc0179dc | 17 | * this list of conditions and the following disclaimer. |
EricLew | 0:ad9dfc0179dc | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
EricLew | 0:ad9dfc0179dc | 19 | * this list of conditions and the following disclaimer in the documentation |
EricLew | 0:ad9dfc0179dc | 20 | * and/or other materials provided with the distribution. |
EricLew | 0:ad9dfc0179dc | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
EricLew | 0:ad9dfc0179dc | 22 | * may be used to endorse or promote products derived from this software |
EricLew | 0:ad9dfc0179dc | 23 | * without specific prior written permission. |
EricLew | 0:ad9dfc0179dc | 24 | * |
EricLew | 0:ad9dfc0179dc | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
EricLew | 0:ad9dfc0179dc | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
EricLew | 0:ad9dfc0179dc | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
EricLew | 0:ad9dfc0179dc | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
EricLew | 0:ad9dfc0179dc | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
EricLew | 0:ad9dfc0179dc | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
EricLew | 0:ad9dfc0179dc | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
EricLew | 0:ad9dfc0179dc | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
EricLew | 0:ad9dfc0179dc | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
EricLew | 0:ad9dfc0179dc | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
EricLew | 0:ad9dfc0179dc | 35 | * |
EricLew | 0:ad9dfc0179dc | 36 | ****************************************************************************** |
EricLew | 0:ad9dfc0179dc | 37 | */ |
EricLew | 0:ad9dfc0179dc | 38 | |
EricLew | 0:ad9dfc0179dc | 39 | /* Define to prevent recursive inclusion -------------------------------------*/ |
EricLew | 0:ad9dfc0179dc | 40 | #ifndef __STM32L476G_DISCOVERY_H |
EricLew | 0:ad9dfc0179dc | 41 | #define __STM32L476G_DISCOVERY_H |
EricLew | 0:ad9dfc0179dc | 42 | |
EricLew | 0:ad9dfc0179dc | 43 | #ifdef __cplusplus |
EricLew | 0:ad9dfc0179dc | 44 | extern "C" { |
EricLew | 0:ad9dfc0179dc | 45 | #endif |
EricLew | 0:ad9dfc0179dc | 46 | |
EricLew | 0:ad9dfc0179dc | 47 | /** |
EricLew | 0:ad9dfc0179dc | 48 | * @brief Define for STM32L476G_DISCOVERY board |
EricLew | 0:ad9dfc0179dc | 49 | */ |
EricLew | 0:ad9dfc0179dc | 50 | #if !defined (USE_STM32L476G_DISCO_REVC) && !defined (USE_STM32L476G_DISCO_REVB) && !defined (USE_STM32L476G_DISCO_REVA) |
EricLew | 0:ad9dfc0179dc | 51 | #define USE_STM32L476G_DISCO_REVC |
EricLew | 0:ad9dfc0179dc | 52 | #endif |
EricLew | 0:ad9dfc0179dc | 53 | |
EricLew | 0:ad9dfc0179dc | 54 | |
EricLew | 0:ad9dfc0179dc | 55 | /* Includes ------------------------------------------------------------------*/ |
EricLew | 0:ad9dfc0179dc | 56 | #include "stm32l4xx_hal.h" |
EricLew | 0:ad9dfc0179dc | 57 | |
EricLew | 0:ad9dfc0179dc | 58 | /** @addtogroup BSP |
EricLew | 0:ad9dfc0179dc | 59 | * @{ |
EricLew | 0:ad9dfc0179dc | 60 | */ |
EricLew | 0:ad9dfc0179dc | 61 | |
EricLew | 0:ad9dfc0179dc | 62 | /** @addtogroup STM32L476G_DISCOVERY |
EricLew | 0:ad9dfc0179dc | 63 | * @{ |
EricLew | 0:ad9dfc0179dc | 64 | */ |
EricLew | 0:ad9dfc0179dc | 65 | |
EricLew | 0:ad9dfc0179dc | 66 | /** @addtogroup STM32L476G_DISCOVERY_Common |
EricLew | 0:ad9dfc0179dc | 67 | * @{ |
EricLew | 0:ad9dfc0179dc | 68 | */ |
EricLew | 0:ad9dfc0179dc | 69 | |
EricLew | 0:ad9dfc0179dc | 70 | /** @defgroup STM32L476G_DISCOVERY_Exported_Types Exported Types |
EricLew | 0:ad9dfc0179dc | 71 | * @{ |
EricLew | 0:ad9dfc0179dc | 72 | */ |
EricLew | 0:ad9dfc0179dc | 73 | |
EricLew | 0:ad9dfc0179dc | 74 | /** |
EricLew | 0:ad9dfc0179dc | 75 | * @brief LED Types Definition |
EricLew | 0:ad9dfc0179dc | 76 | */ |
EricLew | 0:ad9dfc0179dc | 77 | #if defined (USE_STM32L476G_DISCO_REVC) || defined (USE_STM32L476G_DISCO_REVB) |
EricLew | 0:ad9dfc0179dc | 78 | typedef enum |
EricLew | 0:ad9dfc0179dc | 79 | { |
EricLew | 0:ad9dfc0179dc | 80 | LED4 = 0, |
EricLew | 0:ad9dfc0179dc | 81 | LED5 = 1, |
EricLew | 0:ad9dfc0179dc | 82 | LED_RED = LED4, |
EricLew | 0:ad9dfc0179dc | 83 | LED_GREEN = LED5 |
EricLew | 0:ad9dfc0179dc | 84 | }Led_TypeDef; |
EricLew | 0:ad9dfc0179dc | 85 | #elif defined (USE_STM32L476G_DISCO_REVA) |
EricLew | 0:ad9dfc0179dc | 86 | typedef enum |
EricLew | 0:ad9dfc0179dc | 87 | { |
EricLew | 0:ad9dfc0179dc | 88 | LED3 = 0, |
EricLew | 0:ad9dfc0179dc | 89 | LED4 = 1, |
EricLew | 0:ad9dfc0179dc | 90 | LED_RED = LED3, |
EricLew | 0:ad9dfc0179dc | 91 | LED_GREEN = LED4 |
EricLew | 0:ad9dfc0179dc | 92 | }Led_TypeDef; |
EricLew | 0:ad9dfc0179dc | 93 | #endif |
EricLew | 0:ad9dfc0179dc | 94 | |
EricLew | 0:ad9dfc0179dc | 95 | /** |
EricLew | 0:ad9dfc0179dc | 96 | * @brief JOYSTICK Types Definition |
EricLew | 0:ad9dfc0179dc | 97 | */ |
EricLew | 0:ad9dfc0179dc | 98 | typedef enum |
EricLew | 0:ad9dfc0179dc | 99 | { |
EricLew | 0:ad9dfc0179dc | 100 | JOY_SEL = 0, |
EricLew | 0:ad9dfc0179dc | 101 | JOY_LEFT = 1, |
EricLew | 0:ad9dfc0179dc | 102 | JOY_RIGHT = 2, |
EricLew | 0:ad9dfc0179dc | 103 | JOY_DOWN = 3, |
EricLew | 0:ad9dfc0179dc | 104 | JOY_UP = 4, |
EricLew | 0:ad9dfc0179dc | 105 | JOY_NONE = 5 |
EricLew | 0:ad9dfc0179dc | 106 | }JOYState_TypeDef; |
EricLew | 0:ad9dfc0179dc | 107 | |
EricLew | 0:ad9dfc0179dc | 108 | typedef enum |
EricLew | 0:ad9dfc0179dc | 109 | { |
EricLew | 0:ad9dfc0179dc | 110 | JOY_MODE_GPIO = 0, |
EricLew | 0:ad9dfc0179dc | 111 | JOY_MODE_EXTI = 1 |
EricLew | 0:ad9dfc0179dc | 112 | }JOYMode_TypeDef; |
EricLew | 0:ad9dfc0179dc | 113 | |
EricLew | 0:ad9dfc0179dc | 114 | typedef enum |
EricLew | 0:ad9dfc0179dc | 115 | { |
EricLew | 0:ad9dfc0179dc | 116 | SUPPLY_MODE_ERROR = 0, |
EricLew | 0:ad9dfc0179dc | 117 | SUPPLY_MODE_EXTERNAL = 1, |
EricLew | 0:ad9dfc0179dc | 118 | SUPPLY_MODE_BATTERY = 2 |
EricLew | 0:ad9dfc0179dc | 119 | }SupplyMode_TypeDef; |
EricLew | 0:ad9dfc0179dc | 120 | |
EricLew | 0:ad9dfc0179dc | 121 | /** |
EricLew | 0:ad9dfc0179dc | 122 | * @} |
EricLew | 0:ad9dfc0179dc | 123 | */ |
EricLew | 0:ad9dfc0179dc | 124 | |
EricLew | 0:ad9dfc0179dc | 125 | /** @defgroup STM32L476G_DISCOVERY_Exported_Constants Exported Constants |
EricLew | 0:ad9dfc0179dc | 126 | * @{ |
EricLew | 0:ad9dfc0179dc | 127 | */ |
EricLew | 0:ad9dfc0179dc | 128 | |
EricLew | 0:ad9dfc0179dc | 129 | /** @defgroup STM32L476G_DISCOVERY_BATTERY BATTERY Detection Constants |
EricLew | 0:ad9dfc0179dc | 130 | * @{ |
EricLew | 0:ad9dfc0179dc | 131 | */ |
EricLew | 0:ad9dfc0179dc | 132 | #define BATTERY_DETECTION_PIN GPIO_PIN_3 |
EricLew | 0:ad9dfc0179dc | 133 | #define BATTERY_DETECTION_GPIO_PORT GPIOB |
EricLew | 0:ad9dfc0179dc | 134 | #define BATTERY_DETECTION_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 135 | #define BATTERY_DETECTION_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 136 | /** |
EricLew | 0:ad9dfc0179dc | 137 | * @} |
EricLew | 0:ad9dfc0179dc | 138 | */ |
EricLew | 0:ad9dfc0179dc | 139 | |
EricLew | 0:ad9dfc0179dc | 140 | /** @defgroup STM32L476G_DISCOVERY_LED LED Constants |
EricLew | 0:ad9dfc0179dc | 141 | * @{ |
EricLew | 0:ad9dfc0179dc | 142 | */ |
EricLew | 0:ad9dfc0179dc | 143 | #define LEDn 2 |
EricLew | 0:ad9dfc0179dc | 144 | |
EricLew | 0:ad9dfc0179dc | 145 | #if defined (USE_STM32L476G_DISCO_REVC) || defined (USE_STM32L476G_DISCO_REVB) |
EricLew | 0:ad9dfc0179dc | 146 | #define LED4_PIN GPIO_PIN_2 |
EricLew | 0:ad9dfc0179dc | 147 | #define LED4_GPIO_PORT GPIOB |
EricLew | 0:ad9dfc0179dc | 148 | #define LED4_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 149 | #define LED4_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 150 | |
EricLew | 0:ad9dfc0179dc | 151 | #define LED5_PIN GPIO_PIN_8 |
EricLew | 0:ad9dfc0179dc | 152 | #define LED5_GPIO_PORT GPIOE |
EricLew | 0:ad9dfc0179dc | 153 | #define LED5_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 154 | #define LED5_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 155 | |
EricLew | 0:ad9dfc0179dc | 156 | #define LEDx_GPIO_CLK_ENABLE(__LED__) do { if((__LED__) == LED4) { LED4_GPIO_CLK_ENABLE(); } else \ |
EricLew | 0:ad9dfc0179dc | 157 | if((__LED__) == LED5) { LED5_GPIO_CLK_ENABLE(); } } while(0) |
EricLew | 0:ad9dfc0179dc | 158 | |
EricLew | 0:ad9dfc0179dc | 159 | #define LEDx_GPIO_CLK_DISABLE(__LED__) do { if((__LED__) == LED4) { LED4_GPIO_CLK_DISABLE(); } else \ |
EricLew | 0:ad9dfc0179dc | 160 | if((__LED__) == LED5) { LED5_GPIO_CLK_DISABLE(); } } while(0) |
EricLew | 0:ad9dfc0179dc | 161 | |
EricLew | 0:ad9dfc0179dc | 162 | #elif defined (USE_STM32L476G_DISCO_REVA) |
EricLew | 0:ad9dfc0179dc | 163 | #define LED3_PIN GPIO_PIN_2 |
EricLew | 0:ad9dfc0179dc | 164 | #define LED3_GPIO_PORT GPIOB |
EricLew | 0:ad9dfc0179dc | 165 | #define LED3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 166 | #define LED3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 167 | |
EricLew | 0:ad9dfc0179dc | 168 | #define LED4_PIN GPIO_PIN_8 |
EricLew | 0:ad9dfc0179dc | 169 | #define LED4_GPIO_PORT GPIOE |
EricLew | 0:ad9dfc0179dc | 170 | #define LED4_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 171 | #define LED4_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 172 | |
EricLew | 0:ad9dfc0179dc | 173 | #define LEDx_GPIO_CLK_ENABLE(__LED__) do { if((__LED__) == LED3) { LED3_GPIO_CLK_ENABLE(); } else \ |
EricLew | 0:ad9dfc0179dc | 174 | if((__LED__) == LED4) { LED4_GPIO_CLK_ENABLE(); } } while(0) |
EricLew | 0:ad9dfc0179dc | 175 | |
EricLew | 0:ad9dfc0179dc | 176 | #define LEDx_GPIO_CLK_DISABLE(__LED__) do { if((__LED__) == LED3) { LED3_GPIO_CLK_DISABLE(); } else \ |
EricLew | 0:ad9dfc0179dc | 177 | if((__LED__) == LED4) { LED4_GPIO_CLK_DISABLE(); } } while(0) |
EricLew | 0:ad9dfc0179dc | 178 | |
EricLew | 0:ad9dfc0179dc | 179 | #endif |
EricLew | 0:ad9dfc0179dc | 180 | /** |
EricLew | 0:ad9dfc0179dc | 181 | * @} |
EricLew | 0:ad9dfc0179dc | 182 | */ |
EricLew | 0:ad9dfc0179dc | 183 | |
EricLew | 0:ad9dfc0179dc | 184 | /** @defgroup STM32L476G_DISCOVERY_BUTTON BUTTON Constants |
EricLew | 0:ad9dfc0179dc | 185 | * @{ |
EricLew | 0:ad9dfc0179dc | 186 | */ |
EricLew | 0:ad9dfc0179dc | 187 | #define JOYn 5 |
EricLew | 0:ad9dfc0179dc | 188 | |
EricLew | 0:ad9dfc0179dc | 189 | /** |
EricLew | 0:ad9dfc0179dc | 190 | * @brief Joystick Right push-button |
EricLew | 0:ad9dfc0179dc | 191 | */ |
EricLew | 0:ad9dfc0179dc | 192 | #define RIGHT_JOY_PIN GPIO_PIN_2 /* PA.02 */ |
EricLew | 0:ad9dfc0179dc | 193 | #define RIGHT_JOY_GPIO_PORT GPIOA |
EricLew | 0:ad9dfc0179dc | 194 | #define RIGHT_JOY_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 195 | #define RIGHT_JOY_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 196 | #define RIGHT_JOY_EXTI_IRQn EXTI2_IRQn |
EricLew | 0:ad9dfc0179dc | 197 | |
EricLew | 0:ad9dfc0179dc | 198 | /** |
EricLew | 0:ad9dfc0179dc | 199 | * @brief Joystick Left push-button |
EricLew | 0:ad9dfc0179dc | 200 | */ |
EricLew | 0:ad9dfc0179dc | 201 | #define LEFT_JOY_PIN GPIO_PIN_1 /* PA.01 */ |
EricLew | 0:ad9dfc0179dc | 202 | #define LEFT_JOY_GPIO_PORT GPIOA |
EricLew | 0:ad9dfc0179dc | 203 | #define LEFT_JOY_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 204 | #define LEFT_JOY_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 205 | #define LEFT_JOY_EXTI_IRQn EXTI1_IRQn |
EricLew | 0:ad9dfc0179dc | 206 | |
EricLew | 0:ad9dfc0179dc | 207 | /** |
EricLew | 0:ad9dfc0179dc | 208 | * @brief Joystick Up push-button |
EricLew | 0:ad9dfc0179dc | 209 | */ |
EricLew | 0:ad9dfc0179dc | 210 | #define UP_JOY_PIN GPIO_PIN_3 /* PA.03 */ |
EricLew | 0:ad9dfc0179dc | 211 | #define UP_JOY_GPIO_PORT GPIOA |
EricLew | 0:ad9dfc0179dc | 212 | #define UP_JOY_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 213 | #define UP_JOY_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 214 | #define UP_JOY_EXTI_IRQn EXTI3_IRQn |
EricLew | 0:ad9dfc0179dc | 215 | |
EricLew | 0:ad9dfc0179dc | 216 | /** |
EricLew | 0:ad9dfc0179dc | 217 | * @brief Joystick Down push-button |
EricLew | 0:ad9dfc0179dc | 218 | */ |
EricLew | 0:ad9dfc0179dc | 219 | #define DOWN_JOY_PIN GPIO_PIN_5 /* PA.05 */ |
EricLew | 0:ad9dfc0179dc | 220 | #define DOWN_JOY_GPIO_PORT GPIOA |
EricLew | 0:ad9dfc0179dc | 221 | #define DOWN_JOY_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 222 | #define DOWN_JOY_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 223 | #define DOWN_JOY_EXTI_IRQn EXTI9_5_IRQn |
EricLew | 0:ad9dfc0179dc | 224 | |
EricLew | 0:ad9dfc0179dc | 225 | /** |
EricLew | 0:ad9dfc0179dc | 226 | * @brief Joystick Sel push-button |
EricLew | 0:ad9dfc0179dc | 227 | */ |
EricLew | 0:ad9dfc0179dc | 228 | #define SEL_JOY_PIN GPIO_PIN_0 /* PA.00 */ |
EricLew | 0:ad9dfc0179dc | 229 | #define SEL_JOY_GPIO_PORT GPIOA |
EricLew | 0:ad9dfc0179dc | 230 | #define SEL_JOY_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 231 | #define SEL_JOY_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 232 | #define SEL_JOY_EXTI_IRQn EXTI0_IRQn |
EricLew | 0:ad9dfc0179dc | 233 | |
EricLew | 0:ad9dfc0179dc | 234 | #define JOYx_GPIO_CLK_ENABLE(__JOY__) do { if((__JOY__) == JOY_SEL) { SEL_JOY_GPIO_CLK_ENABLE(); } else \ |
EricLew | 0:ad9dfc0179dc | 235 | if((__JOY__) == JOY_DOWN) { DOWN_JOY_GPIO_CLK_ENABLE(); } else \ |
EricLew | 0:ad9dfc0179dc | 236 | if((__JOY__) == JOY_LEFT) { LEFT_JOY_GPIO_CLK_ENABLE(); } else \ |
EricLew | 0:ad9dfc0179dc | 237 | if((__JOY__) == JOY_RIGHT) { RIGHT_JOY_GPIO_CLK_ENABLE(); } else \ |
EricLew | 0:ad9dfc0179dc | 238 | if((__JOY__) == JOY_UP) { UP_JOY_GPIO_CLK_ENABLE(); } } while(0) |
EricLew | 0:ad9dfc0179dc | 239 | |
EricLew | 0:ad9dfc0179dc | 240 | #define JOYx_GPIO_CLK_DISABLE(__JOY__) do { if((__JOY__) == JOY_SEL) { SEL_JOY_GPIO_CLK_DISABLE(); } else \ |
EricLew | 0:ad9dfc0179dc | 241 | if((__JOY__) == JOY_DOWN) { DOWN_JOY_GPIO_CLK_DISABLE(); } else \ |
EricLew | 0:ad9dfc0179dc | 242 | if((__JOY__) == JOY_LEFT) { LEFT_JOY_GPIO_CLK_DISABLE(); } else \ |
EricLew | 0:ad9dfc0179dc | 243 | if((__JOY__) == JOY_RIGHT) { RIGHT_JOY_GPIO_CLK_DISABLE(); } else \ |
EricLew | 0:ad9dfc0179dc | 244 | if((__JOY__) == JOY_UP) { UP_JOY_GPIO_CLK_DISABLE(); } } while(0) |
EricLew | 0:ad9dfc0179dc | 245 | |
EricLew | 0:ad9dfc0179dc | 246 | #define JOY_ALL_PINS (RIGHT_JOY_PIN | LEFT_JOY_PIN | UP_JOY_PIN | DOWN_JOY_PIN | SEL_JOY_PIN) |
EricLew | 0:ad9dfc0179dc | 247 | |
EricLew | 0:ad9dfc0179dc | 248 | /** |
EricLew | 0:ad9dfc0179dc | 249 | * @} |
EricLew | 0:ad9dfc0179dc | 250 | */ |
EricLew | 0:ad9dfc0179dc | 251 | |
EricLew | 0:ad9dfc0179dc | 252 | /** @defgroup STM32L476G_DISCOVERY_BUS BUS Constants |
EricLew | 0:ad9dfc0179dc | 253 | * @{ |
EricLew | 0:ad9dfc0179dc | 254 | */ |
EricLew | 0:ad9dfc0179dc | 255 | #if defined(HAL_SPI_MODULE_ENABLED) |
EricLew | 0:ad9dfc0179dc | 256 | /*##################### SPI2 ###################################*/ |
EricLew | 0:ad9dfc0179dc | 257 | #define DISCOVERY_SPIx SPI2 |
EricLew | 0:ad9dfc0179dc | 258 | #define DISCOVERY_SPIx_CLOCK_ENABLE() __HAL_RCC_SPI2_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 259 | #define DISCOVERY_SPIx_CLOCK_DISABLE() __HAL_RCC_SPI2_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 260 | #define DISCOVERY_SPIx_GPIO_PORT GPIOD /* GPIOD */ |
EricLew | 0:ad9dfc0179dc | 261 | #define DISCOVERY_SPIx_AF GPIO_AF5_SPI2 |
EricLew | 0:ad9dfc0179dc | 262 | #define DISCOVERY_SPIx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 263 | #define DISCOVERY_SPIx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 264 | #define DISCOVERY_SPIx_GPIO_FORCE_RESET() __HAL_RCC_SPI2_FORCE_RESET() |
EricLew | 0:ad9dfc0179dc | 265 | #define DISCOVERY_SPIx_GPIO_RELEASE_RESET() __HAL_RCC_SPI2_RELEASE_RESET() |
EricLew | 0:ad9dfc0179dc | 266 | #define DISCOVERY_SPIx_SCK_PIN GPIO_PIN_1 /* PD.01*/ |
EricLew | 0:ad9dfc0179dc | 267 | #define DISCOVERY_SPIx_MISO_PIN GPIO_PIN_3 /* PD.03 */ |
EricLew | 0:ad9dfc0179dc | 268 | #define DISCOVERY_SPIx_MOSI_PIN GPIO_PIN_4 /* PD.04 */ |
EricLew | 0:ad9dfc0179dc | 269 | |
EricLew | 0:ad9dfc0179dc | 270 | /* Maximum Timeout values for flags waiting loops. These timeouts are not based |
EricLew | 0:ad9dfc0179dc | 271 | on accurate values, they just guarantee that the application will not remain |
EricLew | 0:ad9dfc0179dc | 272 | stuck if the SPI communication is corrupted. |
EricLew | 0:ad9dfc0179dc | 273 | You may modify these timeout values depending on CPU frequency and application |
EricLew | 0:ad9dfc0179dc | 274 | conditions (interrupts routines ...). */ |
EricLew | 0:ad9dfc0179dc | 275 | #define SPIx_TIMEOUT_MAX ((uint32_t)0x1000) |
EricLew | 0:ad9dfc0179dc | 276 | /* Read/Write command */ |
EricLew | 0:ad9dfc0179dc | 277 | #define READWRITE_CMD ((uint8_t)0x80) |
EricLew | 0:ad9dfc0179dc | 278 | /* Multiple byte read/write command */ |
EricLew | 0:ad9dfc0179dc | 279 | #define MULTIPLEBYTE_CMD ((uint8_t)0x40) |
EricLew | 0:ad9dfc0179dc | 280 | /* Dummy Byte Send by the SPI Master device in order to generate the Clock to the Slave device */ |
EricLew | 0:ad9dfc0179dc | 281 | #define DUMMY_BYTE ((uint8_t)0x00) |
EricLew | 0:ad9dfc0179dc | 282 | |
EricLew | 0:ad9dfc0179dc | 283 | #endif /* HAL_SPI_MODULE_ENABLED */ |
EricLew | 0:ad9dfc0179dc | 284 | |
EricLew | 0:ad9dfc0179dc | 285 | #if defined(HAL_I2C_MODULE_ENABLED) |
EricLew | 0:ad9dfc0179dc | 286 | /*##################### I2C1 ###################################*/ |
EricLew | 0:ad9dfc0179dc | 287 | /* User can use this section to tailor I2C1 instance used and associated |
EricLew | 0:ad9dfc0179dc | 288 | resources */ |
EricLew | 0:ad9dfc0179dc | 289 | /* Definition for I2C1 Pins */ |
EricLew | 0:ad9dfc0179dc | 290 | #define DISCOVERY_I2C1_SCL_GPIO_PORT GPIOB |
EricLew | 0:ad9dfc0179dc | 291 | #define DISCOVERY_I2C1_SDA_GPIO_PORT GPIOB |
EricLew | 0:ad9dfc0179dc | 292 | #if defined (USE_STM32L476G_DISCO_REVC) || defined (USE_STM32L476G_DISCO_REVB) |
EricLew | 0:ad9dfc0179dc | 293 | #define DISCOVERY_I2C1_SCL_PIN GPIO_PIN_6 |
EricLew | 0:ad9dfc0179dc | 294 | #define DISCOVERY_I2C1_SDA_PIN GPIO_PIN_7 |
EricLew | 0:ad9dfc0179dc | 295 | #elif defined (USE_STM32L476G_DISCO_REVA) |
EricLew | 0:ad9dfc0179dc | 296 | #define DISCOVERY_I2C1_SCL_PIN GPIO_PIN_8 |
EricLew | 0:ad9dfc0179dc | 297 | #define DISCOVERY_I2C1_SDA_PIN GPIO_PIN_9 |
EricLew | 0:ad9dfc0179dc | 298 | #endif |
EricLew | 0:ad9dfc0179dc | 299 | #define DISCOVERY_I2C1_SCL_SDA_AF GPIO_AF4_I2C1 |
EricLew | 0:ad9dfc0179dc | 300 | |
EricLew | 0:ad9dfc0179dc | 301 | /* Definition for I2C1 clock resources */ |
EricLew | 0:ad9dfc0179dc | 302 | #define DISCOVERY_I2C1 I2C1 |
EricLew | 0:ad9dfc0179dc | 303 | #define DISCOVERY_I2C1_CLK_ENABLE() __HAL_RCC_I2C1_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 304 | #define DISCOVERY_I2C1_CLK_DISABLE() __HAL_RCC_I2C1_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 305 | #define DISCOVERY_I2C1_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 306 | #define DISCOVERY_I2C1_SCL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 307 | #define DISCOVERY_I2C1_SDA_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 308 | #define DISCOVERY_I2C1_SCL_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 309 | #define DISCOVERY_I2C1_FORCE_RESET() __HAL_RCC_I2C1_FORCE_RESET() |
EricLew | 0:ad9dfc0179dc | 310 | #define DISCOVERY_I2C1_RELEASE_RESET() __HAL_RCC_I2C1_RELEASE_RESET() |
EricLew | 0:ad9dfc0179dc | 311 | |
EricLew | 0:ad9dfc0179dc | 312 | /* Definition for I2C1's NVIC */ |
EricLew | 0:ad9dfc0179dc | 313 | #define DISCOVERY_I2C1_EV_IRQn I2C1_EV_IRQn |
EricLew | 0:ad9dfc0179dc | 314 | #define DISCOVERY_I2C1_EV_IRQHandler I2C1_EV_IRQHandler |
EricLew | 0:ad9dfc0179dc | 315 | #define DISCOVERY_I2C1_ER_IRQn I2C1_ER_IRQn |
EricLew | 0:ad9dfc0179dc | 316 | #define DISCOVERY_I2C1_ER_IRQHandler I2C1_ER_IRQHandler |
EricLew | 0:ad9dfc0179dc | 317 | |
EricLew | 0:ad9dfc0179dc | 318 | /* I2C TIMING Register define when I2C clock source is SYSCLK */ |
EricLew | 0:ad9dfc0179dc | 319 | /* I2C TIMING is calculated in case of the I2C Clock source is the SYSCLK = 80 MHz */ |
EricLew | 0:ad9dfc0179dc | 320 | /* Set 0x90112626 value to reach 100 KHz speed (Rise time = 640ns, Fall time = 20ns) */ |
EricLew | 0:ad9dfc0179dc | 321 | #ifndef DISCOVERY_I2C1_TIMING |
EricLew | 0:ad9dfc0179dc | 322 | #define DISCOVERY_I2C1_TIMING 0x90112626 |
EricLew | 0:ad9dfc0179dc | 323 | #endif /* DISCOVERY_I2C1_TIMING */ |
EricLew | 0:ad9dfc0179dc | 324 | |
EricLew | 0:ad9dfc0179dc | 325 | /* I2C clock speed configuration (in Hz) |
EricLew | 0:ad9dfc0179dc | 326 | WARNING: |
EricLew | 0:ad9dfc0179dc | 327 | Make sure that this define is not already declared in other files (ie. |
EricLew | 0:ad9dfc0179dc | 328 | stm324xg_discovery.h file). It can be used in parallel by other modules. */ |
EricLew | 0:ad9dfc0179dc | 329 | #ifndef BSP_I2C_SPEED |
EricLew | 0:ad9dfc0179dc | 330 | #define BSP_I2C_SPEED 100000 |
EricLew | 0:ad9dfc0179dc | 331 | #endif /* BSP_I2C_SPEED */ |
EricLew | 0:ad9dfc0179dc | 332 | |
EricLew | 0:ad9dfc0179dc | 333 | |
EricLew | 0:ad9dfc0179dc | 334 | /* Audio codec I2C address */ |
EricLew | 0:ad9dfc0179dc | 335 | #define AUDIO_I2C_ADDRESS ((uint16_t) 0x94) |
EricLew | 0:ad9dfc0179dc | 336 | |
EricLew | 0:ad9dfc0179dc | 337 | /* Maximum Timeout values for flags waiting loops. These timeouts are not based |
EricLew | 0:ad9dfc0179dc | 338 | on accurate values, they just guarantee that the application will not remain |
EricLew | 0:ad9dfc0179dc | 339 | stuck if the I2C communication is corrupted. |
EricLew | 0:ad9dfc0179dc | 340 | You may modify these timeout values depending on CPU frequency and application |
EricLew | 0:ad9dfc0179dc | 341 | conditions (interrupts routines ...). */ |
EricLew | 0:ad9dfc0179dc | 342 | #define DISCOVERY_I2C1_TIMEOUT_MAX 3000 |
EricLew | 0:ad9dfc0179dc | 343 | |
EricLew | 0:ad9dfc0179dc | 344 | |
EricLew | 0:ad9dfc0179dc | 345 | /*##################### I2C2 ###################################*/ |
EricLew | 0:ad9dfc0179dc | 346 | /* User can use this section to tailor I2C2 instance used and associated |
EricLew | 0:ad9dfc0179dc | 347 | resources */ |
EricLew | 0:ad9dfc0179dc | 348 | /* Definition for I2C2 Pins */ |
EricLew | 0:ad9dfc0179dc | 349 | #define DISCOVERY_I2C2_SCL_PIN GPIO_PIN_10 |
EricLew | 0:ad9dfc0179dc | 350 | #define DISCOVERY_I2C2_SCL_GPIO_PORT GPIOB |
EricLew | 0:ad9dfc0179dc | 351 | #define DISCOVERY_I2C2_SDA_PIN GPIO_PIN_11 |
EricLew | 0:ad9dfc0179dc | 352 | #define DISCOVERY_I2C2_SDA_GPIO_PORT GPIOB |
EricLew | 0:ad9dfc0179dc | 353 | #define DISCOVERY_I2C2_SCL_SDA_AF GPIO_AF4_I2C2 |
EricLew | 0:ad9dfc0179dc | 354 | /* Definition for I2C2 clock resources */ |
EricLew | 0:ad9dfc0179dc | 355 | #define DISCOVERY_I2C2 I2C2 |
EricLew | 0:ad9dfc0179dc | 356 | #define DISCOVERY_I2C2_CLK_ENABLE() __HAL_RCC_I2C2_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 357 | #define DISCOVERY_I2C2_CLK_DISABLE() __HAL_RCC_I2C2_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 358 | #define DISCOVERY_I2C2_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 359 | #define DISCOVERY_I2C2_SCL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 360 | #define DISCOVERY_I2C2_SDA_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 361 | #define DISCOVERY_I2C2_SCL_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 362 | #define DISCOVERY_I2C2_FORCE_RESET() __HAL_RCC_I2C2_FORCE_RESET() |
EricLew | 0:ad9dfc0179dc | 363 | #define DISCOVERY_I2C2_RELEASE_RESET() __HAL_RCC_I2C2_RELEASE_RESET() |
EricLew | 0:ad9dfc0179dc | 364 | |
EricLew | 0:ad9dfc0179dc | 365 | /* Definition for I2C2's NVIC */ |
EricLew | 0:ad9dfc0179dc | 366 | #define DISCOVERY_I2C2_EV_IRQn I2C2_EV_IRQn |
EricLew | 0:ad9dfc0179dc | 367 | #define DISCOVERY_I2C2_ER_IRQn I2C2_ER_IRQn |
EricLew | 0:ad9dfc0179dc | 368 | |
EricLew | 0:ad9dfc0179dc | 369 | /* I2C TIMING Register define when I2C clock source is SYSCLK */ |
EricLew | 0:ad9dfc0179dc | 370 | /* I2C TIMING is calculated in case of the I2C Clock source is the SYSCLK = 80 MHz */ |
EricLew | 0:ad9dfc0179dc | 371 | /* Set 0x90112626 value to reach 100 KHz speed (Rise time = 640ns, Fall time = 20ns) */ |
EricLew | 0:ad9dfc0179dc | 372 | #ifndef DISCOVERY_I2C2_TIMING |
EricLew | 0:ad9dfc0179dc | 373 | #define DISCOVERY_I2C2_TIMING 0x90112626 |
EricLew | 0:ad9dfc0179dc | 374 | #endif /* DISCOVERY_I2C2_TIMING */ |
EricLew | 0:ad9dfc0179dc | 375 | |
EricLew | 0:ad9dfc0179dc | 376 | /* I2C clock speed configuration (in Hz) |
EricLew | 0:ad9dfc0179dc | 377 | WARNING: |
EricLew | 0:ad9dfc0179dc | 378 | Make sure that this define is not already declared in other files (ie. |
EricLew | 0:ad9dfc0179dc | 379 | stm324xg_discovery.h file). It can be used in parallel by other modules. */ |
EricLew | 0:ad9dfc0179dc | 380 | #ifndef BSP_I2C_SPEED |
EricLew | 0:ad9dfc0179dc | 381 | #define BSP_I2C_SPEED 100000 |
EricLew | 0:ad9dfc0179dc | 382 | #endif /* BSP_I2C_SPEED */ |
EricLew | 0:ad9dfc0179dc | 383 | |
EricLew | 0:ad9dfc0179dc | 384 | #define IDD_I2C_ADDRESS ((uint16_t) 0x84) |
EricLew | 0:ad9dfc0179dc | 385 | |
EricLew | 0:ad9dfc0179dc | 386 | /* Maximum Timeout values for flags waiting loops. These timeouts are not based |
EricLew | 0:ad9dfc0179dc | 387 | on accurate values, they just guarantee that the application will not remain |
EricLew | 0:ad9dfc0179dc | 388 | stuck if the I2C communication is corrupted. |
EricLew | 0:ad9dfc0179dc | 389 | You may modify these timeout values depending on CPU frequency and application |
EricLew | 0:ad9dfc0179dc | 390 | conditions (interrupts routines ...). */ |
EricLew | 0:ad9dfc0179dc | 391 | #define DISCOVERY_I2C2_TIMEOUT_MAX 3000 |
EricLew | 0:ad9dfc0179dc | 392 | #endif /* HAL_I2C_MODULE_ENABLED */ |
EricLew | 0:ad9dfc0179dc | 393 | |
EricLew | 0:ad9dfc0179dc | 394 | /*##################### Accelerometer ##########################*/ |
EricLew | 0:ad9dfc0179dc | 395 | /** |
EricLew | 0:ad9dfc0179dc | 396 | * @brief Accelerometer Chip Select macro definition |
EricLew | 0:ad9dfc0179dc | 397 | */ |
EricLew | 0:ad9dfc0179dc | 398 | #define ACCELERO_CS_LOW() HAL_GPIO_WritePin(ACCELERO_CS_GPIO_PORT, ACCELERO_CS_PIN, GPIO_PIN_RESET) |
EricLew | 0:ad9dfc0179dc | 399 | #define ACCELERO_CS_HIGH() HAL_GPIO_WritePin(ACCELERO_CS_GPIO_PORT, ACCELERO_CS_PIN, GPIO_PIN_SET) |
EricLew | 0:ad9dfc0179dc | 400 | |
EricLew | 0:ad9dfc0179dc | 401 | /** |
EricLew | 0:ad9dfc0179dc | 402 | * @brief Accelerometer SPI Interface pins |
EricLew | 0:ad9dfc0179dc | 403 | */ |
EricLew | 0:ad9dfc0179dc | 404 | #define ACCELERO_CS_GPIO_PORT GPIOE /* GPIOE */ |
EricLew | 0:ad9dfc0179dc | 405 | #define ACCELERO_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 406 | #define ACCELERO_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 407 | #define ACCELERO_CS_PIN GPIO_PIN_0 /* PE.00 */ |
EricLew | 0:ad9dfc0179dc | 408 | |
EricLew | 0:ad9dfc0179dc | 409 | /** |
EricLew | 0:ad9dfc0179dc | 410 | * @brief Accelerometer Interrupt pins |
EricLew | 0:ad9dfc0179dc | 411 | */ |
EricLew | 0:ad9dfc0179dc | 412 | #define ACCELERO_XLINT_GPIO_PORT GPIOE /* GPIOE */ |
EricLew | 0:ad9dfc0179dc | 413 | #define ACCELERO_XLINT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 414 | #define ACCELERO_XLINT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 415 | #define ACCELERO_XLINT_PIN GPIO_PIN_1 /* PE.01 */ |
EricLew | 0:ad9dfc0179dc | 416 | #define ACCELERO_XLINT_EXTI_IRQn EXTI1_IRQn |
EricLew | 0:ad9dfc0179dc | 417 | |
EricLew | 0:ad9dfc0179dc | 418 | /*##################### Magnetometer ##########################*/ |
EricLew | 0:ad9dfc0179dc | 419 | /** |
EricLew | 0:ad9dfc0179dc | 420 | * @brief Magnetometer Chip Select macro definition |
EricLew | 0:ad9dfc0179dc | 421 | */ |
EricLew | 0:ad9dfc0179dc | 422 | #define MAGNETO_CS_LOW() HAL_GPIO_WritePin(MAGNETO_CS_GPIO_PORT, MAGNETO_CS_PIN, GPIO_PIN_RESET) |
EricLew | 0:ad9dfc0179dc | 423 | #define MAGNETO_CS_HIGH() HAL_GPIO_WritePin(MAGNETO_CS_GPIO_PORT, MAGNETO_CS_PIN, GPIO_PIN_SET) |
EricLew | 0:ad9dfc0179dc | 424 | |
EricLew | 0:ad9dfc0179dc | 425 | /** |
EricLew | 0:ad9dfc0179dc | 426 | * @brief Magnetometer SPI Interface pins |
EricLew | 0:ad9dfc0179dc | 427 | */ |
EricLew | 0:ad9dfc0179dc | 428 | #define MAGNETO_CS_GPIO_PORT GPIOC /* GPIOC */ |
EricLew | 0:ad9dfc0179dc | 429 | #define MAGNETO_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 430 | #define MAGNETO_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 431 | #define MAGNETO_CS_PIN GPIO_PIN_0 /* PC.00 */ |
EricLew | 0:ad9dfc0179dc | 432 | |
EricLew | 0:ad9dfc0179dc | 433 | |
EricLew | 0:ad9dfc0179dc | 434 | /** |
EricLew | 0:ad9dfc0179dc | 435 | * @brief Magnetometer Interrupt pins |
EricLew | 0:ad9dfc0179dc | 436 | */ |
EricLew | 0:ad9dfc0179dc | 437 | #define MAGNETO_INT_GPIO_PORT GPIOC /* GPIOC */ |
EricLew | 0:ad9dfc0179dc | 438 | #define MAGNETO_INT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 439 | #define MAGNETO_INT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 440 | #define MAGNETO_INT1_PIN GPIO_PIN_1 /* PC.01 */ |
EricLew | 0:ad9dfc0179dc | 441 | #define MAGNETO_INT1_EXTI_IRQn EXTI1_IRQn |
EricLew | 0:ad9dfc0179dc | 442 | |
EricLew | 0:ad9dfc0179dc | 443 | #define MAGNETO_DRDY_GPIO_PORT GPIOC /* GPIOC */ |
EricLew | 0:ad9dfc0179dc | 444 | #define MAGNETO_DRDY_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 445 | #define MAGNETO_DRDY_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 446 | #define MAGNETO_DRDY_PIN GPIO_PIN_2 /* PC.01 */ |
EricLew | 0:ad9dfc0179dc | 447 | |
EricLew | 0:ad9dfc0179dc | 448 | |
EricLew | 0:ad9dfc0179dc | 449 | /*##################### Audio Codec ##########################*/ |
EricLew | 0:ad9dfc0179dc | 450 | /** |
EricLew | 0:ad9dfc0179dc | 451 | * @brief Audio codec chip reset definition |
EricLew | 0:ad9dfc0179dc | 452 | */ |
EricLew | 0:ad9dfc0179dc | 453 | /* Audio codec power on/off macro definition */ |
EricLew | 0:ad9dfc0179dc | 454 | #define CODEC_AUDIO_POWER_OFF() HAL_GPIO_WritePin(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, GPIO_PIN_RESET) |
EricLew | 0:ad9dfc0179dc | 455 | #define CODEC_AUDIO_POWER_ON() HAL_GPIO_WritePin(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, GPIO_PIN_SET) |
EricLew | 0:ad9dfc0179dc | 456 | |
EricLew | 0:ad9dfc0179dc | 457 | /* Audio Reset Pin definition */ |
EricLew | 0:ad9dfc0179dc | 458 | #define AUDIO_RESET_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 459 | #define AUDIO_RESET_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 460 | #define AUDIO_RESET_PIN GPIO_PIN_3 |
EricLew | 0:ad9dfc0179dc | 461 | #define AUDIO_RESET_GPIO GPIOE |
EricLew | 0:ad9dfc0179dc | 462 | |
EricLew | 0:ad9dfc0179dc | 463 | /*##################### Gyroscope ##########################*/ |
EricLew | 0:ad9dfc0179dc | 464 | /** |
EricLew | 0:ad9dfc0179dc | 465 | * @brief Gyroscope Chip Select macro definition |
EricLew | 0:ad9dfc0179dc | 466 | */ |
EricLew | 0:ad9dfc0179dc | 467 | #define GYRO_CS_LOW() HAL_GPIO_WritePin(GYRO_CS_GPIO_PORT, GYRO_CS_PIN, GPIO_PIN_RESET) |
EricLew | 0:ad9dfc0179dc | 468 | #define GYRO_CS_HIGH() HAL_GPIO_WritePin(GYRO_CS_GPIO_PORT, GYRO_CS_PIN, GPIO_PIN_SET) |
EricLew | 0:ad9dfc0179dc | 469 | |
EricLew | 0:ad9dfc0179dc | 470 | /** |
EricLew | 0:ad9dfc0179dc | 471 | * @brief Gyroscope SPI Interface pins |
EricLew | 0:ad9dfc0179dc | 472 | */ |
EricLew | 0:ad9dfc0179dc | 473 | #define GYRO_CS_GPIO_PORT GPIOD /* GPIOD */ |
EricLew | 0:ad9dfc0179dc | 474 | #define GYRO_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 475 | #define GYRO_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 476 | #define GYRO_CS_PIN GPIO_PIN_7 /* PD.07 */ |
EricLew | 0:ad9dfc0179dc | 477 | |
EricLew | 0:ad9dfc0179dc | 478 | /** |
EricLew | 0:ad9dfc0179dc | 479 | * @brief Gyroscope Interrupt pins |
EricLew | 0:ad9dfc0179dc | 480 | */ |
EricLew | 0:ad9dfc0179dc | 481 | #if defined (USE_STM32L476G_DISCO_REVC) || defined (USE_STM32L476G_DISCO_REVB) |
EricLew | 0:ad9dfc0179dc | 482 | #define GYRO_INT1_GPIO_PORT GPIOD /* GPIOD */ |
EricLew | 0:ad9dfc0179dc | 483 | #define GYRO_INT1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 484 | #define GYRO_INT1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 485 | #define GYRO_INT1_PIN GPIO_PIN_2 /* PD.02 */ |
EricLew | 0:ad9dfc0179dc | 486 | #define GYRO_INT1_EXTI_IRQn EXTI2_IRQn |
EricLew | 0:ad9dfc0179dc | 487 | #define GYRO_INT2_GPIO_PORT GPIOB /* GPIOB */ |
EricLew | 0:ad9dfc0179dc | 488 | #define GYRO_INT2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 489 | #define GYRO_INT2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 490 | #define GYRO_INT2_PIN GPIO_PIN_8 /* PB.08 */ |
EricLew | 0:ad9dfc0179dc | 491 | #define GYRO_INT2_EXTI_IRQn EXTI9_5_IRQn |
EricLew | 0:ad9dfc0179dc | 492 | #elif defined (USE_STM32L476G_DISCO_REVA) |
EricLew | 0:ad9dfc0179dc | 493 | #define GYRO_INT1_GPIO_PORT GPIOB /* GPIOB */ |
EricLew | 0:ad9dfc0179dc | 494 | #define GYRO_INT1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 495 | #define GYRO_INT1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 496 | #define GYRO_INT1_PIN GPIO_PIN_6 /* PB.06 */ |
EricLew | 0:ad9dfc0179dc | 497 | #define GYRO_INT1_EXTI_IRQn EXTI9_5_IRQn |
EricLew | 0:ad9dfc0179dc | 498 | #define GYRO_INT2_GPIO_PORT GPIOB /* GPIOB */ |
EricLew | 0:ad9dfc0179dc | 499 | #define GYRO_INT2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 500 | #define GYRO_INT2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 501 | #define GYRO_INT2_PIN GPIO_PIN_7 /* PB.07 */ |
EricLew | 0:ad9dfc0179dc | 502 | #define GYRO_INT2_EXTI_IRQn EXTI9_5_IRQn |
EricLew | 0:ad9dfc0179dc | 503 | #endif |
EricLew | 0:ad9dfc0179dc | 504 | |
EricLew | 0:ad9dfc0179dc | 505 | /*##################### Idd ##########################*/ |
EricLew | 0:ad9dfc0179dc | 506 | /** |
EricLew | 0:ad9dfc0179dc | 507 | * @brief Idd current measurement interface pins |
EricLew | 0:ad9dfc0179dc | 508 | */ |
EricLew | 0:ad9dfc0179dc | 509 | #define IDD_INT_GPIO_PORT GPIOC /* GPIOC */ |
EricLew | 0:ad9dfc0179dc | 510 | #define IDD_INT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 511 | #define IDD_INT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 512 | #define IDD_INT_PIN GPIO_PIN_13 /* PC.13 */ |
EricLew | 0:ad9dfc0179dc | 513 | #define IDD_INT_EXTI_IRQn EXTI15_10_IRQn |
EricLew | 0:ad9dfc0179dc | 514 | |
EricLew | 0:ad9dfc0179dc | 515 | #define IDD_WAKEUP_GPIO_PORT GPIOA /* GPIOA */ |
EricLew | 0:ad9dfc0179dc | 516 | #define IDD_WAKEUP_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() |
EricLew | 0:ad9dfc0179dc | 517 | #define IDD_WAKEUP_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() |
EricLew | 0:ad9dfc0179dc | 518 | #define IDD_WAKEUP_PIN GPIO_PIN_4 /* PA.04 */ |
EricLew | 0:ad9dfc0179dc | 519 | |
EricLew | 0:ad9dfc0179dc | 520 | /** |
EricLew | 0:ad9dfc0179dc | 521 | * @} |
EricLew | 0:ad9dfc0179dc | 522 | */ |
EricLew | 0:ad9dfc0179dc | 523 | |
EricLew | 0:ad9dfc0179dc | 524 | /** |
EricLew | 0:ad9dfc0179dc | 525 | * @} |
EricLew | 0:ad9dfc0179dc | 526 | */ |
EricLew | 0:ad9dfc0179dc | 527 | |
EricLew | 0:ad9dfc0179dc | 528 | |
EricLew | 0:ad9dfc0179dc | 529 | /** @defgroup STM32L476G_DISCOVERY_Exported_Functions Exported Functions |
EricLew | 0:ad9dfc0179dc | 530 | * @{ |
EricLew | 0:ad9dfc0179dc | 531 | */ |
EricLew | 0:ad9dfc0179dc | 532 | uint32_t BSP_GetVersion(void); |
EricLew | 0:ad9dfc0179dc | 533 | SupplyMode_TypeDef BSP_SupplyModeDetection(void); |
EricLew | 0:ad9dfc0179dc | 534 | void BSP_LED_Init(Led_TypeDef Led); |
EricLew | 0:ad9dfc0179dc | 535 | void BSP_LED_DeInit(Led_TypeDef Led); |
EricLew | 0:ad9dfc0179dc | 536 | void BSP_LED_On(Led_TypeDef Led); |
EricLew | 0:ad9dfc0179dc | 537 | void BSP_LED_Off(Led_TypeDef Led); |
EricLew | 0:ad9dfc0179dc | 538 | void BSP_LED_Toggle(Led_TypeDef Led); |
EricLew | 0:ad9dfc0179dc | 539 | uint8_t BSP_JOY_Init(JOYMode_TypeDef Joy_Mode); |
EricLew | 0:ad9dfc0179dc | 540 | void BSP_JOY_DeInit(void); |
EricLew | 0:ad9dfc0179dc | 541 | JOYState_TypeDef BSP_JOY_GetState(void); |
EricLew | 0:ad9dfc0179dc | 542 | |
EricLew | 0:ad9dfc0179dc | 543 | /** |
EricLew | 0:ad9dfc0179dc | 544 | * @} |
EricLew | 0:ad9dfc0179dc | 545 | */ |
EricLew | 0:ad9dfc0179dc | 546 | |
EricLew | 0:ad9dfc0179dc | 547 | /** |
EricLew | 0:ad9dfc0179dc | 548 | * @} |
EricLew | 0:ad9dfc0179dc | 549 | */ |
EricLew | 0:ad9dfc0179dc | 550 | |
EricLew | 0:ad9dfc0179dc | 551 | /** |
EricLew | 0:ad9dfc0179dc | 552 | * @} |
EricLew | 0:ad9dfc0179dc | 553 | */ |
EricLew | 0:ad9dfc0179dc | 554 | |
EricLew | 0:ad9dfc0179dc | 555 | /** |
EricLew | 0:ad9dfc0179dc | 556 | * @} |
EricLew | 0:ad9dfc0179dc | 557 | */ |
EricLew | 0:ad9dfc0179dc | 558 | |
EricLew | 0:ad9dfc0179dc | 559 | #ifdef __cplusplus |
EricLew | 0:ad9dfc0179dc | 560 | } |
EricLew | 0:ad9dfc0179dc | 561 | #endif |
EricLew | 0:ad9dfc0179dc | 562 | |
EricLew | 0:ad9dfc0179dc | 563 | #endif /* __STM32L476G_DISCOVERY_H */ |
EricLew | 0:ad9dfc0179dc | 564 | |
EricLew | 0:ad9dfc0179dc | 565 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
EricLew | 0:ad9dfc0179dc | 566 |