Infineon Logo AIROC BTSDK v4.6 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
KeyscanQueue

Data Structures

struct  KeyscanQueueState
 Keyscan circular event queue state. More...
 

Typedefs

struct {
   BYTE   keyCode
 Key code. More...
 
   BYTE   reserved: 6
 Reserved bits.
 
   BYTE   upDownFlag: 1
 Up/down flag.
 
   BYTE   scanCycleFlag: 1
 Should be toggled for every scan cycle in which a new event is queued. More...
 
KeyEvent
 Definition of a key event.
 

Enumerations

enum  { KEY_DOWN = 0x0, KEY_UP = 0x1 }
 Defines a keyscan driver. More...
 
enum  { ROLLOVER = 0xff, END_OF_SCAN_CYCLE = 0xfe }
 Special event codes used internally by the driver. More...
 
enum  { MIA_KEY_EVENT_FIFO_SIZE = 20, KEYSCAN_FW_FIFO_SIZE = (2*MIA_KEY_EVENT_FIFO_SIZE + 6) }
 Keyscan driver constants. More...
 

Functions

void ksq_init (void *buffer, BYTE elementSize, BYTE maxElements)
 Initialize the keyscan queue. More...
 
void ksq_flush (void)
 Flush all elements from the keyscan queue.
 
BYTE ksq_getCurNumElements (void)
 Get the number of elements currently in the queue. More...
 
BOOL32 ksq_putExcludeOverflowSlot (void *elm, BYTE len)
 Add the given element (by copying into) to the queue, leaving one slot for an overflow indicator. More...
 
BOOL32 ksq_putIncludeOverflowSlot (void *elm, BYTE len)
 Add the given element (by copying into) to the queue. More...
 
void * ksq_getCurElmPtr (void)
 Get element at the front of the queue. More...
 
void ksq_removeCurElement (void)
 Remove the element at the front of the queue.
 
BOOL32 ksq_put (void *elm, BYTE len)
 Puts an element into the queue. More...
 
void ksq_markCurrentEventForRollBack (void)
 Mark current events to save them when an atomic add is required. More...
 
void ksq_rollbackUptoMarkedEvents (void)
 Rollback to marked item on error when using atomic adds.
 
void ksq_putEvent (KeyEvent *event)
 Put a key event into the keyscan data queue. More...
 
void ksq_getEvent (KeyEvent *event)
 Copy over the keyscan event at the front of the queue and delete from the queue. More...
 
INLINE BOOLEAN ksq_isEmpty (void)
 Check if the KeyscanQueue is empty. More...
 

Detailed Description

Enumeration Type Documentation

anonymous enum

Defines a keyscan driver.

The keyscan interface is practically defined as a queue from the consumer's perspective. Key up/down events are seen as a stream coming from the driver. In addition the interface provides the user with the ability to reset the HW as well as turn keyscanning on/off.Up/down flag

anonymous enum

Special event codes used internally by the driver.

Enumerator
ROLLOVER 

Rollover event generated by the keyscan driver in case of an error (ghost or overflow)

END_OF_SCAN_CYCLE 

Event returned to indicate the end of a scan cycle.

anonymous enum

Keyscan driver constants.

Enumerator
MIA_KEY_EVENT_FIFO_SIZE 

Mia keyevent HW FIFO size.

KEYSCAN_FW_FIFO_SIZE 

keyscan FW FIFO size. This FIFO is implemented with KeyscanQueue.

Function Documentation

void* ksq_getCurElmPtr ( void  )

Get element at the front of the queue.

Returns
Pointer to the element at the front of the queue.
BYTE ksq_getCurNumElements ( void  )

Get the number of elements currently in the queue.

Returns
The number of elements in the queue.
void ksq_getEvent ( KeyEvent event)

Copy over the keyscan event at the front of the queue and delete from the queue.

Parameters
eventThe buffer into which to copy the event at the head.
void ksq_init ( void *  buffer,
BYTE  elementSize,
BYTE  maxElements 
)

Initialize the keyscan queue.

Parameters
bufferPointer to a permanently allocated buffer that will be used as the storage area for the circular queue. Use cfa_mm_Sbrk() to allocate in app create.
elementSizeThe max size of each element in the allocated keyscan queue.
maxElementsThe maximum number of elements that can fit in the allocated queue.
INLINE BOOLEAN ksq_isEmpty ( void  )

Check if the KeyscanQueue is empty.

Returns
0 if there are elements in the queue; else !0.
void ksq_markCurrentEventForRollBack ( void  )

Mark current events to save them when an atomic add is required.

This is useful for rolling back what we added in case we encounter errors.

BOOL32 ksq_put ( void *  elm,
BYTE  len 
)

Puts an element into the queue.

Does not perform any bound checking.

Parameters
elmpointer to the element.
lennumber of bytes in element. This number of bytes is copied into the internal storage of the queue. This must be <= the maximum element size specified when the queue was initialized, otherwise the results are undefined.
void ksq_putEvent ( KeyEvent event)

Put a key event into the keyscan data queue.

Parameters
eventPointer to the event that is to be added to the end of the queue.
BOOL32 ksq_putExcludeOverflowSlot ( void *  elm,
BYTE  len 
)

Add the given element (by copying into) to the queue, leaving one slot for an overflow indicator.

Parameters
elmPointer to the buffer that contains the data to be added to the queue.
lenLength of the element being added (can be < max size).
Returns
TRUE if successful; FALSE if there is space for only 1 element in the queue (ele will not be added).
BOOL32 ksq_putIncludeOverflowSlot ( void *  elm,
BYTE  len 
)

Add the given element (by copying into) to the queue.

Parameters
elmPointer to the buffer that contains the data to be added to the queue.
lenLength of the element being added (can be < max size).
Returns
TRUE if successful; FALSE there is no space left.