Michio Ono / Mbed 2 deprecated BLE_konashi_PIO_test

Dependencies:   BLE_API_Native_IRC mbed

Fork of BLE_RCBController by Junichi Katsu

Committer:
jksoft
Date:
Thu Jul 10 14:21:52 2014 +0000
Revision:
0:8c643bfe55b7
??

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:8c643bfe55b7 1 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
jksoft 0:8c643bfe55b7 2 *
jksoft 0:8c643bfe55b7 3 * The information contained herein is property of Nordic Semiconductor ASA.
jksoft 0:8c643bfe55b7 4 * Terms and conditions of usage are described in detail in NORDIC
jksoft 0:8c643bfe55b7 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
jksoft 0:8c643bfe55b7 6 *
jksoft 0:8c643bfe55b7 7 * Licensees are granted free, non-transferable use of the information. NO
jksoft 0:8c643bfe55b7 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
jksoft 0:8c643bfe55b7 9 * the file.
jksoft 0:8c643bfe55b7 10 *
jksoft 0:8c643bfe55b7 11 */
jksoft 0:8c643bfe55b7 12
jksoft 0:8c643bfe55b7 13 /** @file
jksoft 0:8c643bfe55b7 14 *
jksoft 0:8c643bfe55b7 15 * @defgroup hci_slip SLIP module
jksoft 0:8c643bfe55b7 16 * @{
jksoft 0:8c643bfe55b7 17 * @ingroup app_common
jksoft 0:8c643bfe55b7 18 *
jksoft 0:8c643bfe55b7 19 * @brief SLIP layer for supporting packet framing in HCI transport.
jksoft 0:8c643bfe55b7 20 *
jksoft 0:8c643bfe55b7 21 * @details This module implements SLIP packet framing as described in the Bluetooth Core
jksoft 0:8c643bfe55b7 22 * Specification 4.0, Volume 4, Part D, Chapter 3 SLIP Layer.
jksoft 0:8c643bfe55b7 23 *
jksoft 0:8c643bfe55b7 24 * SLIP framing ensures that all packets sent on the UART are framed as:
jksoft 0:8c643bfe55b7 25 * <0xC0> SLIP packet 1 <0xC0> <0xC0> SLIP packet 2 <0xC0>.
jksoft 0:8c643bfe55b7 26 *
jksoft 0:8c643bfe55b7 27 * The SLIP layer uses events to notify the upper layer when data transmission is complete
jksoft 0:8c643bfe55b7 28 * and when a SLIP packet is received.
jksoft 0:8c643bfe55b7 29 */
jksoft 0:8c643bfe55b7 30
jksoft 0:8c643bfe55b7 31 #ifndef HCI_SLIP_H__
jksoft 0:8c643bfe55b7 32 #define HCI_SLIP_H__
jksoft 0:8c643bfe55b7 33
jksoft 0:8c643bfe55b7 34 #include <stdint.h>
jksoft 0:8c643bfe55b7 35 #include "nordic_global.h"
jksoft 0:8c643bfe55b7 36
jksoft 0:8c643bfe55b7 37 /**@brief Event types from the SLIP Layer. */
jksoft 0:8c643bfe55b7 38 typedef enum
jksoft 0:8c643bfe55b7 39 {
jksoft 0:8c643bfe55b7 40 HCI_SLIP_RX_RDY, /**< An event indicating that an RX packet is ready to be read. */
jksoft 0:8c643bfe55b7 41 HCI_SLIP_TX_DONE, /**< An event indicating write completion of the TX packet provided in the function call \ref hci_slip_write . */
jksoft 0:8c643bfe55b7 42 HCI_SLIP_RX_OVERFLOW, /**< An event indicating that RX data has been discarded due to lack of free RX memory. */
jksoft 0:8c643bfe55b7 43 HCI_SLIP_ERROR, /**< An event indicating that an unrecoverable error has occurred. */
jksoft 0:8c643bfe55b7 44 HCI_SLIP_EVT_TYPE_MAX /**< Enumeration upper bound. */
jksoft 0:8c643bfe55b7 45 } hci_slip_evt_type_t;
jksoft 0:8c643bfe55b7 46
jksoft 0:8c643bfe55b7 47 /**@brief Structure containing an event from the SLIP layer.
jksoft 0:8c643bfe55b7 48 */
jksoft 0:8c643bfe55b7 49 typedef struct
jksoft 0:8c643bfe55b7 50 {
jksoft 0:8c643bfe55b7 51 hci_slip_evt_type_t evt_type; /**< Type of event. */
jksoft 0:8c643bfe55b7 52 const uint8_t * packet; /**< This field contains a pointer to the packet for which the event relates, i.e. SLIP_TX_DONE: the packet transmitted, SLIP_RX_RDY: the packet received, SLIP_RX_OVERFLOW: The packet which overflow/or NULL if no receive buffer is available. */
jksoft 0:8c643bfe55b7 53 uint32_t packet_length; /**< Packet length, i.e. SLIP_TX_DONE: Bytes transmitted, SLIP_RX_RDY: Bytes received, SLIP_RX_OVERFLOW: index at which the packet overflowed. */
jksoft 0:8c643bfe55b7 54 } hci_slip_evt_t;
jksoft 0:8c643bfe55b7 55
jksoft 0:8c643bfe55b7 56 /**@brief Function for the SLIP layer event callback.
jksoft 0:8c643bfe55b7 57 */
jksoft 0:8c643bfe55b7 58 typedef void (*hci_slip_event_handler_t)(hci_slip_evt_t event);
jksoft 0:8c643bfe55b7 59
jksoft 0:8c643bfe55b7 60 /**@brief Function for registering the event handler provided as parameter and this event handler
jksoft 0:8c643bfe55b7 61 * will be used by SLIP layer to send events described in \ref hci_slip_evt_type_t.
jksoft 0:8c643bfe55b7 62 *
jksoft 0:8c643bfe55b7 63 * @note Multiple registration requests will overwrite any existing registration.
jksoft 0:8c643bfe55b7 64 *
jksoft 0:8c643bfe55b7 65 * @param[in] event_handler This function is called by the SLIP layer upon an event.
jksoft 0:8c643bfe55b7 66 *
jksoft 0:8c643bfe55b7 67 * @retval NRF_SUCCESS Operation success.
jksoft 0:8c643bfe55b7 68 */
jksoft 0:8c643bfe55b7 69 uint32_t hci_slip_evt_handler_register(hci_slip_event_handler_t event_handler);
jksoft 0:8c643bfe55b7 70
jksoft 0:8c643bfe55b7 71 /**@brief Function for opening the SLIP layer. This function must be called before
jksoft 0:8c643bfe55b7 72 * \ref hci_slip_write and before any data can be received.
jksoft 0:8c643bfe55b7 73 *
jksoft 0:8c643bfe55b7 74 * @note Can be called multiple times.
jksoft 0:8c643bfe55b7 75 *
jksoft 0:8c643bfe55b7 76 * @retval NRF_SUCCESS Operation success.
jksoft 0:8c643bfe55b7 77 *
jksoft 0:8c643bfe55b7 78 * The SLIP layer module will propagate errors from underlying sub-modules.
jksoft 0:8c643bfe55b7 79 * This implementation is using UART module as a physical transmission layer, and hci_slip_open
jksoft 0:8c643bfe55b7 80 * executes \ref app_uart_init . For an extended error list, please refer to \ref app_uart_init .
jksoft 0:8c643bfe55b7 81 */
jksoft 0:8c643bfe55b7 82 uint32_t hci_slip_open(void);
jksoft 0:8c643bfe55b7 83
jksoft 0:8c643bfe55b7 84 /**@brief Function for closing the SLIP layer. After this function is called no data can be
jksoft 0:8c643bfe55b7 85 * transmitted or received in this layer.
jksoft 0:8c643bfe55b7 86 *
jksoft 0:8c643bfe55b7 87 * @note This function can be called multiple times and also for an unopened channel.
jksoft 0:8c643bfe55b7 88 *
jksoft 0:8c643bfe55b7 89 * @retval NRF_SUCCESS Operation success.
jksoft 0:8c643bfe55b7 90 */
jksoft 0:8c643bfe55b7 91 uint32_t hci_slip_close(void);
jksoft 0:8c643bfe55b7 92
jksoft 0:8c643bfe55b7 93 /**@brief Function for writing a packet with SLIP encoding. Packet transmission is confirmed when
jksoft 0:8c643bfe55b7 94 * the HCI_SLIP_TX_DONE event is received by the function caller.
jksoft 0:8c643bfe55b7 95 *
jksoft 0:8c643bfe55b7 96 * @param[in] p_buffer Pointer to the packet to transmit.
jksoft 0:8c643bfe55b7 97 * @param[in] length Packet length, in bytes.
jksoft 0:8c643bfe55b7 98 *
jksoft 0:8c643bfe55b7 99 * @retval NRF_SUCCESS Operation success. Packet was encoded and added to the
jksoft 0:8c643bfe55b7 100 * transmission queue and an event will be sent upon transmission
jksoft 0:8c643bfe55b7 101 * completion.
jksoft 0:8c643bfe55b7 102 * @retval NRF_ERROR_NO_MEM Operation failure. Transmission queue is full and packet was not
jksoft 0:8c643bfe55b7 103 * added to the transmission queue. Application shall wait for
jksoft 0:8c643bfe55b7 104 * the \ref HCI_SLIP_TX_DONE event. After HCI_SLIP_TX_DONE this
jksoft 0:8c643bfe55b7 105 * function can be executed for transmission of next packet.
jksoft 0:8c643bfe55b7 106 * @retval NRF_ERROR_INVALID_ADDR If a NULL pointer is provided.
jksoft 0:8c643bfe55b7 107 * @retval NRF_ERROR_INVALID_STATE Operation failure. Module is not open.
jksoft 0:8c643bfe55b7 108 */
jksoft 0:8c643bfe55b7 109 uint32_t hci_slip_write(const uint8_t * p_buffer, uint32_t length);
jksoft 0:8c643bfe55b7 110
jksoft 0:8c643bfe55b7 111 /**@brief Function for registering a receive buffer. The receive buffer will be used for storage of
jksoft 0:8c643bfe55b7 112 * received and SLIP decoded data.
jksoft 0:8c643bfe55b7 113 * No data can be received by the SLIP layer until a receive buffer has been registered.
jksoft 0:8c643bfe55b7 114 *
jksoft 0:8c643bfe55b7 115 * @note The lifetime of the buffer must be valid during complete reception of data. A static
jksoft 0:8c643bfe55b7 116 * buffer is recommended.
jksoft 0:8c643bfe55b7 117 *
jksoft 0:8c643bfe55b7 118 * @warning Multiple registration requests will overwrite any existing registration.
jksoft 0:8c643bfe55b7 119 *
jksoft 0:8c643bfe55b7 120 * @param[in] p_buffer Pointer to receive buffer. The received and SLIP decoded packet
jksoft 0:8c643bfe55b7 121 * will be placed in this buffer.
jksoft 0:8c643bfe55b7 122 * @param[in] length Buffer length, in bytes.
jksoft 0:8c643bfe55b7 123 *
jksoft 0:8c643bfe55b7 124 * @retval NRF_SUCCESS Operation success.
jksoft 0:8c643bfe55b7 125 */
jksoft 0:8c643bfe55b7 126 uint32_t hci_slip_rx_buffer_register(uint8_t * p_buffer, uint32_t length);
jksoft 0:8c643bfe55b7 127
jksoft 0:8c643bfe55b7 128 #endif // HCI_SLIP_H__
jksoft 0:8c643bfe55b7 129
jksoft 0:8c643bfe55b7 130 /** @} */