mirror of
https://github.com/apache/nuttx.git
synced 2025-12-15 08:44:44 +08:00
Squashed commit of the following:
commit 89e9d426e91c056e659fccf5e5c4392618f8f777 Author: Gregory Nutt <gnutt@nuttx.org> Date: Mon Jul 24 16:44:19 2017 -0600 Update some comments commit 9c5d8a5833350006ed389e898b11c8c8a20e5f4f Author: Gregory Nutt <gnutt@nuttx.org> Date: Mon Jul 24 16:15:54 2017 -0600 Spirit: Rename drivers/wireless/spirit/src to lib. Move Spirit network driver out of IEEE802.15.4 into drivers/wireless/spirit/drivers commit cabc0ec9e6eb558dcb715ab17264383aa0105e7a Merge: 87b616414a6bd744c4b3Author: Gregory Nutt <gnutt@nuttx.org> Date: Mon Jul 24 15:38:40 2017 -0600 Merge remote-tracking branch 'origin/master' into spirit commit 87b616414a79c01a71acea78f8258e05325c1996 Author: Gregory Nutt <gnutt@nuttx.org> Date: Mon Jul 24 15:37:27 2017 -0600 Spirit radio driver is mutating into a standalone network driver. commit 507798233868a661ae8adad3e3aa117075a7a146 Author: Gregory Nutt <gnutt@nuttx.org> Date: Mon Jul 24 13:32:08 2017 -0600 Spirit: More radio initialization logic commit 33af25704ce9ca83d576300d153cfe31cc6d2576 Author: Gregory Nutt <gnutt@nuttx.org> Date: Mon Jul 24 12:19:14 2017 -0600 Spirit: Beginning of radio initialization logic commit 97b20014c016e55952a8f9d8f4ae29e2cc555b23 Author: Gregory Nutt <gnutt@nuttx.org> Date: Mon Jul 24 09:42:06 2017 -0600 Spirit: More initialization logic. commit 295d8e27824c0417fccea2344b30bb5c93ffbabe Author: Gregory Nutt <gnutt@nuttx.org> Date: Sun Jul 23 15:39:53 2017 -0600 Spirit: Add header file containing enumeration of commands. commit 8a2d9dd8eb9cc70cbcdd1b913fc9022b9c9ec8da Author: Gregory Nutt <gnutt@nuttx.org> Date: Sun Jul 23 11:33:50 2017 -0600 Spirit: Add GPIO initialization logic commit 8b6d80c44f92024c45a6ba63ba1af3fdafe94dc3 Author: Gregory Nutt <gnutt@nuttx.org> Date: Sun Jul 23 10:07:25 2017 -0600 Spirit: Add interrupt control logic. commit 423f846fe5c914f92a4bfea4d9d1fa33de1c77a5 Author: Gregory Nutt <gnutt@nuttx.org> Date: Sat Jul 22 19:06:52 2017 -0600 Spirit: Yet a little more radio initialization logic. commit 5895b979823e51ddde5ad52e6de66a8ad662e883 Author: Gregory Nutt <gnutt@nuttx.org> Date: Sat Jul 22 15:36:05 2017 -0600 Spirit: A little more radio initialization logic. commit 86311ab30aad386203c181c792847dd1d37f9a02 Author: Gregory Nutt <gnutt@nuttx.org> Date: Sat Jul 22 13:02:32 2017 -0600 Spirit: A miniscule amount of radio initialization logic. commit ad55e89d5ee12ea1eeea95fcd38ff3da0db4416a Merge: 90a7666655f4e46b0da7Author: Gregory Nutt <gnutt@nuttx.org> Date: Sat Jul 22 10:56:30 2017 -0600 Merge remote-tracking branch 'origin/master' into spirit commit 90a766665534b05da0157dbc383cb06a98c86a79 Author: Gregory Nutt <gnutt@nuttx.org> Date: Sat Jul 22 10:52:52 2017 -0600 Spirit1: A few fixes for a clean build of initial configuration (not much there yet) commit bbbf04c223230a52a7705a2161128265cfbaa480 Merge: 623d54a7f72319ea53a9Author: Gregory Nutt <gnutt@nuttx.org> Date: Sat Jul 22 09:53:57 2017 -0600 Merge remote-tracking branch 'origin/master' into spirit commit 623d54a7f719e9032099f88f38203efee4b80722 Author: Gregory Nutt <gnutt@nuttx.org> Date: Sat Jul 22 09:43:52 2017 -0600 b-l475e-iot01a: Add a configuration for testing sprit radio. commit d309d73d9f4665f9d870eb03531f450043d9389d Merge: 52c3ddfae6d88dc9b2e5Author: Gregory Nutt <gnutt@nuttx.org> Date: Sat Jul 22 09:02:06 2017 -0600 Merge remote-tracking branch 'origin/master' into spirit commit 52c3ddfae6802e111c2b5cf1207baf21a61dd00b Author: Gregory Nutt <gnutt@nuttx.org> Date: Sat Jul 22 08:33:04 2017 -0600 Spirit: Add register definition header file. commit 8d842ab5e8f9ca653b42f9ee88dc279f06b4fa98 Author: Gregory Nutt <gnutt@nuttx.org> Date: Fri Jul 21 17:27:03 2017 -0600 b-l475e-iot01a: Add initial, unverified support for the SPSRGF/Spirit1 module. commit 73d902a1048616fb9c2dd2147cabcd8ee78e19ac Author: Gregory Nutt <gnutt@nuttx.org> Date: Fri Jul 21 15:49:43 2017 -0600 Spirit: Fixes to get skeleton IEEE 802.15.4 driver build. commit ebc5a8387bb94f0cc3827533795f3e4a33207e67 Author: Gregory Nutt <gnutt@nuttx.org> Date: Fri Jul 21 15:16:29 2017 -0600 Spirit1: Add framework for IEEE 802.15.4 driver. Does not yet build. commit 52e195a7ae14ddb18bdd56258f4877381d2501ca Author: Gregory Nutt <gnutt@nuttx.org> Date: Fri Jul 21 14:02:42 2017 -0600 Spirit: A little more SPI logic. commit 90048d0c5b8a5af4d81a15d99535c84ed38d8ae9 Author: Gregory Nutt <gnutt@nuttx.org> Date: Fri Jul 21 11:19:06 2017 -0600 Spirit: Build directories setup. Some initial files added, mostly just to verify build. commit 8273a381ac1f6bb081b292b5e73226185e9e634c Author: Gregory Nutt <gnutt@nuttx.org> Date: Fri Jul 21 08:34:04 2017 -0600 USB composite: Remove references to CDC/ACM and USB MSC from composite logic. They are no longer coupled.
This commit is contained in:
@@ -79,8 +79,6 @@
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
#include "up_arch.h"
|
||||
|
||||
@@ -90,6 +88,8 @@
|
||||
#include "stm32l4_dma.h"
|
||||
#include "stm32l4_spi.h"
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#if defined(CONFIG_STM32L4_SPI1) || defined(CONFIG_STM32L4_SPI2) || \
|
||||
defined(CONFIG_STM32L4_SPI3)
|
||||
|
||||
|
||||
@@ -48,18 +48,18 @@
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Clocking *************************************************************************/
|
||||
|
||||
#if 1
|
||||
# define HSI_CLOCK_CONFIG /* HSI-16 clock configuration */
|
||||
# define HSI_CLOCK_CONFIG 1 /* HSI-16 clock configuration */
|
||||
#elif 0
|
||||
/* Make sure you installed one! */
|
||||
|
||||
# define HSE_CLOCK_CONFIG /* HSE with 8 MHz xtal */
|
||||
# define HSE_CLOCK_CONFIG 1 /* HSE with 8 MHz xtal */
|
||||
#else
|
||||
# define MSI_CLOCK_CONFIG /* MSI @ 4 MHz autotrimmed via LSE */
|
||||
# define MSI_CLOCK_CONFIG 1 /* MSI @ 4 MHz autotrimmed via LSE */
|
||||
#endif
|
||||
|
||||
/* Clocking *************************************************************************/
|
||||
|
||||
#if defined(HSI_CLOCK_CONFIG)
|
||||
/* The STMicro IoT board supports both HSE and LSE crystals. As shipped, the HSE
|
||||
* crystal (X1) is not populated. Therefore the STMicro IoT board will need to run off the
|
||||
@@ -265,7 +265,7 @@
|
||||
|
||||
#define STM32L4_RCC_CFGR_HPRE RCC_CFGR_HPRE_SYSCLK /* HCLK = SYSCLK / 1 */
|
||||
#define STM32L4_HCLK_FREQUENCY STM32L4_SYSCLK_FREQUENCY
|
||||
#define STM32L4_BOARD_HCLK STM32L4_HCLK_FREQUENCY /* Same as above, to satisfy compiler */
|
||||
#define STM32L4_BOARD_HCLK STM32L4_HCLK_FREQUENCY /* Same as above, to satisfy compiler */
|
||||
|
||||
/* APB1 clock (PCLK1) is HCLK/1 (80MHz) */
|
||||
|
||||
@@ -401,7 +401,7 @@
|
||||
#define STM32L4_PLLCFG_PLLP 0
|
||||
#undef STM32L4_PLLCFG_PLLP_ENABLED
|
||||
#define STM32L4_PLLCFG_PLLQ 0
|
||||
#undef STM32L4_PLLCFG_PLLQ_ENABLED
|
||||
#undef STM32L4_PLLCFG_PLLQ_ENABLED
|
||||
#define STM32L4_PLLCFG_PLLR RCC_PLLCFG_PLLR_2
|
||||
#define STM32L4_PLLCFG_PLLR_ENABLED
|
||||
|
||||
|
||||
@@ -46,8 +46,6 @@
|
||||
# include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include <stm32l4.h>
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
@@ -97,6 +95,55 @@
|
||||
* 2Hz, then a fatal error has been detected and the system has halted.
|
||||
*/
|
||||
|
||||
/* SPSGRF-915 Spirit1 library definitions ***********************************(*******/
|
||||
|
||||
/* The TX_WAIT_PCKT_PERIOD should equal the max packet tx time. */
|
||||
|
||||
#define SPIRIT_TX_WAIT_PCKT_PERIOD 50
|
||||
|
||||
/* The RX_WAIT_ACK_PERIOD is the period within which the ACK packet must be received.
|
||||
* ca PACKET_LENGTH / DATA_RATE + ELABORATION_TIME + SPI_OPERATIONS_USED.
|
||||
*/
|
||||
|
||||
#define SPIRIT_RX_WAIT_ACK_PERIOD 50
|
||||
|
||||
#define SPIRIT_CCA_THRESHOLD -90.0 /* dBm */
|
||||
#define SPIRIT_XTAL_FREQUENCY 50000000 /* Hz */
|
||||
#define SPIRIT_XTAL_OFFSET_PPM 0
|
||||
#define SPIRIT_BASE_FREQUENCY 868.0e6
|
||||
#define SPIRIT_CHANNEL_SPACE 20e3
|
||||
#define SPIRIT_CHANNEL_NUMBER 0
|
||||
#define SPIRIT_MODULATION_SELECT FSK
|
||||
#define SPIRIT_DATARATE 38400
|
||||
#define SPIRIT_FREQ_DEVIATION 20e3
|
||||
#define SPIRIT_BANDWIDTH 100.5E3
|
||||
#define SPIRIT_POWER_DBM 10.0
|
||||
#define SPIRIT_PREAMBLE_LENGTH PKT_PREAMBLE_LENGTH_04BYTES
|
||||
#define SPIRIT_SYNC_LENGTH PKT_SYNC_LENGTH_4BYTES
|
||||
#define SPIRIT_SYNC_WORD 0x88888888
|
||||
#define SPIRIT_LENGTH_TYPE PKT_LENGTH_VAR
|
||||
#define SPIRIT_LENGTH_WIDTH 8
|
||||
#define SPIRIT_CRC_MODE PKT_CRC_MODE_16BITS_2
|
||||
#define SPIRIT_CONTROL_LENGTH PKT_CONTROL_LENGTH_0BYTES
|
||||
#define SPIRIT_EN_ADDRESS S_DISABLE
|
||||
#define SPIRIT_EN_FEC S_DISABLE
|
||||
#define SPIRIT_EN_WHITENING S_DISABLE
|
||||
#define SPIRIT_MAX_FIFO_LEN 96
|
||||
#define SPIRIT_RANGE_TYPE RANGE_EXT_NONE /* RANGE_EXT_SKYWORKS */
|
||||
|
||||
/* The MAX_PACKET_LEN is an arbitrary value used to define the two array
|
||||
* spirit_txbuf and spirit_rxbuf.
|
||||
*
|
||||
* The SPIRIT1 supports with its packet handler a length of 65,535 bytes,
|
||||
* and in direct mode (without packet handler) there is no limit of data.
|
||||
*/
|
||||
|
||||
#define SPIRIT_MAX_PACKET_LEN SPIRIT_MAX_FIFO_LEN
|
||||
|
||||
/* Spirit1 IC version */
|
||||
|
||||
#define SPIRIT_VERSION SPIRIT_VERSION_3_0
|
||||
|
||||
/* Alternate function pin selections ************************************************/
|
||||
|
||||
/* USART1: Connected to STLink Debug via PB6, PB7 */
|
||||
@@ -109,6 +156,27 @@
|
||||
#define GPIO_UART4_RX GPIO_UART4_RX_1
|
||||
#define GPIO_UART4_TX GPIO_UART4_TX_1
|
||||
|
||||
/* SPSGRF
|
||||
*
|
||||
* -------- ----------------------- ----------------
|
||||
* SPSGRF Board Signal STM32L4 pin
|
||||
* -------- ----------------------- ----------------
|
||||
* SPI_CLK INTERNAL-SPI3_SCK PC10 SPI3_SCK
|
||||
* SPI_MISO INTERNAL-SPI3_MISO PC11 SPI3_MISO
|
||||
* SPI_MOSI INTERNAL-SPI3_MOSI PC12 SPI3_MOSI
|
||||
* SPI_CS SPSGRF-915-SPI3_CSN PB5 GPIO_Output
|
||||
* GPIO(3) SPSGRF-915-GPIO3_EXTI5 PE5 GPIO_EXTI5
|
||||
* GPIO(2) N/C N/A
|
||||
* GPIO(1) N/C N/A
|
||||
* GPIO(0) N/C N/A
|
||||
* SDN SPSGRF-915-SDN PB15 GPIO_Output
|
||||
* -------- ----------------------- ----------------
|
||||
*/
|
||||
|
||||
#define GPIO_SPI3_SCK GPIO_SPI3_SCK_2
|
||||
#define GPIO_SPI3_MISO GPIO_SPI3_MISO_2
|
||||
#define GPIO_SPI3_MOSI GPIO_SPI3_MOSI_2
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
|
||||
61
configs/b-l475e-iot01a/spirit-mac/defconfig
Normal file
61
configs/b-l475e-iot01a/spirit-mac/defconfig
Normal file
@@ -0,0 +1,61 @@
|
||||
# CONFIG_NET_ETHERNET is not set
|
||||
# CONFIG_NET_IPv4 is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_DF_H is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH_BOARD_B_L475E_IOT01A=y
|
||||
CONFIG_ARCH_BOARD="b-l475e-iot01a"
|
||||
CONFIG_ARCH_CHIP_STM32L4=y
|
||||
CONFIG_ARCH_CHIP_STM32L475VG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DISABLE_POLL=y
|
||||
CONFIG_DRIVERS_IEEE802154=y
|
||||
CONFIG_DRIVERS_WIRELESS=y
|
||||
CONFIG_EXAMPLES_NSH=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IEEE802154_I8SAK=y
|
||||
CONFIG_IEEE802154_MACDEV=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBM=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NET_6LOWPAN=y
|
||||
CONFIG_NET_IPv6=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NETDEVICES=y
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=8
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
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_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_SPIRIT_NETDEV=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_STM32L4_SPI3=y
|
||||
CONFIG_STM32L4_UART4=y
|
||||
CONFIG_UART4_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_WATCHDOG=y
|
||||
CONFIG_WIRELESS_IEEE802154=y
|
||||
CONFIG_WIRELESS=y
|
||||
@@ -35,7 +35,7 @@
|
||||
-include $(TOPDIR)/Make.defs
|
||||
|
||||
ASRCS =
|
||||
CSRCS = stm32_boot.c stm32_bringup.c
|
||||
CSRCS = stm32_boot.c stm32_bringup.c stm32_spi.c
|
||||
|
||||
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
||||
CSRCS += stm32_appinit.c
|
||||
@@ -47,4 +47,8 @@ else
|
||||
CSRCS += stm32_userleds.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SPIRIT_NETDEV),y)
|
||||
CSRCS += stm32_spirit.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/configs/Board.mk
|
||||
|
||||
@@ -48,12 +48,77 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#define HAVE_SPSGRF 1
|
||||
|
||||
/* SPSGRF support depends on:
|
||||
*
|
||||
* CONFIG_STM32L4_SPI3 - SPI3 support
|
||||
* CONFIG_WL_SPIRIT - Spirit wireless library
|
||||
* CONFIG_SPIRIT_NETDEV - Spirit network driver
|
||||
* CONFIG_SCHED_HPWORK - HP work queue support
|
||||
* CONFIG_SCHED_LPWORK - LP work queue support
|
||||
* CONFIG_NET - Networking enabled
|
||||
* CONFIG_NET_6LOWPAN - 6LoWPAN stack enabled
|
||||
*
|
||||
* And probably a few other things.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_STM32L4_SPI3)
|
||||
# undef HAVE_SPSGRF
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_WL_SPIRIT) || !defined(CONFIG_SPIRIT_NETDEV)
|
||||
# undef HAVE_SPSGRF
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_SCHED_HPWORK) || !defined(CONFIG_SCHED_LPWORK)
|
||||
# undef HAVE_SPSGRF
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_NET) || !defined(CONFIG_NET_6LOWPAN)
|
||||
# undef HAVE_SPSGRF
|
||||
#endif
|
||||
|
||||
/* GPIO Definitions *********************************************************/
|
||||
/* LEDs */
|
||||
|
||||
#define GPIO_LED1 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN5)
|
||||
#define GPIO_LED2 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN14)
|
||||
#define GPIO_LED1 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz |\
|
||||
GPIO_OUTPUT_CLEAR | GPIO_PORTA | GPIO_PIN5)
|
||||
#define GPIO_LED2 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz |\
|
||||
GPIO_OUTPUT_CLEAR | GPIO_PORTB | GPIO_PIN14)
|
||||
|
||||
/* SPSGRF
|
||||
*
|
||||
* -------- ----------------------- ----------------
|
||||
* SPSGRF Board Signal STM32L4 pin
|
||||
* -------- ----------------------- ----------------
|
||||
* SPI_CLK INTERNAL-SPI3_SCK PC10 SPI3_SCK
|
||||
* SPI_MISO INTERNAL-SPI3_MISO PC11 SPI3_MISO
|
||||
* SPI_MOSI INTERNAL-SPI3_MOSI PC12 SPI3_MOSI
|
||||
* SPI_CS SPSGRF-915-SPI3_CSN PB5 GPIO_Output
|
||||
* GPIO(3) SPSGRF-915-GPIO3_EXTI5 PE5 GPIO_EXTI5
|
||||
* GPIO(2) N/C N/A
|
||||
* GPIO(1) N/C N/A
|
||||
* GPIO(0) N/C N/A
|
||||
* SDN SPSGRF-915-SDN PB15 GPIO_Output
|
||||
* -------- ----------------------- ----------------
|
||||
*
|
||||
* NOTES:
|
||||
* - The Interrupt request is active low.
|
||||
* - When SDN =1 the Spirit is completely shut down and the contents of the
|
||||
* registers are lost.
|
||||
*/
|
||||
|
||||
#define GPIO_SPSGRF_CS (GPIO_OUTPUT | GPIO_FLOAT | GPIO_PUSHPULL | \
|
||||
GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | \
|
||||
GPIO_PORTB | GPIO_PIN5)
|
||||
#define GPIO_SPSGRF_INT (GPIO_INPUT | GPIO_FLOAT | GPIO_SPEED_100MHz | \
|
||||
GPIO_EXTI | GPIO_PORTE | GPIO_PIN5)
|
||||
#define GPIO_SPSGRF_SDN (GPIO_OUTPUT | GPIO_FLOAT | GPIO_PUSHPULL | \
|
||||
GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | \
|
||||
GPIO_PORTB | GPIO_PIN15)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
@@ -84,5 +149,34 @@
|
||||
int stm32l4_bringup(void);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32l4_spidev_initialize
|
||||
*
|
||||
* Description:
|
||||
* Called to configure SPI chip select GPIO pins for the Nucleo-F401RE and
|
||||
* Nucleo-F411RE boards.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#if defined(CONFIG_STM32L4_SPI1) || defined(CONFIG_STM32L4_SPI2) || defined(CONFIG_STM32L4_SPI3)
|
||||
void weak_function stm32l4_spidev_initialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32l4_spirit_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the Spirit device.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success. Otherwise, a negated errno value is
|
||||
* returned to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_SPSGRF
|
||||
int stm32l4_spirit_initialize(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __CONFIGS_B_L475E_IOT01A_SRC_B_L475E_IOT01A_H */
|
||||
|
||||
@@ -62,6 +62,17 @@
|
||||
|
||||
void stm32l4_board_initialize(void)
|
||||
{
|
||||
#if defined(CONFIG_STM32L4_SPI1) || defined(CONFIG_STM32L4_SPI2) || defined(CONFIG_STM32L4_SPI3)
|
||||
/* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
|
||||
* stm32l4_spidev_initialize() has been brought into the link.
|
||||
*/
|
||||
|
||||
if (stm32l4_spidev_initialize)
|
||||
{
|
||||
stm32l4_spidev_initialize();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
/* Configure on-board LEDs if LED support has been selected. */
|
||||
|
||||
|
||||
@@ -97,5 +97,15 @@ int stm32l4_bringup(void)
|
||||
#endif /* CONFIG_USERLED_LOWER */
|
||||
#endif /* CONFIG_USERLED && !CONFIG_ARCH_LEDS */
|
||||
|
||||
#ifdef HAVE_SPSGRF
|
||||
/* Configure Spirit/SPSGRF wireless */
|
||||
|
||||
ret = stm32l4_spirit_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: stm32l4_spirit_initialize() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
252
configs/b-l475e-iot01a/src/stm32_spi.c
Normal file
252
configs/b-l475e-iot01a/src/stm32_spi.c
Normal file
@@ -0,0 +1,252 @@
|
||||
/****************************************************************************
|
||||
* configs/b-f475e-iot01a/src/stm32_spi.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "stm32l4_gpio.h"
|
||||
#include "stm32l4_spi.h"
|
||||
|
||||
#include "b-l475e-iot01a.h"
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Currently no devices are defined on SPI1 or SPI2 */
|
||||
|
||||
#undef CONFIG_STM32L4_SPI1
|
||||
#undef CONFIG_STM32L4_SPI2
|
||||
|
||||
/* Only the SPSGRF is currently supported on SPI3 */
|
||||
|
||||
#ifndef HAVE_SPSGRF
|
||||
# undef CONFIG_STM32L4_SPI3
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_STM32L4_SPI1) || defined(CONFIG_STM32L4_SPI2) || defined(CONFIG_STM32L4_SPI3)
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
|
||||
/* Global driver instances */
|
||||
|
||||
#ifdef CONFIG_STM32L4_SPI1
|
||||
struct spi_dev_s *g_spi1;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_SPI2
|
||||
struct spi_dev_s *g_spi2;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_SPI3
|
||||
struct spi_dev_s *g_spi3;
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32l4_spidev_initialize
|
||||
*
|
||||
* Description:
|
||||
* Called to configure SPI chip select GPIO pins for the Nucleo-F401RE and
|
||||
* Nucleo-F411RE boards.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void weak_function stm32l4_spidev_initialize(void)
|
||||
{
|
||||
#ifdef CONFIG_STM32L4_SPI1
|
||||
/* Configure SPI-based devices */
|
||||
|
||||
g_spi1 = stm32l4_spibus_initialize(1);
|
||||
if (!g_spi1)
|
||||
{
|
||||
spierr("ERROR: [boot] FAILED to initialize SPI port 1\n");
|
||||
}
|
||||
|
||||
/* Configure chip select GPIOs */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_SPI2
|
||||
/* Configure SPI-based devices */
|
||||
|
||||
g_spi2 = stm32l4_spibus_initialize(2);
|
||||
|
||||
/* Configure chip select GPIOs */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_SPI2
|
||||
/* Configure SPI-based devices */
|
||||
|
||||
g_spi3 = stm32l4_spibus_initialize(3);
|
||||
|
||||
/* Configure chip select GPIOs */
|
||||
|
||||
#ifdef HAVE_SPSGRF
|
||||
stm32l4_configgpio(GPIO_SPSGRF_CS);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32l4_spi1/2/3select and stm32l4_spi1/2/3status
|
||||
*
|
||||
* Description:
|
||||
* The external functions, stm32l4_spi1/2/3select and stm32l4_spi1/2/3status must be
|
||||
* provided by board-specific logic. They are implementations of the select
|
||||
* and status methods of the SPI interface defined by struct spi_ops_s (see
|
||||
* include/nuttx/spi/spi.h). All other methods (including up_spiinitialize())
|
||||
* are provided by common STM32 logic. To use this common SPI logic on your
|
||||
* board:
|
||||
*
|
||||
* 1. Provide logic in stm32l4_boardinitialize() to configure SPI chip select
|
||||
* pins.
|
||||
* 2. Provide stm32l4_spi1/2/3select() and stm32l4_spi1/2/3status() functions in your
|
||||
* board-specific logic. These functions will perform chip selection and
|
||||
* status operations using GPIOs in the way your board is configured.
|
||||
* 3. Add a calls to up_spiinitialize() in your low level application
|
||||
* initialization logic
|
||||
* 4. The handle returned by up_spiinitialize() may then be used to bind the
|
||||
* SPI driver to higher level logic (e.g., calling
|
||||
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
|
||||
* the SPI MMC/SD driver).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32L4_SPI1
|
||||
void stm32l4_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
}
|
||||
|
||||
uint8_t stm32l4_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_SPI2
|
||||
void stm32l4_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
}
|
||||
|
||||
uint8_t stm32l4_spi2status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_SPI3
|
||||
void stm32l4_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
|
||||
#ifdef HAVE_SPSGRF
|
||||
if (devid == SPIDEV_WIRELESS(0))
|
||||
{
|
||||
stm32l4_gpiowrite(GPIO_SPSGRF_CS, !selected);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t stm32l4_spi3status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32l4_spi1cmddata
|
||||
*
|
||||
* Description:
|
||||
* Set or clear the SH1101A A0 or SD1306 D/C n bit to select data (true)
|
||||
* or command (false). This function must be provided by platform-specific
|
||||
* logic. This is an implementation of the cmddata method of the SPI
|
||||
* interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
|
||||
*
|
||||
* Input Parameters:
|
||||
*
|
||||
* spi - SPI device that controls the bus the device that requires the CMD/
|
||||
* DATA selection.
|
||||
* devid - If there are multiple devices on the bus, this selects which one
|
||||
* to select cmd or data. NOTE: This design restricts, for example,
|
||||
* one one SPI display per SPI bus.
|
||||
* cmd - true: select command; false: select data
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
#ifdef CONFIG_STM32L4_SPI1
|
||||
int stm32l4_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_SPI2
|
||||
int stm32l4_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32L4_SPI3
|
||||
int stm32l4_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_SPI_CMDDATA */
|
||||
|
||||
#endif /* CONFIG_STM32L4_SPI1 || CONFIG_STM32L4_SPI2 || CONFIG_STM32L4_SPI3 */
|
||||
285
configs/b-l475e-iot01a/src/stm32_spirit.c
Normal file
285
configs/b-l475e-iot01a/src/stm32_spirit.c
Normal file
@@ -0,0 +1,285 @@
|
||||
/****************************************************************************
|
||||
* configs/b-l475e-iot01a/src/stm32_spirit.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt, All rights reserver
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/wireless/spirit.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "stm32l4_gpio.h"
|
||||
#include "stm32l4_exti.h"
|
||||
#include "stm32l4_spi.h"
|
||||
|
||||
#include "b-l475e-iot01a.h"
|
||||
|
||||
#ifdef HAVE_SPSGRF
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_DRIVERS_WIRELESS
|
||||
# error Wireless support requires CONFIG_DRIVERS_WIRELESS
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct stm32l4_priv_s
|
||||
{
|
||||
struct spirit_lower_s dev;
|
||||
xcpt_t handler;
|
||||
FAR void *arg;
|
||||
uint32_t intcfg;
|
||||
uint32_t sdncfg;
|
||||
uint8_t spidev;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks
|
||||
* to isolate the Spirit driver from differences in GPIO interrupt handling
|
||||
* varying boards and MCUs.
|
||||
*
|
||||
* stm32l4_reset - Reset the Spirit part.
|
||||
* stm32l4_attach_irq - Attach the Spirit interrupt handler to the GPIO
|
||||
interrupt
|
||||
* stm32l4_enable_irq - Enable or disable the GPIO interrupt
|
||||
*/
|
||||
|
||||
static int stm32l4_reset(FAR const struct spirit_lower_s *lower);
|
||||
static int stm32l4_attach_irq(FAR const struct spirit_lower_s *lower,
|
||||
xcpt_t handler, FAR void *arg);
|
||||
static void stm32l4_enable_irq(FAR const struct spirit_lower_s *lower,
|
||||
bool state);
|
||||
static int stm32l4_spirit_devsetup(FAR struct stm32l4_priv_s *priv);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* A reference to a structure of this type must be passed to the Spirit
|
||||
* driver. This structure provides information about the configuration
|
||||
* of the Spirit 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 stm32l4_priv_s g_spirit =
|
||||
{
|
||||
.dev.reset = stm32l4_reset,
|
||||
.dev.attach = stm32l4_attach_irq,
|
||||
.dev.enable = stm32l4_enable_irq,
|
||||
.handler = NULL,
|
||||
.arg = NULL,
|
||||
.intcfg = GPIO_SPSGRF_INT,
|
||||
.sdncfg = GPIO_SPSGRF_SDN,
|
||||
.spidev = 3,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Reset the Spirit 1 part */
|
||||
|
||||
static int stm32l4_reset(FAR const struct spirit_lower_s *lower)
|
||||
{
|
||||
FAR struct stm32l4_priv_s *priv = (FAR struct stm32l4_priv_s *)lower;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
/* Reset pulse */
|
||||
|
||||
stm32l4_gpiowrite(priv->sdncfg, true);
|
||||
stm32l4_gpiowrite(priv->sdncfg, false);
|
||||
|
||||
/* Wait minimum 1.5 ms to allow Spirit a proper boot-up sequence */
|
||||
|
||||
usleep(1500);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* IRQ/GPIO access callbacks. These operations all hidden behind
|
||||
* callbacks to isolate the Spirit 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.
|
||||
*
|
||||
* stm32l4_attach_irq - Attach the Spirit interrupt handler to the GPIO
|
||||
* interrupt
|
||||
* stm32l4_enable_irq - Enable or disable the GPIO interrupt
|
||||
*/
|
||||
|
||||
static int stm32l4_attach_irq(FAR const struct spirit_lower_s *lower,
|
||||
xcpt_t handler, FAR void *arg)
|
||||
{
|
||||
FAR struct stm32l4_priv_s *priv = (FAR struct stm32l4_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 stm32l4_enable_irq(FAR const struct spirit_lower_s *lower,
|
||||
bool state)
|
||||
{
|
||||
FAR struct stm32l4_priv_s *priv = (FAR struct stm32l4_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)
|
||||
{
|
||||
/* Enable interrupts on falling edge (active low) */
|
||||
|
||||
(void)stm32l4_gpiosetevent(priv->intcfg, false, true, false,
|
||||
priv->handler, priv->arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Disable interrupts */
|
||||
|
||||
(void)stm32l4_gpiosetevent(priv->intcfg, false, false, false,
|
||||
NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32l4_spirit_devsetup
|
||||
*
|
||||
* Description:
|
||||
* Initialize one the Spirit device
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success. Otherwise, a negated errno value is
|
||||
* returned to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stm32l4_spirit_devsetup(FAR struct stm32l4_priv_s *priv)
|
||||
{
|
||||
FAR struct spi_dev_s *spi;
|
||||
int ret;
|
||||
|
||||
/* Configure the interrupt pin and SDN pins. Innitializing the SDN to '1'
|
||||
* powers down the Spirit.
|
||||
*/
|
||||
|
||||
stm32l4_configgpio(priv->intcfg);
|
||||
stm32l4_configgpio(priv->sdncfg);
|
||||
|
||||
/* Initialize the SPI bus and get an instance of the SPI interface */
|
||||
|
||||
spi = stm32l4_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 Spirit device */
|
||||
|
||||
ret = spirit_netdev_initialize(spi, &priv->dev);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: spirit_netdev_initialize failed %d\n", priv->spidev);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32l4_spirit_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the Spirit device.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success. Otherwise, a negated errno value is
|
||||
* returned to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32l4_spirit_initialize(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
wlinfo("Configuring Spirit\n");
|
||||
|
||||
ret = stm32l4_spirit_devsetup(&g_spirit);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to initialize Spirit: %d\n", ret);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif /* HAVE_SPSGRF */
|
||||
@@ -76,13 +76,13 @@
|
||||
*/
|
||||
|
||||
#if 0
|
||||
# define HSI_CLOCK_CONFIG /* HSI-16 clock configuration */
|
||||
# define HSI_CLOCK_CONFIG 1 /* HSI-16 clock configuration */
|
||||
#elif 0
|
||||
/* Make sure you actually installed one! */
|
||||
|
||||
# define HSE_CLOCK_CONFIG /* HSE with 8 MHz xtal */
|
||||
# define HSE_CLOCK_CONFIG 1 /* HSE with 8 MHz xtal */
|
||||
#else
|
||||
# define MSI_CLOCK_CONFIG /* MSI @ 4 MHz autotrimmed via LSE */
|
||||
# define MSI_CLOCK_CONFIG 1 /* MSI @ 4 MHz autotrimmed via LSE */
|
||||
#endif
|
||||
|
||||
#if defined(HSI_CLOCK_CONFIG)
|
||||
@@ -287,7 +287,7 @@
|
||||
#define STM32L4_PLLCFG_PLLP 0
|
||||
#undef STM32L4_PLLCFG_PLLP_ENABLED
|
||||
#define STM32L4_PLLCFG_PLLQ 0
|
||||
#undef STM32L4_PLLCFG_PLLQ_ENABLED
|
||||
#undef STM32L4_PLLCFG_PLLQ_ENABLED
|
||||
#define STM32L4_PLLCFG_PLLR RCC_PLLCFG_PLLR_2
|
||||
#define STM32L4_PLLCFG_PLLR_ENABLED
|
||||
|
||||
@@ -324,7 +324,7 @@
|
||||
|
||||
#define STM32L4_RCC_CFGR_HPRE RCC_CFGR_HPRE_SYSCLK /* HCLK = SYSCLK / 1 */
|
||||
#define STM32L4_HCLK_FREQUENCY STM32L4_SYSCLK_FREQUENCY
|
||||
#define STM32L4_BOARD_HCLK STM32L4_HCLK_FREQUENCY /* Same as above, to satisfy compiler */
|
||||
#define STM32L4_BOARD_HCLK STM32L4_HCLK_FREQUENCY /* Same as above, to satisfy compiler */
|
||||
|
||||
/* Configure the APB1 prescaler */
|
||||
|
||||
|
||||
@@ -51,15 +51,6 @@
|
||||
|
||||
#ifdef CONFIG_USBDEV_COMPOSITE
|
||||
|
||||
#ifdef CONFIG_CDCACM_COMPOSITE
|
||||
# include <nuttx/usb/cdcacm.h>
|
||||
# include "cdcacm.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBMSC_COMPOSITE
|
||||
# include "usbmsc.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -16,6 +16,7 @@ menuconfig WL_CC3000
|
||||
select SPI
|
||||
|
||||
source drivers/wireless/cc3000/Kconfig
|
||||
source drivers/wireless/spirit/Kconfig
|
||||
|
||||
menuconfig DRIVERS_IEEE802154
|
||||
bool "IEEE 802.15.4 Device Support"
|
||||
|
||||
@@ -53,14 +53,18 @@ ifeq ($(CONFIG_WL_CC1101),y)
|
||||
CSRCS += cc1101.c ISM1_868MHzGFSK100kbps.c ISM2_905MHzGFSK250kbps.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WL_NRF24L01),y)
|
||||
CSRCS += nrf24l01.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WL_CC3000),y)
|
||||
include wireless$(DELIM)cc3000$(DELIM)Make.defs
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WL_SPIRIT),y)
|
||||
include wireless$(DELIM)spirit$(DELIM)Make.defs
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WL_NRF24L01),y)
|
||||
CSRCS += nrf24l01.c
|
||||
endif
|
||||
|
||||
# Include wireless devices build support
|
||||
|
||||
DEPPATH += --dep-path wireless
|
||||
|
||||
26
drivers/wireless/spirit/Kconfig
Normal file
26
drivers/wireless/spirit/Kconfig
Normal file
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config WL_SPIRIT
|
||||
bool "STMicro Spririt Radio Library"
|
||||
default n
|
||||
select SPI
|
||||
---help---
|
||||
Enable support for the STMicro Spririt Radio Library
|
||||
|
||||
if WL_SPIRIT
|
||||
|
||||
config WL_SPIRIT_SPIFREQUENCY
|
||||
int "Spirit SPI frequency"
|
||||
default 10000000
|
||||
---help---
|
||||
Frequency at which to operate the SPI interface to the Spirit part.
|
||||
The default is the absolution maximum and you may likely have to
|
||||
reduce this for your board.
|
||||
|
||||
endif
|
||||
|
||||
source drivers/wireless/spirit/drivers/Kconfig
|
||||
|
||||
43
drivers/wireless/spirit/Make.defs
Normal file
43
drivers/wireless/spirit/Make.defs
Normal file
@@ -0,0 +1,43 @@
|
||||
############################################################################
|
||||
# drivers/wireless/spirit/Make.defs
|
||||
#
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_WL_SPIRIT),y)
|
||||
|
||||
# Include Spirit library support
|
||||
|
||||
include wireless$(DELIM)spirit$(DELIM)lib$(DELIM)Make.defs
|
||||
include wireless$(DELIM)spirit$(DELIM)include$(DELIM)Make.defs
|
||||
|
||||
endif
|
||||
17
drivers/wireless/spirit/drivers/Kconfig
Normal file
17
drivers/wireless/spirit/drivers/Kconfig
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config SPIRIT_NETDEV
|
||||
bool "STMicro Spirit1-based Network Driver"
|
||||
default n
|
||||
select WL_SPIRIT
|
||||
---help---
|
||||
This selection enables support for the TMicro Spirit1-based device.
|
||||
This configuration generates an IEEE802.15.4 work-alike radio device that
|
||||
works with the 6LoWPAN stack.
|
||||
|
||||
if SPIRIT_NETDEV
|
||||
|
||||
endif # SPIRIT_NETDEV
|
||||
49
drivers/wireless/spirit/drivers/Make.defs
Normal file
49
drivers/wireless/spirit/drivers/Make.defs
Normal file
@@ -0,0 +1,49 @@
|
||||
############################################################################
|
||||
# drivers/spirit/drivers/Make.defs
|
||||
#
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# Include Spirit1 drivers into the build
|
||||
|
||||
ifeq ($(CONFIG_SPIRIT_NETDEV),y)
|
||||
|
||||
CSRCS += spirit_netdev.c
|
||||
|
||||
# Include Spirit1 build support
|
||||
|
||||
DEPPATH += --dep-path wireless$(DELIM)spirit$(DELIM)drivers
|
||||
VPATH += :wireless$(DELIM)spirit$(DELIM)drivers
|
||||
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" \
|
||||
$(TOPDIR)$(DELIM)drivers$(DELIM)wireless$(DELIM)spirit$(DELIM)drivers}
|
||||
|
||||
endif # CONFIG_SPIRIT_NETDEV
|
||||
1290
drivers/wireless/spirit/drivers/spirit_netdev.c
Normal file
1290
drivers/wireless/spirit/drivers/spirit_netdev.c
Normal file
File diff suppressed because it is too large
Load Diff
39
drivers/wireless/spirit/include/Make.defs
Normal file
39
drivers/wireless/spirit/include/Make.defs
Normal file
@@ -0,0 +1,39 @@
|
||||
############################################################################
|
||||
# drivers/wireless/spirit/include/Make.defs
|
||||
#
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# Add path to include Spirit header files in CFLAGS
|
||||
|
||||
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" \
|
||||
$(TOPDIR)$(DELIM)drivers$(DELIM)wireless$(DELIM)spirit$(DELIM)include}
|
||||
147
drivers/wireless/spirit/include/spirit_commands.h
Normal file
147
drivers/wireless/spirit/include/spirit_commands.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/******************************************************************************
|
||||
* include/nuttx/wireless/spirit/spirit_commands.h
|
||||
* Management of SPIRIT Commands.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_COMMANDS_H
|
||||
#define __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_COMMANDS_H
|
||||
|
||||
/* In this module can be found all the API used to strobe commands to
|
||||
* Spirit. Every command strobe is an SPI transaction with a specific command
|
||||
* code.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Included Files
|
||||
******************************************************************************/
|
||||
|
||||
#include "spirit_regs.h"
|
||||
#include "spirit_types.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Macros used in debug assertions */
|
||||
|
||||
#define IS_SPIRIT_CMD(cmd) (cmd == CMD_TX || \
|
||||
cmd == CMD_RX || \
|
||||
cmd == CMD_READY || \
|
||||
cmd == CMD_STANDBY || \
|
||||
cmd == CMD_SLEEP || \
|
||||
cmd == CMD_LOCKRX || \
|
||||
cmd == CMD_LOCKTX || \
|
||||
cmd == CMD_SABORT || \
|
||||
cmd == CMD_LDC_RELOAD || \
|
||||
cmd == CMD_SEQUENCE_UPDATE || \
|
||||
cmd == CMD_AES_ENC || \
|
||||
cmd == CMD_AES_KEY || \
|
||||
cmd == CMD_AES_DEC || \
|
||||
cmd == CMD_AES_KEY_DEC || \
|
||||
cmd == CMD_SRES || \
|
||||
cmd == CMD_FLUSHRXFIFO || \
|
||||
cmd == CMD_FLUSHTXFIFO \
|
||||
)
|
||||
|
||||
/******************************************************************************
|
||||
* Public Types
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* SPIRIT Commands codes enumeration */
|
||||
|
||||
enum spirit_cmd_e
|
||||
{
|
||||
CMD_TX = COMMAND_TX, /* Start to transmit; valid only
|
||||
* from READY */
|
||||
CMD_RX = COMMAND_RX, /* Start to receive; valid only
|
||||
* from READY */
|
||||
CMD_READY = COMMAND_READY, /* Go to READY; valid only from
|
||||
* STANDBY or SLEEP or LOCK */
|
||||
CMD_STANDBY = COMMAND_STANDBY, /* Go to STANDBY; valid only from
|
||||
* READY */
|
||||
CMD_SLEEP = COMMAND_SLEEP, /* Go to SLEEP; valid only from
|
||||
* READY */
|
||||
CMD_LOCKRX = COMMAND_LOCKRX, /* Go to LOCK state by using the
|
||||
* RX configuration of the synth;
|
||||
* valid only from READY */
|
||||
CMD_LOCKTX = COMMAND_LOCKTX, /* Go to LOCK state by using the
|
||||
* TX configuration of the synth;
|
||||
* valid only from READY */
|
||||
CMD_SABORT = COMMAND_SABORT, /* Force exit form TX or RX states
|
||||
* and go to READY state; valid
|
||||
* only from TX or RX */
|
||||
CMD_LDC_RELOAD = COMMAND_LDC_RELOAD, /* LDC Mode: Reload the LDC
|
||||
* timer with the value stored
|
||||
* in the LDC_PRESCALER /
|
||||
* COUNTER registers; valid
|
||||
* from all states */
|
||||
CMD_SEQUENCE_UPDATE = COMMAND_SEQUENCE_UPDATE,
|
||||
/* Autoretransmission: Reload the
|
||||
* Packet sequence counter with the
|
||||
* value stored in the PROTOCOL[2]
|
||||
* register valid from all states */
|
||||
CMD_AES_ENC = COMMAND_AES_ENC, /* Commands: Start the encryption
|
||||
* routine; valid from all states;
|
||||
* valid from all states */
|
||||
CMD_AES_KEY = COMMAND_AES_KEY, /* Commands: Start the procedure
|
||||
* to compute the key for the
|
||||
* decryption; valid from all states */
|
||||
CMD_AES_DEC = COMMAND_AES_DEC, /* Commands: Start the decryption
|
||||
* routine using the current key;
|
||||
* valid from all states */
|
||||
CMD_AES_KEY_DEC = COMMAND_AES_KEY_DEC, /* Commands: Compute the key and
|
||||
* start the decryption; valid
|
||||
* from all states */
|
||||
CMD_SRES = COMMAND_SRES, /* Reset of all digital part,
|
||||
* xcept SPI registers */
|
||||
CMD_FLUSHRXFIFO = COMMAND_FLUSHRXFIFO, /* Clean the RX FIFO; valid from
|
||||
* all states */
|
||||
CMD_FLUSHTXFIFO = COMMAND_FLUSHTXFIFO, /* Clean the TX FIFO; valid from
|
||||
* all states */
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* Public Function Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_COMMANDS_H */
|
||||
46
drivers/wireless/spirit/include/spirit_config.h
Normal file
46
drivers/wireless/spirit/include/spirit_config.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/******************************************************************************
|
||||
* include/nuttx/wireless/spirit/spirit_config.h
|
||||
* Spirit Configuration and useful defines
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_CONFIG_H
|
||||
#define __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_CONFIG_H
|
||||
|
||||
/******************************************************************************
|
||||
* Included Files
|
||||
******************************************************************************/
|
||||
|
||||
#define DOUBLE_XTAL_THR 30000000
|
||||
|
||||
#endif /* __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_CONFIG_H */
|
||||
135
drivers/wireless/spirit/include/spirit_general.h
Normal file
135
drivers/wireless/spirit/include/spirit_general.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/******************************************************************************
|
||||
* include/nuttx/wireless/spirit/spirit_general.h
|
||||
* Configuration and management of SPIRIT General functionalities.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_GENERAL_H
|
||||
#define __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_GENERAL_H
|
||||
|
||||
/******************************************************************************
|
||||
* Included Files
|
||||
******************************************************************************/
|
||||
|
||||
#include "spirit_types.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Macros used in debug assertions */
|
||||
|
||||
#define IS_MODE_EXT(mode) (mode == MODE_EXT_XO || mode == MODE_EXT_XIN)
|
||||
#define IS_BLD_LVL(level) (level == BLD_LVL_2_7_V || level == BLD_LVL_2_5_V || \
|
||||
level == BLD_LVL_2_3_V || level == BLD_LVL_2_1_V)
|
||||
#define IS_GM_CONF(mode) (mode == GM_SU_13_2 || mode == GM_SU_18_2 || \
|
||||
mode == GM_SU_21_5 || mode == GM_SU_25_6 || \
|
||||
mode == GM_SU_28_8 || mode == GM_SU_33_9 || \
|
||||
mode == GM_SU_38_5 || mode == GM_SU_43_0)
|
||||
#define IS_PKT_TYPE(type) (type == PKT_BASIC || type == PKT_MBUS || \
|
||||
type == PKT_STACK)
|
||||
|
||||
/******************************************************************************
|
||||
* Public Types
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* SPIRIT Mode external reference enumeration */
|
||||
|
||||
enum mode_extref_e
|
||||
{
|
||||
MODE_EXT_XO = 0,
|
||||
MODE_EXT_XIN = !MODE_EXT_XO
|
||||
};
|
||||
|
||||
/* SPIRIT Battery level enumeration */
|
||||
|
||||
enum battery_level_e
|
||||
{
|
||||
BLD_LVL_2_7_V = 0,
|
||||
BLD_LVL_2_5_V = 1,
|
||||
BLD_LVL_2_3_V = 2,
|
||||
BLD_LVL_2_1_V = 3
|
||||
};
|
||||
|
||||
/* SPIRIT GM conf enumeration */
|
||||
|
||||
enum gm_conf_e
|
||||
{
|
||||
GM_SU_13_2 = 0,
|
||||
GM_SU_18_2,
|
||||
GM_SU_21_5,
|
||||
GM_SU_25_6,
|
||||
GM_SU_28_8,
|
||||
GM_SU_33_9,
|
||||
GM_SU_38_5,
|
||||
GM_SU_43_0
|
||||
};
|
||||
|
||||
/* SPIRIT packet type enumeration */
|
||||
|
||||
enum packet_type_e
|
||||
{
|
||||
PKT_BASIC = 0x00,
|
||||
PKT_MBUS = 0x02,
|
||||
PKT_STACK
|
||||
};
|
||||
|
||||
/* SPIRIT version type enumeration */
|
||||
|
||||
enum spirit_version_e
|
||||
{
|
||||
SPIRIT_VERSION_2_1 = 0x01, /* Deprecated */
|
||||
SPIRIT_VERSION_3_0, /* The only version of SPIRIT1 */
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* Public Function Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Input parameters:
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#endif /* __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_GENERAL_H */
|
||||
238
drivers/wireless/spirit/include/spirit_gpio.h
Normal file
238
drivers/wireless/spirit/include/spirit_gpio.h
Normal file
@@ -0,0 +1,238 @@
|
||||
/******************************************************************************
|
||||
* include/nuttx/wireless/spirit/spirit_gpio.h
|
||||
* This file provides all the low level API to manage SPIRIT GPIO.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_GPIO_H
|
||||
#define __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_GPIO_H
|
||||
|
||||
/******************************************************************************
|
||||
* Included Files
|
||||
******************************************************************************/
|
||||
|
||||
#include "spirit_regs.h"
|
||||
#include "spirit_types.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Macros used in debug assertions */
|
||||
|
||||
#define IS_SPIRIT_GPIO(pin) \
|
||||
((pin == SPIRIT_GPIO_0) || (pin == SPIRIT_GPIO_1) || \
|
||||
(pin == SPIRIT_GPIO_2) || (pin == SPIRIT_GPIO_3))
|
||||
#define IS_SPIRIT_GPIO_MODE(mode) \
|
||||
((mode == SPIRIT_GPIO_MODE_DIGITAL_INPUT) || \
|
||||
(mode == SPIRIT_GPIO_MODE_DIGITAL_OUTPUT_LP) || \
|
||||
(mode == SPIRIT_GPIO_MODE_DIGITAL_OUTPUT_HP))
|
||||
#define IS_SPIRIT_GPIO_IO(iosel) \
|
||||
((iosel == SPIRIT_GPIO_DIG_OUT_IRQ) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_POR_INV) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_WUT_EXP) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_LBD) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_TX_DATA) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_TX_STATE) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_TX_FIFO_ALMOST_EMPTY) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_TX_FIFO_ALMOST_FULL) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_RX_DATA) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_RX_CLOCK) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_RX_STATE) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_RX_FIFO_ALMOST_FULL) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_RX_FIFO_ALMOST_EMPTY) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_ANTENNA_SWITCH) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_VALID_PREAMBLE) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_SYNC_DETECTED) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_RSSI_THRESHOLD) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_MCU_CLOCK) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_TX_RX_MODE) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_VDD) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_GND) || \
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_SMPS_EXT) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_SLEEP_OR_STANDBY) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_READY) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_LOCK) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_WAIT_FOR_LOCK_SIG) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_WAIT_FOR_TIMER_FOR_LOCK) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_WAIT_FOR_READY2_SIG) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_WAIT_FOR_TIMER_FOR_PM_SET) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_WAIT_VCO_CALIBRATION) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_ENABLE_SYNTH_FULL_CIRCUIT) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_OUT_WAIT_FOR_RCCAL_OK_SIG) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_IN_TX_COMMAND) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_IN_RX_COMMAND) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_IN_TX_DATA_INPUT_FOR_DIRECTRF) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_IN_DATA_WAKEUP) ||\
|
||||
(iosel == SPIRIT_GPIO_DIG_IN_EXT_CLOCK_AT_34_7KHZ))
|
||||
|
||||
/******************************************************************************
|
||||
* Public Types
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* SPIRIT GPIO pin enumeration. */
|
||||
|
||||
enum spirit_gpio_pin_e
|
||||
{
|
||||
SPIRIT_GPIO_0 = GPIO0_CONF_BASE, /* GPIO_0 selected */
|
||||
SPIRIT_GPIO_1 = GPIO1_CONF_BASE, /* GPIO_1 selected */
|
||||
SPIRIT_GPIO_2 = GPIO2_CONF_BASE, /* GPIO_2 selected */
|
||||
SPIRIT_GPIO_3 = GPIO3_CONF_BASE /* GPIO_3 selected */
|
||||
};
|
||||
|
||||
/* SPIRIT GPIO mode enumeration. */
|
||||
|
||||
enum spirit_gpio_mode_e
|
||||
{
|
||||
SPIRIT_GPIO_MODE_DIGITAL_INPUT = 0x01, /* Digital Input on GPIO */
|
||||
SPIRIT_GPIO_MODE_DIGITAL_OUTPUT_LP = 0x02, /* Digital Output on GPIO
|
||||
* (low current) */
|
||||
SPIRIT_GPIO_MODE_DIGITAL_OUTPUT_HP = 0x03 /* Digital Output on GPIO
|
||||
* (high current) */
|
||||
};
|
||||
|
||||
/* SPIRIT I/O selection enumeration. */
|
||||
|
||||
enum spirit_gpio_io_e
|
||||
{
|
||||
SPIRIT_GPIO_DIG_OUT_IRQ = 0x00, /* nIRQ (Interrupt Request,
|
||||
* active low) , default
|
||||
* configuration after POR */
|
||||
SPIRIT_GPIO_DIG_OUT_POR_INV = 0x08, /* POR inverted (active low) */
|
||||
SPIRIT_GPIO_DIG_OUT_WUT_EXP = 0x10, /* Wake-Up Timer expiration:
|
||||
* "1" when WUT has expired */
|
||||
SPIRIT_GPIO_DIG_OUT_LBD = 0x18, /* Low battery detection: "1"
|
||||
* when battery is below
|
||||
* threshold setting */
|
||||
SPIRIT_GPIO_DIG_OUT_TX_DATA = 0x20, /* TX data internal clock
|
||||
* output (TX data are sampled
|
||||
* on the rising edge of it) */
|
||||
SPIRIT_GPIO_DIG_OUT_TX_STATE = 0x28, /* TX state indication: "1"
|
||||
* when Spirit1 is passing in
|
||||
* the TX state */
|
||||
SPIRIT_GPIO_DIG_OUT_TX_FIFO_ALMOST_EMPTY = 0x30, /* TX FIFO Almost Empty Flag */
|
||||
SPIRIT_GPIO_DIG_OUT_TX_FIFO_ALMOST_FULL = 0x38, /* TX FIFO Almost Full Flag */
|
||||
SPIRIT_GPIO_DIG_OUT_RX_DATA = 0x40, /* RX data output */
|
||||
SPIRIT_GPIO_DIG_OUT_RX_CLOCK = 0x48, /* RX clock output
|
||||
* (recovered from received
|
||||
* data) */
|
||||
SPIRIT_GPIO_DIG_OUT_RX_STATE = 0x50, /* RX state indication: "1"
|
||||
* when Spirit1 is passing in
|
||||
* the RX state */
|
||||
SPIRIT_GPIO_DIG_OUT_RX_FIFO_ALMOST_FULL = 0x58, /* RX FIFO Almost Full Flag */
|
||||
SPIRIT_GPIO_DIG_OUT_RX_FIFO_ALMOST_EMPTY = 0x60, /* RX FIFO Almost Empty Flag */
|
||||
SPIRIT_GPIO_DIG_OUT_ANTENNA_SWITCH = 0x68, /* Antenna switch used for
|
||||
* antenna diversity */
|
||||
SPIRIT_GPIO_DIG_OUT_VALID_PREAMBLE = 0x70, /* Valid Preamble Detected Flag */
|
||||
SPIRIT_GPIO_DIG_OUT_SYNC_DETECTED = 0x78, /* Sync WordSync Word Detected
|
||||
* Flag */
|
||||
SPIRIT_GPIO_DIG_OUT_RSSI_THRESHOLD = 0x80, /* RSSI above threshold */
|
||||
SPIRIT_GPIO_DIG_OUT_MCU_CLOCK = 0x88, /* MCU Clock */
|
||||
SPIRIT_GPIO_DIG_OUT_TX_RX_MODE = 0x90, /* TX or RX mode indicator
|
||||
* (to enable an external range
|
||||
* extender) */
|
||||
SPIRIT_GPIO_DIG_OUT_VDD = 0x98, /* VDD (to emulate an additional
|
||||
* GPIO of the MCU, programmable
|
||||
* by SPI) */
|
||||
SPIRIT_GPIO_DIG_OUT_GND = 0xa0, /* GND (to emulate an additional
|
||||
* GPIO of the MCU, programmable
|
||||
* by SPI) */
|
||||
SPIRIT_GPIO_DIG_OUT_SMPS_EXT = 0xa8, /* External SMPS enable
|
||||
* signal (active high) */
|
||||
|
||||
SPIRIT_GPIO_DIG_OUT_SLEEP_OR_STANDBY = 0xb0,
|
||||
SPIRIT_GPIO_DIG_OUT_READY = 0xb8,
|
||||
SPIRIT_GPIO_DIG_OUT_LOCK = 0xc0,
|
||||
SPIRIT_GPIO_DIG_OUT_WAIT_FOR_LOCK_SIG = 0xc8,
|
||||
SPIRIT_GPIO_DIG_OUT_WAIT_FOR_TIMER_FOR_LOCK = 0xd0,
|
||||
SPIRIT_GPIO_DIG_OUT_WAIT_FOR_READY2_SIG = 0xd8,
|
||||
SPIRIT_GPIO_DIG_OUT_WAIT_FOR_TIMER_FOR_PM_SET = 0xe0,
|
||||
SPIRIT_GPIO_DIG_OUT_WAIT_VCO_CALIBRATION = 0xe8,
|
||||
SPIRIT_GPIO_DIG_OUT_ENABLE_SYNTH_FULL_CIRCUIT = 0xf0,
|
||||
SPIRIT_GPIO_DIG_OUT_WAIT_FOR_RCCAL_OK_SIG = 0xff,
|
||||
|
||||
SPIRIT_GPIO_DIG_IN_TX_COMMAND = 0x00,
|
||||
SPIRIT_GPIO_DIG_IN_RX_COMMAND = 0x08,
|
||||
SPIRIT_GPIO_DIG_IN_TX_DATA_INPUT_FOR_DIRECTRF = 0x10,
|
||||
SPIRIT_GPIO_DIG_IN_DATA_WAKEUP = 0x18,
|
||||
SPIRIT_GPIO_DIG_IN_EXT_CLOCK_AT_34_7KHZ = 0x20
|
||||
};
|
||||
|
||||
/* SPIRIT GPIO Init structure definition. */
|
||||
|
||||
struct spirit_gpio_init_s
|
||||
{
|
||||
enum spirit_gpio_pin_e gpiopin; /* Specifies the GPIO pins to be
|
||||
* configured. This parameter can be
|
||||
* any value of enum spirit_gpio_pin_e */
|
||||
enum spirit_gpio_mode_e gpiomode; /* Specifies the operating mode for
|
||||
* the selected pins. This parameter
|
||||
* can be a value of enum
|
||||
* spirit_gpio_mode_e */
|
||||
enum spirit_gpio_io_e gpioio; /* Specifies the I/O selection for
|
||||
* the selected pins. This parameter
|
||||
* can be a value of enum spirit_gpio_io_e */
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* Public Function Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name:
|
||||
*
|
||||
* Description:
|
||||
* Initializes the Spirit GPIOx according to the specified parameters in
|
||||
* the gpioinit parameter.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* gpioinit - A pointer to a struct spirit_gpio_init_s structure that
|
||||
* contains the configuration information for the specified
|
||||
* SPIRIT GPIO.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_gpio_initialize(FAR struct spirit_library_s *spirit,
|
||||
FAR const struct spirit_gpio_init_s *gpioinit);
|
||||
|
||||
#endif /* __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_GPIO_H*/
|
||||
455
drivers/wireless/spirit/include/spirit_irq.h
Normal file
455
drivers/wireless/spirit/include/spirit_irq.h
Normal file
@@ -0,0 +1,455 @@
|
||||
/******************************************************************************
|
||||
* include/nuttx/wireless/spirit/spirit_irq.h
|
||||
* Configuration and management of SPIRIT IRQs.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_IRQ_H
|
||||
#define __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_IRQ_H
|
||||
|
||||
/* On the Spirit side specific IRQs can be enabled by setting a specific bitmask.
|
||||
* The Spirit libraries allow the user to do this in two different ways:
|
||||
*
|
||||
* The first enables the IRQs one by one, i.e. using an SPI transaction for each
|
||||
* IRQ to enable.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* spirit_irq_disableall(spirit); # this call is used to reset the IRQ mask registers
|
||||
* spirit_irq_enable(spirit, RX_DATA_READY , S_ENABLE);
|
||||
* spirit_irq_enable(spirit, VALID_SYNC , S_ENABLE);
|
||||
* spirit_irq_enable(spirit, RX_TIMEOUT , S_ENABLE);
|
||||
*
|
||||
* The most applications will require a Spirit IRQ notification on an
|
||||
* microcontroller EXTI line. Then, the user can check which IRQ has been
|
||||
* raised using two different ways.
|
||||
*
|
||||
* On the ISR of the EXTI line phisically linked to the Spirit pin
|
||||
* configured for IRQ:
|
||||
*
|
||||
* Check only one Spirit IRQ (because the Spirit IRQ status register
|
||||
* automatically blanks itself after an SPI reading) into the ISR.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* if (spirit_irq_is_pending(RX_DATA_READY))
|
||||
* {
|
||||
* # do something...
|
||||
* }
|
||||
*
|
||||
* Check more than one Spirit IRQ status by storing the entire IRQ status
|
||||
* registers into a bitfields struct spirit_irqset_s structure and then
|
||||
* check the interesting bits.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* spirit_irq_get_pending(&irqStatus);
|
||||
*
|
||||
* if (irqStatus.IRQ_RX_DATA_READY)
|
||||
* {
|
||||
* # do something...
|
||||
* }
|
||||
*
|
||||
* if (irqStatus.IRQ_VALID_SYNC)
|
||||
* {
|
||||
* # do something...
|
||||
* }
|
||||
*
|
||||
* if (irqStatus.RX_TIMEOUT)
|
||||
* {
|
||||
* # do something...
|
||||
* }
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Included Files
|
||||
******************************************************************************/
|
||||
|
||||
#include "spirit_types.h"
|
||||
#include "spirit_regs.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* uint32_t masks */
|
||||
|
||||
#define IRQ_TX_FIFO_ALMOST_EMPTY_MASK (0x00010000) /* (1 << 16) */
|
||||
#define IRQ_RX_FIFO_ALMOST_FULL_MASK (0x00020000) /* (1 << 17) */
|
||||
#define IRQ_VALID_SYNC_MASK (0x00200000) /* (1 << 21) */
|
||||
#define IRQ_RX_DATA_READY_MASK (0x01000000) /* (1 << 24) */
|
||||
#define IRQ_RX_DATA_DISC_MASK (0x02000000) /* (1 << 25) */
|
||||
#define IRQ_TX_DATA_SENT_MASK (0x04000000) /* (1 << 26) */
|
||||
#define IRQ_TX_FIFO_ERROR_MASK (0x20000000) /* (1 << 29) */
|
||||
#define IRQ_RX_FIFO_ERROR_MASK (0x40000000) /* (1 << 30) */
|
||||
|
||||
/* Macros used in assertions */
|
||||
|
||||
#define IS_SPIRIT_IRQ_LIST(value) \
|
||||
((value == RX_DATA_READY) || (value == RX_DATA_DISC) || \
|
||||
(value == TX_DATA_SENT) || (value == MAX_RE_TX_REACH) || \
|
||||
(value == CRC_ERROR) || (value == TX_FIFO_ERROR) || \
|
||||
(value == RX_FIFO_ERROR) || (value == TX_FIFO_ALMOST_FULL) || \
|
||||
(value == TX_FIFO_ALMOST_EMPTY) || (value == RX_FIFO_ALMOST_FULL) || \
|
||||
(value == RX_FIFO_ALMOST_EMPTY) || (value == MAX_BO_CCA_REACH) || \
|
||||
(value == VALID_PREAMBLE) || (value == VALID_SYNC) || \
|
||||
(value == RSSI_ABOVE_TH) || (value == WKUP_TOUT_LDC) || \
|
||||
(value == READY) || (value == STANDBY_DELAYED) || \
|
||||
(value == LOW_BATT_LVL) || (value == POR) || \
|
||||
(value == BOR) || (value == LOCK) || \
|
||||
(value == PM_COUNT_EXPIRED) || (value == XO_COUNT_EXPIRED) || \
|
||||
(value == SYNTH_LOCK_TIMEOUT) || (value == SYNTH_LOCK_STARTUP) || \
|
||||
(value == SYNTH_CAL_TIMEOUT) || (value == TX_START_TIME) || \
|
||||
(value == RX_START_TIME) || (value == RX_TIMEOUT) || \
|
||||
(value == AES_END) || (value == ALL_IRQ ))
|
||||
|
||||
/******************************************************************************
|
||||
* Public Types
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* IRQ bitfield structure for SPIRIT. This structure is used to read or write
|
||||
* the single IRQ bit. During the initialization the user has to fill this
|
||||
* structure setting to one the single field related to the IRQ he wants to
|
||||
* enable, and to zero the single field related to all the IRQs he wants to
|
||||
* disable.
|
||||
*
|
||||
* The same structure can be used to retrieve all the IRQ events from the IRQ
|
||||
* registers IRQ_STATUS[3:0], and read if one or more specific IRQ raised.
|
||||
*
|
||||
* NOTE: The fields order in the structure depends on used endianness (little
|
||||
* or big endian). The actual definition is valid ONLY for LITTLE ENDIAN
|
||||
* mode. Be sure to change the field order when use a different endianness.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_ENDIAN_BIG
|
||||
struct spirit_irqset_s
|
||||
{
|
||||
uint8_t IRQ_SYNTH_LOCK_TIMEOUT : 1; /* IRQ: only for debug; LOCK state
|
||||
* timeout */
|
||||
uint8_t IRQ_SYNTH_LOCK_STARTUP : 1; /* IRQ: only for debug; see
|
||||
* CALIBR_START_COUNTER */
|
||||
uint8_t IRQ_SYNTH_CAL_TIMEOUT : 1; /* IRQ: only for debug; SYNTH
|
||||
* calibration timeout */
|
||||
uint8_t IRQ_TX_START_TIME : 1; /* IRQ: only for debug; TX
|
||||
* circuitry startup time; see
|
||||
* TX_START_COUNTER */
|
||||
uint8_t IRQ_RX_START_TIME : 1; /* IRQ: only for debug; RX
|
||||
* circuitry startup time; see
|
||||
* TX_START_COUNTER */
|
||||
uint8_t IRQ_RX_TIMEOUT : 1; /* IRQ: RX operation timeout */
|
||||
uint8_t IRQ_AES_END : 1; /* IRQ: AES End of operation */
|
||||
uint8_t reserved : 1; /* Reserved bit */
|
||||
|
||||
uint8_t IRQ_READY : 1; /* IRQ: READY state */
|
||||
uint8_t IRQ_STANDBY_DELAYED : 1; /* IRQ: STANDBY state after
|
||||
* MCU_CK_CONF_CLOCK_TAIL_X
|
||||
* clock cycles */
|
||||
uint8_t IRQ_LOW_BATT_LVL : 1; /* IRQ: Battery level below
|
||||
* threshold */
|
||||
uint8_t IRQ_POR : 1; /* IRQ: Power On Reset */
|
||||
uint8_t IRQ_BOR : 1; /* IRQ: Brown out event (both
|
||||
* accurate and inaccurate) */
|
||||
uint8_t IRQ_LOCK : 1; /* IRQ: LOCK state */
|
||||
uint8_t IRQ_PM_COUNT_EXPIRED : 1; /* IRQ: only for debug;
|
||||
* Power Management startup
|
||||
* timer expiration (see reg
|
||||
* PM_START_COUNTER, 0xB5) */
|
||||
uint8_t IRQ_XO_COUNT_EXPIRED : 1; /* IRQ: only for debug;
|
||||
* Crystal oscillator settling
|
||||
* time counter expired */
|
||||
|
||||
uint8_t IRQ_TX_FIFO_ALMOST_EMPTY : 1; /* IRQ: TX FIFO almost empty */
|
||||
uint8_t IRQ_RX_FIFO_ALMOST_FULL : 1; /* IRQ: RX FIFO almost full */
|
||||
uint8_t IRQ_RX_FIFO_ALMOST_EMPTY : 1; /* IRQ: RX FIFO almost empty */
|
||||
uint8_t IRQ_MAX_BO_CCA_REACH : 1; /* IRQ: Max number of back-off
|
||||
* during CCA */
|
||||
uint8_t IRQ_VALID_PREAMBLE : 1; /* IRQ: Valid preamble detected */
|
||||
uint8_t IRQ_VALID_SYNC : 1; /* IRQ: Sync word detected */
|
||||
uint8_t IRQ_RSSI_ABOVE_TH : 1; /* IRQ: RSSI above threshold */
|
||||
uint8_t IRQ_WKUP_TOUT_LDC : 1; /* IRQ: Wake-up timeout in LDC mode */
|
||||
|
||||
uint8_t IRQ_RX_DATA_READY : 1; /* IRQ: RX data ready */
|
||||
uint8_t IRQ_RX_DATA_DISC : 1; /* IRQ: RX data discarded
|
||||
* (upon filtering) */
|
||||
uint8_t IRQ_TX_DATA_SENT : 1; /* IRQ: TX data sent */
|
||||
uint8_t IRQ_MAX_RE_TX_REACH : 1; /* IRQ: Max re-TX reached */
|
||||
uint8_t IRQ_CRC_ERROR : 1; /* IRQ: CRC error */
|
||||
uint8_t IRQ_TX_FIFO_ERROR : 1; /* IRQ: TX FIFO underflow/overflow
|
||||
* error */
|
||||
uint8_t IRQ_RX_FIFO_ERROR : 1; /* IRQ: RX FIFO underflow/overflow
|
||||
* error */
|
||||
uint8_t IRQ_TX_FIFO_ALMOST_FULL : 1; /* IRQ: TX FIFO almost full */
|
||||
};
|
||||
#endif
|
||||
|
||||
/* IRQ list enumeration for SPIRIT. This enumeration type can be used to
|
||||
* address a specific IRQ.
|
||||
*/
|
||||
|
||||
enum spirit_irq_e
|
||||
{
|
||||
RX_DATA_READY = 0x00000001, /* IRQ: RX data ready */
|
||||
RX_DATA_DISC = 0x00000002, /* IRQ: RX data discarded (upon
|
||||
* filtering) */
|
||||
TX_DATA_SENT = 0x00000004, /* IRQ: TX data sent */
|
||||
MAX_RE_TX_REACH = 0x00000008, /* IRQ: Max re-TX reached */
|
||||
CRC_ERROR = 0x00000010, /* IRQ: CRC error */
|
||||
TX_FIFO_ERROR = 0x00000020, /* IRQ: TX FIFO underflow/overflow
|
||||
* error */
|
||||
RX_FIFO_ERROR = 0x00000040, /* IRQ: RX FIFO underflow/overflow
|
||||
* error */
|
||||
TX_FIFO_ALMOST_FULL = 0x00000080, /* IRQ: TX FIFO almost full */
|
||||
TX_FIFO_ALMOST_EMPTY = 0x00000100, /* IRQ: TX FIFO almost empty */
|
||||
RX_FIFO_ALMOST_FULL = 0x00000200, /* IRQ: RX FIFO almost full */
|
||||
RX_FIFO_ALMOST_EMPTY = 0x00000400, /* IRQ: RX FIFO almost empty */
|
||||
MAX_BO_CCA_REACH = 0x00000800, /* IRQ: Max number of back-off
|
||||
* during CCA */
|
||||
VALID_PREAMBLE = 0x00001000, /* IRQ: Valid preamble detected */
|
||||
VALID_SYNC = 0x00002000, /* IRQ: Sync word detected */
|
||||
RSSI_ABOVE_TH = 0x00004000, /* IRQ: RSSI above threshold */
|
||||
WKUP_TOUT_LDC = 0x00008000, /* IRQ: Wake-up timeout in LDC mode */
|
||||
READY = 0x00010000, /* IRQ: READY state */
|
||||
STANDBY_DELAYED = 0x00020000, /* IRQ: STANDBY state after
|
||||
* MCU_CK_CONF_CLOCK_TAIL_X clock
|
||||
* cycles */
|
||||
LOW_BATT_LVL = 0x00040000, /* IRQ: Battery level below
|
||||
* threshold */
|
||||
POR = 0x00080000, /* IRQ: Power On Reset */
|
||||
BOR = 0x00100000, /* IRQ: Brown out event (both accurate and
|
||||
* inaccurate) */
|
||||
LOCK = 0x00200000, /* IRQ: LOCK state */
|
||||
PM_COUNT_EXPIRED = 0x00400000, /* IRQ: only for debug; Power
|
||||
* Management startup timer expiration
|
||||
* (see reg PM_START_COUNTER, 0xB5) */
|
||||
XO_COUNT_EXPIRED = 0x00800000, /* IRQ: only for debug; Crystal
|
||||
* oscillator settling time counter
|
||||
* expired */
|
||||
SYNTH_LOCK_TIMEOUT = 0x01000000, /* IRQ: only for debug; LOCK state
|
||||
* timeout */
|
||||
SYNTH_LOCK_STARTUP = 0x02000000, /* IRQ: only for debug; see
|
||||
* CALIBR_START_COUNTER */
|
||||
SYNTH_CAL_TIMEOUT = 0x04000000, /* IRQ: only for debug; SYNTH
|
||||
* calibration timeout */
|
||||
TX_START_TIME = 0x08000000, /* IRQ: only for debug; TX circuitry
|
||||
* startup time; see TX_START_COUNTER */
|
||||
RX_START_TIME = 0x10000000, /* IRQ: only for debug; RX circuitry
|
||||
* startup time; see TX_START_COUNTER */
|
||||
RX_TIMEOUT = 0x20000000, /* IRQ: RX operation timeout */
|
||||
AES_END = 0x40000000, /* IRQ: AES End of operation */
|
||||
ALL_IRQ = 0x7fffffff /* All the above mentioned IRQs */
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* Public Function Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irq_disable_all
|
||||
*
|
||||
* Description:
|
||||
* Ssets the IRQ mask registers to 0x00000000, disabling all IRQs.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_irq_disable_all(FAR struct spirit_library_s *spirit);
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irq_set_mask
|
||||
*
|
||||
* Description:
|
||||
* Enables/disables all the IRQs according to the user defined irqset
|
||||
* structure.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* irqset - Pointer to a variable of type struct spirit_irqset_s, through
|
||||
* which the user enable specific IRQs. This parameter is a
|
||||
* pointer to a struct spirit_irqset_s.
|
||||
*
|
||||
* For example suppose to enable only the two IRQ Low Battery Level
|
||||
* and Tx Data Sent:
|
||||
*
|
||||
* struct spirit_irqset_s g_irqset = {0};
|
||||
* g_irqset.IRQ_LOW_BATT_LVL = 1;
|
||||
* g_irqset.IRQ_TX_DATA_SENT = 1;
|
||||
* spirit_irq_setmask(&g_irqset);
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ENDIAN_BIG
|
||||
int spirit_irq_set_mask(FAR struct spirit_library_s *spirit,
|
||||
FAR struct spirit_irqset_s *irqset);
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irq_enable
|
||||
*
|
||||
* Description:
|
||||
* Enables or disables a specific IRQ.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* irq IRQ to enable or disable.
|
||||
* newstate - new state for the IRQ.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_irq_enable(FAR struct spirit_library_s *spirit,
|
||||
enum spirit_irq_e irq,
|
||||
enum spirit_functional_state_e newstate);
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irt_get_mask
|
||||
*
|
||||
* Description:
|
||||
* Fills a pointer to a structure of struct spirit_irqset_s type with the
|
||||
* content of the IRQ_MASK registers.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* pirqmask - Pointer to a variable of type struct spirit_irqset_s, through
|
||||
* which the user can read which IRQs are enabled. All the
|
||||
* bitfields equals to zero correspond to enabled IRQs, while
|
||||
* all the bitfields equals to one correspond to disabled IRQs.
|
||||
*
|
||||
* For example suppose that the Power On Reset and RX Data
|
||||
* ready are the only enabled IRQs.
|
||||
*
|
||||
* struct spirit_irqset_s g_irqmask;
|
||||
* spirit_irq_get_pending(&g_irqmask);
|
||||
*
|
||||
* Then g_irqmask.IRQ_POR and g_irqmask.IRQ_RX_DATA_READY are
|
||||
* equal to 0 while all the other bitfields are equal to one.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ENDIAN_BIG
|
||||
int spirit_irt_get_mask(FAR struct spirit_library_s *spirit,
|
||||
FAR struct spirit_irqset_s *pirqmask);
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irq_get_pending
|
||||
*
|
||||
* Description:
|
||||
* Fills a pointer to a structure of struct spirit_irqset_s type with the
|
||||
* content of the IRQ_STATUS registers.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* pirqstatus - A pointer to a variable of type struct spirit_irqset_s,
|
||||
* through which the user can receive the status of all the
|
||||
* IRQs. All the bitfields equals to one correspond to the
|
||||
* raised interrupts.
|
||||
*
|
||||
* For example suppose that the XO settling timeout is raised
|
||||
* as well as the Sync word detection.
|
||||
*
|
||||
* struct spirit_irqset_s g_irqstatus;
|
||||
* spirit_irq_get_pending(&g_irqstatus);
|
||||
*
|
||||
* Then g_irqstatus.IRQ_XO_COUNT_EXPIRED and
|
||||
* g_irqstatus.IRQ_VALID_SYNC are equals to 1* while all the
|
||||
* other bitfields are equals to zero.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ENDIAN_BIG
|
||||
int spirit_irq_get_pending(FAR struct spirit_library_s *spirit,
|
||||
FAR struct spirit_irqset_s *pirqstatus);
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irq_clr_pending
|
||||
*
|
||||
* Description:
|
||||
* Clear the IRQ status registers.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_irq_clr_pending(FAR struct spirit_library_s *spirit);
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irq_is_pending
|
||||
*
|
||||
* Description:
|
||||
* Checks if a specific IRQ has been generated. The call resets all the
|
||||
* IRQ status, so it can't be used in case of multiple raising interrupts.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* flag IRQ flag to be checked.
|
||||
* This parameter can be any value of enum spirit_irq_e.
|
||||
*
|
||||
* Returned Value:
|
||||
* true or false.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
bool spirit_irq_is_pending(FAR struct spirit_library_s *spirit,
|
||||
enum spirit_irq_e flag);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_IRQ_H */
|
||||
79
drivers/wireless/spirit/include/spirit_management.h
Normal file
79
drivers/wireless/spirit/include/spirit_management.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/******************************************************************************
|
||||
* include/nuttx/wireless/spirit/spirit_management.h
|
||||
* The management layer for SPIRIT1 library.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_MANAGEMENT_H
|
||||
#define __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_MANAGEMENT_H
|
||||
|
||||
/******************************************************************************
|
||||
* Included Files
|
||||
******************************************************************************/
|
||||
|
||||
#include "spirit_config.h"
|
||||
#include "spirit_types.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Macros used in assertions */
|
||||
|
||||
/******************************************************************************
|
||||
* Public Types
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Public Function Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_management_initcommstate
|
||||
*
|
||||
* Description:
|
||||
* Initialize communication state
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* frequency - Desired communication frequency
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
void spirit_management_initcommstate(FAR struct spirit_library_s *spirit,
|
||||
uint32_t frequency);
|
||||
|
||||
#endif /* __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_MANAGEMENT_H */
|
||||
209
drivers/wireless/spirit/include/spirit_pktbasic.h
Normal file
209
drivers/wireless/spirit/include/spirit_pktbasic.h
Normal file
@@ -0,0 +1,209 @@
|
||||
/******************************************************************************
|
||||
* include/nuttx/wireless/spirit/spirit_pktbasic.h
|
||||
* Configuration and management of SPIRIT Basic packets.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_PKTBASIC_H
|
||||
#define __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_PKTBASIC_H
|
||||
|
||||
/* This module can be used to manage the configuration of Spirit Basic
|
||||
* packets. The user can obtain a packet configuration filling the
|
||||
* structure struct pktbasic_init_s, defining in it some general
|
||||
* parameters for the Spirit Basic packet format. Another structure
|
||||
* the user can fill is struct struct pktbasic_addr_s to define the
|
||||
* addresses which will be used during the communication. Moreover,
|
||||
* functions to set the payload length and the destination address
|
||||
* are provided.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* struct pktbasic_init_s g_pkbasic_init =
|
||||
* {
|
||||
* PKT_PREAMBLE_LENGTH_08BYTES, # preamble length in bytes
|
||||
* PKT_SYNC_LENGTH_4BYTES, # sync word length in bytes
|
||||
* 0x1A2635A8, # sync word
|
||||
* PKT_LENGTH_VAR, # variable or fixed payload length
|
||||
* 7, # length field width in bits (used only for variable length)
|
||||
* PKT_NO_CRC, # CRC mode
|
||||
* PKT_CONTROL_LENGTH_0BYTES, # control field length
|
||||
* S_ENABLE, # address field
|
||||
* S_DISABLE, # FEC
|
||||
* S_ENABLE # whitening
|
||||
* };
|
||||
*
|
||||
* struct struct pktbasic_addr_s g_addrinit =
|
||||
* {
|
||||
* S_ENABLE, # enable/disable filtering on my address
|
||||
* 0x34, # my address (address of the current node)
|
||||
* S_DISABLE, # enable/disable filtering on multicast address
|
||||
* 0xEE, # multicast address
|
||||
* S_DISABLE, # enable/disable filtering on broadcast address
|
||||
* 0xFF # broadcast address
|
||||
* };
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* spirit_pktbasic_initialize(spirit, &g_pkbasic_init);
|
||||
* spirit_pktbasic_addrinit(spirit, &g_addrinit);
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* SpiritPktBasicSetPayloadLength(spirit, 20);
|
||||
* SpiritPktBasicSetDestinationAddress(spirit, 0x44);
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* The module provides some other functions that can be used to modify or
|
||||
* read only some configuration parameters.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Included Files
|
||||
******************************************************************************/
|
||||
|
||||
#include "spirit_types.h"
|
||||
#include "spirit_pktcommon.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Macros used in assertions */
|
||||
|
||||
/******************************************************************************
|
||||
* Public Types
|
||||
******************************************************************************/
|
||||
|
||||
/* SPIRIT Basic Packet Init structure definition. This structure allows
|
||||
* users to set the main options for the Basic packet.
|
||||
*/
|
||||
|
||||
struct pktbasic_init_s
|
||||
{
|
||||
uint32_t syncwords; /* Specifies the sync words. This parameter is
|
||||
* a uint32_t word with format:
|
||||
* 0x|SYNC1|SYNC2|SYNC3|SYNC4 */
|
||||
uint8_t premblen; /* Specifies the preamble length. This parameter
|
||||
* can be any value from enum pkt_premblen_e */
|
||||
uint8_t synclen; /* Specifies the sync word length. The 32bit
|
||||
* word passed (syncwords) will be stored in
|
||||
* the SYNCx registers from the MSB until the
|
||||
* number of bytes in synclen has been stored.
|
||||
* This parameter can be any value of enum
|
||||
* pkt_synlen_e */
|
||||
uint8_t fixedvarlen; /* Specifies if a fixed length of packet has to
|
||||
* be used. This parameter can be any value of
|
||||
* enum pkt_fixvar_len_e */
|
||||
uint8_t pktlenwidth; /* Specifies the size of the length of packet
|
||||
* in bits. This field is useful only if the
|
||||
* field fixedvarlen is set to BASIC_LENGTH_VAR.
|
||||
* For Basic packets the length width is
|
||||
* log2(max payload length + control length
|
||||
* (0 to 4) + address length (0 or 1)). */
|
||||
uint8_t crcmode; /* Specifies the CRC word length of packet.
|
||||
* This parameter can be any value of enum
|
||||
* pkt_crcmode_e */
|
||||
uint8_t ctrllen; /* Specifies the length of a control field to
|
||||
* be sent. This parameter can be any value
|
||||
* from enum pkt_ctrllen_e */
|
||||
uint8_t txdestaddr; /* Specifies if the destination address has to
|
||||
* be sent. This parameter can be S_ENABLE or
|
||||
* S_DISABLE */
|
||||
uint8_t fec; /* Specifies if FEC has to be enabled. This
|
||||
* parameter can be S_ENABLE or S_DISABLE */
|
||||
uint8_t datawhite; /* Specifies if data whitening has to be
|
||||
* enabled. This parameter can be S_ENABLE or
|
||||
* S_DISABLE */
|
||||
};
|
||||
|
||||
/* SPIRIT Basic Packet address structure definition. This structure allows
|
||||
* users to specify the node/multicast/broadcast addresses and the
|
||||
* correspondent filtering options.
|
||||
*/
|
||||
|
||||
struct pktbasic_addr_s
|
||||
{
|
||||
uint8_t destfilter; /* If set RX packet is accepted if its destination
|
||||
* address matches with srcaddr. This parameter
|
||||
* can be S_ENABLE or S_DISABLE */
|
||||
uint8_t srcaddr; /* Specifies the TX packet source address (address
|
||||
* of this node). */
|
||||
uint8_t mcastfilter; /* If set RX packet is accepted if its destination
|
||||
* address matches with mcastaddr. This parameter
|
||||
* can be S_ENABLE or S_DISABLE */
|
||||
uint8_t mcastaddr; /* Specifies the Multicast group address for this
|
||||
* node. */
|
||||
uint8_t bcastfilter; /* If set RX packet is accepted if its destination
|
||||
* address matches with bcastaddr. This parameter
|
||||
* can be S_ENABLE or S_DISABLE */
|
||||
uint8_t bcastaddr; /* Specifies the Broadcast address for this node. */
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* Public Function Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_pktbasic_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initializes the Spirit Basic packet according to the specified parameters
|
||||
* in the struct pktbasic_init_s. Notice that this function sets the
|
||||
* autofiltering option on CRC if it is set to any value different from
|
||||
* BASIC_NO_CRC.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* pktpasic - Basic packet init structure.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_pktbasic_initialize(FAR struct spirit_library_s *spirit,
|
||||
FAR const struct pktbasic_init_s *pktpasic);
|
||||
|
||||
/******************************************************************************
|
||||
* Name:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Input Parameters:
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#endif /* __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_PKTBASIC_H*/
|
||||
205
drivers/wireless/spirit/include/spirit_pktcommon.h
Normal file
205
drivers/wireless/spirit/include/spirit_pktcommon.h
Normal file
@@ -0,0 +1,205 @@
|
||||
/******************************************************************************
|
||||
* include/nuttx/wireless/spirit/spirit_pktcommon.h
|
||||
* Configuration and management of the common features of SPIRIT packets.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_PKTCOMMON_H
|
||||
#define __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_PKTCOMMON_H
|
||||
|
||||
/* This module provides all the common functions and definitions used by the
|
||||
* packets modules. Here are also defined all the generic enumeration types
|
||||
* that are redefined in the specific packets modules, but every enumeration
|
||||
* value is referred to this module. So the user who wants to configure the
|
||||
* preamble of a Basic, or a STack packet has to use the enumeration values
|
||||
* defined here.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* spirit_pktbasic_set_preamblen(PKT_PREAMBLE_LENGTH_18BYTES);
|
||||
*
|
||||
* ...
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Included Files
|
||||
******************************************************************************/
|
||||
|
||||
#include "spirit_types.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Macros used in assertions */
|
||||
|
||||
#define IS_PKT_PREAMBLE_LENGTH(len) \
|
||||
((len == PKT_PREAMBLE_LENGTH_01BYTE) || (len == PKT_PREAMBLE_LENGTH_02BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_03BYTES) || (len == PKT_PREAMBLE_LENGTH_04BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_05BYTES) || (len == PKT_PREAMBLE_LENGTH_06BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_07BYTES) || (len == PKT_PREAMBLE_LENGTH_08BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_09BYTES) || (len == PKT_PREAMBLE_LENGTH_10BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_11BYTES) || (len == PKT_PREAMBLE_LENGTH_12BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_13BYTES) || (len == PKT_PREAMBLE_LENGTH_14BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_15BYTES) || (len == PKT_PREAMBLE_LENGTH_16BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_17BYTES) || (len == PKT_PREAMBLE_LENGTH_18BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_19BYTES) || (len == PKT_PREAMBLE_LENGTH_20BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_21BYTES) || (len == PKT_PREAMBLE_LENGTH_22BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_23BYTES) || (len == PKT_PREAMBLE_LENGTH_24BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_25BYTES) || (len == PKT_PREAMBLE_LENGTH_26BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_27BYTES) || (len == PKT_PREAMBLE_LENGTH_28BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_29BYTES) || (len == PKT_PREAMBLE_LENGTH_30BYTES) || \
|
||||
(len == PKT_PREAMBLE_LENGTH_31BYTES) || (len == PKT_PREAMBLE_LENGTH_32BYTES))
|
||||
#define IS_PKT_SYNC_LENGTH(len) \
|
||||
((len == PKT_SYNC_LENGTH_1BYTE) || (len == PKT_SYNC_LENGTH_2BYTES) || \
|
||||
(len == PKT_SYNC_LENGTH_3BYTES) || (len == PKT_SYNC_LENGTH_4BYTES))
|
||||
#define IS_PKT_FIX_VAR_LENGTH(len) \
|
||||
((len == PKT_LENGTH_FIX) || (len == PKT_LENGTH_VAR))
|
||||
#define IS_PKT_CRC_MODE(mode) \
|
||||
((mode == PKT_NO_CRC) || (mode == PKT_CRC_MODE_8BITS) || \
|
||||
(mode == PKT_CRC_MODE_16BITS_1) || (mode == PKT_CRC_MODE_16BITS_2) || \
|
||||
(mode == PKT_CRC_MODE_24BITS))
|
||||
#define IS_PKT_CONTROL_LENGTH(len) \
|
||||
((len == PKT_CONTROL_LENGTH_0BYTES) || (len == PKT_CONTROL_LENGTH_1BYTE) || \
|
||||
(len == PKT_CONTROL_LENGTH_2BYTES) || (len == PKT_CONTROL_LENGTH_3BYTES) || \
|
||||
(len == PKT_CONTROL_LENGTH_4BYTES))
|
||||
|
||||
/******************************************************************************
|
||||
* Public Types
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Preamble length in bytes enumeration. */
|
||||
|
||||
enum pkt_premblen_e
|
||||
{
|
||||
PKT_PREAMBLE_LENGTH_01BYTE = 0x00, /* Preamble length 1 byte */
|
||||
PKT_PREAMBLE_LENGTH_02BYTES = 0x08, /* Preamble length 2 bytes */
|
||||
PKT_PREAMBLE_LENGTH_03BYTES = 0x10, /* Preamble length 3 bytes */
|
||||
PKT_PREAMBLE_LENGTH_04BYTES = 0x18, /* Preamble length 4 bytes */
|
||||
PKT_PREAMBLE_LENGTH_05BYTES = 0x20, /* Preamble length 5 bytes */
|
||||
PKT_PREAMBLE_LENGTH_06BYTES = 0x28, /* Preamble length 6 bytes */
|
||||
PKT_PREAMBLE_LENGTH_07BYTES = 0x30, /* Preamble length 7 bytes */
|
||||
PKT_PREAMBLE_LENGTH_08BYTES = 0x38, /* Preamble length 8 bytes */
|
||||
PKT_PREAMBLE_LENGTH_09BYTES = 0x40, /* Preamble length 9 bytes */
|
||||
PKT_PREAMBLE_LENGTH_10BYTES = 0x48, /* Preamble length 10 bytes */
|
||||
PKT_PREAMBLE_LENGTH_11BYTES = 0x50, /* Preamble length 11 bytes */
|
||||
PKT_PREAMBLE_LENGTH_12BYTES = 0x58, /* Preamble length 12 bytes */
|
||||
PKT_PREAMBLE_LENGTH_13BYTES = 0x60, /* Preamble length 13 bytes */
|
||||
PKT_PREAMBLE_LENGTH_14BYTES = 0x68, /* Preamble length 14 bytes */
|
||||
PKT_PREAMBLE_LENGTH_15BYTES = 0x70, /* Preamble length 15 bytes */
|
||||
PKT_PREAMBLE_LENGTH_16BYTES = 0x78, /* Preamble length 16 bytes */
|
||||
PKT_PREAMBLE_LENGTH_17BYTES = 0x80, /* Preamble length 17 bytes */
|
||||
PKT_PREAMBLE_LENGTH_18BYTES = 0x88, /* Preamble length 18 bytes */
|
||||
PKT_PREAMBLE_LENGTH_19BYTES = 0x90, /* Preamble length 19 bytes */
|
||||
PKT_PREAMBLE_LENGTH_20BYTES = 0x98, /* Preamble length 20 bytes */
|
||||
PKT_PREAMBLE_LENGTH_21BYTES = 0xa0, /* Preamble length 21 bytes */
|
||||
PKT_PREAMBLE_LENGTH_22BYTES = 0xa8, /* Preamble length 22 bytes */
|
||||
PKT_PREAMBLE_LENGTH_23BYTES = 0xb0, /* Preamble length 23 bytes */
|
||||
PKT_PREAMBLE_LENGTH_24BYTES = 0xb8, /* Preamble length 24 bytes */
|
||||
PKT_PREAMBLE_LENGTH_25BYTES = 0xc0, /* Preamble length 25 bytes */
|
||||
PKT_PREAMBLE_LENGTH_26BYTES = 0xc8, /* Preamble length 26 bytes */
|
||||
PKT_PREAMBLE_LENGTH_27BYTES = 0xd0, /* Preamble length 27 bytes */
|
||||
PKT_PREAMBLE_LENGTH_28BYTES = 0xd8, /* Preamble length 28 bytes */
|
||||
PKT_PREAMBLE_LENGTH_29BYTES = 0xe0, /* Preamble length 29 bytes */
|
||||
PKT_PREAMBLE_LENGTH_30BYTES = 0xe8, /* Preamble length 30 bytes */
|
||||
PKT_PREAMBLE_LENGTH_31BYTES = 0xf0, /* Preamble length 31 bytes */
|
||||
PKT_PREAMBLE_LENGTH_32BYTES = 0xf8 /* Preamble length 32 bytes */
|
||||
};
|
||||
|
||||
/* Sync length in bytes enumeration. */
|
||||
|
||||
enum pkt_synlen_e
|
||||
{
|
||||
PKT_SYNC_LENGTH_1BYTE = 0x00, /* Sync length 1 byte */
|
||||
PKT_SYNC_LENGTH_2BYTES = 0x02, /* Sync length 2 bytes */
|
||||
PKT_SYNC_LENGTH_3BYTES = 0x04, /* Sync length 3 bytes */
|
||||
PKT_SYNC_LENGTH_4BYTES = 0x06, /* Sync length 4 bytes */
|
||||
};
|
||||
|
||||
/* Fixed or variable payload length enumeration. */
|
||||
|
||||
enum pkt_fixvar_len_e
|
||||
{
|
||||
PKT_LENGTH_FIX = 0x00, /* Fixed payload length */
|
||||
PKT_LENGTH_VAR = 0x01 /* Variable payload length */
|
||||
};
|
||||
|
||||
/* CRC length in bytes enumeration. */
|
||||
|
||||
enum pkt_crcmode_e
|
||||
{
|
||||
PKT_NO_CRC = 0x00, /* No CRC */
|
||||
PKT_CRC_MODE_8BITS = 0x20, /* CRC length 8 bits - poly: 0x07 */
|
||||
PKT_CRC_MODE_16BITS_1 = 0x40, /* CRC length 16 bits - poly: 0x8005 */
|
||||
PKT_CRC_MODE_16BITS_2 = 0x60, /* CRC length 16 bits - poly: 0x1021 */
|
||||
PKT_CRC_MODE_24BITS = 0x80, /* CRC length 24 bits - poly: 0x864CFB */
|
||||
};
|
||||
|
||||
/* Control length in bytes enumeration for SPIRIT packets. */
|
||||
|
||||
enum pkt_ctrllen_e
|
||||
{
|
||||
PKT_CONTROL_LENGTH_0BYTES = 0x00, /* Control length 0 byte */
|
||||
PKT_CONTROL_LENGTH_1BYTE, /* Control length 1 byte */
|
||||
PKT_CONTROL_LENGTH_2BYTES, /* Control length 2 bytes */
|
||||
PKT_CONTROL_LENGTH_3BYTES, /* Control length 3 bytes */
|
||||
PKT_CONTROL_LENGTH_4BYTES /* Control length 4 bytes */
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* Public Function Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Input Parameters:
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_PKTCOMMON_H */
|
||||
194
drivers/wireless/spirit/include/spirit_qi.h
Normal file
194
drivers/wireless/spirit/include/spirit_qi.h
Normal file
@@ -0,0 +1,194 @@
|
||||
/******************************************************************************
|
||||
* include/nuttx/wireless/spirit/spirit_qi.h
|
||||
* Configuration and management of SPIRIT QI.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_QI_H
|
||||
#define __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_QI_H
|
||||
|
||||
/******************************************************************************
|
||||
* Included Files
|
||||
******************************************************************************/
|
||||
|
||||
#include "spirit_regs.h"
|
||||
#include "spirit_types.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Macros used in debug assertions */
|
||||
|
||||
#define IS_SQI_THR(value) \
|
||||
(value == SQI_TH_0 || value == SQI_TH_1 || \
|
||||
value == SQI_TH_2 || value == SQI_TH_3)
|
||||
#define IS_RSSI_FILTER_GAIN(value) \
|
||||
(value==RSSI_FG_0 || value==RSSI_FG_1 ||\
|
||||
value==RSSI_FG_2 || value==RSSI_FG_3 ||\
|
||||
value==RSSI_FG_4 || value==RSSI_FG_5 ||\
|
||||
value==RSSI_FG_6 || value==RSSI_FG_7 ||\
|
||||
value==RSSI_FG_8 || value==RSSI_FG_9 ||\
|
||||
value==RSSI_FG_10 || value==RSSI_FG_11 ||\
|
||||
value==RSSI_FG_12 || value==RSSI_FG_13 ||\
|
||||
value==RSSI_FG_14 || value==RSSI_FG_15)
|
||||
|
||||
/* Range for the RSSI Threshold in dBm */
|
||||
|
||||
#define IS_RSSI_THR_DBM(value) (value >= -130 && value <= -2)
|
||||
|
||||
/******************************************************************************
|
||||
* Public Types
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* SQI threshold value enumeration. */
|
||||
|
||||
enum spirit_sqi_threshold_e
|
||||
{
|
||||
SQI_TH_0 = 0x00,
|
||||
SQI_TH_1 = 0x40,
|
||||
SQI_TH_2 = 0x80,
|
||||
SQI_TH_3 = 0xC0
|
||||
};
|
||||
|
||||
/* RSSI filter gain value enumeration. */
|
||||
|
||||
enum spirit_rssi_filtergain_e
|
||||
{
|
||||
RSSI_FG_0 = 0x00,
|
||||
RSSI_FG_1 = 0x10,
|
||||
RSSI_FG_2 = 0x20,
|
||||
RSSI_FG_3 = 0x30,
|
||||
RSSI_FG_4 = 0x40,
|
||||
RSSI_FG_5 = 0x50,
|
||||
RSSI_FG_6 = 0x60,
|
||||
RSSI_FG_7 = 0x70,
|
||||
RSSI_FG_8 = 0x80,
|
||||
RSSI_FG_9 = 0x90,
|
||||
RSSI_FG_10 = 0xa0,
|
||||
RSSI_FG_11 = 0xb0,
|
||||
RSSI_FG_12 = 0xc0,
|
||||
RSSI_FG_13 = 0xd0,
|
||||
RSSI_FG_14 = 0xe0, /* Recommended value */
|
||||
RSSI_FG_15 = 0xf0
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* Public Function Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_qi_sqicheck
|
||||
*
|
||||
* Description:
|
||||
* Enables/Disables the Synchronization Quality Indicator check. The
|
||||
* running peak SQI is compared to a threshold value and the sync valid
|
||||
* IRQ is asserted as soon as the threshold is passed.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* newstate - new state for SQI check.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_qi_sqicheck(FAR struct spirit_library_s *spirit,
|
||||
enum spirit_functional_state_e newstate);
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_qi_set_sqithreshold
|
||||
*
|
||||
* Description:
|
||||
* Sets the SQI threshold. The synchronization quality threshold is equal to
|
||||
* 8 * SYNC_LEN - 2 * SQI_TH with SQI_TH = 0..3. When SQI_TH is 0 perfect
|
||||
* match is required; when SQI_TH = 1, 2, 3 then 1, 2, or 3 bit errors are
|
||||
* respectively accepted. It is recommended that the SQI check is always
|
||||
* enabled.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* sqithr - parameter of the formula above.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_qi_set_sqithreshold(FAR struct spirit_library_s *spirit,
|
||||
enum spirit_sqi_threshold_e sqithr);
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_qi_get_sqithreshold
|
||||
*
|
||||
* Description:
|
||||
* Returns the SQI threshold. The synchronization quality threshold is equal
|
||||
* to 8 * SYNC_LEN - 2 * SQI_TH with SQI_TH = 0..3.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
*
|
||||
* Returned Value:
|
||||
* SQI threshold (SQI_TH of the formula above). Errors are not reported.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
enum spirit_sqi_threshold_e
|
||||
spirit_qi_get_sqithreshold(FAR struct spirit_library_s *spirit);
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_qi_set_rssithreshold
|
||||
*
|
||||
* Description:
|
||||
* Sets the RSSI threshold from its dBm value according to the formula:
|
||||
* (RSSI[Dbm] + 130)/0.5.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* dbmvalue - RSSI threshold reported in dBm.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_qi_set_rssithreshold(FAR struct spirit_library_s *spirit,
|
||||
int dbmvalue);
|
||||
|
||||
#endif /* __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_GENERAL_H*/
|
||||
720
drivers/wireless/spirit/include/spirit_radio.h
Normal file
720
drivers/wireless/spirit/include/spirit_radio.h
Normal file
File diff suppressed because it is too large
Load Diff
2379
drivers/wireless/spirit/include/spirit_regs.h
Normal file
2379
drivers/wireless/spirit/include/spirit_regs.h
Normal file
File diff suppressed because it is too large
Load Diff
204
drivers/wireless/spirit/include/spirit_spi.h
Normal file
204
drivers/wireless/spirit/include/spirit_spi.h
Normal file
@@ -0,0 +1,204 @@
|
||||
/******************************************************************************
|
||||
* include/nuttx/wireless/spirit/include/spirit_spi.h
|
||||
* Header file for NuttX SPIRIT SPI driver interface.
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Derives loosely from similarly licensed SPI interface definitions from
|
||||
* STMicro:
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __DRIVERS_WIRELESS_SPIRIT_INCLUDE_SPIRIT_SPI_H
|
||||
#define __DRIVERS_WIRELESS_SPIRIT_INCLUDE_SPIRIT_SPI_H
|
||||
|
||||
/******************************************************************************
|
||||
* Included Files
|
||||
******************************************************************************/
|
||||
|
||||
#include "spirit_types.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Defintiions
|
||||
******************************************************************************/
|
||||
|
||||
/* SPIRIT1 SPI Headers */
|
||||
|
||||
#define HEADER_WRITE_MASK 0x00 /* Write mask for header byte */
|
||||
#define HEADER_READ_MASK 0x01 /* Read mask for header byte */
|
||||
#define HEADER_ADDRESS_MASK 0x00 /* Address mask for header byte */
|
||||
#define HEADER_COMMAND_MASK 0x80 /* Command mask for header byte */
|
||||
#define LINEAR_FIFO_ADDRESS 0xff /* Linear FIFO address */
|
||||
|
||||
/* SPIRIT macros to construct headers */
|
||||
|
||||
#define __MKHEADER(a,rw) (a | rw)
|
||||
#define WRITE_HEADER __MKHEADER(HEADER_ADDRESS_MASK, HEADER_WRITE_MASK)
|
||||
#define READ_HEADER __MKHEADER(HEADER_ADDRESS_MASK, HEADER_READ_MASK)
|
||||
#define COMMAND_HEADER __MKHEADER(HEADER_COMMAND_MASK, HEADER_WRITE_MASK)
|
||||
|
||||
/******************************************************************************
|
||||
* Public Function Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct spi_dev_s; /* Forward reference */
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_reg_read
|
||||
*
|
||||
* Description:
|
||||
* Read single or multiple SPIRIT1 register
|
||||
*
|
||||
* Input parameters:
|
||||
* regaddr: Base register's address to be read
|
||||
* buffer: Pointer to the buffer of registers' values to be read
|
||||
* buflen: Number of register values to be read
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated errno value is returned on
|
||||
* any failure. On success, spirit->state is updated.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_reg_read(FAR struct spirit_library_s *spirit, uint8_t regaddr,
|
||||
FAR uint8_t *buffer, unsigned int buflen);
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_reg_write
|
||||
*
|
||||
* Description:
|
||||
* Read single or multiple SPIRIT1 register.
|
||||
*
|
||||
* Input parameters:
|
||||
* spirit - Reference to an instance of the driver state stucture.
|
||||
* regaddr - Base register's address to write
|
||||
* buffer - Pointer to the buffer of register values to write
|
||||
* buflen - Number of registers values to be written.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated errno value is returned on
|
||||
* any failure. On success, spirit->state is updated.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_reg_write(FAR struct spirit_library_s *spirit, uint8_t regaddr,
|
||||
FAR const uint8_t *buffer, unsigned int buflen);
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_command
|
||||
*
|
||||
* Description:
|
||||
* Send a command
|
||||
*
|
||||
* Input parameters:
|
||||
* spirit - Reference to an instance of the driver state stucture.
|
||||
* cmd - Command code to be sent
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated errno value is returned on
|
||||
* any failure. On success, spirit->state is updated.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_command(FAR struct spirit_library_s *spirit, uint8_t cmd);
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirt_fifo_read
|
||||
*
|
||||
* Description:
|
||||
* Read data from RX FIFO
|
||||
*
|
||||
* Input parameters:
|
||||
* spirit - Reference to an instance of the driver state stucture.
|
||||
* buffer - Pointer to the buffer of data values to write
|
||||
* buflen - Number of bytes to be written
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated errno value is returned on
|
||||
* any failure. On success, spirit->state is updated.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirt_fifo_read(FAR struct spirit_library_s *spirit, FAR uint8_t *buffer,
|
||||
unsigned int buflen);
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirt_fifo_write
|
||||
*
|
||||
* Description:
|
||||
* Write data into TX FIFO.
|
||||
*
|
||||
* Input parameters:
|
||||
* spirit - Reference to an instance of the driver state stucture.
|
||||
* buffer - Pointer to the buffer of data values to write
|
||||
* buflen - Number of data values to be written.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated errno value is returned on
|
||||
* any failure. On success, spirit->state is updated.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirt_fifo_write(FAR struct spirit_library_s *spirit,
|
||||
FAR const uint8_t *buffer, unsigned int buflen);
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_update_status
|
||||
*
|
||||
* Description:
|
||||
* Updates the state field in the driver instance by reading the MC_STATE
|
||||
* register of SPIRIT.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to an instance of the driver state stucture.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated errno value is returned on
|
||||
* any failure. On success, spirit->state is updated.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_update_status(FAR struct spirit_library_s *spirit);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DRIVERS_WIRELESS_SPIRIT_INCLUDE_SPIRIT_SPI_H */
|
||||
146
drivers/wireless/spirit/include/spirit_timer.h
Normal file
146
drivers/wireless/spirit/include/spirit_timer.h
Normal file
@@ -0,0 +1,146 @@
|
||||
/******************************************************************************
|
||||
* include/nuttx/wireless/spirit/spirit_timer.h
|
||||
* Configuration and management of SPIRIT timers.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_TIMER_H
|
||||
#define __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_TIMER_H
|
||||
|
||||
/******************************************************************************
|
||||
* Included Files
|
||||
******************************************************************************/
|
||||
|
||||
#include "spirit_regs.h"
|
||||
#include "spirit_types.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Macros used in debug assertions */
|
||||
|
||||
#define IS_RX_TIMEOUT_STOP_CONDITION(cond) \
|
||||
(cond == NO_TIMEOUT_STOP || cond == TIMEOUT_ALWAYS_STOPPED || \
|
||||
cond == RSSI_ABOVE_THRESHOLD || cond == SQI_ABOVE_THRESHOLD || \
|
||||
cond == PQI_ABOVE_THRESHOLD || cond == RSSI_AND_SQI_ABOVE_THRESHOLD || \
|
||||
cond == RSSI_AND_PQI_ABOVE_THRESHOLD || cond == SQI_AND_PQI_ABOVE_THRESHOLD || \
|
||||
cond == ALL_ABOVE_THRESHOLD || cond == RSSI_OR_SQI_ABOVE_THRESHOLD || \
|
||||
cond == RSSI_OR_PQI_ABOVE_THRESHOLD || cond == SQI_OR_PQI_ABOVE_THRESHOLD || \
|
||||
cond == ANY_ABOVE_THRESHOLD)
|
||||
|
||||
/******************************************************************************
|
||||
* Public Types
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* All the possible RX timeout stop conditions enumeration. */
|
||||
|
||||
enum spirit_rxtimeout_stopcondition_e
|
||||
{
|
||||
NO_TIMEOUT_STOP = 0x00, /* Timeout never stopped */
|
||||
TIMEOUT_ALWAYS_STOPPED = 0x08, /* Timeout always stopped (default) */
|
||||
RSSI_ABOVE_THRESHOLD = 0x04, /* Timeout stopped on RSSI above
|
||||
* threshold */
|
||||
SQI_ABOVE_THRESHOLD = 0x02, /* Timeout stopped on SQI above
|
||||
* threshold */
|
||||
PQI_ABOVE_THRESHOLD = 0x01, /* Timeout stopped on PQI above
|
||||
* threshold */
|
||||
RSSI_AND_SQI_ABOVE_THRESHOLD = 0x06, /* Timeout stopped on both
|
||||
* RSSI and SQI above threshold */
|
||||
RSSI_AND_PQI_ABOVE_THRESHOLD = 0x05, /* Timeout stopped on both
|
||||
* RSSI and PQI above threshold */
|
||||
SQI_AND_PQI_ABOVE_THRESHOLD = 0x03, /* Timeout stopped on both
|
||||
* SQI and PQI above threshold */
|
||||
ALL_ABOVE_THRESHOLD = 0x07, /* Timeout stopped only if RSSI, SQI
|
||||
* and PQI are above threshold */
|
||||
RSSI_OR_SQI_ABOVE_THRESHOLD = 0x0e, /* Timeout stopped if one
|
||||
* between RSSI or SQI are
|
||||
* above threshold */
|
||||
RSSI_OR_PQI_ABOVE_THRESHOLD = 0x0d, /* Timeout stopped if one
|
||||
* between RSSI or PQI are
|
||||
* above threshold */
|
||||
SQI_OR_PQI_ABOVE_THRESHOLD = 0x0b, /* Timeout stopped if one
|
||||
* between SQI or PQI are above
|
||||
* threshold */
|
||||
ANY_ABOVE_THRESHOLD = 0x0f /* Timeout stopped if one among
|
||||
* RSSI, SQI or SQI are above threshold */
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* Public Function Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_timer_set_rxtimeout
|
||||
*
|
||||
* Description:
|
||||
* Sets the RX timeout timer counter. If 'counter' is equal to 0 the
|
||||
* timeout is disabled.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* counter - value for the timer counter.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_timer_set_rxtimeout(FAR struct spirit_library_s *spirit,
|
||||
uint8_t counter);
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_timer_set_rxtimeout_stopcondition
|
||||
*
|
||||
* Description:
|
||||
* Sets the RX timeout stop conditions.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* stopcondition - New stop condition.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_timer_set_rxtimeout_stopcondition(FAR struct spirit_library_s *spirit,
|
||||
enum spirit_rxtimeout_stopcondition_e
|
||||
stopcondition);
|
||||
|
||||
#endif /* __INCLUDE_NUTT_WIRELESS_SPIRIT_SPIRIT_TIMER_H */
|
||||
162
drivers/wireless/spirit/include/spirit_types.h
Normal file
162
drivers/wireless/spirit/include/spirit_types.h
Normal file
@@ -0,0 +1,162 @@
|
||||
/******************************************************************************
|
||||
* include/nuttx/wireless/spirit/include/spirit_types.h
|
||||
* Header file for SPIRIT types.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted and extended for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTT_WIRELESS_SPIRIT_INCLUDE_SPIRIT_TYPES_H
|
||||
#define __INCLUDE_NUTT_WIRELESS_SPIRIT_INCLUDE_SPIRIT_TYPES_H
|
||||
|
||||
/* This module provide some types definitions which will be used in
|
||||
* all the modules of this library. Here is defined also the global
|
||||
* variable spirit->state which contains the status of Spirit and
|
||||
* is updated every time an SPI transaction occurs.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Included Files
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "spirit_regs.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Macros used in assertions */
|
||||
|
||||
#define IS_SPIRIT_FUNCTIONAL_STATE(STATE) \
|
||||
(STATE == S_DISABLE || STATE == S_ENABLE)
|
||||
|
||||
#define IS_SPIRIT_FLAG_STATUS(STATUS) \
|
||||
(STATUS == S_RESET || STATUS == S_SET)
|
||||
|
||||
/******************************************************************************
|
||||
* Public Types
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Spirit Functional state. Used to enable or disable a specific option. */
|
||||
|
||||
enum spirit_functional_state_e
|
||||
{
|
||||
S_DISABLE = 0,
|
||||
S_ENABLE = 1
|
||||
};
|
||||
|
||||
/* Spirit Flag status. Used to control the state of a flag. */
|
||||
|
||||
enum spirit_flag_status_e
|
||||
{
|
||||
S_RESET = 0,
|
||||
S_SET = 1
|
||||
};
|
||||
|
||||
/* SPIRIT States enumeration. */
|
||||
|
||||
enum spirit_state_e
|
||||
{
|
||||
MC_STATE_STANDBY = 0x40, /* STANDBY */
|
||||
MC_STATE_SLEEP = 0x36, /* SLEEP */
|
||||
MC_STATE_READY = 0x03, /* READY */
|
||||
MC_STATE_PM_SETUP = 0x3d, /* PM_SETUP */
|
||||
MC_STATE_XO_SETTLING = 0x23, /* XO_SETTLING */
|
||||
MC_STATE_SYNTH_SETUP = 0x53, /* SYNT_SETUP */
|
||||
MC_STATE_PROTOCOL = 0x1f, /* PROTOCOL */
|
||||
MC_STATE_SYNTH_CALIBRATION = 0x4f, /* SYNTH */
|
||||
MC_STATE_LOCK = 0x0f, /* LOCK */
|
||||
MC_STATE_RX = 0x33, /* RX */
|
||||
MC_STATE_TX = 0x5f /* TX */
|
||||
};
|
||||
|
||||
/* SPIRIT Status. This definition represents the single field of the SPIRIT
|
||||
* status returned on each SPI transaction, equal also to the MC_STATE registers.
|
||||
* This field-oriented structure allows user to address in simple way the single
|
||||
* field of the SPIRIT status.
|
||||
* The user shall define a variable of SpiritStatus type to access on SPIRIT status fields.
|
||||
* @note The fields order in the structure depends on used endianness (little or big
|
||||
* endian). The actual definition is valid ONLY for LITTLE ENDIAN mode. Be sure to
|
||||
* change opportunely the fields order when use a different endianness.
|
||||
*/
|
||||
|
||||
struct spirit_status_s
|
||||
{
|
||||
uint8_t XO_ON : 1; /* Notifies if XO is operating (XO_ON is
|
||||
* 1) or not (XO_On is 0) */
|
||||
uint8_t MC_STATE : 7; /* Indicates the state of the Main Controller
|
||||
* of SPIRIT. The possible states and their
|
||||
* corresponding values are defined in enum
|
||||
* spirit_state_e */
|
||||
uint8_t ERROR_LOCK : 1; /* Notifies if there is an error on RCO
|
||||
* calibration (ERROR_LOCK is 1) or not
|
||||
* (ERROR_LOCK is 0) */
|
||||
uint8_t RX_FIFO_EMPTY : 1; /* Notifies if RX FIFO is empty (RX_FIFO_EMPTY
|
||||
* is 1) or not (RX_FIFO_EMPTY is 0) */
|
||||
uint8_t TX_FIFO_FULL : 1; /* Notifies if TX FIFO is full (TX_FIFO_FULL
|
||||
* is 1) or not (TX_FIFO_FULL is 0) */
|
||||
uint8_t ANT_SELECT : 1; /* Notifies the currently selected antenna */
|
||||
uint8_t reserved : 4; /* Reserved and equal to 5 */
|
||||
};
|
||||
|
||||
/* An instance of this structure represents the overall state of one Spirit
|
||||
* device from the standpoint of the library. Multiple spirit devices may be
|
||||
* supported by the library with multiple instances of this structure.
|
||||
*/
|
||||
|
||||
struct spirit_library_s
|
||||
{
|
||||
FAR struct spi_dev_s *spi; /* SPI: Contained SPI device instance */
|
||||
uint32_t xtal_frequency; /* RADIO: Crystal frequency */
|
||||
uint32_t commfrequency; /* MANAGEMENT: Desired communication frequency */
|
||||
|
||||
union spirit_struct_u
|
||||
{
|
||||
struct spirit_status_s state; /* State of the Spirit device */
|
||||
uint16_t u16; /* For alternative accesses */
|
||||
} u;
|
||||
|
||||
uint8_t commstate; /* MANAGEMENT: Communication state */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTT_WIRELESS_SPIRIT_INCLUDE_SPIRIT_TYPES_H */
|
||||
44
drivers/wireless/spirit/lib/Make.defs
Normal file
44
drivers/wireless/spirit/lib/Make.defs
Normal file
@@ -0,0 +1,44 @@
|
||||
############################################################################
|
||||
# drivers/wireless/spirit/lib//Make.defs
|
||||
#
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# 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.
|
||||
#-
|
||||
############################################################################
|
||||
|
||||
# Include Spirit driver source files in the build
|
||||
|
||||
CSRCS += spirit_radio.c spirit_pktbasic.c spirit_qi.c spirit_management.c
|
||||
CSRCS += spirit_irq.c spirit_timer.c spirit_gpio.c spirit_spi.c
|
||||
|
||||
# Include Spirit driver build support
|
||||
|
||||
DEPPATH += --dep-path wireless$(DELIM)spirit$(DELIM)lib
|
||||
VPATH += :wireless$(DELIM)spirit$(DELIM)lib
|
||||
101
drivers/wireless/spirit/lib/spirit_gpio.c
Normal file
101
drivers/wireless/spirit/lib/spirit_gpio.c
Normal file
@@ -0,0 +1,101 @@
|
||||
/******************************************************************************
|
||||
* drivers/wireless/spirit/lib/spirit_gpio.c
|
||||
* This file provides all the low level API to manage SPIRIT GPIO.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER 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 <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "spirit_gpio.h"
|
||||
#include "spirit_spi.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Private Functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Public Functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name:
|
||||
*
|
||||
* Description:
|
||||
* Initializes the Spirit GPIOx according to the specified parameters in
|
||||
* the gpioinit parameter.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* gpioinit - A pointer to a struct spirit_gpio_init_s structure that
|
||||
* contains the configuration information for the specified
|
||||
* SPIRIT GPIO.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_gpio_initialize(FAR struct spirit_library_s *spirit,
|
||||
FAR const struct spirit_gpio_init_s *gpioinit)
|
||||
{
|
||||
uint8_t regval = 0x00;
|
||||
|
||||
/* Check the parameters */
|
||||
|
||||
DEBUGASSERT(IS_SPIRIT_GPIO(gpioinit->gpiopin));
|
||||
DEBUGASSERT(IS_SPIRIT_GPIO_MODE(gpioinit->gpiomode));
|
||||
DEBUGASSERT(IS_SPIRIT_GPIO_IO(gpioinit->gpioio));
|
||||
|
||||
regval = ((uint8_t)(gpioinit->gpiomode) | (uint8_t)(gpioinit->gpioio));
|
||||
return spirit_reg_write(spirit, gpioinit->gpiopin, ®val, 1);
|
||||
}
|
||||
324
drivers/wireless/spirit/lib/spirit_irq.c
Normal file
324
drivers/wireless/spirit/lib/spirit_irq.c
Normal file
@@ -0,0 +1,324 @@
|
||||
/******************************************************************************
|
||||
* drivers/wireless/spirit/lib/spirit_irq.c
|
||||
* Configuration and management of SPIRIT IRQs.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER 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 <assert.h>
|
||||
|
||||
#include "spirit_types.h"
|
||||
#include "spirit_spi.h"
|
||||
#include "spirit_irq.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Public Functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irq_disable_all
|
||||
*
|
||||
* Description:
|
||||
* Ssets the IRQ mask registers to 0x00000000, disabling all IRQs.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_irq_disable_all(FAR struct spirit_library_s *spirit)
|
||||
{
|
||||
uint8_t regval[4] = { 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
/* Writes the IRQ_MASK registers */
|
||||
|
||||
return spirit_reg_write(spirit, IRQ_MASK3_BASE, regval, 4);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irq_set_mask
|
||||
*
|
||||
* Description:
|
||||
* Enables/disables all the IRQs according to the user defined irqset
|
||||
* structure.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* irqset - Pointer to a variable of type struct spirit_irqset_s, through
|
||||
* which the user enable specific IRQs. This parameter is a
|
||||
* pointer to a struct spirit_irqset_s.
|
||||
*
|
||||
* For example suppose to enable only the two IRQ Low Battery Level
|
||||
* and Tx Data Sent:
|
||||
*
|
||||
* struct spirit_irqset_s g_irqset = {0};
|
||||
* g_irqset.IRQ_LOW_BATT_LVL = 1;
|
||||
* g_irqset.IRQ_TX_DATA_SENT = 1;
|
||||
* spirit_irq_setmask(&g_irqset);
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ENDIAN_BIG
|
||||
int spirit_irq_set_mask(FAR struct spirit_library_s *spirit,
|
||||
FAR struct spirit_irqset_s *irqset)
|
||||
{
|
||||
/* Writes the IRQ_MASK registers */
|
||||
|
||||
return spirit_reg_write(spirit, IRQ_MASK3_BASE, (FAR uint8_t *)irqset, 4);
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irq_enable
|
||||
*
|
||||
* Description:
|
||||
* Enables or disables a specific IRQ.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* irq IRQ to enable or disable.
|
||||
* newstate - new state for the IRQ.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_irq_enable(FAR struct spirit_library_s *spirit,
|
||||
enum spirit_irq_e irq,
|
||||
enum spirit_functional_state_e newstate)
|
||||
{
|
||||
uint8_t regval[4];
|
||||
uint32_t dwirqs = 0;
|
||||
int ret;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
/* Check the parameters */
|
||||
|
||||
DEBUGASSERT(IS_SPIRIT_IRQ_LIST(irq));
|
||||
DEBUGASSERT(IS_SPIRIT_FUNCTIONAL_STATE(newstate));
|
||||
|
||||
/* Reads the IRQ_MASK registers */
|
||||
|
||||
ret = spirit_reg_read(spirit, IRQ_MASK3_BASE, regval, 4);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Build the IRQ mask word */
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
dwirqs += ((uint32_t) regval[i]) << (8 * (3 - i));
|
||||
}
|
||||
|
||||
/* Rebuild the new mask according to user request */
|
||||
|
||||
if (newstate == S_DISABLE)
|
||||
{
|
||||
dwirqs &= (~irq);
|
||||
}
|
||||
else
|
||||
{
|
||||
dwirqs |= (irq);
|
||||
}
|
||||
|
||||
/* Build the array of bytes to write in the IRQ_MASK registers */
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
regval[j] = (uint8_t)(dwirqs >> (8 * (3 - j)));
|
||||
}
|
||||
|
||||
/* Writes the new IRQ mask in the corresponding registers */
|
||||
|
||||
return spirit_reg_write(spirit, IRQ_MASK3_BASE, regval, 4);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irt_get_mask
|
||||
*
|
||||
* Description:
|
||||
* Fills a pointer to a structure of struct spirit_irqset_s type with the
|
||||
* content of the IRQ_MASK registers.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* pirqmask - Pointer to a variable of type struct spirit_irqset_s, through
|
||||
* which the user can read which IRQs are enabled. All the
|
||||
* bitfields equals to zero correspond to enabled IRQs, while
|
||||
* all the bitfields equals to one correspond to disabled IRQs.
|
||||
*
|
||||
* For example suppose that the Power On Reset and RX Data
|
||||
* ready are the only enabled IRQs.
|
||||
*
|
||||
* struct spirit_irqset_s g_irqmask;
|
||||
* spirit_irq_get_pending(&g_irqmask);
|
||||
*
|
||||
* Then g_irqmask.IRQ_POR and g_irqmask.IRQ_RX_DATA_READY are
|
||||
* equal to 0 while all the other bitfields are equal to one.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ENDIAN_BIG
|
||||
int spirit_irt_get_mask(FAR struct spirit_library_s *spirit,
|
||||
FAR struct spirit_irqset_s *pirqmask)
|
||||
{
|
||||
/* Reads IRQ_MASK registers */
|
||||
|
||||
return spirit_reg_read(spirit, IRQ_MASK3_BASE, (FAR uint8_t *)pirqmask, 4);
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irq_get_pending
|
||||
*
|
||||
* Description:
|
||||
* Fills a pointer to a structure of struct spirit_irqset_s type with the
|
||||
* content of the IRQ_STATUS registers.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* pirqstatus - A pointer to a variable of type struct spirit_irqset_s,
|
||||
* through which the user can receive the status of all the
|
||||
* IRQs. All the bitfields equals to one correspond to the
|
||||
* raised interrupts.
|
||||
*
|
||||
* For example suppose that the XO settling timeout is raised
|
||||
* as well as the Sync word detection.
|
||||
*
|
||||
* struct spirit_irqset_s g_irqstatus;
|
||||
* spirit_irq_get_pending(&g_irqstatus);
|
||||
*
|
||||
* Then g_irqstatus.IRQ_XO_COUNT_EXPIRED and
|
||||
* g_irqstatus.IRQ_VALID_SYNC are equals to 1* while all the
|
||||
* other bitfields are equals to zero.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ENDIAN_BIG
|
||||
int spirit_irq_get_pending(FAR struct spirit_library_s *spirit,
|
||||
FAR struct spirit_irqset_s *pirqstatus)
|
||||
{
|
||||
/* Reads IRQ_STATUS registers */
|
||||
|
||||
return spirit_reg_read(spirit, IRQ_STATUS3_BASE, (FAR uint8_t *)pirqstatus, 4);
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irq_clr_pending
|
||||
*
|
||||
* Description:
|
||||
* Clear the IRQ status registers.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_irq_clr_pending(FAR struct spirit_library_s *spirit)
|
||||
{
|
||||
uint8_t regval[4];
|
||||
|
||||
/* Reads the IRQ_STATUS registers clearing all the flags */
|
||||
|
||||
return spirit_reg_read(spirit, IRQ_STATUS3_BASE, regval, 4);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_irq_is_pending
|
||||
*
|
||||
* Description:
|
||||
* Checks if a specific IRQ has been generated. The call resets all the
|
||||
* IRQ status, so it can't be used in case of multiple raising interrupts.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* flag IRQ flag to be checked.
|
||||
* This parameter can be any value of enum spirit_irq_e.
|
||||
*
|
||||
* Returned Value:
|
||||
* true or false.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
bool spirit_irq_is_pending(FAR struct spirit_library_s *spirit,
|
||||
enum spirit_irq_e flag)
|
||||
{
|
||||
uint8_t regval[4];
|
||||
uint32_t dwirqs = 0;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Check the parameters */
|
||||
|
||||
DEBUGASSERT(IS_SPIRIT_IRQ_LIST(flag));
|
||||
|
||||
/* Read status registers */
|
||||
|
||||
ret = spirit_reg_read(spirit, IRQ_STATUS3_BASE, regval, 4);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Build the status word */
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
dwirqs |= ((uint32_t)regval[i]) << (8 * (3 - i));
|
||||
}
|
||||
|
||||
return ((dwirqs & flag) != 0);
|
||||
}
|
||||
89
drivers/wireless/spirit/lib/spirit_management.c
Normal file
89
drivers/wireless/spirit/lib/spirit_management.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/******************************************************************************
|
||||
* drivers/wireless/spirit/lib/spirit_management.c
|
||||
* The management layer for SPIRIT1 library.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER 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 "spirit_management.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
#define COMMUNICATION_STATE_TX 0
|
||||
#define COMMUNICATION_STATE_RX 1
|
||||
#define COMMUNICATION_STATE_NONE 2
|
||||
|
||||
/******************************************************************************
|
||||
* Private Functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Public Functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_management_initcommstate
|
||||
*
|
||||
* Description:
|
||||
* Initialize communication state
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* frequency - Desired communication frequency
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
void spirit_management_initcommstate(FAR struct spirit_library_s *spirit,
|
||||
uint32_t frequency)
|
||||
{
|
||||
spirit->commstate = COMMUNICATION_STATE_NONE;
|
||||
spirit->commfrequency = frequency;
|
||||
}
|
||||
92
drivers/wireless/spirit/lib/spirit_pktbasic.c
Normal file
92
drivers/wireless/spirit/lib/spirit_pktbasic.c
Normal file
@@ -0,0 +1,92 @@
|
||||
/******************************************************************************
|
||||
* drivers/wireless/spirit/lib/spirit_pktbasic.c
|
||||
* Configuration and management of SPIRIT Basic packets.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER 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 <errno.h>
|
||||
|
||||
#include "spirit_pktbasic.h"
|
||||
#include "spirit_spi.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Private Functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Public Functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_pktbasic_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initializes the Spirit Basic packet according to the specified parameters
|
||||
* in the struct pktbasic_init_s. Notice that this function sets the
|
||||
* autofiltering option on CRC if it is set to any value different from
|
||||
* BASIC_NO_CRC.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* pktpasic - Basic packet init structure.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_pktbasic_initialize(FAR struct spirit_library_s *spirit,
|
||||
FAR const struct pktbasic_init_s *pktpasic)
|
||||
{
|
||||
#warning Missing logic
|
||||
return -ENOSYS;
|
||||
}
|
||||
224
drivers/wireless/spirit/lib/spirit_qi.c
Normal file
224
drivers/wireless/spirit/lib/spirit_qi.c
Normal file
@@ -0,0 +1,224 @@
|
||||
/******************************************************************************
|
||||
* drivers/wireless/spirit/lib/spirit_qi.c
|
||||
* Configuration and management of SPIRIT QI.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER 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 <assert.h>
|
||||
|
||||
#include "spirit_qi.h"
|
||||
#include "spirit_spi.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Private Functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Public Functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_qi_sqicheck
|
||||
*
|
||||
* Description:
|
||||
* Enables/Disables the Synchronization Quality Indicator check. The
|
||||
* running peak SQI is compared to a threshold value and the sync valid
|
||||
* IRQ is asserted as soon as the threshold is passed.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* newstate - new state for SQI check.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_qi_sqicheck(FAR struct spirit_library_s *spirit,
|
||||
enum spirit_functional_state_e newstate)
|
||||
{
|
||||
uint8_t regval;
|
||||
int ret;
|
||||
|
||||
/* Check the parameters */
|
||||
|
||||
DEBUGASSERT(IS_SPIRIT_FUNCTIONAL_STATE(newstate));
|
||||
|
||||
/* Reads the QI register value */
|
||||
|
||||
ret = spirit_reg_read(spirit, QI_BASE, ®val, 1);
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* Enables or disables the SQI Check bit on the QI_BASE register */
|
||||
|
||||
if (newstate == S_ENABLE)
|
||||
{
|
||||
regval |= QI_SQI_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
regval &= ~QI_SQI_MASK;
|
||||
}
|
||||
|
||||
/* Write the value to the QI register */
|
||||
|
||||
ret = spirit_reg_write(spirit, QI_BASE, ®val, 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_qi_set_sqithreshold
|
||||
*
|
||||
* Description:
|
||||
* Sets the SQI threshold. The synchronization quality threshold is equal to
|
||||
* 8 * SYNC_LEN - 2 * SQI_TH with SQI_TH = 0..3. When SQI_TH is 0 perfect
|
||||
* match is required; when SQI_TH = 1, 2, 3 then 1, 2, or 3 bit errors are
|
||||
* respectively accepted. It is recommended that the SQI check is always
|
||||
* enabled.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* sqithr - parameter of the formula above.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_qi_set_sqithreshold(FAR struct spirit_library_s *spirit,
|
||||
enum spirit_sqi_threshold_e sqithr)
|
||||
{
|
||||
uint8_t regval;
|
||||
int ret;
|
||||
|
||||
/* Check the parameters */
|
||||
|
||||
DEBUGASSERT(IS_SQI_THR(sqithr));
|
||||
|
||||
/* Reads the QI register value */
|
||||
|
||||
ret = spirit_reg_read(spirit, QI_BASE, ®val, 1);
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* Build the SQI threshold value to be written */
|
||||
|
||||
regval &= 0x3f;
|
||||
regval |= (uint8_t)sqithr;
|
||||
|
||||
/* Write the new value to the QI register */
|
||||
|
||||
ret = spirit_reg_write(spirit, QI_BASE, ®val, 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_qi_get_sqithreshold
|
||||
*
|
||||
* Description:
|
||||
* Returns the SQI threshold. The synchronization quality threshold is equal
|
||||
* to 8 * SYNC_LEN - 2 * SQI_TH with SQI_TH = 0..3.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
*
|
||||
* Returned Value:
|
||||
* SQI threshold (SQI_TH of the formula above). Errors are not reported.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
enum spirit_sqi_threshold_e
|
||||
spirit_qi_get_sqithreshold(FAR struct spirit_library_s *spirit)
|
||||
{
|
||||
uint8_t regval;
|
||||
|
||||
/* Read the QI register value */
|
||||
|
||||
(void)spirit_reg_read(spirit, QI_BASE, ®val, 1);
|
||||
|
||||
/* Return the SQI threshold value */
|
||||
|
||||
return (enum spirit_sqi_threshold_e)(regval & 0xc0);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_qi_set_rssithreshold
|
||||
*
|
||||
* Description:
|
||||
* Sets the RSSI threshold from its dBm value according to the formula:
|
||||
* (RSSI[Dbm] + 130)/0.5.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* dbmvalue - RSSI threshold reported in dBm.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_qi_set_rssithreshold(FAR struct spirit_library_s *spirit,
|
||||
int dbmvalue)
|
||||
{
|
||||
uint8_t regval = 2 * (dbmvalue + 130);
|
||||
|
||||
/* Check the parameters */
|
||||
|
||||
DEBUGASSERT(IS_RSSI_THR_DBM(dbmvalue));
|
||||
|
||||
/* Writes the new value on the RSSI_TH register */
|
||||
|
||||
return spirit_reg_write(spirit, RSSI_TH_BASE, ®val, 1);
|
||||
}
|
||||
1449
drivers/wireless/spirit/lib/spirit_radio.c
Normal file
1449
drivers/wireless/spirit/lib/spirit_radio.c
Normal file
File diff suppressed because it is too large
Load Diff
421
drivers/wireless/spirit/lib/spirit_spi.c
Normal file
421
drivers/wireless/spirit/lib/spirit_spi.c
Normal file
@@ -0,0 +1,421 @@
|
||||
/******************************************************************************
|
||||
* drivers/wireless/spirit/lib//spirit_spi.c
|
||||
* NuttX SPIRIT SPI driver interface.
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Derives loosely from simlilarly licensed, platform-specific, example
|
||||
* implementations from STMicro:
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* 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 <assert.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
|
||||
#include "spirit_regs.h"
|
||||
#include "spirit_types.h"
|
||||
#include "spirit_spi.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef CONFIG_WL_SPIRIT_SPIFREQUENCY
|
||||
# define CONFIG_WL_SPIRIT_SPIFREQUENCY (10000000)
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Private Functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_lock
|
||||
*
|
||||
* Description:
|
||||
* Lock the SPI bus before each transfer, setting the correct SPI
|
||||
* characteristics for the Spirit device. These must be set if there are
|
||||
* multiple devices on the bus because while the bus was unlocked, another
|
||||
* device may have re-configured the SPIO.
|
||||
*
|
||||
* Parameters:
|
||||
* spi - Reference to the SPI driver structure
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
static void spirit_lock(FAR struct spi_dev_s *spi)
|
||||
{
|
||||
/* Lock the SPI bus because there are multiple devices competing for the
|
||||
* SPI bus
|
||||
*/
|
||||
|
||||
(void)SPI_LOCK(spi, true);
|
||||
|
||||
/* We have the lock. Now make sure that the SPI bus is configured for the
|
||||
* Spirit (it might have gotten configured for a different device while
|
||||
* unlocked)
|
||||
*
|
||||
* NOTES:
|
||||
* - The SPIRIT1 SPI is mode 0 (CPOL=0, CPHA=0)
|
||||
* - Data word is 8-bits
|
||||
* - Maximum clock frequency is 10MHz
|
||||
* - Transfers are MS bit first
|
||||
*/
|
||||
|
||||
SPI_SETMODE(spi, SPIDEV_MODE0);
|
||||
SPI_SETBITS(spi, 8);
|
||||
(void)SPI_HWFEATURES(spi, 0);
|
||||
(void)SPI_SETFREQUENCY(spi, CONFIG_WL_SPIRIT_SPIFREQUENCY);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_unlock
|
||||
*
|
||||
* Description:
|
||||
* Un-lock the SPI bus after each transfer, possibly losing the current
|
||||
* configuration if we are sharing the SPI bus with other devices.
|
||||
*
|
||||
* Parameters:
|
||||
* spi - Reference to the SPI driver structure
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
static void spirit_unlock(FAR struct spi_dev_s *spi)
|
||||
{
|
||||
/* Relinquish the SPI bus. */
|
||||
|
||||
(void)SPI_LOCK(spi, false);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Public Functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_reg_read
|
||||
*
|
||||
* Description:
|
||||
* Read single or multiple SPIRIT1 register
|
||||
*
|
||||
* Input parameters:
|
||||
*
|
||||
* regaddr: Base register's address to be read
|
||||
* buffer: Pointer to the buffer of registers' values to be read
|
||||
* buflen: Number of register values to be read
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated errno value is returned on
|
||||
* any failure. On success, spirit->state is updated.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_reg_read(FAR struct spirit_library_s *spirit, uint8_t regaddr,
|
||||
FAR uint8_t *buffer, unsigned int buflen)
|
||||
{
|
||||
uint8_t header[2];
|
||||
uint8_t status[2];
|
||||
|
||||
/* Setup the header bytes */
|
||||
|
||||
header[0] = READ_HEADER;
|
||||
header[1] = regaddr;
|
||||
|
||||
/* Lock the SPI bus and select the Spirit device */
|
||||
|
||||
spirit_lock(spirit->spi);
|
||||
SPI_SELECT(spirit->spi, SPIDEV_WIRELESS(0), true);
|
||||
|
||||
/* Write the header bytes and read the SPIRIT1 status bytes */
|
||||
|
||||
SPI_EXCHANGE(spirit->spi, header, status, 2);
|
||||
|
||||
/* Update Spirit status. 16-bit status is returned MS bit first */
|
||||
|
||||
spirit->u.u16 = ((uint16_t)status[0] << 8) | (uint16_t)status[1];
|
||||
|
||||
/* Read the register values */
|
||||
|
||||
SPI_RECVBLOCK(spirit->spi, buffer, buflen);
|
||||
|
||||
/* Deselect the Spirit device and return the result */
|
||||
|
||||
SPI_SELECT(spirit->spi, SPIDEV_WIRELESS(0), false);
|
||||
spirit_unlock(spirit->spi);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_reg_write
|
||||
*
|
||||
* Description:
|
||||
* Read single or multiple SPIRIT1 register.
|
||||
*
|
||||
* Input parameters:
|
||||
* spirit - Reference to an instance of the driver state stucture.
|
||||
* regaddr - Base register's address to write
|
||||
* buffer - Pointer to the buffer of register values to write
|
||||
* buflen - Number of registers values to be written.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated errno value is returned on
|
||||
* any failure. On success, spirit->state is updated.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_reg_write(FAR struct spirit_library_s *spirit, uint8_t regaddr,
|
||||
FAR const uint8_t *buffer, unsigned int buflen)
|
||||
{
|
||||
uint8_t header[2];
|
||||
uint8_t status[2];
|
||||
|
||||
/* Setup the header bytes */
|
||||
|
||||
header[0] = WRITE_HEADER;
|
||||
header[1] = regaddr;
|
||||
|
||||
/* Lock the SPI bus and select the Spirit device */
|
||||
|
||||
spirit_lock(spirit->spi);
|
||||
SPI_SELECT(spirit->spi, SPIDEV_WIRELESS(0), true);
|
||||
|
||||
/* Write the header bytes and read the SPIRIT1 status bytes */
|
||||
|
||||
SPI_EXCHANGE(spirit->spi, header, status, 2);
|
||||
|
||||
/* Update Spirit status. 16-bit status is returned MS bit first */
|
||||
|
||||
spirit->u.u16 = ((uint16_t)status[0] << 8) | (uint16_t)status[1];
|
||||
|
||||
/* Write the register values */
|
||||
|
||||
SPI_SNDBLOCK(spirit->spi, buffer, buflen);
|
||||
|
||||
/* Deselect the Spirit device and return the result */
|
||||
|
||||
SPI_SELECT(spirit->spi, SPIDEV_WIRELESS(0), false);
|
||||
spirit_unlock(spirit->spi);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_command
|
||||
*
|
||||
* Description:
|
||||
* Send a command
|
||||
*
|
||||
* Input parameters:
|
||||
* spirit - Reference to an instance of the driver state stucture.
|
||||
* cmd - Command code to be sent
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated errno value is returned on
|
||||
* any failure. On success, spirit->state is updated.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_command(FAR struct spirit_library_s *spirit, uint8_t cmd)
|
||||
{
|
||||
uint8_t header[2];
|
||||
uint8_t status[2];
|
||||
|
||||
/* Setup the header bytes */
|
||||
|
||||
header[0] = COMMAND_HEADER;
|
||||
header[1] = cmd;
|
||||
|
||||
/* Lock the SPI bus and select the Spirit device */
|
||||
|
||||
spirit_lock(spirit->spi);
|
||||
SPI_SELECT(spirit->spi, SPIDEV_WIRELESS(0), true);
|
||||
|
||||
/* Write the header bytes and read the SPIRIT1 status bytes */
|
||||
|
||||
SPI_EXCHANGE(spirit->spi, header, status, 2);
|
||||
|
||||
/* Update Spirit status. 16-bit status is returned MS bit first */
|
||||
|
||||
spirit->u.u16 = ((uint16_t)status[0] << 8) | (uint16_t)status[1];
|
||||
|
||||
/* Deselect the Spirit device and return the result */
|
||||
|
||||
SPI_SELECT(spirit->spi, SPIDEV_WIRELESS(0), false);
|
||||
spirit_unlock(spirit->spi);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirt_fifo_read
|
||||
*
|
||||
* Description:
|
||||
* Read data from RX FIFO
|
||||
*
|
||||
* Input parameters:
|
||||
* spirit - Reference to an instance of the driver state stucture.
|
||||
* buffer - Pointer to the buffer of data values to write
|
||||
* buflen - Number of bytes to be written
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated errno value is returned on
|
||||
* any failure. On success, spirit->state is updated.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirt_fifo_read(FAR struct spirit_library_s *spirit, FAR uint8_t *buffer,
|
||||
unsigned int buflen)
|
||||
{
|
||||
uint8_t header[2];
|
||||
uint8_t status[2];
|
||||
|
||||
/* Setup the header bytes */
|
||||
|
||||
header[0] = READ_HEADER;
|
||||
header[1] = LINEAR_FIFO_ADDRESS;
|
||||
|
||||
/* Lock the SPI bus and select the Spirit device */
|
||||
|
||||
spirit_lock(spirit->spi);
|
||||
SPI_SELECT(spirit->spi, SPIDEV_WIRELESS(0), true);
|
||||
|
||||
/* Write the header bytes and read the SPIRIT1 status bytes */
|
||||
|
||||
SPI_EXCHANGE(spirit->spi, header, status, 2);
|
||||
|
||||
/* Update Spirit status. 16-bit status is returned MS bit first */
|
||||
|
||||
spirit->u.u16 = ((uint16_t)status[0] << 8) | (uint16_t)status[1];
|
||||
|
||||
/* Read the register values */
|
||||
|
||||
SPI_RECVBLOCK(spirit->spi, buffer, buflen);
|
||||
|
||||
/* Deselect the Spirit device and return the result */
|
||||
|
||||
SPI_SELECT(spirit->spi, SPIDEV_WIRELESS(0), false);
|
||||
spirit_unlock(spirit->spi);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirt_fifo_write
|
||||
*
|
||||
* Description:
|
||||
* Write data into TX FIFO.
|
||||
*
|
||||
* Input parameters:
|
||||
* spirit - Reference to an instance of the driver state stucture.
|
||||
* buffer - Pointer to the buffer of data values to write
|
||||
* buflen - Number of data values to be written.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated errno value is returned on
|
||||
* any failure. On success, spirit->state is updated.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirt_fifo_write(FAR struct spirit_library_s *spirit,
|
||||
FAR const uint8_t *buffer, unsigned int buflen)
|
||||
{
|
||||
uint8_t header[2];
|
||||
uint8_t status[2];
|
||||
|
||||
/* Setup the header bytes */
|
||||
|
||||
header[0] = WRITE_HEADER;
|
||||
header[1] = LINEAR_FIFO_ADDRESS;
|
||||
|
||||
/* Lock the SPI bus and select the Spirit device */
|
||||
|
||||
spirit_lock(spirit->spi);
|
||||
SPI_SELECT(spirit->spi, SPIDEV_WIRELESS(0), true);
|
||||
|
||||
/* Write the header bytes and read the SPIRIT1 status bytes */
|
||||
|
||||
SPI_EXCHANGE(spirit->spi, header, status, 2);
|
||||
|
||||
/* Update Spirit status. 16-bit status is returned MS bit first */
|
||||
|
||||
spirit->u.u16 = ((uint16_t)status[0] << 8) | (uint16_t)status[1];
|
||||
|
||||
/* Write the fifo values */
|
||||
|
||||
SPI_SNDBLOCK(spirit->spi, buffer, buflen);
|
||||
|
||||
/* Deselect the Spirit device and return the result */
|
||||
|
||||
SPI_SELECT(spirit->spi, SPIDEV_WIRELESS(0), false);
|
||||
spirit_unlock(spirit->spi);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_update_status
|
||||
*
|
||||
* Description:
|
||||
* Updates the state field in the driver instance, reading the MC_STATE
|
||||
* register of SPIRIT.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to an instance of the driver state stucture.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated errno value is returned on
|
||||
* any failure. On success, spirit->state is updated.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_update_status(FAR struct spirit_library_s *spirit)
|
||||
{
|
||||
uint8_t regval;
|
||||
|
||||
DEBUGASSERT(spirit != NULL);
|
||||
|
||||
/* Reads the MC_STATUS register to update the spirit->state */
|
||||
|
||||
return spirit_reg_read(spirit, MC_STATE1_BASE, ®val, 1);
|
||||
}
|
||||
141
drivers/wireless/spirit/lib/spirit_timer.c
Normal file
141
drivers/wireless/spirit/lib/spirit_timer.c
Normal file
@@ -0,0 +1,141 @@
|
||||
/******************************************************************************
|
||||
* drivers/wireless/spirit/lib/spirit_timer.c
|
||||
* Configuration and management of SPIRIT timers.
|
||||
*
|
||||
* Copyright(c) 2015 STMicroelectronics
|
||||
* Author: VMA division - AMS
|
||||
* Version 3.2.2 08-July-2015
|
||||
*
|
||||
* Adapted for NuttX by:
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 of STMicroelectronics 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 HOLDER 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 <assert.h>
|
||||
|
||||
#include "spirit_timer.h"
|
||||
#include "spirit_radio.h"
|
||||
#include "spirit_spi.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Pre-processor Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Returns the absolute value. */
|
||||
|
||||
#define S_ABS(a) ((a) > 0 ? (a) : -(a))
|
||||
|
||||
/******************************************************************************
|
||||
* Private Functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Public Functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_timer_set_rxtimeout
|
||||
*
|
||||
* Description:
|
||||
* Sets the RX timeout timer counter. If 'counter' is equal to 0 the
|
||||
* timeout is disabled.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* counter - value for the timer counter.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_timer_set_rxtimeout(FAR struct spirit_library_s *spirit,
|
||||
uint8_t counter)
|
||||
{
|
||||
/* Writes the counter value for RX timeout in the corresponding register */
|
||||
|
||||
return spirit_reg_write(spirit, TIMERS4_RX_TIMEOUT_COUNTER_BASE, &counter, 1);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: spirit_timer_set_rxtimeout_stopcondition
|
||||
*
|
||||
* Description:
|
||||
* Sets the RX timeout stop conditions.
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* stopcondition - New stop condition.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
int spirit_timer_set_rxtimeout_stopcondition(FAR struct spirit_library_s *spirit,
|
||||
enum spirit_rxtimeout_stopcondition_e
|
||||
stopcondition)
|
||||
{
|
||||
uint8_t regval[2];
|
||||
int ret;
|
||||
|
||||
/* Check the parameters */
|
||||
|
||||
DEBUGASSERT(IS_RX_TIMEOUT_STOP_CONDITION(stopcondition));
|
||||
|
||||
/* Reads value on the PKT_FLT_OPTIONS and PROTOCOL2 register */
|
||||
|
||||
ret = spirit_reg_read(spirit, PCKT_FLT_OPTIONS_BASE, regval, 2);
|
||||
if (ret >= 0)
|
||||
{
|
||||
regval[0] &= 0xbf;
|
||||
regval[0] |= ((stopcondition & 0x08) << 3);
|
||||
|
||||
regval[1] &= 0x1f;
|
||||
regval[1] |= (stopcondition << 5);
|
||||
|
||||
/* Write value to the PKT_FLT_OPTIONS and PROTOCOL2 register */
|
||||
|
||||
ret = spirit_reg_write(spirit, PCKT_FLT_OPTIONS_BASE, regval, 2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -52,24 +52,6 @@
|
||||
/* Configuration ************************************************************/
|
||||
/* CONFIG_USBDEV_COMPOSITE
|
||||
* Enables USB composite device support
|
||||
* CONFIG_CDCACM_COMPOSITE
|
||||
* Configure the CDC serial driver as part of a composite driver
|
||||
* (only if CONFIG_USBDEV_COMPOSITE is also defined)
|
||||
* CONFIG_COMPOSITE_COMPOSITE
|
||||
* Configure the mass storage driver as part of a composite driver
|
||||
* (only if CONFIG_USBDEV_COMPOSITE is also defined)
|
||||
* CONFIG_COMPOSITE_EP0MAXPACKET
|
||||
* Max packet size for endpoint 0
|
||||
* CONFIG_COMPOSITE_VENDORID and CONFIG_COMPOSITE_VENDORSTR
|
||||
* The vendor ID code/string
|
||||
* CONFIG_COMPOSITE_PRODUCTID and CONFIG_COMPOSITE_PRODUCTSTR
|
||||
* The product ID code/string
|
||||
* CONFIG_COMPOSITE_SERIALSTR
|
||||
* Device serial number string
|
||||
* CONFIG_COMPOSITE_CONFIGSTR
|
||||
* Configuration string
|
||||
* CONFIG_COMPOSITE_VERSIONNO
|
||||
* Interface version number.
|
||||
*/
|
||||
|
||||
#define COMPOSITE_NSTRIDS (5) /* The numer of String-IDs to
|
||||
|
||||
104
include/nuttx/wireless/spirit.h
Normal file
104
include/nuttx/wireless/spirit.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/wireless/spirit.h
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_WIRELESS_SPIRIT_H
|
||||
#define __INCLUDE_NUTTX_WIRELESS_SPIRIT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* The Spirit provides interrupts to the MCU via a GPIO pin. The
|
||||
* following structure provides an MCU-independent mechanixm for controlling
|
||||
* the Spirit GPIO interrupt.
|
||||
*/
|
||||
|
||||
struct spirit_lower_s
|
||||
{
|
||||
int (*reset)(FAR const struct spirit_lower_s *lower);
|
||||
int (*attach)(FAR const struct spirit_lower_s *lower, xcpt_t handler,
|
||||
FAR void *arg);
|
||||
void (*enable)(FAR const struct spirit_lower_s *lower, bool state);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
struct spi_dev_s; /* Forward reference */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: spirit_netdev_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the IEEE802.15.4 driver and register it as a network device.
|
||||
*
|
||||
* Parameters:
|
||||
* spi - A reference to the platform's SPI driver for the spirit
|
||||
* lower - The MCU-specific interrupt used to control low-level MCU
|
||||
* functions (i.e., spirit GPIO interrupts).
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; Negated errno on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int spirit_netdev_initialize(FAR struct spi_dev_s *spi,
|
||||
FAR const struct spirit_lower_s *lower);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_IEEE802154__AT86RF23X_H */
|
||||
Reference in New Issue
Block a user