Commit f996d885 authored by Damien George's avatar Damien George
Browse files

drivers, cc3k: Move cc3000 driver from stmhal to drivers directory.

parent 55a5b807
...@@ -12,32 +12,36 @@ ...@@ -12,32 +12,36 @@
* *
* Redistributions in binary form must reproduce the above copyright * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * 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. * distribution.
* *
* Neither the name of Texas Instruments Incorporated nor the names of * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived * its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission. * from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
*****************************************************************************/ *****************************************************************************/
#ifndef __COMMON_H__ #ifndef __COMMON_H__
#define __COMMON_H__ #define __COMMON_H__
#include "data_types.h"
//****************************************************************************** //******************************************************************************
// Include files // Include files
//****************************************************************************** //******************************************************************************
#include <stdlib.h>
#include <stdint.h>
//***************************************************************************** //*****************************************************************************
// //
...@@ -49,6 +53,8 @@ ...@@ -49,6 +53,8 @@
extern "C" { extern "C" {
#endif #endif
extern int errno;
//***************************************************************************** //*****************************************************************************
// ERROR CODES // ERROR CODES
//***************************************************************************** //*****************************************************************************
...@@ -59,18 +65,16 @@ extern "C" { ...@@ -59,18 +65,16 @@ extern "C" {
//***************************************************************************** //*****************************************************************************
// COMMON DEFINES // COMMON DEFINES
//***************************************************************************** //*****************************************************************************
#define ERROR_SOCKET_INACTIVE -57 #define ERROR_SOCKET_INACTIVE -57
#define WLAN_ENABLE (1) #define WLAN_ENABLE (1)
#define WLAN_DISABLE (0) #define WLAN_DISABLE (0)
#define MAC_ADDR_LEN (6) #define MAC_ADDR_LEN (6)
#define SP_PORTION_SIZE (32) #define SP_PORTION_SIZE (32)
// #define CC3000_TINY_DRIVER /*Defines for minimal and maximal RX buffer size. This size includes the spi
/*Defines for minimal and maximal RX buffer size. This size includes the spi
header and hci header. header and hci header.
The maximal buffer size derives from: The maximal buffer size derives from:
MTU + HCI header + SPI header + sendto() agrs size MTU + HCI header + SPI header + sendto() agrs size
...@@ -78,26 +82,26 @@ extern "C" { ...@@ -78,26 +82,26 @@ extern "C" {
HCI header + SPI header + max args size HCI header + SPI header + max args size
This buffer is used for receiving events and data. This buffer is used for receiving events and data.
The packet can not be longer than MTU size and CC3000 does not support 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 fragmentation. Note that the same buffer is used for reception of the data
and events from CC3000. That is why the minimum is defined. and events from CC3000. That is why the minimum is defined.
The calculation for the actual size of buffer for reception is: 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 Given the maximal data size MAX_DATA that is expected to be received by
application, the required buffer is: application, the required buffer is:
Using recv() or recvfrom(): Using recv() or recvfrom():
max(CC3000_MINIMAL_RX_SIZE, MAX_DATA + HEADERS_SIZE_DATA + fromlen max(CC3000_MINIMAL_RX_SIZE, MAX_DATA + HEADERS_SIZE_DATA + fromlen
+ ucArgsize + 1) + ucArgsize + 1)
Using gethostbyname() with minimal buffer size will limit the host name Using gethostbyname() with minimal buffer size will limit the host name
returned to 99 bytes only. returned to 99 bytes only.
The 1 is used for the overrun detection The 1 is used for the overrun detection
Buffer size increased to 130 following the add_profile() with WEP security Buffer size increased to 130 following the add_profile() with WEP security
which requires TX buffer size of 130 bytes: 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 HEADERS_SIZE_EVNT + WLAN_ADD_PROFILE_WEP_PARAM_LEN + MAX SSID LEN + 4 * MAX KEY LEN = 130
MAX SSID LEN = 32 MAX SSID LEN = 32
MAX SSID LEN = 13 (with add_profile only ascii key setting is supported, MAX SSID LEN = 13 (with add_profile only ascii key setting is supported,
therfore maximum key size is 13) therfore maximum key size is 13)
*/ */
...@@ -106,24 +110,24 @@ extern "C" { ...@@ -106,24 +110,24 @@ extern "C" {
/*Defines for minimal and maximal TX buffer size. /*Defines for minimal and maximal TX buffer size.
This buffer is used for sending events and data. This buffer is used for sending events and data.
The packet can not be longer than MTU size and CC3000 does not support 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 fragmentation. Note that the same buffer is used for transmission of the data
and commands. That is why the minimum is defined. and commands. That is why the minimum is defined.
The calculation for the actual size of buffer for transmission is: The calculation for the actual size of buffer for transmission is:
Given the maximal data size MAX_DATA, the required buffer is: Given the maximal data size MAX_DATA, the required buffer is:
Using Sendto(): Using Sendto():
max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE
+ SOCKET_SENDTO_PARAMS_LEN + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1) + SOCKET_SENDTO_PARAMS_LEN + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1)
Using Send(): Using Send():
max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE
+ HCI_CMND_SEND_ARG_LENGTH + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1) + HCI_CMND_SEND_ARG_LENGTH + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1)
The 1 is used for the overrun detection */
The 1 is used for the overrun detection */ #define CC3000_MINIMAL_TX_SIZE (130 + 1)
#define CC3000_MINIMAL_TX_SIZE (130 + 1)
#define CC3000_MAXIMAL_TX_SIZE (1519 + 1) #define CC3000_MAXIMAL_TX_SIZE (1519 + 1)
//TX and RX buffer sizes, allow to receive and transmit maximum data at length 8. //TX and RX buffer sizes, allow to receive and transmit maximum data at length 8.
...@@ -132,64 +136,64 @@ extern "C" { ...@@ -132,64 +136,64 @@ extern "C" {
#define TINY_CC3000_MAXIMAL_TX_SIZE 59 #define TINY_CC3000_MAXIMAL_TX_SIZE 59
#endif #endif
/*In order to determine your preferred buffer size, /*In order to determine your preferred buffer size,
change CC3000_MAXIMAL_RX_SIZE and CC3000_MAXIMAL_TX_SIZE to a value between change CC3000_MAXIMAL_RX_SIZE and CC3000_MAXIMAL_TX_SIZE to a value between
the minimal and maximal specified above. the minimal and maximal specified above.
Note that the buffers are allocated by SPI. Note that the buffers are allocated by SPI.
In case you change the size of those buffers, you might need also to change 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 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. allocated in the FRAM section that is allocated manually and not by IDE.
*/ */
#ifndef CC3000_TINY_DRIVER #ifndef CC3000_TINY_DRIVER
#define CC3000_RX_BUFFER_SIZE (CC3000_MINIMAL_RX_SIZE) #define CC3000_RX_BUFFER_SIZE (CC3000_MAXIMAL_RX_SIZE)
#define CC3000_TX_BUFFER_SIZE (CC3000_MINIMAL_TX_SIZE) #define CC3000_TX_BUFFER_SIZE (CC3000_MAXIMAL_TX_SIZE)
//if defined TINY DRIVER we use smaller RX and TX buffer in order to minimize RAM consumption //if defined TINY DRIVER we use smaller RX and TX buffer in order to minimize RAM consumption
#else #else
#define CC3000_RX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_RX_SIZE) #define CC3000_RX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_RX_SIZE)
#define CC3000_TX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_TX_SIZE) #define CC3000_TX_BUFFER_SIZE (TINY_CC3000_MAXIMAL_TX_SIZE)
#endif #endif
//***************************************************************************** //*****************************************************************************
// Compound Types // Compound Types
//***************************************************************************** //*****************************************************************************
typedef long time_t; typedef INT32 time_t;
typedef unsigned long clock_t; typedef UINT32 clock_t;
typedef long suseconds_t; typedef INT32 suseconds_t;
typedef struct timeval timeval; typedef struct timeval timeval;
struct timeval struct timeval
{ {
time_t tv_sec; /* seconds */ time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */ suseconds_t tv_usec; /* microseconds */
}; };
typedef char *(*tFWPatches)(unsigned long *usLength); typedef CHAR *(*tFWPatches)(UINT32 *usLength);
typedef char *(*tDriverPatches)(unsigned long *usLength); typedef CHAR *(*tDriverPatches)(UINT32 *usLength);
typedef char *(*tBootLoaderPatches)(unsigned long *usLength); typedef CHAR *(*tBootLoaderPatches)(UINT32 *usLength);
typedef void (*tWlanCB)(long event_type, char * data, unsigned char length ); typedef void (*tWlanCB)(INT32 event_type, CHAR * data, UINT8 length );
typedef long (*tWlanReadInteruptPin)(void); typedef INT32 (*tWlanReadInteruptPin)(void);
typedef void (*tWlanInterruptEnable)(void); typedef void (*tWlanInterruptEnable)(void);
typedef void (*tWlanInterruptDisable)(void); typedef void (*tWlanInterruptDisable)(void);
typedef void (*tWriteWlanPin)(unsigned char val); typedef void (*tWriteWlanPin)(UINT8 val);
typedef struct typedef struct
{ {
unsigned short usRxEventOpcode; UINT16 usRxEventOpcode;
unsigned short usEventOrDataReceived; UINT16 usEventOrDataReceived;
unsigned char *pucReceivedData; UINT8 *pucReceivedData;
unsigned char *pucTxCommandBuffer; UINT8 *pucTxCommandBuffer;
tFWPatches sFWPatches; tFWPatches sFWPatches;
tDriverPatches sDriverPatches; tDriverPatches sDriverPatches;
...@@ -200,16 +204,16 @@ typedef struct ...@@ -200,16 +204,16 @@ typedef struct
tWlanInterruptDisable WlanInterruptDisable; tWlanInterruptDisable WlanInterruptDisable;
tWriteWlanPin WriteWlanPin; tWriteWlanPin WriteWlanPin;
signed long slTransmitDataError; INT32 slTransmitDataError;
unsigned short usNumberOfFreeBuffers; UINT16 usNumberOfFreeBuffers;
unsigned short usSlBufferLength; UINT16 usSlBufferLength;
unsigned short usBufferSize; UINT16 usBufferSize;
unsigned short usRxDataPending; UINT16 usRxDataPending;
unsigned long NumberOfSentPackets; UINT32 NumberOfSentPackets;
unsigned long NumberOfReleasedPackets; UINT32 NumberOfReleasedPackets;
unsigned char InformHostOnTxComplete; UINT8 InformHostOnTxComplete;
}sSimplLinkInformation; }sSimplLinkInformation;
extern volatile sSimplLinkInformation tSLInformation; extern volatile sSimplLinkInformation tSLInformation;
...@@ -235,7 +239,7 @@ extern volatile sSimplLinkInformation tSLInformation; ...@@ -235,7 +239,7 @@ extern volatile sSimplLinkInformation tSLInformation;
// //
//***************************************************************************** //*****************************************************************************
extern void SimpleLinkWaitEvent(unsigned short usOpcode, void *pRetParams); extern void SimpleLinkWaitEvent(UINT16 usOpcode, void *pRetParams);
//***************************************************************************** //*****************************************************************************
// //
...@@ -248,12 +252,12 @@ extern void SimpleLinkWaitEvent(unsigned short usOpcode, void *pRetParams); ...@@ -248,12 +252,12 @@ extern void SimpleLinkWaitEvent(unsigned short usOpcode, void *pRetParams);
//! @return none //! @return none
//! //!
//! @brief Wait for data, pass it to the hci_event_handler //! @brief Wait for data, pass it to the hci_event_handler
//! and update in a global variable that there is //! and update in a global variable that there is
//! data to read. //! data to read.
// //
//***************************************************************************** //*****************************************************************************
extern void SimpleLinkWaitData(unsigned char *pBuf, unsigned char *from, unsigned char *fromlen); extern void SimpleLinkWaitData(UINT8 *pBuf, UINT8 *from, UINT8 *fromlen);
//***************************************************************************** //*****************************************************************************
// //
...@@ -269,7 +273,7 @@ extern void SimpleLinkWaitData(unsigned char *pBuf, unsigned char *from, unsigne ...@@ -269,7 +273,7 @@ extern void SimpleLinkWaitData(unsigned char *pBuf, unsigned char *from, unsigne
// //
//***************************************************************************** //*****************************************************************************
extern unsigned char* UINT32_TO_STREAM_f (unsigned char *p, unsigned long u32); extern UINT8* UINT32_TO_STREAM_f (UINT8 *p, UINT32 u32);
//***************************************************************************** //*****************************************************************************
// //
...@@ -280,12 +284,12 @@ extern unsigned char* UINT32_TO_STREAM_f (unsigned char *p, unsigned long u32); ...@@ -280,12 +284,12 @@ extern unsigned char* UINT32_TO_STREAM_f (unsigned char *p, unsigned long u32);
//! //!
//! \return pointer to the new stream //! \return pointer to the new stream
//! //!
//! \brief This function is used for copying 16 bit to stream //! \brief This function is used for copying 16 bit to stream
//! while converting to little endian format. //! while converting to little endian format.
// //
//***************************************************************************** //*****************************************************************************
extern unsigned char* UINT16_TO_STREAM_f (unsigned char *p, unsigned short u16); extern UINT8* UINT16_TO_STREAM_f (UINT8 *p, UINT16 u16);
//***************************************************************************** //*****************************************************************************
// //
...@@ -296,12 +300,12 @@ extern unsigned char* UINT16_TO_STREAM_f (unsigned char *p, unsigned short u16); ...@@ -296,12 +300,12 @@ extern unsigned char* UINT16_TO_STREAM_f (unsigned char *p, unsigned short u16);
//! //!
//! \return pointer to the new 16 bit //! \return pointer to the new 16 bit
//! //!
//! \brief This function is used for copying received stream to //! \brief This function is used for copying received stream to
//! 16 bit in little endian format. //! 16 bit in little endian format.
// //
//***************************************************************************** //*****************************************************************************
extern unsigned short STREAM_TO_UINT16_f(char* p, unsigned short offset); extern UINT16 STREAM_TO_UINT16_f(CHAR* p, UINT16 offset);
//***************************************************************************** //*****************************************************************************
// //
...@@ -317,21 +321,7 @@ extern unsigned short STREAM_TO_UINT16_f(char* p, unsigned short offset); ...@@ -317,21 +321,7 @@ extern unsigned short STREAM_TO_UINT16_f(char* p, unsigned short offset);
// //
//***************************************************************************** //*****************************************************************************
extern unsigned long STREAM_TO_UINT32_f(char* p, unsigned short offset); extern UINT32 STREAM_TO_UINT32_f(CHAR* p, UINT16 offset);
//*****************************************************************************
//
//! cc3k_int_poll
//!
//! \brief checks if the interrupt pin is low
//! just in case the hardware missed a falling edge
//! function is in ccspi.cpp
//
//*****************************************************************************
extern void cc3k_int_poll();
//***************************************************************************** //*****************************************************************************
...@@ -346,14 +336,14 @@ extern void cc3k_int_poll(); ...@@ -346,14 +336,14 @@ extern void cc3k_int_poll();
//This macro is used for copying 32 bit to stream while converting to little endian format. //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)) #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. //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];} #define ARRAY_TO_STREAM(p, a, l) {register INT16 _i; for (_i = 0; _i < l; _i++) *(p)++ = ((UINT8 *) a)[_i];}
//This macro is used for copying received stream to 8 bit in little endian format. //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));} #define STREAM_TO_UINT8(_p, _offset, _u8) {_u8 = (UINT8)(*(_p + _offset));}
//This macro is used for copying received stream to 16 bit in little endian format. //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);} #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. //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_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];} #define STREAM_TO_STREAM(p, a, l) {register INT16 _i; for (_i = 0; _i < l; _i++) *(a)++= ((UINT8 *) p)[_i];}
......
...@@ -3,14 +3,6 @@ ...@@ -3,14 +3,6 @@
* spi.h - CC3000 Host Driver Implementation. * spi.h - CC3000 Host Driver Implementation.
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* *
* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend)
* & Limor Fried for Adafruit Industries
* This library works with the Adafruit CC3000 breakout
* ----> https://www.adafruit.com/products/1469
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
...@@ -20,23 +12,23 @@ ...@@ -20,23 +12,23 @@
* *
* Redistributions in binary form must reproduce the above copyright * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * 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. * distribution.
* *
* Neither the name of Texas Instruments Incorporated nor the names of * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived * its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission. * from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
*****************************************************************************/ *****************************************************************************/
...@@ -45,15 +37,18 @@ ...@@ -45,15 +37,18 @@
#ifndef __SPI_H__ #ifndef __SPI_H__
#define __SPI_H__ #define __SPI_H__
//#include <string.h> //*****************************************************************************
//#include <stdlib.h> //
//#include <stdio.h> // If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//#include "wlan.h" //
//*****************************************************************************
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*gcSpiHandleRx)(void *p); typedef void (*gcSpiHandleRx)(void *p);
typedef void (*gcSpiHandleTx)(void); typedef void (*gcSpiHandleTx)(void);
extern unsigned char wlan_tx_buffer[]; extern unsigned char wlan_tx_buffer[];
//***************************************************************************** //*****************************************************************************
...@@ -61,23 +56,30 @@ extern unsigned char wlan_tx_buffer[]; ...@@ -61,23 +56,30 @@ extern unsigned char wlan_tx_buffer[];
// Prototypes for the APIs. // Prototypes for the APIs.
// //
//***************************************************************************** //*****************************************************************************
extern void SpiInit(void);
// the arguments must be of type pin_obj_t* and SPI_HandleTypeDef*
extern void SpiInit(void *spi, const void *pin_cs, const void *pin_en, const void *pin_irq);
extern void SpiOpen(gcSpiHandleRx pfRxHandler); extern void SpiOpen(gcSpiHandleRx pfRxHandler);
extern void SpiClose(void); extern void SpiClose(void);
extern void SpiPauseSpi(void);
extern void SpiResumeSpi(void);
extern long SpiWrite(unsigned char *pUserBuffer, unsigned short usLength); extern long SpiWrite(unsigned char *pUserBuffer, unsigned short usLength);
extern void SpiResumeSpi(void); extern void SpiResumeSpi(void);
extern void SpiConfigureHwMapping(void);
extern void SpiCleanGPIOISR(void); extern void SpiCleanGPIOISR(void);
extern long TXBufferIsEmpty(void); extern void SSIConfigure(unsigned long ulSSIFreq, unsigned long bForceGpioConfiguration, unsigned long uiReconfigureSysClock);
extern long RXBufferIsEmpty(void); extern int init_spi(void);
extern void CC3000_UsynchCallback(long lEventType, char * data, unsigned char length);
extern void WriteWlanPin( unsigned char val );
extern long ReadWlanInterruptPin(void); extern long ReadWlanInterruptPin(void);
extern void WlanInterruptEnable(); extern void WriteWlanPin(unsigned char val);
extern void WlanInterruptDisable(); //*****************************************************************************
extern char *sendDriverPatch(unsigned long *Length); //
extern char *sendBootLoaderPatch(unsigned long *Length); // Mark the end of the C bindings section for C++ compilers.
extern char *sendWLFWPatch(unsigned long *Length); //
extern void SpiIntGPIOHandler(void); //*****************************************************************************
#ifdef __cplusplus
}