Merge remote-tracking branch 'origin/master' into ieee802154

This commit is contained in:
Gregory Nutt 2017-03-31 06:41:11 -06:00
commit a43c0c9efb
20 changed files with 2308 additions and 71 deletions

View file

@ -86,8 +86,9 @@
#define _SPIBASE (0x2100) /* SPI driver commands */
#define _GPIOBASE (0x2200) /* GPIO driver commands */
#define _CLIOCBASE (0x2300) /* Contactless modules ioctl commands */
#define _MAC802154BASE (0x2400) /* 802.15.4 MAC ioctl commands */
#define _PHY802154BASE (0x2500) /* 802.15.4 Radio ioctl commands */
#define _USBCBASE (0x2400) /* USB-C controller ioctl commands */
#define _MAC802154BASE (0x2500) /* 802.15.4 MAC ioctl commands */
#define _PHY802154BASE (0x2600) /* 802.15.4 Radio ioctl commands */
/* boardctl() commands share the same number space */
@ -397,19 +398,25 @@
#define _GPIOCVALID(c) (_IOC_TYPE(c)==_GPIOBASE)
#define _GPIOC(nr) _IOC(_GPIOBASE,nr)
/* Contactless driver ioctl definitions ****************************************/
/* Contactless driver ioctl definitions *************************************/
/* (see nuttx/include/contactless/ioctl.h */
#define _CLIOCVALID(c) (_IOC_TYPE(c)==_CLIOCBASE)
#define _CLIOC(nr) _IOC(_CLIOCBASE,nr)
/* 802.15.4 MAC driver ioctl definitions *******************************************/
/* USB-C controller driver ioctl definitions ********************************/
/* (see nuttx/include/usb/xxx.h */
#define _USBCIOCVALID(c) (_IOC_TYPE(c)==_USBCBASE)
#define _USBCIOC(nr) _IOC(_USBCBASE,nr)
/* 802.15.4 MAC driver ioctl definitions ************************************/
/* (see nuttx/include/wireless/ieee802154/ieee802154_mac.h */
#define _MAC802154IOCVALID(c) (_IOC_TYPE(c)==_MAC802154BASE)
#define _MAC802154IOC(nr) _IOC(_MAC802154BASE,nr)
/* 802.15.4 Radio driver ioctl definitions *******************************************/
/* 802.15.4 Radio driver ioctl definitions **********************************/
/* (see nuttx/ieee802154/wireless/ieee802154_radio.h */
#define _PHY802154IOCVALID(c) (_IOC_TYPE(c)==_PHY802154BASE)

View file

@ -116,6 +116,22 @@
# endif
#endif
#ifndef CONFIG_NET_6LOWPAN_FRAG
# undef CONFIG_NET_6LOWPAN_MTU
# undef CONFIG_NET_6LOWPAN_TCP_RECVWNDO
#endif
#ifndef CONFIG_NET_6LOWPAN_MTU
# undef CONFIG_NET_6LOWPAN_TCP_RECVWNDO
# ifdef CONFIG_NET_6LOWPAN_FRAG
# define CONFIG_NET_6LOWPAN_MTU 1294
# define CONFIG_NET_6LOWPAN_TCP_RECVWNDO 1220
# else
# define CONFIG_NET_6LOWPAN_MTU CONFIG_NET_6LOWPAN_FRAMELEN
# define CONFIG_NET_6LOWPAN_TCP_RECVWNDO (CONFIG_NET_6LOWPAN_FRAMELEN - 25)
# endif
#endif
#if defined(CONFIG_NET_MULTILINK)
/* We are supporting multiple network devices using different link layer
* protocols. Get the size of the link layer header from the device
@ -142,15 +158,23 @@
# endif
# ifdef CONFIG_NET_SLIP
# define _MIN_SLIP_MTU MIN(_MIN_LO_MTU,CONFIG_NET_SLIP_MTU)
# define _MAX_SLIP_MTU MAX(_MAX_LO_MTU,CONFIG_NET_SLIP_MTU)
# define _MIN_SLIP_MTU MIN(_MIN_LO_MTU,CONFIG_NET_6LOWPAN_MTU)
# define _MAX_SLIP_MTU MAX(_MAX_LO_MTU,CONFIG_NET_6LOWPAN_MTU)
# else
# define _MIN_SLIP_MTU _MIN_LO_MTU
# define _MAX_SLIP_MTU _MAX_LO_MTU
# endif
# define MIN_NET_DEV_MTU _MIN_SLIP_MTU
# define MAX_NET_DEV_MTU _MAX_SLIP_MTU
# ifdef CONFIG_NET_6LOWPAN
# define _MIN_6LOWPAN_MTU MIN(_MIN_LO_MTU,CONFIG_NET_SLIP_MTU)
# define _MAX_6LOWPAN_MTU MAX(_MAX_LO_MTU,CONFIG_NET_SLIP_MTU)
# else
# define _MIN_6LOWPAN_MTU _MIN_LO_MTU
# define _MAX_6LOWPAN_MTU _MAX_LO_MTU
# endif
# define MIN_NET_DEV_MTU _MIN_6LOWPAN_MTU
# define MAX_NET_DEV_MTU _MAX_6LOWPAN_MTU
/* For the loopback device, we will use the largest MTU */
@ -190,8 +214,20 @@
# define MIN_NET_DEV_MTU NET_LO_MTU
# define MAX_NET_DEV_MTU NET_LO_MTU
#elif defined(CONFIG_NET_6LOWPAN)
/* There is no link layer header with SLIP */
# ifndef CONFIG_NET_IPv6
# error 6loWPAN requires IPv support
# endif
# define NET_LL_HDRLEN(d) 0
# define NET_DEV_MTU(d) CONFIG_NET_6LOWPAN_MTU
# define MIN_NET_DEV_MTU CONFIG_NET_6LOWPAN_MTU
# define MAX_NET_DEV_MTU CONFIG_NET_6LOWPAN_MTU
#else
/* Perhaps only Unix domain sockets of the loopback device */
/* Perhaps only Unix domain sockets or the loopback device */
# define NET_LL_HDRLEN(d) 0
# define NET_DEV_MTU(d) 0

View file

@ -340,9 +340,12 @@ struct rimeaddr_s
* 5) On network input RX oprations, both buffers must be provided. The size
* of the i_frame buffer is, again, greater than or equal to
* CONFIG_NET_6LOWPAN_FRAMELEN. The larger dev.d_buf must have a size
* of at least <tbd>. The dev.d_buf is used for de-compressing each
* frame and reassembling any fragmented packets to create the full input
* packet that is provided to the applicatino.
* of at least the advertised MTU of the protocol, CONFIG_NET_6LOWPAN_MTU.
* If fragmentation is enabled, then the logical packet size may be
* significantly larger than the size of the frame buffer. The dev.d_buf
* is used for de-compressing each frame and reassembling any fragmented
* packets to create the full input packet that is provided to the
* application.
*
* Frame Organization:
*

View file

@ -117,10 +117,11 @@ typedef struct hts221_settings_s
typedef struct hts221_config_s
{
int irq;
CODE int (*irq_attach)(FAR struct hts221_config_s * state, xcpt_t isr);
CODE void (*irq_enable)(FAR const struct hts221_config_s * state,
CODE int (*irq_attach)(FAR struct hts221_config_s * state, xcpt_t isr,
FAR void *arg);
CODE void (*irq_enable)(FAR const struct hts221_config_s *state,
bool enable);
CODE void (*irq_clear)(FAR const struct hts221_config_s * state);
CODE void (*irq_clear)(FAR const struct hts221_config_s *state);
CODE int (*set_power)(FAR const struct hts221_config_s *state, bool on);
} hts221_config_t;

View file

@ -125,4 +125,12 @@
#define SNIOC_READ_CONVERT_DATA _SNIOC(0x002f)
#define SNIOC_DUMP_REGS _SNIOC(0x0030)
/* IOCTL commands unique to the LPS25H */
#define SNIOC_GET_DEV_ID _SNIOC(0x0031)
#define SNIOC_CFGR _SNIOC(0x0032)
#define SNIOC_TEMPERATURE_OUT _SNIOC(0x0033)
#define SNIOC_PRESSURE_OUT _SNIOC(0x0034)
#define SNIOC_SENSOR_OFF _SNIOC(0x0035)
#endif /* __INCLUDE_NUTTX_SENSORS_IOCTL_H */

View file

@ -0,0 +1,105 @@
/****************************************************************************
* include/nuttx/sensors/lps25h.h
*
* Copyright (C) 2014, 2017 Haltian Ltd. All rights reserved.
*
* 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 __INCLUDE_NUTT_SENSORS_LPS25H_H
#define __INCLUDE_NUTT_SENSORS_LPS25H_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/sensors/ioctl.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define LPS25H_TEMPER_DIVIDER 1000
#define LPS25H_VALID_WHO_AM_I 0xbd
/****************************************************************************
* Public Types
****************************************************************************/
typedef struct lps25h_temper_data_s
{
int32_t int_temper; /* int_temper value must be divided by
* LPS25H_TEMPER_DIVIDER in your app code */
int16_t raw_data;
} lps25h_temper_data_t;
typedef struct lps25h_pressure_data_s
{
uint32_t pressure_int_hP;
uint32_t pressure_Pa;
uint32_t raw_data;
} lps25h_pressure_data_t;
typedef struct lps25h_who_am_i_data
{
uint8_t who_am_i;
} lps25h_who_am_i_data;
typedef struct lps25h_config_s
{
/* Device characterization */
int irq; /* IRQ number received by interrupt handler. */
/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks
* to isolate the driver from differences in GPIO interrupt handling
* by varying boards and MCUs.
* irq_attach - Attach the interrupt handler to the GPIO interrupt
* irq_enable - Enable or disable the GPIO
* irq_clear - Acknowledge/clear any pending GPIO interrupt
* set_power - Ask board to turn on regulator
*/
CODE int (*irq_attach)(FAR struct lps25h_config_s *state, xcpt_t isr,
FAR void *arg);
CODE void (*irq_enable)(FAR const struct lps25h_config_s *state,
bool enable);
CODE void (*irq_clear)(FAR const struct lps25h_config_s *state);
CODE int (*set_power)(FAR const struct lps25h_config_s *state, bool on);
} lps25h_config_t;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int lps25h_register(FAR const char *devpath, FAR struct i2c_master_s *i2c,
uint8_t addr, FAR lps25h_config_t *config);
#endif /* __INCLUDE_NUTT_SENSORS_LPS25H_H */

243
include/nuttx/usb/fusb301.h Normal file
View file

@ -0,0 +1,243 @@
/****************************************************************************
* include/nuttx/usb/fusb301.h
* FUSB301 USB type-C controller driver
*
* Copyright (C) 2016-2017 Haltian Ltd. All rights reserved.
* Authors: Harri Luhtala <harri.luhtala@haltian.com>
*
* 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 __INCLUDE_NUTTX_USB_FUSB301_H
#define __INCLUDE_NUTTX_USB_FUSB301_H
#include <nuttx/fs/ioctl.h>
/************************************************************************************
* Pre-Processor Declarations
************************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* IOCTL Commands ***********************************************************/
#define USBCIOC_READ_DEVID _USBCIOC(0x0001) /* Arg: uint8_t* pointer */
#define USBCIOC_SETUP _USBCIOC(0x0002) /* Arg: uint8_t* pointer */
#define USBCIOC_SET_MODE _USBCIOC(0x0003) /* Arg: uint8_t value */
#define USBCIOC_SET_STATE _USBCIOC(0x0004) /* Arg: uint8_t value */
#define USBCIOC_READ_STATUS _USBCIOC(0x0005) /* Arg: uint8_t* pointer*/
#define USBCIOC_READ_DEVTYPE _USBCIOC(0x0006) /* Arg: uint8_t* pointer*/
#define USBCIOC_RESET _USBCIOC(0x0007) /* Arg: None */
/************************************************************************************
* Public Types
************************************************************************************/
enum fusb301_reg_address_e
{
FUSB301_DEV_ID_REG = 0x01,
FUSB301_MODE_REG,
FUSB301_CONTROL_REG,
FUSB301_MANUAL_REG,
FUSB301_RESET_REG,
FUSB301_MASK_REG = 0x10,
FUSB301_STATUS_REG,
FUSB301_TYPE_REG,
FUSB301_INTERRUPT_REG
};
/* Device ID - 0x01 */
enum fusb301_devid_mask_e
{
DEV_ID_REVISION_MASK = 0x0F,
DEV_ID_VERSION_MASK = 0xF0
};
#define DEV_ID_VER_A 0x10
#define DEV_ID_REV_C 0x02
/* Modes - 0x02 */
enum fusb301_mode_e
{
MODE_SRC = (1 << 0),
MODE_SRC_ACC = (1 << 1),
MODE_SNK = (1 << 2),
MODE_SNK_ACC = (1 << 3),
MODE_DRP = (1 << 4),
MODE_DRP_ACC = (1 << 5)
};
/* Control - 0x03 */
enum fusb301_control_e
{
CONTROL_INT_ENABLE = (0 << 0),
CONTROL_INT_DISABLE = (1 << 0),
CONTROL_CUR_DISABLED = (0 << 1),
CONTROL_CUR_DEFAULT = (1 << 1),
CONTROL_CUR_1500 = (2 << 1),
CONTROL_CUR_3000 = (3 << 1),
CONTROL_TGL_35_15MS = (0 << 4),
CONTROL_TGL_30_20MS = (1 << 4),
CONTROL_TGL_25_25MS = (2 << 4),
CONTROL_TGL_20_30MS = (3 << 4)
};
/* Manual - 0x04 */
enum fusb301_manual_e
{
MANUAL_ERROR_REC = (1 << 0),
MANUAL_DISABLED = (1 << 1),
MANUAL_UNATT_SRC = (1 << 2),
MANUAL_UNATT_SNK = (1 << 3)
};
/* Reset - 0x05 */
enum fusb301_reset_e
{
RESET_SW_RES = (1 << 0)
};
/* Interrupt mask - 0x10 */
enum fusb301_int_mask_e
{
INT_MASK_ATTACK = (1 << 0),
INT_MASK_DETACH = (1 << 1),
INT_MASK_BC_LVL = (1 << 2),
INT_MASK_ACC_CH = (1 << 3)
};
/* Status - 0x11 */
enum fusb301_status_e
{
STATUS_ATTACH = (1 << 0),
STATUS_BC_SINK_UNATT = (0 << 1),
STATUS_BC_SINK_DEF = (1 << 1),
STATUS_BC_SINK_1500 = (2 << 1),
STATUS_BC_SINK_3000 = (3 << 1),
STATUS_VBUS_OK = (1 << 3),
STATUS_CC_NO_CONN = (0 << 4),
STATUS_CC_1 = (1 << 4),
STATUS_CC_2 = (2 << 4),
STATUS_CC_FAULT = (3 << 4)
};
/* Type - 0x12 */
enum fusb301_type_e
{
TYPE_AUDIOACC = (1 << 0),
TYPE_DEBUGACC = (1 << 1),
TYPE_SOURCE = (1 << 3),
TYPE_SINK = (1 << 4)
};
/* Interrupt - 0x13 */
enum fusb301_interrupt_e
{
INTERRUPT_ATTACH = (1 << 0),
INTERRUPT_DETACH = (1 << 1),
INTERRUPT_BC_LVL = (1 << 2),
INTERRUPT_ACC_CH = (1 << 3)
};
struct fusb301_result_s
{
uint8_t status;
uint8_t dev_type;
};
struct fusb301_setup_s
{
uint8_t drp_toggle_timing;
uint8_t host_current;
uint8_t int_mask;
bool global_int_mask;
};
struct fusb301_config_s
{
/* Device characterization */
int irq;
CODE int (*irq_attach)(FAR struct fusb301_config_s *state, xcpt_t isr,
FAR void *arg);
CODE void (*irq_enable)(FAR struct fusb301_config_s *state, bool enable);
CODE void (*irq_clear)(FAR struct fusb301_config_s *state);
};
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
/****************************************************************************
* Name: fusb301_register
*
* Description:
* Register the FUSB301 character device as 'devpath'
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/usbc0"
* i2c - An instance of the I2C interface to use to communicate with FUSB301
* addr - The I2C address of the FUSB301. The I2C address of the FUSB301 is 0x25.
* config - Pointer to FUSB301 configuration
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int fusb301_register(FAR const char *devpath, FAR struct i2c_master_s *i2c,
uint8_t addr, FAR struct fusb301_config_s *config);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __INCLUDE_NUTTX_USB_FUSB301_H */