Skip to content

Commit

Permalink
Only whitespace changes, to clarify the real code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Crockett committed Jul 17, 2014
1 parent 35d05c8 commit f05b191
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 111 deletions.
64 changes: 32 additions & 32 deletions CC3000_Host_Driver/evnt_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
// GLOBAL VARAIABLES
//*****************************************************************************

static volatile UINT32 socket_active_status = SOCKET_STATUS_INIT_VAL;
static volatile UINT32 socket_active_status = SOCKET_STATUS_INIT_VAL;
uint32_t cc3000__event_timeout_ms = 0;

//*****************************************************************************
Expand Down Expand Up @@ -639,22 +639,24 @@ INT32 hci_unsol_event_handler(CHAR *event_hdr)
{
switch(event_type)
{
case HCI_EVNT_DATA_UNSOL_FREE_BUFF:
{
hci_event_unsol_flowcontrol_handler(event_hdr);

NumberOfReleasedPackets = tSLInformation.NumberOfReleasedPackets;
NumberOfSentPackets = tSLInformation.NumberOfSentPackets;

if (NumberOfReleasedPackets == NumberOfSentPackets)
{
if (tSLInformation.InformHostOnTxComplete)
{
tSLInformation.sWlanCB(HCI_EVENT_CC3000_CAN_SHUT_DOWN, NULL, 0);
}
}
return 1;
}

case HCI_EVNT_DATA_UNSOL_FREE_BUFF:
{
hci_event_unsol_flowcontrol_handler(event_hdr);

NumberOfReleasedPackets = tSLInformation.NumberOfReleasedPackets;
NumberOfSentPackets = tSLInformation.NumberOfSentPackets;

if (NumberOfReleasedPackets == NumberOfSentPackets)
{
if (tSLInformation.InformHostOnTxComplete)
{
tSLInformation.sWlanCB(HCI_EVENT_CC3000_CAN_SHUT_DOWN, NULL, 0);
}
}
return 1;

}
}
}

Expand Down Expand Up @@ -831,22 +833,20 @@ INT32 hci_unsolicited_event_handler(void)
//! accordingly the global socket status
//
//*****************************************************************************

void set_socket_active_status(INT32 Sd, INT32 Status)
{
//DEBUG("Sd=%d, Status %s",Sd, Status == SOCKET_STATUS_ACTIVE ? "SOCKET_STATUS_ACTIVE" : "SOCKET_STATUS_INACTIVE");

if(M_IS_VALID_SD(Sd) && M_IS_VALID_STATUS(Status))
{
for (;;) {
INT32 oldStatus = socket_active_status;
INT32 newStatus = oldStatus;
newStatus &= ~(1 << Sd); /* clean socket's mask */
newStatus |= (Status << Sd); /* set new socket's mask */
if (__sync_bool_compare_and_swap(&socket_active_status, oldStatus, newStatus))
break;
}
}
if(M_IS_VALID_SD(Sd) && M_IS_VALID_STATUS(Status))
{
for (;;) {
INT32 oldStatus = socket_active_status;
INT32 newStatus = oldStatus;
newStatus &= ~(1 << Sd); /* clean socket's mask */
newStatus |= (Status << Sd); /* set new socket's mask */
if (__sync_bool_compare_and_swap(&socket_active_status, oldStatus, newStatus))
break;
}
}
}

//*****************************************************************************
Expand Down Expand Up @@ -881,8 +881,8 @@ INT32 hci_event_unsol_flowcontrol_handler(CHAR *pEvent)
temp += value;
pReadPayload += FLOW_CONTROL_EVENT_SIZE;
}
__sync_add_and_fetch(&tSLInformation.usNumberOfFreeBuffers, temp);

__sync_add_and_fetch(&tSLInformation.usNumberOfFreeBuffers, temp);
__sync_add_and_fetch(&tSLInformation.NumberOfReleasedPackets, temp);

return(ESUCCESS);
Expand Down
19 changes: 10 additions & 9 deletions CC3000_Host_Driver/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ INT16 HostFlowControlConsumeBuff(INT16 sd)
#ifndef SEND_NON_BLOCKING
/* wait in busy loop */
volatile system_tick_t start = GetSystem1MsTick();
bool stop = false;

bool stop = false;
do
{
// In case last transmission failed then we will return the last failure
Expand All @@ -144,16 +145,16 @@ INT16 HostFlowControlConsumeBuff(INT16 sd)
ERROR("Timeout waiting on on buffers now %ld start %ld elapsed %ld cc3000__event_timeout_ms %ld",now,start,elapsed,cc3000__event_timeout_ms);
return -1;
}
// Do an atomic decrement if > 0
UINT16 freeBuffers = tSLInformation.usNumberOfFreeBuffers;
if (0 < freeBuffers) {
stop = __sync_bool_compare_and_swap(&tSLInformation.usNumberOfFreeBuffers, freeBuffers, freeBuffers-1);
}

// Do an atomic decrement if > 0
UINT16 freeBuffers = tSLInformation.usNumberOfFreeBuffers;
if (0 < freeBuffers) {
stop = __sync_bool_compare_and_swap(&tSLInformation.usNumberOfFreeBuffers, freeBuffers, freeBuffers-1);
}
} while (!stop);
return 0;
#else
#error not here

// In case last transmission failed then we will return the last failure
// reason here.
// Note that the buffer will not be allocated in this case
Expand Down Expand Up @@ -1053,7 +1054,7 @@ INT16 simple_link_send(INT32 sd, const void *buf, INT32 len, INT32 flags,
args = UINT32_TO_STREAM(args, addr_offset);
args = UINT32_TO_STREAM(args, addrlen);
}

// Copy the data received from user into the TX Buffer
ARRAY_TO_STREAM(pDataPtr, ((UINT8 *)buf), len);

Expand Down
6 changes: 3 additions & 3 deletions SPARK_Firmware_Driver/inc/spi_bus.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* File: spi_bus.h
* Author: mat
*
Expand All @@ -13,9 +13,9 @@ extern "C" {
#endif

void reset_bus();

int try_acquire_spi_bus(int owner);

void acquire_spi_bus(int owner);

void release_spi_bus(int owner);
Expand Down
2 changes: 1 addition & 1 deletion SPARK_Firmware_Driver/inc/sst25vf_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extern "C" {
void sFLASH_Init(void);
void sFLASH_EraseSector(uint32_t SectorAddr);
void sFLASH_EraseBulk(void);
void sFLASH_WriteBuffer(uint8_t *pBuffer, uint32_t WriteAddr, uint32_t NumByteToWrite);
void sFLASH_WriteBuffer(const uint8_t *pBuffer, uint32_t WriteAddr, uint32_t NumByteToWrite);
void sFLASH_ReadBuffer(uint8_t *pBuffer, uint32_t ReadAddr, uint32_t NumByteToRead);
uint32_t sFLASH_ReadID(void);

Expand Down
81 changes: 42 additions & 39 deletions SPARK_Firmware_Driver/src/cc3000_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef enum
eSPI_STATE_WRITE_WAIT_IRQ,
eSPI_STATE_WRITE_PROCEED,
eSPI_STATE_WRITE_DONE,
eSPI_STATE_READ_IRQ,
eSPI_STATE_READ_IRQ,
eSPI_STATE_READ_PROCEED,
eSPI_STATE_READ_READY,
eSPI_STATE_READ_PREP_IRQ
Expand Down Expand Up @@ -122,14 +122,15 @@ static inline eCC3000States SetState(eCC3000States ns, eCSActions cs)
intState save = DISABLE_INT();
eCC3000States os = sSpiInformation.ulSpiState;
sSpiInformation.ulSpiState = ns;
switch (cs) {
case eAssert:
ASSERT_CS();
break;
case eDeAssert:
DEASSERT_CS();
break;
}
switch (cs)
{
case eAssert:
ASSERT_CS();
break;
case eDeAssert:
DEASSERT_CS();
break;
}
ENABLE_INT(save);
return os;
}
Expand Down Expand Up @@ -241,7 +242,7 @@ void SpiPauseSpi(void)
int SpiIO(eSPIOperation op, const uint8_t *ptrData, uint32_t ulDataSize, int waitOnCompletion)
{

eCC3000States current = State();
eCC3000States current = State();
/* Disable DMA Channels */
CC3000_SPI_DMA_Channels(DISABLE);

Expand All @@ -263,6 +264,7 @@ int SpiIO(eSPIOperation op, const uint8_t *ptrData, uint32_t ulDataSize, int wai
/* Enable DMA Channels */
CC3000_SPI_DMA_Channels(ENABLE);
return waitOnCompletion ? Still(current) : 0;

}

long SpiSetUp(unsigned char *pUserBuffer, unsigned short usLength)
Expand Down Expand Up @@ -329,7 +331,7 @@ long SpiWrite(unsigned char *ucBuf, unsigned short usLength)
if(NotAborted)
{
NotAborted = Reserve(eSPI_STATE_WRITE_WAIT_IRQ);
//WARN("CC3000 SpiWrite acquire bus");
//WARN("CC3000 SpiWrite acquire bus");
if(NotAborted)
{
usLength = SpiSetUp(ucBuf, usLength);
Expand Down Expand Up @@ -431,8 +433,8 @@ void SPI_DMA_IntHandler(void)
}
else
{
SetState(eSPI_STATE_IDLE, eDeAssert);
//WARN("CC3000 DmaHandler release write spi bus");
SetState(eSPI_STATE_IDLE, eDeAssert);
//WARN("CC3000 DmaHandler release write spi bus");
}
}
break;
Expand All @@ -444,8 +446,9 @@ void SPI_DMA_IntHandler(void)
}
}

void handle_spi_request() {
if (State()==eSPI_STATE_READ_PREP_IRQ && try_acquire_spi_bus(BUS_OWNER_CC3000))
void handle_spi_request()
{
if (State() == eSPI_STATE_READ_PREP_IRQ && try_acquire_spi_bus(BUS_OWNER_CC3000))
{
DEBUG("Handling CC3000 request on main thread");
SetState(eSPI_STATE_READ_IRQ, eAssert);
Expand All @@ -462,29 +465,29 @@ void handle_spi_request() {
*/
void SPI_EXTI_IntHandler(void)
{
//Pending is cleared in first level of ISR handler
if (!tSLInformation.ReadWlanInterruptPin())
{
switch(sSpiInformation.ulSpiState)
{
case eSPI_STATE_POWERUP:
sSpiInformation.ulSpiState = eSPI_STATE_INITIALIZED;
break;
case eSPI_STATE_IDLE:
if (try_acquire_spi_bus(BUS_OWNER_CC3000)) {
SetState(eSPI_STATE_READ_IRQ, eAssert);
SpiIO(eRead, sSpiInformation.pRxPacket, arraySize(spi_readCommand), FALSE);
} else {
SetState(eSPI_STATE_READ_PREP_IRQ, eNone);
WARN("CC3000 cannot lock bus - scheduling later (owner=%d)", current_bus_owner());
}
break;
case eSPI_STATE_WRITE_WAIT_IRQ:
sSpiInformation.ulSpiState = eSPI_STATE_WRITE_PROCEED;
break;
default:
break;
}
}
//Pending is cleared in first level of ISR handler
if (!tSLInformation.ReadWlanInterruptPin())
{
switch(sSpiInformation.ulSpiState)
{
case eSPI_STATE_POWERUP:
sSpiInformation.ulSpiState = eSPI_STATE_INITIALIZED;
break;
case eSPI_STATE_IDLE:
if (try_acquire_spi_bus(BUS_OWNER_CC3000)) {
SetState(eSPI_STATE_READ_IRQ, eAssert);
SpiIO(eRead, sSpiInformation.pRxPacket, arraySize(spi_readCommand), FALSE);
} else {
SetState(eSPI_STATE_READ_PREP_IRQ, eNone);
WARN("CC3000 cannot lock bus - scheduling later (owner=%d)", current_bus_owner());
}
break;
case eSPI_STATE_WRITE_WAIT_IRQ:
sSpiInformation.ulSpiState = eSPI_STATE_WRITE_PROCEED;
break;
default:
break;
}
}
}

1 change: 1 addition & 0 deletions SPARK_Firmware_Driver/src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "spark_macros.h"
#include "debug.h"


uint32_t log_level_at_run_time = LOG_LEVEL_AT_RUN_TIME;

void log_print_(int level, int line, const char *func, const char *file, const char *msg, ...)
Expand Down
19 changes: 9 additions & 10 deletions SPARK_Firmware_Driver/src/hw_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "debug.h"
#include "cc3000_spi.h"


/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/
Expand Down Expand Up @@ -956,7 +955,7 @@ void CC3000_SPI_DMA_Channels(FunctionalState NewState)
/* Select CC3000: ChipSelect pin low */
void CC3000_CS_LOW(void)
{
acquire_spi_bus(BUS_OWNER_CC3000);
acquire_spi_bus(BUS_OWNER_CC3000);
CC3000_SPI->CR1 &= ((uint16_t)0xFFBF);
CC3000_SPI->CR1 = CC3000_SPI_CR | ((uint16_t)0x0040);
GPIO_ResetBits(CC3000_WIFI_CS_GPIO_PORT, CC3000_WIFI_CS_GPIO_PIN);
Expand All @@ -966,7 +965,7 @@ void CC3000_CS_LOW(void)
void CC3000_CS_HIGH(void)
{
GPIO_SetBits(CC3000_WIFI_CS_GPIO_PORT, CC3000_WIFI_CS_GPIO_PIN);
release_spi_bus(BUS_OWNER_CC3000);
release_spi_bus(BUS_OWNER_CC3000);
}

/* CC3000 Hardware related callbacks passed to wlan_init */
Expand Down Expand Up @@ -1138,18 +1137,18 @@ void sFLASH_SPI_Init(void)
/* Select sFLASH: Chip Select pin low */
void sFLASH_CS_LOW(void)
{
acquire_spi_bus(BUS_OWNER_SFLASH);
sFLASH_SPI->CR1 &= ((uint16_t)0xFFBF);
sFLASH_SPI->CR1 = sFLASH_SPI_CR | ((uint16_t)0x0040);
GPIO_ResetBits(sFLASH_MEM_CS_GPIO_PORT, sFLASH_MEM_CS_GPIO_PIN);
acquire_spi_bus(BUS_OWNER_SFLASH);
sFLASH_SPI->CR1 &= ((uint16_t)0xFFBF);
sFLASH_SPI->CR1 = sFLASH_SPI_CR | ((uint16_t)0x0040);
GPIO_ResetBits(sFLASH_MEM_CS_GPIO_PORT, sFLASH_MEM_CS_GPIO_PIN);
}

/* Deselect sFLASH: Chip Select pin high */
void sFLASH_CS_HIGH(void)
{
GPIO_SetBits(sFLASH_MEM_CS_GPIO_PORT, sFLASH_MEM_CS_GPIO_PIN);
release_spi_bus(BUS_OWNER_SFLASH);
handle_spi_request();
GPIO_SetBits(sFLASH_MEM_CS_GPIO_PORT, sFLASH_MEM_CS_GPIO_PIN);
release_spi_bus(BUS_OWNER_SFLASH);
handle_spi_request();
}

/*******************************************************************************
Expand Down
Loading

0 comments on commit f05b191

Please sign in to comment.