mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
Initial cut of a driver for the TI CC3000 network module with support on the Freescale KL25Z board from Alan Carvalho de Assis
This commit is contained in:
@@ -5489,4 +5489,7 @@
|
|||||||
Add logic to support UDPHS clocking (2013-9-13).
|
Add logic to support UDPHS clocking (2013-9-13).
|
||||||
* arm/src/stm32/chip/stm32_tim.h: Some CCER bit settings changed
|
* arm/src/stm32/chip/stm32_tim.h: Some CCER bit settings changed
|
||||||
per SourceForge bug #18 submitted by CCCTSAO (2013-9-2).
|
per SourceForge bug #18 submitted by CCCTSAO (2013-9-2).
|
||||||
|
* apps/examples/cc3000, configs/freedom-kl25z, drivers/wireless/cc3000,
|
||||||
|
and nuttx/include/nuttx/cc3000. Initial support for the TI CC3000
|
||||||
|
network module on the Freescale Freedom-KL25Z board from Alan Carvalho
|
||||||
|
de Assis. This is still very much a work in progress. (2013-9-3).
|
||||||
|
|||||||
@@ -182,9 +182,18 @@
|
|||||||
* alternative.
|
* alternative.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PIN_SPI0_SCK PIN_SPI0_SCK_2
|
#define PIN_SPI0_SCK (PIN_SPI0_SCK_2 | PIN_ALT2_PULLUP)
|
||||||
#define PIN_SPI0_MISO PIN_SPI0_MISO_4
|
#define PIN_SPI0_MISO (PIN_SPI0_MISO_4 | PIN_ALT2_PULLUP)
|
||||||
#define PIN_SPI0_MOSI PIN_SPI0_MOSI_3
|
#define PIN_SPI0_MOSI (PIN_SPI0_MOSI_3 | PIN_ALT2_PULLUP)
|
||||||
|
|
||||||
|
#define PIN_SPI1_SCK (PIN_SPI1_SCK_2 | 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)
|
||||||
|
|
||||||
|
/* 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)
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* configs/freedom-kl25z/include/kl_wifi.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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
@@ -16,14 +16,14 @@ CONFIG_HOST_LINUX=y
|
|||||||
#
|
#
|
||||||
# Build Configuration
|
# Build Configuration
|
||||||
#
|
#
|
||||||
# CONFIG_APPS_DIR="../apps"
|
CONFIG_APPS_DIR="../apps"
|
||||||
# CONFIG_BUILD_2PASS is not set
|
# CONFIG_BUILD_2PASS is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Binary Output Formats
|
# Binary Output Formats
|
||||||
#
|
#
|
||||||
# CONFIG_RRLOAD_BINARY is not set
|
# CONFIG_RRLOAD_BINARY is not set
|
||||||
# CONFIG_INTELHEX_BINARY=y
|
# CONFIG_INTELHEX_BINARY is not set
|
||||||
CONFIG_MOTOROLA_SREC=y
|
CONFIG_MOTOROLA_SREC=y
|
||||||
CONFIG_RAW_BINARY=y
|
CONFIG_RAW_BINARY=y
|
||||||
|
|
||||||
@@ -73,23 +73,31 @@ CONFIG_ARCH_CHIP_KL=y
|
|||||||
# CONFIG_ARCH_CHIP_LPC31XX is not set
|
# CONFIG_ARCH_CHIP_LPC31XX is not set
|
||||||
# CONFIG_ARCH_CHIP_LPC43XX is not set
|
# CONFIG_ARCH_CHIP_LPC43XX is not set
|
||||||
# CONFIG_ARCH_CHIP_NUC1XX is not set
|
# CONFIG_ARCH_CHIP_NUC1XX is not set
|
||||||
# CONFIG_ARCH_CHIP_SAM3U is not set
|
# CONFIG_ARCH_CHIP_SAMA5 is not set
|
||||||
|
# CONFIG_ARCH_CHIP_SAM34 is not set
|
||||||
# CONFIG_ARCH_CHIP_STM32 is not set
|
# CONFIG_ARCH_CHIP_STM32 is not set
|
||||||
# CONFIG_ARCH_CHIP_STR71X is not set
|
# CONFIG_ARCH_CHIP_STR71X is not set
|
||||||
|
# CONFIG_ARCH_ARM7TDMI is not set
|
||||||
|
# CONFIG_ARCH_ARM926EJS is not set
|
||||||
|
# CONFIG_ARCH_ARM920T is not set
|
||||||
CONFIG_ARCH_CORTEXM0=y
|
CONFIG_ARCH_CORTEXM0=y
|
||||||
|
# CONFIG_ARCH_CORTEXM3 is not set
|
||||||
|
# CONFIG_ARCH_CORTEXM4 is not set
|
||||||
|
# CONFIG_ARCH_CORTEXA5 is not set
|
||||||
CONFIG_ARCH_FAMILY="armv6-m"
|
CONFIG_ARCH_FAMILY="armv6-m"
|
||||||
CONFIG_ARCH_CHIP="kl"
|
CONFIG_ARCH_CHIP="kl"
|
||||||
CONFIG_ARCH_HAVE_CMNVECTOR=y
|
CONFIG_ARCH_HAVE_CMNVECTOR=y
|
||||||
# CONFIG_ARMV7M_CMNVECTOR is not set
|
# CONFIG_ARMV7M_CMNVECTOR is not set
|
||||||
|
# CONFIG_ARCH_HAVE_FPU is not set
|
||||||
# CONFIG_ARCH_HAVE_MPU is not set
|
# CONFIG_ARCH_HAVE_MPU is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# ARMV6M Configuration Options
|
# ARMV6M Configuration Options
|
||||||
#
|
#
|
||||||
CONFIG_ARMV6M_TOOLCHAIN_BUILDROOT=y
|
# CONFIG_ARMV6M_TOOLCHAIN_BUILDROOT is not set
|
||||||
# CONFIG_ARMV6M_TOOLCHAIN_CODEREDL is not set
|
# CONFIG_ARMV6M_TOOLCHAIN_CODEREDL is not set
|
||||||
# CONFIG_ARMV6M_TOOLCHAIN_CODESOURCERYL is not set
|
# CONFIG_ARMV6M_TOOLCHAIN_CODESOURCERYL is not set
|
||||||
# CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIL is not set
|
CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIL=y
|
||||||
# CONFIG_GPIO_IRQ is not set
|
# CONFIG_GPIO_IRQ is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -106,13 +114,10 @@ CONFIG_ARCH_FAMILY_KL2X=y
|
|||||||
CONFIG_KL_UART0=y
|
CONFIG_KL_UART0=y
|
||||||
# CONFIG_KL_UART1 is not set
|
# CONFIG_KL_UART1 is not set
|
||||||
# CONFIG_KL_UART2 is not set
|
# CONFIG_KL_UART2 is not set
|
||||||
# CONFIG_KL_UART3 is not set
|
|
||||||
# CONFIG_KL_UART4 is not set
|
|
||||||
# CONFIG_KL_UART5 is not set
|
|
||||||
# CONFIG_KL_FLEXCAN0 is not set
|
# CONFIG_KL_FLEXCAN0 is not set
|
||||||
# CONFIG_KL_FLEXCAN1 is not set
|
# CONFIG_KL_FLEXCAN1 is not set
|
||||||
# CONFIG_KL_SPI0 is not set
|
CONFIG_KL_SPI0=y
|
||||||
# CONFIG_KL_SPI1 is not set
|
CONFIG_KL_SPI1=y
|
||||||
# CONFIG_KL_SPI2 is not set
|
# CONFIG_KL_SPI2 is not set
|
||||||
# CONFIG_KL_I2C0 is not set
|
# CONFIG_KL_I2C0 is not set
|
||||||
# CONFIG_KL_I2C1 is not set
|
# CONFIG_KL_I2C1 is not set
|
||||||
@@ -123,10 +128,9 @@ CONFIG_KL_UART0=y
|
|||||||
# CONFIG_KL_ADC1 is not set
|
# CONFIG_KL_ADC1 is not set
|
||||||
# CONFIG_KL_CMP is not set
|
# CONFIG_KL_CMP is not set
|
||||||
# CONFIG_KL_VREF is not set
|
# CONFIG_KL_VREF is not set
|
||||||
# CONFIG_KL_SDHC is not set
|
# CONFIG_KL_TPM0 is not set
|
||||||
# CONFIG_KL_FTM0 is not set
|
# CONFIG_KL_TPM1 is not set
|
||||||
# CONFIG_KL_FTM1 is not set
|
# CONFIG_KL_TPM2 is not set
|
||||||
# CONFIG_KL_FTM2 is not set
|
|
||||||
# CONFIG_KL_LPTIMER is not set
|
# CONFIG_KL_LPTIMER is not set
|
||||||
# CONFIG_KL_RTC is not set
|
# CONFIG_KL_RTC is not set
|
||||||
# CONFIG_KL_EWM is not set
|
# CONFIG_KL_EWM is not set
|
||||||
@@ -141,20 +145,12 @@ CONFIG_KL_UART0=y
|
|||||||
# CONFIG_KL_PDB is not set
|
# CONFIG_KL_PDB is not set
|
||||||
# CONFIG_KL_PIT is not set
|
# CONFIG_KL_PIT is not set
|
||||||
CONFIG_KL_SYSTICK_CORECLK=y
|
CONFIG_KL_SYSTICK_CORECLK=y
|
||||||
|
# CONFIG_KL_SYSTICK_CORECLK_DIV16 is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Kinetis GPIO Interrupt Configuration
|
# Kinetis GPIO Interrupt Configuration
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
|
||||||
# Kinetis UART Configuration
|
|
||||||
#
|
|
||||||
# CONFIG_KL_UARTFIFOS is not set
|
|
||||||
|
|
||||||
#
|
|
||||||
# External Memory Configuration
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Architecture Options
|
# Architecture Options
|
||||||
#
|
#
|
||||||
@@ -175,8 +171,6 @@ CONFIG_ARCH_STACKDUMP=y
|
|||||||
#
|
#
|
||||||
CONFIG_BOARD_LOOPSPERMSEC=2988
|
CONFIG_BOARD_LOOPSPERMSEC=2988
|
||||||
# CONFIG_ARCH_CALIBRATION is not set
|
# CONFIG_ARCH_CALIBRATION is not set
|
||||||
CONFIG_RAM_START=0x1FFFF000
|
|
||||||
CONFIG_RAM_SIZE=16384
|
|
||||||
CONFIG_ARCH_HAVE_INTERRUPTSTACK=y
|
CONFIG_ARCH_HAVE_INTERRUPTSTACK=y
|
||||||
CONFIG_ARCH_INTERRUPTSTACK=0
|
CONFIG_ARCH_INTERRUPTSTACK=0
|
||||||
|
|
||||||
@@ -189,6 +183,12 @@ CONFIG_BOOT_RUNFROMFLASH=y
|
|||||||
# CONFIG_BOOT_RUNFROMSDRAM is not set
|
# CONFIG_BOOT_RUNFROMSDRAM is not set
|
||||||
# CONFIG_BOOT_COPYTORAM is not set
|
# CONFIG_BOOT_COPYTORAM is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Boot Memory Configuration
|
||||||
|
#
|
||||||
|
CONFIG_RAM_START=0x1FFFF000
|
||||||
|
CONFIG_RAM_SIZE=16384
|
||||||
|
|
||||||
#
|
#
|
||||||
# Board Selection
|
# Board Selection
|
||||||
#
|
#
|
||||||
@@ -281,10 +281,15 @@ CONFIG_DEV_NULL=y
|
|||||||
# CONFIG_CAN is not set
|
# CONFIG_CAN is not set
|
||||||
# CONFIG_PWM is not set
|
# CONFIG_PWM is not set
|
||||||
# CONFIG_I2C is not set
|
# CONFIG_I2C is not set
|
||||||
# CONFIG_SPI is not set
|
CONFIG_SPI=y
|
||||||
|
# CONFIG_SPI_OWNBUS is not set
|
||||||
|
CONFIG_SPI_EXCHANGE=y
|
||||||
|
# CONFIG_SPI_CMDDATA is not set
|
||||||
|
# CONFIG_SPI_BITBANG is not set
|
||||||
# CONFIG_RTC is not set
|
# CONFIG_RTC is not set
|
||||||
# CONFIG_WATCHDOG is not set
|
# CONFIG_WATCHDOG is not set
|
||||||
# CONFIG_ANALOG is not set
|
# CONFIG_ANALOG is not set
|
||||||
|
# CONFIG_AUDIO_DEVICES is not set
|
||||||
# CONFIG_BCH is not set
|
# CONFIG_BCH is not set
|
||||||
# CONFIG_INPUT is not set
|
# CONFIG_INPUT is not set
|
||||||
# CONFIG_LCD is not set
|
# CONFIG_LCD is not set
|
||||||
@@ -294,11 +299,14 @@ CONFIG_DEV_NULL=y
|
|||||||
# CONFIG_PM is not set
|
# CONFIG_PM is not set
|
||||||
# CONFIG_POWER is not set
|
# CONFIG_POWER is not set
|
||||||
# CONFIG_SENSORS is not set
|
# CONFIG_SENSORS is not set
|
||||||
# CONFIG_SERCOMM_CONSOLE is not set
|
|
||||||
CONFIG_SERIAL=y
|
CONFIG_SERIAL=y
|
||||||
# CONFIG_DEV_LOWCONSOLE is not set
|
# CONFIG_DEV_LOWCONSOLE is not set
|
||||||
# CONFIG_16550_UART is not set
|
# CONFIG_16550_UART is not set
|
||||||
CONFIG_ARCH_HAVE_UART0=y
|
CONFIG_ARCH_HAVE_UART0=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# USART Configuration
|
||||||
|
#
|
||||||
CONFIG_MCU_SERIAL=y
|
CONFIG_MCU_SERIAL=y
|
||||||
CONFIG_STANDARD_SERIAL=y
|
CONFIG_STANDARD_SERIAL=y
|
||||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||||
@@ -313,9 +321,16 @@ CONFIG_UART0_BAUD=115200
|
|||||||
CONFIG_UART0_BITS=8
|
CONFIG_UART0_BITS=8
|
||||||
CONFIG_UART0_PARITY=0
|
CONFIG_UART0_PARITY=0
|
||||||
CONFIG_UART0_2STOP=0
|
CONFIG_UART0_2STOP=0
|
||||||
|
# CONFIG_UART0_IFLOWCONTROL is not set
|
||||||
|
# CONFIG_UART0_OFLOWCONTROL is not set
|
||||||
|
# CONFIG_SERIAL_IFLOWCONTROL is not set
|
||||||
|
# CONFIG_SERIAL_OFLOWCONTROL is not set
|
||||||
# CONFIG_USBDEV is not set
|
# CONFIG_USBDEV is not set
|
||||||
# CONFIG_USBHOST is not set
|
# CONFIG_USBHOST is not set
|
||||||
# CONFIG_WIRELESS is not set
|
CONFIG_WIRELESS=y
|
||||||
|
# CONFIG_WL_CC1101 is not set
|
||||||
|
CONFIG_WL_CC3000=y
|
||||||
|
# CONFIG_WL_NRF24L01 is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# System Logging Device Options
|
# System Logging Device Options
|
||||||
@@ -340,6 +355,7 @@ CONFIG_UART0_2STOP=0
|
|||||||
#
|
#
|
||||||
CONFIG_DISABLE_MOUNTPOINT=y
|
CONFIG_DISABLE_MOUNTPOINT=y
|
||||||
# CONFIG_FS_RAMMAP is not set
|
# CONFIG_FS_RAMMAP is not set
|
||||||
|
# CONFIG_FS_BINFS is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# System Logging
|
# System Logging
|
||||||
@@ -360,10 +376,18 @@ CONFIG_MM_SMALL=y
|
|||||||
CONFIG_MM_REGIONS=1
|
CONFIG_MM_REGIONS=1
|
||||||
# CONFIG_GRAN is not set
|
# CONFIG_GRAN is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Audio Support
|
||||||
|
#
|
||||||
|
# CONFIG_AUDIO is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Binary Formats
|
# Binary Formats
|
||||||
#
|
#
|
||||||
CONFIG_BINFMT_DISABLE=y
|
# CONFIG_BINFMT_DISABLE is not set
|
||||||
|
# CONFIG_NXFLAT is not set
|
||||||
|
# CONFIG_ELF is not set
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
# CONFIG_PIC is not set
|
# CONFIG_PIC is not set
|
||||||
# CONFIG_SYMTAB_ORDEREDBYNAME is not set
|
# CONFIG_SYMTAB_ORDEREDBYNAME is not set
|
||||||
|
|
||||||
@@ -380,10 +404,12 @@ CONFIG_NUNGET_CHARS=0
|
|||||||
# CONFIG_LIBM is not set
|
# CONFIG_LIBM is not set
|
||||||
# CONFIG_NOPRINTF_FIELDWIDTH is not set
|
# CONFIG_NOPRINTF_FIELDWIDTH is not set
|
||||||
# CONFIG_LIBC_FLOATINGPOINT is not set
|
# CONFIG_LIBC_FLOATINGPOINT is not set
|
||||||
|
CONFIG_LIB_RAND_ORDER=1
|
||||||
# CONFIG_EOL_IS_CR is not set
|
# CONFIG_EOL_IS_CR is not set
|
||||||
# CONFIG_EOL_IS_LF is not set
|
# CONFIG_EOL_IS_LF is not set
|
||||||
# CONFIG_EOL_IS_BOTH_CRLF is not set
|
# CONFIG_EOL_IS_BOTH_CRLF is not set
|
||||||
CONFIG_EOL_IS_EITHER_CRLF=y
|
CONFIG_EOL_IS_EITHER_CRLF=y
|
||||||
|
# CONFIG_LIBC_EXECFUNCS is not set
|
||||||
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024
|
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024
|
||||||
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=1536
|
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=1536
|
||||||
# CONFIG_LIBC_STRERROR is not set
|
# CONFIG_LIBC_STRERROR is not set
|
||||||
@@ -398,6 +424,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
|
|||||||
#
|
#
|
||||||
# CONFIG_SCHED_WORKQUEUE is not set
|
# CONFIG_SCHED_WORKQUEUE is not set
|
||||||
# CONFIG_LIB_KBDCODEC is not set
|
# CONFIG_LIB_KBDCODEC is not set
|
||||||
|
# CONFIG_LIB_SLCDCODEC is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Basic CXX Support
|
# Basic CXX Support
|
||||||
@@ -412,12 +439,14 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
|
|||||||
#
|
#
|
||||||
# Built-In Applications
|
# Built-In Applications
|
||||||
#
|
#
|
||||||
|
CONFIG_BUILTIN_PROXY_STACKSIZE=1024
|
||||||
|
|
||||||
#
|
#
|
||||||
# Examples
|
# Examples
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_BUTTONS is not set
|
# CONFIG_EXAMPLES_BUTTONS is not set
|
||||||
# CONFIG_EXAMPLES_CAN is not set
|
# CONFIG_EXAMPLES_CAN is not set
|
||||||
|
CONFIG_EXAMPLES_CC3000BASIC=y
|
||||||
# CONFIG_EXAMPLES_COMPOSITE is not set
|
# CONFIG_EXAMPLES_COMPOSITE is not set
|
||||||
# CONFIG_EXAMPLES_DHCPD is not set
|
# CONFIG_EXAMPLES_DHCPD is not set
|
||||||
# CONFIG_EXAMPLES_ELF is not set
|
# CONFIG_EXAMPLES_ELF is not set
|
||||||
@@ -431,8 +460,9 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
|
|||||||
# CONFIG_EXAMPLES_IGMP is not set
|
# CONFIG_EXAMPLES_IGMP is not set
|
||||||
# CONFIG_EXAMPLES_LCDRW is not set
|
# CONFIG_EXAMPLES_LCDRW is not set
|
||||||
# CONFIG_EXAMPLES_MM is not set
|
# CONFIG_EXAMPLES_MM is not set
|
||||||
# CONFIG_EXAMPLES_MOUNT is not set
|
|
||||||
# CONFIG_EXAMPLES_MODBUS is not set
|
# CONFIG_EXAMPLES_MODBUS is not set
|
||||||
|
# CONFIG_EXAMPLES_MOUNT is not set
|
||||||
|
# CONFIG_EXAMPLES_NRF24L01TERM is not set
|
||||||
CONFIG_EXAMPLES_NSH=y
|
CONFIG_EXAMPLES_NSH=y
|
||||||
# CONFIG_EXAMPLES_NULL is not set
|
# CONFIG_EXAMPLES_NULL is not set
|
||||||
# CONFIG_EXAMPLES_NX is not set
|
# CONFIG_EXAMPLES_NX is not set
|
||||||
@@ -446,13 +476,16 @@ CONFIG_EXAMPLES_NSH=y
|
|||||||
# CONFIG_EXAMPLES_OSTEST is not set
|
# CONFIG_EXAMPLES_OSTEST is not set
|
||||||
# CONFIG_EXAMPLES_PASHELLO is not set
|
# CONFIG_EXAMPLES_PASHELLO is not set
|
||||||
# CONFIG_EXAMPLES_PIPE is not set
|
# CONFIG_EXAMPLES_PIPE is not set
|
||||||
# CONFIG_EXAMPLES_POLL is not set
|
|
||||||
# CONFIG_EXAMPLES_POSIXSPAWN is not set
|
# CONFIG_EXAMPLES_POSIXSPAWN is not set
|
||||||
# CONFIG_EXAMPLES_QENCODER is not set
|
# CONFIG_EXAMPLES_QENCODER is not set
|
||||||
# CONFIG_EXAMPLES_RGMP is not set
|
# CONFIG_EXAMPLES_RGMP is not set
|
||||||
# CONFIG_EXAMPLES_ROMFS is not set
|
# CONFIG_EXAMPLES_ROMFS is not set
|
||||||
# CONFIG_EXAMPLES_SENDMAIL is not set
|
# CONFIG_EXAMPLES_SENDMAIL is not set
|
||||||
# CONFIG_EXAMPLES_SERLOOP is not set
|
# CONFIG_EXAMPLES_SERLOOP is not set
|
||||||
|
# CONFIG_EXAMPLES_SLCD is not set
|
||||||
|
# CONFIG_EXAMPLES_SMART_TEST is not set
|
||||||
|
# CONFIG_EXAMPLES_SMART is not set
|
||||||
|
# CONFIG_EXAMPLES_TCPECHO is not set
|
||||||
# CONFIG_EXAMPLES_TELNETD is not set
|
# CONFIG_EXAMPLES_TELNETD is not set
|
||||||
# CONFIG_EXAMPLES_THTTPD is not set
|
# CONFIG_EXAMPLES_THTTPD is not set
|
||||||
# CONFIG_EXAMPLES_TIFF is not set
|
# CONFIG_EXAMPLES_TIFF is not set
|
||||||
@@ -505,6 +538,7 @@ CONFIG_EXAMPLES_NSH=y
|
|||||||
# NSH Library
|
# NSH Library
|
||||||
#
|
#
|
||||||
CONFIG_NSH_LIBRARY=y
|
CONFIG_NSH_LIBRARY=y
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# Disable Individual commands
|
# Disable Individual commands
|
||||||
@@ -512,6 +546,7 @@ CONFIG_NSH_LIBRARY=y
|
|||||||
# CONFIG_NSH_DISABLE_CAT is not set
|
# CONFIG_NSH_DISABLE_CAT is not set
|
||||||
CONFIG_NSH_DISABLE_CD=y
|
CONFIG_NSH_DISABLE_CD=y
|
||||||
CONFIG_NSH_DISABLE_CP=y
|
CONFIG_NSH_DISABLE_CP=y
|
||||||
|
# CONFIG_NSH_DISABLE_CMP is not set
|
||||||
CONFIG_NSH_DISABLE_DD=y
|
CONFIG_NSH_DISABLE_DD=y
|
||||||
# CONFIG_NSH_DISABLE_ECHO is not set
|
# CONFIG_NSH_DISABLE_ECHO is not set
|
||||||
# CONFIG_NSH_DISABLE_EXEC is not set
|
# CONFIG_NSH_DISABLE_EXEC is not set
|
||||||
@@ -548,9 +583,15 @@ CONFIG_NSH_DISABLE_UMOUNT=y
|
|||||||
# CONFIG_NSH_DISABLE_USLEEP is not set
|
# CONFIG_NSH_DISABLE_USLEEP is not set
|
||||||
CONFIG_NSH_DISABLE_WGET=y
|
CONFIG_NSH_DISABLE_WGET=y
|
||||||
# CONFIG_NSH_DISABLE_XD is not set
|
# CONFIG_NSH_DISABLE_XD is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configure Command Options
|
||||||
|
#
|
||||||
|
# CONFIG_NSH_CMDOPT_DF_H is not set
|
||||||
CONFIG_NSH_CODECS_BUFSIZE=128
|
CONFIG_NSH_CODECS_BUFSIZE=128
|
||||||
CONFIG_NSH_FILEIOSIZE=64
|
CONFIG_NSH_FILEIOSIZE=64
|
||||||
CONFIG_NSH_LINELEN=80
|
CONFIG_NSH_LINELEN=80
|
||||||
|
CONFIG_NSH_MAXARGUMENTS=6
|
||||||
CONFIG_NSH_NESTDEPTH=3
|
CONFIG_NSH_NESTDEPTH=3
|
||||||
CONFIG_NSH_DISABLESCRIPT=y
|
CONFIG_NSH_DISABLESCRIPT=y
|
||||||
# CONFIG_NSH_DISABLEBG is not set
|
# CONFIG_NSH_DISABLEBG is not set
|
||||||
@@ -560,7 +601,7 @@ CONFIG_NSH_CONSOLE=y
|
|||||||
# USB Trace Support
|
# USB Trace Support
|
||||||
#
|
#
|
||||||
# CONFIG_NSH_CONDEV is not set
|
# CONFIG_NSH_CONDEV is not set
|
||||||
# CONFIG_NSH_ARCHINIT is not set
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# NxWidgets/NxWM
|
# NxWidgets/NxWM
|
||||||
@@ -585,7 +626,11 @@ CONFIG_NSH_CONSOLE=y
|
|||||||
# CONFIG_SYSTEM_INSTALL is not set
|
# CONFIG_SYSTEM_INSTALL is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# RAM Test
|
# FLASH Erase-all Command
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# RAM test
|
||||||
#
|
#
|
||||||
# CONFIG_SYSTEM_RAMTEST is not set
|
# CONFIG_SYSTEM_RAMTEST is not set
|
||||||
|
|
||||||
@@ -618,3 +663,8 @@ CONFIG_READLINE_ECHO=y
|
|||||||
#
|
#
|
||||||
# USB Monitor
|
# USB Monitor
|
||||||
#
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Zmodem Commands
|
||||||
|
#
|
||||||
|
# CONFIG_SYSTEM_ZMODEM is not set
|
||||||
|
|||||||
@@ -40,13 +40,13 @@ CFLAGS += -I$(TOPDIR)/sched
|
|||||||
ASRCS =
|
ASRCS =
|
||||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||||
|
|
||||||
CSRCS = kl_boardinitialize.c
|
CSRCS = kl_boardinitialize.c kl_wifi.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_KL_TSI),y)
|
ifeq ($(CONFIG_KL_TSI),y)
|
||||||
CSRCS += kl_tsi.c
|
CSRCS += kl_tsi.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_KL_SPI0),y)
|
ifeq ($(CONFIG_KL_SPI),y)
|
||||||
CSRCS += kl_spi.c
|
CSRCS += kl_spi.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,159 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* configs/freedom-kl25z/src/kl_tsi.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 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_wifi.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/fs/fs.h>
|
||||||
|
|
||||||
|
#include <nuttx/cc3000/spi.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
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Used by CC3000 driver to read status of WIFI_IRQ
|
||||||
|
*/
|
||||||
|
inline long ReadWlanInterruptPin(void)
|
||||||
|
{
|
||||||
|
// Return the status of WIFI_IRQ pin
|
||||||
|
return kl_gpioread(GPIO_WIFI_IRQ);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enable/Disable WiFi
|
||||||
|
*/
|
||||||
|
void WriteWlanEnablePin(uint8_t val)
|
||||||
|
{
|
||||||
|
kl_gpiowrite(GPIO_WIFI_EN, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Assert CC3000 CS
|
||||||
|
*/
|
||||||
|
void AssertWlanCS(void)
|
||||||
|
{
|
||||||
|
kl_gpiowrite(GPIO_WIFI_CS, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Deassert CC3000 CS
|
||||||
|
*/
|
||||||
|
void DeassertWlanCS(void)
|
||||||
|
{
|
||||||
|
kl_gpiowrite(GPIO_WIFI_CS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: Wlan_Setup
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize all pins needed to control CC3000 Module and attach to IRQ
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void Wlan_Setup(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
uint32_t regval;
|
||||||
|
|
||||||
|
printf("\nExecuting kl_irq_initialize!\n");
|
||||||
|
|
||||||
|
/* Configure the PIN used to enable the chip */
|
||||||
|
kl_configgpio(GPIO_WIFI_EN);
|
||||||
|
|
||||||
|
/* Configure PIN to detect interrupts */
|
||||||
|
kl_configgpio(GPIO_WIFI_IRQ);
|
||||||
|
|
||||||
|
/* Configure PIN used as SPI CS */
|
||||||
|
kl_configgpio(GPIO_WIFI_CS);
|
||||||
|
|
||||||
|
/* Make sure the chip is OFF before we start */
|
||||||
|
WriteWlanEnablePin(false);
|
||||||
|
|
||||||
|
/* Make sure the SPI CS pin is deasserted */
|
||||||
|
DeassertWlanCS();
|
||||||
|
|
||||||
|
/* Configure pin to detect interrupt on falling edge */
|
||||||
|
regval = getreg32(KL_PORTA_PCR16);
|
||||||
|
regval |= PORT_PCR_IRQC_FALLING;
|
||||||
|
putreg32(regval, KL_PORTA_PCR16);
|
||||||
|
|
||||||
|
ret = irq_attach(KL_IRQ_PORTA, CC3000InterruptHandler);
|
||||||
|
if (ret == OK)
|
||||||
|
{
|
||||||
|
up_enable_irq(KL_IRQ_PORTA);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -67,6 +67,7 @@ include syslog$(DELIM)Make.defs
|
|||||||
include usbdev$(DELIM)Make.defs
|
include usbdev$(DELIM)Make.defs
|
||||||
include usbhost$(DELIM)Make.defs
|
include usbhost$(DELIM)Make.defs
|
||||||
include wireless$(DELIM)Make.defs
|
include wireless$(DELIM)Make.defs
|
||||||
|
include wireless$(DELIM)cc3000$(DELIM)Make.defs
|
||||||
|
|
||||||
ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||||
CSRCS += dev_null.c dev_zero.c loop.c
|
CSRCS += dev_null.c dev_zero.c loop.c
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ config WL_CC1101
|
|||||||
default n
|
default n
|
||||||
select SPI
|
select SPI
|
||||||
|
|
||||||
|
menuconfig WL_CC3000
|
||||||
|
bool "CC3000 Wireless Module support"
|
||||||
|
default n
|
||||||
|
select SPI
|
||||||
|
|
||||||
config WL_NRF24L01
|
config WL_NRF24L01
|
||||||
bool "nRF24l01+ transceiver support"
|
bool "nRF24l01+ transceiver support"
|
||||||
default n
|
default n
|
||||||
@@ -15,6 +20,7 @@ config WL_NRF24L01
|
|||||||
---help---
|
---help---
|
||||||
This options adds driver support for the Nordic nRF24L01+ chip.
|
This options adds driver support for the Nordic nRF24L01+ chip.
|
||||||
|
|
||||||
|
|
||||||
if WL_NRF24L01
|
if WL_NRF24L01
|
||||||
|
|
||||||
config WL_NRF24L01_DFLT_ADDR_WIDTH
|
config WL_NRF24L01_DFLT_ADDR_WIDTH
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#
|
||||||
|
# For a description of the syntax of this configuration file,
|
||||||
|
# see misc/tools/kconfig-language.txt.
|
||||||
|
#
|
||||||
|
|
||||||
|
config WL_CC3000_DUMMY
|
||||||
|
bool "CC3000 Wireless Module Dummy Test"
|
||||||
|
default n
|
||||||
|
select SPI
|
||||||
|
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
############################################################################
|
||||||
|
# drivers/wireless/Make.defs
|
||||||
|
#
|
||||||
|
# Copyright (C) 2011-2012 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_common.c evnt_handler.c hci.c netapp.c nvmem.c security.c socket.c spi.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
|
||||||
@@ -0,0 +1,164 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! \addtogroup common_api
|
||||||
|
//! @{
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Include files
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#include <nuttx/cc3000/cc3000_common.h>
|
||||||
|
#include <nuttx/cc3000/socket.h>
|
||||||
|
#include <nuttx/cc3000/wlan.h>
|
||||||
|
#include <nuttx/cc3000/evnt_handler.h>
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! __error__
|
||||||
|
//!
|
||||||
|
//! @param pcFilename - file name, where error occurred
|
||||||
|
//! @param ulLine - line number, where error occurred
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief stub function for ASSERT macro
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
void
|
||||||
|
__error__(char *pcFilename, unsigned long ulLine)
|
||||||
|
{
|
||||||
|
//TODO full up function
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! UINT32_TO_STREAM_f
|
||||||
|
//!
|
||||||
|
//! @param p pointer to the new stream
|
||||||
|
//! @param u32 pointer to the 32 bit
|
||||||
|
//!
|
||||||
|
//! @return pointer to the new stream
|
||||||
|
//!
|
||||||
|
//! @brief This function is used for copying 32 bit to stream
|
||||||
|
//! while converting to little endian format.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
unsigned char* UINT32_TO_STREAM_f (unsigned char *p, unsigned long u32)
|
||||||
|
{
|
||||||
|
*(p)++ = (unsigned char)(u32);
|
||||||
|
*(p)++ = (unsigned char)((u32) >> 8);
|
||||||
|
*(p)++ = (unsigned char)((u32) >> 16);
|
||||||
|
*(p)++ = (unsigned char)((u32) >> 24);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! UINT16_TO_STREAM_f
|
||||||
|
//!
|
||||||
|
//! @param p pointer to the new stream
|
||||||
|
//! @param u32 pointer to the 16 bit
|
||||||
|
//!
|
||||||
|
//! @return pointer to the new stream
|
||||||
|
//!
|
||||||
|
//! @brief This function is used for copying 16 bit to stream
|
||||||
|
//! while converting to little endian format.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
unsigned char* UINT16_TO_STREAM_f (unsigned char *p, unsigned short u16)
|
||||||
|
{
|
||||||
|
*(p)++ = (unsigned char)(u16);
|
||||||
|
*(p)++ = (unsigned char)((u16) >> 8);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! STREAM_TO_UINT16_f
|
||||||
|
//!
|
||||||
|
//! @param p pointer to the stream
|
||||||
|
//! @param offset offset in the stream
|
||||||
|
//!
|
||||||
|
//! @return pointer to the new 16 bit
|
||||||
|
//!
|
||||||
|
//! @brief This function is used for copying received stream to
|
||||||
|
//! 16 bit in little endian format.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
unsigned short STREAM_TO_UINT16_f(char* p, unsigned short offset)
|
||||||
|
{
|
||||||
|
return (unsigned short)((unsigned short)((unsigned short)
|
||||||
|
(*(p + offset + 1)) << 8) + (unsigned short)(*(p + offset)));
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! STREAM_TO_UINT32_f
|
||||||
|
//!
|
||||||
|
//! @param p pointer to the stream
|
||||||
|
//! @param offset offset in the stream
|
||||||
|
//!
|
||||||
|
//! @return pointer to the new 32 bit
|
||||||
|
//!
|
||||||
|
//! @brief This function is used for copying received stream to
|
||||||
|
//! 32 bit in little endian format.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
unsigned long STREAM_TO_UINT32_f(char* p, unsigned short 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)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Close the Doxygen group.
|
||||||
|
//! @}
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,230 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! \addtogroup hci_app
|
||||||
|
//! @{
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <nuttx/cc3000/cc3000_common.h>
|
||||||
|
#include <nuttx/cc3000/hci.h>
|
||||||
|
#include <nuttx/cc3000/spi.h>
|
||||||
|
#include <nuttx/cc3000/evnt_handler.h>
|
||||||
|
#include <nuttx/cc3000/wlan.h>
|
||||||
|
|
||||||
|
#define SL_PATCH_PORTION_SIZE (1000)
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! hci_command_send
|
||||||
|
//!
|
||||||
|
//! @param usOpcode command operation code
|
||||||
|
//! @param pucBuff pointer to the command's arguments buffer
|
||||||
|
//! @param ucArgsLength length of the arguments
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief Initiate an HCI command.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
unsigned short
|
||||||
|
hci_command_send(unsigned short usOpcode, unsigned char *pucBuff,
|
||||||
|
unsigned char ucArgsLength)
|
||||||
|
{
|
||||||
|
unsigned char *stream;
|
||||||
|
|
||||||
|
stream = (pucBuff + SPI_HEADER_SIZE);
|
||||||
|
|
||||||
|
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
|
||||||
|
SpiWrite(pucBuff, ucArgsLength + SIMPLE_LINK_HCI_CMND_HEADER_SIZE);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! hci_data_send
|
||||||
|
//!
|
||||||
|
//! @param usOpcode command operation code
|
||||||
|
//! @param ucArgs pointer to the command's arguments buffer
|
||||||
|
//! @param usArgsLength length of the arguments
|
||||||
|
//! @param ucTail pointer to the data buffer
|
||||||
|
//! @param usTailLength buffer length
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief Initiate an HCI data write operation
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
long
|
||||||
|
hci_data_send(unsigned char ucOpcode,
|
||||||
|
unsigned char *ucArgs,
|
||||||
|
unsigned short usArgsLength,
|
||||||
|
unsigned short usDataLength,
|
||||||
|
const unsigned char *ucTail,
|
||||||
|
unsigned short usTailLength)
|
||||||
|
{
|
||||||
|
unsigned char *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
|
||||||
|
SpiWrite(ucArgs, SIMPLE_LINK_HCI_DATA_HEADER_SIZE + usArgsLength + usDataLength + usTailLength);
|
||||||
|
|
||||||
|
return(ESUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! hci_data_command_send
|
||||||
|
//!
|
||||||
|
//! @param usOpcode command operation code
|
||||||
|
//! @param pucBuff pointer to the data buffer
|
||||||
|
//! @param ucArgsLength arguments length
|
||||||
|
//! @param ucDataLength data length
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief Prepeare HCI header and initiate an HCI data write operation
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
void hci_data_command_send(unsigned short usOpcode, unsigned char *pucBuff,
|
||||||
|
unsigned char ucArgsLength,unsigned short ucDataLength)
|
||||||
|
{
|
||||||
|
unsigned char *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
|
||||||
|
SpiWrite(pucBuff, ucArgsLength + ucDataLength + SIMPLE_LINK_HCI_DATA_CMND_HEADER_SIZE);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! hci_patch_send
|
||||||
|
//!
|
||||||
|
//! @param usOpcode command operation code
|
||||||
|
//! @param pucBuff pointer to the command's arguments buffer
|
||||||
|
//! @param patch pointer to patch content buffer
|
||||||
|
//! @param usDataLength data length
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief Prepeare HCI header and initiate an HCI patch write operation
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
void
|
||||||
|
hci_patch_send(unsigned char ucOpcode, unsigned char *pucBuff, char *patch, unsigned short usDataLength)
|
||||||
|
{
|
||||||
|
unsigned char *data_ptr = (pucBuff + SPI_HEADER_SIZE);
|
||||||
|
unsigned short usTransLength;
|
||||||
|
unsigned char *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
|
||||||
|
SpiWrite(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
|
||||||
|
SpiWrite(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(unsigned short *)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
|
||||||
|
SpiWrite((unsigned char *)data_ptr, usTransLength + sizeof(usTransLength));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Close the Doxygen group.
|
||||||
|
//! @}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
@@ -0,0 +1,459 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#include <string.h>
|
||||||
|
#include <nuttx/cc3000/netapp.h>
|
||||||
|
#include <nuttx/cc3000/hci.h>
|
||||||
|
#include <nuttx/cc3000/socket.h>
|
||||||
|
#include <nuttx/cc3000/evnt_handler.h>
|
||||||
|
#include <nuttx/cc3000/nvmem.h>
|
||||||
|
|
||||||
|
#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)
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_config_mac_adrress
|
||||||
|
//!
|
||||||
|
//! @param mac device mac address, 6 bytes. Saved: yes
|
||||||
|
//!
|
||||||
|
//! @return return on success 0, otherwise error.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
long netapp_config_mac_adrress(unsigned char * mac)
|
||||||
|
{
|
||||||
|
return nvmem_set_mac_address(mac);
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_dhcp
|
||||||
|
//!
|
||||||
|
//! @param aucIP device mac address, 6 bytes. Saved: yes
|
||||||
|
//! @param aucSubnetMask device mac address, 6 bytes. Saved: yes
|
||||||
|
//! @param aucDefaultGateway device mac address, 6 bytes. Saved: yes
|
||||||
|
//! @param aucDNSServer device mac address, 6 bytes. Saved: yes
|
||||||
|
//!
|
||||||
|
//! @return return on success 0, otherwise error.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,unsigned long *aucDefaultGateway, unsigned long *aucDNSServer)
|
||||||
|
{
|
||||||
|
signed char scRet;
|
||||||
|
unsigned char *ptr;
|
||||||
|
unsigned char *args;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return(scRet);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_timeout_values
|
||||||
|
//!
|
||||||
|
//! @param 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.
|
||||||
|
//!
|
||||||
|
//! @param 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.
|
||||||
|
//!
|
||||||
|
//! @param 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.
|
||||||
|
//!
|
||||||
|
//! @param 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.
|
||||||
|
//!
|
||||||
|
//! @return return on success 0, otherwise error.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
long
|
||||||
|
netapp_timeout_values(unsigned long *aucDHCP, unsigned long *aucARP,unsigned long *aucKeepalive, unsigned long *aucInactivity)
|
||||||
|
{
|
||||||
|
signed char scRet;
|
||||||
|
unsigned char *ptr;
|
||||||
|
unsigned char *args;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return(scRet);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_ping_send
|
||||||
|
//!
|
||||||
|
//! @param ip destination IP address
|
||||||
|
//! @param pingAttempts number of echo requests to send
|
||||||
|
//! @param pingSize send buffer size which may be up to 1400 bytes
|
||||||
|
//! @param pingTimeout Time to wait for a response,in milliseconds.
|
||||||
|
//!
|
||||||
|
//! @return return on success 0, otherwise error.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
long
|
||||||
|
netapp_ping_send(unsigned long *ip, unsigned long ulPingAttempts, unsigned long ulPingSize, unsigned long ulPingTimeout)
|
||||||
|
{
|
||||||
|
signed char scRet;
|
||||||
|
unsigned char *ptr, *args;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return(scRet);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_ping_report
|
||||||
|
//!
|
||||||
|
//! @param none
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief 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:\n 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
void netapp_ping_report(void)
|
||||||
|
{
|
||||||
|
unsigned char *ptr;
|
||||||
|
ptr = tSLInformation.pucTxCommandBuffer;
|
||||||
|
signed char scRet;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_ping_stop
|
||||||
|
//!
|
||||||
|
//! @param none
|
||||||
|
//!
|
||||||
|
//! @return On success, zero is returned. On error, -1 is returned.
|
||||||
|
//!
|
||||||
|
//! @brief Stop any ping request.
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
long netapp_ping_stop(void)
|
||||||
|
{
|
||||||
|
signed char scRet;
|
||||||
|
unsigned char *ptr;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return(scRet);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_ipconfig
|
||||||
|
//!
|
||||||
|
//! @param[out] ipconfig This argument is a pointer to a
|
||||||
|
//! tNetappIpconfigRetArgs structure. This structure is
|
||||||
|
//! filled in with the network interface configuration.
|
||||||
|
//! tNetappIpconfigRetArgs:\n aucIP - ip address,
|
||||||
|
//! aucSubnetMask - mask, aucDefaultGateway - default
|
||||||
|
//! gateway address, aucDHCPServer - dhcp server address
|
||||||
|
//! aucDNSServer - dns server address, uaMacAddr - mac
|
||||||
|
//! address, uaSSID - connected AP ssid
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
void netapp_ipconfig( tNetappIpconfigRetArgs * ipconfig )
|
||||||
|
{
|
||||||
|
unsigned char *ptr;
|
||||||
|
|
||||||
|
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 );
|
||||||
|
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void netapp_ipconfig( tNetappIpconfigRetArgs * ipconfig )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_arp_flush
|
||||||
|
//!
|
||||||
|
//! @param none
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief Flushes ARP table
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
long netapp_arp_flush(void)
|
||||||
|
{
|
||||||
|
signed char scRet;
|
||||||
|
unsigned char *ptr;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return(scRet);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_set_debug_level
|
||||||
|
//!
|
||||||
|
//! @param[in] level debug level. Bitwise [0-8],
|
||||||
|
//! 0(disable)or 1(enable).\n 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
|
||||||
|
//!
|
||||||
|
//! @return On success, zero is returned. On error, -1 is returned
|
||||||
|
//!
|
||||||
|
//! @brief Debug messages sent via the UART debug channel, this function
|
||||||
|
//! enable/disable the debug level
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
long netapp_set_debug_level(unsigned long ulLevel)
|
||||||
|
{
|
||||||
|
signed char scRet;
|
||||||
|
unsigned char *ptr, *args;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return(scRet);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,340 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! \addtogroup nvmem_api
|
||||||
|
//! @{
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <nuttx/cc3000/nvmem.h>
|
||||||
|
#include <nuttx/cc3000/hci.h>
|
||||||
|
#include <nuttx/cc3000/socket.h>
|
||||||
|
#include <nuttx/cc3000/evnt_handler.h>
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Prototypes for the structures for APIs.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#define NVMEM_READ_PARAMS_LEN (12)
|
||||||
|
#define NVMEM_CREATE_PARAMS_LEN (8)
|
||||||
|
#define NVMEM_WRITE_PARAMS_LEN (16)
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_read
|
||||||
|
//!
|
||||||
|
//! @param ulFileId nvmem file id:\n
|
||||||
|
//! 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.
|
||||||
|
//! @param ulLength number of bytes to read
|
||||||
|
//! @param ulOffset ulOffset in file from where to read
|
||||||
|
//! @param buff output buffer pointer
|
||||||
|
//!
|
||||||
|
//! @return number of bytes read, otherwise error.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
signed long
|
||||||
|
nvmem_read(unsigned long ulFileId, unsigned long ulLength, unsigned long ulOffset, unsigned char *buff)
|
||||||
|
{
|
||||||
|
unsigned char ucStatus = 0xFF;
|
||||||
|
unsigned char *ptr;
|
||||||
|
unsigned char *args;
|
||||||
|
|
||||||
|
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, 0);
|
||||||
|
|
||||||
|
return(ucStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_write
|
||||||
|
//!
|
||||||
|
//! @param ulFileId nvmem file id:\n
|
||||||
|
//! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID,
|
||||||
|
//! NVMEM_MAC_FILEID, NVMEM_BOOTLOADER_SP_FILEID,
|
||||||
|
//! and user files 12-15.
|
||||||
|
//! @param ulLength number of bytes to write
|
||||||
|
//! @param ulEntryOffset offset in file to start write operation from
|
||||||
|
//! @param buff data to write
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
signed long
|
||||||
|
nvmem_write(unsigned long ulFileId, unsigned long ulLength, unsigned long
|
||||||
|
ulEntryOffset, unsigned char *buff)
|
||||||
|
{
|
||||||
|
long iRes;
|
||||||
|
unsigned char *ptr;
|
||||||
|
unsigned char *args;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return(iRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_set_mac_address
|
||||||
|
//!
|
||||||
|
//! @param mac mac address to be set
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief Write MAC address to EEPROM.
|
||||||
|
//! mac address as appears over the air (OUI first)
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
unsigned char nvmem_set_mac_address(unsigned char *mac)
|
||||||
|
{
|
||||||
|
return nvmem_write(NVMEM_MAC_FILEID, MAC_ADDR_LEN, 0, mac);
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_get_mac_address
|
||||||
|
//!
|
||||||
|
//! @param[out] mac mac address
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief Read MAC address from EEPROM.
|
||||||
|
//! mac address as appears over the air (OUI first)
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
unsigned char nvmem_get_mac_address(unsigned char *mac)
|
||||||
|
{
|
||||||
|
return nvmem_read(NVMEM_MAC_FILEID, MAC_ADDR_LEN, 0, mac);
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_write_patch
|
||||||
|
//!
|
||||||
|
//! @param ulFileId nvmem file id:\n
|
||||||
|
//! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID,
|
||||||
|
//! @param spLength number of bytes to write
|
||||||
|
//! @param spData SP data to write
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
unsigned char nvmem_write_patch(unsigned long ulFileId, unsigned long spLength, const unsigned char *spData)
|
||||||
|
{
|
||||||
|
unsigned char status = 0;
|
||||||
|
unsigned short offset = 0;
|
||||||
|
unsigned char* spDataPtr = (unsigned char*)spData;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_read_sp_version
|
||||||
|
//!
|
||||||
|
//! @param[out] patchVer first number indicates package ID and the second
|
||||||
|
//! number indicates package build number
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief Read patch version. read package version (WiFi FW patch,
|
||||||
|
//! driver-supplicant-NS patch, bootloader patch)
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
unsigned char nvmem_read_sp_version(unsigned char* patchVer)
|
||||||
|
{
|
||||||
|
unsigned char *ptr;
|
||||||
|
// 1st byte is the status and the rest is the SP version
|
||||||
|
unsigned char retBuf[5];
|
||||||
|
|
||||||
|
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];
|
||||||
|
|
||||||
|
return(retBuf[0]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_create_entry
|
||||||
|
//!
|
||||||
|
//! @param ulFileId nvmem file Id:\n
|
||||||
|
//! * NVMEM_AES128_KEY_FILEID: 12
|
||||||
|
//! * NVMEM_SHARED_MEM_FILEID: 13
|
||||||
|
//! * and fileIDs 14 and 15
|
||||||
|
//! @param ulNewLen entry ulLength
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
signed long
|
||||||
|
nvmem_create_entry(unsigned long ulFileId, unsigned long ulNewLen)
|
||||||
|
{
|
||||||
|
unsigned char *ptr;
|
||||||
|
unsigned char *args;
|
||||||
|
unsigned short retval;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return(retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Close the Doxygen group.
|
||||||
|
//! @}
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,359 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* 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 __COMMON_H__
|
||||||
|
#define __COMMON_H__
|
||||||
|
|
||||||
|
//******************************************************************************
|
||||||
|
// Include files
|
||||||
|
//******************************************************************************
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// If building with a C++ compiler, make all of the definitions in this header
|
||||||
|
// have a C binding.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
// ERROR CODES
|
||||||
|
//*****************************************************************************
|
||||||
|
#define ESUCCESS 0
|
||||||
|
#define EFAIL -1
|
||||||
|
#define EERROR EFAIL
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
// COMMON DEFINES
|
||||||
|
//*****************************************************************************
|
||||||
|
#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_MINIMAL_RX_SIZE)
|
||||||
|
#define CC3000_TX_BUFFER_SIZE (CC3000_MINIMAL_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
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
// Compound Types
|
||||||
|
//*****************************************************************************
|
||||||
|
//acassis: comment to use system definition
|
||||||
|
//typedef long time_t;
|
||||||
|
//typedef unsigned long clock_t;
|
||||||
|
//typedef long suseconds_t;
|
||||||
|
|
||||||
|
//typedef struct timeval timeval;
|
||||||
|
|
||||||
|
//struct timeval
|
||||||
|
//{
|
||||||
|
// time_t tv_sec; /* seconds */
|
||||||
|
// suseconds_t tv_usec; /* microseconds */
|
||||||
|
//};
|
||||||
|
|
||||||
|
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 long (*tWlanReadInteruptPin)(void);
|
||||||
|
|
||||||
|
typedef void (*tWlanInterruptEnable)(void);
|
||||||
|
|
||||||
|
typedef void (*tWlanInterruptDisable)(void);
|
||||||
|
|
||||||
|
typedef void (*tWriteWlanPin)(unsigned char val);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned short usRxEventOpcode;
|
||||||
|
unsigned short usEventOrDataReceived;
|
||||||
|
unsigned char *pucReceivedData;
|
||||||
|
unsigned char *pucTxCommandBuffer;
|
||||||
|
|
||||||
|
tFWPatches sFWPatches;
|
||||||
|
tDriverPatches sDriverPatches;
|
||||||
|
tBootLoaderPatches sBootLoaderPatches;
|
||||||
|
tWlanCB sWlanCB;
|
||||||
|
tWlanReadInteruptPin ReadWlanInterruptPin;
|
||||||
|
tWlanInterruptEnable WlanInterruptEnable;
|
||||||
|
tWlanInterruptDisable WlanInterruptDisable;
|
||||||
|
tWriteWlanPin WriteWlanPin;
|
||||||
|
|
||||||
|
signed long slTransmitDataError;
|
||||||
|
unsigned short usNumberOfFreeBuffers;
|
||||||
|
unsigned short usSlBufferLength;
|
||||||
|
unsigned short usBufferSize;
|
||||||
|
unsigned short usRxDataPending;
|
||||||
|
|
||||||
|
unsigned long NumberOfSentPackets;
|
||||||
|
unsigned long NumberOfReleasedPackets;
|
||||||
|
|
||||||
|
unsigned char InformHostOnTxComplete;
|
||||||
|
}sSimplLinkInformation;
|
||||||
|
|
||||||
|
extern volatile sSimplLinkInformation tSLInformation;
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
// Prototypes for the APIs.
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! SimpleLinkWaitEvent
|
||||||
|
//!
|
||||||
|
//! @param usOpcode command operation code
|
||||||
|
//! @param pRetParams command return parameters
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief Wait for event, pass it to the hci_event_handler and
|
||||||
|
//! update the event opcode in a global variable.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
extern void SimpleLinkWaitEvent(unsigned short usOpcode, void *pRetParams);
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! SimpleLinkWaitData
|
||||||
|
//!
|
||||||
|
//! @param pBuf data buffer
|
||||||
|
//! @param from from information
|
||||||
|
//! @param fromlen from information length
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief Wait for data, pass it to the hci_event_handler
|
||||||
|
//! and update in a global variable that there is
|
||||||
|
//! data to read.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
extern void SimpleLinkWaitData(unsigned char *pBuf, unsigned char *from, unsigned char *fromlen);
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! UINT32_TO_STREAM_f
|
||||||
|
//!
|
||||||
|
//! \param p pointer to the new stream
|
||||||
|
//! \param u32 pointer to the 32 bit
|
||||||
|
//!
|
||||||
|
//! \return pointer to the new stream
|
||||||
|
//!
|
||||||
|
//! \brief This function is used for copying 32 bit to stream
|
||||||
|
//! while converting to little endian format.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
extern unsigned char* UINT32_TO_STREAM_f (unsigned char *p, unsigned long u32);
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! UINT16_TO_STREAM_f
|
||||||
|
//!
|
||||||
|
//! \param p pointer to the new stream
|
||||||
|
//! \param u32 pointer to the 16 bit
|
||||||
|
//!
|
||||||
|
//! \return pointer to the new stream
|
||||||
|
//!
|
||||||
|
//! \brief This function is used for copying 16 bit to stream
|
||||||
|
//! while converting to little endian format.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
extern unsigned char* UINT16_TO_STREAM_f (unsigned char *p, unsigned short u16);
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! STREAM_TO_UINT16_f
|
||||||
|
//!
|
||||||
|
//! \param p pointer to the stream
|
||||||
|
//! \param offset offset in the stream
|
||||||
|
//!
|
||||||
|
//! \return pointer to the new 16 bit
|
||||||
|
//!
|
||||||
|
//! \brief This function is used for copying received stream to
|
||||||
|
//! 16 bit in little endian format.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
extern unsigned short STREAM_TO_UINT16_f(char* p, unsigned short offset);
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! STREAM_TO_UINT32_f
|
||||||
|
//!
|
||||||
|
//! \param p pointer to the stream
|
||||||
|
//! \param offset offset in the stream
|
||||||
|
//!
|
||||||
|
//! \return pointer to the new 32 bit
|
||||||
|
//!
|
||||||
|
//! \brief This function is used for copying received stream to
|
||||||
|
//! 32 bit in little endian format.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
extern unsigned long STREAM_TO_UINT32_f(char* p, unsigned short offset);
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
// COMMON MACROs
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
//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 short _i; for (_i = 0; _i < l; _i++) *(p)++ = ((unsigned char *) 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 = (unsigned char)(*(_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 short _i; for (_i = 0; _i < l; _i++) *(a)++= ((unsigned char *) p)[_i];}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Mark the end of the C bindings section for C++ compilers.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif // __COMMON_H__
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* 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 __EVENT_HANDLER_H__
|
||||||
|
#define __EVENT_HANDLER_H__
|
||||||
|
#include "hci.h"
|
||||||
|
#include "socket.h"
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// If building with a C++ compiler, make all of the definitions in this header
|
||||||
|
// have a C binding.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Prototypes for the APIs.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! hci_event_handler
|
||||||
|
//!
|
||||||
|
//! @param pRetParams incoming data buffer
|
||||||
|
//! @param from from information (in case of data received)
|
||||||
|
//! @param fromlen from information length (in case of data received)
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief Parse the incoming events packets and issues corresponding
|
||||||
|
//! event handler from global array of handlers pointers
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
extern unsigned char *hci_event_handler(void *pRetParams, unsigned char *from, unsigned char *fromlen);
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! hci_unsol_event_handler
|
||||||
|
//!
|
||||||
|
//! @param event_hdr event header
|
||||||
|
//!
|
||||||
|
//! @return 1 if event supported and handled
|
||||||
|
//! 0 if event is not supported
|
||||||
|
//!
|
||||||
|
//! @brief Handle unsolicited events
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
extern long hci_unsol_event_handler(char *event_hdr);
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! hci_unsolicited_event_handler
|
||||||
|
//!
|
||||||
|
//! @param None
|
||||||
|
//!
|
||||||
|
//! @return ESUCCESS if successful, EFAIL if an error occurred
|
||||||
|
//!
|
||||||
|
//! @brief Parse the incoming unsolicited event packets and issues
|
||||||
|
//! corresponding event handler.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
extern long hci_unsolicited_event_handler(void);
|
||||||
|
|
||||||
|
#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))
|
||||||
|
|
||||||
|
extern unsigned long socket_active_status;
|
||||||
|
|
||||||
|
extern void set_socket_active_status(long Sd, long Status);
|
||||||
|
extern long get_socket_active_status(long Sd);
|
||||||
|
|
||||||
|
typedef struct _bsd_accept_return_t
|
||||||
|
{
|
||||||
|
long iSocketDescriptor;
|
||||||
|
long iStatus;
|
||||||
|
sockaddr tSocketAddress;
|
||||||
|
|
||||||
|
} tBsdReturnParams;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _bsd_read_return_t
|
||||||
|
{
|
||||||
|
long iSocketDescriptor;
|
||||||
|
long iNumberOfBytes;
|
||||||
|
unsigned long uiFlags;
|
||||||
|
} tBsdReadReturnParams;
|
||||||
|
|
||||||
|
#define BSD_RECV_FROM_FROMLEN_OFFSET (4)
|
||||||
|
#define BSD_RECV_FROM_FROM_OFFSET (16)
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _bsd_select_return_t
|
||||||
|
{
|
||||||
|
long iStatus;
|
||||||
|
unsigned long uiRdfd;
|
||||||
|
unsigned long uiWrfd;
|
||||||
|
unsigned long uiExfd;
|
||||||
|
} tBsdSelectRecvParams;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _bsd_getsockopt_return_t
|
||||||
|
{
|
||||||
|
unsigned char ucOptValue[4];
|
||||||
|
char iStatus;
|
||||||
|
} tBsdGetSockOptReturnParams;
|
||||||
|
|
||||||
|
typedef struct _bsd_gethostbyname_return_t
|
||||||
|
{
|
||||||
|
long retVal;
|
||||||
|
long outputAddress;
|
||||||
|
} tBsdGethostbynameParams;
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Mark the end of the C bindings section for C++ compilers.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif // __EVENT_HANDLER_H__
|
||||||
|
|
||||||
@@ -0,0 +1,328 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* 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 __HCI_H__
|
||||||
|
#define __HCI_H__
|
||||||
|
|
||||||
|
#include "cc3000_common.h"
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// If building with a C++ compiler, make all of the definitions in this header
|
||||||
|
// have a C binding.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Prototypes for the structures for APIs.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Prototypes for the APIs.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! hci_command_send
|
||||||
|
//!
|
||||||
|
//! @param usOpcode command operation code
|
||||||
|
//! @param pucBuff pointer to the command's arguments buffer
|
||||||
|
//! @param ucArgsLength length of the arguments
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief Initiate an HCI command.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
extern unsigned short hci_command_send(unsigned short usOpcode,
|
||||||
|
unsigned char *ucArgs,
|
||||||
|
unsigned char ucArgsLength);
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! hci_data_send
|
||||||
|
//!
|
||||||
|
//! @param usOpcode command operation code
|
||||||
|
//! @param ucArgs pointer to the command's arguments buffer
|
||||||
|
//! @param usArgsLength length of the arguments
|
||||||
|
//! @param ucTail pointer to the data buffer
|
||||||
|
//! @param usTailLength buffer length
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief Initiate an HCI data write operation
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
extern long hci_data_send(unsigned char ucOpcode,
|
||||||
|
unsigned char *ucArgs,
|
||||||
|
unsigned short usArgsLength,
|
||||||
|
unsigned short usDataLength,
|
||||||
|
const unsigned char *ucTail,
|
||||||
|
unsigned short usTailLength);
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! hci_data_command_send
|
||||||
|
//!
|
||||||
|
//! @param usOpcode command operation code
|
||||||
|
//! @param pucBuff pointer to the data buffer
|
||||||
|
//! @param ucArgsLength arguments length
|
||||||
|
//! @param ucDataLength data length
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief Prepare HCI header and initiate an HCI data write operation
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
extern void hci_data_command_send(unsigned short usOpcode, unsigned char *pucBuff,
|
||||||
|
unsigned char ucArgsLength, unsigned short ucDataLength);
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! hci_patch_send
|
||||||
|
//!
|
||||||
|
//! @param usOpcode command operation code
|
||||||
|
//! @param pucBuff pointer to the command's arguments buffer
|
||||||
|
//! @param patch pointer to patch content buffer
|
||||||
|
//! @param usDataLength data length
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief Prepare HCI header and initiate an HCI patch write operation
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
extern void hci_patch_send(unsigned char ucOpcode, unsigned char *pucBuff, char *patch, unsigned short usDataLength);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Mark the end of the C bindings section for C++ compilers.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif // __HCI_H__
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* 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 __HOST_DRIVER_VERSION_H__
|
||||||
|
#define __HOST_DRIVER_VERSION_H__
|
||||||
|
|
||||||
|
#define DRIVER_VERSION_NUMBER 13
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __VERSION_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,342 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* 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 __NETAPP_H__
|
||||||
|
#define __NETAPP_H__
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// If building with a C++ compiler, make all of the definitions in this header
|
||||||
|
// have a C binding.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! \addtogroup netapp_api
|
||||||
|
//! @{
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
typedef struct _netapp_dhcp_ret_args_t
|
||||||
|
{
|
||||||
|
unsigned char aucIP[4];
|
||||||
|
unsigned char aucSubnetMask[4];
|
||||||
|
unsigned char aucDefaultGateway[4];
|
||||||
|
unsigned char aucDHCPServer[4];
|
||||||
|
unsigned char aucDNSServer[4];
|
||||||
|
}tNetappDhcpParams;
|
||||||
|
|
||||||
|
typedef struct _netapp_ipconfig_ret_args_t
|
||||||
|
{
|
||||||
|
unsigned char aucIP[4];
|
||||||
|
unsigned char aucSubnetMask[4];
|
||||||
|
unsigned char aucDefaultGateway[4];
|
||||||
|
unsigned char aucDHCPServer[4];
|
||||||
|
unsigned char aucDNSServer[4];
|
||||||
|
unsigned char uaMacAddr[6];
|
||||||
|
unsigned char 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;
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_config_mac_adrress
|
||||||
|
//!
|
||||||
|
//! @param mac device mac address, 6 bytes. Saved: yes
|
||||||
|
//!
|
||||||
|
//! @return return on success 0, otherwise error.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
extern long netapp_config_mac_adrress( unsigned char *mac );
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_dhcp
|
||||||
|
//!
|
||||||
|
//! @param aucIP device mac address, 6 bytes. Saved: yes
|
||||||
|
//! @param aucSubnetMask device mac address, 6 bytes. Saved: yes
|
||||||
|
//! @param aucDefaultGateway device mac address, 6 bytes. Saved: yes
|
||||||
|
//! @param aucDNSServer device mac address, 6 bytes. Saved: yes
|
||||||
|
//!
|
||||||
|
//! @return return on success 0, otherwise error.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
extern long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,unsigned long *aucDefaultGateway, unsigned long *aucDNSServer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_timeout_values
|
||||||
|
//!
|
||||||
|
//! @param 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.
|
||||||
|
//!
|
||||||
|
//! @param 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.
|
||||||
|
//!
|
||||||
|
//! @param 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.
|
||||||
|
//!
|
||||||
|
//! @param 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.
|
||||||
|
//!
|
||||||
|
//! @return return on success 0, otherwise error.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
extern long netapp_timeout_values(unsigned long *aucDHCP, unsigned long *aucARP,unsigned long *aucKeepalive, unsigned long *aucInactivity);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_ping_send
|
||||||
|
//!
|
||||||
|
//! @param ip destination IP address
|
||||||
|
//! @param pingAttempts number of echo requests to send
|
||||||
|
//! @param pingSize send buffer size which may be up to 1400 bytes
|
||||||
|
//! @param pingTimeout Time to wait for a response,in milliseconds.
|
||||||
|
//!
|
||||||
|
//! @return return on success 0, otherwise error.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
extern long netapp_ping_send(unsigned long *ip, unsigned long ulPingAttempts, unsigned long ulPingSize, unsigned long ulPingTimeout);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_ping_stop
|
||||||
|
//!
|
||||||
|
//! @param none
|
||||||
|
//!
|
||||||
|
//! @return On success, zero is returned. On error, -1 is returned.
|
||||||
|
//!
|
||||||
|
//! @brief Stop any ping request.
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
extern long netapp_ping_stop();
|
||||||
|
#endif
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_ping_report
|
||||||
|
//!
|
||||||
|
//! @param none
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief 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:\n 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
extern void netapp_ping_report();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_ipconfig
|
||||||
|
//!
|
||||||
|
//! @param[out] ipconfig This argument is a pointer to a
|
||||||
|
//! tNetappIpconfigRetArgs structure. This structure is
|
||||||
|
//! filled in with the network interface configuration.
|
||||||
|
//! tNetappIpconfigRetArgs:\n aucIP - ip address,
|
||||||
|
//! aucSubnetMask - mask, aucDefaultGateway - default
|
||||||
|
//! gateway address, aucDHCPServer - dhcp server address
|
||||||
|
//! aucDNSServer - dns server address, uaMacAddr - mac
|
||||||
|
//! address, uaSSID - connected AP ssid
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
extern void netapp_ipconfig( tNetappIpconfigRetArgs * ipconfig );
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_arp_flush
|
||||||
|
//!
|
||||||
|
//! @param none
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief Flushes ARP table
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
extern long netapp_arp_flush();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! netapp_set_debug_level
|
||||||
|
//!
|
||||||
|
//! @param[in] level debug level. Bitwise [0-8],
|
||||||
|
//! 0(disable)or 1(enable).\n 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
|
||||||
|
//!
|
||||||
|
//! @return On success, zero is returned. On error, -1 is returned
|
||||||
|
//!
|
||||||
|
//! @brief Debug messages sent via the UART debug channel, this function
|
||||||
|
//! enable/disable the debug level
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
long netapp_set_debug_level(unsigned long ulLevel);
|
||||||
|
#endif
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Close the Doxygen group.
|
||||||
|
//! @}
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Mark the end of the C bindings section for C++ compilers.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif // __NETAPP_H__
|
||||||
|
|
||||||
@@ -0,0 +1,248 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* 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 __NVRAM_H__
|
||||||
|
#define __NVRAM_H__
|
||||||
|
|
||||||
|
#include "cc3000_common.h"
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// If building with a C++ compiler, make all of the definitions in this header
|
||||||
|
// have a C binding.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! \addtogroup nvmem_api
|
||||||
|
//! @{
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Definitions for File IDs
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
/* 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)
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_read
|
||||||
|
//!
|
||||||
|
//! @param ulFileId nvmem file id:\n
|
||||||
|
//! 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.
|
||||||
|
//! @param ulLength number of bytes to read
|
||||||
|
//! @param ulOffset ulOffset in file from where to read
|
||||||
|
//! @param buff output buffer pointer
|
||||||
|
//!
|
||||||
|
//! @return number of bytes read, otherwise error.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
extern signed long nvmem_read(unsigned long file_id, unsigned long length, unsigned long offset, unsigned char *buff);
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_write
|
||||||
|
//!
|
||||||
|
//! @param ulFileId nvmem file id:\n
|
||||||
|
//! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID,
|
||||||
|
//! NVMEM_MAC_FILEID, NVMEM_BOOTLOADER_SP_FILEID,
|
||||||
|
//! and user files 12-15.
|
||||||
|
//! @param ulLength number of bytes to write
|
||||||
|
//! @param ulEntryOffset offset in file to start write operation from
|
||||||
|
//! @param buff data to write
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
extern signed long nvmem_write(unsigned long ulFileId, unsigned long ulLength, unsigned long ulEntryOffset, unsigned char *buff);
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_set_mac_address
|
||||||
|
//!
|
||||||
|
//! @param mac mac address to be set
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief Write MAC address to EEPROM.
|
||||||
|
//! mac address as appears over the air (OUI first)
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
extern unsigned char nvmem_set_mac_address(unsigned char *mac);
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_get_mac_address
|
||||||
|
//!
|
||||||
|
//! @param[out] mac mac address
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief Read MAC address from EEPROM.
|
||||||
|
//! mac address as appears over the air (OUI first)
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
extern unsigned char nvmem_get_mac_address(unsigned char *mac);
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_write_patch
|
||||||
|
//!
|
||||||
|
//! @param ulFileId nvmem file id:\n
|
||||||
|
//! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID,
|
||||||
|
//! @param spLength number of bytes to write
|
||||||
|
//! @param spData SP data to write
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
extern unsigned char nvmem_write_patch(unsigned long ulFileId, unsigned long spLength, const unsigned char *spData);
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_read_sp_version
|
||||||
|
//!
|
||||||
|
//! @param[out] patchVer first number indicates package ID and the second
|
||||||
|
//! number indicates package build number
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief Read patch version. read package version (WiFi FW patch,
|
||||||
|
//! driver-supplicant-NS patch, bootloader patch)
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
#ifndef CC3000_TINY_DRIVER
|
||||||
|
extern unsigned char nvmem_read_sp_version(unsigned char* patchVer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! nvmem_create_entry
|
||||||
|
//!
|
||||||
|
//! @param ulFileId nvmem file Id:\n
|
||||||
|
//! * NVMEM_AES128_KEY_FILEID: 12
|
||||||
|
//! * NVMEM_SHARED_MEM_FILEID: 13
|
||||||
|
//! * and fileIDs 14 and 15
|
||||||
|
//! @param ulNewLen entry ulLength
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief 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.
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
extern signed long nvmem_create_entry(unsigned long file_id, unsigned long newlen);
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Mark the end of the C bindings section for C++ compilers.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Close the Doxygen group.
|
||||||
|
//! @}
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif // __NVRAM_H__
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* security.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 __SECURITY__
|
||||||
|
#define __SECURITY__
|
||||||
|
|
||||||
|
#include "nvmem.h"
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// If building with a C++ compiler, make all of the definitions in this header
|
||||||
|
// have a C binding.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define AES128_KEY_SIZE 16
|
||||||
|
|
||||||
|
#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! aes_encrypt
|
||||||
|
//!
|
||||||
|
//! @param[in] key AES128 key of size 16 bytes
|
||||||
|
//! @param[in\out] state 16 bytes of plain text and cipher text
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief AES128 encryption:
|
||||||
|
//! Given AES128 key and 16 bytes plain text, cipher text of 16 bytes
|
||||||
|
//! is computed. The AES implementation is in mode ECB (Electronic
|
||||||
|
//! Code Book).
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
extern void aes_encrypt(unsigned char *state, unsigned char *key);
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! aes_decrypt
|
||||||
|
//!
|
||||||
|
//! @param[in] key AES128 key of size 16 bytes
|
||||||
|
//! @param[in\out] state 16 bytes of cipher text and plain text
|
||||||
|
//!
|
||||||
|
//! @return none
|
||||||
|
//!
|
||||||
|
//! @brief AES128 decryption:
|
||||||
|
//! Given AES128 key and 16 bytes cipher text, plain text of 16 bytes
|
||||||
|
//! is computed The AES implementation is in mode ECB
|
||||||
|
//! (Electronic Code Book).
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
extern void aes_decrypt(unsigned char *state, unsigned char *key);
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! aes_read_key
|
||||||
|
//!
|
||||||
|
//! @param[out] key AES128 key of size 16 bytes
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief Reads AES128 key from EEPROM
|
||||||
|
//! Reads the AES128 key from fileID #12 in EEPROM
|
||||||
|
//! returns an error if the key does not exist.
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
extern signed long aes_read_key(unsigned char *key);
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
//! aes_write_key
|
||||||
|
//!
|
||||||
|
//! @param[out] key AES128 key of size 16 bytes
|
||||||
|
//!
|
||||||
|
//! @return on success 0, error otherwise.
|
||||||
|
//!
|
||||||
|
//! @brief writes AES128 key from EEPROM
|
||||||
|
//! Writes the AES128 key to fileID #12 in EEPROM
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
//*****************************************************************************
|
||||||
|
extern signed long aes_write_key(unsigned char *key);
|
||||||
|
|
||||||
|
#endif //CC3000_UNENCRYPTED_SMART_CONFIG
|
||||||
|
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,45 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
*
|
||||||
|
* ArduinoCC3000SPI.h - SPI functions to connect an Arduidno to the TI
|
||||||
|
* CC3000
|
||||||
|
*
|
||||||
|
* This code uses the Arduino hardware SPI library (or a bit-banged
|
||||||
|
* SPI for the Teensy 3.0) to send & receive data between the library
|
||||||
|
* API calls and the CC3000 hardware. Every
|
||||||
|
*
|
||||||
|
* Version 1.0.1b
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Chris Magagna - cmagagna@yahoo.com
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* Don't sue me if my code blows up your board and burns down your house
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef void (*gcSpiHandleRx)(void *p);
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Prototypes for the APIs.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
void SpiOpen(gcSpiHandleRx pfRxHandler);
|
||||||
|
|
||||||
|
void SpiClose(void);
|
||||||
|
|
||||||
|
long SpiWrite(unsigned char *pUserBuffer, unsigned short usLength);
|
||||||
|
|
||||||
|
void SpiResumeSpi(void);
|
||||||
|
|
||||||
|
int CC3000InterruptHandler(int irq, void *context);
|
||||||
|
|
||||||
|
short SPIInterruptsEnabled;
|
||||||
|
|
||||||
|
unsigned char wlan_tx_buffer[];
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* 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 __SPI_VERSION_H__
|
||||||
|
#define __SPI_VERSION_H__
|
||||||
|
|
||||||
|
#define SPI_VERSION_NUMBER 7
|
||||||
|
|
||||||
|
#endif // __VERSION_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user