Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
a7a1a38d
Commit
a7a1a38d
authored
May 11, 2014
by
Damien George
Browse files
stmhal: Update CC3000 driver to newer version.
Still not working properly.
parent
50073ed5
Changes
19
Hide whitespace changes
Inline
Side-by-side
stmhal/cc3k/cc3000_common.c
View file @
a7a1a38d
...
...
@@ -3,14 +3,6 @@
* cc3000_common.c.c - 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:
...
...
@@ -60,7 +52,6 @@
#include
"socket.h"
#include
"wlan.h"
#include
"evnt_handler.h"
#include
"ccdebug.h"
//*****************************************************************************
//
...
...
@@ -96,12 +87,12 @@ __error__(char *pcFilename, unsigned long ulLine)
//
//*****************************************************************************
u
int8_t
*
UINT32_TO_STREAM_f
(
u
int8_t
*
p
,
uint32_t
u32
)
u
nsigned
char
*
UINT32_TO_STREAM_f
(
u
nsigned
char
*
p
,
unsigned
long
u32
)
{
*
(
p
)
++
=
(
u
int8_t
)(
u32
);
*
(
p
)
++
=
(
u
int8_t
)((
u32
)
>>
8
);
*
(
p
)
++
=
(
u
int8_t
)((
u32
)
>>
16
);
*
(
p
)
++
=
(
u
int8_t
)((
u32
)
>>
24
);
*
(
p
)
++
=
(
u
nsigned
char
)(
u32
);
*
(
p
)
++
=
(
u
nsigned
char
)((
u32
)
>>
8
);
*
(
p
)
++
=
(
u
nsigned
char
)((
u32
)
>>
16
);
*
(
p
)
++
=
(
u
nsigned
char
)((
u32
)
>>
24
);
return
p
;
}
...
...
@@ -119,10 +110,10 @@ uint8_t* UINT32_TO_STREAM_f (uint8_t *p, uint32_t u32)
//
//*****************************************************************************
u
int8_t
*
UINT16_TO_STREAM_f
(
u
int8_t
*
p
,
uint16_
t
u16
)
u
nsigned
char
*
UINT16_TO_STREAM_f
(
u
nsigned
char
*
p
,
unsigned
shor
t
u16
)
{
*
(
p
)
++
=
(
u
int8_t
)(
u16
);
*
(
p
)
++
=
(
u
int8_t
)((
u16
)
>>
8
);
*
(
p
)
++
=
(
u
nsigned
char
)(
u16
);
*
(
p
)
++
=
(
u
nsigned
char
)((
u16
)
>>
8
);
return
p
;
}
...
...
@@ -140,20 +131,10 @@ uint8_t* UINT16_TO_STREAM_f (uint8_t *p, uint16_t u16)
//
//*****************************************************************************
u
int16_
t
STREAM_TO_UINT16_f
(
char
*
c
p
,
u
int16_
t
offset
)
u
nsigned
shor
t
STREAM_TO_UINT16_f
(
char
*
p
,
u
nsigned
shor
t
offset
)
{
uint8_t
*
p
=
(
uint8_t
*
)
cp
;
/*
DEBUGPRINT_F("Stream2u16: ");
DEBUGPRINT_HEX(cp[offset+1]);
DEBUGPRINT_F(" + ");
DEBUGPRINT_HEX(cp[offset]);
DEBUGPRINT_F("\n\r");
*/
return
(
uint16_t
)((
uint16_t
)
((
uint16_t
)(
*
(
p
+
offset
+
1
))
<<
8
)
+
(
uint16_t
)(
*
(
p
+
offset
)));
return
(
unsigned
short
)((
unsigned
short
)((
unsigned
short
)
(
*
(
p
+
offset
+
1
))
<<
8
)
+
(
unsigned
short
)(
*
(
p
+
offset
)));
}
//*****************************************************************************
...
...
@@ -170,23 +151,12 @@ uint16_t STREAM_TO_UINT16_f(char* cp, uint16_t offset)
//
//*****************************************************************************
u
int32_t
STREAM_TO_UINT32_f
(
char
*
c
p
,
u
int16_
t
offset
)
u
nsigned
long
STREAM_TO_UINT32_f
(
char
*
p
,
u
nsigned
shor
t
offset
)
{
uint8_t
*
p
=
(
uint8_t
*
)
cp
;
/*
DEBUGPRINT_F("\tStream2u32: ");
DEBUGPRINT_HEX(cp[offset+3]); DEBUGPRINT_F(" + ");
DEBUGPRINT_HEX(cp[offset+2]); DEBUGPRINT_F(" + ");
DEBUGPRINT_HEX(cp[offset+1]); DEBUGPRINT_F(" + ");
DEBUGPRINT_HEX(cp[offset]);
DEBUGPRINT_F("\n\r");
*/
return
(
uint32_t
)((
uint32_t
)((
uint32_t
)
(
*
(
p
+
offset
+
3
))
<<
24
)
+
(
uint32_t
)((
uint32_t
)
(
*
(
p
+
offset
+
2
))
<<
16
)
+
(
uint32_t
)((
uint32_t
)
(
*
(
p
+
offset
+
1
))
<<
8
)
+
(
uint32_t
)(
*
(
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
)));
}
...
...
stmhal/cc3k/cc3000_common.h
View file @
a7a1a38d
...
...
@@ -3,14 +3,6 @@
* cc3000_common.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:
...
...
@@ -46,9 +38,6 @@
//******************************************************************************
// Include files
//******************************************************************************
//#include <stdlib.h>
//#include <errno.h>
//#include <stdint.h>
//*****************************************************************************
//
...
...
@@ -167,11 +156,7 @@ extern "C" {
//*****************************************************************************
// Compound Types
//*****************************************************************************
#ifdef __AVR__
typedef
unsigned
long
time_t
;
/* KTown: Updated to be compatible with Arduino Time.h */
#else
typedef
long
time_t
;
#endif
typedef
unsigned
long
clock_t
;
typedef
long
suseconds_t
;
...
...
@@ -268,7 +253,7 @@ extern void SimpleLinkWaitEvent(unsigned short usOpcode, void *pRetParams);
//
//*****************************************************************************
extern
void
SimpleLinkWaitData
(
u
int8_t
*
pBuf
,
uint8_t
*
from
,
uint8_t
*
fromlen
);
extern
void
SimpleLinkWaitData
(
u
nsigned
char
*
pBuf
,
unsigned
char
*
from
,
unsigned
char
*
fromlen
);
//*****************************************************************************
//
...
...
@@ -284,7 +269,7 @@ extern void SimpleLinkWaitData(uint8_t *pBuf, uint8_t *from, uint8_t *fromlen);
//
//*****************************************************************************
extern
u
int8_t
*
UINT32_TO_STREAM_f
(
u
int8_t
*
p
,
uint32_t
u32
);
extern
u
nsigned
char
*
UINT32_TO_STREAM_f
(
u
nsigned
char
*
p
,
unsigned
long
u32
);
//*****************************************************************************
//
...
...
@@ -300,7 +285,7 @@ extern uint8_t* UINT32_TO_STREAM_f (uint8_t *p, uint32_t u32);
//
//*****************************************************************************
extern
u
int8_t
*
UINT16_TO_STREAM_f
(
u
int8_t
*
p
,
uint16_
t
u16
);
extern
u
nsigned
char
*
UINT16_TO_STREAM_f
(
u
nsigned
char
*
p
,
unsigned
shor
t
u16
);
//*****************************************************************************
//
...
...
@@ -316,7 +301,7 @@ extern uint8_t* UINT16_TO_STREAM_f (uint8_t *p, uint16_t u16);
//
//*****************************************************************************
extern
u
int16_
t
STREAM_TO_UINT16_f
(
char
*
p
,
u
int16_
t
offset
);
extern
u
nsigned
shor
t
STREAM_TO_UINT16_f
(
char
*
p
,
u
nsigned
shor
t
offset
);
//*****************************************************************************
//
...
...
@@ -332,7 +317,7 @@ extern uint16_t STREAM_TO_UINT16_f(char* p, uint16_t offset);
//
//*****************************************************************************
extern
u
int32_t
STREAM_TO_UINT32_f
(
char
*
p
,
u
int16_
t
offset
);
extern
u
nsigned
long
STREAM_TO_UINT32_f
(
char
*
p
,
u
nsigned
shor
t
offset
);
//*****************************************************************************
...
...
@@ -361,14 +346,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)++ = ((u
int8_t
*) a)[_i];}
#define ARRAY_TO_STREAM(p, a, l) {register short _i; for (_i = 0; _i < l; _i++) *(p)++ = ((u
nsigned char
*) 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 = (u
int8_t
)(*(_p + _offset));}
#define STREAM_TO_UINT8(_p, _offset, _u8) {_u8 = (u
nsigned char
)(*(_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)++= ((u
int8_t
*) p)[_i];}
#define STREAM_TO_STREAM(p, a, l) {register short _i; for (_i = 0; _i < l; _i++) *(a)++= ((u
nsigned char
*) p)[_i];}
...
...
stmhal/cc3k/ccdebug.h
deleted
100644 → 0
View file @
50073ed5
/**************************************************************************/
/*!
@file Adafruit_CC3000.cpp
@author KTOWN (Kevin Townsend for Adafruit Industries)
@license BSD (see license.txt)
This is a library for the Adafruit CC3000 WiFi breakout board
This library works with the Adafruit CC3000 breakout
----> https://www.adafruit.com/products/1469
Check out the links above for our tutorials and wiring diagrams
These chips use SPI to communicate.
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
@section HISTORY
v1.0 - Initial release
*/
/**************************************************************************/
//#include <Arduino.h>
#ifndef _CC3000_DEBUG
#define _CC3000_DEBUG
#define DEBUG_MODE (0)
#define PRINT_F(__s) DEBUGPRINT(FLASHIFY(__s))
#if (DEBUG_MODE != 0)
#define DEBUGPRINT_F(__s) DEBUGPRINT(FLASHIFY(__s))
#define DEBUGPRINT_DEC(x) printDec(x)
#define DEBUGPRINT_DEC16(x) printDec16(x)
#define DEBUGPRINT_HEX(x) printHex(x)
#define DEBUGPRINT_HEX16(x) printHex16(x)
#else
#define DEBUGPRINT_F(__s)
/* do nothing! */
#define DEBUGPRINT_DEC(x)
#define DEBUGPRINT_DEC16(x)
#define DEBUGPRINT_HEX(x)
#define DEBUGPRINT_HEX16(x)
#endif
#if 1 // print debugging info
#define DEBUG_PRINT (1)
#define DEBUG_printf(args...) printf(args)
#else // don't print debugging info
#define DEBUG_printf(args...) (void)0
#endif
int
printf
(
const
char
*
fmt
,
...);
#endif
stmhal/cc3k/ccspi.c
View file @
a7a1a38d
...
...
@@ -51,9 +51,14 @@
#include
"netapp.h"
#include
"evnt_handler.h"
#include
"cc3000_common.h"
#include
"ccdebug.h"
#include
"pybcc3k.h"
#if 0 // print debugging info
#define DEBUG_printf(args...) printf(args)
#else
// don't print debugging info
#define DEBUG_printf(args...) (void)0
#endif
#define READ (3)
#define WRITE (1)
#define HI(value) (((value) & 0xFF00) >> 8)
...
...
@@ -140,7 +145,7 @@ void SpiInit(void)
/**************************************************************************/
void
SpiClose
(
void
)
{
DEBUG
PRINT_F
(
"
\t
CC3000: SpiClose"
);
DEBUG
_printf
(
"
\t
CC3000: SpiClose"
);
if
(
sSpiInformation
.
pRxPacket
)
{
...
...
@@ -158,7 +163,7 @@ void SpiClose(void)
/**************************************************************************/
void
SpiOpen
(
gcSpiHandleRx
pfRxHandler
)
{
DEBUG
PRINT_F
(
"
\t
CC3000: SpiOpen"
);
DEBUG
_printf
(
"
\t
CC3000: SpiOpen"
);
sSpiInformation
.
ulSpiState
=
eSPI_STATE_POWERUP
;
...
...
@@ -177,7 +182,7 @@ void SpiOpen(gcSpiHandleRx pfRxHandler)
/* Enable interrupt on the GPIO pin of WLAN IRQ */
tSLInformation
.
WlanInterruptEnable
();
DEBUG
PRINT_F
(
"
\t
CC3000: Finished SpiOpen
\n\r
"
);
DEBUG
_printf
(
"
\t
CC3000: Finished SpiOpen
\n\r
"
);
}
/**************************************************************************/
...
...
@@ -191,7 +196,7 @@ extern uint8_t g_csPin, g_irqPin, g_vbatPin, g_IRQnum, g_SPIspeed;
int init_spi(void)
{
DEBUG
PRINT_F
("\tCC3000: init_spi\n\r");
DEBUG
_printf
("\tCC3000: init_spi\n\r");
/* Set POWER_EN pin to output and disable the CC3000 by default */
pinMode(g_vbatPin, OUTPUT);
...
...
@@ -222,7 +227,7 @@ int init_spi(void)
/* ToDo: Configure IRQ interrupt! */
DEBUG
PRINT_F
(
"
\t
CC3000: Finished init_spi
\n\r
"
);
DEBUG
_printf
(
"
\t
CC3000: Finished init_spi
\n\r
"
);
return
(
ESUCCESS
);
}
...
...
@@ -235,7 +240,7 @@ int init_spi(void)
/**************************************************************************/
long
SpiFirstWrite
(
unsigned
char
*
ucBuf
,
unsigned
short
usLength
)
{
DEBUG
PRINT_F
(
"
\t
CC3000: SpiWriteFirst
\n\r
"
);
DEBUG
_printf
(
"
\t
CC3000: SpiWriteFirst
\n\r
"
);
/* Workaround for the first transaction */
CC3000_ASSERT_CS
();
...
...
@@ -267,7 +272,7 @@ long SpiWrite(unsigned char *pUserBuffer, unsigned short usLength)
{
unsigned
char
ucPad
=
0
;
DEBUG
PRINT_F
(
"
\t
CC3000: SpiWrite
\n\r
"
);
DEBUG
_printf
(
"
\t
CC3000: SpiWrite
\n\r
"
);
/* Figure out the total length of the packet in order to figure out if there is padding or not */
if
(
!
(
usLength
&
0x0001
))
...
...
@@ -288,7 +293,7 @@ long SpiWrite(unsigned char *pUserBuffer, unsigned short usLength)
* occurred - and we will be stuck here forever! */
if
(
wlan_tx_buffer
[
CC3000_TX_BUFFER_SIZE
-
1
]
!=
CC3000_BUFFER_MAGIC_NUMBER
)
{
DEBUG
PRINT_F
(
"
\t
CC3000: Error - No magic number found in SpiWrite
\n\r
"
);
DEBUG
_printf
(
"
\t
CC3000: Error - No magic number found in SpiWrite
\n\r
"
);
while
(
1
);
}
...
...
@@ -383,7 +388,7 @@ void SpiReadDataSynchronous(unsigned char *data, unsigned short size)
/**************************************************************************/
void
SpiReadHeader
(
void
)
{
DEBUG
PRINT_F
(
"
\t
CC3000: SpiReadHeader
\n\r
"
);
DEBUG
_printf
(
"
\t
CC3000: SpiReadHeader
\n\r
"
);
SpiReadDataSynchronous
(
sSpiInformation
.
pRxPacket
,
HEADERS_SIZE_EVNT
);
}
...
...
@@ -398,7 +403,7 @@ long SpiReadDataCont(void)
long
data_to_recv
;
unsigned
char
*
evnt_buff
,
type
;
DEBUG
PRINT_F
(
"
\t
CC3000: SpiReadDataCont
\n\r
"
);
DEBUG
_printf
(
"
\t
CC3000: SpiReadDataCont
\n\r
"
);
/* Determine what type of packet we have */
evnt_buff
=
sSpiInformation
.
pRxPacket
;
...
...
@@ -454,7 +459,7 @@ long SpiReadDataCont(void)
/**************************************************************************/
void
SpiPauseSpi
(
void
)
{
DEBUG
PRINT_F
(
"
\t
CC3000: SpiPauseSpi
\n\r
"
);
DEBUG
_printf
(
"
\t
CC3000: SpiPauseSpi
\n\r
"
);
ccspi_int_enabled
=
0
;
pyb_cc3000_pause_spi
();
...
...
@@ -467,7 +472,7 @@ void SpiPauseSpi(void)
/**************************************************************************/
void
SpiResumeSpi
(
void
)
{
DEBUG
PRINT_F
(
"
\t
CC3000: SpiResumeSpi
\n\r
"
);
DEBUG
_printf
(
"
\t
CC3000: SpiResumeSpi
\n\r
"
);
ccspi_int_enabled
=
1
;
pyb_cc3000_resume_spi
();
...
...
@@ -480,24 +485,24 @@ void SpiResumeSpi(void)
/**************************************************************************/
void
SpiTriggerRxProcessing
(
void
)
{
DEBUG
PRINT_F
(
"
\t
CC3000: SpiTriggerRxProcessing
\n\r
"
);
DEBUG
_printf
(
"
\t
CC3000: SpiTriggerRxProcessing
\n\r
"
);
/* Trigger Rx processing */
SpiPauseSpi
();
CC3000_DEASSERT_CS
();
//DEBUG
PRINT_F
("Magic?\n\r");
//DEBUG
_printf
("Magic?\n\r");
/* The magic number that resides at the end of the TX/RX buffer (1 byte after the allocated size)
* for the purpose of detection of the overrun. If the magic number is overriten - buffer overrun
* occurred - and we will stuck here forever! */
if
(
sSpiInformation
.
pRxPacket
[
CC3000_RX_BUFFER_SIZE
-
1
]
!=
CC3000_BUFFER_MAGIC_NUMBER
)
{
/* You've got problems if you're here! */
DEBUG
PRINT_F
(
"
\t
CC3000: ERROR - magic number missing!
\n\r
"
);
DEBUG
_printf
(
"
\t
CC3000: ERROR - magic number missing!
\n\r
"
);
while
(
1
);
}
//DEBUG
PRINT_F
("OK!\n\r");
//DEBUG
_printf
("OK!\n\r");
sSpiInformation
.
ulSpiState
=
eSPI_STATE_IDLE
;
sSpiInformation
.
SPIRxHandler
(
sSpiInformation
.
pRxPacket
+
SPI_HEADER_SIZE
);
}
...
...
@@ -509,14 +514,14 @@ void SpiTriggerRxProcessing(void)
/**************************************************************************/
void
SSIContReadOperation
(
void
)
{
DEBUG
PRINT_F
(
"
\t
CC3000: SpiContReadOperation
\n\r
"
);
DEBUG
_printf
(
"
\t
CC3000: SpiContReadOperation
\n\r
"
);
/* The header was read - continue with the payload read */
if
(
!
SpiReadDataCont
())
{
/* All the data was read - finalize handling by switching to teh task
* and calling from task Event Handler */
//DEBUG
PRINT_F
("SPItrig\n\r");
//DEBUG
_printf
("SPItrig\n\r");
SpiTriggerRxProcessing
();
}
}
...
...
@@ -528,23 +533,6 @@ void SSIContReadOperation(void)
/**************************************************************************/
void
WriteWlanPin
(
unsigned
char
val
)
{
#if 0
if (DEBUG_MODE)
{
DEBUGPRINT_F("\tCC3000: WriteWlanPin - ");
DEBUGPRINT_DEC(val);
DEBUGPRINT_F("\n\r");
delay(1);
}
if (val)
{
digitalWrite(g_vbatPin, HIGH);
}
else
{
digitalWrite(g_vbatPin, LOW);
}
#endif
pyb_cc3000_set_en
(
val
==
WLAN_ENABLE
);
}
...
...
@@ -555,9 +543,7 @@ void WriteWlanPin( unsigned char val )
/**************************************************************************/
long
ReadWlanInterruptPin
(
void
)
{
DEBUGPRINT_F
(
"
\t
CC3000: ReadWlanInterruptPin - "
);
DEBUGPRINT_DEC
(
digitalRead
(
g_irqPin
));
DEBUGPRINT_F
(
"
\n\r
"
);
DEBUG_printf
(
"CC3000: ReadWlanInterruptPin
\n
"
);
return
pyb_cc3000_get_irq
();
}
...
...
@@ -569,9 +555,9 @@ long ReadWlanInterruptPin(void)
/**************************************************************************/
void
WlanInterruptEnable
()
{
DEBUG
PRINT_F
(
"
\t
CC3000: WlanInterruptEnable.
\n\r
"
);
// delay(100);
ccspi_int_enabled
=
1
;
DEBUG
_printf
(
"
\t
CC3000: WlanInterruptEnable.
\n\r
"
);
// delay(100);
ccspi_int_enabled
=
1
;
pyb_cc3000_enable_irq
();
}
...
...
@@ -582,7 +568,7 @@ void WlanInterruptEnable()
/**************************************************************************/
void
WlanInterruptDisable
()
{
DEBUG
PRINT_F
(
"
\t
CC3000: WlanInterruptDisable
\n\r
"
);
DEBUG
_printf
(
"
\t
CC3000: WlanInterruptDisable
\n\r
"
);
ccspi_int_enabled
=
0
;
pyb_cc3000_disable_irq
();
}
...
...
@@ -687,7 +673,7 @@ void SPI_IRQ(void)
{
ccspi_is_in_irq = 1;
DEBUG
PRINT_F
("\tCC3000: Entering SPI_IRQ\n\r");
DEBUG
_printf
("\tCC3000: Entering SPI_IRQ\n\r");
if (sSpiInformation.ulSpiState == eSPI_STATE_POWERUP)
{
...
...
@@ -696,7 +682,7 @@ void SPI_IRQ(void)
}
else if (sSpiInformation.ulSpiState == eSPI_STATE_IDLE)
{
//DEBUG
PRINT_F
("IDLE\n\r");
//DEBUG
_printf
("IDLE\n\r");
sSpiInformation.ulSpiState = eSPI_STATE_READ_IRQ;
/* IRQ line goes down - start reception */
...
...
@@ -705,7 +691,7 @@ void SPI_IRQ(void)
// Wait for TX/RX Compete which will come as DMA interrupt
SpiReadHeader();
sSpiInformation.ulSpiState = eSPI_STATE_READ_EOT;
//DEBUG
PRINT_F
("SSICont\n\r");
//DEBUG
_printf
("SSICont\n\r");
SSIContReadOperation();
}
else if (sSpiInformation.ulSpiState == eSPI_STATE_WRITE_IRQ)
...
...
@@ -715,7 +701,7 @@ void SPI_IRQ(void)
CC3000_DEASSERT_CS();
}
DEBUG
PRINT_F
("\tCC3000: Leaving SPI_IRQ\n\r");
DEBUG
_printf
("\tCC3000: Leaving SPI_IRQ\n\r");
ccspi_is_in_irq = 0;
return;
...
...
stmhal/cc3k/evnt_handler.c
View file @
a7a1a38d
...
...
@@ -3,14 +3,6 @@
* evnt_handler.c - 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:
...
...
@@ -64,7 +56,6 @@
#include
"socket.h"
#include
"netapp.h"
#include
"ccspi.h"
#include
"ccdebug.h"
...
...
@@ -251,22 +242,17 @@ hci_event_handler(void *pRetParams, unsigned char *from, unsigned char *fromlen)
while
(
1
)
{
cc3k_int_poll
();
if
(
tSLInformation
.
usEventOrDataReceived
!=
0
)
{
pucReceivedData
=
(
tSLInformation
.
pucReceivedData
);
if
(
*
pucReceivedData
==
HCI_TYPE_EVNT
)
{
// Event Received
STREAM_TO_UINT16
((
char
*
)
pucReceivedData
,
HCI_EVENT_OPCODE_OFFSET
,
usReceivedEventOpcode
);
STREAM_TO_UINT16
((
char
*
)
pucReceivedData
,
HCI_EVENT_OPCODE_OFFSET
,
usReceivedEventOpcode
);
pucReceivedParams
=
pucReceivedData
+
HCI_EVENT_HEADER_SIZE
;
RecvParams
=
pucReceivedParams
;
RetParams
=
(
unsigned
char
*
)
pRetParams
;
RetParams
=
pRetParams
;
// In case unsolicited event received - here the handling finished
if
(
hci_unsol_event_handler
((
char
*
)
pucReceivedData
)
==
0
)
...
...
@@ -277,10 +263,8 @@ hci_event_handler(void *pRetParams, unsigned char *from, unsigned char *fromlen)
{
case
HCI_CMND_READ_BUFFER_SIZE
:
{
STREAM_TO_UINT8
((
char
*
)
pucReceivedParams
,
0
,
tSLInformation
.
usNumberOfFreeBuffers
);
STREAM_TO_UINT16
((
char
*
)
pucReceivedParams
,
1
,
tSLInformation
.
usSlBufferLength
);
STREAM_TO_UINT8
((
char
*
)
pucReceivedParams
,
0
,
tSLInformation
.
usNumberOfFreeBuffers
);
STREAM_TO_UINT16
((
char
*
)
pucReceivedParams
,
1
,
tSLInformation
.
usSlBufferLength
);
}
break
;
...
...
@@ -297,8 +281,7 @@ hci_event_handler(void *pRetParams, unsigned char *from, unsigned char *fromlen)
case
HCI_NETAPP_PING_REPORT
:
case
HCI_EVNT_MDNS_ADVERTISE
:
STREAM_TO_UINT8
(
pucReceivedData
,
HCI_EVENT_STATUS_OFFSET
,
*
(
unsigned
char
*
)
pRetParams
);
STREAM_TO_UINT8
(
pucReceivedData
,
HCI_EVENT_STATUS_OFFSET
,
*
(
unsigned
char
*
)
pRetParams
);
break
;
case
HCI_CMND_SETSOCKOPT
:
...
...
@@ -320,14 +303,12 @@ hci_event_handler(void *pRetParams, unsigned char *from, unsigned char *fromlen)
case
HCI_EVNT_CONNECT
:
case
HCI_EVNT_NVMEM_WRITE
:
STREAM_TO_UINT32
((
char
*
)
pucReceivedParams
,
0
,
*
(
unsigned
long
*
)
pRetParams
);
STREAM_TO_UINT32
((
char
*
)
pucReceivedParams
,
0
,
*
(
unsigned
long
*
)
pRetParams
);
break
;
case
HCI_EVNT_READ_SP_VERSION
:
STREAM_TO_UINT8
(
pucReceivedData
,
HCI_EVENT_STATUS_OFFSET
,
*
(
unsigned
char
*
)
pRetParams
);
STREAM_TO_UINT8
(
pucReceivedData
,
HCI_EVENT_STATUS_OFFSET
,
*
(
unsigned
char
*
)
pRetParams
);
pRetParams
=
((
char
*
)
pRetParams
)
+
1
;
STREAM_TO_UINT32
((
char
*
)
pucReceivedParams
,
0
,
retValue32
);
UINT32_TO_STREAM
((
unsigned
char
*
)
pRetParams
,
retValue32
);
...
...
@@ -360,17 +341,17 @@ hci_event_handler(void *pRetParams, unsigned char *from, unsigned char *fromlen)
case
HCI_EVNT_RECV
:
case
HCI_EVNT_RECVFROM
:
{
STREAM_TO_UINT32
((
char
*
)
pucReceivedParams
,
SL_RECEIVE_SD_OFFSET
,
*
(
unsigned
long
*
)
pRetParams
);
pRetParams
=
((
char
*
)
pRetParams
)
+
4
;
STREAM_TO_UINT32
((
char
*
)
pucReceivedParams
,
SL_RECEIVE_NUM_BYTES_OFFSET
,
*
(
unsigned
long
*
)
pRetParams
);
pRetParams
=
((
char
*
)
pRetParams
)
+
4
;
STREAM_TO_UINT32
((
char
*
)
pucReceivedParams
,
SL_RECEIVE__FLAGS__OFFSET
,
*
(
unsigned
long
*
)
pRetParams
);
//tBsdReadReturnParams *tread = (tBsdReadReturnParams *)pRetParams; // unused
if
(((
tBsdReadReturnParams
*
)
pRetParams
)
->
iNumberOfBytes
==
ERROR_SOCKET_INACTIVE
)
{
set_socket_active_status
(((
tBsdReadReturnParams
*
)
pRetParams
)
->
iSocketDescriptor
,
SOCKET_STATUS_INACTIVE
);
}
break
;
STREAM_TO_UINT32
((
char
*
)
pucReceivedParams
,
SL_RECEIVE_SD_OFFSET
,
*
(
unsigned
long
*
)
pRetParams
);
pRetParams
=
((
char
*
)
pRetParams
)
+
4
;
STREAM_TO_UINT32
((
char
*
)
pucReceivedParams
,
SL_RECEIVE_NUM_BYTES_OFFSET
,
*
(
unsigned
long
*
)
pRetParams
);
pRetParams
=
((
char
*
)
pRetParams
)
+
4
;
STREAM_TO_UINT32
((
char
*
)
pucReceivedParams
,
SL_RECEIVE__FLAGS__OFFSET
,
*
(
unsigned
long
*
)
pRetParams
);
if
(((
tBsdReadReturnParams
*
)
pRetParams
)
->
iNumberOfBytes
==
ERROR_SOCKET_INACTIVE
)
{
set_socket_active_status
(((
tBsdReadReturnParams
*
)
pRetParams
)
->
iSocketDescriptor
,
SOCKET_STATUS_INACTIVE
);
}
break
;
}
case
HCI_EVNT_SEND
:
...
...
@@ -447,7 +428,7 @@ hci_event_handler(void *pRetParams, unsigned char *from, unsigned char *fromlen)
//Read SSID
STREAM_TO_STREAM
(
RecvParams
,
RetParams
,
NETAPP_IPCONFIG_SSID_LENGTH
);
break
;