Added mutex for multiple SPI devices on the same SPI bus

Fork of cc3000_hostdriver_mbedsocket by Martin Kojtal

Revision:
44:960b73df5981
Parent:
42:bd2c631a031a
Child:
45:50ab13d8f2dc
diff -r 864437b6c058 -r 960b73df5981 cc3000.cpp
--- a/cc3000.cpp	Sat Oct 12 23:28:22 2013 +0000
+++ b/cc3000.cpp	Sun Oct 13 11:46:21 2013 +0200
@@ -69,7 +69,7 @@
 
 }
 
-#ifdef CC3000_ETH_COMPAT
+#if (CC3000_ETH_COMPAT == 1)
 // Ethernet library compatible, functions return strings
 // Caches the ipconfig from the usync callback
 static char mac_addr[19];
@@ -92,10 +92,9 @@
 char* cc3000::getNetworkMask() {
     return networkmask;
 }
-
 #endif
 
-void cc3000::usync_callback(int32_t event_type, uint8_t * data, uint8_t length) {
+void cc3000::usync_callback(int32_t event_type, uint8_t *data, uint8_t length) {
     if (event_type == HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE)
     {
         DBG_CC("Callback : HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE");
@@ -121,16 +120,13 @@
 
     if (event_type == HCI_EVNT_WLAN_UNSOL_DHCP)
     {
-        #ifdef CC3000_ETH_COMPAT
-        
+#if (CC3000_ETH_COMPAT == 1)
         _socket.inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_IP_OFFSET]))), ip_addr, 17);
         _socket.inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_GW_OFFSET]))), gateway, 17);
         _socket.inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_SUBNET_OFFSET]))), networkmask, 17);
         _socket.inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_MAC_OFFSET]))), mac_addr, 19);
-        
-        #endif
-        
-        if ( *(data + NETAPP_IPCONFIG_MAC_OFFSET) == 0) {
+#endif
+        if (*(data + NETAPP_IPCONFIG_MAC_OFFSET) == 0) {
             _status.dhcp = 1;
             DBG_CC("Callback : HCI_EVNT_WLAN_UNSOL_DHCP %i.%i.%i.%i", data[3], data[2], data[1], data[0]);
         } else {
@@ -141,7 +137,7 @@
 
     if (event_type == HCI_EVENT_CC3000_CAN_SHUT_DOWN)
     {
-        // Note this means the moudles is idle, so it could be shutdown..
+        // Note this means the modules is idle, so it could be shutdown..
         //DBG_CC("Callback : HCI_EVENT_CC3000_CAN_SHUT_DOWN");
         _status.ok_to_shut_down = 1;
     }
@@ -163,10 +159,9 @@
 }
 
 void cc3000::start_smart_config(const uint8_t *smart_config_key) {
-
     _status.smart_config_complete = 0;
     _wlan.ioctl_set_connection_policy(0, 0, 0);
-    
+
     if (_status.connected == 1)
     {
         disconnect();
@@ -232,21 +227,21 @@
     return ret;
 }
 
-bool cc3000::connect_non_blocking(const uint8_t *ssid, const uint8_t *key, int32_t security_mode) 
+bool cc3000::connect_non_blocking(const uint8_t *ssid, const uint8_t *key, int32_t security_mode)
 {
 bool ret = false;
 
-    if (key == 0) 
+    if (key == 0)
     {
-        if (connect_open(ssid)) 
+        if (connect_open(ssid))
         {
             ret = true;
         }
     }
-    else 
+    else
     {
     #ifndef CC3000_TINY_DRIVER
-        if (connect_secure(ssid,key,security_mode)) 
+        if (connect_secure(ssid,key,security_mode))
         {
             ret = true;
         }
@@ -254,7 +249,7 @@
         /* secure connection not supported with TINY_DRIVER */
     #endif
     }
-    
+
     return ret;
 }