mbed HRM11017を使ってkonashi.jsでナイトライダー
Dependencies: BLE_API_Native_IRC mbed
Fork of BLE_RCBController by
hci_transport.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_transport HCI Transport 00016 * @{ 00017 * @ingroup app_common 00018 * 00019 * @brief HCI transport module implementation. 00020 * 00021 * This module implements certain specific features from the three-wire UART transport layer, 00022 * defined by the Bluetooth specification version 4.0 [Vol 4] part D. 00023 * 00024 * \par Features supported 00025 * - Transmission and reception of Vendor Specific HCI packet type application packets. 00026 * - Transmission and reception of reliable packets: defined by chapter 6 of the specification. 00027 * 00028 * \par Features not supported 00029 * - Link establishment procedure: defined by chapter 8 of the specification. 00030 * - Low power: defined by chapter 9 of the specification. 00031 * 00032 * \par Implementation specific behaviour 00033 * - As Link establishment procedure is not supported following static link configuration parameters 00034 * are used: 00035 * + TX window size is 1. 00036 * + 16 bit CCITT-CRC must be used. 00037 * + Out of frame software flow control not supported. 00038 * + Parameters specific for resending reliable packets are compile time configurable (clarifed 00039 * later in this document). 00040 * + Acknowledgement packet transmissions are not timeout driven , meaning they are delivered for 00041 * transmission within same context which the corresponding application packet was received. 00042 * 00043 * \par Implementation specific limitations 00044 * Current implementation has the following limitations which will have impact to system wide 00045 * behaviour: 00046 * - Delayed acknowledgement scheduling not implemented: 00047 * There exists a possibility that acknowledgement TX packet and application TX packet will collide 00048 * in the TX pipeline having the end result that acknowledgement packet will be excluded from the TX 00049 * pipeline which will trigger the retransmission algorithm within the peer protocol entity. 00050 * - Delayed retransmission scheduling not implemented: 00051 * There exists a possibility that retransmitted application TX packet and acknowledgement TX packet 00052 * will collide in the TX pipeline having the end result that retransmitted application TX packet 00053 * will be excluded from the TX pipeline. 00054 * - Processing of the acknowledgement number from RX application packets: 00055 * Acknowledgement number is not processed from the RX application packets having the end result 00056 * that unnecessary application packet retransmissions can occur. 00057 * 00058 * The application TX packet processing flow is illustrated by the statemachine below. 00059 * 00060 * @image html hci_transport_tx_sm.png "TX - application packet statemachine" 00061 * 00062 * \par Component specific configuration options 00063 * 00064 * The following compile time configuration options are available, and used to configure the 00065 * application TX packet retransmission interval, in order to suite various application specific 00066 * implementations: 00067 * - MAC_PACKET_SIZE_IN_BITS Maximum size of a single application packet in bits. 00068 * - USED_BAUD_RATE Used uart baudrate. 00069 * 00070 * The following compile time configuration option is available to configure module specific 00071 * behaviour: 00072 * - MAX_RETRY_COUNT Max retransmission retry count for applicaton packets. 00073 */ 00074 00075 #ifndef HCI_TRANSPORT_H__ 00076 #define HCI_TRANSPORT_H__ 00077 00078 #include <stdint.h> 00079 #include "nordic_global.h" 00080 #include "nrf_error.h" 00081 00082 /**@brief Generic event callback function events. */ 00083 typedef enum 00084 { 00085 HCI_TRANSPORT_RX_RDY, /**< An event indicating that RX packet is ready for read. */ 00086 HCI_TRANSPORT_EVT_TYPE_MAX /**< Enumeration upper bound. */ 00087 } hci_transport_evt_type_t; 00088 00089 /**@brief Struct containing events from the Transport layer. 00090 */ 00091 typedef struct 00092 { 00093 hci_transport_evt_type_t evt_type; /**< Type of event. */ 00094 } hci_transport_evt_t; 00095 00096 /**@brief Transport layer generic event callback function type. 00097 * 00098 * @param[in] event Transport layer event. 00099 */ 00100 typedef void (*hci_transport_event_handler_t)(hci_transport_evt_t event); 00101 00102 /**@brief TX done event callback function result codes. */ 00103 typedef enum 00104 { 00105 HCI_TRANSPORT_TX_DONE_SUCCESS, /**< Transmission success, peer transport entity has acknowledged the transmission. */ 00106 HCI_TRANSPORT_TX_DONE_FAILURE /**< Transmission failure. */ 00107 } hci_transport_tx_done_result_t; 00108 00109 /**@brief Transport layer TX done event callback function type. 00110 * 00111 * @param[in] result TX done event result code. 00112 */ 00113 typedef void (*hci_transport_tx_done_handler_t)(hci_transport_tx_done_result_t result); 00114 00115 /**@brief Function for registering a generic event handler. 00116 * 00117 * @note Multiple registration requests will overwrite any possible existing registration. 00118 * 00119 * @param[in] event_handler The function to be called by the transport layer upon an event. 00120 * 00121 * @retval NRF_SUCCESS Operation success. 00122 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. 00123 */ 00124 uint32_t hci_transport_evt_handler_reg(hci_transport_event_handler_t event_handler); 00125 00126 /**@brief Function for registering a handler for TX done event. 00127 * 00128 * @note Multiple registration requests will overwrite any possible existing registration. 00129 * 00130 * @param[in] event_handler The function to be called by the transport layer upon TX done 00131 * event. 00132 * 00133 * @retval NRF_SUCCESS Operation success. 00134 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. 00135 */ 00136 uint32_t hci_transport_tx_done_register(hci_transport_tx_done_handler_t event_handler); 00137 00138 /**@brief Function for opening the transport channel and initializing the transport layer. 00139 * 00140 * @warning Must not be called for a channel which has been allready opened. 00141 * 00142 * @retval NRF_SUCCESS Operation success. 00143 * @retval NRF_ERROR_INTERNAL Operation failure. Internal error ocurred. 00144 */ 00145 uint32_t hci_transport_open(void); 00146 00147 /**@brief Function for closing the transport channel. 00148 * 00149 * @note Can be called multiple times and also for not opened channel. 00150 * 00151 * @retval NRF_SUCCESS Operation success. 00152 */ 00153 uint32_t hci_transport_close(void); 00154 00155 /**@brief Function for allocating tx packet memory. 00156 * 00157 * @param[out] pp_memory Pointer to the packet data. 00158 * 00159 * @retval NRF_SUCCESS Operation success. Memory was allocated. 00160 * @retval NRF_ERROR_NO_MEM Operation failure. No memory available. 00161 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. 00162 */ 00163 uint32_t hci_transport_tx_alloc(uint8_t ** pp_memory); 00164 00165 /**@brief Function for freeing tx packet memory. 00166 * 00167 * @note Memory management works in FIFO principle meaning that free order must match the alloc 00168 * order. 00169 * 00170 * @retval NRF_SUCCESS Operation success. Memory was freed. 00171 */ 00172 uint32_t hci_transport_tx_free(void); 00173 00174 /**@brief Function for writing a packet. 00175 * 00176 * @note Completion of this method does not guarantee that actual peripheral transmission would 00177 * have completed. 00178 * 00179 * @note In case of 0 byte packet length write request, message will consist of only transport 00180 * module specific headers. 00181 * 00182 * @retval NRF_SUCCESS Operation success. Packet was added to the transmission queue 00183 * and an event will be send upon transmission completion. 00184 * @retval NRF_ERROR_NO_MEM Operation failure. Transmission queue is full and packet was not 00185 * added to the transmission queue. User should wait for 00186 * a appropriate event prior issuing this operation again. 00187 * @retval NRF_ERROR_DATA_SIZE Operation failure. Packet size exceeds limit. 00188 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. 00189 * @retval NRF_ERROR_INVALID_STATE Operation failure. Channel is not open. 00190 */ 00191 uint32_t hci_transport_pkt_write(const uint8_t * p_buffer, uint32_t length); 00192 00193 /**@brief Function for extracting received packet. 00194 * 00195 * @note Extracted memory can't be reused by the underlying transport layer untill freed by call to 00196 * hci_transport_rx_pkt_consume(). 00197 * 00198 * @param[out] pp_buffer Pointer to the packet data. 00199 * @param[out] p_length Length of packet data in bytes. 00200 * 00201 * @retval NRF_SUCCESS Operation success. Packet was extracted. 00202 * @retval NRF_ERROR_NO_MEM Operation failure. No packet available to extract. 00203 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. 00204 */ 00205 uint32_t hci_transport_rx_pkt_extract(uint8_t ** pp_buffer, uint32_t * p_length); 00206 00207 /**@brief Function for consuming extracted packet described by p_buffer. 00208 * 00209 * RX memory pointed to by p_buffer is freed and can be reused by the underlying transport layer. 00210 * 00211 * @param[in] p_buffer Pointer to the buffer that has been consumed. 00212 * 00213 * @retval NRF_SUCCESS Operation success. 00214 * @retval NRF_ERROR_NO_MEM Operation failure. No packet available to consume. 00215 * @retval NRF_ERROR_INVALID_ADDR Operation failure. Not a valid pointer. 00216 */ 00217 uint32_t hci_transport_rx_pkt_consume(uint8_t * p_buffer); 00218 00219 #endif // HCI_TRANSPORT_H__ 00220 00221 /** @} */
Generated on Tue Jul 12 2022 18:49:54 by 1.7.2