Skip to content

Commit badb79e

Browse files
author
Cruz Monrreal
authored
Merge pull request #7272 from KariHaapalehto/emw3166_driver_support
Add binary drivers for MTB_MXCHIP_EMW3166
2 parents c4edf06 + ea2f53b commit badb79e

File tree

8 files changed

+325
-2
lines changed

8 files changed

+325
-2
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Permissive Binary License
2+
3+
Version 1.0, September 2018
4+
5+
Redistribution. Redistribution and use in binary form, without
6+
modification, are permitted provided that the following conditions are
7+
met:
8+
9+
1) Redistributions must reproduce the above copyright notice and the
10+
following disclaimer in the documentation and/or other materials
11+
provided with the distribution.
12+
13+
2) Unless to the extent explicitly permitted by law, no reverse
14+
engineering, decompilation, or disassembly of this software is
15+
permitted.
16+
17+
3) Redistribution as part of a software development kit must include the
18+
accompanying file named �DEPENDENCIES� and any dependencies listed in
19+
that file.
20+
21+
4) Neither the name of the copyright holder nor the names of its
22+
contributors may be used to endorse or promote products derived from
23+
this software without specific prior written permission.
24+
25+
Limited patent license. The copyright holders (and contributors) grant a
26+
worldwide, non-exclusive, no-charge, royalty-free patent license to
27+
make, have made, use, offer to sell, sell, import, and otherwise
28+
transfer this software, where such license applies only to those patent
29+
claims licensable by the copyright holders (and contributors) that are
30+
necessarily infringed by this software. This patent license shall not
31+
apply to any combinations that include this software. No hardware is
32+
licensed hereunder.
33+
34+
If you institute patent litigation against any entity (including a
35+
cross-claim or counterclaim in a lawsuit) alleging that the software
36+
itself infringes your patent(s), then your rights granted under this
37+
license shall terminate as of the date such litigation is filed.
38+
39+
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
40+
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
41+
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
42+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
43+
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
45+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
47+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
48+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
49+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

targets/TARGET_WICED/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This directory tree contains binaries build from Cypress WICED SDK modified for Mbed OS and released under Permissive Binary License.
Binary file not shown.
Binary file not shown.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/* Wiced implementation of NetworkInterfaceAPI
2+
* Copyright (c) 2017 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef WICED_INTERFACE_H
18+
#define WICED_INTERFACE_H
19+
20+
#include "mbed.h"
21+
#include "EthernetInterface.h"
22+
#include "netsocket/OnboardNetworkStack.h"
23+
24+
25+
/** WicedInterface class
26+
* Implementation of the NetworkStack for the Wiced
27+
*/
28+
class WicedInterface : public WiFiInterface, public EMACInterface
29+
{
30+
public:
31+
32+
WicedInterface(
33+
EMAC &emac = EMAC::get_default_instance(),
34+
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance());
35+
36+
/** Start the interface
37+
*
38+
* Attempts to connect to a WiFi network. Requires ssid and passphrase to be set.
39+
* If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned.
40+
*
41+
* @return 0 on success, negative error code on failure
42+
*/
43+
nsapi_error_t connect();
44+
45+
/** Start the interface
46+
*
47+
* Attempts to connect to a WiFi network.
48+
*
49+
* @param ssid Name of the network to connect to
50+
* @param pass Security passphrase to connect to the network
51+
* @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE)
52+
* @param channel This parameter is not supported, setting it to anything else than 0 will result in NSAPI_ERROR_UNSUPPORTED
53+
* @return 0 on success, or error code on failure
54+
*/
55+
nsapi_error_t connect(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0);
56+
57+
/** Stop the interface
58+
* @return 0 on success, negative on failure
59+
*/
60+
nsapi_error_t disconnect();
61+
62+
/** Set the WiFi network credentials
63+
*
64+
* @param ssid Name of the network to connect to
65+
* @param pass Security passphrase to connect to the network
66+
* @param security Type of encryption for connection
67+
* (defaults to NSAPI_SECURITY_NONE)
68+
* @return 0 on success, or error code on failure
69+
*/
70+
nsapi_error_t set_credentials(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE);
71+
72+
/** Set the WiFi network channel - NOT SUPPORTED
73+
*
74+
* This function is not supported and will return NSAPI_ERROR_UNSUPPORTED
75+
*
76+
* @param channel Channel on which the connection is to be made, or 0 for any (Default: 0)
77+
* @return Not supported, returns NSAPI_ERROR_UNSUPPORTED
78+
*/
79+
nsapi_error_t set_channel(uint8_t channel) {
80+
if (channel != 0) {
81+
return NSAPI_ERROR_UNSUPPORTED;
82+
}
83+
84+
return 0;
85+
}
86+
87+
/** Gets the current radio signal strength for active connection
88+
*
89+
* @return Connection strength in dBm (negative value)
90+
*/
91+
int8_t get_rssi();
92+
93+
/** Scan for available networks
94+
*
95+
* This function will block.
96+
*
97+
* @param ap Pointer to allocated array to store discovered AP
98+
* @param count Size of allocated @a res array, or 0 to only count available AP
99+
* @param timeout Timeout in milliseconds; 0 for no timeout (Default: 0)
100+
* @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error
101+
* see @a nsapi_error
102+
*/
103+
int scan(WiFiAccessPoint *res, unsigned count);
104+
105+
private:
106+
107+
char _ssid[33]; /* The longest possible name (defined in 802.11) +1 for the \0 */
108+
char _pass[64]; /* The longest allowed passphrase + 1 */
109+
nsapi_security_t _security;
110+
};
111+
112+
#endif
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/*
2+
* Copyright (c) 2018 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef WICED_EMAC_H_
18+
#define WICED_EMAC_H_
19+
20+
#include "EMAC.h"
21+
#include "EMACInterface.h"
22+
#include "WiFiInterface.h"
23+
24+
#include "rtos/Semaphore.h"
25+
#include "rtos/Mutex.h"
26+
27+
class WICED_EMAC : public EMAC {
28+
public:
29+
WICED_EMAC();
30+
31+
static WICED_EMAC &get_instance();
32+
33+
/**
34+
* Return maximum transmission unit
35+
*
36+
* @return MTU in bytes
37+
*/
38+
virtual uint32_t get_mtu_size() const;
39+
40+
/**
41+
* Gets memory buffer alignment preference
42+
*
43+
* Gets preferred memory buffer alignment of the Emac device. IP stack may or may not
44+
* align link out memory buffer chains using the alignment.
45+
*
46+
* @return Memory alignment requirement in bytes
47+
*/
48+
virtual uint32_t get_align_preference() const;
49+
50+
/**
51+
* Return interface name
52+
*
53+
* @param name Pointer to where the name should be written
54+
* @param size Maximum number of character to copy
55+
*/
56+
virtual void get_ifname(char *name, uint8_t size) const;
57+
58+
/**
59+
* Returns size of the underlying interface HW address size.
60+
*
61+
* @return HW address size in bytes
62+
*/
63+
virtual uint8_t get_hwaddr_size() const;
64+
65+
/**
66+
* Return interface-supplied HW address
67+
*
68+
* Copies HW address to provided memory, @param addr has to be of correct size see @a get_hwaddr_size
69+
*
70+
* HW address need not be provided if this interface does not have its own HW
71+
* address configuration; stack will choose address from central system
72+
* configuration if the function returns false and does not write to addr.
73+
*
74+
* @param addr HW address for underlying interface
75+
* @return true if HW address is available
76+
*/
77+
virtual bool get_hwaddr(uint8_t *addr) const;
78+
79+
/**
80+
* Set HW address for interface
81+
*
82+
* Provided address has to be of correct size, see @a get_hwaddr_size
83+
*
84+
* Called to set the MAC address to actually use - if @a get_hwaddr is provided
85+
* the stack would normally use that, but it could be overridden, eg for test
86+
* purposes.
87+
*
88+
* @param addr Address to be set
89+
*/
90+
virtual void set_hwaddr(const uint8_t *addr);
91+
92+
/**
93+
* Sends the packet over the link
94+
*
95+
* That can not be called from an interrupt context.
96+
*
97+
* @param buf Packet to be send
98+
* @return True if the packet was send successfully, False otherwise
99+
*/
100+
virtual bool link_out(emac_mem_buf_t *buf);
101+
102+
/**
103+
* Initializes the HW
104+
*
105+
* @return True on success, False in case of an error.
106+
*/
107+
virtual bool power_up();
108+
109+
/**
110+
* Deinitializes the HW
111+
*
112+
*/
113+
virtual void power_down();
114+
115+
/**
116+
* Sets a callback that needs to be called for packets received for that interface
117+
*
118+
* @param input_cb Function to be register as a callback
119+
*/
120+
virtual void set_link_input_cb(emac_link_input_cb_t input_cb);
121+
122+
/**
123+
* Sets a callback that needs to be called on link status changes for given interface
124+
*
125+
* @param state_cb Function to be register as a callback
126+
*/
127+
virtual void set_link_state_cb(emac_link_state_change_cb_t state_cb);
128+
129+
/** Add device to a multicast group
130+
*
131+
* @param address A multicast group hardware address
132+
*/
133+
virtual void add_multicast_group(const uint8_t *address);
134+
135+
/** Remove device from a multicast group
136+
*
137+
* @param address A multicast group hardware address
138+
*/
139+
virtual void remove_multicast_group(const uint8_t *address);
140+
141+
/** Request reception of all multicast packets
142+
*
143+
* @param all True to receive all multicasts
144+
* False to receive only multicasts addressed to specified groups
145+
*/
146+
virtual void set_all_multicast(bool all);
147+
148+
/** Sets memory manager that is used to handle memory buffers
149+
*
150+
* @param mem_mngr Pointer to memory manager
151+
*/
152+
virtual void set_memory_manager(EMACMemoryManager &mem_mngr);
153+
154+
emac_link_input_cb_t emac_link_input_cb; /**< Callback for incoming data */
155+
emac_link_state_change_cb_t emac_link_state_cb;
156+
EMACMemoryManager *memory_manager;
157+
158+
};
159+
160+
#endif /* WICED_EMAC_H_ */

targets/targets.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,9 +1156,10 @@
11561156
"MTB_MXCHIP_EMW3166": {
11571157
"inherits": ["FAMILY_STM32"],
11581158
"core": "Cortex-M4F",
1159-
"extra_labels_add": ["STM32F4", "STM32F412xG", "STM32F412ZG"],
1159+
"extra_labels_add": ["STM32F4", "STM32F412xG", "STM32F412ZG", "WICED", "CYW43362"],
11601160
"macros_add": ["USB_STM_HAL", "USBHOST_OTHER"],
1161-
"device_has_add": ["CAN", "SERIAL_ASYNCH", "SERIAL_FC", "TRNG", "FLASH"],
1161+
"device_has_add": ["CAN", "SERIAL_ASYNCH", "SERIAL_FC", "TRNG", "FLASH", "EMAC"],
1162+
"features": ["LWIP"],
11621163
"release_versions": ["2", "5"],
11631164
"device_name": "STM32F412ZG",
11641165
"bootloader_supported": true,

0 commit comments

Comments
 (0)