Added support for obtaining BLE device name by parsing advertising data.

Fork of BLE_BlueNRG by Mridupawan Das

Committer:
hemddabral
Date:
Thu Jul 31 11:09:28 2014 +0000
Revision:
7:e293b0f43dc7
Parent:
0:309c845d289d
Added support for parsing BLE device name from advertising data

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mridup 0:309c845d289d 1 /**
mridup 0:309c845d289d 2 ******************************************************************************
mridup 0:309c845d289d 3 * @file stm32l0xx_nucleo.h
mridup 0:309c845d289d 4 * @author MCD Application Team
mridup 0:309c845d289d 5 * @version V1.0.0
mridup 0:309c845d289d 6 * @date 22-April-2014
mridup 0:309c845d289d 7 * @brief This file contains definitions for:
mridup 0:309c845d289d 8 * - LEDs and push-button available on STM32L0XX-Nucleo Kit
mridup 0:309c845d289d 9 * from STMicroelectronics
mridup 0:309c845d289d 10 * - LCD, joystick and microSD available on Adafruit 1.8" TFT LCD
mridup 0:309c845d289d 11 * shield (reference ID 802)
mridup 0:309c845d289d 12 ******************************************************************************
mridup 0:309c845d289d 13 * @attention
mridup 0:309c845d289d 14 *
mridup 0:309c845d289d 15 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mridup 0:309c845d289d 16 *
mridup 0:309c845d289d 17 * Redistribution and use in source and binary forms, with or without modification,
mridup 0:309c845d289d 18 * are permitted provided that the following conditions are met:
mridup 0:309c845d289d 19 * 1. Redistributions of source code must retain the above copyright notice,
mridup 0:309c845d289d 20 * this list of conditions and the following disclaimer.
mridup 0:309c845d289d 21 * 2. Redistributions in binary form must reproduce the above copyright notice,
mridup 0:309c845d289d 22 * this list of conditions and the following disclaimer in the documentation
mridup 0:309c845d289d 23 * and/or other materials provided with the distribution.
mridup 0:309c845d289d 24 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mridup 0:309c845d289d 25 * may be used to endorse or promote products derived from this software
mridup 0:309c845d289d 26 * without specific prior written permission.
mridup 0:309c845d289d 27 *
mridup 0:309c845d289d 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mridup 0:309c845d289d 29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mridup 0:309c845d289d 30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mridup 0:309c845d289d 31 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mridup 0:309c845d289d 32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mridup 0:309c845d289d 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mridup 0:309c845d289d 34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mridup 0:309c845d289d 35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mridup 0:309c845d289d 36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mridup 0:309c845d289d 37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mridup 0:309c845d289d 38 *
mridup 0:309c845d289d 39 ******************************************************************************
mridup 0:309c845d289d 40 */
mridup 0:309c845d289d 41
mridup 0:309c845d289d 42 /* Define to prevent recursive inclusion -------------------------------------*/
mridup 0:309c845d289d 43 #ifndef __STM32L0XX_NUCLEO_H
mridup 0:309c845d289d 44 #define __STM32L0XX_NUCLEO_H
mridup 0:309c845d289d 45
mridup 0:309c845d289d 46 #ifdef __cplusplus
mridup 0:309c845d289d 47 extern "C" {
mridup 0:309c845d289d 48 #endif
mridup 0:309c845d289d 49
mridup 0:309c845d289d 50 /* Includes ------------------------------------------------------------------*/
mridup 0:309c845d289d 51 #include "stm32l0xx_hal.h"
mridup 0:309c845d289d 52
mridup 0:309c845d289d 53
mridup 0:309c845d289d 54 /** @addtogroup BSP
mridup 0:309c845d289d 55 * @{
mridup 0:309c845d289d 56 */
mridup 0:309c845d289d 57
mridup 0:309c845d289d 58 /** @addtogroup STM32L0XX_NUCLEO
mridup 0:309c845d289d 59 * @{
mridup 0:309c845d289d 60 */
mridup 0:309c845d289d 61
mridup 0:309c845d289d 62 /** @addtogroup STM32L0XX_NUCLEO_LOW_LEVEL
mridup 0:309c845d289d 63 * @{
mridup 0:309c845d289d 64 */
mridup 0:309c845d289d 65
mridup 0:309c845d289d 66 /** @defgroup STM32L0XX_NUCLEO_LOW_LEVEL_Exported_Types
mridup 0:309c845d289d 67 * @{
mridup 0:309c845d289d 68 */
mridup 0:309c845d289d 69 typedef enum
mridup 0:309c845d289d 70 {
mridup 0:309c845d289d 71 L0_LED2 = 0
mridup 0:309c845d289d 72 } Led_TypeDef;
mridup 0:309c845d289d 73
mridup 0:309c845d289d 74 typedef enum
mridup 0:309c845d289d 75 {
mridup 0:309c845d289d 76 BUTTON_KEY = 0
mridup 0:309c845d289d 77 } Button_TypeDef;
mridup 0:309c845d289d 78
mridup 0:309c845d289d 79 typedef enum
mridup 0:309c845d289d 80 {
mridup 0:309c845d289d 81 BUTTON_MODE_GPIO = 0,
mridup 0:309c845d289d 82 BUTTON_MODE_EXTI = 1
mridup 0:309c845d289d 83 } ButtonMode_TypeDef;
mridup 0:309c845d289d 84
mridup 0:309c845d289d 85 typedef enum
mridup 0:309c845d289d 86 {
mridup 0:309c845d289d 87 JOY_NONE = 0,
mridup 0:309c845d289d 88 JOY_SEL = 1,
mridup 0:309c845d289d 89 JOY_DOWN = 2,
mridup 0:309c845d289d 90 JOY_LEFT = 3,
mridup 0:309c845d289d 91 JOY_RIGHT = 4,
mridup 0:309c845d289d 92 JOY_UP = 5
mridup 0:309c845d289d 93 } JOYState_TypeDef;
mridup 0:309c845d289d 94
mridup 0:309c845d289d 95 /**
mridup 0:309c845d289d 96 * @}
mridup 0:309c845d289d 97 */
mridup 0:309c845d289d 98
mridup 0:309c845d289d 99 /** @defgroup STM32L0XX_NUCLEO_LOW_LEVEL_Exported_Constants
mridup 0:309c845d289d 100 * @{
mridup 0:309c845d289d 101 */
mridup 0:309c845d289d 102
mridup 0:309c845d289d 103 /**
mridup 0:309c845d289d 104 * @brief Define for STM32L0XX_NUCLEO board
mridup 0:309c845d289d 105 */
mridup 0:309c845d289d 106 #if !defined (USE_STM32L0XX_NUCLEO)
mridup 0:309c845d289d 107 #define USE_STM32L0XX_NUCLEO
mridup 0:309c845d289d 108 #endif
mridup 0:309c845d289d 109
mridup 0:309c845d289d 110 /**
mridup 0:309c845d289d 111 * @}
mridup 0:309c845d289d 112 */
mridup 0:309c845d289d 113
mridup 0:309c845d289d 114 /** @addtogroup STM32L0XX_NUCLEO_LOW_LEVEL_LED
mridup 0:309c845d289d 115 * @{
mridup 0:309c845d289d 116 */
mridup 0:309c845d289d 117 #define LEDn 1
mridup 0:309c845d289d 118
mridup 0:309c845d289d 119 #define LED2_PIN GPIO_PIN_5
mridup 0:309c845d289d 120 #define LED2_GPIO_PORT GPIOA
mridup 0:309c845d289d 121 #define LED2_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
mridup 0:309c845d289d 122 #define LED2_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE()
mridup 0:309c845d289d 123
mridup 0:309c845d289d 124 #define LEDx_GPIO_CLK_ENABLE(__INDEX__) (((__INDEX__) == 0) ? LED2_GPIO_CLK_ENABLE() : 0)
mridup 0:309c845d289d 125 #define LEDx_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? LED2_GPIO_CLK_DISABLE() : 0)
mridup 0:309c845d289d 126 /**
mridup 0:309c845d289d 127 * @}
mridup 0:309c845d289d 128 */
mridup 0:309c845d289d 129
mridup 0:309c845d289d 130 /** @addtogroup STM32L0XX_NUCLEO_LOW_LEVEL_BUTTON
mridup 0:309c845d289d 131 * @{
mridup 0:309c845d289d 132 */
mridup 0:309c845d289d 133 #define BUTTONn 1
mridup 0:309c845d289d 134
mridup 0:309c845d289d 135 /**
mridup 0:309c845d289d 136 * @brief Key push-button
mridup 0:309c845d289d 137 */
mridup 0:309c845d289d 138 #define KEY_BUTTON_PIN GPIO_PIN_13
mridup 0:309c845d289d 139 #define KEY_BUTTON_GPIO_PORT GPIOC
mridup 0:309c845d289d 140 #define KEY_BUTTON_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE()
mridup 0:309c845d289d 141 #define KEY_BUTTON_GPIO_CLK_DISABLE() __GPIOC_CLK_DISABLE()
mridup 0:309c845d289d 142 #define KEY_BUTTON_EXTI_LINE GPIO_PIN_13
mridup 0:309c845d289d 143 #define KEY_BUTTON_EXTI_IRQn EXTI4_15_IRQn
mridup 0:309c845d289d 144
mridup 0:309c845d289d 145 #define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) (((__INDEX__) == 0) ? KEY_BUTTON_GPIO_CLK_ENABLE() : 0)
mridup 0:309c845d289d 146 #define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? KEY_BUTTON_GPIO_CLK_DISABLE() : 0)
mridup 0:309c845d289d 147 /**
mridup 0:309c845d289d 148 * @}
mridup 0:309c845d289d 149 */
mridup 0:309c845d289d 150
mridup 0:309c845d289d 151 /** @addtogroup STM32L0XX_NUCLEO_LOW_LEVEL_BUS
mridup 0:309c845d289d 152 * @{
mridup 0:309c845d289d 153 */
mridup 0:309c845d289d 154 /*###################### SPI1 ###################################*/
mridup 0:309c845d289d 155 #define NUCLEO_SPIx SPI1
mridup 0:309c845d289d 156 #define NUCLEO_SPIx_CLK_ENABLE() __SPI1_CLK_ENABLE()
mridup 0:309c845d289d 157
mridup 0:309c845d289d 158 #define NUCLEO_SPIx_SCK_AF GPIO_AF0_SPI1
mridup 0:309c845d289d 159 #define NUCLEO_SPIx_SCK_GPIO_PORT GPIOA
mridup 0:309c845d289d 160 #define NUCLEO_SPIx_SCK_PIN GPIO_PIN_5
mridup 0:309c845d289d 161 #define NUCLEO_SPIx_SCK_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
mridup 0:309c845d289d 162 #define NUCLEO_SPIx_SCK_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE()
mridup 0:309c845d289d 163
mridup 0:309c845d289d 164 #define NUCLEO_SPIx_MISO_MOSI_AF GPIO_AF0_SPI1
mridup 0:309c845d289d 165 #define NUCLEO_SPIx_MISO_MOSI_GPIO_PORT GPIOA
mridup 0:309c845d289d 166 #define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
mridup 0:309c845d289d 167 #define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE()
mridup 0:309c845d289d 168 #define NUCLEO_SPIx_MISO_PIN GPIO_PIN_6
mridup 0:309c845d289d 169 #define NUCLEO_SPIx_MOSI_PIN GPIO_PIN_7
mridup 0:309c845d289d 170 /* Maximum Timeout values for flags waiting loops. These timeouts are not based
mridup 0:309c845d289d 171 on accurate values, they just guarantee that the application will not remain
mridup 0:309c845d289d 172 stuck if the SPI communication is corrupted.
mridup 0:309c845d289d 173 You may modify these timeout values depending on CPU frequency and application
mridup 0:309c845d289d 174 conditions (interrupts routines ...). */
mridup 0:309c845d289d 175 #define NUCLEO_SPIx_TIMEOUT_MAX 1000
mridup 0:309c845d289d 176
mridup 0:309c845d289d 177 /** @addtogroup STM32L0XX_NUCLEO_LOW_LEVEL_COMPONENT
mridup 0:309c845d289d 178 * @{
mridup 0:309c845d289d 179 */
mridup 0:309c845d289d 180
mridup 0:309c845d289d 181 /**
mridup 0:309c845d289d 182 * @brief SD Control Lines management
mridup 0:309c845d289d 183 */
mridup 0:309c845d289d 184 #define SD_CS_LOW() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_RESET)
mridup 0:309c845d289d 185 #define SD_CS_HIGH() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_SET)
mridup 0:309c845d289d 186
mridup 0:309c845d289d 187 /**
mridup 0:309c845d289d 188 * @brief LCD Control Lines management
mridup 0:309c845d289d 189 */
mridup 0:309c845d289d 190 #define LCD_CS_LOW() HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_RESET)
mridup 0:309c845d289d 191 #define LCD_CS_HIGH() HAL_GPIO_WritePin(LCD_CS_GPIO_PORT, LCD_CS_PIN, GPIO_PIN_SET)
mridup 0:309c845d289d 192 #define LCD_DC_LOW() HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_RESET)
mridup 0:309c845d289d 193 #define LCD_DC_HIGH() HAL_GPIO_WritePin(LCD_DC_GPIO_PORT, LCD_DC_PIN, GPIO_PIN_SET)
mridup 0:309c845d289d 194
mridup 0:309c845d289d 195 /**
mridup 0:309c845d289d 196 * @brief SD Control Interface pins
mridup 0:309c845d289d 197 */
mridup 0:309c845d289d 198 #define SD_CS_PIN GPIO_PIN_5
mridup 0:309c845d289d 199 #define SD_CS_GPIO_PORT GPIOB
mridup 0:309c845d289d 200 #define SD_CS_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
mridup 0:309c845d289d 201 #define SD_CS_GPIO_CLK_DISABLE() __GPIOB_CLK_DISABLE()
mridup 0:309c845d289d 202
mridup 0:309c845d289d 203 /**
mridup 0:309c845d289d 204 * @brief LCD Control Interface pins
mridup 0:309c845d289d 205 */
mridup 0:309c845d289d 206 #define LCD_CS_PIN GPIO_PIN_6
mridup 0:309c845d289d 207 #define LCD_CS_GPIO_PORT GPIOB
mridup 0:309c845d289d 208 #define LCD_CS_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
mridup 0:309c845d289d 209 #define LCD_CS_GPIO_CLK_DISABLE() __GPIOB_CLK_DISABLE()
mridup 0:309c845d289d 210
mridup 0:309c845d289d 211 /**
mridup 0:309c845d289d 212 * @brief LCD Data/Command Interface pins
mridup 0:309c845d289d 213 */
mridup 0:309c845d289d 214 #define LCD_DC_PIN GPIO_PIN_9
mridup 0:309c845d289d 215 #define LCD_DC_GPIO_PORT GPIOA
mridup 0:309c845d289d 216 #define LCD_DC_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
mridup 0:309c845d289d 217 #define LCD_DC_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE()
mridup 0:309c845d289d 218
mridup 0:309c845d289d 219 /*##################### ADC1 ###################################*/
mridup 0:309c845d289d 220 /**
mridup 0:309c845d289d 221 * @brief ADC Interface pins
mridup 0:309c845d289d 222 * used to detect motion of Joystick available on Adafruit 1.8" TFT shield
mridup 0:309c845d289d 223 */
mridup 0:309c845d289d 224 #define NUCLEO_ADCx ADC1
mridup 0:309c845d289d 225 #define NUCLEO_ADCx_CLK_ENABLE() __ADC1_CLK_ENABLE()
mridup 0:309c845d289d 226
mridup 0:309c845d289d 227 #define NUCLEO_ADCx_GPIO_PORT GPIOB
mridup 0:309c845d289d 228 #define NUCLEO_ADCx_GPIO_PIN GPIO_PIN_0
mridup 0:309c845d289d 229 #define NUCLEO_ADCx_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE()
mridup 0:309c845d289d 230 #define NUCLEO_ADCx_GPIO_CLK_DISABLE() __GPIOB_CLK_ENABLE()
mridup 0:309c845d289d 231
mridup 0:309c845d289d 232 /** @defgroup STM32L0XX_NUCLEO_LOW_LEVEL_Exported_Macros
mridup 0:309c845d289d 233 * @{
mridup 0:309c845d289d 234 */
mridup 0:309c845d289d 235 /**
mridup 0:309c845d289d 236 * @}
mridup 0:309c845d289d 237 */
mridup 0:309c845d289d 238
mridup 0:309c845d289d 239
mridup 0:309c845d289d 240 /** @defgroup STM32L0XX_NUCLEO_LOW_LEVEL_Exported_Functions
mridup 0:309c845d289d 241 * @{
mridup 0:309c845d289d 242 */
mridup 0:309c845d289d 243 uint32_t BSP_GetVersion(void);
mridup 0:309c845d289d 244 void BSP_LED_Init(Led_TypeDef Led);
mridup 0:309c845d289d 245 void BSP_LED_On(Led_TypeDef Led);
mridup 0:309c845d289d 246 void BSP_LED_Off(Led_TypeDef Led);
mridup 0:309c845d289d 247 void BSP_LED_Toggle(Led_TypeDef Led);
mridup 0:309c845d289d 248 void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode);
mridup 0:309c845d289d 249 uint32_t BSP_PB_GetState(Button_TypeDef Button);
mridup 0:309c845d289d 250 uint8_t BSP_JOY_Init(void);
mridup 0:309c845d289d 251 JOYState_TypeDef BSP_JOY_GetState(void);
mridup 0:309c845d289d 252 /**
mridup 0:309c845d289d 253 * @}
mridup 0:309c845d289d 254 */
mridup 0:309c845d289d 255
mridup 0:309c845d289d 256 #ifdef __cplusplus
mridup 0:309c845d289d 257 }
mridup 0:309c845d289d 258 #endif
mridup 0:309c845d289d 259
mridup 0:309c845d289d 260 #endif /* __STM32L0XX_NUCLEO_H */
mridup 0:309c845d289d 261 /**
mridup 0:309c845d289d 262 * @}
mridup 0:309c845d289d 263 */
mridup 0:309c845d289d 264
mridup 0:309c845d289d 265 /**
mridup 0:309c845d289d 266 * @}
mridup 0:309c845d289d 267 */
mridup 0:309c845d289d 268
mridup 0:309c845d289d 269 /**
mridup 0:309c845d289d 270 * @}
mridup 0:309c845d289d 271 */
mridup 0:309c845d289d 272
mridup 0:309c845d289d 273 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
mridup 0:309c845d289d 274