BeRTOS
Defines | Enumerations | Functions | Variables
kbd.c File Reference

Keyboard driver (implementation) More...

#include "hw/hw_kbd.h"
#include "cfg/cfg_kbd.h"
#include <cfg/debug.h>
#include <cfg/module.h>
#include <drv/timer.h>
#include <mware/event.h>
#include <drv/kbd.h>

Go to the source code of this file.

Defines

#define KBD_CHECK_INTERVAL   10
 (ms) Timing for kbd softint
#define KBD_DEBOUNCE_TIME   30
 (ms) Debounce time
#define KBD_BEEP_TIME   5
 (ms) Duration of keybeep
#define KBD_REPEAT_DELAY   400
 (ms) Keyboard repeat delay for first character
#define KBD_REPEAT_RATE   100
 (ms) Initial interchar delay for keyboard repeat
#define KBD_REPEAT_MAXRATE   20
 (ms) Minimum delay for keyboard repeat
#define KBD_REPEAT_ACCEL   5
 (ms) Keyboard repeat speed increase
#define KBD_LNG_DELAY   1000
 (ms) Keyboard long pression keys delay

Enumerations

enum  
 Status for keyboard repeat state machine.

Functions

static void kbd_poll (void)
 Poll keyboard and dispatch keys to handlers.
static void kbd_softint (UNUSED_ARG(iptr_t, arg))
 Keyboard soft-irq handler.
keymask_t kbd_peek (void)
 Read a key from the keyboard buffer.
keymask_t kbd_get (void)
 Wait for a keypress and return the mask of depressed keys.
keymask_t kbd_get_timeout (mtime_t timeout)
 Wait up to timeout ms for a keypress and return the mask of depressed keys, or K_TIMEOUT if the timeout was reacked.
static keymask_t kbd_defHandlerFunc (keymask_t key)
 This is the default key handler, called after all other handlers have had their chance to do their special processing.
static keymask_t kbd_debHandlerFunc (keymask_t key)
 Handle keyboard debounce.
keymask_t kbd_setRepeatMask (keymask_t mask)
 Set current mask of repeatable keys.
static keymask_t kbd_rptHandlerFunc (keymask_t key)
 Handle keyboard repeat.
void kbd_init (void)
 Initialize keyboard ports and softtimer.

Variables

static Event key_pressed
 Used to notify the occurrence of a key pressed event.
static volatile keymask_t kbd_buf
 Single entry keyboard buffer.
static volatile keymask_t kbd_cnt
 Number of keypress events in kbd_buf.
static keymask_t kbd_rpt_mask
 Mask of repeatable keys.
static Timer kbd_timer
 Keyboard softtimer.
static List kbd_rawHandlers
 Raw keyboard handlers.
static List kbd_handlers
 Cooked keyboard handlers.
static KbdHandler kbd_defHandler
 The default keyboard handler.
static KbdHandler kbd_debHandler
 The debounce keyboard handler.
static KbdHandler kbd_rptHandler
 Auto-repeat keyboard handler.

Detailed Description

Keyboard driver (implementation)

Author:
Bernie Innocenti <bernie@codewiz.org>
Stefano Fedrigo <aleph@develer.com>
Francesco Sacchi <batt@develer.com>

Definition in file kbd.c.


Function Documentation

static keymask_t kbd_debHandlerFunc ( keymask_t  key) [static]

Handle keyboard debounce.

Buffer for debounce

Timer for keyboard debounce

Key aquired after debounce

Definition at line 303 of file kbd.c.

static keymask_t kbd_defHandlerFunc ( keymask_t  key) [static]

This is the default key handler, called after all other handlers have had their chance to do their special processing.

This handler pushes all input in the keyboard FIFO buffer.

Definition at line 275 of file kbd.c.

static void kbd_poll ( void  ) [static]

Poll keyboard and dispatch keys to handlers.

Read the key states and invoke all keyboard handlers to process the new state.

Call this function periodically using a software timer, an interrupt or a process.

Currently depressed key

Definition at line 124 of file kbd.c.

static keymask_t kbd_rptHandlerFunc ( keymask_t  key) [static]

Handle keyboard repeat.

Current repeat rate (for acceleration)

Definition at line 366 of file kbd.c.


Variable Documentation

Mask of repeatable keys.

Definition at line 92 of file kbd.c.