STM32L4xx_Nucleo_144 BSP User Manual: stm32l4xx_nucleo_144.h Source File

STM32L4xx_Nucleo_144 BSP

stm32l4xx_nucleo_144.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_nucleo_144.h
00004   * @author  MCD Application Team
00005   * @brief   This file contains definitions for:
00006   *          - LEDs and push-button available on STM32L4XX-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>&copy; COPYRIGHT(c) 2017 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 __STM32L4XX_NUCLEO_144_H
00042 #define __STM32L4XX_NUCLEO_144_H
00043 
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047 
00048 /* Includes ------------------------------------------------------------------*/
00049 #include "stm32l4xx_hal.h"
00050 
00051 /** @addtogroup BSP
00052   * @{
00053   */
00054 
00055 /** @addtogroup STM32L4XX_NUCLEO_144
00056   * @{
00057   */
00058 
00059 /** @defgroup STM32L4XX_NUCLEO_144_Exported_Types Exported Types
00060   * @{
00061   */
00062 typedef enum
00063 {
00064   LED1 = 0,
00065   LED_GREEN = LED1,
00066   LED2 = 1,
00067   LED_BLUE = LED2,
00068   LED3 = 2,
00069   LED_RED = LED3
00070 }
00071 Led_TypeDef;
00072 
00073 typedef enum
00074 {
00075   BUTTON_USER = 0,
00076   /* Alias */
00077   BUTTON_KEY = BUTTON_USER
00078 } Button_TypeDef;
00079 
00080 typedef enum
00081 {
00082   BUTTON_MODE_GPIO = 0,
00083   BUTTON_MODE_EXTI = 1
00084 } ButtonMode_TypeDef;
00085 
00086 typedef enum
00087 {
00088   JOY_NONE  = 0,
00089   JOY_SEL   = 1,
00090   JOY_DOWN  = 2,
00091   JOY_LEFT  = 3,
00092   JOY_RIGHT = 4,
00093   JOY_UP    = 5
00094 } JOYState_TypeDef;
00095 
00096 /**
00097   * @}
00098   */
00099 
00100 /** @defgroup STM32L4XX_NUCLEO_144_Exported_Constants Exported Constants
00101   * @{
00102   */
00103 
00104 /**
00105   * @brief Define for STM32L4XX_NUCLEO_144 board
00106   */
00107 #if !defined (USE_STM32L4XX_NUCLEO_144)
00108 #define USE_STM32L4XX_NUCLEO_144
00109 #endif
00110 
00111 /** @defgroup STM32L4XX_NUCLEO_144_LED LED
00112   * @{
00113   */
00114 #define LEDn                                    3
00115 
00116 #define LED1_PIN                                GPIO_PIN_7
00117 #define LED1_GPIO_PORT                          GPIOC
00118 #define LED1_GPIO_CLK_ENABLE()                  __HAL_RCC_GPIOC_CLK_ENABLE()
00119 #define LED1_GPIO_CLK_DISABLE()                 __HAL_RCC_GPIOC_CLK_DISABLE()
00120 
00121 #define LED2_PIN                                GPIO_PIN_7
00122 #define LED2_GPIO_PORT                          GPIOB
00123 #define LED2_GPIO_CLK_ENABLE()                  __HAL_RCC_GPIOB_CLK_ENABLE()
00124 #define LED2_GPIO_CLK_DISABLE()                 __HAL_RCC_GPIOB_CLK_DISABLE()
00125 
00126 #define LED3_PIN                                GPIO_PIN_14
00127 #define LED3_GPIO_PORT                          GPIOB
00128 #define LED3_GPIO_CLK_ENABLE()                  __HAL_RCC_GPIOB_CLK_ENABLE()
00129 #define LED3_GPIO_CLK_DISABLE()                 __HAL_RCC_GPIOB_CLK_DISABLE()
00130 
00131 #define LEDx_GPIO_CLK_ENABLE(__INDEX__)   do { if((__INDEX__) == 0) {__HAL_RCC_GPIOC_CLK_ENABLE();} else\
00132                                                                     {__HAL_RCC_GPIOB_CLK_ENABLE();   }} while(0)
00133 #define LEDx_GPIO_CLK_DISABLE(__INDEX__)  do { if((__INDEX__) == 0) {__HAL_RCC_GPIOC_CLK_DISABLE();} else\
00134                                                                     {__HAL_RCC_GPIOB_CLK_DISABLE();   }} while(0)
00135 
00136 /**
00137   * @}
00138   */
00139 
00140 /** @defgroup STM32L4XX_NUCLEO_144_BUTTON BUTTON
00141   * @{
00142   */
00143 #define BUTTONn                                 1
00144 
00145 /**
00146  * @brief Key push-button
00147  */
00148 #define USER_BUTTON_PIN                       GPIO_PIN_13
00149 #define USER_BUTTON_GPIO_PORT                 GPIOC
00150 #define USER_BUTTON_GPIO_CLK_ENABLE()         __HAL_RCC_GPIOC_CLK_ENABLE()
00151 #define USER_BUTTON_GPIO_CLK_DISABLE()        __HAL_RCC_GPIOC_CLK_DISABLE()
00152 #define USER_BUTTON_EXTI_LINE                 GPIO_PIN_13
00153 #define USER_BUTTON_EXTI_IRQn                 EXTI15_10_IRQn
00154 
00155 #define BUTTONx_GPIO_CLK_ENABLE(__INDEX__)    USER_BUTTON_GPIO_CLK_ENABLE()
00156 #define BUTTONx_GPIO_CLK_DISABLE(__INDEX__)   USER_BUTTON_GPIO_CLK_DISABLE()
00157 
00158 /* Aliases */
00159 #define KEY_BUTTON_PIN                       USER_BUTTON_PIN
00160 #define KEY_BUTTON_GPIO_PORT                 USER_BUTTON_GPIO_PORT
00161 #define KEY_BUTTON_GPIO_CLK_ENABLE()         USER_BUTTON_GPIO_CLK_ENABLE()
00162 #define KEY_BUTTON_GPIO_CLK_DISABLE()        USER_BUTTON_GPIO_CLK_DISABLE()
00163 #define KEY_BUTTON_EXTI_LINE                 USER_BUTTON_EXTI_LINE
00164 #define KEY_BUTTON_EXTI_IRQn                 USER_BUTTON_EXTI_IRQn
00165 
00166 /**
00167   * @}
00168   */
00169 
00170 
00171 /** @defgroup STM32L4XX_NUCLEO_144_PIN PIN
00172   * @{
00173   */
00174 #define OTG_FS1_OVER_CURRENT_PIN                  GPIO_PIN_5
00175 #define OTG_FS1_OVER_CURRENT_PORT                 GPIOG
00176 #define OTG_FS1_OVER_CURRENT_PORT_CLK_ENABLE()    __HAL_RCC_GPIOG_CLK_ENABLE()
00177 
00178 #define OTG_FS1_POWER_SWITCH_PIN                  GPIO_PIN_6
00179 #define OTG_FS1_POWER_SWITCH_PORT                 GPIOG
00180 #define OTG_FS1_POWER_SWITCH_PORT_CLK_ENABLE()    __HAL_RCC_GPIOG_CLK_ENABLE()
00181 
00182 /**
00183   * @}
00184   */
00185 
00186 #ifdef USE_STM32L4XX_NUCLEO_144_SMPS
00187 /** @defgroup STM32L4XX_NUCLEO_144_SMPS SMPS
00188   * @{
00189   */
00190 #define SMPS_OK     0
00191 #define SMPS_KO     1
00192 
00193 /**
00194   * @}
00195   */
00196 #endif /* USE_STM32L4XX_NUCLEO_144_SMPS */
00197   
00198 
00199 /** @defgroup STM32L4XX_NUCLEO_144_BUS BUS
00200   * @{
00201   */
00202 /*############################### SPI_A #######################################*/
00203 #ifdef HAL_SPI_MODULE_ENABLED
00204 
00205 #define NUCLEO_SPIx                                     SPI1
00206 #define NUCLEO_SPIx_CLK_ENABLE()                        __HAL_RCC_SPI1_CLK_ENABLE()
00207 
00208 #define NUCLEO_SPIx_SCK_AF                              GPIO_AF5_SPI1
00209 #define NUCLEO_SPIx_SCK_GPIO_PORT                       GPIOA
00210 #define NUCLEO_SPIx_SCK_PIN                             GPIO_PIN_5
00211 #define NUCLEO_SPIx_SCK_GPIO_CLK_ENABLE()               __HAL_RCC_GPIOA_CLK_ENABLE()
00212 #define NUCLEO_SPIx_SCK_GPIO_CLK_DISABLE()              __HAL_RCC_GPIOA_CLK_DISABLE()
00213 
00214 #define NUCLEO_SPIx_MISO_MOSI_AF                        GPIO_AF5_SPI1
00215 #define NUCLEO_SPIx_MISO_MOSI_GPIO_PORT                 GPIOA
00216 #define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_ENABLE()         __HAL_RCC_GPIOA_CLK_ENABLE()
00217 #define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_DISABLE()        __HAL_RCC_GPIOA_CLK_DISABLE()
00218 #define NUCLEO_SPIx_MISO_PIN                            GPIO_PIN_6
00219 #define NUCLEO_SPIx_MOSI_PIN                            GPIO_PIN_7
00220 /* Maximum Timeout values for flags waiting loops. These timeouts are not based
00221    on accurate values, they just guarantee that the application will not remain
00222    stuck if the SPI communication is corrupted.
00223    You may modify these timeout values depending on CPU frequency and application
00224    conditions (interrupts routines ...). */
00225 #define NUCLEO_SPIx_TIMEOUT_MAX                   1000
00226 
00227 #define NUCLEO_SPIx_CS_GPIO_PORT                        GPIOD
00228 #define NUCLEO_SPIx_CS_PIN                              GPIO_PIN_14
00229 #define NUCLEO_SPIx_CS_GPIO_CLK_ENABLE()                __HAL_RCC_GPIOD_CLK_ENABLE()
00230 #define NUCLEO_SPIx_CS_GPIO_CLK_DISABLE()               __HAL_RCC_GPIOD_CLK_DISABLE()
00231 
00232 #define SPIx__CS_LOW()       HAL_GPIO_WritePin(NUCLEO_SPIx_CS_GPIO_PORT, NUCLEO_SPIx_CS_PIN, GPIO_PIN_RESET)
00233 #define SPIx__CS_HIGH()      HAL_GPIO_WritePin(NUCLEO_SPIx_CS_GPIO_PORT, NUCLEO_SPIx_CS_PIN, GPIO_PIN_SET)
00234 
00235 /**
00236   * @brief  SD Control Lines management
00237   */
00238 #define SD_CS_LOW()       HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_RESET)
00239 #define SD_CS_HIGH()      HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_SET)
00240 
00241 /**
00242   * @brief  LCD Control Lines management
00243   */
00244 #define LCD_CS_LOW()      HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_RESET)
00245 #define LCD_CS_HIGH()     HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_SET)
00246 #define LCD_DC_LOW()      HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_RESET)
00247 #define LCD_DC_HIGH()     HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_SET)
00248 
00249 /**
00250   * @brief  SD Control Interface pins (shield D4)
00251   */
00252 #define SD_CS_PIN                                 GPIO_PIN_14
00253 #define SD_CS_GPIO_PORT                           GPIOF
00254 #define SD_CS_GPIO_CLK_ENABLE()                 __HAL_RCC_GPIOF_CLK_ENABLE()
00255 #define SD_CS_GPIO_CLK_DISABLE()                __HAL_RCC_GPIOF_CLK_DISABLE()
00256 
00257 /**
00258   * @brief  LCD Control Interface pins (shield D10)
00259   */
00260 #define LCD_CS_PIN                                 GPIO_PIN_14
00261 #define LCD_CS_GPIO_PORT                           GPIOD
00262 #define LCD_CS_GPIO_CLK_ENABLE()                 __HAL_RCC_GPIOD_CLK_ENABLE()
00263 #define LCD_CS_GPIO_CLK_DISABLE()                __HAL_RCC_GPIOD_CLK_DISABLE()
00264 
00265 /**
00266   * @brief  LCD Data/Command Interface pins (shield D8)
00267   */
00268 #define LCD_DC_PIN                                 GPIO_PIN_12
00269 #define LCD_DC_GPIO_PORT                           GPIOF
00270 #define LCD_DC_GPIO_CLK_ENABLE()                 __HAL_RCC_GPIOF_CLK_ENABLE()
00271 #define LCD_DC_GPIO_CLK_DISABLE()                __HAL_RCC_GPIOF_CLK_DISABLE()
00272 
00273 #endif /* HAL_SPI_MODULE_ENABLED */
00274 
00275 /*################################ ADC1 ######################################*/
00276 /**
00277   * @brief  ADC Interface pins
00278   *         used to detect motion of Joystick available on Adafruit 1.8" TFT shield
00279   */
00280 
00281 #ifdef HAL_ADC_MODULE_ENABLED
00282 
00283 #define NUCLEO_ADCx                               ADC1
00284 
00285 #define NUCLEO_ADCx_CHANNEL                       ADC_CHANNEL_2
00286 #define NUCLEO_ADCx_SAMPLETIME                    ADC_SAMPLETIME_24CYCLES_5
00287 #define NUCLEO_ADCx_CLK_ENABLE()                  __HAL_RCC_ADC_CLK_ENABLE()
00288 #define NUCLEO_ADCx_CLK_DISABLE()                 __HAL_RCC_ADC_CLK_DISABLE()
00289 
00290 #define NUCLEO_ADCx_GPIO_PORT                       GPIOC
00291 #define NUCLEO_ADCx_GPIO_PIN                        GPIO_PIN_1
00292 #define NUCLEO_ADCx_GPIO_CLK_ENABLE()             __HAL_RCC_GPIOC_CLK_ENABLE()
00293 #define NUCLEO_ADCx_GPIO_CLK_DISABLE()            __HAL_RCC_GPIOC_CLK_DISABLE()
00294 
00295 #endif /* HAL_ADC_MODULE_ENABLED */
00296 
00297 /*##################### SMPS###################################*/
00298 #ifdef USE_STM32L4XX_NUCLEO_144_SMPS
00299 
00300 #ifdef USE_ADP5301ACBZ          /* ADP5301ACBZ */
00301 #define PORT_SMPS               GPIOG
00302 #define PIN_SMPS_ENABLE         GPIO_PIN_11
00303 #define PIN_SMPS_POWERGOOD      GPIO_PIN_12
00304 #define PIN_SMPS_SWITCH_ENABLE  GPIO_PIN_13
00305 
00306 #define PWR_GPIO_SMPS           PWR_GPIO_G
00307 #define PWR_GPIO_ENABLE         PWR_GPIO_BIT_11
00308 #define PWR_GPIO_SWITCH_ENABLE  PWR_GPIO_BIT_13
00309 
00310 #define PWR_AND_CLK_SMPS()   do { __HAL_RCC_PWR_CLK_ENABLE(); \
00311                                   HAL_PWREx_EnableVddIO2(); \
00312                                   __HAL_RCC_GPIOG_CLK_ENABLE(); } while(0)
00313 
00314 #endif                          /* ADP5301ACBZ */
00315 
00316 #endif /* USE_STM32L4XX_NUCLEO_144_SMPS */
00317 
00318 /**
00319   * @}
00320   */
00321 
00322 /**
00323   * @}
00324   */
00325 
00326 /** @addtogroup STM32L4XX_NUCLEO_144_Exported_Functions
00327   * @{
00328   */
00329 uint32_t         BSP_GetVersion(void);
00330 
00331 /** @addtogroup STM32L4XX_NUCLEO_144_LED_Functions
00332   * @{
00333   */
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 /**
00340   * @}
00341   */
00342 
00343 /** @addtogroup STM32L4XX_NUCLEO_144_BUTTON_Functions
00344   * @{
00345   */
00346 void             BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode);
00347 void             BSP_PB_DeInit(Button_TypeDef Button);
00348 uint32_t         BSP_PB_GetState(Button_TypeDef Button);
00349 #if defined(HAL_ADC_MODULE_ENABLED)
00350 uint8_t          BSP_JOY_Init(void);
00351 void             BSP_JOY_DeInit(void);
00352 JOYState_TypeDef BSP_JOY_GetState(void);
00353 #endif /* HAL_ADC_MODULE_ENABLED */
00354 /**
00355   * @}
00356   */
00357 
00358 #ifdef USE_STM32L4XX_NUCLEO_144_SMPS
00359 /** @addtogroup STM32L4XX_NUCLEO_144_SMPS_Functions
00360   * @{
00361   */
00362 uint32_t         BSP_SMPS_Init(uint32_t VoltageRange);
00363 uint32_t         BSP_SMPS_DeInit(void);
00364 uint32_t         BSP_SMPS_Enable(uint32_t Delay, uint32_t Power_Good_Check);
00365 uint32_t         BSP_SMPS_Disable(void);
00366 uint32_t         BSP_SMPS_Supply_Enable(uint32_t Delay, uint32_t Power_Good_Check);
00367 uint32_t         BSP_SMPS_Supply_Disable(void);
00368 /**
00369   * @}
00370   */
00371 #endif /* USE_STM32L4XX_NUCLEO_144_SMPS */
00372 
00373 /**
00374   * @}
00375   */
00376 
00377 /**
00378   * @}
00379   */
00380 
00381 /**
00382   * @}
00383   */
00384 
00385 /**
00386   * @}
00387   */
00388 
00389 #ifdef __cplusplus
00390 }
00391 #endif
00392 
00393 #endif /* __STM32L4XX_NUCLEO_144_H */
00394 
00395 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Mon Oct 9 2017 01:35:13 for STM32L4xx_Nucleo_144 BSP User Manual by   doxygen 1.7.6.1