Added mutex for multiple SPI devices on the same SPI bus
Fork of cc3000_hostdriver_mbedsocket by
Diff: Socket/Endpoint.cpp
- Revision:
- 5:245ac5b73132
- Parent:
- 4:15b58c119a0a
- Child:
- 8:4c42ca37ba33
diff -r 15b58c119a0a -r 245ac5b73132 Socket/Endpoint.cpp --- a/Socket/Endpoint.cpp Sat Sep 21 15:01:05 2013 +0000 +++ b/Socket/Endpoint.cpp Thu Sep 26 19:50:37 2013 +0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 mbed.org, MIT License +/* Copyright (C) 2013 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, @@ -72,13 +72,12 @@ void Endpoint::reset_address(void) { _ipAddress[0] = '\0'; - std::memset(&_remote_host,0, sizeof(sockaddr_in)); + std::memset(&_remote_host, 0, sizeof(sockaddr_in)); } int Endpoint::set_address(const char* host, const int port) { reset_address(); - // IP Address char address[5]; char *p_address = address; @@ -89,6 +88,7 @@ for (int i=0;i<4;i++) { address[i] = add[i]; } + std::memset(_ipAddress,0,sizeof(_ipAddress)); if (result != 4) { //Resolve DNS address or populate hard-coded IP address @@ -97,36 +97,22 @@ _remote_host.sin_addr.s_addr = address_integer; inet_ntoa_r(_remote_host.sin_addr, _ipAddress, sizeof(_ipAddress)); - // address[0] = (address_integer >> 24); - // address[1] = (address_integer >> 16); - // address[2] = (address_integer >> 8); - // address[3] = (address_integer >> 0); - // sprintf(_ipAddress,"%3u.%3u.%3u.%3u", address[0],address[1],address[2],address[3]); - // p_address = _ipAddress; - // _remote_host.sin_addr.s_addr = address_integer; } else { std::memcpy((char*)&_remote_host.sin_addr.s_addr, p_address, 4); } + _remote_host.sin_family = AF_INET; + _remote_host.sin_port = htons(port); + #if (CC3000_DEBUG == 1) printf("DEBUG: remote host address (string): %s\n",_ipAddress); printf("DEBUG: remote host address from s_addr : %d.%d.%d.%d\n", int(_remote_host.sin_addr.s_addr & 0xFF), - int((_remote_host.sin_addr.s_addr & 0xFF00)>>8), - int((_remote_host.sin_addr.s_addr & 0xFF0000)>>16), - int((_remote_host.sin_addr.s_addr & 0xFF000000)>>24)); - // address[0] = (_remote_host.sin_addr.s_addr >> 24); - // address[1] = (_remote_host.sin_addr.s_addr >> 16); - // address[2] = (_remote_host.sin_addr.s_addr >> 8); - // address[3] = (_remote_host.sin_addr.s_addr >> 0); - // printf("DEBUG: remote host address from s_addr: %3u.%3u.%3u.%3u\n",address[0],address[1],address[2],address[3]); + int((_remote_host.sin_addr.s_addr & 0xFF00) >> 8), + int((_remote_host.sin_addr.s_addr & 0xFF0000) >> 16), + int((_remote_host.sin_addr.s_addr & 0xFF000000) >> 24)); + printf("DEBUG: port: %x \n", _remote_host.sin_port); #endif - /* store address*/ - _remote_host.sin_family = AF_INET; - - // Set port - _remote_host.sin_port = htons(port); - return 0; }