https://github.com/j123b567/scpi-parser
Dependents: scpi_sx127x scpi_sx127x_firstTest MLX90418_I2C_master
src/fifo_private.h@1:b497f235115a, 2015-08-07 (annotated)
- Committer:
- dudmuck
- Date:
- Fri Aug 07 21:54:11 2015 +0000
- Revision:
- 1:b497f235115a
update from github commit 6e5e3e0e3fc450eaf53feee059824ad85c4f270d
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dudmuck | 1:b497f235115a | 1 | /*- |
dudmuck | 1:b497f235115a | 2 | * Copyright (c) 2012-2013 Jan Breuer, |
dudmuck | 1:b497f235115a | 3 | * |
dudmuck | 1:b497f235115a | 4 | * All Rights Reserved |
dudmuck | 1:b497f235115a | 5 | * |
dudmuck | 1:b497f235115a | 6 | * Redistribution and use in source and binary forms, with or without |
dudmuck | 1:b497f235115a | 7 | * modification, are permitted provided that the following conditions are |
dudmuck | 1:b497f235115a | 8 | * met: |
dudmuck | 1:b497f235115a | 9 | * 1. Redistributions of source code must retain the above copyright notice, |
dudmuck | 1:b497f235115a | 10 | * this list of conditions and the following disclaimer. |
dudmuck | 1:b497f235115a | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
dudmuck | 1:b497f235115a | 12 | * notice, this list of conditions and the following disclaimer in the |
dudmuck | 1:b497f235115a | 13 | * documentation and/or other materials provided with the distribution. |
dudmuck | 1:b497f235115a | 14 | * |
dudmuck | 1:b497f235115a | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR |
dudmuck | 1:b497f235115a | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
dudmuck | 1:b497f235115a | 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
dudmuck | 1:b497f235115a | 18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE |
dudmuck | 1:b497f235115a | 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
dudmuck | 1:b497f235115a | 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
dudmuck | 1:b497f235115a | 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
dudmuck | 1:b497f235115a | 22 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
dudmuck | 1:b497f235115a | 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
dudmuck | 1:b497f235115a | 24 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
dudmuck | 1:b497f235115a | 25 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
dudmuck | 1:b497f235115a | 26 | */ |
dudmuck | 1:b497f235115a | 27 | |
dudmuck | 1:b497f235115a | 28 | /** |
dudmuck | 1:b497f235115a | 29 | * @file scpi_fifo.h |
dudmuck | 1:b497f235115a | 30 | * @date Thu Nov 15 10:58:45 UTC 2012 |
dudmuck | 1:b497f235115a | 31 | * |
dudmuck | 1:b497f235115a | 32 | * @brief basic FIFO implementation |
dudmuck | 1:b497f235115a | 33 | * |
dudmuck | 1:b497f235115a | 34 | * |
dudmuck | 1:b497f235115a | 35 | */ |
dudmuck | 1:b497f235115a | 36 | |
dudmuck | 1:b497f235115a | 37 | #ifndef SCPI_FIFO_H |
dudmuck | 1:b497f235115a | 38 | #define SCPI_FIFO_H |
dudmuck | 1:b497f235115a | 39 | |
dudmuck | 1:b497f235115a | 40 | #include "scpi/types.h" |
dudmuck | 1:b497f235115a | 41 | #include "utils_private.h" |
dudmuck | 1:b497f235115a | 42 | |
dudmuck | 1:b497f235115a | 43 | #ifdef __cplusplus |
dudmuck | 1:b497f235115a | 44 | extern "C" { |
dudmuck | 1:b497f235115a | 45 | #endif |
dudmuck | 1:b497f235115a | 46 | |
dudmuck | 1:b497f235115a | 47 | |
dudmuck | 1:b497f235115a | 48 | #define FIFO_SIZE 16 |
dudmuck | 1:b497f235115a | 49 | |
dudmuck | 1:b497f235115a | 50 | struct _scpi_fifo_t { |
dudmuck | 1:b497f235115a | 51 | int16_t wr; |
dudmuck | 1:b497f235115a | 52 | int16_t rd; |
dudmuck | 1:b497f235115a | 53 | int16_t size; |
dudmuck | 1:b497f235115a | 54 | int16_t data[FIFO_SIZE]; |
dudmuck | 1:b497f235115a | 55 | }; |
dudmuck | 1:b497f235115a | 56 | typedef struct _scpi_fifo_t scpi_fifo_t; |
dudmuck | 1:b497f235115a | 57 | |
dudmuck | 1:b497f235115a | 58 | void fifo_init(scpi_fifo_t * fifo) LOCAL; |
dudmuck | 1:b497f235115a | 59 | void fifo_clear(scpi_fifo_t * fifo) LOCAL; |
dudmuck | 1:b497f235115a | 60 | scpi_bool_t fifo_add(scpi_fifo_t * fifo, int16_t value) LOCAL; |
dudmuck | 1:b497f235115a | 61 | scpi_bool_t fifo_remove(scpi_fifo_t * fifo, int16_t * value) LOCAL; |
dudmuck | 1:b497f235115a | 62 | scpi_bool_t fifo_count(scpi_fifo_t * fifo, int16_t * value) LOCAL; |
dudmuck | 1:b497f235115a | 63 | |
dudmuck | 1:b497f235115a | 64 | #ifdef __cplusplus |
dudmuck | 1:b497f235115a | 65 | } |
dudmuck | 1:b497f235115a | 66 | #endif |
dudmuck | 1:b497f235115a | 67 | |
dudmuck | 1:b497f235115a | 68 | #endif /* SCPI_FIFO_H */ |