mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 17:33:08 +08:00
configs/olimex-stm32-e407: Add support for MRF24J40 radio.
This commit is contained in:
@@ -41,6 +41,7 @@ Configurations
|
||||
|
||||
Configuration Directories
|
||||
-------------------------
|
||||
|
||||
nsh:
|
||||
---
|
||||
Configures the NuttShell (nsh) located at apps/examples/nsh. This
|
||||
@@ -79,8 +80,8 @@ Configurations
|
||||
|
||||
dac:
|
||||
---
|
||||
This is a configuration example to use the DAC1 of the board.The DAC1 is attached
|
||||
to the PA4 pin (Arduino header D10).
|
||||
This is a configuration example to use the DAC1 of the board. The DAC1
|
||||
is attached to the PA4 pin (Arduino header D10).
|
||||
|
||||
This example is configured to work with the USBNSH instead of UART NSH, so
|
||||
the console will be shown over the USB_OTG1 connector.
|
||||
@@ -108,11 +109,89 @@ Configurations
|
||||
|
||||
timer:
|
||||
-----
|
||||
This configuration set the proper configuration to use the timer1 of the board.
|
||||
This example is configured to work with the USBNSH instead of UART NSH, so
|
||||
the console will be shown over the USB_OTG1 connector.
|
||||
This configuration set the proper configuration to use the timer1 of the
|
||||
board. This example is configured to work with the USBNSH instead of
|
||||
UART NSH, so the console will be shown over the USB_OTG1 connector.
|
||||
|
||||
On the console, type "ls /dev " and if the registration process goes fine,
|
||||
you should see a device called "timer1".
|
||||
|
||||
mrf24j40-mac:
|
||||
------------
|
||||
This configuration set the proper configuration to set the 802.15.4
|
||||
communication layer with the MRF24J40 radio. This radio works wit
|
||||
SPI, you need to do the next connections:
|
||||
|
||||
MRF24J40 VCC -> Board 3.3V
|
||||
MRF24J40 GND -> Board GND
|
||||
MRF24J40 SCLK -> Board PA5 (Arduino header D13)
|
||||
MRF24J40 MISO -> Board PA6 (Arduino header D12)
|
||||
MRF24J40 MOSI -> Board PB5 (Arduino header D11)
|
||||
MRF24J40 CS -> Board PA4 (Arduino header D10)
|
||||
MRF24J40 INT -> Board PG12 (Arduino header D8)
|
||||
|
||||
This example is configured to work with the USBNSH instead of UART NSH,
|
||||
so the console will be shown over the USB_OTG1 connector.
|
||||
|
||||
Once you're on the console, you need to check if the initialization
|
||||
process was fine. To do so, you need to type "ls /dev" and you should
|
||||
see a device call "ieee0". At this point we need to set-up the network,
|
||||
follow the next steps:
|
||||
|
||||
This is an example of how to configure a coordinator:
|
||||
i8sak /dev/ieee0 startpan cd:ab
|
||||
i8sak set chan 11
|
||||
i8sak set saddr 42:01
|
||||
i8sak acceptassoc
|
||||
|
||||
This is an example of how to configure the endpoint:
|
||||
i8sak /dev/ieee0
|
||||
i8sak set chan 11
|
||||
i8sak set panid cd:ab
|
||||
i8sak set saddr 42:02
|
||||
i8sak set ep_saddr 42:01
|
||||
i8sak assoc
|
||||
|
||||
mrf24j40-6lowpan:
|
||||
----------------
|
||||
This configuration set the proper configuration to use 6lowpan protocol with the MRF24J40
|
||||
radio. This radio works with SPI, you need to do the next connections:
|
||||
|
||||
MRF24J40 VCC -> Board 3.3V
|
||||
MRF24J40 GND -> Board GND
|
||||
MRF24J40 SCLK -> Board PA5 (Arduino header D13)
|
||||
MRF24J40 MISO -> Board PA6 (Arduino header D12)
|
||||
MRF24J40 MOSI -> Board PB5 (Arduino header D11)
|
||||
MRF24J40 CS -> Board PA4 (Arduino header D10)
|
||||
MRF24J40 INT -> Board PG12 (Arduino header D8)
|
||||
|
||||
This example is configured to work with the USBNSH instead of UART NSH, so
|
||||
the console will be shown over the USB_OTG1 connector.
|
||||
|
||||
Once you're on the console, you need to check if the initialization process
|
||||
was fine. To do so, you need to type "ls /dev" and you should see a device
|
||||
call "ieee0". At this point we need to set-up the network, follow the next steps:
|
||||
|
||||
This is an example of how to configure a coordinator:
|
||||
i8sak wpan0 startpan cd:ab
|
||||
i8sak set chan 11
|
||||
i8sak set saddr 42:01
|
||||
i8sak acceptassoc
|
||||
|
||||
When the association was complete, you need to bring-up the network:
|
||||
ifup wpan0
|
||||
|
||||
This is an example of how to configure the endpoint:
|
||||
i8sak wpan0
|
||||
i8sak set chan 11
|
||||
i8sak set panid cd:ab
|
||||
i8sak set saddr 42:02
|
||||
i8sak set ep_saddr 42:01
|
||||
i8sak assoc
|
||||
|
||||
When the association was complete, you need to bring-up the network:
|
||||
ifup wpan0
|
||||
|
||||
If you execute the command "ifconfig", you will be able to see the info of the WPAN0 interface
|
||||
and see the assigned IP. This interface can be use with an UDP or TCP server/client application.
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
# CONFIG_NET_ETHERNET is not set
|
||||
# CONFIG_NET_IPv4 is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="olimex-stm32-e407"
|
||||
CONFIG_ARCH_BOARD_OLIMEX_STM32E407=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F407ZG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARDCTL_USBDEVCTRL=y
|
||||
CONFIG_BOARD_LATE_INITIALIZE=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CDCACM=y
|
||||
CONFIG_CDCACM_CONSOLE=y
|
||||
CONFIG_DEBUG_ERROR=y
|
||||
CONFIG_DEBUG_FEATURES=y
|
||||
CONFIG_DEBUG_INFO=y
|
||||
CONFIG_DEBUG_NET=y
|
||||
CONFIG_DEBUG_NET_ERROR=y
|
||||
CONFIG_DEBUG_NET_INFO=y
|
||||
CONFIG_DEBUG_NET_WARN=y
|
||||
CONFIG_DEBUG_WARN=y
|
||||
CONFIG_DEBUG_WIRELESS=y
|
||||
CONFIG_DEBUG_WIRELESS_ERROR=y
|
||||
CONFIG_DEBUG_WIRELESS_INFO=y
|
||||
CONFIG_DEBUG_WIRELESS_WARN=y
|
||||
CONFIG_DRIVERS_IEEE802154=y
|
||||
CONFIG_DRIVERS_WIRELESS=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IEEE802154_I8SAK=y
|
||||
CONFIG_IEEE802154_MAC=y
|
||||
CONFIG_IEEE802154_MACDEV=y
|
||||
CONFIG_IEEE802154_MRF24J40=y
|
||||
CONFIG_IEEE802154_NETDEV=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_IOB_BUFSIZE=128
|
||||
CONFIG_IOB_NBUFFERS=32
|
||||
CONFIG_IOB_NCHAINS=16
|
||||
CONFIG_LIB_BOARDCTL=y
|
||||
CONFIG_MAC802154_NTXDESC=32
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDEVICES=y
|
||||
CONFIG_NETDEV_IFINDEX=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NETDEV_PHY_IOCTL=y
|
||||
CONFIG_NETDEV_STATISTICS=y
|
||||
CONFIG_NETDEV_WIRELESS_IOCTL=y
|
||||
CONFIG_NETUTILS_TELNETD=y
|
||||
CONFIG_NET_6LOWPAN=y
|
||||
CONFIG_NET_6LOWPAN_COMPRESSION_THRESHOLD=500
|
||||
CONFIG_NET_6LOWPAN_EXTENDEDADDR=y
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NET_ICMPv6=y
|
||||
CONFIG_NET_ICMPv6_AUTOCONF=y
|
||||
CONFIG_NET_ICMPv6_NEIGHBOR=y
|
||||
CONFIG_NET_ICMPv6_ROUTER=y
|
||||
CONFIG_NET_ICMPv6_SOCKET=y
|
||||
CONFIG_NET_IPv6=y
|
||||
CONFIG_NET_PROMISCUOUS=y
|
||||
CONFIG_NET_ROUTE=y
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_TCPBACKLOG=y
|
||||
CONFIG_NET_TCP_WRITE_BUFFERS=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_UDP_WRITE_BUFFERS=y
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=8
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_MQ_MSGS=4
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PREALLOC_WDOGS=16
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_OTGFS=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_SPI1=y
|
||||
CONFIG_STM32_USART3=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING6=y
|
||||
CONFIG_SYSTEM_SYSTEM=y
|
||||
CONFIG_USART3_RXBUFSIZE=128
|
||||
CONFIG_USART3_TXBUFSIZE=128
|
||||
CONFIG_USBDEV=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_WIRELESS=y
|
||||
CONFIG_WIRELESS_IEEE802154=y
|
||||
@@ -0,0 +1,73 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="olimex-stm32-e407"
|
||||
CONFIG_ARCH_BOARD_OLIMEX_STM32E407=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F407ZG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LATE_INITIALIZE=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_ERROR=y
|
||||
CONFIG_DEBUG_FEATURES=y
|
||||
CONFIG_DEBUG_INFO=y
|
||||
CONFIG_DEBUG_WARN=y
|
||||
CONFIG_DEBUG_WIRELESS=y
|
||||
CONFIG_DEBUG_WIRELESS_ERROR=y
|
||||
CONFIG_DEBUG_WIRELESS_INFO=y
|
||||
CONFIG_DEBUG_WIRELESS_WARN=y
|
||||
CONFIG_DRIVERS_IEEE802154=y
|
||||
CONFIG_DRIVERS_WIRELESS=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IEEE802154_I8SAK=y
|
||||
CONFIG_IEEE802154_MAC=y
|
||||
CONFIG_IEEE802154_MACDEV=y
|
||||
CONFIG_IEEE802154_MRF24J40=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=8
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_MQ_MSGS=4
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PREALLOC_WDOGS=16
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_SPI1=y
|
||||
CONFIG_STM32_USART3=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_USART3_RXBUFSIZE=128
|
||||
CONFIG_USART3_SERIAL_CONSOLE=y
|
||||
CONFIG_USART3_TXBUFSIZE=128
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_WIRELESS=y
|
||||
CONFIG_WIRELESS_IEEE802154=y
|
||||
@@ -96,5 +96,9 @@ ifeq ($(CONFIG_TIMER),y)
|
||||
CSRCS += stm32_timer.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_IEEE802154_MRF24J40),y)
|
||||
CSRCS += stm32_mrf24j40.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/configs/Board.mk
|
||||
|
||||
|
||||
@@ -115,16 +115,28 @@
|
||||
/* Olimex-STM32-E407 GPIOs ****************************************************/
|
||||
/* LEDs */
|
||||
|
||||
#define GPIO_LED_STATUS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN13)
|
||||
#define GPIO_LED_STATUS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN13)
|
||||
|
||||
/* Pin for MRF24J40 radio */
|
||||
|
||||
#define GPIO_MRF24J40_INT (GPIO_INPUT|GPIO_FLOAT|\
|
||||
GPIO_EXTI|GPIO_PORTG|GPIO_PIN12) /* PG12 */
|
||||
#define GPIO_MRF24J40_RST (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTG|GPIO_PIN15) /* PG15 */
|
||||
|
||||
/* SPI chip selects */
|
||||
|
||||
#define GPIO_MRF24J40_CS (GPIO_OUTPUT|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4) /* PA4 */
|
||||
|
||||
/* BUTTONS -- NOTE that all have EXTI interrupts configured */
|
||||
|
||||
#define MIN_IRQBUTTON BUTTON_BUT
|
||||
#define MAX_IRQBUTTON BUTTON_BUT
|
||||
#define NUM_IRQBUTTONS 1
|
||||
#define MIN_IRQBUTTON BUTTON_BUT
|
||||
#define MAX_IRQBUTTON BUTTON_BUT
|
||||
#define NUM_IRQBUTTONS 1
|
||||
|
||||
#define GPIO_BTN_BUT (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_BTN_BUT (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTA|GPIO_PIN0)
|
||||
|
||||
/* USB OTG FS - USB-A connector
|
||||
*
|
||||
@@ -155,14 +167,22 @@
|
||||
* PF11 OTG_HS_Overcurrent
|
||||
*/
|
||||
|
||||
#define GPIO_OTGHS_VBUS (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_OPENDRAIN|GPIO_PORTB|GPIO_PIN13)
|
||||
#define GPIO_OTGHS_PWRON (GPIO_OUTPUT|GPIO_OUTPUT_SET|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN8)
|
||||
#define GPIO_OTGHS_VBUS \
|
||||
(GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_OPENDRAIN|GPIO_PORTB| \
|
||||
GPIO_PIN13)
|
||||
#define GPIO_OTGHS_PWRON \
|
||||
(GPIO_OUTPUT|GPIO_OUTPUT_SET|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL| \
|
||||
GPIO_PORTA|GPIO_PIN8)
|
||||
|
||||
#ifdef CONFIG_USBHOST
|
||||
# define GPIO_OTGHS_OVER (GPIO_INPUT|GPIO_EXTI|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTF|GPIO_PIN11)
|
||||
# define GPIO_OTGHS_OVER \
|
||||
(GPIO_INPUT|GPIO_EXTI|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL| \
|
||||
GPIO_PORTF|GPIO_PIN11)
|
||||
|
||||
#else
|
||||
# define GPIO_OTGHS_OVER (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTF|GPIO_PIN11)
|
||||
# define GPIO_OTGHS_OVER \
|
||||
(GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTF| \
|
||||
GPIO_PIN11)
|
||||
#endif
|
||||
|
||||
/* LAN8710 works with LAN8720 driver
|
||||
@@ -184,10 +204,10 @@
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_STM32_ETHMAC)
|
||||
# define GPIO_EMAC_NINT (GPIO_INPUT|GPIO_PULLUP|GPIO_EXTI| \
|
||||
GPIO_PORTA|GPIO_PIN3)
|
||||
# define GPIO_EMAC_NRST (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz| \
|
||||
GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN6)
|
||||
# define GPIO_EMAC_NINT (GPIO_INPUT|GPIO_PULLUP|GPIO_EXTI| \
|
||||
GPIO_PORTA|GPIO_PIN3)
|
||||
# define GPIO_EMAC_NRST (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz| \
|
||||
GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN6)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@@ -344,5 +364,21 @@ int stm32_ina219initialize(FAR const char *devpath);
|
||||
int stm32_timer_driver_setup(FAR const char *devpath, int timer);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_mrf24j40_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the MRF24J40 device.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success. Otherwise, a negated errno value is
|
||||
* returned to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_IEEE802154_MRF24J40
|
||||
int stm32_mrf24j40_initialize(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __CONFIGS_OLIMEX_STM32_E407_SRC_INTERNAL_H */
|
||||
|
||||
@@ -263,6 +263,16 @@ int stm32_bringup(void)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_IEEE802154_MRF24J40
|
||||
/* Configure MRF24J40 wireless */
|
||||
|
||||
ret = stm32_mrf24j40_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: stm32_mrf24j40_initialize() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,292 @@
|
||||
/****************************************************************************
|
||||
* configs/olimex-stm32-e407/src/stm32_mrf24j40.c
|
||||
*
|
||||
* Copyright (C) 2017, 2019 Gregory Nutt, All rights reserver
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Modified by: Acutronics Robotics (Juan Flores) <juan@erlerobotics.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
#include <nuttx/wireless/ieee802154/mrf24j40.h>
|
||||
|
||||
#include "stm32_gpio.h"
|
||||
#include "stm32_exti.h"
|
||||
#include "stm32_spi.h"
|
||||
|
||||
#include "olimex-stm32-e407.h"
|
||||
|
||||
#ifdef CONFIG_IEEE802154_MRF24J40
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct stm32_priv_s
|
||||
{
|
||||
struct mrf24j40_lower_s dev;
|
||||
xcpt_t handler;
|
||||
FAR void *arg;
|
||||
uint32_t intcfg;
|
||||
uint8_t spidev;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks
|
||||
* to isolate the MRF24J40 driver from differences in GPIO interrupt handling
|
||||
* varying boards and MCUs.
|
||||
*
|
||||
* irq_attach - Attach the MRF24J40 interrupt handler to the GPIO
|
||||
* interrupt
|
||||
* irq_enable - Enable or disable the GPIO interrupt
|
||||
*/
|
||||
|
||||
static int stm32_attach_irq(FAR const struct mrf24j40_lower_s *lower,
|
||||
xcpt_t handler, FAR void *arg);
|
||||
static void stm32_enable_irq(FAR const struct mrf24j40_lower_s *lower,
|
||||
bool state);
|
||||
static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* A reference to a structure of this type must be passed to the MRF24J40
|
||||
* driver. This structure provides information about the configuration
|
||||
* of the MRF24J40 and provides some board-specific hooks.
|
||||
*
|
||||
* Memory for this structure is provided by the caller. It is not copied
|
||||
* by the driver and is presumed to persist while the driver is active. The
|
||||
* memory must be writable because, under certain circumstances, the driver
|
||||
* may modify frequency or X plate resistance values.
|
||||
*/
|
||||
|
||||
static struct stm32_priv_s g_mrf24j40_mb1_priv =
|
||||
{
|
||||
.dev.attach = stm32_attach_irq,
|
||||
.dev.enable = stm32_enable_irq,
|
||||
.handler = NULL,
|
||||
.arg = NULL,
|
||||
.intcfg = GPIO_MRF24J40_INT,
|
||||
.spidev = 1,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/* IRQ/GPIO access callbacks. These operations all hidden behind
|
||||
* callbacks to isolate the MRF24J40 driver from differences in GPIO
|
||||
* interrupt handling by varying boards and MCUs. If possible,
|
||||
* interrupts should be configured on both rising and falling edges
|
||||
* so that contact and loss-of-contact events can be detected.
|
||||
*
|
||||
* irq_attach - Attach the MRF24J40 interrupt handler to the GPIO
|
||||
* interrupt
|
||||
* irq_enable - Enable or disable the GPIO interrupt
|
||||
*/
|
||||
|
||||
static int stm32_attach_irq(FAR const struct mrf24j40_lower_s *lower,
|
||||
xcpt_t handler, FAR void *arg)
|
||||
{
|
||||
FAR struct stm32_priv_s *priv = (FAR struct stm32_priv_s *)lower;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
/* Just save the handler for use when the interrupt is enabled */
|
||||
|
||||
priv->handler = handler;
|
||||
priv->arg = arg;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static void stm32_enable_irq(FAR const struct mrf24j40_lower_s *lower,
|
||||
bool state)
|
||||
{
|
||||
FAR struct stm32_priv_s *priv = (FAR struct stm32_priv_s *)lower;
|
||||
|
||||
/* The caller should not attempt to enable interrupts if the handler
|
||||
* has not yet been 'attached'
|
||||
*/
|
||||
|
||||
DEBUGASSERT(priv != NULL && (priv->handler != NULL || !state));
|
||||
|
||||
wlinfo("state:%d\n", (int)state);
|
||||
|
||||
/* Attach and enable, or detach and disable */
|
||||
|
||||
if (state)
|
||||
{
|
||||
(void)stm32_gpiosetevent(priv->intcfg, false, true, true,
|
||||
priv->handler, priv->arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)stm32_gpiosetevent(priv->intcfg, false, false, false,
|
||||
NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_mrf24j40_devsetup
|
||||
*
|
||||
* Description:
|
||||
* Initialize one the MRF24J40 device in one mikroBUS slot
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success. Otherwise, a negated errno value is
|
||||
* returned to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv)
|
||||
{
|
||||
FAR struct ieee802154_radio_s *radio;
|
||||
MACHANDLE mac;
|
||||
FAR struct spi_dev_s *spi;
|
||||
int ret;
|
||||
|
||||
/* Configure the interrupt pin */
|
||||
|
||||
stm32_configgpio(priv->intcfg);
|
||||
|
||||
/* Initialize the SPI bus and get an instance of the SPI interface */
|
||||
|
||||
spi = stm32_spibus_initialize(priv->spidev);
|
||||
if (spi == NULL)
|
||||
{
|
||||
wlerr("ERROR: Failed to initialize SPI bus %d\n", priv->spidev);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Initialize and register the SPI MRF24J40 device */
|
||||
|
||||
radio = mrf24j40_init(spi, &priv->dev);
|
||||
if (radio == NULL)
|
||||
{
|
||||
wlerr("ERROR: Failed to initialize SPI bus %d\n", priv->spidev);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Create a 802.15.4 MAC device from a 802.15.4 compatible radio device. */
|
||||
|
||||
mac = mac802154_create(radio);
|
||||
if (mac == NULL)
|
||||
{
|
||||
wlerr("ERROR: Failed to initialize IEEE802.15.4 MAC\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_IEEE802154_NETDEV
|
||||
/* 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().
|
||||
*/
|
||||
|
||||
ret = mac802154netdev_register(mac);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to register the MAC network driver wpan%d: %d\n",
|
||||
0, ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#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().
|
||||
*/
|
||||
|
||||
ret = mac802154dev_register(mac, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to register the MAC character driver /dev/ieee%d: %d\n",
|
||||
0, ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_mrf24j40_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the MRF24J40 device.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success. Otherwise, a negated errno value is
|
||||
* returned to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_mrf24j40_initialize(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
wlinfo("Configuring MRF24J40\n");
|
||||
|
||||
ret = stm32_mrf24j40_devsetup(&g_mrf24j40_mb1_priv);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to initialize BD in mikroBUS1: %d\n", ret);
|
||||
}
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
#endif /* CONFIG_IEEE802154_MRF24J40 */
|
||||
@@ -113,7 +113,7 @@ void stm32_spidev_initialize(void)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_IEEE802154_MRF24J40
|
||||
stm32_configgpio(GPIO_MRF24J40_CS);
|
||||
stm32_configgpio(GPIO_MRF24J40_CS); /* MRF24J40 chip select */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user