Infineon Logo AIROC BTSDK v4.6 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
keyscan.h File Reference

Define functions to access Keyscan driver. More...

Data Structures

struct  KeyscanQueueState
 Keyscan circular event queue state. More...
 
struct  KeyscanRegistration
 Keyscan event notification registration structure. Internal. More...
 
struct  KeyscanState
 Keyscan driver 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.
 
typedef struct KeyscanRegistration KeyscanRegistration
 Keyscan event notification registration structure. Internal.
 

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...
 
enum  { EVENT_NONE = 0xfd }
 Defines the standard keyscan driver. More...
 
enum  {
  HW_CTRL_SCAN_CTRL_MASK = 0x00001, HW_CTRL_GHOST_DETECT_MASK = 0x00004, HW_CTRL_INTERRUPT_CTRL_MASK = 0x00008, HW_CTRL_RESET_MASK = 0x00010,
  HW_CTRL_RC_EXT_MASK = 0x000C0, HW_CTRL_ROW_MASK = 0x00700, HW_CTRL_COL_MASK = 0x0F800, HW_CTRL_COL_DRIVE_CTRL_MASK = 0x10000,
  HW_CTRL_ROW_DRIVE_CTRL_MASK = 0x20000, HW_CTRL_SCAN_ENABLE = 0x00001, HW_CTRL_GHOST_ENABLE = 0x00004, HW_CTRL_KS_INTERRUPT_ENABLE = 0x00008,
  HW_CTRL_RESET_ENABLE = 0x00010, HW_CTRL_CLK_ALWAYS_ON = 0x40000, HW_CTRL_RC_DEFAULT = 0x000C0, HW_CTRL_ROW_SHIFT = 8,
  HW_CTRL_COL_SHIFT = 11, HW_CTRL_COL_ACTIVE_DRIVE = 0x10000, HW_CTRL_ROW_ACTIVE_DRIVE = 0x20000, HW_CTRL_SCAN_DISABLE = 0x00000,
  HW_CTRL_GHOST_DISABLE = 0x00000, HW_CTRL_INTERRUPT_DISABLE = 0x00000, HW_CTRL_RESET_DISABLE = 0x00000, HW_CTRL_CLK_AUTO_CTRL = 0x00000,
  HW_CTRL_COLUMN_PASSIVE_DRIVE = 0x00000, HW_CTRL_ROW_PASSIVE_DRIVE = 0x00000
}
 Internal HW control and status bits.
 
enum  { HW_MIA_STATUS_KEYSCAN_INT_SET_MASK = 0x00040 }
 Keyscan interrupt mask. Internal.
 
enum  { HW_LHL_CTRL_CLR_KEYS = 0x0002, HW_LHL_STATUS_GHOST = 0x0008, HW_LHL_STATUS_KEY_FIFO_OVERFLOW = 0x0004, HW_LHL_STATUS_KEYCODE = 0x0002 }
 Keyscan HW status bits. Internal.
 
enum  {
  HW_KEYCODE_MASK = 0x000000ff, HW_SCAN_CYCLE_MASK = 0x40000000, HW_KEY_UP_DOWN_MASK = (int)0x80000000, HW_KEYCODE_SHIFT_COUNT = 0,
  HW_SCAN_CYCLE_SHIFT_COUNT = 30, HW_KEY_UP_DOWN_SHIFT_COUNT = 31, HW_KEYCODE_GHOST = 0xf5, HW_KEYCODE_INIT = 0xff,
  HW_KEY_UP = (int)0x80000000, HW_KEY_DOWN = 0x00000000
}
 Keyscan configuration and status bits.
 
enum  { CH_SEL_KEYSCAN_ROW_INPUT_50_57 = 0x0000, CH_SEL_KEYSCAN_ROW_INPUT_16_23 = 0x0001 }
 

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...
 
void keyscan_init (void)
 Keyscan driver initialization function. More...
 
void keyscan_reset (void)
 Reset the keyscan HW. Any existing events will be thrown away.
 
BOOL32 keyscan_eventsPending (void)
 Check if there are any pending key events. More...
 
BOOL32 keyscan_getNextEvent (KeyEvent *event)
 Get next key event. More...
 
void keyscan_turnOff (void)
 Disables keyscanning and and any associated wakeup.
 
void keyscan_turnOn (void)
 Enabled keyscanning and and any associated wakeup functionality. More...
 
void keyscan_registerForEventNotification (void(*userfn)(void *), void *userdata)
 Register for notification of changes. More...
 
void keyscan_enableEventDetection (void)
 Configures the interrupt source from Keyscan HW and enables event detection. More...
 
void keyscan_flushHwEvents (void)
 Clears the keys in the HW queue.
 
void keyscan_miaFreezeCallBack (void)
 MIA clock freeze notification. More...
 
void keyscan_miaUnfreezeCallBack (void)
 MIA clock unfreeze notification. Internal.
 
void keyscan_enableInterrupt (void)
 Enables the interrupts from Keyscan HW. More...
 
void keyscan_disableInterrupt (void)
 Disables interrupts from the keyscan HW block.
 
void keyscan_ksInterrupt (void)
 Thread context interrupt handler. Internal.
 
void keyscan_restoreActivity (void)
 Reenables keyscan after a soft power up. Internal.
 
void keyscan_clearKeysPressedCount (void)
 Clear the count of unmatched key down events. Internal.
 
UINT8 keyscan_getKeysPressedCount (void)
 Get count of unmatched key down events.
 
void keyscan_enableGhostDetection (BOOL32 enable)
 Enable/disable keyscan ghost detection.
 
void keyscan_hwResetOnce (void)
 Soft Reset the keyscan HW once.
 
void keyscan_initHW (void)
 Initialize the keyscan HE. Internal.
 
void keyscan_configGpios (void)
 Configure the GPIOs used by the keyscan HW based on keyscan config.
 
void keyscan_getEventsFromHWFifo (void)
 Retrieve events from the HW fifo and places them in the FW fifo. More...
 

Detailed Description

Define functions to access Keyscan driver.

Variable Documentation

BYTE keyCode

Key code.

This is the location in the keyscan matrix that is pressed/released. May be implemented as ((row * numCols) + col) or ((col * numRows) + row.

BYTE scanCycleFlag

Should be toggled for every scan cycle in which a new event is queued.

Use of this flag is optional. If used, it allows the consumer to determine whether an event is detected in the same scan cycle as the previous event or a different one. Note that this flag does not indicate any separation in time.