CC3000 driver changes from David Sidrane

This commit is contained in:
Gregory Nutt
2013-10-16 13:18:53 -06:00
parent 4e44868f12
commit 8cd7eea7ad
17 changed files with 2626 additions and 3300 deletions
+2 -2
View File
@@ -74,7 +74,7 @@
* *
*****************************************************************************/ *****************************************************************************/
uint8_t* UINT32_TO_STREAM_f (uint8_t *p, unsigned long u32) uint8_t *UINT32_TO_STREAM_f(uint8_t *p, unsigned long u32)
{ {
*(p)++ = (uint8_t)(u32); *(p)++ = (uint8_t)(u32);
*(p)++ = (uint8_t)((u32) >> 8); *(p)++ = (uint8_t)((u32) >> 8);
@@ -99,7 +99,7 @@ uint8_t* UINT32_TO_STREAM_f (uint8_t *p, unsigned long u32)
* *
*****************************************************************************/ *****************************************************************************/
uint8_t* UINT16_TO_STREAM_f (uint8_t *p, uint16_t u16) uint8_t *UINT16_TO_STREAM_f(uint8_t *p, uint16_t u16)
{ {
*(p)++ = (uint8_t)(u16); *(p)++ = (uint8_t)(u16);
*(p)++ = (uint8_t)((u16) >> 8); *(p)++ = (uint8_t)((u16) >> 8);
+1 -1
View File
@@ -79,7 +79,7 @@
* *
*****************************************************************************/ *****************************************************************************/
long netapp_config_mac_adrress(uint8_t * mac) long netapp_config_mac_adrress(uint8_t *mac)
{ {
return nvmem_set_mac_address(mac); return nvmem_set_mac_address(mac);
} }
+1 -1
View File
@@ -279,7 +279,7 @@ uint8_t nvmem_write_patch(unsigned long ulFileId, unsigned long spLength,
*****************************************************************************/ *****************************************************************************/
#ifndef CC3000_TINY_DRIVER #ifndef CC3000_TINY_DRIVER
uint8_t nvmem_read_sp_version(uint8_t* patchVer) uint8_t nvmem_read_sp_version(uint8_t *patchVer)
{ {
uint8_t *ptr; uint8_t *ptr;
/* 1st byte is the status and the rest is the SP version */ /* 1st byte is the status and the rest is the SP version */
+126 -118
View File
@@ -1,50 +1,53 @@
/***************************************************************************** /*****************************************************************************
* * security.c - CC3000 Host Driver Implementation.
* security.c - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ *
* * Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions * are met:
* are met: *
* * Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer. *
* * Redistributions in binary form must reproduce the above copyright
* Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the
* notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the
* documentation and/or other materials provided with the * distribution.
* distribution. *
* * Neither the name of Texas Instruments Incorporated nor the names of
* Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived
* its contributors may be used to endorse or promote products derived * from this software without specific prior written permission.
* from this software without specific prior written permission. *
* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *****************************************************************************/
*****************************************************************************/
//***************************************************************************** /*****************************************************************************
// * Included Files
//! \addtogroup security_api *****************************************************************************/
//! @{
//
//*****************************************************************************
#include <nuttx/wireless/cc3000/security.h> #include <nuttx/wireless/cc3000/security.h>
#ifndef CC3000_UNENCRYPTED_SMART_CONFIG #ifndef CC3000_UNENCRYPTED_SMART_CONFIG
/*****************************************************************************
* Private Data
*****************************************************************************/
// foreward sbox // foreward sbox
const uint8_t sbox[256] = {
const uint8_t sbox[256] =
{
//0 1 2 3 4 5 6 7 8 9 A B C D E F //0 1 2 3 4 5 6 7 8 9 A B C D E F
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, //0 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, //0
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, //1 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, //1
@@ -61,10 +64,14 @@ const uint8_t sbox[256] = {
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, //C 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, //C
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, //D 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, //D
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, //E 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, //E
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; //F 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 //F
};
// inverse sbox // inverse sbox
const uint8_t rsbox[256] = const uint8_t rsbox[256] =
{ 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb {
0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb
, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb , 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb
, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e , 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e
, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25 , 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25
@@ -79,14 +86,21 @@ const uint8_t rsbox[256] =
, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f , 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f
, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef , 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef
, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61 , 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61
, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d }; , 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
// round constant };
const uint8_t Rcon[11] = {
0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36};
// round constant
const uint8_t Rcon[11] =
{
0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36
};
uint8_t aexpandedKey[176]; uint8_t aexpandedKey[176];
/*****************************************************************************
* Public Functions
*****************************************************************************/
//***************************************************************************** //*****************************************************************************
// //
//! expandKey //! expandKey
@@ -104,9 +118,12 @@ void expandKey(uint8_t *expandedKey,
uint8_t *key) uint8_t *key)
{ {
uint16_t ii, buf1; uint16_t ii, buf1;
for (ii=0;ii<16;ii++) for (ii=0;ii<16;ii++)
expandedKey[ii] = key[ii]; expandedKey[ii] = key[ii];
for (ii=1;ii<11;ii++){
for (ii=1;ii<11;ii++)
{
buf1 = expandedKey[ii*16 - 4]; buf1 = expandedKey[ii*16 - 4];
expandedKey[ii*16 + 0] = sbox[expandedKey[ii*16 - 3]]^expandedKey[(ii-1)*16 + 0]^Rcon[ii]; expandedKey[ii*16 + 0] = sbox[expandedKey[ii*16 - 3]]^expandedKey[(ii-1)*16 + 0]^Rcon[ii];
expandedKey[ii*16 + 1] = sbox[expandedKey[ii*16 - 2]]^expandedKey[(ii-1)*16 + 1]; expandedKey[ii*16 + 1] = sbox[expandedKey[ii*16 - 2]]^expandedKey[(ii-1)*16 + 1];
@@ -125,7 +142,6 @@ void expandKey(uint8_t *expandedKey,
expandedKey[ii*16 +14] = expandedKey[(ii-1)*16 +14]^expandedKey[ii*16 +10]; expandedKey[ii*16 +14] = expandedKey[(ii-1)*16 +14]^expandedKey[ii*16 +10];
expandedKey[ii*16 +15] = expandedKey[(ii-1)*16 +15]^expandedKey[ii*16 +11]; expandedKey[ii*16 +15] = expandedKey[(ii-1)*16 +15]^expandedKey[ii*16 +11];
} }
} }
//***************************************************************************** //*****************************************************************************
@@ -427,69 +443,67 @@ void aes_decr(uint8_t *state, uint8_t *expandedKey)
} }
//***************************************************************************** /*****************************************************************************
// * Name: aes_encrypt
//! aes_encrypt *
//! * Description:
//! @param[in] key AES128 key of size 16 bytes * AES128 encryption: Given AES128 key and 16 bytes plain text, cipher
//! @param[in\out] state 16 bytes of plain text and cipher text * text of 16 bytes is computed. The AES implementation is in mode ECB
//! * (Electronic Code Book).
//! @return none *
//! * Input Parameters:
//! @brief AES128 encryption: * key AES128 key of size 16 bytes
//! Given AES128 key and 16 bytes plain text, cipher text of 16 bytes * state 16 bytes of plain text and cipher text
//! is computed. The AES implementation is in mode ECB (Electronic *
//! Code Book). * Returned Value
//! * None
//! *
//***************************************************************************** *****************************************************************************/
void aes_encrypt(uint8_t *state, void aes_encrypt(uint8_t *state, uint8_t *key)
uint8_t *key)
{ {
// expand the key into 176 bytes // expand the key into 176 bytes
expandKey(aexpandedKey, key); expandKey(aexpandedKey, key);
aes_encr(state, aexpandedKey); aes_encr(state, aexpandedKey);
} }
//***************************************************************************** /*****************************************************************************
// * Name: aes_decrypt
//! aes_decrypt *
//! * Description:
//! @param[in] key AES128 key of size 16 bytes * AES128 decryption: Given AES128 key and 16 bytes cipher text, plain
//! @param[in\out] state 16 bytes of cipher text and plain text * text of 16 bytes is computed The AES implementation is in mode ECB
//! * (Electronic Code Book).
//! @return none *
//! * Input Parameters:
//! @brief AES128 decryption: * key AES128 key of size 16 bytes
//! Given AES128 key and 16 bytes cipher text, plain text of 16 bytes * state 16 bytes of plain text and cipher text
//! is computed The AES implementation is in mode ECB *
//! (Electronic Code Book). * Returned Value
//! * None
//! *
//***************************************************************************** *****************************************************************************/
void aes_decrypt(uint8_t *state, void aes_decrypt(uint8_t *state, uint8_t *key)
uint8_t *key)
{ {
expandKey(aexpandedKey, key); // expand the key into 176 bytes expandKey(aexpandedKey, key); // expand the key into 176 bytes
aes_decr(state, aexpandedKey); aes_decr(state, aexpandedKey);
} }
//***************************************************************************** /*****************************************************************************
// * Name: aes_read_key
//! aes_read_key *
//! * Description:
//! @param[out] key AES128 key of size 16 bytes * Reads AES128 key from EEPROM. Reads the AES128 key from fileID #12 in
//! * EEPROM returns an error if the key does not exist.
//! @return on success 0, error otherwise. *
//! * Input Parameters:
//! @brief Reads AES128 key from EEPROM * key AES128 key of size 16 bytes
//! Reads the AES128 key from fileID #12 in EEPROM *
//! returns an error if the key does not exist. * Returned Value
//! * On success 0, error otherwise.
//! *
//***************************************************************************** *****************************************************************************/
signed long aes_read_key(uint8_t *key) signed long aes_read_key(uint8_t *key)
{ {
@@ -500,19 +514,20 @@ signed long aes_read_key(uint8_t *key)
return returnValue; return returnValue;
} }
//***************************************************************************** /*****************************************************************************
// * Name: aes_write_key
//! aes_write_key *
//! * Description:
//! @param[out] key AES128 key of size 16 bytes * Writes AES128 key from EEPROM Writes the AES128 key to fileID #12 in
//! * EEPROM
//! @return on success 0, error otherwise. *
//! * Input Parameters:
//! @brief writes AES128 key from EEPROM * key AES128 key of size 16 bytes
//! Writes the AES128 key to fileID #12 in EEPROM *
//! * Returned Value
//! * On success 0, error otherwise.
//***************************************************************************** *
*****************************************************************************/
signed long aes_write_key(uint8_t *key) signed long aes_write_key(uint8_t *key)
{ {
@@ -524,10 +539,3 @@ signed long aes_write_key(uint8_t *key)
} }
#endif //CC3000_UNENCRYPTED_SMART_CONFIG #endif //CC3000_UNENCRYPTED_SMART_CONFIG
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
+120 -121
View File
@@ -183,6 +183,11 @@ int HostFlowControlConsumeBuff(int sd)
/***************************************************************************** /*****************************************************************************
* Name: socket * Name: socket
* *
* Decription:
* create an endpoint for communication. The socket function creates a
* socket that is bound to a specific transport service provider. This
* function is called by the application layer to obtain a socket handle.
*
* Input Parameters: * Input Parameters:
* domain selects the protocol family which will be used for * domain selects the protocol family which will be used for
* communication. On this version only AF_INET is supported * communication. On this version only AF_INET is supported
@@ -196,12 +201,6 @@ int HostFlowControlConsumeBuff(int sd)
* On success, socket handle that is used for consequent socket * On success, socket handle that is used for consequent socket
* operations. On error, -1 is returned. * operations. On error, -1 is returned.
* *
* Decription:
* create an endpoint for communication
* The socket function creates a socket that is bound to a specific
* transport service provider. This function is called by the
* application layer to obtain a socket handle.
*
*****************************************************************************/ *****************************************************************************/
int socket(long domain, long type, long protocol) int socket(long domain, long type, long protocol)
@@ -239,15 +238,15 @@ int socket(long domain, long type, long protocol)
/***************************************************************************** /*****************************************************************************
* Name: closesocket * Name: closesocket
* *
* Decription:
* The socket function closes a created socket.
*
* Input Parameters: * Input Parameters:
* sd socket handle. * sd socket handle.
* *
* Returned Value: * Returned Value:
* On success, zero is returned. On error, -1 is returned. * On success, zero is returned. On error, -1 is returned.
* *
* Decription:
* The socket function closes a created socket.
*
*****************************************************************************/ *****************************************************************************/
long closesocket(long sd) long closesocket(long sd)
@@ -285,6 +284,25 @@ long closesocket(long sd)
/***************************************************************************** /*****************************************************************************
* Name: accept * Name: accept
* *
* Decription:
* accept a connection on a socket:
* This function is used with connection-based socket types
* (SOCK_STREAM). It extracts the first connection request on the
* queue of pending connections, creates a new connected socket, and
* returns a new file descriptor referring to that socket.
* The newly created socket is not in the listening state.
* The original socket sd is unaffected by this call.
* The argument sd is a socket that has been created with socket(),
* bound to a local address with bind(), and is listening for
* connections after a listen(). The argument addr is a pointer
* to a sockaddr structure. This structure is filled in with the
* address of the peer socket, as known to the communications layer.
* The exact format of the address returned addr is determined by the
* socket's address family. The addrlen argument is a value-result
* argument: it should initially contain the size of the structure
* pointed to by addr, on return it will contain the actual
* length (in bytes) of the address returned.
*
* Input Parameters: * Input Parameters:
* sd socket descriptor (handle) * sd socket descriptor (handle)
* addr the argument addr is a pointer to a sockaddr structure * addr the argument addr is a pointer to a sockaddr structure
@@ -306,25 +324,6 @@ long closesocket(long sd)
* - On connection pending, SOC_IN_PROGRESS (-2) * - On connection pending, SOC_IN_PROGRESS (-2)
* - On failure, SOC_ERROR (-1) * - On failure, SOC_ERROR (-1)
* *
* Decription:
* accept a connection on a socket:
* This function is used with connection-based socket types
* (SOCK_STREAM). It extracts the first connection request on the
* queue of pending connections, creates a new connected socket, and
* returns a new file descriptor referring to that socket.
* The newly created socket is not in the listening state.
* The original socket sd is unaffected by this call.
* The argument sd is a socket that has been created with socket(),
* bound to a local address with bind(), and is listening for
* connections after a listen(). The argument addr is a pointer
* to a sockaddr structure. This structure is filled in with the
* address of the peer socket, as known to the communications layer.
* The exact format of the address returned addr is determined by the
* socket's address family. The addrlen argument is a value-result
* argument: it should initially contain the size of the structure
* pointed to by addr, on return it will contain the actual
* length (in bytes) of the address returned.
*
*****************************************************************************/ *****************************************************************************/
long accept(long sd, sockaddr *addr, socklen_t *addrlen) long accept(long sd, sockaddr *addr, socklen_t *addrlen)
@@ -375,15 +374,6 @@ long accept(long sd, sockaddr *addr, socklen_t *addrlen)
/***************************************************************************** /*****************************************************************************
* Name: bind * Name: bind
* *
* Input Parameters:
* sd socket descriptor (handle)
* addr specifies the destination address. On this version
* only AF_INET is supported.
* addrlen contains the size of the structure pointed to by addr.
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned.
*
* Decription: * Decription:
* assign a name to a socket * assign a name to a socket
* This function gives the socket the local address addr. * This function gives the socket the local address addr.
@@ -393,6 +383,15 @@ long accept(long sd, sockaddr *addr, socklen_t *addrlen)
* It is necessary to assign a local address before a SOCK_STREAM * It is necessary to assign a local address before a SOCK_STREAM
* socket may receive connections. * socket may receive connections.
* *
* Input Parameters:
* sd socket descriptor (handle)
* addr specifies the destination address. On this version
* only AF_INET is supported.
* addrlen contains the size of the structure pointed to by addr.
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned.
*
*****************************************************************************/ *****************************************************************************/
long bind(long sd, const sockaddr *addr, long addrlen) long bind(long sd, const sockaddr *addr, long addrlen)
@@ -430,14 +429,6 @@ long bind(long sd, const sockaddr *addr, long addrlen)
/***************************************************************************** /*****************************************************************************
* Name: listen * Name: listen
* *
* Input Parameters:
* sd socket descriptor (handle)
* backlog specifies the listen queue depth. On this version
* backlog is not supported.
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned.
*
* Decription: * Decription:
* listen for connections on a socket * listen for connections on a socket
* The willingness to accept incoming connections and a queue * The willingness to accept incoming connections and a queue
@@ -449,6 +440,14 @@ long bind(long sd, const sockaddr *addr, long addrlen)
* *
* NOTE: On this version, backlog is not supported * NOTE: On this version, backlog is not supported
* *
* Input Parameters:
* sd socket descriptor (handle)
* backlog specifies the listen queue depth. On this version
* backlog is not supported.
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned.
*
*****************************************************************************/ *****************************************************************************/
long listen(long sd, long backlog) long listen(long sd, long backlog)
@@ -481,6 +480,14 @@ long listen(long sd, long backlog)
/***************************************************************************** /*****************************************************************************
* Name: gethostbyname * Name: gethostbyname
* *
* Decription:
* Get host IP by name. Obtain the IP Address of machine on network,
* by its name.
*
* NOTE: On this version, only blocking mode is supported. Also note that
* the function requires DNS server to be configured prior to its
* usage.
*
* Input Parameters: * Input Parameters:
* hostname host name * hostname host name
* usNameLen name length * usNameLen name length
@@ -491,14 +498,6 @@ long listen(long sd, long backlog)
* Returned Value: * Returned Value:
* On success, positive is returned. On error, negative is returned * On success, positive is returned. On error, negative is returned
* *
* Decription:
* Get host IP by name. Obtain the IP Address of machine on network,
* by its name.
*
* NOTE: On this version, only blocking mode is supported. Also note that
* the function requires DNS server to be configured prior to its
* usage.
*
*****************************************************************************/ *****************************************************************************/
#ifndef CC3000_TINY_DRIVER #ifndef CC3000_TINY_DRIVER
@@ -543,15 +542,6 @@ int gethostbyname(char * hostname, uint16_t usNameLen, unsigned long* out_ip_add
/***************************************************************************** /*****************************************************************************
* Name: connect * Name: connect
* *
* Input Parameters:
* sd socket descriptor (handle)
* addr specifies the destination addr. On this version
* only AF_INET is supported.
* addrlen contains the size of the structure pointed to by addr
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned
*
* Decription: * Decription:
* initiate a connection on a socket * initiate a connection on a socket
* Function connects the socket referred to by the socket descriptor * Function connects the socket referred to by the socket descriptor
@@ -568,6 +558,15 @@ int gethostbyname(char * hostname, uint16_t usNameLen, unsigned long* out_ip_add
* thus the caller will be waiting either for the connection * thus the caller will be waiting either for the connection
* establishment or for the connection establishment failure. * establishment or for the connection establishment failure.
* *
* Input Parameters:
* sd socket descriptor (handle)
* addr specifies the destination addr. On this version
* only AF_INET is supported.
* addrlen contains the size of the structure pointed to by addr
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned
*
*****************************************************************************/ *****************************************************************************/
long connect(long sd, const sockaddr *addr, long addrlen) long connect(long sd, const sockaddr *addr, long addrlen)
@@ -604,6 +603,15 @@ long connect(long sd, const sockaddr *addr, long addrlen)
/***************************************************************************** /*****************************************************************************
* Name: select * Name: select
* *
* Decription:
* Monitor socket activity
* Select allow a program to monitor multiple file descriptors,
* waiting until one or more of the file descriptors become
* "ready" for some class of I/O operation
*
* NOTE: If the timeout value set to less than 5ms it will automatically set
* to 5ms to prevent overload of the system
*
* Input Parameters: * Input Parameters:
* nfds the highest-numbered file descriptor in any of the * nfds the highest-numbered file descriptor in any of the
* three sets, plus 1. * three sets, plus 1.
@@ -629,15 +637,6 @@ long connect(long sd, const sockaddr *addr, long addrlen)
* will return without delay. * will return without delay.
* *exceptsds - return the sockets which closed recently. * *exceptsds - return the sockets which closed recently.
* *
* Decription:
* Monitor socket activity
* Select allow a program to monitor multiple file descriptors,
* waiting until one or more of the file descriptors become
* "ready" for some class of I/O operation
*
* NOTE: If the timeout value set to less than 5ms it will automatically set
* to 5ms to prevent overload of the system
*
*****************************************************************************/ *****************************************************************************/
int select(long nfds, TICC3000fd_set *readsds, TICC3000fd_set *writesds, int select(long nfds, TICC3000fd_set *readsds, TICC3000fd_set *writesds,
@@ -724,16 +723,6 @@ int select(long nfds, TICC3000fd_set *readsds, TICC3000fd_set *writesds,
/***************************************************************************** /*****************************************************************************
* Name: setsockopt * Name: setsockopt
* *
* Input Parameters:
* sd socket handle
* level defines the protocol level for this option
* optname defines the option name to Interrogate
* optval specifies a value for the option
* optlen specifies the length of the option value
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned
*
* Decription: * Decription:
* set socket options * set socket options
* This function manipulate the options associated with a socket. * This function manipulate the options associated with a socket.
@@ -767,6 +756,16 @@ int select(long nfds, TICC3000fd_set *readsds, TICC3000fd_set *writesds,
* or off. * or off.
* In that case optval should be SOCK_ON or SOCK_OFF (optval). * In that case optval should be SOCK_ON or SOCK_OFF (optval).
* *
* Input Parameters:
* sd socket handle
* level defines the protocol level for this option
* optname defines the option name to Interrogate
* optval specifies a value for the option
* optlen specifies the length of the option value
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned
*
*****************************************************************************/ *****************************************************************************/
#ifndef CC3000_TINY_DRIVER #ifndef CC3000_TINY_DRIVER
@@ -811,16 +810,6 @@ int setsockopt(long sd, long level, long optname, const void *optval, socklen_t
/***************************************************************************** /*****************************************************************************
* Name: getsockopt * Name: getsockopt
* *
* Input Parameters:
* sd socket handle
* level defines the protocol level for this option
* optname defines the option name to Interrogate
* optval specifies a value for the option
* optlen specifies the length of the option value
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned
*
* Decription: * Decription:
* set socket options * set socket options
* This function manipulate the options associated with a socket. * This function manipulate the options associated with a socket.
@@ -854,6 +843,16 @@ int setsockopt(long sd, long level, long optname, const void *optval, socklen_t
* or off. * or off.
* In that case optval should be SOCK_ON or SOCK_OFF (optval). * In that case optval should be SOCK_ON or SOCK_OFF (optval).
* *
* Input Parameters:
* sd socket handle
* level defines the protocol level for this option
* optname defines the option name to Interrogate
* optval specifies a value for the option
* optlen specifies the length of the option value
*
* Returned Value:
* On success, zero is returned. On error, -1 is returned
*
*****************************************************************************/ *****************************************************************************/
int getsockopt (long sd, long level, long optname, void *optval, socklen_t *optlen) int getsockopt (long sd, long level, long optname, void *optval, socklen_t *optlen)
@@ -958,6 +957,11 @@ int simple_link_recv(long sd, void *buf, long len, long flags, sockaddr *from,
/***************************************************************************** /*****************************************************************************
* Name: recv * Name: recv
* *
* Decription:
* function receives a message from a connection-mode socket
*
* NOTE: On this version, only blocking mode is supported.
*
* Input Parameters: * Input Parameters:
* sd socket handle * sd socket handle
* buf Points to the buffer where the message should be stored * buf Points to the buffer where the message should be stored
@@ -970,11 +974,6 @@ int simple_link_recv(long sd, void *buf, long len, long flags, sockaddr *from,
* Return the number of bytes received, or -1 if an error * Return the number of bytes received, or -1 if an error
* occurred * occurred
* *
* Decription:
* function receives a message from a connection-mode socket
*
* NOTE: On this version, only blocking mode is supported.
*
*****************************************************************************/ *****************************************************************************/
int recv(long sd, void *buf, long len, long flags) int recv(long sd, void *buf, long len, long flags)
@@ -985,6 +984,14 @@ int recv(long sd, void *buf, long len, long flags)
/***************************************************************************** /*****************************************************************************
* Name: recvfrom * Name: recvfrom
* *
* Decription:
* read data from socket
* function receives a message from a connection-mode or
* connectionless-mode socket. Note that raw sockets are not
* supported.
*
* NOTE: On this version, only blocking mode is supported.
*
* Input Parameters: * Input Parameters:
* sd socket handle * sd socket handle
* buf Points to the buffer where the message should be stored * buf Points to the buffer where the message should be stored
@@ -1001,14 +1008,6 @@ int recv(long sd, void *buf, long len, long flags)
* Return the number of bytes received, or -1 if an error * Return the number of bytes received, or -1 if an error
* occurred * occurred
* *
* Decription:
* read data from socket
* function receives a message from a connection-mode or
* connectionless-mode socket. Note that raw sockets are not
* supported.
*
* NOTE: On this version, only blocking mode is supported.
*
*****************************************************************************/ *****************************************************************************/
int recvfrom(long sd, void *buf, long len, long flags, sockaddr *from, int recvfrom(long sd, void *buf, long len, long flags, sockaddr *from,
@@ -1137,6 +1136,13 @@ int simple_link_send(long sd, const void *buf, long len, long flags,
/***************************************************************************** /*****************************************************************************
* Name: send * Name: send
* *
* Decription:
* Write data to TCP socket
* This function is used to transmit a message to another
* socket.
*
* NOTE: On this version, only blocking mode is supported.
*
* Input Parameters: * Input Parameters:
* sd socket handle * sd socket handle
* buf Points to a buffer containing the message to be sent * buf Points to a buffer containing the message to be sent
@@ -1147,13 +1153,6 @@ int simple_link_send(long sd, const void *buf, long len, long flags,
* Return the number of bytes transmitted, or -1 if an * Return the number of bytes transmitted, or -1 if an
* error occurred * error occurred
* *
* Decription:
* Write data to TCP socket
* This function is used to transmit a message to another
* socket.
*
* NOTE: On this version, only blocking mode is supported.
*
*****************************************************************************/ *****************************************************************************/
int send(long sd, const void *buf, long len, long flags) int send(long sd, const void *buf, long len, long flags)
@@ -1164,6 +1163,13 @@ int send(long sd, const void *buf, long len, long flags)
/***************************************************************************** /*****************************************************************************
* Name: sendto * Name: sendto
* *
* Decription:
* Write data to TCP socket
* This function is used to transmit a message to another
* socket.
*
* NOTE: On this version, only blocking mode is supported.
*
* Input Parameters: * Input Parameters:
* sd socket handle * sd socket handle
* buf Points to a buffer containing the message to be sent * buf Points to a buffer containing the message to be sent
@@ -1178,13 +1184,6 @@ int send(long sd, const void *buf, long len, long flags)
* Return the number of bytes transmitted, or -1 if an * Return the number of bytes transmitted, or -1 if an
* error occurred * error occurred
* *
* Decription:
* Write data to TCP socket
* This function is used to transmit a message to another
* socket.
*
* NOTE: On this version, only blocking mode is supported.
*
*****************************************************************************/ *****************************************************************************/
int sendto(long sd, const void *buf, long len, long flags, const sockaddr *to, int sendto(long sd, const void *buf, long len, long flags, const sockaddr *to,
@@ -1196,6 +1195,9 @@ int sendto(long sd, const void *buf, long len, long flags, const sockaddr *to,
/***************************************************************************** /*****************************************************************************
* Name: mdnsAdvertiser * Name: mdnsAdvertiser
* *
* Decription:
* Set CC3000 in mDNS advertiser mode in order to advertise itself.
*
* Input Parameters: * Input Parameters:
* mdnsEnabled flag to enable/disable the mDNS feature * mdnsEnabled flag to enable/disable the mDNS feature
* deviceServiceName Service name as part of the published * deviceServiceName Service name as part of the published
@@ -1206,9 +1208,6 @@ int sendto(long sd, const void *buf, long len, long flags, const sockaddr *to,
* On success, zero is returned, return SOC_ERROR if socket was not * On success, zero is returned, return SOC_ERROR if socket was not
* opened successfully, or if an error occurred. * opened successfully, or if an error occurred.
* *
* Decription:
* Set CC3000 in mDNS advertiser mode in order to advertise itself.
* NOTE:
*****************************************************************************/ *****************************************************************************/
int mdnsAdvertiser(uint16_t mdnsEnabled, char * deviceServiceName, int mdnsAdvertiser(uint16_t mdnsEnabled, char * deviceServiceName,
+4
View File
@@ -21,6 +21,10 @@
#ifndef __DRIVERS_WIRELESS_CC3000_SPI_H #ifndef __DRIVERS_WIRELESS_CC3000_SPI_H
#define __DRIVERS_WIRELESS_CC3000_SPI_H #define __DRIVERS_WIRELESS_CC3000_SPI_H
/*****************************************************************************
* Included Files
*****************************************************************************/
#include <stdint.h> #include <stdint.h>
/***************************************************************************** /*****************************************************************************
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -32,11 +32,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
*****************************************************************************/ *****************************************************************************/
#ifndef __EVENT_HANDLER_H__ #ifndef _INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
#define __EVENT_HANDLER_H__ #define _INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
#include <nuttx/wireless/cc3000/hci.h> #include <nuttx/wireless/cc3000/hci.h>
#include <nuttx/wireless/cc3000/socket.h> #include <nuttx/wireless/cc3000/include/sys/socket.h>
//***************************************************************************** //*****************************************************************************
// //
@@ -163,5 +163,5 @@ typedef struct _bsd_gethostbyname_return_t
} }
#endif // __cplusplus #endif // __cplusplus
#endif // __EVENT_HANDLER_H__ #endif // _INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
+132 -162
View File
@@ -1,52 +1,49 @@
/***************************************************************************** /*****************************************************************************
* * hci.h - CC3000 Host Driver Implementation.
* hci.h - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ *
* * Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions * are met:
* are met: *
* * Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer. *
* * Redistributions in binary form must reproduce the above copyright
* Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the
* notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the
* documentation and/or other materials provided with the * distribution.
* distribution. *
* * Neither the name of Texas Instruments Incorporated nor the names of
* Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived
* its contributors may be used to endorse or promote products derived * from this software without specific prior written permission.
* from this software without specific prior written permission. *
* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *****************************************************************************/
*****************************************************************************/
#ifndef __HCI_H__
#define __HCI_H__
#include <nuttx/wireless/cc3000/cc3000_common.h> #ifndef _INCLUDE_NUTTX_WIRELESS_CC3000_HCI_H
#define _INCLUDE_NUTTX_WIRELESS_CC3000_HCI_H
//***************************************************************************** /*****************************************************************************
// * Included Files
// If building with a C++ compiler, make all of the definitions in this header *****************************************************************************/
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C" {
#endif
#include "cc3000_common.h"
/*****************************************************************************
* Pre-processor Definitions
*****************************************************************************/
#define SPI_HEADER_SIZE (5) #define SPI_HEADER_SIZE (5)
#define SIMPLE_LINK_HCI_CMND_HEADER_SIZE (4) #define SIMPLE_LINK_HCI_CMND_HEADER_SIZE (4)
@@ -55,23 +52,17 @@ extern "C" {
#define SIMPLE_LINK_HCI_DATA_HEADER_SIZE (5) #define SIMPLE_LINK_HCI_DATA_HEADER_SIZE (5)
#define SIMPLE_LINK_HCI_PATCH_HEADER_SIZE (2) #define SIMPLE_LINK_HCI_PATCH_HEADER_SIZE (2)
/* Values that can be used as HCI Commands and HCI Packet header defines */
//*****************************************************************************
//
// Values that can be used as HCI Commands and HCI Packet header defines
//
//*****************************************************************************
#define HCI_TYPE_CMND 0x1 #define HCI_TYPE_CMND 0x1
#define HCI_TYPE_DATA 0x2 #define HCI_TYPE_DATA 0x2
#define HCI_TYPE_PATCH 0x3 #define HCI_TYPE_PATCH 0x3
#define HCI_TYPE_EVNT 0x4 #define HCI_TYPE_EVNT 0x4
#define HCI_EVENT_PATCHES_DRV_REQ (1) #define HCI_EVENT_PATCHES_DRV_REQ (1)
#define HCI_EVENT_PATCHES_FW_REQ (2) #define HCI_EVENT_PATCHES_FW_REQ (2)
#define HCI_EVENT_PATCHES_BOOTLOAD_REQ (3) #define HCI_EVENT_PATCHES_BOOTLOAD_REQ (3)
#define HCI_CMND_WLAN_BASE (0x0000) #define HCI_CMND_WLAN_BASE (0x0000)
#define HCI_CMND_WLAN_CONNECT 0x0001 #define HCI_CMND_WLAN_CONNECT 0x0001
#define HCI_CMND_WLAN_DISCONNECT 0x0002 #define HCI_CMND_WLAN_DISCONNECT 0x0002
@@ -87,7 +78,6 @@ extern "C" {
#define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX 0x000C #define HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX 0x000C
#define HCI_CMND_WLAN_CONFIGURE_PATCH 0x000D #define HCI_CMND_WLAN_CONFIGURE_PATCH 0x000D
#define HCI_CMND_SOCKET_BASE 0x1000 #define HCI_CMND_SOCKET_BASE 0x1000
#define HCI_CMND_SOCKET 0x1001 #define HCI_CMND_SOCKET 0x1001
#define HCI_CMND_BIND 0x1002 #define HCI_CMND_BIND 0x1002
@@ -103,7 +93,6 @@ extern "C" {
#define HCI_CMND_GETHOSTNAME 0x1010 #define HCI_CMND_GETHOSTNAME 0x1010
#define HCI_CMND_MDNS_ADVERTISE 0x1011 #define HCI_CMND_MDNS_ADVERTISE 0x1011
#define HCI_DATA_BASE 0x80 #define HCI_DATA_BASE 0x80
#define HCI_CMND_SEND (0x01 + HCI_DATA_BASE) #define HCI_CMND_SEND (0x01 + HCI_DATA_BASE)
@@ -111,10 +100,8 @@ extern "C" {
#define HCI_DATA_BSD_RECVFROM (0x04 + HCI_DATA_BASE) #define HCI_DATA_BSD_RECVFROM (0x04 + HCI_DATA_BASE)
#define HCI_DATA_BSD_RECV (0x05 + HCI_DATA_BASE) #define HCI_DATA_BSD_RECV (0x05 + HCI_DATA_BASE)
#define HCI_CMND_NVMEM_CBASE (0x0200) #define HCI_CMND_NVMEM_CBASE (0x0200)
#define HCI_CMND_NVMEM_CREATE_ENTRY (0x0203) #define HCI_CMND_NVMEM_CREATE_ENTRY (0x0203)
#define HCI_CMND_NVMEM_SWAP_ENTRY (0x0205) #define HCI_CMND_NVMEM_SWAP_ENTRY (0x0205)
#define HCI_CMND_NVMEM_READ (0x0201) #define HCI_CMND_NVMEM_READ (0x0201)
@@ -136,23 +123,12 @@ extern "C" {
#define HCI_NETAPP_SET_DEBUG_LEVEL (0x0008 + HCI_CMND_NETAPP_BASE) #define HCI_NETAPP_SET_DEBUG_LEVEL (0x0008 + HCI_CMND_NETAPP_BASE)
#define HCI_NETAPP_SET_TIMERS (0x0009 + HCI_CMND_NETAPP_BASE) #define HCI_NETAPP_SET_TIMERS (0x0009 + HCI_CMND_NETAPP_BASE)
/* Values that can be used as HCI Events defines */
//*****************************************************************************
//
// Values that can be used as HCI Events defines
//
//*****************************************************************************
#define HCI_EVNT_WLAN_BASE 0x0000 #define HCI_EVNT_WLAN_BASE 0x0000
#define HCI_EVNT_WLAN_CONNECT 0x0001 #define HCI_EVNT_WLAN_CONNECT 0x0001
#define HCI_EVNT_WLAN_DISCONNECT \ #define HCI_EVNT_WLAN_DISCONNECT 0x0002
0x0002 #define HCI_EVNT_WLAN_IOCTL_ADD_PROFILE 0x0005
#define HCI_EVNT_WLAN_IOCTL_ADD_PROFILE \
0x0005
#define HCI_EVNT_SOCKET HCI_CMND_SOCKET #define HCI_EVNT_SOCKET HCI_CMND_SOCKET
#define HCI_EVNT_BIND HCI_CMND_BIND #define HCI_EVNT_BIND HCI_CMND_BIND
@@ -166,7 +142,7 @@ extern "C" {
#define HCI_EVNT_SETSOCKOPT HCI_CMND_SETSOCKOPT #define HCI_EVNT_SETSOCKOPT HCI_CMND_SETSOCKOPT
#define HCI_EVNT_GETSOCKOPT HCI_CMND_GETSOCKOPT #define HCI_EVNT_GETSOCKOPT HCI_CMND_GETSOCKOPT
#define HCI_EVNT_BSD_GETHOSTBYNAME HCI_CMND_GETHOSTNAME #define HCI_EVNT_BSD_GETHOSTBYNAME HCI_CMND_GETHOSTNAME
#define HCI_EVNT_MDNS_ADVERTISE HCI_CMND_MDNS_ADVERTISE #define HCI_EVNT_MDNS_ADVERTISE CI_CMND_MDNS_ADVERTISE
#define HCI_EVNT_SEND 0x1003 #define HCI_EVNT_SEND 0x1003
#define HCI_EVNT_WRITE 0x100E #define HCI_EVNT_WRITE 0x100E
@@ -188,18 +164,15 @@ extern "C" {
#define HCI_EVNT_WLAN_KEEPALIVE (0x0200 + HCI_EVNT_WLAN_UNSOL_BASE) #define HCI_EVNT_WLAN_KEEPALIVE (0x0200 + HCI_EVNT_WLAN_UNSOL_BASE)
#define HCI_EVNT_BSD_TCP_CLOSE_WAIT (0x0800 + HCI_EVNT_WLAN_UNSOL_BASE) #define HCI_EVNT_BSD_TCP_CLOSE_WAIT (0x0800 + HCI_EVNT_WLAN_UNSOL_BASE)
#define HCI_EVNT_DATA_UNSOL_FREE_BUFF \ #define HCI_EVNT_DATA_UNSOL_FREE_BUFF 0x4100
0x4100
#define HCI_EVNT_NVMEM_CREATE_ENTRY \ #define HCI_EVNT_NVMEM_CREATE_ENTRY HCI_CMND_NVMEM_CREATE_ENTRY
HCI_CMND_NVMEM_CREATE_ENTRY
#define HCI_EVNT_NVMEM_SWAP_ENTRY HCI_CMND_NVMEM_SWAP_ENTRY #define HCI_EVNT_NVMEM_SWAP_ENTRY HCI_CMND_NVMEM_SWAP_ENTRY
#define HCI_EVNT_NVMEM_READ HCI_CMND_NVMEM_READ #define HCI_EVNT_NVMEM_READ HCI_CMND_NVMEM_READ
#define HCI_EVNT_NVMEM_WRITE (0x0202) #define HCI_EVNT_NVMEM_WRITE (0x0202)
#define HCI_EVNT_READ_SP_VERSION \ #define HCI_EVNT_READ_SP_VERSION HCI_CMND_READ_SP_VERSION
HCI_CMND_READ_SP_VERSION
#define HCI_EVNT_INPROGRESS 0xFFFF #define HCI_EVNT_INPROGRESS 0xFFFF
@@ -210,12 +183,6 @@ extern "C" {
#define HCI_EVENT_CC3000_CAN_SHUT_DOWN 0x99 #define HCI_EVENT_CC3000_CAN_SHUT_DOWN 0x99
//*****************************************************************************
//
// Prototypes for the structures for APIs.
//
//*****************************************************************************
#define HCI_DATA_HEADER_SIZE (5) #define HCI_DATA_HEADER_SIZE (5)
#define HCI_EVENT_HEADER_SIZE (5) #define HCI_EVENT_HEADER_SIZE (5)
#define HCI_DATA_CMD_HEADER_SIZE (5) #define HCI_DATA_CMD_HEADER_SIZE (5)
@@ -225,104 +192,107 @@ extern "C" {
#define HCI_PACKET_ARGSIZE_OFFSET (2) #define HCI_PACKET_ARGSIZE_OFFSET (2)
#define HCI_PACKET_LENGTH_OFFSET (3) #define HCI_PACKET_LENGTH_OFFSET (3)
#define HCI_EVENT_OPCODE_OFFSET (1) #define HCI_EVENT_OPCODE_OFFSET (1)
#define HCI_EVENT_LENGTH_OFFSET (3) #define HCI_EVENT_LENGTH_OFFSET (3)
#define HCI_EVENT_STATUS_OFFSET (4) #define HCI_EVENT_STATUS_OFFSET (4)
#define HCI_DATA_LENGTH_OFFSET (3) #define HCI_DATA_LENGTH_OFFSET (3)
/*****************************************************************************
* Public Data
*****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
* Public Function Prototypes
*****************************************************************************/
//***************************************************************************** /******************************************************************************
// * Name: hci_command_send
// Prototypes for the APIs. *
// * Description:
//***************************************************************************** * Initiate an HCI command.
*
* Input Parameters:
* usOpcode command operation code
* pucBuff pointer to the command's arguments buffer
* ucArgsLength length of the arguments
*
* Returned Value:
* Zero
*
*****************************************************************************/
//***************************************************************************** uint16_t hci_command_send(uint16_t usOpcode, uint8_t *pucBuff,
//
//! hci_command_send
//!
//! @param usOpcode command operation code
//! @param pucBuff pointer to the command's arguments buffer
//! @param ucArgsLength length of the arguments
//!
//! @return none
//!
//! @brief Initiate an HCI command.
//
//*****************************************************************************
extern uint16_t hci_command_send(uint16_t usOpcode,
uint8_t *ucArgs,
uint8_t ucArgsLength); uint8_t ucArgsLength);
//***************************************************************************** /******************************************************************************
// * Name: hci_data_send
//! hci_data_send *
//! * Description:
//! @param usOpcode command operation code *
//! @param ucArgs pointer to the command's arguments buffer *
//! @param usArgsLength length of the arguments * Input Parameters:
//! @param ucTail pointer to the data buffer * usOpcode command operation code
//! @param usTailLength buffer length * ucArgs pointer to the command's arguments buffer
//! * usArgsLength length of the arguments
//! @return none * ucTail pointer to the data buffer
//! * usTailLength buffer length
//! @brief Initiate an HCI data write operation *
// * Returned Value:
//***************************************************************************** * None
extern long hci_data_send(uint8_t ucOpcode, *
uint8_t *ucArgs, *****************************************************************************/
uint16_t usArgsLength,
uint16_t usDataLength, long hci_data_send(uint8_t ucOpcode, uint8_t *ucArgs, uint16_t usArgsLength,
const uint8_t *ucTail, uint16_t usDataLength, const uint8_t *ucTail,
uint16_t usTailLength); uint16_t usTailLength);
/******************************************************************************
* Name: hci_data_command_send
*
* Description:
* Prepeare HCI header and initiate an HCI data write operation
*
* Input Parameters:
* usOpcode command operation code
* pucBuff pointer to the data buffer
* ucArgsLength arguments length
* ucDataLength data length
*
* Returned Value:
* None
*
*****************************************************************************/
//***************************************************************************** void hci_data_command_send(uint16_t usOpcode, uint8_t *pucBuff,
// uint8_t ucArgsLength,uint16_t ucDataLength);
//! hci_data_command_send
//!
//! @param usOpcode command operation code
//! @param pucBuff pointer to the data buffer
//! @param ucArgsLength arguments length
//! @param ucDataLength data length
//!
//! @return none
//!
//! @brief Prepare HCI header and initiate an HCI data write operation
//
//*****************************************************************************
extern void hci_data_command_send(uint16_t usOpcode, uint8_t *pucBuff,
uint8_t ucArgsLength, uint16_t ucDataLength);
//***************************************************************************** /******************************************************************************
// * Name: hci_patch_send
//! hci_patch_send *
//! * Description:
//! @param usOpcode command operation code * Prepeare HCI header and initiate an HCI patch write operation
//! @param pucBuff pointer to the command's arguments buffer *
//! @param patch pointer to patch content buffer * Input Parameters:
//! @param usDataLength data length * usOpcode command operation code
//! * pucBuff pointer to the command's arguments buffer
//! @return none * patch pointer to patch content buffer
//! * usDataLength data length
//! @brief Prepare HCI header and initiate an HCI patch write operation *
// * Returned Value:
//***************************************************************************** * None
extern void hci_patch_send(uint8_t ucOpcode, uint8_t *pucBuff, char *patch, uint16_t usDataLength); *
*****************************************************************************/
void hci_patch_send(uint8_t ucOpcode, uint8_t *pucBuff, char *patch,
uint16_t usDataLength);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif // __cplusplus #endif // __cplusplus
#endif // __HCI_H__ #endif // _INCLUDE_NUTTX_WIRELESS_CC3000_HCI_H
@@ -1,55 +0,0 @@
/*****************************************************************************
*
* host_driver_version.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 __HOST_DRIVER_VERSION_H__
#define __HOST_DRIVER_VERSION_H__
#define DRIVER_VERSION_NUMBER 13
#endif // __VERSION_H__
@@ -44,8 +44,8 @@
* *
****************************************************************************/ ****************************************************************************/
#ifndef __INCLUDE_NUTTX_WIRELESS_CC3000_CC3000_INTERNAL_H #ifndef __INCLUDE_NUTTX_WIRELESS_CC3000_INCLUDE_CC3000_UPIFL_H
#define __INCLUDE_NUTTX_WIRELESS_CC3000_CC3000_INTERNAL_H #define __INCLUDE_NUTTX_WIRELESS_CC3000_INCLUDE_CC3000_UPIFL_H
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
@@ -76,12 +76,13 @@
#endif #endif
#ifndef CONFIG_CC3000_SPIMODE #ifndef CONFIG_CC3000_SPIMODE
// CPOL = 0, CPHA = 1 Sample Data Falling Edge of Clock /* CPOL = 0, CPHA = 1 Sample Data Falling Edge of Clock
// See http://processors.wiki.ti.com/index.php/CC3000_Serial_Port_Interface_(SPI) * See http://processors.wiki.ti.com/index.php/CC3000_Serial_Port_Interface_(SPI)
*/
# define CONFIG_CC3000_SPIMODE SPIDEV_MODE0 # define CONFIG_CC3000_SPIMODE SPIDEV_MODE0
#endif #endif
/* Check for some required settings. This can save the user a lot of time /* Check for some required settings. This can save the user a lot of time
* in getting the right configuration. * in getting the right configuration.
*/ */
@@ -178,11 +179,8 @@ extern "C" {
* *
****************************************************************************/ ****************************************************************************/
EXTERN int CC3000_register(FAR struct spi_dev_s *spi, int CC3000_register(FAR struct spi_dev_s *spi,
FAR struct cc3000_config_s *config, FAR struct cc3000_config_s *config, int minor);
int minor);
#undef EXTERN #undef EXTERN
#ifdef __cplusplus #ifdef __cplusplus
@@ -190,4 +188,4 @@ EXTERN int CC3000_register(FAR struct spi_dev_s *spi,
#endif #endif
#endif /* CONFIG_WIRELESS && CONFIG_INPUT_CC3000 */ #endif /* CONFIG_WIRELESS && CONFIG_INPUT_CC3000 */
#endif /* __INCLUDE_NUTTX_WIRELESS_CC3000_CC3000_INTERNAL_H */ #endif /* __INCLUDE_NUTTX_WIRELESS_CC3000_INCLUDE_CC3000_UPIFL_H */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+204 -208
View File
@@ -1,67 +1,52 @@
/***************************************************************************** /*****************************************************************************
* * nvmem.h - CC3000 Host Driver Implementation.
* nvmem.h - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ *
* * Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions * are met:
* are met: *
* * Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer. *
* * Redistributions in binary form must reproduce the above copyright
* Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the
* notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the
* documentation and/or other materials provided with the * distribution.
* distribution. *
* * Neither the name of Texas Instruments Incorporated nor the names of
* Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived
* its contributors may be used to endorse or promote products derived * from this software without specific prior written permission.
* from this software without specific prior written permission. *
* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *****************************************************************************/
*****************************************************************************/
#ifndef __NVRAM_H__
#define __NVRAM_H__
#include <nuttx/wireless/cc3000/cc3000_common.h> #ifndef _INCLUDE_NUTTX_WIRELESS_CC3000_NVMEM_H
#define _INCLUDE_NUTTX_WIRELESS_CC3000_NVMEM_H
/*****************************************************************************
* Included Files
*****************************************************************************/
//***************************************************************************** #include "cc3000_common.h"
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
* Pre-processor Definitions
*****************************************************************************/
//*****************************************************************************
//
//! \addtogroup nvmem_api
//! @{
//
//*****************************************************************************
/****************************************************************************
**
** Definitions for File IDs
**
****************************************************************************/
/* NVMEM file ID - system files*/ /* NVMEM file ID - system files*/
#define NVMEM_NVS_FILEID (0) #define NVMEM_NVS_FILEID (0)
#define NVMEM_NVS_SHADOW_FILEID (1) #define NVMEM_NVS_SHADOW_FILEID (1)
#define NVMEM_WLAN_CONFIG_FILEID (2) #define NVMEM_WLAN_CONFIG_FILEID (2)
@@ -76,173 +61,184 @@ extern "C" {
#define NVMEM_RM_FILEID (11) #define NVMEM_RM_FILEID (11)
/* NVMEM file ID - user files*/ /* NVMEM file ID - user files*/
#define NVMEM_AES128_KEY_FILEID (12) #define NVMEM_AES128_KEY_FILEID (12)
#define NVMEM_SHARED_MEM_FILEID (13) #define NVMEM_SHARED_MEM_FILEID (13)
/* max entry in order to invalid nvmem */ /* max entry in order to invalid nvmem */
#define NVMEM_MAX_ENTRY (16) #define NVMEM_MAX_ENTRY (16)
/*****************************************************************************
* Public Data
*****************************************************************************/
//***************************************************************************** #ifdef __cplusplus
// extern "C"
//! nvmem_read {
//!
//! @param ulFileId nvmem file id:\n
//! NVMEM_NVS_FILEID, NVMEM_NVS_SHADOW_FILEID,
//! NVMEM_WLAN_CONFIG_FILEID, NVMEM_WLAN_CONFIG_SHADOW_FILEID,
//! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID,
//! NVMEM_MAC_FILEID, NVMEM_FRONTEND_VARS_FILEID,
//! NVMEM_IP_CONFIG_FILEID, NVMEM_IP_CONFIG_SHADOW_FILEID,
//! NVMEM_BOOTLOADER_SP_FILEID, NVMEM_RM_FILEID,
//! and user files 12-15.
//! @param ulLength number of bytes to read
//! @param ulOffset ulOffset in file from where to read
//! @param buff output buffer pointer
//!
//! @return number of bytes read, otherwise error.
//!
//! @brief Reads data from the file referred by the ulFileId parameter.
//! Reads data from file ulOffset till length. Err if the file can't
//! be used, is invalid, or if the read is out of bounds.
//!
//*****************************************************************************
extern signed long nvmem_read(unsigned long file_id, unsigned long length, unsigned long offset, uint8_t *buff);
//*****************************************************************************
//
//! nvmem_write
//!
//! @param ulFileId nvmem file id:\n
//! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID,
//! NVMEM_MAC_FILEID, NVMEM_BOOTLOADER_SP_FILEID,
//! and user files 12-15.
//! @param ulLength number of bytes to write
//! @param ulEntryOffset offset in file to start write operation from
//! @param buff data to write
//!
//! @return on success 0, error otherwise.
//!
//! @brief Write data to nvmem.
//! writes data to file referred by the ulFileId parameter.
//! Writes data to file ulOffset till ulLength.The file id will be
//! marked invalid till the write is done. The file entry doesn't
//! need to be valid - only allocated.
//!
//*****************************************************************************
extern signed long nvmem_write(unsigned long ulFileId, unsigned long ulLength, unsigned long ulEntryOffset, uint8_t *buff);
//*****************************************************************************
//
//! nvmem_set_mac_address
//!
//! @param mac mac address to be set
//!
//! @return on success 0, error otherwise.
//!
//! @brief Write MAC address to EEPROM.
//! mac address as appears over the air (OUI first)
//!
//*****************************************************************************
extern uint8_t nvmem_set_mac_address(uint8_t *mac);
//*****************************************************************************
//
//! nvmem_get_mac_address
//!
//! @param[out] mac mac address
//!
//! @return on success 0, error otherwise.
//!
//! @brief Read MAC address from EEPROM.
//! mac address as appears over the air (OUI first)
//!
//*****************************************************************************
extern uint8_t nvmem_get_mac_address(uint8_t *mac);
//*****************************************************************************
//
//! nvmem_write_patch
//!
//! @param ulFileId nvmem file id:\n
//! NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID,
//! @param spLength number of bytes to write
//! @param spData SP data to write
//!
//! @return on success 0, error otherwise.
//!
//! @brief program a patch to a specific file ID.
//! The SP data is assumed to be organized in 2-dimensional.
//! Each line is SP_PORTION_SIZE bytes long. Actual programming is
//! applied in SP_PORTION_SIZE bytes portions.
//!
//*****************************************************************************
extern uint8_t nvmem_write_patch(unsigned long ulFileId, unsigned long spLength, const uint8_t *spData);
//*****************************************************************************
//
//! nvmem_read_sp_version
//!
//! @param[out] patchVer first number indicates package ID and the second
//! number indicates package build number
//!
//! @return on success 0, error otherwise.
//!
//! @brief Read patch version. read package version (WiFi FW patch,
//! driver-supplicant-NS patch, bootloader patch)
//!
//*****************************************************************************
#ifndef CC3000_TINY_DRIVER
extern uint8_t nvmem_read_sp_version(uint8_t* patchVer);
#endif #endif
//***************************************************************************** /*****************************************************************************
// * Public Function Prototypes
//! nvmem_create_entry *****************************************************************************/
//!
//! @param ulFileId nvmem file Id:\n
//! * NVMEM_AES128_KEY_FILEID: 12
//! * NVMEM_SHARED_MEM_FILEID: 13
//! * and fileIDs 14 and 15
//! @param ulNewLen entry ulLength
//!
//! @return on success 0, error otherwise.
//!
//! @brief Create new file entry and allocate space on the NVMEM.
//! Applies only to user files.
//! Modify the size of file.
//! If the entry is unallocated - allocate it to size
//! ulNewLen (marked invalid).
//! If it is allocated then deallocate it first.
//! To just mark the file as invalid without resizing -
//! set ulNewLen=0.
//!
//*****************************************************************************
extern signed long nvmem_create_entry(unsigned long file_id, unsigned long newlen);
/******************************************************************************
* Name: nvmem_read
*
* Description:
* Reads data from the file referred by the ulFileId parameter. Reads data
* from file ulOffset till length. Err if the file can't be used, is
* invalid, or if the read is out of bounds.
*
* Input Parameters:
* ulFileId nvmem file id:
* NVMEM_NVS_FILEID, NVMEM_NVS_SHADOW_FILEID,
* NVMEM_WLAN_CONFIG_FILEID, NVMEM_WLAN_CONFIG_SHADOW_FILEID,
* NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID,
* NVMEM_MAC_FILEID, NVMEM_FRONTEND_VARS_FILEID,
* NVMEM_IP_CONFIG_FILEID, NVMEM_IP_CONFIG_SHADOW_FILEID,
* NVMEM_BOOTLOADER_SP_FILEID, NVMEM_RM_FILEID,
* and user files 12-15.
* ulLength number of bytes to read
* ulOffset ulOffset in file from where to read
* buff output buffer pointer
*
* Returned Value:
* Number of bytes read, otherwise error.
*
*****************************************************************************/
//***************************************************************************** signed long nvmem_read(unsigned long ulFileId, unsigned long ulLength,
// unsigned long ulOffset, uint8_t *buff);
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
/******************************************************************************
* Name: nvmem_write
*
* Description:
* Write data to nvmem. Writes data to file referred by the ulFileId
* parameter. Writes data to file ulOffset till ulLength. The file id will be
* marked invalid till the write is done. The file entry doesn't need to be
* valid - only allocated.
*
* Input Parameters:
* ulFileId nvmem file id:
* NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID,
* NVMEM_MAC_FILEID, NVMEM_BOOTLOADER_SP_FILEID,
* and user files 12-15.
* ulLength number of bytes to write
* ulEntryOffset offset in file to start write operation from
* buff data to write
*
* Returned Value:
* On success 0, error otherwise.
*
*****************************************************************************/
//***************************************************************************** signed long nvmem_write(unsigned long ulFileId, unsigned long ulLength,
// unsigned long ulEntryOffset, uint8_t *buff);
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
/******************************************************************************
* Name: nvmem_set_mac_address
*
* Description:
* Write MAC address to EEPROM. mac address as appears over the air (OUI
* first)
*
* Input Parameters:
* mac mac address to be set
*
* Returned Value:
* On success 0, error otherwise.
*
*****************************************************************************/
uint8_t nvmem_set_mac_address(uint8_t *mac);
/******************************************************************************
* Name: nvmem_get_mac_address
*
* Description:
* Read MAC address from EEPROM. mac address as appears over the air (OUI
* first)
*
* Input Parameters:
* mac mac address
*
* Returned Value:
* On success 0, error otherwise.
*
*****************************************************************************/
uint8_t nvmem_get_mac_address(uint8_t *mac);
/******************************************************************************
* Name: nvmem_write_patch
*
* Description:
* Program a patch to a specific file ID. The SP data is assumed to be
* organized in 2-dimensional. Each line is SP_PORTION_SIZE bytes long.
* Actual programming is applied in SP_PORTION_SIZE bytes portions.
*
* Input Parameters:
* ulFileId nvmem file id:
* NVMEM_WLAN_DRIVER_SP_FILEID, NVMEM_WLAN_FW_SP_FILEID,
* spLength number of bytes to write
* spData SP data to write
*
* Returned Value:
* On success 0, error otherwise.
*
*****************************************************************************/
uint8_t nvmem_write_patch(unsigned long ulFileId, unsigned long spLength,
const uint8_t *spData);
/******************************************************************************
* Name: nvmem_read_sp_version
*
* Description:
* Read patch version. read package version (WiFi FW patch,
* driver-supplicant-NS patch, bootloader patch)
*
* Input Parameters:
* patchVer first number indicates package ID and the second
* number indicates package build number
*
* Returned Value:
* On success 0, error otherwise.
*
*****************************************************************************/
#ifndef CC3000_TINY_DRIVER
uint8_t nvmem_read_sp_version(uint8_t *patchVer);
#endif
/******************************************************************************
* Name: nvmem_create_entry
*
* Description:
* Create new file entry and allocate space on the NVMEM. Applies only to
* user files. Modify the size of file. If the entry is unallocated -
* allocate it to size ulNewLen (marked invalid). If it is allocated then
* deallocate it first. To just mark the file as invalid without resizing -
* Set ulNewLen=0.
*
* Input Parameters:
* ulFileId nvmem file Id:
* * NVMEM_AES128_KEY_FILEID: 12
* * NVMEM_SHARED_MEM_FILEID: 13
* * and fileIDs 14 and 15
* ulNewLen entry ulLength
*
* Returned Value:
* On success 0, error otherwise.
*
*****************************************************************************/
signed long nvmem_create_entry(unsigned long ulFileId, unsigned long ulNewLen);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif // __cplusplus #endif // __cplusplus
#endif // __NVRAM_H__ #endif // _INCLUDE_NUTTX_WIRELESS_CC3000_NVMEM_H
+127 -115
View File
@@ -1,126 +1,138 @@
/***************************************************************************** /*****************************************************************************
* * security.h - CC3000 Host Driver Implementation.
* security.h - CC3000 Host Driver Implementation. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ *
* * Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions * are met:
* are met: *
* * Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer. *
* * Redistributions in binary form must reproduce the above copyright
* Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the
* notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the
* documentation and/or other materials provided with the * distribution.
* distribution. *
* * Neither the name of Texas Instruments Incorporated nor the names of
* Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived
* its contributors may be used to endorse or promote products derived * from this software without specific prior written permission.
* from this software without specific prior written permission. *
* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *****************************************************************************/
*****************************************************************************/
#ifndef __SECURITY__
#define __SECURITY__
#include <nuttx/wireless/cc3000/nvmem.h> #ifndef _INCLUDE_NUTTX_WIRELESS_CC3000_SECURITY_H
#define _INCLUDE_NUTTX_WIRELESS_CC3000_SECURITY_H
//***************************************************************************** /*****************************************************************************
// * Included Files
// If building with a C++ compiler, make all of the definitions in this header *****************************************************************************/
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C" {
#endif
#include "nvmem.h"
/*****************************************************************************
* Pre-processor Definitions
*****************************************************************************/
#define AES128_KEY_SIZE 16 #define AES128_KEY_SIZE 16
#ifndef CC3000_UNENCRYPTED_SMART_CONFIG #ifndef CC3000_UNENCRYPTED_SMART_CONFIG
/*****************************************************************************
* Public Data
*****************************************************************************/
//***************************************************************************** #ifdef __cplusplus
// extern "C"
//! aes_encrypt {
//!
//! @param[in] key AES128 key of size 16 bytes
//! @param[in\out] state 16 bytes of plain text and cipher text
//!
//! @return none
//!
//! @brief AES128 encryption:
//! Given AES128 key and 16 bytes plain text, cipher text of 16 bytes
//! is computed. The AES implementation is in mode ECB (Electronic
//! Code Book).
//!
//!
//*****************************************************************************
extern void aes_encrypt(uint8_t *state, uint8_t *key);
//*****************************************************************************
//
//! aes_decrypt
//!
//! @param[in] key AES128 key of size 16 bytes
//! @param[in\out] state 16 bytes of cipher text and plain text
//!
//! @return none
//!
//! @brief AES128 decryption:
//! Given AES128 key and 16 bytes cipher text, plain text of 16 bytes
//! is computed The AES implementation is in mode ECB
//! (Electronic Code Book).
//!
//!
//*****************************************************************************
extern void aes_decrypt(uint8_t *state, uint8_t *key);
//*****************************************************************************
//
//! aes_read_key
//!
//! @param[out] key AES128 key of size 16 bytes
//!
//! @return on success 0, error otherwise.
//!
//! @brief Reads AES128 key from EEPROM
//! Reads the AES128 key from fileID #12 in EEPROM
//! returns an error if the key does not exist.
//!
//!
//*****************************************************************************
extern signed long aes_read_key(uint8_t *key);
//*****************************************************************************
//
//! aes_write_key
//!
//! @param[out] key AES128 key of size 16 bytes
//!
//! @return on success 0, error otherwise.
//!
//! @brief writes AES128 key from EEPROM
//! Writes the AES128 key to fileID #12 in EEPROM
//!
//!
//*****************************************************************************
extern signed long aes_write_key(uint8_t *key);
#endif //CC3000_UNENCRYPTED_SMART_CONFIG
#endif #endif
/*****************************************************************************
* Public Function Prototypes
/*****************************************************************************
/*****************************************************************************
* Name: aes_encrypt
*
* Description:
* AES128 encryption: Given AES128 key and 16 bytes plain text, cipher
* text of 16 bytes is computed. The AES implementation is in mode ECB
* (Electronic Code Book).
*
* Input Parameters:
* key AES128 key of size 16 bytes
* state 16 bytes of plain text and cipher text
*
* Returned Value
* None
*
*****************************************************************************/
void aes_encrypt(uint8_t *state, uint8_t *key);
/*****************************************************************************
* Name: aes_decrypt
*
* Description:
* AES128 decryption: Given AES128 key and 16 bytes cipher text, plain
* text of 16 bytes is computed The AES implementation is in mode ECB
* (Electronic Code Book).
*
* Input Parameters:
* key AES128 key of size 16 bytes
* state 16 bytes of plain text and cipher text
*
* Returned Value
* None
*
*****************************************************************************/
void aes_decrypt(uint8_t *state, uint8_t *key);
/*****************************************************************************
* Name: aes_read_key
*
* Description:
* Reads AES128 key from EEPROM. Reads the AES128 key from fileID #12 in
* EEPROM returns an error if the key does not exist.
*
* Input Parameters:
* key AES128 key of size 16 bytes
*
* Returned Value
* On success 0, error otherwise.
*
*****************************************************************************/
signed long aes_read_key(uint8_t *key);
/*****************************************************************************
* Name: aes_write_key
*
* Description:
* Writes AES128 key from EEPROM Writes the AES128 key to fileID #12 in
* EEPROM
*
* Input Parameters:
* key AES128 key of size 16 bytes
*
* Returned Value
* On success 0, error otherwise.
*
*****************************************************************************/
signed long aes_write_key(uint8_t *key);
#endif /* CC3000_UNENCRYPTED_SMART_CONFIG */
#endif /* _INCLUDE_NUTTX_WIRELESS_CC3000_SECURITY_H */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff