TI's CC3100 host driver and demo. Experimental and a work in progress.

Dependencies:   mbed

Committer:
dflet
Date:
Wed Nov 19 23:04:04 2014 +0000
Revision:
2:a3e52cf86086
Parent:
0:bbe98578d4c0
Added more boards!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:bbe98578d4c0 1 /*
dflet 0:bbe98578d4c0 2 * sl_config.h - get time sample application
dflet 0:bbe98578d4c0 3 *
dflet 0:bbe98578d4c0 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:bbe98578d4c0 5 *
dflet 0:bbe98578d4c0 6 *
dflet 0:bbe98578d4c0 7 * Redistribution and use in source and binary forms, with or without
dflet 0:bbe98578d4c0 8 * modification, are permitted provided that the following conditions
dflet 0:bbe98578d4c0 9 * are met:
dflet 0:bbe98578d4c0 10 *
dflet 0:bbe98578d4c0 11 * Redistributions of source code must retain the above copyright
dflet 0:bbe98578d4c0 12 * notice, this list of conditions and the following disclaimer.
dflet 0:bbe98578d4c0 13 *
dflet 0:bbe98578d4c0 14 * Redistributions in binary form must reproduce the above copyright
dflet 0:bbe98578d4c0 15 * notice, this list of conditions and the following disclaimer in the
dflet 0:bbe98578d4c0 16 * documentation and/or other materials provided with the
dflet 0:bbe98578d4c0 17 * distribution.
dflet 0:bbe98578d4c0 18 *
dflet 0:bbe98578d4c0 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:bbe98578d4c0 20 * its contributors may be used to endorse or promote products derived
dflet 0:bbe98578d4c0 21 * from this software without specific prior written permission.
dflet 0:bbe98578d4c0 22 *
dflet 0:bbe98578d4c0 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:bbe98578d4c0 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:bbe98578d4c0 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:bbe98578d4c0 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:bbe98578d4c0 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:bbe98578d4c0 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:bbe98578d4c0 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:bbe98578d4c0 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:bbe98578d4c0 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:bbe98578d4c0 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:bbe98578d4c0 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:bbe98578d4c0 34 *
dflet 0:bbe98578d4c0 35 */
dflet 0:bbe98578d4c0 36
dflet 0:bbe98578d4c0 37 #ifndef __SL_CONFIG_H__
dflet 0:bbe98578d4c0 38 #define __SL_CONFIG_H__
dflet 0:bbe98578d4c0 39
dflet 0:bbe98578d4c0 40 //*****************************************************************************
dflet 0:bbe98578d4c0 41 //
dflet 0:bbe98578d4c0 42 // If building with a C++ compiler, make all of the definitions in this header
dflet 0:bbe98578d4c0 43 // have a C binding.
dflet 0:bbe98578d4c0 44 //
dflet 0:bbe98578d4c0 45 //*****************************************************************************
dflet 0:bbe98578d4c0 46 #ifdef __cplusplus
dflet 0:bbe98578d4c0 47 extern "C" {
dflet 0:bbe98578d4c0 48 #endif
dflet 0:bbe98578d4c0 49
dflet 0:bbe98578d4c0 50 //Vars taken from main
dflet 0:bbe98578d4c0 51 extern _u32 g_Status ;
dflet 0:bbe98578d4c0 52 extern _u32 g_GatewayIP;
dflet 0:bbe98578d4c0 53 extern _u32 g_StationIP;
dflet 0:bbe98578d4c0 54
dflet 0:bbe98578d4c0 55 /**/
dflet 0:bbe98578d4c0 56 #define LOOP_FOREVER() \
dflet 0:bbe98578d4c0 57 {\
dflet 0:bbe98578d4c0 58 while(1); \
dflet 0:bbe98578d4c0 59 }
dflet 0:bbe98578d4c0 60
dflet 0:bbe98578d4c0 61 #define ASSERT_ON_ERROR(error_code) \
dflet 0:bbe98578d4c0 62 {\
dflet 0:bbe98578d4c0 63 /* Handling the error-codes is specific to the application */ \
dflet 0:bbe98578d4c0 64 if (error_code < 0) return error_code; \
dflet 0:bbe98578d4c0 65 /* else, continue w/ execution */ \
dflet 0:bbe98578d4c0 66 }
dflet 0:bbe98578d4c0 67
dflet 0:bbe98578d4c0 68 #define pal_Memset(x,y,z) memset((void *)x,y,z)
dflet 0:bbe98578d4c0 69 #define pal_Memcpy(x,y,z) memcpy((void *)x, (const void *)y, z)
dflet 0:bbe98578d4c0 70 #define pal_Memcmp(x,y,z) memcmp((const void *)x, (const void *)y, z)
dflet 0:bbe98578d4c0 71 #define pal_Strlen(x) strlen((const char *)x)
dflet 0:bbe98578d4c0 72 #define pal_Strcmp(x,y) strcmp((const char *)x, (const char *)y)
dflet 0:bbe98578d4c0 73 #define pal_Strcpy(x,y) strcpy((char *)x, (const char *)y)
dflet 0:bbe98578d4c0 74 #define pal_Strstr(x,y) strstr((const char *)x, (const char *)y)
dflet 0:bbe98578d4c0 75 #define pal_Strncmp(x,y,z) strncmp((const char *)x, (const char *)y, z)
dflet 0:bbe98578d4c0 76 #define pal_Strcat(x,y) strcat((char *)x, (const char *)y)
dflet 0:bbe98578d4c0 77
dflet 0:bbe98578d4c0 78 /*
dflet 0:bbe98578d4c0 79 * Values for below macros shall be modified per the access-point's (AP) properties
dflet 0:bbe98578d4c0 80 * SimpleLink device will connect to following AP when the application is executed
dflet 0:bbe98578d4c0 81 */
dflet 0:bbe98578d4c0 82 #define SSID_NAME "**********" /* Access point name to connect to. */
dflet 0:bbe98578d4c0 83 #define SEC_TYPE SL_SEC_TYPE_WPA_WPA2 /* Security type of the Access piont */
dflet 0:bbe98578d4c0 84 #define PASSKEY "**********" /* Password in case of secure AP */
dflet 0:bbe98578d4c0 85 #define PASSKEY_LEN pal_Strlen(PASSKEY) /* Password length in case of secure AP */
dflet 0:bbe98578d4c0 86
dflet 0:bbe98578d4c0 87 /* Configuration of the device when it comes up in AP mode */
dflet 0:bbe98578d4c0 88 #define SSID_AP_MODE "mysimplelink" /* SSID of the CC3100 in AP mode */
dflet 0:bbe98578d4c0 89 #define PASSWORD_AP_MODE "" /* Password of CC3100 AP */
dflet 0:bbe98578d4c0 90 #define SEC_TYPE_AP_MODE SL_SEC_TYPE_OPEN /* Can take SL_SEC_TYPE_WEP or
dflet 0:bbe98578d4c0 91 * SL_SEC_TYPE_WPA as well */
dflet 0:bbe98578d4c0 92
dflet 0:bbe98578d4c0 93 /*
dflet 0:bbe98578d4c0 94 * Values for below macros shall be modified based on current time
dflet 0:bbe98578d4c0 95 */
dflet 0:bbe98578d4c0 96 #define DATE 24 /* Current Date */
dflet 0:bbe98578d4c0 97 #define MONTH 7 /* Month */
dflet 0:bbe98578d4c0 98 #define YEAR 2014 /* Current year */
dflet 0:bbe98578d4c0 99 #define HOUR 17 /* Time - hours */
dflet 0:bbe98578d4c0 100 #define MINUTE 30 /* Time - minutes */
dflet 0:bbe98578d4c0 101 #define SECOND 0 /* Time - seconds */
dflet 0:bbe98578d4c0 102
dflet 0:bbe98578d4c0 103 #define SUCCESS 0
dflet 0:bbe98578d4c0 104
dflet 0:bbe98578d4c0 105 /* Status bits - These are used to set/reset the corresponding bits in a 'status_variable' */
dflet 0:bbe98578d4c0 106 typedef enum{
dflet 0:bbe98578d4c0 107 STATUS_BIT_CONNECTION = 0, /* If this bit is:
dflet 0:bbe98578d4c0 108 * 1 in a 'status_variable', the device is connected to the AP
dflet 0:bbe98578d4c0 109 * 0 in a 'status_variable', the device is not connected to the AP
dflet 0:bbe98578d4c0 110 */
dflet 0:bbe98578d4c0 111
dflet 0:bbe98578d4c0 112 STATUS_BIT_STA_CONNECTED, /* If this bit is:
dflet 0:bbe98578d4c0 113 * 1 in a 'status_variable', client is connected to device
dflet 0:bbe98578d4c0 114 * 0 in a 'status_variable', client is not connected to device
dflet 0:bbe98578d4c0 115 */
dflet 0:bbe98578d4c0 116
dflet 0:bbe98578d4c0 117 STATUS_BIT_IP_ACQUIRED, /* If this bit is:
dflet 0:bbe98578d4c0 118 * 1 in a 'status_variable', the device has acquired an IP
dflet 0:bbe98578d4c0 119 * 0 in a 'status_variable', the device has not acquired an IP
dflet 0:bbe98578d4c0 120 */
dflet 0:bbe98578d4c0 121
dflet 0:bbe98578d4c0 122 STATUS_BIT_IP_LEASED, /* If this bit is:
dflet 0:bbe98578d4c0 123 * 1 in a 'status_variable', the device has leased an IP
dflet 0:bbe98578d4c0 124 * 0 in a 'status_variable', the device has not leased an IP
dflet 0:bbe98578d4c0 125 */
dflet 0:bbe98578d4c0 126
dflet 0:bbe98578d4c0 127 STATUS_BIT_CONNECTION_FAILED, /* If this bit is:
dflet 0:bbe98578d4c0 128 * 1 in a 'status_variable', failed to connect to device
dflet 0:bbe98578d4c0 129 * 0 in a 'status_variable'
dflet 0:bbe98578d4c0 130 */
dflet 0:bbe98578d4c0 131
dflet 0:bbe98578d4c0 132 STATUS_BIT_P2P_NEG_REQ_RECEIVED,/* If this bit is:
dflet 0:bbe98578d4c0 133 * 1 in a 'status_variable', connection requested by remote wifi-direct device
dflet 0:bbe98578d4c0 134 * 0 in a 'status_variable',
dflet 0:bbe98578d4c0 135 */
dflet 0:bbe98578d4c0 136 STATUS_BIT_SMARTCONFIG_DONE, /* If this bit is:
dflet 0:bbe98578d4c0 137 * 1 in a 'status_variable', smartconfig completed
dflet 0:bbe98578d4c0 138 * 0 in a 'status_variable', smartconfig event couldn't complete
dflet 0:bbe98578d4c0 139 */
dflet 0:bbe98578d4c0 140
dflet 0:bbe98578d4c0 141 STATUS_BIT_SMARTCONFIG_STOPPED /* If this bit is:
dflet 0:bbe98578d4c0 142 * 1 in a 'status_variable', smartconfig process stopped
dflet 0:bbe98578d4c0 143 * 0 in a 'status_variable', smartconfig process running
dflet 0:bbe98578d4c0 144 */
dflet 0:bbe98578d4c0 145
dflet 0:bbe98578d4c0 146 }e_StatusBits;
dflet 0:bbe98578d4c0 147
dflet 0:bbe98578d4c0 148 #define SET_STATUS_BIT(status_variable, bit) status_variable |= ((unsigned long)1<<(bit))
dflet 0:bbe98578d4c0 149 #define CLR_STATUS_BIT(status_variable, bit) status_variable &= ~((unsigned long)1<<(bit))
dflet 0:bbe98578d4c0 150 #define GET_STATUS_BIT(status_variable, bit) (0 != (status_variable & ((unsigned long)1<<(bit))))
dflet 0:bbe98578d4c0 151
dflet 0:bbe98578d4c0 152 #define IS_CONNECTED(status_variable) GET_STATUS_BIT(status_variable, \
dflet 0:bbe98578d4c0 153 STATUS_BIT_CONNECTION)
dflet 0:bbe98578d4c0 154 #define IS_STA_CONNECTED(status_variable) GET_STATUS_BIT(status_variable, \
dflet 0:bbe98578d4c0 155 STATUS_BIT_STA_CONNECTED)
dflet 0:bbe98578d4c0 156 #define IS_IP_ACQUIRED(status_variable) GET_STATUS_BIT(status_variable, \
dflet 0:bbe98578d4c0 157 STATUS_BIT_IP_ACQUIRED)
dflet 0:bbe98578d4c0 158 #define IS_IP_LEASED(status_variable) GET_STATUS_BIT(status_variable, \
dflet 0:bbe98578d4c0 159 STATUS_BIT_IP_LEASED)
dflet 0:bbe98578d4c0 160 #define IS_CONNECTION_FAILED(status_variable) GET_STATUS_BIT(status_variable, \
dflet 0:bbe98578d4c0 161 STATUS_BIT_CONNECTION_FAILED)
dflet 0:bbe98578d4c0 162 #define IS_P2P_NEG_REQ_RECEIVED(status_variable) GET_STATUS_BIT(status_variable, \
dflet 0:bbe98578d4c0 163 STATUS_BIT_P2P_NEG_REQ_RECEIVED)
dflet 0:bbe98578d4c0 164 #define IS_SMARTCONFIG_DONE(status_variable) GET_STATUS_BIT(status_variable, \
dflet 0:bbe98578d4c0 165 STATUS_BIT_SMARTCONFIG_DONE)
dflet 0:bbe98578d4c0 166 #define IS_SMARTCONFIG_STOPPED(status_variable) GET_STATUS_BIT(status_variable, \
dflet 0:bbe98578d4c0 167 STATUS_BIT_SMARTCONFIG_STOPPED)
dflet 0:bbe98578d4c0 168
dflet 0:bbe98578d4c0 169 #define IS_PING_DONE(status_variable) GET_STATUS_BIT(status_variable, \
dflet 0:bbe98578d4c0 170 STATUS_BIT_PING_DONE)
dflet 0:bbe98578d4c0 171
dflet 0:bbe98578d4c0 172 #define STATUS_BIT_PING_DONE 31
dflet 0:bbe98578d4c0 173
dflet 0:bbe98578d4c0 174 static void SimpleLinkPingReport(SlPingReport_t *pPingReport);
dflet 0:bbe98578d4c0 175
dflet 0:bbe98578d4c0 176 #ifdef __cplusplus
dflet 0:bbe98578d4c0 177 }
dflet 0:bbe98578d4c0 178 #endif /* __cplusplus */
dflet 0:bbe98578d4c0 179
dflet 0:bbe98578d4c0 180 #endif /*__SL_CONFIG_H__*/
dflet 0:bbe98578d4c0 181