Chris BAYLEY / Mbed 2 deprecated UARTSnoop

Dependencies:   MODSERIAL Terminal mbed

Committer:
cbayley
Date:
Wed Aug 01 02:17:00 2012 +0000
Revision:
2:60e6df8211f2
Version 2.5 sped up HEXDUMP style

Who changed what in which revision?

UserRevisionLine numberNew 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 2:60e6df8211f2 12 #define Q_SIZE 8
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 2:60e6df8211f2 17 unsigned char head:3; ///< the bit depth MUST be that power of 2 that is the Q_SIZE
cbayley 2:60e6df8211f2 18 unsigned char tail:3; ///< the bit depth MUST be that power of 2 that is the Q_SIZE
cbayley 2:60e6df8211f2 19 unsigned char fill:4; ///< 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