Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: VL53L0X
Fork of BSP_B-L475E-IOT01 by
stm32l475e_iot01.h
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l475e_iot01.h 00004 * @author MCD Application Team 00005 * @brief STM32L475E IOT01 board support package 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V. 00010 * All rights reserved.</center></h2> 00011 * 00012 * Redistribution and use in source and binary forms, with or without 00013 * modification, are permitted, provided that the following conditions are met: 00014 * 00015 * 1. Redistribution of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of other 00021 * contributors to this software may be used to endorse or promote products 00022 * derived from this software without specific written permission. 00023 * 4. This software, including modifications and/or derivative works of this 00024 * software, must execute solely and exclusively on microcontroller or 00025 * microprocessor devices manufactured by or for STMicroelectronics. 00026 * 5. Redistribution and use of this software other than as permitted under 00027 * this license is void and will automatically terminate your rights under 00028 * this license. 00029 * 00030 * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 00031 * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 00032 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 00033 * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 00034 * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 00035 * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00036 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00037 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00038 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00039 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00040 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00041 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00042 * 00043 ****************************************************************************** 00044 */ 00045 00046 /* Define to prevent recursive inclusion -------------------------------------*/ 00047 #ifndef __STM32L475E_IOT01_H 00048 #define __STM32L475E_IOT01_H 00049 00050 #ifdef __cplusplus 00051 extern "C" { 00052 #endif 00053 00054 /* Includes ------------------------------------------------------------------*/ 00055 #include "stm32l4xx_hal.h" 00056 00057 /** @addtogroup BSP 00058 * @{ 00059 */ 00060 00061 /** @addtogroup STM32L475E_IOT01 00062 * @{ 00063 */ 00064 00065 /** @addtogroup STM32L475E_IOT01_LOW_LEVEL 00066 * @{ 00067 */ 00068 00069 /** @defgroup STM32L475E_IOT01_LOW_LEVEL_Exported_Types LOW LEVEL Exported Types 00070 * @{ 00071 */ 00072 typedef enum 00073 { 00074 DISCO_LED2 = 0, 00075 DISCO_LED_GREEN = DISCO_LED2, 00076 }Led_TypeDef; 00077 00078 00079 typedef enum 00080 { 00081 BUTTON_USER = 0 00082 }Button_TypeDef; 00083 00084 typedef enum 00085 { 00086 BUTTON_MODE_GPIO = 0, 00087 BUTTON_MODE_EXTI = 1 00088 }ButtonMode_TypeDef; 00089 00090 typedef enum 00091 { 00092 COM1 = 0, 00093 COM2 = 0, 00094 }COM_TypeDef; 00095 /** 00096 * @} 00097 */ 00098 00099 /** @defgroup STM32L475E_IOT01_LOW_LEVEL_Exported_Constants LOW LEVEL Exported Constants 00100 * @{ 00101 */ 00102 00103 /** 00104 * @brief Define for STM32L475E_IOT01 board 00105 */ 00106 #if !defined (USE_STM32L475E_IOT01) 00107 #define USE_STM32L475E_IOT01 00108 #endif 00109 00110 #define LEDn ((uint8_t)1) 00111 00112 #define LED2_PIN GPIO_PIN_14 00113 #define LED2_GPIO_PORT GPIOB 00114 #define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() 00115 #define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() 00116 00117 00118 00119 #define LEDx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) LED2_GPIO_CLK_ENABLE();}while(0) 00120 00121 #define LEDx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) LED2_GPIO_CLK_DISABLE();}while(0) 00122 00123 /* Only one User/Wakeup button */ 00124 #define BUTTONn ((uint8_t)1) 00125 00126 /** 00127 * @brief Wakeup push-button 00128 */ 00129 #define USER_BUTTON_PIN GPIO_PIN_13 00130 #define USER_BUTTON_GPIO_PORT GPIOC 00131 #define USER_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() 00132 #define USER_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() 00133 #define USER_BUTTON_EXTI_IRQn EXTI15_10_IRQn 00134 00135 /** 00136 * @brief NFC Gpio PINs 00137 */ 00138 #define NFC_GPIO_GPO_PIN GPIO_PIN_4 00139 #define NFC_GPIO_GPO_PIN_PORT GPIOE 00140 #define NFC_GPIO_RFDISABLE_PIN GPIO_PIN_2 00141 #define NFC_GPIO_RFDISABLE_PIN_PORT GPIOE 00142 #define NFC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE(); 00143 #define NFC_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE(); 00144 00145 00146 #define COMn ((uint8_t)1) 00147 00148 /** 00149 * @brief Definition for COM port1, connected to USART1 00150 */ 00151 #define DISCOVERY_COM1 USART1 00152 #define DISCOVERY_COM1_CLK_ENABLE() __HAL_RCC_USART1_CLK_ENABLE() 00153 #define DISCOVERY_COM1_CLK_DISABLE() __HAL_RCC_USART1_CLK_DISABLE() 00154 00155 #define DISCOVERY_COM1_TX_PIN GPIO_PIN_6 00156 #define DISCOVERY_COM1_TX_GPIO_PORT GPIOB 00157 #define DISCOVERY_COM1_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() 00158 #define DISCOVERY_COM1_TX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() 00159 #define DISCOVERY_COM1_TX_AF GPIO_AF7_USART1 00160 00161 #define DISCOVERY_COM1_RX_PIN GPIO_PIN_7 00162 #define DISCOVERY_COM1_RX_GPIO_PORT GPIOB 00163 #define DISCOVERY_COM1_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() 00164 #define DISCOVERY_COM1_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() 00165 #define DISCOVERY_COM1_RX_AF GPIO_AF7_USART1 00166 00167 #define DISCOVERY_COM1_IRQn USART1_IRQn 00168 00169 00170 #define DISCOVERY_COMx_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_CLK_ENABLE();}} while(0) 00171 #define DISCOVERY_COMx_CLK_DISABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_CLK_DISABLE();}} while(0) 00172 00173 #define DISCOVERY_COMx_TX_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_TX_GPIO_CLK_ENABLE();}} while(0) 00174 #define DISCOVERY_COMx_TX_GPIO_CLK_DISABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_TX_GPIO_CLK_DISABLE();}} while(0) 00175 00176 #define DISCOVERY_COMx_RX_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_RX_GPIO_CLK_ENABLE();}} while(0) 00177 #define DISCOVERY_COMx_RX_GPIO_CLK_DISABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_RX_GPIO_CLK_DISABLE();}} while(0) 00178 00179 00180 /* User can use this section to tailor I2Cx instance used and associated resources */ 00181 /* Definition for I2Cx resources */ 00182 #define DISCOVERY_I2Cx I2C2 00183 #define DISCOVERY_I2Cx_CLK_ENABLE() __HAL_RCC_I2C2_CLK_ENABLE() 00184 #define DISCOVERY_I2Cx_CLK_DISABLE() __HAL_RCC_I2C2_CLK_DISABLE() 00185 #define DISCOVERY_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE() 00186 #define DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() 00187 #define DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() 00188 00189 #define DISCOVERY_I2Cx_FORCE_RESET() __HAL_RCC_I2C2_FORCE_RESET() 00190 #define DISCOVERY_I2Cx_RELEASE_RESET() __HAL_RCC_I2C2_RELEASE_RESET() 00191 00192 /* Definition for I2Cx Pins */ 00193 #define DISCOVERY_I2Cx_SCL_PIN GPIO_PIN_10 00194 #define DISCOVERY_I2Cx_SDA_PIN GPIO_PIN_11 00195 #define DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT GPIOB 00196 #define DISCOVERY_I2Cx_SCL_SDA_AF GPIO_AF4_I2C2 00197 00198 /* I2C interrupt requests */ 00199 #define DISCOVERY_I2Cx_EV_IRQn I2C2_EV_IRQn 00200 #define DISCOVERY_I2Cx_ER_IRQn I2C2_ER_IRQn 00201 00202 /* I2C clock speed configuration (in Hz) 00203 WARNING: 00204 Make sure that this define is not already declared in other files. 00205 It can be used in parallel by other modules. */ 00206 #ifndef DISCOVERY_I2C_SPEED 00207 #define DISCOVERY_I2C_SPEED 100000 00208 #endif /* DISCOVERY_I2C_SPEED */ 00209 00210 #ifndef DISCOVERY_I2Cx_TIMING 00211 #define DISCOVERY_I2Cx_TIMING ((uint32_t)0x00702681) 00212 #endif /* DISCOVERY_I2Cx_TIMING */ 00213 00214 00215 /* I2C Sensors address */ 00216 /* LPS22HB (Pressure) I2C Address */ 00217 #define LPS22HB_I2C_ADDRESS (uint8_t)0xBA 00218 /* HTS221 (Humidity) I2C Address */ 00219 #define HTS221_I2C_ADDRESS (uint8_t)0xBE 00220 00221 #ifdef USE_LPS22HB_TEMP 00222 /* LPS22HB Sensor hardware I2C address */ 00223 #define TSENSOR_I2C_ADDRESS LPS22HB_I2C_ADDRESS 00224 #else /* USE_HTS221_TEMP */ 00225 /* HTS221 Sensor hardware I2C address */ 00226 #define TSENSOR_I2C_ADDRESS HTS221_I2C_ADDRESS 00227 #endif 00228 00229 /* NFC I2C address and specific config parameters */ 00230 #define M24SR_I2C_ADDR (uint8_t) 0xAC /*!< M24SR address */ 00231 #define NFC_I2C_STATUS_SUCCESS (uint16_t) 0x0000 00232 #define NFC_I2C_ERROR_TIMEOUT (uint16_t) 0x0011 00233 #define NFC_I2C_TIMEOUT_STD (uint32_t) 8 /* I2C Time out (ms), used to call Transmit/Receive HAL functions */ 00234 #define NFC_I2C_TIMEOUT_MAX (uint32_t) 200 /* I2C Time out (ms), this is the maximum time needed by M24SR to complete any command */ 00235 #define NFC_I2C_TRIALS (uint32_t) 1 /* In case M24SR will reply ACK failed allow to perform retry before returning error (HAL option not used) */ 00236 00237 00238 /** 00239 * @} 00240 */ 00241 00242 /* Exported types ------------------------------------------------------------*/ 00243 /* Exported constants --------------------------------------------------------*/ 00244 /* Exported macros -----------------------------------------------------------*/ 00245 /* Private macros ------------------------------------------------------------*/ 00246 /* Exported functions --------------------------------------------------------*/ 00247 00248 /** @defgroup STM32L475E_IOT01_LOW_LEVEL_Exported_Functions LOW LEVEL Exported Functions 00249 * @{ 00250 */ 00251 uint32_t BSP_GetVersion(void); 00252 void BSP_LED_Init(Led_TypeDef Led); 00253 void BSP_LED_DeInit(Led_TypeDef Led); 00254 void BSP_LED_On(Led_TypeDef Led); 00255 void BSP_LED_Off(Led_TypeDef Led); 00256 void BSP_LED_Toggle(Led_TypeDef Led); 00257 void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode); 00258 void BSP_PB_DeInit(Button_TypeDef Button); 00259 uint32_t BSP_PB_GetState(Button_TypeDef Button); 00260 void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *husart); 00261 void BSP_COM_DeInit(COM_TypeDef COM, UART_HandleTypeDef *huart); 00262 /** 00263 * @} 00264 */ 00265 00266 /** 00267 * @} 00268 */ 00269 00270 /** 00271 * @} 00272 */ 00273 00274 /** 00275 * @} 00276 */ 00277 #ifdef __cplusplus 00278 } 00279 #endif 00280 00281 #endif /* __STM32L475E_IOT01_H */ 00282 00283 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 15:06:31 by
1.7.2
