CC3000 driver changes from David Sidrane

This commit is contained in:
Gregory Nutt
2013-10-16 11:59:26 -06:00
parent 48a8364267
commit 4e44868f12
14 changed files with 4593 additions and 4730 deletions
+1 -1
View File
@@ -362,7 +362,7 @@ static inline int sst25_readid(struct sst25_dev_s *priv)
priv->nsectors = SST25_VF016_NSECTORS;
return OK;
/* Not implemented yet */
/* Support for this part is not implemented yet */
default:
break;
+49 -3
View File
@@ -3,8 +3,54 @@
# see misc/tools/kconfig-language.txt.
#
config WL_CC3000_DUMMY
bool "CC3000 Wireless Module Dummy Test"
default n
config WL_CC3000
bool "CC3000 Wireless Module"
default n
select SPI
---help---
Enable support for the TI CC3000 Wifi Module
if WL_CC3000
config CC3000_MULTIPLE
bool "Multiple CC3000 Devices"
default n
---help---
Can be defined to support multiple CC3000 devices on board.
config CC3000_NPOLLWAITERS
int "Number poll waiters"
default 4
depends on !DISABLE_POLL
---help---
Maximum number of threads that can be waiting on poll()
config CC3000_SPIDEV
int "SPI bus number"
default 2
---help---
Selects the SPI bus number identying that SPI interface that
connects the CC3000 to the MCU.
config CC3000_DEVMINOR
int "Input device minor number"
default 0
---help---
The CC3000 device will be registered as /dev/wirelessN where N is the
value provided by this setting.
config CC3000_SPI_MODE
int "SPI mode"
default 0
range 0 3
---help---
Controls the SPI mode. The device should work in mode 0, but
sometimes you need to experiment.
config CC3000_SPI_FREQUENCY
int "SPI frequency"
default 16000000
---help---
Define to use a different SPI bus frequency.
endif
+3 -2
View File
@@ -1,7 +1,7 @@
############################################################################
# drivers/wireless/Make.defs
#
# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
# Copyright (C) 2013 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@@ -37,7 +37,8 @@ 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
CSRCS += cc3000.c cc3000_common.c evnt_handler.c hci.c netapp.c nvmem.c
CSRCS += security.c socket.c spi.c wlan.c
# Include wireless devices build support
+125 -136
View File
@@ -1,164 +1,153 @@
/*****************************************************************************
*
* 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
//! @{
//
//*****************************************************************************
/******************************************************************************
* cc3000_common.c.c - CC3000 Host Driver Implementation.
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
*
* Include files
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
/******************************************************************************
* Included files
*****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <nuttx/wireless/cc3000/cc3000_common.h>
#include <nuttx/wireless/cc3000/socket.h>
#include <nuttx/wireless/cc3000/include/sys/socket.h>
#include <nuttx/wireless/cc3000/wlan.h>
#include <nuttx/wireless/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
}
/*****************************************************************************
* Name:__error__
*
* Description:
* Stub function for ASSERT macro
*
* Input Parameters:
* pcFilename - file name, where error occurred
* ulLine - line number, where error occurred
*
* Returned Value:
* None
*
*****************************************************************************/
//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
/*****************************************************************************
* Name: UINT32_TO_STREAM_f
*
* Description:
* This function is used for copying 32 bit to stream while converting to
* little endian format.
*
* Input Parameters:
* p pointer to the new stream
* u32 pointer to the 32 bit
*
* Returned Value:
* Pointer to the new stream
*
*****************************************************************************/
uint8_t* UINT32_TO_STREAM_f (uint8_t *p, unsigned long u32)
{
*(p)++ = (uint8_t)(u32);
*(p)++ = (uint8_t)((u32) >> 8);
*(p)++ = (uint8_t)((u32) >> 16);
*(p)++ = (uint8_t)((u32) >> 24);
return p;
*(p)++ = (uint8_t)(u32);
*(p)++ = (uint8_t)((u32) >> 8);
*(p)++ = (uint8_t)((u32) >> 16);
*(p)++ = (uint8_t)((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.
//
//*****************************************************************************
/*****************************************************************************
* Name: UINT16_TO_STREAM_f
*
* Description:
* This function is used for copying 16 bit to stream while converting to
* little endian format.
*
* Input Parameters:
* p pointer to the new stream
* u16 pointer to the 16 bit
*
* Returned Value:
* Pointer to the new stream
*
*****************************************************************************/
uint8_t* UINT16_TO_STREAM_f (uint8_t *p, uint16_t u16)
{
*(p)++ = (uint8_t)(u16);
*(p)++ = (uint8_t)((u16) >> 8);
return p;
*(p)++ = (uint8_t)(u16);
*(p)++ = (uint8_t)((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.
//
//*****************************************************************************
/*****************************************************************************
* Name: STREAM_TO_UINT16_f
*
* Description:
* This function is used for copying received stream to 16 bit in little
* endian format.
*
* Input Parameters:
* p pointer to the stream
* offset offset in the stream
*
* Returned Value:
* Pointer to the new 16 bit
*
*****************************************************************************/
uint16_t STREAM_TO_UINT16_f(char* p, uint16_t offset)
{
return (uint16_t)((uint16_t)((uint16_t)
(*(p + offset + 1)) << 8) + (uint16_t)(*(p + offset)));
return (uint16_t)((uint16_t)((uint16_t)
(*(p + offset + 1)) << 8) + (uint16_t)(*(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.
//
//*****************************************************************************
/*****************************************************************************
* Name: STREAM_TO_UINT32_f
*
* Description:
* This function is used for copying received stream to 32 bit in little
* endian format.
*
* Input Parameters:
* p pointer to the stream
* offset offset in the stream
*
* Returned Value:
* Pointer to the new 32 bit
*
*****************************************************************************/
unsigned long STREAM_TO_UINT32_f(char* p, uint16_t offset)
{
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)));
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
+216 -210
View File
@@ -1,230 +1,236 @@
/*****************************************************************************
*
* 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.
*
*****************************************************************************/
* 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
//! @{
//
//*****************************************************************************
/******************************************************************************
* Included Files
******************************************************************************/
#include <string.h>
#include <nuttx/wireless/cc3000/cc3000_common.h>
#include <nuttx/wireless/cc3000/hci.h>
#include <nuttx/wireless/cc3000/spi.h>
#include "spi.h"
#include <nuttx/wireless/cc3000/evnt_handler.h>
#include <nuttx/wireless/cc3000/wlan.h>
#define SL_PATCH_PORTION_SIZE (1000)
/******************************************************************************
* Pre-processor Definitions
******************************************************************************/
#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.
//
//*****************************************************************************
uint16_t
hci_command_send(uint16_t usOpcode, uint8_t *pucBuff,
uint8_t ucArgsLength)
{
uint8_t *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);
}
/******************************************************************************
* Public Functions
******************************************************************************/
/******************************************************************************
* Name: hci_command_send
*
* Description:
* Initiate an HCI command.
*
* Input Parameters:
* usOpcode command operation code
* pucBuff pointer to the command's arguments buffer
* ucArgsLength length of the arguments
*
* Returned Value:
* Zero
*
*****************************************************************************/
//*****************************************************************************
//
//! 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(uint8_t ucOpcode,
uint8_t *ucArgs,
uint16_t usArgsLength,
uint16_t usDataLength,
const uint8_t *ucTail,
uint16_t usTailLength)
uint16_t hci_command_send(uint16_t usOpcode, uint8_t *pucBuff, uint8_t ucArgsLength)
{
uint8_t *stream;
stream = ((ucArgs) + SPI_HEADER_SIZE);
UINT8_TO_STREAM(stream, HCI_TYPE_DATA);
UINT8_TO_STREAM(stream, ucOpcode);
UINT8_TO_STREAM(stream, usArgsLength);
stream = UINT16_TO_STREAM(stream, usArgsLength + usDataLength + usTailLength);
// Send the packet over the SPI
SpiWrite(ucArgs, SIMPLE_LINK_HCI_DATA_HEADER_SIZE + usArgsLength + usDataLength + usTailLength);
return(ESUCCESS);
uint8_t *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;
}
/******************************************************************************
* Name: hci_data_send
*
* Description:
*
*
* Input Parameters:
* usOpcode command operation code
* ucArgs pointer to the command's arguments buffer
* usArgsLength length of the arguments
* ucTail pointer to the data buffer
* usTailLength buffer length
*
* Returned Value:
* None
*
*****************************************************************************/
long hci_data_send(uint8_t ucOpcode, uint8_t *ucArgs, uint16_t usArgsLength,
uint16_t usDataLength, const uint8_t *ucTail,
uint16_t usTailLength)
{
uint8_t *stream;
stream = ((ucArgs) + SPI_HEADER_SIZE);
UINT8_TO_STREAM(stream, HCI_TYPE_DATA);
UINT8_TO_STREAM(stream, ucOpcode);
UINT8_TO_STREAM(stream, usArgsLength);
stream = UINT16_TO_STREAM(stream, usArgsLength + usDataLength + usTailLength);
/* Send the packet over the SPI */
SpiWrite(ucArgs, SIMPLE_LINK_HCI_DATA_HEADER_SIZE + usArgsLength + usDataLength + usTailLength);
return ESUCCESS;
}
/******************************************************************************
* Name: hci_data_command_send
*
* Description:
* Prepeare HCI header and initiate an HCI data write operation
*
* Input Parameters:
* usOpcode command operation code
* pucBuff pointer to the data buffer
* ucArgsLength arguments length
* ucDataLength data length
*
* Returned Value:
* None
*
*****************************************************************************/
//*****************************************************************************
//
//! 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(uint16_t usOpcode, uint8_t *pucBuff,
uint8_t ucArgsLength,uint16_t ucDataLength)
{
uint8_t *stream = (pucBuff + SPI_HEADER_SIZE);
UINT8_TO_STREAM(stream, HCI_TYPE_DATA);
UINT8_TO_STREAM(stream, usOpcode);
UINT8_TO_STREAM(stream, ucArgsLength);
stream = UINT16_TO_STREAM(stream, ucArgsLength + ucDataLength);
// Send the command over SPI on data channel
SpiWrite(pucBuff, ucArgsLength + ucDataLength + SIMPLE_LINK_HCI_DATA_CMND_HEADER_SIZE);
return;
uint8_t ucArgsLength,uint16_t ucDataLength)
{
uint8_t *stream = (pucBuff + SPI_HEADER_SIZE);
UINT8_TO_STREAM(stream, HCI_TYPE_DATA);
UINT8_TO_STREAM(stream, usOpcode);
UINT8_TO_STREAM(stream, ucArgsLength);
stream = UINT16_TO_STREAM(stream, ucArgsLength + ucDataLength);
/* Send the command over SPI on data channel */
SpiWrite(pucBuff,
ucArgsLength + ucDataLength + SIMPLE_LINK_HCI_DATA_CMND_HEADER_SIZE);
}
//*****************************************************************************
//
//! 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(uint8_t ucOpcode, uint8_t *pucBuff, char *patch, uint16_t usDataLength)
{
uint8_t *data_ptr = (pucBuff + SPI_HEADER_SIZE);
uint16_t usTransLength;
uint8_t *stream = (pucBuff + SPI_HEADER_SIZE);
UINT8_TO_STREAM(stream, HCI_TYPE_PATCH);
UINT8_TO_STREAM(stream, ucOpcode);
stream = UINT16_TO_STREAM(stream, usDataLength + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE);
if (usDataLength <= SL_PATCH_PORTION_SIZE)
{
UINT16_TO_STREAM(stream, usDataLength);
stream = UINT16_TO_STREAM(stream, usDataLength);
memcpy((pucBuff + SPI_HEADER_SIZE) + HCI_PATCH_HEADER_SIZE, patch, usDataLength);
// Update the opcode of the event we will be waiting for
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;
}
*(uint16_t *)data_ptr = usTransLength;
memcpy(data_ptr + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE, patch, usTransLength);
patch += usTransLength;
// Update the opcode of the event we will be waiting for
SpiWrite((uint8_t *)data_ptr, usTransLength + sizeof(usTransLength));
}
}
}
/******************************************************************************
* Name: hci_patch_send
*
* Description:
* Prepeare HCI header and initiate an HCI patch write operation
*
* Input Parameters:
* usOpcode command operation code
* pucBuff pointer to the command's arguments buffer
* patch pointer to patch content buffer
* usDataLength data length
*
* Returned Value:
* None
*
*****************************************************************************/
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//
//*****************************************************************************
void hci_patch_send(uint8_t ucOpcode, uint8_t *pucBuff, char *patch,
uint16_t usDataLength)
{
uint8_t *data_ptr = (pucBuff + SPI_HEADER_SIZE);
uint16_t usTransLength;
uint8_t *stream = (pucBuff + SPI_HEADER_SIZE);
UINT8_TO_STREAM(stream, HCI_TYPE_PATCH);
UINT8_TO_STREAM(stream, ucOpcode);
stream = UINT16_TO_STREAM(stream, usDataLength + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE);
if (usDataLength <= SL_PATCH_PORTION_SIZE)
{
UINT16_TO_STREAM(stream, usDataLength);
stream = UINT16_TO_STREAM(stream, usDataLength);
memcpy((pucBuff + SPI_HEADER_SIZE) + HCI_PATCH_HEADER_SIZE, patch, usDataLength);
/* Update the opcode of the event we will be waiting for */
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;
}
*(uint16_t *)data_ptr = usTransLength;
memcpy(data_ptr + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE, patch,
usTransLength);
patch += usTransLength;
/* Update the opcode of the event we will be waiting for */
SpiWrite((uint8_t *)data_ptr, usTransLength + sizeof(usTransLength));
}
}
}
@@ -12,23 +12,23 @@
*
* 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
* 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
* 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
* 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
* 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.
*
*****************************************************************************/
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
+36 -31
View File
@@ -1,45 +1,50 @@
/**************************************************************************
*
* 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
*
****************************************************************************/
* 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
*
****************************************************************************/
#ifndef __DRIVERS_WIRELESS_CC3000_SPI_H
#define __DRIVERS_WIRELESS_CC3000_SPI_H
#include <stdint.h>
/*****************************************************************************
* Public Types
*****************************************************************************/
typedef void (*gcSpiHandleRx)(void *p);
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
/*****************************************************************************
* Public Data
*****************************************************************************/
extern uint16_t SPIInterruptsEnabled;
extern uint8_t wlan_tx_buffer[];
/*****************************************************************************
* Public Function Prototypes
*****************************************************************************/
void SpiOpen(gcSpiHandleRx pfRxHandler);
void SpiClose(void);
long SpiWrite(uint8_t *pUserBuffer, uint16_t usLength);
long SpiRead(uint8_t *pUserBuffer, uint16_t usLength);
void SpiResumeSpi(void);
int CC3000InterruptHandler(int irq, void *context);
int16_t SPIInterruptsEnabled;
uint8_t wlan_tx_buffer[];
#endif /* __DRIVERS_WIRELESS_CC3000_SPI_H */
+41 -53
View File
@@ -1,53 +1,41 @@
/*****************************************************************************
*
* 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__
/*****************************************************************************
*
* spi_version.h - CC3000 Host Driver Implementation.
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#ifndef __DRIVERS_WIRELESS_CC3000_SPI_VERSION_H
#define __DRIVERS_WIRELESS_CC3000_SPI_VERSION_H
#define SPI_VERSION_NUMBER 7
#endif /* __DRIVERS_WIRELESS_CC3000_SPI_VERSION_H */
File diff suppressed because it is too large Load Diff