1 | /**
|
---|
2 | ******************************************************************************
|
---|
3 | * @file stm32f4xx_nucleo.h
|
---|
4 | * @author MCD Application Team
|
---|
5 | * @version V1.2.2
|
---|
6 | * @date 14-August-2015
|
---|
7 | * @brief This file contains definitions for:
|
---|
8 | * - LEDs and push-button available on STM32F4XX-Nucleo Kit
|
---|
9 | * from STMicroelectronics
|
---|
10 | * - LCD, joystick and microSD available on Adafruit 1.8" TFT LCD
|
---|
11 | * shield (reference ID 802)
|
---|
12 | ******************************************************************************
|
---|
13 | * @attention
|
---|
14 | *
|
---|
15 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
|
---|
16 | *
|
---|
17 | * Redistribution and use in source and binary forms, with or without modification,
|
---|
18 | * are permitted provided that the following conditions are met:
|
---|
19 | * 1. Redistributions of source code must retain the above copyright notice,
|
---|
20 | * this list of conditions and the following disclaimer.
|
---|
21 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
22 | * this list of conditions and the following disclaimer in the documentation
|
---|
23 | * and/or other materials provided with the distribution.
|
---|
24 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
|
---|
25 | * may be used to endorse or promote products derived from this software
|
---|
26 | * without specific prior written permission.
|
---|
27 | *
|
---|
28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
---|
29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
31 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
---|
32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
---|
34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
---|
35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
36 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
---|
37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
38 | *
|
---|
39 | ******************************************************************************
|
---|
40 | */
|
---|
41 |
|
---|
42 | /* Define to prevent recursive inclusion -------------------------------------*/
|
---|
43 | #ifndef __STM32F4XX_NUCLEO_H
|
---|
44 | #define __STM32F4XX_NUCLEO_H
|
---|
45 |
|
---|
46 | #ifdef __cplusplus
|
---|
47 | extern "C" {
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | /* Includes ------------------------------------------------------------------*/
|
---|
51 | #include "stm32f4xx_hal.h"
|
---|
52 |
|
---|
53 | /** @addtogroup BSP
|
---|
54 | * @{
|
---|
55 | */
|
---|
56 |
|
---|
57 | /** @addtogroup STM32F4XX_NUCLEO
|
---|
58 | * @{
|
---|
59 | */
|
---|
60 |
|
---|
61 | /** @addtogroup STM32F4XX_NUCLEO_LOW_LEVEL
|
---|
62 | * @{
|
---|
63 | */
|
---|
64 |
|
---|
65 | /** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Exported_Types
|
---|
66 | * @{
|
---|
67 | */
|
---|
68 | typedef enum
|
---|
69 | {
|
---|
70 | LED2 = 0
|
---|
71 | }Led_TypeDef;
|
---|
72 |
|
---|
73 | typedef enum
|
---|
74 | {
|
---|
75 | BUTTON_USER = 0,
|
---|
76 | /* Alias */
|
---|
77 | BUTTON_KEY = BUTTON_USER
|
---|
78 | } Button_TypeDef;
|
---|
79 |
|
---|
80 | typedef enum
|
---|
81 | {
|
---|
82 | BUTTON_MODE_GPIO = 0,
|
---|
83 | BUTTON_MODE_EXTI = 1
|
---|
84 | }ButtonMode_TypeDef;
|
---|
85 |
|
---|
86 | typedef enum
|
---|
87 | {
|
---|
88 | JOY_NONE = 0,
|
---|
89 | JOY_SEL = 1,
|
---|
90 | JOY_DOWN = 2,
|
---|
91 | JOY_LEFT = 3,
|
---|
92 | JOY_RIGHT = 4,
|
---|
93 | JOY_UP = 5
|
---|
94 | }JOYState_TypeDef;
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * @}
|
---|
98 | */
|
---|
99 |
|
---|
100 | /** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Exported_Constants
|
---|
101 | * @{
|
---|
102 | */
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * @brief Define for STM32F4XX_NUCLEO board
|
---|
106 | */
|
---|
107 | #if !defined (USE_STM32F4XX_NUCLEO)
|
---|
108 | #define USE_STM32F4XX_NUCLEO
|
---|
109 | #endif
|
---|
110 |
|
---|
111 | /** @addtogroup STM32F4XX_NUCLEO_LOW_LEVEL_LED
|
---|
112 | * @{
|
---|
113 | */
|
---|
114 | #define LEDn 1
|
---|
115 |
|
---|
116 | #define LED2_PIN GPIO_PIN_5
|
---|
117 | #define LED2_GPIO_PORT GPIOA
|
---|
118 | #define LED2_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
|
---|
119 | #define LED2_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE()
|
---|
120 |
|
---|
121 | #define LEDx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) LED2_GPIO_CLK_ENABLE(); \
|
---|
122 | }while(0)
|
---|
123 | #define LEDx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) LED2_GPIO_CLK_DISABLE(); \
|
---|
124 | }while(0)
|
---|
125 | /**
|
---|
126 | * @}
|
---|
127 | */
|
---|
128 |
|
---|
129 | /** @addtogroup STM32F4XX_NUCLEO_LOW_LEVEL_BUTTON
|
---|
130 | * @{
|
---|
131 | */
|
---|
132 | #define BUTTONn 1
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * @brief Key push-button
|
---|
136 | */
|
---|
137 | #define USER_BUTTON_PIN GPIO_PIN_13
|
---|
138 | #define USER_BUTTON_GPIO_PORT GPIOC
|
---|
139 | #define USER_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
|
---|
140 | #define USER_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
|
---|
141 | #define USER_BUTTON_EXTI_LINE GPIO_PIN_13
|
---|
142 | #define USER_BUTTON_EXTI_IRQn EXTI15_10_IRQn
|
---|
143 | /* Aliases */
|
---|
144 | #define KEY_BUTTON_PIN USER_BUTTON_PIN
|
---|
145 | #define KEY_BUTTON_GPIO_PORT USER_BUTTON_GPIO_PORT
|
---|
146 | #define KEY_BUTTON_GPIO_CLK_ENABLE() USER_BUTTON_GPIO_CLK_ENABLE()
|
---|
147 | #define KEY_BUTTON_GPIO_CLK_DISABLE() USER_BUTTON_GPIO_CLK_DISABLE()
|
---|
148 | #define KEY_BUTTON_EXTI_LINE USER_BUTTON_EXTI_LINE
|
---|
149 | #define KEY_BUTTON_EXTI_IRQn USER_BUTTON_EXTI_IRQn
|
---|
150 |
|
---|
151 |
|
---|
152 | #define BUTTONx_GPIO_CLK_ENABLE(__BUTTON__) do { if((__BUTTON__) == BUTTON_USER) { USER_BUTTON_GPIO_CLK_ENABLE(); } } while(0)
|
---|
153 |
|
---|
154 | #define BUTTONx_GPIO_CLK_DISABLE(__BUTTON__) do { if((__BUTTON__) == BUTTON_USER) { USER_BUTTON_GPIO_CLK_DISABLE(); } } while(0)
|
---|
155 | /**
|
---|
156 | * @}
|
---|
157 | */
|
---|
158 |
|
---|
159 | /** @addtogroup STM32F4XX_NUCLEO_LOW_LEVEL_BUS
|
---|
160 | * @{
|
---|
161 | */
|
---|
162 | /*############################### SPI1 #######################################*/
|
---|
163 | #define NUCLEO_SPIx SPI1
|
---|
164 | #define NUCLEO_SPIx_CLK_ENABLE() __SPI1_CLK_ENABLE()
|
---|
165 |
|
---|
166 | #define NUCLEO_SPIx_SCK_AF GPIO_AF5_SPI1
|
---|
167 | #define NUCLEO_SPIx_SCK_GPIO_PORT GPIOA
|
---|
168 | #define NUCLEO_SPIx_SCK_PIN GPIO_PIN_5
|
---|
169 | #define NUCLEO_SPIx_SCK_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
|
---|
170 | #define NUCLEO_SPIx_SCK_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE()
|
---|
171 |
|
---|
172 | #define NUCLEO_SPIx_MISO_MOSI_AF GPIO_AF5_SPI1
|
---|
173 | #define NUCLEO_SPIx_MISO_MOSI_GPIO_PORT GPIOA
|
---|
174 | #define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
|
---|
175 | #define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE()
|
---|
176 | #define NUCLEO_SPIx_MISO_PIN GPIO_PIN_6
|
---|
177 | #define NUCLEO_SPIx_MOSI_PIN GPIO_PIN_7
|
---|
178 | /* Maximum Timeout values for flags waiting loops. These timeouts are not based
|
---|
179 | on accurate values, they just guarantee that the application will not remain
|
---|
180 | stuck if the SPI communication is corrupted.
|
---|
181 | You may modify these timeout values depending on CPU frequency and application
|
---|
182 | conditions (interrupts routines ...). */
|
---|
183 | #define NUCLEO_SPIx_TIMEOUT_MAX 1000
|
---|
184 |
|
---|
185 | /**
|
---|
186 | * @brief SD Control Lines management
|
---|
187 | */
|
---|
188 | #define SD_CS_LOW() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_RESET)
|
---|
189 | #define SD_CS_HIGH() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_SET)
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * @brief LCD Control Lines management
|
---|
193 | */
|
---|
194 | #define LCD_CS_LOW() HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_RESET)
|
---|
195 | #define LCD_CS_HIGH() HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_SET)
|
---|
196 | #define LCD_DC_LOW() HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_RESET)
|
---|
197 | #define LCD_DC_HIGH() HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_SET)
|
---|
198 |
|
---|
199 | /**
|
---|
200 | * @brief SD Control Interface pins
|
---|
201 | */
|
---|
202 | #define SD_CS_PIN GPIO_PIN_5
|
---|
203 | #define SD_CS_GPIO_PORT GPIOB
|
---|
204 | #define SD_CS_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
|
---|
205 | #define SD_CS_GPIO_CLK_DISABLE() __GPIOB_CLK_DISABLE()
|
---|
206 |
|
---|
207 | /**
|
---|
208 | * @brief LCD Control Interface pins
|
---|
209 | */
|
---|
210 | #define LCD_CS_PIN GPIO_PIN_6
|
---|
211 | #define LCD_CS_GPIO_PORT GPIOB
|
---|
212 | #define LCD_CS_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
|
---|
213 | #define LCD_CS_GPIO_CLK_DISABLE() __GPIOB_CLK_DISABLE()
|
---|
214 |
|
---|
215 | /**
|
---|
216 | * @brief LCD Data/Command Interface pins
|
---|
217 | */
|
---|
218 | #define LCD_DC_PIN GPIO_PIN_9
|
---|
219 | #define LCD_DC_GPIO_PORT GPIOA
|
---|
220 | #define LCD_DC_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
|
---|
221 | #define LCD_DC_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE()
|
---|
222 |
|
---|
223 | /*################################ ADC1 ######################################*/
|
---|
224 | /**
|
---|
225 | * @brief ADC Interface pins
|
---|
226 | * used to detect motion of Joystick available on Adafruit 1.8" TFT shield
|
---|
227 | */
|
---|
228 | #define NUCLEO_ADCx ADC1
|
---|
229 | #define NUCLEO_ADCx_CLK_ENABLE() __ADC1_CLK_ENABLE()
|
---|
230 |
|
---|
231 | #define NUCLEO_ADCx_CHANNEL ADC_CHANNEL_8
|
---|
232 |
|
---|
233 | #define NUCLEO_ADCx_GPIO_PORT GPIOB
|
---|
234 | #define NUCLEO_ADCx_GPIO_PIN GPIO_PIN_0
|
---|
235 | #define NUCLEO_ADCx_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
|
---|
236 | #define NUCLEO_ADCx_GPIO_CLK_DISABLE() __GPIOB_CLK_DISABLE()
|
---|
237 | /**
|
---|
238 | * @}
|
---|
239 | */
|
---|
240 |
|
---|
241 | /**
|
---|
242 | * @}
|
---|
243 | */
|
---|
244 |
|
---|
245 | /** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Exported_Macros
|
---|
246 | * @{
|
---|
247 | */
|
---|
248 | /**
|
---|
249 | * @}
|
---|
250 | */
|
---|
251 |
|
---|
252 | /** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Exported_Functions
|
---|
253 | * @{
|
---|
254 | */
|
---|
255 | uint32_t BSP_GetVersion(void);
|
---|
256 | void BSP_LED_Init(Led_TypeDef Led);
|
---|
257 | void BSP_LED_On(Led_TypeDef Led);
|
---|
258 | void BSP_LED_Off(Led_TypeDef Led);
|
---|
259 | void BSP_LED_Toggle(Led_TypeDef Led);
|
---|
260 | void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode);
|
---|
261 | uint32_t BSP_PB_GetState(Button_TypeDef Button);
|
---|
262 | uint8_t BSP_JOY_Init(void);
|
---|
263 | JOYState_TypeDef BSP_JOY_GetState(void);
|
---|
264 |
|
---|
265 | /**
|
---|
266 | * @}
|
---|
267 | */
|
---|
268 |
|
---|
269 | /**
|
---|
270 | * @}
|
---|
271 | */
|
---|
272 |
|
---|
273 | /**
|
---|
274 | * @}
|
---|
275 | */
|
---|
276 |
|
---|
277 | /**
|
---|
278 | * @}
|
---|
279 | */
|
---|
280 |
|
---|
281 | #ifdef __cplusplus
|
---|
282 | }
|
---|
283 | #endif
|
---|
284 |
|
---|
285 | #endif /* __STM32F4XX_NUCLEO_H */
|
---|
286 |
|
---|
287 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
---|