my fork

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers stm32f4xx_nucleo.h Source File

stm32f4xx_nucleo.h

Go to the documentation of this file.
00001 /** 
00002   ******************************************************************************
00003   * @file    stm32f4xx_nucleo.h
00004   * @author  MCD Application Team
00005   * @version V1.1.0
00006   * @date    19-June-2014
00007   * @cond DOXYGEN_EXCLUDE
00008   * @brief   This file contains definitions for:
00009   *          + LEDs and push-button available on STM32F4XX-Nucleo Kit from
00010   *          STMicroelectronics.
00011   *          + LCD, joystick and microSD available on Adafruit 1.8" TFT LCD
00012   *          Expansion Board (reference ID 802).
00013   * @endcond
00014   ******************************************************************************
00015   * @attention
00016   *
00017   * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
00018   *
00019   * Redistribution and use in source and binary forms, with or without modification,
00020   * are permitted provided that the following conditions are met:
00021   *   1. Redistributions of source code must retain the above copyright notice,
00022   *      this list of conditions and the following disclaimer.
00023   *   2. Redistributions in binary form must reproduce the above copyright notice,
00024   *      this list of conditions and the following disclaimer in the documentation
00025   *      and/or other materials provided with the distribution.
00026   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00027   *      may be used to endorse or promote products derived from this software
00028   *      without specific prior written permission.
00029   *
00030   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00031   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00032   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00033   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00034   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00035   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00036   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00037   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00038   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00039   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00040   *
00041   ******************************************************************************  
00042   */ 
00043   
00044 /* Define to prevent recursive inclusion -------------------------------------*/
00045 #ifndef __STM32F4XX_NUCLEO_H
00046 #define __STM32F4XX_NUCLEO_H
00047 
00048 #ifdef __cplusplus
00049  extern "C" {
00050 #endif
00051 
00052 /* Includes ------------------------------------------------------------------*/
00053 #include "stm32f4xx_hal.h"
00054    
00055 /** @addtogroup BSP
00056   * @{
00057   */
00058 
00059 /** @addtogroup STM32F4XX_NUCLEO
00060   * @{
00061   */
00062 
00063 /** @addtogroup STM32F4XX_NUCLEO_LOW_LEVEL
00064   * @{
00065   */ 
00066 
00067 /** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Exported_Types
00068   * @{
00069   */
00070 typedef enum 
00071 {
00072   LED20 = 0
00073 }Led_TypeDef;
00074 
00075 typedef enum 
00076 {  
00077   BUTTON_KEY = 0
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 STM32F4XX_NUCLEO_LOW_LEVEL_Exported_Constants
00101   * @{
00102   */ 
00103 
00104 /** 
00105   * @brief Define for STM32F4XX_NUCLEO board  
00106   */ 
00107 #if !defined (USE_STM32F4XX_NUCLEO)
00108  #define USE_STM32F4XX_NUCLEO
00109 #endif
00110 
00111 /** @addtogroup STM32F4XX_NUCLEO_LOW_LEVEL_LED
00112   * @{
00113   */
00114 #define LEDn                                    1
00115 
00116 #define LED2_PIN                                GPIO_PIN_5
00117 #define LED2_GPIO_PORT                          GPIOA
00118 #define LED2_GPIO_CLK_ENABLE()                  __GPIOA_CLK_ENABLE()
00119 #define LED2_GPIO_CLK_DISABLE()                 __GPIOA_CLK_DISABLE()  
00120 
00121 #define LEDx_GPIO_CLK_ENABLE(__INDEX__)   (((__INDEX__) == 0) ? LED2_GPIO_CLK_ENABLE() : 0)
00122 #define LEDx_GPIO_CLK_DISABLE(__INDEX__)  (((__INDEX__) == 0) ? LED2_GPIO_CLK_DISABLE() : 0)
00123 /**
00124   * @}
00125   */ 
00126   
00127 /** @addtogroup STM32F4XX_NUCLEO_LOW_LEVEL_BUTTON
00128   * @{
00129   */  
00130 #define BUTTONn                                 1  
00131 
00132 /**
00133  * @brief Key push-button
00134  */
00135 #define KEY_BUTTON_PIN                          GPIO_PIN_13
00136 #define KEY_BUTTON_GPIO_PORT                    GPIOC
00137 #define KEY_BUTTON_GPIO_CLK_ENABLE()            __GPIOC_CLK_ENABLE()
00138 #define KEY_BUTTON_GPIO_CLK_DISABLE()           __GPIOC_CLK_DISABLE()
00139 #define KEY_BUTTON_EXTI_IRQn                    EXTI15_10_IRQn
00140 
00141 #define BUTTONx_GPIO_CLK_ENABLE(__INDEX__)   (((__INDEX__) == 0) ? KEY_BUTTON_GPIO_CLK_ENABLE() : 0)
00142 #define BUTTONx_GPIO_CLK_DISABLE(__INDEX__)  (((__INDEX__) == 0) ? KEY_BUTTON_GPIO_CLK_DISABLE() : 0)
00143 /**
00144   * @}
00145   */ 
00146 
00147 /** @addtogroup STM32F4XX_NUCLEO_LOW_LEVEL_BUS
00148   * @{
00149   */
00150 /*############################### SPI1 #######################################*/
00151 #define NUCLEO_SPIx                                     SPI1
00152 #define NUCLEO_SPIx_CLK_ENABLE()                        __SPI1_CLK_ENABLE()
00153 
00154 #define NUCLEO_SPIx_SCK_AF                              GPIO_AF5_SPI1
00155 #define NUCLEO_SPIx_SCK_GPIO_PORT                       GPIOA
00156 #define NUCLEO_SPIx_SCK_PIN                             GPIO_PIN_5
00157 #define NUCLEO_SPIx_SCK_GPIO_CLK_ENABLE()               __GPIOA_CLK_ENABLE()
00158 #define NUCLEO_SPIx_SCK_GPIO_CLK_DISABLE()              __GPIOA_CLK_DISABLE()
00159 
00160 #define NUCLEO_SPIx_MISO_MOSI_AF                        GPIO_AF5_SPI1
00161 #define NUCLEO_SPIx_MISO_MOSI_GPIO_PORT                 GPIOA
00162 #define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_ENABLE()         __GPIOA_CLK_ENABLE()
00163 #define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_DISABLE()        __GPIOA_CLK_DISABLE()
00164 #define NUCLEO_SPIx_MISO_PIN                            GPIO_PIN_6
00165 #define NUCLEO_SPIx_MOSI_PIN                            GPIO_PIN_7
00166 /* Maximum Timeout values for flags waiting loops. These timeouts are not based
00167    on accurate values, they just guarantee that the application will not remain
00168    stuck if the SPI communication is corrupted.
00169    You may modify these timeout values depending on CPU frequency and application
00170    conditions (interrupts routines ...). */   
00171 #define NUCLEO_SPIx_TIMEOUT_MAX                   1000
00172 
00173 /**
00174   * @brief  SD Control Lines management
00175   */
00176 #define SD_CS_LOW()       HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_RESET)
00177 #define SD_CS_HIGH()      HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_SET)
00178 
00179 /**
00180   * @brief  LCD Control Lines management
00181   */
00182 #define LCD_CS_LOW()      HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_RESET)
00183 #define LCD_CS_HIGH()     HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_SET)
00184 #define LCD_DC_LOW()      HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_RESET)
00185 #define LCD_DC_HIGH()     HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_SET)
00186      
00187 /**
00188   * @brief  SD Control Interface pins
00189   */
00190 #define SD_CS_PIN                                 GPIO_PIN_5
00191 #define SD_CS_GPIO_PORT                           GPIOB
00192 #define SD_CS_GPIO_CLK_ENABLE()                 __GPIOB_CLK_ENABLE()
00193 #define SD_CS_GPIO_CLK_DISABLE()                __GPIOB_CLK_DISABLE()
00194 
00195 /**
00196   * @brief  LCD Control Interface pins
00197   */
00198 #define LCD_CS_PIN                                 GPIO_PIN_6
00199 #define LCD_CS_GPIO_PORT                           GPIOB
00200 #define LCD_CS_GPIO_CLK_ENABLE()                 __GPIOB_CLK_ENABLE()
00201 #define LCD_CS_GPIO_CLK_DISABLE()                __GPIOB_CLK_DISABLE()
00202     
00203 /**
00204   * @brief  LCD Data/Command Interface pins
00205   */
00206 #define LCD_DC_PIN                                 GPIO_PIN_9
00207 #define LCD_DC_GPIO_PORT                           GPIOA
00208 #define LCD_DC_GPIO_CLK_ENABLE()                 __GPIOA_CLK_ENABLE()
00209 #define LCD_DC_GPIO_CLK_DISABLE()                __GPIOA_CLK_DISABLE()
00210 
00211 /*################################ ADC1 ######################################*/
00212 /**
00213   * @brief  ADC Interface pins
00214   *         used to detect motion of Joystick available on Adafruit 1.8" TFT shield
00215   */
00216 #define NUCLEO_ADCx                                 ADC1
00217 #define NUCLEO_ADCx_CLK_ENABLE()                  __ADC1_CLK_ENABLE()
00218 
00219 #define NUCLEO_ADCx_CHANNEL                       ADC_CHANNEL_8
00220    
00221 #define NUCLEO_ADCx_GPIO_PORT                       GPIOB
00222 #define NUCLEO_ADCx_GPIO_PIN                        GPIO_PIN_0
00223 #define NUCLEO_ADCx_GPIO_CLK_ENABLE()             __GPIOB_CLK_ENABLE()
00224 #define NUCLEO_ADCx_GPIO_CLK_DISABLE()            __GPIOB_CLK_DISABLE()
00225 /**
00226   * @}
00227   */
00228 
00229 /**
00230   * @}
00231   */
00232 
00233 /** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Exported_Macros
00234   * @{
00235   */  
00236 /**
00237   * @}
00238   */ 
00239 
00240 /** @defgroup STM32F4XX_NUCLEO_LOW_LEVEL_Exported_Functions
00241   * @{
00242   */
00243 uint32_t         BSP_GetVersion(void);  
00244 void             BSP_LED_Init(Led_TypeDef Led);
00245 void             BSP_LED_On(Led_TypeDef Led);
00246 void             BSP_LED_Off(Led_TypeDef Led);
00247 void             BSP_LED_Toggle(Led_TypeDef Led);
00248 void             BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode);
00249 uint32_t         BSP_PB_GetState(Button_TypeDef Button);
00250 uint8_t          BSP_JOY_Init(void);
00251 JOYState_TypeDef BSP_JOY_GetState(void);
00252   
00253 /**
00254   * @}
00255   */ 
00256 
00257 /**
00258   * @}
00259   */ 
00260 
00261 /**
00262   * @}
00263   */
00264 
00265 /**
00266   * @}
00267   */
00268 
00269 #ifdef __cplusplus
00270 }
00271 #endif
00272 
00273 #endif /* __STM32F4XX_NUCLEO_H */
00274 
00275 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
00276