STM32F3xx_Nucleo_144 BSP User Manual
|
stm32f3xx_nucleo_144.h
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f3xx_nucleo_144.h 00004 * @author MCD Application Team 00005 * @brief This file contains definitions for: 00006 * - LEDs and push-button available on STM32F3XX-Nucleo-144 Kit 00007 * from STMicroelectronics 00008 * - LCD, joystick and microSD available on Adafruit 1.8" TFT LCD 00009 * shield (reference ID 802) 00010 ****************************************************************************** 00011 * @attention 00012 * 00013 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 00014 * 00015 * Redistribution and use in source and binary forms, with or without modification, 00016 * are permitted provided that the following conditions are met: 00017 * 1. Redistributions of source code must retain the above copyright notice, 00018 * this list of conditions and the following disclaimer. 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00023 * may be used to endorse or promote products derived from this software 00024 * without specific prior written permission. 00025 * 00026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00029 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00030 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00031 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00032 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00033 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00034 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00035 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 * 00037 ****************************************************************************** 00038 */ 00039 00040 /* Define to prevent recursive inclusion -------------------------------------*/ 00041 #ifndef __STM32F3XX_NUCLEO_144_H 00042 #define __STM32F3XX_NUCLEO_144_H 00043 00044 /** @addtogroup BSP 00045 * @{ 00046 */ 00047 00048 /** @defgroup STM32F3XX_NUCLEO_144 STM32F3XX-NUCLEO 00049 * @{ 00050 */ 00051 00052 #ifdef __cplusplus 00053 extern "C" { 00054 #endif 00055 00056 /* Includes ------------------------------------------------------------------*/ 00057 #include "stm32f3xx_hal.h" 00058 00059 /** @defgroup STM32F3XX_NUCLEO_144_Common STM32F3XX-NUCLEO Common 00060 * @{ 00061 */ 00062 00063 /** @defgroup STM32F3XX_NUCLEO_144_Private_Constants Private Constants 00064 * @{ 00065 */ 00066 /** 00067 * @} 00068 */ 00069 00070 /** @defgroup STM32F3XX_NUCLEO_144_Private_Variables Private Variables 00071 * @{ 00072 */ 00073 /** 00074 * @} 00075 */ 00076 00077 /** @defgroup STM32F3XX_NUCLEO_144_Exported_Types Exported Types 00078 * @{ 00079 */ 00080 00081 /** 00082 * @brief LED Types Definition 00083 */ 00084 typedef enum 00085 { 00086 LED1 = 0, 00087 LED_GREEN = LED1, 00088 LED2 = 1, 00089 LED_RED = LED2, 00090 LED3 = 2, 00091 LED_BLUE = LED3 00092 }Led_TypeDef; 00093 00094 /** 00095 * @brief BUTTON Types Definition 00096 */ 00097 typedef enum 00098 { 00099 BUTTON_USER = 0, 00100 /* Alias */ 00101 BUTTON_KEY = BUTTON_USER 00102 }Button_TypeDef; 00103 00104 typedef enum 00105 { 00106 BUTTON_MODE_GPIO = 0, 00107 BUTTON_MODE_EXTI = 1 00108 }ButtonMode_TypeDef; 00109 00110 /** 00111 * @brief JOYSTICK Types Definition 00112 */ 00113 typedef enum 00114 { 00115 JOY_NONE = 0, 00116 JOY_SEL = 1, 00117 JOY_DOWN = 2, 00118 JOY_LEFT = 3, 00119 JOY_RIGHT = 4, 00120 JOY_UP = 5 00121 }JOYState_TypeDef; 00122 00123 /** 00124 * @} 00125 */ 00126 00127 /** @defgroup STM32F3XX_NUCLEO_144_Exported_Constants Exported Constants 00128 * @{ 00129 */ 00130 00131 /** 00132 * @brief Define for STM32F3XX_NUCLEO_144 board 00133 */ 00134 00135 #if !defined (USE_STM32F3XX_NUCLEO_144) 00136 #define USE_STM32F3XX_NUCLEO_144 00137 #endif 00138 00139 /** @defgroup STM32F3XX_NUCLEO_144_LED STM32F3XX-NUCLEO LED 00140 * @{ 00141 */ 00142 #define LEDn 3 00143 00144 #define LED1_PIN GPIO_PIN_0 00145 #define LED1_GPIO_PORT GPIOB 00146 #define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() 00147 #define LED1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() 00148 00149 #define LED2_PIN GPIO_PIN_7 00150 #define LED2_GPIO_PORT GPIOB 00151 #define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() 00152 #define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() 00153 00154 #define LED3_PIN GPIO_PIN_14 00155 #define LED3_GPIO_PORT GPIOB 00156 #define LED3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() 00157 #define LED3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() 00158 00159 #define LEDx_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == 0) {__HAL_RCC_GPIOB_CLK_ENABLE();} else\ 00160 {__HAL_RCC_GPIOB_CLK_ENABLE(); }} while(0) 00161 #define LEDx_GPIO_CLK_DISABLE(__INDEX__) do { if((__INDEX__) == 0) {__HAL_RCC_GPIOB_CLK_DISABLE();} else\ 00162 {__HAL_RCC_GPIOB_CLK_DISABLE(); }} while(0) 00163 00164 /** 00165 * @} 00166 */ 00167 00168 /** @defgroup STM32F3XX_NUCLEO_144_BUTTON STM32F3XX-NUCLEO BUTTON 00169 * @{ 00170 */ 00171 #define BUTTONn 1 00172 00173 /** 00174 * @brief Key push-button 00175 */ 00176 #define USER_BUTTON_PIN GPIO_PIN_13 00177 #define USER_BUTTON_GPIO_PORT GPIOC 00178 #define USER_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() 00179 #define USER_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() 00180 #define USER_BUTTON_EXTI_LINE GPIO_PIN_13 00181 #define USER_BUTTON_EXTI_IRQn EXTI15_10_IRQn 00182 00183 #define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) USER_BUTTON_GPIO_CLK_ENABLE() 00184 #define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) USER_BUTTON_GPIO_CLK_DISABLE() 00185 00186 /* Aliases */ 00187 #define KEY_BUTTON_PIN USER_BUTTON_PIN 00188 #define KEY_BUTTON_GPIO_PORT USER_BUTTON_GPIO_PORT 00189 #define KEY_BUTTON_GPIO_CLK_ENABLE() USER_BUTTON_GPIO_CLK_ENABLE() 00190 #define KEY_BUTTON_GPIO_CLK_DISABLE() USER_BUTTON_GPIO_CLK_DISABLE() 00191 #define KEY_BUTTON_EXTI_LINE USER_BUTTON_EXTI_LINE 00192 #define KEY_BUTTON_EXTI_IRQn USER_BUTTON_EXTI_IRQn 00193 00194 00195 /** 00196 * @brief Discovery Pins definition 00197 */ 00198 00199 00200 #define OTG_FS1_OVER_CURRENT_PIN GPIO_PIN_7 00201 #define OTG_FS1_OVER_CURRENT_PORT GPIOG 00202 #define OTG_FS1_OVER_CURRENT_PORT_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE() 00203 00204 #define OTG_FS1_POWER_SWITCH_PIN GPIO_PIN_6 00205 #define OTG_FS1_POWER_SWITCH_PORT GPIOG 00206 #define OTG_FS1_POWER_SWITCH_PORT_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE() 00207 00208 /** 00209 * @} 00210 */ 00211 00212 /** @defgroup STM32F3XX_NUCLEO_144_COM STM32F3XX-NUCLEO COM 00213 * @{ 00214 */ 00215 /*############################### SPI_A #######################################*/ 00216 #ifdef HAL_SPI_MODULE_ENABLED 00217 00218 #define NUCLEO_SPIx SPI1 00219 #define NUCLEO_SPIx_CLK_ENABLE() __HAL_RCC_SPI1_CLK_ENABLE() 00220 00221 #define NUCLEO_SPIx_SCK_AF GPIO_AF5_SPI1 00222 #define NUCLEO_SPIx_SCK_GPIO_PORT GPIOA 00223 #define NUCLEO_SPIx_SCK_PIN GPIO_PIN_5 00224 #define NUCLEO_SPIx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() 00225 #define NUCLEO_SPIx_SCK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() 00226 00227 #define NUCLEO_SPIx_MISO_MOSI_AF GPIO_AF5_SPI1 00228 #define NUCLEO_SPIx_MISO_MOSI_GPIO_PORT GPIOA 00229 #define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() 00230 #define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() 00231 #define NUCLEO_SPIx_MISO_PIN GPIO_PIN_6 00232 #define NUCLEO_SPIx_MOSI_PIN GPIO_PIN_7 00233 /* Maximum Timeout values for flags waiting loops. These timeouts are not based 00234 on accurate values, they just guarantee that the application will not remain 00235 stuck if the SPI communication is corrupted. 00236 You may modify these timeout values depending on CPU frequency and application 00237 conditions (interrupts routines ...). */ 00238 #define NUCLEO_SPIx_TIMEOUT_MAX 1000 00239 00240 #define NUCLEO_SPIx_CS_GPIO_PORT GPIOD 00241 #define NUCLEO_SPIx_CS_PIN GPIO_PIN_14 00242 #define NUCLEO_SPIx_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() 00243 #define NUCLEO_SPIx_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() 00244 00245 #define SPIx__CS_LOW() HAL_GPIO_WritePin(NUCLEO_SPIx_CS_GPIO_PORT, NUCLEO_SPIx_CS_PIN, GPIO_PIN_RESET) 00246 #define SPIx__CS_HIGH() HAL_GPIO_WritePin(NUCLEO_SPIx_CS_GPIO_PORT, NUCLEO_SPIx_CS_PIN, GPIO_PIN_SET) 00247 00248 /** 00249 * @} 00250 */ 00251 00252 00253 /** @defgroup STM32F3XX_NUCLEO_144_COMPONENT STM32F3XX-NUCLEO COMPONENT 00254 * @{ 00255 */ 00256 00257 /** 00258 * @brief SD Control Lines management 00259 */ 00260 #define SD_CS_LOW() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_RESET) 00261 #define SD_CS_HIGH() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_SET) 00262 00263 /** 00264 * @brief LCD Control Lines management 00265 */ 00266 #define LCD_CS_LOW() HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_RESET) 00267 #define LCD_CS_HIGH() HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_SET) 00268 #define LCD_DC_LOW() HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_RESET) 00269 #define LCD_DC_HIGH() HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_SET) 00270 00271 /** 00272 * @brief SD Control Interface pins (shield D4) 00273 */ 00274 #define SD_CS_PIN GPIO_PIN_14 00275 #define SD_CS_GPIO_PORT GPIOF 00276 #define SD_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE() 00277 #define SD_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE() 00278 00279 /** 00280 * @brief LCD Control Interface pins (shield D10) 00281 */ 00282 #define LCD_CS_PIN GPIO_PIN_14 00283 #define LCD_CS_GPIO_PORT GPIOD 00284 #define LCD_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() 00285 #define LCD_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() 00286 00287 /** 00288 * @brief LCD Data/Command Interface pins (shield D8) 00289 */ 00290 #define LCD_DC_PIN GPIO_PIN_12 00291 #define LCD_DC_GPIO_PORT GPIOF 00292 #define LCD_DC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE() 00293 #define LCD_DC_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE() 00294 00295 #endif /* HAL_SPI_MODULE_ENABLED */ 00296 00297 /*################################ ADC1 ######################################*/ 00298 /** 00299 * @brief ADC Interface pins 00300 * used to detect motion of Joystick available on Adafruit 1.8" TFT shield 00301 */ 00302 00303 #ifdef HAL_ADC_MODULE_ENABLED 00304 00305 #define NUCLEO_ADCx ADC3 00306 #define NUCLEO_ADCx_CLK_ENABLE() __HAL_RCC_ADC34_CLK_ENABLE() 00307 #define NUCLEO_ADCx_CLK_DISABLE() __HAL_RCC_ADC34_CLK_DISABLE() 00308 00309 #if defined(STM32F303xE) 00310 /* Select Channel 8 to be converted */ 00311 #define NUCLEO_ADCx_CHANNEL ADC_CHANNEL_8 00312 #else 00313 #error "MCU device not yet supported on STM32 F3 Nucleo 144 kit" 00314 #endif /* STM32F303xE */ 00315 00316 #define NUCLEO_ADCx_GPIO_PORT GPIOD 00317 #define NUCLEO_ADCx_GPIO_PIN GPIO_PIN_11 00318 #define NUCLEO_ADCx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() 00319 #define NUCLEO_ADCx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() 00320 #endif /* HAL_ADC_MODULE_ENABLED */ 00321 00322 /** 00323 * @} 00324 */ 00325 00326 /** 00327 * @} 00328 */ 00329 00330 /** @defgroup STM32F3XX_NUCLEO_144_Exported_Functions Exported Functions 00331 * @{ 00332 */ 00333 uint32_t BSP_GetVersion(void); 00334 void BSP_LED_Init(Led_TypeDef Led); 00335 void BSP_LED_DeInit(Led_TypeDef Led); 00336 void BSP_LED_On(Led_TypeDef Led); 00337 void BSP_LED_Off(Led_TypeDef Led); 00338 void BSP_LED_Toggle(Led_TypeDef Led); 00339 void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode); 00340 void BSP_PB_DeInit(Button_TypeDef Button); 00341 uint32_t BSP_PB_GetState(Button_TypeDef Button); 00342 #if defined(HAL_ADC_MODULE_ENABLED) 00343 uint8_t BSP_JOY_Init(void); 00344 JOYState_TypeDef BSP_JOY_GetState(void); 00345 void BSP_JOY_DeInit(void); 00346 #endif /* HAL_ADC_MODULE_ENABLED */ 00347 00348 00349 /** 00350 * @} 00351 */ 00352 00353 /** 00354 * @} 00355 */ 00356 00357 /** 00358 * @} 00359 */ 00360 00361 /** 00362 * @} 00363 */ 00364 00365 #ifdef __cplusplus 00366 } 00367 #endif 00368 00369 #endif /* __STM32F3XX_NUCLEO_144_H */ 00370 00371 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Wed May 31 2017 11:02:21 for STM32F3xx_Nucleo_144 BSP User Manual by
