iOSのBLEコントローラアプリ「RCBController」と接続し、コントローラの操作を取得するサンプルプログラムです。 mbed HRM1017で動作を確認しています。 2014.08.20時点でのBLEライブラリに対応しました。

Dependencies:   BLE_API mbed

Fork of BLE_RCBController by Junichi Katsu

Committer:
jksoft
Date:
Wed Aug 20 13:41:01 2014 +0000
Revision:
4:ebda47d22091
Parent:
nRF51822/nordic/nrf-sdk/app_common/hci_mem_pool.h@1:48f6e08a3ac2
?????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 1:48f6e08a3ac2 1 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
jksoft 1:48f6e08a3ac2 2 *
jksoft 1:48f6e08a3ac2 3 * The information contained herein is property of Nordic Semiconductor ASA.
jksoft 1:48f6e08a3ac2 4 * Terms and conditions of usage are described in detail in NORDIC
jksoft 1:48f6e08a3ac2 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
jksoft 1:48f6e08a3ac2 6 *
jksoft 1:48f6e08a3ac2 7 * Licensees are granted free, non-transferable use of the information. NO
jksoft 1:48f6e08a3ac2 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
jksoft 1:48f6e08a3ac2 9 * the file.
jksoft 1:48f6e08a3ac2 10 *
jksoft 1:48f6e08a3ac2 11 */
jksoft 1:48f6e08a3ac2 12
jksoft 1:48f6e08a3ac2 13 /** @file
jksoft 1:48f6e08a3ac2 14 *
jksoft 1:48f6e08a3ac2 15 * @defgroup memory_pool Memory pool
jksoft 1:48f6e08a3ac2 16 * @{
jksoft 1:48f6e08a3ac2 17 * @ingroup app_common
jksoft 1:48f6e08a3ac2 18 *
jksoft 1:48f6e08a3ac2 19 * @brief Memory pool implementation
jksoft 1:48f6e08a3ac2 20 *
jksoft 1:48f6e08a3ac2 21 * Memory pool implementation, based on circular buffer data structure, which supports asynchronous
jksoft 1:48f6e08a3ac2 22 * processing of RX data. The current default implementation supports 1 TX buffer and 4 RX buffers.
jksoft 1:48f6e08a3ac2 23 * The memory managed by the pool is allocated from static storage instead of heap. The internal
jksoft 1:48f6e08a3ac2 24 * design of the circular buffer implementing the RX memory layout is illustrated in the picture
jksoft 1:48f6e08a3ac2 25 * below.
jksoft 1:48f6e08a3ac2 26 *
jksoft 1:48f6e08a3ac2 27 * @image html memory_pool.png "Circular buffer design"
jksoft 1:48f6e08a3ac2 28 *
jksoft 1:48f6e08a3ac2 29 * The expected call order for the RX APIs is as follows:
jksoft 1:48f6e08a3ac2 30 * - hci_mem_pool_rx_produce
jksoft 1:48f6e08a3ac2 31 * - hci_mem_pool_rx_data_size_set
jksoft 1:48f6e08a3ac2 32 * - hci_mem_pool_rx_extract
jksoft 1:48f6e08a3ac2 33 * - hci_mem_pool_rx_consume
jksoft 1:48f6e08a3ac2 34 *
jksoft 1:48f6e08a3ac2 35 * @warning If the above mentioned expected call order is violated the end result can be undefined.
jksoft 1:48f6e08a3ac2 36 *
jksoft 1:48f6e08a3ac2 37 * \par Component specific configuration options
jksoft 1:48f6e08a3ac2 38 *
jksoft 1:48f6e08a3ac2 39 * The following compile time configuration options are available to suit various implementations:
jksoft 1:48f6e08a3ac2 40 * - TX_BUF_SIZE TX buffer size in bytes.
jksoft 1:48f6e08a3ac2 41 * - RX_BUF_SIZE RX buffer size in bytes.
jksoft 1:48f6e08a3ac2 42 * - RX_BUF_QUEUE_SIZE RX buffer element size.
jksoft 1:48f6e08a3ac2 43 */
jksoft 1:48f6e08a3ac2 44
jksoft 1:48f6e08a3ac2 45 #ifndef HCI_MEM_POOL_H__
jksoft 1:48f6e08a3ac2 46 #define HCI_MEM_POOL_H__
jksoft 1:48f6e08a3ac2 47
jksoft 1:48f6e08a3ac2 48 #include <stdint.h>
jksoft 1:48f6e08a3ac2 49 #include "nrf_error.h"
jksoft 1:48f6e08a3ac2 50
jksoft 1:48f6e08a3ac2 51 /**@brief Function for opening the module.
jksoft 1:48f6e08a3ac2 52 *
jksoft 1:48f6e08a3ac2 53 * @retval NRF_SUCCESS Operation success.
jksoft 1:48f6e08a3ac2 54 */
jksoft 1:48f6e08a3ac2 55 uint32_t hci_mem_pool_open(void);
jksoft 1:48f6e08a3ac2 56
jksoft 1:48f6e08a3ac2 57 /**@brief Function for closing the module.
jksoft 1:48f6e08a3ac2 58 *
jksoft 1:48f6e08a3ac2 59 * @retval NRF_SUCCESS Operation success.
jksoft 1:48f6e08a3ac2 60 */
jksoft 1:48f6e08a3ac2 61 uint32_t hci_mem_pool_close(void);
jksoft 1:48f6e08a3ac2 62
jksoft 1:48f6e08a3ac2 63 /**@brief Function for allocating requested amount of TX memory.
jksoft 1:48f6e08a3ac2 64 *
jksoft 1:48f6e08a3ac2 65 * @param[out] pp_buffer Pointer to the allocated memory.
jksoft 1:48f6e08a3ac2 66 *
jksoft 1:48f6e08a3ac2 67 * @retval NRF_SUCCESS Operation success. Memory was allocated.
jksoft 1:48f6e08a3ac2 68 * @retval NRF_ERROR_NO_MEM Operation failure. No memory available for allocation.
jksoft 1:48f6e08a3ac2 69 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied.
jksoft 1:48f6e08a3ac2 70 */
jksoft 1:48f6e08a3ac2 71 uint32_t hci_mem_pool_tx_alloc(void ** pp_buffer);
jksoft 1:48f6e08a3ac2 72
jksoft 1:48f6e08a3ac2 73 /**@brief Function for freeing previously allocated TX memory.
jksoft 1:48f6e08a3ac2 74 *
jksoft 1:48f6e08a3ac2 75 * @note Memory management follows the FIFO principle meaning that free() order must match the
jksoft 1:48f6e08a3ac2 76 * alloc(...) order, which is the reason for omitting exact memory block identifier as an
jksoft 1:48f6e08a3ac2 77 * input parameter.
jksoft 1:48f6e08a3ac2 78 *
jksoft 1:48f6e08a3ac2 79 * @retval NRF_SUCCESS Operation success. Memory was freed.
jksoft 1:48f6e08a3ac2 80 */
jksoft 1:48f6e08a3ac2 81 uint32_t hci_mem_pool_tx_free(void);
jksoft 1:48f6e08a3ac2 82
jksoft 1:48f6e08a3ac2 83 /**@brief Function for producing a free RX memory block for usage.
jksoft 1:48f6e08a3ac2 84 *
jksoft 1:48f6e08a3ac2 85 * @note Upon produce request amount being 0, NRF_SUCCESS is returned.
jksoft 1:48f6e08a3ac2 86 *
jksoft 1:48f6e08a3ac2 87 * @param[in] length Amount, in bytes, of free memory to be produced.
jksoft 1:48f6e08a3ac2 88 * @param[out] pp_buffer Pointer to the allocated memory.
jksoft 1:48f6e08a3ac2 89 *
jksoft 1:48f6e08a3ac2 90 * @retval NRF_SUCCESS Operation success. Free RX memory block produced.
jksoft 1:48f6e08a3ac2 91 * @retval NRF_ERROR_NO_MEM Operation failure. No suitable memory available for allocation.
jksoft 1:48f6e08a3ac2 92 * @retval NRF_ERROR_DATA_SIZE Operation failure. Request size exceeds limit.
jksoft 1:48f6e08a3ac2 93 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied.
jksoft 1:48f6e08a3ac2 94 */
jksoft 1:48f6e08a3ac2 95 uint32_t hci_mem_pool_rx_produce(uint32_t length, void ** pp_buffer);
jksoft 1:48f6e08a3ac2 96
jksoft 1:48f6e08a3ac2 97 /**@brief Function for setting the length of the last produced RX memory block.
jksoft 1:48f6e08a3ac2 98 *
jksoft 1:48f6e08a3ac2 99 * @warning If call to this API is omitted the end result is that the following call to
jksoft 1:48f6e08a3ac2 100 * mem_pool_rx_extract will return incorrect data in the p_length output parameter.
jksoft 1:48f6e08a3ac2 101 *
jksoft 1:48f6e08a3ac2 102 * @param[in] length Amount, in bytes, of actual memory used.
jksoft 1:48f6e08a3ac2 103 *
jksoft 1:48f6e08a3ac2 104 * @retval NRF_SUCCESS Operation success. Length was set.
jksoft 1:48f6e08a3ac2 105 */
jksoft 1:48f6e08a3ac2 106 uint32_t hci_mem_pool_rx_data_size_set(uint32_t length);
jksoft 1:48f6e08a3ac2 107
jksoft 1:48f6e08a3ac2 108 /**@brief Function for extracting a packet, which has been filled with read data, for further
jksoft 1:48f6e08a3ac2 109 * processing.
jksoft 1:48f6e08a3ac2 110 *
jksoft 1:48f6e08a3ac2 111 * @param[out] pp_buffer Pointer to the packet data.
jksoft 1:48f6e08a3ac2 112 * @param[out] p_length Length of packet data in bytes.
jksoft 1:48f6e08a3ac2 113 *
jksoft 1:48f6e08a3ac2 114 * @retval NRF_SUCCESS Operation success.
jksoft 1:48f6e08a3ac2 115 * @retval NRF_ERROR_NO_MEM Operation failure. No packet available to extract.
jksoft 1:48f6e08a3ac2 116 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied.
jksoft 1:48f6e08a3ac2 117 */
jksoft 1:48f6e08a3ac2 118 uint32_t hci_mem_pool_rx_extract(uint8_t ** pp_buffer, uint32_t * p_length);
jksoft 1:48f6e08a3ac2 119
jksoft 1:48f6e08a3ac2 120 /**@brief Function for freeing previously extracted packet, which has been filled with read data.
jksoft 1:48f6e08a3ac2 121 *
jksoft 1:48f6e08a3ac2 122 * @param[in] p_buffer Pointer to consumed buffer.
jksoft 1:48f6e08a3ac2 123 *
jksoft 1:48f6e08a3ac2 124 * @retval NRF_SUCCESS Operation success.
jksoft 1:48f6e08a3ac2 125 * @retval NRF_ERROR_NO_MEM Operation failure. No packet available to free.
jksoft 1:48f6e08a3ac2 126 * @retval NRF_ERROR_INVALID_ADDR Operation failure. Not a valid pointer.
jksoft 1:48f6e08a3ac2 127 */
jksoft 1:48f6e08a3ac2 128 uint32_t hci_mem_pool_rx_consume(uint8_t * p_buffer);
jksoft 1:48f6e08a3ac2 129
jksoft 1:48f6e08a3ac2 130 #endif // HCI_MEM_POOL_H__
jksoft 1:48f6e08a3ac2 131
jksoft 1:48f6e08a3ac2 132 /** @} */