Nordic stack and drivers for the mbed BLE API Modified for HRM1017 for library 0.1.0
Fork of nRF51822 by
hci_slip.h
00001 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 00002 * 00003 * The information contained herein is property of Nordic Semiconductor ASA. 00004 * Terms and conditions of usage are described in detail in NORDIC 00005 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 00006 * 00007 * Licensees are granted free, non-transferable use of the information. NO 00008 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 00009 * the file. 00010 * 00011 */ 00012 00013 /** @file 00014 * 00015 * @defgroup hci_slip SLIP module 00016 * @{ 00017 * @ingroup app_common 00018 * 00019 * @brief SLIP layer for supporting packet framing in HCI transport. 00020 * 00021 * @details This module implements SLIP packet framing as described in the Bluetooth Core 00022 * Specification 4.0, Volume 4, Part D, Chapter 3 SLIP Layer. 00023 * 00024 * SLIP framing ensures that all packets sent on the UART are framed as: 00025 * <0xC0> SLIP packet 1 <0xC0> <0xC0> SLIP packet 2 <0xC0>. 00026 * 00027 * The SLIP layer uses events to notify the upper layer when data transmission is complete 00028 * and when a SLIP packet is received. 00029 */ 00030 00031 #ifndef HCI_SLIP_H__ 00032 #define HCI_SLIP_H__ 00033 00034 #include <stdint.h> 00035 00036 /**@brief Event types from the SLIP Layer. */ 00037 typedef enum 00038 { 00039 HCI_SLIP_RX_RDY, /**< An event indicating that an RX packet is ready to be read. */ 00040 HCI_SLIP_TX_DONE, /**< An event indicating write completion of the TX packet provided in the function call \ref hci_slip_write . */ 00041 HCI_SLIP_RX_OVERFLOW, /**< An event indicating that RX data has been discarded due to lack of free RX memory. */ 00042 HCI_SLIP_ERROR, /**< An event indicating that an unrecoverable error has occurred. */ 00043 HCI_SLIP_EVT_TYPE_MAX /**< Enumeration upper bound. */ 00044 } hci_slip_evt_type_t; 00045 00046 /**@brief Structure containing an event from the SLIP layer. 00047 */ 00048 typedef struct 00049 { 00050 hci_slip_evt_type_t evt_type; /**< Type of event. */ 00051 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. */ 00052 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. */ 00053 } hci_slip_evt_t; 00054 00055 /**@brief Function for the SLIP layer event callback. 00056 */ 00057 typedef void (*hci_slip_event_handler_t)(hci_slip_evt_t event); 00058 00059 /**@brief Function for registering the event handler provided as parameter and this event handler 00060 * will be used by SLIP layer to send events described in \ref hci_slip_evt_type_t. 00061 * 00062 * @note Multiple registration requests will overwrite any existing registration. 00063 * 00064 * @param[in] event_handler This function is called by the SLIP layer upon an event. 00065 * 00066 * @retval NRF_SUCCESS Operation success. 00067 */ 00068 uint32_t hci_slip_evt_handler_register(hci_slip_event_handler_t event_handler); 00069 00070 /**@brief Function for opening the SLIP layer. This function must be called before 00071 * \ref hci_slip_write and before any data can be received. 00072 * 00073 * @note Can be called multiple times. 00074 * 00075 * @retval NRF_SUCCESS Operation success. 00076 * 00077 * The SLIP layer module will propagate errors from underlying sub-modules. 00078 * This implementation is using UART module as a physical transmission layer, and hci_slip_open 00079 * executes \ref app_uart_init . For an extended error list, please refer to \ref app_uart_init . 00080 */ 00081 uint32_t hci_slip_open(void); 00082 00083 /**@brief Function for closing the SLIP layer. After this function is called no data can be 00084 * transmitted or received in this layer. 00085 * 00086 * @note This function can be called multiple times and also for an unopened channel. 00087 * 00088 * @retval NRF_SUCCESS Operation success. 00089 */ 00090 uint32_t hci_slip_close(void); 00091 00092 /**@brief Function for writing a packet with SLIP encoding. Packet transmission is confirmed when 00093 * the HCI_SLIP_TX_DONE event is received by the function caller. 00094 * 00095 * @param[in] p_buffer Pointer to the packet to transmit. 00096 * @param[in] length Packet length, in bytes. 00097 * 00098 * @retval NRF_SUCCESS Operation success. Packet was encoded and added to the 00099 * transmission queue and an event will be sent upon transmission 00100 * completion. 00101 * @retval NRF_ERROR_NO_MEM Operation failure. Transmission queue is full and packet was not 00102 * added to the transmission queue. Application shall wait for 00103 * the \ref HCI_SLIP_TX_DONE event. After HCI_SLIP_TX_DONE this 00104 * function can be executed for transmission of next packet. 00105 * @retval NRF_ERROR_INVALID_ADDR If a NULL pointer is provided. 00106 * @retval NRF_ERROR_INVALID_STATE Operation failure. Module is not open. 00107 */ 00108 uint32_t hci_slip_write(const uint8_t * p_buffer, uint32_t length); 00109 00110 /**@brief Function for registering a receive buffer. The receive buffer will be used for storage of 00111 * received and SLIP decoded data. 00112 * No data can be received by the SLIP layer until a receive buffer has been registered. 00113 * 00114 * @note The lifetime of the buffer must be valid during complete reception of data. A static 00115 * buffer is recommended. 00116 * 00117 * @warning Multiple registration requests will overwrite any existing registration. 00118 * 00119 * @param[in] p_buffer Pointer to receive buffer. The received and SLIP decoded packet 00120 * will be placed in this buffer. 00121 * @param[in] length Buffer length, in bytes. 00122 * 00123 * @retval NRF_SUCCESS Operation success. 00124 */ 00125 uint32_t hci_slip_rx_buffer_register(uint8_t * p_buffer, uint32_t length); 00126 00127 #endif // HCI_SLIP_H__ 00128 00129 /** @} */
Generated on Tue Jul 12 2022 14:11:56 by 1.7.2