-
Notifications
You must be signed in to change notification settings - Fork 1
/
gecko_main.c
119 lines (102 loc) · 4.48 KB
/
gecko_main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/***************************************************************************//**
* @file
* @brief Silicon Labs Empty Example Project
*
* This example demonstrates the bare minimum needed for a Blue Gecko C application
* that allows Over-the-Air Device Firmware Upgrading (OTA DFU). The application
* starts advertising after boot and restarts advertising after a connection is closed.
*******************************************************************************
* # License
* <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/
/* Board headers */
#include "init_mcu.h"
#include "init_board.h"
#include "init_app.h"
#include "ble-configuration.h"
#include "board_features.h"
/* Bluetooth stack headers */
#include "bg_types.h"
#include "native_gecko.h"
#include "gatt_db.h"
/* Libraries containing default Gecko configuration values */
#include "em_emu.h"
#include "em_cmu.h"
/* Device initialization header */
#include "hal-config.h"
#if defined(HAL_CONFIG)
#include "bsphalconfig.h"
#else
#include "bspconfig.h"
#endif
// Added by Sluiter Sept, 7, 2020 to eliminate a linker warning about the
// implicit definition of appMain() function
#include "src/main.h"
/* Application header */
/***********************************************************************************************//**
* @addtogroup Application
* @{
**************************************************************************************************/
/***********************************************************************************************//**
* @addtogroup app
* @{
**************************************************************************************************/
#ifndef MAX_ADVERTISERS
#define MAX_ADVERTISERS 1
#endif
#ifndef MAX_CONNECTIONS
#define MAX_CONNECTIONS 4
#endif
uint8_t bluetooth_stack_heap[DEFAULT_BLUETOOTH_HEAP(MAX_CONNECTIONS)];
/* Bluetooth stack configuration parameters (see "UG136: Silicon Labs Bluetooth C Application Developer's Guide" for details on each parameter) */
static gecko_configuration_t config = {
.config_flags = 0, /* Check flag options from UG136 */
#if defined(FEATURE_LFXO)
.sleep.flags = SLEEP_FLAGS_DEEP_SLEEP_ENABLE, /* Sleep is enabled */
#else
.sleep.flags = 0,
#endif // LFXO
.bluetooth.max_connections = MAX_CONNECTIONS, /* Maximum number of simultaneous connections */
.bluetooth.max_advertisers = MAX_ADVERTISERS, /* Maximum number of advertisement sets */
.bluetooth.heap = bluetooth_stack_heap, /* Bluetooth stack memory for connection management */
.bluetooth.heap_size = sizeof(bluetooth_stack_heap), /* Bluetooth stack memory for connection management */
.bluetooth.sleep_clock_accuracy = 100, /* Accuracy of the Low Frequency Crystal Oscillator in ppm. *
* Do not modify if you are using a module */
.gattdb = &bg_gattdb_data, /* Pointer to GATT database */
.ota.flags = 0, /* Check flag options from UG136 */
.ota.device_name_len = 3, /* Length of the device name in OTA DFU mode */
.ota.device_name_ptr = "OTA", /* Device name in OTA DFU mode */
#if (HAL_PA_ENABLE)
.pa.config_enable = 1, /* Set this to be a valid PA config */
#if defined(FEATURE_PA_INPUT_FROM_VBAT)
.pa.input = GECKO_RADIO_PA_INPUT_VBAT, /* Configure PA input to VBAT */
#else
.pa.input = GECKO_RADIO_PA_INPUT_DCDC, /* Configure PA input to DCDC */
#endif // defined(FEATURE_PA_INPUT_FROM_VBAT)
#endif // (HAL_PA_ENABLE)
};
/**
* @brief Main function
*/
int main(void)
{
/* Initialize device */
initMcu();
/* Initialize board */
initBoard();
/* Initialize application */
initApp();
/* Start application */
appMain(&config);
}
/** @} (end addtogroup app) */
/** @} (end addtogroup Application) */