Skip to content

Commit 065f8a5

Browse files
committed
stm: initial commit of working CC3000 driver, based on Adafruit.
1 parent 8fe8413 commit 065f8a5

27 files changed

+9579
-2
lines changed

stm/Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
STMSRC=lib
22
FATFSSRC=fatfs
3+
CC3KSRC=cc3k
34
PYSRC=../py
45
BUILD=build
56

@@ -29,6 +30,7 @@ SRC_C = \
2930
timer.c \
3031
audio.c \
3132
sdio.c \
33+
pybwlan.c \
3234

3335
SRC_S = \
3436
startup_stm32f40xx.s \
@@ -94,7 +96,19 @@ SRC_STM = \
9496
stm324x7i_eval.c \
9597
stm324x7i_eval_sdio_sd.c \
9698

97-
OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o) $(PY_O) $(SRC_FATFS:.c=.o) $(SRC_STM:.c=.o))
99+
SRC_CC3K = \
100+
cc3000_common.c \
101+
evnt_handler.c \
102+
hci.c \
103+
netapp.c \
104+
nvmem.c \
105+
security.c \
106+
socket.c \
107+
wlan.c \
108+
ccspi.c \
109+
pybcc3k.c \
110+
111+
OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o) $(PY_O) $(SRC_FATFS:.c=.o) $(SRC_STM:.c=.o) $(SRC_CC3K:.c=.o))
98112

99113
all: $(BUILD) $(BUILD)/flash.dfu
100114

@@ -126,6 +140,9 @@ $(BUILD)/%.o: $(FATFSSRC)/%.c
126140
$(BUILD)/%.o: $(STMSRC)/%.c
127141
$(CC) $(CFLAGS) -c -o $@ $<
128142

143+
$(BUILD)/%.o: $(CC3KSRC)/%.c
144+
$(CC) $(CFLAGS) -c -o $@ $<
145+
129146
$(BUILD)/%.o: $(PYSRC)/%.s
130147
$(AS) -c -o $@ $<
131148

stm/cc3k/cc3000_common.c

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
/*****************************************************************************
2+
*
3+
* cc3000_common.c.c - CC3000 Host Driver Implementation.
4+
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5+
*
6+
* Adapted for use with the Arduino/AVR by KTOWN (Kevin Townsend)
7+
* & Limor Fried for Adafruit Industries
8+
* This library works with the Adafruit CC3000 breakout
9+
* ----> https://www.adafruit.com/products/1469
10+
* Adafruit invests time and resources providing this open source code,
11+
* please support Adafruit and open-source hardware by purchasing
12+
* products from Adafruit!
13+
*
14+
* Redistribution and use in source and binary forms, with or without
15+
* modification, are permitted provided that the following conditions
16+
* are met:
17+
*
18+
* Redistributions of source code must retain the above copyright
19+
* notice, this list of conditions and the following disclaimer.
20+
*
21+
* Redistributions in binary form must reproduce the above copyright
22+
* notice, this list of conditions and the following disclaimer in the
23+
* documentation and/or other materials provided with the
24+
* distribution.
25+
*
26+
* Neither the name of Texas Instruments Incorporated nor the names of
27+
* its contributors may be used to endorse or promote products derived
28+
* from this software without specific prior written permission.
29+
*
30+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41+
*
42+
*****************************************************************************/
43+
//*****************************************************************************
44+
//
45+
//! \addtogroup common_api
46+
//! @{
47+
//
48+
//*****************************************************************************
49+
/******************************************************************************
50+
*
51+
* Include files
52+
*
53+
*****************************************************************************/
54+
#include <stdint.h>
55+
56+
#include "cc3000_common.h"
57+
#include "socket.h"
58+
#include "wlan.h"
59+
#include "evnt_handler.h"
60+
#include "ccdebug.h"
61+
62+
//*****************************************************************************
63+
//
64+
//! __error__
65+
//!
66+
//! @param pcFilename - file name, where error occurred
67+
//! @param ulLine - line number, where error occurred
68+
//!
69+
//! @return none
70+
//!
71+
//! @brief stub function for ASSERT macro
72+
//
73+
//*****************************************************************************
74+
void
75+
__error__(char *pcFilename, unsigned long ulLine)
76+
{
77+
//TODO full up function
78+
}
79+
80+
81+
82+
//*****************************************************************************
83+
//
84+
//! UINT32_TO_STREAM_f
85+
//!
86+
//! @param p pointer to the new stream
87+
//! @param u32 pointer to the 32 bit
88+
//!
89+
//! @return pointer to the new stream
90+
//!
91+
//! @brief This function is used for copying 32 bit to stream
92+
//! while converting to little endian format.
93+
//
94+
//*****************************************************************************
95+
96+
uint8_t* UINT32_TO_STREAM_f (uint8_t *p, uint32_t u32)
97+
{
98+
*(p)++ = (uint8_t)(u32);
99+
*(p)++ = (uint8_t)((u32) >> 8);
100+
*(p)++ = (uint8_t)((u32) >> 16);
101+
*(p)++ = (uint8_t)((u32) >> 24);
102+
return p;
103+
}
104+
105+
//*****************************************************************************
106+
//
107+
//! UINT16_TO_STREAM_f
108+
//!
109+
//! @param p pointer to the new stream
110+
//! @param u32 pointer to the 16 bit
111+
//!
112+
//! @return pointer to the new stream
113+
//!
114+
//! @brief This function is used for copying 16 bit to stream
115+
//! while converting to little endian format.
116+
//
117+
//*****************************************************************************
118+
119+
uint8_t* UINT16_TO_STREAM_f (uint8_t *p, uint16_t u16)
120+
{
121+
*(p)++ = (uint8_t)(u16);
122+
*(p)++ = (uint8_t)((u16) >> 8);
123+
return p;
124+
}
125+
126+
//*****************************************************************************
127+
//
128+
//! STREAM_TO_UINT16_f
129+
//!
130+
//! @param p pointer to the stream
131+
//! @param offset offset in the stream
132+
//!
133+
//! @return pointer to the new 16 bit
134+
//!
135+
//! @brief This function is used for copying received stream to
136+
//! 16 bit in little endian format.
137+
//
138+
//*****************************************************************************
139+
140+
uint16_t STREAM_TO_UINT16_f(char* cp, uint16_t offset)
141+
{
142+
uint8_t *p = (uint8_t *)cp;
143+
/*
144+
DEBUGPRINT_F("Stream2u16: ");
145+
DEBUGPRINT_HEX(cp[offset+1]);
146+
DEBUGPRINT_F(" + ");
147+
DEBUGPRINT_HEX(cp[offset]);
148+
DEBUGPRINT_F("\n\r");
149+
*/
150+
151+
return (uint16_t)((uint16_t)
152+
((uint16_t)(*(p + offset + 1)) << 8) +
153+
(uint16_t)(*(p + offset)));
154+
}
155+
156+
//*****************************************************************************
157+
//
158+
//! STREAM_TO_UINT32_f
159+
//!
160+
//! @param p pointer to the stream
161+
//! @param offset offset in the stream
162+
//!
163+
//! @return pointer to the new 32 bit
164+
//!
165+
//! @brief This function is used for copying received stream to
166+
//! 32 bit in little endian format.
167+
//
168+
//*****************************************************************************
169+
170+
uint32_t STREAM_TO_UINT32_f(char * cp, uint16_t offset)
171+
{
172+
uint8_t *p = (uint8_t *)cp;
173+
174+
/*
175+
DEBUGPRINT_F("\tStream2u32: ");
176+
DEBUGPRINT_HEX(cp[offset+3]); DEBUGPRINT_F(" + ");
177+
DEBUGPRINT_HEX(cp[offset+2]); DEBUGPRINT_F(" + ");
178+
DEBUGPRINT_HEX(cp[offset+1]); DEBUGPRINT_F(" + ");
179+
DEBUGPRINT_HEX(cp[offset]);
180+
DEBUGPRINT_F("\n\r");
181+
*/
182+
183+
return (uint32_t)((uint32_t)((uint32_t)
184+
(*(p + offset + 3)) << 24) + (uint32_t)((uint32_t)
185+
(*(p + offset + 2)) << 16) + (uint32_t)((uint32_t)
186+
(*(p + offset + 1)) << 8) + (uint32_t)(*(p + offset)));
187+
}
188+
189+
190+
191+
//*****************************************************************************
192+
//
193+
// Close the Doxygen group.
194+
//! @}
195+
//
196+
//*****************************************************************************

0 commit comments

Comments
 (0)