| BlueNRG-1 DK: BLE examples

- Main Page
- Modules
- Files

- File List

main.c
Go to the documentation of this file.
1
2 /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
3 * File Name : main.c
4 * Author : VMA DIVISION
5 * Version : 1.0.0
6 * Date : 05-October-2015
7 * Description : Code demostrating the HID/HOGP Bluetooth Low Energy application 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
200 /* Includes ------------------------------------------------------------------*/
201 #include <stdio.h>
202 #ifdef __ICCARM__
203 #include <yfuns.h>
204 #endif
205 #include <string.h>
206 #include "hw_config.h"
207 #include "BlueNRG1_it.h"
208 #include "BlueNRG1_conf.h"
209 #include "sleep.h"
210 #include "ble_const.h"
211 #include "bluenrg1_stack.h"
212 #include "SDK_EVAL_Com.h"
213 #include "hid_stack_config.h"
214 #include "clock.h"
215
216 /* Include the correct HID device header file */
217 #ifdef HID_KEYBOARD
218 #include "keyboard.h"
219 #else
220 #include "mouse.h"
221 #endif
222
223 //#define DEBUG 1
224 #ifdef DEBUG
225 #include <stdio.h>
226 #define PRINTF(...) printf(__VA_ARGS__)
227 #else
228 #define PRINTF(...)
229 #endif
230
231 /* Private typedef -----------------------------------------------------------*/
232 /* Private define ------------------------------------------------------------*/
233 /* Private macro -------------------------------------------------------------*/
234 /* Private variables ---------------------------------------------------------*/
235 int main(void)
236 {
237 uint8_t ret;
238
239 /* System Init */
240 SystemInit();
241
242 /* Identify BlueNRG1 platform */
243 SdkEvalIdentification();
244
245 /* Application demo Led Init
246 LED1 = Sensor configuration led
247 LED3 = Connection led
248 */
249 SdkEvalLedInit(LED1);
250 SdkEvalLedInit(LED3);
251 SdkEvalLedOn(LED1);
252 SdkEvalLedOff(LED3);
253
254 /* Serial Init 115200-8-N-1*/
255 SerialInit();
256
257 /* Clock Init */
258 Clock_Init();
259
260 /* BlueNRG-1 stack init */
261 ret = BlueNRG_Stack_Initialization(&BlueNRG_Stack_Init_params);
262 if (ret != BLE_STATUS_SUCCESS) {
263 PRINTF("Error in BlueNRG_Stack_Initialization() 0x%02x\r\n", ret);
264 while(1);
265 }
266
267 /* Configure HID Peripheral and put the device in discoverable mode */
268 ret = Configure_HidPeripheral();
269 if (ret != BLE_STATUS_SUCCESS) {
270 PRINTF("Error in configure_hid_peripheral() 0x%02x\n", ret);
271 }
272
273 while(1) {
274 /* BLE Tick */
275 BTLE_StackTick();
276
277 /* Application Tick */
278 APP_Tick();
279
280 /* Device Power Save Management Procedures */
281 DevicePowerSaveProcedure();
282 }
283 }
284
285 #ifdef USE_FULL_ASSERT
286
293 void assert_failed(uint8_t* file, uint32_t line)
294 {
295 /* User can add his own implementation to report the file name and line number,
296 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
297
298 /* Infinite loop */
299 while (1)
300 {
301 }
302 }
303
304 #endif