nrf52dk: cpu/nrf52832 support

This commit is contained in:
Wojciech Bober 2016-01-09 14:44:18 +01:00
parent 0671640ea2
commit 20f9515ed1
20 changed files with 1918 additions and 0 deletions

238
cpu/nrf52832/ble/ble-core.c Normal file
View file

@ -0,0 +1,238 @@
/*
* Copyright (c) 2015, Nordic Semiconductor
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/**
* \addtogroup cpu
* @{
*
* \addtogroup nrf52832
* @{
*
* \addtogroup nrf52832-ble Bluetooth Low Energy drivers
* @{
*
* \file
* Basic BLE functions.
* \author
* Wojciech Bober <wojciech.bober@nordicsemi.no>
*
*/
#include <stdbool.h>
#include <stdint.h>
#include "boards.h"
#include "nordic_common.h"
#include "nrf_delay.h"
#include "nrf_sdm.h"
#include "ble_advdata.h"
#include "ble_srv_common.h"
#include "ble_ipsp.h"
#include "softdevice_handler.h"
#include "app_error.h"
#include "iot_defines.h"
#include "ble-core.h"
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
#define IS_SRVC_CHANGED_CHARACT_PRESENT 1
#define APP_ADV_TIMEOUT 0 /**< Time for which the device must be advertising in non-connectable mode (in seconds). 0 disables timeout. */
#define APP_ADV_ADV_INTERVAL MSEC_TO_UNITS(333, UNIT_0_625_MS) /**< The advertising interval. This value can vary between 100ms to 10.24s). */
static ble_gap_adv_params_t m_adv_params; /**< Parameters to be passed to the stack when starting advertising. */
static void
ble_evt_dispatch(ble_evt_t * p_ble_evt);
/*---------------------------------------------------------------------------*/
/**
* \brief Initialize and enable the BLE stack.
*/
void
ble_stack_init(void)
{
uint32_t err_code;
// Enable BLE stack.
ble_enable_params_t ble_enable_params;
memset(&ble_enable_params, 0, sizeof(ble_enable_params));
ble_enable_params.gatts_enable_params.attr_tab_size =
BLE_GATTS_ATTR_TAB_SIZE_DEFAULT;
ble_enable_params.gatts_enable_params.service_changed =
IS_SRVC_CHANGED_CHARACT_PRESENT;
err_code = sd_ble_enable(&ble_enable_params);
APP_ERROR_CHECK(err_code);
// Register with the SoftDevice handler module for BLE events.
err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
APP_ERROR_CHECK(err_code);
// Setup address
ble_gap_addr_t ble_addr;
err_code = sd_ble_gap_address_get(&ble_addr);
APP_ERROR_CHECK(err_code);
ble_addr.addr[5] = 0x00;
ble_addr.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;
err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &ble_addr);
APP_ERROR_CHECK(err_code);
}
/*---------------------------------------------------------------------------*/
/**
* \brief Return device EUI64 MAC address
* \param addr pointer to a buffer to store the address
*/
void
ble_get_mac(uint8_t addr[8])
{
uint32_t err_code;
ble_gap_addr_t ble_addr;
err_code = sd_ble_gap_address_get(&ble_addr);
APP_ERROR_CHECK(err_code);
IPV6_EUI64_CREATE_FROM_EUI48(addr, ble_addr.addr, ble_addr.addr_type);
}
/*---------------------------------------------------------------------------*/
/**
* \brief Initialize BLE advertising data.
* \param name Human readable device name that will be advertised
*/
void
ble_advertising_init(const char *name)
{
uint32_t err_code;
ble_advdata_t advdata;
uint8_t flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *)name,
strlen(name));
APP_ERROR_CHECK(err_code);
ble_uuid_t adv_uuids[] = {{BLE_UUID_IPSP_SERVICE, BLE_UUID_TYPE_BLE}};
// Build and set advertising data.
memset(&advdata, 0, sizeof(advdata));
advdata.name_type = BLE_ADVDATA_FULL_NAME;
advdata.flags = flags;
advdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
advdata.uuids_complete.p_uuids = adv_uuids;
err_code = ble_advdata_set(&advdata, NULL);
APP_ERROR_CHECK(err_code);
// Initialize advertising parameters (used when starting advertising).
memset(&m_adv_params, 0, sizeof(m_adv_params));
m_adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND;
m_adv_params.p_peer_addr = NULL; // Undirected advertisement.
m_adv_params.fp = BLE_GAP_ADV_FP_ANY;
m_adv_params.interval = APP_ADV_ADV_INTERVAL;
m_adv_params.timeout = APP_ADV_TIMEOUT;
}
/*---------------------------------------------------------------------------*/
/**
* \brief Start BLE advertising.
*/
void
ble_advertising_start(void)
{
uint32_t err_code;
err_code = sd_ble_gap_adv_start(&m_adv_params);
APP_ERROR_CHECK(err_code);
PRINTF("ble-core: advertising started\n");
}
/*---------------------------------------------------------------------------*/
/**
* \brief Print GAP address.
* \param addr a pointer to address
*/
void
ble_gap_addr_print(const ble_gap_addr_t *addr)
{
unsigned int i;
for(i = 0; i < sizeof(addr->addr); i++) {
if(i > 0) {
PRINTF(":");
}PRINTF("%02x", addr->addr[i]);
}PRINTF(" (%d)", addr->addr_type);
}
/*---------------------------------------------------------------------------*/
/**
* \brief Function for handling the Application's BLE Stack events.
* \param[in] p_ble_evt Bluetooth stack event.
*/
static void
on_ble_evt(ble_evt_t *p_ble_evt)
{
switch(p_ble_evt->header.evt_id) {
case BLE_GAP_EVT_CONNECTED:
PRINTF("ble-core: connected [handle:%d, peer: ", p_ble_evt->evt.gap_evt.conn_handle);
ble_gap_addr_print(&(p_ble_evt->evt.gap_evt.params.connected.peer_addr));
PRINTF("]\n");
sd_ble_gap_rssi_start(p_ble_evt->evt.gap_evt.conn_handle,
BLE_GAP_RSSI_THRESHOLD_INVALID,
0);
break;
case BLE_GAP_EVT_DISCONNECTED:
PRINTF("ble-core: disconnected [handle:%d]\n", p_ble_evt->evt.gap_evt.conn_handle);
ble_advertising_start();
break;
default:
break;
}
}
/*---------------------------------------------------------------------------*/
/**
* \brief SoftDevice BLE event callback.
* \param[in] p_ble_evt Bluetooth stack event.
*/
static void
ble_evt_dispatch(ble_evt_t *p_ble_evt)
{
ble_ipsp_evt_handler(p_ble_evt);
on_ble_evt(p_ble_evt);
}
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
* @}
*/

View file

@ -0,0 +1,61 @@
/*
* Copyright (c) 2015, Nordic Semiconductor
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/**
* \addtogroup cpu
* @{
*
* \addtogroup nrf52832
* @{
*
* \addtogroup nrf52832-ble Bluetooth Low Energy drivers
* @{
*
* \file
* Basic BLE functions.
* \author
* Wojciech Bober <wojciech.bober@nordicsemi.no>
*/
#ifndef DEV_BLE_H_
#define DEV_BLE_H_
#include <stdint.h>
void ble_stack_init(void);
void ble_advertising_init(const char *name);
void ble_advertising_start(void);
void ble_get_mac(uint8_t addr[8]);
#endif /* DEV_BLE_H_ */
/**
* @}
* @}
* @}
*/

386
cpu/nrf52832/ble/ble-mac.c Normal file
View file

@ -0,0 +1,386 @@
/*
* Copyright (c) 2015, Nordic Semiconductor
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/**
* \addtogroup nrf52832-ble
* @{
*
* \file
* A MAC protocol implementation that uses nRF52 IPSP implementation
* as a link layer.
* \author
* Wojciech Bober <wojciech.bober@nordicsemi.no>
*/
#include <stdint.h>
#include <ble-core.h>
#include "app_error.h"
#include "ble_ipsp.h"
#include "nrf_soc.h"
#include "iot_defines.h"
#include "net/mac/nullmac.h"
#include "net/netstack.h"
#include "net/ip/uip.h"
#include "net/ip/tcpip.h"
#include "net/packetbuf.h"
#include "net/netstack.h"
#include "net/linkaddr.h"
#include "dev/watchdog.h"
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
#ifndef BLE_MAC_MAX_INTERFACE_NUM
#define BLE_MAC_MAX_INTERFACE_NUM 1 /**< Maximum number of interfaces, i.e., connection to master devices */
#endif
/*---------------------------------------------------------------------------*/
process_event_t ble_event_interface_added; /**< This event is broadcast when BLE connection is established */
process_event_t ble_event_interface_deleted; /**< This event is broadcast when BLE connection is destroyed */
/*---------------------------------------------------------------------------*/
PROCESS(ble_ipsp_process, "BLE IPSP process");
/*---------------------------------------------------------------------------*/
/**
* \brief A structure that binds IPSP connection with a peer address.
*/
typedef struct {
eui64_t peer_addr;
ble_ipsp_handle_t handle;
} ble_mac_interface_t;
static ble_mac_interface_t interfaces[BLE_MAC_MAX_INTERFACE_NUM];
static volatile int busy_tx; /**< Flag is set to 1 when the driver is busy transmitting a packet. */
static volatile int busy_rx; /**< Flag is set to 1 when there is a received packet pending. */
struct {
eui64_t src;
uint8_t payload[PACKETBUF_SIZE];
uint16_t len;
int8_t rssi;
} input_packet;
static mac_callback_t mac_sent_cb;
static void *mac_sent_ptr;
/*---------------------------------------------------------------------------*/
/**
* \brief Lookup interface by IPSP connection.
*
* \param handle a pointer to IPSP handle.
* \retval a pointer to interface structure
* \retval NULL if no interface has been found for a given handle
*/
static ble_mac_interface_t *
ble_mac_interface_lookup(ble_ipsp_handle_t *handle)
{
int i;
for(i = 0; i < BLE_MAC_MAX_INTERFACE_NUM; i++) {
if(interfaces[i].handle.conn_handle == handle->conn_handle &&
interfaces[i].handle.cid == handle->cid) {
return &interfaces[i];
}
}
return NULL;
}
/*---------------------------------------------------------------------------*/
/**
* \brief Add IPSP connection to the interface table.
*
* This function binds IPSP connection with peer address.
*
* \param peer a pointer to eui64 address
* \param handle a pointer to IPSP handle
*
* \retval a pointer to an interface structure on success
* \retval NULL if interface table is full
*/
static ble_mac_interface_t *
ble_mac_interface_add(eui64_t *peer, ble_ipsp_handle_t *handle)
{
int i;
for(i = 0; i < BLE_MAC_MAX_INTERFACE_NUM; i++) {
if(interfaces[i].handle.conn_handle == 0 && interfaces[i].handle.cid == 0) {
memcpy(&interfaces[i].handle, handle, sizeof(ble_ipsp_handle_t));
memcpy(&interfaces[i].peer_addr, peer, sizeof(eui64_t));
process_post(PROCESS_BROADCAST, ble_event_interface_added, NULL);
return &interfaces[i];
}
}
return NULL;
}
/*---------------------------------------------------------------------------*/
/**
* \brief Remove interface from the interface table.
* \param interface a pointer to interface
*/
static void
ble_mac_interface_delete(ble_mac_interface_t *interface)
{
memset(interface, 0, sizeof(ble_mac_interface_t));
process_post(PROCESS_BROADCAST, ble_event_interface_deleted, NULL);
}
/*---------------------------------------------------------------------------*/
/**
* \brief Callback registered with IPSP to receive asynchronous events from the module.
* \note This function is called from SoftDevice interrupt context.
*
* \param[in] p_handle Pointer to IPSP handle.
* \param[in] p_evt Pointer to specific event, generated by IPSP module.
*
* \return NRF_SUCCESS on success, otherwise NRF_ERROR_NO_MEM error.
*/
static uint32_t
ble_mac_ipsp_evt_handler_irq(ble_ipsp_handle_t *p_handle, ble_ipsp_evt_t *p_evt)
{
uint32_t retval = NRF_SUCCESS;
ble_mac_interface_t *p_instance = NULL;
p_instance = ble_mac_interface_lookup(p_handle);
if(p_handle) {
PRINTF("ble-mac: IPSP event [handle:%d CID 0x%04X]\n", p_handle->conn_handle, p_handle->cid);
}
switch(p_evt->evt_id) {
case BLE_IPSP_EVT_CHANNEL_CONNECTED: {
eui64_t peer_addr;
PRINTF("ble-mac: channel connected\n");
IPV6_EUI64_CREATE_FROM_EUI48(
peer_addr.identifier,
p_evt->evt_param->params.ch_conn_request.peer_addr.addr,
p_evt->evt_param->params.ch_conn_request.peer_addr.addr_type);
p_instance = ble_mac_interface_add(&peer_addr, p_handle);
if(p_instance != NULL) {
PRINTF("ble-mac: added new IPSP interface\n");
} else {
PRINTF("ble-mac: cannot add new interface. Table is full\n");
ble_ipsp_disconnect(p_handle);
}
break;
}
case BLE_IPSP_EVT_CHANNEL_DISCONNECTED: {
PRINTF("ble-mac: channel disconnected\n");
if(p_instance != NULL) {
PRINTF("ble-mac: removed IPSP interface\n");
ble_mac_interface_delete(p_instance);
}
break;
}
case BLE_IPSP_EVT_CHANNEL_DATA_RX: {
PRINTF("ble-mac: data received\n");
if(p_instance != NULL) {
if(busy_rx) {
PRINTF("ble-mac: packet dropped as input buffer is busy\n");
break;
}
if(p_evt->evt_param->params.ch_rx.len > PACKETBUF_SIZE) {
PRINTF("ble-mac: packet buffer is too small!\n");
break;
}
busy_rx = 1;
input_packet.len = p_evt->evt_param->params.ch_rx.len;
memcpy(input_packet.payload, p_evt->evt_param->params.ch_rx.p_data, input_packet.len);
memcpy(input_packet.src.identifier, p_instance->peer_addr.identifier, sizeof(eui64_t));
sd_ble_gap_rssi_get(p_handle->conn_handle, &input_packet.rssi);
process_poll(&ble_ipsp_process);
} else {
PRINTF("ble-mac: got data to unknown interface!\n");
}
break;
}
case BLE_IPSP_EVT_CHANNEL_DATA_TX_COMPLETE: {
PRINTF("ble-mac: data transmitted\n");
busy_tx = 0;
break;
}
}
return retval;
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(ble_ipsp_process, ev, data)
{
PROCESS_BEGIN();
while(1) {
PROCESS_WAIT_EVENT();
if(ev == PROCESS_EVENT_POLL) {
packetbuf_copyfrom(input_packet.payload, input_packet.len);
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, input_packet.rssi);
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, (const linkaddr_t *)input_packet.src.identifier);
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &linkaddr_node_addr);
busy_rx = 0;
NETSTACK_LLSEC.input();
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
/**
* \brief Lookup IPSP handle by peer address.
*
* \param addr a pointer to eui64 address.
* \retval a pointer to IPSP handle on success
* \retval NULL if an IPSP handle for given address haven't been found
*/
static ble_ipsp_handle_t *
find_handle(const linkaddr_t *addr)
{
int i;
for(i = 0; i < BLE_MAC_MAX_INTERFACE_NUM; i++) {
if(linkaddr_cmp((const linkaddr_t *)&interfaces[i].peer_addr, addr)) {
return &interfaces[i].handle;
}
}
return NULL;
}
/*---------------------------------------------------------------------------*/
/**
* \brief Send packet on a given IPSP handle.
*
* \param handle a pointer to IPSP handle.
* \return 1 on success, 0 otherwise
*/
static int
send_to_peer(ble_ipsp_handle_t *handle)
{
PRINTF("ble-mac: sending packet[GAP handle:%d CID:0x%04X]\n", handle->conn_handle, handle->cid);
return (ble_ipsp_send(handle, packetbuf_dataptr(), packetbuf_datalen()) == NRF_SUCCESS);
}
/*---------------------------------------------------------------------------*/
static void
send_packet(mac_callback_t sent, void *ptr)
{
int i;
const linkaddr_t *dest;
ble_ipsp_handle_t *handle;
int ret = 0;
mac_sent_cb = sent;
mac_sent_ptr = ptr;
dest = packetbuf_addr(PACKETBUF_ADDR_RECEIVER);
if(linkaddr_cmp(dest, &linkaddr_null)) {
for(i = 0; i < BLE_MAC_MAX_INTERFACE_NUM; i++) {
if(interfaces[i].handle.cid != 0 && interfaces[i].handle.conn_handle != 0) {
ret = send_to_peer(&interfaces[i].handle);
watchdog_periodic();
}
}
} else if((handle = find_handle(dest)) != NULL) {
ret = send_to_peer(handle);
} else {
PRINTF("ble-mac: no connection found for peer");
}
if(ret) {
busy_tx = 1;
while(busy_tx) {
watchdog_periodic();
sd_app_evt_wait();
}
mac_call_sent_callback(sent, ptr, MAC_TX_OK, 1);
} else {
mac_call_sent_callback(sent, ptr, MAC_TX_ERR, 1);
}
}
/*---------------------------------------------------------------------------*/
static int
on(void)
{
return 1;
}
/*---------------------------------------------------------------------------*/
static int
off(int keep_radio_on)
{
return 1;
}
/*---------------------------------------------------------------------------*/
static unsigned short
channel_check_interval(void)
{
return 0;
}
/*---------------------------------------------------------------------------*/
static void
init(void)
{
// Initialize IPSP service
uint32_t err_code;
ble_ipsp_init_t ipsp_init_params;
memset(&ipsp_init_params, 0, sizeof(ipsp_init_params));
ipsp_init_params.evt_handler = ble_mac_ipsp_evt_handler_irq;
err_code = ble_ipsp_init(&ipsp_init_params);
APP_ERROR_CHECK(err_code);
ble_event_interface_added = process_alloc_event();
ble_event_interface_deleted = process_alloc_event();
process_start(&ble_ipsp_process, NULL);
}
/*---------------------------------------------------------------------------*/
const struct mac_driver ble_ipsp_mac_driver = {
"nRF52 IPSP driver",
init,
send_packet,
NULL,
on,
off,
channel_check_interval,
};
/*---------------------------------------------------------------------------*/
/**
* @}
*/

View file

@ -0,0 +1,53 @@
/*
* Copyright (c) 2015, Nordic Semiconductor
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/**
* \addtogroup nrf52832-ble
* @{
*
* \file
* A MAC protocol implementation that uses nRF52 IPSP implementation
* as a link layer.
* \author
* Wojciech Bober <wojciech.bober@nordicsemi.no>
*/
#ifndef BLE_MAC_H_
#define BLE_MAC_H_
#include "sys/process.h"
#include "net/mac/mac.h"
extern const struct mac_driver ble_ipsp_mac_driver; /**< BLE over IPSP MAC driver structure */
extern process_event_t ble_event_interface_added; /**< This event is broadcast when a new IPSP connection is established */
extern process_event_t ble_event_interface_deleted; /**< This event is broadcast when a IPSP connection is deleted */
#endif /* BLE_MAC_H_ */
/**
* @}
*/