Mercurial > public > ostc4
comparison Discovery/Inc/stm32f429i_discovery.h @ 38:5f11787b4f42
include in ostc4 repository
| author | heinrichsweikamp |
|---|---|
| date | Sat, 28 Apr 2018 11:52:34 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 37:ccc45c0e1ea2 | 38:5f11787b4f42 |
|---|---|
| 1 /////////////////////////////////////////////////////////////////////////////// | |
| 2 /// -*- coding: UTF-8 -*- | |
| 3 /// | |
| 4 /// \file Discovery/Inc/stm32f429i_discovery.h | |
| 5 /// \brief I2C EEPROM Interface pins | |
| 6 /// \author MCD Application Team | |
| 7 /// \date 26-February-2014 | |
| 8 /// | |
| 9 /// $Id$ | |
| 10 /////////////////////////////////////////////////////////////////////////////// | |
| 11 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
| 12 /// | |
| 13 /// This program is free software: you can redistribute it and/or modify | |
| 14 /// it under the terms of the GNU General Public License as published by | |
| 15 /// the Free Software Foundation, either version 3 of the License, or | |
| 16 /// (at your option) any later version. | |
| 17 /// | |
| 18 /// This program is distributed in the hope that it will be useful, | |
| 19 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 20 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 21 /// GNU General Public License for more details. | |
| 22 /// | |
| 23 /// You should have received a copy of the GNU General Public License | |
| 24 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 25 ////////////////////////////////////////////////////////////////////////////// | |
| 26 /// \par COPYRIGHT(c) 2014 STMicroelectronics | |
| 27 /// | |
| 28 /// Redistribution and use in source and binary forms, with or without modification, | |
| 29 /// are permitted provided that the following conditions are met: | |
| 30 /// 1. Redistributions of source code must retain the above copyright notice, | |
| 31 /// this list of conditions and the following disclaimer. | |
| 32 /// 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 33 /// this list of conditions and the following disclaimer in the documentation | |
| 34 /// and/or other materials provided with the distribution. | |
| 35 /// 3. Neither the name of STMicroelectronics nor the names of its contributors | |
| 36 /// may be used to endorse or promote products derived from this software | |
| 37 /// without specific prior written permission. | |
| 38 /// | |
| 39 /// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 40 /// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 41 /// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 42 /// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |
| 43 /// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| 44 /// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 45 /// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
| 46 /// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
| 47 /// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 48 /// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 49 ////////////////////////////////////////////////////////////////////////////// | |
| 50 | |
| 51 /* Define to prevent recursive inclusion -------------------------------------*/ | |
| 52 #ifndef STM32F429I_DISCOVERY_H | |
| 53 #define STM32F429I_DISCOVERY_H | |
| 54 | |
| 55 /* Includes ------------------------------------------------------------------*/ | |
| 56 #include "stm32f4xx_hal.h" | |
| 57 | |
| 58 typedef enum | |
| 59 { | |
| 60 LED3 = 0, | |
| 61 LED4 = 1 | |
| 62 } Led_TypeDef; | |
| 63 | |
| 64 typedef enum | |
| 65 { | |
| 66 BUTTON_KEY = 0, | |
| 67 } Button_TypeDef; | |
| 68 | |
| 69 typedef enum | |
| 70 { | |
| 71 BUTTON_MODE_GPIO = 0, | |
| 72 BUTTON_MODE_EXTI = 1 | |
| 73 } ButtonMode_TypeDef; | |
| 74 | |
| 75 #if !defined (USE_STM32F429I_DISCO) | |
| 76 #define USE_STM32F429I_DISCO | |
| 77 #endif | |
| 78 | |
| 79 #define LEDn 2 | |
| 80 | |
| 81 #define LED3_PIN GPIO_PIN_13 | |
| 82 #define LED3_GPIO_PORT GPIOG | |
| 83 #define LED3_GPIO_CLK_ENABLE() __GPIOG_CLK_ENABLE() | |
| 84 #define LED3_GPIO_CLK_DISABLE() __GPIOG_CLK_DISABLE() | |
| 85 | |
| 86 | |
| 87 #define LED4_PIN GPIO_PIN_14 | |
| 88 #define LED4_GPIO_PORT GPIOG | |
| 89 #define LED4_GPIO_CLK_ENABLE() __GPIOG_CLK_ENABLE() | |
| 90 #define LED4_GPIO_CLK_DISABLE() __GPIOG_CLK_DISABLE() | |
| 91 | |
| 92 #define LEDx_GPIO_CLK_ENABLE(__INDEX__) (((__INDEX__) == 0) ? LED3_GPIO_CLK_ENABLE() : LED4_GPIO_CLK_ENABLE()) | |
| 93 #define LEDx_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? LED3_GPIO_CLK_DISABLE() : LED4_GPIO_CLK_DISABLE()) | |
| 94 | |
| 95 #define BUTTONn 1 | |
| 96 | |
| 97 /** | |
| 98 * @brief Wakeup push-button | |
| 99 */ | |
| 100 #define KEY_BUTTON_PIN GPIO_PIN_0 | |
| 101 #define KEY_BUTTON_GPIO_PORT GPIOA | |
| 102 #define KEY_BUTTON_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() | |
| 103 #define KEY_BUTTON_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() | |
| 104 #define KEY_BUTTON_EXTI_IRQn EXTI0_IRQn | |
| 105 | |
| 106 #define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) (KEY_BUTTON_GPIO_CLK_ENABLE()) | |
| 107 #define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) (KEY_BUTTON_GPIO_CLK_DISABLE()) | |
| 108 | |
| 109 /* Exported constanIO --------------------------------------------------------*/ | |
| 110 #define IO_I2C_ADDRESS 0x82 | |
| 111 #define TS_I2C_ADDRESS 0x82 | |
| 112 | |
| 113 #ifdef EE_M24LR64 | |
| 114 #define EEPROM_I2C_ADDRESS_A01 0xA0 | |
| 115 #define EEPROM_I2C_ADDRESS_A02 0xA6 | |
| 116 #endif /* EE_M24LR64 */ | |
| 117 | |
| 118 | |
| 119 /*##################### I2Cx ###################################*/ | |
| 120 /* User can use this section to tailor I2Cx instance used and associated | |
| 121 resources */ | |
| 122 #define DISCOVERY_I2Cx I2C3 | |
| 123 #define DISCOVERY_I2Cx_CLOCK_ENABLE() __I2C3_CLK_ENABLE() | |
| 124 #define DISCOVERY_I2Cx_FORCE_RESET() __I2C3_FORCE_RESET() | |
| 125 #define DISCOVERY_I2Cx_RELEASE_RESET() __I2C3_RELEASE_RESET() | |
| 126 #define DISCOVERY_I2Cx_SDA_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() | |
| 127 #define DISCOVERY_I2Cx_SCL_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() | |
| 128 #define DISCOVERY_I2Cx_SDA_GPIO_CLK_DISABLE() __GPIOC_CLK_DISABLE() | |
| 129 | |
| 130 /* Definition for DISCO I2Cx Pins */ | |
| 131 #define DISCOVERY_I2Cx_SCL_PIN GPIO_PIN_8 | |
| 132 #define DISCOVERY_I2Cx_SCL_GPIO_PORT GPIOA | |
| 133 #define DISCOVERY_I2Cx_SCL_SDA_AF GPIO_AF4_I2C3 | |
| 134 #define DISCOVERY_I2Cx_SDA_PIN GPIO_PIN_9 | |
| 135 #define DISCOVERY_I2Cx_SDA_GPIO_PORT GPIOC | |
| 136 | |
| 137 /* Definition for IOE I2Cx's NVIC */ | |
| 138 #define DISCOVERY_I2Cx_EV_IRQn I2C3_EV_IRQn | |
| 139 #define DISCOVERY_I2Cx_ER_IRQn I2C3_ER_IRQn | |
| 140 | |
| 141 /* I2C clock speed configuration (in Hz) | |
| 142 WARNING: | |
| 143 Make sure that this define is not already declared in other files (ie. | |
| 144 stm324x9i_disco.h file). It can be used in parallel by other modules. */ | |
| 145 #ifndef I2C_SPEED | |
| 146 #define I2C_SPEED 100000 | |
| 147 #endif /* I2C_SPEED */ | |
| 148 | |
| 149 #define I2Cx_TIMEOUT_MAX 0x3000 /*<! The value of the maximal timeout for I2C waiting loops */ | |
| 150 | |
| 151 /*##################### SPIx ###################################*/ | |
| 152 #define DISCOVERY_SPIx SPI5 | |
| 153 #define DISCOVERY_SPIx_CLK_ENABLE() __SPI5_CLK_ENABLE() | |
| 154 #define DISCOVERY_SPIx_GPIO_PORT GPIOF /* GPIOF */ | |
| 155 #define DISCOVERY_SPIx_AF GPIO_AF5_SPI5 | |
| 156 #define DISCOVERY_SPIx_GPIO_CLK_ENABLE() __GPIOF_CLK_ENABLE() | |
| 157 #define DISCOVERY_SPIx_GPIO_CLK_DISABLE() __GPIOF_CLK_DISABLE() | |
| 158 #define DISCOVERY_SPIx_SCK_PIN GPIO_PIN_7 /* PF.07 */ | |
| 159 #define DISCOVERY_SPIx_MISO_PIN GPIO_PIN_8 /* PF.08 */ | |
| 160 #define DISCOVERY_SPIx_MOSI_PIN GPIO_PIN_9 /* PF.09 */ | |
| 161 /* Maximum Timeout values for flags waiting loops. These timeouts are not based | |
| 162 on accurate values, they just guarantee that the application will not remain | |
| 163 stuck if the SPI communication is corrupted. | |
| 164 You may modify these timeout values depending on CPU frequency and application | |
| 165 conditions (interrupts routines ...). */ | |
| 166 #define SPIx_TIMEOUT_MAX ((uint32_t)0x1000) | |
| 167 | |
| 168 | |
| 169 /*##################### IOE ###################################*/ | |
| 170 /** | |
| 171 * @brief IOE Control pin | |
| 172 */ | |
| 173 /* Definition for external IT for STMPE811 */ | |
| 174 #define STMPE811_INT_PIN GPIO_PIN_15 | |
| 175 #define STMPE811_INT_GPIO_PORT GPIOA | |
| 176 #define STMPE811_INT_CLK_ENABLE() __GPIOA_CLK_ENABLE() | |
| 177 #define STMPE811_INT_CLK_DISABLE() __GPIOA_CLK_DISABLE() | |
| 178 #define STMPE811_INT_EXTI EXTI15_10_IRQn | |
| 179 #define STMPE811_INT_EXTIHandler EXTI15_10_IRQHandler | |
| 180 | |
| 181 /*##################### LCD ###################################*/ | |
| 182 /* Chip Select macro definition */ | |
| 183 #define LCD_CS_LOW() HAL_GPIO_WritePin(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, GPIO_PIN_RESET) | |
| 184 #define LCD_CS_HIGH() HAL_GPIO_WritePin(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, GPIO_PIN_SET) | |
| 185 | |
| 186 /* Set WRX High to send data */ | |
| 187 #define LCD_WRX_LOW() HAL_GPIO_WritePin(LCD_WRX_GPIO_PORT, LCD_WRX_PIN, GPIO_PIN_RESET) | |
| 188 #define LCD_WRX_HIGH() HAL_GPIO_WritePin(LCD_WRX_GPIO_PORT, LCD_WRX_PIN, GPIO_PIN_SET) | |
| 189 | |
| 190 /* Set WRX High to send data */ | |
| 191 #define LCD_RDX_LOW() HAL_GPIO_WritePin(LCD_RDX_GPIO_PORT, LCD_RDX_PIN, GPIO_PIN_RESET) | |
| 192 #define LCD_RDX_HIGH() HAL_GPIO_WritePin(LCD_RDX_GPIO_PORT, LCD_RDX_PIN, GPIO_PIN_SET) | |
| 193 | |
| 194 /** | |
| 195 * @brief LCD Control pin | |
| 196 */ | |
| 197 #define LCD_NCS_PIN GPIO_PIN_2 | |
| 198 #define LCD_NCS_GPIO_PORT GPIOC | |
| 199 #define LCD_NCS_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() | |
| 200 #define LCD_NCS_GPIO_CLK_DISABLE() __GPIOC_CLK_DISABLE() | |
| 201 | |
| 202 /** | |
| 203 * @brief LCD Command/data pin | |
| 204 */ | |
| 205 #define LCD_WRX_PIN GPIO_PIN_13 | |
| 206 #define LCD_WRX_GPIO_PORT GPIOD | |
| 207 #define LCD_WRX_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() | |
| 208 #define LCD_WRX_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() | |
| 209 | |
| 210 #define LCD_RDX_PIN GPIO_PIN_12 | |
| 211 #define LCD_RDX_GPIO_PORT GPIOD | |
| 212 #define LCD_RDX_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() | |
| 213 #define LCD_RDX_GPIO_CLK_DISABLE() __GPIOD_CLK_DISABLE() | |
| 214 | |
| 215 /*##################### GYRO ##########################*/ | |
| 216 /* Read/Write command */ | |
| 217 #define READWRITE_CMD ((uint8_t)0x80) | |
| 218 /* Multiple byte read/write command */ | |
| 219 #define MULTIPLEBYTE_CMD ((uint8_t)0x40) | |
| 220 /* Dummy Byte Send by the SPI Master device in order to generate the Clock to the Slave device */ | |
| 221 #define DUMMY_BYTE ((uint8_t)0x00) | |
| 222 | |
| 223 /* Chip Select macro definition */ | |
| 224 #define GYRO_CS_LOW() HAL_GPIO_WritePin(GYRO_CS_GPIO_PORT, GYRO_CS_PIN, GPIO_PIN_RESET) | |
| 225 #define GYRO_CS_HIGH() HAL_GPIO_WritePin(GYRO_CS_GPIO_PORT, GYRO_CS_PIN, GPIO_PIN_SET) | |
| 226 | |
| 227 /** | |
| 228 * @brief GYRO SPI Interface pins | |
| 229 */ | |
| 230 #define GYRO_CS_PIN GPIO_PIN_1 /* PC.01 */ | |
| 231 #define GYRO_CS_GPIO_PORT GPIOC /* GPIOC */ | |
| 232 #define GYRO_CS_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() | |
| 233 #define GYRO_CS_GPIO_CLK_DISABLE() __GPIOC_CLK_DISABLE() | |
| 234 | |
| 235 #define GYRO_INT_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE() | |
| 236 #define GYRO_INT_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE() | |
| 237 #define GYRO_INT_GPIO_PORT GPIOA /* GPIOA */ | |
| 238 #define GYRO_INT1_PIN GPIO_PIN_1 /* PA.01 */ | |
| 239 #define GYRO_INT1_EXTI_IRQn EXTI1_IRQn | |
| 240 #define GYRO_INT2_PIN GPIO_PIN_2 /* PA.02 */ | |
| 241 #define GYRO_INT2_EXTI_IRQn EXTI2_IRQn | |
| 242 | |
| 243 #ifdef EE_M24LR64 | |
| 244 | |
| 245 /** | |
| 246 * @brief I2C EEPROM Interface pins | |
| 247 */ | |
| 248 #define EEPROM_I2C_DMA DMA1 | |
| 249 #define EEPROM_I2C_DMA_CHANNEL DMA_CHANNEL_3 | |
| 250 #define EEPROM_I2C_DMA_STREAM_TX DMA1_Stream4 | |
| 251 #define EEPROM_I2C_DMA_STREAM_RX DMA1_Stream2 | |
| 252 #define EEPROM_I2C_DMA_CLK_ENABLE() __DMA1_CLK_ENABLE() | |
| 253 | |
| 254 #define EEPROM_I2C_DMA_TX_IRQn DMA1_Stream4_IRQn | |
| 255 #define EEPROM_I2C_DMA_RX_IRQn DMA1_Stream2_IRQn | |
| 256 #define EEPROM_I2C_DMA_TX_IRQHandler DMA1_Stream4_IRQHandler | |
| 257 #define EEPROM_I2C_DMA_RX_IRQHandler DMA1_Stream2_IRQHandler | |
| 258 #define EEPROM_I2C_DMA_PREPRIO 0 | |
| 259 | |
| 260 #endif /*EE_M24LR64*/ | |
| 261 | |
| 262 uint32_t BSP_GetVersion(void); | |
| 263 void BSP_LED_Init(Led_TypeDef Led); | |
| 264 void BSP_LED_On(Led_TypeDef Led); | |
| 265 void BSP_LED_Off(Led_TypeDef Led); | |
| 266 void BSP_LED_Toggle(Led_TypeDef Led); | |
| 267 void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode); | |
| 268 uint32_t BSP_PB_GetState(Button_TypeDef Button); | |
| 269 | |
| 270 #endif /* STM32F429I_DISCOVERY_H */ |
