From cceff4e3bb8242efa09d738f3d2895c82c518ef6 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 26 Dec 2012 18:54:59 +0000 Subject: [PATCH] Implement encoding the usbhost HID keyboard driver; configre olimex-lpc1766stk HID keyboard configuration to use the kconfig-frontends tool git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5461 42af7a65-404d-4744-a932-0658087f49c3 --- Documentation/NuttxPortingGuide.html | 148 ++++++++++++++++++++++++++- 1 file changed, 147 insertions(+), 1 deletion(-) diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html index 0408f82ac8..ebb3eff4bf 100644 --- a/Documentation/NuttxPortingGuide.html +++ b/Documentation/NuttxPortingGuide.html @@ -131,7 +131,8 @@ 6.3.12 PWM Drivers
6.3.13 CAN Drivers
6.3.14 Quadrature Encoder Drivers
- 6.3.15 Watchdog Timer Drivers + 6.3.15 Watchdog Timer Drivers
+ 6.3.16 Keyboard/Keypad Drivers
6.4 Power Management +

6.3.16 Keyboard/Keypad Drivers

+

+ "Out-of-Band" Commands. + Keyboards and keypads are the same device for NuttX. + A keypad is thought of as simply a keyboard with fewer keys. + In NuttX, a keyboard/keypad driver is simply a character driver that may have an (optional) encoding/decoding layer on the data returned by the character driver. + A keyboard may return simple text data (alphabetic, numeric, and punctuaction) or control characters (enter, control-C, etc.). + We can think about this the normal "in-band" keyboard data stream. + However, in addition, most keyboards support actions that cannot be represented as text data. + Such actions include things like cursor controls (home, up arrow, page down, etc.), editing functions (insert, delete, etc.), volume controls, (mute, volume up, etc.) and other special functions. + We can think about this as special, "out-of-band" keyboard commands. + In this case, some special encoding may be required to multiplex the in-band text data and out-of-band command streams. +

+

+ Encoding/Decoding Layer. + An optional encoding/decoding layer can be used with the basic character driver to encode the out-of-band commands into the text data stream. + The function interfaces that comprise that encoding/decoding layer are defined in the header file include/nuttx/input/kbd_code.h. + These functions provide an matched set of (a) driver encoding interfaces, and (b) application decoding interfaces. +

+
    +
  1. +

    + Driver Encoding Interfaces. +

    +
      +
    • +

      + kbd_puttext() +

      +

      Function Prototype:

      +
        +#include <nuttx/streams.h>
        +#include <nuttx/input/kbd_codec.h>
        +void kbd_puttext(int ch, FAR struct lib_outstream_s *stream);
        +
      +

      Description:

      +
        + Put one byte of normal, "in-band" ASCII data into the output stream. +
      +

      Input Pameters:

      +
        +
      • + ch: The character to be added to the output stream. +
      • +
      • + stream: An instance of lib_outstream_s to perform the actual low-level put operation. +
      • +
      +

      Returned Value:

      +
        + None. +
      +
    • +
    • +

      + kbd_putspecial() +

      +

      Function Prototype:

      +
        +#include <nuttx/streams.h>
        +#include <nuttx/input/kbd_codec.h>
        +void kbd_putspecial(enum kbd_keycode_e keycode, FAR struct lib_outstream_s *stream);
        +
      +

      Description:

      +
        + Put one special, "out-of-band" command into the output stream. +
      +

      Input Pameters:

      +
        +
      • + keycode: The command to be added to the output stream. + The enumeration enum kbd_keycode_e keycode identifies all commands known to the system. +
      • +
      • + stream: An instance of lib_outstream_s to perform the actual low-level put operation. +
      • +
      +

      Returned Value:

      +
        + None. +
      +
    • +
    +
  2. +
  3. +

    + Application Decoding Interfaces. +

    +
      +
    • +

      + kbd_get() +

      +

      Function Prototype:

      +
        +#include <nuttx/streams.h>
        +#include <nuttx/input/kbd_codec.h>
        +int kbd_get(FAR struct lib_instream_s *stream, FAR struct kbd_getstate_s *state, FAR uint8_t *pch);
        +
      +

      Description:

      +
        + Get one byte of data or special command from the driver provided input buffer. +
      +

      Input Pameters:

      +
        +
      • + stream: An instance of lib_instream_s to perform the actual low-level get operation. +
      • +
      • + pch: The location character to save the returned value. + This may be either a normal, "in-band" ASCII characer or a special, "out-of-band" command (i.e., a value from enum kbd_getstate_s. +
      • +
      • + state: A user provided buffer to support parsing. + This structure should be cleared the first time that kbd_get is called. +
      • +
      +

      Returned Value:

      +
        +
      • + 1: + Indicates the successful receipt of a special, "out-of-band" command. + The returned value in pch is a value from enum kbd_getstate_s. +
      • +
      • + 0: + Indicates the successful receipt of normal, "in-band" ASCII data. + The returned value in pch is a simple byte of text or control data. +
      • +
      • + EOF: + An error has getting the next character (reported by the stream). + Normally indicates the end of file. +
      • +
      +
    • +
    +
  4. +
+

+ I/O Streams. + Notice the use of the abstract I/O streams in these interfaces. + These stream interfaces are defined in include/nuttx/streams.h. +

+

6.4 Power Management

6.4.1 Overview