This commit removes all support and all references to the Spark board and to the CC3000 wireless part.
Squashed commit of the following: Author: Gregory Nutt <gnutt@nuttx.org> Fix a few remaining refereces to cc3000. Author: Alan Carvalho de Assis <acassis@gmail.com> drivers/wireless/cc3000: emove the driver to support CC3000 because it doesn't use the USRSOCKET Author: Alan Carvalho de Assis <acassis@gmail.com> configs: Remove board support to CC3000 from all relevant configurations. Author: Gregory Nutt <gnutt@nuttx.org> configs/spark: Removes Spark board configuration. Still available in the Obsoleted repository. This is preparation for removal of CC3000 support by Alan Carvalho de Assis. If there is no CC3000 support, then there is no purpose in supporting the Spark either.
This commit is contained in:
parent
97ca4ef956
commit
b4c1ac0659
@ -8,7 +8,7 @@
|
|||||||
<tr align="center" bgcolor="#e4e4e4">
|
<tr align="center" bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
|
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
|
||||||
<p>Last Updated: March 2, 2017</p>
|
<p>Last Updated: April 4, 2018</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -974,7 +974,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<p>
|
<p>
|
||||||
<li>
|
<li>
|
||||||
Support for networking modules (e.g., the TI CC3000 WLAN module and ESP8266).
|
Support for networking modules (e.g., ESP8266).
|
||||||
</li>
|
</li>
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
@ -1504,7 +1504,7 @@
|
|||||||
<li><a href="#armcortexa9">ARM Cortex-A9</a> (1)</li>
|
<li><a href="#armcortexa9">ARM Cortex-A9</a> (1)</li>
|
||||||
<li><a href="#armcortexr4">ARM Cortex-R4</a> (1)</li>
|
<li><a href="#armcortexr4">ARM Cortex-R4</a> (1)</li>
|
||||||
<li><a href="#armcortexm0">ARM Cortex-M0/M0+</a> (10)</li>
|
<li><a href="#armcortexm0">ARM Cortex-M0/M0+</a> (10)</li>
|
||||||
<li><a href="#armcortexm3">ARM Cortex-M3</a> (38)</li>
|
<li><a href="#armcortexm3">ARM Cortex-M3</a> (37)</li>
|
||||||
<li><a href="#armcortexm4">ARM Cortex-M4</a> (44)</li>
|
<li><a href="#armcortexm4">ARM Cortex-M4</a> (44)</li>
|
||||||
<li><a href="#armcortexm7">ARM Cortex-M7</a> (10)</li>
|
<li><a href="#armcortexm7">ARM Cortex-M7</a> (10)</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -3128,7 +3128,7 @@ nsh>
|
|||||||
<td>
|
<td>
|
||||||
<p>
|
<p>
|
||||||
<a name="stm32f103x"><b>STMicro STM32F103x (STM32 F1 Family)</b>.</a>
|
<a name="stm32f103x"><b>STMicro STM32F103x (STM32 F1 Family)</b>.</a>
|
||||||
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.
|
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.
|
Board supported is available specifically for: STM32F103ZET6, STM32F103RET6, STM32F103VCT, STM32F103VET6, STM32F103RBT6, and STM32103CBT6.
|
||||||
Boards supported include:
|
Boards supported include:
|
||||||
@ -3164,19 +3164,6 @@ nsh>
|
|||||||
see the NuttX board <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/maple/README.txt" target="_blank">README</a> file for further information about the NuttX port.
|
see the NuttX board <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/maple/README.txt" target="_blank">README</a> file for further information about the NuttX port.
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<p>
|
|
||||||
<b>Spark (and <i>emulated Spark</i>)</b>.
|
|
||||||
The Spark boards are based on the STM32F103CBT6 chip and feature wireless networking using the TI CC3000 WLAN module.
|
|
||||||
See the <a href="http://www.spark.io">Spark</a> web site for hardware information;
|
|
||||||
The <i>emulated Spark</i> 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 <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/spark/README.txt" target="_blank">README</a> file for further information about the NuttX port.
|
|
||||||
<p>
|
|
||||||
</p>
|
|
||||||
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.
|
|
||||||
</p>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<p>
|
<p>
|
||||||
<b>Olimexino-STM32</b>.
|
<b>Olimexino-STM32</b>.
|
||||||
@ -3229,13 +3216,6 @@ nsh>
|
|||||||
Support for the Maple boards was contributed by Yiran Liao and first appear in NuttX 6-30.
|
Support for the Maple boards was contributed by Yiran Liao and first appear in NuttX 6-30.
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<p>
|
|
||||||
<b>Spark</b>.
|
|
||||||
David Sidrane has the <i>emulated</i> 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!
|
|
||||||
</p>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<p>
|
<p>
|
||||||
<b>Olimexino-STM32</b>.
|
<b>Olimexino-STM32</b>.
|
||||||
|
@ -275,8 +275,6 @@ nuttx/
|
|||||||
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/sim/README.txt" target="_blank"><b><i>README.txt</i></b></a>
|
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/sim/README.txt" target="_blank"><b><i>README.txt</i></b></a>
|
||||||
| |- skp16c26/
|
| |- skp16c26/
|
||||||
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/skp16c26/README.txt" target="_blank"><b><i>README.txt</i></b></a>
|
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/skp16c26/README.txt" target="_blank"><b><i>README.txt</i></b></a>
|
||||||
| |- spark/
|
|
||||||
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/spark/README.txt" target="_blank"><b><i>README.txt</i></b></a>
|
|
||||||
| |- stm3210e-eval/
|
| |- stm3210e-eval/
|
||||||
| | |- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/stm3210e-eval/RIDE/README.txt" target="_blank">RIDE/README.txt</a>
|
| | |- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/stm3210e-eval/RIDE/README.txt" target="_blank">RIDE/README.txt</a>
|
||||||
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/stm3210e-eval/README.txt" target="_blank"><b><i>README.txt</i></b></a>
|
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/stm3210e-eval/README.txt" target="_blank"><b><i>README.txt</i></b></a>
|
||||||
|
@ -1843,8 +1843,6 @@ nuttx/
|
|||||||
| | `- README.txt
|
| | `- README.txt
|
||||||
| |- skp16c26/
|
| |- skp16c26/
|
||||||
| | `- README.txt
|
| | `- README.txt
|
||||||
| |- spark/
|
|
||||||
| | `- README.txt
|
|
||||||
| |- stm3210e-eval/
|
| |- stm3210e-eval/
|
||||||
| | |- RIDE/README.txt
|
| | |- RIDE/README.txt
|
||||||
| | `- README.txt
|
| | `- README.txt
|
||||||
|
@ -1111,17 +1111,6 @@ config ARCH_BOARD_SKP16C26
|
|||||||
uses the GNU m32c toolchain. STATUS: The port is complete but untested
|
uses the GNU m32c toolchain. STATUS: The port is complete but untested
|
||||||
due to issues with compiler internal errors.
|
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
|
config ARCH_BOARD_PHOTON
|
||||||
bool "Photon wifi board"
|
bool "Photon wifi board"
|
||||||
depends on ARCH_CHIP_STM32F205RG
|
depends on ARCH_CHIP_STM32F205RG
|
||||||
@ -1726,7 +1715,6 @@ config ARCH_BOARD
|
|||||||
default "samv71-xult" if ARCH_BOARD_SAMV71_XULT
|
default "samv71-xult" if ARCH_BOARD_SAMV71_XULT
|
||||||
default "shenzhou" if ARCH_BOARD_SHENZHOU
|
default "shenzhou" if ARCH_BOARD_SHENZHOU
|
||||||
default "skp16c26" if ARCH_BOARD_SKP16C26
|
default "skp16c26" if ARCH_BOARD_SKP16C26
|
||||||
default "spark" if ARCH_BOARD_SPARK
|
|
||||||
default "photon" if ARCH_BOARD_PHOTON
|
default "photon" if ARCH_BOARD_PHOTON
|
||||||
default "stm32butterfly2" if ARCH_BOARD_STM32_BUTTERFLY2
|
default "stm32butterfly2" if ARCH_BOARD_STM32_BUTTERFLY2
|
||||||
default "stm32_tiny" if ARCH_BOARD_STM32_TINY
|
default "stm32_tiny" if ARCH_BOARD_STM32_TINY
|
||||||
@ -2120,9 +2108,6 @@ endif
|
|||||||
if ARCH_BOARD_SKP16C26
|
if ARCH_BOARD_SKP16C26
|
||||||
source "configs/skp16c26/Kconfig"
|
source "configs/skp16c26/Kconfig"
|
||||||
endif
|
endif
|
||||||
if ARCH_BOARD_SPARK
|
|
||||||
source "configs/spark/Kconfig"
|
|
||||||
endif
|
|
||||||
if ARCH_BOARD_PHOTON
|
if ARCH_BOARD_PHOTON
|
||||||
source "configs/photon/Kconfig"
|
source "configs/photon/Kconfig"
|
||||||
endif
|
endif
|
||||||
|
@ -664,10 +664,6 @@ configs/shenzhou
|
|||||||
This is the port of NuttX to the Shenzhou development board from
|
This is the port of NuttX to the Shenzhou development board from
|
||||||
www.armjishu.com. This board features the STMicro STM32F107VCT MCU.
|
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
|
configs/skp16c26
|
||||||
Renesas M16C processor on the Renesas SKP16C26 StarterKit. This port
|
Renesas M16C processor on the Renesas SKP16C26 StarterKit. This port
|
||||||
uses the GNU m32c toolchain. STATUS: The port is complete but untested
|
uses the GNU m32c toolchain. STATUS: The port is complete but untested
|
||||||
|
@ -369,25 +369,3 @@ Where <subdir> is one of the following:
|
|||||||
|
|
||||||
5. This configurations has support for NSH built-in applications. However,
|
5. This configurations has support for NSH built-in applications. However,
|
||||||
in the default configuration no built-in applications are enabled.
|
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
|
|
||||||
|
@ -218,12 +218,6 @@
|
|||||||
#define PIN_SPI1_MISO (PIN_SPI1_MISO_3 | PIN_ALT2_PULLUP)
|
#define PIN_SPI1_MISO (PIN_SPI1_MISO_3 | PIN_ALT2_PULLUP)
|
||||||
#define PIN_SPI1_MOSI (PIN_SPI0_MOSI_7 | 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
|
/* Interrupt pin used by ADXL345
|
||||||
*
|
*
|
||||||
* CS = PTD0 (D10 at connector J2 pin 6 of Freedom Board)
|
* CS = PTD0 (D10 at connector J2 pin 6 of Freedom Board)
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* configs/freedom-kl25z/include/kl_cc300.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 Alan Carvalho de Assis
|
|
||||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
|
||||||
* with adaptions from Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* 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 <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* 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 */
|
|
||||||
|
|
@ -42,10 +42,6 @@ ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
|||||||
CSRCS += kl_appinit.c
|
CSRCS += kl_appinit.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_WL_CC3000),y)
|
|
||||||
CSRCS += kl_cc3000.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_KL_TSI),y)
|
ifeq ($(CONFIG_KL_TSI),y)
|
||||||
CSRCS += kl_tsi.c
|
CSRCS += kl_tsi.c
|
||||||
endif
|
endif
|
||||||
|
@ -127,10 +127,5 @@ void board_initialize(void)
|
|||||||
(void)board_app_initialize(0);
|
(void)board_app_initialize(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* CC3000 wireless initialization */
|
|
||||||
|
|
||||||
#ifdef CONFIG_WL_CC3000
|
|
||||||
wireless_archinitialize(0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,375 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* configs/freedom-kl25z/src/kl_cc3000.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Alan Carvalho de Assis
|
|
||||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
#include <arch/board/kl_cc3000.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/fs/fs.h>
|
|
||||||
#include <nuttx/wireless/cc3000.h>
|
|
||||||
#include <nuttx/wireless/cc3000/include/cc3000_upif.h>
|
|
||||||
|
|
||||||
#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 */
|
|
@ -71,12 +71,6 @@ void weak_function kl_spidev_initialize(void)
|
|||||||
# ifdef CONFIG_ADXL345_SPI
|
# ifdef CONFIG_ADXL345_SPI
|
||||||
kl_configgpio(GPIO_ADXL345_CS);
|
kl_configgpio(GPIO_ADXL345_CS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# ifdef CONFIG_WL_CC3000
|
|
||||||
kl_configgpio(GPIO_WIFI_CS);
|
|
||||||
kl_configgpio(GPIO_WIFI_EN);
|
|
||||||
kl_configgpio(GPIO_WIFI_INT);
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Configure SPI1 chip selects */
|
/* 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);
|
kl_gpiowrite(GPIO_ADXL345_CS, !selected);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_WL_CC3000)
|
|
||||||
if (devid == SPIDEV_WIRELESS(0))
|
|
||||||
{
|
|
||||||
kl_gpiowrite(GPIO_WIFI_CS, !selected);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -48,13 +48,6 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y)
|
|||||||
CSRCS += stm32_buttons.c
|
CSRCS += stm32_buttons.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_WL_CC3000),y)
|
|
||||||
CSRCS += stm32_wireless.c
|
|
||||||
ifeq ($(CONFIG_CC3000_PROBES),)
|
|
||||||
CSRCS += stm32_io.c
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADC),y)
|
ifeq ($(CONFIG_ADC),y)
|
||||||
CSRCS += stm32_adc.c
|
CSRCS += stm32_adc.c
|
||||||
ifeq ($(CONFIG_AJOYSTICK),y)
|
ifeq ($(CONFIG_AJOYSTICK),y)
|
||||||
|
@ -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 */
|
/* SPI1 off */
|
||||||
|
|
||||||
#define GPIO_SPI1_MOSI_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
|
#define GPIO_SPI1_MOSI_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
|
||||||
@ -139,28 +112,12 @@
|
|||||||
#define GPIO_SPI1_SCK_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
|
#define GPIO_SPI1_SCK_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
|
||||||
GPIO_PORTA | GPIO_PIN5)
|
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
|
#ifdef HAVE_MMCSD
|
||||||
# define GPIO_SPI_CS_SD_CARD_OFF \
|
# define GPIO_SPI_CS_SD_CARD_OFF \
|
||||||
(GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \
|
(GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \
|
||||||
GPIO_PORTB | GPIO_PIN5)
|
GPIO_PORTB | GPIO_PIN5)
|
||||||
#endif
|
#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
|
#ifdef HAVE_MMCSD
|
||||||
# define GPIO_SPI_CS_SD_CARD \
|
# define GPIO_SPI_CS_SD_CARD \
|
||||||
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
|
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
|
||||||
@ -175,24 +132,6 @@
|
|||||||
#define NUCLEO_I2C_OBDEV_LED 0x55
|
#define NUCLEO_I2C_OBDEV_LED 0x55
|
||||||
#define NUCLEO_I2C_OBDEV_HMC5883 0x1e
|
#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
|
/* Itead Joystick Shield
|
||||||
*
|
*
|
||||||
* See http://imall.iteadstudio.com/im120417014.html for more information
|
* See http://imall.iteadstudio.com/im120417014.html for more information
|
||||||
|
@ -59,20 +59,6 @@
|
|||||||
* Public Functions
|
* 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
|
* Name: board_app_initialize
|
||||||
*
|
*
|
||||||
|
@ -123,11 +123,5 @@ void board_initialize(void)
|
|||||||
#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_LIB_BOARDCTL)
|
#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_LIB_BOARDCTL)
|
||||||
board_app_initialize(0);
|
board_app_initialize(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* CC3000 wireless initialization */
|
|
||||||
|
|
||||||
#ifdef CONFIG_WL_CC3000
|
|
||||||
wireless_archinitialize(0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,185 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* configs/nucleo-f4x1re/src/stm32_io.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
#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 */
|
|
@ -91,10 +91,6 @@ void weak_function stm32_spidev_initialize(void)
|
|||||||
spierr("ERROR: FAILED to initialize SPI port 1\n");
|
spierr("ERROR: FAILED to initialize SPI port 1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_WL_CC3000
|
|
||||||
stm32_configgpio(GPIO_SPI_CS_WIFI);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_MMCSD
|
#ifdef HAVE_MMCSD
|
||||||
stm32_configgpio(GPIO_SPI_CS_SD_CARD);
|
stm32_configgpio(GPIO_SPI_CS_SD_CARD);
|
||||||
#endif
|
#endif
|
||||||
@ -104,14 +100,6 @@ void weak_function stm32_spidev_initialize(void)
|
|||||||
/* Configure SPI-based devices */
|
/* Configure SPI-based devices */
|
||||||
|
|
||||||
g_spi2 = stm32_spibus_initialize(2);
|
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
|
#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");
|
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
|
#ifdef HAVE_MMCSD
|
||||||
if (devid == SPIDEV_MMCSD(0))
|
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)
|
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");
|
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)
|
uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||||
|
@ -1,367 +0,0 @@
|
|||||||
/************************************************************************************
|
|
||||||
* configs/nucleo-f4x1re/src/stm32_wireless.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Laurent Latil <laurent@latil.nom.fr>
|
|
||||||
* David Sidrane <david_s5@nscdg.com>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Included Files
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <debug.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
|
||||||
#include <nuttx/spi/spi.h>
|
|
||||||
#include <nuttx/wireless/cc3000.h>
|
|
||||||
#include <nuttx/wireless/cc3000/include/cc3000_upif.h>
|
|
||||||
|
|
||||||
#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 */
|
|
@ -48,13 +48,6 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y)
|
|||||||
CSRCS += stm32_buttons.c
|
CSRCS += stm32_buttons.c
|
||||||
endif
|
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)
|
ifeq ($(CONFIG_WL_CC1101),y)
|
||||||
CSRCS += stm32_cc1101.c
|
CSRCS += stm32_cc1101.c
|
||||||
endif
|
endif
|
||||||
|
@ -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 */
|
/* SPI1 off */
|
||||||
|
|
||||||
#define GPIO_SPI1_MOSI_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
|
#define GPIO_SPI1_MOSI_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
|
||||||
@ -158,14 +131,6 @@
|
|||||||
#define GPIO_SPI1_SCK_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
|
#define GPIO_SPI1_SCK_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
|
||||||
GPIO_PORTA | GPIO_PIN5)
|
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
|
#ifdef CONFIG_WL_CC1101
|
||||||
# define GPIO_CC1101_PWR (GPIO_PORTC | GPIO_PIN6 | GPIO_OUTPUT_SET | \
|
# define GPIO_CC1101_PWR (GPIO_PORTC | GPIO_PIN6 | GPIO_OUTPUT_SET | \
|
||||||
GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
|
GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
|
||||||
@ -184,12 +149,6 @@
|
|||||||
|
|
||||||
/* SPI chip selects */
|
/* 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
|
#ifdef HAVE_MMCSD
|
||||||
# define GPIO_SPI_CS_SD_CARD \
|
# define GPIO_SPI_CS_SD_CARD \
|
||||||
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
|
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
|
||||||
@ -209,19 +168,6 @@
|
|||||||
* GPIO0-1 are for probing WIFI status
|
* 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
|
/* Itead Joystick Shield
|
||||||
*
|
*
|
||||||
* See http://imall.iteadstudio.com/im120417014.html for more information
|
* See http://imall.iteadstudio.com/im120417014.html for more information
|
||||||
|
@ -68,20 +68,6 @@
|
|||||||
* Public Functions
|
* 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
|
* Name: board_app_initialize
|
||||||
*
|
*
|
||||||
|
@ -123,11 +123,5 @@ void board_initialize(void)
|
|||||||
#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_NSH_ARCHINIT)
|
#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_NSH_ARCHINIT)
|
||||||
board_app_initialize(0);
|
board_app_initialize(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* CC3000 wireless initialization */
|
|
||||||
|
|
||||||
#ifdef CONFIG_WL_CC3000
|
|
||||||
wireless_archinitialize(0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,367 +0,0 @@
|
|||||||
/************************************************************************************
|
|
||||||
* configs/nucleo-l476rg/src/stm32_cc3000.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Laurent Latil <laurent@latil.nom.fr>
|
|
||||||
* David Sidrane <david_s5@nscdg.com>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Included Files
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <debug.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
|
||||||
#include <nuttx/spi/spi.h>
|
|
||||||
#include <nuttx/wireless/cc3000.h>
|
|
||||||
#include <nuttx/wireless/cc3000/include/cc3000_upif.h>
|
|
||||||
|
|
||||||
#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 */
|
|
@ -1,185 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* configs/nucleo-l476rg/src/stm32_io.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
#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 */
|
|
@ -92,10 +92,6 @@ void weak_function stm32l4_spiinitialize(void)
|
|||||||
spierr("ERROR: FAILED to initialize SPI port 1\n");
|
spierr("ERROR: FAILED to initialize SPI port 1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_WL_CC3000
|
|
||||||
stm32l4_configgpio(GPIO_SPI_CS_WIFI);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_MMCSD
|
#ifdef HAVE_MMCSD
|
||||||
stm32l4_configgpio(GPIO_SPI_CS_SD_CARD);
|
stm32l4_configgpio(GPIO_SPI_CS_SD_CARD);
|
||||||
#endif
|
#endif
|
||||||
@ -106,14 +102,6 @@ void weak_function stm32l4_spiinitialize(void)
|
|||||||
|
|
||||||
g_spi2 = stm32l4_spibus_initialize(2);
|
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
|
#ifdef CONFIG_WL_CC1101
|
||||||
/* Setup CS, IRQ(gdo2) line IOs */
|
/* 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");
|
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
|
#ifdef HAVE_MMCSD
|
||||||
if (devid == SPIDEV_MMCSD(0))
|
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");
|
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
|
#ifdef CONFIG_WL_CC1101
|
||||||
if (devid == SPIDEV_WIRELESS(5))
|
if (devid == SPIDEV_WIRELESS(5))
|
||||||
{
|
{
|
||||||
|
@ -581,8 +581,7 @@ USB Full-Speed Device
|
|||||||
directories that can be used for reference.
|
directories that can be used for reference.
|
||||||
|
|
||||||
2. Linux supports the CDC/ACM driver out of the box. Windows, on the other
|
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
|
than requires that you first install a serial driver (a .inf file).
|
||||||
are example .inf files for NuttX in the nuttx/configs/spark directories.
|
|
||||||
|
|
||||||
3. There is hand-shaking to pace incoming serial data. As a result, you may
|
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
|
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
|
5. By default, this configuration uses the CDC/ACM serial device to
|
||||||
provide the USB console. This works out-of-the-box for Linux.
|
provide the USB console. This works out-of-the-box for Linux.
|
||||||
Windows, on the other hand, will require a CDC/ACM device driver
|
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
|
(.inf file).
|
||||||
directories.
|
|
||||||
|
|
||||||
5. Using the Prolifics PL2303 Emulation
|
5. Using the Prolifics PL2303 Emulation
|
||||||
|
|
||||||
|
@ -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
|
|
@ -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 <david_s5@nscdg.com> 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.
|
|
@ -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
|
|
@ -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 <gnutt@nuttx.org>
|
|
||||||
* Librae <librae8226@gmail.com>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __CONFIGS_SPARK_INCLUDE_BOARD_H
|
|
||||||
#define __CONFIGS_SPARK_INCLUDE_BOARD_H
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Included Files
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
|
||||||
# include <stdint.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <nuttx/board.h>
|
|
||||||
|
|
||||||
#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 */
|
|
@ -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
|
|
@ -1,117 +0,0 @@
|
|||||||
############################################################################
|
|
||||||
# configs/spark/scripts/Make.defs
|
|
||||||
#
|
|
||||||
# Copyright (C) 2013, 2017 Gregory Nutt. All rights reserved.
|
|
||||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
#
|
|
||||||
# 1. Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer in
|
|
||||||
# the documentation and/or other materials provided with the
|
|
||||||
# distribution.
|
|
||||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
# used to endorse or promote products derived from this software
|
|
||||||
# without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
include ${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 =
|
|
@ -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:
|
|
||||||
; <http://msdn.microsoft.com/en-us/cc300389.aspx#MLPL>.
|
|
||||||
; 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"
|
|
@ -1,119 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* configs/spark/scripts/ld.script
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
* Librae <librae8226@gmail.com>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/* 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) }
|
|
||||||
}
|
|
@ -1,119 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* configs/spark/scripts/ld.script.dfu
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
* Librae <librae8226@gmail.com>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/* 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) }
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
############################################################################
|
|
||||||
# configs/spark/src/Makefile
|
|
||||||
#
|
|
||||||
# Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
|
|
||||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
# Librae <librae8226@gmail.com>
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
#
|
|
||||||
# 1. Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer in
|
|
||||||
# the documentation and/or other materials provided with the
|
|
||||||
# distribution.
|
|
||||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
# used to endorse or promote products derived from this software
|
|
||||||
# without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
-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
|
|
@ -1,270 +0,0 @@
|
|||||||
/************************************************************************************
|
|
||||||
* configs/spark/src/spark.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Laurent Latil <laurent@latil.nom.fr>
|
|
||||||
* Librae <librae8226@gmail.com>
|
|
||||||
* David_s5 <david_s5@nscdg.com>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __CONFIGS_SPARK_SRC_SPARK_H
|
|
||||||
#define __CONFIGS_SPARK_SRC_SPARK_H
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Included Files
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
#include <nuttx/compiler.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <arch/chip/chip.h>
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* 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 */
|
|
@ -1,318 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* config/spark/src/stm32_appinit.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2012-2013, 2016 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
* David_s5 <david_s5@nscdg.com>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <syslog.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <nuttx/board.h>
|
|
||||||
#include <nuttx/kmalloc.h>
|
|
||||||
|
|
||||||
#ifdef CONFIG_MTD_SST25
|
|
||||||
# include <nuttx/spi/spi.h>
|
|
||||||
# include <nuttx/mtd/mtd.h>
|
|
||||||
# include <sys/mount.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_USBMONITOR
|
|
||||||
# include <nuttx/usb/usbmonitor.h>
|
|
||||||
#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;
|
|
||||||
}
|
|
@ -1,287 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* configs/spark/src/stm32_autoleds.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
* David Sidrane <david_s5@nscdg.com>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/board.h>
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
|
|
||||||
#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 */
|
|
@ -1,138 +0,0 @@
|
|||||||
/************************************************************************************
|
|
||||||
* configs/spark/src/stm32_boot.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
* Librae <librae8226@gmail.com>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Included Files
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
#include <nuttx/spi/spi.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/board.h>
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
@ -1,125 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* configs/spark/src/stm32_buttons.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011-2015, 2017 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/board.h>
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
|
|
||||||
#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 */
|
|
@ -1,368 +0,0 @@
|
|||||||
/************************************************************************************
|
|
||||||
* configs/spark/src/stm32_cc3000.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009, 2013 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Laurent Latil <laurent@latil.nom.fr>
|
|
||||||
* David Sidrane <david_s5@nscdg.com>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Included Files
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <debug.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
|
||||||
#include <nuttx/spi/spi.h>
|
|
||||||
#include <nuttx/wireless/cc3000.h>
|
|
||||||
#include <nuttx/wireless/cc3000/include/cc3000_upif.h>
|
|
||||||
|
|
||||||
#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 */
|
|
@ -1,621 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* config/spark/src/stm32_composite.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2012-2013, 2016 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
* David_s5 <david_s5@nscdg.com>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <debug.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
|
||||||
#include <nuttx/board.h>
|
|
||||||
|
|
||||||
#ifdef CONFIG_MTD_SST25
|
|
||||||
# include <nuttx/spi/spi.h>
|
|
||||||
# include <nuttx/mtd/mtd.h>
|
|
||||||
# include <sys/mount.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <nuttx/usb/usbdev.h>
|
|
||||||
#include <nuttx/usb/cdcacm.h>
|
|
||||||
#include <nuttx/usb/usbmsc.h>
|
|
||||||
#include <nuttx/usb/composite.h>
|
|
||||||
|
|
||||||
#ifdef CONFIG_USBMONITOR
|
|
||||||
# include <nuttx/usb/usbmonitor.h>
|
|
||||||
#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 */
|
|
@ -1,195 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* configs/spark/src/stm32_io.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011-2014, 2017 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
#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 */
|
|
@ -1,219 +0,0 @@
|
|||||||
/************************************************************************************
|
|
||||||
* configs/spark/src/stm32_spi.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011-2013 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* 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 <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/spi/spi.h>
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
|
|
||||||
#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 */
|
|
@ -1,117 +0,0 @@
|
|||||||
/************************************************************************************
|
|
||||||
* configs/spark/src/stm32_usbdev.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009-2011 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
* Librae <librae8226@gmail.com>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Included Files
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/usb/usbdev.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#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);
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* configs/spark/src/stm32_usbmsc.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#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 */
|
|
@ -1,135 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* configs/spark/src/stm32_userleds.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011, 2013, 2015 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
#include <nuttx/power/pm.h>
|
|
||||||
|
|
||||||
#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 */
|
|
@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
dfu-util -a1 -d 1eaf:0003 -D nuttx.bin -R
|
|
@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cd tools
|
|
||||||
./configure.sh spark/$1
|
|
||||||
cd - > /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
|
|
@ -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
|
|
@ -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
|
|
@ -44,7 +44,7 @@ CSRCS += stm32_pwm.c
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_WL_NRF24L01),y)
|
ifeq ($(CONFIG_WL_NRF24L01),y)
|
||||||
CSRCS += stm32_cc3000.c
|
CSRCS += stm32_nrf24l01.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
||||||
|
@ -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.
|
* Copyright (C) 2009, 2013, 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Laurent Latil <laurent@latil.nom.fr>
|
* Author: Laurent Latil <laurent@latil.nom.fr>
|
@ -93,10 +93,6 @@ void weak_function stm32_spiinitialize(void)
|
|||||||
spierr("ERROR: [boot] FAILED to initialize SPI port 1\n");
|
spierr("ERROR: [boot] FAILED to initialize SPI port 1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_WL_CC3000
|
|
||||||
stm32_configgpio(GPIO_SPI_CS_WIFI);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_MMCSD
|
#ifdef HAVE_MMCSD
|
||||||
stm32_configgpio(GPIO_SPI_CS_SD_CARD);
|
stm32_configgpio(GPIO_SPI_CS_SD_CARD);
|
||||||
#endif
|
#endif
|
||||||
@ -106,14 +102,10 @@ void weak_function stm32_spiinitialize(void)
|
|||||||
/* Configure SPI-based devices */
|
/* Configure SPI-based devices */
|
||||||
|
|
||||||
g_spi2 = up_spiinitialize(2);
|
g_spi2 = up_spiinitialize(2);
|
||||||
|
if (!g_spi2)
|
||||||
/* Setup CS, EN & IRQ line IOs */
|
{
|
||||||
|
spierr("ERROR: [boot] FAILED to initialize SPI port 2\n");
|
||||||
#ifdef CONFIG_WL_CC3000
|
}
|
||||||
stm32_configgpio(GPIO_WIFI_CS);
|
|
||||||
stm32_configgpio(GPIO_WIFI_EN);
|
|
||||||
stm32_configgpio(GPIO_WIFI_INT);
|
|
||||||
#endif
|
|
||||||
#endif
|
#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");
|
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||||
|
|
||||||
#ifdef CONFIG_WL_CC3000
|
|
||||||
if (devid == SPIDEV_WIRELESS(0))
|
if (devid == SPIDEV_WIRELESS(0))
|
||||||
{
|
{
|
||||||
stm32_gpiowrite(GPIO_SPI_CS_WIFI, !selected);
|
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)
|
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");
|
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)
|
uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||||
|
@ -23,12 +23,6 @@ config CC1101_SPIDEV
|
|||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
menuconfig WL_CC3000
|
|
||||||
bool "CC3000 Wireless Module support"
|
|
||||||
default n
|
|
||||||
select SPI
|
|
||||||
|
|
||||||
source drivers/wireless/cc3000/Kconfig
|
|
||||||
source drivers/wireless/spirit/Kconfig
|
source drivers/wireless/spirit/Kconfig
|
||||||
|
|
||||||
menuconfig DRIVERS_IEEE802154
|
menuconfig DRIVERS_IEEE802154
|
||||||
|
@ -60,10 +60,6 @@ CSRCS += cc1101.c ISM1_868MHzGFSK100kbps.c ISM2_905MHzGFSK250kbps.c
|
|||||||
CSRCS += ISM2_433MHzMSK500kbps.c
|
CSRCS += ISM2_433MHzMSK500kbps.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_WL_CC3000),y)
|
|
||||||
include wireless$(DELIM)cc3000$(DELIM)Make.defs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_WL_SPIRIT),y)
|
ifeq ($(CONFIG_WL_SPIRIT),y)
|
||||||
include wireless$(DELIM)spirit$(DELIM)Make.defs
|
include wireless$(DELIM)spirit$(DELIM)Make.defs
|
||||||
endif
|
endif
|
||||||
|
@ -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
|
|
@ -1,48 +0,0 @@
|
|||||||
############################################################################
|
|
||||||
# drivers/wireless/Make.defs
|
|
||||||
#
|
|
||||||
# Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
|
||||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
#
|
|
||||||
# 1. Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer in
|
|
||||||
# the documentation and/or other materials provided with the
|
|
||||||
# distribution.
|
|
||||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
# used to endorse or promote products derived from this software
|
|
||||||
# without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_WL_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
|
|
File diff suppressed because it is too large
Load Diff
@ -1,214 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* drivers//wireless/cc3000.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
|
|
||||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
* David Sidrane <david_s5@nscdg.com>
|
|
||||||
*
|
|
||||||
* 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 <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <mqueue.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include <nuttx/spi/spi.h>
|
|
||||||
#include <nuttx/irq.h>
|
|
||||||
#include <nuttx/wireless/ioctl.h>
|
|
||||||
#include <nuttx/wireless/cc3000.h>
|
|
||||||
#include <nuttx/wireless/cc3000/cc3000_common.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* 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 */
|
|
@ -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 <nuttx/config.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* 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)));
|
|
||||||
}
|
|
@ -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 <sys/types.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* 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
|
|
@ -1,438 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* drivers/wireless/cc3000/cc3000drv.c
|
|
||||||
* Driver wrapper functions to conntect nuttx to the TI CC3000
|
|
||||||
*
|
|
||||||
* Port to nuttx:
|
|
||||||
* David Sidrane <david_s5@nscdg.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 <nuttx/config.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <debug.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include "cc3000drv.h"
|
|
||||||
|
|
||||||
#include <nuttx/mqueue.h>
|
|
||||||
#include <nuttx/fs/fs.h>
|
|
||||||
#include <nuttx/wireless/cc3000.h>
|
|
||||||
#include <nuttx/wireless/cc3000/cc3000_common.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* 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;
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* drivers/wireless/cc3000/cc3000drv.h - Driver wrapper functions to
|
|
||||||
* connect nuttx to the TI CC3000
|
|
||||||
*
|
|
||||||
* Port to nuttx:
|
|
||||||
* David Sidrane <david_s5@nscdg.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_CC3000DRV_H
|
|
||||||
#define __DRIVERS_WIRELESS_CC3000_CC3000DRV_H
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* 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 */
|
|
File diff suppressed because it is too large
Load Diff
@ -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 <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <debug.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <nuttx/wireless/cc3000/cc3000_common.h>
|
|
||||||
#include <nuttx/wireless/cc3000/hci.h>
|
|
||||||
#include "cc3000drv.h"
|
|
||||||
#include <nuttx/wireless/cc3000/evnt_handler.h>
|
|
||||||
#include <nuttx/wireless/cc3000/wlan.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* 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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 */
|
|
@ -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 <string.h>
|
|
||||||
|
|
||||||
#include <nuttx/wireless/cc3000/netapp.h>
|
|
||||||
#include <nuttx/wireless/cc3000/hci.h>
|
|
||||||
#include <nuttx/wireless/cc3000/evnt_handler.h>
|
|
||||||
#include <nuttx/wireless/cc3000/nvmem.h>
|
|
||||||
|
|
||||||
#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
|
|
@ -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 <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <nuttx/wireless/cc3000/nvmem.h>
|
|
||||||
#include <nuttx/wireless/cc3000/hci.h>
|
|
||||||
#include <nuttx/wireless/cc3000/evnt_handler.h>
|
|
||||||
#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;
|
|
||||||
}
|
|
@ -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 <sys/types.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <debug.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include <nuttx/wireless/cc3000/include/sys/socket.h>
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -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 */
|
|
File diff suppressed because it is too large
Load Diff
@ -196,10 +196,8 @@ static int at86rf23x_transmit(FAR struct ieee802154_radio_s *ieee,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* These are pointers to ALL registered at86rf23x devices.
|
/* 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.
|
* 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];
|
static struct at86rf23x_dev_s g_at86rf23x_devices[1];
|
||||||
|
@ -1,177 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* include/nuttx/wireless/cc3000.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011, 2017 Gregory Nutt. All rights reserved.
|
|
||||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
* David Sidrane <david_s5@nscdg.com>
|
|
||||||
*
|
|
||||||
* 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 <nuttx/config.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <nuttx/wireless/ioctl.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* 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 */
|
|
@ -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 <nuttx/config.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* 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
|
|
@ -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 <nuttx/wireless/cc3000/hci.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* 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
|
|
@ -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
|
|
@ -1,191 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* include/nuttx/wireless/cc3000/include/cc3000_upif.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
|
||||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
* David Sidrane <david_s5@nscdg.com>
|
|
||||||
*
|
|
||||||
* 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 <nuttx/config.h>
|
|
||||||
#include <nuttx/spi/spi.h>
|
|
||||||
#include <nuttx/irq.h>
|
|
||||||
|
|
||||||
#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 */
|
|
@ -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 <sys/types.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* 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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -86,14 +86,10 @@
|
|||||||
* command numbers from overlapping.
|
* 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 */
|
/* See include/nuttx/wireless/nrf24l01.h */
|
||||||
|
|
||||||
#define NRF24L01_FIRST (CC3000_FIRST + CC3000_NCMDS)
|
#define NRF24L01_FIRST (WL_FIRST + WL_NCMDS)
|
||||||
#define NRF24L01_NCMDS 14
|
#define NRF24L01_NCMDS 14
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user