STM32F411E-Discovery BSP User Manual
|
stm32f411e_discovery.h
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f411e_discovery.h 00004 * @author MCD Application Team 00005 * @version V1.0.2 00006 * @date 31-January-2017 00007 * @brief This file contains definitions for STM32F401-Discovery Kit's Leds and 00008 * push-button hardware resources. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 00013 * 00014 * Redistribution and use in source and binary forms, with or without modification, 00015 * are permitted provided that the following conditions are met: 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00022 * may be used to endorse or promote products derived from this software 00023 * without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00028 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00029 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00031 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00033 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00034 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************** 00037 */ 00038 00039 /* Define to prevent recursive inclusion -------------------------------------*/ 00040 #ifndef __STM32F411E_DISCOVERY_H 00041 #define __STM32F411E_DISCOVERY_H 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00047 /* Includes ------------------------------------------------------------------*/ 00048 #include "stm32f4xx_hal.h" 00049 00050 /** @addtogroup BSP 00051 * @{ 00052 */ 00053 00054 /** @addtogroup STM32F411E_DISCOVERY 00055 * @{ 00056 */ 00057 00058 /** @defgroup __STM32F411E_DISCOVERY_HLOW_LEVEL STM32F411E DISCOVERY HLOW LEVEL 00059 * @{ 00060 */ 00061 00062 /** @defgroup __STM32F411E_DISCOVERY_HLOW_LEVEL_Exported_Types STM32F411E DISCOVERY HLOW LEVEL Exported Types 00063 * @{ 00064 */ 00065 typedef enum 00066 { 00067 LED4 = 0, 00068 LED3 = 1, 00069 LED5 = 2, 00070 LED6 = 3 00071 }Led_TypeDef; 00072 00073 typedef enum 00074 { 00075 BUTTON_KEY = 0, 00076 }Button_TypeDef; 00077 00078 typedef enum 00079 { 00080 BUTTON_MODE_GPIO = 0, 00081 BUTTON_MODE_EXTI = 1 00082 }ButtonMode_TypeDef; 00083 /** 00084 * @} 00085 */ 00086 00087 /** @defgroup __STM32F411E_DISCOVERY_HLOW_LEVEL_Exported_Constants STM32F411E DISCOVERY HLOW LEVEL Exported Constants 00088 * @{ 00089 */ 00090 00091 /** 00092 * @brief Define for STM32F411E_DISCOVERY board 00093 */ 00094 #if !defined (USE_STM32F411E_DISCO) 00095 #define USE_STM32F411E_DISCO 00096 #endif 00097 00098 /** @defgroup __STM32F411E_DISCOVERY_HLOW_LEVEL_LED STM32F411E DISCOVERY HLOW LEVEL LED 00099 * @{ 00100 */ 00101 #define LEDn 4 00102 00103 #define LED4_PIN GPIO_PIN_12 00104 #define LED4_GPIO_PORT GPIOD 00105 #define LED4_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() 00106 #define LED4_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() 00107 00108 00109 #define LED3_PIN GPIO_PIN_13 00110 #define LED3_GPIO_PORT GPIOD 00111 #define LED3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() 00112 #define LED3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() 00113 00114 00115 #define LED5_PIN GPIO_PIN_14 00116 #define LED5_GPIO_PORT GPIOD 00117 #define LED5_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() 00118 #define LED5_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() 00119 00120 00121 #define LED6_PIN GPIO_PIN_15 00122 #define LED6_GPIO_PORT GPIOD 00123 #define LED6_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() 00124 #define LED6_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE() 00125 00126 #define LEDx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) LED4_GPIO_CLK_ENABLE(); else \ 00127 if((__INDEX__) == 1) LED3_GPIO_CLK_ENABLE(); else \ 00128 if((__INDEX__) == 2) LED5_GPIO_CLK_ENABLE(); else \ 00129 if((__INDEX__) == 3) LED6_GPIO_CLK_ENABLE(); \ 00130 }while(0) 00131 00132 #define LEDx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) LED4_GPIO_CLK_DISABLE(); else \ 00133 if((__INDEX__) == 1) LED3_GPIO_CLK_DISABLE(); else \ 00134 if((__INDEX__) == 2) LED5_GPIO_CLK_DISABLE(); else \ 00135 if((__INDEX__) == 3) LED6_GPIO_CLK_DISABLE(); \ 00136 }while(0) 00137 /** 00138 * @} 00139 */ 00140 00141 /** @defgroup __STM32F411E_DISCOVERY_HLOW_LEVEL_BUTTON STM32F411E DISCOVERY HLOW LEVEL BUTTON 00142 * @{ 00143 */ 00144 #define BUTTONn 1 00145 00146 /** 00147 * @brief Wakeup push-button 00148 */ 00149 #define KEY_BUTTON_PIN GPIO_PIN_0 00150 #define KEY_BUTTON_GPIO_PORT GPIOA 00151 #define KEY_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() 00152 #define KEY_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() 00153 #define KEY_BUTTON_EXTI_IRQn EXTI0_IRQn 00154 00155 #define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_ENABLE(); \ 00156 }while(0) 00157 #define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) KEY_BUTTON_GPIO_CLK_DISABLE(); \ 00158 }while(0) 00159 /** 00160 * @} 00161 */ 00162 00163 /** @defgroup __STM32F411E_DISCOVERY_HLOW_LEVEL_BUS STM32F411E DISCOVERY HLOW LEVEL BUS 00164 * @{ 00165 */ 00166 00167 /*############################### I2Cx #######################################*/ 00168 #define DISCOVERY_I2Cx I2C1 00169 #define DISCOVERY_I2Cx_CLOCK_ENABLE() __HAL_RCC_I2C1_CLK_ENABLE() 00170 #define DISCOVERY_I2Cx_GPIO_PORT GPIOB /* GPIOB */ 00171 #define DISCOVERY_I2Cx_SCL_PIN GPIO_PIN_6 /* PB.06 */ 00172 #define DISCOVERY_I2Cx_SDA_PIN GPIO_PIN_9 /* PB.09 */ 00173 #define DISCOVERY_I2Cx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() 00174 #define DISCOVERY_I2Cx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() 00175 #define DISCOVERY_I2Cx_AF GPIO_AF4_I2C1 00176 00177 #define DISCOVERY_I2Cx_FORCE_RESET() __HAL_RCC_I2C1_FORCE_RESET() 00178 #define DISCOVERY_I2Cx_RELEASE_RESET() __HAL_RCC_I2C1_RELEASE_RESET() 00179 00180 /* I2C interrupt requests */ 00181 #define DISCOVERY_I2Cx_EV_IRQn I2C1_EV_IRQn 00182 #define DISCOVERY_I2Cx_ER_IRQn I2C1_ER_IRQn 00183 00184 /* I2C speed and timeout max */ 00185 #define I2Cx_TIMEOUT_MAX 0xA000 /*<! The value of the maximal timeout for I2C waiting loops */ 00186 #define I2Cx_MAX_COMMUNICATION_FREQ ((uint32_t) 100000) 00187 00188 /*################################# SPI1 #####################################*/ 00189 #define DISCOVERY_SPIx SPI1 00190 #define DISCOVERY_SPIx_CLOCK_ENABLE() __HAL_RCC_SPI1_CLK_ENABLE() 00191 #define DISCOVERY_SPIx_GPIO_PORT GPIOA /* GPIOA */ 00192 #define DISCOVERY_SPIx_AF GPIO_AF5_SPI1 00193 #define DISCOVERY_SPIx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() 00194 #define DISCOVERY_SPIx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE() 00195 #define DISCOVERY_SPIx_SCK_PIN GPIO_PIN_5 /* PA.05 */ 00196 #define DISCOVERY_SPIx_MISO_PIN GPIO_PIN_6 /* PA.06 */ 00197 #define DISCOVERY_SPIx_MOSI_PIN GPIO_PIN_7 /* PA.07 */ 00198 /* Maximum Timeout values for flags waiting loops. These timeouts are not based 00199 on accurate values, they just guarantee that the application will not remain 00200 stuck if the SPI communication is corrupted. 00201 You may modify these timeout values depending on CPU frequency and application 00202 conditions (interrupts routines ...). */ 00203 #define SPIx_TIMEOUT_MAX ((uint32_t)0x1000) 00204 00205 /*################################ GYROSCOPE #################################*/ 00206 /* Read/Write command */ 00207 #define READWRITE_CMD ((uint8_t)0x80) 00208 /* Multiple byte read/write command */ 00209 #define MULTIPLEBYTE_CMD ((uint8_t)0x40) 00210 /* Dummy Byte Send by the SPI Master device in order to generate the Clock to the Slave device */ 00211 #define DUMMY_BYTE ((uint8_t)0x00) 00212 00213 /* Chip Select macro definition */ 00214 #define GYRO_CS_LOW() HAL_GPIO_WritePin(GYRO_CS_GPIO_PORT, GYRO_CS_PIN, GPIO_PIN_RESET) 00215 #define GYRO_CS_HIGH() HAL_GPIO_WritePin(GYRO_CS_GPIO_PORT, GYRO_CS_PIN, GPIO_PIN_SET) 00216 00217 /** 00218 * @brief GYRO SPI Interface pins 00219 */ 00220 #define GYRO_CS_GPIO_PORT GPIOE /* GPIOE */ 00221 #define GYRO_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() 00222 #define GYRO_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() 00223 #define GYRO_CS_PIN GPIO_PIN_3 /* PE.03 */ 00224 00225 #define GYRO_INT_GPIO_PORT GPIOE /* GPIOE */ 00226 #define GYRO_INT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() 00227 #define GYRO_INT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() 00228 #define GYRO_INT1_PIN GPIO_PIN_0 /* PE.00 */ 00229 #define GYRO_INT1_EXTI_IRQn EXTI0_IRQn 00230 #define GYRO_INT2_PIN GPIO_PIN_1 /* PE.01 */ 00231 #define GYRO_INT2_EXTI_IRQn EXTI1_IRQn 00232 00233 /*################################### AUDIO ##################################*/ 00234 /** 00235 * @brief AUDIO I2C Interface pins 00236 */ 00237 /* Device I2C address */ 00238 #define AUDIO_I2C_ADDRESS 0x94 00239 00240 /* Audio codec power on/off macro definition */ 00241 #define CODEC_AUDIO_POWER_OFF() HAL_GPIO_WritePin(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, GPIO_PIN_RESET) 00242 #define CODEC_AUDIO_POWER_ON() HAL_GPIO_WritePin(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, GPIO_PIN_SET) 00243 00244 /* Audio Reset Pin definition */ 00245 #define AUDIO_RESET_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() 00246 #define AUDIO_RESET_PIN GPIO_PIN_4 00247 #define AUDIO_RESET_GPIO GPIOD 00248 /** 00249 * @} 00250 */ 00251 00252 /*############################### ACCELEROMETER ##############################*/ 00253 /** 00254 * @brief ACCELERO I2C1 Interface pins 00255 */ 00256 #define ACCELERO_DRDY_GPIO_PORT GPIOE /* GPIOE */ 00257 #define ACCELERO_DRDY_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() 00258 #define ACCELERO_DRDY_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() 00259 #define ACCELERO_DRDY_PIN GPIO_PIN_2 /* PE.02 */ 00260 #define ACCELERO_DRDY_EXTI_IRQn TAMP_STAMP_IRQn 00261 00262 #define ACCELERO_INT_GPIO_PORT GPIOE /* GPIOE */ 00263 #define ACCELERO_INT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE() 00264 #define ACCELERO_INT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE() 00265 #define ACCELERO_INT1_PIN GPIO_PIN_4 /* PE.04 */ 00266 #define ACCELERO_INT1_EXTI_IRQn EXTI4_IRQn 00267 #define ACCELERO_INT2_PIN GPIO_PIN_5 /* PE.05 */ 00268 #define ACCELERO_INT2_EXTI_IRQn EXTI9_5_IRQn 00269 /** 00270 * @} 00271 */ 00272 00273 /** @defgroup __STM32F411E_DISCOVERY_HLOW_LEVEL_Exported_Macros STM32F411E DISCOVERY HLOW LEVEL Exported Macros 00274 * @{ 00275 */ 00276 /** 00277 * @} 00278 */ 00279 00280 /** @defgroup __STM32F411E_DISCOVERY_HLOW_LEVEL_Exported_Functions STM32F411E DISCOVERY HLOW LEVEL Exported Functions 00281 * @{ 00282 */ 00283 uint32_t BSP_GetVersion(void); 00284 void BSP_LED_Init(Led_TypeDef Led); 00285 void BSP_LED_On(Led_TypeDef Led); 00286 void BSP_LED_Off(Led_TypeDef Led); 00287 void BSP_LED_Toggle(Led_TypeDef Led); 00288 void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode); 00289 uint32_t BSP_PB_GetState(Button_TypeDef Button); 00290 00291 /** 00292 * @} 00293 */ 00294 00295 /** 00296 * @} 00297 */ 00298 00299 /** 00300 * @} 00301 */ 00302 00303 /** 00304 * @} 00305 */ 00306 00307 #ifdef __cplusplus 00308 } 00309 #endif 00310 00311 #endif /* __STM32F411E_DISCOVERY_H */ 00312 00313 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Fri Jan 20 2017 11:38:17 for STM32F411E-Discovery BSP User Manual by 1.7.6.1