drivers/wireless/ieee802154/Kconfig
drivers/wireless/ieee802154/Make.defs Changes to the build infrastructure to include the mrf24j40 driver include/nuttx/spi/spi.h Define a IEEE SPI device include/nuttx/wireless/ieee802154/ieee802154_radio.h This file defines the API of a IEEE 802.15.4 radio device, to be used by the future common MAC 802.15.4 layer drivers/wireless/ieee802154/mrf24j40.c drivers/wireless/ieee802154/mrf24j40.h The main MRF24J40 IEEE 802.15.4 radio driver include/nuttx/wireless/ieee802154/mrf24j40.h This file allows instanciation of the MRF24j40 driver from board configurations
This commit is contained in:
parent
d84fa1689a
commit
dc7adfa817
@ -556,9 +556,7 @@ menuconfig DRIVERS_WIRELESS
|
||||
---help---
|
||||
Drivers for various wireless devices.
|
||||
|
||||
if DRIVERS_WIRELESS
|
||||
source drivers/wireless/Kconfig
|
||||
endif # DRIVERS_WIRELESS
|
||||
|
||||
comment "System Logging Device Options"
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
if DRIVERS_WIRELESS
|
||||
|
||||
config WL_CC1101
|
||||
bool "CC1101 RF transceiver support"
|
||||
default n
|
||||
@ -15,16 +17,14 @@ menuconfig WL_CC3000
|
||||
|
||||
source drivers/wireless/cc3000/Kconfig
|
||||
|
||||
menuconfig IEEE802154
|
||||
menuconfig DRIVERS_IEEE802154
|
||||
bool "IEEE 802.15.4 Device Support"
|
||||
default n
|
||||
depends on EXPERIMENTAL
|
||||
---help---
|
||||
This directory holds implementations of IEEE802.15.4 device drivers.
|
||||
|
||||
if IEEE802154
|
||||
source drivers/wireless/ieee802154/Kconfig
|
||||
endif
|
||||
|
||||
config WL_NRF24L01
|
||||
bool "nRF24l01+ transceiver support"
|
||||
@ -103,3 +103,4 @@ config WL_PN532_DEBUG_RX
|
||||
depends on WL_PN532_DEBUG
|
||||
|
||||
endif # WL_PN532
|
||||
endif # DRIVERS_WIRELESS
|
||||
|
@ -2,3 +2,13 @@
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
if DRIVERS_IEEE802154
|
||||
|
||||
config IEEE802154_MRF24J40
|
||||
bool "Microchip MRF24J40 IEEE 802.15.4 transceiver"
|
||||
default n
|
||||
---help---
|
||||
This selection enables support for the Microchip MRF24J40 device.
|
||||
|
||||
endif # DRIVERS_IEEE802154
|
||||
|
@ -37,9 +37,13 @@
|
||||
|
||||
ifeq ($(CONFIG_DRIVERS_IEEE802154),y)
|
||||
|
||||
# Include common IEEE 802.15.4
|
||||
# Include common IEEE 802.15.4 files into the build
|
||||
|
||||
# Include IEEE 802.15.4 drivers
|
||||
# Include IEEE 802.15.4 drivers into the build
|
||||
|
||||
ifeq ($(CONFIG_IEEE802154_MRF24J40),y)
|
||||
CSRCS += mrf24j40.c
|
||||
endif
|
||||
|
||||
# Include IEEE 802.15.4 build support
|
||||
|
||||
|
1398
drivers/wireless/ieee802154/mrf24j40.c
Normal file
1398
drivers/wireless/ieee802154/mrf24j40.c
Normal file
File diff suppressed because it is too large
Load Diff
206
drivers/wireless/ieee802154/mrf24j40.h
Normal file
206
drivers/wireless/ieee802154/mrf24j40.h
Normal file
@ -0,0 +1,206 @@
|
||||
/****************************************************************************
|
||||
* drivers/wireless/ieee802154/mrf24j40.h
|
||||
*
|
||||
* Copyright (C) 2015-2016 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
* 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 __DRIVERS_IEEE802154_MRF24J40_H
|
||||
#define __DRIVERS_IEEE802154_MRF24J40_H
|
||||
|
||||
/* MRF24J40 Registers *******************************************************/
|
||||
|
||||
#define MRF24J40_RXMCR 0x00
|
||||
#define MRF24J40_PANIDL 0x01
|
||||
#define MRF24J40_PANIDH 0x02
|
||||
#define MRF24J40_SADRL 0x03
|
||||
#define MRF24J40_SADRH 0x04
|
||||
#define MRF24J40_EADR0 0x05
|
||||
#define MRF24J40_EADR1 0x06
|
||||
#define MRF24J40_EADR2 0x07
|
||||
#define MRF24J40_EADR3 0x08
|
||||
#define MRF24J40_EADR4 0x09
|
||||
#define MRF24J40_EADR5 0x0A
|
||||
#define MRF24J40_EADR6 0x0B
|
||||
#define MRF24J40_EADR7 0x0C
|
||||
#define MRF24J40_RXFLUSH 0x0D
|
||||
#define MRF24J40_ORDER 0x10
|
||||
#define MRF24J40_TXMCR 0x11
|
||||
#define MRF24J40_ACKTMOUT 0x12
|
||||
#define MRF24J40_ESLOTG1 0x13
|
||||
#define MRF24J40_SYMTICKL 0x14
|
||||
#define MRF24J40_SYMTICKH 0x15
|
||||
#define MRF24J40_PACON0 0x16
|
||||
#define MRF24J40_PACON1 0x17
|
||||
#define MRF24J40_PACON2 0x18
|
||||
#define MRF24J40_TXBCON0 0x1A
|
||||
#define MRF24J40_TXNCON 0x1B
|
||||
#define MRF24J40_TXG1CON 0x1C
|
||||
#define MRF24J40_TXG2CON 0x1D
|
||||
#define MRF24J40_ESLOTG23 0x1E
|
||||
#define MRF24J40_ESLOTG45 0x1F
|
||||
#define MRF24J40_ESLOTG67 0x20
|
||||
#define MRF24J40_TXPEND 0x21
|
||||
#define MRF24J40_WAKECON 0x22
|
||||
#define MRF24J40_FRMOFFSET 0x23
|
||||
#define MRF24J40_TXSTAT 0x24
|
||||
#define MRF24J40_TXBCON1 0x25
|
||||
#define MRF24J40_GATECLK 0x26
|
||||
#define MRF24J40_TXTIME 0x27
|
||||
#define MRF24J40_HSYMTMRL 0x28
|
||||
#define MRF24J40_HSYMTMRH 0x29
|
||||
#define MRF24J40_SOFTRST 0x2A
|
||||
#define MRF24J40_SECCON0 0x2C
|
||||
#define MRF24J40_SECCON1 0x2C
|
||||
#define MRF24J40_TXSTBL 0x2E
|
||||
#define MRF24J40_RXSR 0x30
|
||||
#define MRF24J40_INTSTAT 0x31
|
||||
#define MRF24J40_INTCON 0x32
|
||||
#define MRF24J40_GPIO 0x33
|
||||
#define MRF24J40_TRISGPIO 0x34
|
||||
#define MRF24J40_SLPACK 0x35
|
||||
#define MRF24J40_RFCTL 0x36
|
||||
#define MRF24J40_SECCR2 0x37
|
||||
#define MRF24J40_BBREG0 0x38
|
||||
#define MRF24J40_BBREG1 0x39
|
||||
#define MRF24J40_BBREG2 0x3A
|
||||
#define MRF24J40_BBREG3 0x3B
|
||||
#define MRF24J40_BBREG4 0x3C
|
||||
#define MRF24J40_BBREG6 0x3E
|
||||
#define MRF24J40_CCAEDTH 0x3F
|
||||
|
||||
#define MRF24J40_RFCON0 0x80000200
|
||||
#define MRF24J40_RFCON1 0x80000201
|
||||
#define MRF24J40_RFCON2 0x80000202
|
||||
#define MRF24J40_RFCON3 0x80000203
|
||||
#define MRF24J40_RFCON5 0x80000205
|
||||
#define MRF24J40_RFCON6 0x80000206
|
||||
#define MRF24J40_RFCON7 0x80000207
|
||||
#define MRF24J40_RFCON8 0x80000208
|
||||
#define MRF24J40_SLPCAL0 0x80000209
|
||||
#define MRF24J40_SLPCAL1 0x8000020A
|
||||
#define MRF24J40_SLPCAL2 0x8000020B
|
||||
#define MRF24J40_RFSTATE 0x8000020F
|
||||
#define MRF24J40_RSSI 0x80000210
|
||||
#define MRF24J40_SLPCON0 0x80000211
|
||||
#define MRF24J40_SLPCON1 0x80000220
|
||||
#define MRF24J40_WAKETIMEL 0x80000222
|
||||
#define MRF24J40_WAKETIMEH 0x80000223
|
||||
#define MRF24J40_REMCNTL 0x80000224
|
||||
#define MRF24J40_REMCNTH 0x80000225
|
||||
#define MRF24J40_MAINCNT0 0x80000226
|
||||
#define MRF24J40_MAINCNT1 0x80000227
|
||||
#define MRF24J40_MAINCNT2 0x80000228
|
||||
#define MRF24J40_MAINCNT3 0x80000229
|
||||
#define MRF24J40_TESTMODE 0x8000022F
|
||||
#define MRF24J40_ASSOEADR0 0x80000230
|
||||
#define MRF24J40_ASSOEADR1 0x80000231
|
||||
#define MRF24J40_ASSOEADR2 0x80000232
|
||||
#define MRF24J40_ASSOEADR3 0x80000233
|
||||
#define MRF24J40_ASSOEADR4 0x80000234
|
||||
#define MRF24J40_ASSOEADR5 0x80000235
|
||||
#define MRF24J40_ASSOEADR6 0x80000236
|
||||
#define MRF24J40_ASSOEADR7 0x80000237
|
||||
#define MRF24J40_ASSOSADR0 0x80000238
|
||||
#define MRF24J40_ASSOSADR1 0x80000239
|
||||
#define MRF24J40_UPNONCE0 0x80000240
|
||||
#define MRF24J40_UPNONCE1 0x80000241
|
||||
#define MRF24J40_UPNONCE2 0x80000242
|
||||
#define MRF24J40_UPNONCE3 0x80000243
|
||||
#define MRF24J40_UPNONCE4 0x80000244
|
||||
#define MRF24J40_UPNONCE5 0x80000245
|
||||
#define MRF24J40_UPNONCE6 0x80000246
|
||||
#define MRF24J40_UPNONCE7 0x80000247
|
||||
#define MRF24J40_UPNONCE8 0x80000248
|
||||
#define MRF24J40_UPNONCE9 0x80000249
|
||||
#define MRF24J40_UPNONCE10 0x8000024A
|
||||
#define MRF24J40_UPNONCE11 0x8000024B
|
||||
#define MRF24J40_UPNONCE12 0x8000024C
|
||||
|
||||
/* INTSTAT bits */
|
||||
|
||||
#define MRF24J40_INTSTAT_SLPIF 0x80
|
||||
#define MRF24J40_INTSTAT_WAKEIF 0x40
|
||||
#define MRF24J40_INTSTAT_HSYMTMRIF 0x20
|
||||
#define MRF24J40_INTSTAT_SECIF 0x10
|
||||
#define MRF24J40_INTSTAT_RXIF 0x08
|
||||
#define MRF24J40_INTSTAT_TXG2IF 0x04
|
||||
#define MRF24J40_INTSTAT_TXG1IF 0x02
|
||||
#define MRF24J40_INTSTAT_TXNIF 0x01
|
||||
|
||||
/* RXMCR bits */
|
||||
|
||||
#define MRF24J40_RXMCR_PROMI 0x01 /* Enable promisc mode (rx all valid packets) */
|
||||
#define MRF24J40_RXMCR_ERRPKT 0x02 /* Do not check CRC */
|
||||
#define MRF24J40_RXMCR_COORD 0x04 /* Enable coordinator mode ??? DIFFERENCE ??? - not used in datasheet! */
|
||||
#define MRF24J40_RXMCR_PANCOORD 0x08 /* Enable PAN coordinator mode ??? DIFFERENCE ??? */
|
||||
#define MRF24J40_RXMCR_NOACKRSP 0x20 /* Enable auto ACK when a packet is rxed */
|
||||
|
||||
/* TXMCR bits */
|
||||
|
||||
#define MRF24J40_TXMCR_CSMABF0 0x01
|
||||
#define MRF24J40_TXMCR_CSMABF1 0x02
|
||||
#define MRF24J40_TXMCR_CSMABF2 0x04
|
||||
#define MRF24J40_TXMCR_MACMINBE0 0x08
|
||||
#define MRF24J40_TXMCR_MACMINBE1 0x10
|
||||
#define MRF24J40_TXMCR_SLOTTED 0x20
|
||||
#define MRF24J40_TXMCR_BATLIFEXT 0x40
|
||||
#define MRF24J40_TXMCR_NOCSMA 0x80
|
||||
|
||||
/* INTCON bits */
|
||||
|
||||
#define MRF24J40_INTCON_SLPIE 0x80
|
||||
#define MRF24J40_INTCON_WAKEIE 0x40
|
||||
#define MRF24J40_INTCON_HSYMTMRIE 0x20
|
||||
#define MRF24J40_INTCON_SECIE 0x10
|
||||
#define MRF24J40_INTCON_RXIE 0x08
|
||||
#define MRF24J40_INTCON_TXG2IE 0x04
|
||||
#define MRF24J40_INTCON_TXG1IE 0x02
|
||||
#define MRF24J40_INTCON_TXNIE 0x01
|
||||
|
||||
/* BBREG1 bits */
|
||||
|
||||
#define MRF24J40_BBREG1_RXDECINV 0x04 /* Enable/Disable packet reception */
|
||||
|
||||
/* BBREG2 bits */
|
||||
|
||||
#define MRF24J40_BBREG2_CCAMODE_ED 0x80
|
||||
#define MRF24J40_BBREG2_CCAMODE_CS 0x40
|
||||
|
||||
/* TXNCON bits */
|
||||
|
||||
#define MRF24J40_TXNCON_TXNTRIG 0x01 /* Trigger packet tx, automatically cleared */
|
||||
#define MRF24J40_TXNCON_TXNSECEN 0x02 /* Enable security */
|
||||
#define MRF24J40_TXNCON_TXNACKREQ 0x04 /* An ACK is requested for this pkt */
|
||||
#define MRF24J40_TXNCON_INDIRECT 0x08 /* Activate indirect tx bit (for coordinators) */
|
||||
#define MRF24J40_TXNCON_FPSTAT 0x10 /* Status of the frame pending big in txed acks */
|
||||
|
||||
#endif /* __DRIVERS_IEEE802154_MRF24J40_H */
|
@ -402,6 +402,7 @@ enum spi_dev_e
|
||||
SPIDEV_ACCELEROMETER, /* Select SPI Accelerometer device */
|
||||
SPIDEV_BAROMETER, /* Select SPI Pressure/Barometer device */
|
||||
SPIDEV_TEMPERATURE, /* Select SPI Temperature sensor device */
|
||||
SPIDEV_IEEE802154, /* Select SPI IEEE 802.15.4 wireless device */
|
||||
SPIDEV_USER /* Board-specific values start here */
|
||||
};
|
||||
|
||||
|
224
include/nuttx/wireless/ieee802154/ieee802154_radio.h
Normal file
224
include/nuttx/wireless/ieee802154/ieee802154_radio.h
Normal file
@ -0,0 +1,224 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/wireless/ieee802154/ieee802154_radio.h
|
||||
*
|
||||
* Copyright (C) 2014-2016 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
* 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_WIRELESS_IEEE802154_IEEE802154_H
|
||||
#define __INCLUDE_NUTTX_WIRELESS_IEEE802154_IEEE802154_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
/* None at the moment */
|
||||
|
||||
/* IEEE 802.15.4 MAC Interface **********************************************/
|
||||
|
||||
/* Frame control field masks, 2 bytes
|
||||
* Seee IEEE 802.15.4/2003 7.2.1.1 page 112
|
||||
*/
|
||||
|
||||
#define IEEE802154_FC1_FTYPE 0x03 /* Frame type, bits 0-2 */
|
||||
#define IEEE802154_FC1_SEC 0x08 /* Security Enabled, bit 3 */
|
||||
#define IEEE802154_FC1_PEND 0x10 /* Frame pending, bit 4 */
|
||||
#define IEEE802154_FC1_ACKREQ 0x20 /* Acknowledge request, bit 5 */
|
||||
#define IEEE802154_FC1_INTRA 0x40 /* Intra PAN, bit 6 */
|
||||
#define IEEE802154_FC2_DADDR 0x0C /* Dest addressing mode, bits 10-11 */
|
||||
#define IEEE802154_FC2_VERSION 0x30 /* Source addressing mode, bits 12-13 */
|
||||
#define IEEE802154_FC2_SADDR 0xC0 /* Source addressing mode, bits 14-15 */
|
||||
|
||||
/* Frame Type */
|
||||
|
||||
#define IEEE802154_FRAME_BEACON 0x00
|
||||
#define IEEE802154_FRAME_DATA 0x01
|
||||
#define IEEE802154_FRAME_ACK 0x02
|
||||
#define IEEE802154_FRAME_COMMAND 0x03
|
||||
|
||||
/* Security Enabled */
|
||||
|
||||
#define IEEE802154_SEC_OFF 0x00
|
||||
#define IEEE802154_SEC_ON 0x08
|
||||
|
||||
/* Flags */
|
||||
|
||||
#define IEEE802154_PEND 0x10
|
||||
#define IEEE802154_ACK_REQ 0x20
|
||||
#define IEEE802154_INTRA 0x40
|
||||
|
||||
/* Dest Addressing modes */
|
||||
|
||||
#define IEEE802154_DADDR_NONE 0x00
|
||||
#define IEEE802154_DADDR_SHORT 0x08
|
||||
#define IEEE802154_DADDR_EXT 0x0A
|
||||
|
||||
/* Src Addressing modes */
|
||||
|
||||
#define IEEE802154_SADDR_NONE 0x00
|
||||
#define IEEE802154_SADDR_SHORT 0x80
|
||||
#define IEEE802154_SADDR_EXT 0xA0
|
||||
|
||||
/* Some addresses */
|
||||
|
||||
#define IEEE802154_PAN_DEFAULT (uint16_t)0xFFFF
|
||||
#define IEEE802154_SADDR_UNSPEC (uint16_t)0xFFFF
|
||||
#define IEEE802154_SADDR_BCAST (uint16_t)0xFFFE
|
||||
#define IEEE802154_EADDR_UNSPEC (uint8_t*)"\xff\xff\xff\xff\xff\xff\xff\xff"
|
||||
|
||||
#define IEEE802154_CMD_ASSOC_REQ 0x01
|
||||
#define IEEE802154_CMD_ASSOC_RSP 0x02
|
||||
#define IEEE802154_CMD_DIS_NOT 0x03
|
||||
#define IEEE802154_CMD_DATA_REQ 0x04
|
||||
#define IEEE802154_CMD_PANID_CONF_NOT 0x05
|
||||
#define IEEE802154_CMD_ORPHAN_NOT 0x06
|
||||
#define IEEE802154_CMD_BEACON_REQ 0x07
|
||||
#define IEEE802154_CMD_COORD_REALIGN 0x08
|
||||
#define IEEE802154_CMD_GTS_REQ 0x09
|
||||
|
||||
/* Device modes */
|
||||
|
||||
#define IEEE802154_MODE_DEVICE 0x00
|
||||
#define IEEE802154_MODE_COORD 0x01 /* avail in mrf24j40, but why? */
|
||||
#define IEEE802154_MODE_PANCOORD 0x02
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct ieee802154_packet_s
|
||||
{
|
||||
uint8_t len;
|
||||
uint8_t data[127];
|
||||
uint8_t lqi;
|
||||
uint8_t rssi;
|
||||
};
|
||||
|
||||
struct ieee802154_cca_s
|
||||
{
|
||||
uint8_t use_ed : 1; /* CCA using ED */
|
||||
uint8_t use_cs : 1; /* CCA using carrier sense */
|
||||
uint8_t edth; /* Energy detection threshold for CCA */
|
||||
uint8_t csth; /* Carrier sense threshold for CCA */
|
||||
};
|
||||
|
||||
struct ieee802154_dev_s;
|
||||
|
||||
struct ieee802154_devops_s
|
||||
{
|
||||
CODE int (*setchannel)(FAR struct ieee802154_dev_s *dev, uint8_t channel);
|
||||
CODE int (*getchannel)(FAR struct ieee802154_dev_s *dev,
|
||||
FAR uint8_t *channel);
|
||||
|
||||
CODE int (*setpanid)(FAR struct ieee802154_dev_s *dev, uint16_t panid);
|
||||
CODE int (*getpanid)(FAR struct ieee802154_dev_s *dev,
|
||||
FAR uint16_t *panid);
|
||||
|
||||
CODE int (*setsaddr)(FAR struct ieee802154_dev_s *dev, uint16_t saddr);
|
||||
CODE int (*getsaddr)(FAR struct ieee802154_dev_s *dev,
|
||||
FAR uint16_t *saddr);
|
||||
|
||||
CODE int (*seteaddr)(FAR struct ieee802154_dev_s *dev,
|
||||
FAR uint8_t *laddr);
|
||||
CODE int (*geteaddr)(FAR struct ieee802154_dev_s *dev,
|
||||
FAR uint8_t *laddr);
|
||||
|
||||
CODE int (*setpromisc)(FAR struct ieee802154_dev_s *dev, bool promisc);
|
||||
CODE int (*getpromisc)(FAR struct ieee802154_dev_s *dev,
|
||||
FAR bool *promisc);
|
||||
|
||||
CODE int (*setdevmode)(FAR struct ieee802154_dev_s *dev, uint8_t devmode);
|
||||
CODE int (*getdevmode)(FAR struct ieee802154_dev_s *dev,
|
||||
FAR uint8_t *devmode);
|
||||
|
||||
CODE int (*settxpower)(FAR struct ieee802154_dev_s *dev,
|
||||
int32_t txpwr); /* unit = 1 mBm = 1/100 dBm */
|
||||
CODE int (*gettxpower)(FAR struct ieee802154_dev_s *dev,
|
||||
FAR int32_t *txpwr);
|
||||
|
||||
CODE int (*setcca)(FAR struct ieee802154_dev_s *dev,
|
||||
FAR struct ieee802154_cca_s *cca);
|
||||
CODE int (*getcca)(FAR struct ieee802154_dev_s *dev,
|
||||
FAR struct ieee802154_cca_s *cca);
|
||||
|
||||
CODE int (*ioctl)(FAR struct ieee802154_dev_s *ieee, int cmd,
|
||||
unsigned long arg);
|
||||
CODE int (*energydetect)(FAR struct ieee802154_dev_s *dev,
|
||||
FAR uint8_t *energy);
|
||||
CODE int (*rxenable)(FAR struct ieee802154_dev_s *dev, bool state,
|
||||
FAR struct ieee802154_packet_s *packet);
|
||||
CODE int (*transmit)(FAR struct ieee802154_dev_s *dev,
|
||||
FAR struct ieee802154_packet_s *packet);
|
||||
|
||||
/*TODO beacon/sf order*/
|
||||
};
|
||||
|
||||
struct ieee802154_dev_s
|
||||
{
|
||||
FAR const struct ieee802154_devops_s *ops;
|
||||
|
||||
/* Packet reception management */
|
||||
|
||||
struct ieee802154_packet_s *rxbuf;
|
||||
sem_t rxsem;
|
||||
|
||||
/* Packet transmission management */
|
||||
|
||||
sem_t txsem;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_WIRELESS_IEEE802154_MRF24J40_H */
|
111
include/nuttx/wireless/ieee802154/mrf24j40.h
Normal file
111
include/nuttx/wireless/ieee802154/mrf24j40.h
Normal file
@ -0,0 +1,111 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/wireless/ieee802154/mrf24j40.h
|
||||
*
|
||||
* Copyright (C) 2014-2016 Sebastien Lorquet. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
* 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_WIRELESS_IEEE802154_MRF24J40_H
|
||||
#define __INCLUDE_NUTTX_WIRELESS_IEEE802154_MRF24J40_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* The MRF24J40 provides interrupts to the MCU via a GPIO pin. The
|
||||
* following structure provides an MCU-independent mechanism for controlling
|
||||
* the MRF24J40 GPIO interrupt.
|
||||
*
|
||||
* The MRF24J40 interrupt is an active low, *level* interrupt. From Datasheet:
|
||||
* "Note 1: The INTEDGE polarity defaults to:
|
||||
* 0 = Falling Edge. Ensure that the inter-
|
||||
* rupt polarity matches the interrupt pin
|
||||
* polarity of the host microcontroller.
|
||||
* Note 2: The INT pin will remain high or low,
|
||||
* depending on INTEDGE polarity setting,
|
||||
* until INTSTAT register is read."
|
||||
*/
|
||||
|
||||
struct mrf24j40_lower_s
|
||||
{
|
||||
int (*attach)(FAR const struct mrf24j40_lower_s *lower, xcpt_t handler);
|
||||
void (*enable)(FAR const struct mrf24j40_lower_s *lower, int state);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: mrf24j40_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize the IEEE802.15.4 driver. The MRF24J40 device is assumed to be
|
||||
* in the post-reset state upon entry to this function.
|
||||
*
|
||||
* Parameters:
|
||||
* spi - A reference to the platform's SPI driver for the MRF24J40
|
||||
* lower - The MCU-specific interrupt used to control low-level MCU
|
||||
* functions (i.e., MRF24J40 GPIO interrupts).
|
||||
* devno - If more than one MRF24J40 is supported, then this is the
|
||||
* zero based number that identifies the MRF24J40;
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; Negated errno on failure.
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct spi_dev_s; /* Forward reference */
|
||||
FAR struct ieee802154_dev_s *mrf24j40_init(FAR struct spi_dev_s *spi,
|
||||
FAR const struct mrf24j40_lower_s *lower);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_WIRELESS_IEEE802154_MRF24J40_H */
|
Loading…
Reference in New Issue
Block a user