mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 04:23:33 +08:00
Merge NuttX r5527
This commit is contained in:
@@ -140,7 +140,8 @@ menuconfig SPI
|
||||
bool "SPI Driver Support"
|
||||
default n
|
||||
---help---
|
||||
This selection enables building of the "upper-half" SPI driver.
|
||||
This selection enables selection of common SPI options. This option
|
||||
should be enabled by all platforms that support SPI interfaces.
|
||||
See include/nuttx/spi.h for further SPI driver information.
|
||||
|
||||
if SPI
|
||||
|
||||
@@ -123,6 +123,25 @@ config STMPE811_I2C
|
||||
|
||||
endchoice
|
||||
|
||||
config STMPE811_ACTIVELOW
|
||||
bool "Active Low Interrupt"
|
||||
default n
|
||||
---help---
|
||||
The STMPE811 interrupt is provided by a discrete input (usually a
|
||||
GPIO interrupt on most MCU architectures). This setting determines
|
||||
whether the interrupt is active high (or rising edge triggered) or
|
||||
active low (or falling edge triggered). Default: Active
|
||||
high/rising edge.
|
||||
|
||||
config STMPE811_EDGE
|
||||
bool "Edge triggered Interrupt"
|
||||
default n
|
||||
---help---
|
||||
The STMPE811 interrupt is provided by a discrete input (usually a
|
||||
GPIO interrupt on most MCU architectures). This setting determines
|
||||
whether the interrupt is edge or level triggered. Default: Level
|
||||
triggered.
|
||||
|
||||
config STMPE811_MULTIPLE
|
||||
bool "Multiple STMPE811 Devices"
|
||||
default n
|
||||
|
||||
@@ -51,6 +51,10 @@ ifeq ($(CONFIG_LCD_UG2864AMBAG01),y)
|
||||
CSRCS += ug-2864ambag01.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LCD_UG2864HSWEG01),y)
|
||||
CSRCS += ug-2864hsweg01.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LCD_UG9664HSWAG01),y)
|
||||
CSRCS += ug-9664hswag01.c
|
||||
endif
|
||||
|
||||
@@ -428,7 +428,7 @@ static inline void ug2864ambag01_configspi(FAR struct spi_dev_s *spi)
|
||||
|
||||
SPI_SETMODE(spi, CONFIG_UG2864AMBAG01_SPIMODE);
|
||||
SPI_SETBITS(spi, 8);
|
||||
SPI_SETFREQUENCY(spi, CONFIG_UG2864AMBAG01_FREQUENCY)
|
||||
SPI_SETFREQUENCY(spi, CONFIG_UG2864AMBAG01_FREQUENCY);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1035,7 +1035,7 @@ FAR struct lcd_dev_s *ug2864ambag01_initialize(FAR struct spi_dev_s *spi, unsign
|
||||
|
||||
/* Configure the SPI */
|
||||
|
||||
ug2864ambag01_configspi(spi)
|
||||
ug2864ambag01_configspi(spi);
|
||||
|
||||
/* Lock and select device */
|
||||
|
||||
@@ -1148,8 +1148,8 @@ void ug2864ambag01_fill(FAR struct lcd_dev_s *dev, uint8_t color)
|
||||
|
||||
/* Transfer one page of the selected color */
|
||||
|
||||
(void)SPI_SNDBLOCK(priv->spi, &priv->fb[page * UG2864AMBAG01_XRES],
|
||||
UG2864AMBAG01_XRES);
|
||||
(void)SPI_SNDBLOCK(priv->spi, &priv->fb[page * UG2864AMBAG01_XRES],
|
||||
UG2864AMBAG01_XRES);
|
||||
}
|
||||
|
||||
/* De-select and unlock the device */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config MMCSD_NSLOTS
|
||||
int "Number of MMC/SD slots"
|
||||
default 1
|
||||
@@ -38,8 +39,9 @@ config MMCSD_HAVECARDDETECT
|
||||
100% accurate
|
||||
|
||||
config MMCSD_SPI
|
||||
bool "MMC/SD spi transfer support"
|
||||
bool "MMC/SD SPI transfer support"
|
||||
default y
|
||||
depends on SPI
|
||||
|
||||
config MMCSD_SPICLOCK
|
||||
int "MMC/SD maximum SPI clock"
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
|
||||
# Include MTD drivers
|
||||
|
||||
ifeq ($(CONFIG_MTD),y)
|
||||
|
||||
CSRCS += at45db.c flash_eraseall.c ftl.c m25px.c rammtd.c ramtron.c
|
||||
|
||||
ifeq ($(CONFIG_MTD_AT24XX),y)
|
||||
@@ -60,3 +62,4 @@ endif
|
||||
DEPPATH += --dep-path mtd
|
||||
VPATH += :mtd
|
||||
|
||||
endif
|
||||
|
||||
@@ -523,12 +523,12 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
{
|
||||
/* Save the configuration and inform the constituent classes */
|
||||
|
||||
ret = CLASS_SETUP(priv->dev1, dev, ctrl);
|
||||
ret = CLASS_SETUP(priv->dev1, dev, ctrl, dataout, outlen);
|
||||
dispatched = true;
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
ret = CLASS_SETUP(priv->dev2, dev, ctrl);
|
||||
ret = CLASS_SETUP(priv->dev2, dev, ctrl, dataout, outlen);
|
||||
if (ret >= 0)
|
||||
{
|
||||
priv->config = value;
|
||||
|
||||
@@ -333,7 +333,7 @@ static void usbclass_wrcomplete(FAR struct usbdev_ep_s *ep,
|
||||
|
||||
/* USB class device ********************************************************/
|
||||
|
||||
static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
FAR struct usbdev_s *dev);
|
||||
static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
FAR struct usbdev_s *dev);
|
||||
@@ -1295,7 +1295,7 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
priv->usbdev = dev;
|
||||
|
||||
/* Save the reference to our private data structure in EP0 so that it
|
||||
* can be recovered in ep0 completion events (Unless we are part of
|
||||
* can be recovered in ep0 completion events (Unless we are part of
|
||||
* a composite device and, in that case, the composite device owns
|
||||
* EP0).
|
||||
*/
|
||||
@@ -1859,7 +1859,7 @@ static void usbclass_disconnect(FAR struct usbdevclass_driver_s *driver,
|
||||
* re-enumerated.
|
||||
*/
|
||||
|
||||
DEV_CONNECT(dev);
|
||||
DEV_CONNECT(dev);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1878,7 +1878,7 @@ static int usbser_setup(FAR struct uart_dev_s *dev)
|
||||
{
|
||||
FAR struct pl2303_dev_s *priv;
|
||||
|
||||
usbtrace(PL2303_CLASSASPI_SETUP, 0);
|
||||
usbtrace(PL2303_CLASSAPI_SETUP, 0);
|
||||
|
||||
/* Sanity check */
|
||||
|
||||
@@ -1919,7 +1919,7 @@ static int usbser_setup(FAR struct uart_dev_s *dev)
|
||||
|
||||
static void usbser_shutdown(FAR struct uart_dev_s *dev)
|
||||
{
|
||||
usbtrace(PL2303_CLASSASPI_SHUTDOWN, 0);
|
||||
usbtrace(PL2303_CLASSAPI_SHUTDOWN, 0);
|
||||
|
||||
/* Sanity check */
|
||||
|
||||
@@ -1941,7 +1941,7 @@ static void usbser_shutdown(FAR struct uart_dev_s *dev)
|
||||
|
||||
static int usbser_attach(FAR struct uart_dev_s *dev)
|
||||
{
|
||||
usbtrace(PL2303_CLASSASPI_ATTACH, 0);
|
||||
usbtrace(PL2303_CLASSAPI_ATTACH, 0);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -1955,7 +1955,7 @@ static int usbser_attach(FAR struct uart_dev_s *dev)
|
||||
|
||||
static void usbser_detach(FAR struct uart_dev_s *dev)
|
||||
{
|
||||
usbtrace(PL2303_CLASSASPI_DETACH, 0);
|
||||
usbtrace(PL2303_CLASSAPI_DETACH, 0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1981,7 +1981,7 @@ static void usbser_rxint(FAR struct uart_dev_s *dev, bool enable)
|
||||
FAR uart_dev_t *serdev;
|
||||
irqstate_t flags;
|
||||
|
||||
usbtrace(PL2303_CLASSASPI_RXINT, (uint16_t)enable);
|
||||
usbtrace(PL2303_CLASSAPI_RXINT, (uint16_t)enable);
|
||||
|
||||
/* Sanity check */
|
||||
|
||||
@@ -2072,7 +2072,7 @@ static void usbser_txint(FAR struct uart_dev_s *dev, bool enable)
|
||||
{
|
||||
FAR struct pl2303_dev_s *priv;
|
||||
|
||||
usbtrace(PL2303_CLASSASPI_TXINT, (uint16_t)enable);
|
||||
usbtrace(PL2303_CLASSAPI_TXINT, (uint16_t)enable);
|
||||
|
||||
/* Sanity checks */
|
||||
|
||||
@@ -2117,7 +2117,7 @@ static bool usbser_txempty(FAR struct uart_dev_s *dev)
|
||||
{
|
||||
FAR struct pl2303_dev_s *priv = (FAR struct pl2303_dev_s*)dev->priv;
|
||||
|
||||
usbtrace(PL2303_CLASSASPI_TXEMPTY, 0);
|
||||
usbtrace(PL2303_CLASSAPI_TXEMPTY, 0);
|
||||
|
||||
#if CONFIG_DEBUG
|
||||
if (!priv)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config USBHOST_NPREALLOC
|
||||
int "Number of pre-allocated class instances"
|
||||
default 4
|
||||
@@ -29,64 +30,85 @@ config USBHOST_ISOC_DISABLE
|
||||
On some architectures, selecting this setting will reduce driver size
|
||||
by disabling isochronous endpoint support
|
||||
|
||||
config USBHOST_HIDKBD
|
||||
bool "HID keyboad class support"
|
||||
config USBHOST_MSC
|
||||
bool "Mass Storage Class Support"
|
||||
default n
|
||||
depends on !USBHOST_INT_DISABLE && SCHED_WORKQUEUE && !DISABLE_SIGNALS
|
||||
depends on !BULK_DISABLE
|
||||
---help---
|
||||
Enable support for the keyboard class driver. This also depends on
|
||||
NFILE_DESCRIPTORS > 0 && SCHED_WORKQUEUE=y
|
||||
|
||||
config USBHOST_HIDKBD
|
||||
bool "HID Keyboard Class Support"
|
||||
default n
|
||||
depends on !INT_DISABLE
|
||||
---help---
|
||||
Enable support for the keyboard class driver. This also depends on
|
||||
SCHED_WORKQUEUE && !DISABLE_SIGNALS
|
||||
|
||||
if USBHOST_HIDKBD
|
||||
config HIDKBD_POLLUSEC
|
||||
bool ""
|
||||
default n
|
||||
int "Keyboard Poll Rate (MSEC)"
|
||||
default 100000
|
||||
---help---
|
||||
Device poll rate in microseconds. Default: 100 milliseconds.
|
||||
Device poll rate in microseconds. Default: 100,000 microseconds.
|
||||
|
||||
config HIDKBD_DEFPRIO
|
||||
bool ""
|
||||
default n
|
||||
int "Polling Thread Priority"
|
||||
default 50
|
||||
---help---
|
||||
Priority of the polling thread. Default: 50.
|
||||
|
||||
config HIDKBD_STACKSIZE
|
||||
bool ""
|
||||
default n
|
||||
int "Polling thread stack size"
|
||||
default 1024
|
||||
---help---
|
||||
Stack size for polling thread. Default: 1024
|
||||
|
||||
config HIDKBD_BUFSIZE
|
||||
bool ""
|
||||
default n
|
||||
int "Scancode Buffer Size"
|
||||
default 64
|
||||
---help---
|
||||
Scancode buffer size. Default: 64.
|
||||
|
||||
config HIDKBD_NPOLLWAITERS
|
||||
bool ""
|
||||
default n
|
||||
int "Max Number of Waiters for Poll Event"
|
||||
default 2
|
||||
depends on !DISABLE_POLL
|
||||
---help---
|
||||
If the poll() method is enabled, this defines the maximum number
|
||||
of threads that can be waiting for keyboard events. Default: 2.
|
||||
|
||||
config HIDKBD_RAWSCANCODES
|
||||
bool ""
|
||||
bool "Use Raw Scan Codes"
|
||||
default n
|
||||
---help---
|
||||
If set to y no conversion will be made on the raw keyboard scan
|
||||
codes. Default: ASCII conversion.
|
||||
If set to y no conversions will be made on the raw keyboard scan
|
||||
codes. This option is useful during testing. Default: ASCII conversion.
|
||||
|
||||
config HIDKBD_ENCODED
|
||||
bool "Enocode Special Keys"
|
||||
default n
|
||||
depends on !HIDKBD_RAWSCANCODES && LIB_KBDCODEC
|
||||
---help---
|
||||
Encode special key press events in the user buffer. In this case,
|
||||
the user end must decode the encoded special key values using the
|
||||
interfaces defined in include/nuttx/input/kbd_codec.h. These
|
||||
special keys include such things as up/down arrows, home and end
|
||||
keys, etc. If this not defined, only 7-bit print-able and control
|
||||
ASCII characters will be provided to the user.
|
||||
|
||||
config HIDKBD_ALLSCANCODES
|
||||
bool ""
|
||||
bool "Use All Scancodes"
|
||||
default n
|
||||
---help---
|
||||
If set to y all 231 possible scancodes will be converted to
|
||||
something. Default: 104 key US keyboard.
|
||||
|
||||
config HIDKBD_NODEBOUNCE
|
||||
bool ""
|
||||
bool "Disable Debounce"
|
||||
default n
|
||||
---help---
|
||||
If set to y normal debouncing is disabled. Default:
|
||||
Debounce enabled (No repeat keys).
|
||||
USB host mass storage class driver. Requires USBHOST=y,
|
||||
config USBHOST_BULK_DISABLE=n, NFILE_DESCRIPTORS > 0,
|
||||
and SCHED_WORKQUEUE=y
|
||||
endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* drivers/usbhost/usbhost_hidkbd.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -62,6 +62,11 @@
|
||||
#include <nuttx/usb/usbhost.h>
|
||||
#include <nuttx/usb/hid.h>
|
||||
|
||||
#ifdef CONFIG_HIDKBD_ENCODED
|
||||
# include <nuttx/streams.h>
|
||||
# include <nuttx/input/kbd_codec.h>
|
||||
#endif
|
||||
|
||||
/* Don't compile if prerequisites are not met */
|
||||
|
||||
#if defined(CONFIG_USBHOST) && !defined(CONFIG_USBHOST_INT_DISABLE) && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
@@ -126,6 +131,22 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* We cant support encoding of special characters of unless the Keyboard
|
||||
* CODEC is enabled.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_LIB_KBDCODEC
|
||||
# undef CONFIG_HIDKBD_ENCODED
|
||||
#endif
|
||||
|
||||
/* If we are using raw scancodes, then we cannot support encoding of
|
||||
* special characters either.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_HIDKBD_RAWSCANCODES
|
||||
# undef CONFIG_HIDKBD_ENCODED
|
||||
#endif
|
||||
|
||||
/* Driver support ***********************************************************/
|
||||
/* This format is used to construct the /dev/kbd[n] device driver path. It
|
||||
* defined here so that it will be used consistently in all places.
|
||||
@@ -144,6 +165,23 @@
|
||||
|
||||
#define USBHOST_MAX_CREFS 0x7fff
|
||||
|
||||
/* Debug ********************************************************************/
|
||||
/* Both CONFIG_DEBUG_INPUT and CONFIG_DEBUG_USB could apply to this file.
|
||||
* We assume here that CONFIG_DEBUG_INPUT might be enabled separately, but
|
||||
* CONFIG_DEBUG_USB implies both.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_DEBUG_INPUT
|
||||
# undef idbg
|
||||
# define idbg udbg
|
||||
# undef illdbg
|
||||
# define illdbg ulldbg
|
||||
# undef ivdbg
|
||||
# define ivdbg uvdbg
|
||||
# undef illvdbg
|
||||
# define illvdbg ullvdbg
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@@ -209,6 +247,16 @@ struct usbhost_state_s
|
||||
uint8_t kbdbuffer[CONFIG_HIDKBD_BUFSIZE];
|
||||
};
|
||||
|
||||
/* This type is used for encoding special characters */
|
||||
|
||||
#ifdef CONFIG_HIDKBD_ENCODED
|
||||
struct usbhost_outstream_s
|
||||
{
|
||||
struct lib_outstream_s stream;
|
||||
FAR struct usbhost_state_s *priv;
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
@@ -240,7 +288,15 @@ static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, char *dev
|
||||
/* Keyboard polling thread */
|
||||
|
||||
static void usbhost_destroy(FAR void *arg);
|
||||
static void usbhost_putbuffer(FAR struct usbhost_state_s *priv, uint8_t keycode);
|
||||
#ifdef CONFIG_HIDKBD_ENCODED
|
||||
static void usbhost_putstream(FAR struct lib_outstream_s *this, int ch);
|
||||
#endif
|
||||
static inline uint8_t usbhost_mapscancode(uint8_t scancode, uint8_t modifier);
|
||||
#ifdef CONFIG_HIDKBD_ENCODED
|
||||
static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv,
|
||||
uint8_t scancode, uint8_t modifier);
|
||||
#endif
|
||||
static int usbhost_kbdpoll(int argc, char *argv[]);
|
||||
|
||||
/* Helpers for usbhost_connect() */
|
||||
@@ -346,6 +402,121 @@ static struct usbhost_state_s *g_priv; /* Data passed to thread */
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_HIDKBD_RAWSCANCODES
|
||||
#ifdef CONFIG_HIDKBD_ENCODED
|
||||
|
||||
/* The first and last scancode values with encode-able values */
|
||||
|
||||
#define FIRST_ENCODING USBHID_KBDUSE_ENTER /* 0x28 Keyboard Return (ENTER) */
|
||||
#ifndef CONFIG_HIDKBD_ALLSCANCODES
|
||||
# define LAST_ENCODING USBHID_KBDUSE_POWER /* 0x66 Keyboard Power */
|
||||
#else
|
||||
# define LAST_ENCODING USBHID_KBDUSE_KPDHEXADECIMAL /* 0xdd Keypad Hexadecimal */
|
||||
#endif
|
||||
|
||||
#define USBHID_NUMENCODINGS (LAST_ENCODING - FIRST_ENCODING + 1)
|
||||
|
||||
static const uint8_t encoding[USBHID_NUMENCODINGS] =
|
||||
{
|
||||
/* 0x28-0x2f: Enter,escape,del,back-tab,space,_,+,{ */
|
||||
|
||||
KEYCODE_ENTER, 0, KEYCODE_FWDDEL, KEYCODE_BACKDEL, 0, 0, 0, 0,
|
||||
|
||||
/* 0x30-0x37: },|,Non-US tilde,:,",grave tilde,<,> */
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
/* 0x38-0x3f: /,CapsLock,F1,F2,F3,F4,F5,F6 */
|
||||
|
||||
0, KEYCODE_CAPSLOCK, KEYCODE_F1, KEYCODE_F2, KEYCODE_F3, KEYCODE_F4, KEYCODE_F5, KEYCODE_F6,
|
||||
|
||||
/* 0x40-0x47: F7,F8,F9,F10,F11,F12,PrtScn,ScrollLock */
|
||||
|
||||
KEYCODE_F7, KEYCODE_F8, KEYCODE_F9, KEYCODE_F10, KEYCODE_F11, KEYCODE_F12, KEYCODE_PRTSCRN, KEYCODE_SCROLLLOCK,
|
||||
|
||||
/* 0x48-0x4f: Pause,Insert,Home,PageUp,DeleteForward,End,PageDown,RightArrow */
|
||||
|
||||
KEYCODE_PAUSE, KEYCODE_INSERT, KEYCODE_HOME, KEYCODE_PAGEUP, KEYCODE_FWDDEL, KEYCODE_END, KEYCODE_PAGEDOWN, KEYCODE_RIGHT,
|
||||
|
||||
/* 0x50-0x57: LeftArrow,DownArrow,UpArrow,Num Lock,/,*,-,+ */
|
||||
|
||||
KEYCODE_LEFT, KEYCODE_DOWN, KEYCODE_UP, KEYCODE_NUMLOCK, 0, 0, 0, 0,
|
||||
|
||||
/* 0x58-0x5f: Enter,1-7 */
|
||||
|
||||
KEYCODE_ENTER, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
/* 0x60-0x66: 8-9,0,.,Non-US \,Application,Power */
|
||||
|
||||
0, 0, 0, 0, 0, 0, KEYCODE_POWER,
|
||||
|
||||
#ifdef CONFIG_HIDKBD_ALLSCANCODES
|
||||
|
||||
0, /* 0x67 = */
|
||||
|
||||
/* 0x68-0x6f: F13,F14,F15,F16,F17,F18,F19,F20 */
|
||||
|
||||
KEYCODE_F13, KEYCODE_F14, KEYCODE_F15, KEYCODE_F16, KEYCODE_F17, KEYCODE_F18, KEYCODE_F19, KEYCODE_F20,
|
||||
|
||||
/* 0x70-0x77: F21,F22,F23,F24,Execute,Help,Menu,Select */
|
||||
|
||||
KEYCODE_F21, KEYCODE_F22, KEYCODE_F23, KEYCODE_F24, KEYCODE_EXECUTE, KEYCODE_HELP, KEYCODE_MENU, KEYCODE_SELECT,
|
||||
|
||||
/* 0x78-0x7f: Stop,Again,Undo,Cut,Copy,Paste,Find,Mute */
|
||||
|
||||
KEYCODE_STOP, KEYCODE_AGAIN, KEYCODE_UNDO, KEYCODE_CUT, KEYCODE_COPY, KEYCODE_PASTE, KEYCODE_FIND, KEYCODE_MUTE,
|
||||
|
||||
/* 0x80-0x87: VolUp,VolDown,LCapsLock,lNumLock,LScrollLock,,,=,International1 */
|
||||
|
||||
KEYCODE_VOLUP, KEYCODE_VOLDOWN, KEYCODE_LCAPSLOCK, KEYCODE_LNUMLOCK, KEYCODE_LSCROLLLOCK, 0, 0, 0,
|
||||
|
||||
/* 0x88-0x8f: International 2-9 */
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
/* 0x90-0x97: LAN 1-8 */
|
||||
|
||||
KEYCODE_LANG1, KEYCODE_LANG2, KEYCODE_LANG3, KEYCODE_LANG4, KEYCODE_LANG5, KEYCODE_LANG6, KEYCODE_LANG7, KEYCODE_LANG8,
|
||||
|
||||
/* 0x98-0x9f: LAN 9,Erase,SysReq,Cancel,Clear,Prior,Return,Separator */
|
||||
|
||||
0, 0, KEYCODE_SYSREQ, KEYCODE_CANCEL, KEYCODE_CLEAR, 0, KEYCODE_ENTER, 0,
|
||||
|
||||
/* 0xa0-0xa7: Out,Oper,Clear,CrSel,Excel,(reserved) */
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
/* 0xa8-0xaf: (reserved) */
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
/* 0xb0-0xb7: 00,000,ThouSeparator,DecSeparator,CurrencyUnit,SubUnit,(,) */
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
/* 0xb8-0xbf: {,},tab,backspace,A-D */
|
||||
|
||||
0, 0, 0, KEYCODE_BACKDEL, 0, 0, 0, 0,
|
||||
|
||||
/* 0xc0-0xc7: E-F,XOR,^,%,<,>,& */
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
/* 0xc8-0xcf: &&,|,||,:,#, ,@,! */
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
/* 0xd0-0xd7: Memory Store,Recall,Clear,Add,Subtract,Muliply,Divide,+/- */
|
||||
|
||||
KEYCODE_MEMSTORE, KEYCODE_MEMRECALL, KEYCODE_MEMCLEAR, KEYCODE_MEMADD, KEYCODE_MEMSUB, KEYCODE_MEMMUL, KEYCODE_MEMDIV, KEYCODE_NEGATE,
|
||||
|
||||
/* 0xd8-0xdd: Clear,ClearEntry,Binary,Octal,Decimal,Hexadecimal */
|
||||
|
||||
KEYCODE_CLEAR, KEYCODE_CLEARENTRY, KEYCODE_BINARY, KEYCODE_OCTAL, KEYCODE_DECIMAL, KEYCODE_HEXADECIMAL
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
static const uint8_t ucmap[USBHID_NUMSCANCODES] =
|
||||
{
|
||||
0, 0, 0, 0, 'A', 'B', 'C', 'D', /* 0x00-0x07: Reserved, errors, A-D */
|
||||
@@ -354,12 +525,12 @@ static const uint8_t ucmap[USBHID_NUMSCANCODES] =
|
||||
'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@', /* 0x18-0x1f: U-Z,!,@ */
|
||||
'#', '$', '%', '^', '&', '*', '(', ')', /* 0x20-0x27: #,$,%,^,&,*,(,) */
|
||||
'\n', '\033', '\177', 0, ' ', '_', '+', '{', /* 0x28-0x2f: Enter,escape,del,back-tab,space,_,+,{ */
|
||||
'}', '|', 0, ':', '"', 0, '<', '>', /* 0x30-0x37: },|,Non-US tilde,:,",grave tidle,<,> */
|
||||
'}', '|', 0, ':', '"', '~', '<', '>', /* 0x30-0x37: },|,Non-US tilde,:,",grave tilde,<,> */
|
||||
'?', 0, 0, 0, 0, 0, 0, 0, /* 0x38-0x3f: /,CapsLock,F1,F2,F3,F4,F5,F6 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0x40-0x47: F7,F8,F9,F10,F11,F12,PrtScn,sScrollLock */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0x40-0x47: F7,F8,F9,F10,F11,F12,PrtScn,ScrollLock */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0x48-0x4f: Pause,Insert,Home,PageUp,DeleteForward,End,PageDown,RightArrow */
|
||||
0, 0, 0, 0, '/', '*', '-', '+', /* 0x50-0x57: LeftArrow,DownArrow,UpArrow,Num Lock,/,*,-,+ */
|
||||
'\n', '1', '2', '3', '4', '4', '6', '7', /* 0x58-0x5f: Enter,1-7 */
|
||||
'\n', '1', '2', '3', '4', '5', '6', '7', /* 0x58-0x5f: Enter,1-7 */
|
||||
'8', '9', '0', '.', 0, 0, 0, '=', /* 0x60-0x67: 8-9,0,.,Non-US \,Application,Power,= */
|
||||
#ifdef CONFIG_HIDKBD_ALLSCANCODES
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0x68-0x6f: F13,F14,F15,F16,F17,F18,F19,F20 */
|
||||
@@ -368,7 +539,7 @@ static const uint8_t ucmap[USBHID_NUMSCANCODES] =
|
||||
0, 0, 0, 0, 0, ',', 0, 0, /* 0x80-0x87: VolUp,VolDown,LCapsLock,lNumLock,LScrollLock,,,=,International1 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0x88-0x8f: International 2-9 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0x90-0x97: LAN 1-8 */
|
||||
0, 0, 0, 0, 0, 0, '\n', 0, /* 0x98-0x9f: LAN 9,Ease,SysReq,Cancel,Clear,Prior,Return,Separator */
|
||||
0, 0, 0, 0, 0, 0, '\n', 0, /* 0x98-0x9f: LAN 9,Erase,SysReq,Cancel,Clear,Prior,Return,Separator */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0-0xa7: Out,Oper,Clear,CrSel,Excel,(reserved) */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0xa8-0xaf: (reserved) */
|
||||
0, 0, 0, 0, 0, 0, '(', ')', /* 0xb0-0xb7: 00,000,ThouSeparator,DecSeparator,CurrencyUnit,SubUnit,(,) */
|
||||
@@ -389,12 +560,12 @@ static const uint8_t lcmap[USBHID_NUMSCANCODES] =
|
||||
'u', 'v', 'w', 'x', 'y', 'z', '1', '2', /* 0x18-0x1f: u-z,1-2 */
|
||||
'3', '4', '5', '6', '7', '8', '9', '0', /* 0x20-0x27: 3-9,0 */
|
||||
'\n', '\033', '\177', '\t', ' ', '-', '=', '[', /* 0x28-0x2f: Enter,escape,del,tab,space,-,=,[ */
|
||||
']', '\\', '\234', ';', '\'', 0, ',', '.', /* 0x30-0x37: ],\,Non-US pound,;,',grave accent,,,. */
|
||||
']', '\\', '\234', ';', '\'', '`', ',', '.', /* 0x30-0x37: ],\,Non-US pound,;,',grave accent,,,. */
|
||||
'/', 0, 0, 0, 0, 0, 0, 0, /* 0x38-0x3f: /,CapsLock,F1,F2,F3,F4,F5,F6 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0x40-0x47: F7,F8,F9,F10,F11,F12,PrtScn,ScrollLock */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0x48-0x4f: Pause,Insert,Home,PageUp,DeleteForward,End,PageDown,RightArrow */
|
||||
0, 0, 0, 0, '/', '*', '-', '+', /* 0x50-0x57: LeftArrow,DownArrow,UpArrow,Num Lock,/,*,-,+ */
|
||||
'\n', '1', '2', '3', '4', '4', '6', '7', /* 0x58-0x5f: Enter,1-7 */
|
||||
'\n', '1', '2', '3', '4', '5', '6', '7', /* 0x58-0x5f: Enter,1-7 */
|
||||
'8', '9', '0', '.', 0, 0, 0, '=', /* 0x60-0x67: 8-9,0,.,Non-US \,Application,Power,= */
|
||||
#ifdef CONFIG_HIDKBD_ALLSCANCODES
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0x68-0x6f: F13,F14,F15,F16,F17,F18,F19,F20 */
|
||||
@@ -403,7 +574,7 @@ static const uint8_t lcmap[USBHID_NUMSCANCODES] =
|
||||
0, 0, 0, 0, 0, ',', 0, 0, /* 0x80-0x87: VolUp,VolDown,LCapsLock,lNumLock,LScrollLock,,,=,International1 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0x88-0x8f: International 2-9 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0x90-0x97: LAN 1-8 */
|
||||
0, 0, 0, 0, 0, 0, '\n', 0, /* 0x98-0x9f: LAN 9,Ease,SysReq,Cancel,Clear,Prior,Return,Separator */
|
||||
0, 0, 0, 0, 0, 0, '\n', 0, /* 0x98-0x9f: LAN 9,Erase,SysReq,Cancel,Clear,Prior,Return,Separator */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0-0xa7: Out,Oper,Clear,CrSel,Excel,(reserved) */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* 0xa8-0xaf: (reserved) */
|
||||
0, 0, 0, 0, 0, 0, '(', ')', /* 0xb0-0xb7: 00,000,ThouSeparator,DecSeparator,CurrencyUnit,SubUnit,(,) */
|
||||
@@ -637,6 +808,88 @@ static void usbhost_destroy(FAR void *arg)
|
||||
usbhost_freeclass(priv);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbhost_putbuffer
|
||||
*
|
||||
* Description:
|
||||
* Add one character to the user buffer.
|
||||
*
|
||||
* Input Parameters:
|
||||
* priv - Driver internal state
|
||||
* keycode - The value to add to the user buffer
|
||||
*
|
||||
* Returned Values:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void usbhost_putbuffer(FAR struct usbhost_state_s *priv,
|
||||
uint8_t keycode)
|
||||
{
|
||||
register unsigned int head;
|
||||
register unsigned int tail;
|
||||
|
||||
/* Copy the next keyboard character into the user buffer. */
|
||||
|
||||
head = priv->headndx;
|
||||
priv->kbdbuffer[head] = keycode;
|
||||
|
||||
/* Increment the head index */
|
||||
|
||||
if (++head >= CONFIG_HIDKBD_BUFSIZE)
|
||||
{
|
||||
head = 0;
|
||||
}
|
||||
|
||||
/* If the buffer is full, then increment the tail index to make space. Is
|
||||
* it better to lose old keystrokes or new?
|
||||
*/
|
||||
|
||||
tail = priv->tailndx;
|
||||
if (tail == head)
|
||||
{
|
||||
if (++tail >= CONFIG_HIDKBD_BUFSIZE)
|
||||
{
|
||||
tail = 0;
|
||||
}
|
||||
|
||||
/* Save the updated tail index */
|
||||
|
||||
priv->tailndx = tail;
|
||||
}
|
||||
|
||||
/* Save the updated head index */
|
||||
|
||||
priv->headndx = head;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbhost_putstream
|
||||
*
|
||||
* Description:
|
||||
* A wrapper for usbhost_putc that is compatibile with the lib_outstream_s
|
||||
* putc methos.
|
||||
*
|
||||
* Input Parameters:
|
||||
* stream - The struct lib_outstream_s reference
|
||||
* ch - The character to add to the user buffer
|
||||
*
|
||||
* Returned Values:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HIDKBD_ENCODED
|
||||
static void usbhost_putstream(FAR struct lib_outstream_s *stream, int ch)
|
||||
{
|
||||
FAR struct usbhost_outstream_s *privstream = (FAR struct usbhost_outstream_s *)stream;
|
||||
|
||||
DEBUGASSERT(privstream && privstream->priv);
|
||||
usbhost_putbuffer(privstream->priv, (uint8_t)ch);
|
||||
stream->nput++;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbhost_mapscancode
|
||||
*
|
||||
@@ -679,6 +932,58 @@ static inline uint8_t usbhost_mapscancode(uint8_t scancode, uint8_t modifier)
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbhost_encodescancode
|
||||
*
|
||||
* Description:
|
||||
* Check if the key has a special function encoding and, if it does, add
|
||||
* the encoded value to the user buffer.
|
||||
*
|
||||
* Input Parameters:
|
||||
* priv - Driver internal state
|
||||
* scancode - Scan code to be mapped.
|
||||
* modifier - Ctrl,Alt,Shift,GUI modifier bits
|
||||
*
|
||||
* Returned Values:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_HIDKBD_ENCODED
|
||||
static inline void usbhost_encodescancode(FAR struct usbhost_state_s *priv,
|
||||
uint8_t scancode, uint8_t modifier)
|
||||
{
|
||||
uint8_t encoded;
|
||||
|
||||
/* Check if the raw scancode is in a valid range */
|
||||
|
||||
if (scancode >= FIRST_ENCODING && scancode <= LAST_ENCODING)
|
||||
{
|
||||
/* Yes the value is within range */
|
||||
|
||||
encoded = encoding[scancode - FIRST_ENCODING];
|
||||
ivdbg(" scancode: %02x modifier: %02x encoded: %d\n",
|
||||
scancode, modifier, encoded);
|
||||
|
||||
if (encoded)
|
||||
{
|
||||
struct usbhost_outstream_s usbstream;
|
||||
|
||||
/* And it does correspond to a special function key */
|
||||
|
||||
usbstream.stream.put = usbhost_putstream;
|
||||
usbstream.stream.nput = 0;
|
||||
usbstream.priv = priv;
|
||||
|
||||
/* Add the special function value to the user buffer */
|
||||
|
||||
kbd_specpress((enum kbd_keycode_e)encoded,
|
||||
(FAR struct lib_outstream_s *)&usbstream);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbhost_kbdpoll
|
||||
*
|
||||
@@ -704,6 +1009,8 @@ static int usbhost_kbdpoll(int argc, char *argv[])
|
||||
unsigned int npolls = 0;
|
||||
#endif
|
||||
unsigned int nerrors = 0;
|
||||
bool empty = true;
|
||||
bool newstate;
|
||||
int ret;
|
||||
|
||||
uvdbg("Started\n");
|
||||
@@ -717,17 +1024,18 @@ static int usbhost_kbdpoll(int argc, char *argv[])
|
||||
* running.
|
||||
*/
|
||||
|
||||
priv = g_priv;
|
||||
DEBUGASSERT(priv != NULL);
|
||||
priv = g_priv;
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
priv->polling = true;
|
||||
priv->crefs++;
|
||||
usbhost_givesem(&g_syncsem);
|
||||
sleep(1);
|
||||
priv->polling = true;
|
||||
priv->crefs++;
|
||||
usbhost_givesem(&g_syncsem);
|
||||
sleep(1);
|
||||
|
||||
/* Loop here until the device is disconnected */
|
||||
|
||||
uvdbg("Entering poll loop\n");
|
||||
|
||||
while (!priv->disconnected)
|
||||
{
|
||||
/* Make sure that we have exclusive access to the private data
|
||||
@@ -784,17 +1092,12 @@ static int usbhost_kbdpoll(int argc, char *argv[])
|
||||
else if (priv->open)
|
||||
{
|
||||
struct usbhid_kbdreport_s *rpt = (struct usbhid_kbdreport_s *)priv->tbuffer;
|
||||
unsigned int head;
|
||||
unsigned int tail;
|
||||
uint8_t ascii;
|
||||
uint8_t keycode;
|
||||
int i;
|
||||
|
||||
/* Add the newly received keystrokes to our internal buffer */
|
||||
|
||||
usbhost_takesem(&priv->exclsem);
|
||||
head = priv->headndx;
|
||||
tail = priv->tailndx;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
/* Is this key pressed? But not pressed last time?
|
||||
@@ -828,15 +1131,15 @@ static int usbhost_kbdpoll(int argc, char *argv[])
|
||||
* or cursor controls in this version of the driver.
|
||||
*/
|
||||
|
||||
ascii = usbhost_mapscancode(rpt->key[i], rpt->modifier);
|
||||
uvdbg("Key %d: %02x ASCII:%c modifier: %02x\n",
|
||||
i, rpt->key[i], ascii ? ascii : ' ', rpt->modifier);
|
||||
keycode = usbhost_mapscancode(rpt->key[i], rpt->modifier);
|
||||
ivdbg("Key %d: %02x keycode:%c modifier: %02x\n",
|
||||
i, rpt->key[i], keycode ? keycode : ' ', rpt->modifier);
|
||||
|
||||
/* Zero at this point means that the key does not map to a
|
||||
* printable character.
|
||||
*/
|
||||
|
||||
if (ascii != 0)
|
||||
if (keycode != 0)
|
||||
{
|
||||
/* Handle control characters. Zero after this means
|
||||
* a valid, NUL character.
|
||||
@@ -844,36 +1147,28 @@ static int usbhost_kbdpoll(int argc, char *argv[])
|
||||
|
||||
if ((rpt->modifier & (USBHID_MODIFER_LCTRL|USBHID_MODIFER_RCTRL)) != 0)
|
||||
{
|
||||
ascii &= 0x1f;
|
||||
keycode &= 0x1f;
|
||||
}
|
||||
|
||||
/* Copy the next keyboard character into the user
|
||||
* buffer.
|
||||
*/
|
||||
|
||||
priv->kbdbuffer[head] = ascii;
|
||||
|
||||
/* Increment the head index */
|
||||
|
||||
if (++head >= CONFIG_HIDKBD_BUFSIZE)
|
||||
{
|
||||
head = 0;
|
||||
}
|
||||
|
||||
/* If the buffer is full, then increment the tail
|
||||
* index to make space. Is it better to lose old
|
||||
* keystrokes or new?
|
||||
*/
|
||||
|
||||
if (tail == head)
|
||||
{
|
||||
if (++tail >= CONFIG_HIDKBD_BUFSIZE)
|
||||
{
|
||||
tail = 0;
|
||||
}
|
||||
}
|
||||
usbhost_putbuffer(priv, keycode);
|
||||
}
|
||||
|
||||
/* The zero might, however, map to a special keyboard action (such as a
|
||||
* cursor movement or function key). Attempt to encode the special key.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_HIDKBD_ENCODED
|
||||
else
|
||||
{
|
||||
usbhost_encodescancode(priv, rpt->key[i], rpt->modifier);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Save the scancode (or lack thereof) for key debouncing on
|
||||
* next keyboard report.
|
||||
*/
|
||||
@@ -883,9 +1178,10 @@ static int usbhost_kbdpoll(int argc, char *argv[])
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Did we just transition from no data available to data available? */
|
||||
/* Is there data available? */
|
||||
|
||||
if (head != tail && priv->headndx == priv->tailndx)
|
||||
newstate = (priv->headndx == priv->tailndx);
|
||||
if (!newstate)
|
||||
{
|
||||
/* Yes.. Is there a thread waiting for keyboard data now? */
|
||||
|
||||
@@ -897,15 +1193,18 @@ static int usbhost_kbdpoll(int argc, char *argv[])
|
||||
priv->waiting = false;
|
||||
}
|
||||
|
||||
/* And wake up any threads waiting for the POLLIN event */
|
||||
/* Did we just transition from no data available to data
|
||||
* available? If so, wake up any threads waiting for the
|
||||
* POLLIN event.
|
||||
*/
|
||||
|
||||
usbhost_pollnotify(priv);
|
||||
if (empty)
|
||||
{
|
||||
usbhost_pollnotify(priv);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update the head/tail indices */
|
||||
|
||||
priv->headndx = head;
|
||||
priv->tailndx = tail;
|
||||
empty = newstate;
|
||||
usbhost_givesem(&priv->exclsem);
|
||||
}
|
||||
|
||||
@@ -958,6 +1257,7 @@ static int usbhost_kbdpoll(int argc, char *argv[])
|
||||
|
||||
usbhost_givesem(&priv->exclsem);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1861,6 +2161,7 @@ static ssize_t usbhost_read(FAR struct file *filep, FAR char *buffer, size_t len
|
||||
/* Wait for data to be available */
|
||||
|
||||
uvdbg("Waiting...\n");
|
||||
|
||||
priv->waiting = true;
|
||||
usbhost_givesem(&priv->exclsem);
|
||||
usbhost_takesem(&priv->waitsem);
|
||||
|
||||
Reference in New Issue
Block a user