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

This commit is contained in:
Gregory Nutt 2017-06-19 17:27:00 -06:00
commit 4eb548226b
69 changed files with 3735 additions and 1176 deletions

View File

@ -14488,7 +14488,7 @@
pthread_mutex_trytake() which does sem_trywait() and if successful,
does correctly add the mutext to the TCB list. This should
eliminated the assertion (2017-03-29).
* 6loWPAN: IEEE802.15.4 MAC driver will need a special form of the
* 6LoWPAN: IEEE802.15.4 MAC driver will need a special form of the
network device structure to manage fragmentation of the large packet
into frames (2017-03-29).
* wireless/ieee802154: Adds MAC character driver structure.
@ -14544,10 +14544,10 @@
Jussi Kivilinna (2017-03-31).
* TCP/IPv6: Fix a compile issue when IPv6, but not IPv4 is enabled
(2017-03-31).
* net/: Fix MULTINIC/MULTILINK selection when 6loWPAN selected
* net/: Fix MULTINIC/MULTILINK selection when 6LoWPAN selected
(2017-03-31).
* net/: Permit net/neighbor to build when IPv6 is defined, but not
Ethernet. Needs more work to support 6loWPAN (2017-03-31).
Ethernet. Needs more work to support 6LoWPAN (2017-03-31).
* stm32f7: Serial fix for dropped data: (1) Revert the inherited dma
bug from the stm32. see
https://bitbucket.org/nuttx/nuttx/commits/df9ae3c13fc2fff2c21ebdb098c520b11f43280d
@ -14558,7 +14558,7 @@
(2017-03-31).
* stm32f7: stm32_sdmmc removed stray semicolon. From David Sidrane
(2017-03-31).
* 6loWPAN: Contiki 6loWPAN port is now complete (but completely
* 6LoWPAN: Contiki 6LoWPAN port is now complete (but completely
untested) (2017-04-02).
* iee802154 loopback: Eliminate dependency on CONFIG_NET_LOOPBACK
(2017-04-02).
@ -14572,11 +14572,11 @@
* STM32: Add STM32L162VE to chip.h. From Juha Niskanen (2017-04-03).
* iee802154 loopback: Eliminate dependency on CONFIG_NET_LOOPBACK
(2017-04-02).
* sim: Add a configuration for testing 6loWPAN (2017-04-03).
* sim: Add a configuration for testing 6LoWPAN (2017-04-03).
* wireless/ieee802154: Add initialization logic for loopback driver;
configs/sim: Add configuration for testing 6loWPAN; net/sixlowpan:
configs/sim: Add configuration for testing 6LoWPAN; net/sixlowpan:
Fix for compilation with debug output enabled (2017-04-03).
* 6loWPAN: Updates/fixes from initial testing with the IEEE802.15.4
* 6LoWPAN: Updates/fixes from initial testing with the IEEE802.15.4
loopback driver (2017-04-03).
* STM32: Add I2C3 SDA pin mapping for STM32F411. From no1wudi
(2017-04-04).
@ -14584,7 +14584,7 @@
sensor. From Juha Niskanen (2017-04-04).
* STM32: stm32_flash: Add EEPROM writing for STM32L15XX. From Juha
Niskanen (2017-04-04).
* 6loWPAN: Add option to dump buffers (2017-04-04).
* 6LoWPAN: Add option to dump buffers (2017-04-04).
* STM32: stm32l15xx_rcc: Add support for using MSI as system clock.
From Juha Niskanen (2017-04-05).
* STM32: stm32l15xxx_rcc: configure medium performance voltage range
@ -14634,7 +14634,7 @@
to detect if RTC has valid time (after reset) or should application
attempt to get real time by other means (for example, by launching
ntpclient or GPS). From Jussi Kivilinna (2017-04-06).
* 6loWPAN: Add network IOCTL support to set the node address
* 6LoWPAN: Add network IOCTL support to set the node address
(2017-04-06).
* EFM32 I2C: Fix timeout calculation. From Masayuki Ishikawa
(2017-04-06).
@ -14646,7 +14646,7 @@
priority, such that if any writers come in they are given priority
for writing. From Mark Schulte (2017-04-07).
* pthread rwlock bugfixes. From Mark Schulte (2017-04-07).
* 6loWPAN: Add calculation of TCP header size. It is not a constant
* 6LoWPAN: Add calculation of TCP header size. It is not a constant
(2017-04-07).
* Restore TCP_HDRLEN to MSS calculation. Also add to UDP MSS
calculation where it never appearred. Add some missing MSS and
@ -14741,7 +14741,7 @@
CONFIG_NETDEV_MULTINIC. From Andreas Bihlmaier (2017-04-15).
* networking: IPv4 change of last PR should also be applied to
corresponding IPv6 logic (2017-04-15).
* 6loWPAN: Add some checks for the case where there are multiple
* 6LoWPAN: Add some checks for the case where there are multiple
network devices and multiple link layer protocols (2017-04-15).
* net/: Add IOCTL support for forwarding IEEE802.15.4 MAC and PHY
IOCTLs (2017-04-15).
@ -14764,9 +14764,9 @@
* photon: Add sdpcm tx basic support. From Simon Piriou (2017-04-16).
* photon: Request firmware version and MAC address. From Simon Piriou
(2017-04-16).
* 6loWPAN network driver: Still only a skeleton but has some added
* 6LoWPAN network driver: Still only a skeleton but has some added
thought experimentation (2017-04-16).
* 6loWPAN: Correct ordering of headers. fragmentation header was
* 6LoWPAN: Correct ordering of headers. fragmentation header was
coming out before FCF (2017-04-16).
* wireless/ieee802154: Continues development on transmit structure.
From Anthony Merlino (2017-04-17).
@ -14811,14 +14811,14 @@
mac802154_chardevice_s. From Anthony Merlino (2017-04-19).
* wireless/ieee802154: Changes radio interface to match MAC callback
design. From Anthony Merlino (2017-04-19).
* 6loWPAN: Fix a missing source address in header. Correct
* 6LoWPAN: Fix a missing source address in header. Correct
calculation of payload size (2017-04-19).
* SAMV7 EMAC: Add conditional logic to account the fact that the
SAMV71 has 6 rather than 3 queues after version 1. From Ian McAfee
(2017-04-19).
* wireless/ieee802154: Starts structuring transmission completion
handling. From Anthony Merlino (2017-04-19).
* 6loWPAN: Add an IOCTL to set the IEEE802.15.4 PAN ID (2017-04-19).
* 6LoWPAN: Add an IOCTL to set the IEEE802.15.4 PAN ID (2017-04-19).
* STM32 L1: stm32l15xx_rcc: Allow board to configure HSE clock in
bypass-mode. Allows using MCO output from ST-link chip (on Nucleo
and Discovery boards) as HSE input. From Juha Niskanen (2017-04-20).
@ -14852,17 +14852,17 @@
Jussi Kivilinna (2017-04-21).
* wireless/ieee802154: Simplifies TX completion interface. Documents
and cleans up some functions. From Anthony Merlino (2017-04-21).
* Remove the 6loWPAN PANID IOCTLs they are redundant (2017-04-21).
* 6loWPAN: Remove the PAN ID from the 6loWPAN data structure. This is
* Remove the 6LoWPAN PANID IOCTLs they are redundant (2017-04-21).
* 6LoWPAN: Remove the PAN ID from the 6LoWPAN data structure. This is
owned by the radio driver. Rather, use an IOCTL to obtain the PAN ID
from the downstream radio driver (2017-04-21).
* photon: Add basic wlan scan function. From Simon Piriou (2017-04-22).
* 6loWPAN: Separate MAC-related definitions from sixlowpan.h. Put in
* 6LoWPAN: Separate MAC-related definitions from sixlowpan.h. Put in
ieee802154.h (2017-04-22).
* net/: network drver now retains Ethernet MAC address in a union so
that other link layer addresses may be used in a MULTILINK
environment (2017-04-22).
* 6loWPAN: Add IEEE802.15.4 Rime address to union of link layer
* 6LoWPAN: Add IEEE802.15.4 Rime address to union of link layer
addresses in the network driver (2017-04-22).
* SAM3/4: Fixed configurations for TWI master. Obviously an
incomplete port from SAMA5 (2017-04-23).
@ -14945,7 +14945,7 @@
Simon Piriou (2017-04-28).
* Add all network IOCTLs to include/sys/ioctl.h (2017-04-28).
* Add all ieee802.15.4 IOCTLs to include/sys/ioctl.h (2017-04-28).
* 6loWPAN: Can't reuse same header on each fragment. DSN needs to
* 6LoWPAN: Can't reuse same header on each fragment. DSN needs to
increment (2017-04-29).
* SPI: Add an instance argument to the SPIDEV definitions (2017-04-29).
* STM32F0: Add some protection. There is only one interrupt for
@ -15004,7 +15004,7 @@
F7. From Juha Niskanen (2017-05-02).
* STM32L4: stm32l4x6xx_pinmap: Update I2C4 and DCMI pins. From Juha
Niskanen (2017-05-02).
* 6loWPAN: Add basic call path to interface with the MAC layer through
* 6LoWPAN: Add basic call path to interface with the MAC layer through
the MAC network driver. Logic has not yet been implemented. This is
just a structural change in preparation for additional changes
(2017-05-02).
@ -15012,11 +15012,11 @@
Merlino (2017-05-02).
* wireless/ieee802154: Finishes some IOCTL logic for MAC layer. From
Anthony Merlino (2017-05-02).
* 6loWPAN: Changes to use new MAC interfaces. Incomplete and needs
* 6LoWPAN: Changes to use new MAC interfaces. Incomplete and needs
some clean-up of dangling, unused definitions (2017-05-03).
* wireless/ieee802154: Starts work on setting PIB attributes. From
Anthony Merlino (2017-05-03).
* 6loWPAN: Fixes hang in loopback test (2017-05-03).
* 6LoWPAN: Fixes hang in loopback test (2017-05-03).
* drivers/wireless/bcmf: Fix frame not freed when dropped + cleanup.
From Simon Piriou (2017-05-03).
* STM32L4: stm32l4_i2c: Change wrong macro to CONFIG_I2C_POLLED. From
@ -15040,11 +15040,11 @@
* Fix STM32F7 I2C interrupt handler. From Jussi Kivilinna (2017-05-04).
* STM32F7 serial: Allow configuring Rx DMA buffer size. From Jussi
Kivilinna (2017-05-04).
* 6loWPAN: Replace Rime address naming with more consistent
* 6LoWPAN: Replace Rime address naming with more consistent
short/exended address terminology (2017-05-04).
* 6loWPAN: Remove all ieee802.15.4 MAC knowledge from 6loWPAN. Now
* 6LoWPAN: Remove all ieee802.15.4 MAC knowledge from 6LoWPAN. Now
relies on wires/ieee802154 for all MAC-related operations (2017-05-04).
* 6loWPAN: Local address length is fixed by the configuration. The
* 6LoWPAN: Local address length is fixed by the configuration. The
remote address be with short or extended (2017-05-04).
* STM32L4: Separate SYSCFG into product line specific files for
clarity. From Juha Niskanen (2017-05-05).
@ -15075,7 +15075,7 @@
(2017-05-05).
* STM32L4: Add support for many new MCUs from STM32L4X3XX product line
and Nucleo-L452 board. From Juha Niskanen (2017-05-05).
* 6loWPAN: Use information in struct ieee802154_data_ind_s when
* 6LoWPAN: Use information in struct ieee802154_data_ind_s when
reassembling a packet (2017-05-05).
* ieee 802.15.4: Add a pool-based memory allocator for RX frame
meta-data (2017-05-05).
@ -15096,7 +15096,7 @@
Hides private data. From Anthony Merlino (2017-05-06).
* STM32: Serial Allow configuring Rx DMA buffer size. From David
Sidrane (2017-05-06).
* 6loWPAN: Minor cleanup and re-verification of all compression modes
* 6LoWPAN: Minor cleanup and re-verification of all compression modes
after so many recent changes (2017-05-06).
* Update the C coding standard document (2017-05-06).
* IEEE 802.15.4 network driver. Remove support for multicast address

View File

@ -816,7 +816,7 @@
<td><br></td>
<td>
<p>
<li>IEEE 802.15.4 MAC + 6loWPAN</li>
<li>IEEE 802.15.4 MAC + 6LoWPAN</li>
</p>
</td>
</tr>
@ -3998,7 +3998,7 @@ nsh>
<p>
<b>MikroElektronika Clicker2 for STM32</b>.
This is yet another board supported by NuttX that uses the same STM32F407VGT6 MCU as does the STM32F4-Discovery board.
This board has been used primarily with the MRF24J40 Click board for the development of IEEE 802.15.4 MAC and 6loWPAN support.
This board has been used primarily with the MRF24J40 Click board for the development of IEEE 802.15.4 MAC and 6LoWPAN support.
<p>
See the <a href="https://shop.mikroe.com/development-boards/starter/clicker-2/stm32f4">Mikroelektronika</a> website for more information about this board and the NuttX board <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/clicker2-stm32/README.txt" target="_blank">README</a> file for further information about the NuttX port.
</p>

View File

@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec">
<i>NuttX C Coding Standard</i>
</font></big></h1>
<p>Last Updated: June 11, 2017</p>
<p>Last Updated: June 18, 2017</p>
</td>
</tr>
</table>
@ -2290,6 +2290,14 @@ x++;
<h2>4.5 <a name="switch"><code>switch</code> Statement</a></h2>
<p><b>Definitions:</b></p>
<ul>
<li>
<b><i>Case logic</i></b>.
By <i>case logic</i> it is mean the <code>case</code> or <code>default</code> and all of the lines of code following the <code>case</code> or <code>default</code> up to the next <code>case</code>, <code>default</code>, or the right brace indicating the end of the switch statement.
</li>
</ul>
<p><b>Coding Standard:</b></p>
<ul>
<li>
@ -2306,17 +2314,22 @@ x++;
The <code>default</code> case should always be present and trigger an error if it is reached when it should not be.
</li>
<li>
<b>Case logic in braces</b>.
It is preferable that all case logic (except for the <code>break</code>) be enclosed in braces.
<b><i>Case logic</i> in braces</b>.
It is preferable that all <i>case logic</i> (except for the <code>break</code>) be enclosed in braces.
If you need to instantiate local variables in case logic, then that logic must be surrounded with braces.
</li>
<li>
<b><code>break</code> outside of braces</b>.
<code>break</code> statements are normally indented by two spaces.
When used conditionally with case logic, the placement of the break statement follows normal indentation rules.
When used conditionally with <i>case logic</i>, the placement of the break statement follows normal indentation rules.
</li>
<li>
<b>Followed by a single blank line</b>.
<b><i>Case logic</i> followed by a single blank line</b>.
A single blank line must separate the <i>case logic</i> and any following <code>case</code> or <code>default</code>.
The should, however, be no blank lines between the <i>case logic</i> and the closing right brace.
</li>
<li>
<b>Switch followed by a single blank line</b>.
The final right brace that closes the <code>switch &lt;value&gt;</code> statement must be followed by a single blank line.
</li>
<li>

View File

@ -1,4 +1,4 @@
6loWPAN IPv6 over Low power Wireless Personal Area Networks
6LoWPAN IPv6 over Low power Wireless Personal Area Networks
ACM Abstract Control Model (USB)
ADC Analog to Digital Conversion
AIC Advanced Interrupt Controller (Atmel SAM)

View File

@ -13652,8 +13652,8 @@ Additional new features and extended functionality:
incomplete and has not been verified.
- IEEE 802.15.4 Network Loopback Driver: A simple IEEE 802.15.4 MAC
loopback driver was developed. This driver allowed for parallel
development of the IEEE 802.15.4 MAC and 6loWPAN.
- 6loWPAN: The Contiki 6loWPAN stack has been ported so that works
development of the IEEE 802.15.4 MAC and 6LoWPAN.
- 6LoWPAN: The Contiki 6LoWPAN stack has been ported so that works
within the NuttX networking framework and interfaces with the new
IEEE 802.15.4 MAC via the network driver. Live testing with
IEEE 802.15.4 radios has not yet been done; all testing has used
@ -13721,7 +13721,7 @@ Additional new features and extended functionality:
* Simulation
- configs/sim/sixlowpan: Configuration for testing the 6loWPAN with
- configs/sim/sixlowpan: Configuration for testing the 6LoWPAN with
the IEEE 802.15.4 loopback network driver.
* Infineon XMC4xxx:
@ -13926,7 +13926,7 @@ Additional new features and extended functionality:
default is +x. No printing of a trace of script commands as they are
executed. From David Sidrane.
- Print expanded variables if -x. From David Sidrane.
- ifconfig command: Extend ifconfig to support 6loWPAN. Adapt to
- ifconfig command: Extend ifconfig to support 6LoWPAN. Adapt to
some changes in configuration variable usage.
- Network initialization: If IEEE802.11 selected use wlan0 instead of
eth0 for network device name.
@ -13949,11 +13949,11 @@ Additional new features and extended functionality:
cleanup handlers. From Juha Niskanen.
- examples/usrsocktest: Add application for USRSOCK testing. From
Jussi Kivilinna.
- examples/nettest: Adapt for use in testing 6loWPAN.
- examples/nettest: Adapt for use in testing 6LoWPAN.
- examples/nettest: If doing loopback, but not using the official
loopback device, then use the server should use the configured client
IP address.
- examples/udpblaster: Several fixes to work with 6loWPAN.
- examples/udpblaster: Several fixes to work with 6LoWPAN.
- examples/udpblaster: Add logic to bind the local UDP socket to a
well-known address.
- examples/configdata: Add stacksize and priority. From Juha Niskanen.
@ -13962,7 +13962,7 @@ Additional new features and extended functionality:
- netutils/netlib: Add IEEE 802.11 wireless IOCTL wrappers.
- netutils/netlib: Add a helper function to convert a string to a
6loWPAN node address.
6LoWPAN node address.
- netlib and NSH: Add logic to get/set the IEEE802.15.4 PAN ID.
- netutils/dhcpc: Make the network device name a configuration
option. Was hardcoded to eth0 but may, instead, need to be wlan0.

296
TODO
View File

@ -1,4 +1,4 @@
NuttX TODO List (Last updated June 14, 2017)
NuttX TODO List (Last updated June 18, 2017)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This file summarizes known NuttX bugs, limitations, inconsistencies with
@ -9,22 +9,22 @@ issues related to each board port.
nuttx/:
(11) Task/Scheduler (sched/)
(12) Task/Scheduler (sched/)
(1) SMP
(1) Memory Management (mm/)
(0) Power Management (drivers/pm)
(3) Signals (sched/signal, arch/)
(3) pthreads (sched/pthread)
(4) pthreads (sched/pthread)
(0) Message Queues (sched/mqueue)
(8) Kernel/Protected Build
(3) C++ Support
(6) Binary loaders (binfmt/)
(14) Network (net/, drivers/net)
(16) Network (net/, drivers/net)
(4) USB (drivers/usbdev, drivers/usbhost)
(0) Other drivers (drivers/)
(12) Libraries (libc/, libm/)
(13) Libraries (libc/, libm/)
(10) File system/Generic drivers (fs/, drivers/)
(9) Graphics Subsystem (graphics/)
(10) Graphics Subsystem (graphics/)
(3) Build system / Toolchains
(3) Linux/Cywgin simulation (arch/sim)
(4) ARM (arch/arm/)
@ -34,6 +34,7 @@ apps/ and other Add-Ons:
(2) Network Utilities (apps/netutils/)
(1) NuttShell (NSH) (apps/nshlib)
(1) System libraries apps/system (apps/system)
(1) Modbus (apps/modbus)
(1) Pascal add-on (pcode/)
(4) Other Applications & Tests (apps/examples/)
@ -234,32 +235,65 @@ o Task/Scheduler (sched/)
could be improved and made a little more efficient with this
change.
Title: INAPPROPRIATE USE OF sched_lock() BY pthreads
Description: In implementation of standard pthread functions, the non-
standard, NuttX function sched_lock() is used. This is very
strong sense it disables pre-emption for all threads in all
task groups. I believe it is only really necessary in most
cases to lock threads in the task group with a new non-
standard interface, say pthread_lock().
Task: IDLE THREAD TCB SETUP
Description: There are issues with setting IDLE thread stacks:
This is because the OS resources used by a thread such as
mutexes, condition variable, barriers, etc. are only
meaningful from within the task group. So, in order to
performance exclusive operations on these resources, it is
only necessary to block other threads executing within the
task group.
1. One problem is stack-related data in the IDLE threads TCB.
A solution might be to standardize the use of g_idle_topstack.
That you could add initialization like this in os_start:
This is an easy change: pthread_lock() and pthread_unlock()
would simply operate on a semaphore retained in the task
group structure. I am, however, hesitant to make this change:
I the flat build model, there is nothing that prevents people
from accessing the inter-thread controls from threads in
differnt task groups. Making this change, while correct,
might introduce subtle bugs in code by people who are not
using NuttX correctly.
Status: Open
Priority: Low. This change would improve real-time performance of the
OS but is not otherwise required.
@@ -344,6 +347,11 @@ void os_start(void)
g_idleargv[1] = NULL;
g_idletcb.argv = g_idleargv;
+ /* Set the IDLE task stack size */
+
+ g_idletcb.cmn.adj_stack_size = CONFIG_IDLETHREAD_STACKSIZE;
+ g_idletcb.cmn.stack_alloc_ptr = (void *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE);
+
/* Then add the idle task's TCB to the head of the ready to run list */
dq_addfirst((FAR dq_entry_t *)&g_idletcb, (FAR dq_queue_t *)&g_readytorun);
The g_idle_topstack variable is available for almost all architectures:
$ find . -name *.h | xargs grep g_idle_top
./arm/src/common/up_internal.h:EXTERN const uint32_t g_idle_topstack;
./avr/src/avr/avr.h:extern uint16_t g_idle_topstack;
./avr/src/avr32/avr32.h:extern uint32_t g_idle_topstack;
./hc/src/common/up_internal.h:extern uint16_t g_idle_topstack;
./mips/src/common/up_internal.h:extern uint32_t g_idle_topstack;
./misoc/src/lm32/lm32.h:extern uint32_t g_idle_topstack;
./renesas/src/common/up_internal.h:extern uint32_t g_idle_topstack;
./renesas/src/m16c/chip.h:extern uint32_t g_idle_topstack; /* Start of the heap */
./risc-v/src/common/up_internal.h:EXTERN uint32_t g_idle_topstack;
./x86/src/common/up_internal.h:extern uint32_t g_idle_topstack;
That omits there architectures: sh1, sim, xtensa, z16, z80,
ez80, and z8. All would have to support this common
globlal variable.
Also, the stack itself may be 8-, 16-, or 32-bits wide,
depending upon the architecture.
2. Another problem is colorizing that stack to use with
stack usage monitoring logic. There is logic in some
start functions to do this in a function called go_os_start.
It is available in these architectures:
./arm/src/efm32/efm32_start.c:static void go_os_start(void *pv, unsigned int nbytes)
./arm/src/kinetis/kinetis_start.c:static void go_os_start(void *pv, unsigned int nbytes)
./arm/src/sam34/sam_start.c:static void go_os_start(void *pv, unsigned int nbytes)
./arm/src/samv7/sam_start.c:static void go_os_start(void *pv, unsigned int nbytes)
./arm/src/stm32/stm32_start.c:static void go_os_start(void *pv, unsigned int nbytes)
./arm/src/stm32f7/stm32_start.c:static void go_os_start(void *pv, unsigned int nbytes)
./arm/src/stm32l4/stm32l4_start.c:static void go_os_start(void *pv, unsigned int nbytes)
./arm/src/tms570/tms570_boot.c:static void go_os_start(void *pv, unsigned int nbytes)
./arm/src/xmc4/xmc4_start.c:static void go_os_start(void *pv, unsigned int nbytes)
But no others.
Status: Open
Priority: Low, only needed for more complete debug.
o SMP
^^^
@ -534,6 +568,33 @@ o pthreads (sched/pthreads)
Priority: Medium-low. Priority may be higher if system call overheade becomes
an issue.
Title: INAPPROPRIATE USE OF sched_lock() BY pthreads
Description: In implementation of standard pthread functions, the non-
standard, NuttX function sched_lock() is used. This is very
strong sense it disables pre-emption for all threads in all
task groups. I believe it is only really necessary in most
cases to lock threads in the task group with a new non-
standard interface, say pthread_lock().
This is because the OS resources used by a thread such as
mutexes, condition variable, barriers, etc. are only
meaningful from within the task group. So, in order to
performance exclusive operations on these resources, it is
only necessary to block other threads executing within the
task group.
This is an easy change: pthread_lock() and pthread_unlock()
would simply operate on a semaphore retained in the task
group structure. I am, however, hesitant to make this change:
I the flat build model, there is nothing that prevents people
from accessing the inter-thread controls from threads in
differnt task groups. Making this change, while correct,
might introduce subtle bugs in code by people who are not
using NuttX correctly.
Status: Open
Priority: Low. This change would improve real-time performance of the
OS but is not otherwise required.
o Message Queues (sched/mqueue)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1171,6 +1232,64 @@ o Network (net/, drivers/net)
deal with a list of devices. That would be a huge effect and
certainly doesn't dount as a "simple solution".
Title: ICMPv6 FOR 6LoWPAN
Description: The current ICMPv6 and neighbor-related logic only works with
Ethernet MAC. For 6LoWPAN, a new more conservative IPv6
neigbor discovery is provided by RFC 6775. This RFC needs to
be supported in order to support ping6 on a 6LoWPAN network.
If RFC 6775 were implemented, then arbitrary IPv6 addresses,
including addresses from DHCPv6 could be used.
can
UPDATE: With IPv6 neighbor discovery, any IPv6 address may
be associated with any short or extended address. In fact,
that is the whole purpose of the neighbor discover logic: It
plays the same role as ARP in IPv4; it ultimately just manages
a neighbor table that, like the arp table, provides the
mapping between IP addresses and node addresses.
The NuttX, Contiki-based 6LoWPAN implementation circumvented
the need for the neighbor discovery logic by using only MAC-
based addressing, i.e., the lower two or eight bytes of the
IP address are the node address.
Most of the 6LoWPAN compression algorithms exploit this to
compress the IPv6 address to nothing but a bit indicating
that the IP address derives from the node address. So I
think IPv6 neighbor discover is useless in the current
implementation.
If we want to use IPv6 neighbor discovery, we could dispense
with the all MAC based addressing. But if we want to retain
the more compact MAC-based addressing, then we don't need
IPv6 neighbor discovery.
So, the full neighbor discovery logic is not currently useful,
but it would still be nice to have enough in place to support
ping6. Full neighbor support would probably be necessary if we
wanted to route 6LoWPAN frames outside of the WPAN.
Status: Open
Priority: Low for now. I don't plan on implementing this. It would
only be relevant if we were to decide to abandon the use of
MAC-based addressing in the 6LoWPAN implementation.
Title: ETHERNET LOCAL BROADCAST DOES NOT WORK
Description: In case of "local broadcast" the system still send ARP
request to the destination, but it shouldn't, it should
broadcast. For Example, the system has network with IP
10.0.0.88, netmask of 255.255.255.0, it should send
messages for 10.0.0.255 as broadcast, and not send ARP
for 10.0.0.255
For more easier networking, the next line should have give
me the broadcast address of the network, but it doesn't:
ioctl(_socket_fd, SIOCGIFBRDADDR, &bc_addr);
Status: Open
Priority: Medium
o USB (drivers/usbdev, drivers/usbhost)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1532,6 +1651,64 @@ o Libraries (libc/, libm/)
Status: Open
Priority: Low
Title: FORMATTING FIXED WIDTH INTEGERS
Description: Formats like this: lib_vsprintf(_, "%6.6u", 0) do not work.
There is no support for the precision/width option with
integer types. The format is simply is ignored and so can
even cause crashes.
For example:
int hello_main(int argc, char *argv[])
{
printf("Hello, World!!\n");
printf("%3.3u %3.3u %3.3u %3.3u %3.3u\n", 9, 99, 999, 9999, 99999);
return 0;
}
Generates this incorrect output:
NuttShell (NSH) NuttX-7.20
nsh> hello
Hello, World!!
9 99 999 9999 99999
nsh>
That output, of course, should have been:
9 99 999 999 999
The period and the precision value were being ignored (if
floating point was disabled). In that case, parsing of the
variable arguments could get out of sync. But a side
effect of the referenced change is that precision value is
now always parsed (but still incorrectly ignored for the
case of integer formats).
The fix would not be too difficult but would involve change
several functions. It would involve clipping the size of the
number string. For example:
/* Get the width of the output */
uwidth = getusize(FMT_CHAR, flags, n);
if (trunc > 0 && uwidth > trunc)
{
uwidth = trunc;
}
Then limiting the length of the output string to uwidth.
This would probably mean passing an additional parameter to
the many *toascii() functions like:
/* Output the number */
utoascii(obj, FMT_CHAR, flags, (unsigned int)n, uwidth);
Status: Open
Priority: Low
o File system / Generic drivers (fs/, drivers/)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1830,6 +2007,16 @@ o Graphics Subsystem (graphics/)
the single user mode, it will be yanked out from under your
feet in the not-so-distant future.
Title: WIDE-FOUNT SUPPORT
Description: Wide fonts are not currently supported by the NuttX graphics sub-
system. There is some discussion here:
https://groups.yahoo.com/neo/groups/nuttx/conversations/topics/3507
http://www.nuttx.org/doku.php?id=wiki:graphics:wide-fonts
Status: Open
Priority: Low for many, but I imagine higher in countries that use wide fonts
o Build system
^^^^^^^^^^^^
@ -1887,6 +2074,30 @@ o Build system
see that the .a archive file has the newer time stamp and those .o
file will never be added to the archive until the directory is cleaned
or some other dependency changes.
UPDATE: There is another way that Control-C can break dependencies:
If you control-c out of the make during the apps/ part of the build,
the archive at apps/libapps.a is deleted. You can see this in the
make outout, for example:
CC: ieee802154_getsaddr.c
make[2]: *** [Makefile:104: ieee802154_getsaddr.o] Interrupt
make: *** Deleting file '../apps/libapps.a'
When you rebuild the system, the first file archived will recreate
libapps.a and set the timestamp to the current time. Then, none of
the other object files will be added to the archive because they are
all older.
The typical symptom of such an issue is a link time error like:
LD: nuttx libsched.a(os_bringup.o): In function `os_bringup':
os_bringup.c:(.text+0x34): undefined reference to `nsh_main'
The work-around for now is:
$ make apps_distclean
Status Open
Priority: Medium-High. It is a rare event that control-C happens at just the
point in time. However, when it does occur the resulting code may
@ -1926,6 +2137,7 @@ o Build system
The .archive file would have to be removed on 'make clean' and would
also need to appear in .gitignore files.
o Other drivers (drivers/)
^^^^^^^^^^^^^^^^^^^^^^^^
@ -2151,6 +2363,30 @@ o System libraries apps/system (apps/system)
Priority: Low (unless you are using mixed C-buffered I/O with readline and
fgetc, for example).
o Modbus (apps/modbus)
^^^^^^^^^^^^^^^^^^^^
Title: MODBUS NOT USABLE WITH USB SERIAL
Description: Modbus can be used with USB serial, however, if the USB
serial connectiont is lost, Modbus will hang in an infinite
loop.
This is a problem in the handling of select() and read()
and could probabaly resolved by studying the Modbus error
handling.
A more USB-friendly solution would be to: (1) Re-connect and
(2) re-open the serial drviers. That is what is done is NSH.
When the serial USB device is removed, this terminates the
session and NSH will then try to re-open the USB device. See
the function nsh_waitusbready() in the file
apps/nshlib/nsh_usbconsole.c. When the USB serial is
reconnected the open() in the function will succeed and a new
session will be started.
Status: Open
Priority: Low. This is really an enhancement request: Modbus was never
designed to work with removable serial devices.
o Pascal Add-On (pcode/)
^^^^^^^^^^^^^^^^^^^^^^

View File

@ -254,7 +254,8 @@
# endif
#endif
#if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429)
#if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) || \
defined(CONFIG_STM32_STM32F469)
# define STM32_FLASH_OPTCR1_OFFSET 0x0018
#endif
@ -287,7 +288,8 @@
# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
# define STM32_FLASH_OPTCR (STM32_FLASHIF_BASE+STM32_FLASH_OPTCR_OFFSET)
# endif
# if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429)
# if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) || \
defined(CONFIG_STM32_STM32F469)
# define STM32_FLASH_OPTCR1 (STM32_FLASHIF_BASE+STM32_FLASH_OPTCR1_OFFSET)
# endif
#endif

View File

@ -108,7 +108,7 @@
#define STM32_HRTIM_CMN_ICR_OFFSET 0x000C /* HRTIM Interrupt Clear Register */
#define STM32_HRTIM_CMN_IER_OFFSET 0x0010 /* HRTIM Interrupt Enable Register */
#define STM32_HRTIM_CMN_OENR_OFFSET 0x0014 /* HRTIM Output Enable Register */
#define STM32_HRTIM_CMN_DISR_OFFSET 0x0018 /* HRTIM Output Disable Register */
#define STM32_HRTIM_CMN_ODISR_OFFSET 0x0018 /* HRTIM Output Disable Register */
#define STM32_HRTIM_CMN_ODSR_OFFSET 0x001C /* HRTIM Output Disable Status Register */
#define STM32_HRTIM_CMN_BMCR_OFFSET 0x0020 /* HRTIM Burst Mode Control Register */
#define STM32_HRTIM_CMN_BMTRGR_OFFSET 0x0024 /* HRTIM Burst Mode Trigger Register */
@ -132,79 +132,6 @@
#define STM32_HRTIM_CMN_BDTEUPR_OFFSET 0x006C /* HRTIM Timer E Update Register */
#define STM32_HRTIM_CMN_BDMADR_OFFSET 0x0070 /* HRTIM DMA Data Register */
/* Register Addresses *******************************************************************************/
/* HRTIM1 Timer A */
/* remove ? */
#define STM32_HRTIM1_TIMERA_CR (STM32_HRTIM_TIM_CR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_ISR (STM32_HRTIM_TIM_ISR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_ICR (STM32_HRTIM_TIM_ICR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_DIER (STM32_HRTIM_TIM_DIER_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_CNTR (STM32_HRTIM_TIM_CNTR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_PER (STM32_HRTIM_TIM_PER_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_REP (STM32_HRTIM_TIM_REP_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_CMP1R (STM32_HRTIM_TIM_CMP1R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_CMP1CR (STM32_HRTIM_TIM_CMP1CR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_CMP2R (STM32_HRTIM_TIM_CMP2R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_CMP3R (STM32_HRTIM_TIM_CMP3R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_CMP4R (STM32_HRTIM_TIM_CMP4R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_CPT1R (STM32_HRTIM_TIM_CMPT1R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_CPT2R (STM32_HRTIM_TIM_CMPT2R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_DTR (STM32_HRTIM_TIM_DTR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_SET1R (STM32_HRTIM_TIM_SET1R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_RST1R (STM32_HRTIM_TIM_RST1R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_SET2R (STM32_HRTIM_TIM_SET2R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_RST2R (STM32_HRTIM_TIM_RST2R_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_EEFR1 (STM32_HRTIM_TIM_EEFR1_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_EEFR2 (STM32_HRTIM_TIM_EEFR2_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_RSTR (STM32_HRTIM_TIM_RSTR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_CHPR (STM32_HRTIM_TIM_CHPR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_CPT1CR (STM32_HRTIM_TIM_CPT1CR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_CPT2CR (STM32_HRTIM_TIM_CPT2CR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_OUTR (STM32_HRTIM_TIM_OUTR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
#define STM32_HRTIM1_TIMERA_FLTR (STM32_HRTIM_TIM_FLTR_OFFSET+STM32_HRTIM1_TIMERA_BASE)
/* HRTIM1 Timer B */
/* HRTIM1 Timer C */
/* HRTIM1 Timer D */
/* HRTIM1 Timer E */
/* HRTIM1 Common Registers */
#define STM32_HRTIM_CMN_CR1 (STM32_HRTIM_CMN_CR1_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_CR2 (STM32_HRTIM_CMN_CR2_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_ISR (STM32_HRTIM_CMN_ISR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_ICR (STM32_HRTIM_CMN_ICR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_IER (STM32_HRTIM_CMN_IER_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_OENR (STM32_HRTIM_CMN_OENR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_DISR (STM32_HRTIM_CMN_DISR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_ODSR (STM32_HRTIM_CMN_ODSR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_BMCR (STM32_HRTIM_CMN_BMCR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_BMTGR (STM32_HRTIM_CMN_BMTGR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_BMCMPR (STM32_HRTIM_CMN_MBCMPR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_BMPER (STM32_HRTIM_CMN_BMPER_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_EECR1 (STM32_HRTIM_CMN_EECR1_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_EECR2 (STM32_HRTIM_CMN_EECR2_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_EECR3 (STM32_HRTIM_CMN_EECR3_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_ADC1R (STM32_HRTIM_CMN_ADC1R_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_ADC2R (STM32_HRTIM_CMN_ADC2R_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_ADC3R (STM32_HRTIM_CMN_ADC3R_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_ADC4R (STM32_HRTIM_CMN_ADC4R_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_DLLCR (STM32_HRTIM_CMN_DLLCR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_FLTINR1 (STM32_HRTIM_CMN_FTLINR1_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_FLTINR2 (STM32_HRTIM_CMN_FLTINR2_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_BDMUPDR (STM32_HRTIM_CMN_BDMUPDR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_BDTAUPR (STM32_HRTIM_CMN_BDTAUPR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_BDTBUPR (STM32_HRTIM_CMN_BDTBUR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_BDTCUPR (STM32_HRTIM_CMN_BDTCUPR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_BDTDUPR (STM32_HRTIM_CMN_BDTDUPR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_BDTEUPR (STM32_HRTIM_CMN_BDTEUPR_OFFSET+STM32_HRTIM1_CMN_BASE)
#define STM32_HRTIM_CMN_BDMADR (STM32_HRTIM_CMN_BDMADR_OFFSET+STM32_HRTIM1_CMN_BASE)
/* Register Bitfield Definitions ****************************************************/
/* Control Register Bits Common to Master Timer and Timer A-E */
@ -1136,11 +1063,12 @@
/* Timer X Fault Register */
#define HRTIM_TIMFLT_FLT1EN (1 << 0) /* Bit 0 */
#define HRTIM_TIMFLT_FLT2EN (1 << 1) /* Bit 1 */
#define HRTIM_TIMFLT_FLT3EN (1 << 2) /* Bit 2 */
#define HRTIM_TIMFLT_FLT4EN (1 << 3) /* Bit 3 */
#define HRTIM_TIMFLT_FLT5EN (1 << 4) /* Bit 4 */
#define HRTIM_TIMFLT_FLT1EN (1 << 0) /* Bit 0: Fault1 enable */
#define HRTIM_TIMFLT_FLT2EN (1 << 1) /* Bit 1: Fault 2 enable */
#define HRTIM_TIMFLT_FLT3EN (1 << 2) /* Bit 2: Fault 3 enable*/
#define HRTIM_TIMFLT_FLT4EN (1 << 3) /* Bit 3: Fault 4 enable */
#define HRTIM_TIMFLT_FLT5EN (1 << 4) /* Bit 4: Fault 5 enable */
#define HRTIM_TIMFLT_FLTLCK (1 << 31) /* Bit 31: Fault sources lock*/
/* Common Control Register 1 */

File diff suppressed because it is too large Load Diff

View File

@ -56,6 +56,66 @@
* Pre-processor definitions
************************************************************************************/
#if defined(CONFIG_STM32_HRTIM_TIMA) || defined(CONFIG_STM32_HRTIM_TIMB) || \
defined(CONFIG_STM32_HRTIM_TIMC) || defined(CONFIG_STM32_HRTIM_TIMD) || \
defined(CONFIG_STM32_HRTIM_TIME)
# define HRTIM_HAVE_SLAVE 1
#endif
#if defined(CONFIG_STM32_HRTIM_TIMA_PWM) || defined(CONFIG_STM32_HRTIM_TIMB_PWM) || \
defined(CONFIG_STM32_HRTIM_TIMC_PWM) || defined(CONFIG_STM32_HRTIM_TIMD_PWM) || \
defined(CONFIG_STM32_HRTIM_TIME_PWM)
# define HRTIM_HAVE_PWM 1
#endif
#if defined(CONFIG_STM32_HRTIM_TIMA_CAP) || defined(CONFIG_STM32_HRTIM_TIMB_CAP) || \
defined(CONFIG_STM32_HRTIM_TIMC_CAP) || defined(CONFIG_STM32_HRTIM_TIMD_CAP) || \
defined(CONFIG_STM32_HRTIM_TIME_CAP)
# define HRTIM_HAVE_CAPTURE 1
#endif
#if defined(CONFIG_STM32_HRTIM_TIMA_DT) || defined(CONFIG_STM32_HRTIM_TIMB_DT) || \
defined(CONFIG_STM32_HRTIM_TIMC_DT) || defined(CONFIG_STM32_HRTIM_TIMD_DT) || \
defined(CONFIG_STM32_HRTIM_TIME_DT)
# define HRTIM_HAVE_DEADTIME 1
#endif
#if defined(CONFIG_STM32_HRTIM_TIMA_CHOP) || defined(CONFIG_STM32_HRTIM_TIMB_CHOP) || \
defined(CONFIG_STM32_HRTIM_TIMC_CHOP) || defined(CONFIG_STM32_HRTIM_TIMD_CHOP) || \
defined(CONFIG_STM32_HRTIM_TIME_CHOP)
# define HRTIM_HAVE_CHOPPER 1
#endif
#if defined(CONFIG_STM32_HRTIM_SCOUT) || defined(CONFIG_STM32_HRTIM_SCIN)
# define HRTIM_HAVE_SYNC 1
#endif
#if defined(CONFIG_STM32_HRTIM_FAULT1) || defined(CONFIG_STM32_HRTIM_FAULT2) || \
defined(CONFIG_STM32_HRTIM_FAULT3) || defined(CONFIG_STM32_HRTIM_FAULT4) || \
defined(CONFIG_STM32_HRTIM_FAULT5)
# define HRTIM_HAVE_FAULTS 1
#endif
#if defined(CONFIG_STM32_HRTIM_EEV1) || defined(CONFIG_STM32_HRTIM_EEV2) || \
defined(CONFIG_STM32_HRTIM_EEV3) || defined(CONFIG_STM32_HRTIM_EEV4) || \
defined(CONFIG_STM32_HRTIM_EEV5) || defined(CONFIG_STM32_HRTIM_EEV6) || \
defined(CONFIG_STM32_HRTIM_EEV7) || defined(CONFIG_STM32_HRTIM_EEV8) || \
defined(CONFIG_STM32_HRTIM_EEV9) || defined(CONFIG_STM32_HRTIM_EEV10)
# define HRTIM_HAVE_EEV 1
#endif
#if defined(CONFIG_STM32_HRTIM_MASTER_IRQ) || defined(CONFIG_STM32_HRTIM_TIMA_IRQ) || \
defined(CONFIG_STM32_HRTIM_TIMB_IRQ) || defined(CONFIG_STM32_HRTIM_TIMC_IRQ) || \
defined(CONFIG_STM32_HRTIM_TIMD_IRQ) || defined(CONFIG_STM32_HRTIM_TIME_IRQ) || \
defined(CONFIG_STM32_HRTIM_CMN_IRQ)
# defined HRTIM_HAVE_INTERRUPTS
#endif
#if defined(CONFIG_STM32_HRTIM_ADC_TRG1) || defined(CONFIG_STM32_HRTIM_ADC_TRG2) || \
defined(CONFIG_STM32_HRTIM_ADC_TRG3) || defined(CONFIG_STM32_HRTIM_ADC_TRG4)
# define HRTIM_HAVE_ADC
#endif
/************************************************************************************
* Public Types
************************************************************************************/
@ -64,22 +124,23 @@
enum stm32_hrtim_tim_e
{
HRTIM_TIMER_MASTER,
HRTIM_TIMER_MASTER = 0,
#ifdef CONFIG_STM32_HRTIM_TIMA
HRTIM_TIMER_TIMA,
HRTIM_TIMER_TIMA = 1,
#endif
#ifdef CONFIG_STM32_HRTIM_TIMB
HRTIM_TIMER_TIMB,
HRTIM_TIMER_TIMB = 2,
#endif
#ifdef CONFIG_STM32_HRTIM_TIMC
HRTIM_TIMER_TIMC,
HRTIM_TIMER_TIMC = 3,
#endif
#ifdef CONFIG_STM32_HRTIM_TIMD
HRTIM_TIMER_TIMD,
HRTIM_TIMER_TIMD = 4,
#endif
#ifdef CONFIG_STM32_HRTIM_TIME
HRTIM_TIMER_TIME,
HRTIM_TIMER_TIME = 5,
#endif
HRTIM_TIMER_COMMON = 6
};
/* Source which can force the Tx1/Tx2 output to its inactive state */
@ -117,7 +178,7 @@ enum stm32_hrtim_out_rst_e
HRTIM_OUT_RST_CMP1 = (1 << 28),
HRTIM_OUT_RST_PER = (1 << 29),
HRTIM_OUT_RST_RESYNC = (1 << 30),
HRTIM_OUT_RST_SOFT = (1 << 31),
HRTIM_OUT_RST_SOFT = (1 << 31)
};
/* Source which can force the Tx1/Tx2 output to its active state */
@ -155,7 +216,7 @@ enum stm32_hrtim_out_set_e
HRTIM_OUT_SET_CMP1 = (1 << 28),
HRTIM_OUT_SET_PER = (1 << 29),
HRTIM_OUT_SET_RESYNC = (1 << 30),
HRTIM_OUT_SET_SOFT = (1 << 31),
HRTIM_OUT_SET_SOFT = (1 << 31)
};
/* Events that can reset TimerX Counter */
@ -205,7 +266,7 @@ enum stm32_hrtim_tim_rst_e
HRTIM_RST_EXTEVNT4,
HRTIM_RST_EXTEVNT3,
HRTIM_RST_EXTEVNT2,
HRTIM_RST_EXTEVNT1,
HRTIM_RST_EXTEVNT1
};
/* HRTIM Timer X prescaler */
@ -219,41 +280,442 @@ enum stm32_hrtim_tim_prescaler_e
HRTIM_PRESCALER_16,
HRTIM_PRESCALER_32,
HRTIM_PRESCALER_64,
HRTIM_PRESCALER_128,
HRTIM_PRESCALER_128
};
/* HRTIM Timer Master/Slave mode */
enum stm32_hrtim_mode_e
{
HRTIM_MODE_PRELOAD = (1 << 0), /* Preload enable */
HRTIM_MODE_HALF = (1 << 1), /* Half mode */
HRTIM_MODE_RETRIG = (1 << 2), /* Re-triggerable mode */
HRTIM_MODE_CONT = (1 << 3), /* Continuous mode */
/* Only slave Timers */
HRTIM_MODE_PSHPLL = (1 << 7), /* Push-Pull mode */
};
/* HRTIM Slave Timer auto-delayed mode
* NOTE: details in STM32F334 Manual
*/
enum stm32_hrtim_autodelayed_e
{
/* CMP2 auto-delayed mode */
HRTIM_AUTODELAYED_CMP2_MODE1 = 1, /* DELCMP2 = 01 */
HRTIM_AUTODELAYED_CMP2_MODE2 = 2, /* DELCMP2 = 10 */
HRTIM_AUTODELAYED_CMP2_MODE3 = 3, /* DELCMP2 = 11 */
/* CMP4 auto-delayed mode */
HRTIM_AUTODELAYED_CMP4_MODE1 = (1 << 2), /* DELCMP4 = 01 */
HRTIM_AUTODELAYED_CMP4_MODE2 = (2 << 2), /* DELCMP4 = 10 */
HRTIM_AUTODELAYED_CMP4_MODE3 = (3 << 2), /* DELCMP4 = 11 */
};
/* HRTIM Slave Timer fault sources Lock */
enum stm32_hrtim_tim_fault_lock_e
{
HRTIM_TIM_FAULT_RW = 0, /* Slave Timer fault source are read/write */
HRTIM_TIM_FAULT_LOCK = (1 << 7) /* Slave Timer fault source are read only */
};
/* HRTIM Slave Timer Fault configuration */
enum stm32_hrtim_tim_fault_src_e
{
HRTIM_TIM_FAULT1 = (1 << 0),
HRTIM_TIM_FAULT2 = (1 << 2),
HRTIM_TIM_FAULT3 = (1 << 3),
HRTIM_TIM_FAULT4 = (1 << 4),
HRTIM_TIM_FAULT5 = (1 << 5)
};
/* HRTIM Fault Source */
enum stm32_hrtim_fault_src_e
{
HRTIM_FAULT_SRC_PIN,
HRTIM_FAULT_SRC_INTERNAL
HRTIM_FAULT_SRC_PIN = 0,
HRTIM_FAULT_SRC_INTERNAL = 1
};
/* HRTIM External Event Source
* NOTE: according to Table 82 from STM32F334XX Manual
* NOTE: according to Table 82 from STM32F334XX Manual.
*/
enum stm32_hrtim_eev_src_e
{
HRTIM_EEV_SRC_PIN,
HRTIM_EEV_SRC_ANALOG,
HRTIM_EEV_SRC_TRGO,
HRTIM_EEV_SRC_ADC
HRTIM_EEV_SRC_PIN = 0,
HRTIM_EEV_SRC_ANALOG = 1,
HRTIM_EEV_SRC_TRGO = 2,
HRTIM_EEV_SRC_ADC = 3
};
/* HRTIM Fault Polarity */
enum stm32_hrtim_fault_pol_e
{
HRTIM_FAULT_POL_LOW = 0,
HRTIM_FAULT_POL_HIGH = 1
};
/* HRTIM External Event Polarity */
enum stm32_hrtim_eev_pol_e
{
HRTIM_EEV_POL_HIGH = 0, /* External Event is active high */
HRTIM_EEV_POL_LOW = 1 /* External Event is active low */
};
/* HRTIM External Event sensitivity */
enum stm32_hrtim_eev_sen_e
{
HRTIM_EEV_SEN_LEVEL = 0, /* On active level defined by polarity */
HRTIM_EEV_SEN_RISING = 1, /* Rising edgne */
HRTIM_EEV_SEN_FALLING = 2, /* Falling edge */
HRTIM_EEV_SEN_BOTH = 3 /* Both edges */
};
/* External Event Sampling clock division */
enum stm32_hrtim_eev_sampling_e
{
HRTIM_EEV_SAMPLING_d1 = 0,
HRTIM_EEV_SAMPLING_d2 = 1,
HRTIM_EEV_SAMPLING_d4 = 2,
HRTIM_EEV_SAMPLING_d8 = 3
};
/* HRTIM External Event Mode.
* NOTE: supported only for EEV1-5.
*/
enum stm32_hrtim_eev_mode_e
{
HRTIM_EEV_MODE_NORMAL = 0,
HRTIM_EEV_MODE_FAST = 1 /* low latency mode */
};
/* External Event filter.
* NOTE: supported only for EEV6-10.
*/
enum stm32_hrtim_eev_filter_e
{
HRTIM_EEV_DISABLE = 0,
HRTIM_EEV_HRT_N2 = 1,
HRTIM_EEV_HRT_N4 = 2,
HRTIM_EEV_HRT_N8 = 3,
HRTIM_EEV_EEVSd2_N6 = 4,
HRTIM_EEV_EEVSd2_N8 = 5,
HRTIM_EEV_EEVSd4_N6 = 6,
HRTIM_EEV_EEVSd4_N8 = 7,
HRTIM_EEV_EEVSd8_N6 = 8,
HRTIM_EEV_EEVSd8_N8 = 9,
HRTIM_EEV_EEVSd16_N5 = 10,
HRTIM_EEV_EEVSd16_N6 = 11,
HRTIM_EEV_EEVSd16_N8 = 12,
HRTIM_EEV_EEVSd32_N5 = 13,
HRTIM_EEV_EEVSd32_N6 = 14,
HRTIM_EEV_EEVSd32_N8 = 15
};
/* Compare register index */
enum stm32_hrtim_cmp_index_e
{
HRTIM_CMP1,
HRTIM_CMP2,
HRTIM_CMP3,
HRTIM_CMP4
};
/* HRTIM Slave Timer Outputs */
enum stm32_outputs_e
{
HRTIM_OUT_TIMA_CH1 = (1 << 0),
HRTIM_OUT_TIMA_CH2 = (1 << 1),
HRTIM_OUT_TIMB_CH1 = (1 << 2),
HRTIM_OUT_TIMB_CH2 = (1 << 3),
HRTIM_OUT_TIMC_CH1 = (1 << 4),
HRTIM_OUT_TIMC_CH2 = (1 << 5),
HRTIM_OUT_TIMD_CH1 = (1 << 6),
HRTIM_OUT_TIMD_CH2 = (1 << 7),
HRTIM_OUT_TIME_CH1 = (1 << 8),
HRTIM_OUT_TIME_CH2 = (1 << 9)
};
/* DAC synchronization event */
enum stm32_hrtim_dacsync_e
{
HRTIM_DACSYNC_DIS,
HRTIM_DACSYNC_1,
HRTIM_DACSYNC_2,
HRTIM_DACSYNC_3
};
/* HRTIM Deadtime Locks */
enum stm32_hrtim_deadtime_lock_e
{
HRTIM_DT_VALUE_LOCK = (1 << 0), /* Lock Deadtime value */
HRTIM_DT_SIGN_LOCK = (1 << 1) /* Lock Deadtime sign */
};
/* HRTIM Deadtime types */
enum stm32_hrtim_deadtime_edge_e
{
HRTIM_DT_RISING = 0,
HRTIM_DT_FALLING = 1
};
/* Chopper start pulsewidth */
enum stm32_hrtim_chopper_start_e
{
HRTIM_CHP_START_16,
HRTIM_CHP_START_32,
HRTIM_CHP_START_48,
HRTIM_CHP_START_64,
HRTIM_CHP_START_80,
HRTIM_CHP_START_96,
HRTIM_CHP_START_112,
HRTIM_CHP_START_128,
HRTIM_CHP_START_144,
HRTIM_CHP_START_160,
HRTIM_CHP_START_176,
HRTIM_CHP_START_192,
HRTIM_CHP_START_208,
HRTIM_CHP_START_224,
HRTIM_CHP_START_256
};
/* Chopper duty cycle */
enum stm32_hrtim_chopper_duty_e
{
HRTIM_CHP_DUTY_0,
HRTIM_CHP_DUTY_1,
HRTIM_CHP_DUTY_2,
HRTIM_CHP_DUTY_3,
HRTIM_CHP_DUTY_4,
HRTIM_CHP_DUTY_5,
HRTIM_CHP_DUTY_6,
HRTIM_CHP_DUTY_7
};
/* Chopper carrier frequency */
enum stm32_hrtim_chopper_freq_e
{
HRTIM_CHP_FREQ_d16,
HRTIM_CHP_FREQ_d32,
HRTIM_CHP_FREQ_d48,
HRTIM_CHP_FREQ_d64,
HRTIM_CHP_FREQ_d80,
HRTIM_CHP_FREQ_d96,
HRTIM_CHP_FREQ_d112,
HRTIM_CHP_FREQ_d128,
HRTIM_CHP_FREQ_d144,
HRTIM_CHP_FREQ_d160,
HRTIM_CHP_FREQ_d176,
HRTIM_CHP_FREQ_d192,
HRTIM_CHP_FREQ_d208,
HRTIM_CHP_FREQ_d224,
HRTIM_CHP_FREQ_d240,
HRTIM_CHP_FREQ_d256
};
/* HRTIM ADC Trigger 1/3 */
enum stm32_hrtim_adc_trq13_e
{
HRTIM_ADCTRG13_MC1 = (1 << 0),
HRTIM_ADCTRG13_MC2 = (1 << 1),
HRTIM_ADCTRG13_MC3 = (1 << 2),
HRTIM_ADCTRG13_MC4 = (1 << 3),
HRTIM_ADCTRG13_MPER = (1 << 4),
HRTIM_ADCTRG13_EEV1 = (1 << 5),
HRTIM_ADCTRG13_EEV2 = (1 << 6),
HRTIM_ADCTRG13_EEV3 = (1 << 7),
HRTIM_ADCTRG13_EEV4 = (1 << 8),
HRTIM_ADCTRG13_EEV5 = (1 << 9),
HRTIM_ADCTRG13_AC2 = (1 << 10),
HRTIM_ADCTRG13_AC3 = (1 << 11),
HRTIM_ADCTRG13_AC4 = (1 << 12),
HRTIM_ADCTRG13_APER = (1 << 13),
HRTIM_ADCTRG13_ARST = (1 << 14),
HRTIM_ADCTRG13_BC2 = (1 << 15),
HRTIM_ADCTRG13_BC3 = (1 << 16),
HRTIM_ADCTRG13_BC4 = (1 << 17),
HRTIM_ADCTRG13_BPER = (1 << 18),
HRTIM_ADCTRG13_BRST = (1 << 19),
HRTIM_ADCTRG13_CC2 = (1 << 20),
HRTIM_ADCTRG13_CC3 = (1 << 21),
HRTIM_ADCTRG13_CC4 = (1 << 22),
HRTIM_ADCTRG13_CPER = (1 << 23),
HRTIM_ADCTRG13_DC2 = (1 << 24),
HRTIM_ADCTRG13_DC3 = (1 << 25),
HRTIM_ADCTRG13_DC4 = (1 << 26),
HRTIM_ADCTRG13_DPER = (1 << 27),
HRTIM_ADCTRG13_EC2 = (1 << 28),
HRTIM_ADCTRG13_EC3 = (1 << 29),
HRTIM_ADCTRG13_EC4 = (1 << 30),
HRTIM_ADCTRG13_ERST = (1 << 31),
};
/* HRTIM ADC Trigger 2/4 */
enum stm32_hrtim_adc_trq24_e
{
HRTIM_ADCTRG24_MC1 = (1 << 0),
HRTIM_ADCTRG24_MC2 = (1 << 1),
HRTIM_ADCTRG24_MC3 = (1 << 2),
HRTIM_ADCTRG24_MC4 = (1 << 3),
HRTIM_ADCTRG24_MPER = (1 << 4),
HRTIM_ADCTRG24_EEV6 = (1 << 5),
HRTIM_ADCTRG24_EEV7 = (1 << 6),
HRTIM_ADCTRG24_EEV8 = (1 << 7),
HRTIM_ADCTRG24_EEV9 = (1 << 8),
HRTIM_ADCTRG24_EEV10 = (1 << 9),
HRTIM_ADCTRG24_AC2 = (1 << 10),
HRTIM_ADCTRG24_AC3 = (1 << 11),
HRTIM_ADCTRG24_AC4 = (1 << 12),
HRTIM_ADCTRG24_APER = (1 << 13),
HRTIM_ADCTRG24_BC2 = (1 << 14),
HRTIM_ADCTRG24_BC3 = (1 << 15),
HRTIM_ADCTRG24_BC4 = (1 << 16),
HRTIM_ADCTRG24_BPER = (1 << 17),
HRTIM_ADCTRG24_CC2 = (1 << 18),
HRTIM_ADCTRG24_CC3 = (1 << 19),
HRTIM_ADCTRG24_CC4 = (1 << 20),
HRTIM_ADCTRG24_CPER = (1 << 21),
HRTIM_ADCTRG24_CRST = (1 << 22),
HRTIM_ADCTRG24_DC2 = (1 << 23),
HRTIM_ADCTRG24_DC3 = (1 << 24),
HRTIM_ADCTRG24_DC4 = (1 << 25),
HRTIM_ADCTRG24_DPER = (1 << 26),
HRTIM_ADCTRG24_DRST = (1 << 27),
HRTIM_ADCTRG24_EC2 = (1 << 28),
HRTIM_ADCTRG24_EC3 = (1 << 29),
HRTIM_ADCTRG24_EC4 = (1 << 30),
HRTIM_ADCTRG24_ERST = (1 << 31),
};
/* HRTIM DAC synchronization */
enum stm32_hrtim_dac_e
{
HRTIM_DAC_SYNC_DIS = 0,
HRTIM_DAC_SYNC_1 = 1,
HRTIM_DAC_SYNC_2 = 2,
HRTIM_DAC_SYNC_3 = 3
};
/* HRTIM Master Timer interrupts */
enum stm32_irq_master_e
{
HRTIM_IRQ_MCMP1 = (1 << 0), /* Master Compare 1 Interrupt */
HRTIM_IRQ_MCMP2 = (1 << 1), /* Master Compare 2 Interrupt */
HRTIM_IRQ_MCMP3 = (1 << 2), /* Master Compare 3 Interrupt */
HRTIM_IRQ_MCMP4 = (1 << 3), /* Master Compare 4 Interrupt */
HRTIM_IRQ_MREP = (1 << 4), /* Master Repetition Interrupt */
HRTIM_IRQ_MSYNC = (1 << 5), /* Sync Input Interrupt */
HRTIM_IRQ_MUPD = (1 << 6) /* Master Update Interrupt */
};
/* HRTIM Slave Timer interrupts */
enum stm32_irq_slave_e
{
HRTIM_IRQ_CMP1 = (1 << 0), /* Slave Compare 1 Interrupt */
HRTIM_IRQ_CMP2 = (1 << 1), /* Slave Compare 2 Interrupt */
HRTIM_IRQ_CMP3 = (1 << 2), /* Slave Compare 3 Interrupt */
HRTIM_IRQ_CMP4 = (1 << 3), /* Slave Compare 4 Interrupt */
HRTIM_IRQ_REP = (1 << 4), /* Slave Repetition Interrupt */
HRTIM_IRQ_UPD = (1 << 6), /* Slave Update Interrupt */
HRTIM_IRQ_CPT1 = (1 << 7), /* Slave Capture 1 Interrupt */
HRTIM_IRQ_CPT2 = (1 << 8), /* Slave Capture 2 Interrupt */
HRTIM_IRQ_SETX1 = (1 << 9), /* Slave Output 1 Set Interrupt */
HRTIM_IRQ_RSTX1 = (1 << 10), /* Slave Output 1 Reset Interrupt */
HRTIM_IRQ_SETX2 = (1 << 11), /* Slave Output 2 Set Interrupt */
HRTIM_IRQ_RSTX2 = (1 << 12), /* Slave Output 2 Reset Interrupt */
HRTIM_IRQ_RST = (1 << 13), /* Slave Reset/roll-over Interrupt */
HRTIM_IRQ_DLYPRT = (1 << 14) /* Slave Delayed Protection Interrupt */
};
/* HRTIM Common Interrupts */
enum stm32_irq_cmn_e
{
HRTIM_IRQ_FLT1 = (1 << 0), /* Fault 1 Interrupt */
HRTIM_IRQ_FLT2 = (1 << 1), /* Fault 2 Interrupt */
HRTIM_IRQ_FLT3 = (1 << 2), /* Fault 3 Interrupt */
HRTIM_IRQ_FLT4 = (1 << 3), /* Fault 4 Interrupt */
HRTIM_IRQ_FLT5 = (1 << 4), /* Fault 5 Interrupt */
HRTIM_IRQ_SYSFLT = (1 << 5), /* System Fault Interrupt */
HRTIM_IRQ_DLLRDY = (1 << 16), /* DLL Ready Interrupt */
HRTIM_IRQ_BMPER = (1 << 17) /* Burst Mode Period Interrupt */
};
/* HRTIM vtable */
struct hrtim_dev_s;
struct stm32_hrtim_ops_s
{
int (*cmp_update)(FAR struct hrtim_dev_s *dev, uint8_t timer,
uint8_t index, uint16_t cmp);
int (*per_update)(FAR struct hrtim_dev_s *dev, uint8_t timer, uint16_t per);
uint16_t (*per_get)(FAR struct hrtim_dev_s *dev, uint8_t timer);
uint16_t (*cmp_get)(FAR struct hrtim_dev_s *dev, uint8_t timer,
uint8_t index);
#ifdef HRTIM_HAVE_INTERRUPTS
void (*irq_ack)(FAR struct hrtim_dev_s *dev, uint8_t timer, int source);
#endif
#ifdef HRTIM_HAVE_PWM
int (*outputs_enable)(FAR struct hrtim_dev_s *dev, uint16_t outputs,
bool state);
#endif
};
/* HRTIM device structure */
struct hrtim_dev_s
{
#ifdef CONFIG_HRTIM
/* Fields managed by common upper half HRTIM logic */
uint8_t hd_ocount; /* The number of times the device has been opened */
sem_t hd_closesem; /* Locks out new opens while close is in progress */
uint8_t hd_ocount; /* The number of times the device has been opened */
sem_t hd_closesem; /* Locks out new opens while close is in progress */
#endif
/* Fields provided by lower half HRTIM logic */
FAR void *hd_priv; /* Used by the arch-specific logic */
FAR const struct stm32_hrtim_ops_s *hd_ops; /* HRTIM operations */
FAR void *hd_priv; /* Used by the arch-specific logic */
bool initialized; /* true: HRTIM driver has been initialized */
};
/************************************************************************************

View File

@ -67,6 +67,7 @@
#include "up_internal.h"
#include "up_arch.h"
#include "cache.h"
#include "chip.h"
#include "stm32_rcc.h"
#include "stm32_tim.h"
@ -1131,6 +1132,9 @@ static void adc_dmaconvcallback(DMA_HANDLE handle, uint8_t isr, FAR void *arg)
FAR struct stm32_dev_s *priv = (FAR struct stm32_dev_s *)dev->ad_priv;
int i;
arch_invalidate_dcache((uintptr_t)priv->dmabuffer,
(uintptr_t)priv->dmabuffer + sizeof(priv->dmabuffer));
/* Verify that the upper-half driver has bound its callback functions */
if (priv->cb != NULL)
@ -1149,6 +1153,7 @@ static void adc_dmaconvcallback(DMA_HANDLE handle, uint8_t isr, FAR void *arg)
}
}
}
/* Restart DMA for the next conversion series */
adc_modifyreg(priv, STM32_ADC_DMAREG_OFFSET, ADC_DMAREG_DMA, 0);
@ -1347,7 +1352,7 @@ static void adc_reset(FAR struct adc_dev_s *dev)
adc_getreg(priv, STM32_ADC_SR_OFFSET),
adc_getreg(priv, STM32_ADC_CR1_OFFSET),
adc_getreg(priv, STM32_ADC_CR2_OFFSET));
ainfo("SQR1: 0x%08x SQR2: 0x%08x SQR3: 0x%08x\n",
adc_getreg(priv, STM32_ADC_SQR1_OFFSET),
adc_getreg(priv, STM32_ADC_SQR2_OFFSET),

View File

@ -78,7 +78,7 @@ Board Features
This cannot integrate cleanly with the NuttX network stack. A
USERSOCK option was recently added that would permit implementation
of the Inventek support in an applications. But that would then
preclude the 6loWPAN integration into IPv6.
preclude the 6LoWPAN integration into IPv6.
2. The board uses Bluetooth® V4.1 module (SPBTLE-RF), which has built-in
BLE stack. Similar with wifi, you only use simple AT command to talk

View File

@ -365,7 +365,7 @@ Configurations
nsh> i8 /dev/ieee0 startpan
nsh> i8 acceptassoc
2. Assocate and endpoint device with the WPAN. On the endpoint
2. Assocate an endpoint device with the WPAN. On the endpoint
device:
nsh> i8 /dev/ieee0 assoc
@ -374,7 +374,7 @@ Configurations
This is another version of nsh that is very similar to the mrf24j40-mac
configuration but is focused on testing the IEEE 802.15.4 MAC
integration with the 6loWPAN network stack. It derives directly from the
integration with the 6LoWPAN network stack. It derives directly from the
mrf24j40-mac and all NOTES provided there apply. Additional differences
are summarized below:
@ -426,16 +426,33 @@ Configurations
the system has crashed because (a) it will be unresponsive and (b)
the LD2 will be blinking at about 2Hz.
4. IPv6 networking is enabled with TCP/IP, UDP, 6loWPAN, and NSH
4. IPv6 networking is enabled with TCP/IP, UDP, 6LoWPAN, and NSH
Telnet support.
5. Configuration instructions: Basic PAN configuration is the same as
for the ieee802154-mac configuration with the exception that after
the PAN has been configured with the i8sak utility, you must
explicity bring the network up:
explicity bring the network up on each node:
nsh> ifup wpan0
6. examples/udp is enabled. This will allow two MRF24J40 nodes to
exchange UDP packets. Basic instructions:
On the server node:
nsh> ifconfig wpan0
nsh> udpserver &
The ifconfig command will show the IP address of the server. Then on
the client node use this IP address to start the client:
nsh> udpserver <server-ip> &
Where <server-ip> is the IP address of the server that you got above.
NOTE: There is no way to stop the UDP test once it has been started
other than by resetting the board.
nsh:
Configures the NuttShell (nsh) located at examples/nsh. This

View File

@ -810,7 +810,8 @@ CONFIG_NETDEV_TELNET=y
CONFIG_TELNET_RXBUFFER_SIZE=256
CONFIG_TELNET_TXBUFFER_SIZE=256
# CONFIG_NETDEV_MULTINIC is not set
# CONFIG_ARCH_HAVE_NETDEV_STATISTICS is not set
CONFIG_ARCH_HAVE_NETDEV_STATISTICS=y
CONFIG_NETDEV_STATISTICS=y
CONFIG_NETDEV_LATEINIT=y
#
@ -1136,12 +1137,15 @@ CONFIG_IOB_THROTTLE=8
CONFIG_WIRELESS=y
CONFIG_WIRELESS_IEEE802154=y
CONFIG_IEEE802154_DEFAULT_EADDR=0x00fade00deadbeef
CONFIG_IEEE802154_MAC_DEV=y
CONFIG_MAC802154_HPWORK=y
CONFIG_IEEE802154_NTXDESC=3
CONFIG_IEEE802154_IND_PREALLOC=20
CONFIG_IEEE802154_IND_IRQRESERVE=10
# CONFIG_IEEE802154_NETDEV is not set
CONFIG_IEEE802154_MACDEV=y
CONFIG_IEEE802154_MACDEV_RECVRPRIO=0
CONFIG_IEEE802154_NETDEV=y
CONFIG_IEEE802154_NETDEV_RECVRPRIO=1
CONFIG_IEEE802154_NETDEV_HPWORK=y
# CONFIG_IEEE802154_LOOPBACK is not set
#
@ -1348,7 +1352,28 @@ CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
# CONFIG_EXAMPLES_TELNETD is not set
# CONFIG_EXAMPLES_TIFF is not set
# CONFIG_EXAMPLES_TOUCHSCREEN is not set
# CONFIG_EXAMPLES_UDP is not set
CONFIG_EXAMPLES_UDP=y
# CONFIG_EXAMPLES_UDP_SERVER1 is not set
CONFIG_EXAMPLES_UDP_PRIORITY1=100
CONFIG_EXAMPLES_UDP_STACKSIZE1=2048
CONFIG_EXAMPLES_UDP_TARGET2=y
CONFIG_EXAMPLES_UDP_PRIORITY2=100
CONFIG_EXAMPLES_UDP_STACKSIZE2=2048
CONFIG_EXAMPLES_UDP_DEVNAME="wpan0"
# CONFIG_EXAMPLES_UDP_NETINIT is not set
CONFIG_EXAMPLES_UDP_IPv6=y
#
# Server IPv6 address
#
CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_1=0xfe80
CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_2=0x0000
CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_3=0x0000
CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_4=0x0000
CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_5=0x0000
CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_6=0x00ff
CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_7=0xfe00
CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_8=0x0d00
# CONFIG_EXAMPLES_UDPBLASTER is not set
# CONFIG_EXAMPLES_USBSERIAL is not set
# CONFIG_EXAMPLES_WATCHDOG is not set
@ -1446,7 +1471,7 @@ CONFIG_NSH_DISABLE_GET=y
# CONFIG_NSH_DISABLE_HELP is not set
# CONFIG_NSH_DISABLE_HEXDUMP is not set
# CONFIG_NSH_DISABLE_IFCONFIG is not set
CONFIG_NSH_DISABLE_IFUPDOWN=y
# CONFIG_NSH_DISABLE_IFUPDOWN is not set
# CONFIG_NSH_DISABLE_KILL is not set
# CONFIG_NSH_DISABLE_LOSETUP is not set
CONFIG_NSH_DISABLE_LOSMART=y
@ -1507,50 +1532,9 @@ CONFIG_NSH_ARCHINIT=y
#
CONFIG_NSH_NETINIT=y
CONFIG_NSH_NETLOCAL=y
#
# IP Address Configuration
#
#
# Target IPv6 address
#
CONFIG_NSH_IPv6ADDR_1=0xfc00
CONFIG_NSH_IPv6ADDR_2=0x0000
CONFIG_NSH_IPv6ADDR_3=0x0000
CONFIG_NSH_IPv6ADDR_4=0x0000
CONFIG_NSH_IPv6ADDR_5=0x0000
CONFIG_NSH_IPv6ADDR_6=0x00ff
CONFIG_NSH_IPv6ADDR_7=0xfe00
CONFIG_NSH_IPv6ADDR_8=0xa9cd
#
# Router IPv6 address
#
CONFIG_NSH_DRIPv6ADDR_1=0xfc00
CONFIG_NSH_DRIPv6ADDR_2=0x0000
CONFIG_NSH_DRIPv6ADDR_3=0x0000
CONFIG_NSH_DRIPv6ADDR_4=0x0000
CONFIG_NSH_DRIPv6ADDR_5=0x0000
CONFIG_NSH_DRIPv6ADDR_6=0x00ff
CONFIG_NSH_DRIPv6ADDR_7=0xfe00
CONFIG_NSH_DRIPv6ADDR_8=0x1034
#
# IPv6 Network mask
#
CONFIG_NSH_IPv6NETMASK_1=0xffff
CONFIG_NSH_IPv6NETMASK_2=0xffff
CONFIG_NSH_IPv6NETMASK_3=0xffff
CONFIG_NSH_IPv6NETMASK_4=0xffff
CONFIG_NSH_IPv6NETMASK_5=0xffff
CONFIG_NSH_IPv6NETMASK_6=0xffff
CONFIG_NSH_IPv6NETMASK_7=0xffff
CONFIG_NSH_IPv6NETMASK_8=0x0000
CONFIG_NSH_NOMAC=y
CONFIG_NSH_SWMAC=y
CONFIG_NSH_MACADDR=0xabcd
CONFIG_NSH_PANID=0xface
CONFIG_NSH_MACADDR=0x00fade00deadbeef
CONFIG_NSH_MAX_ROUNDTRIP=20
#

View File

@ -393,6 +393,7 @@ CONFIG_STM32_HAVE_I2C2=y
CONFIG_STM32_HAVE_I2C3=y
CONFIG_STM32_HAVE_SPI2=y
CONFIG_STM32_HAVE_SPI3=y
CONFIG_STM32_HAVE_I2S3=y
# CONFIG_STM32_HAVE_SPI4 is not set
# CONFIG_STM32_HAVE_SPI5 is not set
# CONFIG_STM32_HAVE_SPI6 is not set
@ -431,6 +432,7 @@ CONFIG_STM32_PWR=y
# CONFIG_STM32_SPI1 is not set
# CONFIG_STM32_SPI2 is not set
CONFIG_STM32_SPI3=y
# CONFIG_STM32_I2S3 is not set
CONFIG_STM32_SYSCFG=y
# CONFIG_STM32_TIM1 is not set
# CONFIG_STM32_TIM2 is not set
@ -968,6 +970,7 @@ CONFIG_MM_IOB=y
CONFIG_IOB_NBUFFERS=8
CONFIG_IOB_BUFSIZE=196
CONFIG_IOB_NCHAINS=0
CONFIG_IOB_THROTTLE=0
#
# Audio Support
@ -980,11 +983,12 @@ CONFIG_IOB_NCHAINS=0
CONFIG_WIRELESS=y
CONFIG_WIRELESS_IEEE802154=y
CONFIG_IEEE802154_DEFAULT_EADDR=0x00fade00deadbeef
CONFIG_IEEE802154_MAC_DEV=y
CONFIG_MAC802154_HPWORK=y
CONFIG_IEEE802154_NTXDESC=3
CONFIG_IEEE802154_IND_PREALLOC=20
CONFIG_IEEE802154_IND_IRQRESERVE=10
CONFIG_IEEE802154_MACDEV=y
CONFIG_IEEE802154_MACDEV_RECVRPRIO=0
#
# Binary Loader
@ -1162,10 +1166,10 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
CONFIG_EXAMPLES_NSH=y
CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set
# CONFIG_EXAMPLES_NXFFS is not set
# CONFIG_EXAMPLES_NXHELLO is not set
# CONFIG_EXAMPLES_NXIMAGE is not set
# CONFIG_EXAMPLES_NX is not set
# CONFIG_EXAMPLES_NXLINES is not set
# CONFIG_EXAMPLES_NXTERM is not set
# CONFIG_EXAMPLES_NXTEXT is not set

View File

@ -256,7 +256,7 @@ static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv)
}
#ifdef CONFIG_IEEE802154_NETDEV
/* Use the IEEE802.15.4 MAC interface instance to create a 6loWPAN
/* Use the IEEE802.15.4 MAC interface instance to create a 6LoWPAN
* network interface by wrapping the MAC intrface instance in a
* network device driver via mac802154dev_register().
*/
@ -270,7 +270,7 @@ static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv)
}
#endif
#ifdef CONFIG_IEEE802154_MAC_DEV
#ifdef CONFIG_IEEE802154_MACDEV
/* If want to call these APIs from userspace, you have to wrap the MAC
* interface in a character device viamac802154dev_register().
*/

View File

@ -28,6 +28,7 @@ CONFIG_BUILD_FLAT=y
# CONFIG_MOTOROLA_SREC is not set
CONFIG_RAW_BINARY=y
# CONFIG_UBOOT_UIMAGE is not set
# CONFIG_DFU_BINARY is not set
#
# Customize Header Files
@ -123,7 +124,6 @@ CONFIG_ARCH_ARM926EJS=y
# CONFIG_ARCH_CORTEXR7F is not set
CONFIG_ARCH_FAMILY="arm"
CONFIG_ARCH_CHIP="dm320"
# CONFIG_ARCH_TOOLCHAIN_IAR is not set
# CONFIG_ARCH_HAVE_FPU is not set
# CONFIG_ARCH_HAVE_DPFPU is not set
# CONFIG_ARCH_HAVE_TRUSTZONE is not set
@ -149,6 +149,8 @@ CONFIG_ARM_TOOLCHAIN_CODESOURCERYL=y
#
CONFIG_DM320_UART0=y
CONFIG_DM320_UART1=y
# CONFIG_ARCH_TOOLCHAIN_IAR is not set
# CONFIG_ARCH_TOOLCHAIN_GNU is not set
#
# Architecture Options
@ -169,6 +171,7 @@ CONFIG_ARCH_HAVE_MMU=y
# CONFIG_ARCH_HAVE_EXTCLK is not set
# CONFIG_ARCH_HAVE_POWEROFF is not set
# CONFIG_ARCH_HAVE_RESET is not set
# CONFIG_ARCH_HAVE_RTC_SUBSECONDS is not set
CONFIG_ARCH_USE_MMU=y
# CONFIG_PAGING is not set
# CONFIG_ARCH_STACKDUMP is not set
@ -335,14 +338,6 @@ CONFIG_DEV_NULL=y
#
# Buffering
#
#
# Common I/O Buffer Support
#
CONFIG_MM_IOB=y
CONFIG_IOB_NBUFFERS=8
CONFIG_IOB_BUFSIZE=196
CONFIG_IOB_NCHAINS=8
# CONFIG_DRVR_WRITEBUFFER is not set
# CONFIG_DRVR_READAHEAD is not set
# CONFIG_RAMDISK is not set
@ -504,7 +499,9 @@ CONFIG_UART1_2STOP=0
# System Logging
#
# CONFIG_ARCH_SYSLOG is not set
CONFIG_SYSLOG_WRITE=y
# CONFIG_RAMLOG is not set
# CONFIG_SYSLOG_BUFFER is not set
# CONFIG_SYSLOG_INTBUFFER is not set
# CONFIG_SYSLOG_TIMESTAMP is not set
CONFIG_SYSLOG_SERIAL_CONSOLE=y
@ -653,6 +650,15 @@ CONFIG_MM_REGIONS=1
# CONFIG_GRAN is not set
# CONFIG_MM_PGALLOC is not set
#
# Common I/O Buffer Support
#
CONFIG_MM_IOB=y
CONFIG_IOB_NBUFFERS=8
CONFIG_IOB_BUFSIZE=196
CONFIG_IOB_NCHAINS=8
CONFIG_IOB_THROTTLE=0
#
# Audio Support
#
@ -661,6 +667,7 @@ CONFIG_MM_REGIONS=1
#
# Wireless Support
#
# CONFIG_WIRELESS is not set
#
# Binary Loader
@ -837,7 +844,12 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
# CONFIG_EXAMPLES_TIFF is not set
# CONFIG_EXAMPLES_TOUCHSCREEN is not set
CONFIG_EXAMPLES_UDP=y
# CONFIG_EXAMPLES_UDP_SERVER is not set
# CONFIG_EXAMPLES_UDP_SERVER1 is not set
CONFIG_EXAMPLES_UDP_PRIORITY1=100
CONFIG_EXAMPLES_UDP_STACKSIZE1=2048
# CONFIG_EXAMPLES_UDP_TARGET2 is not set
CONFIG_EXAMPLES_UDP_DEVNAME="eth0"
CONFIG_EXAMPLES_UDP_NETINIT=y
CONFIG_EXAMPLES_UDP_IPv4=y
#
@ -916,10 +928,12 @@ CONFIG_NETUTILS_NETLIB=y
#
# CONFIG_SYSTEM_CLE is not set
# CONFIG_SYSTEM_CUTERM is not set
# CONFIG_SYSTEM_DHCPC is not set
# CONFIG_SYSTEM_FREE is not set
# CONFIG_SYSTEM_HEX2BIN is not set
# CONFIG_SYSTEM_HEXED is not set
# CONFIG_SYSTEM_INSTALL is not set
# CONFIG_SYSTEM_NTPC is not set
# CONFIG_SYSTEM_RAMTEST is not set
# CONFIG_READLINE_HAVE_EXTMATCH is not set
# CONFIG_SYSTEM_READLINE is not set
@ -932,3 +946,10 @@ CONFIG_NETUTILS_NETLIB=y
#
# Wireless Libraries and NSH Add-Ons
#
#
# IEEE 802.15.4 applications
#
# CONFIG_IEEE802154_LIBMAC is not set
# CONFIG_IEEE802154_LIBUTILS is not set
# CONFIG_IEEE802154_I8SAK is not set

View File

@ -804,12 +804,12 @@ pashello
sixlowpan
This configuration was intended only for unit-level testing of the
6loWPAN stack. It enables networking with 6loWPAN support and uses
6LoWPAN stack. It enables networking with 6LoWPAN support and uses
only a IEEE802.15.4 MAC loopback network device to supported testing.
This configuration includes apps/examples/nettest and apps/examples/udpblaster.
Neither are truly functional. The only intent of this configuration
is to verify that the 6loWPAN stack correctly encodes IEEE802.15.4
is to verify that the 6LoWPAN stack correctly encodes IEEE802.15.4
packets on output to the loopback device and correct decodes the
returned packet.

View File

@ -34,6 +34,7 @@ CONFIG_BUILD_FLAT=y
# CONFIG_MOTOROLA_SREC is not set
CONFIG_RAW_BINARY=y
# CONFIG_UBOOT_UIMAGE is not set
# CONFIG_DFU_BINARY is not set
#
# Customize Header Files
@ -88,6 +89,8 @@ CONFIG_SIM_X8664_MICROSOFT=y
# CONFIG_SIM_FRAMEBUFFER is not set
# CONFIG_SIM_SPIFLASH is not set
# CONFIG_SIM_QSPIFLASH is not set
# CONFIG_ARCH_TOOLCHAIN_IAR is not set
# CONFIG_ARCH_TOOLCHAIN_GNU is not set
#
# Architecture Options
@ -108,6 +111,7 @@ CONFIG_ARCH_HAVE_MULTICPU=y
# CONFIG_ARCH_HAVE_EXTCLK is not set
CONFIG_ARCH_HAVE_POWEROFF=y
# CONFIG_ARCH_HAVE_RESET is not set
# CONFIG_ARCH_HAVE_RTC_SUBSECONDS is not set
CONFIG_ARCH_STACKDUMP=y
# CONFIG_ENDIAN_BIG is not set
# CONFIG_ARCH_IDLE_CUSTOM is not set
@ -294,15 +298,6 @@ CONFIG_DEV_NULL=y
#
# Buffering
#
#
# Common I/O Buffer Support
#
CONFIG_MM_IOB=y
CONFIG_IOB_NBUFFERS=36
CONFIG_IOB_BUFSIZE=196
CONFIG_IOB_NCHAINS=8
CONFIG_IOB_THROTTLE=8
# CONFIG_DRVR_WRITEBUFFER is not set
# CONFIG_DRVR_READAHEAD is not set
# CONFIG_RAMDISK is not set
@ -481,14 +476,21 @@ CONFIG_STANDARD_SERIAL=y
# CONFIG_USBHOST is not set
# CONFIG_USBMISC is not set
# CONFIG_HAVE_USBTRACE is not set
# CONFIG_DRIVERS_WIRELESS is not set
CONFIG_DRIVERS_WIRELESS=y
# CONFIG_WL_CC1101 is not set
# CONFIG_WL_CC3000 is not set
# CONFIG_DRIVERS_IEEE802154 is not set
# CONFIG_DRIVERS_IEEE80211 is not set
# CONFIG_WL_NRF24L01 is not set
# CONFIG_DRIVERS_CONTACTLESS is not set
#
# System Logging
#
# CONFIG_ARCH_SYSLOG is not set
CONFIG_SYSLOG_WRITE=y
# CONFIG_RAMLOG is not set
# CONFIG_SYSLOG_BUFFER is not set
# CONFIG_SYSLOG_INTBUFFER is not set
# CONFIG_SYSLOG_TIMESTAMP is not set
CONFIG_SYSLOG_SERIAL_CONSOLE=y
@ -527,6 +529,7 @@ CONFIG_NET_6LOWPAN=y
#
CONFIG_NETDEV_IOCTL=y
CONFIG_NETDEV_PHY_IOCTL=y
# CONFIG_NETDEV_WIRELESS_IOCTL is not set
#
# Internet Protocol Selection
@ -687,6 +690,15 @@ CONFIG_MM_REGIONS=1
# CONFIG_ARCH_HAVE_HEAP2 is not set
# CONFIG_GRAN is not set
#
# Common I/O Buffer Support
#
CONFIG_MM_IOB=y
CONFIG_IOB_NBUFFERS=36
CONFIG_IOB_BUFSIZE=196
CONFIG_IOB_NCHAINS=8
CONFIG_IOB_THROTTLE=8
#
# Audio Support
#
@ -697,6 +709,13 @@ CONFIG_MM_REGIONS=1
#
CONFIG_WIRELESS=y
CONFIG_WIRELESS_IEEE802154=y
CONFIG_IEEE802154_DEFAULT_EADDR=0x00fade00deadbeef
CONFIG_MAC802154_HPWORK=y
CONFIG_IEEE802154_NTXDESC=3
CONFIG_IEEE802154_IND_PREALLOC=20
CONFIG_IEEE802154_IND_IRQRESERVE=10
# CONFIG_IEEE802154_MACDEV is not set
# CONFIG_IEEE802154_NETDEV is not set
CONFIG_IEEE802154_LOOPBACK=y
CONFIG_IEEE802154_LOOPBACK_HPWORK=y
@ -897,6 +916,7 @@ CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_5=0x0000
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_6=0x00ff
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_7=0xfe00
CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_8=0x1034
# CONFIG_EXAMPLES_NRF24L01TERM is not set
CONFIG_EXAMPLES_NSH=y
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set
@ -1117,52 +1137,12 @@ CONFIG_NSH_ARCHINIT=y
# Networking Configuration
#
CONFIG_NSH_NETINIT=y
# CONFIG_NSH_NETLOCAL is not set
# CONFIG_NSH_NETINIT_THREAD is not set
#
# IP Address Configuration
#
#
# Target IPv6 address
#
CONFIG_NSH_IPv6ADDR_1=0xfe80
CONFIG_NSH_IPv6ADDR_2=0x0000
CONFIG_NSH_IPv6ADDR_3=0x0000
CONFIG_NSH_IPv6ADDR_4=0x0000
CONFIG_NSH_IPv6ADDR_5=0x0000
CONFIG_NSH_IPv6ADDR_6=0x00ff
CONFIG_NSH_IPv6ADDR_7=0xfe00
CONFIG_NSH_IPv6ADDR_8=0xa9cd
#
# Router IPv6 address
#
CONFIG_NSH_DRIPv6ADDR_1=0xfe80
CONFIG_NSH_DRIPv6ADDR_2=0x0000
CONFIG_NSH_DRIPv6ADDR_3=0x0000
CONFIG_NSH_DRIPv6ADDR_4=0x0000
CONFIG_NSH_DRIPv6ADDR_5=0x0000
CONFIG_NSH_DRIPv6ADDR_6=0x00ff
CONFIG_NSH_DRIPv6ADDR_7=0xfe00
CONFIG_NSH_DRIPv6ADDR_8=0x1034
#
# IPv6 Network mask
#
CONFIG_NSH_IPv6NETMASK_1=0xffff
CONFIG_NSH_IPv6NETMASK_2=0xffff
CONFIG_NSH_IPv6NETMASK_3=0xffff
CONFIG_NSH_IPv6NETMASK_4=0xffff
CONFIG_NSH_IPv6NETMASK_5=0xffff
CONFIG_NSH_IPv6NETMASK_6=0xffff
CONFIG_NSH_IPv6NETMASK_7=0xffff
CONFIG_NSH_IPv6NETMASK_8=0x0000
# CONFIG_NSH_DNS is not set
CONFIG_NSH_NOMAC=y
CONFIG_NSH_SWMAC=y
CONFIG_NSH_MACADDR=0xabcd
CONFIG_NSH_PANID=0xface
CONFIG_NSH_MACADDR=0x00fade00deadbeef
CONFIG_NSH_MAX_ROUNDTRIP=20
# CONFIG_NSH_LOGIN is not set
# CONFIG_NSH_CONSOLE_LOGIN is not set
@ -1195,6 +1175,7 @@ CONFIG_I2CTOOL_DEFFREQ=400000
# CONFIG_SYSTEM_INSTALL is not set
# CONFIG_SYSTEM_MDIO is not set
# CONFIG_SYSTEM_NETDB is not set
# CONFIG_SYSTEM_NTPC is not set
# CONFIG_SYSTEM_RAMTEST is not set
CONFIG_READLINE_HAVE_EXTMATCH=y
CONFIG_SYSTEM_READLINE=y
@ -1211,3 +1192,12 @@ CONFIG_READLINE_ECHO=y
#
# Wireless Libraries and NSH Add-Ons
#
#
# IEEE 802.15.4 applications
#
CONFIG_IEEE802154_LIBMAC=y
# CONFIG_IEEE802154_LIBUTILS is not set
# CONFIG_IEEE802154_I8SAK is not set
# CONFIG_WIRELESS_IWPAN is not set
# CONFIG_WIRELESS_WAPI is not set

View File

@ -911,7 +911,7 @@ static void usbmsc_lununinitialize(struct usbmsc_lun_s *lun)
(void)close_blockdriver(lun->inode);
}
memset(lun, 0, sizeof(struct usbmsc_lun_s *));
memset(lun, 0, sizeof(struct usbmsc_lun_s));
}
/****************************************************************************
@ -1492,7 +1492,7 @@ int usbmsc_bindlun(FAR void *handle, FAR const char *drvrpath,
/* Initialize the LUN structure */
memset(lun, 0, sizeof(struct usbmsc_lun_s *));
memset(lun, 0, sizeof(struct usbmsc_lun_s));
/* Allocate an I/O buffer big enough to hold one hardware sector. SCSI commands
* are processed one at a time so all LUNs may share a single I/O buffer. The

View File

@ -98,7 +98,7 @@ config USBHOST_MSC
default n
depends on !BULK_DISABLE
---help---
Enable support for the keyboard class driver. This also depends on
Enable support for the mass storage class driver. This also depends on
NFILE_DESCRIPTORS > 0 && SCHED_WORKQUEUE=y
config USBHOST_CDCACM

View File

@ -443,7 +443,7 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv,
uint8_t *ie_buffer;
unsigned int ie_offset;
unsigned int check_offset;
result_size = BCMF_SCAN_RESULT_SIZE - priv->scan_result_size;
bss_info_len = bss->length;

View File

@ -110,7 +110,7 @@ struct at86rf23x_dev_s
FAR struct spi_dev_s *spi; /* Saved SPI interface instance */
struct work_s irqwork; /* Interrupt continuation work queue support */
FAR const struct at86rf23x_lower_s *lower; /* Low-level MCU-specific support */
uint16_t panid; /* PAN identifier, FFFF = not set */
uint8_t panid[2]; /* PAN identifier, FFFF = not set */
uint16_t saddr; /* Short address, FFFF = not set */
uint8_t eaddr[8]; /* Extended address, FFFFFFFFFFFFFFFF = not set */
uint8_t channel; /* 11 to 26 for the 2.4 GHz band */

View File

@ -208,32 +208,18 @@ static inline void mrf24j40_norm_trigger(FAR struct mrf24j40_radio_s *dev);
static int mrf24j40_setchannel(FAR struct mrf24j40_radio_s *dev,
uint8_t chan);
static int mrf24j40_getchannel(FAR struct mrf24j40_radio_s *dev,
FAR uint8_t *chan);
static int mrf24j40_setpanid(FAR struct mrf24j40_radio_s *dev,
uint16_t panid);
static int mrf24j40_getpanid(FAR struct mrf24j40_radio_s *dev,
FAR uint16_t *panid);
FAR const uint8_t *panid);
static int mrf24j40_setsaddr(FAR struct mrf24j40_radio_s *dev,
uint16_t saddr);
static int mrf24j40_getsaddr(FAR struct mrf24j40_radio_s *dev,
FAR uint16_t *saddr);
FAR const uint8_t *saddr);
static int mrf24j40_seteaddr(FAR struct mrf24j40_radio_s *dev,
FAR const uint8_t *eaddr);
static int mrf24j40_geteaddr(FAR struct mrf24j40_radio_s *dev,
FAR uint8_t *eaddr);
static int mrf24j40_setdevmode(FAR struct mrf24j40_radio_s *dev,
uint8_t mode);
static int mrf24j40_getdevmode(FAR struct mrf24j40_radio_s *dev,
FAR uint8_t *mode);
static int mrf24j40_settxpower(FAR struct mrf24j40_radio_s *dev,
int32_t txpwr);
static int mrf24j40_gettxpower(FAR struct mrf24j40_radio_s *dev,
FAR int32_t *txpwr);
static int mrf24j40_setcca(FAR struct mrf24j40_radio_s *dev,
FAR struct ieee802154_cca_s *cca);
static int mrf24j40_getcca(FAR struct mrf24j40_radio_s *dev,
FAR struct ieee802154_cca_s *cca);
static int mrf24j40_energydetect(FAR struct mrf24j40_radio_s *dev,
FAR uint8_t *energy);
static void mrf24j40_mactimer(FAR struct mrf24j40_radio_s *dev, int numsymbols);
@ -964,22 +950,6 @@ static int mrf24j40_setchannel(FAR struct mrf24j40_radio_s *dev, uint8_t chan)
return OK;
}
/****************************************************************************
* Name: mrf24j40_getchannel
*
* Description:
* Get the channel the device is operating on.
*
****************************************************************************/
static int mrf24j40_getchannel(FAR struct mrf24j40_radio_s *dev,
FAR uint8_t *chan)
{
*chan = dev->channel;
return OK;
}
/****************************************************************************
* Name: mrf24j40_setpanid
*
@ -989,29 +959,13 @@ static int mrf24j40_getchannel(FAR struct mrf24j40_radio_s *dev,
****************************************************************************/
static int mrf24j40_setpanid(FAR struct mrf24j40_radio_s *dev,
uint16_t panid)
FAR const uint8_t *panid)
{
mrf24j40_setreg(dev->spi, MRF24J40_PANIDH, (uint8_t)(panid>>8));
mrf24j40_setreg(dev->spi, MRF24J40_PANIDL, (uint8_t)(panid&0xFF));
mrf24j40_setreg(dev->spi, MRF24J40_PANIDL, panid[0]);
mrf24j40_setreg(dev->spi, MRF24J40_PANIDH, panid[1]);
dev->addr.panid = panid;
wlinfo("%04X\n", (unsigned)panid);
return OK;
}
/****************************************************************************
* Name: mrf24j40_getpanid
*
* Description:
* Define the current PAN ID the device is operating on.
*
****************************************************************************/
static int mrf24j40_getpanid(FAR struct mrf24j40_radio_s *dev,
FAR uint16_t *panid)
{
*panid = dev->addr.panid;
IEEE802154_PANIDCOPY(dev->addr.panid, panid);
wlinfo("%02X:%02X\n", panid[1], panid[0]);
return OK;
}
@ -1027,29 +981,14 @@ static int mrf24j40_getpanid(FAR struct mrf24j40_radio_s *dev,
****************************************************************************/
static int mrf24j40_setsaddr(FAR struct mrf24j40_radio_s *dev,
uint16_t saddr)
FAR const uint8_t *saddr)
{
mrf24j40_setreg(dev->spi, MRF24J40_SADRH, (uint8_t)(saddr>>8));
mrf24j40_setreg(dev->spi, MRF24J40_SADRL, (uint8_t)(saddr&0xFF));
mrf24j40_setreg(dev->spi, MRF24J40_SADRL, saddr[0]);
mrf24j40_setreg(dev->spi, MRF24J40_SADRH, saddr[1]);
dev->addr.saddr = saddr;
wlinfo("%04X\n", (unsigned)saddr);
return OK;
}
/****************************************************************************
* Name: mrf24j40_getsaddr
*
* Description:
* Define the current short address the device is using.
*
****************************************************************************/
static int mrf24j40_getsaddr(FAR struct mrf24j40_radio_s *dev,
FAR uint16_t *saddr)
{
*saddr = dev->addr.saddr;
IEEE802154_SADDRCOPY(dev->addr.saddr, saddr);
wlinfo("%02X:%02X\n", saddr[1], saddr[0]);
return OK;
}
@ -1076,22 +1015,6 @@ static int mrf24j40_seteaddr(FAR struct mrf24j40_radio_s *dev,
return OK;
}
/****************************************************************************
* Name: mrf24j40_geteaddr
*
* Description:
* Define the current extended address the device is using.
*
****************************************************************************/
static int mrf24j40_geteaddr(FAR struct mrf24j40_radio_s *dev,
FAR uint8_t *eaddr)
{
memcpy(eaddr, dev->addr.eaddr, 8);
return OK;
}
/****************************************************************************
* Name: mrf24j40_setdevmode
*
@ -1142,21 +1065,6 @@ static int mrf24j40_setdevmode(FAR struct mrf24j40_radio_s *dev,
return ret;
}
/****************************************************************************
* Name: mrf24j40_setdevmode
*
* Description:
* Return the current device mode
*
****************************************************************************/
static int mrf24j40_getdevmode(FAR struct mrf24j40_radio_s *dev,
FAR uint8_t *mode)
{
*mode = dev->devmode;
return OK;
}
/****************************************************************************
* Name: mrf24j40_settxpower
*
@ -1241,21 +1149,6 @@ static int mrf24j40_settxpower(FAR struct mrf24j40_radio_s *dev,
return OK;
}
/****************************************************************************
* Name: mrf24j40_gettxpower
*
* Description:
* Return the actual transmit power, in mBm.
*
****************************************************************************/
static int mrf24j40_gettxpower(FAR struct mrf24j40_radio_s *dev,
FAR int32_t *txpwr)
{
*txpwr = dev->txpower;
return OK;
}
/****************************************************************************
* Name: mrf24j40_setcca
*
@ -1300,21 +1193,6 @@ static int mrf24j40_setcca(FAR struct mrf24j40_radio_s *dev,
return OK;
}
/****************************************************************************
* Name: mrf24j40_getcca
*
* Description:
* Return the Clear Channel Assessement method.
*
****************************************************************************/
static int mrf24j40_getcca(FAR struct mrf24j40_radio_s *dev,
FAR struct ieee802154_cca_s *cca)
{
memcpy(cca, &dev->cca, sizeof(struct ieee802154_cca_s));
return OK;
}
/****************************************************************************
* Name: mrf24j40_regdump
*

View File

@ -218,7 +218,7 @@
/* There is no link layer header with SLIP */
# ifndef CONFIG_NET_IPv6
# error 6loWPAN requires IPv support
# error 6LoWPAN requires IPv support
# endif
# define NET_LL_HDRLEN(d) 0
@ -620,7 +620,7 @@
# define NET_DEV_RCVWNDO(d) CONFIG_NET_ETH_TCP_RECVWNDO
#elif defined(CONFIG_NET_6LOWPAN)
/* Only 6loWPAN.. use the configured 6loWPAN receive window size */
/* Only 6LoWPAN.. use the configured 6LoWPAN receive window size */
# define NET_DEV_RCVWNDO(d) CONFIG_NET_6LOWPAN_TCP_RECVWNDO

153
include/nuttx/net/rfc6775.h Normal file
View File

@ -0,0 +1,153 @@
/****************************************************************************
* include/nuttx/net/rfc6775.h
* Definitions for 6LoWPAN Neighbor Discovery
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Reference: RFC6775, Neighbor Discovery Optimization for IPv6 over Low-
* Power Wireless Personal Area Networks (6LoWPANs), Internet
* Engineering Task Force (IETF), November 2012
*
* 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_NET_RFC6775_H
#define __INCLUDE_NUTTX_NET_RFC6775_H
/* Acronyms (in addition to those defined in context below:
*
* 6LN - 6LoWPAN Node
* 6LR - 6LoWPAN Router
* 6LBR - 6LoWPAN Border Router
*/
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* 4.2 Bit definitions for 6CO resccid field */
#define RESCCID_CID_SHIFT (0) /* Bits 0-3: Context identifier */
#define RESCCID_CID_MASK (7 << RESCCID_CID_SHIFT)
#define RESCCID_C (1 << 4) /* Bit 4: Compression Flag */
/* Bits 5-7: Reserved */
/* 9 Protocol Constants */
/* 6LBR Constants: */
#define MIN_CONTEXT_CHANGE_DELAY 300 /* Seconds */
/* 6LR Constants: */
#define MAX_RTR_ADVERTISEMENTS 3 /* Transmissions */
#define MIN_DELAY_BETWEEN_RAS 10 /* Seconds */
#define MAX_RA_DELAY_TIME 2 /* Seconds */
#define TENTATIVE_NCE_LIFETIME 20 /* Seconds */
/* Router Constants: */
#define MULTIHOP_HOPLIMI 64
/* Host Constants: */
#define RTR_SOLICITATION_INTERVAL 10 /* Seconds */
#define MAX_RTR_SOLICITATIONS 3 /* Transmissions */
#define MAX_RTR_SOLICITATION_INTERVAL 60 /* Seconds */
/****************************************************************************
* Public Types
****************************************************************************/
/* Table 1. alues for status field */
enum sixlowpan_status_e
{
SIXLOWPAN_SUCCESS = 0, /* Success */
SIXLOWPAN_DUPLICATE = 1, /* Duplicate address */
SIXLOWPAN_FULL = 2, /* Neighbor cache full */
SIXLOWPAN_ALLOCATED = 3 /* 3-255: Allocated using standard action (RFC5226 */
};
/* 4.1 Source Link-Layer Address Option (SLLAO) */
struct sixlowpan_sllao_s
{
uint8_t type; /* Byte 0: Type = 33 */
uint8_t length; /* Byte 1: Length in units of 8 bytes = 2 */
uint8_t status; /* Byte 2: Status of NS message. See enum sixlowpan_status_e */
uint8_t reserved[3]; /* Bytes 3-5: Reserved */
uint8_t lifetime[2]; /* Bytes 6-7: Registration lifetime */
uint8_t eui64[8]; /* Bytes 8-15: EUI-64 identifier assigned to interface */
};
/* 4.2 6LoWPAN Context Option (6CO) */
struct sixlowpan_6co_s
{
uint8_t type; /* Byte 0: Type = 34 */
uint8_t length; /* Byte 1: Length in units of 8 bytes = 2 or 3 */
uint8_t ctxlen; /* Byte 2: Context length = 0-128 bits */
uint8_t resccid; /* Byte 3: See RESCCID_* bit definitions */
uint8_t reserved[2]; /* Bytes 4-6: Reserved */
uint8_t lifetime[2]; /* Bytes 6-7: Valid lifetime */
uint8_t prefix[1]; /* Bytes 8-15 or 8-23: Context Prefix */
};
#define SIXLOWPAN_6CO_LEN(b) ((b > 64) ? 16 : 8)
#define SIZEOF_SIXLOWPAN_6CO_S(b) (sizeof(struct sixlowpan_6co_s) + CMPV6_6CO_LEN(b) - 1)
/* 4.3 Authoritative Border Router Option (ABRO) */
struct sixlowpan_abro_s
{
uint8_t type; /* Byte 0: Type = 35 */
uint8_t length; /* Byte 1: Length in units of 8 bytes = 3 */
uint8_t verlo[2]; /* Bytes 2-3: Version low */
uint8_t verhi[2]; /* Bytes 4-5: Version high */
uint8_t lifetime[2]; /* Bytes 6-7: Valid lifetime */
uint8_t ipv6[16]; /* Bytes 8-23: IPv6 address of the 6LBR orign of version */
};
/* 4.4 Duplicate Address Messages (DAD for both DAR and DAC) */
struct sixlowpan_dad_s
{
uint8_t type; /* Byte 0: Type = 157 (DAR) or 158 (DAC) */
uint8_t code; /* Byte 1: Code */
uint8_t chksum[2]; /* Bytes 2-3: Checksum */
uint8_t status; /* Byte 4: Status of DAR. See enum sixlowpan_status_e */
uint8_t reserved; /* Byte 5: Reserved */
uint8_t lifetime[2]; /* Bytes 6-7: Registration lifetime */
uint8_t eui64[8]; /* Bytes 8-15: EUI-64 identifier registered address */
uint8_t ipv6[16]; /* Bytes 16-31: Registered address */
};
#endif /* __INCLUDE_NUTTX_NET_RFC6775_H */

View File

@ -481,7 +481,7 @@ struct ieee802154_driver_s
* Name: sixlowpan_input
*
* Description:
* Process an incoming 6loWPAN frame.
* Process an incoming 6LoWPAN frame.
*
* This function is called when the device driver has received an
* IEEE802.15.4 frame from the network. The frame from the device

View File

@ -56,12 +56,8 @@
* Pre-processor Definitions
************************************************************************************/
/* IEEE 802.15.4 Radio Character Driver IOCTL commands ******************************/
/* None defined */
/* IEEE 802.15.4 MAC Character Driver IOCTL commands ********************************/
#define MAC802154IOC_NOTIFY_REGISTER _WLCIOC(IEEE802154_FIRST)
#define MAC802154IOC_GET_EVENT _WLCIOC(IEEE802154_FIRST+1)
#define MAC802154IOC_ENABLE_EVENTS _WLCIOC(IEEE802154_FIRST+2)

View File

@ -61,6 +61,42 @@
* Pre-Processor Definitions
****************************************************************************/
/* IEEE 802.15.4 address macros */
/* Copy a an IEEE 802.15.4 address */
#define IEEE802154_ANYADDRCOPY(dest,src,len) \
memcpy(dest, src, len)
#define IEEE802154_PANIDCOPY(dest,src) \
IEEE802154_ANYADDRCOPY(dest,src,IEEE802154_PANIDSIZE)
#define IEEE802154_SADDRCOPY(dest,src) \
IEEE802154_ANYADDRCOPY(dest,src,IEEE802154_SADDRSIZE)
#define IEEE802154_EADDRCOPY(dest,src) \
IEEE802154_ANYADDRCOPY(dest,src,IEEE802154_EADDRSIZE)
/* Compare two IEEE 802.15.4 addresses */
#define IEEE802154_ANYADDRCMP(addr1,addr2,len) \
(memcmp(addr1, addr2, len) == 0)
#define IEEE802154_PANIDCMP(addr1,addr2) \
IEEE802154_ANYADDRCMP(addr1,addr2,IEEE802154_PANIDSIZE)
#define IEEE802154_SADDRCMP(addr1,addr2) \
IEEE802154_ANYADDRCMP(addr1,addr2,IEEE802154_SADDRSIZE)
#define IEEE802154_EADDRCMP(addr1,addr2) \
IEEE802154_ANYADDRCMP(addr1,addr2,IEEE802154_EADDRSIZE)
/* Some addresses */
#define IEEE802154_PANID_UNSPEC ((uint8_t[]){0xFF,0xFF})
#define IEEE802154_SADDR_UNSPEC ((uint8_t[]){0xFF,0xFF})
#define IEEE802154_SADDR_BCAST ((uint8_t[]){0xFE,0xFF})
#define IEEE802154_EADDR_UNSPEC ((uint8_t[]){0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF})
/* Configuration ************************************************************/
/* None at the moment */
@ -102,13 +138,6 @@
/* IEEE 802.15.4 MAC Interface **********************************************/
/* Some addresses */
#define IEEE802154_PAN_UNSPEC (uint16_t)0xFFFF
#define IEEE802154_SADDR_UNSPEC (uint16_t)0xFFFF
#define IEEE802154_SADDR_BCAST (uint16_t)0xFFFE
#define IEEE802154_EADDR_UNSPEC (uint8_t[]){0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}
/* Frame control field masks, 2 bytes
* Seee IEEE 802.15.4/2011 5.2.1.1 page 57
*/
@ -241,10 +270,11 @@ enum ieee802154_status_e
static const char *IEEE802154_STATUS_STRING[] =
{
"Success",
"Out of capacity",
"Denied",
"Failure",
"Beacon loss",
"Channel access failure",
"Denied",
"Disable TRX failure",
"Failed security check",
"Frame too long",
@ -255,7 +285,6 @@ static const char *IEEE802154_STATUS_STRING[] =
"No beacon",
"No data",
"No short address",
"Out of cap",
"PAN ID conflict",
"Realignment",
"Transaction expired",
@ -398,7 +427,9 @@ enum ieee802154_devmode_e
IEEE802154_DEVMODE_PANCOORD
};
#define IEEE802154_EADDR_LEN 8
#define IEEE802154_PANIDSIZE 2
#define IEEE802154_SADDRSIZE 2
#define IEEE802154_EADDRSIZE 8
/* IEEE 802.15.4 Device address
* The addresses in ieee802154 have several formats:
@ -424,10 +455,9 @@ struct ieee802154_addr_s
enum ieee802154_addrmode_e mode;
uint16_t panid; /* PAN identifier, can be
* IEEE802154_PAN_UNSPEC */
uint16_t saddr; /* short address */
uint8_t eaddr[IEEE802154_EADDR_LEN]; /* extended address */
uint8_t panid[IEEE802154_PANIDSIZE]; /* PAN identifier */
uint8_t saddr[IEEE802154_SADDRSIZE]; /* short address */
uint8_t eaddr[IEEE802154_EADDRSIZE]; /* extended address */
};
#define IEEE802154_ADDRSTRLEN 22 /* (2*2+1+8*2, PPPP/EEEEEEEEEEEEEEEE) */
@ -540,12 +570,12 @@ struct ieee802154_cca_s
union ieee802154_macattr_u
{
uint8_t eaddr[IEEE802154_EADDR_LEN];
uint16_t saddr;
uint16_t panid;
uint8_t eaddr[IEEE802154_EADDRSIZE];
uint8_t saddr[IEEE802154_SADDRSIZE];
uint8_t panid[IEEE802154_PANIDSIZE];
uint8_t coord_eaddr[IEEE802154_EADDR_LEN];
uint16_t coord_saddr;
uint8_t coord_eaddr[IEEE802154_EADDRSIZE];
uint8_t coord_saddr[IEEE802154_SADDRSIZE];
enum ieee802154_devmode_e devmode;
@ -845,7 +875,7 @@ struct ieee802154_assoc_ind_s
{
/* Address of device requesting association. Always in extended mode */
uint8_t devaddr[IEEE802154_EADDR_LEN];
uint8_t devaddr[IEEE802154_EADDRSIZE];
/* Capabilities of associating device */
@ -870,11 +900,11 @@ struct ieee802154_assoc_resp_s
{
/* Address of device requesting association. Always in extended mode */
uint8_t devaddr[8];
uint8_t devaddr[IEEE802154_EADDRSIZE];
/* Address assigned to the device. 0xFFFF if failure */
uint16_t assocsaddr;
uint8_t assocsaddr[IEEE802154_SADDRSIZE];
/* Status of association attempt */
@ -903,7 +933,7 @@ struct ieee802154_assoc_conf_s
* unsuccessful.
*/
uint16_t saddr;
uint8_t saddr[IEEE802154_SADDRSIZE];
/* Status of association attempt */
@ -1287,7 +1317,7 @@ struct ieee802154_set_req_s
struct ieee802154_start_req_s
{
uint16_t panid;
uint8_t panid[IEEE802154_PANIDSIZE];
uint8_t chnum;
uint8_t chpage;
@ -1571,7 +1601,7 @@ int mac802154dev_register(MACHANDLE mac, int minor);
*
* Description:
* Register a network driver to access the IEEE 802.15.4 MAC layer from
* a socket using 6loWPAN
* a socket using 6LoWPAN
*
* Input Parameters:
* mac - Pointer to the mac layer struct to be registered.

View File

@ -95,14 +95,14 @@ systime_t g_polltime;
*
* 1. TCP socket output. For the case of TCP output to an
* IEEE802.15.4, the TCP output is caught in the socket
* send()/sendto() logic and and redirected to 6loWPAN logic.
* send()/sendto() logic and and redirected to 6LoWPAN logic.
* 2. TCP output from the TCP state machine. That will occur
* during TCP packet processing by the TCP state meachine.
* 3. TCP output resulting from TX or timer polling
*
* Cases 2 is handled here. Logic here detected if (1) an attempt
* to return with d_len > 0 and (2) that the device is an
* IEEE802.15.4 MAC network driver. Under those conditions, 6loWPAN
* IEEE802.15.4 MAC network driver. Under those conditions, 6LoWPAN
* logic will be called to create the IEEE80215.4 frames.
*
* Assumptions:
@ -127,13 +127,13 @@ static void devif_packet_conversion(FAR struct net_driver_s *dev,
FAR struct ipv6_hdr_s *ipv6 = (FAR struct ipv6_hdr_s *)dev->d_buf;
/* This packet came from a response to TCP polling and is directed
* to an IEEE802.15.4 device using 6loWPAN. Verify that the outgoing
* to an IEEE802.15.4 device using 6LoWPAN. Verify that the outgoing
* packet is IPv6 with TCP protocol.
*/
if (ipv6->vtc == IPv6_VERSION && ipv6->proto == IP_PROTO_TCP)
{
/* Let 6loWPAN convert IPv6 TCP output into IEEE802.15.4 frames. */
/* Let 6LoWPAN convert IPv6 TCP output into IEEE802.15.4 frames. */
sixlowpan_tcp_send(dev);
}

View File

@ -265,14 +265,14 @@ int ipv6_input(FAR struct net_driver_s *dev)
*
* 1. TCP socket output. For the case of TCP output to an
* IEEE802.15.4, the TCP output is caught in the socket
* send()/sendto() logic and and redirected to 6loWPAN logic.
* send()/sendto() logic and and redirected to 6LoWPAN logic.
* 2. TCP output from the TCP state machine. That will occur
* during TCP packet processing by the TCP state meachine.
* 3. TCP output resulting from TX or timer polling
*
* Cases 2 is handled here. Logic here detected if (1) an attempt
* to return with d_len > 0 and (2) that the device is an
* IEEE802.15.4 MAC network driver. Under those conditions, 6loWPAN
* IEEE802.15.4 MAC network driver. Under those conditions, 6LoWPAN
* logic will be called to create the IEEE80215.4 frames.
*/
@ -284,7 +284,7 @@ int ipv6_input(FAR struct net_driver_s *dev)
if (dev->d_len > 0)
#endif
{
/* Let 6loWPAN handle the TCP output */
/* Let 6LoWPAN handle the TCP output */
sixlowpan_tcp_send(dev);

View File

@ -102,7 +102,7 @@ void net_setup(void)
neighbor_initialize();
#ifdef CONFIG_NET_6LOWPAN
/* Initialize 6loWPAN data structures */
/* Initialize 6LoWPAN data structures */
sixlowpan_initialize();
#endif

View File

@ -736,7 +736,7 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
}
break;
/* MAC address operations only make sense if Ethernet or 6loWPAN are
/* MAC address operations only make sense if Ethernet or 6LoWPAN are
* supported.
*/

View File

@ -159,7 +159,7 @@ static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
{
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%s\tLink encap:6loWPAN HWaddr "
"%s\tLink encap:6LoWPAN HWaddr "
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
dev->d_ifname,
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1],
@ -168,7 +168,7 @@ static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
dev->d_mac.ieee802154.u8[6], dev->d_mac.ieee802154.u8[7]);
#else
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%s\tLink encap:6loWPAN HWaddr %02x:%02x",
"%s\tLink encap:6LoWPAN HWaddr %02x:%02x",
dev->d_ifname,
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1]);
#endif
@ -221,7 +221,7 @@ static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
#elif defined(CONFIG_NET_6LOWPAN)
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%s\tLink encap:6loWPAN HWaddr "
"%s\tLink encap:6LoWPAN HWaddr "
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x at %s\n",
dev->d_ifname,
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1],
@ -231,7 +231,7 @@ static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
status);
#else
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%s\tLink encap:6loWPAN HWaddr %02x:%02x at %s\n",
"%s\tLink encap:6LoWPAN HWaddr %02x:%02x at %s\n",
dev->d_ifname,
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1],
status);

View File

@ -7,7 +7,7 @@ menu "6LoWPAN Configuration"
depends on NET_6LOWPAN
config NET_6LOWPAN_FRAG
bool "6loWPAN Fragmentation"
bool "6LoWPAN Fragmentation"
default y
---help---
CONFIG_NET_6LOWPAN_FRAG specifies if 6lowpan fragmentation should be
@ -22,7 +22,7 @@ config NET_6LOWPAN_FRAMELEN
setting should never be smaller than 127.
choice
prompt "6loWPAN Compression"
prompt "6LoWPAN Compression"
default NET_6LOWPAN_COMPRESSION_HC06
config NET_6LOWPAN_COMPRESSION_IPv6
@ -33,16 +33,16 @@ config NET_6LOWPAN_COMPRESSION_IPv6
the IPv6 dispatch byte before the packet.
config NET_6LOWPAN_COMPRESSION_HC1
bool "6loWPAN HC1"
bool "6LoWPAN HC1"
---help---
Compress IP/UDP header using HC1 and HC_UDP
config NET_6LOWPAN_COMPRESSION_HC06
bool "6loWPAN HC06"
bool "6LoWPAN HC06"
---help---
Compress IP/UDP header using HC06 compression
endchoice # 6loWPAN Compression
endchoice # 6LoWPAN Compression
config NET_6LOWPAN_COMPRESSION_THRESHOLD
int "Lower compression threshold"
@ -196,7 +196,7 @@ config NET_6LOWPAN_DUMPBUFFER
depends on DEBUG_NET_INFO
---help---
Enable dumping of all packet and frame buffers coming into and out
of the 6loWPAN logic. This will generate a large volume of data if
of the 6LoWPAN logic. This will generate a large volume of data if
selected.
endmenu # 6LoWPAN Configuration

View File

@ -1,4 +1,60 @@
Optimal 6loWPAN Configuration
6LoWPAN Addressing
------------------
The current 6LoWPAN implementation uses only link local, MAC-based
addressing addressing (as discussed in more detail below). Thus if you know
the node addressing, then you know the IPv6 address (and vice-versa).
As a configuration option, the 6LoWPAN implementation will use either the
node's 2-byte short address or 8-byte extended address as the MAC address
that the IPv6 address is based on. This is determined by the configuration
setting CONFIG_NET_6LOWPAN_EXTENDEDADDR. By default, the 2-byte short
address is used for the IEEE802.15.4 MAC device's link layer address. If
this option is selected, then an 8-byte extended address will be used,
instead.
All nodes operating on a network have unique, 8-byte extended address,
that was assigned before the network is configured. 6LoWPAN will use
either the extended address for direct communication within the PAN or
the short 2-byte address. The short 2-byte address, however, is allocated
by the PAN coordinator when the device associated. If short addresses are
used, the network cannot be brought up until is is associated.
Node addressing is modified through IOCTL calls from application logic.
The network must be in the DOWN state when ever the node addressing is
modified. The modified node addresses will have no effect on the reported
IPv6 address until the network is brought to the UP state. The new IPv6
MAC-based addresses are only instantiated when the network transitions
from the DOWN to UP state.
IPv6 Neighbor Discovery
-----------------------
IPv6 Neighbor Discovery is not supported. The current ICMPv6 and neighbor-
related logic only works with Ethernet MAC. For 6LoWPAN, a new more
conservative IPv6 neigbor discovery is provided by RFC 6775 which is not
currently supported. With IPv6 neighbor discovery, any IPv6 address may be
associated with any short or extended address. In fact, that is the whole
purpose of the neighbor discover logic: It plays the same role as ARP in
IPv4; it ultimately just manages a neighbor table that, like the arp table,
provides the mapping between IP addresses and node addresses.
The NuttX, Contiki-based 6LoWPAN implementation circumvents the need for
the neighbor discovery logic by using only MAC-based addressing, i.e., the
lower two or eight bytes of the IP address are the node address.
Most of the 6LoWPAN compression algorithms exploit this kind of addressing
to compress the IPv6 address to nothing but a single bit indicating that the
IP address derives from the node address. In this use case, IPv6 neighbor
discover is not useful: If we want to use IPv6 neighbor discovery, we could
dispense with the all MAC based addressing. But if we want to retain the
more compact MAC-based addressing, then we don't need IPv6 neighbor discovery.
However, it would still be nice to have enough in place to support ping6.
Full neighbor support would be necessary if we wanted to route 6LoWPAN frames
outside of the WPAN.
Optimal 6LoWPAN Configuration
-----------------------------
1. Link local IP addresses:

View File

@ -63,9 +63,9 @@ struct sockaddr; /* Forward reference */
* Description:
* sixlowpan_initialize() is called during OS initialization at power-up
* reset. It is called from the common net_setup() function.
* sixlowpan_initialize() configures 6loWPAN networking data structures.
* sixlowpan_initialize() configures 6LoWPAN networking data structures.
* It is called prior to platform-specific driver initialization so that
* the 6loWPAN networking subsystem is prepared to deal with network
* the 6LoWPAN networking subsystem is prepared to deal with network
* driver initialization actions.
*
* Input Parameters:

View File

@ -313,8 +313,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
* PAN IDs are the same.
*/
pktmeta.dpanid = 0xffff;
(void)sixlowpan_src_panid(ieee, &pktmeta.dpanid);
(void)sixlowpan_src_panid(ieee, pktmeta.dpanid);
/* Based on the collected attributes and addresses, construct the MAC meta
* data structure that we need to interface with the IEEE802.15.4 MAC (we

View File

@ -198,7 +198,8 @@ int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
/* Broadcast requires short address mode. */
meta->destaddr.mode = IEEE802154_ADDRMODE_SHORT;
meta->destaddr.saddr = 0;
meta->destaddr.saddr[0] = 0;
meta->destaddr.saddr[1] = 0;
}
else if (pktmeta->dextended != 0)
{
@ -215,7 +216,7 @@ int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
sixlowpan_saddrcopy(&meta->destaddr.saddr, pktmeta->dest.saddr.u8);
}
meta->destaddr.panid = pktmeta->dpanid;
IEEE802154_SADDRCOPY(meta->destaddr.panid, pktmeta->dpanid);
/* Handle associated with MSDU. Will increment once per packet, not
* necesarily per frame: The same MSDU handle will be used for each

View File

@ -366,7 +366,7 @@ static void uncompress_addr(FAR net_ipv6addr_t ipaddr, uint8_t const prefix[],
* reset. It is called from the common sixlowpan_initialize() function.
* sixlowpan_hc06_initialize() configures HC06 networking data structures.
* It is called prior to platform-specific driver initialization so that
* the 6loWPAN networking subsystem is prepared to deal with network
* the 6LoWPAN networking subsystem is prepared to deal with network
* driver initialization actions.
*
* Input Parameters:

View File

@ -54,9 +54,9 @@
* Description:
* sixlowpan_initialize() is called during OS initialization at power-up
* reset. It is called from the common net_setup() function.
* sixlowpan_initialize() configures 6loWPAN networking data structures.
* sixlowpan_initialize() configures 6LoWPAN networking data structures.
* It is called prior to platform-specific driver initialization so that
* the 6loWPAN networking subsystem is prepared to deal with network
* the 6LoWPAN networking subsystem is prepared to deal with network
* driver initialization actions.
*
* Input Parameters:

View File

@ -1,6 +1,6 @@
/****************************************************************************
* net/sixlowpan/sixlowpan_input.c
* 6loWPAN implementation (RFC4944 and draft-ietf-6loWPAN-hc-06)
* 6LoWPAN implementation (RFC4944 and draft-ietf-6LoWPAN-hc-06)
*
* Copyright (C) 2017, Gregory Nutt, all rights reserved
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -272,10 +272,10 @@ static void sixlowpan_uncompress_ipv6hdr(FAR uint8_t *fptr, FAR uint8_t *bptr)
* Name: sixlowpan_frame_process
*
* Description:
* Process an incoming 6loWPAN frame in 'iob'.
* Process an incoming 6LoWPAN frame in 'iob'.
*
* If its a FRAG1 or a non-fragmented frame we first uncompress the IP
* header. The 6loWPAN payload and possibly the uncompressed IP header
* header. The 6LoWPAN payload and possibly the uncompressed IP header
* are then copied into d_buf. An indication is returned if the packet
* in d_buf is complete (i.e., non-fragmented frame or and the last
* FRAGN frame).
@ -436,7 +436,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
else if (fragsize == 0)
{
nwarn("WARNING: Dropping zero-length 6loWPAN fragment\n");
nwarn("WARNING: Dropping zero-length 6LoWPAN fragment\n");
return INPUT_PARTIAL;
}
@ -460,7 +460,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
* being reassembled or the packet is not a fragment.
*/
nwarn("WARNING: Dropping 6loWPAN packet that is not a fragment of "
nwarn("WARNING: Dropping 6LoWPAN packet that is not a fragment of "
"the packet currently being reassembled\n");
return INPUT_PARTIAL;
}
@ -487,7 +487,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
if (!isfirstfrag)
{
nwarn("WARNING: FRAGN 6loWPAN fragment while not reassembling\n");
nwarn("WARNING: FRAGN 6LoWPAN fragment while not reassembling\n");
return OK;
}
@ -708,7 +708,7 @@ static int sixlowpan_dispatch(FAR struct ieee802154_driver_s *ieee)
* Name: sixlowpan_input
*
* Description:
* Process an incoming 6loWPAN frame.
* Process an incoming 6LoWPAN frame.
*
* This function is called when the device driver has received an
* IEEE802.15.4 frame from the network. The frame from the device

View File

@ -169,7 +169,7 @@ struct ipv6icmp_hdr_s
/* In order to provide a customizable IEEE 802.15.4 MAC header, a structure
* of meta data is passed to the MAC network driver, struct
* ieee802154_frame_meta_s. Many of the settings in this meta data are
* fixed, deterimined by the 6loWPAN configuration. Other settings depend
* fixed, deterimined by the 6LoWPAN configuration. Other settings depend
* on the protocol used in the current packet or on chacteristics of the
* destination node.
*
@ -180,12 +180,12 @@ struct ipv6icmp_hdr_s
struct packet_metadata_s
{
uint8_t sextended : 1; /* Extended source address */
uint8_t dextended : 1; /* Extended destination address */
uint8_t xmits; /* Max MAC transmisstion */
uint16_t dpanid; /* Destination PAN ID */
union sixlowpan_anyaddr_u source; /* Source IEEE 802.15.4 address */
union sixlowpan_anyaddr_u dest; /* Destination IEEE 802.15.4 address */
uint8_t sextended : 1; /* Extended source address */
uint8_t dextended : 1; /* Extended destination address */
uint8_t xmits; /* Max MAC transmisstion */
uint8_t dpanid[IEEE802154_PANIDSIZE]; /* Destination PAN ID */
union sixlowpan_anyaddr_u source; /* Source IEEE 802.15.4 address */
union sixlowpan_anyaddr_u dest; /* Destination IEEE 802.15.4 address */
};
/****************************************************************************
@ -382,7 +382,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
* reset. It is called from the common sixlowpan_initialize() function.
* sixlowpan_hc06_initialize() configures HC06 networking data structures.
* It is called prior to platform-specific driver initialization so that
* the 6loWPAN networking subsystem is prepared to deal with network
* the 6LoWPAN networking subsystem is prepared to deal with network
* driver initialization actions.
*
* Input Parameters:
@ -592,6 +592,6 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
****************************************************************************/
int sixlowpan_src_panid(FAR struct ieee802154_driver_s *ieee,
FAR uint16_t *panid);
FAR uint8_t *panid);
#endif /* CONFIG_NET_6LOWPAN */
#endif /* _NET_SIXLOWPAN_SIXLOWPAN_INTERNAL_H */

View File

@ -325,7 +325,7 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
sixlowpan_addrfromip(conn->u.ipv6.raddr, &destmac);
/* If routable, then call sixlowpan_send() to format and send the 6loWPAN
/* If routable, then call sixlowpan_send() to format and send the 6LoWPAN
* packet.
*/

View File

@ -300,7 +300,7 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
sixlowpan_addrfromip(to6->sin6_addr.in6_u.u6_addr16, &destmac);
/* If routable, then call sixlowpan_send() to format and send the 6loWPAN
/* If routable, then call sixlowpan_send() to format and send the 6LoWPAN
* packet.
*/

View File

@ -188,7 +188,7 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
****************************************************************************/
int sixlowpan_src_panid(FAR struct ieee802154_driver_s *ieee,
FAR uint16_t *panid)
FAR uint8_t *panid)
{
FAR struct net_driver_s *dev = &ieee->i_dev;
struct ieee802154_netmac_s arg;
@ -204,7 +204,7 @@ int sixlowpan_src_panid(FAR struct ieee802154_driver_s *ieee,
return ret;
}
*panid = arg.u.getreq.attrval.mac.panid;
IEEE802154_PANIDCOPY(panid, arg.u.getreq.attrval.mac.panid);
return OK;
}

View File

@ -156,7 +156,15 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
net_lock();
#ifdef CONFIG_NETDEV_MULTINIC
/* Find the device matching the IPv4 address in the connection structure */
/* Find the device matching the IPv4 address in the connection structure.
* NOTE: listening sockets have no ripaddr. Work around is to use the
* lipaddr when ripaddr is not available.
*/
`
if (ripaddr == 0)
{
ripaddr = lipaddr;
}
dev = netdev_findby_ipv4addr(lipaddr, ripaddr);
#else
@ -279,7 +287,15 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
net_lock();
#ifdef CONFIG_NETDEV_MULTINIC
/* Find the device matching the IPv6 address in the connection structure */
/* Find the device matching the IPv6 address in the connection structure.
* NOTE: listening sockets have no ripaddr. Work around is to use the
* lipaddr when ripaddr is not available.
*/
if (net_ipv6addr_cmp(ripaddr, g_ipv6_allzeroaddr))
{
ripaddr = lipaddr;
}
dev = netdev_findby_ipv6addr(*lipaddr, *ripaddr);
#else

View File

@ -151,7 +151,12 @@ int psock_listen(FAR struct socket *psock, int backlog)
* accept() is called and enables poll()/select() logic.
*/
tcp_listen(conn);
errcode = tcp_listen(conn);
if (errcode < 0)
{
errcode = -errcode;
goto errout;
}
#else
errcode = EOPNOTSUPP;
goto errout;

View File

@ -162,7 +162,7 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
#endif
{
#ifdef CONFIG_NET_6LOWPAN
/* Try 6loWPAN TCP packet send */
/* Try 6LoWPAN TCP packet send */
ret = psock_6lowpan_tcp_send(psock, buf, len);
@ -205,7 +205,7 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
#endif
{
#if defined(CONFIG_NET_6LOWPAN)
/* Try 6loWPAN UDP packet send */
/* Try 6LoWPAN UDP packet send */
ret = psock_6lowpan_udp_send(psock, buf, len);

View File

@ -239,7 +239,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
#endif
{
#if defined(CONFIG_NET_6LOWPAN)
/* Try 6loWPAN UDP packet sendto() */
/* Try 6LoWPAN UDP packet sendto() */
nsent = psock_6lowpan_udp_sendto(psock, buf, len, flags, to, tolen);

View File

@ -88,12 +88,12 @@ bool sched_addprioritized(FAR struct tcb_s *tcb, DSEG dq_queue_t *list)
ASSERT(sched_priority >= SCHED_PRIORITY_MIN);
/* Search the list to find the location to insert the new Tcb.
* Each is list is maintained in ascending sched_priority order.
* Each is list is maintained in descending sched_priority order.
*/
for (next = (FAR struct tcb_s *)list->head;
(next && sched_priority <= next->sched_priority);
next = next->flink);
next = next->flink);
/* Add the tcb to the spot found in the list. Check if the tcb
* goes at the end of the list. NOTE: This could only happen if list

View File

@ -21,14 +21,6 @@ config IEEE802154_DEFAULT_EADDR
---help---
Set the default extended address to be used by MAC networks on init
config IEEE802154_MAC_DEV
bool "Character driver for IEEE 802.15.4 MAC layer"
default n
depends on WIRELESS_IEEE802154
---help---
Enable the device driver to expose the IEEE 802.15.4 MAC layer
access to user space as IOCTLs
choice
prompt "IEEE 802.15.4 work queue"
default MAC802154_LPWORK if SCHED_LPWORK
@ -83,18 +75,66 @@ config IEEE802154_IND_IRQRESERVE
Non-interrupt logic will also first attempt to allocate from the
general, pre-allocated structure pool. If that fails, it will
dynamically allocate the meta data structure with an additional cost in performance.
config IEEE802154_MACDEV
bool "Character driver for IEEE 802.15.4 MAC layer"
default n
depends on WIRELESS_IEEE802154
---help---
Enable the device driver to expose the IEEE 802.15.4 MAC layer
access to user space as IOCTLs
if IEEE802154_MACDEV
config IEEE802154_MACDEV_RECVRPRIO
int "Priority of frame receiver registerd with the MAC layer"
default 0
---help---
When the MAC layer receives an incoming data frame, it passes the frame
to registered receivers, in order of receiver priority, until one of the
receivers claim the frame.
An example case would be when 6LoWPAN and the MAC character driver are
enabled. Both have receivers registered with the MAC. The 6LoWPAN layer
should get assigned a higher priority than the character driver. In this
case, the 6LoWPAN receiver will receive the frame first. If the frame is
a 6LoWPAN frame, it will claim the frame and the MAC will not pass the
frame to any additional receivers. If it does not claim the frame, the
MAC layer will call the next highest priority receiver, in this case,
the MAC character driver (which should always be lowest priority since
it is a "catch-all" type receiver).
endif # IEEE802154_MACDEV
config IEEE802154_NETDEV
bool "IEEE802154 6loWPAN Network Device"
bool "IEEE802154 6LoWPAN Network Device"
default n
depends on NET_6LOWPAN && NET_IPv6
select ARCH_HAVE_NETDEV_STATISTICS
---help---
Add support for the IEEE802.15.4 6loWPAN network device built on
Add support for the IEEE802.15.4 6LoWPAN network device built on
the common IEEE802.15.4 MAC.
if IEEE802154_NETDEV
config IEEE802154_NETDEV_RECVRPRIO
int "Priority of frame receiver registerd with the MAC layer"
default 1
---help---
When the MAC layer receives an incoming data frame, it passes the frame
to registered receivers, in order of receiver priority, until one of the
receivers claim the frame.
An example case would be when 6LoWPAN and the MAC character driver are
enabled. Both have receivers registered with the MAC. The 6LoWPAN layer
should get assigned a higher priority than the character driver. In this
case, the 6LoWPAN receiver will receive the frame first. If the frame is
a 6LoWPAN frame, it will claim the frame and the MAC will not pass the
frame to any additional receivers. If it does not claim the frame, the
MAC layer will call the next highest priority receiver, in this case,
the MAC character driver (which should always be lowest priority since
it is a "catch-all" type receiver).
choice
prompt "Work queue"
default IEEE802154_NETDEV_LPWORK if SCHED_LPWORK
@ -117,12 +157,12 @@ endchoice # Work queue
endif # IEEE802154_NETDEV
config IEEE802154_LOOPBACK
bool "IEEE802154 6loWPAN Loopback"
bool "IEEE802154 6LoWPAN Loopback"
default n
depends on NET_6LOWPAN && NET_IPv6
select ARCH_HAVE_NETDEV_STATISTICS
---help---
Add support for the IEEE802.15.4 6loWPAN Loopback test device.
Add support for the IEEE802.15.4 6LoWPAN Loopback test device.
if IEEE802154_LOOPBACK

View File

@ -46,7 +46,7 @@ CSRCS += mac802154_sync.c
# Include wireless devices build support
ifeq ($(CONFIG_IEEE802154_MAC_DEV),y)
ifeq ($(CONFIG_IEEE802154_MACDEV),y)
CSRCS += mac802154_device.c
endif

View File

@ -75,8 +75,8 @@ static void mac802154_resetqueues(FAR struct ieee802154_privmac_s *priv);
/* IEEE 802.15.4 PHY Interface OPs */
static int mac802154_poll(FAR const struct ieee802154_radiocb_s *radiocb,
bool gts, FAR struct ieee802154_txdesc_s **tx_desc);
static int mac802154_radiopoll(FAR const struct ieee802154_radiocb_s *radiocb,
bool gts, FAR struct ieee802154_txdesc_s **tx_desc);
static void mac802154_txdone(FAR const struct ieee802154_radiocb_s *radiocb,
FAR struct ieee802154_txdesc_s *tx_desc);
@ -95,7 +95,7 @@ static void mac802154_purge_worker(FAR void *arg);
/* Watchdog Timeout Functions */
static void mac802154_timeout_expiry(int argc, uint32_t arg, ...);
static void mac802154_timeout_expiry(int argc, wdparm_t arg, ...);
static uint32_t mac802154_symtoticks(FAR struct ieee802154_privmac_s *priv,
uint32_t symbols);
@ -232,6 +232,128 @@ int mac802154_txdesc_alloc(FAR struct ieee802154_privmac_s *priv,
return OK;
}
/****************************************************************************
* Name: mac802154_create_datareq
*
* Description:
* Internal function used by various parts of the MAC layer. This function
* allocates an IOB, populates the frame according to input args, and links
* the IOB into the provided tx descriptor.
*
* Assumptions:
* Called with the MAC locked
*
****************************************************************************/
void mac802154_create_datareq(FAR struct ieee802154_privmac_s *priv,
FAR struct ieee802154_addr_s *coordaddr,
enum ieee802154_addrmode_e srcmode,
FAR struct ieee802154_txdesc_s *txdesc)
{
FAR struct iob_s *iob;
FAR uint16_t *u16;
/* The only node allowed to use a source address of none is the PAN Coordinator.
* PAN coordinators should not be sending data request commans.
*/
DEBUGASSERT(srcmode != IEEE802154_ADDRMODE_NONE);
/* Allocate an IOB to put the frame in */
iob = iob_alloc(false);
DEBUGASSERT(iob != NULL);
iob->io_flink = NULL;
iob->io_len = 0;
iob->io_offset = 0;
iob->io_pktlen = 0;
/* Get a uin16_t reference to the first two bytes. ie frame control field */
u16 = (FAR uint16_t *)&iob->io_data[iob->io_len];
iob->io_len = 2;
*u16 = (IEEE802154_FRAME_COMMAND << IEEE802154_FRAMECTRL_SHIFT_FTYPE);
*u16 |= IEEE802154_FRAMECTRL_ACKREQ;
*u16 |= (coordaddr->mode << IEEE802154_FRAMECTRL_SHIFT_DADDR);
*u16 |= (srcmode << IEEE802154_FRAMECTRL_SHIFT_SADDR);
/* Each time a data or a MAC command frame is generated, the MAC sublayer
* shall copy the value of macDSN into the Sequence Number field of the
* MHR of the outgoing frame and then increment it by one. [1] pg. 40.
*/
iob->io_data[iob->io_len++] = priv->dsn++;
/* If the destination address is present, copy the PAN ID and one of the
* addresses, depending on mode, into the MHR.
*/
if (coordaddr->mode != IEEE802154_ADDRMODE_NONE)
{
mac802154_putpanid(iob, coordaddr->panid);
if (coordaddr->mode == IEEE802154_ADDRMODE_SHORT)
{
mac802154_putsaddr(iob, coordaddr->saddr);
}
else if (coordaddr->mode == IEEE802154_ADDRMODE_EXTENDED)
{
mac802154_puteaddr(iob, coordaddr->eaddr);
}
}
*u16 |= (coordaddr->mode << IEEE802154_FRAMECTRL_SHIFT_DADDR);
/* If the Destination Addressing Mode field is set to indicate that
* destination addressing information is not present, the PAN ID Compression
* field shall be set to zero and the source PAN identifier shall contain the
* value of macPANId. Otherwise, the PAN ID Compression field shall be set to
* one. In this case and in accordance with the PAN ID Compression field, the
* Destination PAN Identifier field shall contain the value of macPANId, while
* the Source PAN Identifier field shall be omitted. [1] pg. 72
*/
if (coordaddr->mode != IEEE802154_ADDRMODE_NONE &&
IEEE802154_PANIDCMP(coordaddr->panid, priv->addr.panid))
{
*u16 |= IEEE802154_FRAMECTRL_PANIDCOMP;
}
else
{
mac802154_putpanid(iob, priv->addr.panid);
}
if (srcmode == IEEE802154_ADDRMODE_SHORT)
{
mac802154_putsaddr(iob, priv->addr.saddr);
}
else if (srcmode == IEEE802154_ADDRMODE_EXTENDED)
{
mac802154_puteaddr(iob, priv->addr.eaddr);
}
/* Copy in the Command Frame Identifier */
iob->io_data[iob->io_len++] = IEEE802154_CMD_DATA_REQ;
/* Copy the IOB reference to the descriptor */
txdesc->frame = iob;
txdesc->frametype = IEEE802154_FRAME_COMMAND;
/* Save a copy of the destination addressing infromation into the tx descriptor.
* We only do this for commands to help with handling their progession.
*/
memcpy(&txdesc->destaddr, &coordaddr, sizeof(struct ieee802154_addr_s));
/* Copy the IOB reference to the descriptor */
txdesc->frame = iob;
}
/****************************************************************************
* Name: mac802154_setupindirect
*
@ -363,7 +485,7 @@ static void mac802154_purge_worker(FAR void *arg)
}
/****************************************************************************
* Name: mac802154_poll
* Name: mac802154_radiopoll
*
* Description:
* Called from the radio driver through the callback struct. This function is
@ -373,8 +495,8 @@ static void mac802154_purge_worker(FAR void *arg)
*
****************************************************************************/
static int mac802154_poll(FAR const struct ieee802154_radiocb_s *radiocb,
bool gts, FAR struct ieee802154_txdesc_s **txdesc)
static int mac802154_radiopoll(FAR const struct ieee802154_radiocb_s *radiocb,
bool gts, FAR struct ieee802154_txdesc_s **txdesc)
{
FAR struct mac802154_radiocb_s *cb =
(FAR struct mac802154_radiocb_s *)radiocb;
@ -499,11 +621,13 @@ static void mac802154_txdone_worker(FAR void *arg)
notif->notiftype = IEEE802154_NOTIFY_CONF_DATA;
/* Release the MAC, call the callback, get exclusive access again */
mac802154_givesem(&priv->exclsem);
priv->cb->notify(priv->cb, notif);
mac802154_notify(priv, notif);
mac802154_takesem(&priv->exclsem, false);
}
break;
case IEEE802154_FRAME_COMMAND:
{
switch (priv->curr_cmd)
@ -511,10 +635,13 @@ static void mac802154_txdone_worker(FAR void *arg)
case IEEE802154_CMD_ASSOC_REQ:
mac802154_txdone_assocreq(priv, txdesc);
break;
case IEEE802154_CMD_ASSOC_RESP:
break;
case IEEE802154_CMD_DISASSOC_NOT:
break;
case IEEE802154_CMD_DATA_REQ:
/* Data requests can be sent for 3 different reasons.
*
@ -534,23 +661,31 @@ static void mac802154_txdone_worker(FAR void *arg)
case MAC802154_OP_ASSOC:
mac802154_txdone_datareq_assoc(priv, txdesc);
break;
case MAC802154_OP_POLL:
mac802154_txdone_datareq_poll(priv, txdesc);
break;
default:
break;
}
break;
case IEEE802154_CMD_PANID_CONF_NOT:
break;
case IEEE802154_CMD_ORPHAN_NOT:
break;
case IEEE802154_CMD_BEACON_REQ:
break;
case IEEE802154_CMD_COORD_REALIGN:
break;
case IEEE802154_CMD_GTS_REQ:
break;
default:
/* We can deallocate the data conf notification as it is no
* longer needed. We can't use the public function here
@ -559,10 +694,12 @@ static void mac802154_txdone_worker(FAR void *arg)
privnotif->flink = priv->notif_free;
priv->notif_free = privnotif;
priv->nnotif = 0;
break;
}
}
break;
default:
{
/* We can deallocate the data conf notification as it is no longer
@ -648,7 +785,7 @@ static void mac802154_rxframe_worker(FAR void *arg)
FAR struct ieee802154_privmac_s *priv =
(FAR struct ieee802154_privmac_s *)arg;
FAR struct ieee802154_data_ind_s *ind;
FAR struct iob_s *frame;
FAR struct iob_s *iob;
uint16_t *frame_ctrl;
bool panid_comp;
uint8_t ftype;
@ -676,14 +813,14 @@ static void mac802154_rxframe_worker(FAR void *arg)
/* Get a local copy of the frame to make it easier to access */
frame = ind->frame;
iob = ind->frame;
/* Set a local pointer to the frame control then move the offset past
* the frame control field
*/
frame_ctrl = (uint16_t *)&frame->io_data[frame->io_offset];
frame->io_offset += 2;
frame_ctrl = (uint16_t *)&iob->io_data[iob->io_offset];
iob->io_offset += 2;
/* We use the data_ind_s as a container for the frame information even if
* this isn't a data frame
@ -698,7 +835,7 @@ static void mac802154_rxframe_worker(FAR void *arg)
panid_comp = (*frame_ctrl & IEEE802154_FRAMECTRL_PANIDCOMP) >>
IEEE802154_FRAMECTRL_SHIFT_PANIDCOMP;
ind->dsn = frame->io_data[frame->io_offset++];
ind->dsn = iob->io_data[iob->io_offset++];
/* If the destination address is included */
@ -706,19 +843,15 @@ static void mac802154_rxframe_worker(FAR void *arg)
{
/* Get the destination PAN ID */
memcpy(&ind->dest.panid, &frame->io_data[frame->io_offset], 2);
frame->io_offset += 2;
mac802154_takepanid(iob, ind->dest.panid);
if (ind->dest.mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(&ind->dest.saddr, &frame->io_data[frame->io_offset], 2);
frame->io_offset += 2;
mac802154_takesaddr(iob, ind->dest.saddr);
}
else if (ind->dest.mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(&ind->dest.eaddr[0], &frame->io_data[frame->io_offset],
IEEE802154_EADDR_LEN);
frame->io_offset += IEEE802154_EADDR_LEN;
mac802154_takeeaddr(iob, ind->dest.eaddr);
}
}
@ -732,24 +865,20 @@ static void mac802154_rxframe_worker(FAR void *arg)
{
/* The source PAN ID is equal to the destination PAN ID */
ind->src.panid = ind->dest.panid;
IEEE802154_PANIDCOPY(ind->src.panid, ind->dest.panid);
}
else
{
memcpy(&ind->src.panid, &frame->io_data[frame->io_offset], 2);
frame->io_offset += 2;
mac802154_takepanid(iob, ind->src.panid);
}
if (ind->src.mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(&ind->src.saddr, &frame->io_data[frame->io_offset], 2);
frame->io_offset += 2;
mac802154_takesaddr(iob, ind->src.saddr);
}
else if (ind->src.mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(&ind->src.eaddr[0], &frame->io_data[frame->io_offset],
IEEE802154_EADDR_LEN);
frame->io_offset += 8;
mac802154_takeeaddr(iob, ind->src.eaddr);
}
}
@ -771,29 +900,37 @@ static void mac802154_rxframe_worker(FAR void *arg)
* subsequent functions can start from the byte after the command ID.
*/
uint8_t cmdtype = frame->io_data[frame->io_offset++];
uint8_t cmdtype = iob->io_data[iob->io_offset++];
switch (cmdtype)
{
case IEEE802154_CMD_ASSOC_REQ:
mac802154_rx_assocreq(priv, ind);
break;
case IEEE802154_CMD_ASSOC_RESP:
mac802154_rx_assocresp(priv, ind);
break;
case IEEE802154_CMD_DISASSOC_NOT:
break;
case IEEE802154_CMD_DATA_REQ:
mac802154_rx_datareq(priv, ind);
break;
case IEEE802154_CMD_PANID_CONF_NOT:
break;
case IEEE802154_CMD_ORPHAN_NOT:
break;
case IEEE802154_CMD_BEACON_REQ:
break;
case IEEE802154_CMD_COORD_REALIGN:
break;
case IEEE802154_CMD_GTS_REQ:
break;
}
@ -810,8 +947,10 @@ static void mac802154_rxframe_worker(FAR void *arg)
* coordinator if beacon tracking was enabled during the Association
* operation.
*
* txdesc = mac802154_assoc_getresp(priv);
* sq_addlast((FAR sq_entry_t *)txdesc, &priv->csma_queue);
* mac802154_txdesc_alloc(priv, &respdec, false);
* mac802154_create_datareq(priv, &req->coordaddr,
* IEEE802154_ADDRMODE_EXTENDED, respdesc);
* sq_addlast((FAR sq_entry_t *)respdesc, &priv->csma_queue);
*/
}
break;
@ -874,19 +1013,18 @@ static void mac802154_rx_dataframe(FAR struct ieee802154_privmac_s *priv,
if (priv->promisc)
{
if (ind->dest.panid != priv->addr.panid)
if (!IEEE802154_PANIDCMP(ind->dest.panid, priv->addr.panid))
{
goto notify_with_lock;
}
if (ind->dest.mode == IEEE802154_ADDRMODE_SHORT &&
ind->dest.saddr != priv->addr.saddr)
!IEEE802154_SADDRCMP(ind->dest.saddr, priv->addr.saddr))
{
goto notify_with_lock;
}
else if (ind->dest.mode == IEEE802154_ADDRMODE_EXTENDED &&
(memcmp(&ind->dest.eaddr[0], &priv->addr.eaddr[0],
IEEE802154_EADDR_LEN) != 0))
!IEEE802154_EADDRCMP(ind->dest.eaddr, priv->addr.eaddr))
{
goto notify_with_lock;
}
@ -909,13 +1047,12 @@ static void mac802154_rx_dataframe(FAR struct ieee802154_privmac_s *priv,
}
if (ind->src.mode == IEEE802154_ADDRMODE_SHORT &&
ind->src.saddr != priv->cmd_desc->destaddr.saddr)
!IEEE802154_SADDRCMP(ind->src.saddr, priv->cmd_desc->destaddr.saddr))
{
goto notify_with_lock;
}
else if (ind->src.mode == IEEE802154_ADDRMODE_EXTENDED &&
(memcmp(&ind->src.eaddr[0], &priv->cmd_desc->destaddr.eaddr[0],
IEEE802154_EADDR_LEN) != 0))
!IEEE802154_EADDRCMP(ind->src.eaddr, priv->cmd_desc->destaddr.eaddr))
{
goto notify_with_lock;
}
@ -965,8 +1102,7 @@ static void mac802154_rx_dataframe(FAR struct ieee802154_privmac_s *priv,
/* Release the MAC */
mac802154_givesem(&priv->exclsem);
priv->cb->notify(priv->cb, notif);
mac802154_notify(priv, notif);
/* If there was data, pass it along */
@ -977,26 +1113,48 @@ static void mac802154_rx_dataframe(FAR struct ieee802154_privmac_s *priv,
}
else
{
FAR struct mac802154_maccb_s *cb;
notify_with_lock:
mac802154_givesem(&priv->exclsem);
notify_without_lock:
/* If there is a registered MCPS callback receiver registered,
* send the frame, otherwise, throw it out.
/* If there are registered MCPS callback receivers registered,
* then forward the frame in priority order. If there are no
* registered receivers or if none of the receivers accept the
* data frame then drop the frame.
*/
if (priv->cb->rxframe != NULL)
for (cb = priv->cb; cb != NULL; cb = cb->flink)
{
priv->cb->rxframe(priv->cb, ind);
}
else
{
/* Free the data indication struct from the pool */
int ret;
ieee802154_ind_free(ind);
/* Does this MAC client want frames? */
if (cb->rxframe != NULL)
{
/* Yes.. Offer this frame to the receiver */
ret = cb->rxframe(cb, ind);
if (ret >= 0)
{
/* The receiver accepted and disposed of the frame and
* its metadata. We are done.
*/
return;
}
}
}
/* We get here if the there are no registered receivers or if
* all of the registered receivers declined the frame.
* Free the data indication struct from the pool
*/
ieee802154_ind_free(ind);
}
}
@ -1043,7 +1201,7 @@ static void mac802154_rx_datareq(FAR struct ieee802154_privmac_s *priv,
{
if (txdesc->destaddr.mode == IEEE802154_ADDRMODE_SHORT)
{
if (txdesc->destaddr.saddr == ind->src.saddr)
if (IEEE802154_SADDRCMP(txdesc->destaddr.saddr, ind->src.saddr))
{
/* Remove the transaction from the queue */
@ -1058,7 +1216,7 @@ static void mac802154_rx_datareq(FAR struct ieee802154_privmac_s *priv,
else if (txdesc->destaddr.mode == IEEE802154_ADDRMODE_EXTENDED)
{
if (memcmp(&txdesc->destaddr.eaddr[0], &ind->src.eaddr[0],
sizeof(IEEE802154_EADDR_LEN)) == 0)
sizeof(IEEE802154_EADDRSIZE)) == 0)
{
/* Remove the transaction from the queue */
@ -1131,18 +1289,15 @@ no_data:
* respond.
*/
*((uint16_t *)&iob->io_data[iob->io_len]) = ind->src.panid;
iob->io_len += 2;
mac802154_putpanid(iob, ind->src.panid);
if (ind->src.mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(&iob->io_data[iob->io_len], &ind->src.saddr, 2);
iob->io_len += 2;
mac802154_putsaddr(iob, ind->src.saddr);
}
else if (ind->src.mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(&iob->io_data[iob->io_len], &ind->src.eaddr, IEEE802154_EADDR_LEN);
iob->io_len += IEEE802154_EADDR_LEN;
mac802154_puteaddr(iob, ind->src.eaddr);
}
else
{
@ -1155,7 +1310,7 @@ no_data:
/* Check if the source PAN ID of the incoming request is the same as ours. */
if (ind->src.panid == priv->addr.panid)
if (IEEE802154_PANIDCMP(ind->src.panid, priv->addr.panid))
{
*frame_ctrl |= IEEE802154_FRAMECTRL_PANIDCOMP;
}
@ -1163,23 +1318,19 @@ no_data:
{
/* Copy in our PAN ID */
memcpy(&iob->io_data[iob->io_len], &priv->addr.panid, 2);
iob->io_len += 2;
mac802154_putpanid(iob, priv->addr.panid);
}
/* Copy in our address using the mode that the device used to address us */
if (ind->dest.mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(&iob->io_data[iob->io_len], &priv->addr.saddr, 2);
iob->io_len += 2;
mac802154_putsaddr(iob, priv->addr.saddr);
*frame_ctrl |= (IEEE802154_ADDRMODE_SHORT << IEEE802154_FRAMECTRL_SHIFT_SADDR);
}
else
{
memcpy(&iob->io_data[iob->io_len], &ind->dest.eaddr, IEEE802154_EADDR_LEN);
iob->io_len += IEEE802154_EADDR_LEN;
mac802154_puteaddr(iob, priv->addr.eaddr);
*frame_ctrl |= (IEEE802154_ADDRMODE_EXTENDED << IEEE802154_FRAMECTRL_SHIFT_SADDR);
}
@ -1271,7 +1422,8 @@ int mac802154_timerstart(FAR struct ieee802154_privmac_s *priv,
/* Start the watchdog */
wd_start(priv->timeout, (int32_t)ticks, mac802154_timeout_expiry, 1, (uint32_t)priv);
wd_start(priv->timeout, (int32_t)ticks, mac802154_timeout_expiry,
1, (wdparm_t)priv);
return OK;
}
@ -1294,7 +1446,7 @@ int mac802154_timerstart(FAR struct ieee802154_privmac_s *priv,
*
****************************************************************************/
static void mac802154_timeout_expiry(int argc, uint32_t arg, ...)
static void mac802154_timeout_expiry(int argc, wdparm_t arg, ...)
{
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)arg;
@ -1344,7 +1496,7 @@ MACHANDLE mac802154_create(FAR struct ieee802154_radio_s *radiodev)
{
FAR struct ieee802154_privmac_s *mac;
FAR struct ieee802154_radiocb_s *radiocb;
uint8_t eaddr[IEEE802154_EADDR_LEN];
uint8_t eaddr[IEEE802154_EADDRSIZE];
int i;
/* Allocate object */
@ -1380,7 +1532,7 @@ MACHANDLE mac802154_create(FAR struct ieee802154_radio_s *radiodev)
mac->radiocb.priv = mac;
radiocb = &mac->radiocb.cb;
radiocb->poll = mac802154_poll;
radiocb->poll = mac802154_radiopoll;
radiocb->txdone = mac802154_txdone;
radiocb->rxframe = mac802154_rxframe;
@ -1395,12 +1547,12 @@ MACHANDLE mac802154_create(FAR struct ieee802154_radio_s *radiodev)
/* Set the default extended address */
for (i = 0; i < IEEE802154_EADDR_LEN; i++)
for (i = 0; i < IEEE802154_EADDRSIZE; i++)
{
eaddr[i] = (CONFIG_IEEE802154_DEFAULT_EADDR >> (8 * i)) & 0xFF;
}
memcpy(&mac->addr.eaddr, &eaddr[0], IEEE802154_EADDR_LEN);
IEEE802154_EADDRCOPY(mac->addr.eaddr, eaddr);
mac->radio->set_attr(mac->radio, IEEE802154_ATTR_MAC_EXTENDED_ADDR,
(union ieee802154_attr_u *)&eaddr[0]);

View File

@ -58,18 +58,22 @@
* Public Data Types
****************************************************************************/
/* Callback operations to notify the next highest layer of various asynchronous
* events, usually triggered by some previous request or response invoked by the
* upper layer.
/* Callback operations to notify the next highest layer of various
* asynchronous events, usually triggered by some previous request or
* response invoked by the upper layer.
*/
struct mac802154_maccb_s
{
CODE void (*notify)(FAR const struct mac802154_maccb_s *maccb,
FAR struct ieee802154_notif_s *notif);
FAR struct mac802154_maccb_s *flink; /* Implements a singly linked list */
uint8_t prio; /* RX frame callback priority */
CODE void (*rxframe)(FAR const struct mac802154_maccb_s *maccb,
FAR struct ieee802154_data_ind_s *ind);
/* Callback methods */
CODE void (*notify)(FAR struct mac802154_maccb_s *maccb,
FAR struct ieee802154_notif_s *notif);
CODE int (*rxframe)(FAR struct mac802154_maccb_s *maccb,
FAR struct ieee802154_data_ind_s *ind);
};
/****************************************************************************
@ -93,7 +97,7 @@ struct iob_s; /* Forward reference */
*
****************************************************************************/
int mac802154_bind(MACHANDLE mac, FAR const struct mac802154_maccb_s *cb);
int mac802154_bind(MACHANDLE mac, FAR struct mac802154_maccb_s *cb);
/****************************************************************************
* Name: mac802154_ioctl

View File

@ -59,8 +59,6 @@
****************************************************************************/
static void mac802154_timeout_assoc(FAR struct ieee802154_privmac_s *priv);
static FAR struct ieee802154_txdesc_s *
mac802154_assoc_getresp(FAR struct ieee802154_privmac_s *priv);
/****************************************************************************
* Public MAC Functions
@ -92,6 +90,11 @@ int mac802154_req_associate(MACHANDLE mac,
bool rxonidle;
int ret;
if (req->coordaddr.mode == IEEE802154_ADDRMODE_NONE)
{
return -EINVAL;
}
/* Get exlusive access to the operation sempaphore. This must happen before
* getting exclusive access to the MAC struct or else there could be a lockup
* condition. This would occur if another thread is using the cmdtrans but
@ -124,34 +127,16 @@ int mac802154_req_associate(MACHANDLE mac,
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_PHY_CURRENT_PAGE,
(FAR const union ieee802154_attr_u *)&req->chpage);
/* Set the PANID attribute */
priv->addr.panid = req->coordaddr.panid;
priv->coordaddr.panid = req->coordaddr.panid;
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_MAC_PANID,
(FAR const union ieee802154_attr_u *)&req->coordaddr.panid);
/* Set the coordinator address attributes */
priv->coordaddr.mode = req->coordaddr.mode;
memcpy(&priv->coordaddr, &req->coordaddr, sizeof(struct ieee802154_addr_s));
if (priv->coordaddr.mode == IEEE802154_ADDRMODE_SHORT)
{
priv->coordaddr.saddr = req->coordaddr.saddr;
memcpy(&priv->coordaddr.eaddr[0], IEEE802154_EADDR_UNSPEC,
IEEE802154_EADDR_LEN);
}
else if (priv->coordaddr.mode == IEEE802154_ADDRMODE_EXTENDED)
{
priv->coordaddr.saddr = IEEE802154_SADDR_UNSPEC;
memcpy(&priv->coordaddr.eaddr[0], &req->coordaddr.eaddr[0],
IEEE802154_EADDR_LEN);
}
else
{
ret = -EINVAL;
goto errout;
}
/* Copy the coordinator PAN ID to our PAN ID */
IEEE802154_PANIDCOPY(priv->addr.panid, req->coordaddr.panid);
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_MAC_PANID,
(FAR const union ieee802154_attr_u *)req->coordaddr.panid);
/* Copy in the capabilities information bitfield */
@ -212,8 +197,7 @@ int mac802154_req_associate(MACHANDLE mac,
* PAN to which to associate. [1] pg. 68
*/
memcpy(&iob->io_data[iob->io_len], &priv->coordaddr.panid, 2);
iob->io_len += 2;
mac802154_putpanid(iob, priv->coordaddr.panid);
/* The Destination Address field shall contain the address from the beacon
* frame that was transmitted by the coordinator to which the association
@ -222,27 +206,20 @@ int mac802154_req_associate(MACHANDLE mac,
if (priv->coordaddr.mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(&iob->io_data[iob->io_len], &priv->coordaddr.saddr, 2);
iob->io_len += 2;
mac802154_putsaddr(iob, priv->coordaddr.saddr);
}
else if (priv->coordaddr.mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(&iob->io_data[iob->io_len], &priv->coordaddr.eaddr[0],
IEEE802154_EADDR_LEN);
iob->io_len += IEEE802154_EADDR_LEN;
mac802154_puteaddr(iob, priv->coordaddr.eaddr);
}
/* The Source PAN Identifier field shall contain the broadcast PAN identifier.*/
u16 = (uint16_t *)&iob->io_data[iob->io_len];
*u16 = IEEE802154_SADDR_BCAST;
iob->io_len += 2;
mac802154_putsaddr(iob, &IEEE802154_SADDR_BCAST);
/* The Source Address field shall contain the value of macExtendedAddress. */
memcpy(&iob->io_data[iob->io_len], &priv->addr.eaddr[0],
IEEE802154_EADDR_LEN);
iob->io_len += IEEE802154_EADDR_LEN;
mac802154_puteaddr(iob, priv->addr.eaddr);
/* Copy in the Command Frame Identifier */
@ -286,10 +263,6 @@ int mac802154_req_associate(MACHANDLE mac,
priv->radio->txdelayed(priv->radio, txdesc, 0);
return OK;
errout:
mac802154_givesem(&priv->exclsem);
return ret;
}
/****************************************************************************
@ -353,20 +326,17 @@ int mac802154_resp_associate(MACHANDLE mac,
* Destination PAN Identifier field shall contain the value of macPANId, while
* the Source PAN Identifier field shall be omitted. [1] pg. 69
*/
memcpy(&iob->io_data[iob->io_len], &priv->addr.panid, 2);
iob->io_len += 2;
mac802154_putpanid(iob, priv->addr.panid);
/* The Destination Address field shall contain the extended address of the
* device requesting association. [1] pg. 69 */
memcpy(&iob->io_data[iob->io_len], &resp->devaddr[0], IEEE802154_EADDR_LEN);
iob->io_len += IEEE802154_EADDR_LEN;
mac802154_puteaddr(iob, resp->devaddr);
/* The Source Address field shall contain the value of macExtendedAddress. */
memcpy(&iob->io_data[iob->io_len], &priv->addr.eaddr[0], IEEE802154_EADDR_LEN);
iob->io_len += IEEE802154_EADDR_LEN;
mac802154_puteaddr(iob, priv->addr.eaddr);
/* Copy in the Command Frame Identifier */
@ -376,14 +346,12 @@ int mac802154_resp_associate(MACHANDLE mac,
if (resp->status == IEEE802154_STATUS_SUCCESS)
{
memcpy(&iob->io_data[iob->io_len], &resp->assocsaddr, 2);
mac802154_putsaddr(iob, resp->assocsaddr);
}
else
{
u16 = (FAR uint16_t *)&iob->io_data[iob->io_len];
*u16 = IEEE802154_SADDR_UNSPEC;
mac802154_putsaddr(iob, &IEEE802154_SADDR_UNSPEC);
}
iob->io_len += 2;
/* Copy in the association status */
@ -411,9 +379,9 @@ int mac802154_resp_associate(MACHANDLE mac,
txdesc->frame = iob;
txdesc->frametype = IEEE802154_FRAME_COMMAND;
txdesc->destaddr.panid = priv->addr.panid;
txdesc->destaddr.mode = IEEE802154_ADDRMODE_EXTENDED;
memcpy(&txdesc->destaddr.eaddr[0], &resp->devaddr[0], IEEE802154_EADDR_LEN);
IEEE802154_PANIDCOPY(txdesc->destaddr.panid, priv->addr.panid);
IEEE802154_EADDRCOPY(txdesc->destaddr.eaddr, resp->devaddr);
mac802154_setupindirect(priv, txdesc);
@ -471,7 +439,7 @@ void mac802154_txdone_assocreq(FAR struct ieee802154_privmac_s *priv,
* if the association attempt was unsuccessful. [1] pg. 81
*/
notif->u.assocconf.saddr = IEEE802154_SADDR_UNSPEC;
IEEE802154_SADDRCOPY(notif->u.assocconf.saddr, &IEEE802154_SADDR_UNSPEC);
/* We are now done the operation, unlock the semaphore */
@ -482,7 +450,7 @@ void mac802154_txdone_assocreq(FAR struct ieee802154_privmac_s *priv,
/* Release the MAC, call the callback, get exclusive access again */
mac802154_givesem(&priv->exclsem);
priv->cb->notify(priv->cb, notif);
mac802154_notify(priv, notif);
mac802154_takesem(&priv->exclsem, false);
}
else
@ -509,17 +477,30 @@ void mac802154_txdone_assocreq(FAR struct ieee802154_privmac_s *priv,
* due to NO_DATA.
*/
mac802154_timerstart(priv,
priv->resp_waittime*IEEE802154_BASE_SUPERFRAME_DURATION,
mac802154_timeout_assoc);
mac802154_timerstart(priv, (priv->resp_waittime *
IEEE802154_BASE_SUPERFRAME_DURATION),
mac802154_timeout_assoc);
}
else
{
/* Make sure the coordinator address mode is not set to none. This shouldn't
* happen since the association request should have set the mode to short or
* extended
*/
DEBUGASSERT(priv->coordaddr.mode != IEEE802154_ADDRMODE_NONE);
/* Send the Data Request MAC command after macResponseWaitTime to
* extract the data from the coordinator.
*/
respdesc = mac802154_assoc_getresp(priv);
mac802154_txdesc_alloc(priv, &respdesc, false);
mac802154_create_datareq(priv, &priv->coordaddr,
IEEE802154_ADDRMODE_EXTENDED, respdesc);
priv->curr_cmd = IEEE802154_CMD_DATA_REQ;
priv->radio->txdelayed(priv->radio, respdesc,
(priv->resp_waittime*IEEE802154_BASE_SUPERFRAME_DURATION));
}
@ -590,7 +571,7 @@ void mac802154_txdone_datareq_assoc(FAR struct ieee802154_privmac_s *priv,
* if the association attempt was unsuccessful. [1] pg. 81
*/
notif->u.assocconf.saddr = IEEE802154_SADDR_UNSPEC;
IEEE802154_SADDRCOPY(notif->u.assocconf.saddr, &IEEE802154_SADDR_UNSPEC);
/* We are now done the operation, and can release the command */
@ -601,7 +582,7 @@ void mac802154_txdone_datareq_assoc(FAR struct ieee802154_privmac_s *priv,
/* Release the MAC, call the callback, get exclusive access again */
mac802154_givesem(&priv->exclsem);
priv->cb->notify(priv->cb, notif);
mac802154_notify(priv, notif);
mac802154_takesem(&priv->exclsem, false);
}
else
@ -670,8 +651,7 @@ void mac802154_rx_assocreq(FAR struct ieee802154_privmac_s *priv,
/* Copy the extended address of the requesting device */
memcpy(&notif->u.assocind.devaddr[0], &ind->src.eaddr[0],
sizeof(struct ieee802154_addr_s));
IEEE802154_EADDRCOPY(notif->u.assocind.devaddr, ind->src.eaddr);
/* Copy in the capability information from the frame to the notification */
@ -697,8 +677,7 @@ void mac802154_rx_assocreq(FAR struct ieee802154_privmac_s *priv,
/* Notify the next highest layer of the association status */
priv->cb->notify(priv->cb, notif);
mac802154_notify(priv, notif);
return;
errout_with_sem:
@ -718,7 +697,7 @@ errout_with_sem:
void mac802154_rx_assocresp(FAR struct ieee802154_privmac_s *priv,
FAR struct ieee802154_data_ind_s *ind)
{
FAR struct iob_s *frame = ind->frame;
FAR struct iob_s *iob = ind->frame;
FAR struct ieee802154_notif_s *notif;
/* Check if we are performing an Association operation, if not, we will just
@ -745,13 +724,12 @@ void mac802154_rx_assocresp(FAR struct ieee802154_privmac_s *priv,
/* Parse the short address from the response */
priv->addr.saddr = (uint16_t)(frame->io_data[frame->io_offset]);
frame->io_offset += 2;
mac802154_takesaddr(iob, priv->addr.saddr);
/* Inform the radio of the address change */
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_MAC_SHORT_ADDRESS,
(FAR union ieee802154_attr_u *)&priv->addr.saddr);
(FAR union ieee802154_attr_u *)priv->addr.saddr);
/* A Short Address field value equal to 0xfffe shall indicate that the device
* has been successfully associated with a PAN but has not been allocated a
@ -759,7 +737,7 @@ void mac802154_rx_assocresp(FAR struct ieee802154_privmac_s *priv,
* only its extended address. [1] pg. 70
*/
if (priv->addr.saddr == IEEE802154_SADDR_BCAST)
if (IEEE802154_SADDRCMP(priv->addr.saddr, &IEEE802154_SADDR_BCAST))
{
/* TODO: Figure out if this is sufficient */
@ -768,7 +746,7 @@ void mac802154_rx_assocresp(FAR struct ieee802154_privmac_s *priv,
/* Parse the status from the response */
notif->u.assocconf.status = frame->io_data[frame->io_offset++];
notif->u.assocconf.status = iob->io_data[iob->io_offset++];
if (notif->u.assocconf.status == IEEE802154_STATUS_SUCCESS)
{
@ -779,7 +757,7 @@ void mac802154_rx_assocresp(FAR struct ieee802154_privmac_s *priv,
priv->isassoc = false;
}
notif->u.assocconf.saddr = priv->addr.saddr;
IEEE802154_SADDRCOPY(notif->u.assocconf.saddr, priv->addr.saddr);
/* Unlock the MAC */
@ -793,7 +771,7 @@ void mac802154_rx_assocresp(FAR struct ieee802154_privmac_s *priv,
/* Notify the next highest layer of the association status */
priv->cb->notify(priv->cb, notif);
mac802154_notify(priv, notif);
}
/****************************************************************************
@ -840,118 +818,7 @@ static void mac802154_timeout_assoc(FAR struct ieee802154_privmac_s *priv)
notif->notiftype = IEEE802154_NOTIFY_CONF_ASSOC;
notif->u.assocconf.status = IEEE802154_STATUS_NO_DATA;
notif->u.assocconf.saddr = IEEE802154_SADDR_UNSPEC;
IEEE802154_SADDRCOPY(notif->u.assocconf.saddr, &IEEE802154_SADDR_UNSPEC);
priv->cb->notify(priv->cb, notif);
}
/****************************************************************************
* Name: mac802154_assoc_getresp
*
* Description:
* Send a data request to the coordinator to extract the association response.
*
* Assumptions:
* MAC is locked when called.
*
* TODO: Can this be used for general data extraction?
*
****************************************************************************/
static FAR struct ieee802154_txdesc_s *
mac802154_assoc_getresp(FAR struct ieee802154_privmac_s *priv)
{
FAR struct iob_s *iob;
FAR struct ieee802154_txdesc_s *txdesc;
FAR uint16_t *u16;
/* Allocate an IOB to put the frame in */
iob = iob_alloc(false);
DEBUGASSERT(iob != NULL);
iob->io_flink = NULL;
iob->io_len = 0;
iob->io_offset = 0;
iob->io_pktlen = 0;
/* Allocate a tx descriptor */
mac802154_txdesc_alloc(priv, &txdesc, false);
priv->curr_cmd = IEEE802154_CMD_DATA_REQ;
/* Get a uin16_t reference to the first two bytes. ie frame control field */
u16 = (FAR uint16_t *)&iob->io_data[0];
*u16 = (IEEE802154_FRAME_COMMAND << IEEE802154_FRAMECTRL_SHIFT_FTYPE);
*u16 |= IEEE802154_FRAMECTRL_ACKREQ;
*u16 |= (priv->coordaddr.mode << IEEE802154_FRAMECTRL_SHIFT_DADDR);
*u16 |= (IEEE802154_ADDRMODE_EXTENDED << IEEE802154_FRAMECTRL_SHIFT_SADDR);
/* If the Destination Addressing Mode field is set to indicate that
* destination addressing information is not present, the PAN ID Compression
* field shall be set to zero and the source PAN identifier shall contain the
* value of macPANId. Otherwise, the PAN ID Compression field shall be set to
* one. In this case and in accordance with the PAN ID Compression field, the
* Destination PAN Identifier field shall contain the value of macPANId, while
* the Source PAN Identifier field shall be omitted. [1] pg. 72
*
* The destination address for a data request to extract an assoication request
* should never be set to none. So we always set the PAN ID compression field
*/
DEBUGASSERT(priv->coordaddr.mode != IEEE802154_ADDRMODE_NONE);
*u16 |= IEEE802154_FRAMECTRL_PANIDCOMP;
iob->io_len = 2;
/* Each time a data or a MAC command frame is generated, the MAC sublayer
* shall copy the value of macDSN into the Sequence Number field of the
* MHR of the outgoing frame and then increment it by one. [1] pg. 40.
*/
iob->io_data[iob->io_len++] = priv->dsn++;
/* The Destination PAN Identifier field shall contain the identifier of
* the PAN to which to associate. [1] pg. 68
*/
memcpy(&iob->io_data[iob->io_len], &priv->coordaddr.panid, 2);
iob->io_len += 2;
/* The Destination Address field shall contain the address from the
* beacon frame that was transmitted by the coordinator to which the
* association request command is being sent. [1] pg. 68
*/
if (priv->coordaddr.mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(&iob->io_data[iob->io_len], &priv->coordaddr.saddr, 2);
iob->io_len += 2;
}
else if (priv->coordaddr.mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(&iob->io_data[iob->io_len], &priv->coordaddr.eaddr[0],
IEEE802154_EADDR_LEN);
iob->io_len += IEEE802154_EADDR_LEN;
}
/* The Source Address field shall contain the value of macExtendedAddress. */
memcpy(&iob->io_data[iob->io_len], &priv->addr.eaddr[0],
IEEE802154_EADDR_LEN);
iob->io_len += IEEE802154_EADDR_LEN;
/* Copy in the Command Frame Identifier */
iob->io_data[iob->io_len++] = IEEE802154_CMD_DATA_REQ;
/* Copy the IOB reference to the descriptor */
txdesc->frame = iob;
return txdesc;
mac802154_notify(priv, notif);
}

View File

@ -69,12 +69,48 @@
*
****************************************************************************/
int mac802154_bind(MACHANDLE mac, FAR const struct mac802154_maccb_s *cb)
int mac802154_bind(MACHANDLE mac, FAR struct mac802154_maccb_s *cb)
{
FAR struct ieee802154_privmac_s *priv =
(FAR struct ieee802154_privmac_s *)mac;
FAR struct mac802154_maccb_s *next;
FAR struct mac802154_maccb_s *prev;
/* Add the MAC client callback structure to the list of MAC callbacks in
* priority order.
*
* Search the list to find the location to insert the new instance.
* The list is maintained in descending priority order.
*/
for (prev = NULL, next = priv->cb;
(next != NULL && cb->prio <= next->prio);
prev = next, next = next->flink);
/* Add the instance to the spot found in the list. Check if the instance
* goes at the head of the list.
*/
if (prev == NULL)
{
cb->flink = priv->cb; /* May be NULL */
priv->cb = cb;
}
/* No.. the instance goes between prev and next */
else
{
cb->flink = next; /* May be NULL */
prev->flink = cb;
}
/* Keep track of the number of clients requesting notification */
if (cb->notify != NULL)
{
priv->nclients++;
}
priv->cb = cb;
return OK;
}

View File

@ -79,7 +79,7 @@ int mac802154_req_data(MACHANDLE mac,
(FAR struct ieee802154_privmac_s *)mac;
FAR struct ieee802154_txdesc_s *txdesc;
uint16_t *frame_ctrl;
uint8_t mhr_len = 3; /* Start assuming frame control and seq. num */
uint8_t mhr_len = 3;
int ret;
/* Check the required frame size */
@ -123,20 +123,18 @@ int mac802154_req_data(MACHANDLE mac,
if (meta->destaddr.mode != IEEE802154_ADDRMODE_NONE)
{
memcpy(&frame->io_data[mhr_len], &meta->destaddr.panid, 2);
IEEE802154_PANIDCOPY(&frame->io_data[mhr_len], meta->destaddr.panid);
mhr_len += 2;
if (meta->destaddr.mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(&frame->io_data[mhr_len], &meta->destaddr.saddr, 2);
IEEE802154_SADDRCOPY(&frame->io_data[mhr_len], meta->destaddr.saddr);
mhr_len += 2;
}
else if (meta->destaddr.mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(&frame->io_data[mhr_len], &meta->destaddr.eaddr,
IEEE802154_EADDR_LEN);
mhr_len += IEEE802154_EADDR_LEN;
IEEE802154_EADDRCOPY(&frame->io_data[mhr_len], meta->destaddr.eaddr);
mhr_len += IEEE802154_EADDRSIZE;
}
}
@ -165,7 +163,7 @@ int mac802154_req_data(MACHANDLE mac,
* from the transmitted frame. [1] pg. 41.
*/
if (meta->destaddr.panid == priv->addr.panid)
if (IEEE802154_PANIDCMP(meta->destaddr.panid, priv->addr.panid))
{
*frame_ctrl |= IEEE802154_FRAMECTRL_PANIDCOMP;
}
@ -180,21 +178,19 @@ int mac802154_req_data(MACHANDLE mac,
if ((meta->destaddr.mode == IEEE802154_ADDRMODE_NONE) ||
(!(*frame_ctrl & IEEE802154_FRAMECTRL_PANIDCOMP)))
{
memcpy(&frame->io_data[mhr_len], &priv->addr.panid, 2);
IEEE802154_PANIDCOPY(&frame->io_data[mhr_len], priv->addr.panid);
mhr_len += 2;
}
if (meta->srcaddr_mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(&frame->io_data[mhr_len], &priv->addr.saddr, 2);
IEEE802154_SADDRCOPY(&frame->io_data[mhr_len], priv->addr.saddr);
mhr_len += 2;
}
else if (meta->srcaddr_mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(&frame->io_data[mhr_len], &priv->addr.eaddr,
IEEE802154_EADDR_LEN);
mhr_len += IEEE802154_EADDR_LEN;
IEEE802154_EADDRCOPY(&frame->io_data[mhr_len], priv->addr.eaddr);
mhr_len += IEEE802154_EADDRSIZE;
}
}
else

View File

@ -141,10 +141,9 @@ static inline void mac802154dev_pushevent(FAR struct mac802154_chardevice_s *dev
static inline FAR struct ieee802154_notif_s *
mac802154dev_popevent(FAR struct mac802154_chardevice_s *dev);
static void mac802154dev_notify(FAR const struct mac802154_maccb_s *maccb,
static void mac802154dev_notify(FAR struct mac802154_maccb_s *maccb,
FAR struct ieee802154_notif_s *notif);
static void mac802154dev_rxframe(FAR const struct mac802154_maccb_s *maccb,
static int mac802154dev_rxframe(FAR struct mac802154_maccb_s *maccb,
FAR struct ieee802154_data_ind_s *ind);
static int mac802154dev_open(FAR struct file *filep);
@ -762,7 +761,7 @@ static int mac802154dev_ioctl(FAR struct file *filep, int cmd,
return ret;
}
static void mac802154dev_notify(FAR const struct mac802154_maccb_s *maccb,
static void mac802154dev_notify(FAR struct mac802154_maccb_s *maccb,
FAR struct ieee802154_notif_s *notif)
{
FAR struct mac802154dev_callback_s *cb =
@ -826,8 +825,20 @@ static void mac802154dev_notify(FAR const struct mac802154_maccb_s *maccb,
mac802154dev_givesem(&dev->md_exclsem);
}
static void mac802154dev_rxframe(FAR const struct mac802154_maccb_s *maccb,
FAR struct ieee802154_data_ind_s *ind)
/****************************************************************************
* Name: mac802154dev_rxframe
*
* Description:
* Handle received frames forward by the IEEE 802.15.4 MAC.
*
* Returned Value:
* any failure. On success, the ind and its contained iob will be freed.
* The ind will be intact if this function returns a failure.
*
****************************************************************************/
static int mac802154dev_rxframe(FAR struct mac802154_maccb_s *maccb,
FAR struct ieee802154_data_ind_s *ind)
{
FAR struct mac802154dev_callback_s *cb =
(FAR struct mac802154dev_callback_s *)maccb;
@ -858,6 +869,7 @@ static void mac802154dev_rxframe(FAR const struct mac802154_maccb_s *maccb,
/* Release the driver */
mac802154dev_givesem(&dev->md_exclsem);
return OK;
}
/****************************************************************************
@ -923,6 +935,8 @@ int mac802154dev_register(MACHANDLE mac, int minor)
dev->md_cb.mc_priv = dev;
maccb = &dev->md_cb.mc_cb;
maccb->flink = NULL;
maccb->prio = CONFIG_IEEE802154_MACDEV_RECVRPRIO;
maccb->notify = mac802154dev_notify;
maccb->rxframe = mac802154dev_rxframe;

View File

@ -110,7 +110,7 @@ int mac802154_get_mhrlen(MACHANDLE mac,
* from the transmitted frame. [1] pg. 41.
*/
if (meta->destaddr.panid == priv->addr.panid)
if (IEEE802154_PANIDCMP(meta->destaddr.panid, priv->addr.panid))
{
ret += 2; /* 2 bytes for destination PAN ID */
return ret;

View File

@ -84,13 +84,13 @@ int mac802154_req_get(MACHANDLE mac, enum ieee802154_attr_e attr,
switch (attr)
{
case IEEE802154_ATTR_MAC_PANID:
attrval->mac.panid = priv->addr.panid;
IEEE802154_PANIDCOPY(attrval->mac.panid, priv->addr.panid);
break;
case IEEE802154_ATTR_MAC_SHORT_ADDRESS:
attrval->mac.saddr = priv->addr.saddr;
IEEE802154_SADDRCOPY(attrval->mac.saddr, priv->addr.saddr);
break;
case IEEE802154_ATTR_MAC_EXTENDED_ADDR:
memcpy(&attrval->mac.eaddr[0], &priv->addr.eaddr[0], IEEE802154_EADDR_LEN);
IEEE802154_EADDRCOPY(attrval->mac.eaddr, priv->addr.eaddr);
break;
case IEEE802154_ATTR_MAC_DEVMODE:
attrval->mac.devmode = priv->devmode;
@ -133,7 +133,7 @@ int mac802154_req_set(MACHANDLE mac, enum ieee802154_attr_e attr,
{
case IEEE802154_ATTR_MAC_PANID:
{
priv->addr.panid = attrval->mac.panid;
IEEE802154_PANIDCOPY(priv->addr.panid, attrval->mac.panid);
/* Tell the radio about the attribute */
@ -144,7 +144,7 @@ int mac802154_req_set(MACHANDLE mac, enum ieee802154_attr_e attr,
break;
case IEEE802154_ATTR_MAC_SHORT_ADDRESS:
{
priv->addr.saddr = attrval->mac.saddr;
IEEE802154_SADDRCOPY(priv->addr.saddr, attrval->mac.saddr);
/* Tell the radio about the attribute */
@ -157,8 +157,7 @@ int mac802154_req_set(MACHANDLE mac, enum ieee802154_attr_e attr,
{
/* Set the MAC copy of the address in the table */
memcpy(&priv->addr.eaddr[0], &attrval->mac.eaddr[0],
IEEE802154_EADDR_LEN);
IEEE802154_EADDRCOPY(priv->addr.eaddr, attrval->mac.eaddr);
/* Tell the radio about the attribute */

View File

@ -66,6 +66,77 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define mac802154_putpanid(iob, panid) \
do \
{ \
IEEE802154_PANIDCOPY(&iob->io_data[iob->io_len], panid); \
iob->io_len += IEEE802154_PANIDSIZE; \
} \
while(0)
#define mac802154_putsaddr(iob, saddr) \
do \
{ \
IEEE802154_SADDRCOPY(&iob->io_data[iob->io_len], saddr); \
iob->io_len += IEEE802154_SADDRSIZE; \
} \
while(0)
#define mac802154_puteaddr(iob, eaddr) \
do \
{ \
IEEE802154_EADDRCOPY(&iob->io_data[iob->io_len], eaddr); \
iob->io_len += IEEE802154_EADDRSIZE; \
} \
while(0)
#define mac802154_takepanid(iob, panid) \
do \
{ \
IEEE802154_PANIDCOPY(panid, &iob->io_data[iob->io_offset]); \
iob->io_offset += IEEE802154_PANIDSIZE; \
} \
while(0)
#define mac802154_takesaddr(iob, saddr) \
do \
{ \
IEEE802154_SADDRCOPY(saddr, &iob->io_data[iob->io_offset]); \
iob->io_offset += IEEE802154_SADDRSIZE; \
} \
while(0)
#define mac802154_takeeaddr(iob, eaddr) \
do \
{ \
IEEE802154_EADDRCOPY(eaddr, &iob->io_data[iob->io_offset]); \
iob->io_offset += IEEE802154_EADDRSIZE; \
} \
while(0)
/* General helper macros ****************************************************/
/* GET 16-bit data: source in network order, result in host order */
#define GETHOST16(ptr,index) \
((((uint16_t)((ptr)[index])) << 8) | ((uint16_t)(((ptr)[(index) + 1]))))
/* GET 16-bit data: source in network order, result in network order */
#define GETNET16(ptr,index) \
((((uint16_t)((ptr)[(index) + 1])) << 8) | ((uint16_t)(((ptr)[index]))))
/* PUT 16-bit data: source in host order, result in newtwork order */
#define PUTHOST16(ptr,index,value) \
do \
{ \
(ptr)[index] = ((uint16_t)(value) >> 8) & 0xff; \
(ptr)[index + 1] = (uint16_t)(value) & 0xff; \
} \
while(0)
/* Configuration ************************************************************/
/* If processing is not done at the interrupt level, then work queue support
* is required.
@ -147,10 +218,12 @@ typedef void (*mac802154_worker_t)(FAR struct ieee802154_privmac_s *priv);
struct ieee802154_privmac_s
{
FAR struct ieee802154_radio_s *radio; /* Contained IEEE802.15.4 radio dev */
FAR const struct mac802154_maccb_s *cb; /* Contained MAC callbacks */
FAR struct mac802154_maccb_s *cb; /* Head of a list of MAC callbacks */
FAR struct mac802154_radiocb_s radiocb; /* Interface to bind to radio */
sem_t exclsem; /* Support exclusive access */
sem_t exclsem; /* Support exclusive access */
uint8_t nclients; /* Number of notification clients */
uint8_t nnotif; /* Number of remaining notifications */
/* Only support a single command at any given time. As of now I see no
* condition where you need to have more than one command frame simultaneously
@ -402,4 +475,9 @@ int mac802154_timerstart(FAR struct ieee802154_privmac_s *priv,
void mac802154_setupindirect(FAR struct ieee802154_privmac_s *priv,
FAR struct ieee802154_txdesc_s *txdesc);
void mac802154_create_datareq(FAR struct ieee802154_privmac_s *priv,
FAR struct ieee802154_addr_s *coordaddr,
enum ieee802154_addrmode_e srcmode,
FAR struct ieee802154_txdesc_s *txdesc);
#endif /* __WIRELESS_IEEE802154__MAC802154_INTERNAL_H */

View File

@ -98,7 +98,7 @@ struct lo_driver_s
{
bool lo_bifup; /* true:ifup false:ifdown */
bool lo_pending; /* True: TX poll pending */
uint16_t lo_panid; /* Fake PAN ID for testing */
uint8_t lo_panid[2]; /* Fake PAN ID for testing */
WDOG_ID lo_polldog; /* TX poll timer */
struct work_s lo_work; /* For deferring poll work to the work queue */
FAR struct iob_s *lo_head; /* Head of IOBs queued for loopback */
@ -116,10 +116,30 @@ struct lo_driver_s
static struct lo_driver_s g_loopback;
static uint8_t g_iobuffer[CONFIG_NET_6LOWPAN_MTU + CONFIG_NET_GUARDSIZE];
static uint8_t g_eaddr[IEEE802154_EADDRSIZE] =
{
0x00, 0xfa, 0xde, 0x00, 0xde, 0xad, 0xbe, 0xef
};
static uint8_t g_saddr[IEEE802154_SADDRSIZE] =
{
0xab, 0xcd
};
static uint8_t g_panid[IEEE802154_PANIDSIZE] =
{
0xca, 0xfe
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* Utility functions */
static void lo_addr2ip(FAR struct net_driver_s *dev);
static inline void lo_netmask(FAR struct net_driver_s *dev);
/* Polling logic */
static int lo_loopback(FAR struct net_driver_s *dev);
@ -153,6 +173,81 @@ static int lo_req_data(FAR struct ieee802154_driver_s *netdev,
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: lo_addr2ip
*
* Description:
* Create a MAC-based IP address from the IEEE 802.15.14 short or extended
* address assigned to the node.
*
* 128 112 96 80 64 48 32 16
* ---- ---- ---- ---- ---- ---- ---- ----
* fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte short address IEEE 48-bit MAC
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte extended address IEEE EUI-64
*
****************************************************************************/
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
static void lo_addr2ip(FAR struct net_driver_s *dev)
{
dev->d_ipv6addr[0] = HTONS(0xfe80);
dev->d_ipv6addr[1] = 0;
dev->d_ipv6addr[2] = 0;
dev->d_ipv6addr[3] = 0;
dev->d_ipv6addr[4] = (uint16_t)g_eaddr[0] << 8 | (uint16_t)g_eaddr[1];
dev->d_ipv6addr[5] = (uint16_t)g_eaddr[2] << 8 | (uint16_t)g_eaddr[3];
dev->d_ipv6addr[6] = (uint16_t)g_eaddr[4] << 8 | (uint16_t)g_eaddr[5];
dev->d_ipv6addr[7] = (uint16_t)g_eaddr[6] << 8 | (uint16_t)g_eaddr[6];
dev->d_ipv6addr[4] ^= 0x200;
}
#else
static void lo_addr2ip(FAR struct net_driver_s *dev)
{
dev->d_ipv6addr[0] = HTONS(0xfe80);
dev->d_ipv6addr[1] = 0;
dev->d_ipv6addr[2] = 0;
dev->d_ipv6addr[3] = 0;
dev->d_ipv6addr[4] = 0;
dev->d_ipv6addr[5] = HTONS(0x00ff);
dev->d_ipv6addr[6] = HTONS(0xfe00);
dev->d_ipv6addr[7] = (uint16_t)g_saddr[0] << 8 | (uint16_t)g_saddr[1];
dev->d_ipv6addr[7] ^= 0x200;
}
#endif
/****************************************************************************
* Name: lo_netmask
*
* Description:
* Create a netmask of a MAC-based IP address which may be based on either
* the IEEE 802.15.14 short or extended address of the MAC.
*
* 128 112 96 80 64 48 32 16
* ---- ---- ---- ---- ---- ---- ---- ----
* fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte short address IEEE 48-bit MAC
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte extended address IEEE EUI-64
*
****************************************************************************/
static inline void lo_netmask(FAR struct net_driver_s *dev)
{
dev->d_ipv6netmask[0] = 0xffff;
dev->d_ipv6netmask[1] = 0xffff;
dev->d_ipv6netmask[2] = 0xffff;
dev->d_ipv6netmask[3] = 0xffff;
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
dev->d_ipv6netmask[4] = 0;
dev->d_ipv6netmask[5] = 0;
dev->d_ipv6netmask[6] = 0;
dev->d_ipv6netmask[7] = 0;
#else
dev->d_ipv6netmask[4] = 0xffff;
dev->d_ipv6netmask[5] = 0xffff;
dev->d_ipv6netmask[6] = 0xffff;
dev->d_ipv6netmask[7] = 0;
#endif
}
/****************************************************************************
* Name: lo_loopback
*
@ -353,16 +448,16 @@ static int lo_ifup(FAR struct net_driver_s *dev)
dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
ninfo(" Node: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x PANID=%04x\n",
ninfo(" Node: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x PANID=%02x:%02x\n",
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1],
dev->d_mac.ieee802154.u8[2], dev->d_mac.ieee802154.u8[3],
dev->d_mac.ieee802154.u8[4], dev->d_mac.ieee802154.u8[5],
dev->d_mac.ieee802154.u8[6], dev->d_mac.ieee802154.u8[7],
priv->lo_panid);
priv->lo_panid[0], priv->lo_panid[1]);
#else
ninfo(" Node: %02x:%02x PANID=%04x\n",
ninfo(" Node: %02x:%02x PANID=%02x:%02x\n",
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1],
priv->lo_panid);
priv->lo_panid[0], priv->lo_panid[1]);
#endif
/* Set and activate a timer process */
@ -580,8 +675,12 @@ static int lo_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
unsigned long arg)
{
#if 0
FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)dev->d_private;
FAR struct lo_driver_s *priv;
DEBUGASSERT(dev != NULL && dev->d_private != NULL);
priv = (FAR struct lo_driver_s *)dev->d_private;
UNUSED(priv);
/* Check for IOCTLs aimed at the IEEE802.15.4 MAC layer */
@ -589,9 +688,71 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
{
FAR struct ieee802154_netmac_s *netmac =
(FAR struct ieee802154_netmac_s *)arg;
DEBUGASSERT(netmac != NULL);
if (cmd == MAC802154IOC_MLME_SET_REQUEST)
{
FAR struct ieee802154_set_req_s *setreq = &netmac->u.setreq;
switch (setreq->attr)
{
case IEEE802154_ATTR_MAC_PANID:
IEEE802154_PANIDCOPY(g_panid, setreq->attrval.mac.panid);
break;
case IEEE802154_ATTR_MAC_EXTENDED_ADDR:
IEEE802154_EADDRCOPY(g_eaddr, setreq->attrval.mac.eaddr);
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
lo_addr2ip(dev);
#endif
break;
case IEEE802154_ATTR_MAC_SHORT_ADDRESS:
IEEE802154_SADDRCOPY(g_saddr, setreq->attrval.mac.saddr);
#ifndef CONFIG_NET_6LOWPAN_EXTENDEDADDR
lo_addr2ip(dev);
#endif
break;
default:
return -ENOTTY;
}
return OK;
}
else if (cmd == MAC802154IOC_MLME_GET_REQUEST)
{
FAR struct ieee802154_get_req_s *getreq = &netmac->u.getreq;
switch (getreq->attr)
{
case IEEE802154_ATTR_MAC_PANID:
IEEE802154_PANIDCOPY(getreq->attrval.mac.panid, g_panid);
break;
case IEEE802154_ATTR_MAC_EXTENDED_ADDR:
IEEE802154_EADDRCOPY(getreq->attrval.mac.eaddr, g_eaddr);
break;
case IEEE802154_ATTR_MAC_SHORT_ADDRESS:
IEEE802154_SADDRCOPY(getreq->attrval.mac.saddr, g_saddr);
break;
default:
return -ENOTTY;
}
return OK;
}
else
{
/* Not a supported IEEE 802.15.4 MAC IOCTL command */
return -ENOTTY;
}
}
else
#endif
{
/* Not a valid IEEE 802.15.4 MAC IOCTL command */
@ -741,6 +902,11 @@ int ieee8021514_loopback(void)
dev->d_buf = g_iobuffer; /* Attach the IO buffer */
dev->d_private = (FAR void *)priv; /* Used to recover private state from dev */
/* Set the network mask and advertise our MAC-based IP address */
lo_netmask(dev);
lo_addr2ip(dev);
/* Initialize the Network frame-related callbacks */
ieee->i_get_mhrlen = lo_get_mhrlen; /* Get MAC header length */

View File

@ -109,7 +109,7 @@ struct macnet_callback_s
{
/* This holds the information visible to the MAC layer */
struct mac802154_maccb_s mc_cb; /* Interface understood by the MAC layer */
struct mac802154_maccb_s mc_cb; /* Interface understood by the MAC layer */
FAR struct macnet_driver_s *mc_priv; /* Our priv data */
};
@ -136,11 +136,16 @@ struct macnet_driver_s
* Private Function Prototypes
****************************************************************************/
/* Utility functions ********************************************************/
static int macnet_advertise(FAR struct net_driver_s *dev);
static inline void macnet_netmask(FAR struct net_driver_s *dev);
/* IEE802.15.4 MAC callback functions ***************************************/
static void macnet_notify(FAR const struct mac802154_maccb_s *maccb,
static void macnet_notify(FAR struct mac802154_maccb_s *maccb,
FAR struct ieee802154_notif_s *notif);
static void macnet_rxframe(FAR const struct mac802154_maccb_s *maccb,
static int macnet_rxframe(FAR struct mac802154_maccb_s *maccb,
FAR struct ieee802154_data_ind_s *ind);
/* Asynchronous confirmations to requests */
@ -162,7 +167,7 @@ static void macnet_conf_start(FAR struct macnet_driver_s *priv,
static void macnet_conf_poll(FAR struct macnet_driver_s *priv,
FAR struct ieee802154_poll_conf_s *conf);
/* Asynchronous event indications, replied to synchronously with responses */
/* Asynchronous event indications, replied to synchronously with responses */
static void macnet_ind_associate(FAR struct macnet_driver_s *priv,
FAR struct ieee802154_assoc_ind_s *conf);
@ -216,6 +221,128 @@ static int macnet_req_data(FAR struct ieee802154_driver_s *netdev,
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: macnet_advertise
*
* Description:
* Advertise the MAC and IPv6 address for this node.
*
* Creates a MAC-based IP address from the IEEE 802.15.14 short or extended
* address assigned to the node.
*
* 128 112 96 80 64 48 32 16
* ---- ---- ---- ---- ---- ---- ---- ----
* fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte short address IEEE 48-bit MAC
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte extended address IEEE EUI-64
*
****************************************************************************/
static int macnet_advertise(FAR struct net_driver_s *dev)
{
struct ieee802154_netmac_s arg;
int ret;
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
uint8_t *eaddr;
/* Get the eaddr from the MAC */
memcpy(arg.ifr_name, dev->d_ifname, IFNAMSIZ);
arg.u.getreq.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR;
ret = dev->d_ioctl(dev, MAC802154IOC_MLME_GET_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
wlerr("ERROR: MAC802154IOC_MLME_GET_REQUEST failed: %d\n", ret);
return ret;
}
else
{
/* Set the IP address based on the eaddr */
eaddr = arg.u.getreq.attrval.mac.eaddr;
IEEE802154_EADDRCOPY(dev->d_mac.ieee802154.u8, eaddr);
dev->d_ipv6addr[0] = HTONS(0xfe80);
dev->d_ipv6addr[1] = 0;
dev->d_ipv6addr[2] = 0;
dev->d_ipv6addr[3] = 0;
dev->d_ipv6addr[4] = (uint16_t)eaddr[0] << 8 | (uint16_t)eaddr[1];
dev->d_ipv6addr[5] = (uint16_t)eaddr[2] << 8 | (uint16_t)eaddr[3];
dev->d_ipv6addr[6] = (uint16_t)eaddr[4] << 8 | (uint16_t)eaddr[5];
dev->d_ipv6addr[7] = (uint16_t)eaddr[6] << 8 | (uint16_t)eaddr[6];
dev->d_ipv6addr[4] ^= 0x200;
return OK;
}
#else
uint8_t *saddr;
/* Get the saddr from the MAC */
memcpy(arg.ifr_name, dev->d_ifname, IFNAMSIZ);
arg.u.getreq.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS;
ret = dev->d_ioctl(dev, MAC802154IOC_MLME_GET_REQUEST,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
wlerr("ERROR: MAC802154IOC_MLME_GET_REQUEST failed: %d\n", ret);
return ret;
}
else
{
saddr = arg.u.getreq.attrval.mac.saddr;
IEEE802154_SADDRCOPY(dev->d_mac.ieee802154.u8, saddr);
/* Set the IP address based on the saddr */
dev->d_ipv6addr[0] = HTONS(0xfe80);
dev->d_ipv6addr[1] = 0;
dev->d_ipv6addr[2] = 0;
dev->d_ipv6addr[3] = 0;
dev->d_ipv6addr[4] = 0;
dev->d_ipv6addr[5] = HTONS(0x00ff);
dev->d_ipv6addr[6] = HTONS(0xfe00);
dev->d_ipv6addr[7] = (uint16_t)saddr[0] << 8 | (uint16_t)saddr[1];
dev->d_ipv6addr[7] ^= 0x200;
return OK;
}
#endif
}
/****************************************************************************
* Name: macnet_netmask
*
* Description:
* Create a netmask of a MAC-based IP address which may be based on either
* the IEEE 802.15.14 short or extended address of the MAC.
*
* 128 112 96 80 64 48 32 16
* ---- ---- ---- ---- ---- ---- ---- ----
* fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte short address IEEE 48-bit MAC
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte extended address IEEE EUI-64
*
****************************************************************************/
static inline void macnet_netmask(FAR struct net_driver_s *dev)
{
dev->d_ipv6netmask[0] = 0xffff;
dev->d_ipv6netmask[1] = 0xffff;
dev->d_ipv6netmask[2] = 0xffff;
dev->d_ipv6netmask[3] = 0xffff;
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
dev->d_ipv6netmask[4] = 0;
dev->d_ipv6netmask[5] = 0;
dev->d_ipv6netmask[6] = 0;
dev->d_ipv6netmask[7] = 0;
#else
dev->d_ipv6netmask[4] = 0xffff;
dev->d_ipv6netmask[5] = 0xffff;
dev->d_ipv6netmask[6] = 0xffff;
dev->d_ipv6netmask[7] = 0;
#endif
}
/****************************************************************************
* Name: macnet_notify
*
@ -223,7 +350,7 @@ static int macnet_req_data(FAR struct ieee802154_driver_s *netdev,
*
****************************************************************************/
static void macnet_notify(FAR const struct mac802154_maccb_s *maccb,
static void macnet_notify(FAR struct mac802154_maccb_s *maccb,
FAR struct ieee802154_notif_s *notif)
{
FAR struct macnet_callback_s *cb =
@ -244,17 +371,27 @@ static void macnet_notify(FAR const struct mac802154_maccb_s *maccb,
default:
break;
}
/* Free the event notification */
mac802154_notif_free(priv->md_mac, notif);
}
/****************************************************************************
* Name: macnet_rxframe
*
* Description:
* Handle received frames forward by the IEEE 802.15.4 MAC.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure. On success, the ind and its contained iob will be freed.
* The ind will be intact if this function returns a failure.
*
****************************************************************************/
static void macnet_rxframe(FAR const struct mac802154_maccb_s *maccb,
FAR struct ieee802154_data_ind_s *ind)
static int macnet_rxframe(FAR struct mac802154_maccb_s *maccb,
FAR struct ieee802154_data_ind_s *ind)
{
FAR struct macnet_callback_s *cb =
(FAR struct macnet_callback_s *)maccb;
@ -264,10 +401,31 @@ static void macnet_rxframe(FAR const struct mac802154_maccb_s *maccb,
DEBUGASSERT(cb != NULL && cb->mc_priv != NULL);
priv = cb->mc_priv;
/* Extract the IOB containing the frame from the struct ieee802154_data_ind_s */
/* Ignore the frame if the network is not up */
if (!priv->md_bifup)
{
return -ENETDOWN;
}
/* Peek the IOB contained the frame in the struct ieee802154_data_ind_s */
DEBUGASSERT(priv != NULL && ind != NULL && ind->frame != NULL);
iob = ind->frame;
iob = ind->frame;
/* If the frame is not a 6LoWPAN frame, then return an error. The first
* byte following the MAC head at the io_offset should be a valid IPHC
* header.
*/
if ((iob->io_data[iob->io_offset] & SIXLOWPAN_DISPATCH_NALP_MASK) ==
SIXLOWPAN_DISPATCH_NALP)
{
return -EINVAL;
}
/* Remove the IOB containing the frame. */
ind->frame = NULL;
/* Transfer the frame to the network logic */
@ -279,6 +437,7 @@ static void macnet_rxframe(FAR const struct mac802154_maccb_s *maccb,
*/
ieee802154_ind_free(ind);
return OK;
}
/****************************************************************************
@ -624,34 +783,43 @@ static void macnet_txpoll_expiry(int argc, wdparm_t arg, ...)
static int macnet_ifup(FAR struct net_driver_s *dev)
{
FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)dev->d_private;
FAR struct macnet_driver_s *priv =
(FAR struct macnet_driver_s *)dev->d_private;
int ret;
#ifdef CONFIG_NET_IPv4
ninfo("Bringing up: %d.%d.%d.%d\n",
dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff,
(dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24);
#endif
#ifdef CONFIG_NET_IPv6
ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2],
dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5],
dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
/* Set the IP address based on the addressing assigned to the node */
ret = macnet_advertise(dev);
if (ret >= 0)
{
ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2],
dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5],
dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
ninfo(" Node: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1],
dev->d_mac.ieee802154.u8[2], dev->d_mac.ieee802154.u8[3],
dev->d_mac.ieee802154.u8[4], dev->d_mac.ieee802154.u8[5],
dev->d_mac.ieee802154.u8[6], dev->d_mac.ieee802154.u8[7]);
#else
ninfo(" Node: %02x:%02x\n",
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1]);
#endif
/* Initialize PHYs, the IEEE 802.15.4 interface, and setup up IEEE 802.15.4 interrupts */
#warning Missing logic
/* Set and activate a timer process */
/* Setup up address filtering */
(void)wd_start(priv->md_txpoll, TXPOLL_WDDELAY, macnet_txpoll_expiry,
1, (wdparm_t)priv);
/* Set and activate a timer process */
/* The interface is now up */
(void)wd_start(priv->md_txpoll, TXPOLL_WDDELAY, macnet_txpoll_expiry, 1,
(wdparm_t)priv);
priv->md_bifup = true;
ret = OK;
}
/* Enable the IEEE 802.15.4 radio */
priv->md_bifup = true;
return OK;
return ret;
}
/****************************************************************************
@ -993,7 +1161,7 @@ static int macnet_req_data(FAR struct ieee802154_driver_s *netdev,
*
* Description:
* Register a network driver to access the IEEE 802.15.4 MAC layer from
* a socket using 6loWPAN
* a socket using 6LoWPAN
*
* Input Parameters:
* mac - Pointer to the mac layer struct to be registered.
@ -1062,6 +1230,10 @@ int mac802154netdev_register(MACHANDLE mac)
DEBUGASSERT(priv->md_txpoll != NULL);
/* Set the network mask. */
macnet_netmask(dev);
/* Initialize the Network frame-related callbacks */
ieee->i_get_mhrlen = macnet_get_mhrlen; /* Get MAC header length */
@ -1072,6 +1244,8 @@ int mac802154netdev_register(MACHANDLE mac)
priv->md_cb.mc_priv = priv;
maccb = &priv->md_cb.mc_cb;
maccb->flink = NULL;
maccb->prio = CONFIG_IEEE802154_NETDEV_RECVRPRIO;
maccb->notify = macnet_notify;
maccb->rxframe = macnet_rxframe;

View File

@ -74,18 +74,38 @@ int mac802154_notif_free(MACHANDLE mac,
{
FAR struct ieee802154_privmac_s *priv =
(FAR struct ieee802154_privmac_s *)mac;
FAR struct mac802154_notif_s *privnotif = (FAR struct mac802154_notif_s *)notif;
FAR struct mac802154_notif_s *privnotif =
(FAR struct mac802154_notif_s *)notif;
/* Get exclusive access to the MAC */
mac802154_takesem(&priv->exclsem, false);
privnotif->flink = priv->notif_free;
priv->notif_free = privnotif;
mac802154_givesem(&priv->notif_sem);
/* We know how many clients have registered for notifications. Each must
* call mac802154_notif_free() before we can release the notification
* resource.
*/
if (priv->nnotif < 2)
{
/* This is the free from the last notification */
privnotif->flink = priv->notif_free;
priv->notif_free = privnotif;
priv->nnotif = 0;
mac802154_givesem(&priv->notif_sem);
}
else
{
/* More calls are expected. Decrement the count of expected calls
* and preserve the notification resources.
*/
priv->nnotif--;
}
mac802154_givesem(&priv->exclsem);
return -ENOTTY;
}
@ -125,6 +145,7 @@ void mac802154_notifpool_init(FAR struct ieee802154_privmac_s *priv)
pool++;
remaining--;
}
sem_init(&priv->notif_sem, 0, CONFIG_MAC802154_NNOTIF);
}
@ -165,6 +186,7 @@ int mac802154_notif_alloc(FAR struct ieee802154_privmac_s *priv,
{
privnotif = priv->notif_free;
priv->notif_free = privnotif->flink;
priv->nnotif = 0;
}
else
{
@ -200,9 +222,44 @@ int mac802154_notif_alloc(FAR struct ieee802154_privmac_s *priv,
privnotif = priv->notif_free;
priv->notif_free = privnotif->flink;
priv->nnotif = 0;
}
*notif = (FAR struct ieee802154_notif_s *)privnotif;
return OK;
}
}
/****************************************************************************
* Name: mac802154_notify
*
* Description:
* Notify every register MAC client.
*
****************************************************************************/
void mac802154_notify(FAR struct ieee802154_privmac_s *priv,
FAR struct ieee802154_notif_s *notif)
{
FAR struct mac802154_maccb_s *cb;
/* Set the notification count so that the notification resources will be
* preserved until the final notification.
*/
priv->nnotif = priv->nclients;
/* Try to notify every registered MAC client */
for (cb = priv->cb; cb != NULL; cb = cb->flink)
{
/* Does this client want notifications? */
if (cb->notify != NULL)
{
/* Yes.. Notify */
cb->notify(cb, notif);
}
}
}

View File

@ -63,8 +63,8 @@
struct mac802154_notif_s
{
struct ieee802154_notif_s pub;
FAR struct mac802154_notif_s *flink;
struct ieee802154_notif_s pub; /* Publically visible structure */
FAR struct mac802154_notif_s *flink; /* Supports a singly linked list */
};
/****************************************************************************
@ -79,4 +79,7 @@ int mac802154_notif_alloc(FAR struct ieee802154_privmac_s *priv,
FAR struct ieee802154_notif_s **notif,
bool allow_interrupt);
void mac802154_notify(FAR struct ieee802154_privmac_s *priv,
FAR struct ieee802154_notif_s *notif);
#endif /* __WIRELESS_IEEE802154__MAC802154_NOTIF_H */

View File

@ -50,8 +50,6 @@
#include <debug.h>
#include <string.h>
#include <nuttx/mm/iob.h>
#include "mac802154.h"
#include "mac802154_internal.h"
@ -83,9 +81,7 @@ int mac802154_req_poll(MACHANDLE mac, FAR struct ieee802154_poll_req_s *req)
{
FAR struct ieee802154_privmac_s *priv =
(FAR struct ieee802154_privmac_s *)mac;
FAR struct iob_s *iob;
FAR struct ieee802154_txdesc_s *txdesc;
FAR uint16_t *frame_ctrl;
int ret;
/* On receipt of the MLME-POLL.request primitive, the MLME requests data from
@ -108,9 +104,6 @@ int mac802154_req_poll(MACHANDLE mac, FAR struct ieee802154_poll_req_s *req)
return ret;
}
priv->curr_op = MAC802154_OP_POLL;
priv->curr_cmd = IEEE802154_CMD_DATA_REQ;
/* Get exclusive access to the MAC */
ret = mac802154_takesem(&priv->exclsem, true);
@ -120,117 +113,35 @@ int mac802154_req_poll(MACHANDLE mac, FAR struct ieee802154_poll_req_s *req)
return ret;
}
/* Allocate an IOB to put the frame in */
iob = iob_alloc(false);
DEBUGASSERT(iob != NULL);
iob->io_flink = NULL;
iob->io_len = 0;
iob->io_offset = 0;
iob->io_pktlen = 0;
priv->curr_op = MAC802154_OP_POLL;
priv->curr_cmd = IEEE802154_CMD_DATA_REQ;
/* Allocate the txdesc, waiting if necessary */
ret = mac802154_txdesc_alloc(priv, &txdesc, true);
if (ret < 0)
{
iob_free(iob);
mac802154_givesem(&priv->exclsem);
mac802154_givesem(&priv->op_sem);
return ret;
}
/* Get a uin16_t reference to the first two bytes. ie frame control field */
frame_ctrl = (FAR uint16_t *)&iob->io_data[0];
iob->io_len = 2;
*frame_ctrl = (IEEE802154_FRAME_COMMAND << IEEE802154_FRAMECTRL_SHIFT_FTYPE);
*frame_ctrl |= IEEE802154_FRAMECTRL_ACKREQ;
/* Each time a data or a MAC command frame is generated, the MAC sublayer
* shall copy the value of macDSN into the Sequence Number field of the
* MHR of the outgoing frame and then increment it by one. [1] pg. 40.
*/
iob->io_data[iob->io_len++] = priv->dsn++;
/* If the destination address is present, copy the PAN ID and one of the
* addresses, depending on mode, into the MHR.
*/
if (req->coordaddr.mode != IEEE802154_ADDRMODE_NONE)
{
memcpy(&iob->io_data[iob->io_len], &req->coordaddr.panid, 2);
iob->io_len += 2;
if (req->coordaddr.mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(&iob->io_data[iob->io_len], &req->coordaddr.saddr, 2);
iob->io_len += 2;
}
else if (req->coordaddr.mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(&iob->io_data[iob->io_len], &req->coordaddr.eaddr,
IEEE802154_EADDR_LEN);
iob->io_len += IEEE802154_EADDR_LEN;
}
}
*frame_ctrl |= (req->coordaddr.mode << IEEE802154_FRAMECTRL_SHIFT_DADDR);
/* If the PAN identifiers are identical, the PAN ID Compression field
* shall be set to one, and the source PAN identifier shall be omitted
* from the transmitted frame. [1] pg. 41.
*/
if (req->coordaddr.mode != IEEE802154_ADDRMODE_NONE &&
req->coordaddr.panid == priv->addr.panid)
{
*frame_ctrl |= IEEE802154_FRAMECTRL_PANIDCOMP;
}
else
{
memcpy(&iob->io_data[iob->io_len], &priv->addr.panid, 2);
iob->io_len += 2;
}
/* The Source Addressing Mode field shall be set according to the value of
* macShortAddress. If macShortAddress is less than 0xfffe, short addressing
* shall be used. Extended addressing shall be used otherwise.
*/
if (priv->addr.saddr == IEEE802154_SADDR_BCAST)
if (IEEE802154_SADDRCMP(priv->addr.saddr, &IEEE802154_SADDR_BCAST))
{
*frame_ctrl |= (IEEE802154_ADDRMODE_EXTENDED << IEEE802154_FRAMECTRL_SHIFT_SADDR);
memcpy(&iob->io_data[iob->io_len], &priv->addr.eaddr[0], IEEE802154_EADDR_LEN);
iob->io_len += IEEE802154_EADDR_LEN;
mac802154_create_datareq(priv, &req->coordaddr, IEEE802154_ADDRMODE_EXTENDED,
txdesc);
}
else
{
*frame_ctrl |= (IEEE802154_ADDRMODE_SHORT << IEEE802154_FRAMECTRL_SHIFT_SADDR);
memcpy(&iob->io_data[iob->io_len], &priv->addr.saddr, 2);
iob->io_len += 2;
mac802154_create_datareq(priv, &req->coordaddr, IEEE802154_ADDRMODE_SHORT,
txdesc);
}
/* Copy in the Command Frame Identifier */
iob->io_data[iob->io_len++] = IEEE802154_CMD_DATA_REQ;
/* Copy the IOB reference to the descriptor */
txdesc->frame = iob;
txdesc->frametype = IEEE802154_FRAME_COMMAND;
/* Save a copy of the destination addressing infromation into the tx descriptor.
* We only do this for commands to help with handling their progession.
*/
memcpy(&txdesc->destaddr, &req->coordaddr, sizeof(struct ieee802154_addr_s));
/* Save a reference of the tx descriptor */
priv->cmd_desc = txdesc;
@ -307,7 +218,7 @@ void mac802154_txdone_datareq_poll(FAR struct ieee802154_privmac_s *priv,
/* Release the MAC, call the callback, get exclusive access again */
mac802154_givesem(&priv->exclsem);
priv->cb->notify(priv->cb, notif);
mac802154_notify(priv, notif);
mac802154_takesem(&priv->exclsem, false);
}
else
@ -347,7 +258,7 @@ void mac802154_txdone_datareq_poll(FAR struct ieee802154_privmac_s *priv,
*
****************************************************************************/
static void mac802154_timeout_poll(FAR struct ieee802154_privmac_s *priv)
void mac802154_timeout_poll(FAR struct ieee802154_privmac_s *priv)
{
FAR struct ieee802154_notif_s *notif;
@ -372,5 +283,5 @@ static void mac802154_timeout_poll(FAR struct ieee802154_privmac_s *priv)
notif->notiftype = IEEE802154_NOTIFY_CONF_POLL;
notif->u.pollconf.status = IEEE802154_STATUS_NO_DATA;
priv->cb->notify(priv->cb, notif);
mac802154_notify(priv, notif);
}

View File

@ -114,16 +114,16 @@ int mac802154_req_reset(MACHANDLE mac, bool rst_pibattr)
/* Reset the Coordinator address */
priv->coordaddr.mode = IEEE802154_ADDRMODE_NONE;
priv->coordaddr.saddr = IEEE802154_SADDR_UNSPEC;
memcpy(&priv->coordaddr.eaddr[0], IEEE802154_EADDR_UNSPEC,
IEEE802154_EADDR_LEN);
IEEE802154_PANIDCOPY(priv->coordaddr.panid, &IEEE802154_PANID_UNSPEC);
IEEE802154_SADDRCOPY(priv->coordaddr.saddr, &IEEE802154_SADDR_UNSPEC);
IEEE802154_EADDRCOPY(priv->coordaddr.eaddr, &IEEE802154_EADDR_UNSPEC);
/* Reset the device's address */
priv->addr.mode = IEEE802154_ADDRMODE_NONE;
priv->addr.panid = IEEE802154_PAN_UNSPEC;
priv->addr.saddr = IEEE802154_SADDR_UNSPEC;
memcpy(&priv->addr.eaddr[0], IEEE802154_EADDR_UNSPEC, IEEE802154_EADDR_LEN);
IEEE802154_PANIDCOPY(priv->addr.panid, &IEEE802154_PANID_UNSPEC);
IEEE802154_SADDRCOPY(priv->addr.saddr, &IEEE802154_SADDR_UNSPEC);
IEEE802154_EADDRCOPY(priv->addr.eaddr, &IEEE802154_EADDR_UNSPEC);
priv->radio->reset_attrs(priv->radio);

View File

@ -97,9 +97,9 @@ int mac802154_req_start(MACHANDLE mac, FAR struct ieee802154_start_req_s *req)
/* Set the PANID attribute */
priv->addr.panid = req->panid;
IEEE802154_PANIDCOPY(priv->addr.panid, req->panid);
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_MAC_PANID,
(FAR const union ieee802154_attr_u *)&req->panid);
(FAR const union ieee802154_attr_u *)req->panid);
/* Set the radio attributes */
priv->radio->set_attr(priv->radio, IEEE802154_ATTR_PHY_CURRENT_CHANNEL,