| BlueNRG-1 DK: BLE examples

- Main Page
- Modules
- Files

- File List

BLE_RC_main.c
Go to the documentation of this file.
1
2 /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
3 * File Name : BLE_RC_main.c
4 * Author : VMA DIVISION
5 * Version : 1.0.0
6 * Date : 25-September-2015
7 * Description : Code demostrating a simple remote control application
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
195 /* Includes ------------------------------------------------------------------*/
196 #include <stdio.h>
197 #include <string.h>
198 #include <stdlib.h>
199 #include "BlueNRG1_it.h"
200 #include "BlueNRG1_conf.h"
201 #include "ble_const.h"
202 #include "bluenrg1_stack.h"
203 #include "SDK_EVAL_Config.h"
204 #include "rc.h"
205 #include "sleep.h"
206 #include "RemoteControl_config.h"
207
208 /* External variables --------------------------------------------------------*/
209 /* Private typedef -----------------------------------------------------------*/
210 /* Private defines -----------------------------------------------------------*/
214 #ifndef DEBUG
215 #define DEBUG 1
216 #endif
217
218 /* Private macros ------------------------------------------------------------*/
219 #if DEBUG
220 #include <stdio.h>
221 #define PRINTF(...) printf(__VA_ARGS__)
222 #else
223 #define PRINTF(...)
224 #endif
225
226 #define BLE_RC_VERSION_STRING "1.0.0"
227
228 /* Private variables ---------------------------------------------------------*/
229 /* Private function prototypes -----------------------------------------------*/
230 /* Private functions ---------------------------------------------------------*/
231
232 /*******************************************************************************
233 * Function Name : main.
234 * Description : Main routine.
235 * Input : None.
236 * Output : None.
237 * Return : None.
238 *******************************************************************************/
239 int main(void)
240 {
241 uint8_t ret;
242
243 SystemInit();
244
245 /* Identify BlueNRG1 platform */
246 SdkEvalIdentification();
247
248 /* Configure I/O communication channel */
249 SdkEvalComUartInit(UART_BAUDRATE);
250
251 /* BlueNRG-1 stack init */
252 ret = BlueNRG_Stack_Initialization(&BlueNRG_Stack_Init_params);
253 if (ret != BLE_STATUS_SUCCESS) {
254 PRINTF("Error in BlueNRG_Stack_Initialization() 0x%02x\r\n", ret);
255 while(1);
256 }
257
258 /* Configure application LED */
259 SdkEvalLedInit(LED1);
260 SdkEvalLedInit(LED3);
261 SdkEvalLedOff(LED1);
262 SdkEvalLedOff(LED3);
263
264 ret = RC_DeviceInit();
265 if (ret != BLE_STATUS_SUCCESS) {
266 PRINTF("RC_DeviceInit() failed: 0x%02x\r\n", ret);
267 while(1);
268 }
269
270 PRINTF("BlueNRG-1 BLE Remote Control Application (version: %s)\r\n", BLE_RC_VERSION_STRING);
271
272 while(1) {
273 /* BLE Stack Tick */
274 BTLE_StackTick();
275
276 /* Application Tick */
277 APP_Tick();
278
279 /* Power Save management */
280 BlueNRG_Sleep(SLEEPMODE_WAKETIMER, 0, 0, 0);
281 }
282 }
283
284 #ifdef USE_FULL_ASSERT
285 /*******************************************************************************
286 * Function Name : assert_failed
287 * Description : Reports the name of the source file and the source line number
288 * where the assert_param error has occurred.
289 * Input : - file: pointer to the source file name
290 * - line: assert_param error line source number
291 * Output : None
292 * Return : None
293 *******************************************************************************/
294 void assert_failed(uint8_t* file, uint32_t line)
295 {
296 /* User can add his own implementation to report the file name and line number,
297 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
298
299 /* Infinite loop */
300 while (1)
301 {}
302 }
303 #endif
304
305 /******************* (C) COPYRIGHT 2014 STMicroelectronics *****END OF FILE****/