diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index a0e22807cf..3b15a38a06 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -8,7 +8,7 @@

NuttX RTOS

-

Last Updated: March 2, 2017

+

Last Updated: April 4, 2018

@@ -974,7 +974,7 @@

  • - Support for networking modules (e.g., the TI CC3000 WLAN module and ESP8266). + Support for networking modules (e.g., ESP8266).
  • @@ -1504,7 +1504,7 @@
  • ARM Cortex-A9 (1)
  • ARM Cortex-R4 (1)
  • ARM Cortex-M0/M0+ (10)
  • -
  • ARM Cortex-M3 (38)
  • +
  • ARM Cortex-M3 (37)
  • ARM Cortex-M4 (44)
  • ARM Cortex-M7 (10)
  • @@ -3128,7 +3128,7 @@ nsh>

    STMicro STM32F103x (STM32 F1 Family). - Support for four MCUs and four board configurations are available. + Support for five board configurations are available. MCU support includes all of the high density and connectivity line families. Board supported is available specifically for: STM32F103ZET6, STM32F103RET6, STM32F103VCT, STM32F103VET6, STM32F103RBT6, and STM32103CBT6. Boards supported include: @@ -3164,19 +3164,6 @@ nsh> see the NuttX board README file for further information about the NuttX port.

    -
  • -

    - Spark (and emulated Spark). - The Spark boards are based on the STM32F103CBT6 chip and feature wireless networking using the TI CC3000 WLAN module. - See the Spark web site for hardware information; - The emulated Spark is a base board for the Maple Mini board (see above) developed by David Sidrane that supports Spark development while we all way breathlessly for or Spark boards. - see the NuttX board README file for further information about the NuttX port. -

    -

    - Initially Spark support was introduced in NuttX 6.31 and completed in NuttX 6.32. - Most of this work is the result of the effort of David Sidrane. -

    -
  • Olimexino-STM32. @@ -3229,13 +3216,6 @@ nsh> Support for the Maple boards was contributed by Yiran Liao and first appear in NuttX 6-30.

  • -
  • -

    - Spark. - David Sidrane has the emulated Spark board up-and-running with a functional CC3000 network, SST25 FAT file system, an NSH shell, and a composite USB CDC/ACM and USBMSC devices. This configuration is was first available NuttX 6.31 and completed in NuttX 6.32. - That is really quite a lot of high end functionality on an STM32 that only has 20KB of RAM! I am impressed! -

    -
  • Olimexino-STM32. diff --git a/Documentation/README.html b/Documentation/README.html index 0083b25137..098e098b8d 100644 --- a/Documentation/README.html +++ b/Documentation/README.html @@ -275,8 +275,6 @@ nuttx/ | | `- README.txt | |- skp16c26/ | | `- README.txt - | |- spark/ - | | `- README.txt | |- stm3210e-eval/ | | |- RIDE/README.txt | | `- README.txt diff --git a/README.txt b/README.txt index 0f8958db95..9cc67a34e9 100644 --- a/README.txt +++ b/README.txt @@ -1843,8 +1843,6 @@ nuttx/ | | `- README.txt | |- skp16c26/ | | `- README.txt - | |- spark/ - | | `- README.txt | |- stm3210e-eval/ | | |- RIDE/README.txt | | `- README.txt diff --git a/configs/Kconfig b/configs/Kconfig index 3a567d65b1..c97c384935 100644 --- a/configs/Kconfig +++ b/configs/Kconfig @@ -1111,17 +1111,6 @@ config ARCH_BOARD_SKP16C26 uses the GNU m32c toolchain. STATUS: The port is complete but untested due to issues with compiler internal errors. -config ARCH_BOARD_SPARK - bool "Spark Core" - depends on ARCH_CHIP_STM32F103CB - select ARCH_HAVE_LEDS - select ARCH_HAVE_BUTTONS - select ARCH_HAVE_IRQBUTTONS - ---help--- - A configuration for the Spark Core from Spark Devices - (http://www.spark.io). This board features the STM32103CBT6 - MCU from STMicro. - config ARCH_BOARD_PHOTON bool "Photon wifi board" depends on ARCH_CHIP_STM32F205RG @@ -1726,7 +1715,6 @@ config ARCH_BOARD default "samv71-xult" if ARCH_BOARD_SAMV71_XULT default "shenzhou" if ARCH_BOARD_SHENZHOU default "skp16c26" if ARCH_BOARD_SKP16C26 - default "spark" if ARCH_BOARD_SPARK default "photon" if ARCH_BOARD_PHOTON default "stm32butterfly2" if ARCH_BOARD_STM32_BUTTERFLY2 default "stm32_tiny" if ARCH_BOARD_STM32_TINY @@ -2120,9 +2108,6 @@ endif if ARCH_BOARD_SKP16C26 source "configs/skp16c26/Kconfig" endif -if ARCH_BOARD_SPARK -source "configs/spark/Kconfig" -endif if ARCH_BOARD_PHOTON source "configs/photon/Kconfig" endif diff --git a/configs/README.txt b/configs/README.txt index ec53cde7fa..34ee5a821e 100644 --- a/configs/README.txt +++ b/configs/README.txt @@ -664,10 +664,6 @@ configs/shenzhou This is the port of NuttX to the Shenzhou development board from www.armjishu.com. This board features the STMicro STM32F107VCT MCU. -configs/spark - Board support for the Spark Core from Spark Devices http://www.sparkdevices.com). - This board features the STM32103CBT6 MCU from STMicro. - configs/skp16c26 Renesas M16C processor on the Renesas SKP16C26 StarterKit. This port uses the GNU m32c toolchain. STATUS: The port is complete but untested diff --git a/configs/freedom-kl25z/README.txt b/configs/freedom-kl25z/README.txt index d8b5da82a5..b043df6144 100644 --- a/configs/freedom-kl25z/README.txt +++ b/configs/freedom-kl25z/README.txt @@ -369,25 +369,3 @@ Where is one of the following: 5. This configurations has support for NSH built-in applications. However, in the default configuration no built-in applications are enabled. - - 6. This configuration has been used to verify the TI CC3000 wireless - networking module. In order to enable this module, you would need to - make the following changes to the default configuration files: - - System Type -> Kinetis peripheral support - CONFIG_KL_SPI0=y : Enable SPI - CONFIG_KL_SPI1=y - - Drivers -> SPI - CONFIG_SPI=y : Enable SPI - CONFIG_SPI_EXCHANGE=y - - Drivers -> Wireless - CONFIG_DRIVERS_WIRELESS=y : Enable wireless support - CONFIG_WL_CC3000=y : Build the CC3000 driver - - Applications -> Examples - CONFIG_EXAMPLES_CC3000BASIC=y : CC3000 test example - - Applications -> NSH Library - CONFIG_NSH_ARCHINIT=y : Build in CC3000 initialization logic diff --git a/configs/freedom-kl25z/include/board.h b/configs/freedom-kl25z/include/board.h index 918b00d73d..42a7454a8b 100644 --- a/configs/freedom-kl25z/include/board.h +++ b/configs/freedom-kl25z/include/board.h @@ -218,12 +218,6 @@ #define PIN_SPI1_MISO (PIN_SPI1_MISO_3 | PIN_ALT2_PULLUP) #define PIN_SPI1_MOSI (PIN_SPI0_MOSI_7 | PIN_ALT2_PULLUP) -/* These pins are used by CC3000 module */ - -#define GPIO_WIFI_EN (GPIO_OUTPUT | GPIO_OUTPUT_ZER0 | PIN_PORTC | PIN12) -#define GPIO_WIFI_IRQ (GPIO_INPUT | PIN_PORTA | PIN16) -#define GPIO_WIFI_CS (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTE | PIN1) - /* Interrupt pin used by ADXL345 * * CS = PTD0 (D10 at connector J2 pin 6 of Freedom Board) diff --git a/configs/freedom-kl25z/include/kl_cc3000.h b/configs/freedom-kl25z/include/kl_cc3000.h deleted file mode 100644 index ce252a67a0..0000000000 --- a/configs/freedom-kl25z/include/kl_cc3000.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** - * configs/freedom-kl25z/include/kl_cc300.h - * - * Copyright (C) 2013 Alan Carvalho de Assis - * Author: Alan Carvalho de Assis - * with adaptions from Gregory Nutt - * - * Reference: https://community.freescale.com/community/ - * the-embedded-beat/blog/2012/10/15/ - * using-the-touch-interface-on-the-freescale-freedom-development-platform - * - * 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 __CONFIGS_FREEDOM_KL25Z_INCLUDE_KL_CC3000_H -#define __CONFIGS_FREEDOM_KL25Z_INCLUDE_KL_CC3000_H 1 - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -long ReadWlanInterruptPin(void); - -/* Enable WiFi Interrupt */ - -void WlanInterruptEnable(void); - -/* Disable WiFi Interrupt */ - -void WlanInterruptDisable(void); - -/* Enable/Disable WiFi */ - -void WriteWlanEnablePin(uint8_t val); - -/* Assert CC3000 CS */ - -void AssertWlanCS(void); - -/* Deassert CC3000 CS */ - -void DeassertWlanCS(void); - -/* Setup needed pins */ - -void Wlan_Setup(void); - -#endif /* __CONFIGS_FREEDOM_KL25Z_INCLUDE_KL_CC3000_H */ - diff --git a/configs/freedom-kl25z/src/Makefile b/configs/freedom-kl25z/src/Makefile index 843155c3bc..9da4c3d8db 100644 --- a/configs/freedom-kl25z/src/Makefile +++ b/configs/freedom-kl25z/src/Makefile @@ -42,10 +42,6 @@ ifeq ($(CONFIG_LIB_BOARDCTL),y) CSRCS += kl_appinit.c endif -ifeq ($(CONFIG_WL_CC3000),y) -CSRCS += kl_cc3000.c -endif - ifeq ($(CONFIG_KL_TSI),y) CSRCS += kl_tsi.c endif diff --git a/configs/freedom-kl25z/src/kl_boardinitialize.c b/configs/freedom-kl25z/src/kl_boardinitialize.c index 4da407d238..81eea49cfd 100644 --- a/configs/freedom-kl25z/src/kl_boardinitialize.c +++ b/configs/freedom-kl25z/src/kl_boardinitialize.c @@ -127,10 +127,5 @@ void board_initialize(void) (void)board_app_initialize(0); #endif - /* CC3000 wireless initialization */ - -#ifdef CONFIG_WL_CC3000 - wireless_archinitialize(0); -#endif } #endif diff --git a/configs/freedom-kl25z/src/kl_cc3000.c b/configs/freedom-kl25z/src/kl_cc3000.c deleted file mode 100644 index c446ff870b..0000000000 --- a/configs/freedom-kl25z/src/kl_cc3000.c +++ /dev/null @@ -1,375 +0,0 @@ -/**************************************************************************** - * configs/freedom-kl25z/src/kl_cc3000.c - * - * Copyright (C) 2014 Alan Carvalho de Assis - * Author: Alan Carvalho de Assis - * - * 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 -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "up_arch.h" -#include "kl_gpio.h" -#include "chip/kl_pinmux.h" -#include "chip/kl_sim.h" -#include "freedom-kl25z.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifdef CONFIG_WL_CC3000 -#ifndef CONFIG_DRIVERS_WIRELESS -# error "Wireless support requires CONFIG_DRIVERS_WIRELESS" -#endif - -#ifndef CONFIG_KL_SPI0 -# error "CC3000 Wireless support requires CONFIG_KL_SPI0" -#endif - -#ifndef CC3000_SPI_FREQUENCY -# define CC3000_SPI_FREQUENCY 16000000 -#endif - -#ifndef CC3000_SPIDEV -# define CC3000_SPIDEV 0 -#endif - -#if CC3000_SPIDEV != 0 -# error "CC3000_SPIDEV must be 0" -#endif - -#ifndef CC3000_DEVMINOR -# define CC3000_DEVMINOR 0 -#endif - -#ifndef CONFIG_CC3000_RX_BUFFER_SIZE -# define CONFIG_CC3000_RX_BUFFER_SIZE 132 -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -struct kl_config_s -{ - struct cc3000_config_s dev; - xcpt_t handler; -}; - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks - * to isolate the CC3000 driver from differences in GPIO interrupt handling - * by varying boards and MCUs. If possible, interrupts should be configured - * on falling edges to detect the Ready Condition At T2: The normal master - * SPI write sequence is SPI_CS low, followed by SPI_IRQ low CC3000 to host, - * indicating that the CC3000 core module is ready to accept data. T2 - * duration is approximately 7 ms. - * - * irq_attach - Attach the CC3000 interrupt handler to the GPIO - * interrupt - * irq_enable - Enable or disable the GPIO interrupt - * irq_clear - Acknowledge/clear any pending GPIO interrupt - * power_enable - Enable or disable Module enable. - * chip_chip_select - The Chip Select - * irq_read - Return the state of the interrupt GPIO input - * probe - Debug support - */ - -static int wl_attach_irq(FAR struct cc3000_config_s *state, xcpt_t handler, - FAR void *arg); -static void wl_enable_irq(FAR struct cc3000_config_s *state, bool enable); -static void wl_clear_irq(FAR struct cc3000_config_s *state); -static void wl_select(FAR struct cc3000_config_s *state, bool enable); -static void wl_enable_power(FAR struct cc3000_config_s *state, bool enable); -static bool wl_read_irq(FAR struct cc3000_config_s *state); -#ifdef CONFIG_CC3000_PROBES -static bool probe(FAR struct cc3000_config_s *state,int n, bool s); -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* A reference to a structure of this type must be passed to the CC3000 - * driver. This structure provides information about the configuration - * of the CC3000 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 kl_config_s g_cc3000_info = -{ - .dev.spi_frequency = CONFIG_CC3000_SPI_FREQUENCY, - .dev.spi_mode = CONFIG_CC3000_SPI_MODE, - .dev.max_rx_size = 0, - .dev.irq_attach = wl_attach_irq, - .dev.irq_enable = wl_enable_irq, - .dev.irq_clear = wl_clear_irq, - .dev.power_enable = wl_enable_power, - .dev.chip_chip_select = wl_select, - .dev.irq_read = wl_read_irq, -#ifdef CONFIG_CC3000_PROBES - .dev.probe = probe, /* This is used for debugging */ -#endif - .handler = NULL, - .arg = NULL, -}; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/* IRQ/GPIO access callbacks. These operations all hidden behind - * callbacks to isolate the CC3000 driver from differences in GPIO - * interrupt handling by varying boards and MCUs. If possible, - * interrupts should be configured on both rising and falling edges - * so that contact and loss-of-contact events can be detected. - * - * irq_attach - Attach the CC3000 interrupt handler to the GPIO - * interrupt - * irq_enable - Enable or disable the GPIO interrupt - * irq_clear - Acknowledge/clear any pending GPIO interrupt - * power_enable - Enable or disable Module enable. - * chip_chip_select - The Chip Select - * irq_read - Return the state of the interrupt GPIO input - * probe - Debug support - */ - -static int wl_attach_irq(FAR struct cc3000_config_s *state, xcpt_t handler, - FAR void *arg) -{ - FAR struct kl_config_s *priv = (FAR struct kl_config_s *)state; - - /* Just save the handler for use when the interrupt is enabled */ - - priv->handler = handler; - priv->arg = arg; - return OK; -} - -static void wl_enable_irq(FAR struct cc3000_config_s *state, bool enable) -{ - FAR struct kl_config_s *priv = (FAR struct kl_config_s *)state; - - /* The caller should not attempt to enable interrupts if the handler - * has not yet been 'attached' - */ - - DEBUGASSERT(priv->handler || !enable); - - /* Attach and enable, or detach and disable */ - - iinfo("enable:%d\n", enable); - if (enable) - { - (void)kl_gpioirqattach(GPIO_WIFI_INT, priv->handler, priv->arg); - kl_gpioirqenable(GPIO_WIFI_INT); - } - else - { - (void)kl_gpioirqattach(GPIO_WIFI_INT, NULL, NULL); - kl_gpioirqdisable(GPIO_WIFI_INT); - } -} - -static void wl_enable_power(FAR struct cc3000_config_s *state, bool enable) -{ - iinfo("enable:%d\n", enable); - - /* Active high enable */ - - kl_gpiowrite(GPIO_WIFI_EN, enable); -} - -static void wl_select(FAR struct cc3000_config_s *state, bool enable) -{ - iinfo("enable:%d\n", enable); - - /* Active high enable */ - - kl_gpiowrite(GPIO_WIFI_CS, enable); -} - -static void wl_clear_irq(FAR struct cc3000_config_s *state) -{ - /* Does nothing */ -} - -static bool wl_read_irq(FAR struct cc3000_config_s *state) -{ - /* Active low*/ - - return kl_gpioread(GPIO_WIFI_INT) ? false : true; -} - -#ifdef CONFIG_CC3000_PROBES -static bool probe(FAR struct cc3000_config_s *state,int n, bool s) -{ - if (n == 0) - { - kl_gpiowrite(GPIO_D0, s); - } - - if (n == 1) - { - kl_gpiowrite(GPIO_D1, s); - } - - return true; -} -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arch_wlinitialize - * - * Description: - * Each board that supports a wireless device must provide this function. - * This function is called by application-specific, setup logic to - * configure the wireless device. This function will register the driver - * as /dev/wirelessN where N is the minor device number. - * - * Returned Value: - * Zero is returned on success. Otherwise, a negated errno value is - * returned to indicate the nature of the failure. - * - ****************************************************************************/ - -int wireless_archinitialize(size_t max_rx_size) -{ - FAR struct spi_dev_s *spi; - - /* Init SPI bus */ - - iinfo("minor %d\n", minor); - DEBUGASSERT(CONFIG_CC3000_DEVMINOR == 0); - -#ifdef CONFIG_CC3000_PROBES - kl_configgpio(GPIO_D0); - kl_configgpio(GPIO_D1); - kl_gpiowrite(GPIO_D0, 1); - kl_gpiowrite(GPIO_D1, 1); -#endif - - /* Get an instance of the SPI interface */ - - spi = kl_spibus_initialize(CONFIG_CC3000_SPIDEV); - if (!spi) - { - ierr("ERROR: Failed to initialize SPI bus %d\n", CONFIG_CC3000_SPIDEV); - return -ENODEV; - } - - /* Initialize and register the SPI CC3000 device */ - - g_cc3000_info.dev.max_rx_size = max_rx_size ? max_rx_size : CONFIG_CC3000_RX_BUFFER_SIZE; - int ret = cc3000_register(spi, &g_cc3000_info.dev, CONFIG_CC3000_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to initialize SPI bus %d\n", CONFIG_CC3000_SPIDEV); - return -ENODEV; - } - - return OK; -} - -/**************************************************************************** - * Name: C3000_wlan_init - * - * Description: - * Initialize wlan driver - * - * Warning: This function must be called before ANY other wlan driver - * function - * - * Input Parameters: - * sWlanCB Asynchronous events callback. - * 0 no event call back. - * - Call back parameters: - * 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event, - * HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event, - * HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done, - * HCI_EVNT_WLAN_UNSOL_DHCP dhcp report, - * HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR - * HCI_EVNT_WLAN_KEEPALIVE keepalive. - * 2) data: pointer to extra data that received by the event - * (NULL no data). - * 3) length: data length. - * - Events with extra data: - * HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask, - * 4 bytes default gateway, 4 bytes DHCP server and 4 bytes - * for DNS server. - * HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent, - * 4 bytes Packets received, 4 bytes Min round time, - * 4 bytes Max round time and 4 bytes for Avg round time. - * - * sFWPatches 0 no patch or pointer to FW patches - * sDriverPatches 0 no patch or pointer to driver patches - * sBootLoaderPatches 0 no patch or pointer to bootloader patches - * - * Returned Value: - * None - * - ****************************************************************************/ - -void cc3000_wlan_init(size_t max_tx_len, - tWlanCB sWlanCB, - tFWPatches sFWPatches, tDriverPatches - sDriverPatches, tBootLoaderPatches sBootLoaderPatches) -{ - wlan_init(max_tx_len, sWlanCB, sFWPatches, sDriverPatches, sBootLoaderPatches); -} - -#endif /* CONFIG_WL_CC3000 */ diff --git a/configs/freedom-kl25z/src/kl_spi.c b/configs/freedom-kl25z/src/kl_spi.c index 566af53909..99c562f02b 100644 --- a/configs/freedom-kl25z/src/kl_spi.c +++ b/configs/freedom-kl25z/src/kl_spi.c @@ -71,12 +71,6 @@ void weak_function kl_spidev_initialize(void) # ifdef CONFIG_ADXL345_SPI kl_configgpio(GPIO_ADXL345_CS); #endif - -# ifdef CONFIG_WL_CC3000 - kl_configgpio(GPIO_WIFI_CS); - kl_configgpio(GPIO_WIFI_EN); - kl_configgpio(GPIO_WIFI_INT); -# endif #endif /* Configure SPI1 chip selects */ @@ -153,14 +147,6 @@ void kl_spi0select(FAR struct spi_dev_s *dev, uint32_t devid, kl_gpiowrite(GPIO_ADXL345_CS, !selected); } #endif - -#if defined(CONFIG_WL_CC3000) - if (devid == SPIDEV_WIRELESS(0)) - { - kl_gpiowrite(GPIO_WIFI_CS, !selected); - } -#endif - } #endif diff --git a/configs/nucleo-f4x1re/src/Makefile b/configs/nucleo-f4x1re/src/Makefile index 0636f64f5c..a836bb6370 100644 --- a/configs/nucleo-f4x1re/src/Makefile +++ b/configs/nucleo-f4x1re/src/Makefile @@ -48,13 +48,6 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y) CSRCS += stm32_buttons.c endif -ifeq ($(CONFIG_WL_CC3000),y) -CSRCS += stm32_wireless.c -ifeq ($(CONFIG_CC3000_PROBES),) -CSRCS += stm32_io.c -endif -endif - ifeq ($(CONFIG_ADC),y) CSRCS += stm32_adc.c ifeq ($(CONFIG_AJOYSTICK),y) diff --git a/configs/nucleo-f4x1re/src/nucleo-f4x1re.h b/configs/nucleo-f4x1re/src/nucleo-f4x1re.h index 88a7cf4440..59d96c0604 100644 --- a/configs/nucleo-f4x1re/src/nucleo-f4x1re.h +++ b/configs/nucleo-f4x1re/src/nucleo-f4x1re.h @@ -103,33 +103,6 @@ * */ -#ifdef CONFIG_WL_CC3000 -# define GPIO_WIFI_INT (GPIO_PORTB | GPIO_PIN3 | GPIO_INPUT | \ - GPIO_PULLUP | GPIO_EXTI) -# define GPIO_WIFI_EN (GPIO_PORTB | GPIO_PIN4 | GPIO_OUTPUT_CLEAR | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_WIFI_CS (GPIO_PORTB | GPIO_PIN6 | GPIO_OUTPUT_SET | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_D14 (GPIO_PORTB | GPIO_PIN9 | GPIO_OUTPUT_CLEAR | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_D15 (GPIO_PORTB | GPIO_PIN8 | GPIO_OUTPUT_CLEAR | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_D0 (GPIO_PORTA | GPIO_PIN3 | GPIO_INPUT | \ - GPIO_PULLUP) -# define GPIO_D1 (GPIO_PORTA | GPIO_PIN2 | GPIO_OUTPUT_CLEAR | \ - GPIO_PULLUP) -# define GPIO_D2 (GPIO_PORTA | GPIO_PIN10 | GPIO_OUTPUT_CLEAR | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_A0 (GPIO_PORTA | GPIO_PIN0 | GPIO_OUTPUT_SET | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_A1 (GPIO_PORTA | GPIO_PIN1 | GPIO_OUTPUT_SET | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_A2 (GPIO_PORTA | GPIO_PIN4 | GPIO_INPUT | \ - GPIO_PULLUP) -# define GPIO_A3 (GPIO_PORTB | GPIO_PIN0 | GPIO_INPUT | \ - GPIO_PULLUP) -#endif - /* SPI1 off */ #define GPIO_SPI1_MOSI_OFF (GPIO_INPUT | GPIO_PULLDOWN | \ @@ -139,28 +112,12 @@ #define GPIO_SPI1_SCK_OFF (GPIO_INPUT | GPIO_PULLDOWN | \ GPIO_PORTA | GPIO_PIN5) -/* SPI1 chip selects off */ - -#ifdef CONFIG_WL_CC3000 -# define GPIO_SPI_CS_WIFI_OFF \ - (GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \ - GPIO_PORTB | GPIO_PIN6) -#endif - #ifdef HAVE_MMCSD # define GPIO_SPI_CS_SD_CARD_OFF \ (GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \ GPIO_PORTB | GPIO_PIN5) #endif -/* SPI chip selects */ - -#ifdef CONFIG_WL_CC3000 -# define GPIO_SPI_CS_WIFI \ - (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \ - GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN6) -#endif - #ifdef HAVE_MMCSD # define GPIO_SPI_CS_SD_CARD \ (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \ @@ -175,24 +132,6 @@ #define NUCLEO_I2C_OBDEV_LED 0x55 #define NUCLEO_I2C_OBDEV_HMC5883 0x1e -/* User GPIOs - * - * GPIO0-1 are for probing WIFI status - */ - -#ifdef CONFIG_WL_CC3000 -# define GPIO_GPIO0_INPUT \ - (GPIO_INPUT | GPIO_PULLUP | GPIO_PORTB | GPIO_PIN8) -# define GPIO_GPIO1_INPUT \ - (GPIO_INPUT | GPIO_PULLUP | GPIO_PORTB | GPIO_PIN9) -# define GPIO_GPIO0_OUTPUT \ - (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \ - GPIO_OUTPUT_CLEAR | GPIO_PORTB | GPIO_PIN8) -# define GPIO_GPIO1_OUTPUT \ - (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \ - GPIO_OUTPUT_CLEAR | GPIO_PORTB | GPIO_PIN9) -#endif - /* Itead Joystick Shield * * See http://imall.iteadstudio.com/im120417014.html for more information diff --git a/configs/nucleo-f4x1re/src/stm32_appinit.c b/configs/nucleo-f4x1re/src/stm32_appinit.c index 05b0c54880..7028c55a21 100644 --- a/configs/nucleo-f4x1re/src/stm32_appinit.c +++ b/configs/nucleo-f4x1re/src/stm32_appinit.c @@ -59,20 +59,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_netinitialize - * - * Description: - * Dummy function expected to start-up logic. - * - ****************************************************************************/ - -#ifdef CONFIG_WL_CC3000 -void up_netinitialize(void) -{ -} -#endif - /**************************************************************************** * Name: board_app_initialize * diff --git a/configs/nucleo-f4x1re/src/stm32_boot.c b/configs/nucleo-f4x1re/src/stm32_boot.c index 2b6f69e65e..1fb22f61e7 100644 --- a/configs/nucleo-f4x1re/src/stm32_boot.c +++ b/configs/nucleo-f4x1re/src/stm32_boot.c @@ -123,11 +123,5 @@ void board_initialize(void) #if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_LIB_BOARDCTL) board_app_initialize(0); #endif - - /* CC3000 wireless initialization */ - -#ifdef CONFIG_WL_CC3000 - wireless_archinitialize(0); -#endif } #endif diff --git a/configs/nucleo-f4x1re/src/stm32_io.c b/configs/nucleo-f4x1re/src/stm32_io.c deleted file mode 100644 index a319e69a83..0000000000 --- a/configs/nucleo-f4x1re/src/stm32_io.c +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** - * configs/nucleo-f4x1re/src/stm32_io.c - * - * Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include - -#include -#include "chip/stm32_tim.h" - -#include "nucleo-f4x1re.h" - -#ifndef CONFIG_CC3000_PROBES - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_leds - * - * Description: - * - ****************************************************************************/ - -void up_leds(int r, int g ,int b, int freqs) -{ - long fosc = 72000000; - long prescale = 2048; - long p1s = fosc/prescale; - long p0p5s = p1s/2; - long p; - - static struct stm32_tim_dev_s *tim1 = 0; - - if (tim1 == 0) - { - tim1 = stm32_tim_init(1); - STM32_TIM_SETMODE(tim1, STM32_TIM_MODE_UP); - STM32_TIM_SETCLOCK(tim1, p1s-8); - STM32_TIM_SETPERIOD(tim1, p1s); - STM32_TIM_SETCOMPARE(tim1, 1, 0); - STM32_TIM_SETCOMPARE(tim1, 2, 0); - STM32_TIM_SETCOMPARE(tim1, 3, 0); - STM32_TIM_SETCHANNEL(tim1, 1, STM32_TIM_CH_OUTPWM | STM32_TIM_CH_POLARITY_NEG); - STM32_TIM_SETCHANNEL(tim1, 2, STM32_TIM_CH_OUTPWM | STM32_TIM_CH_POLARITY_NEG); - STM32_TIM_SETCHANNEL(tim1, 3, STM32_TIM_CH_OUTPWM | STM32_TIM_CH_POLARITY_NEG); - } - - p = freqs == 0 ? p1s : p1s / freqs; - STM32_TIM_SETPERIOD(tim1, p); - - p = freqs == 0 ? p1s + 1 : p0p5s / freqs; - - STM32_TIM_SETCOMPARE(tim1, 2, (r * p) / 255); - STM32_TIM_SETCOMPARE(tim1, 1, (b * p) / 255); - STM32_TIM_SETCOMPARE(tim1, 3, (g * p) / 255); -} - -/**************************************************************************** - * Name: up_ioinit - * - * Description: - * - ****************************************************************************/ - -void up_ioinit(void) -{ - /* Configure the GPIO pins as inputs. NOTE that EXTI interrupts are - * configured for all pins. - */ - - up_leds(0,0,0,0); - stm32_configgpio(GPIO_A0); /* Probes */ - stm32_configgpio(GPIO_A1); /* Probes */ - stm32_configgpio(GPIO_A2); /* Smart Config */ - stm32_configgpio(GPIO_A3); /* not used */ - stm32_configgpio(GPIO_BTN_USER); /* Sw 1 */ - stm32_configgpio(GPIO_D0); /* USART2 RX*/ - stm32_configgpio(GPIO_D1); /* uSART2 TX*/ - stm32_configgpio(GPIO_D2); /* Activate */ -} - -/**************************************************************************** - * Name: up_read_inputs - * - * N.B The return state in true logic, the button polarity is dealt here in - * - ****************************************************************************/ - -uint8_t up_read_inputs(void) -{ - uint8_t bits = 0; - bits |= stm32_gpioread(GPIO_D14) == 0 ? 1 : 0; - bits |= stm32_gpioread(GPIO_D15) == 0 ? 2 : 0; - bits |= stm32_gpioread(GPIO_A2) == 0 ? 4 : 0; - bits |= stm32_gpioread(GPIO_A3) == 0 ? 8 : 0; - return bits; -} - -/**************************************************************************** - * Name: up_write_outputs - * - * N.B The return state in true logic, the button polarity is dealt here in - * - ****************************************************************************/ - -void up_write_outputs(int id, bool bits) -{ - if (id == 2) - { - stm32_gpiowrite(GPIO_D2, bits); - } - else if (id == 0) - { - stm32_gpiowrite(GPIO_A0, bits); - } - else if (id == 1) - { - stm32_gpiowrite(GPIO_A1, bits); - } -} - -/**************************************************************************** - * Name: up_irqio - * - * Description: - * - ****************************************************************************/ - -int up_irqio(int id, xcpt_t irqhandler, void *arg) -{ - int ret = -EINVAL; - - /* The following should be atomic */ - - if (id == 0) - { - ret = stm32_gpiosetevent(GPIO_D14, true, true, true, irqhandler, arg); - } - else if (id == 1) - { - ret = stm32_gpiosetevent(GPIO_D15, true, true, true, irqhandler, arg); - } - - return ret; -} -#endif /* CONFIG_CC3000_PROBES */ diff --git a/configs/nucleo-f4x1re/src/stm32_spi.c b/configs/nucleo-f4x1re/src/stm32_spi.c index cdcb582fd5..4f8027a596 100644 --- a/configs/nucleo-f4x1re/src/stm32_spi.c +++ b/configs/nucleo-f4x1re/src/stm32_spi.c @@ -91,10 +91,6 @@ void weak_function stm32_spidev_initialize(void) spierr("ERROR: FAILED to initialize SPI port 1\n"); } -#ifdef CONFIG_WL_CC3000 - stm32_configgpio(GPIO_SPI_CS_WIFI); -#endif - #ifdef HAVE_MMCSD stm32_configgpio(GPIO_SPI_CS_SD_CARD); #endif @@ -104,14 +100,6 @@ void weak_function stm32_spidev_initialize(void) /* Configure SPI-based devices */ g_spi2 = stm32_spibus_initialize(2); - - /* Setup CS, EN & IRQ line IOs */ - -#ifdef CONFIG_WL_CC3000 - stm32_configgpio(GPIO_WIFI_CS); - stm32_configgpio(GPIO_WIFI_EN); - stm32_configgpio(GPIO_WIFI_INT); -#endif #endif } @@ -145,13 +133,6 @@ void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); -#ifdef CONFIG_WL_CC3000 - if (devid == SPIDEV_WIRELESS(0)) - { - stm32_gpiowrite(GPIO_SPI_CS_WIFI, !selected); - } - else -#endif #ifdef HAVE_MMCSD if (devid == SPIDEV_MMCSD(0)) { @@ -170,13 +151,6 @@ uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) void stm32_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); - -#ifdef CONFIG_WL_CC3000 - if (devid == SPIDEV_WIRELESS(0)) - { - stm32_gpiowrite(GPIO_WIFI_CS, !selected); - } -#endif } uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) diff --git a/configs/nucleo-f4x1re/src/stm32_wireless.c b/configs/nucleo-f4x1re/src/stm32_wireless.c deleted file mode 100644 index b868cad46c..0000000000 --- a/configs/nucleo-f4x1re/src/stm32_wireless.c +++ /dev/null @@ -1,367 +0,0 @@ -/************************************************************************************ - * configs/nucleo-f4x1re/src/stm32_wireless.c - * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. - * Author: Laurent Latil - * David Sidrane - * - * 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 - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "stm32.h" -#include "nucleo-f4x1re.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ -/* Configuration ************************************************************/ - -#ifdef CONFIG_WL_CC3000 -#ifndef CONFIG_DRIVERS_WIRELESS -# error "Wireless support requires CONFIG_DRIVERS_WIRELESS" -#endif - -#ifndef CONFIG_STM32_SPI2 -# error "CC3000 Wireless support requires CONFIG_STM32_SPI2" -#endif - -#ifndef CC3000_SPI_FREQUENCY -# define CC3000_SPI_FREQUENCY 16000000 -#endif - -#ifndef CC3000_SPIDEV -# define CC3000_SPIDEV 2 -#endif - -#if CC3000_SPIDEV != 2 -# error "CC3000_SPIDEV must be 2" -#endif - -#ifndef CC3000_DEVMINOR -# define CC3000_DEVMINOR 0 -#endif - -#ifndef CONFIG_CC3000_RX_BUFFER_SIZE -#define CONFIG_CC3000_RX_BUFFER_SIZE 132 -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -struct stm32_config_s -{ - struct cc3000_config_s dev; - xcpt_t handler; -}; - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks - * to isolate the CC3000 driver from differences in GPIO interrupt handling - * by varying boards and MCUs. If possible, interrupts should be configured - * on falling edges to detect the Ready Condition At T2: The normal master - * SPI write sequence is SPI_CS low, followed by SPI_IRQ low CC3000 to host, - * indicating that the CC3000 core module is ready to accept data. T2 - * duration is approximately 7 ms. - * - * irq_attach - Attach the CC3000 interrupt handler to the GPIO interrupt - * irq_enable - Enable or disable the GPIO interrupt - * clear_irq - Acknowledge/clear any pending GPIO interrupt - * power_enable - Enable or disable Module enable. - * chip_chip_select - The Chip Select - * wl_read_irq - Return the state of the interrupt GPIO input - */ - -static int wl_attach_irq(FAR struct cc3000_config_s *state, xcpt_t handler, - FAR void *arg); -static void wl_enable_irq(FAR struct cc3000_config_s *state, bool enable); -static void wl_clear_irq(FAR struct cc3000_config_s *state); -static void wl_select(FAR struct cc3000_config_s *state, bool enable); -static void wl_enable_power(FAR struct cc3000_config_s *state, bool enable); -static bool wl_read_irq(FAR struct cc3000_config_s *state); -#ifdef CONFIG_CC3000_PROBES -static bool probe(FAR struct cc3000_config_s *state,int n, bool s); -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* A reference to a structure of this type must be passed to the CC3000 - * driver. This structure provides information about the configuration - * of the CC3000 and provides some board-specific hooks. - * - * Memory for this structure is provided by the caller. It is not copied - * by the driver and is presumed to persist while the driver is active. The - * memory must be writable because, under certain circumstances, the driver - * may modify frequency or X plate resistance values. - */ - -static struct stm32_config_s g_cc3000_info = -{ - .dev.spi_frequency = CONFIG_CC3000_SPI_FREQUENCY, - .dev.spi_mode = CONFIG_CC3000_SPI_MODE, - .dev.max_rx_size = 0, - .dev.irq_attach = wl_attach_irq, - .dev.irq_enable = wl_enable_irq, - .dev.irq_clear = wl_clear_irq, - .dev.power_enable = wl_enable_power, - .dev.chip_chip_select = wl_select, - .dev.irq_read = wl_read_irq, -#ifdef CONFIG_CC3000_PROBES - .dev.probe = probe, /* This is used for debugging */ -#endif - .handler = NULL, - .arg = NULL, -}; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/* IRQ/GPIO access callbacks. These operations all hidden behind - * callbacks to isolate the CC3000 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. - * - * attach - Attach the CC3000 interrupt handler to the GPIO interrupt - * enable - Enable or disable the GPIO interrupt - * clear - Acknowledge/clear any pending GPIO interrupt - * pendown - Return the state of the pen down GPIO input - */ - -static int wl_attach_irq(FAR struct cc3000_config_s *state, xcpt_t handler, - FAR void *arg) -{ - FAR struct stm32_config_s *priv = (FAR struct stm32_config_s *)state; - - /* Just save the handler for use when the interrupt is enabled */ - - priv->handler = handler; - priv->arg = arg; - return OK; -} - -static void wl_enable_irq(FAR struct cc3000_config_s *state, bool enable) -{ - FAR struct stm32_config_s *priv = (FAR struct stm32_config_s *)state; - - /* The caller should not attempt to enable interrupts if the handler - * has not yet been 'attached' - */ - - DEBUGASSERT(priv->handler || !enable); - - /* Attach and enable, or detach and disable */ - - iinfo("enable:%d\n", enable); - if (enable) - { - (void)stm32_gpiosetevent(GPIO_WIFI_INT, false, true, false, - priv->handler, priv->arg); - } - else - { - (void)stm32_gpiosetevent(GPIO_WIFI_INT, false, false, false, - NULL, NULL); - } -} - -static void wl_enable_power(FAR struct cc3000_config_s *state, bool enable) -{ - iinfo("enable:%d\n", enable); - - /* Active high enable */ - - stm32_gpiowrite(GPIO_WIFI_EN, enable); -} - -static void wl_select(FAR struct cc3000_config_s *state, bool enable) -{ - iinfo("enable:%d\n", enable); - - /* Active high enable */ - - stm32_gpiowrite(GPIO_WIFI_CS, enable); -} - -static void wl_clear_irq(FAR struct cc3000_config_s *state) -{ - /* Does nothing */ -} - -static bool wl_read_irq(FAR struct cc3000_config_s *state) -{ - /* Active low*/ - - return stm32_gpioread(GPIO_WIFI_INT) ? false : true; -} - -#ifdef CONFIG_CC3000_PROBES -static bool probe(FAR struct cc3000_config_s *state,int n, bool s) -{ - if (n == 0) - { - stm32_gpiowrite(GPIO_D14, s); - } - - if (n == 1) - { - stm32_gpiowrite(GPIO_D15, s); - } - - return true; -} -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arch_wlinitialize - * - * Description: - * Each board that supports a wireless device must provide this function. - * This function is called by application-specific, setup logic to - * configure the wireless device. This function will register the driver - * as /dev/wirelessN where N is the minor device number. - * - * Returned Value: - * Zero is returned on success. Otherwise, a negated errno value is - * returned to indicate the nature of the failure. - * - ****************************************************************************/ - -int wireless_archinitialize(size_t max_rx_size) -{ - FAR struct spi_dev_s *spi; - - /* Init SPI bus */ - - iinfo("minor %d\n", minor); - DEBUGASSERT(CONFIG_CC3000_DEVMINOR == 0); - -#ifdef CONFIG_CC3000_PROBES - stm32_configgpio(GPIO_D14); - stm32_configgpio(GPIO_D15); - stm32_gpiowrite(GPIO_D14, 1); - stm32_gpiowrite(GPIO_D15, 1); -#endif - - /* Get an instance of the SPI interface */ - - spi = stm32_spibus_initialize(CONFIG_CC3000_SPIDEV); - if (!spi) - { - ierr("ERROR: Failed to initialize SPI bus %d\n", CONFIG_CC3000_SPIDEV); - return -ENODEV; - } - - /* Initialize and register the SPI CC3000 device */ - - g_cc3000_info.dev.max_rx_size = max_rx_size ? max_rx_size : CONFIG_CC3000_RX_BUFFER_SIZE; - int ret = cc3000_register(spi, &g_cc3000_info.dev, CONFIG_CC3000_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to initialize SPI bus %d\n", CONFIG_CC3000_SPIDEV); - return -ENODEV; - } - - return OK; -} - -/**************************************************************************** - * Name: C3000_wlan_init - * - * Description: - * Initialize wlan driver - * - * Warning: This function must be called before ANY other wlan driver - * function - * - * Input Parameters: - * sWlanCB Asynchronous events callback. - * 0 no event call back. - * - Call back parameters: - * 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event, - * HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event, - * HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done, - * HCI_EVNT_WLAN_UNSOL_DHCP dhcp report, - * HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR - * HCI_EVNT_WLAN_KEEPALIVE keepalive. - * 2) data: pointer to extra data that received by the event - * (NULL no data). - * 3) length: data length. - * - Events with extra data: - * HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask, - * 4 bytes default gateway, 4 bytes DHCP server and 4 bytes - * for DNS server. - * HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent, - * 4 bytes Packets received, 4 bytes Min round time, - * 4 bytes Max round time and 4 bytes for Avg round time. - * - * sFWPatches 0 no patch or pointer to FW patches - * sDriverPatches 0 no patch or pointer to driver patches - * sBootLoaderPatches 0 no patch or pointer to bootloader patches - * - * Returned Value: - * None - * - ****************************************************************************/ - -void cc3000_wlan_init(size_t max_tx_len, - tWlanCB sWlanCB, - tFWPatches sFWPatches, tDriverPatches - sDriverPatches, tBootLoaderPatches sBootLoaderPatches) -{ - wlan_init(max_tx_len, sWlanCB, sFWPatches, sDriverPatches, sBootLoaderPatches); -} - -#endif /* CONFIG_WL_CC3000 */ diff --git a/configs/nucleo-l476rg/src/Makefile b/configs/nucleo-l476rg/src/Makefile index a21fd2956d..cfa6ae2baf 100644 --- a/configs/nucleo-l476rg/src/Makefile +++ b/configs/nucleo-l476rg/src/Makefile @@ -48,13 +48,6 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y) CSRCS += stm32_buttons.c endif -ifeq ($(CONFIG_WL_CC3000),y) -CSRCS += stm32_cc3000.c -ifeq ($(CONFIG_CC3000_PROBES),) -CSRCS += stm32_io.c -endif -endif - ifeq ($(CONFIG_WL_CC1101),y) CSRCS += stm32_cc1101.c endif diff --git a/configs/nucleo-l476rg/src/nucleo-l476rg.h b/configs/nucleo-l476rg/src/nucleo-l476rg.h index d8524b3340..4921bdd08d 100644 --- a/configs/nucleo-l476rg/src/nucleo-l476rg.h +++ b/configs/nucleo-l476rg/src/nucleo-l476rg.h @@ -122,33 +122,6 @@ * */ -#ifdef CONFIG_WL_CC3000 -# define GPIO_WIFI_INT (GPIO_PORTB | GPIO_PIN3 | GPIO_INPUT | \ - GPIO_PULLUP | GPIO_EXTI) -# define GPIO_WIFI_EN (GPIO_PORTB | GPIO_PIN4 | GPIO_OUTPUT_CLEAR | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_WIFI_CS (GPIO_PORTB | GPIO_PIN6 | GPIO_OUTPUT_SET | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_D14 (GPIO_PORTB | GPIO_PIN9 | GPIO_OUTPUT_CLEAR | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_D15 (GPIO_PORTB | GPIO_PIN8 | GPIO_OUTPUT_CLEAR | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_D0 (GPIO_PORTA | GPIO_PIN3 | GPIO_INPUT | \ - GPIO_PULLUP) -# define GPIO_D1 (GPIO_PORTA | GPIO_PIN2 | GPIO_OUTPUT_CLEAR | \ - GPIO_PULLUP) -# define GPIO_D2 (GPIO_PORTA | GPIO_PIN10 | GPIO_OUTPUT_CLEAR | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_A0 (GPIO_PORTA | GPIO_PIN0 | GPIO_OUTPUT_SET | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_A1 (GPIO_PORTA | GPIO_PIN1 | GPIO_OUTPUT_SET | \ - GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -# define GPIO_A2 (GPIO_PORTA | GPIO_PIN4 | GPIO_INPUT | \ - GPIO_PULLUP) -# define GPIO_A3 (GPIO_PORTB | GPIO_PIN0 | GPIO_INPUT | \ - GPIO_PULLUP) -#endif - /* SPI1 off */ #define GPIO_SPI1_MOSI_OFF (GPIO_INPUT | GPIO_PULLDOWN | \ @@ -158,14 +131,6 @@ #define GPIO_SPI1_SCK_OFF (GPIO_INPUT | GPIO_PULLDOWN | \ GPIO_PORTA | GPIO_PIN5) -/* SPI1 chip selects off */ - -#ifdef CONFIG_WL_CC3000 -# define GPIO_SPI_CS_WIFI_OFF \ - (GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \ - GPIO_PORTB | GPIO_PIN6) -#endif - #ifdef CONFIG_WL_CC1101 # define GPIO_CC1101_PWR (GPIO_PORTC | GPIO_PIN6 | GPIO_OUTPUT_SET | \ GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) @@ -184,12 +149,6 @@ /* SPI chip selects */ -#ifdef CONFIG_WL_CC3000 -# define GPIO_SPI_CS_WIFI \ - (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \ - GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN6) -#endif - #ifdef HAVE_MMCSD # define GPIO_SPI_CS_SD_CARD \ (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \ @@ -209,19 +168,6 @@ * GPIO0-1 are for probing WIFI status */ -#ifdef CONFIG_WL_CC3000 -# define GPIO_GPIO0_INPUT \ - (GPIO_INPUT | GPIO_PULLUP | GPIO_PORTB | GPIO_PIN8) -# define GPIO_GPIO1_INPUT \ - (GPIO_INPUT | GPIO_PULLUP | GPIO_PORTB | GPIO_PIN9) -# define GPIO_GPIO0_OUTPUT \ - (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \ - GPIO_OUTPUT_CLEAR | GPIO_PORTB | GPIO_PIN8) -# define GPIO_GPIO1_OUTPUT \ - (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \ - GPIO_OUTPUT_CLEAR | GPIO_PORTB | GPIO_PIN9) -#endif - /* Itead Joystick Shield * * See http://imall.iteadstudio.com/im120417014.html for more information diff --git a/configs/nucleo-l476rg/src/stm32_appinit.c b/configs/nucleo-l476rg/src/stm32_appinit.c index 5dbfa215b4..b9a8b2d9ec 100644 --- a/configs/nucleo-l476rg/src/stm32_appinit.c +++ b/configs/nucleo-l476rg/src/stm32_appinit.c @@ -68,20 +68,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_netinitialize - * - * Description: - * Dummy function expected to start-up logic. - * - ****************************************************************************/ - -#ifdef CONFIG_WL_CC3000 -void up_netinitialize(void) -{ -} -#endif - /**************************************************************************** * Name: board_app_initialize * diff --git a/configs/nucleo-l476rg/src/stm32_boot.c b/configs/nucleo-l476rg/src/stm32_boot.c index a8af653206..08bc45ded0 100644 --- a/configs/nucleo-l476rg/src/stm32_boot.c +++ b/configs/nucleo-l476rg/src/stm32_boot.c @@ -123,11 +123,5 @@ void board_initialize(void) #if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_NSH_ARCHINIT) board_app_initialize(0); #endif - - /* CC3000 wireless initialization */ - -#ifdef CONFIG_WL_CC3000 - wireless_archinitialize(0); -#endif } #endif diff --git a/configs/nucleo-l476rg/src/stm32_cc3000.c b/configs/nucleo-l476rg/src/stm32_cc3000.c deleted file mode 100644 index ac935e929f..0000000000 --- a/configs/nucleo-l476rg/src/stm32_cc3000.c +++ /dev/null @@ -1,367 +0,0 @@ -/************************************************************************************ - * configs/nucleo-l476rg/src/stm32_cc3000.c - * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. - * Author: Laurent Latil - * David Sidrane - * - * 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 - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "stm32l4.h" -#include "nucleo-l476rg.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ -/* Configuration ************************************************************/ - -#ifdef CONFIG_WL_CC3000 -#ifndef CONFIG_WIRELESS -# error "Wireless support requires CONFIG_WIRELESS" -#endif - -#ifndef CONFIG_STM32_SPI2 -# error "CC3000 Wireless support requires CONFIG_STM32_SPI2" -#endif - -#ifndef CC3000_SPI_FREQUENCY -# define CC3000_SPI_FREQUENCY 16000000 -#endif - -#ifndef CC3000_SPIDEV -# define CC3000_SPIDEV 2 -#endif - -#if CC3000_SPIDEV != 2 -# error "CC3000_SPIDEV must be 2" -#endif - -#ifndef CC3000_DEVMINOR -# define CC3000_DEVMINOR 0 -#endif - -#ifndef CONFIG_CC3000_RX_BUFFER_SIZE -#define CONFIG_CC3000_RX_BUFFER_SIZE 132 -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -struct stm32_config_s -{ - struct cc3000_config_s dev; - xcpt_t handler; -}; - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks - * to isolate the CC3000 driver from differences in GPIO interrupt handling - * by varying boards and MCUs. If possible, interrupts should be configured - * on falling edges to detect the Ready Condition At T2: The normal master - * SPI write sequence is SPI_CS low, followed by SPI_IRQ low CC3000 to host, - * indicating that the CC3000 core module is ready to accept data. T2 - * duration is approximately 7 ms. - * - * irq_attach - Attach the CC3000 interrupt handler to the GPIO interrupt - * irq_enable - Enable or disable the GPIO interrupt - * clear_irq - Acknowledge/clear any pending GPIO interrupt - * power_enable - Enable or disable Module enable. - * chip_chip_select - The Chip Select - * wl_read_irq - Return the state of the interrupt GPIO input - */ - -static int wl_attach_irq(FAR struct cc3000_config_s *state, xcpt_t handler, - FAR void *arg); -static void wl_enable_irq(FAR struct cc3000_config_s *state, bool enable); -static void wl_clear_irq(FAR struct cc3000_config_s *state); -static void wl_select(FAR struct cc3000_config_s *state, bool enable); -static void wl_enable_power(FAR struct cc3000_config_s *state, bool enable); -static bool wl_read_irq(FAR struct cc3000_config_s *state); -#ifdef CONFIG_CC3000_PROBES -static bool probe(FAR struct cc3000_config_s *state,int n, bool s); -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* A reference to a structure of this type must be passed to the CC3000 - * driver. This structure provides information about the configuration - * of the CC3000 and provides some board-specific hooks. - * - * Memory for this structure is provided by the caller. It is not copied - * by the driver and is presumed to persist while the driver is active. The - * memory must be writable because, under certain circumstances, the driver - * may modify frequency or X plate resistance values. - */ - -static struct stm32_config_s g_cc3000_info = -{ - .dev.spi_frequency = CONFIG_CC3000_SPI_FREQUENCY, - .dev.spi_mode = CONFIG_CC3000_SPI_MODE, - .dev.max_rx_size = 0, - .dev.irq_attach = wl_attach_irq, - .dev.irq_enable = wl_enable_irq, - .dev.irq_clear = wl_clear_irq, - .dev.power_enable = wl_enable_power, - .dev.chip_chip_select = wl_select, - .dev.irq_read = wl_read_irq, -#ifdef CONFIG_CC3000_PROBES - .dev.probe = probe, /* This is used for debugging */ -#endif - .handler = NULL, - .arg = NULL, -}; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/* IRQ/GPIO access callbacks. These operations all hidden behind - * callbacks to isolate the CC3000 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. - * - * attach - Attach the CC3000 interrupt handler to the GPIO interrupt - * enable - Enable or disable the GPIO interrupt - * clear - Acknowledge/clear any pending GPIO interrupt - * pendown - Return the state of the pen down GPIO input - */ - -static int wl_attach_irq(FAR struct cc3000_config_s *state, xcpt_t handler, - FAR void *arg) -{ - FAR struct stm32_config_s *priv = (FAR struct stm32_config_s *)state; - - /* Just save the handler for use when the interrupt is enabled */ - - priv->handler = handler; - priv->arg = arg; - return OK; -} - -static void wl_enable_irq(FAR struct cc3000_config_s *state, bool enable) -{ - FAR struct stm32_config_s *priv = (FAR struct stm32_config_s *)state; - - /* The caller should not attempt to enable interrupts if the handler - * has not yet been 'attached' - */ - - DEBUGASSERT(priv->handler || !enable); - - /* Attach and enable, or detach and disable */ - - iinfo("enable:%d\n", enable); - if (enable) - { - (void)stm32_gpiosetevent(GPIO_WIFI_INT, false, true, false, - priv->handler, priv->arg); - } - else - { - (void)stm32_gpiosetevent(GPIO_WIFI_INT, false, false, false, - NULL, NULL); - } -} - -static void wl_enable_power(FAR struct cc3000_config_s *state, bool enable) -{ - iinfo("enable:%d\n", enable); - - /* Active high enable */ - - stm32_gpiowrite(GPIO_WIFI_EN, enable); -} - -static void wl_select(FAR struct cc3000_config_s *state, bool enable) -{ - iinfo("enable:%d\n", enable); - - /* Active high enable */ - - stm32_gpiowrite(GPIO_WIFI_CS, enable); -} - -static void wl_clear_irq(FAR struct cc3000_config_s *state) -{ - /* Does nothing */ -} - -static bool wl_read_irq(FAR struct cc3000_config_s *state) -{ - /* Active low*/ - - return stm32_gpioread(GPIO_WIFI_INT) ? false : true; -} - -#ifdef CONFIG_CC3000_PROBES -static bool probe(FAR struct cc3000_config_s *state,int n, bool s) -{ - if (n == 0) - { - stm32_gpiowrite(GPIO_D14, s); - } - - if (n == 1) - { - stm32_gpiowrite(GPIO_D15, s); - } - - return true; -} -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arch_wlinitialize - * - * Description: - * Each board that supports a wireless device must provide this function. - * This function is called by application-specific, setup logic to - * configure the wireless device. This function will register the driver - * as /dev/wirelessN where N is the minor device number. - * - * Returned Value: - * Zero is returned on success. Otherwise, a negated errno value is - * returned to indicate the nature of the failure. - * - ****************************************************************************/ - -int wireless_archinitialize(size_t max_rx_size) -{ - FAR struct spi_dev_s *spi; - - /* Init SPI bus */ - - iinfo("minor %d\n", minor); - DEBUGASSERT(CONFIG_CC3000_DEVMINOR == 0); - -#ifdef CONFIG_CC3000_PROBES - stm32_configgpio(GPIO_D14); - stm32_configgpio(GPIO_D15); - stm32_gpiowrite(GPIO_D14, 1); - stm32_gpiowrite(GPIO_D15, 1); -#endif - - /* Get an instance of the SPI interface */ - - spi = up_spiinitialize(CONFIG_CC3000_SPIDEV); - if (!spi) - { - ierr("ERROR: Failed to initialize SPI bus %d\n", CONFIG_CC3000_SPIDEV); - return -ENODEV; - } - - /* Initialize and register the SPI CC3000 device */ - - g_cc3000_info.dev.max_rx_size = max_rx_size ? max_rx_size : CONFIG_CC3000_RX_BUFFER_SIZE; - int ret = cc3000_register(spi, &g_cc3000_info.dev, CONFIG_CC3000_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to initialize SPI bus %d\n", CONFIG_CC3000_SPIDEV); - return -ENODEV; - } - - return OK; -} - -/**************************************************************************** - * Name: C3000_wlan_init - * - * Description: - * Initialize wlan driver - * - * Warning: This function must be called before ANY other wlan driver - * function - * - * Input Parameters: - * sWlanCB Asynchronous events callback. - * 0 no event call back. - * - Call back parameters: - * 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event, - * HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event, - * HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done, - * HCI_EVNT_WLAN_UNSOL_DHCP dhcp report, - * HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR - * HCI_EVNT_WLAN_KEEPALIVE keepalive. - * 2) data: pointer to extra data that received by the event - * (NULL no data). - * 3) length: data length. - * - Events with extra data: - * HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask, - * 4 bytes default gateway, 4 bytes DHCP server and 4 bytes - * for DNS server. - * HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent, - * 4 bytes Packets received, 4 bytes Min round time, - * 4 bytes Max round time and 4 bytes for Avg round time. - * - * sFWPatches 0 no patch or pointer to FW patches - * sDriverPatches 0 no patch or pointer to driver patches - * sBootLoaderPatches 0 no patch or pointer to bootloader patches - * - * Returned Value: - * None - * - ****************************************************************************/ - -void cc3000_wlan_init(size_t max_tx_len, - tWlanCB sWlanCB, - tFWPatches sFWPatches, tDriverPatches - sDriverPatches, tBootLoaderPatches sBootLoaderPatches) -{ - wlan_init(max_tx_len, sWlanCB, sFWPatches, sDriverPatches, sBootLoaderPatches); -} - -#endif /* CONFIG_WL_CC3000 */ diff --git a/configs/nucleo-l476rg/src/stm32_io.c b/configs/nucleo-l476rg/src/stm32_io.c deleted file mode 100644 index 3ece19cf32..0000000000 --- a/configs/nucleo-l476rg/src/stm32_io.c +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** - * configs/nucleo-l476rg/src/stm32_io.c - * - * Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include - -#include -#include "chip/stm32l4_tim.h" - -#include "nucleo-l476rg.h" - -#ifndef CONFIG_CC3000_PROBES - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_leds - * - * Description: - * - ****************************************************************************/ - -void up_leds(int r, int g ,int b, int freqs) -{ - long fosc = 72000000; - long prescale = 2048; - long p1s = fosc/prescale; - long p0p5s = p1s/2; - long p; - - static struct stm32_tim_dev_s *tim1 = 0; - - if (tim1 == 0) - { - tim1 = stm32_tim_init(1); - STM32_TIM_SETMODE(tim1, STM32_TIM_MODE_UP); - STM32_TIM_SETCLOCK(tim1, p1s-8); - STM32_TIM_SETPERIOD(tim1, p1s); - STM32_TIM_SETCOMPARE(tim1, 1, 0); - STM32_TIM_SETCOMPARE(tim1, 2, 0); - STM32_TIM_SETCOMPARE(tim1, 3, 0); - STM32_TIM_SETCHANNEL(tim1, 1, STM32_TIM_CH_OUTPWM | STM32_TIM_CH_POLARITY_NEG); - STM32_TIM_SETCHANNEL(tim1, 2, STM32_TIM_CH_OUTPWM | STM32_TIM_CH_POLARITY_NEG); - STM32_TIM_SETCHANNEL(tim1, 3, STM32_TIM_CH_OUTPWM | STM32_TIM_CH_POLARITY_NEG); - } - - p = freqs == 0 ? p1s : p1s / freqs; - STM32_TIM_SETPERIOD(tim1, p); - - p = freqs == 0 ? p1s + 1 : p0p5s / freqs; - - STM32_TIM_SETCOMPARE(tim1, 2, (r * p) / 255); - STM32_TIM_SETCOMPARE(tim1, 1, (b * p) / 255); - STM32_TIM_SETCOMPARE(tim1, 3, (g * p) / 255); -} - -/**************************************************************************** - * Name: up_ioinit - * - * Description: - * - ****************************************************************************/ - -void up_ioinit(void) -{ - /* Configure the GPIO pins as inputs. NOTE that EXTI interrupts are - * configured for all pins. - */ - - up_leds(0,0,0,0); - stm32_configgpio(GPIO_A0); /* Probes */ - stm32_configgpio(GPIO_A1); /* Probes */ - stm32_configgpio(GPIO_A2); /* Smart Config */ - stm32_configgpio(GPIO_A3); /* not used */ - stm32_configgpio(GPIO_BTN_USER); /* Sw 1 */ - stm32_configgpio(GPIO_D0); /* USART2 RX*/ - stm32_configgpio(GPIO_D1); /* uSART2 TX*/ - stm32_configgpio(GPIO_D2); /* Activate */ -} - -/**************************************************************************** - * Name: up_read_inputs - * - * N.B The return state in true logic, the button polarity is dealt here in - * - ****************************************************************************/ - -uint8_t up_read_inputs(void) -{ - uint8_t bits = 0; - bits |= stm32_gpioread(GPIO_D14) == 0 ? 1 : 0; - bits |= stm32_gpioread(GPIO_D15) == 0 ? 2 : 0; - bits |= stm32_gpioread(GPIO_A2) == 0 ? 4 : 0; - bits |= stm32_gpioread(GPIO_A3) == 0 ? 8 : 0; - return bits; -} - -/**************************************************************************** - * Name: up_write_outputs - * - * N.B The return state in true logic, the button polarity is dealt here in - * - ****************************************************************************/ - -void up_write_outputs(int id, bool bits) -{ - if (id == 2) - { - stm32_gpiowrite(GPIO_D2, bits); - } - else if (id == 0) - { - stm32_gpiowrite(GPIO_A0, bits); - } - else if (id == 1) - { - stm32_gpiowrite(GPIO_A1, bits); - } -} - -/**************************************************************************** - * Name: up_irqio - * - * Description: - * - ****************************************************************************/ - -int up_irqio(int id, xcpt_t irqhandler, void *arg) -{ - int ret = -EINVAL; - - /* The following should be atomic */ - - if (id == 0) - { - ret = stm32_gpiosetevent(GPIO_D14, true, true, true, irqhandler, arg); - } - else if (id == 1) - { - ret = stm32_gpiosetevent(GPIO_D15, true, true, true, irqhandler, arg); - } - - return ret; -} -#endif /* CONFIG_CC3000_PROBES */ diff --git a/configs/nucleo-l476rg/src/stm32_spi.c b/configs/nucleo-l476rg/src/stm32_spi.c index d6d07d64f8..c0ab3d7b3b 100644 --- a/configs/nucleo-l476rg/src/stm32_spi.c +++ b/configs/nucleo-l476rg/src/stm32_spi.c @@ -92,10 +92,6 @@ void weak_function stm32l4_spiinitialize(void) spierr("ERROR: FAILED to initialize SPI port 1\n"); } -#ifdef CONFIG_WL_CC3000 - stm32l4_configgpio(GPIO_SPI_CS_WIFI); -#endif - #ifdef HAVE_MMCSD stm32l4_configgpio(GPIO_SPI_CS_SD_CARD); #endif @@ -106,14 +102,6 @@ void weak_function stm32l4_spiinitialize(void) g_spi2 = stm32l4_spibus_initialize(2); -#ifdef CONFIG_WL_CC3000 - /* Setup CS, EN & IRQ line IOs */ - - stm32l4_configgpio(GPIO_WIFI_CS); - stm32l4_configgpio(GPIO_WIFI_EN); - stm32l4_configgpio(GPIO_WIFI_INT); -#endif - #ifdef CONFIG_WL_CC1101 /* Setup CS, IRQ(gdo2) line IOs */ @@ -155,13 +143,6 @@ 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"); -#ifdef CONFIG_WL_CC3000 - if (devid == SPIDEV_WIRELESS(0)) - { - stm32l4_gpiowrite(GPIO_SPI_CS_WIFI, !selected); - } - else -#endif #ifdef HAVE_MMCSD if (devid == SPIDEV_MMCSD(0)) { @@ -181,13 +162,6 @@ 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"); -#ifdef CONFIG_WL_CC3000 - if (devid == SPIDEV_WIRELESS(0)) - { - stm32l4_gpiowrite(GPIO_WIFI_CS, !selected); - } -#endif - #ifdef CONFIG_WL_CC1101 if (devid == SPIDEV_WIRELESS(5)) { diff --git a/configs/sam4e-ek/README.txt b/configs/sam4e-ek/README.txt index 58c4c4c785..e676d79465 100644 --- a/configs/sam4e-ek/README.txt +++ b/configs/sam4e-ek/README.txt @@ -581,8 +581,7 @@ USB Full-Speed Device directories that can be used for reference. 2. Linux supports the CDC/ACM driver out of the box. Windows, on the other - than requires that you first install a serial driver (a .inf file). There - are example .inf files for NuttX in the nuttx/configs/spark directories. + than requires that you first install a serial driver (a .inf file). 3. There is hand-shaking to pace incoming serial data. As a result, you may experience data loss due to RX overrun errors. The overrun errors occur @@ -1380,8 +1379,7 @@ Configurations 5. By default, this configuration uses the CDC/ACM serial device to provide the USB console. This works out-of-the-box for Linux. Windows, on the other hand, will require a CDC/ACM device driver - (.inf file). There is a sample .inf file in the nuttx/configs/spark - directories. + (.inf file). 5. Using the Prolifics PL2303 Emulation diff --git a/configs/spark/Kconfig b/configs/spark/Kconfig deleted file mode 100644 index cb73361c18..0000000000 --- a/configs/spark/Kconfig +++ /dev/null @@ -1,48 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see the file kconfig-language.txt in the NuttX tools repository. -# - -if ARCH_BOARD_SPARK - -config SPARK_FLASH - bool "MTD driver for onboard 2M FLASH" - default y - select MTD - select MTD_SST25 - select FS_FAT - select STM32_SPI2 - select MTD_BYTE_WRITE - ---help--- - Configures an MTD device for use with the onboard flash - -config SPARK_FLASH_SPI - int "Flash SPI bus number" - default 2 - depends on SPARK_FLASH - ---help--- - Selects the SPI bus number identying that SPI interface that - connects the Flash to the MCU. - -config SPARK_FLASH_MINOR - int "Minor number for the FLASH /dev/fat entry" - default 0 - depends on SPARK_FLASH - ---help--- - Sets the minor number for the FLASH MTD /dev entry - -config SPARK_FLASH_PART - bool "Enable partition support on FLASH" - default n - depends on SPARK_FLASH - ---help--- - Enables creation of partitions on the FLASH - -config SPARK_FLASH_PART_LIST - string "Flash partition size list" - default "512,1536" - depends on SPARK_FLASH_PART - ---help--- - Comma separated list of partition sizes in KB - -endif diff --git a/configs/spark/README.txt b/configs/spark/README.txt deleted file mode 100644 index 2975270412..0000000000 --- a/configs/spark/README.txt +++ /dev/null @@ -1,364 +0,0 @@ -README -====== - -This README discusses issues unique to NuttX configurations for the Spark Core board from Spark Devices (http://www.spark.io). This board features the STM32103CBT6 MCU from STMicro. - - - Microprocessor: 32-bit ARM Cortex M3 at 72MHz STM32F103CBT6 - Memory: 120 KB Flash and 20 KB SRAM, 2M serial Flash - I/O Pins Out: 37, 17 On the Connector - Network: TI CC3000 Wifi Module - ADCs: 9 (at 12-bit resolution) - Peripherals: 4 timers, 2 I2Cs, 2 SPI ports, 3 USARTs, 2 led's one Blue and one RGB. - Other: Sleep, stop, and standby modes; serial wire debug and JTAG interfaces - - During the development of the SparkCore, the hardware was in limited supply - As a work around David Sidrane created a SparkCore Big board - (http://nscdg.com/spark/sparkBB.png) that will interface with a maple mini - (http://leaflabs.com/docs/hardware/maple-mini.html), and a CC3000BOOST - (https://estore.ti.com/CC3000BOOST-CC3000-BoosterPack-P4258.aspx) - - It breaks out the Tx, Rx to connect to a FTDI TTL-232RG-VREG3V3-WE for the console and - wires in the spark LEDs and serial flash to the same I/O as the sparkcore. It has a Jlink - compatible Jtag connector on it. - -Contents -======== - - - Hardware - - Core Pin out - - LEDs - - Buttons - - USARTS and Serial Consoles - - DFU and JTAG - - Spark -specific Configuration Options - - Configurations - -DFU and JTAG -============ - - Enbling Support for the DFU Bootloader - -------------------------------------- - The linker files in these projects can be configured to indicate that you - will be loading code using STMicro built-in USB Device Firmware Upgrade (DFU) - loader or via some JTAG emulator. You can specify the DFU bootloader by - adding the following line: - - CONFIG_STM32_DFU=y - - to your .config file. Most of the configurations in this directory are set - up to use the DFU loader. - - If CONFIG_STM32_DFU is defined, the code will not be positioned at the beginning - of FLASH (0x08000000) but will be offset to 0x08005000. This offset is needed - to make space for the DFU loader and 0x08005000 is where the DFU loader expects - to find new applications at boot time. If you need to change that origin for some - other bootloader, you will need to edit the file(s) ld.script.dfu for the - configuration. - - For Linux or Mac: - ---------------- - - While on Linux or Mac, we can use dfu-util to upload nuttx binary. - - 1. Make sure we have installed dfu-util. (From yum, apt-get or build from source.) - 2. Start the DFU loader (bootloader) on the Spark board. You do this by - resetting the board while holding the "Key" button. Windows should - recognize that the DFU loader has been installed. - 3. Flash the nuttx.bin to the board use dfu-util. Here's an example: - - $ dfu-util -a1 -d 1eaf:0003 -D nuttx.bin -R - - For anything not clear, we can refer to LeafLabs official document: - - http://leaflabs.com/docs/unix-toolchain.html - - For Windows: - ----------- - - The DFU SE PC-based software is available from the STMicro website, - http://www.st.com. General usage instructions: - - 1. Convert the NuttX Intel Hex file (nuttx.hex) into a special DFU - file (nuttx.dfu)... see below for details. - 2. Connect the M3 Wildfire board to your computer using a USB - cable. - 3. Start the DFU loader on the M3 Wildfire board. You do this by - resetting the board while holding the "Key" button. Windows should - recognize that the DFU loader has been installed. - 3. Run the DFU SE program to load nuttx.dfu into FLASH. - - What if the DFU loader is not in FLASH? The loader code is available - inside of the Demo dirctory of the USBLib ZIP file that can be downloaded - from the STMicro Website. You can build it using RIDE (or other toolchains); - you will need a JTAG emulator to burn it into FLASH the first time. - - In order to use STMicro's built-in DFU loader, you will have to get - the NuttX binary into a special format with a .dfu extension. The - DFU SE PC_based software installation includes a file "DFU File Manager" - conversion program that a file in Intel Hex format to the special DFU - format. When you successfully build NuttX, you will find a file called - nutt.hex in the top-level directory. That is the file that you should - provide to the DFU File Manager. You will end up with a file called - nuttx.dfu that you can use with the STMicro DFU SE program. - - Enabling JTAG - ------------- - If you are not using the DFU, then you will probably also need to enable - JTAG support. By default, all JTAG support is disabled but there NuttX - configuration options to enable JTAG in various different ways. - - These configurations effect the setting of the SWJ_CFG[2:0] bits in the AFIO - MAPR register. These bits are used to configure the SWJ and trace alternate function I/Os. - The SWJ (SerialWire JTAG) supports JTAG or SWD access to the Cortex debug port. - The default state in this port is for all JTAG support to be disable. - - CONFIG_STM32_JTAG_FULL_ENABLE - sets SWJ_CFG[2:0] to 000 which enables full - SWJ (JTAG-DP + SW-DP) - - CONFIG_STM32_JTAG_NOJNTRST_ENABLE - sets SWJ_CFG[2:0] to 001 which enable - full SWJ (JTAG-DP + SW-DP) but without JNTRST. - - CONFIG_STM32_JTAG_SW_ENABLE - sets SWJ_CFG[2:0] to 010 which would set JTAG-DP - disabled and SW-DP enabled - - The default setting (none of the above defined) is SWJ_CFG[2:0] set to 100 - which disable JTAG-DP and SW-DP. - -Hardware -======== - - The Spark comprises a STM32F103CB 72 Mhz, 128 Flash, 20K Ram, with 37 IO Pins, and - a TI CC3000 Wifi Module. It has a 2MB serial flash, onboad regulation and 2 led's - one Blue and one RGB. - - During the development of the SparkCore, the hardware was in limited supply - As a work around david_s5 created a SparkCore Big board (http://nscdg.com/spark/sparkBB.png) - that will interface with a maple mini (http://leaflabs.com/docs/hardware/maple-mini.html), - and a CC3000BOOST (https://estore.ti.com/CC3000BOOST-CC3000-BoosterPack-P4258.aspx) - - It breaks out the Tx, Rx to connect to a FTDI TTL-232RG-VREG3V3-WE for the console and - wires in the spark LEDs and serial flash to the same I/O as the sparkcore. It has a Jlink - compatible Jtag connector on it. - -Core Pin out -============ - - There are 24 pis on the Spark Core module. - - Spark Spark Function STM32F103CBT6 - Name Pin # Pin # - -------- ------ ------------------------------------------------ --------------- - RAW JP1-1 Input Power N/A - GND JP1-2 GND - TX JP1-3 PA[02] USART2_TX/ADC12_IN2/TIM2_CH3 12 - RX JP1-4 PA[03] USART2_RX/ADC12_IN3/TIM2_CH4 13 - A7 JP1-5 PB[01] ADC12_IN9/TIM3_CH4 19 - A6 JP1-6 PB[00] ADC12_IN8/TIM3_CH3 18 - A5 JP1-7 PA[07] SPI1_MOSI/ADC12_IN7/TIM3_CH2 17 - A4 JP1-8 PA[06] SPI1_MISO/ADC12_IN6/TIM3_CH1 16 - A3 JP1-9 PA[05] SPI1_SCK/ADC12_IN5 15 - A2 JP1-10 PA[04] SPI1_NSS/USART2_CK/ADC12_IN4 14 - A1 JP1-11 PA[01] USART2_RTS/ADC12_IN1/TIM2_CH2 11 - A0 JP1-12 PA[00] WKUP/USART2_CTS/ADC12_IN0/TIM2_CH1_ETR 10 - - +3V3 JP2-1 V3.3 Out of Core NA - RST JP2-2 NRST 7 - VDDA JP2-3 ADC Voltage 9 - GND JP2-4 GND - D7 JP2-5 PA[13] JTMS/SWDIO 34 Common with Blue LED LED_USR - D6 JP2-6 PA[14] JTCK/SWCLK 37 - D5 JP2-7 PA[15] JTDI 38 - D4 JP2-8 PB[03] JTDO 39 - D3 JP2-9 PB[04] NJTRST 40 - D2 JP2-10 PB[05] I2C1_SMBA 41 - D1 JP2-11 PB[06] I2C1_SCL/TIM4_CH1 42 - D0 JP2-12 PB[07] I2C1_SDA/TIM4_CH2 43 - -Core Internal IO -================ - - Spark Function STM32F103CBT6 - Name Pin # - -------- ------------------------------------------------ --------------- - BTN PB[02] BOOT1 20 - LED1,D7 PA[13] JTMS/SWDIO 34 - LED2 PA[08] USART1_CK/TIM1_CH1/MCO 29 - LED3 PA[09] USART1_TX/TIM1_CH2 30 - LED4 PA[10] USART1_RX/TIM1_CH3 31 - MEM_CS PB[09] TIM4_CH4 46 SST25VF016B Chip Select - SPI_CLK PB[13] SPI2_SCK/USART3_CTS/TIM1_CH1N 26 - SPI_MISO PB[14] SPI2_MISO/USART3_RTS/TIM1_CH2N 27 - SPI_MOSI PB[15] SPI2_MOSI/TIM1_CH3N 28 - USB_DISC PB[10] I2C2_SCL/USART3_TX 21 - WIFI_CS PB[12] SPI2_NSS/I2C2_SMBA/USART3_CK/TIM1_BKIN 25 CC3000 Chip Select - WIFI_EN PB[08] TIM4_CH3 45 CC3000 Module enable - WIFI_INT PB[11] I2C2_SDA/USART3_RX 22 CC3000 Host interface SPI interrupt - -Buttons and LEDs -================ - - Buttons - ------- - The Spark has two mechanical buttons. One button is the RESET button - connected to the STM32F103CB's reset line via /RST and the other is a - generic user configurable button labeled BTN and connected to GPIO - PB2/BOOT1. Since on the Spark, BOOT0 is tied to GND it is a moot point - that BTN signal is connected to the BOOT1 signal. When a button is - pressed it will drive the I/O line to GND. - - LEDs - ---- - There are 4 user-controllable LEDs in two packages on board the Spark board: - - Sigal Location Color GPIO Active - ------- ------------ ----------- ----- ----------- - LED1 LED_USR Blue LED PA13 High Common With D7 - LED2 LED_RGB Red LED PA8 Low - LED3 LED_RGB Blue LED PA9 Low - LED4 LED_RGB Green LED PA10 Low - - LED1 is connected to ground and can be illuminated by driving the PA13 - output high, it shares the Sparks D7 output. The LED2,LED3 and LED4 - are pulled high and can be illuminated by driving the corresponding GPIO output - to low. - - The RGB LEDs are not used by the board port unless CONFIG_ARCH_LEDS is - defined. In that case, the usage by the board port is defined in - include/board.h and src/up_leds.c. The LEDs are used to encode OS-related - events as follows: - - SYMBOL Meaning LED2 LED3 LED4 - red blue green Color - ------------------- ----------------------- ------- ------- ------ --------- - LED_STARTED NuttX has been started ON OFF OFF Red - LED_HEAPALLOCATE Heap has been allocated OFF ON OFF Blue - LED_IRQSENABLED Interrupts enabled ON OFF ON Orange - LED_STACKCREATED Idle stack created OFF OFF ON Green - LED_INIRQ In an interrupt** ON N/C N/C Orange Glow - LED_SIGNAL In a signal handler*** N/C ON N/C Blue Glow - LED_ASSERTION An assertion failed ON ON ON White - LED_PANIC The system has crashed ON N/C N/C Red Flashing - LED_IDLE STM32 is is sleep mode (Optional, not used) - - * If LED2, LED3, LED4 are statically on, then NuttX probably failed to boot - and these LEDs will give you some indication of where the failure was - ** The normal state is LED4 ON and LED2 faintly glowing. This faint glow - is because of timer interrupts that result in the LED being illuminated - on a small proportion of the time. - *** LED3 may also flicker normally if signals are processed. - -Serial Consoles -=============== - - USART2 - ----- - If you have a 3.3 V TTL to RS-232 convertor then this is the most convenient - serial console to use. UART2 is the default in all of these - configurations. - - USART2 RX PA3 JP1 pin 4 - USART2 TX PA2 JP1 pin 3 - GND JP1 pin 2 - V3.3 JP2 pin 1 - - Virtual COM Port - ---------------- - Yet another option is to use UART0 and the USB virtual COM port. This - option may be more convenient for long term development, but was - painful to use during board bring-up. - -Spark -specific Configuration Options -============== - WIP - -Configurations -============== - - Composite: The composite is a super set of all the functions in nsh, - usbserial, usbmsc. (usbnsh has not been rung out). - - Build it with - - make distclean;cd tools;./configure.sh spark/composite;cd .. - - then run make menuconfig if you wish to customize things. - - N.B. Memory is tight, both Flash and RAM are taxed. If you enable - debugging you will need to add -Os following the line -g in the line: - - ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g - - in the top level Make.degs or the code will not fit. - - Stack space has been hand optimized using the stack coloring by enabling - "Stack coloration" (CONFIG_STACK_COLORATION) in Build Setup-> Debug - Options. I have selected values that have 8-16 bytes of headroom with - network debugging on. If you enable more debugging and get a hard fault - or any weirdness like commands hanging. Then the Idle, main or Interrupt - stack my be too small. Stop the target and have a look a memory for a - blown stack: No DEADBEEF at the lowest address of a given stack. - - Given the RAM memory constraints it is not possible to be running the - network and USB CDC/ACM and MSC at the same time. But on the bright - side, you can export the FLASH memory to the PC. Write files on the - Flash. Reboot and mount the FAT FS and run network code that will have - access the files. - - You can use the scripts/cdc-acm.inf file to install the windows - composite device. - - SPI2 is enabled and support is included for the FAT file system on the - 16Mbit (2M) SST25 device and control of the CC3000 on the spark core. - - When the system boots, you should have a dev/mtdblock0 that can be - mounted using the command: - - mount -t vfat /dev/mtdblock0 /mnt/p0 - - or /dev/mtdblock0 can be exported as MSC on the USB interface along with - a Virtual serial port as a CDC/ACM interface. - - Use the command conn* and disconn to manage the USB interface. - - N.B. *If /dev/mtdblock0 is mounted then You must unmount it prior to - exporting it via the conn command. Bad things will happen if not. - - Network control is facilitated by running the c3b (cc3000basic) application. - - Run c3b from the nsh prompt. - - +-------------------------------------------+ - | Nuttx CC3000 Demo Program | - +-------------------------------------------+ - - 01 - Initialize the CC3000 - 02 - Show RX & TX buffer sizes, & free RAM - 03 - Start Smart Config - 04 - Manually connect to AP - 05 - Manually add connection profile - 06 - List access points - 07 - Show CC3000 information - 08 - Telnet - - Type 01-07 to select above option: - - Select 01. Then use 03 and the TI Smart config application running on an - IOS or Android device to configure join your network. - - Use 07 to see the IP address of the device. - - (On the next reboot running c3b 01 the CC3000 will automaticaly rejoin the - network after the 01 give it a few seconds and enter 07 or 08) - - Use 08 to start Telnet. Then you can connect to the device using the - address listed in command 07. - - qq will exit the c3b with the telnet deamon running (if started) - - Slow.... You will be thinking 300 bps. This is because of packet sizes and - how the select thread runs in the telnet session. Telnet is not the best - showcase for the CC3000, but simply a proof of network connectivity. - - http POST and GET should be more efficient. diff --git a/configs/spark/composite/defconfig b/configs/spark/composite/defconfig deleted file mode 100644 index 64e28d8db7..0000000000 --- a/configs/spark/composite/defconfig +++ /dev/null @@ -1,116 +0,0 @@ -# CONFIG_DISABLE_OS_API is not set -# CONFIG_NSH_DISABLE_CMP is not set -# CONFIG_NSH_DISABLE_DD is not set -# CONFIG_NSH_DISABLE_EXEC is not set -# CONFIG_NSH_DISABLE_EXIT is not set -# CONFIG_NSH_DISABLE_GET is not set -# CONFIG_NSH_DISABLE_HEXDUMP is not set -# CONFIG_NSH_DISABLE_IFCONFIG is not set -# CONFIG_NSH_DISABLE_LOSETUP is not set -# CONFIG_NSH_DISABLE_MKRD is not set -# CONFIG_NSH_DISABLE_PS is not set -# CONFIG_NSH_DISABLE_PUT is not set -# CONFIG_NSH_DISABLE_SEMICOLON is not set -# CONFIG_NSH_DISABLE_WGET is not set -# CONFIG_NSH_DISABLE_XD is not set -# CONFIG_NSH_DISABLEBG is not set -CONFIG_ANALOG=y -CONFIG_ARCH_BOARD_SPARK=y -CONFIG_ARCH_BOARD="spark" -CONFIG_ARCH_BUTTONS=y -CONFIG_ARCH_CHIP_STM32=y -CONFIG_ARCH_CHIP_STM32F103CB=y -CONFIG_ARCH_INTERRUPTSTACK=340 -CONFIG_ARCH_IRQBUTTONS=y -CONFIG_ARCH_STACKDUMP=y -CONFIG_ARCH="arm" -CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL=y -CONFIG_BOARD_INITIALIZE=y -CONFIG_BOARD_LOOPSPERMSEC=5483 -CONFIG_BUILTIN_PROXY_STACKSIZE=768 -CONFIG_BUILTIN=y -CONFIG_CC3000_SELECT_STACKSIZE=390 -CONFIG_CDCACM_COMPOSITE=y -CONFIG_CDCACM_EPBULKIN_HSSIZE=64 -CONFIG_CDCACM_EPBULKOUT_HSSIZE=64 -CONFIG_CDCACM_NRDREQS=2 -CONFIG_CDCACM_NWRREQS=2 -CONFIG_CDCACM_RXBUFSIZE=96 -CONFIG_CDCACM_TXBUFSIZE=96 -CONFIG_CDCACM=y -CONFIG_COMPOSITE_CONFIGSTR="system/composite" -CONFIG_COMPOSITE_IAD=y -CONFIG_COMPOSITE_PRODUCTID=0x2022 -CONFIG_COMPOSITE_PRODUCTSTR="Composite Device" -CONFIG_COMPOSITE_SERIALSTR="12345" -CONFIG_COMPOSITE_VENDORID=0x03eb -CONFIG_DEFAULT_SMALL=y -CONFIG_DISABLE_POLL=y -CONFIG_DRIVERS_WIRELESS=y -CONFIG_EXAMPLES_CC3000BASIC=y -CONFIG_EXAMPLES_NSH=y -CONFIG_FAT_LCNAMES=y -CONFIG_FAT_LFN=y -CONFIG_FAT_MAXFNAME=12 -CONFIG_FS_FATTIME=y -CONFIG_FS_NAMED_SEMAPHORES=y -CONFIG_IDLETHREAD_STACKSIZE=280 -CONFIG_INTELHEX_BINARY=y -CONFIG_LIB_RAND_ORDER=2 -CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=16 -CONFIG_MAX_WDOGPARMS=2 -CONFIG_MM_SMALL=y -CONFIG_MQ_MAXMSGSIZE=8 -CONFIG_MTD_PARTITION=y -CONFIG_NAME_MAX=8 -CONFIG_NFILE_DESCRIPTORS=5 -CONFIG_NFILE_STREAMS=5 -CONFIG_NPTHREAD_KEYS=0 -CONFIG_NSH_ARCHINIT=y -CONFIG_NSH_BUILTIN_APPS=y -CONFIG_NSH_CODECS_BUFSIZE=0 -CONFIG_NSH_FILEIOSIZE=128 -CONFIG_NSH_LINELEN=80 -CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=768 -CONFIG_PREALLOC_MQ_MSGS=1 -CONFIG_PREALLOC_TIMERS=2 -CONFIG_PREALLOC_WDOGS=2 -CONFIG_PTHREAD_STACK_DEFAULT=340 -CONFIG_RAM_SIZE=20480 -CONFIG_RAM_START=0x20000000 -CONFIG_RAW_BINARY=y -CONFIG_RR_INTERVAL=200 -CONFIG_SDCLONE_DISABLE=y -CONFIG_SST25_SECTOR512=y -CONFIG_SST25_SPIFREQUENCY=80000000 -CONFIG_START_DAY=30 -CONFIG_START_MONTH=11 -CONFIG_START_YEAR=2013 -CONFIG_STDIO_DISABLE_BUFFERING=y -CONFIG_STM32_CRC=y -CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y -CONFIG_STM32_DMA1=y -CONFIG_STM32_JTAG_FULL_ENABLE=y -CONFIG_STM32_SPI_DMA=y -CONFIG_STM32_USART2=y -CONFIG_STM32_USB=y -CONFIG_SYMTAB_ORDEREDBYNAME=y -CONFIG_SYSTEM_COMPOSITE=y -CONFIG_TASK_NAME_SIZE=7 -CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=768 -CONFIG_USART2_RXBUFSIZE=32 -CONFIG_USART2_SERIAL_CONSOLE=y -CONFIG_USART2_TXBUFSIZE=32 -CONFIG_USBDEV_COMPOSITE=y -CONFIG_USBDEV_TRACE_NRECORDS=32 -CONFIG_USBDEV_TRACE=y -CONFIG_USBMSC_COMPOSITE=y -CONFIG_USBMSC_NRDREQS=2 -CONFIG_USBMSC_NWRREQS=2 -CONFIG_USBMSC_SCSI_STACKSIZE=340 -CONFIG_USBMSC=y -CONFIG_USER_ENTRYPOINT="nsh_main" -CONFIG_USERMAIN_STACKSIZE=1024 -CONFIG_WDOG_INTRESERVE=0 -CONFIG_WL_CC3000=y diff --git a/configs/spark/include/board.h b/configs/spark/include/board.h deleted file mode 100644 index f88f3923fe..0000000000 --- a/configs/spark/include/board.h +++ /dev/null @@ -1,215 +0,0 @@ -/************************************************************************************ - * configs/spark/include/board.h - * include/arch/board/board.h - * - * Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved. - * Authors: Gregory Nutt - * Librae - * - * 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 __CONFIGS_SPARK_INCLUDE_BOARD_H -#define __CONFIGS_SPARK_INCLUDE_BOARD_H - -/************************************************************************************ - * Included Files - ************************************************************************************/ - -#include - -#ifndef __ASSEMBLY__ -# include -#endif - -#include - -#include "stm32_rcc.h" -#include "stm32_sdio.h" -#include "stm32.h" - -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ - -/* Clocking *************************************************************************/ - -/* On-board crystal frequency is 8MHz (HSE) */ - -#define STM32_BOARD_XTAL 8000000ul - -/* PLL source is HSE/1, PLL multipler is 9: PLL frequency is 8MHz (XTAL) x 9 = 72MHz */ - -#define STM32_CFGR_PLLSRC RCC_CFGR_PLLSRC -#define STM32_CFGR_PLLXTPRE 0 -#define STM32_CFGR_PLLMUL RCC_CFGR_PLLMUL_CLKx9 -#define STM32_PLL_FREQUENCY (9*STM32_BOARD_XTAL) - -/* Use the PLL and set the SYSCLK source to be the PLL */ - -#define STM32_SYSCLK_SW RCC_CFGR_SW_PLL -#define STM32_SYSCLK_SWS RCC_CFGR_SWS_PLL -#define STM32_SYSCLK_FREQUENCY STM32_PLL_FREQUENCY - -/* AHB clock (HCLK) is SYSCLK (72MHz) */ - -#define STM32_RCC_CFGR_HPRE RCC_CFGR_HPRE_SYSCLK -#define STM32_HCLK_FREQUENCY STM32_PLL_FREQUENCY -#define STM32_BOARD_HCLK STM32_HCLK_FREQUENCY /* same as above, to satisfy compiler */ - -/* APB2 clock (PCLK2) is HCLK (72MHz) */ - -#define STM32_RCC_CFGR_PPRE2 RCC_CFGR_PPRE2_HCLK -#define STM32_PCLK2_FREQUENCY STM32_HCLK_FREQUENCY - -/* APB2 timers 1 and 8 will receive PCLK2. */ - -#define STM32_APB2_TIM1_CLKIN (STM32_PCLK2_FREQUENCY) -#define STM32_APB2_TIM8_CLKIN (STM32_PCLK2_FREQUENCY) - -/* APB1 clock (PCLK1) is HCLK/2 (36MHz) */ - -#define STM32_RCC_CFGR_PPRE1 RCC_CFGR_PPRE1_HCLKd2 -#define STM32_PCLK1_FREQUENCY (STM32_HCLK_FREQUENCY/2) - -/* APB1 timers 2-7 will be twice PCLK1 */ - -#define STM32_APB1_TIM2_CLKIN (2*STM32_PCLK1_FREQUENCY) -#define STM32_APB1_TIM3_CLKIN (2*STM32_PCLK1_FREQUENCY) -#define STM32_APB1_TIM4_CLKIN (2*STM32_PCLK1_FREQUENCY) -#define STM32_APB1_TIM5_CLKIN (2*STM32_PCLK1_FREQUENCY) -#define STM32_APB1_TIM6_CLKIN (2*STM32_PCLK1_FREQUENCY) -#define STM32_APB1_TIM7_CLKIN (2*STM32_PCLK1_FREQUENCY) - -/* USB divider -- Divide PLL clock by 1.5 */ - -#define STM32_CFGR_USBPRE 0 - -/* Timer Frequencies, if APBx is set to 1, frequency is same to APBx - * otherwise frequency is 2xAPBx. - * Note: TIM1,8 are on APB2, others on APB1 */ - -#define BOARD_TIM1_FREQUENCY STM32_HCLK_FREQUENCY -#define BOARD_TIM2_FREQUENCY STM32_HCLK_FREQUENCY -#define BOARD_TIM3_FREQUENCY STM32_HCLK_FREQUENCY -#define BOARD_TIM4_FREQUENCY STM32_HCLK_FREQUENCY -#define BOARD_TIM5_FREQUENCY STM32_HCLK_FREQUENCY -#define BOARD_TIM6_FREQUENCY STM32_HCLK_FREQUENCY -#define BOARD_TIM7_FREQUENCY STM32_HCLK_FREQUENCY -#define BOARD_TIM8_FREQUENCY STM32_HCLK_FREQUENCY - -/* SDIO dividers. Note that slower clocking is required when DMA is disabled - * in order to avoid RX overrun/TX underrun errors due to delayed responses - * to service FIFOs in interrupt driven mode. These values have not been - * tuned!!! - * - * HCLK=72MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(178+2)=400 KHz - */ - -#define SDIO_INIT_CLKDIV (178 << SDIO_CLKCR_CLKDIV_SHIFT) - -/* DMA ON: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(2+2)=18 MHz - * DMA OFF: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(3+2)=14.4 MHz - */ - -#ifdef CONFIG_SDIO_DMA -# define SDIO_MMCXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT) -#else -# define SDIO_MMCXFR_CLKDIV (3 << SDIO_CLKCR_CLKDIV_SHIFT) -#endif - -/* DMA ON: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(1+2)=24 MHz - * DMA OFF: HCLK=72 MHz, SDIOCLK=72MHz, SDIO_CK=HCLK/(3+2)=14.4 MHz - */ - -#ifdef CONFIG_SDIO_DMA -# define SDIO_SDXFR_CLKDIV (1 << SDIO_CLKCR_CLKDIV_SHIFT) -#else -# define SDIO_SDXFR_CLKDIV (3 << SDIO_CLKCR_CLKDIV_SHIFT) -#endif - -/* LED definitions ******************************************************************/ -/* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any - * way. The following definitions are used to access individual LEDs. - */ - -/* LED index values for use with board_userled() */ - -#define BOARD_LED1 0 /* Tied to LED_USR */ -#define BOARD_LED2 1 /* Tied to LED_RGB RED */ -#define BOARD_LED3 2 /* Tied to LED_RGB BLUE */ -#define BOARD_LED4 3 /* Tied to LED_RGB GREEN */ -#define BOARD_NLEDS 4 - -#define BOARD_USR_LED_BLUE BOARD_LED1 -#define BOARD_RGB_LED_RED BOARD_LED3 -#define BOARD_RGB_LED_GREEN BOARD_LED4 -#define BOARD_RGB_LED_BLUE BOARD_LED2 - -/* LED bits for use with board_userled_all() */ - -#define BOARD_USR_LED_BIT (1 << BOARD_USR_LED_BLUE) -#define BOARD_RED_LED_BIT (1 << BOARD_RGB_LED_RED) -#define BOARD_BLUE_LED_BIT (1 << BOARD_RGB_LED_BLUE) -#define BOARD_GREEN_LED_BIT (1 << BOARD_RGB_LED_GREEN) - -#define LED_ACTIVE_LOW (BOARD_RED_LED_BIT|BOARD_BLUE_LED_BIT|BOARD_GREEN_LED_BIT) - -/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the 4 LEDs on board the - * spark. The following definitions describe how NuttX controls the LEDs: - */ - - /* LED1 LED2 LED3 LED4 */ - /* blue red blue green Color */ -#define LED_STARTED 0 /* ------ ------ ------ ------ --------- */ -#define LED_HEAPALLOCATE 1 /* OFF ON OFF OFF Red */ -#define LED_IRQSENABLED 2 /* OFF OFF ON OFF Blue */ -#define LED_STACKCREATED 3 /* OFF ON OFF ON Orange */ -#define LED_INIRQ 4 /* N/C OFF OFF ON Green */ -#define LED_SIGNAL 5 /* N/C ON N/C N/C Red Glow */ -#define LED_ASSERTION 6 /* N/C N/C ON N/C Blue Glow */ -#define LED_PANIC 7 /* N/C ON ON ON White */ -#define LED_NUM_CODES 8 - -/* Button definitions ***************************************************************/ -/* The Spark supports two buttons; only one button is controllable by software: - * - * BTN: user and wake-up button connected to the I/O PB2/BOOT1 of the STM32F103CB. - * N.B. Since BOOT0 is tied to GND it is a moot point that BTN signal is connected - * to the BOOT1 signal. - * RESET: This pushbutton connected to NRST is used to RESET the STM32F103CB. - */ - -#define BUTTON_USER 0 -#define NUM_BUTTONS 1 - -#define BUTTON_USER_BIT (1 << BUTTON_USER) -#define BUTTON_ACTIVE_LOW (BUTTON_USER_BIT) - -#endif /* __CONFIGS_SPARK_INCLUDE_BOARD_H */ diff --git a/configs/spark/nsh/defconfig b/configs/spark/nsh/defconfig deleted file mode 100644 index 28222b3f4d..0000000000 --- a/configs/spark/nsh/defconfig +++ /dev/null @@ -1,104 +0,0 @@ -# CONFIG_DISABLE_OS_API is not set -# CONFIG_NSH_DISABLE_CMP is not set -# CONFIG_NSH_DISABLE_DD is not set -# CONFIG_NSH_DISABLE_EXEC is not set -# CONFIG_NSH_DISABLE_EXIT is not set -# CONFIG_NSH_DISABLE_GET is not set -# CONFIG_NSH_DISABLE_HEXDUMP is not set -# CONFIG_NSH_DISABLE_IFCONFIG is not set -# CONFIG_NSH_DISABLE_LOSETUP is not set -# CONFIG_NSH_DISABLE_MKRD is not set -# CONFIG_NSH_DISABLE_PS is not set -# CONFIG_NSH_DISABLE_PUT is not set -# CONFIG_NSH_DISABLE_WGET is not set -# CONFIG_NSH_DISABLE_XD is not set -# CONFIG_NSH_DISABLEBG is not set -# CONFIG_NSH_DISABLESCRIPT is not set -CONFIG_ANALOG=y -CONFIG_ARCH_BOARD_SPARK=y -CONFIG_ARCH_BOARD="spark" -CONFIG_ARCH_BUTTONS=y -CONFIG_ARCH_CHIP_STM32=y -CONFIG_ARCH_CHIP_STM32F103CB=y -CONFIG_ARCH_INTERRUPTSTACK=156 -CONFIG_ARCH_IRQBUTTONS=y -CONFIG_ARCH_STACKDUMP=y -CONFIG_ARCH="arm" -CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL=y -CONFIG_BOARD_INITIALIZE=y -CONFIG_BOARD_LOOPSPERMSEC=5483 -CONFIG_BUILTIN=y -CONFIG_CDCACM_BULKIN_REQLEN=100 -CONFIG_CDCACM_COMPOSITE=y -CONFIG_CDCACM_RXBUFSIZE=100 -CONFIG_CDCACM_TXBUFSIZE=80 -CONFIG_CDCACM=y -CONFIG_COMPOSITE_IAD=y -CONFIG_COMPOSITE_VENDORID=0x03eb -CONFIG_DEFAULT_SMALL=y -CONFIG_DISABLE_POLL=y -CONFIG_DRIVERS_WIRELESS=y -CONFIG_EXAMPLES_CC3000BASIC=y -CONFIG_EXAMPLES_NSH=y -CONFIG_FAT_LCNAMES=y -CONFIG_FAT_LFN=y -CONFIG_FAT_MAXFNAME=12 -CONFIG_FS_FATTIME=y -CONFIG_FS_NAMED_SEMAPHORES=y -CONFIG_IDLETHREAD_STACKSIZE=300 -CONFIG_INTELHEX_BINARY=y -CONFIG_LIB_RAND_ORDER=2 -CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=16 -CONFIG_MAX_WDOGPARMS=2 -CONFIG_MM_SMALL=y -CONFIG_MQ_MAXMSGSIZE=8 -CONFIG_MTD_PARTITION=y -CONFIG_NAME_MAX=8 -CONFIG_NFILE_DESCRIPTORS=5 -CONFIG_NFILE_STREAMS=5 -CONFIG_NPTHREAD_KEYS=0 -CONFIG_NSH_ARCHINIT=y -CONFIG_NSH_BUILTIN_APPS=y -CONFIG_NSH_CODECS_BUFSIZE=0 -CONFIG_NSH_FILEIOSIZE=128 -CONFIG_NSH_LINELEN=40 -CONFIG_PREALLOC_MQ_MSGS=1 -CONFIG_PREALLOC_TIMERS=2 -CONFIG_PREALLOC_WDOGS=2 -CONFIG_PTHREAD_STACK_DEFAULT=464 -CONFIG_RAM_SIZE=20480 -CONFIG_RAM_START=0x20000000 -CONFIG_RAW_BINARY=y -CONFIG_RR_INTERVAL=200 -CONFIG_SDCLONE_DISABLE=y -CONFIG_SST25_SECTOR512=y -CONFIG_SST25_SPIFREQUENCY=80000000 -CONFIG_START_DAY=30 -CONFIG_START_MONTH=11 -CONFIG_START_YEAR=2013 -CONFIG_STDIO_DISABLE_BUFFERING=y -CONFIG_STM32_CRC=y -CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y -CONFIG_STM32_DMA1=y -CONFIG_STM32_JTAG_FULL_ENABLE=y -CONFIG_STM32_SPI_DMA=y -CONFIG_STM32_USART2=y -CONFIG_STM32_USB=y -CONFIG_SYMTAB_ORDEREDBYNAME=y -CONFIG_TASK_NAME_SIZE=7 -CONFIG_USART2_RXBUFSIZE=32 -CONFIG_USART2_SERIAL_CONSOLE=y -CONFIG_USART2_TXBUFSIZE=32 -CONFIG_USBDEV_COMPOSITE=y -CONFIG_USBDEV_TRACE_NRECORDS=32 -CONFIG_USBDEV_TRACE=y -CONFIG_USBMSC_BULKINREQLEN=256 -CONFIG_USBMSC_BULKOUTREQLEN=256 -CONFIG_USBMSC_COMPOSITE=y -CONFIG_USBMSC_SCSI_STACKSIZE=464 -CONFIG_USBMSC=y -CONFIG_USER_ENTRYPOINT="nsh_main" -CONFIG_USERMAIN_STACKSIZE=880 -CONFIG_WDOG_INTRESERVE=0 -CONFIG_WL_CC3000=y diff --git a/configs/spark/scripts/Make.defs b/configs/spark/scripts/Make.defs deleted file mode 100644 index d4c0a58120..0000000000 --- a/configs/spark/scripts/Make.defs +++ /dev/null @@ -1,117 +0,0 @@ -############################################################################ -# configs/spark/scripts/Make.defs -# -# Copyright (C) 2013, 2017 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# 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 ${TOPDIR}/.config -include ${TOPDIR}/tools/Config.mk -include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs - -ifeq ($(CONFIG_STM32_DFU),y) - LDSCRIPT = ld.script.dfu -else - LDSCRIPT = ld.script -endif - -ifeq ($(WINTOOL),y) - # Windows-native toolchains - DIRLINK = $(TOPDIR)/tools/copydir.sh - DIRUNLINK = $(TOPDIR)/tools/unlink.sh - MKDEP = $(TOPDIR)/tools/mkwindeps.sh - ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" - ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" - ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" -else - # Linux/Cygwin-native toolchain - MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) - ARCHINCLUDES = -I. -isystem $(TOPDIR)/include - ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx - ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) -endif - -CC = $(CROSSDEV)gcc -CXX = $(CROSSDEV)g++ -CPP = $(CROSSDEV)gcc -E -LD = $(CROSSDEV)ld -STRIP = $(CROSSDEV)strip --strip-unneeded -AR = $(CROSSDEV)ar rcs -NM = $(CROSSDEV)nm -OBJCOPY = $(CROSSDEV)objcopy -OBJDUMP = $(CROSSDEV)objdump - -ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} -ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer -endif - -ARCHCFLAGS = -fno-builtin -ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -ARCHWARNINGSXX = -Wall -Wshadow -Wundef -ARCHDEFINES = -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - -CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe -CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) -CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe -CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) -CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -AFLAGS = $(CFLAGS) -D__ASSEMBLY__ - -NXFLATLDFLAGS1 = -r -d -warn-common -NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections -LDNXFLATFLAGS = -e main -s 2048 - -ASMEXT = .S -OBJEXT = .o -LIBEXT = .a -EXEEXT = - -ifneq ($(CROSSDEV),arm-nuttx-elf-) - LDFLAGS += -nostartfiles -nodefaultlibs -endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - - -HOSTCC = gcc -HOSTINCLUDES = -I. -HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe -HOSTLDFLAGS = diff --git a/configs/spark/scripts/cdc-acm.inf b/configs/spark/scripts/cdc-acm.inf deleted file mode 100644 index f348b810b5..0000000000 --- a/configs/spark/scripts/cdc-acm.inf +++ /dev/null @@ -1,108 +0,0 @@ -; Windows USB CDC ACM Setup File - -; Based on : https://www.kernel.org/doc/Documentation/usb/linux-cdc-acm.inf -; Based on INF template which was: -; Copyright (c) 2000 Microsoft Corporation -; Copyright (c) 2007 Microchip Technology Inc. -; likely to be covered by the MLPL as found at: -; . -; For use only on Windows operating systems. - -[Version] -Signature="$Windows NT$" -Class=Ports -ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} -Provider=%Linux% -DriverVer=11/15/2007,5.1.2600.0 - -[Manufacturer] -%Linux%=DeviceList, NTamd64 - -[DestinationDirs] -DefaultDestDir=12 - - -;------------------------------------------------------------------------------ -; Windows 2000/XP/Vista-32bit Sections -;------------------------------------------------------------------------------ - -[DriverInstall.nt] -include=mdmcpq.inf -CopyFiles=DriverCopyFiles.nt -AddReg=DriverInstall.nt.AddReg - -[DriverCopyFiles.nt] -usbser.sys,,,0x20 - -[DriverInstall.nt.AddReg] -HKR,,DevLoader,,*ntkern -HKR,,NTMPDriver,,USBSER.sys -HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" - -[DriverInstall.nt.Services] -AddService=usbser, 0x00000002, DriverService.nt - -[DriverService.nt] -DisplayName=%SERVICE% -ServiceType=1 -StartType=3 -ErrorControl=1 -ServiceBinary=%12%\USBSER.sys - -;------------------------------------------------------------------------------ -; Vista-64bit Sections -;------------------------------------------------------------------------------ - -[DriverInstall.NTamd64] -include=mdmcpq.inf -CopyFiles=DriverCopyFiles.NTamd64 -AddReg=DriverInstall.NTamd64.AddReg - -[DriverCopyFiles.NTamd64] -USBSER.sys,,,0x20 - -[DriverInstall.NTamd64.AddReg] -HKR,,DevLoader,,*ntkern -HKR,,NTMPDriver,,USBSER.sys -HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" - -[DriverInstall.NTamd64.Services] -AddService=usbser, 0x00000002, DriverService.NTamd64 - -[DriverService.NTamd64] -DisplayName=%SERVICE% -ServiceType=1 -StartType=3 -ErrorControl=1 -ServiceBinary=%12%\USBSER.sys - - -;------------------------------------------------------------------------------ -; Vendor and Product ID Definitions -;------------------------------------------------------------------------------ -; When developing your USB device, the VID and PID used in the PC side -; application program and the firmware on the microcontroller must match. -; Modify the below line to use your VID and PID. Use the format as shown -; below. -; Note: One INF file can be used for multiple devices with different -; VID and PIDs. For each supported device, append -; ",USB\VID_xxxx&PID_yyyy" to the end of the line. -;------------------------------------------------------------------------------ -[SourceDisksFiles] -[SourceDisksNames] -[DeviceList] -%DESCRIPTION%=DriverInstall, USB\VID_0525&PID_A4A7, USB\VID_03EB&PID_2022&MI_00 - -[DeviceList.NTamd64] -%DESCRIPTION%=DriverInstall, USB\VID_0525&PID_A4A7, USB\VID_03EB&PID_2022&MI_00 - - -;------------------------------------------------------------------------------ -; String Definitions -;------------------------------------------------------------------------------ -;Modify these strings to customize your device -;------------------------------------------------------------------------------ -[Strings] -Linux = "Nutts Developer Community" -DESCRIPTION = "Nuttx CDC/ACM" -SERVICE = "Nuttx CDC/ACM Driver" diff --git a/configs/spark/scripts/ld.script b/configs/spark/scripts/ld.script deleted file mode 100644 index 1ae9912a2c..0000000000 --- a/configs/spark/scripts/ld.script +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** - * configs/spark/scripts/ld.script - * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * Librae - * - * 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. - * - ****************************************************************************/ - -/* The STM32F103xB has 128Kb of FLASH beginning at address 0x0800:0000 and - * 20Kb of SRAM beginning at address 0x2000:0000. When booting from FLASH, - * FLASH memory is aliased to address 0x0000:0000 where the code expects to - * begin execution by jumping to the entry point in the 0x0800:0000 address - * range. - */ - -MEMORY -{ - flash (rx) : ORIGIN = 0x08000000, LENGTH = 128K - sram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K -} - -OUTPUT_ARCH(arm) -ENTRY(_stext) -SECTIONS -{ - .text : { - _stext = ABSOLUTE(.); - *(.vectors) - *(.text .text.*) - *(.fixup) - *(.gnu.warning) - *(.rodata .rodata.*) - *(.gnu.linkonce.t.*) - *(.glue_7) - *(.glue_7t) - *(.got) - *(.gcc_except_table) - *(.gnu.linkonce.r.*) - _etext = ABSOLUTE(.); - } > flash - - .init_section : { - _sinit = ABSOLUTE(.); - *(.init_array .init_array.*) - _einit = ABSOLUTE(.); - } > flash - - .ARM.extab : { - *(.ARM.extab*) - } > flash - - __exidx_start = ABSOLUTE(.); - .ARM.exidx : { - *(.ARM.exidx*) - } > flash - __exidx_end = ABSOLUTE(.); - - _eronly = ABSOLUTE(.); - - /* The STM32F103VCT6 has 48Kb of SRAM beginning at the following address */ - - .data : { - _sdata = ABSOLUTE(.); - *(.data .data.*) - *(.gnu.linkonce.d.*) - CONSTRUCTORS - _edata = ABSOLUTE(.); - } > sram AT > flash - - .bss : { - _sbss = ABSOLUTE(.); - *(.bss .bss.*) - *(.gnu.linkonce.b.*) - *(COMMON) - _ebss = ABSOLUTE(.); - } > sram - - /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/configs/spark/scripts/ld.script.dfu b/configs/spark/scripts/ld.script.dfu deleted file mode 100644 index 48f7e7d291..0000000000 --- a/configs/spark/scripts/ld.script.dfu +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** - * configs/spark/scripts/ld.script.dfu - * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * Librae - * - * 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. - * - ****************************************************************************/ - -/* The STM32F103xB has 128Kb of FLASH beginning at address 0x0800:0000 and - * 20Kb of SRAM beginning at address 0x2000:0000. Here we assume that the - * spark's DFU bootloader is being used. In that case, the correct - * load .text load address is 0x0800:5000 (leaving 108Kb). - */ - -MEMORY -{ - flash (rx) : ORIGIN = 0x08005000, LENGTH = 108K - sram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K -} - -OUTPUT_ARCH(arm) -ENTRY(_stext) - -SECTIONS -{ - .text : { - _stext = ABSOLUTE(.); - *(.vectors) - *(.text .text.*) - *(.fixup) - *(.gnu.warning) - *(.rodata .rodata.*) - *(.gnu.linkonce.t.*) - *(.glue_7) - *(.glue_7t) - *(.got) - *(.gcc_except_table) - *(.gnu.linkonce.r.*) - _etext = ABSOLUTE(.); - } > flash - - .init_section : { - _sinit = ABSOLUTE(.); - *(.init_array .init_array.*) - _einit = ABSOLUTE(.); - } > flash - - .ARM.extab : { - *(.ARM.extab*) - } > flash - - __exidx_start = ABSOLUTE(.); - .ARM.exidx : { - *(.ARM.exidx*) - } > flash - __exidx_end = ABSOLUTE(.); - - _eronly = ABSOLUTE(.); - - /* The STM32F103VCT6 has 48Kb of SRAM beginning at the following address */ - - .data : { - _sdata = ABSOLUTE(.); - *(.data .data.*) - *(.gnu.linkonce.d.*) - CONSTRUCTORS - _edata = ABSOLUTE(.); - } > sram AT > flash - - .bss : { - _sbss = ABSOLUTE(.); - *(.bss .bss.*) - *(.gnu.linkonce.b.*) - *(COMMON) - _ebss = ABSOLUTE(.); - } > sram - - /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/configs/spark/src/Makefile b/configs/spark/src/Makefile deleted file mode 100644 index 70a7879f15..0000000000 --- a/configs/spark/src/Makefile +++ /dev/null @@ -1,76 +0,0 @@ -############################################################################ -# configs/spark/src/Makefile -# -# Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# Librae -# -# 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 $(TOPDIR)/Make.defs - -ASRCS = -CSRCS = stm32_boot.c stm32_spi.c - -ifeq ($(CONFIG_ARCH_LEDS),y) -CSRCS += stm32_autoleds.c -else -CSRCS += stm32_userleds.c -endif - -ifeq ($(CONFIG_ARCH_BUTTONS),y) -CSRCS += stm32_buttons.c -endif - -ifeq ($(CONFIG_LIB_BOARDCTL),y) -CSRCS += stm32_appinit.c -endif - -ifeq ($(CONFIG_USBDEV),y) -CSRCS += stm32_usbdev.c -endif - -ifeq ($(CONFIG_BOARDCTL_USBDEVCTRL),y) -CSRCS += stm32_usbmsc.c -endif - -ifeq ($(CONFIG_USBDEV_COMPOSITE),y) -CSRCS += stm32_composite.c -endif - -ifeq ($(CONFIG_WL_CC3000),y) -CSRCS += stm32_cc3000.c -endif - -ifeq ($(CONFIG_CC3000_PROBES),) -CSRCS += stm32_io.c -endif - -include $(TOPDIR)/configs/Board.mk diff --git a/configs/spark/src/spark.h b/configs/spark/src/spark.h deleted file mode 100644 index 0bfd4e3a05..0000000000 --- a/configs/spark/src/spark.h +++ /dev/null @@ -1,270 +0,0 @@ -/************************************************************************************ - * configs/spark/src/spark.h - * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. - * Author: Laurent Latil - * Librae - * David_s5 - * - * 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 __CONFIGS_SPARK_SRC_SPARK_H -#define __CONFIGS_SPARK_SRC_SPARK_H - -/************************************************************************************ - * Included Files - ************************************************************************************/ - -#include -#include -#include -#include - -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ -/* During the development of the SparkCore, the hardware was in limited supply - * As a work around david_s5 created a SparkCore Big board (http://nscdg.com/spark/sparkBB.png) - * that will interface with a maple mini (http://leaflabs.com/docs/hardware/maple-mini.html), - * and a CC3000BOOST (https://estore.ti.com/CC3000BOOST-CC3000-BoosterPack-P4258.aspx) - * - * It breaks out the Tx, Rx to connect to a FTDI TTL-232RG-VREG3V3-WE for the console and - * wires in the spark LEDs and serial flash to the same I/O as the sparkcore. It has a Jlink - * compatible Jtag connector on it. - * - * - * Board GPIO Usage: - * - * GPIO Function MPU Core Core Maple Maple - * Pin # Name Pin # Name Pin # - * ----- -------------------------------- -------------------------------------------------------- - * PA[00] WKUP/USART2_CTS/ADC12_IN0/TIM2_CH1_ETR 10 A0 JP1-12 J1-8 - * PA[01] USART2_RTS/ADC12_IN1/TIM2_CH2 11 A1 JP1-11 J1-9 - * PA[02] USART2_TX/ADC12_IN2/TIM2_CH3 12 TX JP1-3 J1-10 - * PA[03] USART2_RX/ADC12_IN3/TIM2_CH4 13 RX JP1-4 J1-11 - * PA[04] SPI1_NSS/USART2_CK/ADC12_IN4 14 A2 JP1-10 J1-12 - * PA[05] SPI1_SCK/ADC12_IN5 15 A3 JP1-9 J1-13 - * PA[06] SPI1_MISO/ADC12_IN6/TIM3_CH1 16 A4 JP1-8 J1-14 - * PA[07] SPI1_MOSI/ADC12_IN7/TIM3_CH2 17 A5 JP1-7 J1-15 - * PA[08] USART1_CK/TIM1_CH1/MCO 29 LED2 J2-5 - * PA[09] USART1_TX/TIM1_CH2 30 LED3 J2-6 - * PA[10] USART1_RX/TIM1_CH3 31 LED4 J2-7 - * PA[11] USART1_CTS/CAN_RX/TIM1_CH4/USBDM 32 USBM USBDM J2-8 - * PA[12] USART1_RTS/CAN_TX/TIM1_ETR/USBDP 33 USBP USBDP J2-9 - * PA[13] JTMS/SWDIO 34 D7,LED1 JP2-5 J2-10 - * PA[14] JTCK/SWCLK 37 D6 JP2-6 J2-11 - * PA[15] JTDI 38 D5 JP2-7 J2-12 - * - * PB[00] ADC12_IN8/TIM3_CH3 18 A6 JP1-6 J1-16 - * PB[01] ADC12_IN9/TIM3_CH4 19 A7 JP1-5 R1-LED - * PB[02] BOOT1 20 BTN BTN J1-17 - * PB[03] JTDO 39 D4 JP2-8 J2-13 - * PB[04] NJTRST 40 D3 JP2-9 J2-14 - * PB[05] I2C1_SMBA 41 D2 JP2-10 J2-15 - * PB[06] I2C1_SCL/TIM4_CH1 42 D1 JP2-11 J2-16 - * PB[07] I2C1_SDA/TIM4_CH2 43 D0 JP2-12 J2-17 - * PB[08] TIM4_CH3 45 WIFI_EN BOOT0 J2-18 - * PB[09] TIM4_CH4 46 MEM_CS DISC - * PB[10] I2C2_SCL/USART3_TX 21 USB_DISC J1-18 - * PB[11] I2C2_SDA/USART3_RX 22 WIFI_INT J1-19 - * PB[12] SPI2_NSS/I2C2_SMBA/USART3_CK/TIM1_BKIN 25 WIFI_CS J2-1 - * PB[13] SPI2_SCK/USART3_CTS/TIM1_CH1N 26 SPI_CLK J2-2 - * PB[14] SPI2_MISO/USART3_RTS/TIM1_CH2N 27 SPI_MISO J2-3 - * PB[15] SPI2_MOSI/TIM1_CH3N 28 SPI_MOSI J2-4 - * - * PC[13] TAMPER-RTC 2 N.C. J1-4 - * PC[14] OSC32_IN 3 OSC32_IN Y1 N.C. - * PC[15] OSC32_OUT 4 OSC32_OUT Y1 N.C. - * - * PD[00] OSC_IN 5 OSC_IN Y2 8MHZ OSC 8MHZ OSC - * PD[01] OSC_OUT 6 OSC_OUT Y2 8MHZ OSC 8MHZ OSC - * - * Spark Core pin Mapping - * - * GPIO ADC Timer I2C UART SPI JTAG Other 5V? STM Pin# Core HW Core SW - * PA0 CH0 2_CH1_ETR 2_CTS 10 A0 10 - * PA1 CH1 2_CH2 2_RTS 11 A1 11 - * PA2 CH2 2_CH3 2_TX 12 TX 19 - * PA3 CH3 2_CH4 2_RX 13 RX 18 - * PA4 CH4 2_CK 1_NSS 14 A2 12 - * PA5 CH5 1_SCK 15 A3 13 - * PA6 CH6 3_CH1 1_MISO 16 A4 14 - * PA7 CH7 3_CH2 1_MOSI 17 A5 15 - * PA8 1_CH1 1_CK MCO Yes 29 LED2 - * PA9 1_CH2 1_TX Yes 30 LED3 - * PA10 1_CH3 1_RX Yes 31 LED4 - * PA11 1_CH4 1_CTS USB- Yes 32 USBM - * PA12 1_ETR 1_RTS USB+ Yes 33 USBP - * PA13 JTMS Yes 34 D7 7 - * PA14 JTCK Yes 37 D6 6 - * PA15 JTDI Yes 38 D5 5 - * - * PB0 CH8 3_CH3 18 A6 16 - * PB1 CH9 3_CH4 19 A7 17 - * PB2 BOOT1 Yes 20 BTN - * PB3 JTDO Yes 39 D4 4 - * PB4 NJTRST Yes 40 D3 3 - * PB5 1_SMBA 41 D2 2 - * PB6 4_CH1 1_SCL Yes 42 D1 1 - * PB7 4_CH2 1_SDA Yes 43 D0 0 - * PB8 4_CH3 Yes 45 WIFI_EN - * PB9 4_CH4 Yes 46 MEM_CS - * PB10 2_SCL 3_TX Yes 21 USB_DISC - * PB11 2_SDA 3_RX Yes 22 WIFI_INT - * PB12 1_BKIN 2_SMBA 3_CK 2_NSS Yes 25 WIFI_CS - * PB13 3_CTS 2_SCK Yes 26 SPI_SCK - * PB14 3_RTS 2_MISO Yes 27 SPI_MISO - * PB15 2_MOSI Yes 28 SPI_MOSI - * - * PC13 2 - * PC14 RTC Oscillator 3 OSC32IN - * PC15 RTC Oscillator 4 OSC32OUT - * - * PD0 Oscillator <= 5 OSC - * PD1 Oscillator => 6 OSC - */ - -/* How many SPI modules does this chip support? The LM3S6918 supports 2 SPI - * modules (others may support more -- in such case, the following must be - * expanded). - */ - -#if STM32_NSPI < 1 -# undef CONFIG_STM32_SPI1 -# undef CONFIG_STM32_SPI2 -#elif STM32_NSPI < 2 -# undef CONFIG_STM32_SPI2 -#endif - -/* LEDs *****************************************************************************/ -/* - * GPIO Function MPU Core Core Maple Maple - * Pin # Name Pin # Name Pin # - * ----- -------------------------------- -------------------------------------------------------- - * - * PA[08] USART1_CK/TIM1_CH1/MCO 29 LED2 J2-5 - * PA[09] USART1_TX/TIM1_CH2 30 LED3 J2-6 - * PA[10] USART1_RX/TIM1_CH3 31 LED4 J2-7 - * PA[13] JTMS/SWDIO 34 D7,LED1 JP2-5 J2-10 - */ - -#define GPIO_LED1 (GPIO_PORTA | GPIO_PIN13 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz) -#define GPIO_LED_USR GPIO_LED1 -#define GPIO_LED2 (GPIO_PORTA | GPIO_PIN8 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz) -#define GPIO_LED3 (GPIO_PORTA | GPIO_PIN9 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz) -#define GPIO_LED4 (GPIO_PORTA | GPIO_PIN10 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz) - -#define GPIO_USB_PULLUP (GPIO_PORTB | GPIO_PIN10 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz) - -/* BUTTON ***************************************************************************/ -/* - * GPIO Function MPU Core Core Maple Maple - * Pin # Name Pin # Name Pin # - * ----- -------------------------------- -------------------------------------------------------- - * PB[02] BOOT1 20 BTN BTN J1-17 - */ -#define IRQBUTTON BUTTON_USER - -#define GPIO_BTN (GPIO_PORTB | GPIO_PIN2 | GPIO_INPUT | GPIO_CNF_INPULLUP | GPIO_EXTI) - - -/* MEMORYs **************************************************************************/ -/* - * GPIO Function MPU Core Core Maple Maple - * Pin # Name Pin # Name Pin # - * ----- -------------------------------- -------------------------------------------------------- - * PB[09] TIM4_CH4 46 MEM_CS DISC -*/ - -#define GPIO_MEM_CS (GPIO_PORTB | GPIO_PIN9 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz) - -/* CCS3000 **************************************************************************/ -/* - * GPIO Function MPU Core Core Maple Maple - * Pin # Name Pin # Name Pin # - * ----- -------------------------------- -------------------------------------------------------- - * PB[08] TIM4_CH3 45 WIFI_EN BOOT0 J2-18 - * PB[11] I2C2_SDA/USART3_RX 22 WIFI_INT J1-19 - * PB[12] SPI2_NSS/I2C2_SMBA/USART3_CK/TIM1_BKIN 25 WIFI_CS J2-1 -*/ - -#define GPIO_WIFI_EN (GPIO_PORTB | GPIO_PIN8 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz) -#define GPIO_WIFI_CS (GPIO_PORTB | GPIO_PIN12 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz) - -#define GPIO_WIFI_INT (GPIO_PORTB | GPIO_PIN11 | GPIO_INPUT | GPIO_CNF_INPULLUP | GPIO_EXTI) - -#if defined(CONFIG_CC3000_PROBES) -#define GPIO_D0 (GPIO_PORTB | GPIO_PIN7 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz) -#define GPIO_D1 (GPIO_PORTB | GPIO_PIN6 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz) -#else -#define GPIO_D0 (GPIO_PORTB | GPIO_PIN7 | GPIO_INPUT | GPIO_CNF_INPULLUP | GPIO_EXTI) -#define GPIO_D1 (GPIO_PORTB | GPIO_PIN6 | GPIO_INPUT | GPIO_CNF_INPULLUP | GPIO_EXTI) -#define GPIO_D2 (GPIO_PORTB | GPIO_PIN5 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz) -#define GPIO_A0 (GPIO_PORTA | GPIO_PIN0 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz) -#define GPIO_A1 (GPIO_PORTA | GPIO_PIN1 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz) -#define GPIO_A2 (GPIO_PORTA | GPIO_PIN4 | GPIO_INPUT | GPIO_CNF_INPULLUP ) -#define GPIO_A3 (GPIO_PORTA | GPIO_PIN5 | GPIO_INPUT | GPIO_CNF_INPULLUP ) -#endif -/************************************************************************************ - * Public Types - ************************************************************************************/ - -/************************************************************************************ - * Public data - ************************************************************************************/ - -#ifndef __ASSEMBLY__ - -/************************************************************************************ - * Public Functions - ************************************************************************************/ - -/************************************************************************************ - * Name: stm32_spidev_initialize - * - * Description: - * Called to configure SPI chip select GPIO pins. - * - ************************************************************************************/ - -void stm32_spidev_initialize(void); - -/************************************************************************************ - * Name: stm32_usbinitialize - * - * Description: - * Called to setup USB-related GPIO pins. - * - ************************************************************************************/ - -void stm32_usbinitialize(void); - -#endif /* __ASSEMBLY__ */ -#endif /* __CONFIGS_SPARK_SRC_SPARK_H */ diff --git a/configs/spark/src/stm32_appinit.c b/configs/spark/src/stm32_appinit.c deleted file mode 100644 index a666eb089e..0000000000 --- a/configs/spark/src/stm32_appinit.c +++ /dev/null @@ -1,318 +0,0 @@ -/**************************************************************************** - * config/spark/src/stm32_appinit.c - * - * Copyright (C) 2012-2013, 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * David_s5 - * - * 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 - -#include -#include -#include -#include - -#include -#include - -#ifdef CONFIG_MTD_SST25 -# include -# include -# include -#endif - -#ifdef CONFIG_USBMONITOR -# include -#endif - -#ifdef CONFIG_USBDEV -# include "stm32_usbdev.h" -#endif - -#include "stm32.h" -#include "spark.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -/* Can't support the SST25 device if it SPI2 or SST25 support is not enabled */ - -#define HAVE_SST25 1 -#if !defined(CONFIG_STM32_SPI2) || !defined(CONFIG_MTD_SST25) -# undef HAVE_SST25 -#endif - -/* Can't support SST25 features if mountpoints are disabled */ - -#if defined(CONFIG_DISABLE_MOUNTPOINT) -# undef HAVE_SST25 -#endif - -#ifndef CONFIG_SPARK_FLASH_MOUNT_POINT -# define CONFIG_SPARK_FLASH_MOUNT_POINT "/mnt/p%d" -#endif - -/* Use minor device number 0 is not is provided */ - -#ifndef CONFIG_SPARK_FLASH_MINOR -# define CONFIG_SPARK_FLASH_MINOR 0 -#endif - -/* Can't support both FAT and NXFFS */ - -#if defined(CONFIG_FS_FAT) && defined(CONFIG_FS_NXFFS) -# warning "Can't support both FAT and NXFFS -- using FAT" -#endif - -#define HAVE_USBDEV 1 -#define HAVE_USBMONITOR 1 - -/* Can't support USB device is USB device is not enabled */ - -#ifndef CONFIG_USBDEV -# undef HAVE_USBDEV -# undef HAVE_USBMONITOR -#endif - -/* Check if we should enable the USB monitor before starting NSH */ - -#if !defined(CONFIG_USBDEV_TRACE) || !defined(CONFIG_USBMONITOR) -# undef HAVE_USBMONITOR -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static bool g_app_initialzed; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: board_app_initialize - * - * Description: - * Perform application specific initialization. This function is never - * called directly from application code, but only indirectly via the - * (non-standard) boardctl() interface using the command BOARDIOC_INIT. - * - * Input Parameters: - * arg - The boardctl() argument is passed to the board_app_initialize() - * implementation without modification. The argument has no - * meaning to NuttX; the meaning of the argument is a contract - * between the board-specific initalization logic and the - * matching application logic. The value cold be such things as a - * mode enumeration value, a set of DIP switch switch settings, a - * pointer to configuration data read from a file or serial FLASH, - * or whatever you would like to do with it. Every implementation - * should accept zero/NULL as a default configuration. - * - * Returned Value: - * Zero (OK) is returned on success; a negated errno value is returned on - * any failure to indicate the nature of the failure. - * - ****************************************************************************/ - -int board_app_initialize(uintptr_t arg) -{ - /* Check if already initialized */ - - if (g_app_initialzed) - { - return OK; - } - -#ifdef HAVE_SST25 - { - FAR struct spi_dev_s *spi; - FAR struct mtd_dev_s *mtd; - int ret; - - /* Configure SPI-based devices */ - /* Get the SPI port */ - - syslog(LOG_INFO, "Initializing SPI port %d\n", - CONFIG_SPARK_FLASH_SPI); - - spi = stm32_spibus_initialize(CONFIG_SPARK_FLASH_SPI); - if (!spi) - { - syslog(LOG_ERR, "ERROR: Failed to initialize SPI port %d\n", - CONFIG_SPARK_FLASH_SPI); - return -ENODEV; - } - - syslog(LOG_INFO, "Successfully initialized SPI port %d\n", - CONFIG_SPARK_FLASH_SPI); - - /* Now bind the SPI interface to the SST25 SPI FLASH driver */ - - syslog(LOG_INFO, "Bind SPI to the SPI flash driver\n"); - - mtd = sst25_initialize(spi); - if (!mtd) - { - syslog(LOG_ERR, "ERROR: Failed to bind SPI port %d to the SPI FLASH driver\n", - CONFIG_SPARK_FLASH_SPI); - } - else - { - syslog(LOG_INFO, "Successfully bound SPI port %d to the SPI FLASH driver\n", - CONFIG_SPARK_FLASH_SPI); - } - -#ifndef CONFIG_SPARK_FLASH_PART - - /* Use the FTL layer to wrap the MTD driver as a block driver */ - - ret = ftl_initialize(CONFIG_SPARK_FLASH_MINOR, mtd); - if (ret < 0) - { - ferr("ERROR: Initialize the FTL layer\n"); - return ret; - } - -#ifdef CONFIG_SPARK_MOUNT_FLASH - { - char partname[16]; - char mntpoint[16]; - - /* mount -t vfat /dev/mtdblock0 /mnt/p0 */ - - snprintf(partname, sizeof(partname), "/dev/mtdblock%d", - CONFIG_SPARK_FLASH_MINOR); - snprintf(mntpoint, sizeof(mntpoint)-1, CONFIG_SPARK_FLASH_MOUNT_POINT, - CONFIG_SPARK_FLASH_MINOR); - - /* Mount the file system at /mnt/pn */ - - ret = mount(partname, mntpoint, "vfat", 0, NULL); - if (ret < 0) - { - ferr("ERROR: Failed to mount the FAT volume: %d\n", errno); - return ret; - } - } -#endif -#else - { - int partno; - int partsize; - int partoffset; - const char *partstring = CONFIG_SPARK_FLASH_PART_LIST; - const char *ptr; - FAR struct mtd_dev_s *mtd_part; - char partname[16]; - char mntpoint[16]; - - /* Now create a partition on the FLASH device */ - - partno = CONFIG_SPARK_FLASH_MINOR; - ptr = partstring; - partoffset = 0; - while (*ptr != '\0') - { - /* Get the partition size */ - - partsize = atoi(ptr); - mtd_part = mtd_partition(mtd, partoffset, (partsize >> 2) * 16); - partoffset += (partsize >> 2) * 16; - - /* Use the FTL layer to wrap the MTD driver as a block driver */ - - ret = ftl_initialize(partno, mtd_part); - if (ret < 0) - { - ferr("ERROR: Initialize the FTL layer\n"); - return ret; - } - - snprintf(partname,sizeof(partname), "/dev/mtdblock%d", partno); - snprintf(mntpoint,sizeof(mntpoint)-1, CONFIG_SPARK_FLASH_MOUNT_POINT, - partno); - - /* Mount the file system at /mnt/pn */ - - ret = mount(partname, mntpoint, "vfat", 0, NULL); - if (ret < 0) - { - ferr("ERROR: Failed to mount the FAT volume: %d\n", errno); - return ret; - } - - /* Update the pointer to point to the next size in the list */ - - while ((*ptr >= '0') && (*ptr <= '9')) - { - ptr++; - } - - if (*ptr == ',') - { - ptr++; - } - - /* Increment the part number */ - - partno++; - } - } -#endif /* CONFIG_SPARK_FLASH_PART */ - } -#endif /* HAVE_SST25 */ - -#ifdef HAVE_USBMONITOR - { - int ret; - - /* Start the USB Monitor */ - - ret = usbmonitor_start(); - if (ret != OK) - { - syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); - } - } -#endif - - g_app_initialzed = true; - return OK; -} diff --git a/configs/spark/src/stm32_autoleds.c b/configs/spark/src/stm32_autoleds.c deleted file mode 100644 index 8d72a6678c..0000000000 --- a/configs/spark/src/stm32_autoleds.c +++ /dev/null @@ -1,287 +0,0 @@ -/**************************************************************************** - * configs/spark/src/stm32_autoleds.c - * - * Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * David Sidrane - * - * 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 - -#include -#include -#include - -#include -#include - -#include "chip.h" -#include "up_arch.h" -#include "up_internal.h" -#include "stm32.h" -#include "spark.h" - -#ifdef CONFIG_ARCH_LEDS - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* The following definitions map the encoded LED setting to bit sets used to - * manipulate the LEDs. All terms are in true logic, the led polarity is dealt - * with in the phy_xxx operations - */ - -#define ON_SETBITS_SHIFT (0) -#define ON_CLRBITS_SHIFT (4) -#define OFF_SETBITS_SHIFT (8) -#define OFF_CLRBITS_SHIFT (12) - -#define ON_BITS(v) ((v) & 0xff) -#define OFF_BITS(v) (((v) >> 8) & 0x0ff) -#define SETBITS(b) ((b) & 0x0f) -#define CLRBITS(b) (((b) >> 4) & 0x0f) - -#define ON_SETBITS(v) (SETBITS(ON_BITS(v)) -#define ON_CLRBITS(v) (CLRBITS(ON_BITS(v)) -#define OFF_SETBITS(v) (SETBITS(OFF_BITS(v)) -#define OFF_CLRBITS(v) (CLRBITS(OFF_BITS(v)) - -#define LED_STARTED_ON_SETBITS ((BOARD_RED_LED_BIT) << ON_SETBITS_SHIFT) -#define LED_STARTED_ON_CLRBITS ((BOARD_GREEN_LED_BIT|BOARD_BLUE_LED_BIT|BOARD_USR_LED_BIT) << ON_CLRBITS_SHIFT) -#define LED_STARTED_OFF_SETBITS (0 << OFF_SETBITS_SHIFT) -#define LED_STARTED_OFF_CLRBITS ((BOARD_RED_LED_BIT|BOARD_GREEN_LED_BIT|BOARD_BLUE_LED_BIT|BOARD_USR_LED_BIT) << OFF_CLRBITS_SHIFT) - -#define LED_HEAPALLOCATE_ON_SETBITS ((BOARD_BLUE_LED_BIT) << ON_SETBITS_SHIFT) -#define LED_HEAPALLOCATE_ON_CLRBITS ((BOARD_RED_LED_BIT|BOARD_GREEN_LED_BIT|BOARD_USR_LED_BIT) << ON_CLRBITS_SHIFT) -#define LED_HEAPALLOCATE_OFF_SETBITS ((BOARD_RED_LED_BIT) << OFF_SETBITS_SHIFT) -#define LED_HEAPALLOCATE_OFF_CLRBITS ((BOARD_GREEN_LED_BIT|BOARD_BLUE_LED_BIT|BOARD_USR_LED_BIT) << OFF_CLRBITS_SHIFT) - -#define LED_IRQSENABLED_ON_SETBITS ((BOARD_RED_LED_BIT|BOARD_GREEN_LED_BIT) << ON_SETBITS_SHIFT) -#define LED_IRQSENABLED_ON_CLRBITS ((BOARD_BLUE_LED_BIT|BOARD_USR_LED_BIT) << ON_CLRBITS_SHIFT) -#define LED_IRQSENABLED_OFF_SETBITS ((BOARD_BLUE_LED_BIT) << OFF_SETBITS_SHIFT) -#define LED_IRQSENABLED_OFF_CLRBITS ((BOARD_RED_LED_BIT|BOARD_GREEN_LED_BIT|BOARD_USR_LED_BIT) << OFF_CLRBITS_SHIFT) - -#define LED_STACKCREATED_ON_SETBITS ((BOARD_GREEN_LED_BIT) << ON_SETBITS_SHIFT) -#define LED_STACKCREATED_ON_CLRBITS ((BOARD_RED_LED_BIT|BOARD_BLUE_LED_BIT|BOARD_USR_LED_BIT) << ON_CLRBITS_SHIFT) -#define LED_STACKCREATED_OFF_SETBITS ((BOARD_RED_LED_BIT|BOARD_GREEN_LED_BIT) << OFF_SETBITS_SHIFT) -#define LED_STACKCREATED_OFF_CLRBITS ((BOARD_BLUE_LED_BIT|BOARD_USR_LED_BIT) << OFF_CLRBITS_SHIFT) - -#define LED_INIRQ_ON_SETBITS ((BOARD_RED_LED_BIT) << ON_SETBITS_SHIFT) -#define LED_INIRQ_ON_CLRBITS ((0) << ON_CLRBITS_SHIFT) -#define LED_INIRQ_OFF_SETBITS ((0) << OFF_SETBITS_SHIFT) -#define LED_INIRQ_OFF_CLRBITS ((BOARD_RED_LED_BIT) << OFF_CLRBITS_SHIFT) - -#define LED_SIGNAL_ON_SETBITS ((BOARD_BLUE_LED_BIT) << ON_SETBITS_SHIFT) -#define LED_SIGNAL_ON_CLRBITS ((0) << ON_CLRBITS_SHIFT) -#define LED_SIGNAL_OFF_SETBITS ((0) << OFF_SETBITS_SHIFT) -#define LED_SIGNAL_OFF_CLRBITS ((BOARD_BLUE_LED_BIT) << OFF_CLRBITS_SHIFT) - -#define LED_ASSERTION_ON_SETBITS ((BOARD_RED_LED_BIT|BOARD_GREEN_LED_BIT|BOARD_BLUE_LED_BIT) << ON_SETBITS_SHIFT) -#define LED_ASSERTION_ON_CLRBITS ((0) << ON_CLRBITS_SHIFT) -#define LED_ASSERTION_OFF_SETBITS ((0) << OFF_SETBITS_SHIFT) -#define LED_ASSERTION_OFF_CLRBITS ((BOARD_RED_LED_BIT|BOARD_GREEN_LED_BIT|BOARD_BLUE_LED_BIT) << OFF_CLRBITS_SHIFT) - -#define LED_PANIC_ON_SETBITS ((BOARD_RED_LED_BIT) << ON_SETBITS_SHIFT) -#define LED_PANIC_ON_CLRBITS ((0) << ON_CLRBITS_SHIFT) -#define LED_PANIC_OFF_SETBITS ((0) << OFF_SETBITS_SHIFT) -#define LED_PANIC_OFF_CLRBITS ((BOARD_RED_LED_BIT) << OFF_CLRBITS_SHIFT) - -/************************************************************************************** - * Private Function Prototypes - **************************************************************************************/ - -/* LED State Controls */ - -static inline void phy_led_on(unsigned int on_bitset); -static inline void phy_led_off(unsigned int off_bitset); -static void led_setonoff(unsigned int bitset); - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static const uint16_t g_ledbits[LED_NUM_CODES] = -{ - (LED_STARTED_ON_SETBITS | LED_STARTED_ON_CLRBITS | - LED_STARTED_OFF_SETBITS | LED_STARTED_OFF_CLRBITS), - - (LED_HEAPALLOCATE_ON_SETBITS | LED_HEAPALLOCATE_ON_CLRBITS | - LED_HEAPALLOCATE_OFF_SETBITS | LED_HEAPALLOCATE_OFF_CLRBITS), - - (LED_IRQSENABLED_ON_SETBITS | LED_IRQSENABLED_ON_CLRBITS | - LED_IRQSENABLED_OFF_SETBITS | LED_IRQSENABLED_OFF_CLRBITS), - - (LED_STACKCREATED_ON_SETBITS | LED_STACKCREATED_ON_CLRBITS | - LED_STACKCREATED_OFF_SETBITS | LED_STACKCREATED_OFF_CLRBITS), - - (LED_INIRQ_ON_SETBITS | LED_INIRQ_ON_CLRBITS | - LED_INIRQ_OFF_SETBITS | LED_INIRQ_OFF_CLRBITS), - - (LED_SIGNAL_ON_SETBITS | LED_SIGNAL_ON_CLRBITS | - LED_SIGNAL_OFF_SETBITS | LED_SIGNAL_OFF_CLRBITS), - - (LED_ASSERTION_ON_SETBITS | LED_ASSERTION_ON_CLRBITS | - LED_ASSERTION_OFF_SETBITS | LED_ASSERTION_OFF_CLRBITS), - - (LED_PANIC_ON_SETBITS | LED_PANIC_ON_CLRBITS | - LED_PANIC_OFF_SETBITS | LED_PANIC_OFF_CLRBITS) -}; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: phy_led_on - * - * Description: - * Performs the physical IO to turn On LEDs to the bit encoded state - * - ****************************************************************************/ - -static inline void phy_led_on(unsigned int on_bitset) -{ - /* All RGB LEDs are pulled up and, hence, active low */ - - if ((on_bitset & BOARD_RED_LED_BIT) != 0) - { - stm32_gpiowrite(GPIO_LED2, false); - } - - if ((on_bitset & BOARD_GREEN_LED_BIT) != 0) - { - stm32_gpiowrite(GPIO_LED4, false); - } - - if ((on_bitset & BOARD_BLUE_LED_BIT) != 0) - { - stm32_gpiowrite(GPIO_LED3, false); - } - - /* USR LED is pulled down and, hence, active high */ - - if ((on_bitset & BOARD_USR_LED_BIT) != 0) - { - stm32_gpiowrite(GPIO_LED1, true); - } -} - -/**************************************************************************** - * Name: phy_led_off - * - * Description: - * Performs the physical IO to turn Off LEDs to the bit encoded state - * - ****************************************************************************/ - -static inline void phy_led_off(unsigned int off_bitset) -{ - /* All RGB LEDs are pulled up and, hence, active low */ - - if ((off_bitset & BOARD_RED_LED_BIT) != 0) - { - stm32_gpiowrite(GPIO_LED2, true); - } - - if ((off_bitset & BOARD_GREEN_LED_BIT) != 0) - { - stm32_gpiowrite(GPIO_LED4, true); - } - - if ((off_bitset & BOARD_BLUE_LED_BIT) != 0) - { - stm32_gpiowrite(GPIO_LED3, true); - } - - /* USR LED is pulled down and, hence, active high */ - - if ((off_bitset & BOARD_USR_LED_BIT) != 0) - { - stm32_gpiowrite(GPIO_LED1, false); - } -} - -/**************************************************************************** - * Name: led_setonoff - * - * Description: - * Set/clear all LEDs to the bit encoded state - * - ****************************************************************************/ - -static void led_setonoff(unsigned int bits) -{ - phy_led_off(CLRBITS(bits)); - phy_led_on(SETBITS(bits)); -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: board_autoled_initialize - ****************************************************************************/ - -void board_autoled_initialize(void) -{ - /* Configure LED1-4 GPIOs for output */ - - stm32_configgpio(GPIO_LED1); - stm32_configgpio(GPIO_LED2); - stm32_configgpio(GPIO_LED3); - stm32_configgpio(GPIO_LED4); -} - -/**************************************************************************** - * Name: board_autoled_on - ****************************************************************************/ - -void board_autoled_on(int led) -{ - led_setonoff(ON_BITS(g_ledbits[led])); -} - -/**************************************************************************** - * Name: board_autoled_off - ****************************************************************************/ - -void board_autoled_off(int led) -{ - led_setonoff(OFF_BITS(g_ledbits[led])); -} - -#endif /* CONFIG_ARCH_LEDS */ diff --git a/configs/spark/src/stm32_boot.c b/configs/spark/src/stm32_boot.c deleted file mode 100644 index 6d278fb502..0000000000 --- a/configs/spark/src/stm32_boot.c +++ /dev/null @@ -1,138 +0,0 @@ -/************************************************************************************ - * configs/spark/src/stm32_boot.c - * - * Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * Librae - * - * 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 -#include -#include - -#include -#include - -#include "up_arch.h" -#include "spark.h" - -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ - -/************************************************************************************ - * Private Data - ************************************************************************************/ - -/************************************************************************************ - * Public Functions - ************************************************************************************/ - -/************************************************************************************ - * Name: stm32_boardinitialize - * - * Description: - * All STM32 architectures must provide the following entry point. This entry point - * is called early in the initialization -- after all memory has been configured - * and mapped but before any devices have been initialized. - * - ************************************************************************************/ - -void stm32_boardinitialize(void) -{ - /* Configure on-board LEDs if LED support has been selected. */ - -#ifdef CONFIG_ARCH_LEDS - board_autoled_initialize(); -#endif - -#ifdef CONFIG_ARCH_BUTTONS - board_button_initialize(); -#endif - - /* Configure SPI chip selects if 1) SP2 is not disabled, and 2) the weak function - * stm32_spidev_initialize() has been brought into the link. - */ - -#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3) - stm32_spidev_initialize(); -#endif - - - /* Initialize USB is 1) USBDEV is selected, 2) the USB controller is not - * disabled, and 3) the weak function stm32_usbinitialize() has been brought - * into the build. - */ - -#if defined(CONFIG_USBDEV) && defined(CONFIG_STM32_USB) - stm32_usbinitialize(); -#endif -} - -/**************************************************************************** - * Name: board_initialize - * - * Description: - * If CONFIG_BOARD_INITIALIZE is selected, then an additional - * initialization call will be performed in the boot-up sequence to a - * function called board_initialize(). board_initialize() will be - * called immediately after up_intiialize() is called and just before the - * initial application is started. This additional initialization phase - * may be used, for example, to initialize board-specific device drivers. - * - ****************************************************************************/ - -#ifdef CONFIG_BOARD_INITIALIZE -void board_initialize(void) -{ - /* Perform NSH initialization here instead of from the NSH. This - * alternative NSH initialization is necessary when NSH is ran in user-space - * but the initialization function must run in kernel space. - */ - -#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_LIB_BOARDCTL) - board_app_initialize(0); -#endif - - /* CC3000 wireless initialization - * Avoid Double registration if CONFIG_EXAMPLES_CC3000BASIC is defined - */ - -#if defined(CONFIG_WL_CC3000) && !defined(CONFIG_EXAMPLES_CC3000BASIC) - wireless_archinitialize(0); -#endif -} -#endif - diff --git a/configs/spark/src/stm32_buttons.c b/configs/spark/src/stm32_buttons.c deleted file mode 100644 index 3534eeeb6a..0000000000 --- a/configs/spark/src/stm32_buttons.c +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** - * configs/spark/src/stm32_buttons.c - * - * Copyright (C) 2011-2015, 2017 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include - -#include -#include -#include - -#include "spark.h" - -#ifdef CONFIG_ARCH_BUTTONS - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: board_button_initialize - * - * Description: - * board_button_initialize() must be called to initialize button resources. After - * that, board_buttons() may be called to collect the current state of all - * buttons or board_button_irq() may be called to register button interrupt - * handlers. - * - ****************************************************************************/ - -void board_button_initialize(void) -{ - /* Configure the GPIO pins as inputs. NOTE that EXTI interrupts are - * configured for all pins. - */ - - stm32_configgpio(GPIO_BTN); -} - -/**************************************************************************** - * Name: board_buttons - * - * N.B The return state in true logic, the button polarity is dealt here in - ****************************************************************************/ - -uint32_t board_buttons(void) -{ - return stm32_gpioread(GPIO_BTN)==0 ? BUTTON_USER_BIT : 0; -} - -/************************************************************************************ - * Button support. - * - * Description: - * board_button_initialize() must be called to initialize button resources. After - * that, board_buttons() may be called to collect the current state of all - * buttons or board_button_irq() may be called to register button interrupt - * handlers. - * - * After board_button_initialize() has been called, board_buttons() may be called to - * collect the state of all buttons. board_buttons() returns an 32-bit bit set - * with each bit associated with a button. See the BUTTON_*_BIT - * definitions in board.h for the meaning of each bit. - * - * board_button_irq() may be called to register an interrupt handler that will - * be called when a button is depressed or released. The ID value is a - * button enumeration value that uniquely identifies a button resource. See the - * BUTTON_* definitions in board.h for the meaning of enumeration - * value. - * - ************************************************************************************/ - -#ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) -{ - int ret = -EINVAL; - - /* The following should be atomic */ - - if (id == BUTTON_USER) - { - ret = stm32_gpiosetevent(GPIO_BTN, true, true, true, irqhandler, arg); - } - - return ret; -} -#endif -#endif /* CONFIG_ARCH_BUTTONS */ diff --git a/configs/spark/src/stm32_cc3000.c b/configs/spark/src/stm32_cc3000.c deleted file mode 100644 index 8cda9fb602..0000000000 --- a/configs/spark/src/stm32_cc3000.c +++ /dev/null @@ -1,368 +0,0 @@ -/************************************************************************************ - * configs/spark/src/stm32_cc3000.c - * - * Copyright (C) 2009, 2013 Gregory Nutt. All rights reserved. - * Author: Laurent Latil - * David Sidrane - * - * 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 - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "stm32.h" -#include "spark.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ -/* Configuration ************************************************************/ - -#ifdef CONFIG_WL_CC3000 -#ifndef CONFIG_DRIVERS_WIRELESS -# error "Wireless support requires CONFIG_DRIVERS_WIRELESS" -#endif - -#ifndef CONFIG_STM32_SPI2 -# error "CC3000 Wireless support requires CONFIG_STM32_SPI2" -#endif - -#ifndef CC3000_SPI_FREQUENCY -# define CC3000_SPI_FREQUENCY 16000000 -#endif - -#ifndef CC3000_SPIDEV -# define CC3000_SPIDEV 2 -#endif - -#if CC3000_SPIDEV != 2 -# error "CC3000_SPIDEV must be 2" -#endif - -#ifndef CC3000_DEVMINOR -# define CC3000_DEVMINOR 0 -#endif - -#ifndef CONFIG_CC3000_RX_BUFFER_SIZE -#define CONFIG_CC3000_RX_BUFFER_SIZE 132 -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -struct stm32_config_s -{ - struct cc3000_config_s dev; - xcpt_t handler; - void *arg; -}; - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks - * to isolate the CC3000 driver from differences in GPIO interrupt handling - * by varying boards and MCUs. If possible, interrupts should be configured - * on falling edges to detect the Ready Condition At T2: The normal master - * SPI write sequence is SPI_CS low, followed by SPI_IRQ low CC3000 to host, - * indicating that the CC3000 core module is ready to accept data. T2 - * duration is approximately 7 ms. - * - * irq_attach - Attach the CC3000 interrupt handler to the GPIO interrupt - * irq_enable - Enable or disable the GPIO interrupt - * clear_irq - Acknowledge/clear any pending GPIO interrupt - * power_enable - Enable or disable Module enable. - * chip_chip_select - The Chip Select - * wl_read_irq - Return the state of the interrupt GPIO input - */ - -static int wl_attach_irq(FAR struct cc3000_config_s *state, xcpt_t handler, - FAR void *arg); -static void wl_enable_irq(FAR struct cc3000_config_s *state, bool enable); -static void wl_clear_irq(FAR struct cc3000_config_s *state); -static void wl_select(FAR struct cc3000_config_s *state, bool enable); -static void wl_enable_power(FAR struct cc3000_config_s *state, bool enable); -static bool wl_read_irq(FAR struct cc3000_config_s *state); -#ifdef CONFIG_CC3000_PROBES -static bool probe(FAR struct cc3000_config_s *state,int n, bool s); -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* A reference to a structure of this type must be passed to the CC3000 - * driver. This structure provides information about the configuration - * of the CC3000 and provides some board-specific hooks. - * - * Memory for this structure is provided by the caller. It is not copied - * by the driver and is presumed to persist while the driver is active. The - * memory must be writable because, under certain circumstances, the driver - * may modify frequency or X plate resistance values. - */ - -static struct stm32_config_s g_cc3000_info = -{ - .dev.spi_frequency = CONFIG_CC3000_SPI_FREQUENCY, - .dev.spi_mode = CONFIG_CC3000_SPI_MODE, - .dev.max_rx_size = 0, - .dev.irq_attach = wl_attach_irq, - .dev.irq_enable = wl_enable_irq, - .dev.irq_clear = wl_clear_irq, - .dev.power_enable = wl_enable_power, - .dev.chip_chip_select = wl_select, - .dev.irq_read = wl_read_irq, -#ifdef CONFIG_CC3000_PROBES - .dev.probe = probe, /* This is used for debugging */ -#endif - .handler = NULL, - .arg = NULL, -}; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/* IRQ/GPIO access callbacks. These operations all hidden behind - * callbacks to isolate the CC3000 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. - * - * attach - Attach the CC3000 interrupt handler to the GPIO interrupt - * enable - Enable or disable the GPIO interrupt - * clear - Acknowledge/clear any pending GPIO interrupt - * pendown - Return the state of the pen down GPIO input - */ - -static int wl_attach_irq(FAR struct cc3000_config_s *state, xcpt_t handler, - FAR void *arg) -{ - FAR struct stm32_config_s *priv = (FAR struct stm32_config_s *)state; - - /* Just save the handler for use when the interrupt is enabled */ - - priv->handler = handler; - priv->arg = arg; - return OK; -} - -static void wl_enable_irq(FAR struct cc3000_config_s *state, bool enable) -{ - FAR struct stm32_config_s *priv = (FAR struct stm32_config_s *)state; - - /* The caller should not attempt to enable interrupts if the handler - * has not yet been 'attached' - */ - - DEBUGASSERT(priv->handler || !enable); - - /* Attach and enable, or detach and disable */ - - iinfo("enable:%d\n", enable); - if (enable) - { - (void)stm32_gpiosetevent(GPIO_WIFI_INT, false, true, false, - priv->handler, priv->arg); - } - else - { - (void)stm32_gpiosetevent(GPIO_WIFI_INT, false, false, false, - NULL, NULL); - } -} - -static void wl_enable_power(FAR struct cc3000_config_s *state, bool enable) -{ - iinfo("enable:%d\n", enable); - - /* Active high enable */ - - stm32_gpiowrite(GPIO_WIFI_EN, enable); -} - -static void wl_select(FAR struct cc3000_config_s *state, bool enable) -{ - iinfo("enable:%d\n", enable); - - /* Active high enable */ - - stm32_gpiowrite(GPIO_WIFI_CS, enable); -} - -static void wl_clear_irq(FAR struct cc3000_config_s *state) -{ - /* Does nothing */ -} - -static bool wl_read_irq(FAR struct cc3000_config_s *state) -{ - /* Active low*/ - - return stm32_gpioread(GPIO_WIFI_INT) ? false : true; -} - -#ifdef CONFIG_CC3000_PROBES -static bool probe(FAR struct cc3000_config_s *state,int n, bool s) -{ - if (n == 0) - { - stm32_gpiowrite(GPIO_D0, s); - } - - if (n == 1) - { - stm32_gpiowrite(GPIO_D1, s); - } - - return true; -} -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arch_wlinitialize - * - * Description: - * Each board that supports a wireless device must provide this function. - * This function is called by application-specific, setup logic to - * configure the wireless device. This function will register the driver - * as /dev/wirelessN where N is the minor device number. - * - * - * Returned Value: - * Zero is returned on success. Otherwise, a negated errno value is - * returned to indicate the nature of the failure. - * - ****************************************************************************/ - -int wireless_archinitialize(size_t max_rx_size) -{ - FAR struct spi_dev_s *spi; - - /* Init SPI bus */ - - iinfo("minor %d\n", minor); - DEBUGASSERT(CONFIG_CC3000_DEVMINOR == 0); - -#ifdef CONFIG_CC3000_PROBES - stm32_configgpio(GPIO_D0); - stm32_configgpio(GPIO_D1); - stm32_gpiowrite(GPIO_D0, 1); - stm32_gpiowrite(GPIO_D1, 1); -#endif - - /* Get an instance of the SPI interface */ - - spi = stm32_spibus_initialize(CONFIG_CC3000_SPIDEV); - if (!spi) - { - ierr("ERROR: Failed to initialize SPI bus %d\n", CONFIG_CC3000_SPIDEV); - return -ENODEV; - } - - /* Initialize and register the SPI CC3000 device */ - g_cc3000_info.dev.max_rx_size = max_rx_size ? max_rx_size : CONFIG_CC3000_RX_BUFFER_SIZE; - int ret = cc3000_register(spi, &g_cc3000_info.dev, CONFIG_CC3000_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to initialize SPI bus %d\n", CONFIG_CC3000_SPIDEV); - return -ENODEV; - } - - return OK; -} - -/**************************************************************************** - * Name: C3000_wlan_init - * - * Description: - * Initialize wlan driver - * - * Warning: This function must be called before ANY other wlan driver - * function - * - * Input Parameters: - * sWlanCB Asynchronous events callback. - * 0 no event call back. - * - Call back parameters: - * 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event, - * HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event, - * HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done, - * HCI_EVNT_WLAN_UNSOL_DHCP dhcp report, - * HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR - * HCI_EVNT_WLAN_KEEPALIVE keepalive. - * 2) data: pointer to extra data that received by the event - * (NULL no data). - * 3) length: data length. - * - Events with extra data: - * HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask, - * 4 bytes default gateway, 4 bytes DHCP server and 4 bytes - * for DNS server. - * HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent, - * 4 bytes Packets received, 4 bytes Min round time, - * 4 bytes Max round time and 4 bytes for Avg round time. - * - * sFWPatches 0 no patch or pointer to FW patches - * sDriverPatches 0 no patch or pointer to driver patches - * sBootLoaderPatches 0 no patch or pointer to bootloader patches - * - * Returned Value: - * None - * - ****************************************************************************/ - -void cc3000_wlan_init(size_t max_tx_len, - tWlanCB sWlanCB, - tFWPatches sFWPatches, tDriverPatches - sDriverPatches, tBootLoaderPatches sBootLoaderPatches) -{ - wlan_init(max_tx_len, sWlanCB, sFWPatches, sDriverPatches, sBootLoaderPatches); -} - -#endif /* CONFIG_WL_CC3000 */ diff --git a/configs/spark/src/stm32_composite.c b/configs/spark/src/stm32_composite.c deleted file mode 100644 index 9d8943c18e..0000000000 --- a/configs/spark/src/stm32_composite.c +++ /dev/null @@ -1,621 +0,0 @@ -/**************************************************************************** - * config/spark/src/stm32_composite.c - * - * Copyright (C) 2012-2013, 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * David_s5 - * - * 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 - -#include -#include -#include -#include - -#include -#include - -#ifdef CONFIG_MTD_SST25 -# include -# include -# include -#endif - -#include -#include -#include -#include - -#ifdef CONFIG_USBMONITOR -# include -#endif - -#ifdef CONFIG_USBDEV -# include "stm32_usbdev.h" -#endif - -#include "stm32.h" -#include "spark.h" - -#if defined(CONFIG_BOARDCTL_USBDEVCTRL) && defined(CONFIG_USBDEV_COMPOSITE) - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -/* Can't support the SST25 device if it SPI2 or SST25 support is not enabled */ - -#define HAVE_SST25 1 -#if !defined(CONFIG_STM32_SPI2) || !defined(CONFIG_MTD_SST25) -# undef HAVE_SST25 -#endif - -/* Can't support SST25 features if mountpoints are disabled */ - -#if defined(CONFIG_DISABLE_MOUNTPOINT) -# undef HAVE_SST25 -#endif - -#ifndef CONFIG_SPARK_FLASH_MOUNT_POINT -# define CONFIG_SPARK_FLASH_MOUNT_POINT "/mnt/p%d" -#endif - -/* Use minor device number 0 is not is provided */ - -#ifndef CONFIG_SPARK_FLASH_MINOR -# define CONFIG_SPARK_FLASH_MINOR 0 -#endif - -/* Can't support both FAT and NXFFS */ - -#if defined(CONFIG_FS_FAT) && defined(CONFIG_FS_NXFFS) -# warning "Can't support both FAT and NXFFS -- using FAT" -#endif - -#define HAVE_USBDEV 1 -#define HAVE_USBMONITOR 1 - -/* Can't support USB device is USB device is not enabled */ - -#ifndef CONFIG_USBDEV -# undef HAVE_USBDEV -# undef HAVE_USBMONITOR -#endif - -/* Check if we should enable the USB monitor before starting NSH */ - -#if !defined(CONFIG_USBDEV_TRACE) || !defined(CONFIG_USBMONITOR) -# undef HAVE_USBMONITOR -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -#ifdef CONFIG_USBMSC_COMPOSITE -static FAR void *g_mschandle; -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: stm32_composite_initialize - * - * Description: - * Perform architecture specific initialization - * - ****************************************************************************/ - -#ifndef CONFIG_NSH_BUILTIN_APPS -static int stm32_composite_initialize(void) -{ -#ifdef HAVE_SST25 - FAR struct spi_dev_s *spi; - FAR struct mtd_dev_s *mtd; - int ret; - - /* Configure SPI-based devices */ - - /* Get the SPI port */ - - finfo("Initializing SPI port %d\n", CONFIG_SPARK_FLASH_SPI); - - spi = stm32_spibus_initialize(CONFIG_SPARK_FLASH_SPI); - if (!spi) - { - ferr("ERROR: Failed to initialize SPI port %d\n", - CONFIG_SPARK_FLASH_SPI); - return -ENODEV; - } - - finfo("Successfully initialized SPI port %d\n", CONFIG_SPARK_FLASH_SPI); - - /* Now bind the SPI interface to the SST25 SPI FLASH driver */ - - finfo("Bind SPI to the SPI flash driver\n"); - mtd = sst25_initialize(spi); - if (!mtd) - { - ferr("ERROR: Failed to bind SPI port %d to the SPI FLASH driver\n", - CONFIG_SPARK_FLASH_SPI); - } - else - { - finfo("Successfully bound SPI port %d to the SPI FLASH driver\n", - CONFIG_SPARK_FLASH_SPI); - } - -#ifndef CONFIG_SPARK_FLASH_PART - - /* Use the FTL layer to wrap the MTD driver as a block driver */ - - ret = ftl_initialize(CONFIG_SPARK_FLASH_MINOR, mtd); - if (ret < 0) - { - ferr("ERROR: Initialize the FTL layer\n"); - return ret; - } - -#ifdef CONFIG_SPARK_MOUNT_FLASH - char partname[16]; - char mntpoint[16]; - - /* mount -t vfat /dev/mtdblock0 /mnt/p0 */ - - snprintf(partname, sizeof(partname), "/dev/mtdblock%d", - CONFIG_SPARK_FLASH_MINOR); - snprintf(mntpoint, sizeof(mntpoint)-1, CONFIG_SPARK_FLASH_MOUNT_POINT, - CONFIG_SPARK_FLASH_MINOR); - - /* Mount the file system at /mnt/pn */ - - ret = mount(partname, mntpoint, "vfat", 0, NULL); - if (ret < 0) - { - ferr("ERROR: Failed to mount the FAT volume: %d\n", errno); - return ret; - } - -#endif -#else - { - int partno; - int partsize; - int partoffset; - const char *partstring = CONFIG_SPARK_FLASH_PART_LIST; - const char *ptr; - FAR struct mtd_dev_s *mtd_part; - char partname[16]; - char mntpoint[16]; - - /* Now create a partition on the FLASH device */ - - partno = CONFIG_SPARK_FLASH_MINOR; - ptr = partstring; - partoffset = 0; - while (*ptr != '\0') - { - /* Get the partition size */ - - partsize = atoi(ptr); - mtd_part = mtd_partition(mtd, partoffset, (partsize >> 2) * 16); - partoffset += (partsize >> 2) * 16; - - /* Use the FTL layer to wrap the MTD driver as a block driver */ - - ret = ftl_initialize(partno, mtd_part); - if (ret < 0) - { - ferr("ERROR: Initialize the FTL layer\n"); - return ret; - } - - snprintf(partname,sizeof(partname), "/dev/mtdblock%d", partno); - snprintf(mntpoint,sizeof(mntpoint)-1, CONFIG_SPARK_FLASH_MOUNT_POINT, - partno); - - /* Mount the file system at /mnt/pn */ - - ret = mount(partname, mntpoint, "vfat", 0, NULL); - if (ret < 0) - { - ferr("ERROR: Failed to mount the FAT volume: %d\n", errno); - return ret; - } - - /* Update the pointer to point to the next size in the list */ - - while ((*ptr >= '0') && (*ptr <= '9')) - { - ptr++; - } - - if (*ptr == ',') - { - ptr++; - } - - /* Increment the part number */ - - partno++; - } - } -#endif /* CONFIG_SPARK_FLASH_PART */ - -#endif /* HAVE_SST25 */ - -#ifdef HAVE_USBMONITOR - /* Start the USB Monitor */ - - ret = usbmonitor_start(); - if (ret != OK) - { - ferr("ERROR: Failed to start USB monitor: %d\n", ret); - } -#endif - - return OK; -} -#endif - -/**************************************************************************** - * Name: board_mscclassobject - * - * Description: - * If the mass storage class driver is part of composite device, then - * its instantiation and configuration is a multi-step, board-specific, - * process (See comments for usbmsc_configure below). In this case, - * board-specific logic must provide board_mscclassobject(). - * - * board_mscclassobject() is called from the composite driver. It must - * encapsulate the instantiation and configuration of the mass storage - * class and the return the mass storage device's class driver instance - * to the composite driver. - * - * Input Parameters: - * classdev - The location to return the mass storage class' device - * instance. - * - * Returned Value: - * 0 on success; a negated errno on failure - * - ****************************************************************************/ - -#ifdef CONFIG_USBMSC_COMPOSITE -static int board_mscclassobject(int minor, - FAR struct usbdev_devinfo_s *devinfo, - FAR struct usbdevclass_driver_s **classdev) -{ - int ret; - - DEBUGASSERT(g_mschandle == NULL); - - /* Configure the mass storage device */ - - uinfo("Configuring with NLUNS=1\n"); - ret = usbmsc_configure(1, &g_mschandle); - if (ret < 0) - { - uerr("ERROR: usbmsc_configure failed: %d\n", -ret); - return ret; - } - - uinfo("MSC handle=%p\n", g_mschandle); - - /* Bind the LUN(s) */ - - uinfo("Bind LUN=0 to /dev/mtdblock0\n"); - ret = usbmsc_bindlun(g_mschandle, "/dev/mtdblock0", 0, 0, 0, false); - if (ret < 0) - { - uerr("ERROR: usbmsc_bindlun failed for LUN 1 at /dev/mtdblock0: %d\n", - ret); - usbmsc_uninitialize(g_mschandle); - g_mschandle = NULL; - return ret; - } - - /* Get the mass storage device's class object */ - - ret = usbmsc_classobject(g_mschandle, devinfo, classdev); - if (ret < 0) - { - uerr("ERROR: usbmsc_classobject failed: %d\n", -ret); - usbmsc_uninitialize(g_mschandle); - g_mschandle = NULL; - } - - return ret; -} -#endif - - /**************************************************************************** - * Name: board_mscuninitialize - * - * Description: - * Un-initialize the USB storage class driver. This is just an application- - * specific wrapper aboutn usbmsc_unitialize() that is called form the - * composite device logic. - * - * Input Parameters: - * classdev - The class driver instrance previously give to the composite - * driver by board_mscclassobject(). - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_USBMSC_COMPOSITE -static void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) -{ - DEBUGASSERT(g_mschandle != NULL); - usbmsc_uninitialize(g_mschandle); - g_mschandle = NULL; -} -#endif - -/**************************************************************************** - * Name: board_composite0_connect - * - * Description: - * Connect the USB composite device on the specified USB device port for - * configuration 0. - * - * Input Parameters: - * port - The USB device port. - * - * Returned Value: - * A non-NULL handle value is returned on success. NULL is returned on - * any failure. - * - ****************************************************************************/ - -#ifdef CONFIG_USBMSC_COMPOSITE -static FAR void *board_composite0_connect(int port) -{ - /* Here we are composing the configuration of the usb composite device. - * - * The standard is to use one CDC/ACM and one USB mass storage device. - */ - - struct composite_devdesc_s dev[2]; - int ifnobase = 0; - int strbase = COMPOSITE_NSTRIDS; - - /* Configure the CDC/ACM device */ - - /* Ask the cdcacm driver to fill in the constants we didn't - * know here. - */ - - cdcacm_get_composite_devdesc(&dev[0]); - - /* Overwrite and correct some values... */ - /* The callback functions for the CDC/ACM class */ - - dev[0].classobject = cdcacm_classobject; - dev[0].uninitialize = cdcacm_uninitialize; - - /* Interfaces */ - - dev[0].devinfo.ifnobase = ifnobase; /* Offset to Interface-IDs */ - dev[0].minor = 0; /* The minor interface number */ - - /* Strings */ - - dev[0].devinfo.strbase = strbase; /* Offset to String Numbers */ - - /* Endpoints */ - - dev[0].devinfo.epno[CDCACM_EP_INTIN_IDX] = 1; - dev[0].devinfo.epno[CDCACM_EP_BULKIN_IDX] = 2; - dev[0].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = 3; - - /* Count up the base numbers */ - - ifnobase += dev[0].devinfo.ninterfaces; - strbase += dev[0].devinfo.nstrings; - - /* Configure the mass storage device device */ - /* Ask the usbmsc driver to fill in the constants we didn't - * know here. - */ - - usbmsc_get_composite_devdesc(&dev[1]); - - /* Overwrite and correct some values... */ - /* The callback functions for the USBMSC class */ - - dev[1].classobject = board_mscclassobject; - dev[1].uninitialize = board_mscuninitialize; - - /* Interfaces */ - - dev[1].devinfo.ifnobase = ifnobase; /* Offset to Interface-IDs */ - dev[1].minor = 0; /* The minor interface number */ - - /* Strings */ - - dev[1].devinfo.strbase = strbase; /* Offset to String Numbers */ - - /* Endpoints */ - - dev[1].devinfo.epno[USBMSC_EP_BULKIN_IDX] = 5; - dev[1].devinfo.epno[USBMSC_EP_BULKOUT_IDX] = 4; - - /* Count up the base numbers */ - - ifnobase += dev[1].devinfo.ninterfaces; - strbase += dev[1].devinfo.nstrings; - - return composite_initialize(2, dev); -} -#endif - -/**************************************************************************** - * Name: board_composite1_connect - * - * Description: - * Connect the USB composite device on the specified USB device port for - * configuration 1. - * - * Input Parameters: - * port - The USB device port. - * - * Returned Value: - * A non-NULL handle value is returned on success. NULL is returned on - * any failure. - * - ****************************************************************************/ - -static FAR void *board_composite1_connect(int port) -{ - /* REVISIT: This configuration currently fails. stm32_epallocpma() fails - * allocate a buffer for the 6th endpoint. Currenlty it supports 7x64 byte - * buffers, two required for EP0, leaving only buffers for 5 additional - * endpoints. - */ - -#if 0 - struct composite_devdesc_s dev[2]; - int strbase = COMPOSITE_NSTRIDS; - int ifnobase = 0; - int epno; - int i; - - for (i = 0, epno = 1; i < 2; i++) - { - /* Ask the cdcacm driver to fill in the constants we didn't know here */ - - cdcacm_get_composite_devdesc(&dev[i]); - - /* Overwrite and correct some values... */ - /* The callback functions for the CDC/ACM class */ - - dev[i].classobject = cdcacm_classobject; - dev[i].uninitialize = cdcacm_uninitialize; - - dev[i].minor = i; /* The minor interface number */ - - /* Interfaces */ - - dev[i].devinfo.ifnobase = ifnobase; /* Offset to Interface-IDs */ - - /* Strings */ - - dev[i].devinfo.strbase = strbase; /* Offset to String Numbers */ - - /* Endpoints */ - - dev[i].devinfo.epno[CDCACM_EP_INTIN_IDX] = epno++; - dev[i].devinfo.epno[CDCACM_EP_BULKIN_IDX] = epno++; - dev[i].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = epno++; - - ifnobase += dev[i].devinfo.ninterfaces; - strbase += dev[i].devinfo.nstrings; - } - - return composite_initialize(2, dev); -#else - return NULL; -#endif -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: board_composite_initialize - * - * Description: - * Perform architecture specific initialization of a composite USB device. - * - ****************************************************************************/ - -int board_composite_initialize(int port) -{ -#ifdef CONFIG_NSH_BUILTIN_APPS - return OK; -#else - return stm32_composite_initialize(); -#endif -} - -/**************************************************************************** - * Name: board_composite_connect - * - * Description: - * Connect the USB composite device on the specified USB device port using - * the specified configuration. The interpretation of the configid is - * board specific. - * - * Input Parameters: - * port - The USB device port. - * configid - The USB composite configuration - * - * Returned Value: - * A non-NULL handle value is returned on success. NULL is returned on - * any failure. - * - ****************************************************************************/ - -FAR void *board_composite_connect(int port, int configid) -{ - if (configid == 0) - { -#ifdef CONFIG_USBMSC_COMPOSITE - return board_composite0_connect(port); -#else - return NULL; -#endif - } - else if (configid == 1) - { - return board_composite1_connect(port); - } - else - { - return NULL; - } -} - -#endif /* CONFIG_BOARDCTL_USBDEVCTRL && CONFIG_USBDEV_COMPOSITE */ diff --git a/configs/spark/src/stm32_io.c b/configs/spark/src/stm32_io.c deleted file mode 100644 index b6601c1ac6..0000000000 --- a/configs/spark/src/stm32_io.c +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************** - * configs/spark/src/stm32_io.c - * - * Copyright (C) 2011-2014, 2017 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include - -#include -#include "chip/stm32_tim.h" - -#include "spark.h" - -#ifndef CONFIG_CC3000_PROBES - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_leds - * - * Description: - * - ****************************************************************************/ - -void up_leds(int r, int g ,int b, int freqs) -{ - long fosc = 72000000; - long prescale = 2048; - long p1s = fosc/prescale; - long p0p5s = p1s/2; - long p; - - static struct stm32_tim_dev_s *tim1 = 0; - - if (tim1 == 0) - { - tim1 = stm32_tim_init(1); - STM32_TIM_SETMODE(tim1, STM32_TIM_MODE_UP); - STM32_TIM_SETCLOCK(tim1, p1s-8); - STM32_TIM_SETPERIOD(tim1, p1s); - STM32_TIM_SETCOMPARE(tim1, 1, 0); - STM32_TIM_SETCOMPARE(tim1, 2, 0); - STM32_TIM_SETCOMPARE(tim1, 3, 0); - STM32_TIM_SETCHANNEL(tim1, 1, STM32_TIM_CH_OUTPWM | STM32_TIM_CH_POLARITY_NEG); - STM32_TIM_SETCHANNEL(tim1, 2, STM32_TIM_CH_OUTPWM | STM32_TIM_CH_POLARITY_NEG); - STM32_TIM_SETCHANNEL(tim1, 3, STM32_TIM_CH_OUTPWM | STM32_TIM_CH_POLARITY_NEG); - } - - p = freqs == 0 ? p1s : p1s / freqs; - STM32_TIM_SETPERIOD(tim1, p); - - p = freqs == 0 ? p1s + 1 : p0p5s / freqs; - - STM32_TIM_SETCOMPARE(tim1, 2, (r * p) / 255); - STM32_TIM_SETCOMPARE(tim1, 1, (b * p) / 255); - STM32_TIM_SETCOMPARE(tim1, 3, (g * p) / 255); -} - -/**************************************************************************** - * Name: up_ioinit - * - * Description: - * - ****************************************************************************/ - -void up_ioinit(void) -{ - /* Configure the GPIO pins as inputs. NOTE that EXTI interrupts are - * configured for all pins. - */ - - up_leds(0,0,0,0); - stm32_configgpio(GPIO_A0); /* Probes */ - stm32_configgpio(GPIO_A1); /* Probes */ - stm32_configgpio(GPIO_A2); /* Smart Config */ - stm32_configgpio(GPIO_A3); /* not used */ - stm32_configgpio(GPIO_D0); /* Sw 1 */ - stm32_configgpio(GPIO_D1); /* Sw 2 */ - stm32_configgpio(GPIO_D2); /* Activate */ -} - -/**************************************************************************** - * Name: up_read_inputs - * - * N.B The return state in true logic, the button polarity is dealt here in - * - ****************************************************************************/ - -uint8_t up_read_inputs(void) -{ - uint8_t bits = 0; - bits |= stm32_gpioread(GPIO_D0) == 0 ? 1 : 0; - bits |= stm32_gpioread(GPIO_D1) == 0 ? 2 : 0; - bits |= stm32_gpioread(GPIO_A2) == 0 ? 4 : 0; - bits |= stm32_gpioread(GPIO_A3) == 0 ? 8 : 0; - return bits; -} - -/**************************************************************************** - * Name: up_write_outputs - * - * N.B The return state in true logic, the button polarity is dealt here in - * - ****************************************************************************/ - -void up_write_outputs(int id, bool bits) -{ - if (id == 2) - { - stm32_gpiowrite(GPIO_D2, bits); - } - else if (id == 0) - { - stm32_gpiowrite(GPIO_A0, bits); - } - else if (id == 1) - { - stm32_gpiowrite(GPIO_A1, bits); - } -} - -/**************************************************************************** - * Name: up_irqio - * - * Description: - * - ****************************************************************************/ - -int up_irqio(int id, xcpt_t irqhandler, void *arg) -{ - int ret = -EINVAL; - - /* The following should be atomic */ - - if (id == 0) - { - ret = stm32_gpiosetevent(GPIO_D0, true, true, true, irqhandler, arg); - } - else if (id == 1) - { - ret = stm32_gpiosetevent(GPIO_D1, true, true, true, irqhandler, arg); - } - - return ret; -} -#endif /* CONFIG_CC3000_PROBES */ diff --git a/configs/spark/src/stm32_spi.c b/configs/spark/src/stm32_spi.c deleted file mode 100644 index 8002196d86..0000000000 --- a/configs/spark/src/stm32_spi.c +++ /dev/null @@ -1,219 +0,0 @@ -/************************************************************************************ - * configs/spark/src/stm32_spi.c - * - * Copyright (C) 2011-2013 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Modifications: - * - * - 10/8/2013: David Sidrane - * - Modified to support SPI2 on the Spark Core. - * - * 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 - -#include -#include -#include -#include - -#include -#include - -#include "up_arch.h" -#include "chip.h" -#include "stm32.h" -#include "spark.h" - -#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3) - -/************************************************************************************ - * Public Functions - ************************************************************************************/ - -/************************************************************************************ - * Name: stm32_spidev_initialize - * - * Description: - * Called to configure SPI chip select GPIO pins for the Spark board. - * - ************************************************************************************/ - -void weak_function stm32_spidev_initialize(void) -{ -#ifdef CONFIG_STM32_SPI2 - - /* Setup CS, EN & IRQ line IOs */ - -#ifdef CONFIG_WL_CC3000 - stm32_configgpio(GPIO_WIFI_CS); - stm32_configgpio(GPIO_WIFI_EN); - stm32_configgpio(GPIO_WIFI_INT); -#endif - -#ifdef CONFIG_MTD_SST25 - stm32_configgpio(GPIO_MEM_CS); /* FLASH chip select */ -#endif - -#endif -} - -/**************************************************************************** - * Name: stm32_spi1/2/3select and stm32_spi1/2/3status - * - * Description: - * The external functions, stm32_spi1/2/3select and stm32_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 stm32_spibus_initialize()) - * are provided by common STM32 logic. To use this common SPI logic on your - * board: - * - * 1. Provide logic in stm32_boardinitialize() to configure SPI chip select - * pins. - * 2. Provide stm32_spi1/2/3select() and stm32_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 stm32_spibus_initialize() in your low level application - * initialization logic - * 4. The handle returned by stm32_spibus_initialize() 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_STM32_SPI1 -void stm32_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 stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) -{ - return 0; -} -#endif - -#ifdef CONFIG_STM32_SPI2 -void stm32_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) -{ - spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); - -#if defined(CONFIG_MTD_SST25) - - if (devid == SPIDEV_FLASH(0)) - { - stm32_gpiowrite(GPIO_MEM_CS, !selected); - } -#if defined(CONFIG_WL_CC3000) - else -#endif -#endif - -#if defined(CONFIG_WL_CC3000) - if (devid == SPIDEV_WIRELESS(0)) - { - stm32_gpiowrite(GPIO_WIFI_CS, !selected); - } -#endif -} - -uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) -{ - return 0; -} -#endif - -#ifdef CONFIG_STM32_SPI3 -void stm32_spi3select(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 stm32_spi3status(FAR struct spi_dev_s *dev, uint32_t devid) -{ - return 0; -} -#endif - -/**************************************************************************** - * Name: stm32_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_STM32_SPI1 -int stm32_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) -{ - return -ENODEV; -} -#endif - -#ifdef CONFIG_STM32_SPI2 -int stm32_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) -{ - return OK; -} -#endif - -#ifdef CONFIG_STM32_SPI3 -int stm32_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) -{ - return OK; -} -#endif -#endif /* CONFIG_SPI_CMDDATA */ - -#endif /* CONFIG_STM32_SPI1 || CONFIG_STM32_SPI2 */ diff --git a/configs/spark/src/stm32_usbdev.c b/configs/spark/src/stm32_usbdev.c deleted file mode 100644 index ef59cef0c6..0000000000 --- a/configs/spark/src/stm32_usbdev.c +++ /dev/null @@ -1,117 +0,0 @@ -/************************************************************************************ - * configs/spark/src/stm32_usbdev.c - * - * Copyright (C) 2009-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * Librae - * - * 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 - -#include -#include -#include -#include - -#include -#include - -#include "up_arch.h" -#include "stm32.h" -#include "spark.h" - -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ - -/************************************************************************************ - * Private Functions - ************************************************************************************/ - -/************************************************************************************ - * Public Functions - ************************************************************************************/ - -/************************************************************************************ - * Name: stm32_usbinitialize - * - * Description: - * Called to setup USB-related GPIO pins. - * - ************************************************************************************/ - -void stm32_usbinitialize(void) -{ - uinfo("called\n"); - - /* USB Soft Connect Pullup */ - - stm32_configgpio(GPIO_USB_PULLUP); -} - -/************************************************************************************ - * Name: stm32_usbpullup - * - * Description: - * If USB is supported and the board supports a pullup via GPIO (for USB software - * connect and disconnect), then the board software must provide stm32_pullup. - * See include/nuttx/usb/usbdev.h for additional description of this method. - * Alternatively, if no pull-up GPIO the following EXTERN can be redefined to be - * NULL. - * - ************************************************************************************/ - -int stm32_usbpullup(FAR struct usbdev_s *dev, bool enable) -{ - usbtrace(TRACE_DEVPULLUP, (uint16_t)enable); - stm32_gpiowrite(GPIO_USB_PULLUP, !enable); - return OK; -} - -/************************************************************************************ - * Name: stm32_usbsuspend - * - * Description: - * Board logic must provide the stm32_usbsuspend logic if the USBDEV driver is - * used. This function is called whenever the USB enters or leaves suspend mode. - * This is an opportunity for the board logic to shutdown clocks, power, etc. - * while the USB is suspended. - * - ************************************************************************************/ - -void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume) -{ - uinfo("resume: %d\n", resume); -} diff --git a/configs/spark/src/stm32_usbmsc.c b/configs/spark/src/stm32_usbmsc.c deleted file mode 100644 index 57e9e30d82..0000000000 --- a/configs/spark/src/stm32_usbmsc.c +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** - * configs/spark/src/stm32_usbmsc.c - * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include - -#include "nuttx/board.h" - -#include "spark.h" - -#if defined(CONFIG_USBMSC) && defined(CONFIG_BOARDCTL_USBDEVCTRL) - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: board_usbmsc_initialize - * - * Description: - * Perform architecture specific initialization as needed to establish - * the mass storage device that will be exported by the USB MSC device. - * - ****************************************************************************/ - -int board_usbmsc_initialize(int port) -{ - return board_app_initialize(0); -} - -#endif /* CONFIG_USBMSC && CONFIG_BOARDCTL_USBDEVCTRL */ diff --git a/configs/spark/src/stm32_userleds.c b/configs/spark/src/stm32_userleds.c deleted file mode 100644 index 7acbf76b89..0000000000 --- a/configs/spark/src/stm32_userleds.c +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** - * configs/spark/src/stm32_userleds.c - * - * Copyright (C) 2011, 2013, 2015 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include -#include - -#include -#include - -#include "chip.h" -#include "up_arch.h" -#include "up_internal.h" -#include "stm32.h" -#include "spark.h" - -#ifndef CONFIG_ARCH_LEDS - -/**************************************************************************** - * Private Data - ****************************************************************************/ -/* This array maps an LED number to GPIO pin configuration */ - -static uint32_t g_ledcfg[BOARD_NLEDS] = -{ - GPIO_LED1, GPIO_LED2, GPIO_LED3, GPIO_LED4 -}; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: board_userled_initialize - ****************************************************************************/ - -void board_userled_initialize(void) -{ - /* Configure LED1-4 GPIOs for output */ - - stm32_configgpio(GPIO_LED1); - stm32_configgpio(GPIO_LED2); - stm32_configgpio(GPIO_LED3); - stm32_configgpio(GPIO_LED4); -} - -/**************************************************************************** - * Name: board_userled - ****************************************************************************/ - -void board_userled(int led, bool ledon) -{ - if ((unsigned)led < BOARD_NLEDS) - { - bool active_low = (LED_ACTIVE_LOW & (1 << ledon)) != 0; - stm32_gpiowrite(g_ledcfg[led], active_low ? !ledon : ledon); - } -} - -/**************************************************************************** - * Name: board_userled_all - * Description: - * This function will be called to set the state of the Leds on the board - * - * Input Parameters: - * ledset: is a bit set of 1s for the LEDs to effect - * led_states_set: a bit set of 1 for on 0 for off - * N.B. The led_states_set terms are in true logic, the led polarity is - * dealt herein - * - ****************************************************************************/ - -void board_userled_all(uint8_t ledset, uint8_t led_states_set) -{ - led_states_set ^= LED_ACTIVE_LOW; - if ((ledset & BOARD_USR_LED_BIT) == 0) - { - stm32_gpiowrite(GPIO_LED1, (led_states_set & BOARD_USR_LED_BIT) == 0); - } - - if ((ledset & BOARD_RED_LED_BIT) == 0) - { - stm32_gpiowrite(GPIO_LED2, (led_states_set & BOARD_RED_LED_BIT) == 0); - } - - if ((ledset & BOARD_BLUE_LED_BIT) == 0) - { - stm32_gpiowrite(GPIO_LED3, (led_states_set & BOARD_BLUE_LED_BIT) == 0); - } - - if ((ledset & BOARD_GREEN_LED_BIT) == 0) - { - stm32_gpiowrite(GPIO_LED4, (led_states_set & BOARD_GREEN_LED_BIT) == 0); - } -} - -#endif /* !CONFIG_ARCH_LEDS */ diff --git a/configs/spark/tools/dfu.sh b/configs/spark/tools/dfu.sh deleted file mode 100755 index 4ca7e0eb1e..0000000000 --- a/configs/spark/tools/dfu.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -dfu-util -a1 -d 1eaf:0003 -D nuttx.bin -R diff --git a/configs/spark/tools/env.sh b/configs/spark/tools/env.sh deleted file mode 100755 index 1d90665286..0000000000 --- a/configs/spark/tools/env.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -cd tools -./configure.sh spark/$1 -cd - > /dev/null diff --git a/configs/spark/usbmsc/defconfig b/configs/spark/usbmsc/defconfig deleted file mode 100644 index eed15c31c7..0000000000 --- a/configs/spark/usbmsc/defconfig +++ /dev/null @@ -1,101 +0,0 @@ -# CONFIG_DISABLE_OS_API is not set -# CONFIG_NSH_DISABLE_CMP is not set -# CONFIG_NSH_DISABLE_DD is not set -# CONFIG_NSH_DISABLE_EXEC is not set -# CONFIG_NSH_DISABLE_EXIT is not set -# CONFIG_NSH_DISABLE_GET is not set -# CONFIG_NSH_DISABLE_HEXDUMP is not set -# CONFIG_NSH_DISABLE_IFCONFIG is not set -# CONFIG_NSH_DISABLE_LOSETUP is not set -# CONFIG_NSH_DISABLE_MKRD is not set -# CONFIG_NSH_DISABLE_PS is not set -# CONFIG_NSH_DISABLE_PUT is not set -# CONFIG_NSH_DISABLE_WGET is not set -# CONFIG_NSH_DISABLE_XD is not set -# CONFIG_NSH_DISABLEBG is not set -# CONFIG_NSH_DISABLESCRIPT is not set -CONFIG_ANALOG=y -CONFIG_ARCH_BOARD_SPARK=y -CONFIG_ARCH_BOARD="spark" -CONFIG_ARCH_BUTTONS=y -CONFIG_ARCH_CHIP_STM32=y -CONFIG_ARCH_CHIP_STM32F103CB=y -CONFIG_ARCH_INTERRUPTSTACK=234 -CONFIG_ARCH_IRQBUTTONS=y -CONFIG_ARCH_STACKDUMP=y -CONFIG_ARCH="arm" -CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL=y -CONFIG_BOARD_INITIALIZE=y -CONFIG_BOARD_LOOPSPERMSEC=5483 -CONFIG_BUILTIN_PROXY_STACKSIZE=768 -CONFIG_BUILTIN=y -CONFIG_CC3000_SELECT_STACKSIZE=390 -CONFIG_DEFAULT_SMALL=y -CONFIG_DISABLE_POLL=y -CONFIG_DRIVERS_WIRELESS=y -CONFIG_EXAMPLES_CC3000BASIC=y -CONFIG_EXAMPLES_NSH=y -CONFIG_FAT_LCNAMES=y -CONFIG_FAT_LFN=y -CONFIG_FAT_MAXFNAME=12 -CONFIG_FS_FATTIME=y -CONFIG_FS_NAMED_SEMAPHORES=y -CONFIG_IDLETHREAD_STACKSIZE=280 -CONFIG_INTELHEX_BINARY=y -CONFIG_LIB_RAND_ORDER=2 -CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=16 -CONFIG_MAX_WDOGPARMS=2 -CONFIG_MM_SMALL=y -CONFIG_MQ_MAXMSGSIZE=8 -CONFIG_MTD_PARTITION=y -CONFIG_NAME_MAX=8 -CONFIG_NFILE_DESCRIPTORS=5 -CONFIG_NFILE_STREAMS=5 -CONFIG_NPTHREAD_KEYS=0 -CONFIG_NSH_ARCHINIT=y -CONFIG_NSH_BUILTIN_APPS=y -CONFIG_NSH_CODECS_BUFSIZE=0 -CONFIG_NSH_FILEIOSIZE=128 -CONFIG_NSH_LINELEN=80 -CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=768 -CONFIG_PREALLOC_MQ_MSGS=1 -CONFIG_PREALLOC_TIMERS=2 -CONFIG_PREALLOC_WDOGS=2 -CONFIG_PTHREAD_STACK_DEFAULT=340 -CONFIG_RAM_SIZE=20480 -CONFIG_RAM_START=0x20000000 -CONFIG_RAW_BINARY=y -CONFIG_RR_INTERVAL=200 -CONFIG_SDCLONE_DISABLE=y -CONFIG_SST25_SECTOR512=y -CONFIG_SST25_SPIFREQUENCY=80000000 -CONFIG_START_DAY=30 -CONFIG_START_MONTH=11 -CONFIG_START_YEAR=2013 -CONFIG_STDIO_DISABLE_BUFFERING=y -CONFIG_STM32_CRC=y -CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y -CONFIG_STM32_DMA1=y -CONFIG_STM32_JTAG_FULL_ENABLE=y -CONFIG_STM32_SPI_DMA=y -CONFIG_STM32_USART2=y -CONFIG_STM32_USB=y -CONFIG_SYMTAB_ORDEREDBYNAME=y -CONFIG_SYSTEM_USBMSC_DEVPATH1="/dev/mtdblock0" -CONFIG_SYSTEM_USBMSC=y -CONFIG_TASK_NAME_SIZE=7 -CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=768 -CONFIG_USART2_RXBUFSIZE=32 -CONFIG_USART2_SERIAL_CONSOLE=y -CONFIG_USART2_TXBUFSIZE=32 -CONFIG_USBDEV_TRACE_NRECORDS=32 -CONFIG_USBDEV_TRACE=y -CONFIG_USBMSC_NRDREQS=2 -CONFIG_USBMSC_NWRREQS=2 -CONFIG_USBMSC_SCSI_STACKSIZE=340 -CONFIG_USBMSC=y -CONFIG_USER_ENTRYPOINT="nsh_main" -CONFIG_USERMAIN_STACKSIZE=1024 -CONFIG_WDOG_INTRESERVE=0 -CONFIG_WL_CC3000=y diff --git a/configs/spark/usbnsh/defconfig b/configs/spark/usbnsh/defconfig deleted file mode 100644 index 29d4c54d08..0000000000 --- a/configs/spark/usbnsh/defconfig +++ /dev/null @@ -1,75 +0,0 @@ -# CONFIG_DEV_CONSOLE is not set -# CONFIG_DISABLE_OS_API is not set -# CONFIG_NSH_DISABLE_CMP is not set -# CONFIG_NSH_DISABLE_DD is not set -# CONFIG_NSH_DISABLE_EXEC is not set -# CONFIG_NSH_DISABLE_EXIT is not set -# CONFIG_NSH_DISABLE_GET is not set -# CONFIG_NSH_DISABLE_HEXDUMP is not set -# CONFIG_NSH_DISABLE_IFCONFIG is not set -# CONFIG_NSH_DISABLE_LOSETUP is not set -# CONFIG_NSH_DISABLE_MKFATFS is not set -# CONFIG_NSH_DISABLE_MKRD is not set -# CONFIG_NSH_DISABLE_PS is not set -# CONFIG_NSH_DISABLE_PUT is not set -# CONFIG_NSH_DISABLE_WGET is not set -# CONFIG_NSH_DISABLE_XD is not set -# CONFIG_NSH_DISABLEBG is not set -# CONFIG_NSH_DISABLESCRIPT is not set -CONFIG_ARCH_BOARD_SPARK=y -CONFIG_ARCH_BOARD="spark" -CONFIG_ARCH_CHIP_STM32=y -CONFIG_ARCH_CHIP_STM32F103CB=y -CONFIG_ARCH_INTERRUPTSTACK=512 -CONFIG_ARCH_STACKDUMP=y -CONFIG_ARCH="arm" -CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL=y -CONFIG_BOARD_LOOPSPERMSEC=5483 -CONFIG_BUILTIN=y -CONFIG_CDCACM_CONSOLE=y -CONFIG_CDCACM_RXBUFSIZE=256 -CONFIG_CDCACM_TXBUFSIZE=256 -CONFIG_CDCACM=y -CONFIG_DEFAULT_SMALL=y -CONFIG_DISABLE_POLL=y -CONFIG_EXAMPLES_NSH=y -CONFIG_FS_AUTOMOUNTER=y -CONFIG_INTELHEX_BINARY=y -CONFIG_LIB_BOARDCTL=y -CONFIG_LIB_RAND_ORDER=2 -CONFIG_MAX_TASKS=16 -CONFIG_MAX_WDOGPARMS=2 -CONFIG_MQ_MAXMSGSIZE=8 -CONFIG_NFILE_DESCRIPTORS=8 -CONFIG_NFILE_STREAMS=8 -CONFIG_NSH_BUILTIN_APPS=y -CONFIG_NSH_FILEIOSIZE=1024 -CONFIG_NSH_LINELEN=80 -CONFIG_NSH_USBCONSOLE=y -CONFIG_PREALLOC_MQ_MSGS=4 -CONFIG_PREALLOC_TIMERS=4 -CONFIG_PREALLOC_WDOGS=6 -CONFIG_PTHREAD_STACK_DEFAULT=1024 -CONFIG_RAM_SIZE=20480 -CONFIG_RAM_START=0x20000000 -CONFIG_RAW_BINARY=y -CONFIG_RR_INTERVAL=200 -CONFIG_SCHED_HPWORK=y -CONFIG_SCHED_HPWORKSTACKSIZE=800 -CONFIG_SDCLONE_DISABLE=y -CONFIG_START_DAY=23 -CONFIG_START_MONTH=10 -CONFIG_START_YEAR=2013 -CONFIG_STM32_CRC=y -CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y -CONFIG_STM32_DMA1=y -CONFIG_STM32_JTAG_FULL_ENABLE=y -CONFIG_STM32_SPI_DMA=y -CONFIG_STM32_USART2=y -CONFIG_STM32_USB=y -CONFIG_SYMTAB_ORDEREDBYNAME=y -CONFIG_TASK_NAME_SIZE=0 -CONFIG_USBDEV_TRACE_NRECORDS=32 -CONFIG_USBDEV_TRACE=y -CONFIG_USER_ENTRYPOINT="nsh_main" -CONFIG_WDOG_INTRESERVE=0 diff --git a/configs/spark/usbserial/defconfig b/configs/spark/usbserial/defconfig deleted file mode 100644 index 7b0d94af99..0000000000 --- a/configs/spark/usbserial/defconfig +++ /dev/null @@ -1,87 +0,0 @@ -# CONFIG_DISABLE_ENVIRON is not set -# CONFIG_DISABLE_POSIX_TIMERS is not set -CONFIG_ANALOG=y -CONFIG_ARCH_BOARD_SPARK=y -CONFIG_ARCH_BOARD="spark" -CONFIG_ARCH_BUTTONS=y -CONFIG_ARCH_CHIP_STM32=y -CONFIG_ARCH_CHIP_STM32F103CB=y -CONFIG_ARCH_INTERRUPTSTACK=512 -CONFIG_ARCH_IRQBUTTONS=y -CONFIG_ARCH_STACKDUMP=y -CONFIG_ARCH="arm" -CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL=y -CONFIG_BOARD_INITIALIZE=y -CONFIG_BOARD_LOOPSPERMSEC=5483 -CONFIG_BUILTIN_PROXY_STACKSIZE=768 -CONFIG_BUILTIN=y -CONFIG_CC3000_PROBES=y -CONFIG_CC3000_SELECT_STACKSIZE=390 -CONFIG_CDCACM_EPBULKIN_HSSIZE=64 -CONFIG_CDCACM_EPBULKOUT_HSSIZE=64 -CONFIG_CDCACM_RXBUFSIZE=40 -CONFIG_CDCACM_TXBUFSIZE=40 -CONFIG_CDCACM=y -CONFIG_DEFAULT_SMALL=y -CONFIG_DISABLE_POLL=y -CONFIG_DRIVERS_WIRELESS=y -CONFIG_EXAMPLES_CC3000BASIC=y -CONFIG_EXAMPLES_USBSERIAL_TRACECLASS=y -CONFIG_EXAMPLES_USBSERIAL_TRACECONTROLLER=y -CONFIG_EXAMPLES_USBSERIAL_TRACEINIT=y -CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=y -CONFIG_EXAMPLES_USBSERIAL_TRACETRANSFERS=y -CONFIG_EXAMPLES_USBSERIAL=y -CONFIG_FAT_LCNAMES=y -CONFIG_FAT_LFN=y -CONFIG_FAT_MAXFNAME=12 -CONFIG_FS_FATTIME=y -CONFIG_FS_NAMED_SEMAPHORES=y -CONFIG_INTELHEX_BINARY=y -CONFIG_LIB_BOARDCTL=y -CONFIG_LIB_RAND_ORDER=2 -CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=16 -CONFIG_MAX_WDOGPARMS=2 -CONFIG_MM_SMALL=y -CONFIG_MQ_MAXMSGSIZE=8 -CONFIG_MTD_PARTITION=y -CONFIG_NAME_MAX=8 -CONFIG_NFILE_DESCRIPTORS=5 -CONFIG_NFILE_STREAMS=5 -CONFIG_NPTHREAD_KEYS=0 -CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=768 -CONFIG_PREALLOC_MQ_MSGS=1 -CONFIG_PREALLOC_TIMERS=2 -CONFIG_PREALLOC_WDOGS=2 -CONFIG_PTHREAD_STACK_DEFAULT=340 -CONFIG_RAM_SIZE=20480 -CONFIG_RAM_START=0x20000000 -CONFIG_RAW_BINARY=y -CONFIG_RR_INTERVAL=200 -CONFIG_SDCLONE_DISABLE=y -CONFIG_SST25_SECTOR512=y -CONFIG_SST25_SPIFREQUENCY=80000000 -CONFIG_START_DAY=30 -CONFIG_START_MONTH=11 -CONFIG_START_YEAR=2013 -CONFIG_STDIO_DISABLE_BUFFERING=y -CONFIG_STM32_CRC=y -CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y -CONFIG_STM32_DMA1=y -CONFIG_STM32_JTAG_FULL_ENABLE=y -CONFIG_STM32_SPI_DMA=y -CONFIG_STM32_USART2=y -CONFIG_STM32_USB=y -CONFIG_SYMTAB_ORDEREDBYNAME=y -CONFIG_TASK_NAME_SIZE=7 -CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=768 -CONFIG_USART2_RXBUFSIZE=32 -CONFIG_USART2_SERIAL_CONSOLE=y -CONFIG_USART2_TXBUFSIZE=32 -CONFIG_USBDEV_TRACE_NRECORDS=32 -CONFIG_USBDEV_TRACE=y -CONFIG_USER_ENTRYPOINT="usbserial_main" -CONFIG_USERMAIN_STACKSIZE=1024 -CONFIG_WDOG_INTRESERVE=0 -CONFIG_WL_CC3000=y diff --git a/configs/stm32_tiny/src/Makefile b/configs/stm32_tiny/src/Makefile index 02062684c6..0e9f1bff8e 100644 --- a/configs/stm32_tiny/src/Makefile +++ b/configs/stm32_tiny/src/Makefile @@ -44,7 +44,7 @@ CSRCS += stm32_pwm.c endif ifeq ($(CONFIG_WL_NRF24L01),y) -CSRCS += stm32_cc3000.c +CSRCS += stm32_nrf24l01.c endif ifeq ($(CONFIG_LIB_BOARDCTL),y) diff --git a/configs/stm32_tiny/src/stm32_cc3000.c b/configs/stm32_tiny/src/stm32_nrf24l01.c similarity index 99% rename from configs/stm32_tiny/src/stm32_cc3000.c rename to configs/stm32_tiny/src/stm32_nrf24l01.c index 9a8a0d3619..e6d3513338 100644 --- a/configs/stm32_tiny/src/stm32_cc3000.c +++ b/configs/stm32_tiny/src/stm32_nrf24l01.c @@ -1,5 +1,5 @@ /************************************************************************************ - * configs/stm32_tiny/src/stm32_cc3000.c + * configs/stm32_tiny/src/stm32_nrf24l01.c * * Copyright (C) 2009, 2013, 2017 Gregory Nutt. All rights reserved. * Author: Laurent Latil diff --git a/configs/stm32l476vg-disco/src/stm32_spi.c b/configs/stm32l476vg-disco/src/stm32_spi.c index 32e813b639..49c6bc8fa9 100644 --- a/configs/stm32l476vg-disco/src/stm32_spi.c +++ b/configs/stm32l476vg-disco/src/stm32_spi.c @@ -93,10 +93,6 @@ void weak_function stm32_spiinitialize(void) spierr("ERROR: [boot] FAILED to initialize SPI port 1\n"); } -#ifdef CONFIG_WL_CC3000 - stm32_configgpio(GPIO_SPI_CS_WIFI); -#endif - #ifdef HAVE_MMCSD stm32_configgpio(GPIO_SPI_CS_SD_CARD); #endif @@ -106,14 +102,10 @@ void weak_function stm32_spiinitialize(void) /* Configure SPI-based devices */ g_spi2 = up_spiinitialize(2); - - /* Setup CS, EN & IRQ line IOs */ - -#ifdef CONFIG_WL_CC3000 - stm32_configgpio(GPIO_WIFI_CS); - stm32_configgpio(GPIO_WIFI_EN); - stm32_configgpio(GPIO_WIFI_INT); -#endif + if (!g_spi2) + { + spierr("ERROR: [boot] FAILED to initialize SPI port 2\n"); + } #endif } @@ -147,7 +139,6 @@ void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); -#ifdef CONFIG_WL_CC3000 if (devid == SPIDEV_WIRELESS(0)) { stm32_gpiowrite(GPIO_SPI_CS_WIFI, !selected); @@ -172,13 +163,6 @@ uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) void stm32_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); - -#ifdef CONFIG_WL_CC3000 - if (devid == SPIDEV_WIRELESS(0)) - { - stm32_gpiowrite(GPIO_WIFI_CS, !selected); - } -#endif } uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) diff --git a/drivers/wireless/Kconfig b/drivers/wireless/Kconfig index 70bc28eb3b..eb806d0052 100644 --- a/drivers/wireless/Kconfig +++ b/drivers/wireless/Kconfig @@ -23,12 +23,6 @@ config CC1101_SPIDEV endif -menuconfig WL_CC3000 - bool "CC3000 Wireless Module support" - default n - select SPI - -source drivers/wireless/cc3000/Kconfig source drivers/wireless/spirit/Kconfig menuconfig DRIVERS_IEEE802154 diff --git a/drivers/wireless/Make.defs b/drivers/wireless/Make.defs index b0ae71fe56..e9a67ec2b6 100644 --- a/drivers/wireless/Make.defs +++ b/drivers/wireless/Make.defs @@ -60,10 +60,6 @@ CSRCS += cc1101.c ISM1_868MHzGFSK100kbps.c ISM2_905MHzGFSK250kbps.c CSRCS += ISM2_433MHzMSK500kbps.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 diff --git a/drivers/wireless/cc3000/Kconfig b/drivers/wireless/cc3000/Kconfig deleted file mode 100644 index c1e65c4099..0000000000 --- a/drivers/wireless/cc3000/Kconfig +++ /dev/null @@ -1,77 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see the file kconfig-language.txt in the NuttX tools repository. -# - -config WL_CC3000 - bool "CC3000 Wireless Module" - default n - select SPI - select ARCH_HAVE_NET - select CRYPTO - select CRYPTO_SW_AES - ---help--- - Enable support for the TI CC3000 Wifi Module - -if WL_CC3000 - -config CC3000_MULTIPLE - bool "Multiple CC3000 Devices" - default n - ---help--- - Can be defined to support multiple CC3000 devices on board. - -config CC3000_NPOLLWAITERS - int "Number poll waiters" - default 4 - depends on !DISABLE_POLL - ---help--- - Maximum number of threads that can be waiting on poll() - -config CC3000_SPIDEV - int "SPI bus number" - default 2 - ---help--- - Selects the SPI bus number identying that SPI interface that - connects the CC3000 to the MCU. - -config CC3000_DEVMINOR - int "Input device minor number" - default 0 - ---help--- - The CC3000 device will be registered as /dev/wirelessN where N is the - value provided by this setting. - -config CC3000_SPI_MODE - int "SPI mode" - default 1 - range 0 3 - ---help--- - Controls the SPI mode. The device should work in mode 1, but - sometimes you need to experiment. - -config CC3000_SPI_FREQUENCY - int "SPI frequency" - default 16000000 - ---help--- - Define to use a different SPI bus frequency. - -config CC3000_WORKER_STACKSIZE - int "Worker thread stack size" - default 240 - -config CC3000_SELECT_STACKSIZE - int "Select thread stack size" - default 368 - -config CC3000_UNSOLICED_STACKSIZE - int "Unsolicited thread stack size" - default 264 - -config CC3000_PROBES - bool "Thread probes" - default n - ---help--- - Select to use DO and D1 to indicate worker thread and ISR - -endif diff --git a/drivers/wireless/cc3000/Make.defs b/drivers/wireless/cc3000/Make.defs deleted file mode 100644 index 9571d750ab..0000000000 --- a/drivers/wireless/cc3000/Make.defs +++ /dev/null @@ -1,48 +0,0 @@ -############################################################################ -# drivers/wireless/Make.defs -# -# Copyright (C) 2013 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# 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_CC3000),y) - -# Include cc3000 drivers - -CSRCS += cc3000.c cc3000_common.c cc3000drv.c evnt_handler.c hci.c netapp.c -CSRCS += nvmem.c socket.c socket_imp.c wlan.c - -# Include wireless devices build support - -DEPPATH += --dep-path wireless$(DELIM)cc3000 -VPATH += :wireless$(DELIM)cc3000 -CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)wireless$(DELIM)cc3000} -endif diff --git a/drivers/wireless/cc3000/cc3000.c b/drivers/wireless/cc3000/cc3000.c deleted file mode 100644 index 2055cdaec5..0000000000 --- a/drivers/wireless/cc3000/cc3000.c +++ /dev/null @@ -1,1855 +0,0 @@ -/**************************************************************************** - * drivers/wireless/cc3000.c - * - * Copyright (C) 2013-2016 Gregory Nutt. All rights reserved. - * Authors: Gregory Nutt - * David_s5 - * - * References: - * CC30000 from Texas Instruments http://processors.wiki.ti.com/index.php/CC3000 - * - * See also: - * http://processors.wiki.ti.com/index.php/CC3000_Host_Driver_Porting_Guide - * http://processors.wiki.ti.com/index.php/CC3000_Host_Programming_Guide - * - * 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 - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include "cc3000_socket.h" -#include "cc3000.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ -#ifndef CCASSERT -#define CCASSERT(predicate) _x_CCASSERT_LINE(predicate, __LINE__) -#define _x_CCASSERT_LINE(predicate, line) typedef char constraint_violated_on_line_##line[2*((predicate)!=0)-1]; -#endif - -CCASSERT(sizeof(cc3000_buffer_desc) <= CONFIG_MQ_MAXMSGSIZE); - -#ifndef CONFIG_CC3000_WORKER_THREAD_PRIORITY -# define CONFIG_CC3000_WORKER_THREAD_PRIORITY (SCHED_PRIORITY_MAX) -#endif - -#ifndef CONFIG_CC3000_WORKER_STACKSIZE -# define CONFIG_CC3000_WORKER_STACKSIZE 240 -#endif - -#ifndef CONFIG_CC3000_SELECT_THREAD_PRIORITY -# define CONFIG_CC3000_SELECT_THREAD_PRIORITY (SCHED_PRIORITY_DEFAULT-1) -#endif - -#ifndef CONFIG_CC3000_SELECT_STACKSIZE -# define CONFIG_CC3000_SELECT_STACKSIZE 368 -#endif - -#ifndef ARRAY_SIZE -# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif -#define NUMBER_OF_MSGS 1 - -#define FREE_SLOT -1 -#define CLOSE_SLOT -2 - -#if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_CC3000_PROBES) -# define CC3000_GUARD (0xc35aa53c) -# define INIT_GUARD(p) p->guard = CC3000_GUARD -# define CHECK_GUARD(p) DEBUGASSERT(p->guard == CC3000_GUARD) -# define PROBE(pin,state) priv->config->probe(priv->config,pin, state) -#else -# define INIT_GUARD(p) -# define CHECK_GUARD(p) -# define PROBE(pin,state) -#endif - -#define waiterr(x,...) // _err -#define waitinfo(x,...) // _info - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/* Low-level SPI helpers */ - -static void cc3000_lock_and_select(FAR struct spi_dev_s *spi); -static void cc3000_deselect_and_unlock(FAR struct spi_dev_s *spi); - -/* Interrupts and data sampling */ - -static void cc3000_notify(FAR struct cc3000_dev_s *priv); -static void *cc3000_worker(FAR void *arg); -static int cc3000_interrupt(int irq, FAR void *context, FAR void *arg); - -/* Character driver methods */ - -static int cc3000_open(FAR struct file *filep); -static int cc3000_close(FAR struct file *filep); -static ssize_t cc3000_read(FAR struct file *filep, FAR char *buffer, - size_t len); -static ssize_t cc3000_write(FAR struct file *filep, - FAR const char *buffer, size_t len); -static int cc3000_ioctl(FAR struct file *filep, int cmd, unsigned long arg); -#ifndef CONFIG_DISABLE_POLL -static int cc3000_poll(FAR struct file *filep, struct pollfd *fds, - bool setup); -#endif - -static int cc3000_wait_data(FAR struct cc3000_dev_s *priv, int sockfd); -static int cc3000_accept_socket(FAR struct cc3000_dev_s *priv, int sd, - FAR struct sockaddr *addr, - socklen_t *addrlen); -static int cc3000_add_socket(FAR struct cc3000_dev_s *priv, int sd); -static int cc3000_remove_socket(FAR struct cc3000_dev_s *priv, int sd); -static int cc3000_remote_closed_socket(FAR struct cc3000_dev_s *priv, int sd); - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* This the vtable that supports the character driver interface */ - -static const struct file_operations cc3000_fops = -{ - cc3000_open, /* open */ - cc3000_close, /* close */ - cc3000_read, /* read */ - cc3000_write, /* write */ - 0, /* seek */ - cc3000_ioctl, /* ioctl */ -#ifndef CONFIG_DISABLE_POLL - cc3000_poll /* poll */ -#endif -}; - -/* If only a single CC3000 device is supported, then the driver state - * structure may as well be pre-allocated. - */ - -#ifndef CONFIG_CC3000_MULTIPLE -static struct cc3000_dev_s g_cc3000; - -/* Otherwise, we will need to maintain allocated driver instances in a list */ - -#else -static struct cc3000_dev_s *g_cc3000list; -#endif - -uint8_t spi_readCommand[] = READ_COMMAND; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ -/**************************************************************************** - * Name: cc3000_devtake() and cc3000_devgive() - * - * Description: - * Used to get exclusive access to a CC3000 driver. - * - ****************************************************************************/ - -static inline void cc3000_devtake(FAR struct cc3000_dev_s *priv) -{ - int ret; - - do - { - /* Take the semaphore (perhaps waiting) */ - - ret = nxsem_wait(&priv->devsem); - - /* The only case that an error should occur here is if the wait was - * awakened by a signal. - */ - - DEBUGASSERT(ret == OK || ret == -EINTR); - } - while (ret == -EINTR); -} - -static inline void cc3000_devgive(FAR struct cc3000_dev_s *priv) -{ - (void)nxsem_post(&priv->devsem); -} - -/**************************************************************************** - * Name: cc3000_configspi - * - * Description: - * Configure the SPI for use with the CC3000. This function should be - * called to configure the SPI - * bus. - * - * Input Parameters: - * spi - Reference to the SPI driver structure - * - * Returned Value: - * None - * - * Assumptions: - * - ****************************************************************************/ - -static inline void cc3000_configspi(FAR struct spi_dev_s *spi) -{ - ninfo("Mode: %d Bits: 8 Frequency: %d\n", - CONFIG_CC3000_SPI_MODE, CONFIG_CC3000_SPI_FREQUENCY); - - SPI_SETMODE(spi, CONFIG_CC3000_SPI_MODE); - SPI_SETBITS(spi, 8); - (void)SPI_HWFEATURES(spi, 0); - (void)SPI_SETFREQUENCY(spi, CONFIG_CC3000_SPI_FREQUENCY); -} - -/**************************************************************************** - * Name: cc3000_lock - * - * Description: - * Lock the SPI bus and re-configure as necessary. This function must be - * to assure: (1) exclusive access to the SPI bus, and (2) to assure that - * the shared bus is properly configured for the cc3000 module. - * - * Input Parameters: - * spi - Reference to the SPI driver structure - * - * Returned Value: - * None - * - * Assumptions: - * - ****************************************************************************/ - -static void cc3000_lock_and_select(FAR struct spi_dev_s *spi) -{ - /* Lock the SPI bus so that we have exclusive access */ - - (void)SPI_LOCK(spi, true); - - /* We have the lock. Now make sure that the SPI bus is configured for the - * CC3000 (it might have gotten configured for a different device while - * unlocked) - */ - - cc3000_configspi(spi); - SPI_SELECT(spi, SPIDEV_WIRELESS(0), true); -} - -/**************************************************************************** - * Name: cc3000_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. - * - * Input Parameters: - * spi - Reference to the SPI driver structure - * - * Returned Value: - * None - * - * Assumptions: - * - ****************************************************************************/ - -static void cc3000_deselect_and_unlock(FAR struct spi_dev_s *spi) -{ - /* De select */ - - SPI_SELECT(spi, SPIDEV_WIRELESS(0), false); - - /* Relinquish the SPI bus. */ - - (void)SPI_LOCK(spi, false); -} - -/**************************************************************************** - * Name: cc3000_wait - * - * Description: - * Helper function to wait on the semaphore signaled by the - * - * Input Parameters: - * priv - Reference to the CC3000 driver structure - * priv - - * - * Returned Value: - * 0 - Semaphore signaled and devsem retaken - * < 0 - Some Error occurred - * Assumptions: - * Own the devsem on entry - * - ****************************************************************************/ - -static int cc3000_wait(FAR struct cc3000_dev_s *priv, sem_t *psem) -{ - int ret; - - /* Give up */ - - sched_lock(); - cc3000_devgive(priv); - - /* Wait on first psem to become signaled */ - - ret = nxsem_wait(psem); - if (ret < 0) - { - return ret; - } - - /* Then retake the mutual exclusion semaphore */ - - cc3000_devtake(priv); - sched_unlock(); - return OK; -} - -/**************************************************************************** - * Name: cc3000_wait_irq - * - * Description: - * Helper function to wait on the irqsem signaled by the interrupt - * - * Input Parameters: - * priv - Reference to the CC3000 driver structure - * - * Returned Value: - * 0 - Semaphore signaled and devsem retaken - * < 0 - Some Error occurred - * Assumptions: - * Own the devsem on entry - * - ****************************************************************************/ - -static inline int cc3000_wait_irq(FAR struct cc3000_dev_s *priv) -{ - return cc3000_wait(priv, &priv->irqsem); -} - -/**************************************************************************** - * Name: cc3000_wait_ready - * - * Description: - * Helper function to wait on the readysem signaled by the interrupt - * - * Input Parameters: - * priv - Reference to the CC3000 driver structure - * - * Returned Value: - * 0 - Semaphore signaled and devsem retaken - * < 0 - Some Error occurred - * Assumptions: - * Own the devsem on entry - * - ****************************************************************************/ - -static inline int cc3000_wait_ready(FAR struct cc3000_dev_s *priv) -{ - return cc3000_wait(priv, &priv->readysem); -} - -/**************************************************************************** - * Name: cc3000_pollnotify - ****************************************************************************/ - -#ifndef CONFIG_DISABLE_POLL -static void cc3000_pollnotify(FAR struct cc3000_dev_s *priv, uint32_t type) -{ - int i; - - for (i = 0; i < CONFIG_CC3000_NPOLLWAITERS; i++) - { - struct pollfd *fds = priv->fds[i]; - if (fds) - { - fds->revents |= type; - ninfo("Report events: %02x\n", fds->revents); - nxsem_post(fds->sem); - } - } -} -#endif - -/**************************************************************************** - * Name: cc3000_notify - ****************************************************************************/ - -static void cc3000_notify(FAR struct cc3000_dev_s *priv) -{ - /* If there are threads waiting for read data, then signal one of them - * that the read data is available. - */ - - if (priv->nwaiters > 0) - { - /* After posting this semaphore, we need to exit because the CC3000 - * is no longer available. - */ - - nxsem_post(&priv->waitsem); - } - - /* If there are threads waiting on poll() for CC3000 data to become available, - * then wake them up now. NOTE: we wake up all waiting threads because we - * do not know that they are going to do. If they all try to read the data, - * then some make end up blocking after all. - */ - -#ifndef CONFIG_DISABLE_POLL - cc3000_pollnotify(priv, POLLIN); -#endif -} - -/**************************************************************************** - * Name: cc3000_worker - ****************************************************************************/ - -static void *select_thread_func(FAR void *arg) -{ - FAR struct cc3000_dev_s *priv = (FAR struct cc3000_dev_s *)arg; - struct timeval timeout; - TICC3000fd_set readsds; - TICC3000fd_set exceptsds; - int ret = 0; - int maxFD = 0; - int s = 0; - - memset(&timeout, 0, sizeof(struct timeval)); - timeout.tv_sec = 0; - timeout.tv_usec = (500000); /* 500 msecs */ - - while (1) - { - nxsem_wait(&priv->selectsem); - - CHECK_GUARD(priv); - - /* Increase the count back by one to be decreased by the original caller */ - - nxsem_post(&priv->selectsem); - - maxFD = -1; - CC3000_FD_ZERO(&readsds); - CC3000_FD_ZERO(&exceptsds); - - /* Ping correct socket descriptor param for select */ - - for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++) - { - if (priv->sockets[s].sd != FREE_SLOT) - { - if (priv->sockets[s].sd == CLOSE_SLOT) - { - priv->sockets[s].sd = FREE_SLOT; - waitinfo("Close\n"); - int count; - do - { - nxsem_getvalue(&priv->sockets[s].semwait, &count); - if (count < 0) - { - /* Release the waiting threads */ - - waitinfo("Closed Signaled %d\n", count); - nxsem_post(&priv->sockets[s].semwait); - } - } - while (count < 0); - - continue; - } - - CC3000_FD_SET(priv->sockets[s].sd, &readsds); - CC3000_FD_SET(priv->sockets[s].sd, &exceptsds); - if (maxFD <= priv->sockets[s].sd) - { - maxFD = priv->sockets[s].sd + 1; - } - } - } - - if (maxFD < 0) - { - /* Handled only socket close. */ - - continue; - } - - /* Polling instead of blocking here to process "accept" below */ - - ret = cc3000_select(maxFD, (fd_set *) &readsds, NULL, - (fd_set *) &exceptsds, &timeout); - - if (priv->selecttid == -1) - { - /* driver close will terminate the thread and by that all sync - * objects owned by it will be released - */ - - return OK; - } - - for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++) - { - if ((priv->sockets[s].sd != FREE_SLOT || - priv->sockets[s].sd != CLOSE_SLOT) && /* Check that the socket is valid */ - priv->sockets[s].sd != priv->accepting_socket.acc.sd) /* Verify this is not an accept socket */ - { - if (ret > 0 && CC3000_FD_ISSET(priv->sockets[s].sd, &readsds)) /* and has pending data */ - { - waitinfo("Signaled %d\n", priv->sockets[s].sd); - nxsem_post(&priv->sockets[s].semwait); /* release the waiting thread */ - } - else if (ret > 0 && CC3000_FD_ISSET(priv->sockets[s].sd, &exceptsds)) /* or has pending exception */ - { - waitinfo("Signaled %d (exception)\n", priv->sockets[s].sd); - nxsem_post(&priv->sockets[s].semwait); /* release the waiting thread */ - } - else if (priv->sockets[s].received_closed_event) /* or remote has closed connection and we have now read all of HW buffer. */ - { - waitinfo("Signaled %d (closed & empty)\n", priv->sockets[s].sd); - priv->sockets[s].emptied_and_remotely_closed = true; - nxsem_post(&priv->sockets[s].semwait); /* release the waiting thread */ - } - } - } - - if (priv->accepting_socket.acc.sd != FREE_SLOT) /* If accept polling in needed */ - { - if (priv->accepting_socket.acc.sd == CLOSE_SLOT) - { - ret = CC3000_SOC_ERROR; - } - else - { - ret = cc3000_do_accept(priv->accepting_socket.acc.sd, /* Send the select command on non blocking */ - &priv->accepting_socket.addr, /* Set up in ioctl */ - &priv->accepting_socket.addrlen); - } - - if (ret != CC3000_SOC_IN_PROGRESS) /* Not waiting => error or accepted */ - { - priv->accepting_socket.acc.sd = FREE_SLOT; - priv->accepting_socket.acc.status = ret; - nxsem_post(&priv->accepting_socket.acc.semwait); /* Release the waiting thread */ - } - } - } - - return OK; -} - -/**************************************************************************** - * Name: cc3000_worker - ****************************************************************************/ - -static void *cc3000_worker(FAR void *arg) -{ - FAR struct cc3000_dev_s *priv = (FAR struct cc3000_dev_s *)arg; - int ret; - - ASSERT(priv != NULL && priv->config != NULL); - - /* We have started, release our creator */ - - nxsem_post(&priv->readysem); - while (1) - { - PROBE(0, 1); - CHECK_GUARD(priv); - cc3000_devtake(priv); - - /* Done ? */ - - if ((cc3000_wait_irq(priv) != -EINTR) && (priv->workertid != -1)) - { - PROBE(0, 0); - ninfo("State%d\n", priv->state); - switch (priv->state) - { - case eSPI_STATE_POWERUP: - /* Signal the device has interrupted after power up */ - - priv->state = eSPI_STATE_INITIALIZED; - nxsem_post(&priv->readysem); - break; - - case eSPI_STATE_WRITE_WAIT_IRQ: - /* Signal the device has interrupted after Chip Select During a write operation */ - - priv->state = eSPI_STATE_WRITE_PROCEED; - nxsem_post(&priv->readysem); - break; - - case eSPI_STATE_WRITE_DONE: /* IRQ post a write => Solicited */ - case eSPI_STATE_IDLE: /* IRQ when Idel => cc3000 has data for the hosts Unsolicited */ - { - uint16_t data_to_recv; - priv->state = eSPI_STATE_READ_IRQ; - - /* Issue the read command */ - - cc3000_lock_and_select(priv->spi); /* Assert CS */ - priv->state = eSPI_STATE_READ_PROCEED; - SPI_EXCHANGE(priv->spi, spi_readCommand, priv->rx_buffer.pbuffer, - ARRAY_SIZE(spi_readCommand)); - - /* Extract Length bytes from Rx Buffer. Here we need to convert - * unaligned data in network order (big endian, MS byte first) to - * host order. We cannot use ntohs here because the data is not - * aligned. - */ - - data_to_recv = (uint16_t)priv->rx_buffer.pbuffer[READ_OFFSET_TO_LENGTH] << 8 | - (uint16_t)priv->rx_buffer.pbuffer[READ_OFFSET_TO_LENGTH + 1]; - - if (data_to_recv) - { - /* We will read ARRAY_SIZE(spi_readCommand) + data_to_recv. is it odd? */ - - if ((data_to_recv + ARRAY_SIZE(spi_readCommand)) & 1) - { - /* Odd so make it even */ - - data_to_recv++; - } - - /* Read the whole payload in at the beginning of the buffer - * Will it fit? - */ - - if (data_to_recv >= priv->rx_buffer_max_len) - { - ninfo("data_to_recv %d", data_to_recv); - } - - DEBUGASSERT(data_to_recv < priv->rx_buffer_max_len); - SPI_RECVBLOCK(priv->spi, priv->rx_buffer.pbuffer, data_to_recv); - } - - cc3000_deselect_and_unlock(priv->spi); /* De assert CS */ - - /* Disable more messages as the wl code will resume via CC3000IOC_COMPLETE */ - - if (data_to_recv) - { - int count; - - priv->state = eSPI_STATE_READ_READY; - priv->rx_buffer.len = data_to_recv; - - ret = nxmq_send(priv->queue, - (FAR const char *)&priv->rx_buffer, - sizeof(priv->rx_buffer), 1); - DEBUGASSERT(ret >= 0); - UNUSED(ret); - - /* Notify any waiters that new CC3000 data is available */ - - cc3000_notify(priv); - - /* Give up driver */ - - cc3000_devgive(priv); - - ninfo("Wait On Completion\n"); - nxsem_wait(priv->wrkwaitsem); - ninfo("Completed S:%d irq :%d\n", - priv->state, priv->config->irq_read(priv->config)); - - nxsem_getvalue(&priv->irqsem, &count); - if (priv->config->irq_read(priv->config) && count == 0) - { - nxsem_post(&priv->irqsem); - } - - if (priv->state == eSPI_STATE_READ_READY) - { - priv->state = eSPI_STATE_IDLE; - } - - continue; - } - } - break; - - default: - ninfo("default: State%d\n", priv->state); - break; - } - } - - cc3000_devgive(priv); - } - - return OK; -} - -/**************************************************************************** - * Name: cc3000_interrupt - ****************************************************************************/ - -static int cc3000_interrupt(int irq, FAR void *context, FAR void *arg) -{ - FAR struct cc3000_dev_s *priv = (FAR struct cc3000_dev_s *)arg; - - DEBUGASSERT(priv != NULL); - - /* Run the worker thread */ - - PROBE(1, 0); - nxsem_post(&priv->irqsem); - PROBE(1, 1); - - /* Clear any pending interrupts and return success */ - - priv->config->irq_clear(priv->config); - return OK; -} - -/**************************************************************************** - * Name: cc3000_open - ****************************************************************************/ - -static int cc3000_open(FAR struct file *filep) -{ - FAR struct inode *inode; - struct mq_attr attr; - pthread_attr_t tattr; - pthread_t threadid; - struct sched_param param; - char queuename[QUEUE_NAMELEN]; - FAR struct cc3000_dev_s *priv; - uint8_t tmp; - int ret; -#ifdef CONFIG_CC3000_MT - int s; -#endif - - DEBUGASSERT(filep); - inode = filep->f_inode; - - DEBUGASSERT(inode && inode->i_private); - priv = (FAR struct cc3000_dev_s *)inode->i_private; - - CHECK_GUARD(priv); - - ninfo("crefs: %d\n", priv->crefs); - - /* Get exclusive access to the driver data structure */ - - cc3000_devtake(priv); - - /* Increment the reference count */ - - tmp = priv->crefs + 1; - if (tmp == 0) - { - /* More than 255 opens; uint8_t overflows to zero */ - - ret = -EMFILE; - goto out_with_sem; - } - - /* When the reference increments to 1, this is the first open event - * on the driver.. and an opportunity to do any one-time initialization. - */ - - if (tmp == 1) - { - /* Initialize semaphores */ - - nxsem_init(&priv->waitsem, 0, 0); /* Initialize event wait semaphore */ - nxsem_init(&priv->irqsem, 0, 0); /* Initialize IRQ Ready semaphore */ - nxsem_init(&priv->readysem, 0, 0); /* Initialize Device Ready semaphore */ - - /* These semaphores are all used for signaling and, hence, should - * not have priority inheritance enabled. - */ - - nxsem_setprotocol(&priv->waitsem, SEM_PRIO_NONE); - nxsem_setprotocol(&priv->irqsem, SEM_PRIO_NONE); - nxsem_setprotocol(&priv->readysem, SEM_PRIO_NONE); - -#ifdef CONFIG_CC3000_MT - priv->accepting_socket.acc.sd = FREE_SLOT; - nxsem_init(&priv->accepting_socket.acc.semwait, 0, 0); - nxsem_setprotocol(&priv->accepting_socket.acc.semwait, SEM_PRIO_NONE); - - for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++) - { - priv->sockets[s].sd = FREE_SLOT; - priv->sockets[s].received_closed_event = false; - priv->sockets[s].emptied_and_remotely_closed = false; - - nxsem_init(&priv->sockets[s].semwait, 0, 0); - nxsem_setprotocol(&priv->sockets[s].semwait, SEM_PRIO_NONE); - } -#endif - - /* Ensure the power is off so we get the falling edge of IRQ */ - - priv->config->power_enable(priv->config, false); - - attr.mq_maxmsg = NUMBER_OF_MSGS; - attr.mq_msgsize = sizeof(cc3000_buffer_desc); - attr.mq_flags = 0; - - /* Set the flags for the open of the queue. - * Make it a blocking open on the queue, meaning it will block if - * this process tries to send to the queue and the queue is full. - * - * O_CREAT - the queue will get created if it does not already exist. - * O_WRONLY - we are only planning to write to the queue. - * - * Open the queue, and create it if the receiving process hasn't - * already created it. - */ - - snprintf(queuename, QUEUE_NAMELEN, QUEUE_FORMAT, priv->minor); - priv->queue = mq_open(queuename, O_WRONLY | O_CREAT, 0666, &attr); - if (priv->queue < 0) - { - ret = -errno; - goto errout_sem_destroy; - } - - pthread_attr_init(&tattr); - tattr.stacksize = CONFIG_CC3000_WORKER_STACKSIZE; - param.sched_priority = CONFIG_CC3000_WORKER_THREAD_PRIORITY; - pthread_attr_setschedparam(&tattr, ¶m); - - ret = pthread_create(&priv->workertid, &tattr, cc3000_worker, - (pthread_addr_t)priv); - if (ret != 0) - { - ret = -ret; /* pthread_create does not modify errno. */ - goto errout_mq_close; - } - - pthread_attr_init(&tattr); - tattr.stacksize = CONFIG_CC3000_SELECT_STACKSIZE; - param.sched_priority = CONFIG_CC3000_SELECT_THREAD_PRIORITY; - pthread_attr_setschedparam(&tattr, ¶m); - - nxsem_init(&priv->selectsem, 0, 0); - nxsem_setprotocol(&priv->selectsem, SEM_PRIO_NONE); - - ret = pthread_create(&priv->selecttid, &tattr, select_thread_func, - (pthread_addr_t)priv); - if (ret != 0) - { - ret = -ret; /* pthread_create does not modify errno. */ - goto errout_worker_cancel; - } - - /* Do late allocation with hopes of realloc not fragmenting */ - - priv->rx_buffer.pbuffer = kmm_malloc(priv->rx_buffer_max_len); - DEBUGASSERT(priv->rx_buffer.pbuffer); - if (!priv->rx_buffer.pbuffer) - { - ret = -errno; - goto errout_select_cancel; - } - - priv->state = eSPI_STATE_POWERUP; - priv->config->irq_clear(priv->config); - - /* Bring the device Online A) on http://processors.wiki.ti.com/index.php/File:CC3000_Master_SPI_Write_Sequence_After_Power_Up.png */ - - priv->config->irq_enable(priv->config, true); - - /* Wait on child thread */ - - cc3000_wait_ready(priv); - priv->config->power_enable(priv->config, true); - } - - /* Save the new open count on success */ - - priv->crefs = tmp; - ret = OK; - - goto out_with_sem; - -errout_select_cancel: - threadid = priv->selecttid; - priv->selecttid = -1; - pthread_cancel(threadid); - pthread_join(threadid, NULL); - nxsem_destroy(&priv->selectsem); - -errout_worker_cancel: - threadid = priv->workertid; - priv->workertid = -1; - pthread_cancel(threadid); - pthread_join(threadid, NULL); - -errout_mq_close: - mq_close(priv->queue); - priv->queue = 0; - -errout_sem_destroy: -#ifdef CONFIG_CC3000_MT - nxsem_destroy(&priv->accepting_socket.acc.semwait); - - for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++) - { - priv->sockets[s].sd = FREE_SLOT; - nxsem_destroy(&priv->sockets[s].semwait); - } -#endif - - nxsem_destroy(&priv->waitsem); - nxsem_destroy(&priv->irqsem); - nxsem_destroy(&priv->readysem); - -out_with_sem: - cc3000_devgive(priv); - return ret; -} - -/**************************************************************************** - * Name: cc3000_close - ****************************************************************************/ - -static int cc3000_close(FAR struct file *filep) -{ - FAR struct inode *inode; - FAR struct cc3000_dev_s *priv; -#ifdef CONFIG_CC3000_MT - int s; -#endif - - DEBUGASSERT(filep); - inode = filep->f_inode; - - DEBUGASSERT(inode && inode->i_private); - priv = (FAR struct cc3000_dev_s *)inode->i_private; - - CHECK_GUARD(priv); - - ninfo("crefs: %d\n", priv->crefs); - - /* Get exclusive access to the driver data structure */ - - cc3000_devtake(priv); - - /* Decrement the reference count unless it would decrement a negative - * value. When the count decrements to zero, there are no further - * open references to the driver. - */ - - int tmp = priv->crefs; - if (priv->crefs >= 1) - { - priv->crefs--; - } - - if (tmp == 1) - { - pthread_t id = priv->selecttid; - priv->selecttid = -1; - pthread_cancel(id); - pthread_join(id, NULL); - nxsem_destroy(&priv->selectsem); - - priv->config->irq_enable(priv->config, false); - priv->config->irq_clear(priv->config); - priv->config->power_enable(priv->config, false); - - id = priv->workertid; - priv->workertid = -1; - pthread_cancel(id); - pthread_join(id, NULL); - - mq_close(priv->queue); - priv->queue = 0; - - kmm_free(priv->rx_buffer.pbuffer); - priv->rx_buffer.pbuffer = 0; - -#ifdef CONFIG_CC3000_MT - nxsem_destroy(&priv->accepting_socket.acc.semwait); - - for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++) - { - priv->sockets[s].sd = FREE_SLOT; - nxsem_destroy(&priv->sockets[s].semwait); - } -#endif - - nxsem_destroy(&priv->waitsem); - nxsem_destroy(&priv->irqsem); - nxsem_destroy(&priv->readysem); - } - - cc3000_devgive(priv); - return OK; -} - -/**************************************************************************** - * Name: cc3000_read - ****************************************************************************/ - -static ssize_t cc3000_read(FAR struct file *filep, FAR char *buffer, size_t len) -{ - FAR struct inode *inode; - FAR struct cc3000_dev_s *priv; - int ret; - ssize_t nread; - - ninfo("buffer:%p len:%d\n", buffer, len); - DEBUGASSERT(filep); - inode = filep->f_inode; - - DEBUGASSERT(inode && inode->i_private); - priv = (FAR struct cc3000_dev_s *)inode->i_private; - - CHECK_GUARD(priv); - - /* Get exclusive access to the driver data structure */ - - cc3000_devtake(priv); - - /* Verify that the caller has provided a buffer large enough to receive - * the maximum data. - */ - - if (len < priv->rx_buffer_max_len) - { - nerr("ERROR: Unsupported read size: %d\n", len); - nread = -ENOSYS; - goto errout_with_sem; - } - - - for (nread = priv->rx_buffer.len; nread == 0; nread = priv->rx_buffer.len) - { - if (nread > 0) - { - /* Yes.. break out to return what we have. */ - - break; - } - - /* data is not available now. We would have to wait to get - * receive sample data. If the user has specified the O_NONBLOCK - * option, then just return an error. - */ - - ninfo("CC3000 data is not available\n"); - if (filep->f_oflags & O_NONBLOCK) - { - nread = -EAGAIN; - break; - } - - /* Otherwise, wait for something to be written to the - * buffer. Increment the number of waiters so that the notify - * will know that it needs to post the semaphore to wake us up. - */ - - sched_lock(); - priv->nwaiters++; - cc3000_devgive(priv); - - /* We may now be pre-empted! But that should be okay because we - * have already incremented nwaiters. Pre-emptions is disabled - * but will be re-enabled while we are waiting. - */ - - ninfo("Waiting..\n"); - ret = nxsem_wait(&priv->waitsem); - priv->nwaiters--; - sched_unlock(); - - /* Did we successfully get the waitsem? */ - - if (ret >= 0) - { - /* Yes... then retake the mutual exclusion semaphore */ - - cc3000_devtake(priv); - } - - /* Was the semaphore wait successful? Did we successful re-take the - * mutual exclusion semaphore? - */ - - if (ret < 0) - { - /* No.. One of the two nxsem_wait's failed. */ - - /* Were we awakened by a signal? Did we read anything before - * we received the signal? - */ - - if (ret != -EINTR || nread >= 0) - { - /* Yes.. return the error. */ - - nread = ret; - } - - /* Break out to return what we have. Note, we can't exactly - * "break" out because whichever error occurred, we do not hold - * the exclusion semaphore. - */ - - goto errout_without_sem; - } - } - - if (nread > 0) - { - memcpy(buffer, priv->rx_buffer.pbuffer, priv->rx_buffer.len); - priv->rx_buffer.len = 0; - } - -errout_with_sem: - cc3000_devgive(priv); - -errout_without_sem: - ninfo("Returning: %d\n", nread); -#ifndef CONFIG_DISABLE_POLL - if (nread > 0) - { - cc3000_pollnotify(priv, POLLOUT); - } -#endif - - return nread; -} - -/**************************************************************************** - * Name: cc3000_write - * - * Bit of non standard buffer management ahead - * The buffer is memory allocated in the user space with space for the spi - * header - * - ****************************************************************************/ - -static ssize_t cc3000_write(FAR struct file *filep, FAR const char *usrbuffer, size_t len) -{ - FAR struct inode *inode; - FAR struct cc3000_dev_s *priv; - FAR char *buffer = (FAR char *) usrbuffer; - ssize_t nwritten = 0; - int ret; - - /* Set the padding if count(buffer) is even ( as it will be come odd with header) */ - - size_t tx_len = (len & 1) ? len : len +1; - - ninfo("buffer:%p len:%d tx_len:%d\n", buffer, len, tx_len); - - DEBUGASSERT(filep); - inode = filep->f_inode; - - DEBUGASSERT(inode && inode->i_private); - priv = (FAR struct cc3000_dev_s *)inode->i_private; - - CHECK_GUARD(priv); - - /* Get exclusive access to the driver data structure */ - - cc3000_devtake(priv); - - /* Figure out the total length of the packet in order to figure out if there is padding or not */ - - buffer[0] = WRITE; - buffer[1] = HI(tx_len); - buffer[2] = LO(tx_len); - buffer[3] = 0; - buffer[4] = 0; - tx_len += SPI_HEADER_SIZE; - - /* The first write transaction to occur after release of the shutdown has - * slightly different timing than the others. The normal Master SPI - * write sequence is nCS low, followed by IRQ low (CC3000 host), - * indicating that the CC3000 core device is ready to accept data. - * However, after power up the sequence is slightly different, as shown - * in the following Figure: - * - * http://processors.wiki.ti.com/index.php/File:CC3000_Master_SPI_Write_Sequence_After_Power_Up.png - * - * The following is a sequence of operations: - * - The master detects the IRQ line low: in this case the detection of - * IRQ low does not indicate the intention of the CC3000 device to - * communicate with the master but rather CC3000 readiness after power - * up. - * - The master asserts nCS. - * - The master introduces a delay of at least 50 μs before starting - * actual transmission of data. - * - The master transmits the first 4 bytes of the SPI header. - * - The master introduces a delay of at least an additional 50 μs. - * - The master transmits the rest of the packet. - */ - - if (priv->state == eSPI_STATE_POWERUP) - { - ret = cc3000_wait_ready(priv); - if (ret < 0) - { - nwritten = ret; - goto errout_without_sem; - } - } - - if (priv->state == eSPI_STATE_INITIALIZED) - { - cc3000_lock_and_select(priv->spi); /* Assert CS */ - nxsig_usleep(55); - SPI_SNDBLOCK(priv->spi, buffer, 4); - nxsig_usleep(55); - SPI_SNDBLOCK(priv->spi, buffer+4, tx_len-4); - } - else - { - ninfo("Assert CS\n"); - priv->state = eSPI_STATE_WRITE_WAIT_IRQ; - cc3000_lock_and_select(priv->spi); /* Assert CS */ - ninfo("Wait on IRQ Active\n"); - ret = cc3000_wait_ready(priv); - ninfo("IRQ Signaled\n"); - if (ret < 0) - { - /* This should only happen if the wait was canceled by an signal */ - - cc3000_deselect_and_unlock(priv->spi); - ninfo("nxsem_wait: %d\n", ret); - DEBUGASSERT(ret == -EINTR || ret == -ECANCELED); - nwritten = ret; - goto errout_without_sem; - } - - SPI_SNDBLOCK(priv->spi, buffer, tx_len); - } - - priv->state = eSPI_STATE_WRITE_DONE; - ninfo("Deassert CS S:eSPI_STATE_WRITE_DONE\n"); - cc3000_deselect_and_unlock(priv->spi); - nwritten = tx_len; - cc3000_devgive(priv); - -errout_without_sem: - ninfo("Returning: %d\n", ret); - return nwritten; -} - -/**************************************************************************** - * Name: cc3000_ioctl - ****************************************************************************/ - -static int cc3000_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - FAR struct inode *inode; - FAR struct cc3000_dev_s *priv; - int ret; - - ninfo("cmd: %d arg: %ld\n", cmd, arg); - DEBUGASSERT(filep); - inode = filep->f_inode; - - DEBUGASSERT(inode && inode->i_private); - priv = (FAR struct cc3000_dev_s *)inode->i_private; - - CHECK_GUARD(priv); - - /* Get exclusive access to the driver data structure */ - - cc3000_devtake(priv); - - /* Process the IOCTL by command */ - - ret = OK; - switch (cmd) - { - case CC3000IOC_GETQUESEMID: - { - FAR int *pminor = (FAR int *)(arg); - DEBUGASSERT(pminor != NULL); - *pminor = priv->minor; - break; - } - - case CC3000IOC_ADDSOCKET: - { - FAR int *pfd = (FAR int *)(arg); - DEBUGASSERT(pfd != NULL); - *pfd = cc3000_add_socket(priv, *pfd); - break; - } - - case CC3000IOC_REMOVESOCKET: - { - FAR int *pfd = (FAR int *)(arg); - DEBUGASSERT(pfd != NULL); - *pfd = cc3000_remove_socket(priv, *pfd); - break; - } - - case CC3000IOC_REMOTECLOSEDSOCKET: - { - FAR int *pfd = (FAR int *)(arg); - DEBUGASSERT(pfd != NULL); - *pfd = cc3000_remote_closed_socket(priv, *pfd); - break; - } - - case CC3000IOC_SELECTDATA: - { - FAR int *pfd = (FAR int *)(arg); - DEBUGASSERT(pfd != NULL); - *pfd = cc3000_wait_data(priv, *pfd); - break; - } - - case CC3000IOC_SELECTACCEPT: - { - FAR cc3000_acceptcfg *pcfg = (FAR cc3000_acceptcfg *)(arg); - DEBUGASSERT(pcfg != NULL); - pcfg->sockfd = cc3000_accept_socket(priv, pcfg->sockfd, pcfg->addr, pcfg->addrlen); - break; - } - - case CC3000IOC_SETRX_SIZE: - { - irqstate_t flags; - FAR int *psize = (FAR int *)(arg); - int rv; - - DEBUGASSERT(psize != NULL); - rv = priv->rx_buffer_max_len; - flags = enter_critical_section(); - priv->rx_buffer_max_len = *psize; - priv->rx_buffer.pbuffer = kmm_realloc(priv->rx_buffer.pbuffer, *psize); - leave_critical_section(flags); - DEBUGASSERT(priv->rx_buffer.pbuffer); - *psize = rv; - break; - } - - default: - ret = -ENOTTY; - break; - } - - cc3000_devgive(priv); - return ret; -} - -/**************************************************************************** - * Name: cc3000_poll - ****************************************************************************/ - -#ifndef CONFIG_DISABLE_POLL -static int cc3000_poll(FAR struct file *filep, FAR struct pollfd *fds, - bool setup) -{ - FAR struct inode *inode; - FAR struct cc3000_dev_s *priv; - int ret = OK; - int i; - - ninfo("setup: %d\n", (int)setup); - DEBUGASSERT(filep && fds); - inode = filep->f_inode; - - DEBUGASSERT(inode && inode->i_private); - priv = (FAR struct cc3000_dev_s *)inode->i_private; - - CHECK_GUARD(priv); - - /* Are we setting up the poll? Or tearing it down? */ - - cc3000_devtake(priv); - - if (setup) - { - /* Ignore waits that do not include POLLIN */ - - if ((fds->events & POLLIN) == 0) - { - ret = -EDEADLK; - goto errout; - } - - /* This is a request to set up the poll. Find an available - * slot for the poll structure reference - */ - - for (i = 0; i < CONFIG_CC3000_NPOLLWAITERS; i++) - { - /* Find an available slot */ - - if (!priv->fds[i]) - { - /* Bind the poll structure and this slot */ - - priv->fds[i] = fds; - fds->priv = &priv->fds[i]; - break; - } - } - - if (i >= CONFIG_CC3000_NPOLLWAITERS) - { - fds->priv = NULL; - ret = -EBUSY; - goto errout; - } - - /* Should we immediately notify on any of the requested events? */ - - if (priv->rx_buffer.len) - { - cc3000_notify(priv); - } - } - else if (fds->priv) - { - /* This is a request to tear down the poll. */ - - struct pollfd **slot = (struct pollfd **)fds->priv; - DEBUGASSERT(slot != NULL); - - /* Remove all memory of the poll setup */ - - *slot = NULL; - fds->priv = NULL; - } - -errout: - cc3000_devgive(priv); - return ret; -} -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: cc3000_register - * - * Description: - * Configure the CC3000 to use the provided SPI device instance. This - * will register the driver as /dev/inputN where N is the minor device - * number - * - * Input Parameters: - * dev - An SPI driver instance - * config - Persistent board configuration data - * minor - The input device minor number - * - * Returned Value: - * Zero is returned on success. Otherwise, a negated errno value is - * returned to indicate the nature of the failure. - * - ****************************************************************************/ - -int cc3000_register(FAR struct spi_dev_s *spi, - FAR struct cc3000_config_s *config, int minor) -{ - FAR struct cc3000_dev_s *priv; - char drvname[DEV_NAMELEN]; - char semname[SEM_NAMELEN]; -#ifdef CONFIG_CC3000_MULTIPLE - irqstate_t flags; -#endif - int ret; - - ninfo("spi: %p minor: %d\n", spi, minor); - - /* Debug-only sanity checks */ - - DEBUGASSERT(spi != NULL && config != NULL && minor >= 0 && minor < 100); - - /* Create and initialize a CC3000 device driver instance */ - -#ifndef CONFIG_CC3000_MULTIPLE - priv = &g_cc3000; -#else - priv = (FAR struct cc3000_dev_s *)kmm_malloc(sizeof(struct cc3000_dev_s)); - if (!priv) - { - nerr("ERROR: kmm_malloc(%d) failed\n", sizeof(struct cc3000_dev_s)); - return -ENOMEM; - } -#endif - - /* Initialize the CC3000 device driver instance */ - - memset(priv, 0, sizeof(struct cc3000_dev_s)); - INIT_GUARD(priv); - priv->minor = minor; /* Save the minor number */ - priv->spi = spi; /* Save the SPI device handle */ - priv->config = config; /* Save the board configuration */ - - priv->rx_buffer_max_len = config->max_rx_size; - - nxsem_init(&priv->devsem, 0, 1); /* Initialize device structure semaphore */ - - (void)snprintf(semname, SEM_NAMELEN, SEM_FORMAT, minor); - priv->wrkwaitsem = sem_open(semname, O_CREAT, 0, 0); /* Initialize Worker Wait semaphore */ - -#ifdef CONFIG_CC3000_MT - pthread_mutex_init(&g_cc3000_mut, NULL); -#endif - - /* Make sure that interrupts are disabled */ - - config->irq_clear(config); - config->irq_enable(config, false); - - /* Attach the interrupt handler */ - - ret = config->irq_attach(config, cc3000_interrupt, priv); - if (ret < 0) - { - nerr("ERROR: Failed to attach interrupt\n"); - goto errout_with_priv; - } - - /* Register the device as an input device */ - - (void)snprintf(drvname, DEV_NAMELEN, DEV_FORMAT, minor); - ninfo("Registering %s\n", drvname); - - ret = register_driver(drvname, &cc3000_fops, 0666, priv); - if (ret < 0) - { - nerr("ERROR: register_driver() failed: %d\n", ret); - goto errout_with_priv; - } - - /* If multiple CC3000 devices are supported, then we will need to add - * this new instance to a list of device instances so that it can be - * found by the interrupt handler based on the recieved IRQ number. - */ - -#ifdef CONFIG_CC3000_MULTIPLE - priv->flink = g_cc3000list; - g_cc3000list = priv; - leave_critical_section(flags); -#endif - - /* And return success (?) */ - - return OK; - -errout_with_priv: - nxsem_destroy(&priv->devsem); - sem_close(priv->wrkwaitsem); - sem_unlink(semname); - -#ifdef CONFIG_CC3000_MT - pthread_mutex_destroy(&g_cc3000_mut); -#endif - -#ifdef CONFIG_CC3000_MULTIPLE - kmm_free(priv); -#endif - return ret; -} - -/**************************************************************************** - * Name: cc3000_wait_data - * - * Description: - * Adds this socket for monitoring for the data available - * - * Input Parameters: - * priv - The device cc3000_dev_s instance - * sockfd cc3000 socket handle - * - * Returned Value: - * Zero is returned on success. Otherwise, a -1 value is - * returned to indicate socket not found or shut down occured. - * - ****************************************************************************/ - -static int cc3000_wait_data(FAR struct cc3000_dev_s *priv, int sockfd) -{ - int s; - - for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++) - { - if (priv->sockets[s].sd == sockfd) - { - sched_lock(); - cc3000_devgive(priv); - nxsem_post(&priv->selectsem); /* Wake select thread if need be */ - nxsem_wait(&priv->sockets[s].semwait); /* Wait caller on select to finish */ - nxsem_wait(&priv->selectsem); /* Sleep select thread */ - cc3000_devtake(priv); - sched_unlock(); - - if (priv->sockets[s].sd != sockfd) - { - return -1; - } - - if (priv->sockets[s].emptied_and_remotely_closed) - { - return -ECONNABORTED; - } - - return OK; - } - } - - return (s >= CONFIG_WL_MAX_SOCKETS || priv->selecttid == -1) ? -1 : OK; -} - -/**************************************************************************** - * Name: cc3000_accept_socket - * - * Description: - * Adds this socket for monitoring for the accept operation - * - * Input Parameters: - * priv - The device cc3000_dev_s instance - * sockfd - cc3000 socket handle to monitor - * - * Returned Value: - * Zero is returned on success. Otherwise, a negative value is - * returned to indicate an error. - * - ****************************************************************************/ - -static int cc3000_accept_socket(FAR struct cc3000_dev_s *priv, int sd, struct sockaddr *addr, - socklen_t *addrlen) -{ - - priv->accepting_socket.acc.status = CC3000_SOC_ERROR; - priv->accepting_socket.acc.sd = sd; - - sched_lock(); - cc3000_devgive(priv); - nxsem_post(&priv->selectsem); /* Wake select thread if need be */ - nxsem_wait(&priv->accepting_socket.acc.semwait); /* Wait caller on select to finish */ - nxsem_wait(&priv->selectsem); /* Sleep the Thread */ - cc3000_devtake(priv); - sched_unlock(); - - if (priv->accepting_socket.acc.status != CC3000_SOC_ERROR) - { - *addr = priv->accepting_socket.addr; - *addrlen = priv->accepting_socket.addrlen; - cc3000_add_socket(priv, priv->accepting_socket.acc.status); - } - - return priv->accepting_socket.acc.status; -} - -/**************************************************************************** - * Name: cc3000_add_socket - * - * Description: - * Adds a socket to the list for monitoring for long operation - * - * Input Parameters: - * sd cc3000 socket handle - * minor - The input device minor number - * - * Returned Value: - * Zero is returned on success. Otherwise, a -1 value is - * returned to indicate socket not found. - * - ****************************************************************************/ - -static int cc3000_add_socket(FAR struct cc3000_dev_s *priv, int sd) -{ - irqstate_t flags; - int s; - - if (sd < 0) - { - return sd; - } - - flags = enter_critical_section(); - for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++) - { - if (priv->sockets[s].sd == FREE_SLOT) - { - priv->sockets[s].received_closed_event = false; - priv->sockets[s].emptied_and_remotely_closed = false; - priv->sockets[s].sd = sd; - break; - } - } - - leave_critical_section(flags); - return s >= CONFIG_WL_MAX_SOCKETS ? -1 : OK; -} - -/**************************************************************************** - * Name: cc3000_remove_socket - * - * Description: - * Removes a socket from the list of monitoring for long operation - * - * Input Parameters: - * sd cc3000 socket handle - * minor - The input device minor number - * - * Returned Value: - * Zero is returned on success. Otherwise, a -1 value is - * returned to indicate socket not found. - * - ****************************************************************************/ - -static int cc3000_remove_socket(FAR struct cc3000_dev_s *priv, int sd) -{ - irqstate_t flags; - int s; - sem_t *ps = 0; - - if (sd < 0) - { - return sd; - } - - flags = enter_critical_section(); - if (priv->accepting_socket.acc.sd == sd) - { - priv->accepting_socket.acc.sd = CLOSE_SLOT; - ps = &priv->accepting_socket.acc.semwait; - } - - for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++) - { - if (priv->sockets[s].sd == sd) - { - priv->sockets[s].received_closed_event = false; - priv->sockets[s].emptied_and_remotely_closed = false; - priv->sockets[s].sd = CLOSE_SLOT; - ps = &priv->sockets[s].semwait; - break; - } - } - - leave_critical_section(flags); - if (ps) - { - sched_lock(); - cc3000_devgive(priv); - nxsem_post(&priv->selectsem); /* Wake select thread if need be */ - nxsem_wait(ps); - nxsem_wait(&priv->selectsem); /* Sleep the Thread */ - cc3000_devtake(priv); - sched_unlock(); - } - - return s >= CONFIG_WL_MAX_SOCKETS ? -1 : OK; -} - -/**************************************************************************** - * Name: cc3000_remote_closed_socket - * - * Description: - * Mark socket as closed by remote host - * - * Input Parameters: - * sd cc3000 socket handle - * - * Returned Value: - * Zero is returned on success. Otherwise, a -1 value is - * returned to indicate socket not found. - * - ****************************************************************************/ - -static int cc3000_remote_closed_socket(FAR struct cc3000_dev_s *priv, int sd) -{ - irqstate_t flags; - int s; - - if (sd < 0) - { - return sd; - } - - flags = enter_critical_section(); - for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++) - { - if (priv->sockets[s].sd == sd) - { - priv->sockets[s].received_closed_event = true; - } - } - - leave_critical_section(flags); - - return s >= CONFIG_WL_MAX_SOCKETS ? -1 : OK; -} diff --git a/drivers/wireless/cc3000/cc3000.h b/drivers/wireless/cc3000/cc3000.h deleted file mode 100644 index d969a1e5f6..0000000000 --- a/drivers/wireless/cc3000/cc3000.h +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************** - * drivers//wireless/cc3000.h - * - * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. - * Authors: Gregory Nutt - * David Sidrane - * - * References: - * CC30000 from Texas Instruments http://processors.wiki.ti.com/index.php/CC3000 - * - * See also: - * http://processors.wiki.ti.com/index.php/CC3000_Host_Driver_Porting_Guide - * http://processors.wiki.ti.com/index.php/CC3000_Host_Programming_Guide - * - * 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_WIRELESS_CC3000_H -#define __DRIVERS_WIRELESS_WIRELESS_CC3000_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define CONFIG_CC3000_MT /* Indicate multi threaded version */ - -#ifdef CONFIG_CC3000_MT -# define CONFIG_WL_MAX_SOCKETS 5 -#endif - -/* CC3000 Interfaces ********************************************************/ - -/* Driver support ***********************************************************/ -/* This format is used to construct the /dev/input[n] device driver path. It - * defined here so that it will be used consistently in all places. - */ - -#define READ 3 -#define READ_COMMAND {READ, 0 , 0 , 0 , 0} -#define READ_OFFSET_TO_LENGTH 3 //cmd dmy dmy lh ll -#define WRITE 1 - -#define HI(value) (((value) & 0xFF00) >> 8) -#define LO(value) ((value) & 0x00FF) - -#define SPI_HEADER_SIZE (5) - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -#ifdef CONFIG_CC3000_MT -/* lock to serialize access to driver (SPI protocol is window size 1) */ - -extern pthread_mutex_t g_cc3000_mut; - -/* This structure describes the state of one CC3000 driver instance */ - -typedef struct cc3000_socket_ent -{ - volatile int sd; - long status; - bool received_closed_event:1; - bool emptied_and_remotely_closed:1; - sem_t semwait; -} cc3000_socket_ent; - -typedef struct cc3000_accept_ent -{ - cc3000_socket_ent acc; - struct sockaddr addr; - socklen_t addrlen; -} cc3000_accept_ent; -#endif - -typedef enum -{ - eSPI_STATE_POWERUP = 0, - eSPI_STATE_INITIALIZED, - eSPI_STATE_IDLE, - eSPI_STATE_WRITE_WAIT_IRQ, - eSPI_STATE_WRITE_PROCEED, - eSPI_STATE_WRITE_DONE, - eSPI_STATE_READ_IRQ, - eSPI_STATE_READ_PROCEED, - eSPI_STATE_READ_READY, -} eDeviceStates; - -struct cc3000_dev_s -{ -#ifdef CONFIG_CC3000_MULTIPLE - FAR struct cc3000_dev_s *flink; /* Supports a singly linked list of drivers */ -#endif - pthread_t workertid; /* Handle for the worker thread */ - uint8_t crefs; /* Number of times the device has been opened */ - uint8_t nwaiters; /* Number of threads waiting for CC3000 data */ - uint8_t minor; /* minor */ - sem_t devsem; /* Manages exclusive access to this structure */ - sem_t *wrkwaitsem; /* Suspend and resume the delivery of messages */ - sem_t waitsem; /* Used to wait for the availability of data */ - sem_t irqsem; /* Used to signal irq from cc3000 */ - sem_t readysem; /* Used to wait for Ready Condition from the cc3000 */ - - FAR struct cc3000_config_s *config; /* Board configuration data */ - FAR struct spi_dev_s *spi; /* Saved SPI driver instance */ - mqd_t queue; /* For unsolicited data delivery */ - eDeviceStates state; /* The device state */ - cc3000_buffer_desc rx_buffer; - ssize_t rx_buffer_max_len; - - /* The following is a list if socket structures of threads waiting - * long operations to finish; - */ -#ifdef CONFIG_CC3000_MT - pthread_t selecttid; /* Handle for the select thread */ - sem_t selectsem; /* Used to sleep the select thread */ - cc3000_socket_ent sockets[CONFIG_WL_MAX_SOCKETS]; - cc3000_accept_ent accepting_socket; -#endif - - /* The following is a list if poll structures of threads waiting for - * driver events. The 'struct pollfd' reference for each open is also - * retained in the f_priv field of the 'struct file'. - */ - -#ifndef CONFIG_DISABLE_POLL - struct pollfd *fds[CONFIG_CC3000_NPOLLWAITERS]; -#endif - -#if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_CC3000_PROBES) - long guard; -#endif - -}; - -/******************************************************************************************** - * Public Function Prototypes - ********************************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" { -#else -#define EXTERN extern -#endif - -static inline void cc3000_lib_lock(void) -{ -#ifdef CONFIG_CC3000_MT - int status = pthread_mutex_lock(&g_cc3000_mut); - DEBUGASSERT(status == 0); - UNUSED(status); -#endif -} - -static inline void cc3000_lib_unlock(void) -{ -#ifdef CONFIG_CC3000_MT - int status = pthread_mutex_unlock(&g_cc3000_mut); - DEBUGASSERT(status == 0); - UNUSED(status); -#endif -} - -int cc3000_do_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* __DRIVERS_WIRELESS_WIRELESS_CC3000_H */ diff --git a/drivers/wireless/cc3000/cc3000_common.c b/drivers/wireless/cc3000/cc3000_common.c deleted file mode 100644 index bf8a8da8cd..0000000000 --- a/drivers/wireless/cc3000/cc3000_common.c +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** - * drivers/wireless/cc3000/cc3000_common.c.c - CC3000 Host Driver Implementation. - * - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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 -#include - -/**************************************************************************** - * Name: __error__ - * - * Description: - * Stub function for ASSERT macro - * - * Input Parameters: - * pcFilename - file name, where error occurred - * ulLine - line number, where error occurred - * - * Returned Value: - * None - * - ****************************************************************************/ - -/**************************************************************************** - * Name: UINT32_TO_STREAM_f - * - * Description: - * This function is used for copying 32 bit to stream while converting to - * little endian format. - * - * Input Parameters: - * p pointer to the new stream - * u32 pointer to the 32 bit - * - * Returned Value: - * Pointer to the new stream - * - ****************************************************************************/ - -uint8_t *UINT32_TO_STREAM_f(uint8_t *p, unsigned long u32) -{ - *(p)++ = (uint8_t)(u32); - *(p)++ = (uint8_t)((u32) >> 8); - *(p)++ = (uint8_t)((u32) >> 16); - *(p)++ = (uint8_t)((u32) >> 24); - return p; -} - -/**************************************************************************** - * Name: UINT16_TO_STREAM_f - * - * Description: - * This function is used for copying 16 bit to stream while converting to - * little endian format. - * - * Input Parameters: - * p pointer to the new stream - * u16 pointer to the 16 bit - * - * Returned Value: - * Pointer to the new stream - * - ****************************************************************************/ - -uint8_t *UINT16_TO_STREAM_f(uint8_t *p, uint16_t u16) -{ - *(p)++ = (uint8_t)(u16); - *(p)++ = (uint8_t)((u16) >> 8); - return p; -} - -/**************************************************************************** - * Name: STREAM_TO_UINT16_f - * - * Description: - * This function is used for copying received stream to 16 bit in little - * endian format. - * - * Input Parameters: - * p pointer to the stream - * offset offset in the stream - * - * Returned Value: - * Pointer to the new 16 bit - * - ****************************************************************************/ - -uint16_t STREAM_TO_UINT16_f(FAR char *p, uint16_t offset) -{ - return (uint16_t)((uint16_t)((uint16_t) - (*(p + offset + 1)) << 8) + (uint16_t)(*(p + offset))); -} - -/**************************************************************************** - * Name: STREAM_TO_UINT32_f - * - * Description: - * This function is used for copying received stream to 32 bit in little - * endian format. - * - * Input Parameters: - * p pointer to the stream - * offset offset in the stream - * - * Returned Value: - * Pointer to the new 32 bit - * - ****************************************************************************/ - -unsigned long STREAM_TO_UINT32_f(FAR char *p, uint16_t offset) -{ - return (unsigned long)((unsigned long)((unsigned long) - (*(p + offset + 3)) << 24) + (unsigned long)((unsigned long) - (*(p + offset + 2)) << 16) + (unsigned long)((unsigned long) - (*(p + offset + 1)) << 8) + (unsigned long)(*(p + offset))); -} diff --git a/drivers/wireless/cc3000/cc3000_socket.h b/drivers/wireless/cc3000/cc3000_socket.h deleted file mode 100644 index 0218221abc..0000000000 --- a/drivers/wireless/cc3000/cc3000_socket.h +++ /dev/null @@ -1,663 +0,0 @@ -/**************************************************************************** - * drivers/wireless/cc3000_socket.h - CC3000 Host Driver Implementation. - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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_CC3000_SOCKET_H -#define __DRIVERS_WIRELESS_CC3000_SOCKET_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define CC3000_HOSTNAME_MAX_LENGTH (230) /* 230 bytes + header shouldn't exceed 8 - * bit value */ - -/*--------- Address Families --------*/ - -#define CC3000_AF_INET 2 -#define CC3000_AF_INET6 23 - - -/*------------ Socket Types ------------*/ - -#define CC3000_SOCK_STREAM 1 -#define CC3000_SOCK_DGRAM 2 -#define CC3000_SOCK_RAW 3 /* Raw sockets allow new IPv4 - * protocols to be implemented in - * user space. A raw socket receives - * or sends the raw datagram not - * including link level headers */ -#define CC3000_SOCK_RDM 4 -#define CC3000_SOCK_SEQPACKET 5 - -/*----------- Socket Protocol ----------*/ - -#define CC3000_IPPROTO_IP 0 /* Dummy for IP */ -#define CC3000_IPPROTO_ICMP 1 /* Control message protocol */ -#define CC3000_IPPROTO_IPV4 CC3000_IPPROTO_IP /* IP inside IP */ -#define CC3000_IPPROTO_TCP 6 /* TCP */ -#define CC3000_IPPROTO_UDP 17 /* User datagram protocol */ -#define CC3000_IPPROTO_IPV6 41 /* IPv6 in IPv6 */ -#define CC3000_IPPROTO_NONE 59 /* No next header */ -#define CC3000_IPPROTO_TX_TEST_RAW 150 /* Raw 802.11 Tx Test packet */ -#define CC3000_IPPROTO_RAW 255 /* Raw IP packet */ -#define CC3000_IPPROTO_MAX 256 - -/*----------- Socket retunr codes -----------*/ - -#define CC3000_SOC_ERROR (-1) /* Error */ -#define CC3000_SOC_IN_PROGRESS (-2) /* Socket in progress */ - -/*----------- Socket Options -----------*/ -#define CC3000_SOL_SOCKET 0xffff /* Socket level */ -#define CC3000_SOCKOPT_RECV_NONBLOCK 0 /* recv non block mode, set SOCK_ON or - * SOCK_OFF (default block mode) */ -#define CC3000_SOCKOPT_RECV_TIMEOUT 1 /* optname to configure recv and recvfromtimeout */ -#define CC3000_SOCKOPT_ACCEPT_NONBLOCK 2 /* accept non block mode, set SOCK_ON or SOCK_OFF - * (default block mode) */ -#define CC3000_SOCK_ON 0 /* socket non-blocking mode is enabled */ -#define CC3000_SOCK_OFF 1 /* socket blocking mode is enabled */ - -#define CC3000_TCP_NODELAY 0x0001 -#define CC3000_TCP_BSDURGENT 0x7000 - -#define CC3000_MAX_PACKET_SIZE 1500 -#define CC3000_MAX_LISTEN_QUEUE 4 - -#define CC3000_IOCTL_SOCKET_EVENTMASK - -#define CC3000_FD_SETSIZE 32 - -#define CC3000_ASIC_ADDR_LEN 8 - -#define CC3000_NO_QUERY_RECIVED -3 - -/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */ - -#define __NFDBITS (8 * sizeof (__fd_mask)) -#define __FDELT(d) ((d) / __NFDBITS) -#define __FDMASK(d) ((__fd_mask) 1 << ((d) % __NFDBITS)) - -#define __FDS_BITS(set) ((set)->fds_bits) - -/* We don't use `memset' because this would require a prototype and - * the array isn't too big. - */ - -#define __FD_ZERO(set) \ - do { \ - unsigned int __i; \ - TICC3000fd_set *__arr = (set); \ - for (__i = 0; __i < sizeof (TICC3000fd_set) / sizeof (__fd_mask); ++__i) \ - __FDS_BITS (__arr)[__i] = 0; \ - } while (0) -#define __FD_SET(d, set) (__FDS_BITS (set)[__FDELT (d)] |= __FDMASK (d)) -#define __FD_CLR(d, set) (__FDS_BITS (set)[__FDELT (d)] &= ~__FDMASK (d)) -#define __FD_ISSET(d, set) (__FDS_BITS (set)[__FDELT (d)] & __FDMASK (d)) - -/* Access macros for 'TICC3000fd_set' */ - -#define CC3000_FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp) -#define CC3000_FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp) -#define CC3000_FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp) -#define CC3000_FD_ZERO(fdsetp) __FD_ZERO (fdsetp) - - -/* mDNS port - 5353 mDNS multicast address - 224.0.0.251 */ - -#define SET_mDNS_ADD(sockaddr) sockaddr.sa_data[0] = 0x14; \ - sockaddr.sa_data[1] = 0xe9; \ - sockaddr.sa_data[2] = 0xe0; \ - sockaddr.sa_data[3] = 0x0; \ - sockaddr.sa_data[4] = 0x0; \ - sockaddr.sa_data[5] = 0xfb; - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/* The fd_set member is required to be an array of longs. */ - -typedef long int __fd_mask; - -/* fd_set for select and pselect. */ - -typedef struct -{ - __fd_mask fds_bits[CC3000_FD_SETSIZE / __NFDBITS]; -} TICC3000fd_set; - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#ifdef __cplusplus -extern "C" { -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: cc3000_socket_impl - * - * Decription: - * create an endpoint for communication. The socket function creates a - * socket that is bound to a specific transport service provider. This - * function is called by the application layer to obtain a socket handle. - * - * Input Parameters: - * domain selects the protocol family which will be used for - * communication. On this version only AF_INET is supported - * type specifies the communication semantics. On this version - * only SOCK_STREAM, SOCK_DGRAM, SOCK_RAW are supported - * protocol specifies a particular protocol to be used with the - * socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are - * supported. - * - * Returned Value: - * On success, socket handle that is used for consequent socket - * operations. On error, -1 is returned. - * - ****************************************************************************/ - -int cc3000_socket_impl(long domain, long type, long protocol); - -/**************************************************************************** - * Name: cc3000_closesocket_impl - * - * Decription: - * The socket function closes a created socket. - * - * Input Parameters: - * sd socket handle. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -long cc3000_closesocket_impl(long sd); - -/**************************************************************************** - * Name: cc3000_accept_impl - * - * Decription: - * accept a connection on a socket: - * This function is used with connection-based socket types - * (SOCK_STREAM). It extracts the first connection request on the - * queue of pending connections, creates a new connected socket, and - * returns a new file descriptor referring to that socket. - * The newly created socket is not in the listening state. - * The original socket sd is unaffected by this call. - * The argument sd is a socket that has been created with socket(), - * bound to a local address with bind(), and is listening for - * connections after a listen(). The argument addr is a pointer - * to a sockaddr structure. This structure is filled in with the - * address of the peer socket, as known to the communications layer. - * The exact format of the address returned addr is determined by the - * socket's address family. The addrlen argument is a value-result - * argument: it should initially contain the size of the structure - * pointed to by addr, on return it will contain the actual - * length (in bytes) of the address returned. - * - * Input Parameters: - * sd socket descriptor (handle) - * addr the argument addr is a pointer to a sockaddr structure - * This structure is filled in with the address of the - * peer socket, as known to the communications layer. - * determined. The exact format of the address returned - * addr is by the socket's address sockaddr. - * On this version only AF_INET is supported. - * This argument returns in network order. - * addrlen The addrlen argument is a value-result argument: - * it should initially contain the size of the structure - * pointed to by addr. - * - * Returned Value: - * For socket in blocking mode: - * On success, socket handle. on failure negative - * For socket in non-blocking mode: - * - On connection establishment, socket handle - * - On connection pending, SOC_IN_PROGRESS (-2) - * - On failure, SOC_ERROR (-1) - * - ****************************************************************************/ - -long cc3000_accept_impl(long sd, struct sockaddr *addr, socklen_t *addrlen); - -/**************************************************************************** - * Name: cc3000_bind_impl - * - * Decription: - * assign a name to a socket - * This function gives the socket the local address addr. - * addr is addrlen bytes long. Traditionally, this is called when a - * socket is created with socket, it exists in a name space (address - * family) but has no name assigned. - * It is necessary to assign a local address before a SOCK_STREAM - * socket may receive connections. - * - * Input Parameters: - * sd socket descriptor (handle) - * addr specifies the destination address. On this version - * only AF_INET is supported. - * addrlen contains the size of the structure pointed to by addr. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -long cc3000_bind_impl(long sd, FAR const struct sockaddr *addr, socklen_t addrlen); - -/**************************************************************************** - * Name: cc3000_listen_impl - * - * Decription: - * listen for connections on a socket - * The willingness to accept incoming connections and a queue - * limit for incoming connections are specified with listen(), - * and then the connections are accepted with accept. - * The listen() call applies only to sockets of type SOCK_STREAM - * The backlog parameter defines the maximum length the queue of - * pending connections may grow to. - * - * NOTE: On this version, backlog is not supported - * - * Input Parameters: - * sd socket descriptor (handle) - * backlog specifies the listen queue depth. On this version - * backlog is not supported. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -long cc3000_listen_impl(long sd, long backlog); - -/**************************************************************************** - * Name: cc3000_connect_impl - * - * Decription: - * initiate a connection on a socket - * Function connects the socket referred to by the socket descriptor - * sd, to the address specified by addr. The addrlen argument - * specifies the size of addr. The format of the address in addr is - * determined by the address space of the socket. If it is of type - * SOCK_DGRAM, this call specifies the peer with which the socket is - * to be associated; this address is that to which datagrams are to be - * sent, and the only address from which datagrams are to be received. - * If the socket is of type SOCK_STREAM, this call attempts to make a - * connection to another socket. The other socket is specified by - * address, which is an address in the communications space of the - * socket. Note that the function implements only blocking behavior - * thus the caller will be waiting either for the connection - * establishment or for the connection establishment failure. - * - * Input Parameters: - * sd socket descriptor (handle) - * addr specifies the destination addr. On this version - * only AF_INET is supported. - * addrlen contains the size of the structure pointed to by addr - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -long cc3000_connect_impl(long sd, FAR const struct sockaddr *addr, socklen_t addrlen); - -/**************************************************************************** - * Name: cc3000_select_impl - * - * Decription: - * Monitor socket activity - * Select allow a program to monitor multiple file descriptors, - * waiting until one or more of the file descriptors become - * "ready" for some class of I/O operation - * - * NOTE: If the timeout value set to less than 5ms it will automatically set - * to 5ms to prevent overload of the system - * - * Input Parameters: - * nfds the highest-numbered file descriptor in any of the - * three sets, plus 1. - * readfds socket descriptors list for read monitoring - * writefds socket descriptors list for write monitoring - * exceptfds socket descriptors list for exception monitoring - * timeout is an upper bound on the amount of time elapsed - * before select() returns. Null means infinity - * timeout. The minimum timeout is 5 milliseconds, - * less than 5 milliseconds will be set - * automatically to 5 milliseconds. - * - * Returned Value: - * On success, select() returns the number of file descriptors - * contained in the three returned descriptor sets (that is, the - * total number of bits that are set in readfds, writefds, - * exceptfds) which may be zero if the timeout expires before - * anything interesting happens. - * On error, -1 is returned. - * *readfds - return the sockets on which Read request will - * return without delay with valid data. - * *writefds - return the sockets on which Write request - * will return without delay. - * *exceptfds - return the sockets which closed recently. - * - ****************************************************************************/ - -struct timeval; - -int cc3000_select_impl(long nfds, TICC3000fd_set *readfds, TICC3000fd_set *writefds,TICC3000fd_set *exceptfds, - struct timeval *timeout); - -int cc3000_select(int nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, struct timeval *timeout); - - -#ifndef CC3000_TINY_DRIVER -/**************************************************************************** - * Name: cc3000_setsockopt_impl - * - * Decription: - * set socket options - * This function manipulate the options associated with a socket. - * Options may exist at multiple protocol levels; they are always - * present at the uppermost socket level. - * When manipulating socket options the level at which the option - * resides and the name of the option must be specified. - * To manipulate options at the socket level, level is specified as - * SOL_SOCKET. To manipulate options at any other level the protocol - * number of the appropriate protocol controlling the option is - * supplied. For example, to indicate that an option is to be - * interpreted by the TCP protocol, level should be set to the - * protocol number of TCP; - * The parameters optval and optlen are used to access optval - - * use for setsockopt(). For getsockopt() they identify a buffer - * in which the value for the requested option(s) are to - * be returned. For getsockopt(), optlen is a value-result - * parameter, initially containing the size of the buffer - * pointed to by option_value, and modified on return to - * indicate the actual size of the value returned. If no option - * value is to be supplied or returned, option_value may be NULL. - * - * NOTE: On this version the following two socket options are enabled: - * The only protocol level supported in this version - * is SOL_SOCKET (level). - * 1. SOCKOPT_RECV_TIMEOUT (optname) - * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout - * in milliseconds. - * In that case optval should be pointer to unsigned long. - * 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on - * or off. - * In that case optval should be SOCK_ON or SOCK_OFF (optval). - * - * Input Parameters: - * sd socket handle - * level defines the protocol level for this option - * optname defines the option name to Interrogate - * optval specifies a value for the option - * optlen specifies the length of the option value - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -int cc3000_setsockopt_impl(long sd, long level, long optname, const void *optval, socklen_t optlen); -#endif - -/**************************************************************************** - * Name: cc3000_getsockopt_impl - * - * Decription: - * set socket options - * This function manipulate the options associated with a socket. - * Options may exist at multiple protocol levels; they are always - * present at the uppermost socket level. - * When manipulating socket options the level at which the option - * resides and the name of the option must be specified. - * To manipulate options at the socket level, level is specified as - * SOL_SOCKET. To manipulate options at any other level the protocol - * number of the appropriate protocol controlling the option is - * supplied. For example, to indicate that an option is to be - * interpreted by the TCP protocol, level should be set to the - * protocol number of TCP; - * The parameters optval and optlen are used to access optval - - * use for setsockopt(). For getsockopt() they identify a buffer - * in which the value for the requested option(s) are to - * be returned. For getsockopt(), optlen is a value-result - * parameter, initially containing the size of the buffer - * pointed to by option_value, and modified on return to - * indicate the actual size of the value returned. If no option - * value is to be supplied or returned, option_value may be NULL. - * - * NOTE: On this version the following two socket options are enabled: - * The only protocol level supported in this version - * is SOL_SOCKET (level). - * 1. SOCKOPT_RECV_TIMEOUT (optname) - * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout - * in milliseconds. - * In that case optval should be pointer to unsigned long. - * 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on - * or off. - * In that case optval should be SOCK_ON or SOCK_OFF (optval). - * - * Input Parameters: - * sd socket handle - * level defines the protocol level for this option - * optname defines the option name to Interrogate - * optval specifies a value for the option - * optlen specifies the length of the option value - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -int cc3000_getsockopt_impl(long sd, long level, long optname, void *optval, socklen_t *optlen); - - -/**************************************************************************** - * Name: cc3000_recv_impl - * - * Decription: - * function receives a message from a connection-mode socket - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sd socket handle - * buf Points to the buffer where the message should be stored - * len Specifies the length in bytes of the buffer pointed to - * by the buffer argument. - * flags Specifies the type of message reception. - * On this version, this parameter is not supported. - * - * Returned Value: - * Return the number of bytes received, or -1 if an error - * occurred - * - ****************************************************************************/ - -int cc3000_recv_impl(long sd, void *buf, long len, long flags); - -/**************************************************************************** - * Name: cc3000_recvfrom_impl - * - * Decription: - * read data from socket - * function receives a message from a connection-mode or - * connectionless-mode socket. Note that raw sockets are not - * supported. - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sd socket handle - * buf Points to the buffer where the message should be stored - * len Specifies the length in bytes of the buffer pointed to - * by the buffer argument. - * flags Specifies the type of message reception. - * On this version, this parameter is not supported. - * from pointer to an address structure indicating the source - * address: sockaddr. On this version only AF_INET is - * supported. - * fromlen source address tructure size - * - * Returned Value: - * Return the number of bytes received, or -1 if an error - * occurred - * - ****************************************************************************/ - -int cc3000_recvfrom_impl(long sd, void *buf, long len, long flags, - struct sockaddr *from, socklen_t *fromlen); - -/**************************************************************************** - * Name: cc3000_send_impl - * - * Decription: - * Write data to TCP socket - * This function is used to transmit a message to another - * socket. - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sd socket handle - * buf Points to a buffer containing the message to be sent - * len message size in bytes - * flags On this version, this parameter is not supported - * - * Returned Value: - * Return the number of bytes transmitted, or -1 if an - * error occurred - * - ****************************************************************************/ - -int cc3000_send_impl(long sd, const void *buf, long len, long flags); - -/**************************************************************************** - * Name: cc3000_sendto_impl - * - * Decription: - * Write data to TCP socket - * This function is used to transmit a message to another - * socket. - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sd socket handle - * buf Points to a buffer containing the message to be sent - * len message size in bytes - * flags On this version, this parameter is not supported - * to pointer to an address structure indicating the destination - * address: sockaddr. On this version only AF_INET is - * supported. - * tolen destination address structure size - * - * Returned Value: - * Return the number of bytes transmitted, or -1 if an - * error occurred - * - ****************************************************************************/ - -int cc3000_sendto_impl(long sd, FAR const void *buf, long len, long flags, - FAR const struct sockaddr *to, socklen_t tolen); - -#ifndef CC3000_TINY_DRIVER -/**************************************************************************** - * Name: cc3000_gethostbyname_impl - * - * Decription: - * Get host IP by name. Obtain the IP Address of machine on network, - * by its name. - * - * NOTE: On this version, only blocking mode is supported. Also note that - * the function requires DNS server to be configured prior to its - * usage. - * - * Input Parameters: - * hostname host name - * usNameLen name length - * out_ip_addr This parameter is filled in with host IP address. - * In case that host name is not resolved, - * out_ip_addr is zero. - * - * Returned Value: - * On success, positive is returned. On error, negative is returned - * - ****************************************************************************/ - -//struct hostent *gethostbyname(const char *name); -int cc3000_gethostbyname_impl(char * hostname, uint16_t usNameLen, unsigned long* out_ip_addr); -#endif - -/**************************************************************************** - * Name: cc3000_mdnsAdvertiser_impl - * - * Decription: - * Set CC3000 in mDNS advertiser mode in order to advertise itself. - * - * Input Parameters: - * mdnsEnabled flag to enable/disable the mDNS feature - * deviceServiceName Service name as part of the published - * canonical domain name - * deviceServiceNameLength Length of the service name - * - * Returned Value: - * On success, zero is returned, return SOC_ERROR if socket was not - * opened successfully, or if an error occurred. - * - ****************************************************************************/ - -int cc3000_mdnsadvertiser_impl(uint16_t mdnsEnabled, char * deviceServiceName, - uint16_t deviceServiceNameLength); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // __DRIVERS_WIRELESS_CC3000_SOCKET_H diff --git a/drivers/wireless/cc3000/cc3000drv.c b/drivers/wireless/cc3000/cc3000drv.c deleted file mode 100644 index acd9ae8528..0000000000 --- a/drivers/wireless/cc3000/cc3000drv.c +++ /dev/null @@ -1,438 +0,0 @@ -/**************************************************************************** - * drivers/wireless/cc3000/cc3000drv.c - * Driver wrapper functions to conntect nuttx to the TI CC3000 - * - * Port to nuttx: - * David Sidrane - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include "cc3000drv.h" - -#include -#include -#include -#include - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -static struct -{ - int cc3000fd; - gcSpiHandleRx pfRxHandler; - pthread_t unsoliced_thread; - bool run; - cc3000_buffer_desc rx_buffer; - mqd_t queue; - sem_t *done; - sem_t unsoliced_thread_wakesem; -} spiconf = -{ - -1, -}; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: cc3000_resume - * - * Description: - * Will re enable the to deliver messages - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void cc3000_resume(void) -{ - DEBUGASSERT(spiconf.cc3000fd >= 0 && spiconf.done); - nxsem_post(spiconf.done); - ninfo("Done\n"); -} - -/**************************************************************************** - * Name: cc3000_write - * - * Description: - * This function enter point for write flow - * - * Input Parameters: - * pUserBuffer - * usLength - * - * Returned Value: - * - ****************************************************************************/ - -long cc3000_write(uint8_t *pUserBuffer, uint16_t usLength) -{ - ssize_t ret; - - DEBUGASSERT(spiconf.cc3000fd >= 0); - - ret = nx_write(spiconf.cc3000fd, pUserBuffer, usLength); - return ret >= 0 ? 0 : ret; -} - -/**************************************************************************** - * Name: cc3000_read - * - * Description: - * This function enter point for read flow. This function will block the - * caller until there is data available - * - * Input Parameters: - * pUserBuffer - * usLength - * - * Returned Value: - * - ****************************************************************************/ - -long cc3000_read(uint8_t *pUserBuffer, uint16_t usLength) -{ - DEBUGASSERT(spiconf.cc3000fd >= 0); - return nx_read(spiconf.cc3000fd, pUserBuffer, usLength); -} - -/**************************************************************************** - * Name: cc3000_wait - * - * Description: - * Waits on a message from the driver. - * - * Input Parameters: - * None - * - * Returned Value: - * - ****************************************************************************/ - -uint8_t *cc3000_wait(void) -{ - DEBUGASSERT(spiconf.cc3000fd >= 0); - - (void)nxmq_receive(spiconf.queue, (FAR char *)&spiconf.rx_buffer, - sizeof(spiconf.rx_buffer), 0); - return spiconf.rx_buffer.pbuffer; -} - -/**************************************************************************** - * Name: unsoliced_thread_func - * - * Description: - * This is the thread for unsolicited events. This function will block the - * caller until there is data available - * - * Input Parameters: - * parameter - * - * Returned Value: - * - ****************************************************************************/ - -static void *unsoliced_thread_func(void *parameter) -{ - char buff[QUEUE_NAMELEN]; - int status = 0; - int nbytes = 0; - int minor = 0; - - ioctl(spiconf.cc3000fd, CC3000IOC_GETQUESEMID, (unsigned long)&minor); - snprintf(buff, QUEUE_NAMELEN, QUEUE_FORMAT, minor); - spiconf.queue = mq_open(buff, O_RDONLY); - DEBUGASSERT(spiconf.queue != (mqd_t) -1); - DEBUGASSERT(SEM_NAMELEN == QUEUE_NAMELEN); - snprintf(buff, SEM_NAMELEN, SEM_FORMAT, minor); - spiconf.done = sem_open(buff, O_RDONLY); - DEBUGASSERT(spiconf.done != SEM_FAILED); - - nxsem_post(&spiconf.unsoliced_thread_wakesem); - - while (spiconf.run) - { - memset(&spiconf.rx_buffer, 0, sizeof(spiconf.rx_buffer)); - nbytes = nxmq_receive(spiconf.queue, (FAR char *)&spiconf.rx_buffer, - sizeof(spiconf.rx_buffer), 0); - if (nbytes > 0) - { - ninfo("%d Processed\n", nbytes); - spiconf.pfRxHandler(spiconf.rx_buffer.pbuffer); - } - } - - mq_close(spiconf.queue); - sem_close(spiconf.done); - pthread_exit((pthread_addr_t)status); - return (pthread_addr_t)status; -} - -/**************************************************************************** - * Name: cc3000_open - * - * Description: - * Open the cc3000 driver - * - * Input Parameters: - * pfRxHandler the Rx handler for messages - * - * Returned Value: - * None - * - ****************************************************************************/ - -void cc3000_open(gcSpiHandleRx pfRxHandler) -{ - int status; - int ret; - int fd; - - DEBUGASSERT(spiconf.cc3000fd == -1); - - fd = open("/dev/wireless0", O_RDWR | O_BINARY); - if (fd >= 0) - { - spiconf.pfRxHandler = pfRxHandler; - spiconf.cc3000fd = fd; - spiconf.run = true; - - nxsem_init(&spiconf.unsoliced_thread_wakesem, 0, 0); - - pthread_attr_t attr; - struct sched_param param; - pthread_attr_init(&attr); - attr.stacksize = CONFIG_CC3000_UNSOLICED_STACKSIZE; - param.sched_priority = SCHED_PRIORITY_DEFAULT-10; - pthread_attr_setschedparam(&attr, ¶m); - status = pthread_create(&spiconf.unsoliced_thread, &attr, - unsoliced_thread_func, NULL); - DEBUGASSERT(status == 0); - UNUSED(status); - - /* Wait unsoliced_thread to wake-up. */ - - do - { - ret = nxsem_wait(&spiconf.unsoliced_thread_wakesem); - - /* The only case that an error should occur here is if the wait - * was awakened by a signal. - */ - - DEBUGASSERT(ret == OK || ret == -EINTR); - } - while (ret == -EINTR); - } - - DEBUGASSERT(spiconf.cc3000fd >= 0); -} - -/**************************************************************************** - * Name: cc3000_close - * - * Description: - * Close the cc3000 driver - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void cc3000_close(void) -{ - if (spiconf.cc3000fd >= 0) - { - int status; - spiconf.run = false; - - pthread_cancel(spiconf.unsoliced_thread); - pthread_join(spiconf.unsoliced_thread, (FAR pthread_addr_t *)&status); - - close(spiconf.cc3000fd); - - memset(&spiconf, 0, sizeof(spiconf)); - spiconf.cc3000fd = -1; - } -} - -/**************************************************************************** - * Name: cc3000_wait_data - * - * Description: - * Adds this socket for monitoring for the data operation - * - * Input Parameters: - * sd cc3000 socket handle or -1 tp remove it - * - * Returned Value: - * Zero is returned on success. Otherwise, a -1 value is - * returned to indicate socket not found. - * - ****************************************************************************/ - -int cc3000_wait_data(int sockfd) -{ - int rv = sockfd; - - DEBUGASSERT(spiconf.cc3000fd >= 0); - ioctl(spiconf.cc3000fd, CC3000IOC_SELECTDATA, (unsigned long)&rv); - return rv; -} - -/**************************************************************************** - * Name: cc3000_accept_socket - * - * Description: - * Adds this socket for monitoring for the accept operation - * - * Input Parameters: - * sd cc3000 socket handle or -1 tp remove it - * minor - The input device minor number - * - * Returned Value: - * Zero is returned on success. Otherwise, a -1 value is - * returned to indicate socket not found. - * - ****************************************************************************/ - -int cc3000_accept_socket(int sockfd, struct sockaddr *addr, socklen_t *addrlen) -{ - DEBUGASSERT(spiconf.cc3000fd >= 0); - - cc3000_acceptcfg cfg; - cfg.sockfd = sockfd; - cfg.addr = addr; - cfg.addrlen = addrlen; - ioctl(spiconf.cc3000fd, CC3000IOC_SELECTACCEPT, (unsigned long)&cfg); - return cfg.sockfd; -} - -/**************************************************************************** - * Name: cc3000_add_socket - * - * Description: - * Adds a socket to the list for monitoring for long operation - * - * Input Parameters: - * sd cc3000 socket handle - * minor - The input device minor number - * - * Returned Value: - * Zero is returned on success. Otherwise, a -1 value is - * returned to indicate socket not found. - * - ****************************************************************************/ - -int cc3000_add_socket(int sockfd) -{ - int rv = sockfd; - - DEBUGASSERT(spiconf.cc3000fd >= 0); - ioctl(spiconf.cc3000fd, CC3000IOC_ADDSOCKET, (unsigned long)&rv); - return rv; -} - -/**************************************************************************** - * Name: cc3000_remove_socket - * - * Description: - * Removes a socket from the list of monitoring for long operation - * - * Input Parameters: - * sd cc3000 socket handle - * minor - The input device minor number - * - * Returned Value: - * Zero is returned on success. Otherwise, a -1 value is - * returned to indicate socket not found. - * - ****************************************************************************/ - -int cc3000_remove_socket(int sockfd) -{ - int rv = sockfd; - - DEBUGASSERT(spiconf.cc3000fd >= 0); - ioctl(spiconf.cc3000fd, CC3000IOC_REMOVESOCKET, (unsigned long)&rv); - return rv; -} - -/**************************************************************************** - * Name: cc3000_remote_closed_socket - * - * Description: - * Mark socket as closed by remote host - * - * Input Parameters: - * sd cc3000 socket handle - * - * Returned Value: - * Zero is returned on success. Otherwise, a -1 value is - * returned to indicate socket not found. - * - ****************************************************************************/ - -int cc3000_remote_closed_socket(int sockfd) -{ - int rv = sockfd; - - DEBUGASSERT(spiconf.cc3000fd >= 0); - ioctl(spiconf.cc3000fd, CC3000IOC_REMOTECLOSEDSOCKET, (unsigned long)&rv); - return rv; -} diff --git a/drivers/wireless/cc3000/cc3000drv.h b/drivers/wireless/cc3000/cc3000drv.h deleted file mode 100644 index 4c67fa2fe4..0000000000 --- a/drivers/wireless/cc3000/cc3000drv.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** - * drivers/wireless/cc3000/cc3000drv.h - Driver wrapper functions to - * connect nuttx to the TI CC3000 - * - * Port to nuttx: - * David Sidrane - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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_CC3000_CC3000DRV_H -#define __DRIVERS_WIRELESS_CC3000_CC3000DRV_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -typedef void (*gcSpiHandleRx)(void *p); - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -void cc3000_open(gcSpiHandleRx pfRxHandler); -void cc3000_close(void); -long cc3000_write(uint8_t *pUserBuffer, uint16_t usLength); -uint8_t *cc3000_wait(void); -long cc3000_read(uint8_t *pUserBuffer, uint16_t usLength); -void cc3000_resume(void); - -int cc3000_wait_data(int sockfd); -int cc3000_accept_socket(int sockfd, struct sockaddr *addr, - socklen_t *addrlen); -int cc3000_add_socket(int sockfd); -int cc3000_remove_socket(int sockfd); -int cc3000_remote_closed_socket(int sockfd); - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* __DRIVERS_WIRELESS_CC3000_CC3000DRV_H */ diff --git a/drivers/wireless/cc3000/evnt_handler.c b/drivers/wireless/cc3000/evnt_handler.c deleted file mode 100644 index b2ec2b016a..0000000000 --- a/drivers/wireless/cc3000/evnt_handler.c +++ /dev/null @@ -1,1021 +0,0 @@ -/**************************************************************************** - * drivers/wireless/cc3000/evnt_handler.c - CC3000 Host Driver Implementation. - * - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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 - -#include -#include -#include -#include - -#include -#include -#include -#include -#include "cc3000_socket.h" -#include "cc3000drv.h" -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define FLOW_CONTROL_EVENT_HANDLE_OFFSET (0) -#define FLOW_CONTROL_EVENT_BLOCK_MODE_OFFSET (1) -#define FLOW_CONTROL_EVENT_FREE_BUFFS_OFFSET (2) -#define FLOW_CONTROL_EVENT_SIZE (4) - -#define BSD_RSP_PARAMS_SOCKET_OFFSET (0) -#define BSD_RSP_PARAMS_STATUS_OFFSET (4) - -#define GET_HOST_BY_NAME_RETVAL_OFFSET (0) -#define GET_HOST_BY_NAME_ADDR_OFFSET (4) - -#define ACCEPT_SD_OFFSET (0) -#define ACCEPT_RETURN_STATUS_OFFSET (4) -#define ACCEPT_ADDRESS__OFFSET (8) - -#define SL_RECEIVE_SD_OFFSET (0) -#define SL_RECEIVE_NUM_BYTES_OFFSET (4) -#define SL_RECEIVE__FLAGS__OFFSET (8) - -#define SELECT_STATUS_OFFSET (0) -#define SELECT_READFD_OFFSET (4) -#define SELECT_WRITEFD_OFFSET (8) -#define SELECT_EXFD_OFFSET (12) - -#define NETAPP_IPCONFIG_IP_OFFSET (0) -#define NETAPP_IPCONFIG_SUBNET_OFFSET (4) -#define NETAPP_IPCONFIG_GW_OFFSET (8) -#define NETAPP_IPCONFIG_DHCP_OFFSET (12) -#define NETAPP_IPCONFIG_DNS_OFFSET (16) -#define NETAPP_IPCONFIG_MAC_OFFSET (20) -#define NETAPP_IPCONFIG_SSID_OFFSET (26) - -#define NETAPP_IPCONFIG_IP_LENGTH (4) -#define NETAPP_IPCONFIG_MAC_LENGTH (6) -#define NETAPP_IPCONFIG_SSID_LENGTH (32) - -#define NETAPP_PING_PACKETS_SENT_OFFSET (0) -#define NETAPP_PING_PACKETS_RCVD_OFFSET (4) -#define NETAPP_PING_MIN_RTT_OFFSET (8) -#define NETAPP_PING_MAX_RTT_OFFSET (12) -#define NETAPP_PING_AVG_RTT_OFFSET (16) - -#define GET_SCAN_RESULTS_TABlE_COUNT_OFFSET (0) -#define GET_SCAN_RESULTS_SCANRESULT_STATUS_OFFSET (4) -#define GET_SCAN_RESULTS_ISVALID_TO_SSIDLEN_OFFSET (8) -#define GET_SCAN_RESULTS_FRAME_TIME_OFFSET (10) -#define GET_SCAN_RESULTS_SSID_MAC_LENGTH (38) - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -unsigned long socket_active_status = SOCKET_STATUS_INIT_VAL; - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -static long hci_event_unsol_flowcontrol_handler(char *pEvent); -static void update_socket_active_status(char *resp_params); - -/**************************************************************************** - * Public Functions - ****************************************************************************/ -/**************************************************************************** - * Name: hci_unsol_handle_patch_request - * - * Description: - * Handle unsolicited event from type patch request - * - * Input Parameters: - * event_hdr event header - * - * Returned Value: - * None - * - ****************************************************************************/ - -void hci_unsol_handle_patch_request(char *event_hdr) -{ - char *params = (char *)(event_hdr) + HCI_EVENT_HEADER_SIZE; - unsigned long ucLength = 0; - char *patch; - - switch (*params) - { - case HCI_EVENT_PATCHES_DRV_REQ: - - if (tSLInformation.sDriverPatches) - { - patch = tSLInformation.sDriverPatches(&ucLength); - - if (patch) - { - hci_patch_send(HCI_EVENT_PATCHES_DRV_REQ, - tSLInformation.pucTxCommandBuffer, - patch, ucLength); - return; - } - } - - /* Send 0 length Patches response event */ - - hci_patch_send(HCI_EVENT_PATCHES_DRV_REQ, - tSLInformation.pucTxCommandBuffer, 0, 0); - break; - - case HCI_EVENT_PATCHES_FW_REQ: - - if (tSLInformation.sFWPatches) - { - patch = tSLInformation.sFWPatches(&ucLength); - - /* Build and send a patch */ - - if (patch) - { - hci_patch_send(HCI_EVENT_PATCHES_FW_REQ, - tSLInformation.pucTxCommandBuffer, - patch, ucLength); - return; - } - } - - /* Send 0 length Patches response event */ - - hci_patch_send(HCI_EVENT_PATCHES_FW_REQ, - tSLInformation.pucTxCommandBuffer, 0, 0); - break; - - case HCI_EVENT_PATCHES_BOOTLOAD_REQ: - - if (tSLInformation.sBootLoaderPatches) - { - patch = tSLInformation.sBootLoaderPatches(&ucLength); - - if (patch) - { - hci_patch_send(HCI_EVENT_PATCHES_BOOTLOAD_REQ, - tSLInformation.pucTxCommandBuffer, - patch, ucLength); - return; - } - } - - /* Send 0 length Patches response event */ - - hci_patch_send(HCI_EVENT_PATCHES_BOOTLOAD_REQ, - tSLInformation.pucTxCommandBuffer, 0, 0); - break; - } -} - -/**************************************************************************** - * Name: hci_event_handler - * - * Description: - * Parse the incoming events packets and issues corresponding event handler - * from global array of handlers pointers - * - * Input Parameters: - * pRetParams incoming data buffer - * from from information (in case of data received) - * fromlen from information length (in case of data received) - * - * Returned Value: - * None - * - ****************************************************************************/ - -uint8_t *hci_event_handler(void *pRetParams, uint8_t *from, uint8_t *fromlen) -{ - uint8_t *pucReceivedData, ucArgsize; - uint16_t usLength; - uint8_t *pucReceivedParams; - uint16_t usReceivedEventOpcode = 0; - unsigned long retValue32; - uint8_t * RecvParams; - uint8_t *RetParams; - - while (1) - { - if (tSLInformation.usEventOrDataReceived != 0) - { - pucReceivedData = (tSLInformation.pucReceivedData); - - if (*pucReceivedData == HCI_TYPE_EVNT) - { - /* Event Received */ - - STREAM_TO_UINT16((char *)pucReceivedData, - HCI_EVENT_OPCODE_OFFSET, - usReceivedEventOpcode); - - pucReceivedParams = pucReceivedData + HCI_EVENT_HEADER_SIZE; - RecvParams = pucReceivedParams; - RetParams = (uint8_t *)pRetParams; - - /* In case unsolicited event received - here the handling finished */ - - if (hci_unsol_event_handler((char *)pucReceivedData) == 0) - { - STREAM_TO_UINT8(pucReceivedData, HCI_DATA_LENGTH_OFFSET, usLength); - - switch (usReceivedEventOpcode) - { - case HCI_CMND_READ_BUFFER_SIZE: - { - STREAM_TO_UINT8((char *)pucReceivedParams, 0, - tSLInformation.usNumberOfFreeBuffers); - STREAM_TO_UINT16((char *)pucReceivedParams, 1, - tSLInformation.usSlBufferLength); - } - break; - - case HCI_CMND_WLAN_CONFIGURE_PATCH: - case HCI_NETAPP_DHCP: - case HCI_NETAPP_PING_SEND: - case HCI_NETAPP_PING_STOP: - case HCI_NETAPP_ARP_FLUSH: - case HCI_NETAPP_SET_DEBUG_LEVEL: - case HCI_NETAPP_SET_TIMERS: - case HCI_EVNT_NVMEM_READ: - case HCI_EVNT_NVMEM_CREATE_ENTRY: - case HCI_CMND_NVMEM_WRITE_PATCH: - case HCI_NETAPP_PING_REPORT: - case HCI_EVNT_MDNS_ADVERTISE: - - STREAM_TO_UINT8(pucReceivedData, HCI_EVENT_STATUS_OFFSET, - *(uint8_t *)pRetParams); - break; - - case HCI_CMND_SETSOCKOPT: - case HCI_CMND_WLAN_CONNECT: - case HCI_CMND_WLAN_IOCTL_STATUSGET: - case HCI_EVNT_WLAN_IOCTL_ADD_PROFILE: - case HCI_CMND_WLAN_IOCTL_DEL_PROFILE: - case HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY: - case HCI_CMND_WLAN_IOCTL_SET_SCANPARAM: - case HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START: - case HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP: - case HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX: - case HCI_CMND_EVENT_MASK: - case HCI_EVNT_WLAN_DISCONNECT: - case HCI_EVNT_SOCKET: - case HCI_EVNT_BIND: - case HCI_CMND_LISTEN: - case HCI_EVNT_CLOSE_SOCKET: - case HCI_EVNT_CONNECT: - case HCI_EVNT_NVMEM_WRITE: - - STREAM_TO_UINT32((char *)pucReceivedParams, 0, - *(unsigned long *)pRetParams); - break; - - case HCI_EVNT_READ_SP_VERSION: - - STREAM_TO_UINT8(pucReceivedData, HCI_EVENT_STATUS_OFFSET, - *(uint8_t *)pRetParams); - pRetParams = ((char *)pRetParams) + 1; - STREAM_TO_UINT32((char *)pucReceivedParams, 0, retValue32); - UINT32_TO_STREAM((uint8_t *)pRetParams, retValue32); - break; - - case HCI_EVNT_BSD_GETHOSTBYNAME: - - STREAM_TO_UINT32((char *)pucReceivedParams, - GET_HOST_BY_NAME_RETVAL_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 4; - STREAM_TO_UINT32((char *)pucReceivedParams, - GET_HOST_BY_NAME_ADDR_OFFSET, - *(unsigned long *)pRetParams); - break; - - case HCI_EVNT_ACCEPT: - { - STREAM_TO_UINT32((char *)pucReceivedParams, - ACCEPT_SD_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 4; - STREAM_TO_UINT32((char *)pucReceivedParams, - ACCEPT_RETURN_STATUS_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 4; - - /* This argument returns in network order */ - - memcpy((uint8_t *)pRetParams, - pucReceivedParams + ACCEPT_ADDRESS__OFFSET, - sizeof(struct sockaddr)); - } - break; - - case HCI_EVNT_RECV: - case HCI_EVNT_RECVFROM: - { - STREAM_TO_UINT32((char *)pucReceivedParams, - SL_RECEIVE_SD_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 4; - STREAM_TO_UINT32((char *)pucReceivedParams, - SL_RECEIVE_NUM_BYTES_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 4; - STREAM_TO_UINT32((char *)pucReceivedParams, - SL_RECEIVE__FLAGS__OFFSET, - *(unsigned long *)pRetParams); - - if (((tBsdReadReturnParams *)pRetParams)->iNumberOfBytes == - ERROR_SOCKET_INACTIVE) - { - set_socket_active_status - (((tBsdReadReturnParams *)pRetParams)->iSocketDescriptor, - SOCKET_STATUS_INACTIVE); - } - } - break; - - case HCI_EVNT_SEND: - case HCI_EVNT_SENDTO: - { - STREAM_TO_UINT32((char *)pucReceivedParams, - SL_RECEIVE_SD_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 4; - STREAM_TO_UINT32((char *)pucReceivedParams, - SL_RECEIVE_NUM_BYTES_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 4; - } - break; - - case HCI_EVNT_SELECT: - { - STREAM_TO_UINT32((char *)pucReceivedParams, - SELECT_STATUS_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 4; - STREAM_TO_UINT32((char *)pucReceivedParams, - SELECT_READFD_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 4; - STREAM_TO_UINT32((char *)pucReceivedParams, - SELECT_WRITEFD_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 4; - STREAM_TO_UINT32((char *)pucReceivedParams, - SELECT_EXFD_OFFSET, - *(unsigned long *)pRetParams); - } - break; - - case HCI_CMND_GETSOCKOPT: - - STREAM_TO_UINT8(pucReceivedData, HCI_EVENT_STATUS_OFFSET, - ((tBsdGetSockOptReturnParams *)pRetParams)->iStatus); - - /* This argument returns in network order */ - - memcpy((uint8_t *)pRetParams, pucReceivedParams, 4); - break; - - case HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS: - - STREAM_TO_UINT32((char *)pucReceivedParams, - GET_SCAN_RESULTS_TABlE_COUNT_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 4; - STREAM_TO_UINT32((char *)pucReceivedParams, - GET_SCAN_RESULTS_SCANRESULT_STATUS_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 4; - - STREAM_TO_UINT16((char *)pucReceivedParams, - GET_SCAN_RESULTS_ISVALID_TO_SSIDLEN_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 2; - STREAM_TO_UINT16((char *)pucReceivedParams, - GET_SCAN_RESULTS_FRAME_TIME_OFFSET, - *(unsigned long *)pRetParams); - pRetParams = ((char *)pRetParams) + 2; - memcpy((uint8_t *)pRetParams, - (char *)(pucReceivedParams + - GET_SCAN_RESULTS_FRAME_TIME_OFFSET + 2), - GET_SCAN_RESULTS_SSID_MAC_LENGTH); - break; - - case HCI_CMND_SIMPLE_LINK_START: - break; - - case HCI_NETAPP_IPCONFIG: - - /* Read IP address */ - - STREAM_TO_STREAM(RecvParams, RetParams, NETAPP_IPCONFIG_IP_LENGTH); - RecvParams += 4; - - /* Read subnet */ - - STREAM_TO_STREAM(RecvParams, RetParams, NETAPP_IPCONFIG_IP_LENGTH); - RecvParams += 4; - - /* Read default GW */ - - STREAM_TO_STREAM(RecvParams, RetParams, NETAPP_IPCONFIG_IP_LENGTH); - RecvParams += 4; - - /* Read DHCP server */ - - STREAM_TO_STREAM(RecvParams, RetParams, NETAPP_IPCONFIG_IP_LENGTH); - RecvParams += 4; - - /* Read DNS server */ - - STREAM_TO_STREAM(RecvParams, RetParams, NETAPP_IPCONFIG_IP_LENGTH); - RecvParams += 4; - - /* Read Mac address */ - - STREAM_TO_STREAM(RecvParams, RetParams, NETAPP_IPCONFIG_MAC_LENGTH); - RecvParams += 6; - - /* Read SSID */ - - STREAM_TO_STREAM(RecvParams, RetParams, NETAPP_IPCONFIG_SSID_LENGTH); - break; - - default: - PANIC(); - break; - } - } - - if (usReceivedEventOpcode == tSLInformation.usRxEventOpcode) - { - tSLInformation.usRxEventOpcode = 0; - } - } - else - { - pucReceivedParams = pucReceivedData; - STREAM_TO_UINT8((char *)pucReceivedData, - HCI_PACKET_ARGSIZE_OFFSET, ucArgsize); - - STREAM_TO_UINT16((char *)pucReceivedData, - HCI_PACKET_LENGTH_OFFSET, usLength); - - /* Data received: note that the only case where from and from length - * are not null is in recv from, so fill the args accordingly - */ - - if (from) - { - STREAM_TO_UINT32((char *)(pucReceivedData + HCI_DATA_HEADER_SIZE), - BSD_RECV_FROM_FROMLEN_OFFSET, - *(unsigned long *)fromlen); - memcpy(from, - (pucReceivedData + HCI_DATA_HEADER_SIZE + BSD_RECV_FROM_FROM_OFFSET), - *fromlen); - } - - memcpy(pRetParams, pucReceivedParams + HCI_DATA_HEADER_SIZE + ucArgsize, - usLength - ucArgsize); - - if (fromlen) - { - *fromlen = usLength - ucArgsize; - } - - tSLInformation.usRxDataPending = 0; - } - - tSLInformation.usEventOrDataReceived = 0; - - cc3000_resume(); - - /* Since we are going to TX - we need to handle this event after the - * ResumeSPi since we need interrupts - */ - - if ((*pucReceivedData == HCI_TYPE_EVNT) && - (usReceivedEventOpcode == HCI_EVNT_PATCHES_REQ)) - { - hci_unsol_handle_patch_request((char *)pucReceivedData); - } - - if ((tSLInformation.usRxEventOpcode == 0) && - (tSLInformation.usRxDataPending == 0)) - { - break; - } - } - } - - return NULL; -} - -/**************************************************************************** - * Name: hci_unsol_event_handler - * - * Description: - * Handle unsolicited events - * - * Input Parameters: - * event_hdr event header - * - * Returned Value: - * 1 if event supported and handled - * 0 if event is not supported - * - ****************************************************************************/ - -long hci_unsol_event_handler(char *event_hdr) -{ - char * data = NULL; - long event_type; - unsigned long NumberOfReleasedPackets; - unsigned long NumberOfSentPackets; - - STREAM_TO_UINT16(event_hdr, HCI_EVENT_OPCODE_OFFSET, event_type); - - if (event_type == HCI_EVNT_PATCHES_REQ) - { - hci_unsol_handle_patch_request(event_hdr); - } - - if (event_type & HCI_EVNT_UNSOL_BASE) - { - switch (event_type) - { - case HCI_EVNT_DATA_UNSOL_FREE_BUFF: - { - hci_event_unsol_flowcontrol_handler(event_hdr); - - NumberOfReleasedPackets = tSLInformation.NumberOfReleasedPackets; - NumberOfSentPackets = tSLInformation.NumberOfSentPackets; - - if (NumberOfReleasedPackets == NumberOfSentPackets) - { - if (tSLInformation.InformHostOnTxComplete) - { - tSLInformation.sWlanCB(HCI_EVENT_CC3000_CAN_SHUT_DOWN, NULL, 0); - } - } - - return 1; - } - } - } - - if (event_type & HCI_EVNT_WLAN_UNSOL_BASE) - { - switch (event_type) - { - case HCI_EVNT_WLAN_KEEPALIVE: - case HCI_EVNT_WLAN_UNSOL_CONNECT: - case HCI_EVNT_WLAN_UNSOL_DISCONNECT: - case HCI_EVNT_WLAN_UNSOL_INIT: - case HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE: - - if (tSLInformation.sWlanCB) - { - tSLInformation.sWlanCB(event_type, 0, 0); - } - break; - - case HCI_EVNT_WLAN_UNSOL_DHCP: - { - uint8_t params[NETAPP_IPCONFIG_MAC_OFFSET + 1]; /* Extra byte is for the status */ - uint8_t *recParams = params; - - data = (FAR char *)(event_hdr) + HCI_EVENT_HEADER_SIZE; - - /* Read IP address */ - - STREAM_TO_STREAM(data, recParams, NETAPP_IPCONFIG_IP_LENGTH); - data += 4; - - /* Read subnet */ - - STREAM_TO_STREAM(data, recParams, NETAPP_IPCONFIG_IP_LENGTH); - data += 4; - - /* Read default GW */ - - STREAM_TO_STREAM(data, recParams, NETAPP_IPCONFIG_IP_LENGTH); - data += 4; - - /* Read DHCP server */ - - STREAM_TO_STREAM(data, recParams, NETAPP_IPCONFIG_IP_LENGTH); - data += 4; - - /* Read DNS server */ - - STREAM_TO_STREAM(data, recParams, NETAPP_IPCONFIG_IP_LENGTH); - - /* Read the status */ - - STREAM_TO_UINT8(event_hdr, HCI_EVENT_STATUS_OFFSET, *recParams); - - if (tSLInformation.sWlanCB) - { - tSLInformation.sWlanCB(event_type, (char *)params, sizeof(params)); - } - } - break; - - case HCI_EVNT_WLAN_ASYNC_PING_REPORT: - { - netapp_pingreport_args_t params; - data = (FAR char *)(event_hdr) + HCI_EVENT_HEADER_SIZE; - STREAM_TO_UINT32(data, NETAPP_PING_PACKETS_SENT_OFFSET, params.packets_sent); - STREAM_TO_UINT32(data, NETAPP_PING_PACKETS_RCVD_OFFSET, params.packets_received); - STREAM_TO_UINT32(data, NETAPP_PING_MIN_RTT_OFFSET, params.min_round_time); - STREAM_TO_UINT32(data, NETAPP_PING_MAX_RTT_OFFSET, params.max_round_time); - STREAM_TO_UINT32(data, NETAPP_PING_AVG_RTT_OFFSET, params.avg_round_time); - - if (tSLInformation.sWlanCB) - { - tSLInformation.sWlanCB(event_type, (char *)¶ms, sizeof(params)); - } - } - break; - - case HCI_EVNT_BSD_TCP_CLOSE_WAIT: - { - int sockfd; - - data = (FAR char *)(event_hdr) + HCI_EVENT_HEADER_SIZE; - STREAM_TO_UINT32(data, NETAPP_PING_PACKETS_SENT_OFFSET, sockfd); - data += 4; - - (void)cc3000_remote_closed_socket(sockfd); - - if (tSLInformation.sWlanCB) - { - tSLInformation.sWlanCB(event_type, NULL, 0); - } - } - break; - - /* 'default' case which means "event not supported" */ - - default: - return 0; - } - - return 1; - } - - if ((event_type == HCI_EVNT_SEND) || (event_type == HCI_EVNT_SENDTO) || - (event_type == HCI_EVNT_WRITE)) - { - char *pArg; - long status; - - pArg = M_BSD_RESP_PARAMS_OFFSET(event_hdr); - STREAM_TO_UINT32(pArg, BSD_RSP_PARAMS_STATUS_OFFSET, status); - - if (ERROR_SOCKET_INACTIVE == status) - { - /* The only synchronous event that can come from SL device in form of - * command complete is "Command Complete" on data sent, in case SL device - * was unable to transmit - */ - - STREAM_TO_UINT8(event_hdr, HCI_EVENT_STATUS_OFFSET, - tSLInformation.slTransmitDataError); - update_socket_active_status(M_BSD_RESP_PARAMS_OFFSET(event_hdr)); - - return 1; - } - else - { - return 0; - } - } - - return 0; -} - -/**************************************************************************** - * Name: hci_unsolicited_event_handler - * - * Description: - * Parse the incoming unsolicited event packets and issues corresponding - * event handler. - * - * Input Parameters: - * None - * - * Returned Value: - * ESUCCESS if successful, EFAIL if an error occurred - * - ****************************************************************************/ - -long hci_unsolicited_event_handler(void) -{ - unsigned long res = 0; - uint8_t *pucReceivedData; - - if (tSLInformation.usEventOrDataReceived != 0) - { - pucReceivedData = (tSLInformation.pucReceivedData); - - if (*pucReceivedData == HCI_TYPE_EVNT) - { - /* In case unsolicited event received - here the handling finished */ - - if (hci_unsol_event_handler((char *)pucReceivedData) == 1) - { - /* There was an unsolicited event received - we can release the buffer - * and clean the event received - */ - - tSLInformation.usEventOrDataReceived = 0; - - res = 1; - cc3000_resume(); - } - } - } - - return res; -} - -/**************************************************************************** - * Name: set_socket_active_status - * - * Description: - * Check if the socket ID and status are valid and set accordingly the - * global socket status - * - * Input Parameters: - * Sd - * Status - * - * Returned Value: - * None - * - ****************************************************************************/ - -void set_socket_active_status(long Sd, long Status) -{ - if (M_IS_VALID_SD(Sd) && M_IS_VALID_STATUS(Status)) - { - socket_active_status &= ~(1 << Sd); /* Clean socket's mask */ - socket_active_status |= (Status << Sd); /* Set new socket's mask */ - } -} - -/**************************************************************************** - * Name: hci_event_unsol_flowcontrol_handler - * - * Description: - * Called in case unsolicited event from type HCI_EVNT_DATA_UNSOL_FREE_BUFF - * has received. Keep track on the number of packets transmitted and update - * the number of free buffer in the SL device. - * - * Input Parameters: - * pEvent pointer to the string contains parameters for IPERF - * - * Returned Value: - * ESUCCESS if successful, EFAIL if an error occurred - * - ****************************************************************************/ - -long hci_event_unsol_flowcontrol_handler(char *pEvent) -{ - long temp, value; - uint16_t i; - uint16_t pusNumberOfHandles = 0; - char *pReadPayload; - - STREAM_TO_UINT16((char *)pEvent, HCI_EVENT_HEADER_SIZE, pusNumberOfHandles); - pReadPayload = ((char *)pEvent + - HCI_EVENT_HEADER_SIZE + sizeof(pusNumberOfHandles)); - temp = 0; - - for (i = 0; i < pusNumberOfHandles ; i++) - { - STREAM_TO_UINT16(pReadPayload, FLOW_CONTROL_EVENT_FREE_BUFFS_OFFSET, value); - temp += value; - pReadPayload += FLOW_CONTROL_EVENT_SIZE; - } - - tSLInformation.usNumberOfFreeBuffers += temp; - tSLInformation.NumberOfReleasedPackets += temp; - - return(ESUCCESS); -} - -/**************************************************************************** - * Name: get_socket_active_status - * - * Description: - * Retrieve socket status - * - * Input Parameters: - * Sd Socket IS - * - * Returned Value: - * Current status of the socket. - * - ****************************************************************************/ - -long get_socket_active_status(long Sd) -{ - if (M_IS_VALID_SD(Sd)) - { - return (socket_active_status & (1 << Sd)) ? - SOCKET_STATUS_INACTIVE : SOCKET_STATUS_ACTIVE; - } - - return SOCKET_STATUS_INACTIVE; -} - -/**************************************************************************** - * Name: update_socket_active_status - * - * Description: - * Retrieve socket status - * - * Input Parameters: - * resp_params Socket IS - * - * Returned Value: - * Current status of the socket. - * - ****************************************************************************/ - -void update_socket_active_status(char *resp_params) -{ - long status, sd; - - STREAM_TO_UINT32(resp_params, BSD_RSP_PARAMS_SOCKET_OFFSET, sd); - STREAM_TO_UINT32(resp_params, BSD_RSP_PARAMS_STATUS_OFFSET, status); - - if (ERROR_SOCKET_INACTIVE == status) - { - set_socket_active_status(sd, SOCKET_STATUS_INACTIVE); - } -} - -/**************************************************************************** - * Name: SimpleLinkWaitEvent - * - * Description: - * Wait for event, pass it to the hci_event_handler and update the event - * opcode in a global variable. - * - * Input Parameters: - * opcode command operation code - * pRetParams command return parameters - * - * Returned Value: - * None - * - ****************************************************************************/ - -void SimpleLinkWaitEvent(uint16_t opcode, void *pRetParams) -{ - /* In the blocking implementation the control to caller will be returned only - * after the end of current transaction - */ - - tSLInformation.usRxEventOpcode = opcode; - ninfo("Looking for opcode 0x%x\n", opcode); - uint16_t event_type; - - do - { - ninfo("cc3000_wait\n"); - tSLInformation.pucReceivedData = cc3000_wait(); - tSLInformation.usEventOrDataReceived = 1; - STREAM_TO_UINT16((FAR char *)tSLInformation.pucReceivedData, - HCI_EVENT_OPCODE_OFFSET, event_type); - - if (*tSLInformation.pucReceivedData == HCI_TYPE_EVNT) - { - ninfo("Evtn:0x%x\n", event_type); - } - - if (event_type != opcode) - { - if (hci_unsolicited_event_handler() == 1) - { - ninfo("Processed Event 0x%x want 0x%x\n", event_type, opcode); - } - } - else - { - ninfo("Processing opcode 0x%x\n", opcode); - hci_event_handler(pRetParams, 0, 0); - } - } - while (tSLInformation.usRxEventOpcode != 0); - - ninfo("Done for opcode 0x%x\n", opcode); -} - -/**************************************************************************** - * Name: SimpleLinkWaitData - * - * Description: - * Wait for data, pass it to the hci_event_handler and update in a global - * variable that there is data to read. - * - * Input Parameters: - * pBuf data buffer - * from from information - * fromlen from information length - * - * Returned Value: - * None - * - ****************************************************************************/ - -void SimpleLinkWaitData(uint8_t *pBuf, uint8_t *from, uint8_t *fromlen) -{ - /* In the blocking implementation the control to caller will be returned only - * after the end of current transaction, i.e. only after data will be received - */ - - ninfo("Looking for Data\n"); - uint16_t event_type; - uint16_t opcode = tSLInformation.usRxEventOpcode; - - do - { - tSLInformation.pucReceivedData = cc3000_wait(); - tSLInformation.usEventOrDataReceived = 1; - - if (*tSLInformation.pucReceivedData == HCI_TYPE_DATA) - { - tSLInformation.usRxDataPending = 1; - hci_event_handler(pBuf, from, fromlen); - break; - } - else - { - STREAM_TO_UINT16((char *)tSLInformation.pucReceivedData, HCI_EVENT_OPCODE_OFFSET, event_type); - ninfo("Evtn:0x%x\n", event_type); - - if (hci_unsolicited_event_handler() == 1) - { - ninfo("Processed Event 0x%x want Data! Opcode 0x%x\n", event_type, opcode); - } - else - { - ninfo("!!!!!opcode 0x%x\n", opcode); - } - - UNUSED(event_type); - } - } - while (*tSLInformation.pucReceivedData == HCI_TYPE_EVNT); - - ninfo("Done for Data 0x%x\n", opcode); - UNUSED(opcode); -} diff --git a/drivers/wireless/cc3000/hci.c b/drivers/wireless/cc3000/hci.c deleted file mode 100644 index 9d07450943..0000000000 --- a/drivers/wireless/cc3000/hci.c +++ /dev/null @@ -1,249 +0,0 @@ -/**************************************************************************** - * drivers/wireless/cc3000/hci.c - CC3000 Host Driver Implementation. - * - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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 - -#include -#include - -#include -#include -#include "cc3000drv.h" -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define SL_PATCH_PORTION_SIZE (1000) - -/**************************************************************************** - * Public Functions - ****************************************************************************/ -/**************************************************************************** - * Name: hci_command_send - * - * Description: - * Initiate an HCI command. - * - * Input Parameters: - * usOpcode command operation code - * pucBuff pointer to the command's arguments buffer - * ucArgsLength length of the arguments - * - * Returned Value: - * Zero - * - ****************************************************************************/ - -uint16_t hci_command_send(uint16_t usOpcode, uint8_t *pucBuff, - uint8_t ucArgsLength) -{ - uint8_t *stream; - - stream = (pucBuff + SPI_HEADER_SIZE); - - ninfo("Send 0x%x\n", usOpcode); - UINT8_TO_STREAM(stream, HCI_TYPE_CMND); - stream = UINT16_TO_STREAM(stream, usOpcode); - UINT8_TO_STREAM(stream, ucArgsLength); - - /* Update the opcode of the event we will be waiting for */ - - cc3000_write(pucBuff, ucArgsLength + SIMPLE_LINK_HCI_CMND_HEADER_SIZE); - ninfo("Send of 0x%x Completed\n", usOpcode); - - return 0; -} - -/**************************************************************************** - * Name: hci_data_send - * - * Description: - * - * - * Input Parameters: - * usOpcode command operation code - * ucArgs pointer to the command's arguments buffer - * usArgsLength length of the arguments - * ucTail pointer to the data buffer - * usTailLength buffer length - * - * Returned Value: - * None - * - ****************************************************************************/ - -long hci_data_send(uint8_t ucOpcode, uint8_t *ucArgs, uint16_t usArgsLength, - uint16_t usDataLength, const uint8_t *ucTail, - uint16_t usTailLength) -{ - uint8_t *stream; - - stream = ((ucArgs) + SPI_HEADER_SIZE); - - UINT8_TO_STREAM(stream, HCI_TYPE_DATA); - UINT8_TO_STREAM(stream, ucOpcode); - UINT8_TO_STREAM(stream, usArgsLength); - stream = UINT16_TO_STREAM(stream, usArgsLength + usDataLength + usTailLength); - - /* Send the packet over the SPI */ - - cc3000_write(ucArgs, - SIMPLE_LINK_HCI_DATA_HEADER_SIZE + usArgsLength + - usDataLength + usTailLength); - - return ESUCCESS; -} - -/**************************************************************************** - * Name: hci_data_command_send - * - * Description: - * Prepeare HCI header and initiate an HCI data write operation - * - * Input Parameters: - * usOpcode command operation code - * pucBuff pointer to the data buffer - * ucArgsLength arguments length - * ucDataLength data length - * - * Returned Value: - * None - * - ****************************************************************************/ - -void hci_data_command_send(uint16_t usOpcode, uint8_t *pucBuff, - uint8_t ucArgsLength, uint16_t ucDataLength) -{ - uint8_t *stream = (pucBuff + SPI_HEADER_SIZE); - - UINT8_TO_STREAM(stream, HCI_TYPE_DATA); - UINT8_TO_STREAM(stream, usOpcode); - UINT8_TO_STREAM(stream, ucArgsLength); - stream = UINT16_TO_STREAM(stream, ucArgsLength + ucDataLength); - - /* Send the command over SPI on data channel */ - - cc3000_write(pucBuff, - ucArgsLength + ucDataLength + - SIMPLE_LINK_HCI_DATA_CMND_HEADER_SIZE); -} - -/**************************************************************************** - * Name: hci_patch_send - * - * Description: - * Prepeare HCI header and initiate an HCI patch write operation - * - * Input Parameters: - * usOpcode command operation code - * pucBuff pointer to the command's arguments buffer - * patch pointer to patch content buffer - * usDataLength data length - * - * Returned Value: - * None - * - ****************************************************************************/ - -void hci_patch_send(uint8_t ucOpcode, uint8_t *pucBuff, char *patch, - uint16_t usDataLength) -{ - uint8_t *data_ptr = (pucBuff + SPI_HEADER_SIZE); - uint16_t usTransLength; - uint8_t *stream = (pucBuff + SPI_HEADER_SIZE); - - UINT8_TO_STREAM(stream, HCI_TYPE_PATCH); - UINT8_TO_STREAM(stream, ucOpcode); - stream = UINT16_TO_STREAM(stream, - usDataLength + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE); - - if (usDataLength <= SL_PATCH_PORTION_SIZE) - { - UINT16_TO_STREAM(stream, usDataLength); - stream = UINT16_TO_STREAM(stream, usDataLength); - memcpy((pucBuff + SPI_HEADER_SIZE) + HCI_PATCH_HEADER_SIZE, patch, - usDataLength); - - /* Update the opcode of the event we will be waiting for */ - - cc3000_write(pucBuff, usDataLength + HCI_PATCH_HEADER_SIZE); - } - else - { - usTransLength = (usDataLength/SL_PATCH_PORTION_SIZE); - UINT16_TO_STREAM(stream, - usDataLength + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE + - usTransLength*SIMPLE_LINK_HCI_PATCH_HEADER_SIZE); - stream = UINT16_TO_STREAM(stream, SL_PATCH_PORTION_SIZE); - memcpy(pucBuff + SPI_HEADER_SIZE + HCI_PATCH_HEADER_SIZE, patch, - SL_PATCH_PORTION_SIZE); - usDataLength -= SL_PATCH_PORTION_SIZE; - patch += SL_PATCH_PORTION_SIZE; - - /* Update the opcode of the event we will be waiting for */ - - cc3000_write(pucBuff, SL_PATCH_PORTION_SIZE + HCI_PATCH_HEADER_SIZE); - - while (usDataLength) - { - if (usDataLength <= SL_PATCH_PORTION_SIZE) - { - usTransLength = usDataLength; - usDataLength = 0; - } - else - { - usTransLength = SL_PATCH_PORTION_SIZE; - usDataLength -= usTransLength; - } - - *(uint16_t *)data_ptr = usTransLength; - memcpy(data_ptr + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE, patch, - usTransLength); - patch += usTransLength; - - /* Update the opcode of the event we will be waiting for */ - - cc3000_write((uint8_t *)data_ptr, usTransLength + sizeof(usTransLength)); - } - } -} diff --git a/drivers/wireless/cc3000/host_driver_version.h b/drivers/wireless/cc3000/host_driver_version.h deleted file mode 100644 index e191ba1ae0..0000000000 --- a/drivers/wireless/cc3000/host_driver_version.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -* -* host_driver_version.h - CC3000 Host Driver Implementation. -* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* 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. -* -* Neither the name of Texas Instruments Incorporated 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_CC3000_HOST_DRIVER_VERSION_H -#define __DRIVERS_WIRELESS_CC3000_HOST_DRIVER_VERSION_H - -#define DRIVER_VERSION_NUMBER 13 - -#endif /* __DRIVERS_WIRELESS_CC3000_HOST_DRIVER_VERSION_H */ diff --git a/drivers/wireless/cc3000/netapp.c b/drivers/wireless/cc3000/netapp.c deleted file mode 100644 index 648ecb1b89..0000000000 --- a/drivers/wireless/cc3000/netapp.c +++ /dev/null @@ -1,541 +0,0 @@ -/**************************************************************************** - * drivers/wireless/cc3000/netapp.c - CC3000 Host Driver Implementation. - * - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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 - -#include -#include -#include -#include - -#include "cc3000.h" -#include "cc3000_socket.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define MIN_TIMER_VAL_SECONDS 20 -#define MIN_TIMER_SET(t) if ((0 != t) && (t < MIN_TIMER_VAL_SECONDS)) \ - { \ - t = MIN_TIMER_VAL_SECONDS; \ - } - - -#define NETAPP_DHCP_PARAMS_LEN (20) -#define NETAPP_SET_TIMER_PARAMS_LEN (20) -#define NETAPP_SET_DEBUG_LEVEL_PARAMS_LEN (4) -#define NETAPP_PING_SEND_PARAMS_LEN (16) - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: netapp_config_mac_adrress - * - * Description: - * Configure device MAC address and store it in NVMEM. The value of the MAC - * address configured through the API will be stored in CC3000 non volatile - * memory, thus preserved over resets. - * - * Input Parameters: - * mac device mac address, 6 bytes. Saved: yes - * - * Returned Value: - * Return on success 0, otherwise error. - * - ****************************************************************************/ - -long netapp_config_mac_adrress(uint8_t *mac) -{ - return nvmem_set_mac_address(mac); -} - -/**************************************************************************** - * Name: netapp_dhcp - * - * Description: - * netapp_dhcp is used to configure the network interface, static or - * dynamic (DHCP).\n In order to activate DHCP mode, aucIP, aucSubnetMask, - * aucDefaultGateway must be 0. The default mode of CC3000 is DHCP mode. Note - * that the configuration is saved in non volatile memory and thus preserved - * over resets. - * - * NOTE: If the mode is altered a reset of CC3000 device is required in order - * to apply changes.\nAlso note that asynchronous event of DHCP_EVENT, which - * is generated when an IP address is allocated either by the DHCP server or - * due to static allocation is generated only upon a connection to the AP was - * established. - * - * Input Parameters: - * aucIP device mac address, 6 bytes. Saved: yes - * aucSubnetMask device mac address, 6 bytes. Saved: yes - * aucDefaultGateway device mac address, 6 bytes. Saved: yes - * aucDNSServer device mac address, 6 bytes. Saved: yes - * - * Returned Value: - * Return on success 0, otherwise error. - * - ****************************************************************************/ - -long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask, - unsigned long *aucDefaultGateway, unsigned long *aucDNSServer) -{ - int8_t scRet; - uint8_t *ptr; - uint8_t *args; - - cc3000_lib_lock(); - - scRet = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in temporary command buffer */ - - ARRAY_TO_STREAM(args, aucIP, 4); - ARRAY_TO_STREAM(args, aucSubnetMask, 4); - ARRAY_TO_STREAM(args, aucDefaultGateway, 4); - args = UINT32_TO_STREAM(args, 0); - ARRAY_TO_STREAM(args, aucDNSServer, 4); - - /* Initiate a HCI command */ - - hci_command_send(HCI_NETAPP_DHCP, ptr, NETAPP_DHCP_PARAMS_LEN); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_NETAPP_DHCP, &scRet); - - cc3000_lib_unlock(); - - return(scRet); -} - -/**************************************************************************** - * Name: netapp_timeout_values - * - * Description: - * Set new timeout values. Function set new timeout values for: DHCP lease - * timeout, ARP refresh timeout, keepalive event timeout and socket - * inactivity timeout - * - * NOTE: If a parameter set to non zero value which is less than 20s, it will - * be set automatically to 20s. - * - * Input Parameters: - * aucDHCP DHCP lease time request, also impact the DHCP renew timeout. - * Range: [0-0xffffffff] seconds, 0 or 0xffffffff == infinity - * lease timeout. - * Resolution: 10 seconds. - * Influence: only after reconnecting to the AP - * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds. - * The parameter is saved into the CC3000 NVMEM. The default - * value on CC3000 is 14400 seconds. - * aucARP ARP refresh timeout, if ARP entry is not updated by incoming - * packet, the ARP entry will be deleted by the end of the - * timeout. - * Range: [0-0xffffffff] seconds, 0 == infinity ARP timeout - * Resolution: 10 seconds. - * Influence: on runtime. - * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds. - * The parameter is saved into the CC3000 NVMEM. The default - * value on CC3000 is 3600 seconds. - * aucKeepalive Keepalive event sent by the end of keepalive timeout - * Range: [0-0xffffffff] seconds, 0 == infinity timeout - * Resolution: 10 seconds. - * Influence: on runtime. - * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec - * The parameter is saved into the CC3000 NVMEM. The default - * value on CC3000 is 10 seconds. - * aucInactivity Socket inactivity timeout, socket timeout is refreshed by - * incoming or outgoing packet, by the end of the socket - * timeout the socket will be closed - * Range: [0-0xffffffff] sec, 0 == infinity timeout. - * Resolution: 10 seconds. Influence: on runtime. - * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec - * The parameter is saved into the CC3000 NVMEM. The default - * value on CC3000 is 60 seconds. - * - * Returned Value: - * Return on success 0, otherwise error. - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long netapp_timeout_values(unsigned long *aucDHCP, unsigned long *aucARP, - unsigned long *aucKeepalive, - unsigned long *aucInactivity) -{ - int8_t scRet; - uint8_t *ptr; - uint8_t *args; - - cc3000_lib_lock(); - - scRet = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Set minimal values of timers */ - - MIN_TIMER_SET(*aucDHCP) - MIN_TIMER_SET(*aucARP) - MIN_TIMER_SET(*aucKeepalive) - MIN_TIMER_SET(*aucInactivity) - - /* Fill in temporary command buffer */ - - args = UINT32_TO_STREAM(args, *aucDHCP); - args = UINT32_TO_STREAM(args, *aucARP); - args = UINT32_TO_STREAM(args, *aucKeepalive); - args = UINT32_TO_STREAM(args, *aucInactivity); - - /* Initiate a HCI command */ - - hci_command_send(HCI_NETAPP_SET_TIMERS, ptr, NETAPP_SET_TIMER_PARAMS_LEN); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_NETAPP_SET_TIMERS, &scRet); - - cc3000_lib_unlock(); - - return scRet; -} -#endif - -/**************************************************************************** - * Name: netapp_ping_send - * - * Description: - * Send ICMP ECHO_REQUEST to network hosts - * - * NOTE: If an operation finished successfully asynchronous ping report event - * will be generated. The report structure is as defined by structure - * netapp_pingreport_args_t. - * - * WARNING: Calling this function while a previous Ping Requests are in - * progress will stop the previous ping request. - * - * Input Parameters: - * ip destination IP address - * pingAttempts number of echo requests to send - * pingSize send buffer size which may be up to 1400 bytes - * pingTimeout Time to wait for a response,in milliseconds. - * - * Returned Value: - * Return on success 0, otherwise error. - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long netapp_ping_send(unsigned long *ip, unsigned long ulPingAttempts, - unsigned long ulPingSize, unsigned long ulPingTimeout) -{ - int8_t scRet; - uint8_t *ptr, *args; - - cc3000_lib_lock(); - - scRet = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in temporary command buffer */ - - args = UINT32_TO_STREAM(args, *ip); - args = UINT32_TO_STREAM(args, ulPingAttempts); - args = UINT32_TO_STREAM(args, ulPingSize); - args = UINT32_TO_STREAM(args, ulPingTimeout); - - /* Initiate a HCI command */ - - hci_command_send(HCI_NETAPP_PING_SEND, ptr, NETAPP_PING_SEND_PARAMS_LEN); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_NETAPP_PING_SEND, &scRet); - - cc3000_lib_unlock(); - - return scRet; -} -#endif - -/**************************************************************************** - * Name: netapp_ping_report - * - * Description: - * Request for ping status. This API triggers the CC3000 to send asynchronous - * events: HCI_EVNT_WLAN_ASYNC_PING_REPORT. This event will carry the report - * structure: netapp_pingreport_args_t. This structure is filled in with ping - * results up till point of triggering API. - * - * netapp_pingreport_args_t: - * packets_sent - echo sent, - * packets_received - echo reply - * min_round_time - minimum round time, - * max_round_time - max round time, - * avg_round_time - average round time - * - * NOTE: When a ping operation is not active, the returned structure fields - * are 0. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -void netapp_ping_report(void) -{ - uint8_t *ptr; - ptr = tSLInformation.pucTxCommandBuffer; - int8_t scRet; - - cc3000_lib_lock(); - - scRet = EFAIL; - - /* Initiate a HCI command */ - - hci_command_send(HCI_NETAPP_PING_REPORT, ptr, 0); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_NETAPP_PING_REPORT, &scRet); - - cc3000_lib_unlock(); -} -#endif - -/**************************************************************************** - * Name: netapp_ping_stop - * - * Description: - * Stop any ping request. - * - * Input Parameters: - * None - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long netapp_ping_stop(void) -{ - int8_t scRet; - uint8_t *ptr; - - cc3000_lib_lock(); - - scRet = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - - /* Initiate a HCI command */ - - hci_command_send(HCI_NETAPP_PING_STOP, ptr, 0); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_NETAPP_PING_STOP, &scRet); - - cc3000_lib_unlock(); - - return(scRet); -} -#endif - -/**************************************************************************** - * Name: netapp_ipconfig - * - * Description: - * Obtain the CC3000 Network interface information. Note that the information - * is available only after the WLAN connection was established. Calling this - * function before associated, will cause non-defined values to be returned. - * - * NOTE: The function is useful for figuring out the IP Configuration of the - * device when DHCP is used and for figuring out the SSID of the Wireless - * network the device is associated with. - * - * Input Parameters: - * ipconfig This argument is a pointer to a tNetappIpconfigRetArgs structure. - * This structure is filled in with the network interface configuration. - * - * tNetappIpconfigRetArgs: - * aucIP - ip address, - * aucSubnetMask - mask, - * aucDefaultGateway - default gateway address - * aucDHCPServer - dhcp server address - * aucDNSServer - dns server address - * uaMacAddr - mac - * address, uaSSID - connected AP ssid - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -void netapp_ipconfig(tNetappIpconfigRetArgs * ipconfig) -{ - uint8_t *ptr; - - cc3000_lib_lock(); - - ptr = tSLInformation.pucTxCommandBuffer; - - /* Initiate a HCI command */ - - hci_command_send(HCI_NETAPP_IPCONFIG, ptr, 0); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_NETAPP_IPCONFIG, ipconfig); - - cc3000_lib_unlock(); -} -#else -void netapp_ipconfig(tNetappIpconfigRetArgs * ipconfig) -{ -} -#endif - -/**************************************************************************** - * Name: netapp_arp_flush - * - * Description: - * Flushes ARP table - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long netapp_arp_flush(void) -{ - int8_t scRet; - uint8_t *ptr; - - - cc3000_lib_lock(); - - scRet = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - - /* Initiate a HCI command */ - - hci_command_send(HCI_NETAPP_ARP_FLUSH, ptr, 0); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_NETAPP_ARP_FLUSH, &scRet); - - cc3000_lib_unlock(); - - return scRet; -} -#endif - -/**************************************************************************** - * Name: netapp_set_debug_level - * - * Description: - * Debug messages sent via the UART debug channel, this function enable/disable - * the debug level - * - * Input Parameters: - * level debug level. Bitwise [0-8], 0(disable)or 1(enable). - * Bitwise map: - * 0 - Critical message - * 1 - information message - * 2 - core messages - * 3 - HCI messages - * 4 - Network stack messages - * 5 - wlan messages - * 6 - wlan driver messages - * 7 - epprom messages, - * 8 - general messages. - * Default: 0x13f. Saved: no - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long netapp_set_debug_level(unsigned long ulLevel) -{ - int8_t scRet; - uint8_t *ptr, *args; - - cc3000_lib_lock(); - - scRet = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in temporary command buffer */ - - args = UINT32_TO_STREAM(args, ulLevel); - - /* Initiate a HCI command */ - - hci_command_send(HCI_NETAPP_SET_DEBUG_LEVEL, ptr, NETAPP_SET_DEBUG_LEVEL_PARAMS_LEN); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_NETAPP_SET_DEBUG_LEVEL, &scRet); - - cc3000_lib_unlock(); - - return scRet; -} -#endif diff --git a/drivers/wireless/cc3000/nvmem.c b/drivers/wireless/cc3000/nvmem.c deleted file mode 100644 index 01c4b5a897..0000000000 --- a/drivers/wireless/cc3000/nvmem.c +++ /dev/null @@ -1,367 +0,0 @@ -/**************************************************************************** - * drivers/wireless/cc3000/nvmem.c - CC3000 Host Driver Implementation. - * - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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 -#include - -#include -#include -#include -#include "cc3000.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define NVMEM_READ_PARAMS_LEN (12) -#define NVMEM_CREATE_PARAMS_LEN (8) -#define NVMEM_WRITE_PARAMS_LEN (16) - -/**************************************************************************** - * Public Functions - ****************************************************************************/ -/**************************************************************************** - * Name: nvmem_read - * - * Description: - * Reads data from the file referred by the ulFileId parameter. Reads data - * from file ulOffset till length. Err if the file can't be used, is - * invalid, or if the read is out of bounds. - * - * Input Parameters: - * ulFileId nvmem file id: - * NVMEM_NVS_FILEID, NVMEM_NVS_SHADOW_FILEID, - * NVMEM_WLAN_CONFIG_FILEID, NVMEM_WLAN_CONFIG_SHADOW_FILEID, - * NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID, - * NVMEM_MAC_FILEID, NVMEM_FRONTEND_VARS_FILEID, - * NVMEM_IP_CONFIG_FILEID, NVMEM_IP_CONFIG_SHADOW_FILEID, - * NVMEM_BOOTLOADER_SP_FILEID, NVMEM_RM_FILEID, - * and user files 12-15. - * ulLength number of bytes to read - * ulOffset ulOffset in file from where to read - * buff output buffer pointer - * - * Returned Value: - * Number of bytes read, otherwise error. - * - ****************************************************************************/ - -signed long nvmem_read(unsigned long ulFileId, unsigned long ulLength, - unsigned long ulOffset, uint8_t *buff) -{ - uint8_t ucStatus = 0xff; - uint8_t *ptr; - uint8_t *args; - - cc3000_lib_lock(); - - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in HCI packet structure */ - - args = UINT32_TO_STREAM(args, ulFileId); - args = UINT32_TO_STREAM(args, ulLength); - args = UINT32_TO_STREAM(args, ulOffset); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_NVMEM_READ, ptr, NVMEM_READ_PARAMS_LEN); - SimpleLinkWaitEvent(HCI_CMND_NVMEM_READ, &ucStatus); - - /* In case there is data - read it - even if an error code is returned - * Note: It is the user responsibility to ignore the data in case of an - * error code - */ - - /* Wait for the data in a synchronous way. Here we assume that the buffer is - * big enough to store also parameters of nvmem - */ - - SimpleLinkWaitData(buff, 0, &ucStatus); - - cc3000_lib_unlock(); - - return ucStatus; -} - -/**************************************************************************** - * Name: nvmem_write - * - * Description: - * Write data to nvmem. Writes data to file referred by the ulFileId - * parameter. Writes data to file ulOffset till ulLength. The file id will be - * marked invalid till the write is done. The file entry doesn't need to be - * valid - only allocated. - * - * Input Parameters: - * ulFileId nvmem file id: - * NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID, - * NVMEM_MAC_FILEID, NVMEM_BOOTLOADER_SP_FILEID, - * and user files 12-15. - * ulLength number of bytes to write - * ulEntryOffset offset in file to start write operation from - * buff data to write - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -signed long nvmem_write(unsigned long ulFileId, unsigned long ulLength, - unsigned long ulEntryOffset, uint8_t *buff) -{ - long iRes; - uint8_t *ptr; - uint8_t *args; - - cc3000_lib_lock(); - - iRes = EFAIL; - - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + SPI_HEADER_SIZE + HCI_DATA_CMD_HEADER_SIZE); - - /* Fill in HCI packet structure */ - - args = UINT32_TO_STREAM(args, ulFileId); - args = UINT32_TO_STREAM(args, 12); - args = UINT32_TO_STREAM(args, ulLength); - args = UINT32_TO_STREAM(args, ulEntryOffset); - - memcpy((ptr + SPI_HEADER_SIZE + HCI_DATA_CMD_HEADER_SIZE + - NVMEM_WRITE_PARAMS_LEN), buff, ulLength); - - /* Initiate a HCI command but it will come on data channel */ - - hci_data_command_send(HCI_CMND_NVMEM_WRITE, ptr, NVMEM_WRITE_PARAMS_LEN, - ulLength); - - SimpleLinkWaitEvent(HCI_EVNT_NVMEM_WRITE, &iRes); - - cc3000_lib_unlock(); - - return iRes; -} - -/**************************************************************************** - * Name: nvmem_set_mac_address - * - * Description: - * Write MAC address to EEPROM. mac address as appears over the air (OUI - * first) - * - * Input Parameters: - * mac mac address to be set - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -uint8_t nvmem_set_mac_address(uint8_t *mac) -{ - return nvmem_write(NVMEM_MAC_FILEID, MAC_ADDR_LEN, 0, mac); -} - -/**************************************************************************** - * Name: nvmem_get_mac_address - * - * Description: - * Read MAC address from EEPROM. mac address as appears over the air (OUI - * first) - * - * Input Parameters: - * mac mac address - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -uint8_t nvmem_get_mac_address(uint8_t *mac) -{ - return nvmem_read(NVMEM_MAC_FILEID, MAC_ADDR_LEN, 0, mac); -} - -/**************************************************************************** - * Name: nvmem_write_patch - * - * Description: - * Program a patch to a specific file ID. The SP data is assumed to be - * organized in 2-dimensional. Each line is SP_PORTION_SIZE bytes long. - * Actual programming is applied in SP_PORTION_SIZE bytes portions. - * - * Input Parameters: - * ulFileId nvmem file id: - * NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID, - * spLength number of bytes to write - * spData SP data to write - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -uint8_t nvmem_write_patch(unsigned long ulFileId, unsigned long spLength, - const uint8_t *spData) -{ - FAR uint8_t *spDataPtr = (FAR uint8_t *)spData; - uint8_t status = 0; - uint16_t offset = 0; - - while ((status == 0) && (spLength >= SP_PORTION_SIZE)) - { - status = nvmem_write(ulFileId, SP_PORTION_SIZE, offset, spDataPtr); - offset += SP_PORTION_SIZE; - spLength -= SP_PORTION_SIZE; - spDataPtr += SP_PORTION_SIZE; - } - - if (status != 0) - { - /* NVMEM error occurred */ - - return status; - } - - if (spLength != 0) - { - /* if reached here, a reminder is left */ - - status = nvmem_write(ulFileId, spLength, offset, spDataPtr); - } - - return status; -} - -/**************************************************************************** - * Name: nvmem_read_sp_version - * - * Description: - * Read patch version. read package version (WiFi FW patch, - * driver-supplicant-NS patch, bootloader patch) - * - * Input Parameters: - * patchVer first number indicates package ID and the second - * number indicates package build number - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -uint8_t nvmem_read_sp_version(uint8_t *patchVer) -{ - uint8_t *ptr; - /* 1st byte is the status and the rest is the SP version */ - uint8_t retBuf[5]; - - cc3000_lib_lock(); - - ptr = tSLInformation.pucTxCommandBuffer; - - /* Initiate a HCI command, no args are required */ - - hci_command_send(HCI_CMND_READ_SP_VERSION, ptr, 0); - SimpleLinkWaitEvent(HCI_CMND_READ_SP_VERSION, retBuf); - - /* Package ID */ - - *patchVer = retBuf[3]; - - /* Package build number */ - - *(patchVer+1) = retBuf[4]; - - cc3000_lib_unlock(); - - return retBuf[0]; -} -#endif - -/**************************************************************************** - * Name: nvmem_create_entry - * - * Description: - * Create new file entry and allocate space on the NVMEM. Applies only to - * user files. Modify the size of file. If the entry is unallocated - - * allocate it to size ulNewLen (marked invalid). If it is allocated then - * deallocate it first. To just mark the file as invalid without resizing - - * Set ulNewLen=0. - * - * Input Parameters: - * ulFileId nvmem file Id: - * * NVMEM_AES128_KEY_FILEID: 12 - * * NVMEM_SHARED_MEM_FILEID: 13 - * * and fileIDs 14 and 15 - * ulNewLen entry ulLength - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -signed long nvmem_create_entry(unsigned long ulFileId, unsigned long ulNewLen) -{ - uint8_t *ptr; - uint8_t *args; - uint16_t retval; - - cc3000_lib_lock(); - - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in HCI packet structure */ - - args = UINT32_TO_STREAM(args, ulFileId); - args = UINT32_TO_STREAM(args, ulNewLen); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_NVMEM_CREATE_ENTRY, ptr, NVMEM_CREATE_PARAMS_LEN); - - SimpleLinkWaitEvent(HCI_CMND_NVMEM_CREATE_ENTRY, &retval); - - cc3000_lib_unlock(); - - return retval; -} diff --git a/drivers/wireless/cc3000/socket.c b/drivers/wireless/cc3000/socket.c deleted file mode 100644 index b1da05d0c9..0000000000 --- a/drivers/wireless/cc3000/socket.c +++ /dev/null @@ -1,812 +0,0 @@ -/**************************************************************************** - * drivers/wireless/cc3000/socket.c - CC3000 Host Driver Implementation. - * - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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 -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "cc3000_socket.h" -#include "cc3000drv.h" -#include "cc3000.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef ARRAY_SIZE -# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -#define waiterr(x,...) // _err -#define waitinfo(x,...) // _info - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -pthread_mutex_t g_cc3000_mut; - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static const int bsd2ti_types[] = -{ - CC3000_SOCK_STREAM, /* SOCK_STREAM */ - CC3000_SOCK_DGRAM, /* SOCK_DGRAM */ - CC3000_SOCK_SEQPACKET, /* SOCK_SEQPACKET */ - CC3000_SOCK_RAW, /* SOCK_RAW */ - CC3000_SOCK_RDM /* SOCK_RDM */ -}; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: socket - * - * Description: - * create an endpoint for communication. The socket function creates a - * socket that is bound to a specific transport service provider. This - * function is called by the application layer to obtain a socket handle. - * - * Input Parameters: - * domain selects the protocol family which will be used for - * communication. On this version only AF_INET is supported - * type specifies the communication semantics. On this version - * only SOCK_STREAM, SOCK_DGRAM, SOCK_RAW are supported - * protocol specifies a particular protocol to be used with the - * socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are - * supported. - * - * Returned Value: - * On success, socket handle that is used for consequent socket - * operations. On error, -1 is returned. - * - ****************************************************************************/ - -int cc3000_socket(int domain, int type, int protocol) -{ - int sd; - - if (type < SOCK_STREAM || type >= ARRAY_SIZE(bsd2ti_types)) - { - set_errno(EPROTOTYPE); - return -1; - } - - switch (domain) - { - case AF_INET: - domain = CC3000_AF_INET; - break; - - case AF_INET6: - domain = CC3000_AF_INET6; - break; - - default: - set_errno(EAFNOSUPPORT); - return -1; - } - - switch (protocol) - { - case CC3000_IPPROTO_IP: - case CC3000_IPPROTO_ICMP: - case CC3000_IPPROTO_TCP: - case CC3000_IPPROTO_UDP: - case CC3000_IPPROTO_IPV6: - case CC3000_IPPROTO_NONE: - case CC3000_IPPROTO_TX_TEST_RAW: - case CC3000_IPPROTO_RAW: - case CC3000_IPPROTO_MAX: - break; - - default: - set_errno(EPROTONOSUPPORT); - return -1; - } - - cc3000_lib_lock(); - type = bsd2ti_types[type]; - sd = cc3000_socket_impl(domain, type, protocol); -#ifdef CONFIG_CC3000_MT - cc3000_add_socket(sd); -#endif - cc3000_lib_unlock(); - return sd; -} - -/**************************************************************************** - * Name: closesocket - * - * Description: - * The socket function closes a created socket. - * - * Input Parameters: - * sockfd socket handle. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -int cc3000_closesocket(int sockfd) -{ - int ret; - -#ifdef CONFIG_CC3000_MT - waitinfo("remove\n"); - cc3000_remove_socket(sockfd); -#endif - cc3000_lib_lock(); - waitinfo("Call closesocketl\n"); - ret = cc3000_closesocket_impl(sockfd); - waitinfo("return closesocket\n"); - cc3000_lib_unlock(); - return ret; -} - -/**************************************************************************** - * Name: accept, cc3000_do_accept - * - * Description: - * accept a connection on a socket: - * This function is used with connection-based socket types - * (SOCK_STREAM). It extracts the first connection request on the - * queue of pending connections, creates a new connected socket, and - * returns a new file descriptor referring to that socket. - * The newly created socket is not in the listening state. - * The original socket sd is unaffected by this call. - * The argument sd is a socket that has been created with socket(), - * bound to a local address with bind(), and is listening for - * connections after a listen(). The argument addr is a pointer - * to a sockaddr structure. This structure is filled in with the - * address of the peer socket, as known to the communications layer. - * The exact format of the address returned addr is determined by the - * socket's address family. The addrlen argument is a value-result - * argument: it should initially contain the size of the structure - * pointed to by addr, on return it will contain the actual - * length (in bytes) of the address returned. - * - * Input Parameters: - * sockfd socket descriptor (handle) - * addr the argument addr is a pointer to a sockaddr structure - * This structure is filled in with the address of the - * peer socket, as known to the communications layer. - * determined. The exact format of the address returned - * addr is by the socket's address sockaddr. - * On this version only AF_INET is supported. - * This argument returns in network order. - * addrlen The addrlen argument is a value-result argument: - * it should initially contain the size of the structure - * pointed to by addr. - * - * Returned Value: - * For socket in blocking mode: - * On success, socket handle. on failure negative - * For socket in non-blocking mode: - * - On connection establishment, socket handle - * - On connection pending, SOC_IN_PROGRESS (-2) - * - On failure, SOC_ERROR (-1) - * - ****************************************************************************/ - -int cc3000_do_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) -{ - int ret; - - cc3000_lib_lock(); - ret = cc3000_accept_impl(sockfd, addr, addrlen); - cc3000_lib_unlock(); - return ret; -} - -int cc3000_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) -#ifdef CONFIG_CC3000_MT -{ - short non_blocking = CC3000_SOCK_ON; - if (setsockopt(sockfd, CC3000_SOL_SOCKET, CC3000_SOCKOPT_ACCEPT_NONBLOCK, - &non_blocking, sizeof(non_blocking)) < 0) - { - nerr("ERROR: setsockopt failure %d\n", errno); - return -errno; - } - - memset(addr, 0, *addrlen); - return cc3000_accept_socket(sockfd, addr, addrlen); -} -#else -{ - cc3000_accept_socket(sockfd, 0); - short nonBlocking = CC3000_SOCK_OFF; - - if (setsockopt(sockfd, CC3000_SOL_SOCKET, CC3000_SOCKOPT_ACCEPT_NONBLOCK, - &nonBlocking, sizeof(nonBlocking)) < 0) - { - nerr("ERROR: setsockopt failure %d\n", errno); - return -errno; - } - - return cc3000_do_accept(sockfd, addr, addrlen); -} -#endif - -/**************************************************************************** - * Name: bind - * - * Description: - * assign a name to a socket - * This function gives the socket the local address addr. - * addr is addrlen bytes long. Traditionally, this is called when a - * socket is created with socket, it exists in a name space (address - * family) but has no name assigned. - * It is necessary to assign a local address before a SOCK_STREAM - * socket may receive connections. - * - * Input Parameters: - * sockfd socket descriptor (handle) - * addr specifies the destination address. On this version - * only AF_INET is supported. - * addrlen contains the size of the structure pointed to by addr. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -int cc3000_bind(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen) -{ - int ret; - - cc3000_lib_lock(); - ret = cc3000_bind_impl(sockfd, addr, addrlen); - cc3000_lib_unlock(); - return ret; -} - -/**************************************************************************** - * Name: listen - * - * Description: - * listen for connections on a socket - * The willingness to accept incoming connections and a queue - * limit for incoming connections are specified with listen(), - * and then the connections are accepted with accept. - * The listen() call applies only to sockets of type SOCK_STREAM - * The backlog parameter defines the maximum length the queue of - * pending connections may grow to. - * - * NOTE: On this version, backlog is not supported - * - * Input Parameters: - * sockfd socket descriptor (handle) - * backlog specifies the listen queue depth. On this version - * backlog is not supported. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -int cc3000_listen(int sockfd, int backlog) -{ - int ret; - - cc3000_lib_lock(); - ret = cc3000_listen_impl(sockfd, backlog); - cc3000_lib_unlock(); - return ret; -} - -/**************************************************************************** - * Name: connect - * - * Description: - * initiate a connection on a socket - * Function connects the socket referred to by the socket descriptor - * sd, to the address specified by addr. The addrlen argument - * specifies the size of addr. The format of the address in addr is - * determined by the address space of the socket. If it is of type - * SOCK_DGRAM, this call specifies the peer with which the socket is - * to be associated; this address is that to which datagrams are to be - * sent, and the only address from which datagrams are to be received. - * If the socket is of type SOCK_STREAM, this call attempts to make a - * connection to another socket. The other socket is specified by - * address, which is an address in the communications space of the - * socket. Note that the function implements only blocking behavior - * thus the caller will be waiting either for the connection - * establishment or for the connection establishment failure. - * - * Input Parameters: - * sockfd socket descriptor (handle) - * addr specifies the destination addr. On this version - * only AF_INET is supported. - * addrlen contains the size of the structure pointed to by addr - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -int cc3000_connect(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen) -{ - int ret; - - cc3000_lib_lock(); - ret = cc3000_connect_impl(sockfd, addr, addrlen); - cc3000_lib_unlock(); - return ret; -} - -/**************************************************************************** - * Name: select - * - * Description: - * Monitor socket activity - * Select allow a program to monitor multiple file descriptors, - * waiting until one or more of the file descriptors become - * "ready" for some class of I/O operation - * - * NOTE: If the timeout value set to less than 5ms it will automatically set - * to 5ms to prevent overload of the system - * - * Input Parameters: - * nfds the highest-numbered file descriptor in any of the - * three sets, plus 1. - * readfds socket descriptors list for read monitoring - * writefds socket descriptors list for write monitoring - * exceptfds socket descriptors list for exception monitoring - * timeout is an upper bound on the amount of time elapsed - * before select() returns. Null means infinity - * timeout. The minimum timeout is 5 milliseconds, - * less than 5 milliseconds will be set - * automatically to 5 milliseconds. - * - * Returned Value: - * On success, select() returns the number of file descriptors - * contained in the three returned descriptor sets (that is, the - * total number of bits that are set in readfds, writefds, - * exceptfds) which may be zero if the timeout expires before - * anything interesting happens. - * On error, -1 is returned. - * *readfds - return the sockets on which Read request will - * return without delay with valid data. - * *writefds - return the sockets on which Write request - * will return without delay. - * *exceptfds - return the sockets which closed recently. - * - ****************************************************************************/ - -int cc3000_select(int nfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout) -{ - int ret; - - cc3000_lib_lock(); - ret = cc3000_select_impl(nfds, (TICC3000fd_set *)readfds, - (TICC3000fd_set *)writefds, - (TICC3000fd_set *)exceptfds, timeout); - cc3000_lib_unlock(); - return ret; -} - -#ifndef CC3000_TINY_DRIVER -/**************************************************************************** - * Name: setsockopt - * - * Description: - * set socket options - * This function manipulate the options associated with a socket. - * Options may exist at multiple protocol levels; they are always - * present at the uppermost socket level. - * When manipulating socket options the level at which the option - * resides and the name of the option must be specified. - * To manipulate options at the socket level, level is specified as - * SOL_SOCKET. To manipulate options at any other level the protocol - * number of the appropriate protocol controlling the option is - * supplied. For example, to indicate that an option is to be - * interpreted by the TCP protocol, level should be set to the - * protocol number of TCP; - * The parameters value and value_len are used to access value - - * use for setsockopt(). For getsockopt() they identify a buffer - * in which the value for the requested option(s) are to - * be returned. For getsockopt(), value_len is a value-result - * parameter, initially containing the size of the buffer - * pointed to by option_value, and modified on return to - * indicate the actual size of the value returned. If no option - * value is to be supplied or returned, option_value may be NULL. - * - * NOTE: On this version the following two socket options are enabled: - * The only protocol level supported in this version - * is SOL_SOCKET (level). - * - * 1. SOCKOPT_RECV_TIMEOUT (option) - * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout - * in milliseconds. In that case value should be pointer to - * unsigned long. - * 2. SOCKOPT_NONBLOCK (option). sets the socket non-blocking mode on - * or off. In that case value should be SOCK_ON or SOCK_OFF (value). - * - * Input Parameters: - * sockfd socket handle - * level defines the protocol level for this option - * option defines the option name to Interrogate - * value specifies a value for the option - * value_len specifies the length of the option value - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -int cc3000_setsockopt(int sockfd, int level, int option, - FAR const void *value, socklen_t value_len) -{ - int ret; - - cc3000_lib_lock(); - ret = cc3000_setsockopt_impl(sockfd, level, option, value, value_len); - cc3000_lib_unlock(); - return ret; -} -#endif - -/**************************************************************************** - * Name: getsockopt - * - * Description: - * set socket options - * This function manipulate the options associated with a socket. - * Options may exist at multiple protocol levels; they are always - * present at the uppermost socket level. - * When manipulating socket options the level at which the option - * resides and the name of the option must be specified. - * To manipulate options at the socket level, level is specified as - * SOL_SOCKET. To manipulate options at any other level the protocol - * number of the appropriate protocol controlling the option is - * supplied. For example, to indicate that an option is to be - * interpreted by the TCP protocol, level should be set to the - * protocol number of TCP; - * The parameters value and value_len are used to access value - - * use for setsockopt(). For getsockopt() they identify a buffer - * in which the value for the requested option(s) are to - * be returned. For getsockopt(), value_len is a value-result - * parameter, initially containing the size of the buffer - * pointed to by option_value, and modified on return to - * indicate the actual size of the value returned. If no option - * value is to be supplied or returned, option_value may be NULL. - * - * NOTE: On this version the following two socket options are enabled: - * The only protocol level supported in this version - * is SOL_SOCKET (level). - * 1. SOCKOPT_RECV_TIMEOUT (option) - * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout - * in milliseconds. - * In that case value should be pointer to unsigned long. - * 2. SOCKOPT_NONBLOCK (option). sets the socket non-blocking mode on - * or off. - * In that case value should be SOCK_ON or SOCK_OFF (value). - * - * Input Parameters: - * sockfd socket handle - * level defines the protocol level for this option - * option defines the option name to Interrogate - * value specifies a value for the option - * value_len specifies the length of the option value - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -int cc3000_getsockopt(int sockfd, int level, int option, FAR void *value, - FAR socklen_t *value_len) -{ - int ret; - - cc3000_lib_lock(); - ret = cc3000_getsockopt_impl(sockfd, level, option, value, value_len); - cc3000_lib_unlock(); - return ret; -} - -/**************************************************************************** - * Name: recv - * - * Description: - * function receives a message from a connection-mode socket - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sockfd socket handle - * buf Points to the buffer where the message should be stored - * len Specifies the length in bytes of the buffer pointed to - * by the buffer argument. - * flags Specifies the type of message reception. - * On this version, this parameter is not supported. - * - * Returned Value: - * Return the number of bytes received, or -1 if an error - * occurred - * - ****************************************************************************/ - -ssize_t cc3000_recv(int sockfd, FAR void *buf, size_t len, int flags) -{ - ssize_t ret; - -#ifdef CONFIG_CC3000_MT - waitinfo("wait\n"); - ret = cc3000_wait_data(sockfd); - waitinfo("wait %d\n", ret); - - if (ret == -ECONNABORTED) - { - return 0; - } - - if (ret != OK) - { - return -1; - } -#endif - - cc3000_lib_lock(); - waitinfo("recv\n"); - ret = cc3000_recv_impl(sockfd, buf, len, flags); - waitinfo("recv %d\n", ret); - cc3000_lib_unlock(); - return ret; -} - -/**************************************************************************** - * Name: recvfrom - * - * Description: - * read data from socket - * function receives a message from a connection-mode or - * connectionless-mode socket. Note that raw sockets are not - * supported. - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sockfd socket handle - * buf Points to the buffer where the message should be stored - * len Specifies the length in bytes of the buffer pointed to - * by the buffer argument. - * flags Specifies the type of message reception. - * On this version, this parameter is not supported. - * from pointer to an address structure indicating the source - * address: sockaddr. On this version only AF_INET is - * supported. - * fromlen source address tructure size - * - * Returned Value: - * Return the number of bytes received, or -1 if an error - * occurred - * - ****************************************************************************/ - -ssize_t cc3000_recvfrom(int sockfd, FAR void *buf, size_t len, int flags, - FAR struct sockaddr *from, FAR socklen_t *fromlen) -{ - ssize_t ret; - -#ifdef CONFIG_CC3000_MT - ret = cc3000_wait_data(sockfd); - if (ret == -ECONNABORTED) - { - return 0; - } - - if (ret != OK) - { - return -1; - } -#endif - - cc3000_lib_lock(); - ret = cc3000_recvfrom_impl(sockfd, buf, len, flags, from, fromlen); - cc3000_lib_unlock(); - return ret; -} - -/**************************************************************************** - * Name: send - * - * Description: - * Write data to TCP socket - * This function is used to transmit a message to another - * socket. - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sockfd socket handle - * buf Points to a buffer containing the message to be sent - * len message size in bytes - * flags On this version, this parameter is not supported - * - * Returned Value: - * Return the number of bytes transmitted, or -1 if an - * error occurred - * - ****************************************************************************/ - -ssize_t cc3000_send(int sockfd, FAR const void *buf, size_t len, int flags) -{ - ssize_t ret; - - cc3000_lib_lock(); - ret = cc3000_send_impl(sockfd, buf, len, flags); - cc3000_lib_unlock(); - return ret; -} - -/**************************************************************************** - * Name: sendto - * - * Description: - * Write data to TCP socket - * This function is used to transmit a message to another - * socket. - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sockfd socket handle - * buf Points to a buffer containing the message to be sent - * len message size in bytes - * flags On this version, this parameter is not supported - * to pointer to an address structure indicating the destination - * address: sockaddr. On this version only AF_INET is - * supported. - * tolen destination address structure size - * - * Returned Value: - * Return the number of bytes transmitted, or -1 if an - * error occurred - * - ****************************************************************************/ - -ssize_t cc3000_sendto(int sockfd, FAR const void *buf, size_t len, int flags, - FAR const struct sockaddr *to, socklen_t tolen) -{ - ssize_t ret; - - cc3000_lib_lock(); - ret = cc3000_sendto_impl(sockfd, buf, len, flags, to, tolen); - cc3000_lib_unlock(); - return ret; -} - -/**************************************************************************** - * Name: gethostbyname - * - * Description: - * Get host IP by name. Obtain the IP Address of machine on network, - * by its name. - * - * NOTE: On this version, only blocking mode is supported. Also note that - * the function requires DNS server to be configured prior to its - * usage. - * - * Input Parameters: - * hostname host name - * usNameLen name length - * out_ip_addr This parameter is filled in with host IP address. - * In case that host name is not resolved, - * out_ip_addr is zero. - * - * Returned Value: - * On success, positive is returned. On error, negative is returned - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -/* REVISIT: Standard is struct hostent *gethostbyname(const char *name); */ - -int cc3000_gethostbyname(char *hostname, uint16_t usNameLen, - unsigned long *out_ip_addr) -{ - int ret; - - cc3000_lib_lock(); - ret = cc3000_gethostbyname_impl(hostname, usNameLen, out_ip_addr); - cc3000_lib_unlock(); - return ret; -} -#endif - -/**************************************************************************** - * Name: mdnsAdvertiser - * - * Description: - * Set CC3000 in mDNS advertiser mode in order to advertise itself. - * - * Input Parameters: - * mdnsEnabled flag to enable/disable the mDNS feature - * deviceServiceName Service name as part of the published - * canonical domain name - * deviceServiceNameLength Length of the service name - * - * Returned Value: - * On success, zero is returned, return SOC_ERROR if socket was not - * opened successfully, or if an error occurred. - * - ****************************************************************************/ - -int cc3000_mdnsadvertiser(uint16_t mdnsEnabled, char *deviceServiceName, - uint16_t deviceServiceNameLength) - -{ - int ret; - - cc3000_lib_lock(); - ret = cc3000_mdnsadvertiser_impl(mdnsEnabled, deviceServiceName, deviceServiceNameLength); - cc3000_lib_unlock(); - return ret; -} diff --git a/drivers/wireless/cc3000/socket_imp.c b/drivers/wireless/cc3000/socket_imp.c deleted file mode 100644 index 832e696a02..0000000000 --- a/drivers/wireless/cc3000/socket_imp.c +++ /dev/null @@ -1,1249 +0,0 @@ -/**************************************************************************** - * drivers/wireless/cc3000/socket_imp.c - CC3000 Host Driver Implementation. - * - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Port to nuttx: - * David Sidrane - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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 -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "cc3000_socket.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Enable this flag if and only if you must comply with BSD socket close() - * function - */ - -#ifdef _API_USE_BSD_CLOSE -# define close(sd) closesocket(sd) -#endif - -#define SOCKET_OPEN_PARAMS_LEN (12) -#define SOCKET_CLOSE_PARAMS_LEN (4) -#define SOCKET_ACCEPT_PARAMS_LEN (4) -#define SOCKET_BIND_PARAMS_LEN (20) -#define SOCKET_LISTEN_PARAMS_LEN (8) -#define SOCKET_GET_HOST_BY_NAME_PARAMS_LEN (9) -#define SOCKET_CONNECT_PARAMS_LEN (20) -#define SOCKET_SELECT_PARAMS_LEN (44) -#define SOCKET_SET_SOCK_OPT_PARAMS_LEN (20) -#define SOCKET_GET_SOCK_OPT_PARAMS_LEN (12) -#define SOCKET_RECV_FROM_PARAMS_LEN (12) -#define SOCKET_SENDTO_PARAMS_LEN (24) -#define SOCKET_MDNS_ADVERTISE_PARAMS_LEN (12) - -/* The legnth of arguments for the SEND command: sd + buff_offset + len + flags, - * while size of each parameter is 32 bit - so the total length is 16 bytes; - */ - -#define HCI_CMND_SEND_ARG_LENGTH (16) - -#define SELECT_TIMEOUT_MIN_MICRO_SECONDS 5000 - -#define HEADERS_SIZE_DATA (SPI_HEADER_SIZE + 5) - -#define SIMPLE_LINK_HCI_CMND_TRANSPORT_HEADER_SIZE \ - (SPI_HEADER_SIZE + SIMPLE_LINK_HCI_CMND_HEADER_SIZE) - -#define MDNS_DEVICE_SERVICE_MAX_LENGTH (32) - -/**************************************************************************** - * Public Functions - ****************************************************************************/ -/**************************************************************************** - * Name: HostFlowControlConsumeBuff - * - * Input Parameters: - * sd socket descriptor - * - * Returned Value: - * 0 in case there are buffers available, - * -1 in case of bad socket - * -2 if there are no free buffers present (only when - * SEND_NON_BLOCKING is enabled) - * - * Decription: - * if SEND_NON_BLOCKING not define - block until have free buffer - * becomes available, else return immediately with correct status - * regarding the buffers available. - * - ****************************************************************************/ - -int HostFlowControlConsumeBuff(int sd) -{ -#ifndef SEND_NON_BLOCKING - /* Wait in busy loop */ - - do - { - /* In case last transmission failed then we will return the last failure - * reason here. - * Note that the buffer will not be allocated in this case - */ - - if (tSLInformation.slTransmitDataError != 0) - { - set_errno(tSLInformation.slTransmitDataError); - tSLInformation.slTransmitDataError = 0; - return tSLInformation.slTransmitDataError; - } - - if (SOCKET_STATUS_ACTIVE != get_socket_active_status(sd)) - { - return -1; - } - - /* We must yield here for the Event to get processed that returns - * the buffers - */ - - if (0 == tSLInformation.usNumberOfFreeBuffers) - { - nxsig_usleep(100000); - } - } - while (0 == tSLInformation.usNumberOfFreeBuffers); - - tSLInformation.usNumberOfFreeBuffers--; - - return 0; -#else - - /* In case last transmission failed then we will return the last failure - * reason here. - * Note that the buffer will not be allocated in this case - */ - - if (tSLInformation.slTransmitDataError != 0) - { - set_errno(tSLInformation.slTransmitDataError); - tSLInformation.slTransmitDataError = 0; - return tSLInformation.slTransmitDataError; - } - - if (SOCKET_STATUS_ACTIVE != get_socket_active_status(sd)) - { - return -1; - } - - /* If there are no available buffers, return -2. It is recommended to use - * select or receive to see if there is any buffer occupied with received data - * If so, call receive() to release the buffer. - */ - - if (0 == tSLInformation.usNumberOfFreeBuffers) - { - return -2; - } - else - { - tSLInformation.usNumberOfFreeBuffers--; - return 0; - } -#endif -} - -/**************************************************************************** - * Name: socket - * - * Decription: - * create an endpoint for communication. The socket function creates a - * socket that is bound to a specific transport service provider. This - * function is called by the application layer to obtain a socket handle. - * - * Input Parameters: - * domain selects the protocol family which will be used for - * communication. On this version only AF_INET is supported - * type specifies the communication semantics. On this version - * only SOCK_STREAM, SOCK_DGRAM, SOCK_RAW are supported - * protocol specifies a particular protocol to be used with the - * socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are - * supported. - * - * Returned Value: - * On success, socket handle that is used for consequent socket - * operations. On error, -1 is returned. - * - ****************************************************************************/ - -int cc3000_socket_impl(long domain, long type, long protocol) -{ - long ret; - uint8_t *ptr, *args; - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in HCI packet structure */ - - args = UINT32_TO_STREAM(args, domain); - args = UINT32_TO_STREAM(args, type); - args = UINT32_TO_STREAM(args, protocol); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_SOCKET, ptr, SOCKET_OPEN_PARAMS_LEN); - - /* Since we are in blocking state - wait for event complete */ - - SimpleLinkWaitEvent(HCI_CMND_SOCKET, &ret); - - /* Process the event */ - - set_errno(ret); - set_socket_active_status(ret, SOCKET_STATUS_ACTIVE); - return ret; -} - -/**************************************************************************** - * Name: closesocket - * - * Decription: - * The socket function closes a created socket. - * - * Input Parameters: - * sd socket handle. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -long cc3000_closesocket_impl(long sd) -{ - long ret; - uint8_t *ptr, *args; - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in HCI packet structure */ - - args = UINT32_TO_STREAM(args, sd); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_CLOSE_SOCKET, - ptr, SOCKET_CLOSE_PARAMS_LEN); - - /* Since we are in blocking state - wait for event complete */ - - SimpleLinkWaitEvent(HCI_CMND_CLOSE_SOCKET, &ret); - set_errno(ret); - - /* Since 'close' call may result in either OK (and then it closed) or error - * mark this socket as invalid - */ - - set_socket_active_status(sd, SOCKET_STATUS_INACTIVE); - - return ret; -} - -/**************************************************************************** - * Name: accept - * - * Decription: - * accept a connection on a socket: - * This function is used with connection-based socket types - * (SOCK_STREAM). It extracts the first connection request on the - * queue of pending connections, creates a new connected socket, and - * returns a new file descriptor referring to that socket. - * The newly created socket is not in the listening state. - * The original socket sd is unaffected by this call. - * The argument sd is a socket that has been created with socket(), - * bound to a local address with bind(), and is listening for - * connections after a listen(). The argument addr is a pointer - * to a sockaddr structure. This structure is filled in with the - * address of the peer socket, as known to the communications layer. - * The exact format of the address returned addr is determined by the - * socket's address family. The addrlen argument is a value-result - * argument: it should initially contain the size of the structure - * pointed to by addr, on return it will contain the actual - * length (in bytes) of the address returned. - * - * Input Parameters: - * sd socket descriptor (handle) - * addr the argument addr is a pointer to a sockaddr structure - * This structure is filled in with the address of the - * peer socket, as known to the communications layer. - * determined. The exact format of the address returned - * addr is by the socket's address sockaddr. - * On this version only AF_INET is supported. - * This argument returns in network order. - * addrlen The addrlen argument is a value-result argument: - * it should initially contain the size of the structure - * pointed to by addr. - * - * Returned Value: - * For socket in blocking mode: - * On success, socket handle. on failure negative - * For socket in non-blocking mode: - * - On connection establishment, socket handle - * - On connection pending, SOC_IN_PROGRESS (-2) - * - On failure, SOC_ERROR (-1) - * - ****************************************************************************/ - -long cc3000_accept_impl(long sd, struct sockaddr *addr, socklen_t *addrlen) -{ - long ret; - uint8_t *ptr, *args; - tBsdReturnParams tAcceptReturnArguments; - - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in temporary command buffer */ - - args = UINT32_TO_STREAM(args, sd); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_ACCEPT, - ptr, SOCKET_ACCEPT_PARAMS_LEN); - - /* Since we are in blocking state - wait for event complete */ - - SimpleLinkWaitEvent(HCI_CMND_ACCEPT, &tAcceptReturnArguments); - - - /* Need specify return parameters!!! */ - - memcpy(addr, &tAcceptReturnArguments.tSocketAddress, CC3000_ASIC_ADDR_LEN); - *addrlen = CC3000_ASIC_ADDR_LEN; - set_errno(tAcceptReturnArguments.iStatus); - ret = tAcceptReturnArguments.iStatus; - - /* if succeeded, iStatus = new socket descriptor. otherwise - error number */ - - if (M_IS_VALID_SD(ret)) - { - set_socket_active_status(ret, SOCKET_STATUS_ACTIVE); - } - else - { - set_socket_active_status(sd, SOCKET_STATUS_INACTIVE); - } - - return ret; -} - -/**************************************************************************** - * Name: bind - * - * Decription: - * assign a name to a socket - * This function gives the socket the local address addr. - * addr is addrlen bytes long. Traditionally, this is called when a - * socket is created with socket, it exists in a name space (address - * family) but has no name assigned. - * It is necessary to assign a local address before a SOCK_STREAM - * socket may receive connections. - * - * Input Parameters: - * sd socket descriptor (handle) - * addr specifies the destination address. On this version - * only AF_INET is supported. - * addrlen contains the size of the structure pointed to by addr. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -long cc3000_bind_impl(long sd, const struct sockaddr *addr, socklen_t addrlen) -{ - long ret; - uint8_t *ptr, *args; - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - addrlen = CC3000_ASIC_ADDR_LEN; - - /* Fill in temporary command buffer */ - - args = UINT32_TO_STREAM(args, sd); - args = UINT32_TO_STREAM(args, 0x00000008); - args = UINT32_TO_STREAM(args, addrlen); - ARRAY_TO_STREAM(args, ((uint8_t *)addr), addrlen); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_BIND, - ptr, SOCKET_BIND_PARAMS_LEN); - - /* Since we are in blocking state - wait for event complete */ - - SimpleLinkWaitEvent(HCI_CMND_BIND, &ret); - - set_errno(ret); - return ret; -} - -/**************************************************************************** - * Name: listen - * - * Decription: - * listen for connections on a socket - * The willingness to accept incoming connections and a queue - * limit for incoming connections are specified with listen(), - * and then the connections are accepted with accept. - * The listen() call applies only to sockets of type SOCK_STREAM - * The backlog parameter defines the maximum length the queue of - * pending connections may grow to. - * - * NOTE: On this version, backlog is not supported - * - * Input Parameters: - * sd socket descriptor (handle) - * backlog specifies the listen queue depth. On this version - * backlog is not supported. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -long cc3000_listen_impl(long sd, long backlog) -{ - long ret; - uint8_t *ptr, *args; - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in temporary command buffer */ - - args = UINT32_TO_STREAM(args, sd); - args = UINT32_TO_STREAM(args, backlog); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_LISTEN, - ptr, SOCKET_LISTEN_PARAMS_LEN); - - /* Since we are in blocking state - wait for event complete */ - - SimpleLinkWaitEvent(HCI_CMND_LISTEN, &ret); - - set_errno(ret); - return ret; -} - -/**************************************************************************** - * Name: gethostbyname - * - * Decription: - * Get host IP by name. Obtain the IP Address of machine on network, - * by its name. - * - * NOTE: On this version, only blocking mode is supported. Also note that - * the function requires DNS server to be configured prior to its - * usage. - * - * Input Parameters: - * hostname host name - * usNameLen name length - * out_ip_addr This parameter is filled in with host IP address. - * In case that host name is not resolved, - * out_ip_addr is zero. - * - * Returned Value: - * On success, positive is returned. On error, negative is returned - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -int cc3000_gethostbyname_impl(char *hostname, uint16_t usNameLen, - unsigned long *out_ip_addr) -{ - tBsdGethostbynameParams ret; - uint8_t *ptr; - uint8_t *args; - - if (usNameLen > CC3000_HOSTNAME_MAX_LENGTH) - { - return -EINVAL; - } - - ret.retVal = OK; - - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + SIMPLE_LINK_HCI_CMND_TRANSPORT_HEADER_SIZE); - - /* Fill in HCI packet structure */ - - args = UINT32_TO_STREAM(args, 8); - args = UINT32_TO_STREAM(args, usNameLen); - ARRAY_TO_STREAM(args, hostname, usNameLen); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_GETHOSTNAME, ptr, SOCKET_GET_HOST_BY_NAME_PARAMS_LEN - + usNameLen - 1); - - /* Since we are in blocking state - wait for event complete */ - - SimpleLinkWaitEvent(HCI_EVNT_BSD_GETHOSTBYNAME, &ret); - - (*((FAR long *)out_ip_addr)) = ret.outputAddress; - - return (int)ret.retVal; -} -#endif - -/**************************************************************************** - * Name: connect - * - * Decription: - * initiate a connection on a socket - * Function connects the socket referred to by the socket descriptor - * sd, to the address specified by addr. The addrlen argument - * specifies the size of addr. The format of the address in addr is - * determined by the address space of the socket. If it is of type - * SOCK_DGRAM, this call specifies the peer with which the socket is - * to be associated; this address is that to which datagrams are to be - * sent, and the only address from which datagrams are to be received. - * If the socket is of type SOCK_STREAM, this call attempts to make a - * connection to another socket. The other socket is specified by - * address, which is an address in the communications space of the - * socket. Note that the function implements only blocking behavior - * thus the caller will be waiting either for the connection - * establishment or for the connection establishment failure. - * - * Input Parameters: - * sd socket descriptor (handle) - * addr specifies the destination addr. On this version - * only AF_INET is supported. - * addrlen contains the size of the structure pointed to by addr - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -long cc3000_connect_impl(long sd, const struct sockaddr *addr, socklen_t addrlen) -{ - long int ret; - uint8_t *ptr, *args; - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + SIMPLE_LINK_HCI_CMND_TRANSPORT_HEADER_SIZE); - addrlen = 8; - - /* Fill in temporary command buffer */ - - args = UINT32_TO_STREAM(args, sd); - args = UINT32_TO_STREAM(args, 0x00000008); - args = UINT32_TO_STREAM(args, addrlen); - ARRAY_TO_STREAM(args, ((uint8_t *)addr), addrlen); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_CONNECT, - ptr, SOCKET_CONNECT_PARAMS_LEN); - - /* Since we are in blocking state - wait for event complete */ - - SimpleLinkWaitEvent(HCI_CMND_CONNECT, &ret); - - set_errno(ret); - return (long)ret; -} - -/**************************************************************************** - * Name: select - * - * Decription: - * Monitor socket activity - * Select allow a program to monitor multiple file descriptors, - * waiting until one or more of the file descriptors become - * "ready" for some class of I/O operation - * - * NOTE: If the timeout value set to less than 5ms it will automatically set - * to 5ms to prevent overload of the system - * - * Input Parameters: - * nfds the highest-numbered file descriptor in any of the - * three sets, plus 1. - * writesds socket descriptors list for write monitoring - * readsds socket descriptors list for read monitoring - * exceptsds socket descriptors list for exception monitoring - * timeout is an upper bound on the amount of time elapsed - * before select() returns. Null means infinity - * timeout. The minimum timeout is 5 milliseconds, - * less than 5 milliseconds will be set - * automatically to 5 milliseconds. - * - * Returned Value: - * On success, select() returns the number of file descriptors - * contained in the three returned descriptor sets (that is, the - * total number of bits that are set in readfds, writefds, - * exceptfds) which may be zero if the timeout expires before - * anything interesting happens. - * On error, -1 is returned. - * *readsds - return the sockets on which Read request will - * return without delay with valid data. - * *writesds - return the sockets on which Write request - * will return without delay. - * *exceptsds - return the sockets which closed recently. - * - ****************************************************************************/ - -int cc3000_select_impl(long nfds, TICC3000fd_set *readsds, TICC3000fd_set *writesds, - TICC3000fd_set *exceptsds, struct timeval *timeout) -{ - uint8_t *ptr, *args; - tBsdSelectRecvParams tParams; - unsigned long is_blocking; - - if (timeout == NULL) - { - is_blocking = 1; /* blocking , infinity timeout */ - } - else - { - is_blocking = 0; /* no blocking, timeout */ - } - - /* Fill in HCI packet structure */ - - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in temporary command buffer */ - - args = UINT32_TO_STREAM(args, nfds); - args = UINT32_TO_STREAM(args, 0x00000014); - args = UINT32_TO_STREAM(args, 0x00000014); - args = UINT32_TO_STREAM(args, 0x00000014); - args = UINT32_TO_STREAM(args, 0x00000014); - args = UINT32_TO_STREAM(args, is_blocking); - args = UINT32_TO_STREAM(args, ((readsds) ? *(FAR unsigned long *)readsds : 0)); - args = UINT32_TO_STREAM(args, ((writesds) ? *(FAR unsigned long *)writesds : 0)); - args = UINT32_TO_STREAM(args, ((exceptsds) ? *(FAR unsigned long *)exceptsds : 0)); - - if (timeout) - { - if (0 == timeout->tv_sec && timeout->tv_usec < - SELECT_TIMEOUT_MIN_MICRO_SECONDS) - { - timeout->tv_usec = SELECT_TIMEOUT_MIN_MICRO_SECONDS; - } - - args = UINT32_TO_STREAM(args, timeout->tv_sec); - args = UINT32_TO_STREAM(args, timeout->tv_usec); - } - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_BSD_SELECT, ptr, SOCKET_SELECT_PARAMS_LEN); - - /* Since we are in blocking state - wait for event complete */ - - SimpleLinkWaitEvent(HCI_EVNT_SELECT, &tParams); - - /* Update actually read FD */ - - if (tParams.iStatus >= 0) - { - if (readsds) - { - memcpy(readsds, &tParams.uiRdfd, sizeof(tParams.uiRdfd)); - } - - if (writesds) - { - memcpy(writesds, &tParams.uiWrfd, sizeof(tParams.uiWrfd)); - } - - if (exceptsds) - { - memcpy(exceptsds, &tParams.uiExfd, sizeof(tParams.uiExfd)); - } - - return tParams.iStatus; - } - else - { - set_errno(tParams.iStatus); - return -1; - } -} - -/**************************************************************************** - * Name: setsockopt - * - * Decription: - * set socket options - * This function manipulate the options associated with a socket. - * Options may exist at multiple protocol levels; they are always - * present at the uppermost socket level. - * When manipulating socket options the level at which the option - * resides and the name of the option must be specified. - * To manipulate options at the socket level, level is specified as - * SOL_SOCKET. To manipulate options at any other level the protocol - * number of the appropriate protocol controlling the option is - * supplied. For example, to indicate that an option is to be - * interpreted by the TCP protocol, level should be set to the - * protocol number of TCP; - * The parameters optval and optlen are used to access optval - - * use for setsockopt(). For getsockopt() they identify a buffer - * in which the value for the requested option(s) are to - * be returned. For getsockopt(), optlen is a value-result - * parameter, initially containing the size of the buffer - * pointed to by option_value, and modified on return to - * indicate the actual size of the value returned. If no option - * value is to be supplied or returned, option_value may be NULL. - * - * NOTE: On this version the following two socket options are enabled: - * The only protocol level supported in this version - * is SOL_SOCKET (level). - * 1. SOCKOPT_RECV_TIMEOUT (optname) - * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout - * in milliseconds. - * In that case optval should be pointer to unsigned long. - * 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on - * or off. - * In that case optval should be SOCK_ON or SOCK_OFF (optval). - * - * Input Parameters: - * sd socket handle - * level defines the protocol level for this option - * optname defines the option name to Interrogate - * optval specifies a value for the option - * optlen specifies the length of the option value - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -int cc3000_setsockopt_impl(long sd, long level, long optname, const void *optval, socklen_t optlen) -{ - int ret; - uint8_t *ptr, *args; - - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in temporary command buffer */ - - args = UINT32_TO_STREAM(args, sd); - args = UINT32_TO_STREAM(args, level); - args = UINT32_TO_STREAM(args, optname); - args = UINT32_TO_STREAM(args, 0x00000008); - args = UINT32_TO_STREAM(args, optlen); - ARRAY_TO_STREAM(args, ((uint8_t *)optval), optlen); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_SETSOCKOPT, - ptr, SOCKET_SET_SOCK_OPT_PARAMS_LEN + optlen); - - /* Since we are in blocking state - wait for event complete */ - - SimpleLinkWaitEvent(HCI_CMND_SETSOCKOPT, &ret); - - if (ret >= 0) - { - return 0; - } - else - { - set_errno(ret); - return ret; - } -} -#endif - -/**************************************************************************** - * Name: getsockopt - * - * Decription: - * set socket options - * This function manipulate the options associated with a socket. - * Options may exist at multiple protocol levels; they are always - * present at the uppermost socket level. - * When manipulating socket options the level at which the option - * resides and the name of the option must be specified. - * To manipulate options at the socket level, level is specified as - * SOL_SOCKET. To manipulate options at any other level the protocol - * number of the appropriate protocol controlling the option is - * supplied. For example, to indicate that an option is to be - * interpreted by the TCP protocol, level should be set to the - * protocol number of TCP; - * The parameters optval and optlen are used to access optval - - * use for setsockopt(). For getsockopt() they identify a buffer - * in which the value for the requested option(s) are to - * be returned. For getsockopt(), optlen is a value-result - * parameter, initially containing the size of the buffer - * pointed to by option_value, and modified on return to - * indicate the actual size of the value returned. If no option - * value is to be supplied or returned, option_value may be NULL. - * - * NOTE: On this version the following two socket options are enabled: - * The only protocol level supported in this version - * is SOL_SOCKET (level). - * 1. SOCKOPT_RECV_TIMEOUT (optname) - * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout - * in milliseconds. - * In that case optval should be pointer to unsigned long. - * 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on - * or off. - * In that case optval should be SOCK_ON or SOCK_OFF (optval). - * - * Input Parameters: - * sd socket handle - * level defines the protocol level for this option - * optname defines the option name to Interrogate - * optval specifies a value for the option - * optlen specifies the length of the option value - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -int cc3000_getsockopt_impl(long sd, long level, long optname, void *optval, socklen_t *optlen) -{ - uint8_t *ptr, *args; - tBsdGetSockOptReturnParams tRetParams; - - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in temporary command buffer */ - - args = UINT32_TO_STREAM(args, sd); - args = UINT32_TO_STREAM(args, level); - args = UINT32_TO_STREAM(args, optname); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_GETSOCKOPT, - ptr, SOCKET_GET_SOCK_OPT_PARAMS_LEN); - - /* Since we are in blocking state - wait for event complete */ - - SimpleLinkWaitEvent(HCI_CMND_GETSOCKOPT, &tRetParams); - - if (((int8_t)tRetParams.iStatus) >= 0) - { - *optlen = 4; - memcpy(optval, tRetParams.ucOptValue, 4); - return 0; - } - else - { - set_errno(tRetParams.iStatus); - return tRetParams.iStatus; - } -} - -/**************************************************************************** - * Name: simple_link_recv - * - * Input Parameters: - * sd socket handle - * buf read buffer - * len buffer length - * flags indicates blocking or non-blocking operation - * from pointer to an address structure indicating source address - * fromlen source address structure size - * - * Returned Value: - * Return the number of bytes received, or -1 if an error - * occurred - * - * Decription: - * Read data from socket - * Return the length of the message on successful completion. - * If a message is too long to fit in the supplied buffer, - * excess bytes may be discarded depending on the type of - * socket the message is received from - * - ****************************************************************************/ - -int simple_link_recv(long sd, void *buf, long len, long flags, struct sockaddr *from, - socklen_t *fromlen, long opcode) -{ - uint8_t *ptr, *args; - tBsdReadReturnParams tSocketReadEvent; - - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in HCI packet structure */ - - args = UINT32_TO_STREAM(args, sd); - args = UINT32_TO_STREAM(args, len); - args = UINT32_TO_STREAM(args, flags); - - /* Generate the read command, and wait for the */ - - hci_command_send(opcode, ptr, SOCKET_RECV_FROM_PARAMS_LEN); - - /* Since we are in blocking state - wait for event complete */ - - SimpleLinkWaitEvent(opcode, &tSocketReadEvent); - - /* In case the number of bytes is more then zero - read data */ - - if (tSocketReadEvent.iNumberOfBytes > 0) - { - /* Wait for the data in a synchronous way. Here we assume that the bug is - * big enough to store also parameters of receive from too.... - */ - - SimpleLinkWaitData((uint8_t *)buf, (uint8_t *)from, (uint8_t *)fromlen); - } - - set_errno(tSocketReadEvent.iNumberOfBytes); - return tSocketReadEvent.iNumberOfBytes; -} - -/**************************************************************************** - * Name: recv - * - * Decription: - * function receives a message from a connection-mode socket - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sd socket handle - * buf Points to the buffer where the message should be stored - * len Specifies the length in bytes of the buffer pointed to - * by the buffer argument. - * flags Specifies the type of message reception. - * On this version, this parameter is not supported. - * - * Returned Value: - * Return the number of bytes received, or -1 if an error - * occurred - * - ****************************************************************************/ - -int cc3000_recv_impl(long sd, void *buf, long len, long flags) -{ - return(simple_link_recv(sd, buf, len, flags, NULL, NULL, HCI_CMND_RECV)); -} - -/**************************************************************************** - * Name: recvfrom - * - * Decription: - * read data from socket - * function receives a message from a connection-mode or - * connectionless-mode socket. Note that raw sockets are not - * supported. - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sd socket handle - * buf Points to the buffer where the message should be stored - * len Specifies the length in bytes of the buffer pointed to - * by the buffer argument. - * flags Specifies the type of message reception. - * On this version, this parameter is not supported. - * from pointer to an address structure indicating the source - * address: sockaddr. On this version only AF_INET is - * supported. - * fromlen source address tructure size - * - * Returned Value: - * Return the number of bytes received, or -1 if an error - * occurred - * - ****************************************************************************/ - -int cc3000_recvfrom_impl(long sd, void *buf, long len, long flags, struct sockaddr *from, - socklen_t *fromlen) -{ - return(simple_link_recv(sd, buf, len, flags, from, fromlen, - HCI_CMND_RECVFROM)); -} - -/**************************************************************************** - * Name: simple_link_send - * - * Input Parameters: - * sd socket handle - * buf write buffer - * len buffer length - * flags On this version, this parameter is not supported - * to pointer to an address structure indicating destination - * address - * tolen destination address structure size - * - * Returned Value: - * Return the number of bytes transmitted, or -1 if an error - * occurred, or -2 in case there are no free buffers available - * (only when SEND_NON_BLOCKING is enabled) - * - * Decription: - * This function is used to transmit a message to another - * socket - * - ****************************************************************************/ - -int simple_link_send(long sd, const void *buf, long len, long flags, - const struct sockaddr *to, long tolen, long opcode) -{ - tBsdReadReturnParams tSocketSendEvent; - uint8_t uArgSize = 0, addrlen; - uint8_t *ptr, *pDataPtr = NULL, *args; - unsigned long addr_offset = 0; - int res; - - /* Check the bsd_arguments */ - - if (0 != (res = HostFlowControlConsumeBuff(sd))) - { - return res; - } - - /* Update the number of sent packets */ - - tSLInformation.NumberOfSentPackets++; - - /* Allocate a buffer and construct a packet and send it over spi */ - - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_DATA); - - /* Update the offset of data and parameters according to the command */ - - switch (opcode) - { - case HCI_CMND_SENDTO: - { - addr_offset = len + sizeof(len) + sizeof(len); - addrlen = 8; - uArgSize = SOCKET_SENDTO_PARAMS_LEN; - pDataPtr = ptr + HEADERS_SIZE_DATA + SOCKET_SENDTO_PARAMS_LEN; - break; - } - - case HCI_CMND_SEND: - { - tolen = 0; - to = NULL; - uArgSize = HCI_CMND_SEND_ARG_LENGTH; - pDataPtr = ptr + HEADERS_SIZE_DATA + HCI_CMND_SEND_ARG_LENGTH; - break; - } - - default: - { - break; - } - } - - /* Fill in temporary command buffer */ - - args = UINT32_TO_STREAM(args, sd); - args = UINT32_TO_STREAM(args, uArgSize - sizeof(sd)); - args = UINT32_TO_STREAM(args, len); - args = UINT32_TO_STREAM(args, flags); - - if (opcode == HCI_CMND_SENDTO) - { - args = UINT32_TO_STREAM(args, addr_offset); - args = UINT32_TO_STREAM(args, addrlen); - } - - /* Copy the data received from user into the TX Buffer */ - - ARRAY_TO_STREAM(pDataPtr, ((FAR uint8_t *)buf), len); - - /* In case we are using SendTo, copy the to parameters */ - - if (opcode == HCI_CMND_SENDTO) - { - ARRAY_TO_STREAM(pDataPtr, ((FAR uint8_t *)to), tolen); - } - - /* Initiate a HCI command */ - - hci_data_send(opcode, ptr, uArgSize, len, (FAR uint8_t *)to, tolen); - - if (opcode == HCI_CMND_SENDTO) - { - SimpleLinkWaitEvent(HCI_EVNT_SENDTO, &tSocketSendEvent); - } - else - { - SimpleLinkWaitEvent(HCI_EVNT_SEND, &tSocketSendEvent); - } - - return len; -} - -/**************************************************************************** - * Name: send - * - * Decription: - * Write data to TCP socket - * This function is used to transmit a message to another - * socket. - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sd socket handle - * buf Points to a buffer containing the message to be sent - * len message size in bytes - * flags On this version, this parameter is not supported - * - * Returned Value: - * Return the number of bytes transmitted, or -1 if an - * error occurred - * - ****************************************************************************/ - -int cc3000_send_impl(long sd, const void *buf, long len, long flags) -{ - return(simple_link_send(sd, buf, len, flags, NULL, 0, HCI_CMND_SEND)); -} - -/**************************************************************************** - * Name: sendto - * - * Decription: - * Write data to TCP socket - * This function is used to transmit a message to another - * socket. - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sd socket handle - * buf Points to a buffer containing the message to be sent - * len message size in bytes - * flags On this version, this parameter is not supported - * to pointer to an address structure indicating the destination - * address: sockaddr. On this version only AF_INET is - * supported. - * tolen destination address structure size - * - * Returned Value: - * Return the number of bytes transmitted, or -1 if an - * error occurred - * - ****************************************************************************/ - -int cc3000_sendto_impl(long sd, const void *buf, long len, long flags, const struct sockaddr *to, - socklen_t tolen) -{ - return(simple_link_send(sd, buf, len, flags, to, tolen, HCI_CMND_SENDTO)); -} - -/**************************************************************************** - * Name: mdnsAdvertiser - * - * Decription: - * Set CC3000 in mDNS advertiser mode in order to advertise itself. - * - * Input Parameters: - * mdnsEnabled flag to enable/disable the mDNS feature - * deviceServiceName Service name as part of the published - * canonical domain name - * deviceServiceNameLength Length of the service name - * - * Returned Value: - * On success, zero is returned, return SOC_ERROR if socket was not - * opened successfully, or if an error occurred. - * - ****************************************************************************/ - -int cc3000_mdnsadvertiser_impl(uint16_t mdnsEnabled, char * deviceServiceName, - uint16_t deviceServiceNameLength) -{ - uint8_t *pTxBuffer; - uint8_t *pArgs; - int ret; - - if (deviceServiceNameLength > MDNS_DEVICE_SERVICE_MAX_LENGTH) - { - return EFAIL; - } - - pTxBuffer = tSLInformation.pucTxCommandBuffer; - pArgs = (pTxBuffer + SIMPLE_LINK_HCI_CMND_TRANSPORT_HEADER_SIZE); - - /* Fill in HCI packet structure */ - - pArgs = UINT32_TO_STREAM(pArgs, mdnsEnabled); - pArgs = UINT32_TO_STREAM(pArgs, 8); - pArgs = UINT32_TO_STREAM(pArgs, deviceServiceNameLength); - ARRAY_TO_STREAM(pArgs, deviceServiceName, deviceServiceNameLength); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_MDNS_ADVERTISE, pTxBuffer, SOCKET_MDNS_ADVERTISE_PARAMS_LEN + deviceServiceNameLength); - - /* Since we are in blocking state - wait for event complete */ - - SimpleLinkWaitEvent(HCI_EVNT_MDNS_ADVERTISE, &ret); - - return ret; -} diff --git a/drivers/wireless/cc3000/spi_version.h b/drivers/wireless/cc3000/spi_version.h deleted file mode 100644 index 607988fb0e..0000000000 --- a/drivers/wireless/cc3000/spi_version.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -* -* spi_version.h - CC3000 Host Driver Implementation. -* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* 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. -* -* Neither the name of Texas Instruments Incorporated 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_CC3000_SPI_VERSION_H -#define __DRIVERS_WIRELESS_CC3000_SPI_VERSION_H - -#define SPI_VERSION_NUMBER 7 - -#endif /* __DRIVERS_WIRELESS_CC3000_SPI_VERSION_H */ diff --git a/drivers/wireless/cc3000/wlan.c b/drivers/wireless/cc3000/wlan.c deleted file mode 100644 index 2e23343935..0000000000 --- a/drivers/wireless/cc3000/wlan.c +++ /dev/null @@ -1,1395 +0,0 @@ -/**************************************************************************** - * drivers/wireless/cc3000/wlan.c - CC3000 Host Driver Implementation. - * - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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 -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include "cc3000.h" -#include "cc3000drv.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define SMART_CONFIG_PROFILE_SIZE 67 /* 67 = 32 (max ssid) + 32 (max key) + - * 1 (SSID length) + 1 (security type) + - * 1 (key length) */ - -/* SOCKET_SELECT_PARAMS_LEN + SPI_HEADER_SIZE++SIMPLE_LINK_HCI_DATA_HEADER_SIZ */ - -#define MAX_HCI_CMD_LENGTH (44+SIMPLE_LINK_HCI_DATA_HEADER_SIZE+SPI_HEADER_SIZE) - -/* Patches type */ - -#define PATCHES_HOST_TYPE_WLAN_DRIVER 0x01 -#define PATCHES_HOST_TYPE_WLAN_FW 0x02 -#define PATCHES_HOST_TYPE_BOOTLOADER 0x03 - -#define SL_SET_SCAN_PARAMS_INTERVAL_LIST_SIZE (16) -#define SL_SIMPLE_CONFIG_PREFIX_LENGTH (3) -#define ETH_ALEN (6) -#define MAXIMAL_SSID_LENGTH (32) - -#define SL_PATCHES_REQUEST_DEFAULT (0) -#define SL_PATCHES_REQUEST_FORCE_HOST (1) -#define SL_PATCHES_REQUEST_FORCE_NONE (2) - -#define WLAN_SEC_UNSEC (0) -#define WLAN_SEC_WEP (1) -#define WLAN_SEC_WPA (2) -#define WLAN_SEC_WPA2 (3) - -#define WLAN_SL_INIT_START_PARAMS_LEN (1) -#define WLAN_PATCH_PARAMS_LENGTH (8) -#define WLAN_SET_CONNECTION_POLICY_PARAMS_LEN (12) -#define WLAN_DEL_PROFILE_PARAMS_LEN (4) -#define WLAN_SET_MASK_PARAMS_LEN (4) -#define WLAN_SET_SCAN_PARAMS_LEN (100) -#define WLAN_GET_SCAN_RESULTS_PARAMS_LEN (4) -#define WLAN_ADD_PROFILE_NOSEC_PARAM_LEN (24) -#define WLAN_ADD_PROFILE_WEP_PARAM_LEN (36) -#define WLAN_ADD_PROFILE_WPA_PARAM_LEN (44) -#define WLAN_CONNECT_PARAM_LEN (29) -#define WLAN_SMART_CONFIG_START_PARAMS_LEN (4) - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -volatile sSimplLinkInformation tSLInformation; -#ifndef CC3000_UNENCRYPTED_SMART_CONFIG -uint8_t akey[AES128_KEY_SIZE]; -uint8_t profileArray[SMART_CONFIG_PROFILE_SIZE]; -#endif /* CC3000_UNENCRYPTED_SMART_CONFIG */ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ -/**************************************************************************** - * Name: SimpleLink_Init_Start - * - * Input Parameters: - * usPatchesAvailableAtHost flag to indicate if patches available - * from host or from EEPROM. Due to the - * fact the patches are burn to the EEPROM - * using the patch programmer utility, the - * patches will be available from the EEPROM - * and not from the host. - * - * Returned Value: - * None - * - * Description: - * Send HCI_CMND_SIMPLE_LINK_START to CC3000 - * - ****************************************************************************/ - -static void SimpleLink_Init_Start(uint16_t usPatchesAvailableAtHost) -{ - uint8_t *ptr; - uint8_t *args; - - ptr = tSLInformation.pucTxCommandBuffer; - args = (uint8_t *)(ptr + HEADERS_SIZE_CMD); - - if (usPatchesAvailableAtHost <= SL_PATCHES_REQUEST_DEFAULT || - usPatchesAvailableAtHost > SL_PATCHES_REQUEST_FORCE_NONE) - { - usPatchesAvailableAtHost = SL_PATCHES_REQUEST_DEFAULT; - } - - UINT8_TO_STREAM(args, usPatchesAvailableAtHost); - - /* IRQ Line asserted - send HCI_CMND_SIMPLE_LINK_START to CC3000 */ - - hci_command_send(HCI_CMND_SIMPLE_LINK_START, ptr, WLAN_SL_INIT_START_PARAMS_LEN); - - SimpleLinkWaitEvent(HCI_CMND_SIMPLE_LINK_START, 0); -} - -/**************************************************************************** - * Name: wlan_init - * - * Input Parameters: - * sWlanCB Asynchronous events callback. - * 0 no event call back. - * - call back parameters: - * 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event, - * HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event, - * HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done, - * HCI_EVNT_WLAN_UNSOL_DHCP dhcp report, - * HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR - * HCI_EVNT_WLAN_KEEPALIVE keepalive. - * 2) data: pointer to extra data that received by the event - * (NULL no data). - * 3) length: data length. - * - Events with extra data: - * HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask, - * 4 bytes default gateway, 4 bytes DHCP server and 4 bytes - * for DNS server. - * HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent, - * 4 bytes Packets received, 4 bytes Min round time, - * 4 bytes Max round time and 4 bytes for Avg round time. - * - * sFWPatches 0 no patch or pointer to FW patches - * sDriverPatches 0 no patch or pointer to driver patches - * sBootLoaderPatches 0 no patch or pointer to bootloader patches - * - * Returned Value: - * None - * - * Description: - * Initialize wlan driver - * - * WARNING: This function must be called before ANY other wlan driver function - * - ****************************************************************************/ - -void wlan_init(size_t max_tx_len, - tWlanCB sWlanCB, - tFWPatches sFWPatches, - tDriverPatches sDriverPatches, - tBootLoaderPatches sBootLoaderPatches) -{ - void *old = NULL; - - cc3000_lib_lock(); - tSLInformation.sFWPatches = sFWPatches; - tSLInformation.sDriverPatches = sDriverPatches; - tSLInformation.sBootLoaderPatches = sBootLoaderPatches; - - /* Allocate the memory for the RX/TX data transactions */ - - if (tSLInformation.pucTxCommandBuffer != NULL) - { - old = tSLInformation.pucTxCommandBuffer; - } - - tSLInformation.pucTxCommandBuffer = malloc(max_tx_len); - tSLInformation.usrBuffer.pbuffer = &tSLInformation.pucTxCommandBuffer[MAX_HCI_CMD_LENGTH]; - tSLInformation.usrBuffer.len = max_tx_len - MAX_HCI_CMD_LENGTH; - - /* Init I/O callback */ - /* Init asynchronous events callback */ - - tSLInformation.sWlanCB = sWlanCB; - - /* By default TX Complete events are routed to host too */ - - tSLInformation.InformHostOnTxComplete = 1; - cc3000_lib_unlock(); - - if (old) - { - free(old); - } -} - -/**************************************************************************** - * Name: SpiReceiveHandler - * - * Input Parameters: - * pvBuffer - pointer to the received data buffer - * - * Returned Value: - * None - * - * Description: - * The function triggers Received event/data processing. It is - * called from the SPI library to receive the data - * - ****************************************************************************/ - -void SpiReceiveHandler(void *pvBuffer) -{ - uint16_t event_type; - - tSLInformation.pucReceivedData = (uint8_t *)pvBuffer; - tSLInformation.usEventOrDataReceived = 1; - - STREAM_TO_UINT16((char *)tSLInformation.pucReceivedData, - HCI_EVENT_OPCODE_OFFSET, event_type); - - ninfo("Evnt:0x%x\n", event_type); - UNUSED(event_type); - - hci_unsolicited_event_handler(); -} - -/**************************************************************************** - * Name: wlan_start - * - * Input Parameters: - * usPatchesAvailableAtHost - flag to indicate if patches available - * from host or from EEPROM. Due to the - * fact the patches are burn to the EEPROM - * using the patch programmer utility, the - * patches will be available from the EEPROM - * and not from the host. - * - * Returned Value: - * None - * - * Description: - * Start WLAN device. This function asserts the enable pin of - * the device (WLAN_EN), starting the HW initialization process. - * The function blocked until device Initialization is completed. - * Function also configure patches (FW, driver or bootloader) - * and calls appropriate device callbacks. - * - * NOTE: Prior calling the function wlan_init shall be called. - * WARNING: This function must be called after wlan_init and before any - * other wlan API - * - ****************************************************************************/ - -void wlan_start(uint16_t usPatchesAvailableAtHost) -{ - cc3000_lib_lock(); - - tSLInformation.NumberOfSentPackets = 0; - tSLInformation.NumberOfReleasedPackets = 0; - tSLInformation.usRxEventOpcode = 0; - tSLInformation.usNumberOfFreeBuffers = 0; - tSLInformation.usSlBufferLength = 0; - tSLInformation.usBufferSize = 0; - tSLInformation.usRxDataPending = 0; - tSLInformation.slTransmitDataError = 0; - tSLInformation.usEventOrDataReceived = 0; - tSLInformation.pucReceivedData = 0; - - /* Init spi */ - - cc3000_open(SpiReceiveHandler); - - SimpleLink_Init_Start(usPatchesAvailableAtHost); - - /* Read Buffer's size and finish */ - - hci_command_send(HCI_CMND_READ_BUFFER_SIZE, tSLInformation.pucTxCommandBuffer, 0); - SimpleLinkWaitEvent(HCI_CMND_READ_BUFFER_SIZE, 0); - cc3000_lib_unlock(); -} - -/**************************************************************************** - * Name: wlan_get_buffer - * - * Input Parameters: - * pdes - Location to return the buffer pointer. - * - * Returned Value: - * None - * - ****************************************************************************/ - -void wlan_get_buffer(wlan_buffer_desc *pdes) -{ - *pdes = tSLInformation.usrBuffer; -} - -/**************************************************************************** - * Name: wlan_stop - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - * Description: - * Stop WLAN device by putting it into reset state. - * - ****************************************************************************/ - -void wlan_stop(void) -{ - cc3000_lib_lock(); - cc3000_close(); - cc3000_lib_unlock(); -} - -/**************************************************************************** - * Name: wlan_connect - * - * Input Parameters: - * sec_type security options: - * WLAN_SEC_UNSEC, - * WLAN_SEC_WEP (ASCII support only), - * WLAN_SEC_WPA or WLAN_SEC_WPA2 - * ssid up to 32 bytes and is ASCII SSID of the AP - * ssid_len length of the SSID - * bssid 6 bytes specified the AP bssid - * key up to 16 bytes specified the AP security key - * key_len key length - * - * Returned Value: - * On success, zero is returned. On error, negative is returned. - * Note that even though a zero is returned on success to trigger - * connection operation, it does not mean that CCC3000 is already - * connected. An asynchronous "Connected" event is generated when - * actual association process finishes and CC3000 is connected to - * the AP. If DHCP is set, An asynchronous "DHCP" event is - * generated when DHCP process is finish. - * - * Description: - * Connect to AP - * - * WARNING: Please Note that when connection to AP configured with security - * type WEP, please confirm that the key is set as ASCII and not - * as HEX. - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long wlan_connect(unsigned long ulSecType, FAR const char *ssid, - long ssid_len, FAR const uint8_t *bssid, - FAR const uint8_t *key, long key_len) -{ - long ret; - uint8_t *ptr; - uint8_t *args; - uint8_t bssid_zero[] = {0, 0, 0, 0, 0, 0}; - - cc3000_lib_lock(); - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in command buffer */ - - args = UINT32_TO_STREAM(args, 0x0000001c); - args = UINT32_TO_STREAM(args, ssid_len); - args = UINT32_TO_STREAM(args, ulSecType); - args = UINT32_TO_STREAM(args, 0x00000010 + ssid_len); - args = UINT32_TO_STREAM(args, key_len); - args = UINT16_TO_STREAM(args, 0); - - /* Padding shall be zeroed */ - - if (bssid) - { - ARRAY_TO_STREAM(args, bssid, ETH_ALEN); - } - else - { - ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN); - } - - ARRAY_TO_STREAM(args, ssid, ssid_len); - - if (key_len && key) - { - ARRAY_TO_STREAM(args, key, key_len); - } - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_WLAN_CONNECT, ptr, WLAN_CONNECT_PARAM_LEN + - ssid_len + key_len - 1); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_CMND_WLAN_CONNECT, &ret); - set_errno(ret); - cc3000_lib_unlock(); - return ret; -} -#else -long wlan_connect(FAR const char *ssid, long ssid_len) -{ - long ret; - uint8_t *ptr; - uint8_t *args; - uint8_t bssid_zero[] = {0, 0, 0, 0, 0, 0}; - - cc3000_lib_lock(); - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in command buffer */ - - args = UINT32_TO_STREAM(args, 0x0000001c); - args = UINT32_TO_STREAM(args, ssid_len); - args = UINT32_TO_STREAM(args, 0); - args = UINT32_TO_STREAM(args, 0x00000010 + ssid_len); - args = UINT32_TO_STREAM(args, 0); - args = UINT16_TO_STREAM(args, 0); - - /* Padding shall be zeroed */ - - ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN); - ARRAY_TO_STREAM(args, ssid, ssid_len); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_WLAN_CONNECT, ptr, WLAN_CONNECT_PARAM_LEN + - ssid_len - 1); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_CMND_WLAN_CONNECT, &ret); - set_errno(ret); - - cc3000_lib_unlock(); - - return ret; -} -#endif - -/**************************************************************************** - * Name: wlan_disconnect - * - * Input Parameters: - * None - * - * Returned Value: - * 0 disconnected done, other CC3000 already disconnected - * - * Description: - * Disconnect connection from AP. - * - ****************************************************************************/ - -long wlan_disconnect(void) -{ - long ret; - uint8_t *ptr; - - cc3000_lib_lock(); - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - - hci_command_send(HCI_CMND_WLAN_DISCONNECT, ptr, 0); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_CMND_WLAN_DISCONNECT, &ret); - set_errno(ret); - - cc3000_lib_unlock(); - - return ret; -} - -/**************************************************************************** - * Name: wlan_ioctl_set_connection_policy - * - * Input Parameters: - * should_connect_to_open_ap enable(1), disable(0) connect to any - * available AP. This parameter corresponds to the configuration of - * item # 3 in the brief description. - * should_use_fast_connect enable(1), disable(0). if enabled, tries - * to connect to the last connected AP. This parameter corresponds - * to the configuration of item # 1 in the brief description. - * auto_start enable(1), disable(0) auto connect - * after reset and periodically reconnect if needed. This - * configuration configures option 2 in the above description. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * When auto is enabled, the device tries to connect according - * the following policy: - * 1) If fast connect is enabled and last connection is valid, - * the device will try to connect to it without the scanning - * procedure (fast). The last connection will be marked as - * invalid, due to adding/removing profile. - * 2) If profile exists, the device will try to connect it - * (Up to seven profiles). - * 3) If fast and profiles are not found, and open mode is - * enabled, the device will try to connect to any AP. - * * Note that the policy settings are stored in the CC3000 NVMEM. - * - ****************************************************************************/ - -long wlan_ioctl_set_connection_policy(unsigned long should_connect_to_open_ap, - unsigned long ulShouldUseFastConnect, - unsigned long ulUseProfiles) -{ - long ret; - uint8_t *ptr; - uint8_t *args; - - cc3000_lib_lock(); - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (uint8_t *)(ptr + HEADERS_SIZE_CMD); - - /* Fill in HCI packet structure */ - - args = UINT32_TO_STREAM(args, should_connect_to_open_ap); - args = UINT32_TO_STREAM(args, ulShouldUseFastConnect); - args = UINT32_TO_STREAM(args, ulUseProfiles); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY, - ptr, WLAN_SET_CONNECTION_POLICY_PARAMS_LEN); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY, &ret); - - cc3000_lib_unlock(); - return ret; -} - -/**************************************************************************** - * Name: wlan_add_profile - * - * Input Parameters: - * ulSecType WLAN_SEC_UNSEC,WLAN_SEC_WEP,WLAN_SEC_WPA,WLAN_SEC_WPA2 - * ucSsid ssid SSID up to 32 bytes - * ulSsidLen ssid length - * ucBssid bssid 6 bytes - * ulPriority ulPriority profile priority. Lowest priority:0. - * ulPairwiseCipher_Or_TxKeyLen key length for WEP security - * ulGroupCipher_TxKeyIndex key index - * ulKeyMgmt KEY management - * ucPf_OrKey security key - * ulPassPhraseLen security key length for WPA\WPA2 - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * When auto start is enabled, the device connects to - * station from the profiles table. Up to 7 profiles are supported. - * If several profiles configured the device choose the highest - * priority profile, within each priority group, device will choose - * profile based on security policy, signal strength, etc - * parameters. All the profiles are stored in CC3000 NVMEM. - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long wlan_add_profile(unsigned long ulSecType, uint8_t *ucSsid, - unsigned long ulSsidLen, uint8_t *ucBssid, - unsigned long ulPriority, - unsigned long ulPairwiseCipher_Or_TxKeyLen, - unsigned long ulGroupCipher_TxKeyIndex, - unsigned long ulKeyMgmt, uint8_t *ucPf_OrKey, - unsigned long ulPassPhraseLen) -{ - uint16_t arg_len = 0; - long ret; - uint8_t *ptr; - long i = 0; - uint8_t *args; - uint8_t bssid_zero[] = {0, 0, 0, 0, 0, 0}; - - cc3000_lib_lock(); - - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - args = UINT32_TO_STREAM(args, ulSecType); - - /* Setup arguments in accordance with the security type */ - - switch (ulSecType) - { - /* OPEN */ - - case WLAN_SEC_UNSEC: - { - args = UINT32_TO_STREAM(args, 0x00000014); - args = UINT32_TO_STREAM(args, ulSsidLen); - args = UINT16_TO_STREAM(args, 0); - if (ucBssid) - { - ARRAY_TO_STREAM(args, ucBssid, ETH_ALEN); - } - else - { - ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN); - } - - args = UINT32_TO_STREAM(args, ulPriority); - ARRAY_TO_STREAM(args, ucSsid, ulSsidLen); - - arg_len = WLAN_ADD_PROFILE_NOSEC_PARAM_LEN + ulSsidLen; - } - break; - - /* WEP */ - - case WLAN_SEC_WEP: - { - args = UINT32_TO_STREAM(args, 0x00000020); - args = UINT32_TO_STREAM(args, ulSsidLen); - args = UINT16_TO_STREAM(args, 0); - if (ucBssid) - { - ARRAY_TO_STREAM(args, ucBssid, ETH_ALEN); - } - else - { - ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN); - } - - args = UINT32_TO_STREAM(args, ulPriority); - args = UINT32_TO_STREAM(args, 0x0000000C + ulSsidLen); - args = UINT32_TO_STREAM(args, ulPairwiseCipher_Or_TxKeyLen); - args = UINT32_TO_STREAM(args, ulGroupCipher_TxKeyIndex); - ARRAY_TO_STREAM(args, ucSsid, ulSsidLen); - - for (i = 0; i < 4; i++) - { - uint8_t *p = &ucPf_OrKey[i * ulPairwiseCipher_Or_TxKeyLen]; - - ARRAY_TO_STREAM(args, p, ulPairwiseCipher_Or_TxKeyLen); - } - - arg_len = WLAN_ADD_PROFILE_WEP_PARAM_LEN + ulSsidLen + - ulPairwiseCipher_Or_TxKeyLen * 4; - } - break; - - /* WPA, WPA2 */ - - case WLAN_SEC_WPA: - case WLAN_SEC_WPA2: - { - args = UINT32_TO_STREAM(args, 0x00000028); - args = UINT32_TO_STREAM(args, ulSsidLen); - args = UINT16_TO_STREAM(args, 0); - if (ucBssid) - { - ARRAY_TO_STREAM(args, ucBssid, ETH_ALEN); - } - else - { - ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN); - } - - args = UINT32_TO_STREAM(args, ulPriority); - args = UINT32_TO_STREAM(args, ulPairwiseCipher_Or_TxKeyLen); - args = UINT32_TO_STREAM(args, ulGroupCipher_TxKeyIndex); - args = UINT32_TO_STREAM(args, ulKeyMgmt); - args = UINT32_TO_STREAM(args, 0x00000008 + ulSsidLen); - args = UINT32_TO_STREAM(args, ulPassPhraseLen); - ARRAY_TO_STREAM(args, ucSsid, ulSsidLen); - ARRAY_TO_STREAM(args, ucPf_OrKey, ulPassPhraseLen); - - arg_len = WLAN_ADD_PROFILE_WPA_PARAM_LEN + ulSsidLen + ulPassPhraseLen; - } - break; - } - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_WLAN_IOCTL_ADD_PROFILE, - ptr, arg_len); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_ADD_PROFILE, &ret); - cc3000_lib_unlock(); - return ret; -} -#else -long wlan_add_profile(unsigned long ulSecType, uint8_t * ucSsid, uint8_t ulSsidLen, - uint8_t *ucBssid, unsigned long ulPriority, - unsigned long ulPairwiseCipher_Or_TxKeyLen, - unsigned long ulGroupCipher_TxKeyIndex, - unsigned long ulKeyMgmt, uint8_t * ucPf_OrKey, - unsigned long ulPassPhraseLen) -{ - return -1; -} -#endif - -/**************************************************************************** - * Name: wlan_ioctl_del_profile - * - * Input Parameters: - * index number of profile to delete - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * Delete WLAN profile - * - * @Note In order to delete all stored profile, set index to 255. - * - ****************************************************************************/ - -long wlan_ioctl_del_profile(unsigned long ulIndex) -{ - long ret; - uint8_t *ptr; - uint8_t *args; - - cc3000_lib_lock(); - - ptr = tSLInformation.pucTxCommandBuffer; - args = (uint8_t *)(ptr + HEADERS_SIZE_CMD); - - /* Fill in HCI packet structure */ - - args = UINT32_TO_STREAM(args, ulIndex); - ret = EFAIL; - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_WLAN_IOCTL_DEL_PROFILE, - ptr, WLAN_DEL_PROFILE_PARAMS_LEN); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_DEL_PROFILE, &ret); - - cc3000_lib_unlock(); - - return ret; -} - -/**************************************************************************** - * Name: wlan_ioctl_get_scan_results - * - * Input Parameters: - * scan_timeout parameter not supported - * ucResults scan results (_wlan_full_scan_results_args_t) - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * Gets entry from scan result table. - * The scan results are returned one by one, and each entry - * represents a single AP found in the area. The following is a - * format of the scan result: - * - 4 Bytes: number of networks found - * - 4 Bytes: The status of the scan: 0 - aged results, - * 1 - results valid, 2 - no results - * - 42 bytes: Result entry, where the bytes are arranged as follows: - * - 1 bit isValid - is result valid or not - * - 7 bits rssi - RSSI value; - * - 2 bits: securityMode - security mode of the AP: - * 0 - Open, 1 - WEP, 2 WPA, 3 WPA2 - * - 6 bits: SSID name length - * - 2 bytes: the time at which the entry has entered into - * scans result table - * - 32 bytes: SSID name - * - 6 bytes: BSSID - * - * NOTE: scan_timeout, is not supported on this version. - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long wlan_ioctl_get_scan_results(unsigned long ulScanTimeout, uint8_t *ucResults) -{ - uint8_t *ptr; - uint8_t *args; - - cc3000_lib_lock(); - - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in temporary command buffer */ - - args = UINT32_TO_STREAM(args, ulScanTimeout); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS, - ptr, WLAN_GET_SCAN_RESULTS_PARAMS_LEN); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS, ucResults); - - cc3000_lib_unlock(); - - return 0; -} -#endif - -/**************************************************************************** - * Name: wlan_ioctl_set_scan_params - * - * Input Parameters: - * uiEnable - start/stop application scan: - * 1 = start scan with default interval value of 10 min. - * in order to set a different scan interval value apply the value - * in milliseconds. minimum 1 second. 0=stop). Wlan reset - * (wlan_stop() wlan_start()) is needed when changing scan interval - * value. Saved: No - * uiMinDwellTime minimum dwell time value to be used for each - * channel, in milliseconds. Saved: yes - * Recommended Value: 100 (Default: 20) - * uiMaxDwellTime maximum dwell time value to be used for each - * channel, in milliseconds. Saved: yes - * Recommended Value: 100 (Default: 30) - * uiNumOfProbeRequests max probe request between dwell time. - * Saved: yes. Recommended Value: 5 (Default:2) - * uiChannelMask bitwise, up to 13 channels (0x1fff). - * Saved: yes. Default: 0x7ff - * uiRSSIThreshold RSSI threshold. Saved: yes (Default: -80) - * uiSNRThreshold NSR threshold. Saved: yes (Default: 0) - * uiDefaultTxPower probe Tx power. Saved: yes (Default: 205) - * aiIntervalList pointer to array with 16 entries (16 channels) - * each entry (unsigned long) holds timeout between periodic scan - * (connection scan) - in millisecond. Saved: yes. Default 2000ms. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * start and stop scan procedure. Set scan parameters. - * - * @Note uiDefaultTxPower, is not supported on this version. - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long wlan_ioctl_set_scan_params(unsigned long uiEnable, - unsigned long uiMinDwellTime, - unsigned long uiMaxDwellTime, - unsigned long uiNumOfProbeRequests, - unsigned long uiChannelMask, - long iRSSIThreshold, - unsigned long uiSNRThreshold, - unsigned long uiDefaultTxPower, - unsigned long *aiIntervalList) -{ - unsigned long uiRes; - uint8_t *ptr; - uint8_t *args; - - cc3000_lib_lock(); - - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - /* Fill in temporary command buffer */ - - args = UINT32_TO_STREAM(args, 36); - args = UINT32_TO_STREAM(args, uiEnable); - args = UINT32_TO_STREAM(args, uiMinDwellTime); - args = UINT32_TO_STREAM(args, uiMaxDwellTime); - args = UINT32_TO_STREAM(args, uiNumOfProbeRequests); - args = UINT32_TO_STREAM(args, uiChannelMask); - args = UINT32_TO_STREAM(args, iRSSIThreshold); - args = UINT32_TO_STREAM(args, uiSNRThreshold); - args = UINT32_TO_STREAM(args, uiDefaultTxPower); - ARRAY_TO_STREAM(args, aiIntervalList, sizeof(unsigned long) * - SL_SET_SCAN_PARAMS_INTERVAL_LIST_SIZE); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_WLAN_IOCTL_SET_SCANPARAM, - ptr, WLAN_SET_SCAN_PARAMS_LEN); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_SET_SCANPARAM, &uiRes); - - cc3000_lib_unlock(); - - return uiRes; -} -#endif - -/**************************************************************************** - * Name: wlan_set_event_mask - * - * Input Parameters: - * mask mask option: - * HCI_EVNT_WLAN_UNSOL_CONNECT connect event - * HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event - * HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE smart config done - * HCI_EVNT_WLAN_UNSOL_INIT init done - * HCI_EVNT_WLAN_UNSOL_DHCP dhcp event report - * HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report - * HCI_EVNT_WLAN_KEEPALIVE keepalive - * HCI_EVNT_WLAN_TX_COMPLETE - disable information on end of transmission - * Saved: no. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * Mask event according to bit mask. In case that event is - * masked (1), the device will not send the masked event to host. - * - ****************************************************************************/ - -long wlan_set_event_mask(unsigned long ulMask) -{ - long ret; - uint8_t *ptr; - uint8_t *args; - - cc3000_lib_lock(); - - if ((ulMask & HCI_EVNT_WLAN_TX_COMPLETE) == HCI_EVNT_WLAN_TX_COMPLETE) - { - tSLInformation.InformHostOnTxComplete = 0; - - /* Since an event is a virtual event - i.e. it is not coming from CC3000 - * there is no need to send anything to the device if it was an only event - */ - - if (ulMask == HCI_EVNT_WLAN_TX_COMPLETE) - { - return 0; - } - - ulMask &= ~HCI_EVNT_WLAN_TX_COMPLETE; - ulMask |= HCI_EVNT_WLAN_UNSOL_BASE; - } - else - { - tSLInformation.InformHostOnTxComplete = 1; - } - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (uint8_t *)(ptr + HEADERS_SIZE_CMD); - - /* Fill in HCI packet structure */ - - args = UINT32_TO_STREAM(args, ulMask); - - /* Initiate a HCI command */ - - hci_command_send(HCI_CMND_EVENT_MASK, - ptr, WLAN_SET_MASK_PARAMS_LEN); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_CMND_EVENT_MASK, &ret); - - cc3000_lib_unlock(); - - return ret; -} - -/**************************************************************************** - * Name: wlan_ioctl_statusget - * - * Input Parameters: - * None - * - * Returned Value: - * WLAN_STATUS_DISCONNECTED, WLAN_STATUS_SCANING, - * STATUS_CONNECTING or WLAN_STATUS_CONNECTED - * - * Description: - * get wlan status: disconnected, scanning, connecting or connected - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long wlan_ioctl_statusget(void) -{ - long ret; - uint8_t *ptr; - - cc3000_lib_lock(); - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - - hci_command_send(HCI_CMND_WLAN_IOCTL_STATUSGET, - ptr, 0); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_STATUSGET, &ret); - - cc3000_lib_unlock(); - - return ret; -} -#endif - -/**************************************************************************** - * Name: wlan_smart_config_start - * - * Input Parameters: - * algoEncryptedFlag indicates whether the information is encrypted - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * Start to acquire device profile. The device acquire its own - * profile, if profile message is found. The acquired AP information - * is stored in CC3000 EEPROM only in case AES128 encryption is used. - * In case AES128 encryption is not used, a profile is created by - * CC3000 internally. - * - * @Note An asynchronous event - Smart Config Done will be generated as soon - * as the process finishes successfully. - * - ****************************************************************************/ - -long wlan_smart_config_start(unsigned long algoEncryptedFlag) -{ - long ret; - uint8_t *ptr; - uint8_t *args; - - cc3000_lib_lock(); - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (uint8_t *)(ptr + HEADERS_SIZE_CMD); - - /* Fill in HCI packet structure */ - - args = UINT32_TO_STREAM(args, algoEncryptedFlag); - - hci_command_send(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START, ptr, - WLAN_SMART_CONFIG_START_PARAMS_LEN); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START, &ret); - - cc3000_lib_unlock(); - return ret; -} - -/**************************************************************************** - * Name: wlan_smart_config_stop - * - * Input Parameters: - * algoEncryptedFlag indicates whether the information is encrypted - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * Stop the acquire profile procedure - * - ****************************************************************************/ - -long wlan_smart_config_stop(void) -{ - long ret; - uint8_t *ptr; - - cc3000_lib_lock(); - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - - hci_command_send(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP, ptr, 0); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP, &ret); - - cc3000_lib_unlock(); - return ret; -} - -/**************************************************************************** - * Name: wlan_smart_config_set_prefix - * - * Input Parameters: - * newPrefix 3 bytes identify the SSID prefix for the Smart Config. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * Configure station ssid prefix. The prefix is used internally - * in CC3000. It should always be TTT. - * - * @Note The prefix is stored in CC3000 NVMEM - * - ****************************************************************************/ - -long wlan_smart_config_set_prefix(FAR char *cNewPrefix) -{ - long ret; - uint8_t *ptr; - uint8_t *args; - - cc3000_lib_lock(); - - ret = EFAIL; - ptr = tSLInformation.pucTxCommandBuffer; - args = (ptr + HEADERS_SIZE_CMD); - - if (cNewPrefix == NULL) - { - return ret; - } - - /* With the new Smart Config, prefix must be TTT */ - - else - { - *cNewPrefix = 'T'; - *(cNewPrefix + 1) = 'T'; - *(cNewPrefix + 2) = 'T'; - } - - ARRAY_TO_STREAM(args, cNewPrefix, SL_SIMPLE_CONFIG_PREFIX_LENGTH); - - hci_command_send(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX, ptr, - SL_SIMPLE_CONFIG_PREFIX_LENGTH); - - /* Wait for command complete event */ - - SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX, &ret); - - cc3000_lib_unlock(); - - return ret; -} - -/**************************************************************************** - * Name: aes_read_key - * - * Description: - * Reads AES128 key from EEPROM. Reads the AES128 key from fileID #12 in - * EEPROM returns an error if the key does not exist. - * - * Input Parameters: - * key AES128 key of size 16 bytes - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -#ifndef CC3000_UNENCRYPTED_SMART_CONFIG -signed long aes_read_key(uint8_t *key) -{ - signed long returnValue; - - returnValue = nvmem_read(NVMEM_AES128_KEY_FILEID, AES128_KEY_SIZE, 0, key); - - return returnValue; -} -#endif - -/**************************************************************************** - * Name: aes_write_key - * - * Description: - * Writes AES128 key from EEPROM Writes the AES128 key to fileID #12 in - * EEPROM - * - * Input Parameters: - * key AES128 key of size 16 bytes - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -#if 0 //#ifndef CC3000_UNENCRYPTED_SMART_CONFIG -signed long aes_write_key(uint8_t *key) -{ - signed long returnValue; - - returnValue = nvmem_write(NVMEM_AES128_KEY_FILEID, AES128_KEY_SIZE, 0, key); - - return returnValue; -} -#endif - -/**************************************************************************** - * Name: wlan_smart_config_process - * - * Input Parameters: - * None - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * process the acquired data and store it as a profile. The acquired - * AP information is stored in CC3000 EEPROM encrypted. - * The encrypted data is decrypted and stored as a profile. - * behavior is as defined by connection policy. - * - ****************************************************************************/ - -#ifndef CC3000_UNENCRYPTED_SMART_CONFIG -long wlan_smart_config_process() -{ - signed long returnValue; - unsigned long ssidLen, keyLen; - uint8_t *decKeyPtr; - uint8_t *ssidPtr; - - /* Read the key from EEPROM - fileID 12 */ - - returnValue = aes_read_key(akey); - - if (returnValue != 0) - { - return returnValue; - } - - /* Read the received data from fileID #13 and parse it according to the followings: - * 1) SSID LEN - not encrypted - * 2) SSID - not encrypted - * 3) KEY LEN - not encrypted. always 32 bytes long - * 4) Security type - not encrypted - * 5) KEY - encrypted together with true key length as the first byte in KEY - * to elaborate, there are two corner cases: - * 1) the KEY is 32 bytes long. In this case, the first byte does not represent - * KEY length - * 2) the KEY is 31 bytes long. In this case, the first byte represent KEY - * length and equals 31 - */ - - returnValue = nvmem_read(NVMEM_SHARED_MEM_FILEID, SMART_CONFIG_PROFILE_SIZE, - 0, profileArray); - - if (returnValue != 0) - { - return returnValue; - } - - ssidPtr = &profileArray[1]; - - ssidLen = profileArray[0]; - - decKeyPtr = &profileArray[profileArray[0] + 3]; - - aes_decrypt(decKeyPtr, akey); - if (profileArray[profileArray[0] + 1] > 16) - { - aes_decrypt((uint8_t *)(decKeyPtr + 16), akey); - } - - if (*(uint8_t *)(decKeyPtr +31) != 0) - { - if (*decKeyPtr == 31) - { - keyLen = 31; - decKeyPtr++; - } - else - { - keyLen = 32; - } - } - else - { - keyLen = *decKeyPtr; - decKeyPtr++; - } - - /* Add a profile */ - - switch (profileArray[profileArray[0] + 2]) - { - case WLAN_SEC_UNSEC: /* None */ - { - returnValue = wlan_add_profile(profileArray[profileArray[0] + 2], /* Security type */ - ssidPtr, /* SSID */ - ssidLen, /* SSID length */ - NULL, /* BSSID */ - 1, /* Priority */ - 0, 0, 0, 0, 0); - break; - } - - case WLAN_SEC_WEP: /* WEP */ - { - returnValue = wlan_add_profile(profileArray[profileArray[0] + 2], /* Security type */ - ssidPtr, /* SSID */ - ssidLen, /* SSID length */ - NULL, /* BSSID */ - 1, /* Priority */ - keyLen, /* KEY length */ - 0, /* KEY index */ - 0, - decKeyPtr, /* KEY */ - 0); - break; - } - - case WLAN_SEC_WPA: /* WPA */ - case WLAN_SEC_WPA2: /* WPA2 */ - { - returnValue = wlan_add_profile(WLAN_SEC_WPA2, /* Security type */ - ssidPtr, - ssidLen, - NULL, /* BSSID */ - 1, /* Priority */ - 0x18, /* PairwiseCipher */ - 0x1e, /* GroupCipher */ - 2, /* KEY management */ - decKeyPtr, /* KEY */ - keyLen); /* KEY length */ - break; - } - } - - return returnValue; -} -#endif /* CC3000_UNENCRYPTED_SMART_CONFIG */ diff --git a/drivers/wireless/ieee802154/at86rf23x/at86rf23x.c b/drivers/wireless/ieee802154/at86rf23x/at86rf23x.c index cfd5dd0488..c32fec963d 100644 --- a/drivers/wireless/ieee802154/at86rf23x/at86rf23x.c +++ b/drivers/wireless/ieee802154/at86rf23x/at86rf23x.c @@ -196,10 +196,8 @@ static int at86rf23x_transmit(FAR struct ieee802154_radio_s *ieee, ****************************************************************************/ /* These are pointers to ALL registered at86rf23x devices. - * This table is used during irqs to find the context + * This table is used during interrupt handling to find the context. * Only one device is supported for now. - * More devices can be supported in the future by lookup them up - * using the IRQ number. See the ENC28J60 or CC3000 drivers for reference. */ static struct at86rf23x_dev_s g_at86rf23x_devices[1]; diff --git a/include/nuttx/wireless/cc3000.h b/include/nuttx/wireless/cc3000.h deleted file mode 100644 index 0350578b39..0000000000 --- a/include/nuttx/wireless/cc3000.h +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************************** - * include/nuttx/wireless/cc3000.h - * - * Copyright (C) 2011, 2017 Gregory Nutt. All rights reserved. - * Authors: Gregory Nutt - * David Sidrane - * - * References: - * CC30000 from Texas Instruments http://processors.wiki.ti.com/index.php/CC3000 - * - * See also: - * http://processors.wiki.ti.com/index.php/CC3000_Host_Driver_Porting_Guide - * http://processors.wiki.ti.com/index.php/CC3000_Host_Programming_Guide - * - * 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_CC3000_H -#define __INCLUDE_NUTTX_WIRELESS_CC3000_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define DEV_FORMAT "/dev/wireless%d" /* The device Name*/ -#define DEV_NAMELEN 17 /* The buffer size to hold formatted string*/ - -#define QUEUE_FORMAT "wlq%d" /* The Queue name */ -#define QUEUE_NAMELEN 8 /* The buffer size to hold formatted string*/ - -#define SEM_FORMAT "wls%d" /* The Spi Resume Senaphore name*/ -#define SEM_NAMELEN 8 /* The buffer size to hold formatted string*/ - -/* IOCTL commands */ - -#define CC3000IOC_GETQUESEMID _WLCIOC(CC3000_FIRST+0) /* arg: Address of int for number*/ -#define CC3000IOC_ADDSOCKET _WLCIOC(CC3000_FIRST+1) /* arg: Address of int for result*/ -#define CC3000IOC_REMOVESOCKET _WLCIOC(CC3000_FIRST+2) /* arg: Address of int for result*/ -#define CC3000IOC_SELECTDATA _WLCIOC(CC3000_FIRST+3) /* arg: Address of int for result*/ -#define CC3000IOC_SELECTACCEPT _WLCIOC(CC3000_FIRST+4) /* arg: Address of struct cc3000_acceptcfg_s */ -#define CC3000IOC_SETRX_SIZE _WLCIOC(CC3000_FIRST+5) /* arg: Address of int for new size */ -#define CC3000IOC_REMOTECLOSEDSOCKET _WLCIOC(CC3000_FIRST+6) /* arg: Address of int for result*/ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -typedef char *(*tFWPatches)(unsigned long *usLength); -typedef char *(*tDriverPatches)(unsigned long *usLength); -typedef char *(*tBootLoaderPatches)(unsigned long *usLength); -typedef void (*tWlanCB)(long event_type, char * data, unsigned char length); - -typedef struct cc3000_buffer_desc_s -{ - uint8_t *pbuffer; - ssize_t len; -} cc3000_buffer_desc; - -typedef struct cc3000_acceptcfg_s -{ - int sockfd; - struct sockaddr *addr; - socklen_t *addrlen; - -} cc3000_acceptcfg; - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -/**************************************************************************** - * Name: wlan_init - * - * Description: - * Initialize wlan driver - * - * WARNING: This function must be called before ANY other wlan driver function - * - * Input Parameters: - * sWlanCB Asynchronous events callback. - * 0 no event call back. - * - call back parameters: - * 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event, - * HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event, - * HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done, - * HCI_EVNT_WLAN_UNSOL_DHCP dhcp report, - * HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR - * HCI_EVNT_WLAN_KEEPALIVE keepalive. - * 2) data: pointer to extra data that received by the event - * (NULL no data). - * 3) length: data length. - * - Events with extra data: - * HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask, - * 4 bytes default gateway, 4 bytes DHCP server and 4 bytes - * for DNS server. - * HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent, - * 4 bytes Packets received, 4 bytes Min round time, - * 4 bytes Max round time and 4 bytes for Avg round time. - * - * sFWPatches 0 no patch or pointer to FW patches - * sDriverPatches 0 no patch or pointer to driver patches - * sBootLoaderPatches 0 no patch or pointer to bootloader patches - * - * Returned Value: - * None - * - ****************************************************************************/ - -void wlan_init(size_t max_tx_len, - tWlanCB sWlanCB, tFWPatches sFWPatches, - tDriverPatches sDriverPatches, - tBootLoaderPatches sBootLoaderPatches); - -void cc3000_wlan_init(size_t max_tx_len, - tWlanCB sWlanCB, - tFWPatches sFWPatches, - tDriverPatches sDriverPatches, - tBootLoaderPatches sBootLoaderPatches); - -/************************************************************************************ - * Name: wireless_archinitialize - * - * Description: - * Called to configure wireless module (wireless_archinitialize). - * - ************************************************************************************/ - -int wireless_archinitialize(size_t max_rx_size); - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* __INCLUDE_NUTTX_WIRELESS_CC3000_H */ diff --git a/include/nuttx/wireless/cc3000/cc3000_common.h b/include/nuttx/wireless/cc3000/cc3000_common.h deleted file mode 100644 index 857c6560b3..0000000000 --- a/include/nuttx/wireless/cc3000/cc3000_common.h +++ /dev/null @@ -1,394 +0,0 @@ -/**************************************************************************** - * cc3000_common.h - CC3000 Host Driver Implementation. - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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_CC3000_CC3300_COMMON_H -#define __INCLUDE_NUTTX_WIRELESS_CC3000_CC3300_COMMON_H - -/**************************************************************************** - * Included files - ****************************************************************************/ - -#include -#include - -#include -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Error codes */ - -#define ESUCCESS 0 -#define EFAIL -1 -#define EERROR EFAIL - -/* Common definitions */ - -#define ERROR_SOCKET_INACTIVE -57 - -#define WLAN_ENABLE (1) -#define WLAN_DISABLE (0) - -#define MAC_ADDR_LEN (6) - -#define SP_PORTION_SIZE (32) - -/* Defines for minimal and maximal RX buffer size. This size includes the spi - * header and hci header. - * The maximal buffer size derives from: - * MTU + HCI header + SPI header + sendto() agrs size - * The minimum buffer size derives from: - * HCI header + SPI header + max args size - * - * This buffer is used for receiving events and data. - * The packet can not be longer than MTU size and CC3000 does not support - * fragmentation. Note that the same buffer is used for reception of the data - * and events from CC3000. That is why the minimum is defined. - * The calculation for the actual size of buffer for reception is: - * Given the maximal data size MAX_DATA that is expected to be received by - * application, the required buffer is: - * Using recv() or recvfrom(): - * - * max(CC3000_MINIMAL_RX_SIZE, MAX_DATA + HEADERS_SIZE_DATA + fromlen - * + ucArgsize + 1) - * - * Using gethostbyname() with minimal buffer size will limit the host name - * returned to 99 bytes only. - * The 1 is used for the overrun detection - * - * Buffer size increased to 130 following the add_profile() with WEP security - * which requires TX buffer size of 130 bytes: - * HEADERS_SIZE_EVNT + WLAN_ADD_PROFILE_WEP_PARAM_LEN + MAX SSID LEN + 4 * MAX KEY LEN = 130 - * MAX SSID LEN = 32 - * MAX SSID LEN = 13 (with add_profile only ascii key setting is supported, - * therfore maximum key size is 13) - */ - -#define CC3000_MINIMAL_RX_SIZE (130 + 1) -#define CC3000_MAXIMAL_RX_SIZE (1519 + 1) - -/* Defines for minimal and maximal TX buffer size. - * This buffer is used for sending events and data. - * The packet can not be longer than MTU size and CC3000 does not support - * fragmentation. Note that the same buffer is used for transmission of the - * data and commands. That is why the minimum is defined. - * The calculation for the actual size of buffer for transmission is: - * Given the maximal data size MAX_DATA, the required buffer is: - * Using Sendto(): - * - * max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE - * + SOCKET_SENDTO_PARAMS_LEN + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1) - * - * Using Send(): - * - * max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE - * + HCI_CMND_SEND_ARG_LENGTH + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1) - * - * The 1 is used for the overrun detection - */ - -#define CC3000_MINIMAL_TX_SIZE (130 + 1) -#define CC3000_MAXIMAL_TX_SIZE (1519 + 1) - -/* TX and RX buffer sizes, allow to receive and transmit maximum data at - * length 8. - */ - -#ifdef CC3000_TINY_DRIVER -# define TINY_CC3000_MAXIMAL_RX_SIZE 44 -# define TINY_CC3000_MAXIMAL_TX_SIZE 59 -#endif - -/* In order to determine your preferred buffer size, - * change CC3000_MAXIMAL_RX_SIZE and CC3000_MAXIMAL_TX_SIZE to a value between - * the minimal and maximal specified above. - * Note that the buffers are allocated by SPI. - * In case you change the size of those buffers, you might need also to change - * the linker file, since for example on MSP430 FRAM devices the buffers are - * allocated in the FRAM section that is allocated manually and not by IDE. - */ - -#ifndef CC3000_TINY_DRIVER -# define CC3000_RX_BUFFER_SIZE (CC3000_MAXIMAL_RX_SIZE) -# define CC3000_TX_BUFFER_SIZE (CC3000_MAXIMAL_TX_SIZE) - -/* if defined TINY DRIVER we use smaller RX and TX buffer in order to minimize - * RAM consumption - */ - -#else -# define CC3000_RX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_RX_SIZE) -# define CC3000_TX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_TX_SIZE) -#endif - -/* This macro is used for copying 8 bit to stream while converting to little - * endian format. - */ - -#define UINT8_TO_STREAM(_p, _val) {*(_p)++ = (_val);} - -/* This macro is used for copying 16 bit to stream while converting to little - * endian format. - */ - -#define UINT16_TO_STREAM(_p, _u16) (UINT16_TO_STREAM_f(_p, _u16)) - -/* This macro is used for copying 32 bit to stream while converting to little - * endian format. - */ - -#define UINT32_TO_STREAM(_p, _u32) (UINT32_TO_STREAM_f(_p, _u32)) - -/* This macro is used for copying a specified value length bits (l) to stream - * while converting to little endian format. - */ - -#define ARRAY_TO_STREAM(p, a, l) {register int16_t _i; for (_i = 0; _i < l; _i++) *(p)++ = ((uint8_t *) a)[_i];} - -/* This macro is used for copying received stream to 8 bit in little endian - * format. - */ - -#define STREAM_TO_UINT8(_p, _offset, _u8) {_u8 = (uint8_t)(*(_p + _offset));} - -/* This macro is used for copying received stream to 16 bit in little endian - * format. - */ - -#define STREAM_TO_UINT16(_p, _offset, _u16) {_u16 = STREAM_TO_UINT16_f(_p, _offset);} - -/* This macro is used for copying received stream to 32 bit in little endian - * format. - */ - -#define STREAM_TO_UINT32(_p, _offset, _u32) {_u32 = STREAM_TO_UINT32_f(_p, _offset);} -#define STREAM_TO_STREAM(p, a, l) {register int16_t _i; for (_i = 0; _i < l; _i++) *(a)++= ((uint8_t *) p)[_i];} - - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -typedef struct wlan_buffer_desc_s -{ - uint8_t *pbuffer; - ssize_t len; -} wlan_buffer_desc; - -typedef char *(*tFWPatches)(unsigned long *usLength); - -typedef char *(*tDriverPatches)(unsigned long *usLength); - -typedef char *(*tBootLoaderPatches)(unsigned long *usLength); - -typedef void (*tWlanCB)(long event_type, char * data, uint8_t length ); - -typedef long (*tWlanReadInteruptPin)(void); - -typedef void (*tWlanInterruptEnable)(void); - -typedef void (*tWlanInterruptDisable)(void); - -typedef void (*tWriteWlanPin)(uint8_t val); - -typedef struct -{ - uint16_t usRxEventOpcode; - uint16_t usEventOrDataReceived; - uint8_t *pucReceivedData; - uint8_t *pucTxCommandBuffer; - wlan_buffer_desc usrBuffer; - - tFWPatches sFWPatches; - tDriverPatches sDriverPatches; - tBootLoaderPatches sBootLoaderPatches; - tWlanCB sWlanCB; - - signed long slTransmitDataError; - uint16_t usNumberOfFreeBuffers; - uint16_t usSlBufferLength; - uint16_t usBufferSize; - uint16_t usRxDataPending; - - unsigned long NumberOfSentPackets; - unsigned long NumberOfReleasedPackets; - - uint8_t InformHostOnTxComplete; -} sSimplLinkInformation; - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -extern volatile sSimplLinkInformation tSLInformation; - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: wlan_get_buffer - * - * Input Parameters: - * pdes - Location to return the buffer pointer. - * - * Returned Value: - * None - * - ****************************************************************************/ - -void wlan_get_buffer(wlan_buffer_desc *pdes); - -/**************************************************************************** - * Name: SimpleLinkWaitEvent - * - * Description: - * Wait for event, pass it to the hci_event_handler and update the event - * opcode in a global variable. - * - * Input Parameters: - * usOpcode command operation code - * pRetParams command return parameters - * - * Returned Value: - * None - * - ****************************************************************************/ - -void SimpleLinkWaitEvent(uint16_t usOpcode, void *pRetParams); - -/**************************************************************************** - * Name: SimpleLinkWaitData - * - * Description: - * Wait for data, pass it to the hci_event_handler and update in a global - * variable that there is data to read. - * - * Input Parameters: - * pBuf data buffer - * from from information - * fromlen from information length - * - * Returned Value: - * None - * - ****************************************************************************/ - -void SimpleLinkWaitData(uint8_t *pBuf, uint8_t *from, uint8_t *fromlen); - -/**************************************************************************** - * Name: UINT32_TO_STREAM_f - * - * Description: - * This function is used for copying 32 bit to stream while converting to - * little endian format. - * - * Input Parameters: - * p pointer to the new stream - * u32 pointer to the 32 bit - * - * Returned Value: - * Pointer to the new stream - * - ****************************************************************************/ - -uint8_t *UINT32_TO_STREAM_f(uint8_t *p, unsigned long u32); - -/**************************************************************************** - * Name: UINT16_TO_STREAM_f - * - * Description: - * This function is used for copying 16 bit to stream while converting to - * little endian format. - * - * Input Parameters: - * p pointer to the new stream - * u16 pointer to the 16 bit - * - * Returned Value: - * Pointer to the new stream - * - ****************************************************************************/ - -uint8_t *UINT16_TO_STREAM_f(uint8_t *p, uint16_t u16); - -/**************************************************************************** - * Name: STREAM_TO_UINT16_f - * - * Description: - * This function is used for copying received stream to 16 bit in little - * endian format. - * - * Input Parameters: - * p pointer to the stream - * offset offset in the stream - * - * Returned Value: - * Pointer to the new 16 bit - * - ****************************************************************************/ - -uint16_t STREAM_TO_UINT16_f(char* p, uint16_t offset); - -/**************************************************************************** - * Name: STREAM_TO_UINT32_f - * - * Description: - * This function is used for copying received stream to 32 bit in little - * endian format. - * - * Input Parameters: - * p pointer to the stream - * offset offset in the stream - * - * Returned Value: - * Pointer to the new 32 bit - * - ****************************************************************************/ - -unsigned long STREAM_TO_UINT32_f(char* p, uint16_t offset); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // __INCLUDE_NUTTX_WIRELESS_CC3000_CC3300_COMMON_H diff --git a/include/nuttx/wireless/cc3000/evnt_handler.h b/include/nuttx/wireless/cc3000/evnt_handler.h deleted file mode 100644 index a720a04de9..0000000000 --- a/include/nuttx/wireless/cc3000/evnt_handler.h +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************** -* -* evnt_handler.h - CC3000 Host Driver Implementation. -* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* 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. -* -* Neither the name of Texas Instruments Incorporated 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_CC3000_EVENT_HANDLER_H -#define __INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define M_BSD_RESP_PARAMS_OFFSET(hci_event_hdr)\ - ((char *)(hci_event_hdr) + HCI_EVENT_HEADER_SIZE) - -#define SOCKET_STATUS_ACTIVE 0 -#define SOCKET_STATUS_INACTIVE 1 - -/* Init socket_active_status = 'all ones': init all sockets with - * SOCKET_STATUS_INACTIVE. Will be changed by 'set_socket_active_status' upon - * 'connect' and 'accept' calls - */ - -#define SOCKET_STATUS_INIT_VAL 0xFFFF -#define M_IS_VALID_SD(sd) ((0 <= (sd)) && ((sd) <= 7)) -#define M_IS_VALID_STATUS(status) \ - (((status) == SOCKET_STATUS_ACTIVE)||((status) == SOCKET_STATUS_INACTIVE)) - -#define BSD_RECV_FROM_FROMLEN_OFFSET (4) -#define BSD_RECV_FROM_FROM_OFFSET (16) - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -typedef struct _bsd_accept_return_t -{ - long iSocketDescriptor; - long iStatus; - struct sockaddr tSocketAddress; -} tBsdReturnParams; - -typedef struct _bsd_read_return_t -{ - long iSocketDescriptor; - long iNumberOfBytes; - unsigned long uiFlags; -} tBsdReadReturnParams; - -typedef struct _bsd_select_return_t -{ - long iStatus; - unsigned long uiRdfd; - unsigned long uiWrfd; - unsigned long uiExfd; -} tBsdSelectRecvParams; - -typedef struct _bsd_getsockopt_return_t -{ - uint8_t ucOptValue[4]; - char iStatus; -} tBsdGetSockOptReturnParams; - -typedef struct _bsd_gethostbyname_return_t -{ - long retVal; - long outputAddress; -} tBsdGethostbynameParams; - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -extern unsigned long socket_active_status; - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: hci_event_handler - * - * Description: - * Parse the incoming events packets and issues corresponding event - * handler from global array of handlers pointers - * - * Input Parameters: - * pRetParams incoming data buffer - * from from information (in case of data received) - * fromlen from information length (in case of data received) - * - * Returned Value: - * None - * - ****************************************************************************/ - -uint8_t *hci_event_handler(void *pRetParams, uint8_t *from, uint8_t *fromlen); - -/**************************************************************************** - * Name: hci_unsol_event_handler - * - * Description: - * Handle unsolicited events - * - * Input Parameters: - * event_hdr event header - * - * Returned Value: - * 1 if event supported and handled; 0 if event is not supported - * - ****************************************************************************/ - -long hci_unsol_event_handler(char *event_hdr); - -/**************************************************************************** - * Name: hci_unsolicited_event_handler - * - * Description: - * Parse the incoming unsolicited event packets and issues corresponding - * event handler. - * - * Input Parameters: - * None - * - * Returned Value: - * ESUCCESS if successful, EFAIL if an error occurred - * - ****************************************************************************/ - -long hci_unsolicited_event_handler(void); - -void set_socket_active_status(long Sd, long Status); -long get_socket_active_status(long Sd); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // __INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H diff --git a/include/nuttx/wireless/cc3000/hci.h b/include/nuttx/wireless/cc3000/hci.h deleted file mode 100644 index 8b4c3e67ab..0000000000 --- a/include/nuttx/wireless/cc3000/hci.h +++ /dev/null @@ -1,299 +0,0 @@ -/**************************************************************************** - * hci.h - CC3000 Host Driver Implementation. - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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_CC3000_HCI_H -#define __INCLUDE_NUTTX_WIRELESS_CC3000_HCI_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include "cc3000_common.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define SPI_HEADER_SIZE (5) -#define SIMPLE_LINK_HCI_CMND_HEADER_SIZE (4) -#define HEADERS_SIZE_CMD (SPI_HEADER_SIZE + SIMPLE_LINK_HCI_CMND_HEADER_SIZE) -#define SIMPLE_LINK_HCI_DATA_CMND_HEADER_SIZE (5) -#define SIMPLE_LINK_HCI_DATA_HEADER_SIZE (5) -#define SIMPLE_LINK_HCI_PATCH_HEADER_SIZE (2) - -/* Values that can be used as HCI Commands and HCI Packet header defines */ - -#define HCI_TYPE_CMND 0x1 -#define HCI_TYPE_DATA 0x2 -#define HCI_TYPE_PATCH 0x3 -#define HCI_TYPE_EVNT 0x4 - -#define HCI_EVENT_PATCHES_DRV_REQ (1) -#define HCI_EVENT_PATCHES_FW_REQ (2) -#define HCI_EVENT_PATCHES_BOOTLOAD_REQ (3) - -#define HCI_CMND_WLAN_BASE (0x0000) -#define HCI_CMND_WLAN_CONNECT 0x0001 -#define HCI_CMND_WLAN_DISCONNECT 0x0002 -#define HCI_CMND_WLAN_IOCTL_SET_SCANPARAM 0x0003 -#define HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY 0x0004 -#define HCI_CMND_WLAN_IOCTL_ADD_PROFILE 0x0005 -#define HCI_CMND_WLAN_IOCTL_DEL_PROFILE 0x0006 -#define HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS 0x0007 -#define HCI_CMND_EVENT_MASK 0x0008 -#define HCI_CMND_WLAN_IOCTL_STATUSGET 0x0009 -#define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START 0x000A -#define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP 0x000B -#define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX 0x000C -#define HCI_CMND_WLAN_CONFIGURE_PATCH 0x000D - -#define HCI_CMND_SOCKET_BASE 0x1000 -#define HCI_CMND_SOCKET 0x1001 -#define HCI_CMND_BIND 0x1002 -#define HCI_CMND_RECV 0x1004 -#define HCI_CMND_ACCEPT 0x1005 -#define HCI_CMND_LISTEN 0x1006 -#define HCI_CMND_CONNECT 0x1007 -#define HCI_CMND_BSD_SELECT 0x1008 -#define HCI_CMND_SETSOCKOPT 0x1009 -#define HCI_CMND_GETSOCKOPT 0x100A -#define HCI_CMND_CLOSE_SOCKET 0x100B -#define HCI_CMND_RECVFROM 0x100D -#define HCI_CMND_GETHOSTNAME 0x1010 -#define HCI_CMND_MDNS_ADVERTISE 0x1011 - -#define HCI_DATA_BASE 0x80 - -#define HCI_CMND_SEND (0x01 + HCI_DATA_BASE) -#define HCI_CMND_SENDTO (0x03 + HCI_DATA_BASE) -#define HCI_DATA_BSD_RECVFROM (0x04 + HCI_DATA_BASE) -#define HCI_DATA_BSD_RECV (0x05 + HCI_DATA_BASE) - -#define HCI_CMND_NVMEM_CBASE (0x0200) - -#define HCI_CMND_NVMEM_CREATE_ENTRY (0x0203) -#define HCI_CMND_NVMEM_SWAP_ENTRY (0x0205) -#define HCI_CMND_NVMEM_READ (0x0201) -#define HCI_CMND_NVMEM_WRITE (0x0090) -#define HCI_CMND_NVMEM_WRITE_PATCH (0x0204) -#define HCI_CMND_READ_SP_VERSION (0x0207) - -#define HCI_CMND_READ_BUFFER_SIZE 0x400B -#define HCI_CMND_SIMPLE_LINK_START 0x4000 - -#define HCI_CMND_NETAPP_BASE 0x2000 - -#define HCI_NETAPP_DHCP (0x0001 + HCI_CMND_NETAPP_BASE) -#define HCI_NETAPP_PING_SEND (0x0002 + HCI_CMND_NETAPP_BASE) -#define HCI_NETAPP_PING_REPORT (0x0003 + HCI_CMND_NETAPP_BASE) -#define HCI_NETAPP_PING_STOP (0x0004 + HCI_CMND_NETAPP_BASE) -#define HCI_NETAPP_IPCONFIG (0x0005 + HCI_CMND_NETAPP_BASE) -#define HCI_NETAPP_ARP_FLUSH (0x0006 + HCI_CMND_NETAPP_BASE) -#define HCI_NETAPP_SET_DEBUG_LEVEL (0x0008 + HCI_CMND_NETAPP_BASE) -#define HCI_NETAPP_SET_TIMERS (0x0009 + HCI_CMND_NETAPP_BASE) - -/* Values that can be used as HCI Events defines */ - -#define HCI_EVNT_WLAN_BASE 0x0000 -#define HCI_EVNT_WLAN_CONNECT 0x0001 -#define HCI_EVNT_WLAN_DISCONNECT 0x0002 -#define HCI_EVNT_WLAN_IOCTL_ADD_PROFILE 0x0005 - -#define HCI_EVNT_SOCKET HCI_CMND_SOCKET -#define HCI_EVNT_BIND HCI_CMND_BIND -#define HCI_EVNT_RECV HCI_CMND_RECV -#define HCI_EVNT_ACCEPT HCI_CMND_ACCEPT -#define HCI_EVNT_LISTEN HCI_CMND_LISTEN -#define HCI_EVNT_CONNECT HCI_CMND_CONNECT -#define HCI_EVNT_SELECT HCI_CMND_BSD_SELECT -#define HCI_EVNT_CLOSE_SOCKET HCI_CMND_CLOSE_SOCKET -#define HCI_EVNT_RECVFROM HCI_CMND_RECVFROM -#define HCI_EVNT_SETSOCKOPT HCI_CMND_SETSOCKOPT -#define HCI_EVNT_GETSOCKOPT HCI_CMND_GETSOCKOPT -#define HCI_EVNT_BSD_GETHOSTBYNAME HCI_CMND_GETHOSTNAME -#define HCI_EVNT_MDNS_ADVERTISE HCI_CMND_MDNS_ADVERTISE - -#define HCI_EVNT_SEND 0x1003 -#define HCI_EVNT_WRITE 0x100E -#define HCI_EVNT_SENDTO 0x100F - -#define HCI_EVNT_PATCHES_REQ 0x1000 - -#define HCI_EVNT_UNSOL_BASE 0x4000 - -#define HCI_EVNT_WLAN_UNSOL_BASE (0x8000) - -#define HCI_EVNT_WLAN_UNSOL_CONNECT (0x0001 + HCI_EVNT_WLAN_UNSOL_BASE) -#define HCI_EVNT_WLAN_UNSOL_DISCONNECT (0x0002 + HCI_EVNT_WLAN_UNSOL_BASE) -#define HCI_EVNT_WLAN_UNSOL_INIT (0x0004 + HCI_EVNT_WLAN_UNSOL_BASE) -#define HCI_EVNT_WLAN_TX_COMPLETE (0x0008 + HCI_EVNT_WLAN_UNSOL_BASE) -#define HCI_EVNT_WLAN_UNSOL_DHCP (0x0010 + HCI_EVNT_WLAN_UNSOL_BASE) -#define HCI_EVNT_WLAN_ASYNC_PING_REPORT (0x0040 + HCI_EVNT_WLAN_UNSOL_BASE) -#define HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE (0x0080 + HCI_EVNT_WLAN_UNSOL_BASE) -#define HCI_EVNT_WLAN_KEEPALIVE (0x0200 + HCI_EVNT_WLAN_UNSOL_BASE) -#define HCI_EVNT_BSD_TCP_CLOSE_WAIT (0x0800 + HCI_EVNT_WLAN_UNSOL_BASE) - -#define HCI_EVNT_DATA_UNSOL_FREE_BUFF 0x4100 - -#define HCI_EVNT_NVMEM_CREATE_ENTRY HCI_CMND_NVMEM_CREATE_ENTRY -#define HCI_EVNT_NVMEM_SWAP_ENTRY HCI_CMND_NVMEM_SWAP_ENTRY - -#define HCI_EVNT_NVMEM_READ HCI_CMND_NVMEM_READ -#define HCI_EVNT_NVMEM_WRITE (0x0202) - -#define HCI_EVNT_READ_SP_VERSION HCI_CMND_READ_SP_VERSION - -#define HCI_EVNT_INPROGRESS 0xFFFF - - -#define HCI_DATA_RECVFROM 0x84 -#define HCI_DATA_RECV 0x85 -#define HCI_DATA_NVMEM 0x91 - -#define HCI_EVENT_CC3000_CAN_SHUT_DOWN 0x99 - -#define HCI_DATA_HEADER_SIZE (5) -#define HCI_EVENT_HEADER_SIZE (5) -#define HCI_DATA_CMD_HEADER_SIZE (5) -#define HCI_PATCH_HEADER_SIZE (6) - -#define HCI_PACKET_TYPE_OFFSET (0) -#define HCI_PACKET_ARGSIZE_OFFSET (2) -#define HCI_PACKET_LENGTH_OFFSET (3) - -#define HCI_EVENT_OPCODE_OFFSET (1) -#define HCI_EVENT_LENGTH_OFFSET (3) -#define HCI_EVENT_STATUS_OFFSET (4) -#define HCI_DATA_LENGTH_OFFSET (3) - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: hci_command_send - * - * Description: - * Initiate an HCI command. - * - * Input Parameters: - * usOpcode command operation code - * pucBuff pointer to the command's arguments buffer - * ucArgsLength length of the arguments - * - * Returned Value: - * Zero - * - ****************************************************************************/ - -uint16_t hci_command_send(uint16_t usOpcode, uint8_t *pucBuff, - uint8_t ucArgsLength); - - -/**************************************************************************** - * Name: hci_data_send - * - * Description: - * - * - * Input Parameters: - * usOpcode command operation code - * ucArgs pointer to the command's arguments buffer - * usArgsLength length of the arguments - * ucTail pointer to the data buffer - * usTailLength buffer length - * - * Returned Value: - * None - * - ****************************************************************************/ - -long hci_data_send(uint8_t ucOpcode, uint8_t *ucArgs, uint16_t usArgsLength, - uint16_t usDataLength, const uint8_t *ucTail, - uint16_t usTailLength); - -/**************************************************************************** - * Name: hci_data_command_send - * - * Description: - * Prepeare HCI header and initiate an HCI data write operation - * - * Input Parameters: - * usOpcode command operation code - * pucBuff pointer to the data buffer - * ucArgsLength arguments length - * ucDataLength data length - * - * Returned Value: - * None - * - ****************************************************************************/ - -void hci_data_command_send(uint16_t usOpcode, uint8_t *pucBuff, - uint8_t ucArgsLength,uint16_t ucDataLength); - -/**************************************************************************** - * Name: hci_patch_send - * - * Description: - * Prepeare HCI header and initiate an HCI patch write operation - * - * Input Parameters: - * usOpcode command operation code - * pucBuff pointer to the command's arguments buffer - * patch pointer to patch content buffer - * usDataLength data length - * - * Returned Value: - * None - * - ****************************************************************************/ - -void hci_patch_send(uint8_t ucOpcode, uint8_t *pucBuff, char *patch, - uint16_t usDataLength); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // __INCLUDE_NUTTX_WIRELESS_CC3000_HCI_H diff --git a/include/nuttx/wireless/cc3000/include/cc3000_upif.h b/include/nuttx/wireless/cc3000/include/cc3000_upif.h deleted file mode 100644 index e44a2cf45c..0000000000 --- a/include/nuttx/wireless/cc3000/include/cc3000_upif.h +++ /dev/null @@ -1,191 +0,0 @@ -/**************************************************************************** - * include/nuttx/wireless/cc3000/include/cc3000_upif.h - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Authors: Gregory Nutt - * David Sidrane - * - * This is the definition for the interface to the bottom half of the cc3000 driver. - * it provides the wiring of the board's GPIO and spi to the cc3000 driver. - * - * References: - * CC30000 from Texas Instruments http://processors.wiki.ti.com/index.php/CC3000 - * - * See also: - * http://processors.wiki.ti.com/index.php/CC3000_Host_Driver_Porting_Guide - * http://processors.wiki.ti.com/index.php/CC3000_Host_Programming_Guide - * - * 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_CC3000_INCLUDE_CC3000_UPIFL_H -#define __INCLUDE_NUTTX_WIRELESS_CC3000_INCLUDE_CC3000_UPIFL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -#if defined(CONFIG_DRIVERS_WIRELESS) && defined(CONFIG_WL_CC3000) - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ -/* SPI Frequency. Default: 16MHz */ - -#ifndef CONFIG_CC3000_SPI_FREQUENCY -# define CONFIG_CC3000_SPI_FREQUENCY 16000000 -#endif - -/* Maximum number of threads than can be waiting for POLL events */ - -#ifndef CONFIG_CC3000_NPOLLWAITERS -# define CONFIG_CC3000_NPOLLWAITERS 2 -#endif - -#ifndef CONFIG_CC3000_SPI_MODE -/* CPOL = 0, CPHA = 1 Sample Data Falling Edge of Clock - * See http://processors.wiki.ti.com/index.php/CC3000_Serial_Port_Interface_(SPI) - */ - -# define CONFIG_CC3000_SPI_MODE SPIDEV_MODE1 -#endif - -/* Check for some required settings. This can save the user a lot of time - * in getting the right configuration. - */ - -#ifdef CONFIG_DISABLE_SIGNALS -# error "Signals are required. CONFIG_DISABLE_SIGNALS must not be selected." -#endif - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/* A reference to a structure of this type must be passed to the CC3000 - * driver. This structure provides information about the configuration - * of the CC3000 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. - */ - -struct cc3000_config_s -{ - /* Device characterization */ - - uint32_t spi_frequency; /* SPI frequency */ - uint32_t spi_mode; /* SPI mode */ - size_t max_rx_size; /* Size allocated by driver for rx buffer */ - - /* If multiple CC3000 devices are supported, then an IRQ number must - * be provided for each so that their interrupts can be distinguished. - */ - -#ifndef CONFIG_CC3000_MULTIPLE - int irq; /* IRQ number received by interrupt handler. */ -#endif - - /* IRQ/GPIO access callbacks. These operations all hidden behind - * callbacks to isolate the CC3000 driver from differences in GPIO - * interrupt handling by varying boards and MCUs. If possible, - * interrupts should be configured on falling edges to detect the Ready Condition - * At T2: The normal master SPI write sequence is SPI_CS low, followed by SPI_IRQ low - * CC3000 to host, indicating that the CC3000 core module is ready to accept data. - * T2 duration is approximately 7 ms. - * - * irq_attach - Attach the CC3000 interrupt handler to the GPIO interrupt - * irq_enable - Enable or disable the GPIO interrupt - * irq_clear - Acknowledge/clear any pending GPIO interrupt - * power_enable - Enable or disable Module enable. - * chip_chip_select - The Chip Select - * irq_read - Return the state of the interrupt GPIO input - * probe - Debug support - */ - - int (*irq_attach)(FAR struct cc3000_config_s *state, xcpt_t isr, FAR void *arg); - void (*irq_enable)(FAR struct cc3000_config_s *state, bool enable); - void (*irq_clear)(FAR struct cc3000_config_s *state); - void (*power_enable)(FAR struct cc3000_config_s *state,bool enable); - void (*chip_chip_select)(FAR struct cc3000_config_s *state,bool enable); - bool (*irq_read)(FAR struct cc3000_config_s *state); -#ifdef CONFIG_CC3000_PROBES - bool (*probe)(FAR struct cc3000_config_s *state, int n, bool s); -#endif -}; - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -/**************************************************************************** - * Name: cc3000_register - * - * Description: - * Configure the CC3000 to use the provided SPI device instance. This - * will register the driver as /dev/inputN where N is the minor device - * number - * - * Input Parameters: - * spi - An SPI driver instance - * config - Persistent board configuration data - * minor - The CC000 device minor number - * - * Returned Value: - * Pointer to newly allocated cc3000 device structure or NULL on error - * (errno is set accordingly in this case). - * - ****************************************************************************/ - -int cc3000_register(FAR struct spi_dev_s *spi, - FAR struct cc3000_config_s *config, int minor); - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* CONFIG_DRIVERS_WIRELESS && CONFIG_INPUT_CC3000 */ -#endif /* __INCLUDE_NUTTX_WIRELESS_CC3000_INCLUDE_CC3000_UPIFL_H */ diff --git a/include/nuttx/wireless/cc3000/include/sys/socket.h b/include/nuttx/wireless/cc3000/include/sys/socket.h deleted file mode 100644 index f40f7b6406..0000000000 --- a/include/nuttx/wireless/cc3000/include/sys/socket.h +++ /dev/null @@ -1,559 +0,0 @@ -/**************************************************************************** - * socket.h - CC3000 Host Driver Implementation. - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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_CC3000_INCLUDE_SYS_SOCKET_H -#define __INCLUDE_NUTTX_WIRELESS_CC3000_INCLUDE_SYS_SOCKET_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define socket(a,t,p) cc3000_socket(a,t,p) -#define closesocket(s) cc3000_closesocket(s) -#define bind(s,a,l) cc3000_bind(s,a,l) -#define connect(s,a,l) cc3000_connect(s,a,l) -#define listen(s,b) cc3000_listen(s,b) -#define accept(s,a,l) cc3000_accept(s,a,l) -#define send(s,b,l,f) cc3000_send(s,b,l,f) -#define sendto(s,b,l,f,a,n) cc3000_sendto(s,b,l,f,a,n) -#define recv(s,b,l,f) cc3000_recv(s,b,l,f) -#define recvfrom(s,b,l,f,a,n) cc3000_recvfrom(s,b,l,f,a,n) -#define setsockopt(s,l,o,v,n) cc3000_setsockopt(s,l,o,v,n) -#define getsockopt(s,l,o,v,n) cc3000_getsockopt(s,l,o,v,n) -#define gethostbyname(h,l,i) cc3000_gethostbyname(h,l,i) -#define mdnsadvertiser(e,n,l) cc3000_mdnsadvertiser(e,n,l) - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: socket - * - * Decription: - * create an endpoint for communication. The socket function creates a - * socket that is bound to a specific transport service provider. This - * function is called by the application layer to obtain a socket handle. - * - * Input Parameters: - * domain selects the protocol family which will be used for - * communication. On this version only AF_INET is supported - * type specifies the communication semantics. On this version - * only SOCK_STREAM, SOCK_DGRAM, SOCK_RAW are supported - * protocol specifies a particular protocol to be used with the - * socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are - * supported. - * - * Returned Value: - * On success, socket handle that is used for consequent socket - * operations. On error, -1 is returned. - * - ****************************************************************************/ - -int socket(int domain, int type, int protocol); - -/**************************************************************************** - * Name: closesocket - * - * Decription: - * The socket function closes a created socket. - * - * Input Parameters: - * sockfd socket handle. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -int closesocket(int sockfd); - -/**************************************************************************** - * Name: accept - * - * Decription: - * accept a connection on a socket: - * This function is used with connection-based socket types - * (SOCK_STREAM). It extracts the first connection request on the - * queue of pending connections, creates a new connected socket, and - * returns a new file descriptor referring to that socket. - * The newly created socket is not in the listening state. - * The original socket sd is unaffected by this call. - * The argument sd is a socket that has been created with socket(), - * bound to a local address with bind(), and is listening for - * connections after a listen(). The argument addr is a pointer - * to a sockaddr structure. This structure is filled in with the - * address of the peer socket, as known to the communications layer. - * The exact format of the address returned addr is determined by the - * socket's address family. The addrlen argument is a value-result - * argument: it should initially contain the size of the structure - * pointed to by addr, on return it will contain the actual - * length (in bytes) of the address returned. - * - * Input Parameters: - * sockfd socket descriptor (handle) - * addr the argument addr is a pointer to a sockaddr structure - * This structure is filled in with the address of the - * peer socket, as known to the communications layer. - * determined. The exact format of the address returned - * addr is by the socket's address sockaddr. - * On this version only AF_INET is supported. - * This argument returns in network order. - * addrlen The addrlen argument is a value-result argument: - * it should initially contain the size of the structure - * pointed to by addr. - * - * Returned Value: - * For socket in blocking mode: - * On success, socket handle. on failure negative - * For socket in non-blocking mode: - * - On connection establishment, socket handle - * - On connection pending, SOC_IN_PROGRESS (-2) - * - On failure, SOC_ERROR (-1) - * - ****************************************************************************/ - -int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); - -/**************************************************************************** - * Name: bind - * - * Decription: - * assign a name to a socket - * This function gives the socket the local address addr. - * addr is addrlen bytes long. Traditionally, this is called when a - * socket is created with socket, it exists in a name space (address - * family) but has no name assigned. - * It is necessary to assign a local address before a SOCK_STREAM - * socket may receive connections. - * - * Input Parameters: - * sockfd socket descriptor (handle) - * addr specifies the destination address. On this version - * only AF_INET is supported. - * addrlen contains the size of the structure pointed to by addr. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -int bind(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen); - -/**************************************************************************** - * Name: listen - * - * Decription: - * listen for connections on a socket - * The willingness to accept incoming connections and a queue - * limit for incoming connections are specified with listen(), - * and then the connections are accepted with accept. - * The listen() call applies only to sockets of type SOCK_STREAM - * The backlog parameter defines the maximum length the queue of - * pending connections may grow to. - * - * NOTE: On this version, backlog is not supported - * - * Input Parameters: - * sockfd socket descriptor (handle) - * backlog specifies the listen queue depth. On this version - * backlog is not supported. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -int listen(int sockfd, int backlog); - -/**************************************************************************** - * Name: connect - * - * Decription: - * initiate a connection on a socket - * Function connects the socket referred to by the socket descriptor - * sd, to the address specified by addr. The addrlen argument - * specifies the size of addr. The format of the address in addr is - * determined by the address space of the socket. If it is of type - * SOCK_DGRAM, this call specifies the peer with which the socket is - * to be associated; this address is that to which datagrams are to be - * sent, and the only address from which datagrams are to be received. - * If the socket is of type SOCK_STREAM, this call attempts to make a - * connection to another socket. The other socket is specified by - * address, which is an address in the communications space of the - * socket. Note that the function implements only blocking behavior - * thus the caller will be waiting either for the connection - * establishment or for the connection establishment failure. - * - * Input Parameters: - * sockfd socket descriptor (handle) - * addr specifies the destination addr. On this version - * only AF_INET is supported. - * addrlen contains the size of the structure pointed to by addr - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -int connect(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen); - -/**************************************************************************** - * Name: select - * - * Decription: - * Monitor socket activity - * Select allow a program to monitor multiple file descriptors, - * waiting until one or more of the file descriptors become - * "ready" for some class of I/O operation - * - * NOTE: If the timeout value set to less than 5ms it will automatically set - * to 5ms to prevent overload of the system - * - * Input Parameters: - * nfds the highest-numbered file descriptor in any of the - * three sets, plus 1. - * readfds socket descriptors list for read monitoring - * writefds socket descriptors list for write monitoring - * exceptfds socket descriptors list for exception monitoring - * timeout is an upper bound on the amount of time elapsed - * before select() returns. Null means infinity - * timeout. The minimum timeout is 5 milliseconds, - * less than 5 milliseconds will be set - * automatically to 5 milliseconds. - * - * Returned Value: - * On success, select() returns the number of file descriptors - * contained in the three returned descriptor sets (that is, the - * total number of bits that are set in readfds, writefds, - * exceptfds) which may be zero if the timeout expires before - * anything interesting happens. - * On error, -1 is returned. - * *readfds - return the sockets on which Read request will - * return without delay with valid data. - * *writefds - return the sockets on which Write request - * will return without delay. - * *exceptfds - return the sockets which closed recently. - * - ****************************************************************************/ - -struct timeval; -int cc3000_select(int nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, - struct timeval *timeout); - -#ifndef CC3000_TINY_DRIVER -/**************************************************************************** - * Name: setsockopt - * - * Decription: - * set socket options - * This function manipulate the options associated with a socket. - * Options may exist at multiple protocol levels; they are always - * present at the uppermost socket level. - * When manipulating socket options the level at which the option - * resides and the name of the option must be specified. - * To manipulate options at the socket level, level is specified as - * SOL_SOCKET. To manipulate options at any other level the protocol - * number of the appropriate protocol controlling the option is - * supplied. For example, to indicate that an option is to be - * interpreted by the TCP protocol, level should be set to the - * protocol number of TCP; - * The parameters value and value_len are used to access value - - * use for setsockopt(). For getsockopt() they identify a buffer - * in which the value for the requested option(s) are to - * be returned. For getsockopt(), value_len is a value-result - * parameter, initially containing the size of the buffer - * pointed to by option_value, and modified on return to - * indicate the actual size of the value returned. If no option - * value is to be supplied or returned, option_value may be NULL. - * - * NOTE: On this version the following two socket options are enabled: - * The only protocol level supported in this version - * is SOL_SOCKET (level). - * 1. SOCKOPT_RECV_TIMEOUT (option) - * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout - * in milliseconds. - * In that case value should be pointer to unsigned long. - * 2. SOCKOPT_NONBLOCK (option). sets the socket non-blocking mode on - * or off. - * In that case value should be SOCK_ON or SOCK_OFF (value). - * - * Input Parameters: - * sockfd socket handle - * level defines the protocol level for this option - * option defines the option name to Interrogate - * value specifies a value for the option - * value_len specifies the length of the option value - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -int setsockopt(int sockfd, int level, int option, FAR const void *value, socklen_t value_len); -#endif - -/**************************************************************************** - * Name: getsockopt - * - * Decription: - * set socket options - * This function manipulate the options associated with a socket. - * Options may exist at multiple protocol levels; they are always - * present at the uppermost socket level. - * When manipulating socket options the level at which the option - * resides and the name of the option must be specified. - * To manipulate options at the socket level, level is specified as - * SOL_SOCKET. To manipulate options at any other level the protocol - * number of the appropriate protocol controlling the option is - * supplied. For example, to indicate that an option is to be - * interpreted by the TCP protocol, level should be set to the - * protocol number of TCP; - * The parameters value and value_len are used to access value - - * use for setsockopt(). For getsockopt() they identify a buffer - * in which the value for the requested option(s) are to - * be returned. For getsockopt(), value_len is a value-result - * parameter, initially containing the size of the buffer - * pointed to by option_value, and modified on return to - * indicate the actual size of the value returned. If no option - * value is to be supplied or returned, option_value may be NULL. - * - * NOTE: On this version the following two socket options are enabled: - * The only protocol level supported in this version - * is SOL_SOCKET (level). - * - * 1. SOCKOPT_RECV_TIMEOUT (option) - * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout - * in milliseconds. In that case value should be pointer to unsigned - * long. - * 2. SOCKOPT_NONBLOCK (option). sets the socket non-blocking mode on - * or off. In that case value should be SOCK_ON or SOCK_OFF (value). - * - * Input Parameters: - * sockfd socket handle - * level defines the protocol level for this option - * option defines the option name to Interrogate - * value specifies a value for the option - * value_len specifies the length of the option value - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -int getsockopt(int sockfd, int level, int option, FAR void *value, FAR socklen_t *value_len); - -/**************************************************************************** - * Name: recv - * - * Decription: - * function receives a message from a connection-mode socket - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sockfd socket handle - * buf Points to the buffer where the message should be stored - * len Specifies the length in bytes of the buffer pointed to - * by the buffer argument. - * flags Specifies the type of message reception. - * On this version, this parameter is not supported. - * - * Returned Value: - * Return the number of bytes received, or -1 if an error - * occurred - * - ****************************************************************************/ - -ssize_t recv(int sockfd, FAR void *buf, size_t len, int flags); - -/**************************************************************************** - * Name: recvfrom - * - * Decription: - * read data from socket - * function receives a message from a connection-mode or - * connectionless-mode socket. Note that raw sockets are not - * supported. - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sockfd socket handle - * buf Points to the buffer where the message should be stored - * len Specifies the length in bytes of the buffer pointed to - * by the buffer argument. - * flags Specifies the type of message reception. - * On this version, this parameter is not supported. - * from pointer to an address structure indicating the source - * address: sockaddr. On this version only AF_INET is - * supported. - * fromlen source address tructure size - * - * Returned Value: - * Return the number of bytes received, or -1 if an error - * occurred - * - ****************************************************************************/ - -ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags, - FAR struct sockaddr *from, FAR socklen_t *fromlen); - -/**************************************************************************** - * Name: send - * - * Decription: - * Write data to TCP socket - * This function is used to transmit a message to another - * socket. - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sockfd socket handle - * buf Points to a buffer containing the message to be sent - * len message size in bytes - * flags On this version, this parameter is not supported - * - * Returned Value: - * Return the number of bytes transmitted, or -1 if an - * error occurred - * - ****************************************************************************/ - -ssize_t send(int sockfd, FAR const void *buf, size_t len, int flags); - -/**************************************************************************** - * Name: sendto - * - * Decription: - * Write data to TCP socket - * This function is used to transmit a message to another - * socket. - * - * NOTE: On this version, only blocking mode is supported. - * - * Input Parameters: - * sockfd socket handle - * buf Points to a buffer containing the message to be sent - * len message size in bytes - * flags On this version, this parameter is not supported - * to pointer to an address structure indicating the destination - * address: sockaddr. On this version only AF_INET is - * supported. - * tolen destination address structure size - * - * Returned Value: - * Return the number of bytes transmitted, or -1 if an - * error occurred - * - ****************************************************************************/ - -ssize_t sendto(int sockfd, FAR const void *buf, size_t len, int flags, - FAR const struct sockaddr *to, socklen_t tolen); - -#ifndef CC3000_TINY_DRIVER -/**************************************************************************** - * Name: gethostbyname - * - * Decription: - * Get host IP by name. Obtain the IP Address of machine on network, - * by its name. - * - * NOTE: On this version, only blocking mode is supported. Also note that - * the function requires DNS server to be configured prior to its - * usage. - * - * Input Parameters: - * hostname host name - * usNameLen name length - * out_ip_addr This parameter is filled in with host IP address. - * In case that host name is not resolved, - * out_ip_addr is zero. - * - * Returned Value: - * On success, positive is returned. On error, negative is returned - * - ****************************************************************************/ - -int gethostbyname(char * hostname, uint16_t usNameLen, unsigned long* out_ip_addr); -#endif - -/**************************************************************************** - * Name: mdnsAdvertiser - * - * Decription: - * Set CC3000 in mDNS advertiser mode in order to advertise itself. - * - * Input Parameters: - * mdnsEnabled flag to enable/disable the mDNS feature - * deviceServiceName Service name as part of the published - * canonical domain name - * deviceServiceNameLength Length of the service name - * - * Returned Value: - * On success, zero is returned, return SOC_ERROR if socket was not - * opened successfully, or if an error occurred. - * - ****************************************************************************/ - -int mdnsadvertiser(uint16_t mdnsEnabled, char *deviceServiceName, - uint16_t deviceServiceNameLength); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // __INCLUDE_NUTTX_WIRELESS_CC3000_INCLUDE_SYS_SOCKET_H diff --git a/include/nuttx/wireless/cc3000/netapp.h b/include/nuttx/wireless/cc3000/netapp.h deleted file mode 100644 index 8a0bcf4acb..0000000000 --- a/include/nuttx/wireless/cc3000/netapp.h +++ /dev/null @@ -1,357 +0,0 @@ -/**************************************************************************** - * netapp.h - CC3000 Host Driver Implementation. - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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_CC3000_NETAPP_H -#define __INCLUDE_NUTTX_WIRELESS_CC3000_NETAPP_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -typedef struct _netapp_dhcp_ret_args_t -{ - uint8_t aucIP[4]; - uint8_t aucSubnetMask[4]; - uint8_t aucDefaultGateway[4]; - uint8_t aucDHCPServer[4]; - uint8_t aucDNSServer[4]; -} tNetappDhcpParams; - -typedef struct _netapp_ipconfig_ret_args_t -{ - uint8_t aucIP[4]; - uint8_t aucSubnetMask[4]; - uint8_t aucDefaultGateway[4]; - uint8_t aucDHCPServer[4]; - uint8_t aucDNSServer[4]; - uint8_t uaMacAddr[6]; - uint8_t uaSSID[32]; -} tNetappIpconfigRetArgs; - -/*Ping send report parameters*/ - -typedef struct _netapp_pingreport_args -{ - unsigned long packets_sent; - unsigned long packets_received; - unsigned long min_round_time; - unsigned long max_round_time; - unsigned long avg_round_time; -} netapp_pingreport_args_t; - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: netapp_config_mac_adrress - * - * Description: - * Configure device MAC address and store it in NVMEM. The value of the MAC - * address configured through the API will be stored in CC3000 non volatile - * memory, thus preserved over resets. - * - * Input Parameters: - * mac device mac address, 6 bytes. Saved: yes - * - * Returned Value: - * Return on success 0, otherwise error. - * - ****************************************************************************/ - -long netapp_config_mac_adrress(uint8_t *mac); - -/**************************************************************************** - * Name: netapp_dhcp - * - * Description: - * netapp_dhcp is used to configure the network interface, static or - * dynamic (DHCP).\n In order to activate DHCP mode, aucIP, aucSubnetMask, - * aucDefaultGateway must be 0. The default mode of CC3000 is DHCP mode. Note - * that the configuration is saved in non volatile memory and thus preserved - * over resets. - * - * NOTE: If the mode is altered a reset of CC3000 device is required in order - * to apply changes.\nAlso note that asynchronous event of DHCP_EVENT, which - * is generated when an IP address is allocated either by the DHCP server or - * due to static allocation is generated only upon a connection to the AP was - * established. - * - * Input Parameters: - * aucIP device mac address, 6 bytes. Saved: yes - * aucSubnetMask device mac address, 6 bytes. Saved: yes - * aucDefaultGateway device mac address, 6 bytes. Saved: yes - * aucDNSServer device mac address, 6 bytes. Saved: yes - * - * Returned Value: - * Return on success 0, otherwise error. - * - ****************************************************************************/ - -long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask, - unsigned long *aucDefaultGateway, unsigned long *aucDNSServer); - -/**************************************************************************** - * Name: netapp_timeout_values - * - * Description: - * Set new timeout values. Function set new timeout values for: DHCP lease - * timeout, ARP refresh timeout, keepalive event timeout and socket - * inactivity timeout - * - * NOTE: If a parameter set to non zero value which is less than 20s, it will - * be set automatically to 20s. - * - * Input Parameters: - * aucDHCP DHCP lease time request, also impact the DHCP renew timeout. - * Range: [0-0xffffffff] seconds, 0 or 0xffffffff == infinity - * lease timeout. - * Resolution: 10 seconds. - * Influence: only after reconnecting to the AP - * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds. - * The parameter is saved into the CC3000 NVMEM. The default - * value on CC3000 is 14400 seconds. - * aucARP ARP refresh timeout, if ARP entry is not updated by incoming - * packet, the ARP entry will be deleted by the end of the - * timeout. - * Range: [0-0xffffffff] seconds, 0 == infinity ARP timeout - * Resolution: 10 seconds. - * Influence: on runtime. - * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds. - * The parameter is saved into the CC3000 NVMEM. The default - * value on CC3000 is 3600 seconds. - * aucKeepalive Keepalive event sent by the end of keepalive timeout - * Range: [0-0xffffffff] seconds, 0 == infinity timeout - * Resolution: 10 seconds. - * Influence: on runtime. - * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec - * The parameter is saved into the CC3000 NVMEM. The default - * value on CC3000 is 10 seconds. - * aucInactivity Socket inactivity timeout, socket timeout is refreshed by - * incoming or outgoing packet, by the end of the socket - * timeout the socket will be closed - * Range: [0-0xffffffff] sec, 0 == infinity timeout. - * Resolution: 10 seconds. Influence: on runtime. - * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec - * The parameter is saved into the CC3000 NVMEM. The default - * value on CC3000 is 60 seconds. - * - * Returned Value: - * Return on success 0, otherwise error. - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long netapp_timeout_values(unsigned long *aucDHCP, unsigned long *aucARP, - unsigned long *aucKeepalive, - unsigned long *aucInactivity); -#endif - -/**************************************************************************** - * Name: netapp_ping_send - * - * Description: - * Send ICMP ECHO_REQUEST to network hosts - * - * NOTE: If an operation finished successfully asynchronous ping report event - * will be generated. The report structure is as defined by structure - * netapp_pingreport_args_t. - * - * WARNING: Calling this function while a previous Ping Requests are in - * progress will stop the previous ping request. - * - * Input Parameters: - * ip destination IP address - * pingAttempts number of echo requests to send - * pingSize send buffer size which may be up to 1400 bytes - * pingTimeout Time to wait for a response,in milliseconds. - * - * Returned Value: - * Return on success 0, otherwise error. - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long netapp_ping_send(unsigned long *ip, unsigned long ulPingAttempts, - unsigned long ulPingSize, unsigned long ulPingTimeout); -#endif - -/**************************************************************************** - * Name: netapp_ping_stop - * - * Description: - * Stop any ping request. - * - * Input Parameters: - * None - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned. - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long netapp_ping_stop(void); -#endif - -/**************************************************************************** - * Name: netapp_ping_report - * - * Description: - * Request for ping status. This API triggers the CC3000 to send asynchronous - * events: HCI_EVNT_WLAN_ASYNC_PING_REPORT. This event will carry the report - * structure: netapp_pingreport_args_t. This structure is filled in with ping - * results up till point of triggering API. - * - * netapp_pingreport_args_t: - * packets_sent - echo sent, - * packets_received - echo reply - * min_round_time - minimum round time, - * max_round_time - max round time, - * avg_round_time - average round time - * - * NOTE: When a ping operation is not active, the returned structure fields - * are 0. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -void netapp_ping_report(void); -#endif - - -/**************************************************************************** - * Name: netapp_ipconfig - * - * Description: - * Obtain the CC3000 Network interface information. Note that the information - * is available only after the WLAN connection was established. Calling this - * function before associated, will cause non-defined values to be returned. - * - * NOTE: The function is useful for figuring out the IP Configuration of the - * device when DHCP is used and for figuring out the SSID of the Wireless - * network the device is associated with. - * - * Input Parameters: - * ipconfig This argument is a pointer to a tNetappIpconfigRetArgs structure. - * This structure is filled in with the network interface configuration. - * - * tNetappIpconfigRetArgs: - * aucIP - ip address, - * aucSubnetMask - mask, - * aucDefaultGateway - default gateway address - * aucDHCPServer - dhcp server address - * aucDNSServer - dns server address - * uaMacAddr - mac - * address, uaSSID - connected AP ssid - * - * Returned Value: - * None - * - ****************************************************************************/ - -void netapp_ipconfig(tNetappIpconfigRetArgs * ipconfig); - -/**************************************************************************** - * Name: netapp_arp_flush - * - * Description: - * Flushes ARP table - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long netapp_arp_flush(void); -#endif - -/**************************************************************************** - * Name: netapp_set_debug_level - * - * Description: - * Debug messages sent via the UART debug channel, this function enable/disable - * the debug level - * - * Input Parameters: - * level debug level. Bitwise [0-8], 0(disable)or 1(enable). - * Bitwise map: - * 0 - Critical message - * 1 - information message - * 2 - core messages - * 3 - HCI messages - * 4 - Network stack messages - * 5 - wlan messages - * 6 - wlan driver messages - * 7 - epprom messages, - * 8 - general messages. - * Default: 0x13f. Saved: no - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long netapp_set_debug_level(unsigned long ulLevel); -#endif - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // __INCLUDE_NUTTX_WIRELESS_CC3000_NETAPP_H diff --git a/include/nuttx/wireless/cc3000/nvmem.h b/include/nuttx/wireless/cc3000/nvmem.h deleted file mode 100644 index afc6aec890..0000000000 --- a/include/nuttx/wireless/cc3000/nvmem.h +++ /dev/null @@ -1,244 +0,0 @@ -/**************************************************************************** - * nvmem.h - CC3000 Host Driver Implementation. - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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_CC3000_NVMEM_H -#define __INCLUDE_NUTTX_WIRELESS_CC3000_NVMEM_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include "cc3000_common.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* NVMEM file ID - system files*/ - -#define NVMEM_NVS_FILEID (0) -#define NVMEM_NVS_SHADOW_FILEID (1) -#define NVMEM_WLAN_CONFIG_FILEID (2) -#define NVMEM_WLAN_CONFIG_SHADOW_FILEID (3) -#define NVMEM_WLAN_DRIVER_SP_FILEID (4) -#define NVMEM_WLAN_FW_SP_FILEID (5) -#define NVMEM_MAC_FILEID (6) -#define NVMEM_FRONTEND_VARS_FILEID (7) -#define NVMEM_IP_CONFIG_FILEID (8) -#define NVMEM_IP_CONFIG_SHADOW_FILEID (9) -#define NVMEM_BOOTLOADER_SP_FILEID (10) -#define NVMEM_RM_FILEID (11) - -/* NVMEM file ID - user files*/ - -#define NVMEM_AES128_KEY_FILEID (12) -#define NVMEM_SHARED_MEM_FILEID (13) - -/* max entry in order to invalid nvmem */ - -#define NVMEM_MAX_ENTRY (16) - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: nvmem_read - * - * Description: - * Reads data from the file referred by the ulFileId parameter. Reads data - * from file ulOffset till length. Err if the file can't be used, is - * invalid, or if the read is out of bounds. - * - * Input Parameters: - * ulFileId nvmem file id: - * NVMEM_NVS_FILEID, NVMEM_NVS_SHADOW_FILEID, - * NVMEM_WLAN_CONFIG_FILEID, NVMEM_WLAN_CONFIG_SHADOW_FILEID, - * NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID, - * NVMEM_MAC_FILEID, NVMEM_FRONTEND_VARS_FILEID, - * NVMEM_IP_CONFIG_FILEID, NVMEM_IP_CONFIG_SHADOW_FILEID, - * NVMEM_BOOTLOADER_SP_FILEID, NVMEM_RM_FILEID, - * and user files 12-15. - * ulLength number of bytes to read - * ulOffset ulOffset in file from where to read - * buff output buffer pointer - * - * Returned Value: - * Number of bytes read, otherwise error. - * - ****************************************************************************/ - -signed long nvmem_read(unsigned long ulFileId, unsigned long ulLength, - unsigned long ulOffset, uint8_t *buff); - -/**************************************************************************** - * Name: nvmem_write - * - * Description: - * Write data to nvmem. Writes data to file referred by the ulFileId - * parameter. Writes data to file ulOffset till ulLength. The file id will be - * marked invalid till the write is done. The file entry doesn't need to be - * valid - only allocated. - * - * Input Parameters: - * ulFileId nvmem file id: - * NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID, - * NVMEM_MAC_FILEID, NVMEM_BOOTLOADER_SP_FILEID, - * and user files 12-15. - * ulLength number of bytes to write - * ulEntryOffset offset in file to start write operation from - * buff data to write - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -signed long nvmem_write(unsigned long ulFileId, unsigned long ulLength, - unsigned long ulEntryOffset, uint8_t *buff); - -/**************************************************************************** - * Name: nvmem_set_mac_address - * - * Description: - * Write MAC address to EEPROM. mac address as appears over the air (OUI - * first) - * - * Input Parameters: - * mac mac address to be set - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -uint8_t nvmem_set_mac_address(uint8_t *mac); - -/**************************************************************************** - * Name: nvmem_get_mac_address - * - * Description: - * Read MAC address from EEPROM. mac address as appears over the air (OUI - * first) - * - * Input Parameters: - * mac mac address - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -uint8_t nvmem_get_mac_address(uint8_t *mac); - -/**************************************************************************** - * Name: nvmem_write_patch - * - * Description: - * Program a patch to a specific file ID. The SP data is assumed to be - * organized in 2-dimensional. Each line is SP_PORTION_SIZE bytes long. - * Actual programming is applied in SP_PORTION_SIZE bytes portions. - * - * Input Parameters: - * ulFileId nvmem file id: - * NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID, - * spLength number of bytes to write - * spData SP data to write - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -uint8_t nvmem_write_patch(unsigned long ulFileId, unsigned long spLength, - const uint8_t *spData); - -/**************************************************************************** - * Name: nvmem_read_sp_version - * - * Description: - * Read patch version. read package version (WiFi FW patch, - * driver-supplicant-NS patch, bootloader patch) - * - * Input Parameters: - * patchVer first number indicates package ID and the second - * number indicates package build number - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -uint8_t nvmem_read_sp_version(uint8_t *patchVer); -#endif - -/**************************************************************************** - * Name: nvmem_create_entry - * - * Description: - * Create new file entry and allocate space on the NVMEM. Applies only to - * user files. Modify the size of file. If the entry is unallocated - - * allocate it to size ulNewLen (marked invalid). If it is allocated then - * deallocate it first. To just mark the file as invalid without resizing - - * Set ulNewLen=0. - * - * Input Parameters: - * ulFileId nvmem file Id: - * * NVMEM_AES128_KEY_FILEID: 12 - * * NVMEM_SHARED_MEM_FILEID: 13 - * * and fileIDs 14 and 15 - * ulNewLen entry ulLength - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -signed long nvmem_create_entry(unsigned long ulFileId, unsigned long ulNewLen); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // __INCLUDE_NUTTX_WIRELESS_CC3000_NVMEM_H diff --git a/include/nuttx/wireless/cc3000/wlan.h b/include/nuttx/wireless/cc3000/wlan.h deleted file mode 100644 index 70f2601ab3..0000000000 --- a/include/nuttx/wireless/cc3000/wlan.h +++ /dev/null @@ -1,549 +0,0 @@ -/**************************************************************************** - * include/nuttx/wireless/cc3000/wlan.h - * - * wlan.h - CC3000 Host Driver Implementation. - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 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. - * - * Neither the name of Texas Instruments Incorporated 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_CC3000_WLAN_H -#define __INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include "cc3000_common.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define WLAN_SEC_UNSEC (0) -#define WLAN_SEC_WEP (1) -#define WLAN_SEC_WPA (2) -#define WLAN_SEC_WPA2 (3) - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: wlan_init - * - * Input Parameters: - * sWlanCB Asynchronous events callback. - * 0 no event call back. - * - call back parameters: - * 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event, - * HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event, - * HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done, - * HCI_EVNT_WLAN_UNSOL_DHCP dhcp report, - * HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR - * HCI_EVNT_WLAN_KEEPALIVE keepalive. - * 2) data: pointer to extra data that received by the event - * (NULL no data). - * 3) length: data length. - * - Events with extra data: - * HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask, - * 4 bytes default gateway, 4 bytes DHCP server and 4 bytes - * for DNS server. - * HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent, - * 4 bytes Packets received, 4 bytes Min round time, - * 4 bytes Max round time and 4 bytes for Avg round time. - * - * sFWPatches 0 no patch or pointer to FW patches - * sDriverPatches 0 no patch or pointer to driver patches - * sBootLoaderPatches 0 no patch or pointer to bootloader patches - * sReadWlanInterruptPin init callback. the callback read wlan - * interrupt status. - * sWlanInterruptEnable init callback. the callback enable wlan - * interrupt. - * sWlanInterruptDisable init callback. the callback disable wlan - * interrupt. - * sWriteWlanPin init callback. the callback write value - * to device pin. - * - * Returned Value: - * None - * - * Description: - * Initialize wlan driver - * - * WARNING: This function must be called before ANY other wlan driver function - * - ****************************************************************************/ - -void wlan_init(size_t max_tx_len, - tWlanCB sWlanCB, tFWPatches sFWPatches, - tDriverPatches sDriverPatches, - tBootLoaderPatches sBootLoaderPatches); - -/**************************************************************************** - * Name: wlan_start - * - * Input Parameters: - * usPatchesAvailableAtHost - flag to indicate if patches available - * from host or from EEPROM. Due to the - * fact the patches are burn to the EEPROM - * using the patch programmer utility, the - * patches will be available from the EEPROM - * and not from the host. - * - * Returned Value: - * None - * - * Description: - * Start WLAN device. This function asserts the enable pin of - * the device (WLAN_EN), starting the HW initialization process. - * The function blocked until device Initialization is completed. - * Function also configure patches (FW, driver or bootloader) - * and calls appropriate device callbacks. - * - * NOTE: Prior calling the function wlan_init shall be called. - * WARNING: This function must be called after wlan_init and before any - * other wlan API - * - ****************************************************************************/ - -void wlan_start(uint16_t usPatchesAvailableAtHost); - -/**************************************************************************** - * Name: wlan_stop - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - * Description: - * Stop WLAN device by putting it into reset state. - * - ****************************************************************************/ - -void wlan_stop(void); - -/**************************************************************************** - * Name: wlan_connect - * - * Input Parameters: - * sec_type security options: - * WLAN_SEC_UNSEC, - * WLAN_SEC_WEP (ASCII support only), - * WLAN_SEC_WPA or WLAN_SEC_WPA2 - * ssid up to 32 bytes and is ASCII SSID of the AP - * ssid_len length of the SSID - * bssid 6 bytes specified the AP bssid - * key up to 16 bytes specified the AP security key - * key_len key length - * - * Returned Value: - * On success, zero is returned. On error, negative is returned. - * Note that even though a zero is returned on success to trigger - * connection operation, it does not mean that CCC3000 is already - * connected. An asynchronous "Connected" event is generated when - * actual association process finishes and CC3000 is connected to - * the AP. If DHCP is set, An asynchronous "DHCP" event is - * generated when DHCP process is finish. - * - * Description: - * Connect to AP - * - * WARNING: Please Note that when connection to AP configured with security - * type WEP, please confirm that the key is set as ASCII and not - * as HEX. - * - ****************************************************************************/ - -#ifndef CC3000_TINY_DRIVER -long wlan_connect(unsigned long ulSecType, FAR const char *ssid, - long ssid_len, FAR const uint8_t *bssid, - FAR const uint8_t *key, long key_len); -#else -long wlan_connect(FAR const char *ssid, long ssid_len); -#endif - -/**************************************************************************** - * Name: wlan_disconnect - * - * Input Parameters: - * None - * - * Returned Value: - * 0 disconnected done, other CC3000 already disconnected - * - * Description: - * Disconnect connection from AP. - * - ****************************************************************************/ - -long wlan_disconnect(void); - -/**************************************************************************** - * Name: wlan_add_profile - * - * Input Parameters: - * ulSecType WLAN_SEC_UNSEC,WLAN_SEC_WEP,WLAN_SEC_WPA,WLAN_SEC_WPA2 - * ucSsid ssid SSID up to 32 bytes - * ulSsidLen ssid length - * ucBssid bssid 6 bytes - * ulPriority ulPriority profile priority. Lowest priority:0. - * ulPairwiseCipher_Or_TxKeyLen key length for WEP security - * ulGroupCipher_TxKeyIndex key index - * ulKeyMgmt KEY management - * ucPf_OrKey security key - * ulPassPhraseLen security key length for WPA\WPA2 - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * When auto start is enabled, the device connects to - * station from the profiles table. Up to 7 profiles are supported. - * If several profiles configured the device choose the highest - * priority profile, within each priority group, device will choose - * profile based on security policy, signal strength, etc - * parameters. All the profiles are stored in CC3000 NVMEM. - * - ****************************************************************************/ - -long wlan_add_profile(unsigned long ulSecType, uint8_t* ucSsid, - unsigned long ulSsidLen, uint8_t *ucBssid, - unsigned long ulPriority, - unsigned long ulPairwiseCipher_Or_TxKeyLen, - unsigned long ulGroupCipher_TxKeyIndex, - unsigned long ulKeyMgmt, uint8_t* ucPf_OrKey, - unsigned long ulPassPhraseLen); - -/**************************************************************************** - * Name: wlan_ioctl_del_profile - * - * Input Parameters: - * index number of profile to delete - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * Delete WLAN profile - * - * @Note In order to delete all stored profile, set index to 255. - * - ****************************************************************************/ - -long wlan_ioctl_del_profile(unsigned long ulIndex); - -/**************************************************************************** - * Name: wlan_set_event_mask - * - * Input Parameters: - * mask mask option: - * HCI_EVNT_WLAN_UNSOL_CONNECT connect event - * HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event - * HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE smart config done - * HCI_EVNT_WLAN_UNSOL_INIT init done - * HCI_EVNT_WLAN_UNSOL_DHCP dhcp event report - * HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report - * HCI_EVNT_WLAN_KEEPALIVE keepalive - * HCI_EVNT_WLAN_TX_COMPLETE - disable information on end of transmission - * Saved: no. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * Mask event according to bit mask. In case that event is - * masked (1), the device will not send the masked event to host. - * - ****************************************************************************/ - -long wlan_set_event_mask(unsigned long ulMask); - -/**************************************************************************** - * Name: wlan_ioctl_statusget - * - * Input Parameters: - * None - * - * Returned Value: - * WLAN_STATUS_DISCONNECTED, WLAN_STATUS_SCANING, - * STATUS_CONNECTING or WLAN_STATUS_CONNECTED - * - * Description: - * get wlan status: disconnected, scanning, connecting or connected - * - ****************************************************************************/ - -long wlan_ioctl_statusget(void); - -/**************************************************************************** - * Name: wlan_ioctl_set_connection_policy - * - * Input Parameters: - * should_connect_to_open_ap enable(1), disable(0) connect to any - * available AP. This parameter corresponds to the configuration of - * item # 3 in the brief description. - * should_use_fast_connect enable(1), disable(0). if enabled, tries - * to connect to the last connected AP. This parameter corresponds - * to the configuration of item # 1 in the brief description. - * auto_start enable(1), disable(0) auto connect - * after reset and periodically reconnect if needed. This - * configuration configures option 2 in the above description. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * When auto is enabled, the device tries to connect according - * the following policy: - * 1) If fast connect is enabled and last connection is valid, - * the device will try to connect to it without the scanning - * procedure (fast). The last connection will be marked as - * invalid, due to adding/removing profile. - * 2) If profile exists, the device will try to connect it - * (Up to seven profiles). - * 3) If fast and profiles are not found, and open mode is - * enabled, the device will try to connect to any AP. - * * Note that the policy settings are stored in the CC3000 NVMEM. - * - ****************************************************************************/ - -long wlan_ioctl_set_connection_policy(unsigned long should_connect_to_open_ap, - unsigned long ulShouldUseFastConnect, - unsigned long ulUseProfiles); - -/**************************************************************************** - * Name: wlan_ioctl_get_scan_results - * - * Input Parameters: - * scan_timeout parameter not supported - * ucResults scan results (_wlan_full_scan_results_args_t) - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * Gets entry from scan result table. - * The scan results are returned one by one, and each entry - * represents a single AP found in the area. The following is a - * format of the scan result: - * - 4 Bytes: number of networks found - * - 4 Bytes: The status of the scan: 0 - aged results, - * 1 - results valid, 2 - no results - * - 42 bytes: Result entry, where the bytes are arranged as follows: - * - 1 bit isValid - is result valid or not - * - 7 bits rssi - RSSI value; - * - 2 bits: securityMode - security mode of the AP: - * 0 - Open, 1 - WEP, 2 WPA, 3 WPA2 - * - 6 bits: SSID name length - * - 2 bytes: the time at which the entry has entered into - * scans result table - * - 32 bytes: SSID name - * - 6 bytes: BSSID - * - * NOTE: scan_timeout, is not supported on this version. - * - ****************************************************************************/ - -long wlan_ioctl_get_scan_results(unsigned long ulScanTimeout, uint8_t *ucResults); - -/**************************************************************************** - * Name: wlan_ioctl_set_scan_params - * - * Input Parameters: - * uiEnable - start/stop application scan: - * 1 = start scan with default interval value of 10 min. - * in order to set a different scan interval value apply the value - * in milliseconds. minimum 1 second. 0=stop). Wlan reset - * (wlan_stop() wlan_start()) is needed when changing scan interval - * value. Saved: No - * uiMinDwellTime minimum dwell time value to be used for each - * channel, in milliseconds. Saved: yes - * Recommended Value: 100 (Default: 20) - * uiMaxDwellTime maximum dwell time value to be used for each - * channel, in milliseconds. Saved: yes - * Recommended Value: 100 (Default: 30) - * uiNumOfProbeRequests max probe request between dwell time. - * Saved: yes. Recommended Value: 5 (Default:2) - * uiChannelMask bitwise, up to 13 channels (0x1fff). - * Saved: yes. Default: 0x7ff - * uiRSSIThreshold RSSI threshold. Saved: yes (Default: -80) - * uiSNRThreshold NSR threshold. Saved: yes (Default: 0) - * uiDefaultTxPower probe Tx power. Saved: yes (Default: 205) - * aiIntervalList pointer to array with 16 entries (16 channels) - * each entry (unsigned long) holds timeout between periodic scan - * (connection scan) - in millisecond. Saved: yes. Default 2000ms. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * start and stop scan procedure. Set scan parameters. - * - * @Note uiDefaultTxPower, is not supported on this version. - * - ****************************************************************************/ - -long wlan_ioctl_set_scan_params(unsigned long uiEnable, - unsigned long uiMinDwellTime, - unsigned long uiMaxDwellTime, - unsigned long uiNumOfProbeRequests, - unsigned long uiChannelMask,long iRSSIThreshold, - unsigned long uiSNRThreshold, - unsigned long uiDefaultTxPower, - unsigned long *aiIntervalList); - -/**************************************************************************** - * Name: wlan_smart_config_start - * - * Input Parameters: - * algoEncryptedFlag indicates whether the information is encrypted - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * Start to acquire device profile. The device acquire its own - * profile, if profile message is found. The acquired AP information - * is stored in CC3000 EEPROM only in case AES128 encryption is used. - * In case AES128 encryption is not used, a profile is created by - * CC3000 internally. - * - * @Note An asynchronous event - Smart Config Done will be generated as soon - * as the process finishes successfully. - * - ****************************************************************************/ - -long wlan_smart_config_start(unsigned long algoEncryptedFlag); - -/**************************************************************************** - * Name: wlan_smart_config_stop - * - * Input Parameters: - * algoEncryptedFlag indicates whether the information is encrypted - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * Stop the acquire profile procedure - * - ****************************************************************************/ - -long wlan_smart_config_stop(void); - -/**************************************************************************** - * Name: wlan_smart_config_set_prefix - * - * Input Parameters: - * newPrefix 3 bytes identify the SSID prefix for the Smart Config. - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * Configure station ssid prefix. The prefix is used internally - * in CC3000. It should always be TTT. - * - * @Note The prefix is stored in CC3000 NVMEM - * - ****************************************************************************/ - -long wlan_smart_config_set_prefix(char* cNewPrefix); - -/**************************************************************************** - * Name: aes_read_key - * - * Description: - * Reads AES128 key from EEPROM. Reads the AES128 key from fileID #12 in - * EEPROM returns an error if the key does not exist. - * - * Input Parameters: - * key AES128 key of size 16 bytes - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -signed long aes_read_key(FAR uint8_t *key); - -/**************************************************************************** - * Name: aes_write_key - * - * Description: - * Writes AES128 key from EEPROM Writes the AES128 key to fileID #12 in - * EEPROM - * - * Input Parameters: - * key AES128 key of size 16 bytes - * - * Returned Value: - * On success 0, error otherwise. - * - ****************************************************************************/ - -signed long aes_write_key(FAR uint8_t *key); - -/**************************************************************************** - * Name: wlan_smart_config_process - * - * Input Parameters: - * None - * - * Returned Value: - * On success, zero is returned. On error, -1 is returned - * - * Description: - * process the acquired data and store it as a profile. The acquired - * AP information is stored in CC3000 EEPROM encrypted. - * The encrypted data is decrypted and stored as a profile. - * behavior is as defined by connection policy. - * - ****************************************************************************/ - -long wlan_smart_config_process(void); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // __INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H diff --git a/include/nuttx/wireless/ioctl.h b/include/nuttx/wireless/ioctl.h index ea3abc0e1c..e9bd5c816d 100644 --- a/include/nuttx/wireless/ioctl.h +++ b/include/nuttx/wireless/ioctl.h @@ -86,14 +86,10 @@ * command numbers from overlapping. */ -/* See include/nuttx/wireless/cc3000.h */ - -#define CC3000_FIRST (WL_FIRST + WL_NCMDS) -#define CC3000_NCMDS 7 /* See include/nuttx/wireless/nrf24l01.h */ -#define NRF24L01_FIRST (CC3000_FIRST + CC3000_NCMDS) +#define NRF24L01_FIRST (WL_FIRST + WL_NCMDS) #define NRF24L01_NCMDS 14 /************************************************************************************