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