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