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

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

parent 55a5b807
......@@ -35,9 +35,13 @@
#ifndef __COMMON_H__
#define __COMMON_H__
#include "data_types.h"
//******************************************************************************
// Include files
//******************************************************************************
#include <stdlib.h>
#include <stdint.h>
//*****************************************************************************
//
......@@ -49,6 +53,8 @@
extern "C" {
#endif
extern int errno;
//*****************************************************************************
// ERROR CODES
//*****************************************************************************
......@@ -68,8 +74,6 @@ extern "C" {
#define SP_PORTION_SIZE (32)
// #define CC3000_TINY_DRIVER
/*Defines for minimal and maximal RX buffer size. This size includes the spi
header and hci header.
The maximal buffer size derives from:
......@@ -143,8 +147,8 @@ extern "C" {
#ifndef CC3000_TINY_DRIVER
#define CC3000_RX_BUFFER_SIZE (CC3000_MINIMAL_RX_SIZE)
#define CC3000_TX_BUFFER_SIZE (CC3000_MINIMAL_TX_SIZE)
#define CC3000_RX_BUFFER_SIZE (CC3000_MAXIMAL_RX_SIZE)
#define CC3000_TX_BUFFER_SIZE (CC3000_MAXIMAL_TX_SIZE)
//if defined TINY DRIVER we use smaller RX and TX buffer in order to minimize RAM consumption
#else
......@@ -156,9 +160,9 @@ extern "C" {
//*****************************************************************************
// Compound Types
//*****************************************************************************
typedef long time_t;
typedef unsigned long clock_t;
typedef long suseconds_t;
typedef INT32 time_t;
typedef UINT32 clock_t;
typedef INT32 suseconds_t;
typedef struct timeval timeval;
......@@ -168,28 +172,28 @@ struct timeval
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 (*tWlanInterruptDisable)(void);
typedef void (*tWriteWlanPin)(unsigned char val);
typedef void (*tWriteWlanPin)(UINT8 val);
typedef struct
{
unsigned short usRxEventOpcode;
unsigned short usEventOrDataReceived;
unsigned char *pucReceivedData;
unsigned char *pucTxCommandBuffer;
UINT16 usRxEventOpcode;
UINT16 usEventOrDataReceived;
UINT8 *pucReceivedData;
UINT8 *pucTxCommandBuffer;
tFWPatches sFWPatches;
tDriverPatches sDriverPatches;
......@@ -200,16 +204,16 @@ typedef struct
tWlanInterruptDisable WlanInterruptDisable;
tWriteWlanPin WriteWlanPin;
signed long slTransmitDataError;
unsigned short usNumberOfFreeBuffers;
unsigned short usSlBufferLength;
unsigned short usBufferSize;
unsigned short usRxDataPending;
INT32 slTransmitDataError;
UINT16 usNumberOfFreeBuffers;
UINT16 usSlBufferLength;
UINT16 usBufferSize;
UINT16 usRxDataPending;
unsigned long NumberOfSentPackets;
unsigned long NumberOfReleasedPackets;
UINT32 NumberOfSentPackets;
UINT32 NumberOfReleasedPackets;
unsigned char InformHostOnTxComplete;
UINT8 InformHostOnTxComplete;
}sSimplLinkInformation;
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);
//*****************************************************************************
//
......@@ -253,7 +257,7 @@ extern void SimpleLinkWaitEvent(unsigned short usOpcode, void *pRetParams);
//
//*****************************************************************************
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
//
//*****************************************************************************
extern unsigned char* UINT32_TO_STREAM_f (unsigned char *p, unsigned long u32);
extern UINT8* UINT32_TO_STREAM_f (UINT8 *p, UINT32 u32);
//*****************************************************************************
//
......@@ -285,7 +289,7 @@ extern unsigned char* UINT32_TO_STREAM_f (unsigned char *p, unsigned long u32);
//
//*****************************************************************************
extern unsigned char* UINT16_TO_STREAM_f (unsigned char *p, unsigned short u16);
extern UINT8* UINT16_TO_STREAM_f (UINT8 *p, UINT16 u16);
//*****************************************************************************
//
......@@ -301,7 +305,7 @@ extern unsigned char* UINT16_TO_STREAM_f (unsigned char *p, unsigned short u16);
//
//*****************************************************************************
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);
//
//*****************************************************************************
extern unsigned long STREAM_TO_UINT32_f(char* p, unsigned short 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();
extern UINT32 STREAM_TO_UINT32_f(CHAR* p, UINT16 offset);
//*****************************************************************************
......@@ -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.
#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];}
#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.
#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.
#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];}
#define STREAM_TO_STREAM(p, a, l) {register INT16 _i; for (_i = 0; _i < l; _i++) *(a)++= ((UINT8 *) p)[_i];}
......
......@@ -3,14 +3,6 @@
* spi.h - CC3000 Host Driver Implementation.
* 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
* modification, are permitted provided that the following conditions
* are met:
......@@ -45,15 +37,18 @@
#ifndef __SPI_H__
#define __SPI_H__
//#include <string.h>
//#include <stdlib.h>
//#include <stdio.h>
//#include "wlan.h"
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*gcSpiHandleRx)(void *p);
typedef void (*gcSpiHandleTx)(void);
extern unsigned char wlan_tx_buffer[];
//*****************************************************************************
......@@ -61,23 +56,30 @@ extern unsigned char wlan_tx_buffer[];
// 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 SpiClose(void);
extern void SpiPauseSpi(void);
extern void SpiResumeSpi(void);
extern long SpiWrite(unsigned char *pUserBuffer, unsigned short usLength);
extern void SpiResumeSpi(void);
extern void SpiConfigureHwMapping(void);
extern void SpiCleanGPIOISR(void);
extern long TXBufferIsEmpty(void);
extern long RXBufferIsEmpty(void);
extern void CC3000_UsynchCallback(long lEventType, char * data, unsigned char length);
extern void WriteWlanPin( unsigned char val );
extern void SSIConfigure(unsigned long ulSSIFreq, unsigned long bForceGpioConfiguration, unsigned long uiReconfigureSysClock);
extern int init_spi(void);
extern long ReadWlanInterruptPin(void);
extern void WlanInterruptEnable();
extern void WlanInterruptDisable();
extern char *sendDriverPatch(unsigned long *Length);
extern char *sendBootLoaderPatch(unsigned long *Length);
extern char *sendWLFWPatch(unsigned long *Length);
extern void SpiIntGPIOHandler(void);
extern void WriteWlanPin(unsigned char val);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif // __cplusplus
#endif
/*****************************************************************************
*
* data_types.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 __DATA_TYPES__
#define __DATA_TYPES__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C" {
#endif
#ifndef NULL
#define NULL (0)
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
#ifndef OK
#define OK (0)
#endif
#ifndef _INT8
#define _INT8
typedef signed char INT8;
#endif
#ifndef _UINT8
#define _UINT8
typedef unsigned char UINT8;
#endif
#ifndef _INT16
#define _INT16
typedef signed short INT16;
#endif
#ifndef _UINT16
#define _UINT16
typedef unsigned short UINT16;
#endif
#ifndef _BOOLEAN
#define _BOOLEAN
typedef unsigned char BOOLEAN;
#endif
#ifndef _INT32
#define _INT32
typedef signed long INT32;
#endif
#ifndef _UINT32
#define _UINT32
typedef unsigned long UINT32;
#endif
typedef int INT;
typedef char CHAR;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __DATA_TYPE__ */
......@@ -67,7 +67,7 @@ extern "C" {
//! event handler from global array of handlers pointers
//
//*****************************************************************************
extern unsigned char *hci_event_handler(void *pRetParams, unsigned char *from, unsigned char *fromlen);
extern UINT8 *hci_event_handler(void *pRetParams, UINT8 *from, UINT8 *fromlen);
//*****************************************************************************
//
......@@ -81,7 +81,7 @@ extern unsigned char *hci_event_handler(void *pRetParams, unsigned char *from, u
//! @brief Handle unsolicited events
//
//*****************************************************************************
extern long hci_unsol_event_handler(char *event_hdr);
extern INT32 hci_unsol_event_handler(CHAR *event_hdr);
//*****************************************************************************
//
......@@ -95,9 +95,9 @@ extern long hci_unsol_event_handler(char *event_hdr);
//! corresponding event handler.
//
//*****************************************************************************
extern long hci_unsolicited_event_handler(void);
extern INT32 hci_unsolicited_event_handler(void);
#define M_BSD_RESP_PARAMS_OFFSET(hci_event_hdr)((char *)(hci_event_hdr) + HCI_EVENT_HEADER_SIZE)
#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
......@@ -107,15 +107,15 @@ extern long hci_unsolicited_event_handler(void);
#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 UINT32 socket_active_status;
extern void set_socket_active_status(long Sd, long Status);
extern long get_socket_active_status(long Sd);
extern void set_socket_active_status(INT32 Sd, INT32 Status);
extern INT32 get_socket_active_status(INT32 Sd);
typedef struct _bsd_accept_return_t
{
long iSocketDescriptor;
long iStatus;
INT32 iSocketDescriptor;
INT32 iStatus;
sockaddr tSocketAddress;
} tBsdReturnParams;
......@@ -123,9 +123,9 @@ typedef struct _bsd_accept_return_t
typedef struct _bsd_read_return_t
{
long iSocketDescriptor;
long iNumberOfBytes;
unsigned long uiFlags;
INT32 iSocketDescriptor;
INT32 iNumberOfBytes;
UINT32 uiFlags;
} tBsdReadReturnParams;
#define BSD_RECV_FROM_FROMLEN_OFFSET (4)
......@@ -134,23 +134,23 @@ typedef struct _bsd_read_return_t
typedef struct _bsd_select_return_t
{
long iStatus;
unsigned long uiRdfd;
unsigned long uiWrfd;
unsigned long uiExfd;
INT32 iStatus;
UINT32 uiRdfd;
UINT32 uiWrfd;
UINT32 uiExfd;
} tBsdSelectRecvParams;
typedef struct _bsd_getsockopt_return_t
{
unsigned char ucOptValue[4];
char iStatus;
UINT8 ucOptValue[4];
CHAR iStatus;
} tBsdGetSockOptReturnParams;
typedef struct _bsd_gethostbyname_return_t
{
long retVal;
long outputAddress;
INT32 retVal;
INT32 outputAddress;
} tBsdGethostbynameParams;
//*****************************************************************************
......
......@@ -102,6 +102,7 @@ extern "C" {
#define HCI_CMND_RECVFROM 0x100D
#define HCI_CMND_GETHOSTNAME 0x1010
#define HCI_CMND_MDNS_ADVERTISE 0x1011
#define HCI_CMND_GETMSSVALUE 0x1012
#define HCI_DATA_BASE 0x80
......@@ -167,6 +168,7 @@ extern "C" {
#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_GETMSSVALUE HCI_CMND_GETMSSVALUE
#define HCI_EVNT_SEND 0x1003
#define HCI_EVNT_WRITE 0x100E
......@@ -253,9 +255,9 @@ extern "C" {
//! @brief Initiate an HCI command.
//
//*****************************************************************************
extern unsigned short hci_command_send(unsigned short usOpcode,
unsigned char *ucArgs,
unsigned char ucArgsLength);
extern UINT16 hci_command_send(UINT16 usOpcode,
UINT8 *ucArgs,
UINT8 ucArgsLength);
//*****************************************************************************
......@@ -273,12 +275,12 @@ extern unsigned short hci_command_send(unsigned short usOpcode,
//! @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);
extern INT32 hci_data_send(UINT8 ucOpcode,
UINT8 *ucArgs,
UINT16 usArgsLength,
UINT16 usDataLength,
const UINT8 *ucTail,
UINT16 usTailLength);
//*****************************************************************************
......@@ -295,8 +297,8 @@ extern long hci_data_send(unsigned char ucOpcode,
//! @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);
extern void hci_data_command_send(UINT16 usOpcode, UINT8 *pucBuff,
UINT8 ucArgsLength, UINT16 ucDataLength);
//*****************************************************************************
//
......@@ -312,7 +314,7 @@ extern void hci_data_command_send(unsigned short usOpcode, unsigned char *pucBuf
//! @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);
extern void hci_patch_send(UINT8 ucOpcode, UINT8 *pucBuff, CHAR *patch, UINT16 usDataLength);
......
......@@ -35,7 +35,7 @@
#ifndef __HOST_DRIVER_VERSION_H__
#define __HOST_DRIVER_VERSION_H__
#define DRIVER_VERSION_NUMBER 14
#define DRIVER_VERSION_NUMBER 15
......
#ifndef __INET_NTOP_H
#define __INET_NTOP_H
char *inet_ntop(int af, const void *addr, char *buf, size_t size);
#endif /* __INET_NTOP_H */
#ifndef __INET_PTON_H
#define __INET_PTON_H
int inet_pton(int, const char *, void *);
#endif /* __INET_PTON_H */
......@@ -35,6 +35,7 @@
#ifndef __NETAPP_H__
#define __NETAPP_H__
#include "data_types.h"
//*****************************************************************************
//
......@@ -55,33 +56,33 @@ extern "C" {
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];
UINT8 aucIP[4];
UINT8 aucSubnetMask[4];
UINT8 aucDefaultGateway[4];
UINT8 aucDHCPServer[4];
UINT8 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];
UINT8 aucIP[4];
UINT8 aucSubnetMask[4];
UINT8 aucDefaultGateway[4];
UINT8 aucDHCPServer[4];
UINT8 aucDNSServer[4];
UINT8 uaMacAddr[6];
UINT8 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;