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