| BlueNRG-1 DK: BLE examples

- Main Page
- Modules
- Files

- File List

BLE_ANCS_main.c
Go to the documentation of this file.
1
2 /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
3 * File Name : BLE_ANCS_main.c
4 * Author : VMA DIVISION
5 * Version : 1.0.0
6 * Date : 16-Jane-2016
7 * Description : Code demostrating the BLE ANCS profile
8 ********************************************************************************
9 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
10 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
11 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
12 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
13 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
14 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
15 *******************************************************************************/
16
170 /* Includes ------------------------------------------------------------------*/
171 #include <stdio.h>
172 #ifdef __ICCARM__
173 #include <yfuns.h>
174 #endif
175 #include <string.h>
176 #include "BlueNRG1_it.h"
177 #include "BlueNRG1_conf.h"
178 #include "sleep.h"
179 #include "ble_const.h"
180 #include "bluenrg1_stack.h"
181 #include "SDK_EVAL_Config.h"
182 #include "clock.h"
183 #include "ancs_stack_config.h"
184 #include "demo_application.h"
185
186 /* Private typedef -----------------------------------------------------------*/
187 /* Private define ------------------------------------------------------------*/
188 /* Private macro -------------------------------------------------------------*/
189 /* Private variables ---------------------------------------------------------*/
190 int main(void)
191 {
192 uint8_t ret;
193
194 /* System Init */
195 SystemInit();
196
197 /* Identify BlueNRG1 platform */
198 SdkEvalIdentification();
199
200 /* Application demo Led Init
201 LED1 = Sensor configuration led
202 LED3 = Connection led
203 */
204 SdkEvalLedInit(LED1);
205 SdkEvalLedInit(LED3);
206 SdkEvalLedOn(LED1);
207 SdkEvalLedOff(LED3);
208
209 /* Configure I/O communication channel */
210 SdkEvalComIOConfig(SdkEvalComIOProcessInputData);
211
212 /* SysTick Init */
213 Clock_Init();
214
215 /* BlueNRG-1 stack init */
216 ret = BlueNRG_Stack_Initialization(&BlueNRG_Stack_Init_params);
217 if (ret != BLE_STATUS_SUCCESS) {
218 printf("Error in BlueNRG_Stack_Initialization() 0x%02x\r\n", ret);
219 while(1);
220 }
221
222 /* Application Init */
223 ret = application_init();
224 if (ret != BLE_STATUS_SUCCESS) {
225 printf("Error in application_init() 0x%02x\n", ret);
226 }
227
228 /* Start Advertising */
229 ret = application_ADV_Start();
230 if (ret != BLE_STATUS_SUCCESS) {
231 printf("Error in application_ADV_Start() 0x%02x\n", ret);
232 }
233
234 while(1) {
235 /* BLE Tick */
236 BTLE_StackTick();
237
238 /* Application Tick */
239 APP_Tick();
240
241 /* Device Power Save Management Procedures */
242 BlueNRG_Sleep(SLEEPMODE_NOTIMER, 0, 0, 0);
243 }
244 }
245
246 #ifdef USE_FULL_ASSERT
247
254 void assert_failed(uint8_t* file, uint32_t line)
255 {
256 /* User can add his own implementation to report the file name and line number,
257 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
258
259 /* Infinite loop */
260 while (1)
261 {
262 }
263 }
264
265 #endif