mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 05:55:46 +08:00
CC3000 driver changes from David Sidrane
This commit is contained in:
@@ -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) >> 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) >> 8);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ uint8_t nvmem_get_mac_address(uint8_t *mac)
|
||||
*****************************************************************************/
|
||||
|
||||
uint8_t nvmem_write_patch(unsigned long ulFileId, unsigned long spLength,
|
||||
const uint8_t *spData)
|
||||
const uint8_t *spData)
|
||||
{
|
||||
uint8_t status = 0;
|
||||
uint16_t offset = 0;
|
||||
@@ -279,7 +279,7 @@ uint8_t nvmem_write_patch(unsigned long ulFileId, unsigned long spLength,
|
||||
*****************************************************************************/
|
||||
|
||||
#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;
|
||||
/* 1st byte is the status and the rest is the SP version */
|
||||
|
||||
+160
-152
@@ -1,50 +1,53 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* security.c - 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.
|
||||
*
|
||||
*****************************************************************************/
|
||||
* security.c - 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.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup security_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
/*****************************************************************************
|
||||
* Included Files
|
||||
*****************************************************************************/
|
||||
|
||||
#include <nuttx/wireless/cc3000/security.h>
|
||||
|
||||
#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
|
||||
|
||||
/*****************************************************************************
|
||||
* Private Data
|
||||
*****************************************************************************/
|
||||
|
||||
// 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
|
||||
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
|
||||
@@ -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
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
, 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
|
||||
@@ -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
|
||||
, 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
|
||||
, 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};
|
||||
, 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
|
||||
};
|
||||
|
||||
uint8_t aexpandedKey[176];
|
||||
|
||||
/*****************************************************************************
|
||||
* Public Functions
|
||||
*****************************************************************************/
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! expandKey
|
||||
@@ -104,9 +118,12 @@ void expandKey(uint8_t *expandedKey,
|
||||
uint8_t *key)
|
||||
{
|
||||
uint16_t ii, buf1;
|
||||
|
||||
for (ii=0;ii<16;ii++)
|
||||
expandedKey[ii] = key[ii];
|
||||
for (ii=1;ii<11;ii++){
|
||||
|
||||
for (ii=1;ii<11;ii++)
|
||||
{
|
||||
buf1 = expandedKey[ii*16 - 4];
|
||||
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];
|
||||
@@ -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 +15] = expandedKey[(ii-1)*16 +15]^expandedKey[ii*16 +11];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
@@ -142,12 +158,12 @@ void expandKey(uint8_t *expandedKey,
|
||||
|
||||
uint8_t galois_mul2(uint8_t value)
|
||||
{
|
||||
if (value>>7)
|
||||
{
|
||||
value = value << 1;
|
||||
return (value^0x1b);
|
||||
} else
|
||||
return value<<1;
|
||||
if (value>>7)
|
||||
{
|
||||
value = value << 1;
|
||||
return (value^0x1b);
|
||||
} else
|
||||
return value<<1;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
@@ -166,18 +182,18 @@ uint8_t galois_mul2(uint8_t value)
|
||||
//! - subbytes
|
||||
//! - shiftrows
|
||||
//! - mixcolums
|
||||
//! is executed 9 times, after this addroundkey to finish the 9th
|
||||
//! is executed 9 times, after this addroundkey to finish the 9th
|
||||
//! round, after that the 10th round without mixcolums
|
||||
//! no further subfunctions to save cycles for function calls
|
||||
//! no structuring with "for (....)" to save cycles.
|
||||
//!
|
||||
//!
|
||||
//!
|
||||
//*****************************************************************************
|
||||
|
||||
void aes_encr(uint8_t *state, uint8_t *expandedKey)
|
||||
{
|
||||
uint8_t buf1, buf2, buf3, round;
|
||||
|
||||
|
||||
for (round = 0; round < 9; round ++){
|
||||
// addroundkey, sbox and shiftrows
|
||||
// row 0
|
||||
@@ -204,7 +220,7 @@ void aes_encr(uint8_t *state, uint8_t *expandedKey)
|
||||
state[11] = sbox[(state[ 7] ^ expandedKey[(round*16) + 7])];
|
||||
state[ 7] = sbox[(state[ 3] ^ expandedKey[(round*16) + 3])];
|
||||
state[ 3] = sbox[buf1];
|
||||
|
||||
|
||||
// mixcolums //////////
|
||||
// col1
|
||||
buf1 = state[0] ^ state[1] ^ state[2] ^ state[3];
|
||||
@@ -233,8 +249,8 @@ void aes_encr(uint8_t *state, uint8_t *expandedKey)
|
||||
buf3 = state[12]^state[13]; buf3=galois_mul2(buf3); state[12] = state[12] ^ buf3 ^ buf1;
|
||||
buf3 = state[13]^state[14]; buf3=galois_mul2(buf3); state[13] = state[13] ^ buf3 ^ buf1;
|
||||
buf3 = state[14]^state[15]; buf3=galois_mul2(buf3); state[14] = state[14] ^ buf3 ^ buf1;
|
||||
buf3 = state[15]^buf2; buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1;
|
||||
|
||||
buf3 = state[15]^buf2; buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1;
|
||||
|
||||
}
|
||||
// 10th round without mixcols
|
||||
state[ 0] = sbox[(state[ 0] ^ expandedKey[(round*16) ])];
|
||||
@@ -275,9 +291,9 @@ void aes_encr(uint8_t *state, uint8_t *expandedKey)
|
||||
state[11]^=expandedKey[171];
|
||||
state[12]^=expandedKey[172];
|
||||
state[13]^=expandedKey[173];
|
||||
state[14]^=expandedKey[174];
|
||||
state[14]^=expandedKey[174];
|
||||
state[15]^=expandedKey[175];
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
@@ -306,7 +322,7 @@ void aes_decr(uint8_t *state, uint8_t *expandedKey)
|
||||
uint8_t buf1, buf2, buf3;
|
||||
int8_t round;
|
||||
round = 9;
|
||||
|
||||
|
||||
// initial addroundkey
|
||||
state[ 0]^=expandedKey[160];
|
||||
state[ 1]^=expandedKey[161];
|
||||
@@ -322,9 +338,9 @@ void aes_decr(uint8_t *state, uint8_t *expandedKey)
|
||||
state[11]^=expandedKey[171];
|
||||
state[12]^=expandedKey[172];
|
||||
state[13]^=expandedKey[173];
|
||||
state[14]^=expandedKey[174];
|
||||
state[14]^=expandedKey[174];
|
||||
state[15]^=expandedKey[175];
|
||||
|
||||
|
||||
// 10th round without mixcols
|
||||
state[ 0] = rsbox[state[ 0]] ^ expandedKey[(round*16) ];
|
||||
state[ 4] = rsbox[state[ 4]] ^ expandedKey[(round*16) + 4];
|
||||
@@ -349,7 +365,7 @@ void aes_decr(uint8_t *state, uint8_t *expandedKey)
|
||||
state[ 7] = rsbox[state[11]] ^ expandedKey[(round*16) + 7];
|
||||
state[11] = rsbox[state[15]] ^ expandedKey[(round*16) + 11];
|
||||
state[15] = buf1;
|
||||
|
||||
|
||||
for (round = 8; round >= 0; round--){
|
||||
// barreto
|
||||
//col1
|
||||
@@ -396,8 +412,8 @@ void aes_decr(uint8_t *state, uint8_t *expandedKey)
|
||||
buf3 = state[12]^state[13]; buf3=galois_mul2(buf3); state[12] = state[12] ^ buf3 ^ buf1;
|
||||
buf3 = state[13]^state[14]; buf3=galois_mul2(buf3); state[13] = state[13] ^ buf3 ^ buf1;
|
||||
buf3 = state[14]^state[15]; buf3=galois_mul2(buf3); state[14] = state[14] ^ buf3 ^ buf1;
|
||||
buf3 = state[15]^buf2; buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1;
|
||||
|
||||
buf3 = state[15]^buf2; buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1;
|
||||
|
||||
// addroundkey, rsbox and shiftrows
|
||||
// row 0
|
||||
state[ 0] = rsbox[state[ 0]] ^ expandedKey[(round*16) ];
|
||||
@@ -424,110 +440,102 @@ void aes_decr(uint8_t *state, uint8_t *expandedKey)
|
||||
state[11] = rsbox[state[15]] ^ expandedKey[(round*16) + 11];
|
||||
state[15] = buf1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! 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).
|
||||
//!
|
||||
//!
|
||||
//*****************************************************************************
|
||||
|
||||
void aes_encrypt(uint8_t *state,
|
||||
uint8_t *key)
|
||||
{
|
||||
// expand the key into 176 bytes
|
||||
expandKey(aexpandedKey, key);
|
||||
aes_encr(state, aexpandedKey);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! 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).
|
||||
//!
|
||||
//!
|
||||
//*****************************************************************************
|
||||
/*****************************************************************************
|
||||
* 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_decrypt(uint8_t *state,
|
||||
uint8_t *key)
|
||||
void aes_encrypt(uint8_t *state, uint8_t *key)
|
||||
{
|
||||
// expand the key into 176 bytes
|
||||
expandKey(aexpandedKey, key);
|
||||
aes_encr(state, aexpandedKey);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* 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)
|
||||
{
|
||||
expandKey(aexpandedKey, key); // expand the key into 176 bytes
|
||||
aes_decr(state, aexpandedKey);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! 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.
|
||||
//!
|
||||
//!
|
||||
//*****************************************************************************
|
||||
/*****************************************************************************
|
||||
* 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)
|
||||
{
|
||||
signed long returnValue;
|
||||
|
||||
returnValue = nvmem_read(NVMEM_AES128_KEY_FILEID, AES128_KEY_SIZE, 0, key);
|
||||
signed long returnValue;
|
||||
|
||||
return returnValue;
|
||||
returnValue = nvmem_read(NVMEM_AES128_KEY_FILEID, AES128_KEY_SIZE, 0, key);
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! 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
|
||||
//!
|
||||
//!
|
||||
//*****************************************************************************
|
||||
/*****************************************************************************
|
||||
* 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)
|
||||
{
|
||||
signed long returnValue;
|
||||
signed long returnValue;
|
||||
|
||||
returnValue = nvmem_write(NVMEM_AES128_KEY_FILEID, AES128_KEY_SIZE, 0, key);
|
||||
returnValue = nvmem_write(NVMEM_AES128_KEY_FILEID, AES128_KEY_SIZE, 0, key);
|
||||
|
||||
return returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
#endif //CC3000_UNENCRYPTED_SMART_CONFIG
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
+120
-121
@@ -183,6 +183,11 @@ int HostFlowControlConsumeBuff(int sd)
|
||||
/*****************************************************************************
|
||||
* 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:
|
||||
* domain selects the protocol family which will be used for
|
||||
* 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
|
||||
* 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)
|
||||
@@ -239,15 +238,15 @@ int socket(long domain, long type, long protocol)
|
||||
/*****************************************************************************
|
||||
* Name: closesocket
|
||||
*
|
||||
* Decription:
|
||||
* The socket function closes a created socket.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sd socket handle.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, zero is returned. On error, -1 is returned.
|
||||
*
|
||||
* Decription:
|
||||
* The socket function closes a created socket.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
long closesocket(long sd)
|
||||
@@ -285,6 +284,25 @@ long closesocket(long sd)
|
||||
/*****************************************************************************
|
||||
* 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:
|
||||
* sd socket descriptor (handle)
|
||||
* 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 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)
|
||||
@@ -375,15 +374,6 @@ long accept(long sd, sockaddr *addr, socklen_t *addrlen)
|
||||
/*****************************************************************************
|
||||
* 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:
|
||||
* assign a name to a socket
|
||||
* 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
|
||||
* 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)
|
||||
@@ -430,14 +429,6 @@ long bind(long sd, const sockaddr *addr, long addrlen)
|
||||
/*****************************************************************************
|
||||
* 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:
|
||||
* listen for connections on a socket
|
||||
* 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
|
||||
*
|
||||
* 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)
|
||||
@@ -481,6 +480,14 @@ long listen(long sd, long backlog)
|
||||
/*****************************************************************************
|
||||
* 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:
|
||||
* hostname host name
|
||||
* usNameLen name length
|
||||
@@ -491,14 +498,6 @@ long listen(long sd, long backlog)
|
||||
* Returned Value:
|
||||
* 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
|
||||
@@ -543,15 +542,6 @@ int gethostbyname(char * hostname, uint16_t usNameLen, unsigned long* out_ip_add
|
||||
/*****************************************************************************
|
||||
* 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:
|
||||
* initiate a connection on a socket
|
||||
* 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
|
||||
* 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)
|
||||
@@ -604,6 +603,15 @@ long connect(long sd, const sockaddr *addr, long addrlen)
|
||||
/*****************************************************************************
|
||||
* 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:
|
||||
* nfds the highest-numbered file descriptor in any of the
|
||||
* three sets, plus 1.
|
||||
@@ -629,15 +637,6 @@ long connect(long sd, const sockaddr *addr, long addrlen)
|
||||
* will return without delay.
|
||||
* *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,
|
||||
@@ -724,16 +723,6 @@ int select(long nfds, TICC3000fd_set *readsds, TICC3000fd_set *writesds,
|
||||
/*****************************************************************************
|
||||
* 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:
|
||||
* set socket options
|
||||
* 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.
|
||||
* 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
|
||||
@@ -811,16 +810,6 @@ int setsockopt(long sd, long level, long optname, const void *optval, socklen_t
|
||||
/*****************************************************************************
|
||||
* 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:
|
||||
* set socket options
|
||||
* 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.
|
||||
* 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)
|
||||
@@ -958,6 +957,11 @@ int simple_link_recv(long sd, void *buf, long len, long flags, sockaddr *from,
|
||||
/*****************************************************************************
|
||||
* Name: recv
|
||||
*
|
||||
* Decription:
|
||||
* function receives a message from a connection-mode socket
|
||||
*
|
||||
* NOTE: On this version, only blocking mode is supported.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sd socket handle
|
||||
* 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
|
||||
* 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)
|
||||
@@ -985,6 +984,14 @@ int recv(long sd, void *buf, long len, long flags)
|
||||
/*****************************************************************************
|
||||
* 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:
|
||||
* sd socket handle
|
||||
* 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
|
||||
* 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,
|
||||
@@ -1137,6 +1136,13 @@ int simple_link_send(long sd, const void *buf, long len, long flags,
|
||||
/*****************************************************************************
|
||||
* 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:
|
||||
* sd socket handle
|
||||
* 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
|
||||
* 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)
|
||||
@@ -1164,6 +1163,13 @@ int send(long sd, const void *buf, long len, long flags)
|
||||
/*****************************************************************************
|
||||
* 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:
|
||||
* sd socket handle
|
||||
* 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
|
||||
* 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,
|
||||
@@ -1196,6 +1195,9 @@ int sendto(long sd, const void *buf, long len, long flags, const sockaddr *to,
|
||||
/*****************************************************************************
|
||||
* Name: mdnsAdvertiser
|
||||
*
|
||||
* Decription:
|
||||
* Set CC3000 in mDNS advertiser mode in order to advertise itself.
|
||||
*
|
||||
* Input Parameters:
|
||||
* mdnsEnabled flag to enable/disable the mDNS feature
|
||||
* 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
|
||||
* 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,
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
#ifndef __DRIVERS_WIRELESS_CC3000_SPI_H
|
||||
#define __DRIVERS_WIRELESS_CC3000_SPI_H
|
||||
|
||||
/*****************************************************************************
|
||||
* Included Files
|
||||
*****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,11 +32,11 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __EVENT_HANDLER_H__
|
||||
#define __EVENT_HANDLER_H__
|
||||
#ifndef _INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
|
||||
#define _INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_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 // __EVENT_HANDLER_H__
|
||||
#endif // _INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
|
||||
|
||||
|
||||
+278
-308
File diff suppressed because it is too large
Load Diff
@@ -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__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* CC30000 from Texas Instruments http://processors.wiki.ti.com/index.php/CC3000
|
||||
*
|
||||
* See also:
|
||||
* http://processors.wiki.ti.com/index.php/CC3000_Host_Driver_Porting_Guide
|
||||
* http://processors.wiki.ti.com/index.php/CC3000_Host_Programming_Guide
|
||||
* http://processors.wiki.ti.com/index.php/CC3000_Host_Driver_Porting_Guide
|
||||
* http://processors.wiki.ti.com/index.php/CC3000_Host_Programming_Guide
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -44,8 +44,8 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_WIRELESS_CC3000_CC3000_INTERNAL_H
|
||||
#define __INCLUDE_NUTTX_WIRELESS_CC3000_CC3000_INTERNAL_H
|
||||
#ifndef __INCLUDE_NUTTX_WIRELESS_CC3000_INCLUDE_CC3000_UPIFL_H
|
||||
#define __INCLUDE_NUTTX_WIRELESS_CC3000_INCLUDE_CC3000_UPIFL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
@@ -76,12 +76,13 @@
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_CC3000_SPIMODE
|
||||
// CPOL = 0, CPHA = 1 Sample Data Falling Edge of Clock
|
||||
// See http://processors.wiki.ti.com/index.php/CC3000_Serial_Port_Interface_(SPI)
|
||||
/* CPOL = 0, CPHA = 1 Sample Data Falling Edge of Clock
|
||||
* See http://processors.wiki.ti.com/index.php/CC3000_Serial_Port_Interface_(SPI)
|
||||
*/
|
||||
|
||||
# define CONFIG_CC3000_SPIMODE SPIDEV_MODE0
|
||||
#endif
|
||||
|
||||
|
||||
/* Check for some required settings. This can save the user a lot of time
|
||||
* in getting the right configuration.
|
||||
*/
|
||||
@@ -113,7 +114,7 @@ struct cc3000_config_s
|
||||
/* Device characterization */
|
||||
|
||||
uint32_t spi_frequency; /* SPI frequency */
|
||||
uint32_t spi_mode; /* SPI mode */
|
||||
uint32_t spi_mode; /* SPI mode */
|
||||
|
||||
/* If multiple CC3000 devices are supported, then an IRQ number must
|
||||
* be provided for each so that their interrupts can be distinguished.
|
||||
@@ -131,12 +132,12 @@ struct cc3000_config_s
|
||||
* CC3000 to host, indicating that the CC3000 core module is ready to accept data.
|
||||
* T2 duration is approximately 7 ms.
|
||||
*
|
||||
* irq_attach - Attach the CC3000 interrupt handler to the GPIO interrupt
|
||||
* irq_enable - Enable or disable the GPIO interrupt
|
||||
* clear_irq - Acknowledge/clear any pending GPIO interrupt
|
||||
* irq_attach - Attach the CC3000 interrupt handler to the GPIO interrupt
|
||||
* irq_enable - Enable or disable the GPIO interrupt
|
||||
* clear_irq - Acknowledge/clear any pending GPIO interrupt
|
||||
* power_enable - Enable or disable Module enable.
|
||||
* chip_select - The Chip Select
|
||||
* busy - Return the state of the interrupt GPIO input
|
||||
* busy - Return the state of the interrupt GPIO input
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -178,11 +179,8 @@ extern "C" {
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int CC3000_register(FAR struct spi_dev_s *spi,
|
||||
FAR struct cc3000_config_s *config,
|
||||
int minor);
|
||||
|
||||
|
||||
int CC3000_register(FAR struct spi_dev_s *spi,
|
||||
FAR struct cc3000_config_s *config, int minor);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
@@ -190,4 +188,4 @@ EXTERN int CC3000_register(FAR struct spi_dev_s *spi,
|
||||
#endif
|
||||
|
||||
#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
@@ -1,248 +1,244 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* nvmem.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 __NVRAM_H__
|
||||
#define __NVRAM_H__
|
||||
* nvmem.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.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <nuttx/wireless/cc3000/cc3000_common.h>
|
||||
#ifndef _INCLUDE_NUTTX_WIRELESS_CC3000_NVMEM_H
|
||||
#define _INCLUDE_NUTTX_WIRELESS_CC3000_NVMEM_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
|
||||
*****************************************************************************/
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup nvmem_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
/****************************************************************************
|
||||
**
|
||||
** Definitions for File IDs
|
||||
**
|
||||
****************************************************************************/
|
||||
/* NVMEM file ID - system files*/
|
||||
#define NVMEM_NVS_FILEID (0)
|
||||
#define NVMEM_NVS_SHADOW_FILEID (1)
|
||||
#define NVMEM_WLAN_CONFIG_FILEID (2)
|
||||
#define NVMEM_WLAN_CONFIG_SHADOW_FILEID (3)
|
||||
#define NVMEM_WLAN_DRIVER_SP_FILEID (4)
|
||||
#define NVMEM_WLAN_FW_SP_FILEID (5)
|
||||
#define NVMEM_MAC_FILEID (6)
|
||||
#define NVMEM_FRONTEND_VARS_FILEID (7)
|
||||
#define NVMEM_IP_CONFIG_FILEID (8)
|
||||
#define NVMEM_IP_CONFIG_SHADOW_FILEID (9)
|
||||
#define NVMEM_BOOTLOADER_SP_FILEID (10)
|
||||
#define NVMEM_RM_FILEID (11)
|
||||
|
||||
#define NVMEM_NVS_FILEID (0)
|
||||
#define NVMEM_NVS_SHADOW_FILEID (1)
|
||||
#define NVMEM_WLAN_CONFIG_FILEID (2)
|
||||
#define NVMEM_WLAN_CONFIG_SHADOW_FILEID (3)
|
||||
#define NVMEM_WLAN_DRIVER_SP_FILEID (4)
|
||||
#define NVMEM_WLAN_FW_SP_FILEID (5)
|
||||
#define NVMEM_MAC_FILEID (6)
|
||||
#define NVMEM_FRONTEND_VARS_FILEID (7)
|
||||
#define NVMEM_IP_CONFIG_FILEID (8)
|
||||
#define NVMEM_IP_CONFIG_SHADOW_FILEID (9)
|
||||
#define NVMEM_BOOTLOADER_SP_FILEID (10)
|
||||
#define NVMEM_RM_FILEID (11)
|
||||
|
||||
/* NVMEM file ID - user files*/
|
||||
#define NVMEM_AES128_KEY_FILEID (12)
|
||||
#define NVMEM_SHARED_MEM_FILEID (13)
|
||||
|
||||
/* max entry in order to invalid nvmem */
|
||||
#define NVMEM_MAX_ENTRY (16)
|
||||
#define NVMEM_AES128_KEY_FILEID (12)
|
||||
#define NVMEM_SHARED_MEM_FILEID (13)
|
||||
|
||||
/* max entry in order to invalid nvmem */
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! 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.
|
||||
//!
|
||||
//*****************************************************************************
|
||||
#define NVMEM_MAX_ENTRY (16)
|
||||
|
||||
extern signed long nvmem_read(unsigned long file_id, unsigned long length, unsigned long offset, uint8_t *buff);
|
||||
/*****************************************************************************
|
||||
* Public Data
|
||||
*****************************************************************************/
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! 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);
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! 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);
|
||||
/*****************************************************************************
|
||||
* Public Function Prototypes
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* 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.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
signed long nvmem_read(unsigned long ulFileId, unsigned long ulLength,
|
||||
unsigned long ulOffset, uint8_t *buff);
|
||||
|
||||
/******************************************************************************
|
||||
* 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.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
signed long nvmem_write(unsigned long ulFileId, unsigned long ulLength,
|
||||
unsigned long ulEntryOffset, uint8_t *buff);
|
||||
|
||||
/******************************************************************************
|
||||
* 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
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __NVRAM_H__
|
||||
#endif // _INCLUDE_NUTTX_WIRELESS_CC3000_NVMEM_H
|
||||
|
||||
@@ -1,126 +1,138 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* security.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 __SECURITY__
|
||||
#define __SECURITY__
|
||||
* security.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.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <nuttx/wireless/cc3000/nvmem.h>
|
||||
#ifndef _INCLUDE_NUTTX_WIRELESS_CC3000_SECURITY_H
|
||||
#define _INCLUDE_NUTTX_WIRELESS_CC3000_SECURITY_H
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
* Included Files
|
||||
*****************************************************************************/
|
||||
|
||||
#include "nvmem.h"
|
||||
|
||||
#define AES128_KEY_SIZE 16
|
||||
/*****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
*****************************************************************************/
|
||||
|
||||
#define AES128_KEY_SIZE 16
|
||||
|
||||
#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
|
||||
|
||||
/*****************************************************************************
|
||||
* Public Data
|
||||
*****************************************************************************/
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#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
Reference in New Issue
Block a user