TI's CC3100. A test demo with very little testing done!

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dflet
Date:
Sun Feb 22 18:33:10 2015 +0000
Parent:
2:b3fd5b3d9860
Child:
4:5af740da0a59
Commit message:
Removed more debug.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
simplelink/cc3100.cpp Show annotated file Show diff for this revision Revisions of this file
simplelink/cc3100.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Feb 15 11:01:37 2015 +0000
+++ b/main.cpp	Sun Feb 22 18:33:10 2015 +0000
@@ -50,13 +50,12 @@
 #include "cc3100_sl_common.h"
 
 #include "fPtr_func.h"
+#include "cc3100.h"
 #include "cc3100_spi.h"
 #include "myBoardInit.h"
 
 using namespace mbed_cc3100;
 
-class cc3100_netcfg *_netcfg;
-
 #if (THIS_BOARD == MBED_BOARD_LPC1768)
 //cc3100 _cc3100(p9, p10, p8, SPI(p5, p6, p7));//LPC1768  irq, nHib, cs, mosi, miso, sck
 cc3100 _cc3100(p9, p10, p8, SPI(p11, p12, p13));//LPC1768  irq, nHib, cs, mosi, miso, sck
@@ -82,7 +81,7 @@
 /*
  * GLOBAL VARIABLES -- Start
  */
-int32_t demo = 1;
+int32_t demo = 0;
 
 /*
  * GLOBAL VARIABLES -- End
@@ -119,7 +118,7 @@
 
     _cc3100.CLR_STATUS_BIT(g_Status, STATUS_BIT_PING_DONE);
     g_PingPacketsRecv = 0;
-
+    
     /*
      * Following function configures the device to default state by cleaning
      * the persistent settings stored in NVMEM (viz. connection profiles &
@@ -209,11 +208,11 @@
     if (ROLE_AP == role) {
         /* If the device is in AP mode, we need to wait for this event before doing anything */
         while(!_cc3100.IS_IP_ACQUIRED(g_Status,STATUS_BIT_IP_ACQUIRED)) {
-            _cc3100.SlNonOsMainLoopTask();
+            _cc3100._nonos._SlNonOsMainLoopTask();
         }
     } else {
         /* Configure CC3100 to start in AP mode */
-        retVal = _cc3100.WlanSetMode(ROLE_AP);
+        retVal = _cc3100._wlan.sl_WlanSetMode(ROLE_AP);
         if(retVal < 0)
             LOOP_FOREVER();
 
@@ -227,7 +226,7 @@
         if (ROLE_AP == role) {
             /* If the device is in AP mode, we need to wait for this event before doing anything */
             while(!_cc3100.IS_IP_ACQUIRED(g_Status,STATUS_BIT_IP_ACQUIRED)) {
-                _cc3100.SlNonOsMainLoopTask();
+                _cc3100._nonos._SlNonOsMainLoopTask();
             }
         } else {
             printf(" Device couldn't be configured in AP mode \n\r");
@@ -238,36 +237,36 @@
     printf(" Ready to configue SSID\r\n");
 
     /* Configure the SSID of the CC3100 */
-    retVal = _cc3100.WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(SSID_AP_MODE), (uint8_t *)SSID_AP_MODE);
+    retVal = _cc3100._wlan.sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(SSID_AP_MODE), (uint8_t *)SSID_AP_MODE);
     if(retVal < 0)
         LOOP_FOREVER();
 
     SecType = SEC_TYPE_AP_MODE;
     /* Configure the Security parameter the AP mode */
-    retVal = _cc3100.WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, (uint8_t *)&SecType);
+    retVal = _cc3100._wlan.sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, (uint8_t *)&SecType);
     if(retVal < 0)
         LOOP_FOREVER();
 
-    retVal = _cc3100.WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, strlen(PASSWORD_AP_MODE), (uint8_t *)PASSWORD_AP_MODE);
+    retVal = _cc3100._wlan.sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, strlen(PASSWORD_AP_MODE), (uint8_t *)PASSWORD_AP_MODE);
     if(retVal < 0){
         LOOP_FOREVER();
     }
     
-    ipV4.ipV4 = _netcfg->SL_IPV4_VAL(192,168,0,1);//CONFIG_IP;
-    ipV4.ipV4Mask = _netcfg->SL_IPV4_VAL(255,255,255,0);//CONFIG_MASK;
-    ipV4.ipV4Gateway = _netcfg->SL_IPV4_VAL(192,168,0,1);//CONFIG_GATEWAY;
-    ipV4.ipV4DnsServer = _netcfg->SL_IPV4_VAL(192,168,0,1);//CONFIG_DNS;
+    ipV4.ipV4 = _cc3100._netcfg.SL_IPV4_VAL(192,168,0,1);//CONFIG_IP;
+    ipV4.ipV4Mask = _cc3100._netcfg.SL_IPV4_VAL(255,255,255,0);//CONFIG_MASK;
+    ipV4.ipV4Gateway = _cc3100._netcfg.SL_IPV4_VAL(192,168,0,1);//CONFIG_GATEWAY;
+    ipV4.ipV4DnsServer = _cc3100._netcfg.SL_IPV4_VAL(192,168,0,1);//CONFIG_DNS;
 
     /* Configure the Static IP */
-    retVal = _cc3100.NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE,1,sizeof(SlNetCfgIpV4Args_t), (uint8_t *)&ipV4);
+    retVal = _cc3100._netcfg.sl_NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE,1,sizeof(SlNetCfgIpV4Args_t), (uint8_t *)&ipV4);
     if(retVal < 0)
         LOOP_FOREVER();
 
     dhcpParams.lease_time      =  IP_LEASE_TIME;
-    dhcpParams.ipv4_addr_start =  _netcfg->SL_IPV4_VAL(192,168,0,100);//DHCP_START_IP;
-    dhcpParams.ipv4_addr_last  =  _netcfg->SL_IPV4_VAL(192,168,0,200);//DHCP_END_IP;
+    dhcpParams.ipv4_addr_start =  _cc3100._netcfg.SL_IPV4_VAL(192,168,0,100);//DHCP_START_IP;
+    dhcpParams.ipv4_addr_last  =  _cc3100._netcfg.SL_IPV4_VAL(192,168,0,200);//DHCP_END_IP;
 
-    retVal = _cc3100.NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, sizeof(SlNetAppDhcpServerBasicOpt_t), (uint8_t*)&dhcpParams);
+    retVal = _cc3100._netapp.sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, sizeof(SlNetAppDhcpServerBasicOpt_t), (uint8_t*)&dhcpParams);
     if(retVal < 0)
         LOOP_FOREVER();
 
@@ -283,7 +282,7 @@
     if (ROLE_AP == role) {
         /* If the device is in AP mode, we need to wait for this event before doing anything */
         while(!_cc3100.IS_IP_ACQUIRED(g_Status,STATUS_BIT_IP_ACQUIRED)) {
-            _cc3100.SlNonOsMainLoopTask();
+            _cc3100._nonos._SlNonOsMainLoopTask();
         }
     } else {
         printf(" Device couldn't enter AP mode \n\r");
@@ -294,7 +293,7 @@
     /* Wait */
     printf(" Waiting for clients to connect...!\n\r");
     while((!_cc3100.IS_IP_LEASED(g_Status,STATUS_BIT_IP_LEASED)) || (!_cc3100.IS_STA_CONNECTED(g_Status,STATUS_BIT_STA_CONNECTED))) {
-        _cc3100.SlNonOsMainLoopTask();
+        _cc3100._nonos._SlNonOsMainLoopTask();
     }
     printf(" Client connected to the device \n\r");
     printf(" Pinging...! \n\r");
@@ -308,13 +307,13 @@
     PingParams.Ip = g_StationIP; /* Fill the station IP address connected to CC3100 */
 
     /* Ping client connected to CC3100 */
-    retVal = _cc3100.NetAppPingStart((SlPingStartCommand_t*)&PingParams, SL_AF_INET, (SlPingReport_t*)&Report, &SimpleLinkPingReport);
+    retVal = _cc3100._netapp.sl_NetAppPingStart((SlPingStartCommand_t*)&PingParams, SL_AF_INET, (SlPingReport_t*)&Report, &SimpleLinkPingReport);
     if(retVal < 0)
         LOOP_FOREVER();
 
     /* Wait */
     while(!_cc3100.IS_PING_DONE(g_Status,STATUS_BIT_PING_DONE)) {
-        _cc3100.SlNonOsMainLoopTask();
+        _cc3100._nonos._SlNonOsMainLoopTask();
     }
 
     if (0 == g_PingPacketsRecv) {
--- a/mbed.bld	Sun Feb 15 11:01:37 2015 +0000
+++ b/mbed.bld	Sun Feb 22 18:33:10 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac
\ No newline at end of file
--- a/simplelink/cc3100.cpp	Sun Feb 15 11:01:37 2015 +0000
+++ b/simplelink/cc3100.cpp	Sun Feb 22 18:33:10 2015 +0000
@@ -96,41 +96,6 @@
 
     return SUCCESS;
 }
-
-int32_t cc3100::NetAppPingStart(SlPingStartCommand_t* pPingParams, uint8_t family, SlPingReport_t *pReport, const P_SL_DEV_PING_CALLBACK pPingCallback){
-
-    return (_netapp.sl_NetAppPingStart(pPingParams, family, pReport, pPingCallback));
-
-}
-
-int32_t cc3100::NetAppSet(uint8_t AppId ,uint8_t Option,uint8_t OptionLen, uint8_t *pOptionValue){
-	
-	return (_netapp.sl_NetAppSet(AppId ,Option, OptionLen, (uint8_t *)pOptionValue));
-	
-}	
-
-int16_t cc3100::NetCfgSet(uint8_t ConfigId ,uint8_t ConfigOpt, uint8_t ConfigLen, uint8_t *pValues){
-	
-	return (_netcfg.sl_NetCfgSet(ConfigId ,ConfigOpt, ConfigLen, (uint8_t *)pValues));
-	
-}	
-
-int16_t cc3100::WlanSet(uint16_t ConfigId ,uint16_t ConfigOpt,uint16_t ConfigLen, uint8_t *pValues){
-	
-	return (_wlan.sl_WlanSet(ConfigId, ConfigOpt, ConfigLen, (uint8_t*)pValues));
-	
-}	
-
-void cc3100::SlNonOsMainLoopTask(){
-	
-	_nonos._SlNonOsMainLoopTask();
-	
-}	
-
-int16_t cc3100::WlanSetMode(const uint8_t mode){
-	
-	return ( _wlan.sl_WlanSetMode(mode));
-}
     
 /*!
     \brief Disconnecting from a WLAN Access point
@@ -157,7 +122,7 @@
     if(0 == retVal)
     {
         /* Wait */
-        while(IS_CONNECTED(g_Status,STATUS_BIT_CONNECTION)) { SlNonOsMainLoopTask(); }
+        while(IS_CONNECTED(g_Status,STATUS_BIT_CONNECTION)) { _nonos._SlNonOsMainLoopTask(); }
     }
 
     return SUCCESS;
@@ -244,7 +209,7 @@
     if(0 == retVal) {
         /* Wait */
         while(IS_CONNECTED(g_Status,STATUS_BIT_CONNECTION)) {
-            SlNonOsMainLoopTask();
+            _nonos._SlNonOsMainLoopTask();
         }
     }
     
@@ -306,11 +271,6 @@
     }
 
     return sd;
-}
-
-int32_t cc3100::sock_Close(int16_t sd){
-	
-	return _socket.sl_Close(sd);
 }	
 
 /*!
@@ -798,7 +758,7 @@
     ASSERT_ON_ERROR(retVal);
 
     /* Wait */
-    while(!IS_PING_DONE(g_Status,STATUS_BIT_PING_DONE)) { SlNonOsMainLoopTask(); }
+    while(!IS_PING_DONE(g_Status,STATUS_BIT_PING_DONE)) { _nonos._SlNonOsMainLoopTask(); }
 
     if(0 == g_PingPacketsRecv)
     {
@@ -851,7 +811,7 @@
     ASSERT_ON_ERROR(retVal);
 
     /* Wait */
-    while(!IS_PING_DONE(g_Status,STATUS_BIT_PING_DONE)) { SlNonOsMainLoopTask(); }
+    while(!IS_PING_DONE(g_Status,STATUS_BIT_PING_DONE)) { _nonos._SlNonOsMainLoopTask(); }
 
     if (0 == g_PingPacketsRecv)
     {
@@ -994,15 +954,15 @@
 void cc3100::CLR_STATUS_BIT(uint32_t status_variable, const uint32_t bit){
 	    
 	    g_Status = status_variable;
-	    status_variable &= ~((uint32_t)1L<<(bit));
-	    g_Status = status_variable;
+	    g_Status &= ~((uint32_t)1L<<(bit));
+	    
 }
 
 void cc3100::SET_STATUS_BIT(uint32_t status_variable, const uint32_t bit){
 
 	    g_Status = status_variable;
-	    status_variable |= ((uint32_t)1L<<(bit));
-	    g_Status = status_variable;
+	    g_Status |= ((uint32_t)1L<<(bit));
+	    
 }
 	    
 /*****************************************************************************/
@@ -1028,7 +988,7 @@
     InitComplete_t  AsyncRsp;
 
     /* Perform any preprocessing before enable networking services */
-    sl_DeviceEnablePreamble();
+    sl_DeviceEnablePreamble();//stub only
     
     /* ControlBlock init */
     _driver._SlDrvDriverCBInit();
@@ -1049,6 +1009,7 @@
         printf("SL_POOL_IS_EMPTY\r\n");
         return SL_POOL_IS_EMPTY;
     }
+    
     OSI_RET_OK_CHECK(_nonos.sl_LockObjLock(&g_pCB->ProtectionLockObj,  NON_OS_LOCK_OBJ_UNLOCK_VALUE, NON_OS_LOCK_OBJ_LOCK_VALUE, SL_OS_WAIT_FOREVER));
     g_pCB->ObjPool[ObjIdx].pRespArgs = (uint8_t *)&AsyncRsp;
     OSI_RET_OK_CHECK(_nonos.sl_LockObjUnlock(&g_pCB->ProtectionLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE));
--- a/simplelink/cc3100.h	Sun Feb 15 11:01:37 2015 +0000
+++ b/simplelink/cc3100.h	Sun Feb 22 18:33:10 2015 +0000
@@ -774,22 +774,7 @@
 #endif
 #endif
 
-
-int32_t NetAppPingStart(SlPingStartCommand_t* pPingParams,uint8_t family,SlPingReport_t *pReport,const P_SL_DEV_PING_CALLBACK pPingCallback);
-
-int32_t NetAppSet(uint8_t AppId ,uint8_t Option,uint8_t OptionLen, uint8_t *pOptionValue);
-    
-int16_t NetCfgSet(uint8_t ConfigId ,uint8_t ConfigOpt, uint8_t ConfigLen, uint8_t *pValues);    
-
-int16_t WlanSet(uint16_t ConfigId ,uint16_t ConfigOpt,uint16_t ConfigLen, uint8_t *pValues);
-
-void SlNonOsMainLoopTask(void);
-
-int16_t WlanSetMode(const uint8_t mode);
-
-int32_t sock_Close(int16_t sd);
-
-private:
+public:
     
     cc3100_spi               _spi;
     cc3100_driver            _driver;