Add m9s12 serial logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3305 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
2814d4dd8c
commit
5a52fca179
@ -41,12 +41,65 @@
|
|||||||
|
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
#include "m9s12_internal.h"
|
#include "m9s12_internal.h"
|
||||||
#include "m9s12_flash.h"
|
#include "m9s12_sci.h"
|
||||||
|
#include "m9s12_serial.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_HCS12_SERIALMON
|
||||||
|
# include "m9s12_flash.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Private Definitions
|
* Private Definitions
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
/* Select SCI parameters for the selected console */
|
||||||
|
|
||||||
|
#if defined(CONFIG_SCI0_SERIAL_CONSOLE)
|
||||||
|
# define HCS12_CONSOLE_BASE HCS12_SCI0_BASE
|
||||||
|
# define HCS12_CONSOLE_BAUD CONFIG_SCI0_BAUD
|
||||||
|
# define HCS12_CONSOLE_BITS CONFIG_SCI0_BITS
|
||||||
|
# define HCS12_CONSOLE_PARITY CONFIG_SCI0_PARITY
|
||||||
|
# define HCS12_CONSOLE_2STOP CONFIG_SCI0_2STOP
|
||||||
|
#elif defined(CONFIG_SCI1_SERIAL_CONSOLE)
|
||||||
|
# define HCS12_CONSOLE_BASE HCS12_SCI1_BASE
|
||||||
|
# define HCS12_CONSOLE_BAUD CONFIG_SCI1_BAUD
|
||||||
|
# define HCS12_CONSOLE_BITS CONFIG_SCI1_BITS
|
||||||
|
# define HCS12_CONSOLE_PARITY CONFIG_SCI1_PARITY
|
||||||
|
# define HCS12_CONSOLE_2STOP CONFIG_SCI1_2STOP
|
||||||
|
#else
|
||||||
|
# warning "No CONFIG_SCIn_SERIAL_CONSOLE Setting"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Selete the SCIBR register value */
|
||||||
|
|
||||||
|
#define CONSOLE_SCIBR_VALUE SCIBR_VALUE(HCS12_CONSOLE_BAUD)
|
||||||
|
|
||||||
|
/* Select the SCICR1 register settings */
|
||||||
|
|
||||||
|
#if HCS12_CONSOLE_BITS == 9
|
||||||
|
# define UART_SCICR1_NBITS SCI_CR1_M
|
||||||
|
#elif HCS12_CONSOLE_BITS == 8
|
||||||
|
# define UART_SCICR1_NBITS 0
|
||||||
|
#else
|
||||||
|
# warning "Number of bits not supported"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HCS12_CONSOLE_PARITY == 0
|
||||||
|
# define UART_SCICR1_PARITY 0
|
||||||
|
#elif HCS12_CONSOLE_PARITY == 1
|
||||||
|
# define UART_SCICR1_PARITY SCI_CR1_PE
|
||||||
|
#elif HCS12_CONSOLE_PARITY == 2
|
||||||
|
# define UART_SCICR1_PARITY (SCI_CR1_PE|SCI_CR1_PT)
|
||||||
|
#else
|
||||||
|
# error "ERROR: Invalid parity selection"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HCS12_CONSOLE_2STOP != 0
|
||||||
|
# warning "Only a single stop bit supported"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CONSOLE_SCICR_VALUE (UART_SCICR1_NBITS|UART_SCICR1_PARITY)
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
@ -82,7 +135,31 @@ up_lowsetup:
|
|||||||
#ifdef CONFIG_HCS12_SERIALMON
|
#ifdef CONFIG_HCS12_SERIALMON
|
||||||
rts
|
rts
|
||||||
#else
|
#else
|
||||||
# error "up_lowsetup not implemented"
|
/* Disable the console */
|
||||||
|
|
||||||
|
ldab #0
|
||||||
|
stab (HCS12_CONSOLE_BASE+HCS12_SCI_CR1_OFFSET)
|
||||||
|
stab (HCS12_CONSOLE_BASE+HCS12_SCI_CR2_OFFSET)
|
||||||
|
|
||||||
|
/* Set the BAUD pre-scaler value */
|
||||||
|
|
||||||
|
ldab #(CONSOLE_SCIBR_VALUE >> 8)
|
||||||
|
stab (HCS12_CONSOLE_BASE+HCS12_SCI_BDH_OFFSET)
|
||||||
|
|
||||||
|
ldab #(CONSOLE_SCIBR_VALUE & 0xff)
|
||||||
|
stab (HCS12_CONSOLE_BASE+HCS12_SCI_BDL_OFFSET)
|
||||||
|
|
||||||
|
/* Set number of bits, parity, stop bits, etc. */
|
||||||
|
|
||||||
|
ldab #CONSOLE_SCICR_VALUE
|
||||||
|
stab (HCS12_CONSOLE_BASE+HCS12_SCI_CR1_OFFSET)
|
||||||
|
|
||||||
|
/* Enable transmitter and receiver */
|
||||||
|
|
||||||
|
ldab #(SCI_CR2_RE|SCI_CR2_TE)
|
||||||
|
stab (HCS12_CONSOLE_BASE+HCS12_SCI_CR2_OFFSET)
|
||||||
|
rts
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
.size up_lowsetup, . - up_lowsetup
|
.size up_lowsetup, . - up_lowsetup
|
||||||
|
|
||||||
@ -97,7 +174,31 @@ up_lowputc:
|
|||||||
#ifdef CONFIG_HCS12_SERIALMON
|
#ifdef CONFIG_HCS12_SERIALMON
|
||||||
jmp PutChar
|
jmp PutChar
|
||||||
#else
|
#else
|
||||||
# error "up_lowputc not implemented"
|
# if HCS12_CONSOLE_BITS == 9
|
||||||
|
staa 1, -sp
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Wait for the transmit data register to be available (TRDE==1) */
|
||||||
|
|
||||||
|
.Lwait:
|
||||||
|
ldaa (HCS12_CONSOLE_BASE+HCS12_SCI_SR1_OFFSET)
|
||||||
|
bita #SCI_SR1_TDRE
|
||||||
|
bne .Lwait
|
||||||
|
|
||||||
|
/* Then write the byte to the transmit data register */
|
||||||
|
|
||||||
|
# if HCS12_CONSOLE_BITS == 9
|
||||||
|
ldaa 1, sp+
|
||||||
|
bita #(0x01)
|
||||||
|
bne .L8bit
|
||||||
|
ldaa #SCI_DRH_T8
|
||||||
|
bra .Lwrdrh
|
||||||
|
.L8bit:
|
||||||
|
ldaa #0
|
||||||
|
.Lwrdrh:
|
||||||
|
staa (HCS12_CONSOLE_BASE+HCS12_SCI_DRH_OFFSET)
|
||||||
|
# endif
|
||||||
|
stab (HCS12_CONSOLE_BASE+HCS12_SCI_DRL_OFFSET)
|
||||||
rts
|
rts
|
||||||
#endif
|
#endif
|
||||||
.size up_lowputc, . - up_lowputc
|
.size up_lowputc, . - up_lowputc
|
||||||
|
94
arch/hc/src/m9s12/m9s12_serial.h
Executable file
94
arch/hc/src/m9s12/m9s12_serial.h
Executable file
@ -0,0 +1,94 @@
|
|||||||
|
/************************************************************************************
|
||||||
|
* arch/hc/src/m9s12/serial.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ARCH_HC_SRC_M9S12_CHIP_H
|
||||||
|
#define __ARCH_HC_SRC_M9S12_CHIP_H
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Included Files
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
************************************************************************************/
|
||||||
|
/* Configuration ********************************************************************/
|
||||||
|
|
||||||
|
/* Is there a SCI enabled? */
|
||||||
|
|
||||||
|
#if defined(CONFIG_SCI0_DISABLE) && defined(CONFIG_SCI1_DISABLE)
|
||||||
|
# error "No SCIs enabled"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Is there a serial console? */
|
||||||
|
|
||||||
|
#if defined(CONFIG_SCI0_SERIAL_CONSOLE) && !defined(CONFIG_SCI0_DISABLE)
|
||||||
|
# undef CONFIG_SCI1_SERIAL_CONSOLE
|
||||||
|
# define HAVE_CONSOLE 1
|
||||||
|
#elif defined(CONFIG_SCI1_SERIAL_CONSOLE) && !defined(CONFIG_SCI1_DISABLE)
|
||||||
|
# undef CONFIG_SCI0_SERIAL_CONSOLE
|
||||||
|
# define HAVE_CONSOLE 1
|
||||||
|
#else
|
||||||
|
# warning "No valid CONFIG_SCIn_SERIAL_CONSOLE Setting"
|
||||||
|
# undef CONFIG_SCI0_SERIAL_CONSOLE
|
||||||
|
# undef CONFIG_SCI1_SERIAL_CONSOLE
|
||||||
|
# undef HAVE_CONSOLE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* BAUD *****************************************************************************/
|
||||||
|
/* Baud calculations. The SCI module is driven by the BUSCLK. The SCIBR
|
||||||
|
* register value divides down the BUSCLK to accomplish the required BAUD.
|
||||||
|
*
|
||||||
|
* BAUD = HCS12_BUSCLK / (16 * SCIBR)
|
||||||
|
* SCIBR = HCS12_BUSCLK / (16 * BAUD)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SCIBR_VALUE(b) ((HCS12_BUSCLK * (b) + ((b) << 3))/((b) << 4))
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Public Types
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Public Data
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
#endif /* __ARCH_HC_SRC_M9S12_CHIP_H */
|
@ -40,6 +40,8 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "m9s12_internal.h"
|
#include "m9s12_internal.h"
|
||||||
#include "m9s12_mmc.h"
|
#include "m9s12_mmc.h"
|
||||||
#include "m9s12_crg.h"
|
#include "m9s12_crg.h"
|
||||||
@ -118,8 +120,9 @@
|
|||||||
/* Set the multipler and divider and enable the PLL */
|
/* Set the multipler and divider and enable the PLL */
|
||||||
|
|
||||||
bclr *HCS12_CRG_PLLCTL #CRG_PLLCTL_PLLON
|
bclr *HCS12_CRG_PLLCTL #CRG_PLLCTL_PLLON
|
||||||
ldab #15
|
ldab #HCS12_SYNR_VALUE
|
||||||
stab HCS12_CRG_SYNR
|
stab HCS12_CRG_SYNR
|
||||||
|
ldab #HCS12_REFDV_VALUE
|
||||||
stab HCS12_CRG_REFDV
|
stab HCS12_CRG_REFDV
|
||||||
bset *HCS12_CRG_PLLCTL #CRG_PLLCTL_PLLON
|
bset *HCS12_CRG_PLLCTL #CRG_PLLCTL_PLLON
|
||||||
|
|
||||||
|
@ -51,9 +51,30 @@
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
/* Clocking *************************************************************************/
|
/* Clocking *************************************************************************/
|
||||||
|
/* Frequency of the crystal oscillator */
|
||||||
|
|
||||||
#define HCS12_OSCCLK 16000000 /* 16MHz */
|
#define HCS12_OSCCLK 16000000 /* 16MHz */
|
||||||
|
|
||||||
|
/* PLL Settings
|
||||||
|
*
|
||||||
|
* SYNR register controls the multiplication factor of the PLL. If the PLL is on, the
|
||||||
|
* count in the loop divider (SYNR) register effectively multiplies up the PLL clock
|
||||||
|
* (PLLCLK) from the reference frequency by 2 x (SYNR+1). PLLCLK will not be below
|
||||||
|
* the minimum VCO frequency (fSCM).
|
||||||
|
*
|
||||||
|
* The REFDV register provides a finer granularity for the PLL multiplier steps. The
|
||||||
|
* count in the reference divider divides OSCCLK frequency by REFDV + 1.
|
||||||
|
*
|
||||||
|
* PLLCLK = 2 * OSCCLK * (SYNR + 1) / (REFDV + 1)
|
||||||
|
*
|
||||||
|
* If (PLLSEL = 1), Bus Clock = PLLCLK / 2
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define HCS12_SYNR_VALUE 0x15
|
||||||
|
#define HCS12_REFDV_VALUE 0x15
|
||||||
|
#define HCS12_PLLCLK (2*HCS12_OSCCLK*(HCS12_SYNR+1)/(HCS12_REFDV+1))
|
||||||
|
#define HCS12_BUSCLK (HSC12_PLLCLK/2)
|
||||||
|
|
||||||
/* LED definitions ******************************************************************/
|
/* LED definitions ******************************************************************/
|
||||||
|
|
||||||
/* The DEMO9S12NE64 board has 2 LEDs that we will encode as: */
|
/* The DEMO9S12NE64 board has 2 LEDs that we will encode as: */
|
||||||
|
@ -80,11 +80,11 @@ struct hid_state_s
|
|||||||
int hid_parsereport(FAR const uint8_t *report, int rptlen,
|
int hid_parsereport(FAR const uint8_t *report, int rptlen,
|
||||||
hid_rptfilter_t filter, FAR struct hid_rptinfo_s *rptinfo)
|
hid_rptfilter_t filter, FAR struct hid_rptinfo_s *rptinfo)
|
||||||
{
|
{
|
||||||
struct hid_state_s state[HID_STATETABLE_STACK_DEPTH];
|
struct hid_state_s state[CONFIG_HID_STATEDEPTH];
|
||||||
struct hid_state_s *currstate = &state[0];
|
struct hid_state_s *currstate = &state[0];
|
||||||
struct hid_collectionpath_s *collectionpath = NULL;
|
struct hid_collectionpath_s *collectionpath = NULL;
|
||||||
struct hid_rptsizeinfo_s *rptidinfo = &rptinfo->rptsize[0];
|
struct hid_rptsizeinfo_s *rptidinfo = &rptinfo->rptsize[0];
|
||||||
uint16_t usage[HID_USAGE_STACK_DEPTH];
|
uint16_t usage[CONFIG_HID_USAGEDEPTH];
|
||||||
uint8_t nusage = 0;
|
uint8_t nusage = 0;
|
||||||
struct hid_range_s usage_range = { 0, 0 };
|
struct hid_range_s usage_range = { 0, 0 };
|
||||||
int i;
|
int i;
|
||||||
@ -134,7 +134,7 @@ int hid_parsereport(FAR const uint8_t *report, int rptlen,
|
|||||||
switch (item & ~USBHID_RPTITEM_SIZE_MASK)
|
switch (item & ~USBHID_RPTITEM_SIZE_MASK)
|
||||||
{
|
{
|
||||||
case USBHID_GLOBAL_PUSH_PREFIX:
|
case USBHID_GLOBAL_PUSH_PREFIX:
|
||||||
if (currstate == &state[HID_STATETABLE_STACK_DEPTH - 1])
|
if (currstate == &state[CONFIG_HID_STATEDEPTH - 1])
|
||||||
{
|
{
|
||||||
return -E2BIG;
|
return -E2BIG;
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ int hid_parsereport(FAR const uint8_t *report, int rptlen,
|
|||||||
|
|
||||||
if (rptidinfo == NULL)
|
if (rptidinfo == NULL)
|
||||||
{
|
{
|
||||||
if (rptinfo->nreports == HID_MAX_REPORT_IDS)
|
if (rptinfo->nreports == CONFIG_HID_MAXIDS)
|
||||||
{
|
{
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ int hid_parsereport(FAR const uint8_t *report, int rptlen,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case USBHID_LOCAL_USAGE_PREFIX:
|
case USBHID_LOCAL_USAGE_PREFIX:
|
||||||
if (nusage == HID_USAGE_STACK_DEPTH)
|
if (nusage == CONFIG_HID_USAGEDEPTH)
|
||||||
{
|
{
|
||||||
return -E2BIG;
|
return -E2BIG;
|
||||||
}
|
}
|
||||||
@ -258,7 +258,7 @@ int hid_parsereport(FAR const uint8_t *report, int rptlen,
|
|||||||
|
|
||||||
while (collectionpath->parent != NULL)
|
while (collectionpath->parent != NULL)
|
||||||
{
|
{
|
||||||
if (collectionpath == &rptinfo->collectionpaths[HID_MAX_COLLECTIONS - 1])
|
if (collectionpath == &rptinfo->collectionpaths[CONFIG_HID_MAXCOLLECTIONS - 1])
|
||||||
{
|
{
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
@ -332,15 +332,15 @@ int hid_parsereport(FAR const uint8_t *report, int rptlen,
|
|||||||
tag = (item & ~USBHID_RPTITEM_SIZE_MASK);
|
tag = (item & ~USBHID_RPTITEM_SIZE_MASK);
|
||||||
if (tag == USBHID_MAIN_INPUT_PREFIX)
|
if (tag == USBHID_MAIN_INPUT_PREFIX)
|
||||||
{
|
{
|
||||||
newitem.type = USBHID_REPORTTYPE_INPUT;
|
newitem.type = HID_REPORT_ITEM_IN;
|
||||||
}
|
}
|
||||||
else if (tag == USBHID_MAIN_OUTPUT_PREFIX)
|
else if (tag == USBHID_MAIN_OUTPUT_PREFIX)
|
||||||
{
|
{
|
||||||
newitem.type = USBHID_REPORTTYPE_OUTPUT;
|
newitem.type = HID_REPORT_ITEM_OUT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newitem.type = USBHID_REPORTTYPE_FEATURE;
|
newitem.type = HID_REPORT_ITEM_FEATURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
newitem.bitoffset = rptidinfo->size[newitem.type];
|
newitem.bitoffset = rptidinfo->size[newitem.type];
|
||||||
@ -355,7 +355,7 @@ int hid_parsereport(FAR const uint8_t *report, int rptlen,
|
|||||||
|
|
||||||
if ((data & USBHID_MAIN_CONSTANT) == 0 && filter(&newitem))
|
if ((data & USBHID_MAIN_CONSTANT) == 0 && filter(&newitem))
|
||||||
{
|
{
|
||||||
if (rptinfo->nitems == HID_MAX_REPORTITEMS)
|
if (rptinfo->nitems == CONFIG_HID_MAXITEMS)
|
||||||
{
|
{
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
@ -515,7 +515,7 @@ void hid_putitem(FAR uint8_t *report, struct hid_rptitem_s *item)
|
|||||||
size_t hid_reportsize(FAR struct hid_rptinfo_s *rptinfo, uint8_t id, uint8_t rpttype)
|
size_t hid_reportsize(FAR struct hid_rptinfo_s *rptinfo, uint8_t id, uint8_t rpttype)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < HID_MAX_REPORT_IDS; i++)
|
for (i = 0; i < CONFIG_HID_MAXIDS; i++)
|
||||||
{
|
{
|
||||||
size_t size = rptinfo->rptsize[i].size[rpttype];
|
size_t size = rptinfo->rptsize[i].size[rpttype];
|
||||||
|
|
||||||
|
@ -44,64 +44,72 @@
|
|||||||
|
|
||||||
/* Configuration ************************************************************/
|
/* Configuration ************************************************************/
|
||||||
|
|
||||||
/* HID_STATETABLE_STACK_DEPTH
|
/* CONFIG_HID_STATEDEPTH
|
||||||
* Constant indicating the maximum stack depth of the state table. A larger
|
* Constant indicating the maximum stack depth of the state table. A larger
|
||||||
* state table allows for more PUSH/POP report items to be nested, but
|
* state table allows for more PUSH/POP report items to be nested, but
|
||||||
* consumes more memory. By default this is set to 2 levels (allowing non-
|
* consumes more memory. By default this is set to 2 levels (allowing non-
|
||||||
* nested PUSH items) but this can be overridden by defining
|
* nested PUSH items) but this can be overridden by defining
|
||||||
* HID_STATETABLE_STACK_DEPTH in the Nuttx config file.
|
* CONFIG_HID_STATEDEPTH in the Nuttx config file.
|
||||||
*
|
*
|
||||||
* HID_USAGE_STACK_DEPTH
|
* CONFIG_HID_USAGEDEPTH
|
||||||
* Constant indicating the maximum stack depth of the usage table. A larger
|
* Constant indicating the maximum stack depth of the usage table. A larger
|
||||||
* usage table allows for more USAGE items to be indicated sequentially for
|
* usage table allows for more USAGE items to be indicated sequentially for
|
||||||
* REPORT COUNT entries of more than one, but requires more stack space. By
|
* REPORT COUNT entries of more than one, but requires more stack space. By
|
||||||
* default this is set to 8 levels (allowing for a report item with a count
|
* default this is set to 8 levels (allowing for a report item with a count
|
||||||
* of 8) but this can be overridden by defining HID_USAGE_STACK_DEPTH to
|
* of 8) but this can be overridden by defining CONFIG_HID_USAGEDEPTH to
|
||||||
* in the Nuttx config file.
|
* in the Nuttx config file.
|
||||||
*
|
*
|
||||||
* HID_MAX_COLLECTIONS
|
* CONFIG_HID_MAXCOLLECTIONS
|
||||||
* Constant indicating the maximum number of COLLECTION items (nested or
|
* Constant indicating the maximum number of COLLECTION items (nested or
|
||||||
* unnested) that can be processed in the report item descriptor. A large
|
* unnested) that can be processed in the report item descriptor. A large
|
||||||
* value allows for more COLLECTION items to be processed, but consumes
|
* value allows for more COLLECTION items to be processed, but consumes
|
||||||
* more memory. By default this is set to 10 collections, but this can be
|
* more memory. By default this is set to 10 collections, but this can be
|
||||||
* overridden by defining HID_MAX_COLLECTIONS in the Nuttx config file.
|
* overridden by defining CONFIG_HID_MAXCOLLECTIONS in the Nuttx config file.
|
||||||
*
|
*
|
||||||
|
* CONFIG_HID_MAXITEMS
|
||||||
* Constant indicating the maximum number of report items (IN, OUT or
|
* Constant indicating the maximum number of report items (IN, OUT or
|
||||||
* FEATURE) that can be processed in the report item descriptor and stored
|
* FEATURE) that can be processed in the report item descriptor and stored
|
||||||
* in the user HID Report Info structure. A large value allows
|
* in the user HID Report Info structure. A large value allows
|
||||||
* for more report items to be stored, but consumes more memory. By default
|
* for more report items to be stored, but consumes more memory. By default
|
||||||
* this is set to 20 items, but this can be overridden by defining
|
* this is set to 20 items, but this can be overridden by defining
|
||||||
* HID_MAX_REPORTITEMS in the Nuttx config file.
|
* CONFIG_HID_MAXITEMS in the Nuttx config file.
|
||||||
*
|
*
|
||||||
|
* CONFIG_HID_MAXIDS
|
||||||
* Constant indicating the maximum number of unique report IDs that can be
|
* Constant indicating the maximum number of unique report IDs that can be
|
||||||
* processed in the report item descriptor for the report size information
|
* processed in the report item descriptor for the report size information
|
||||||
* array in the user HID Report Info structure. A large value allows for
|
* array in the user HID Report Info structure. A large value allows for
|
||||||
* more report ID report sizes to be stored, but consumes more memory. By
|
* more report ID report sizes to be stored, but consumes more memory. By
|
||||||
* default this is set to 10 items, but this can be overridden by defining
|
* default this is set to 10 items, but this can be overridden by defining
|
||||||
* HID_MAX_REPORT_IDS in the Nuttx config file. Note that IN, OUT and FEATURE
|
* CONFIG_HID_MAXIDS in the Nuttx config file. Note that IN, OUT and FEATURE
|
||||||
* items sharing the same report ID consume only one size item in the array.
|
* items sharing the same report ID consume only one size item in the array.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HID_STATETABLE_STACK_DEPTH
|
#ifndef CONFIG_HID_STATEDEPTH
|
||||||
# define HID_STATETABLE_STACK_DEPTH 2
|
# define CONFIG_HID_STATEDEPTH 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HID_USAGE_STACK_DEPTH
|
#ifndef CONFIG_HID_USAGEDEPTH
|
||||||
# define HID_USAGE_STACK_DEPTH 8
|
# define CONFIG_HID_USAGEDEPTH 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HID_MAX_COLLECTIONS
|
#ifndef CONFIG_HID_MAXCOLLECTIONS
|
||||||
# define HID_MAX_COLLECTIONS 10
|
# define CONFIG_HID_MAXCOLLECTIONS 10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HID_MAX_REPORTITEMS
|
#ifndef CONFIG_HID_MAXITEMS
|
||||||
# define HID_MAX_REPORTITEMS 20
|
# define CONFIG_HID_MAXITEMS 20
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HID_MAX_REPORT_IDS
|
#ifndef CONFIG_HID_MAXIDS
|
||||||
# define HID_MAX_REPORT_IDS 10
|
# define CONFIG_HID_MAXIDS 10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* HID report type indices */
|
||||||
|
|
||||||
|
#define HID_REPORT_ITEM_IN 0
|
||||||
|
#define HID_REPORT_ITEM_OUT 1
|
||||||
|
#define HID_REPORT_ITEM_FEATURE 2
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -112,8 +120,8 @@
|
|||||||
|
|
||||||
struct hid_range_s
|
struct hid_range_s
|
||||||
{
|
{
|
||||||
uint32_t min; /* Minimum value for the attribute. */
|
uint32_t min; /* Minimum value for the attribute */
|
||||||
uint32_t max; /* Maximum value for the attribute. */
|
uint32_t max; /* Maximum value for the attribute */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* HID Parser Report Item Unit Structure. Type define for the Unit attributes
|
/* HID Parser Report Item Unit Structure. Type define for the Unit attributes
|
||||||
@ -122,8 +130,8 @@ struct hid_range_s
|
|||||||
|
|
||||||
struct hid_unit_t
|
struct hid_unit_t
|
||||||
{
|
{
|
||||||
uint32_t type; /* Unit type (refer to HID specifications for details). */
|
uint32_t type; /* Unit type (refer to HID spec for details) */
|
||||||
uint8_t exponent; /* Unit exponent (refer to HID specifications for details). */
|
uint8_t exponent; /* Unit exponent (refer to HID spec for details) */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* HID Parser Report Item Usage Structure. Type define for the Usage
|
/* HID Parser Report Item Usage Structure. Type define for the Usage
|
||||||
@ -132,8 +140,8 @@ struct hid_unit_t
|
|||||||
|
|
||||||
struct hid_usage_t
|
struct hid_usage_t
|
||||||
{
|
{
|
||||||
uint16_t page; /* Usage page of the report item. */
|
uint16_t page; /* Usage page of the report item */
|
||||||
uint16_t usage; /* Usage of the report item. */
|
uint16_t usage; /* Usage of the report item */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* HID Parser Report Item Collection Path Structure. Type define for a
|
/* HID Parser Report Item Collection Path Structure. Type define for a
|
||||||
@ -143,9 +151,9 @@ struct hid_usage_t
|
|||||||
|
|
||||||
struct hid_collectionpath_s
|
struct hid_collectionpath_s
|
||||||
{
|
{
|
||||||
uint8_t type; /* Collection type (e.g. "Generic Desktop"). */
|
uint8_t type; /* Collection type (e.g. "Generic Desktop") */
|
||||||
struct hid_usage_t usage; /* Collection usage. */
|
struct hid_usage_t usage; /* Collection usage */
|
||||||
struct hid_collectionpath_s *parent; /* Reference to parent collection, or NULL if root collection. */
|
struct hid_collectionpath_s *parent; /* Reference to parent collection (NULL if root) */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* HID Parser Report Item Attributes Structure. Type define for all the data
|
/* HID Parser Report Item Attributes Structure. Type define for all the data
|
||||||
@ -154,11 +162,11 @@ struct hid_collectionpath_s
|
|||||||
|
|
||||||
struct hid_rptitem_attributes_s
|
struct hid_rptitem_attributes_s
|
||||||
{
|
{
|
||||||
uint8_t bitsize; /* Size in bits of the report item's data. */
|
uint8_t bitsize; /* Size in bits of the report item's data */
|
||||||
struct hid_usage_t usage; /* Usage of the report item. */
|
struct hid_usage_t usage; /* Usage of the report item */
|
||||||
struct hid_unit_t unit; /* Unit type and exponent of the report item. */
|
struct hid_unit_t unit; /* Unit type and exponent of the report item */
|
||||||
struct hid_range_s logical; /* Logical minimum and maximum of the report item. */
|
struct hid_range_s logical; /* Logical minimum and maximum of the report item */
|
||||||
struct hid_range_s physical; /* Physical minimum and maximum of the report item. */
|
struct hid_range_s physical; /* Physical minimum and maximum of the report item */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* HID Parser Report Item Details Structure. Type define for a report item
|
/* HID Parser Report Item Details Structure. Type define for a report item
|
||||||
@ -167,14 +175,14 @@ struct hid_rptitem_attributes_s
|
|||||||
|
|
||||||
struct hid_rptitem_s
|
struct hid_rptitem_s
|
||||||
{
|
{
|
||||||
uint16_t bitoffset; /* Bit offset in the IN, OUT or FEATURE report of the item. */
|
uint16_t bitoffset; /* Bit offset in IN, OUT or FEATURE report of the item */
|
||||||
uint8_t type; /* Report item type, a value in HID_ReportItemTypes_t. */
|
uint8_t type; /* Report item type */
|
||||||
uint16_t flags; /* Item data flags, a mask of HID_IOF_* constants. */
|
uint16_t flags; /* Item data flags */
|
||||||
uint8_t id; /* Report ID this item belongs to, or 0x00 if device has only one report */
|
uint8_t id; /* Report ID this item belongs to (0 if only one report) */
|
||||||
struct hid_collectionpath_s *collectionpath; /* Collection path of the item. */
|
struct hid_collectionpath_s *collectionpath; /* Collection path of the item */
|
||||||
struct hid_rptitem_attributes_s attrib; /* Report item attributes. */
|
struct hid_rptitem_attributes_s attrib; /* Report item attributes */
|
||||||
uint32_t value; /* Current value of the report item */
|
uint32_t value; /* Current value of the report item */
|
||||||
uint32_t previous; /* Previous value of the report item. */
|
uint32_t previous; /* Previous value of the report item */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* HID Parser Report Size Structure. Type define for a report item size
|
/* HID Parser Report Size Structure. Type define for a report item size
|
||||||
@ -183,8 +191,8 @@ struct hid_rptitem_s
|
|||||||
|
|
||||||
struct hid_rptsizeinfo_s
|
struct hid_rptsizeinfo_s
|
||||||
{
|
{
|
||||||
uint8_t id; /* Report ID of the report within the HID interface. */
|
uint8_t id; /* Report ID of the report within the HID interface */
|
||||||
uint16_t size[3]; /* Number of bits in each report type for the given Report ID */
|
uint16_t size[3]; /* Number of bits in report type for the Report ID */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* HID Parser State Structure. Type define for a complete processed HID
|
/* HID Parser State Structure. Type define for a complete processed HID
|
||||||
@ -196,16 +204,16 @@ struct hid_rptinfo_s
|
|||||||
/* nitems is the number of report items stored in the report items array (rptitems[]). */
|
/* nitems is the number of report items stored in the report items array (rptitems[]). */
|
||||||
|
|
||||||
uint8_t nitems;
|
uint8_t nitems;
|
||||||
struct hid_rptitem_s items[HID_MAX_REPORTITEMS];
|
struct hid_rptitem_s items[CONFIG_HID_MAXITEMS];
|
||||||
|
|
||||||
/* All collection items, referenced by the report items. */
|
/* All collection items, referenced by the report items. */
|
||||||
|
|
||||||
struct hid_collectionpath_s collectionpaths[HID_MAX_COLLECTIONS];
|
struct hid_collectionpath_s collectionpaths[CONFIG_HID_MAXCOLLECTIONS];
|
||||||
|
|
||||||
uint8_t nreports; /* Number of reports within the HID interface */
|
uint8_t nreports; /* Number of reports within the HID interface */
|
||||||
struct hid_rptsizeinfo_s rptsize[HID_MAX_REPORT_IDS]; /* Report sizes for each report in the interface */
|
struct hid_rptsizeinfo_s rptsize[CONFIG_HID_MAXIDS]; /* Report sizes for each report in the interface */
|
||||||
uint16_t maxrptsize; /* Largest report that the attached device will generate, in bits */
|
uint16_t maxrptsize; /* Largest report that the attached device will generate, in bits */
|
||||||
bool haverptid; /* Device has at least one REPORT ID in its HID report. */
|
bool haverptid; /* Device has at least one REPORT ID in its HID report */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Callback routine for the HID Report Parser. This callback must be
|
/* Callback routine for the HID Report Parser. This callback must be
|
||||||
|
Loading…
Reference in New Issue
Block a user