Nordic Semiconductor nRF5 AirFuel SDK  version 2.2.0
main.c File Reference
#include <stdint.h>
#include "boards.h"
#include "debug.h"
#include "pru.h"
#include "softdevice_handler.h"
#include "pru_config.h"
#include "app_util_platform.h"
#include "wireless_debug.h"
#include "nrf_nvic.h"
#include "common_hal_buttons.h"

Go to the source code of this file.

Macros

#define CENTRAL_LINK_COUNT   0
 
#define PERIPHERAL_LINK_COUNT   1
 
#define DEAD_BEEF   0xDEADBEEF
 

Functions

static void m_ble_evt_dispatch (ble_evt_t *p_ble_evt)
 Dispatches a BLE stack event to all profiles. More...
 
static void m_ble_stack_init (void)
 BLE stack initialization. More...
 
int main ()
 Application main function. More...
 

Function Documentation

static void m_ble_evt_dispatch ( ble_evt_t *  p_ble_evt)
static

Dispatches a BLE stack event to all profiles.

This function is called from the BLE Stack event interrupt handler after a BLE stack event has been received.

Parameters
[in]p_ble_evtBluetooth stack event.

Definition at line 47 of file main.c.

48 {
49  pru_on_ble_evt(p_ble_evt);
50 }
void pru_on_ble_evt(ble_evt_t *p_ble_evt)
Handle BLE event.
Definition: pru.c:510
static void m_ble_stack_init ( void  )
static

BLE stack initialization.

Initializes the SoftDevice and the BLE event interrupt.

Definition at line 56 of file main.c.

57 {
58  uint32_t err_code;
59  ble_conn_bw_counts_t count = {{1,0,0},{1,0,0}};
60 
61  // Initialize the SoftDevice handler module.
62  nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
63  SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
64 
65  // Enable BLE stack.
66  ble_enable_params_t ble_enable_params = {0};
67  ble_enable_params.gap_enable_params.periph_conn_count = PERIPHERAL_LINK_COUNT;
68  ble_enable_params.common_enable_params.p_conn_bw_counts = &count;
69 
70  ble_opt_t opt;
71  opt.common_opt.conn_bw.conn_bw.conn_bw_rx = BLE_CONN_BW_HIGH;
72  opt.common_opt.conn_bw.conn_bw.conn_bw_tx = BLE_CONN_BW_HIGH;
73  opt.common_opt.conn_bw.role = BLE_GAP_ROLE_PERIPH;
74 
75  //Check the ram settings against the used number of links
76  CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT);
77 
78  err_code = softdevice_enable(&ble_enable_params);
79  APP_ERROR_CHECK(err_code);
80 
81  err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_BW, &opt);
82  APP_ERROR_CHECK(err_code);
83 
84  err_code = softdevice_ble_evt_handler_set(m_ble_evt_dispatch);
85  APP_ERROR_CHECK(err_code);
86 
87  // It is important that this is set to the same priority as the
88  // timers in the system.
89  err_code = sd_nvic_SetPriority(SD_EVT_IRQn, APP_IRQ_PRIORITY_LOW);
90  APP_ERROR_CHECK(err_code);
91 }
static void m_ble_evt_dispatch(ble_evt_t *p_ble_evt)
Dispatches a BLE stack event to all profiles.
Definition: main.c:47
#define CENTRAL_LINK_COUNT
Definition: main.c:34
#define PERIPHERAL_LINK_COUNT
Definition: main.c:35