diff --git a/Doxyfile b/Doxyfile index a75bea1..f466027 100755 --- a/Doxyfile +++ b/Doxyfile @@ -746,7 +746,7 @@ WARN_IF_DOC_ERROR = YES # parameter documentation, but not about the absence of documentation. # The default value is: NO. -WARN_NO_PARAMDOC = YES +WARN_NO_PARAMDOC = NO # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when # a warning is encountered. @@ -2010,7 +2010,7 @@ ENABLE_PREPROCESSING = YES # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -WARN_NO_PARAMDOC = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then # the macro expansion is limited to the macros specified with the PREDEFINED and @@ -2018,7 +2018,7 @@ WARN_NO_PARAMDOC = NO # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES, the include files in the # INCLUDE_PATH will be searched if a #include is found. @@ -2061,7 +2061,7 @@ PREDEFINED = ARDUINO=10506 \ # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = __attribute__(x) # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have diff --git a/Doxyfile.auto b/Doxyfile.auto index e786f5c..b51d6a0 100755 --- a/Doxyfile.auto +++ b/Doxyfile.auto @@ -746,7 +746,7 @@ WARN_IF_DOC_ERROR = YES # parameter documentation, but not about the absence of documentation. # The default value is: NO. -WARN_NO_PARAMDOC = YES +WARN_NO_PARAMDOC = NO # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when # a warning is encountered. @@ -2010,7 +2010,7 @@ ENABLE_PREPROCESSING = YES # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -WARN_NO_PARAMDOC = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then # the macro expansion is limited to the macros specified with the PREDEFINED and @@ -2018,7 +2018,7 @@ WARN_NO_PARAMDOC = NO # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES, the include files in the # INCLUDE_PATH will be searched if a #include is found. @@ -2061,7 +2061,7 @@ PREDEFINED = ARDUINO=10506 \ # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = __attribute__(x) # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have diff --git a/README.md b/README.md index 58ad029..7fb9620 100755 --- a/README.md +++ b/README.md @@ -31,12 +31,14 @@ Port of Queue has been made to work with STM32 code written in plain c. - `q_isEmpty(Queue_t * q)`: `true` if full, `false` otherwise - `q_isFull(Queue_t * q)`: `true` if empty, `false` otherwise - `q_sizeof(Queue_t * q)`: queue size in bytes (returns 0 in case queue allocation failed) - - `q_getCount(Queue_t * q)` or `q_nbRecs(Queue_t * q)`: number of records in the queue + - `q_getCount(Queue_t * q)` or `q_nbRecs(Queue_t * q)`: number of records stored in the queue + - `q_getRemainingCount(Queue_t * q)`: number of records left in the queue - `q_clean(Queue_t * q)` or `q_flush(Queue_t * q)`: remove all items in the queue ## Examples included - [SimpleQueue.ino](examples/SimpleQueue/SimpleQueue.ino): Simple queue example (both LIFO FIFO implementations can be tested) +- [PointersQueue.ino](examples/PointersQueue/PointersQueue.ino): Queue of function pointers performing queued actions - [RolloverTest.ino](examples/RolloverTest/RolloverTest.ino): Simple test to test queue rollover (for lib testing purposes mainly) - [LibTst.ino](examples/LibTst/LibTst.ino): flexible test (for lib testing purposes mainly) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 99f3810..4218b6c 100755 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -10,9 +10,12 @@ Feel free to share your thoughts @ xgarmanboziax@gmail.com about: ** Actual: -v1.4 3 May 2018: +v1.4 26 May 2018: +- Added q_sizeOf inline to check full queue size in byte (may also be used to check if queue has been allocated properly) +- Added q_getRemainingCount inline returning how much records are left in the queue - Adding support for unit tests and doxygen documentation generation with Travis CI - Updated README.md +- Added more example sketches & updated LibTst example using latest inlines additions v1.3 14 March 2018: - Init control value set back to 0 when queue is killed (prevents failure if killing twice the same queue) diff --git a/cQueue_v1_3.pdf b/cQueue_v1_3.pdf deleted file mode 100755 index 863b3f8..0000000 Binary files a/cQueue_v1_3.pdf and /dev/null differ diff --git a/cQueue_v1_4.pdf b/cQueue_v1_4.pdf new file mode 100755 index 0000000..b9a8f53 Binary files /dev/null and b/cQueue_v1_4.pdf differ diff --git a/examples/LibTst/LibTst.ino b/examples/LibTst/LibTst.ino index 21e1338..675ef83 100755 --- a/examples/LibTst/LibTst.ino +++ b/examples/LibTst/LibTst.ino @@ -6,7 +6,7 @@ This example code is in the public domain. created 14 July 2017 - modified 21 May 2018 + modified 26 May 2018 by SMFSW */ @@ -60,6 +60,8 @@ void loop() { Serial.print(rec.entry2, HEX); Serial.print(" Count "); Serial.print(q_getCount(&q)); + Serial.print(" Remaining "); + Serial.print(q_getRemainingCount(&q)); Serial.print(" Full? "); Serial.println(q_isFull(&q)); } diff --git a/examples/PointersQueue/PointersQueue.ino b/examples/PointersQueue/PointersQueue.ino new file mode 100755 index 0000000..74e63e7 --- /dev/null +++ b/examples/PointersQueue/PointersQueue.ino @@ -0,0 +1,70 @@ +/* + Pointers Queue + Pointers queue demonstration + + This example code is in the public domain. + + created 26 May 2018 + by SMFSW + */ + +#include + +typedef void (* f_act)(int *); //!< Function pointer typedef for easier use + + +Queue_t q; // Queue declaration + +void action1(int * v) { *v+=2; Serial.print("Action 1 Called (+2), val="); Serial.println(*v); } +void action2(int * v) { *v*=2; Serial.print("Action 2 Called (*2), val="); Serial.println(*v); } +void action3(int * v) { *v-=1; Serial.print("Action 3 Called (-1), val="); Serial.println(*v); } + +int val = 8; // Value passed to function pointer for processing + + +// the setup function runs once when you press reset or power the board +void setup() { + Serial.begin(115200); + + q_init(&q, sizeof(f_act), 5, FIFO, false); + + for (unsigned int i = 0 ; i < 5 ; i++) + { + f_act Act = 0; + + switch (i) + { + case 0: + Act = action1; + break; + case 1: + Act = action2; + break; + case 2: + Act = action3; + break; + case 3: + Act = action2; + break; + case 4: + Act = action1; + break; + } + + q_push(&q, &Act); + } +} + +// the loop function runs over and over again forever +void loop() { + Serial.print("Value before processing = "); + Serial.println(val); + for (unsigned int i = 0 ; i < 5 ; i++) + { + f_act Act = 0; + q_pop(&q, &Act); + Act(&val); + } + + while(1); +} diff --git a/keywords.txt b/keywords.txt index 196be05..15f8101 100755 --- a/keywords.txt +++ b/keywords.txt @@ -20,6 +20,7 @@ q_isFull KEYWORD2 q_sizeof KEYWORD2 q_getCount KEYWORD2 q_nbRecs KEYWORD2 +q_getRemainingCount KEYWORD2 q_push KEYWORD2 q_pop KEYWORD2 q_pull KEYWORD2 diff --git a/library.properties b/library.properties index 707758d..f5c7b0c 100755 --- a/library.properties +++ b/library.properties @@ -3,7 +3,7 @@ version=1.4 author=SMFSW maintainer=SMFSW sentence=Queue handling library (written in plain c) -paragraph=Queue handling library (written in plain c). May be compiled without change with gcc for other purporses/targets +paragraph=May be compiled without change with gcc for other purporses/targets category=Data Storage url=/~https://github.com/SMFSW/cQueue architectures=* diff --git a/src/cQueue.c b/src/cQueue.c index e72454e..82f9f6c 100755 --- a/src/cQueue.c +++ b/src/cQueue.c @@ -1,6 +1,6 @@ /*!\file cQueue.c ** \author SMFSW -** \date 2018/05/21 +** \date 2018/05/26 ** \copyright BSD 3-Clause License (c) 2017-2018, SMFSW ** \brief Queue handling library (designed in c on STM32) ** \details Queue handling library (designed in c on STM32) diff --git a/src/cQueue.h b/src/cQueue.h index 477bdc6..c3ae490 100755 --- a/src/cQueue.h +++ b/src/cQueue.h @@ -1,6 +1,6 @@ /*!\file cQueue.h ** \author SMFSW -** \date 2018/05/21 +** \date 2018/05/26 ** \copyright BSD 3-Clause License (c) 2017-2018, SMFSW ** \brief Queue handling library (designed in c on STM32) ** \details Queue handling library (designed in c on STM32) @@ -111,11 +111,18 @@ inline uint32_t __attribute__((always_inline)) q_sizeof(const Queue_t * q) { /*! \brief get number of records in the queue ** \param [in] q - pointer of queue to handle -** \return Number of records left in the queue +** \return Number of records stored in the queue **/ inline uint16_t __attribute__((always_inline)) q_getCount(const Queue_t * q) { return q->cnt; } +/*! \brief get number of records left in the queue +** \param [in] q - pointer of queue to handle +** \return Number of records left in the queue +**/ +inline uint16_t __attribute__((always_inline)) q_getRemainingCount(const Queue_t * q) { + return q->rec_nb - q->cnt; } + /*! \brief Push record to queue ** \warning If using q_push, q_pop, q_peek and/or q_drop in both interrupts and main application, ** you shall disable interrupts in main application when using these functions