![](/media/cache/profiles/1b8833c58d3a24b62eb45027f94d093e.jpg.50x50_q85.jpg)
Knight Rider PIO sample for teckBASIC, konashi.js
Dependencies: BLE_API_Native_IRC mbed
Fork of BLE_konashi_PIO_test 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 "nordic_global.h" 00028 #include "nrf_error.h" 00029 00030 /**@brief A FIFO instance structure. Keeps track of which bytes to read and write next. 00031 * Also it keeps the information about which memory is allocated for the buffer 00032 * and its size. This needs to be initialized by app_fifo_init() before use. 00033 */ 00034 typedef struct 00035 { 00036 uint8_t * p_buf; /**< Pointer to FIFO buffer memory. */ 00037 uint16_t buf_size_mask; /**< Read/write index mask. Also used for size checking. */ 00038 volatile uint32_t read_pos; /**< Next read position in the FIFO buffer. */ 00039 volatile uint32_t write_pos; /**< Next write position in the FIFO buffer. */ 00040 } app_fifo_t; 00041 00042 /**@brief Function for initializing the FIFO. 00043 * 00044 * @param[out] p_fifo FIFO object. 00045 * @param[in] p_buf FIFO buffer for storing data. The buffer size has to be a power of two. 00046 * @param[in] buf_size Size of the FIFO buffer provided, has to be a power of 2. 00047 * 00048 * @retval NRF_SUCCESS If initialization was successful. 00049 * @retval NRF_ERROR_NULL If a NULL pointer is provided as buffer. 00050 * @retval NRF_ERROR_INVALID_LENGTH If size of buffer provided is not a power of two. 00051 */ 00052 uint32_t app_fifo_init(app_fifo_t * p_fifo, uint8_t * p_buf, uint16_t buf_size); 00053 00054 /**@brief Function for adding an element to the FIFO. 00055 * 00056 * @param[in] p_fifo Pointer to the FIFO. 00057 * @param[in] byte Data byte to add to the FIFO. 00058 * 00059 * @retval NRF_SUCCESS If an element has been successfully added to the FIFO. 00060 * @retval NRF_ERROR_NO_MEM If the FIFO is full. 00061 */ 00062 uint32_t app_fifo_put(app_fifo_t * p_fifo, uint8_t byte); 00063 00064 /**@brief Function for getting the next element from the FIFO. 00065 * 00066 * @param[in] p_fifo Pointer to the FIFO. 00067 * @param[out] p_byte Byte fetched from the FIFO. 00068 * 00069 * @retval NRF_SUCCESS If an element was returned. 00070 * @retval NRF_ERROR_NOT_FOUND If there is no more elements in the queue. 00071 */ 00072 uint32_t app_fifo_get(app_fifo_t * p_fifo, uint8_t * p_byte); 00073 00074 /**@brief Function for flushing the FIFO. 00075 * 00076 * @param[in] p_fifo Pointer to the FIFO. 00077 * 00078 * @retval NRF_SUCCESS If the FIFO flushed successfully. 00079 */ 00080 uint32_t app_fifo_flush(app_fifo_t * p_fifo); 00081 00082 #endif // APP_FIFO_H__ 00083 00084 /** @} */
Generated on Tue Jul 12 2022 16:55:06 by
![doxygen](doxygen.png)