Nordic stack and drivers for the mbed BLE API Modified for HRM1017 for library 0.1.0
Fork of nRF51822 by
app_fifo.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 app_fifo FIFO implementation 00016 * @{ 00017 * @ingroup app_common 00018 * 00019 * @brief FIFO implementation. 00020 */ 00021 00022 #ifndef APP_FIFO_H__ 00023 #define APP_FIFO_H__ 00024 00025 #include <stdint.h> 00026 #include <stdlib.h> 00027 #include "nrf_error.h" 00028 00029 /**@brief A FIFO instance structure. Keeps track of which bytes to read and write next. 00030 * Also it keeps the information about which memory is allocated for the buffer 00031 * and its size. This needs to be initialized by app_fifo_init() before use. 00032 */ 00033 typedef struct 00034 { 00035 uint8_t * p_buf; /**< Pointer to FIFO buffer memory. */ 00036 uint16_t buf_size_mask; /**< Read/write index mask. Also used for size checking. */ 00037 volatile uint32_t read_pos; /**< Next read position in the FIFO buffer. */ 00038 volatile uint32_t write_pos; /**< Next write position in the FIFO buffer. */ 00039 } app_fifo_t; 00040 00041 /**@brief Function for initializing the FIFO. 00042 * 00043 * @param[out] p_fifo FIFO object. 00044 * @param[in] p_buf FIFO buffer for storing data. The buffer size has to be a power of two. 00045 * @param[in] buf_size Size of the FIFO buffer provided, has to be a power of 2. 00046 * 00047 * @retval NRF_SUCCESS If initialization was successful. 00048 * @retval NRF_ERROR_NULL If a NULL pointer is provided as buffer. 00049 * @retval NRF_ERROR_INVALID_LENGTH If size of buffer provided is not a power of two. 00050 */ 00051 uint32_t app_fifo_init(app_fifo_t * p_fifo, uint8_t * p_buf, uint16_t buf_size); 00052 00053 /**@brief Function for adding an element to the FIFO. 00054 * 00055 * @param[in] p_fifo Pointer to the FIFO. 00056 * @param[in] byte Data byte to add to the FIFO. 00057 * 00058 * @retval NRF_SUCCESS If an element has been successfully added to the FIFO. 00059 * @retval NRF_ERROR_NO_MEM If the FIFO is full. 00060 */ 00061 uint32_t app_fifo_put(app_fifo_t * p_fifo, uint8_t byte); 00062 00063 /**@brief Function for getting the next element from the FIFO. 00064 * 00065 * @param[in] p_fifo Pointer to the FIFO. 00066 * @param[out] p_byte Byte fetched from the FIFO. 00067 * 00068 * @retval NRF_SUCCESS If an element was returned. 00069 * @retval NRF_ERROR_NOT_FOUND If there is no more elements in the queue. 00070 */ 00071 uint32_t app_fifo_get(app_fifo_t * p_fifo, uint8_t * p_byte); 00072 00073 /**@brief Function for flushing the FIFO. 00074 * 00075 * @param[in] p_fifo Pointer to the FIFO. 00076 * 00077 * @retval NRF_SUCCESS If the FIFO flushed successfully. 00078 */ 00079 uint32_t app_fifo_flush(app_fifo_t * p_fifo); 00080 00081 #endif // APP_FIFO_H__ 00082 00083 /** @} */
Generated on Tue Jul 12 2022 14:11:53 by 1.7.2