Numerous updates to the CC3000 driver from David Sidrane

This commit is contained in:
Gregory Nutt 2014-02-18 14:16:51 -06:00
parent c5fe9fb425
commit 6092b5813a
14 changed files with 263 additions and 95 deletions

View File

@ -6594,4 +6594,13 @@
David Alession (2014-2-18)
* stm32f429i-disco/src: Files renamed to make more consistent
with current board file naming conventions (2014-2-18).
* stm32 SPI: Disable SPI before changing CR1 register. From David
Sidrane (2014-2-18).
* stm32 TIM: Set CCMR when selecting timer channerl. From David
Sidrane (2014-2-18).
* configs/spark: Board configuration updated by David Sidrane
(2014-2-19).
* libc/stdio/lib_sscanf.c: Bug fixes from David Sidrane (2014-2-18).
* nuttx/drivers/wireless/cc3000 and nuttx/include/nuttx/wireless/cc3000:
Numerous updates to the CC3000 driver from David Sidrane (2014-2-18).

View File

@ -1,7 +1,7 @@
/****************************************************************************
* drivers/wireless/cc3000.c
*
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* David_s5 <david_s5@nscdg.com>
*
@ -80,11 +80,13 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#if CC3000_RX_BUFFER_SIZE > CONFIG_MQ_MAXMSGSIZE
#error "CONFIG_MQ_MAXMSGSIZE needs to be >= CC3000_RX_BUFFER_SIZE"
#ifndef CCASSERT
#define CCASSERT(predicate) _x_CCASSERT_LINE(predicate, __LINE__)
#define _x_CCASSERT_LINE(predicate, line) typedef char constraint_violated_on_line_##line[2*((predicate)!=0)-1];
#endif
CCASSERT(sizeof(cc3000_buffer_desc) <= CONFIG_MQ_MAXMSGSIZE);
#ifndef CONFIG_CC3000_WORKER_THREAD_PRIORITY
# define CONFIG_CC3000_WORKER_THREAD_PRIORITY (SCHED_PRIORITY_MAX)
#endif
@ -94,7 +96,7 @@
#endif
#ifndef CONFIG_CC3000_SELECT_THREAD_PRIORITY
# define CONFIG_CC3000_SELECT_THREAD_PRIORITY (SCHED_PRIORITY_DEFAULT+10)
# define CONFIG_CC3000_SELECT_THREAD_PRIORITY (SCHED_PRIORITY_DEFAULT-1)
#endif
#ifndef CONFIG_CC3000_SELECT_STACKSIZE
@ -107,6 +109,7 @@
#define NUMBER_OF_MSGS 1
#define FREE_SLOT -1
#define CLOSE_SLOT -2
#if defined(CONFIG_CC3000_PROBES)
# define CC3000_GUARD (0xc35aa53c)
@ -119,6 +122,8 @@
# define PROBE(pin,state)
#endif
#define waitlldbg(x,...)
/****************************************************************************
* Private Types
****************************************************************************/
@ -265,7 +270,7 @@ static void usdelay(long ustimeout)
static inline void cc3000_configspi(FAR struct spi_dev_s *spi)
{
idbg("Mode: %d Bits: 8 Frequency: %d\n",
ndbg("Mode: %d Bits: 8 Frequency: %d\n",
CONFIG_CC3000_SPIMODE, CONFIG_CC3000_SPI_FREQUENCY);
SPI_SETMODE(spi, CONFIG_CC3000_SPIMODE);
@ -498,7 +503,7 @@ static void * select_thread_func(FAR void *arg)
memset(&timeout, 0, sizeof(struct timeval));
timeout.tv_sec = 0;
timeout.tv_usec = (100); /* .1 msecs */
timeout.tv_usec = (500000); /* 500 msecs */
while (1)
{
@ -518,6 +523,27 @@ static void * select_thread_func(FAR void *arg)
{
if (priv->sockets[s].sd != FREE_SLOT)
{
if (priv->sockets[s].sd == CLOSE_SLOT)
{
priv->sockets[s].sd = FREE_SLOT;
waitlldbg("Close\n");
int count;
do
{
sem_getvalue(&priv->sockets[s].semwait, &count);
if (count < 0)
{
/* Release the waiting threads */
waitlldbg("Closed Signaled %d\n",count);
sem_post(&priv->sockets[s].semwait);
}
}
while (count < 0);
continue;
}
CC3000_FD_SET(priv->sockets[s].sd, &readsds);
if (maxFD <= priv->sockets[s].sd)
{
@ -542,10 +568,12 @@ static void * select_thread_func(FAR void *arg)
{
for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++)
{
if (priv->sockets[s].sd != FREE_SLOT && /* Check that the socket is valid */
priv->sockets[s].sd != priv->accepting_socket.acc.sd && /* Verify this is not an accept socket */
CC3000_FD_ISSET(priv->sockets[s].sd, &readsds)) /* and has pending data */
if ((priv->sockets[s].sd != FREE_SLOT ||
priv->sockets[s].sd != CLOSE_SLOT) && /* Check that the socket is valid */
priv->sockets[s].sd != priv->accepting_socket.acc.sd && /* Verify this is not an accept socket */
CC3000_FD_ISSET(priv->sockets[s].sd, &readsds)) /* and has pending data */
{
waitlldbg("Signaled %d\n",priv->sockets[s].sd);
sem_post(&priv->sockets[s].semwait); /* release the waiting thread */
}
}
@ -553,9 +581,16 @@ static void * select_thread_func(FAR void *arg)
if (priv->accepting_socket.acc.sd != FREE_SLOT) /* If accept polling in needed */
{
ret = cc3000_do_accept(priv->accepting_socket.acc.sd, /* Send the select command on non blocking */
&priv->accepting_socket.addr, /* Set up in ioctl */
&priv->accepting_socket.addrlen);
if (priv->accepting_socket.acc.sd == CLOSE_SLOT)
{
ret = CC3000_SOC_ERROR;
}
else
{
ret = cc3000_do_accept(priv->accepting_socket.acc.sd, /* Send the select command on non blocking */
&priv->accepting_socket.addr, /* Set up in ioctl */
&priv->accepting_socket.addrlen);
}
if (ret != CC3000_SOC_IN_PROGRESS) /* Not waiting => error or accepted */
{
@ -607,12 +642,14 @@ static void * cc3000_worker(FAR void *arg)
{
case eSPI_STATE_POWERUP:
/* Signal the device has interrupted after power up */
priv->state = eSPI_STATE_INITIALIZED;
sem_post(&priv->readysem);
break;
case eSPI_STATE_WRITE_WAIT_IRQ:
/* Signal the device has interrupted after Chip Select During a write operation */
priv->state = eSPI_STATE_WRITE_PROCEED;
sem_post(&priv->readysem);
break;
@ -627,11 +664,11 @@ static void * cc3000_worker(FAR void *arg)
cc3000_lock_and_select(priv->spi); /* Assert CS */
priv->state = eSPI_STATE_READ_PROCEED;
SPI_EXCHANGE(priv->spi,spi_readCommand,priv->rx_buffer, ARRAY_SIZE(spi_readCommand));
SPI_EXCHANGE(priv->spi,spi_readCommand,priv->rx_buffer.pbuffer, ARRAY_SIZE(spi_readCommand));
/* Extract Length bytes from Rx Buffer */
uint16_t *pnetlen = (uint16_t *) &priv->rx_buffer[READ_OFFSET_TO_LENGTH];
uint16_t *pnetlen = (uint16_t *) &priv->rx_buffer.pbuffer[READ_OFFSET_TO_LENGTH];
data_to_recv = ntohs(*pnetlen);
if (data_to_recv)
@ -649,8 +686,11 @@ static void * cc3000_worker(FAR void *arg)
* Will it fit?
*/
DEBUGASSERT(data_to_recv < ARRAY_SIZE(priv->rx_buffer));
SPI_RECVBLOCK(priv->spi, priv->rx_buffer, data_to_recv);
if (data_to_recv >= priv->rx_buffer_max_len){
lowsyslog("data_to_recv %d",data_to_recv);
}
DEBUGASSERT(data_to_recv < priv->rx_buffer_max_len);
SPI_RECVBLOCK(priv->spi, priv->rx_buffer.pbuffer, data_to_recv);
}
cc3000_deselect_and_unlock(priv->spi); /* De assert CS */
@ -662,9 +702,9 @@ static void * cc3000_worker(FAR void *arg)
int count;
priv->state = eSPI_STATE_READ_READY;
priv->rx_buffer_len = data_to_recv;
priv->rx_buffer.len = data_to_recv;
ret = mq_send(priv->queue, priv->rx_buffer, data_to_recv, 1);
ret = mq_send(priv->queue, &priv->rx_buffer, sizeof(priv->rx_buffer), 1);
DEBUGASSERT(ret>=0);
/* Notify any waiters that new CC3000 data is available */
@ -793,7 +833,7 @@ static int cc3000_open(FAR struct file *filep)
priv->config->power_enable(priv->config, false);
attr.mq_maxmsg = NUMBER_OF_MSGS;
attr.mq_msgsize = CC3000_RX_BUFFER_SIZE;
attr.mq_msgsize = sizeof(cc3000_buffer_desc);
attr.mq_flags = 0;
/* Set the flags for the open of the queue.
@ -848,6 +888,17 @@ static int cc3000_open(FAR struct file *filep)
goto errout_with_sem;
}
/* Do late allocation with hopes of realloc not fragmenting */
priv->rx_buffer.pbuffer = kmalloc(priv->rx_buffer_max_len);
DEBUGASSERT(priv->rx_buffer.pbuffer);
if (!priv->rx_buffer.pbuffer)
{
priv->crefs--;
ret = -errno;
goto errout_with_sem;
}
priv->state = eSPI_STATE_POWERUP;
priv->config->irq_clear(priv->config);
@ -927,6 +978,10 @@ static int cc3000_close(FAR struct file *filep)
mq_close(priv->queue);
priv->queue = 0;
kfree(priv->rx_buffer.pbuffer);
priv->rx_buffer.pbuffer = 0;
}
cc3000_devgive(priv);
@ -953,17 +1008,6 @@ static ssize_t cc3000_read(FAR struct file *filep, FAR char *buffer, size_t len)
CHECK_GUARD(priv);
/* Verify that the caller has provided a buffer large enough to receive
* the maximum data.
*/
if (len < CC3000_RX_BUFFER_SIZE)
{
idbg("Unsupported read size: %d\n", len);
nread = -ENOSYS;
goto errout_without_sem;
}
/* Get exclusive access to the driver data structure */
ret = cc3000_devtake(priv);
@ -974,7 +1018,19 @@ static ssize_t cc3000_read(FAR struct file *filep, FAR char *buffer, size_t len)
goto errout_without_sem;
}
for (nread = priv->rx_buffer_len; nread == 0; nread = priv->rx_buffer_len)
/* Verify that the caller has provided a buffer large enough to receive
* the maximum data.
*/
if (len < priv->rx_buffer_max_len)
{
ndbg("Unsupported read size: %d\n", len);
nread = -ENOSYS;
goto errout_with_sem;
}
for (nread = priv->rx_buffer.len; nread == 0; nread = priv->rx_buffer.len)
{
if (nread > 0)
{
@ -1055,10 +1111,11 @@ static ssize_t cc3000_read(FAR struct file *filep, FAR char *buffer, size_t len)
if (nread > 0)
{
memcpy(buffer,priv->rx_buffer,priv->rx_buffer_len);
priv->rx_buffer_len = 0;
memcpy(buffer,priv->rx_buffer.pbuffer,priv->rx_buffer.len);
priv->rx_buffer.len = 0;
}
errout_with_sem:
cc3000_devgive(priv);
errout_without_sem:
@ -1082,12 +1139,13 @@ errout_without_sem:
*
****************************************************************************/
static ssize_t cc3000_write(FAR struct file *filep, FAR const char *buffer, size_t len)
static ssize_t cc3000_write(FAR struct file *filep, FAR const char *usrbuffer, size_t len)
{
FAR struct inode *inode;
FAR struct cc3000_dev_s *priv;
int ret;
FAR char *buffer = (FAR char *) usrbuffer;
ssize_t nwritten = 0;
int ret;
/* Set the padding if count(buffer) is even ( as it will be come odd with header) */
@ -1110,20 +1168,18 @@ static ssize_t cc3000_write(FAR struct file *filep, FAR const char *buffer, size
{
/* This should only happen if the wait was canceled by an signal */
idbg("sem_wait: %d\n", errno);
ndbg("sem_wait: %d\n", errno);
nwritten = -errno;
goto errout_without_sem;
}
/* Figure out the total length of the packet in order to figure out if there is padding or not */
priv->tx_buffer[0] = WRITE;
priv->tx_buffer[1] = HI(tx_len);
priv->tx_buffer[2] = LO(tx_len);
priv->tx_buffer[3] = 0;
priv->tx_buffer[4] = 0;
memcpy(&priv->tx_buffer[SPI_HEADER_SIZE],&buffer[SPI_HEADER_SIZE],tx_len);
buffer[0] = WRITE;
buffer[1] = HI(tx_len);
buffer[2] = LO(tx_len);
buffer[3] = 0;
buffer[4] = 0;
tx_len += SPI_HEADER_SIZE;
/* The first write transaction to occur after release of the shutdown has
@ -1162,9 +1218,9 @@ static ssize_t cc3000_write(FAR struct file *filep, FAR const char *buffer, size
{
cc3000_lock_and_select(priv->spi); /* Assert CS */
usdelay(55);
SPI_SNDBLOCK(priv->spi, priv->tx_buffer, 4);
SPI_SNDBLOCK(priv->spi, buffer, 4);
usdelay(55);
SPI_SNDBLOCK(priv->spi, priv->tx_buffer+4, tx_len-4);
SPI_SNDBLOCK(priv->spi, buffer+4, tx_len-4);
}
else
{
@ -1185,7 +1241,7 @@ static ssize_t cc3000_write(FAR struct file *filep, FAR const char *buffer, size
goto errout_without_sem;
}
SPI_SNDBLOCK(priv->spi, priv->tx_buffer, tx_len);
SPI_SNDBLOCK(priv->spi, buffer, tx_len);
}
priv->state = eSPI_STATE_WRITE_DONE;
@ -1273,6 +1329,23 @@ static int cc3000_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
break;
}
case CC3000IOC_SETRX_SIZE:
{
irqstate_t flags;
FAR int *psize = (FAR int *)(arg);
int rv;
DEBUGASSERT(psize != NULL);
rv = priv->rx_buffer_max_len;
flags = irqsave();
priv->rx_buffer_max_len = *psize;
priv->rx_buffer.pbuffer = krealloc(priv->rx_buffer.pbuffer,*psize);
irqrestore(flags);
DEBUGASSERT(priv->rx_buffer.pbuffer);
*psize = rv;
break;
}
default:
ret = -ENOTTY;
break;
@ -1427,7 +1500,7 @@ int cc3000_register(FAR struct spi_dev_s *spi,
priv = (FAR struct cc3000_dev_s *)kmalloc(sizeof(struct cc3000_dev_s));
if (!priv)
{
idbg("kmalloc(%d) failed\n", sizeof(struct cc3000_dev_s));
ndbg("kmalloc(%d) failed\n", sizeof(struct cc3000_dev_s));
return -ENOMEM;
}
#endif
@ -1440,6 +1513,8 @@ int cc3000_register(FAR struct spi_dev_s *spi,
priv->spi = spi; /* Save the SPI device handle */
priv->config = config; /* Save the board configuration */
priv->rx_buffer_max_len = config->max_rx_size;
sem_init(&priv->devsem, 0, 1); /* Initialize device structure semaphore */
sem_init(&priv->waitsem, 0, 0); /* Initialize event wait semaphore */
sem_init(&priv->irqsem, 0, 0); /* Initialize IRQ Ready semaphore */
@ -1469,7 +1544,7 @@ int cc3000_register(FAR struct spi_dev_s *spi,
ret = config->irq_attach(config, cc3000_interrupt);
if (ret < 0)
{
idbg("Failed to attach interrupt\n");
ndbg("Failed to attach interrupt\n");
goto errout_with_priv;
}
@ -1481,7 +1556,7 @@ int cc3000_register(FAR struct spi_dev_s *spi,
ret = register_driver(drvname, &cc3000_fops, 0666, priv);
if (ret < 0)
{
idbg("register_driver() failed: %d\n", ret);
ndbg("register_driver() failed: %d\n", ret);
goto errout_with_priv;
}
@ -1555,7 +1630,7 @@ static int cc3000_wait_data(FAR struct cc3000_dev_s *priv, int sockfd)
sem_wait(&priv->selectsem); /* Sleep select thread */
cc3000_devtake(priv);
sched_unlock();
break;
return priv->sockets[s].sd == sockfd ? OK : -1;
}
}
@ -1663,28 +1738,41 @@ static int cc3000_remove_socket(FAR struct cc3000_dev_s *priv, int sd)
{
irqstate_t flags;
int s;
sem_t *ps = 0;
if (sd < 0)
{
return sd;
}
flags = irqsave();
if (priv->accepting_socket.acc.sd == sd)
{
priv->accepting_socket.acc.sd = FREE_SLOT;
priv->accepting_socket.addrlen = 0;
}
flags = irqsave();
if (priv->accepting_socket.acc.sd == sd)
{
priv->accepting_socket.acc.sd = CLOSE_SLOT;
ps = &priv->accepting_socket.acc.semwait;
}
for (s = 0; s < CONFIG_WL_MAX_SOCKETS; s++)
{
if (priv->sockets[s].sd == sd)
{
priv->sockets[s].sd = FREE_SLOT;
priv->sockets[s].sd = CLOSE_SLOT;
ps = &priv->sockets[s].semwait;
break;
}
}
irqrestore(flags);
if (ps)
{
sched_lock();
cc3000_devgive(priv);
sem_post(&priv->selectsem); /* Wake select thread if need be */
sem_wait(ps);
sem_wait(&priv->selectsem); /* Sleep the Thread */
cc3000_devtake(priv);
sched_unlock();
}
return s >= CONFIG_WL_MAX_SOCKETS ? -1 : OK;
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
* drivers//wireless/cc3000.h
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* David Sidrane <david_s5@nscdg.com>
*
@ -97,7 +97,7 @@ extern pthread_mutex_t g_cc3000_mut;
typedef struct cc3000_socket_ent
{
int sd;
volatile int sd;
long status;
sem_t semwait;
} cc3000_socket_ent;
@ -142,11 +142,8 @@ struct cc3000_dev_s
FAR struct spi_dev_s *spi; /* Saved SPI driver instance */
mqd_t queue; /* For unsolicited data delivery */
eDeviceStates state; /* The device state */
uint8_t rx_buffer[CC3000_RX_BUFFER_SIZE];
ssize_t rx_buffer_len;
uint8_t tx_buffer[CC3000_TX_BUFFER_SIZE];
ssize_t tx_buffer_len;
cc3000_buffer_desc rx_buffer;
ssize_t rx_buffer_max_len;
/* The following is a list if socket structures of threads waiting
* long operations to finish;

View File

@ -87,7 +87,7 @@ static struct
gcSpiHandleRx pfRxHandler;
pthread_t unsoliced_thread;
bool run;
uint8_t rx_buffer[CC3000_RX_BUFFER_SIZE];
cc3000_buffer_desc rx_buffer;
mqd_t queue;
sem_t *done;
} spiconf;
@ -175,8 +175,8 @@ uint8_t *cc3000_wait(void)
{
DEBUGASSERT(spiconf.cc3000fd);
mq_receive(spiconf.queue, spiconf.rx_buffer, CC3000_RX_BUFFER_SIZE, 0);
return spiconf.rx_buffer;
mq_receive(spiconf.queue, &spiconf.rx_buffer, sizeof(spiconf.rx_buffer), 0);
return spiconf.rx_buffer.pbuffer;
}
/*****************************************************************************
@ -211,13 +211,13 @@ static void *unsoliced_thread_func(void *parameter)
while(spiconf.run)
{
memset(spiconf.rx_buffer,0,sizeof(spiconf.rx_buffer));
nbytes = mq_receive(spiconf.queue, spiconf.rx_buffer,
CC3000_RX_BUFFER_SIZE, 0);
memset(&spiconf.rx_buffer,0,sizeof(spiconf.rx_buffer));
nbytes = mq_receive(spiconf.queue, &spiconf.rx_buffer,
sizeof(spiconf.rx_buffer), 0);
if (nbytes > 0)
{
nlldbg("%d Processed\n",nbytes);
spiconf.pfRxHandler(spiconf.rx_buffer);
spiconf.pfRxHandler(spiconf.rx_buffer.pbuffer);
}
}

View File

@ -519,6 +519,11 @@ uint8_t *hci_event_handler(void *pRetParams, uint8_t *from, uint8_t *fromlen)
memcpy(pRetParams, pucReceivedParams + HCI_DATA_HEADER_SIZE + ucArgsize,
usLength - ucArgsize);
if (fromlen)
{
*fromlen = usLength - ucArgsize;
}
tSLInformation.usRxDataPending = 0;
}

View File

@ -113,7 +113,7 @@ signed long nvmem_read(unsigned long ulFileId, unsigned long ulLength,
* big enough to store also parameters of nvmem
*/
SimpleLinkWaitData(buff, 0, 0);
SimpleLinkWaitData(buff, 0, &ucStatus);
cc3000_lib_unlock();

View File

@ -61,6 +61,8 @@
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
#define waitlldbg(x,...) // lldbg
/****************************************************************************
* Private Types
****************************************************************************/
@ -187,11 +189,14 @@ int cc3000_closesocket(int sockfd)
{
int ret;
cc3000_lib_lock();
ret = cc3000_closesocket_impl(sockfd);
#ifdef CONFIG_CC3000_MT
waitlldbg("remove\n");
cc3000_remove_socket(sockfd);
#endif
cc3000_lib_lock();
waitlldbg("Call closesocketl\n");
ret = cc3000_closesocket_impl(sockfd);
waitlldbg("return closesocket\n");
cc3000_lib_unlock();
return ret;
}
@ -587,7 +592,9 @@ ssize_t cc3000_recv(int sockfd, FAR void *buf, size_t len, int flags)
ssize_t ret;
#ifdef CONFIG_CC3000_MT
waitlldbg("wait\n");
ret = cc3000_wait_data(sockfd);
waitlldbg("wait %d\n", ret);
if (ret != OK )
{
return -1;
@ -595,7 +602,9 @@ ssize_t cc3000_recv(int sockfd, FAR void *buf, size_t len, int flags)
#endif
cc3000_lib_lock();
waitlldbg("recv\n");
ret = cc3000_recv_impl(sockfd, buf, len, flags);
waitlldbg("recv %d\n", ret);
cc3000_lib_unlock();
return ret;
}

View File

@ -149,7 +149,10 @@ int HostFlowControlConsumeBuff(int sd)
* the buffers
*/
usleep(100000);
if (0 == tSLInformation.usNumberOfFreeBuffers)
{
usleep(100000);
}
}
while (0 == tSLInformation.usNumberOfFreeBuffers);

View File

@ -60,6 +60,11 @@
#define SMART_CONFIG_PROFILE_SIZE 67 /* 67 = 32 (max ssid) + 32 (max key) +
* 1 (SSID length) + 1 (security type) +
* 1 (key length) */
/* SOCKET_SELECT_PARAMS_LEN + SPI_HEADER_SIZE++SIMPLE_LINK_HCI_DATA_HEADER_SIZ */
#define MAX_HCI_CMD_LENGTH (44+SIMPLE_LINK_HCI_DATA_HEADER_SIZE+SPI_HEADER_SIZE)
/* Patches type */
#define PATCHES_HOST_TYPE_WLAN_DRIVER 0x01
@ -97,8 +102,6 @@
* Private Variables
****************************************************************************/
static uint8_t wlan_tx_buffer[CC3000_TX_BUFFER_SIZE];
/*****************************************************************************
* Public Data
*****************************************************************************/
@ -187,7 +190,9 @@ static void SimpleLink_Init_Start(uint16_t usPatchesAvailableAtHost)
*
*****************************************************************************/
void wlan_init(tWlanCB sWlanCB, tFWPatches sFWPatches,
void wlan_init(size_t max_tx_len,
tWlanCB sWlanCB,
tFWPatches sFWPatches,
tDriverPatches sDriverPatches,
tBootLoaderPatches sBootLoaderPatches)
{
@ -196,6 +201,13 @@ void wlan_init(tWlanCB sWlanCB, tFWPatches sFWPatches,
tSLInformation.sDriverPatches = sDriverPatches;
tSLInformation.sBootLoaderPatches = sBootLoaderPatches;
/* Allocate the memory for the RX/TX data transactions */
tSLInformation.pucTxCommandBuffer = malloc(max_tx_len);
tSLInformation.usrBuffer.pbuffer = &tSLInformation.pucTxCommandBuffer[MAX_HCI_CMD_LENGTH];
tSLInformation.usrBuffer.len = max_tx_len - MAX_HCI_CMD_LENGTH;
/* Init I/O callback */
/* Init asynchronous events callback */
@ -276,10 +288,6 @@ void wlan_start(uint16_t usPatchesAvailableAtHost)
tSLInformation.usEventOrDataReceived = 0;
tSLInformation.pucReceivedData = 0;
/* Allocate the memory for the RX/TX data transactions */
tSLInformation.pucTxCommandBuffer = (uint8_t *)wlan_tx_buffer;
/* Init spi */
cc3000_open(SpiReceiveHandler);
@ -293,6 +301,22 @@ void wlan_start(uint16_t usPatchesAvailableAtHost)
cc3000_lib_unlock();
}
/*****************************************************************************
* Name: wlan_get_buffer
*
* Input Parameters:
* pdes - Location to return the buffer pointer.
*
* Returned Value:
* None
*
*****************************************************************************/
void wlan_get_buffer(wlan_buffer_desc *pdes)
{
*pdes = tSLInformation.usrBuffer;
}
/*****************************************************************************
* Name: wlan_stop
*

View File

@ -49,6 +49,7 @@
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/wireless/wireless.h>
/****************************************************************************
@ -71,6 +72,7 @@
#define CC3000IOC_REMOVESOCKET _WLIOC_USER(0x0003) /* arg: Address of int for result*/
#define CC3000IOC_SELECTDATA _WLIOC_USER(0x0004) /* arg: Address of int for result*/
#define CC3000IOC_SELECTACCEPT _WLIOC_USER(0x0005) /* arg: Address of struct cc3000_acceptcfg_s */
#define CC3000IOC_SETRX_SIZE _WLIOC_USER(0x0006) /* arg: Address of int for new size */
/****************************************************************************
* Public Types
@ -81,6 +83,12 @@ typedef char *(*tDriverPatches)(unsigned long *usLength);
typedef char *(*tBootLoaderPatches)(unsigned long *usLength);
typedef void (*tWlanCB)(long event_type, char * data, unsigned char length);
typedef struct cc3000_buffer_desc_s
{
uint8_t *pbuffer;
ssize_t len;
} cc3000_buffer_desc;
typedef struct cc3000_acceptcfg_s
{
int sockfd;
@ -139,11 +147,14 @@ extern "C"
*
*****************************************************************************/
void wlan_init(tWlanCB sWlanCB, tFWPatches sFWPatches,
void wlan_init(size_t max_tx_len,
tWlanCB sWlanCB, tFWPatches sFWPatches,
tDriverPatches sDriverPatches,
tBootLoaderPatches sBootLoaderPatches);
void cc3000_wlan_init(tWlanCB sWlanCB, tFWPatches sFWPatches,
void cc3000_wlan_init(size_t max_tx_len,
tWlanCB sWlanCB,
tFWPatches sFWPatches,
tDriverPatches sDriverPatches,
tBootLoaderPatches sBootLoaderPatches);
@ -155,7 +166,7 @@ void cc3000_wlan_init(tWlanCB sWlanCB, tFWPatches sFWPatches,
*
************************************************************************************/
int wireless_archinitialize(void);
int wireless_archinitialize(size_t max_rx_size);
#undef EXTERN
#ifdef __cplusplus

View File

@ -143,9 +143,9 @@
*/
#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
*/
@ -203,6 +203,12 @@
* Public Types
*****************************************************************************/
typedef struct wlan_buffer_desc_s
{
uint8_t *pbuffer;
ssize_t len;
} wlan_buffer_desc;
typedef char *(*tFWPatches)(unsigned long *usLength);
typedef char *(*tDriverPatches)(unsigned long *usLength);
@ -225,6 +231,7 @@ typedef struct
uint16_t usEventOrDataReceived;
uint8_t *pucReceivedData;
uint8_t *pucTxCommandBuffer;
wlan_buffer_desc usrBuffer;
tFWPatches sFWPatches;
tDriverPatches sDriverPatches;
@ -258,6 +265,19 @@ extern volatile sSimplLinkInformation tSLInformation;
* Public Function Prototypes
*****************************************************************************/
/*****************************************************************************
* Name: wlan_get_buffer
*
* Input Parameters:
* pdes - Location to return the buffer pointer.
*
* Returned Value:
* None
*
*****************************************************************************/
void wlan_get_buffer(wlan_buffer_desc *pdes);
/*****************************************************************************
* Name: SimpleLinkWaitEvent
*

View File

@ -109,15 +109,16 @@ struct cc3000_config_s
{
/* Device characterization */
uint32_t spi_frequency; /* SPI frequency */
uint32_t spi_mode; /* SPI mode */
uint32_t spi_frequency; /* SPI frequency */
uint32_t spi_mode; /* SPI mode */
size_t max_rx_size; /* Size allocated by driver for rx buffer */
/* If multiple CC3000 devices are supported, then an IRQ number must
* be provided for each so that their interrupts can be distinguished.
*/
#ifndef CONFIG_CC3000_MULTIPLE
int irq; /* IRQ number received by interrupt handler. */
int irq; /* IRQ number received by interrupt handler. */
#endif
/* IRQ/GPIO access callbacks. These operations all hidden behind

View File

@ -288,8 +288,8 @@ int connect(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen);
*
*****************************************************************************/
int select(int nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds,
struct timeval *timeout);
int cc3000_select(int nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds,
struct timeval *timeout);
#ifndef CC3000_TINY_DRIVER
/*****************************************************************************

View File

@ -110,7 +110,8 @@ extern "C" {
*
*****************************************************************************/
void wlan_init(tWlanCB sWlanCB, tFWPatches sFWPatches,
void wlan_init(size_t max_tx_len,
tWlanCB sWlanCB, tFWPatches sFWPatches,
tDriverPatches sDriverPatches,
tBootLoaderPatches sBootLoaderPatches);