To get started with Seeed Tiny BLE, include detecting motion, button and battery level.

Dependencies:   BLE_API eMPL_MPU6050 mbed nRF51822

Committer:
yihui
Date:
Wed Apr 22 07:47:17 2015 +0000
Revision:
1:fc2f9d636751
update libraries; ; delete nRF51822/nordic-sdk/components/gpiote/app_gpiote.c to solve GPIOTE_IRQHandler multiply defined issue. temperarily change nRF51822 library to folder

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 1:fc2f9d636751 1 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
yihui 1:fc2f9d636751 2 *
yihui 1:fc2f9d636751 3 * The information contained herein is confidential property of Nordic Semiconductor. The use,
yihui 1:fc2f9d636751 4 * copying, transfer or disclosure of such information is prohibited except by express written
yihui 1:fc2f9d636751 5 * agreement with Nordic Semiconductor.
yihui 1:fc2f9d636751 6 *
yihui 1:fc2f9d636751 7 */
yihui 1:fc2f9d636751 8 /**
yihui 1:fc2f9d636751 9 @addtogroup BLE_L2CAP Logical Link Control and Adaptation Protocol (L2CAP)
yihui 1:fc2f9d636751 10 @{
yihui 1:fc2f9d636751 11 @brief Definitions and prototypes for the L2CAP interface.
yihui 1:fc2f9d636751 12 */
yihui 1:fc2f9d636751 13
yihui 1:fc2f9d636751 14 #ifndef BLE_L2CAP_H__
yihui 1:fc2f9d636751 15 #define BLE_L2CAP_H__
yihui 1:fc2f9d636751 16
yihui 1:fc2f9d636751 17 #include "ble_types.h"
yihui 1:fc2f9d636751 18 #include "ble_ranges.h"
yihui 1:fc2f9d636751 19 #include "ble_err.h"
yihui 1:fc2f9d636751 20 #include "nrf_svc.h"
yihui 1:fc2f9d636751 21
yihui 1:fc2f9d636751 22 /**@addtogroup BLE_L2CAP_ENUMERATIONS Enumerations
yihui 1:fc2f9d636751 23 * @{ */
yihui 1:fc2f9d636751 24
yihui 1:fc2f9d636751 25 /**@brief L2CAP API SVC numbers. */
yihui 1:fc2f9d636751 26 enum BLE_L2CAP_SVCS
yihui 1:fc2f9d636751 27 {
yihui 1:fc2f9d636751 28 SD_BLE_L2CAP_CID_REGISTER = BLE_L2CAP_SVC_BASE, /**< Register a CID. */
yihui 1:fc2f9d636751 29 SD_BLE_L2CAP_CID_UNREGISTER, /**< Unregister a CID. */
yihui 1:fc2f9d636751 30 SD_BLE_L2CAP_TX /**< Transmit a packet. */
yihui 1:fc2f9d636751 31 };
yihui 1:fc2f9d636751 32
yihui 1:fc2f9d636751 33 /** @} */
yihui 1:fc2f9d636751 34
yihui 1:fc2f9d636751 35 /**@addtogroup BLE_L2CAP_DEFINES Defines
yihui 1:fc2f9d636751 36 * @{ */
yihui 1:fc2f9d636751 37
yihui 1:fc2f9d636751 38 /**@defgroup BLE_ERRORS_L2CAP SVC return values specific to L2CAP
yihui 1:fc2f9d636751 39 * @{ */
yihui 1:fc2f9d636751 40 #define BLE_ERROR_L2CAP_CID_IN_USE (NRF_L2CAP_ERR_BASE + 0x000) /**< CID already in use. */
yihui 1:fc2f9d636751 41 /** @} */
yihui 1:fc2f9d636751 42
yihui 1:fc2f9d636751 43 /**@brief Default L2CAP MTU. */
yihui 1:fc2f9d636751 44 #define BLE_L2CAP_MTU_DEF (23)
yihui 1:fc2f9d636751 45
yihui 1:fc2f9d636751 46 /**@brief Invalid Channel Identifier. */
yihui 1:fc2f9d636751 47 #define BLE_L2CAP_CID_INVALID (0x0000)
yihui 1:fc2f9d636751 48
yihui 1:fc2f9d636751 49 /**@brief Dynamic Channel Identifier base. */
yihui 1:fc2f9d636751 50 #define BLE_L2CAP_CID_DYN_BASE (0x0040)
yihui 1:fc2f9d636751 51
yihui 1:fc2f9d636751 52 /**@brief Maximum amount of dynamic CIDs. */
yihui 1:fc2f9d636751 53 #define BLE_L2CAP_CID_DYN_MAX (8)
yihui 1:fc2f9d636751 54
yihui 1:fc2f9d636751 55 /** @} */
yihui 1:fc2f9d636751 56
yihui 1:fc2f9d636751 57 /**@addtogroup BLE_L2CAP_STRUCTURES Structures
yihui 1:fc2f9d636751 58 * @{ */
yihui 1:fc2f9d636751 59
yihui 1:fc2f9d636751 60 /**@brief Packet header format for L2CAP transmission. */
yihui 1:fc2f9d636751 61 typedef struct
yihui 1:fc2f9d636751 62 {
yihui 1:fc2f9d636751 63 uint16_t len; /**< Length of valid info in data member. */
yihui 1:fc2f9d636751 64 uint16_t cid; /**< Channel ID on which packet is transmitted. */
yihui 1:fc2f9d636751 65 } ble_l2cap_header_t;
yihui 1:fc2f9d636751 66
yihui 1:fc2f9d636751 67 /**@brief L2CAP Event IDs. */
yihui 1:fc2f9d636751 68 enum BLE_L2CAP_EVTS
yihui 1:fc2f9d636751 69 {
yihui 1:fc2f9d636751 70 BLE_L2CAP_EVT_RX = BLE_L2CAP_EVT_BASE /**< L2CAP packet received. */
yihui 1:fc2f9d636751 71 };
yihui 1:fc2f9d636751 72
yihui 1:fc2f9d636751 73
yihui 1:fc2f9d636751 74 /**@brief L2CAP Received packet event report. */
yihui 1:fc2f9d636751 75 typedef struct
yihui 1:fc2f9d636751 76 {
yihui 1:fc2f9d636751 77 ble_l2cap_header_t header; /** L2CAP packet header. */
yihui 1:fc2f9d636751 78 uint8_t data[1]; /**< Packet data, variable length. */
yihui 1:fc2f9d636751 79 } ble_l2cap_evt_rx_t;
yihui 1:fc2f9d636751 80
yihui 1:fc2f9d636751 81
yihui 1:fc2f9d636751 82 /**@brief L2CAP event callback event structure. */
yihui 1:fc2f9d636751 83 typedef struct
yihui 1:fc2f9d636751 84 {
yihui 1:fc2f9d636751 85 uint16_t conn_handle; /**< Connection Handle on which event occured. */
yihui 1:fc2f9d636751 86 union
yihui 1:fc2f9d636751 87 {
yihui 1:fc2f9d636751 88 ble_l2cap_evt_rx_t rx; /**< RX Event parameters. */
yihui 1:fc2f9d636751 89 } params;
yihui 1:fc2f9d636751 90 } ble_l2cap_evt_t;
yihui 1:fc2f9d636751 91
yihui 1:fc2f9d636751 92
yihui 1:fc2f9d636751 93 /**@brief Register a CID with L2CAP.
yihui 1:fc2f9d636751 94 *
yihui 1:fc2f9d636751 95 * @details This registers a higher protocol layer with the L2CAP multiplexer, and is requried prior to all operations on the CID.
yihui 1:fc2f9d636751 96 *
yihui 1:fc2f9d636751 97 * @param[in] cid L2CAP CID.
yihui 1:fc2f9d636751 98 *
yihui 1:fc2f9d636751 99 * @return @ref NRF_SUCCESS Successfully registered a CID with the L2CAP layer.
yihui 1:fc2f9d636751 100 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CID must be above @ref BLE_L2CAP_CID_DYN_BASE.
yihui 1:fc2f9d636751 101 * @return @ref BLE_ERROR_L2CAP_CID_IN_USE L2CAP CID already in use.
yihui 1:fc2f9d636751 102 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
yihui 1:fc2f9d636751 103 */
yihui 1:fc2f9d636751 104 SVCALL(SD_BLE_L2CAP_CID_REGISTER, uint32_t, sd_ble_l2cap_cid_register(uint16_t cid));
yihui 1:fc2f9d636751 105
yihui 1:fc2f9d636751 106 /**@brief Unregister a CID with L2CAP.
yihui 1:fc2f9d636751 107 *
yihui 1:fc2f9d636751 108 * @details This unregisters a previously registerd higher protocol layer with the L2CAP multiplexer.
yihui 1:fc2f9d636751 109 *
yihui 1:fc2f9d636751 110 * @param[in] cid L2CAP CID.
yihui 1:fc2f9d636751 111 *
yihui 1:fc2f9d636751 112 * @return @ref NRF_SUCCESS Successfully unregistered the CID.
yihui 1:fc2f9d636751 113 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
yihui 1:fc2f9d636751 114 * @return @ref NRF_ERROR_NOT_FOUND CID not previously registered.
yihui 1:fc2f9d636751 115 */
yihui 1:fc2f9d636751 116 SVCALL(SD_BLE_L2CAP_CID_UNREGISTER, uint32_t, sd_ble_l2cap_cid_unregister(uint16_t cid));
yihui 1:fc2f9d636751 117
yihui 1:fc2f9d636751 118 /**@brief Transmit an L2CAP packet.
yihui 1:fc2f9d636751 119 *
yihui 1:fc2f9d636751 120 * @note It is important to note that a call to this function will <b>consume an application buffer</b>, and will therefore
yihui 1:fc2f9d636751 121 * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted.
yihui 1:fc2f9d636751 122 * Please see the documentation of @ref sd_ble_tx_buffer_count_get for more details.
yihui 1:fc2f9d636751 123 *
yihui 1:fc2f9d636751 124 * @param[in] conn_handle Connection Handle.
yihui 1:fc2f9d636751 125 * @param[in] p_header Pointer to a packet header containing length and CID.
yihui 1:fc2f9d636751 126 * @param[in] p_data Pointer to the data to be transmitted.
yihui 1:fc2f9d636751 127 *
yihui 1:fc2f9d636751 128 * @return @ref NRF_SUCCESS Successfully queued an L2CAP packet for transmission.
yihui 1:fc2f9d636751 129 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:fc2f9d636751 130 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CIDs must be registered beforehand with @ref sd_ble_l2cap_cid_register.
yihui 1:fc2f9d636751 131 * @return @ref NRF_ERROR_NOT_FOUND CID not found.
yihui 1:fc2f9d636751 132 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
yihui 1:fc2f9d636751 133 * @return @ref BLE_ERROR_NO_TX_BUFFERS Not enough application buffers available.
yihui 1:fc2f9d636751 134 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, see @ref BLE_L2CAP_MTU_DEF.
yihui 1:fc2f9d636751 135 */
yihui 1:fc2f9d636751 136 SVCALL(SD_BLE_L2CAP_TX, uint32_t, sd_ble_l2cap_tx(uint16_t conn_handle, ble_l2cap_header_t const * const p_header, uint8_t const * const p_data));
yihui 1:fc2f9d636751 137
yihui 1:fc2f9d636751 138 /** @} */
yihui 1:fc2f9d636751 139
yihui 1:fc2f9d636751 140 #endif // BLE_L2CAP_H__
yihui 1:fc2f9d636751 141
yihui 1:fc2f9d636751 142 /**
yihui 1:fc2f9d636751 143 @}
yihui 1:fc2f9d636751 144 */