Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MODSERIAL Terminal mbed
TinyQueue.h@3:b8bad606d4f2, 2012-08-02 (annotated)
- Committer:
- cbayley
- Date:
- Thu Aug 02 21:23:04 2012 +0000
- Revision:
- 3:b8bad606d4f2
- Parent:
- STQ_TinyQueue.h@2:60e6df8211f2
Version 2.6; Got buffering right - none on input and plenty on output. bytes are fed into 'Stripes' on input interrupts and Stripes are queued for output.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cbayley | 2:60e6df8211f2 | 1 | #ifndef TINYQ_H |
cbayley | 2:60e6df8211f2 | 2 | #define TINYQ_H |
cbayley | 2:60e6df8211f2 | 3 | |
cbayley | 2:60e6df8211f2 | 4 | /** \defgroup tinyQ Tiny Queue |
cbayley | 2:60e6df8211f2 | 5 | * Tiny Queues implements a 4 byte queue for iPhone events with just 1 byte of management overhead. |
cbayley | 2:60e6df8211f2 | 6 | * Head and Tail pointers both inherently wrap at the end of the buffer and no bounds checking is |
cbayley | 2:60e6df8211f2 | 7 | * necesary IFF the buffer size is set as a power of 2 equal to the width of the pointers !! |
cbayley | 2:60e6df8211f2 | 8 | * i.e head is 2 bits wide so the buffer must be 2^2 = 4 bytes deep. |
cbayley | 2:60e6df8211f2 | 9 | * @{ |
cbayley | 2:60e6df8211f2 | 10 | */ |
cbayley | 2:60e6df8211f2 | 11 | /** NOTE: Q_SIZE MUST be == 2 ^ widthof( tinyQ_t.head ) */ |
cbayley | 3:b8bad606d4f2 | 12 | #define Q_SIZE 256 |
cbayley | 2:60e6df8211f2 | 13 | |
cbayley | 2:60e6df8211f2 | 14 | /** a tinyQ tracks a 8 * queue with just 1 byte overhead */ |
cbayley | 2:60e6df8211f2 | 15 | typedef struct |
cbayley | 2:60e6df8211f2 | 16 | { |
cbayley | 3:b8bad606d4f2 | 17 | unsigned char head:8; ///< the bit depth MUST be that power of 2 that is the Q_SIZE |
cbayley | 3:b8bad606d4f2 | 18 | unsigned char tail:8; ///< the bit depth MUST be that power of 2 that is the Q_SIZE |
cbayley | 3:b8bad606d4f2 | 19 | unsigned char fill:9; ///< Must be 1 bit bigger than the head and tail pointers |
cbayley | 2:60e6df8211f2 | 20 | void* data[Q_SIZE]; ///< NOTE: Q_SIZE MUST be == 2 ^ widthof( tinyQ_t.head ) |
cbayley | 2:60e6df8211f2 | 21 | }tinyQ_t; |
cbayley | 2:60e6df8211f2 | 22 | |
cbayley | 2:60e6df8211f2 | 23 | |
cbayley | 2:60e6df8211f2 | 24 | /** |
cbayley | 2:60e6df8211f2 | 25 | * \brief Push an Accessibility Event onto our queue for sending to the iphone |
cbayley | 2:60e6df8211f2 | 26 | * \param q pointer to our tinyQ_t |
cbayley | 2:60e6df8211f2 | 27 | * \param c the Event to send to the iphone |
cbayley | 2:60e6df8211f2 | 28 | * \return null if Q full, 1 on success |
cbayley | 2:60e6df8211f2 | 29 | * \sa Qpop(), Qjump() |
cbayley | 2:60e6df8211f2 | 30 | * \ingroup tinyQ |
cbayley | 2:60e6df8211f2 | 31 | */ |
cbayley | 2:60e6df8211f2 | 32 | int Qpush( tinyQ_t* q, void* p ); |
cbayley | 2:60e6df8211f2 | 33 | |
cbayley | 2:60e6df8211f2 | 34 | /** |
cbayley | 2:60e6df8211f2 | 35 | * \brief Push an Accessibility Event onto front of our queue for sending to the iphone |
cbayley | 2:60e6df8211f2 | 36 | * \param q pointer to our tinyQ_t |
cbayley | 2:60e6df8211f2 | 37 | * \param c the Event to send to the iphone |
cbayley | 2:60e6df8211f2 | 38 | * \return null if Q full, 1 on success |
cbayley | 2:60e6df8211f2 | 39 | * \sa Qpush(), Qpop() |
cbayley | 2:60e6df8211f2 | 40 | * \ingroup tinyQ |
cbayley | 2:60e6df8211f2 | 41 | */ |
cbayley | 2:60e6df8211f2 | 42 | int Qjump( tinyQ_t* q, void* p ); |
cbayley | 2:60e6df8211f2 | 43 | |
cbayley | 2:60e6df8211f2 | 44 | /** |
cbayley | 2:60e6df8211f2 | 45 | * \brief Pop an Accessibility Event off our queue for sending to the iphone |
cbayley | 2:60e6df8211f2 | 46 | * \param q pointer to our tinyQ_t |
cbayley | 2:60e6df8211f2 | 47 | * \param c pointer to receive the Event |
cbayley | 2:60e6df8211f2 | 48 | * \return null if Q empty, 1 on success |
cbayley | 2:60e6df8211f2 | 49 | * \sa Qpop(), Qjump() |
cbayley | 2:60e6df8211f2 | 50 | * \ingroup tinyQ |
cbayley | 2:60e6df8211f2 | 51 | */ |
cbayley | 2:60e6df8211f2 | 52 | int Qpop( tinyQ_t* q, void ** p); |
cbayley | 2:60e6df8211f2 | 53 | |
cbayley | 2:60e6df8211f2 | 54 | #endif |