changed low freq. clock source to IRC
Dependents: BLE_ANCS_SDAPI_IRC
Fork of nRF51822 by
hci_mem_pool.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 memory_pool Memory pool 00016 * @{ 00017 * @ingroup app_common 00018 * 00019 * @brief Memory pool implementation 00020 * 00021 * Memory pool implementation, based on circular buffer data structure, which supports asynchronous 00022 * processing of RX data. The current default implementation supports 1 TX buffer and 4 RX buffers. 00023 * The memory managed by the pool is allocated from static storage instead of heap. The internal 00024 * design of the circular buffer implementing the RX memory layout is illustrated in the picture 00025 * below. 00026 * 00027 * @image html memory_pool.png "Circular buffer design" 00028 * 00029 * The expected call order for the RX APIs is as follows: 00030 * - hci_mem_pool_rx_produce 00031 * - hci_mem_pool_rx_data_size_set 00032 * - hci_mem_pool_rx_extract 00033 * - hci_mem_pool_rx_consume 00034 * 00035 * @warning If the above mentioned expected call order is violated the end result can be undefined. 00036 * 00037 * \par Component specific configuration options 00038 * 00039 * The following compile time configuration options are available to suit various implementations: 00040 * - TX_BUF_SIZE TX buffer size in bytes. 00041 * - RX_BUF_SIZE RX buffer size in bytes. 00042 * - RX_BUF_QUEUE_SIZE RX buffer element size. 00043 */ 00044 00045 #ifndef HCI_MEM_POOL_H__ 00046 #define HCI_MEM_POOL_H__ 00047 00048 #include <stdint.h> 00049 #include "nordic_global.h" 00050 #include "nrf_error.h" 00051 00052 /**@brief Function for opening the module. 00053 * 00054 * @retval NRF_SUCCESS Operation success. 00055 */ 00056 uint32_t hci_mem_pool_open(void); 00057 00058 /**@brief Function for closing the module. 00059 * 00060 * @retval NRF_SUCCESS Operation success. 00061 */ 00062 uint32_t hci_mem_pool_close(void); 00063 00064 /**@brief Function for allocating requested amount of TX memory. 00065 * 00066 * @param[out] pp_buffer Pointer to the allocated memory. 00067 * 00068 * @retval NRF_SUCCESS Operation success. Memory was allocated. 00069 * @retval NRF_ERROR_NO_MEM Operation failure. No memory available for allocation. 00070 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. 00071 */ 00072 uint32_t hci_mem_pool_tx_alloc(void ** pp_buffer); 00073 00074 /**@brief Function for freeing previously allocated TX memory. 00075 * 00076 * @note Memory management follows the FIFO principle meaning that free() order must match the 00077 * alloc(...) order, which is the reason for omitting exact memory block identifier as an 00078 * input parameter. 00079 * 00080 * @retval NRF_SUCCESS Operation success. Memory was freed. 00081 */ 00082 uint32_t hci_mem_pool_tx_free(void); 00083 00084 /**@brief Function for producing a free RX memory block for usage. 00085 * 00086 * @note Upon produce request amount being 0, NRF_SUCCESS is returned. 00087 * 00088 * @param[in] length Amount, in bytes, of free memory to be produced. 00089 * @param[out] pp_buffer Pointer to the allocated memory. 00090 * 00091 * @retval NRF_SUCCESS Operation success. Free RX memory block produced. 00092 * @retval NRF_ERROR_NO_MEM Operation failure. No suitable memory available for allocation. 00093 * @retval NRF_ERROR_DATA_SIZE Operation failure. Request size exceeds limit. 00094 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. 00095 */ 00096 uint32_t hci_mem_pool_rx_produce(uint32_t length, void ** pp_buffer); 00097 00098 /**@brief Function for setting the length of the last produced RX memory block. 00099 * 00100 * @warning If call to this API is omitted the end result is that the following call to 00101 * mem_pool_rx_extract will return incorrect data in the p_length output parameter. 00102 * 00103 * @param[in] length Amount, in bytes, of actual memory used. 00104 * 00105 * @retval NRF_SUCCESS Operation success. Length was set. 00106 */ 00107 uint32_t hci_mem_pool_rx_data_size_set(uint32_t length); 00108 00109 /**@brief Function for extracting a packet, which has been filled with read data, for further 00110 * processing. 00111 * 00112 * @param[out] pp_buffer Pointer to the packet data. 00113 * @param[out] p_length Length of packet data in bytes. 00114 * 00115 * @retval NRF_SUCCESS Operation success. 00116 * @retval NRF_ERROR_NO_MEM Operation failure. No packet available to extract. 00117 * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. 00118 */ 00119 uint32_t hci_mem_pool_rx_extract(uint8_t ** pp_buffer, uint32_t * p_length); 00120 00121 /**@brief Function for freeing previously extracted packet, which has been filled with read data. 00122 * 00123 * @param[in] p_buffer Pointer to consumed buffer. 00124 * 00125 * @retval NRF_SUCCESS Operation success. 00126 * @retval NRF_ERROR_NO_MEM Operation failure. No packet available to free. 00127 * @retval NRF_ERROR_INVALID_ADDR Operation failure. Not a valid pointer. 00128 */ 00129 uint32_t hci_mem_pool_rx_consume(uint8_t * p_buffer); 00130 00131 #endif // HCI_MEM_POOL_H__ 00132 00133 /** @} */
Generated on Tue Jul 12 2022 16:36:22 by 1.7.2