TI's CC3100 websocket camera demo with Arducam mini ov5642 and freertos. Should work with other M3's. Work in progress test demo.
cc3100.h
00001 /* 00002 * device.h - CC31xx/CC32xx Host Driver Implementation 00003 * 00004 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ 00005 * 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 00014 * Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in the 00016 * documentation and/or other materials provided with the 00017 * distribution. 00018 * 00019 * Neither the name of Texas Instruments Incorporated nor the names of 00020 * its contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00026 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00027 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00028 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00029 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00030 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00031 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00032 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 */ 00036 00037 #ifndef DEVICE_H_ 00038 #define DEVICE_H_ 00039 00040 /*****************************************************************************/ 00041 /* Include files */ 00042 /*****************************************************************************/ 00043 #include "mbed.h" 00044 #include "cc3100_simplelink.h" 00045 #include "cc3100_driver.h" 00046 #include "cc3100_wlan_rx_filters.h" 00047 00048 #include "cc3100_spi.h" 00049 #include "cc3100_netcfg.h" 00050 00051 namespace mbed_cc3100 { 00052 00053 /*! 00054 00055 \addtogroup device 00056 @{ 00057 00058 */ 00059 const int16_t ROLE_UNKNOWN_ERR = -1; 00060 00061 const uint16_t MAX_BUFF_SIZE = 1460; 00062 extern uint32_t g_PingPacketsRecv; 00063 extern uint32_t g_GatewayIP; 00064 extern uint32_t g_StationIP; 00065 extern uint32_t g_DestinationIP; 00066 extern uint32_t g_BytesReceived; // variable to store the file size 00067 extern uint32_t g_Status; 00068 extern uint8_t g_buff[MAX_BUFF_SIZE+1]; 00069 extern int32_t g_SockID; 00070 00071 00072 /* File on the serial flash */ 00073 #define FILE_NAME "cc3000_module.pdf" 00074 #define HOST_NAME "www.ti.com" 00075 00076 #define HTTP_FILE_NOT_FOUND "404 Not Found" /* HTTP file not found response */ 00077 //#define HTTP_STATUS_OK "200 OK" /* HTTP status ok response */ 00078 #define HTTP_CONTENT_LENGTH "Content-Length:" /* HTTP content length header */ 00079 #define HTTP_TRANSFER_ENCODING "Transfer-Encoding:" /* HTTP transfer encoding header */ 00080 #define HTTP_ENCODING_CHUNKED "chunked" /* HTTP transfer encoding header value */ 00081 #define HTTP_CONNECTION "Connection:" /* HTTP Connection header */ 00082 #define HTTP_CONNECTION_CLOSE "close" /* HTTP Connection header value */ 00083 #define HTTP_END_OF_HEADER "\r\n\r\n" /* string marking the end of headers in response */ 00084 00085 /*****************************************************************************/ 00086 /* Macro declarations */ 00087 /*****************************************************************************/ 00088 00089 const uint16_t IP_LEASE_TIME = 3600; 00090 00091 const uint16_t SIZE_45K = 46080; /* Serial flash file size 45 KB */ 00092 const uint16_t READ_SIZE = 1450; 00093 const uint8_t SPACE = 32; 00094 00095 const uint16_t PING_INTERVAL = 1000; 00096 const uint8_t PING_SIZE = 20; 00097 const uint16_t PING_TIMEOUT = 3000; 00098 const uint8_t PING_ATTEMPTS = 3; 00099 const uint8_t PING_PKT_SIZE = 20; 00100 00101 const uint8_t SL_STOP_TIMEOUT = 0xFF; 00102 00103 /* SL internal Error codes */ 00104 00105 /* Receive this error in case there are no resources to issue the command 00106 If possible, increase the number of MAX_CUNCURENT_ACTIONS (result in memory increase) 00107 If not, try again later */ 00108 const int16_t SL_POOL_IS_EMPTY = (-2000); 00109 00110 /* Receive this error in case a given length for RX buffer was too small. 00111 Receive payload was bigger than the given buffer size. Therefore, payload is cut according to receive size 00112 Recommend to increase buffer size */ 00113 const int16_t SL_ESMALLBUF = (-2001); 00114 00115 /* Receive this error in case zero length is supplied to a "get" API 00116 Recommend to supply length according to requested information (view options defines for help) */ 00117 const int16_t SL_EZEROLEN = (-2002); 00118 00119 /* User supplied invalid parameter */ 00120 const int16_t SL_INVALPARAM = (-2003); 00121 00122 /* Failed to open interface */ 00123 const int16_t SL_BAD_INTERFACE = (-2004); 00124 00125 /* End of SL internal Error codes */ 00126 00127 /*****************************************************************************/ 00128 /* Errors returned from the general error async event */ 00129 /*****************************************************************************/ 00130 00131 /* Use bit 32: Lower bits of status variable are used for NWP events 00132 * 1 in a 'status_variable', the device has completed the ping operation 00133 * 0 in a 'status_variable', the device has not completed the ping operation 00134 */ 00135 //const uint32_t STATUS_BIT_PING_DONE = 31; 00136 00137 /* Status bits - These are used to set/reset the corresponding bits in a 'status_variable' */ 00138 typedef enum { 00139 STATUS_BIT_CONNECTION = 0, /* If this bit is: 00140 * 1 in a 'status_variable', the device is connected to the AP 00141 * 0 in a 'status_variable', the device is not connected to the AP 00142 */ 00143 00144 STATUS_BIT_STA_CONNECTED, /* If this bit is: 00145 * 1 in a 'status_variable', client is connected to device 00146 * 0 in a 'status_variable', client is not connected to device 00147 */ 00148 00149 STATUS_BIT_IP_ACQUIRED, /* If this bit is: 00150 * 1 in a 'status_variable', the device has acquired an IP 00151 * 0 in a 'status_variable', the device has not acquired an IP 00152 */ 00153 00154 STATUS_BIT_IP_LEASED, /* If this bit is: 00155 * 1 in a 'status_variable', the device has leased an IP 00156 * 0 in a 'status_variable', the device has not leased an IP 00157 */ 00158 00159 STATUS_BIT_CONNECTION_FAILED, /* If this bit is: 00160 * 1 in a 'status_variable', failed to connect to device 00161 * 0 in a 'status_variable' 00162 */ 00163 00164 STATUS_BIT_P2P_NEG_REQ_RECEIVED,/* If this bit is: 00165 * 1 in a 'status_variable', connection requested by remote wifi-direct device 00166 * 0 in a 'status_variable', 00167 */ 00168 STATUS_BIT_SMARTCONFIG_DONE, /* If this bit is: 00169 * 1 in a 'status_variable', smartconfig completed 00170 * 0 in a 'status_variable', smartconfig event couldn't complete 00171 */ 00172 00173 STATUS_BIT_SMARTCONFIG_STOPPED, /* If this bit is: 00174 * 1 in a 'status_variable', smartconfig process stopped 00175 * 0 in a 'status_variable', smartconfig process running 00176 */ 00177 00178 STATUS_BIT_PING_DONE = 31 00179 /* Use bit 32: Lower bits of status variable are used for NWP events 00180 * 1 in a 'status_variable', the device has completed the ping operation 00181 * 0 in a 'status_variable', the device has not completed the ping operation 00182 */ 00183 00184 } e_StatusBits; 00185 00186 /* Application specific status/error codes */ 00187 typedef enum { 00188 LAN_CONNECTION_FAILED = -0x7D0, /* Choosing this number to avoid overlap with host-driver's error codes */ 00189 CAMERA_CAPTURE_FAILED = -0x7D0, 00190 INTERNET_CONNECTION_FAILED = LAN_CONNECTION_FAILED - 1, 00191 DEVICE_NOT_IN_STATION_MODE = INTERNET_CONNECTION_FAILED - 1, 00192 DEVICE_NOT_IN_AP_MODE = DEVICE_NOT_IN_STATION_MODE - 1, 00193 DEVICE_NOT_IN_P2P_MODE = DEVICE_NOT_IN_STATION_MODE - 1, 00194 HTTP_SEND_ERROR = DEVICE_NOT_IN_STATION_MODE - 1, 00195 HTTP_RECV_ERROR = HTTP_SEND_ERROR - 1, 00196 HTTP_INVALID_RESPONSE = HTTP_RECV_ERROR -1, 00197 SNTP_SEND_ERROR = DEVICE_NOT_IN_STATION_MODE - 1, 00198 SNTP_RECV_ERROR = SNTP_SEND_ERROR - 1, 00199 SNTP_SERVER_RESPONSE_ERROR = SNTP_RECV_ERROR - 1, 00200 INVALID_HEX_STRING = DEVICE_NOT_IN_STATION_MODE - 1, 00201 TCP_RECV_ERROR = INVALID_HEX_STRING - 1, 00202 TCP_SEND_ERROR = TCP_RECV_ERROR - 1, 00203 FILE_NOT_FOUND_ERROR = TCP_SEND_ERROR - 1, 00204 INVALID_SERVER_RESPONSE = FILE_NOT_FOUND_ERROR - 1, 00205 FORMAT_NOT_SUPPORTED = INVALID_SERVER_RESPONSE - 1, 00206 FILE_WRITE_ERROR = FORMAT_NOT_SUPPORTED - 1, 00207 INVALID_FILE = FILE_WRITE_ERROR - 1, 00208 00209 STATUS_CODE_MAX = -0xBB8 00210 } e_AppStatusCodes; 00211 00212 /* Send types */ 00213 typedef enum { 00214 SL_ERR_SENDER_HEALTH_MON, 00215 SL_ERR_SENDER_CLI_UART, 00216 SL_ERR_SENDER_SUPPLICANT, 00217 SL_ERR_SENDER_NETWORK_STACK, 00218 SL_ERR_SENDER_WLAN_DRV_IF, 00219 SL_ERR_SENDER_WILINK, 00220 SL_ERR_SENDER_INIT_APP, 00221 SL_ERR_SENDER_NETX, 00222 SL_ERR_SENDER_HOST_APD, 00223 SL_ERR_SENDER_MDNS, 00224 SL_ERR_SENDER_HTTP_SERVER, 00225 SL_ERR_SENDER_DHCP_SERVER, 00226 SL_ERR_SENDER_DHCP_CLIENT, 00227 SL_ERR_DISPATCHER, 00228 SL_ERR_NUM_SENDER_LAST=0xFF 00229 } SlErrorSender_e; 00230 00231 /* Error codes */ 00232 const int8_t SL_ERROR_STATIC_ADDR_SUBNET_ERROR = (-60); /* network stack error*/ 00233 const int8_t SL_ERROR_ILLEGAL_CHANNEL = (-61); /* supplicant error */ 00234 const int8_t SL_ERROR_SUPPLICANT_ERROR = (-72); /* init error code */ 00235 const int8_t SL_ERROR_HOSTAPD_INIT_FAIL = (-73); /* init error code */ 00236 const int8_t SL_ERROR_HOSTAPD_INIT_IF_FAIL = (-74); /* init error code */ 00237 const int8_t SL_ERROR_WLAN_DRV_INIT_FAIL = (-75); /* init error code */ 00238 const int8_t SL_ERROR_WLAN_DRV_START_FAIL = (-76); /* wlan start error */ 00239 const int8_t SL_ERROR_FS_FILE_TABLE_LOAD_FAILED = (-77); /* init file system failed */ 00240 const int8_t SL_ERROR_PREFERRED_NETWORKS_FILE_LOAD_FAILED = (-78); /* init file system failed */ 00241 const int8_t SL_ERROR_HOSTAPD_BSSID_VALIDATION_ERROR = (-79); /* Ap configurations BSSID error */ 00242 const int8_t SL_ERROR_HOSTAPD_FAILED_TO_SETUP_INTERFACE = (-80); /* Ap configurations interface error */ 00243 const int8_t SL_ERROR_MDNS_ENABLE_FAIL = (-81); /* mDNS enable failed */ 00244 const int8_t SL_ERROR_HTTP_SERVER_ENABLE_FAILED = (-82); /* HTTP server enable failed */ 00245 const int8_t SL_ERROR_DHCP_SERVER_ENABLE_FAILED = (-83); /* DHCP server enable failed */ 00246 const int8_t SL_ERROR_PREFERRED_NETWORK_LIST_FULL = (-93); /* supplicant error */ 00247 const int8_t SL_ERROR_PREFERRED_NETWORKS_FILE_WRITE_FAILED = (-94); /* supplicant error */ 00248 const int8_t SL_ERROR_DHCP_CLIENT_RENEW_FAILED = (-100); /* DHCP client error */ 00249 /* WLAN Connection management status */ 00250 const int8_t SL_ERROR_CON_MGMT_STATUS_UNSPECIFIED = (-102); 00251 const int8_t SL_ERROR_CON_MGMT_STATUS_AUTH_REJECT = (-103); 00252 const int8_t SL_ERROR_CON_MGMT_STATUS_ASSOC_REJECT = (-104); 00253 const int8_t SL_ERROR_CON_MGMT_STATUS_SECURITY_FAILURE = (-105); 00254 const int8_t SL_ERROR_CON_MGMT_STATUS_AP_DEAUTHENTICATE = (-106); 00255 const int8_t SL_ERROR_CON_MGMT_STATUS_AP_DISASSOCIATE = (-107); 00256 const int8_t SL_ERROR_CON_MGMT_STATUS_ROAMING_TRIGGER = (-108); 00257 const int8_t SL_ERROR_CON_MGMT_STATUS_DISCONNECT_DURING_CONNECT = (-109); 00258 const int8_t SL_ERROR_CON_MGMT_STATUS_SG_RESELECT = (-110); 00259 const int8_t SL_ERROR_CON_MGMT_STATUS_ROC_FAILURE = (-111); 00260 const int8_t SL_ERROR_CON_MGMT_STATUS_MIC_FAILURE = (-112); 00261 /* end of WLAN connection management error statuses */ 00262 const int8_t SL_ERROR_WAKELOCK_ERROR_PREFIX = (-115); /* Wake lock expired */ 00263 const int8_t SL_ERROR_LENGTH_ERROR_PREFIX = (-116); /* Uart header length error */ 00264 const int8_t SL_ERROR_MDNS_CREATE_FAIL = (-121); /* mDNS create failed */ 00265 const int8_t SL_ERROR_GENERAL_ERROR = (-127); 00266 00267 00268 00269 const int8_t SL_DEVICE_GENERAL_CONFIGURATION = (1); 00270 const int8_t SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME = (11); 00271 const int8_t SL_DEVICE_GENERAL_VERSION = (12); 00272 const int8_t SL_DEVICE_STATUS = (2); 00273 00274 /* 00275 Declare the different event group classifications 00276 The SimpleLink device send asynchronous events. Each event has a group 00277 classification according to its nature. 00278 */ 00279 #if 1 00280 /* SL_EVENT_CLASS_WLAN connection user events */ 00281 const int8_t SL_WLAN_CONNECT_EVENT = (1); 00282 const int8_t SL_WLAN_DISCONNECT_EVENT = (2); 00283 /* WLAN Smart Config user events */ 00284 const int8_t SL_WLAN_SMART_CONFIG_COMPLETE_EVENT = (3); 00285 const int8_t SL_WLAN_SMART_CONFIG_STOP_EVENT = (4); 00286 /* WLAN AP user events */ 00287 const int8_t SL_WLAN_STA_CONNECTED_EVENT = (5); 00288 const int8_t SL_WLAN_STA_DISCONNECTED_EVENT = (6); 00289 /* WLAN P2P user events */ 00290 const int8_t SL_WLAN_P2P_DEV_FOUND_EVENT = (7); 00291 const int8_t SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT = (8); 00292 const int8_t SL_WLAN_CONNECTION_FAILED_EVENT = (9); 00293 /* SL_EVENT_CLASS_DEVICE user events */ 00294 const int8_t SL_DEVICE_FATAL_ERROR_EVENT = (1); 00295 const int8_t SL_DEVICE_ABORT_ERROR_EVENT = (2); 00296 /* SL_EVENT_CLASS_BSD user events */ 00297 const int8_t SL_SOCKET_TX_FAILED_EVENT = (1); 00298 const int8_t SL_SOCKET_ASYNC_EVENT = (2); 00299 /* SL_EVENT_CLASS_NETAPP user events */ 00300 const int8_t SL_NETAPP_IPV4_IPACQUIRED_EVENT = (1); 00301 const int8_t SL_NETAPP_IPV6_IPACQUIRED_EVENT = (2); 00302 const int8_t SL_NETAPP_IP_LEASED_EVENT = (3); 00303 const int8_t SL_NETAPP_IP_RELEASED_EVENT = (4); 00304 00305 /* Server Events */ 00306 const int8_t SL_NETAPP_HTTPGETTOKENVALUE_EVENT = (1); 00307 const int8_t SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT = (2); 00308 #endif 00309 00310 /* 00311 Declare the different event group classifications for sl_DevGet 00312 for getting status indications 00313 */ 00314 00315 /* Events list to mask/unmask*/ 00316 const int8_t SL_EVENT_CLASS_GLOBAL = (0); 00317 const int8_t SL_EVENT_CLASS_DEVICE = (1); 00318 const int8_t SL_EVENT_CLASS_WLAN = (2); 00319 const int8_t SL_EVENT_CLASS_BSD = (3); 00320 const int8_t SL_EVENT_CLASS_NETAPP = (4); 00321 const int8_t SL_EVENT_CLASS_NETCFG = (5); 00322 const int8_t SL_EVENT_CLASS_FS = (6); 00323 00324 00325 /****************** DEVICE CLASS status ****************/ 00326 const uint32_t EVENT_DROPPED_DEVICE_ASYNC_GENERAL_ERROR = (0x00000001L); 00327 const uint32_t STATUS_DEVICE_SMART_CONFIG_ACTIVE = (0x80000000L); 00328 00329 /****************** WLAN CLASS status ****************/ 00330 const uint32_t EVENT_DROPPED_WLAN_WLANASYNCONNECTEDRESPONSE = (0x00000001L); 00331 const uint32_t EVENT_DROPPED_WLAN_WLANASYNCDISCONNECTEDRESPONSE = (0x00000002L); 00332 const uint32_t EVENT_DROPPED_WLAN_STA_CONNECTED = (0x00000004L); 00333 const uint32_t EVENT_DROPPED_WLAN_STA_DISCONNECTED = (0x00000008L); 00334 const uint32_t STATUS_WLAN_STA_CONNECTED = (0x80000000L); 00335 00336 /****************** NETAPP CLASS status ****************/ 00337 const uint32_t EVENT_DROPPED_NETAPP_IPACQUIRED = (0x00000001L); 00338 const uint32_t EVENT_DROPPED_NETAPP_IPACQUIRED_V6 = (0x00000002L); 00339 const uint32_t EVENT_DROPPED_NETAPP_IP_LEASED = (0x00000004L); 00340 const uint32_t EVENT_DROPPED_NETAPP_IP_RELEASED = (0x00000008L); 00341 00342 /****************** BSD CLASS status ****************/ 00343 const uint32_t EVENT_DROPPED_SOCKET_TXFAILEDASYNCRESPONSE = (0x00000001L); 00344 00345 /****************** FS CLASS ****************/ 00346 00347 /*****************************************************************************/ 00348 /* Structure/Enum declarations */ 00349 /*****************************************************************************/ 00350 00351 #ifdef SL_IF_TYPE_UART 00352 typedef struct { 00353 uint32_t BaudRate; 00354 uint8_t FlowControlEnable; 00355 uint8_t CommPort; 00356 } SlUartIfParams_t; 00357 #endif 00358 00359 typedef struct { 00360 uint32_t ChipId; 00361 uint32_t FwVersion[4]; 00362 uint8_t PhyVersion[4]; 00363 } _SlPartialVersion; 00364 00365 typedef struct { 00366 _SlPartialVersion ChipFwAndPhyVersion; 00367 uint32_t NwpVersion[4]; 00368 uint16_t RomVersion; 00369 uint16_t Padding; 00370 } SlVersionFull; 00371 00372 typedef struct 00373 { 00374 uint32_t AbortType; 00375 uint32_t AbortData; 00376 }sl_DeviceReportAbort; 00377 00378 typedef struct { 00379 int8_t status; 00380 SlErrorSender_e sender; 00381 } sl_DeviceReport; 00382 00383 typedef union { 00384 sl_DeviceReport deviceEvent; 00385 sl_DeviceReportAbort deviceReport; 00386 } _SlDeviceEventData_u; 00387 00388 typedef struct { 00389 uint32_t Event; 00390 _SlDeviceEventData_u EventData; 00391 } SlDeviceEvent_t; 00392 00393 typedef struct { 00394 /* time */ 00395 uint32_t sl_tm_sec; 00396 uint32_t sl_tm_min; 00397 uint32_t sl_tm_hour; 00398 /* date */ 00399 uint32_t sl_tm_day; /* 1-31 */ 00400 uint32_t sl_tm_mon; /* 1-12 */ 00401 uint32_t sl_tm_year; /* YYYY 4 digits */ 00402 uint32_t sl_tm_week_day; /* not required */ 00403 uint32_t sl_tm_year_day; /* not required */ 00404 uint32_t reserved[3]; 00405 } SlDateTime_t; 00406 00407 /******************************************************************************/ 00408 /* Type declarations */ 00409 /******************************************************************************/ 00410 typedef void (*P_INIT_CALLBACK)(uint32_t Status); 00411 00412 class cc3100_netcfg; 00413 00414 class cc3100 00415 { 00416 00417 public: 00418 00419 cc3100(PinName button1_irq, PinName button2_irq, PinName cc3100_irq, PinName cc3100_nHIB, PinName cc3100_cs, SPI cc3100_spi); 00420 00421 ~cc3100(); 00422 00423 /*****************************************************************************/ 00424 /* Function prototypes */ 00425 /*****************************************************************************/ 00426 int32_t initializeAppVariables(); 00427 00428 int32_t establishConnectionWithAP(void); 00429 00430 int32_t checkLanConnection(void); 00431 00432 int32_t checkInternetConnection(void); 00433 00434 int32_t createUDPConnection(void); 00435 00436 int32_t createConnection(uint32_t DestinationIP); 00437 00438 int32_t getChunkSize(int32_t *len, uint8_t **p_Buff, uint32_t *chunk_size); 00439 00440 int32_t hexToi(unsigned char *ptr); 00441 00442 // int32_t getFile(void); 00443 00444 int32_t disconnectFromAP(void); 00445 00446 uint16_t itoa(int16_t cNum, uint8_t *cString); 00447 00448 int32_t Network_IF_InitDriver(uint32_t uiMode); 00449 00450 int32_t configureSimpleLinkToDefaultState(void); 00451 00452 int16_t _sl_GetStartResponseConvert(uint32_t Status); 00453 00454 void _sl_HandleAsync_InitComplete(void *pVoidBuf); 00455 00456 bool IS_PING_DONE(uint32_t status_variable,const uint32_t bit); 00457 bool IS_CONNECTED(uint32_t status_variable,const uint32_t bit); 00458 bool IS_STA_CONNECTED(uint32_t status_variable,const uint32_t bit); 00459 bool IS_IP_ACQUIRED(uint32_t status_variable,const uint32_t bit); 00460 bool IS_IP_LEASED(uint32_t status_variable,const uint32_t bit); 00461 bool IS_CONNECTION_FAILED(uint32_t status_variable,const uint32_t bit); 00462 bool IS_P2P_NEG_REQ_RECEIVED(uint32_t status_variable,const uint32_t bit); 00463 bool IS_SMARTCONFIG_DONE(uint32_t status_variable,const uint32_t bit); 00464 bool IS_SMARTCONFIG_STOPPED(uint32_t status_variable,const uint32_t bit); 00465 00466 00467 00468 void CLR_STATUS_BIT(uint32_t status_variable, const uint32_t bit); 00469 void SET_STATUS_BIT(uint32_t status_variable, const uint32_t bit); 00470 void CLR_STATUS_BIT_ALL(uint32_t status_variable); 00471 00472 /*! 00473 \brief Start the SimpleLink device 00474 00475 This function initialize the communication interface, set the enable pin 00476 of the device, and call to the init complete callback. 00477 00478 \param[in] pIfHdl Opened Interface Object. In case the interface 00479 must be opened outside the SimpleLink Driver, the 00480 user might give the handler to be used in \n 00481 any access of the communication interface with the 00482 device (UART/SPI). \n 00483 The SimpleLink driver will open an interface port 00484 only if this parameter is null! \n 00485 \param[in] pDevName The name of the device to open. Could be used when 00486 the pIfHdl is null, to transfer information to the 00487 open interface function \n 00488 This pointer could be used to pass additional information to 00489 sl_IfOpen in case it is required (e.g. UART com port name) 00490 \param[in] pInitCallBack Pointer to function that would be called 00491 on completion of the initialization process.\n 00492 If this parameter is NULL the function is 00493 blocked until the device initialization 00494 is completed, otherwise the function returns 00495 immediately. 00496 00497 \return Returns the current active role (STA/AP/P2P) or an error code: 00498 - ROLE_STA, ROLE_AP, ROLE_P2P in case of success, 00499 otherwise in failure one of the following is return: 00500 - ROLE_STA_ERR (Failure to load MAC/PHY in STA role) 00501 - ROLE_AP_ERR (Failure to load MAC/PHY in AP role) 00502 - ROLE_P2P_ERR (Failure to load MAC/PHY in P2P role) 00503 00504 00505 \sa sl_Stop 00506 00507 \note belongs to \ref basic_api 00508 00509 \warning This function must be called before any other SimpleLink API is used, or after sl_Stop is called for reinit the device 00510 \par Example: 00511 \code 00512 An example for open interface without callback routine. The interface name and handler are 00513 handled by the sl_IfOpen routine: 00514 00515 if( sl_Start(NULL, NULL, NULL) < 0 ) 00516 { 00517 LOG("Error opening interface to device\n"); 00518 } 00519 \endcode 00520 */ 00521 #if _SL_INCLUDE_FUNC(sl_Start) 00522 int16_t sl_Start(const void* pIfHdl, int8_t* pDevName, const P_INIT_CALLBACK pInitCallBack); 00523 #endif 00524 00525 /*! 00526 \brief Stop the SimpleLink device 00527 00528 This function clears the enable pin of the device, closes the communication \n 00529 interface and invokes the stop complete callback 00530 00531 \param[in] timeout Stop timeout in msec. Should be used to give the device time to finish \n 00532 any transmission/reception that is not completed when the function was called. \n 00533 Additional options: 00534 - 0 Enter to hibernate immediately \n 00535 - 0xFFFF Host waits for device's response before \n 00536 hibernating, without timeout protection \n 00537 - 0 < Timeout[msec] < 0xFFFF Host waits for device's response before \n 00538 hibernating, with a defined timeout protection \n 00539 This timeout defines the max time to wait. The NWP \n 00540 response can be sent earlier than this timeout. 00541 00542 \return On success, zero is returned. On error, -1 is returned 00543 00544 \sa sl_Start 00545 00546 \note This API will shutdown the device and invoke the "i/f close" function regardless \n 00547 if it was opened implicitly or explicitly. \n 00548 It is up to the platform interface library to properly handle interface close \n 00549 routine \n 00550 belongs to \ref basic_api \n 00551 \warning 00552 */ 00553 #if _SL_INCLUDE_FUNC(sl_Stop) 00554 int16_t sl_Stop(const uint16_t timeout); 00555 #endif 00556 00557 00558 /*! 00559 \brief Internal function for setting device configurations 00560 00561 \return On success, zero is returned. On error, -1 is 00562 returned 00563 00564 \param[in] DeviceSetId configuration id 00565 \param[in] Option configurations option 00566 \param[in] ConfigLen configurations len 00567 \param[in] pValues configurations values 00568 00569 \sa 00570 \note 00571 \warning 00572 \par Examples: 00573 \code 00574 Setting device time and date example: 00575 00576 SlDateTime_t dateTime= {0}; 00577 dateTime.sl_tm_day = (uint32_t)23; // Day of month (DD format) range 1-13 00578 dateTime.sl_tm_mon = (uint32_t)6; // Month (MM format) in the range of 1-12 00579 dateTime.sl_tm_year = (uint32_t)2014; // Year (YYYY format) 00580 dateTime.sl_tm_hour = (uint32_t)17; // Hours in the range of 0-23 00581 dateTime.sl_tm_min = (uint32_t)55; // Minutes in the range of 0-59 00582 dateTime.sl_tm_sec = (uint32_t)22; // Seconds in the range of 0-59 00583 sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION, 00584 SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME, 00585 sizeof(SlDateTime_t), 00586 (uint8_t *)(&dateTime)); 00587 00588 \endcode 00589 */ 00590 #if _SL_INCLUDE_FUNC(sl_DevSet) 00591 int32_t sl_DevSet(const uint8_t DeviceSetId , const uint8_t Option, const uint8_t ConfigLen, const uint8_t *pValues); 00592 #endif 00593 00594 /*! 00595 \brief Internal function for getting device configurations 00596 \return On success, zero is returned. On error, -1 is 00597 returned 00598 \param[in] DeviceGetId configuration id - example SL_DEVICE_STATUS 00599 \param[out] pOption Get configurations option, example for get status options 00600 - SL_EVENT_CLASS_GLOBAL 00601 - SL_EVENT_CLASS_DEVICE 00602 - SL_EVENT_CLASS_WLAN 00603 - SL_EVENT_CLASS_BSD 00604 - SL_EVENT_CLASS_NETAPP 00605 - SL_EVENT_CLASS_NETCFG 00606 - SL_EVENT_CLASS_FS 00607 \param[out] pConfigLen The length of the allocated memory as input, when the 00608 function complete, the value of this parameter would be 00609 the len that actually read from the device.\n 00610 If the device return length that is longer from the input 00611 value, the function will cut the end of the returned structure 00612 and will return SL_ESMALLBUF 00613 \param[out] pValues Get configurations values 00614 \sa 00615 \note 00616 \warning 00617 \par Examples: 00618 \code 00619 Example for getting WLAN class status: 00620 uint32_t statusWlan; 00621 uint8_t pConfigOpt; 00622 uint8_t pConfigLen; 00623 pConfigLen = sizeof(_u32); 00624 pConfigOpt = SL_EVENT_CLASS_WLAN; 00625 sl_DevGet(SL_DEVICE_STATUS,&pConfigOpt,&pConfigLen,(uint8_t *)(&statusWlan)); 00626 Example for getting version: 00627 SlVersionFull ver; 00628 pConfigLen = sizeof(ver); 00629 pConfigOpt = SL_DEVICE_GENERAL_VERSION; 00630 sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&pConfigOpt,&pConfigLen,(uint8_t *)(&ver)); 00631 printf("CHIP %d\nMAC 31.%d.%d.%d.%d\nPHY %d.%d.%d.%d\nNWP %d.%d.%d.%d\nROM %d\nHOST %d.%d.%d.%d\n", 00632 ver.ChipFwAndPhyVersion.ChipId, 00633 ver.ChipFwAndPhyVersion.FwVersion[0],ver.ChipFwAndPhyVersion.FwVersion[1], 00634 ver.ChipFwAndPhyVersion.FwVersion[2],ver.ChipFwAndPhyVersion.FwVersion[3], 00635 ver.ChipFwAndPhyVersion.PhyVersion[0],ver.ChipFwAndPhyVersion.PhyVersion[1], 00636 ver.ChipFwAndPhyVersion.PhyVersion[2],ver.ChipFwAndPhyVersion.PhyVersion[3], 00637 ver.NwpVersion[0],ver.NwpVersion[1],ver.NwpVersion[2],ver.NwpVersion[3], 00638 ver.RomVersion, 00639 SL_MAJOR_VERSION_NUM,SL_MINOR_VERSION_NUM,SL_VERSION_NUM,SL_SUB_VERSION_NUM); 00640 00641 \endcode 00642 \code 00643 Getting Device time and date example: 00644 00645 SlDateTime_t dateTime = {0}; 00646 int8_t configLen = sizeof(SlDateTime_t); 00647 int8_t configOpt = SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME; 00648 sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&configOpt, &configLen,(uint8_t *)(&dateTime)); 00649 00650 printf("Day %d,Mon %d,Year %d,Hour %,Min %d,Sec %d\n",dateTime.sl_tm_day,dateTime.sl_tm_mon,dateTime.sl_tm_year 00651 dateTime.sl_tm_hour,dateTime.sl_tm_min,dateTime.sl_tm_sec); 00652 \endcode 00653 */ 00654 #if _SL_INCLUDE_FUNC(sl_DevGet) 00655 int32_t sl_DevGet(const uint8_t DeviceGetId, uint8_t *pOption,uint8_t *pConfigLen, uint8_t *pValues); 00656 #endif 00657 00658 00659 /*! 00660 \brief Set asynchronous event mask 00661 00662 Mask asynchronous events from the device. Masked events do not 00663 generate asynchronous messages from the device. 00664 By default - all events are active 00665 00666 \param[in] EventClass The classification groups that the 00667 mask is referred to. Need to be one of 00668 the following: 00669 - SL_EVENT_CLASS_GLOBAL 00670 - SL_EVENT_CLASS_DEVICE 00671 - SL_EVENT_CLASS_WLAN 00672 - SL_EVENT_CLASS_BSD 00673 - SL_EVENT_CLASS_NETAPP 00674 - SL_EVENT_CLASS_NETCFG 00675 - SL_EVENT_CLASS_FS 00676 00677 00678 \param[in] Mask Event Mask bitmap. Valid mask are (per group): 00679 - SL_EVENT_CLASS_WLAN user events 00680 - SL_WLAN_CONNECT_EVENT 00681 - SL_WLAN_DISCONNECT_EVENT 00682 - SL_EVENT_CLASS_DEVICE user events 00683 - SL_DEVICE_FATAL_ERROR_EVENT 00684 - SL_EVENT_CLASS_BSD user events 00685 - SL_SOCKET_TX_FAILED_EVENT 00686 - SL_SOCKET_ASYNC_EVENT 00687 - SL_EVENT_CLASS_NETAPP user events 00688 - SL_NETAPP_IPV4_IPACQUIRED_EVENT 00689 - SL_NETAPP_IPV6_IPACQUIRED_EVENT 00690 00691 \return On success, zero is returned. On error, -1 is returned 00692 00693 \sa sl_EventMaskGet 00694 00695 \note belongs to \ref ext_api 00696 00697 \warning 00698 \par Example: 00699 \code 00700 00701 An example of masking connection/disconnection async events from WLAN class: 00702 sl_EventMaskSet(SL_EVENT_CLASS_WLAN, (SL_WLAN_CONNECT_EVENT | SL_WLAN_DISCONNECT_EVENT) ); 00703 00704 \endcode 00705 */ 00706 #if _SL_INCLUDE_FUNC(sl_EventMaskSet) 00707 int16_t sl_EventMaskSet(const uint8_t EventClass , const uint32_t Mask); 00708 #endif 00709 00710 /*! 00711 \brief Get current event mask of the device 00712 00713 return the events bit mask from the device. In case that event is 00714 masked, the device is not sending this event. 00715 00716 \param[in] EventClass The classification groups that the 00717 mask is referred to. Need to be one of 00718 the following: 00719 - SL_EVENT_CLASS_GLOBAL 00720 - SL_EVENT_CLASS_DEVICE 00721 - SL_EVENT_CLASS_WLAN 00722 - SL_EVENT_CLASS_BSD 00723 - SL_EVENT_CLASS_NETAPP 00724 - SL_EVENT_CLASS_NETCFG 00725 - SL_EVENT_CLASS_FS 00726 00727 \param[out] pMask Pointer to Mask bitmap where the 00728 value should be stored. Bitmasks are the same as in \ref sl_EventMaskSet 00729 00730 \return On success, zero is returned. On error, -1 is returned 00731 00732 \sa sl_EventMaskSet 00733 00734 \note belongs to \ref ext_api 00735 00736 \warning 00737 \par Example: 00738 \code 00739 00740 An example of getting an event mask for WLAN class 00741 uint32_t maskWlan; 00742 sl_StatusGet(SL_EVENT_CLASS_WLAN,&maskWlan); 00743 00744 \endcode 00745 */ 00746 #if _SL_INCLUDE_FUNC(sl_EventMaskGet) 00747 int16_t sl_EventMaskGet(const uint8_t EventClass, uint32_t *pMask); 00748 #endif 00749 00750 00751 /*! 00752 \brief the simple link task entry 00753 00754 \Param 00755 This function must be called from the main loop or from dedicated thread in 00756 the following cases: 00757 - Non-Os Platform - should be called from the mail loop 00758 - Multi Threaded Platform when the user does not implement the external spawn functions - 00759 should be called from dedicated thread allocated to the simplelink driver. 00760 In this mode the function never return. 00761 00762 \return None 00763 00764 \sa sl_Stop 00765 00766 \note belongs to \ref basic_api 00767 00768 \warning This function must be called from a thread that is start running before 00769 any call to other simple link API 00770 */ 00771 #if _SL_INCLUDE_FUNC(sl_Task) 00772 void sl_Task(void); 00773 #endif 00774 00775 00776 /*! 00777 \brief Setting the internal uart mode 00778 00779 \param[in] pUartParams Pointer to the uart configuration parameter set: 00780 baudrate - up to 711 Kbps 00781 flow control - enable/disable 00782 comm port - the comm port number 00783 00784 \return On success zero is returned, otherwise - Failed. 00785 00786 \sa sl_Stop 00787 00788 \note belongs to \ref basic_api 00789 00790 \warning This function must consider the host uart capability 00791 */ 00792 #ifdef SL_IF_TYPE_UART 00793 #if _SL_INCLUDE_FUNC(sl_UartSetMode) 00794 int16_t sl_UartSetMode(const SlUartIfParams_t* pUartParams); 00795 #endif 00796 #endif 00797 00798 public: 00799 00800 cc3100_spi _spi; 00801 cc3100_driver _driver; 00802 #ifndef SL_PLATFORM_MULTI_THREADED 00803 cc3100_nonos _nonos; 00804 #endif 00805 cc3100_wlan _wlan; 00806 cc3100_wlan_rx_filters _wlan_filters; 00807 cc3100_netapp _netapp; 00808 cc3100_fs _fs; 00809 cc3100_netcfg _netcfg; 00810 cc3100_socket _socket; 00811 cc3100_flowcont _flowcont; 00812 00813 00814 protected: 00815 00816 00817 };//class 00818 00819 }//namespace mbed_cc3100 00820 00821 /*! 00822 00823 Close the Doxygen group. 00824 @} 00825 00826 */ 00827 00828 00829 #endif /* __DEVICE_H__ */ 00830 00831 00832
Generated on Wed Jul 13 2022 15:58:45 by
1.7.2