Skip to content

Commit 6fc3b8d

Browse files
Mika Leppänenkjbracey
authored andcommitted
Made feature-emac changes to emac greentea tests default code
Removed flagging of the new/old code.
1 parent 1acb513 commit 6fc3b8d

12 files changed

+7
-270
lines changed

TESTS/network/emac/emac_TestMemoryManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
#if MBED_CONF_APP_TEST_EMAC
18+
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
1919

2020
#include <stdio.h>
2121
#include <stdarg.h>

TESTS/network/emac/emac_TestMemoryManager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18-
#if MBED_CONF_APP_TEST_EMAC
18+
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
19+
1920
#ifndef EMAC_TEST_MEMORY_MANAGER_H
2021
#define EMAC_TEST_MEMORY_MANAGER_H
2122

TESTS/network/emac/emac_TestNetworkStack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
#if MBED_CONF_APP_TEST_EMAC
18+
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
1919

2020
#include "unity.h"
2121

TESTS/network/emac/emac_TestNetworkStack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
#if MBED_CONF_APP_TEST_EMAC
18+
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
1919

2020
#ifndef EMAC_TEST_NETWORK_STACK_H
2121
#define EMAC_TEST_NETWORK_STACK_H

TESTS/network/emac/emac_ctp.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,10 @@
2323

2424
#include "mbed.h"
2525

26-
#if MBED_CONF_APP_TEST_EMAC
27-
2826
#include "EMAC.h"
2927
#include "EMACMemoryManager.h"
3028
#include "emac_TestMemoryManager.h"
3129

32-
#else
33-
34-
#include "lwip/opt.h" /* ETH_PAD_SIZE */
35-
#include "emac_stack_mem.h"
36-
#include "emac_api.h"
37-
38-
#endif
39-
4030
#include "emac_tests.h"
4131
#include "emac_ctp.h"
4232

@@ -126,7 +116,6 @@ void emac_if_ctp_msg_build(int eth_frame_len, const unsigned char *dest_addr, co
126116
return;
127117
}
128118

129-
#if MBED_CONF_APP_TEST_EMAC
130119
int alloc_opt = 0;
131120
int align = 0;
132121
if (options & CTP_OPT_NON_ALIGNED) {
@@ -141,9 +130,6 @@ void emac_if_ctp_msg_build(int eth_frame_len, const unsigned char *dest_addr, co
141130
// Default allocation is from pool
142131
buf = emac_m_mngr_get()->alloc_pool(eth_frame_len, align, alloc_opt);
143132
}
144-
#else
145-
emac_stack_mem_chain_t *buf = emac_stack_mem_alloc(0, eth_frame_len + ETH_PAD_SIZE, 0);
146-
#endif
147133

148134
if (!buf) {
149135
SET_ERROR_FLAGS(NO_FREE_MEM_BUF);
@@ -161,14 +147,9 @@ void emac_if_ctp_msg_build(int eth_frame_len, const unsigned char *dest_addr, co
161147

162148
emac_if_memory_buffer_write(buf, eth_output_frame_data, true);
163149

164-
#if MBED_CONF_APP_TEST_EMAC
165150
emac_if_check_memory(true);
166151
emac_if_get()->link_out(buf);
167152
emac_if_check_memory(false);
168-
#else
169-
emac_if_get()->ops.link_out(emac_if_get(), buf);
170-
emac_stack_mem_free(0, buf);
171-
#endif
172153
}
173154

174155
#endif

TESTS/network/emac/emac_initialize.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@
2020

2121
unsigned char *emac_if_get_hw_addr(void);
2222
bool emac_if_init(void);
23-
24-
#if MBED_CONF_APP_TEST_EMAC
2523
EMAC *emac_if_get(void);
2624
EmacTestMemoryManager *emac_m_mngr_get(void);
27-
#else
28-
emac_interface_t *emac_if_get(void);
29-
#endif
3025

3126
#endif /* EMAC_INITIALIZE_H */

TESTS/network/emac/emac_membuf.cpp

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,14 @@
2626

2727
#include "mbed.h"
2828

29-
#if MBED_CONF_APP_TEST_EMAC
30-
3129
#include "EMAC.h"
3230
#include "EMACMemoryManager.h"
3331
#include "emac_TestMemoryManager.h"
3432

35-
#else
36-
37-
#include "emac_api.h"
38-
#include "emac_stack_mem.h"
39-
40-
#endif
41-
4233
#include "emac_initialize.h"
4334
#include "emac_membuf.h"
4435
#include "emac_util.h"
4536

46-
#if MBED_CONF_APP_TEST_EMAC
47-
4837
int emac_if_memory_buffer_read(void *buf, unsigned char *eth_frame)
4938
{
5039
int eth_frame_index = 0;
@@ -91,58 +80,4 @@ void emac_if_memory_buffer_write(void *buf, unsigned char *eth_frame, bool write
9180
}
9281
}
9382

94-
#else
95-
96-
int emac_if_memory_buffer_read(void *buf, unsigned char *eth_frame)
97-
{
98-
int eth_frame_index = 0;
99-
int invalid_data_index = 0;
100-
int index = ETH_PAD_SIZE;
101-
102-
for (emac_stack_mem_t *mem_p = emac_stack_mem_chain_dequeue(0, &buf); mem_p != NULL; mem_p = emac_stack_mem_chain_dequeue(0, &buf)) {
103-
unsigned char *buf_payload = (unsigned char *) emac_stack_mem_ptr(0, mem_p);
104-
int buf_payload_len = emac_stack_mem_len(0, mem_p);
105-
106-
for (; index < buf_payload_len; index++) {
107-
if (eth_frame_index < ETH_FRAME_HEADER_LEN) {
108-
eth_frame[eth_frame_index] = buf_payload[index];
109-
} else {
110-
if (buf_payload[index] != (uint8_t) eth_frame_index) {
111-
invalid_data_index = eth_frame_index;
112-
break;
113-
}
114-
}
115-
eth_frame_index++;
116-
}
117-
index = 0;
118-
}
119-
120-
return invalid_data_index;
121-
}
122-
123-
void emac_if_memory_buffer_write(void *buf, unsigned char *eth_frame, bool write_data)
124-
{
125-
int eth_frame_index = 0;
126-
int index = ETH_PAD_SIZE;
127-
128-
for (emac_stack_mem_t *mem_p = emac_stack_mem_chain_dequeue(0, &buf); mem_p != NULL; mem_p = emac_stack_mem_chain_dequeue(0, &buf)) {
129-
unsigned char *buf_payload = (unsigned char *) emac_stack_mem_ptr(0, mem_p);
130-
int buf_payload_len = emac_stack_mem_len(0, mem_p);
131-
132-
for (; index < buf_payload_len; index++) {
133-
if (eth_frame_index < ETH_FRAME_HEADER_LEN) {
134-
buf_payload[index] = eth_frame[eth_frame_index];
135-
} else if (write_data) {
136-
buf_payload[index] = (char) eth_frame_index;
137-
} else {
138-
break;
139-
}
140-
eth_frame_index++;
141-
}
142-
index = 0;
143-
}
144-
}
145-
146-
#endif
147-
14883
#endif

TESTS/network/emac/emac_test_initialize.cpp

Lines changed: 1 addition & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,20 @@
2424

2525
#if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET
2626

27-
#if MBED_CONF_APP_TEST_EMAC
28-
2927
#include "EthernetInterface.h"
3028
#include "EMAC.h"
3129
#include "EMACMemoryManager.h"
3230
#include "emac_TestMemoryManager.h"
3331
#include "emac_TestNetworkStack.h"
3432

35-
#else
36-
37-
#include "inttypes.h"
38-
3933
#if MBED_CONF_APP_TEST_WIFI
34+
4035
#ifdef TARGET_UBLOX_EVK_ODIN_W2
41-
#include "wifi_emac_api.h"
4236
#include "OdinWiFiInterface.h"
4337
#endif
4438
#ifdef TARGET_REALTEK_RTL8195AM
45-
#include "rtw_emac.h"
4639
#include "RTWInterface.h"
4740
#endif
48-
#endif
49-
50-
#include "emac_api.h"
5141

5242
#endif
5343

@@ -59,17 +49,10 @@ using namespace utest::v1;
5949

6050
static unsigned char eth_mac_addr[ETH_MAC_ADDR_LEN];
6151

62-
#if !MBED_CONF_APP_TEST_EMAC
63-
static char emac_if_link_state_change_cb_data[] = "link_state_change_cb_data";
64-
static char emac_if_link_input_cb_data[] = "link_input_cb_data";
65-
#endif
66-
6752
void test_emac_initialize()
6853
{
6954
worker_loop_init();
7055

71-
#if MBED_CONF_APP_TEST_EMAC
72-
7356
#if MBED_CONF_APP_TEST_ETHERNET
7457

7558
static EthernetInterface *network_interface = new EthernetInterface;
@@ -112,54 +95,13 @@ void test_emac_initialize()
11295
network_interface->connect();
11396

11497
worker_loop_link_up_wait();
115-
#else
116-
117-
#if MBED_CONF_APP_TEST_WIFI
118-
static WiFiInterface *wifi;
119-
120-
#ifdef TARGET_UBLOX_EVK_ODIN_W2
121-
wifi = new OdinWiFiInterface;
122-
#endif
123-
#ifdef TARGET_REALTEK_RTL8195AM
124-
wifi = new RTWInterface;
125-
#endif
126-
127-
#if MBED_CONF_APP_WIFI_SCAN
128-
WiFiAccessPoint ap[30];
129-
130-
int size = wifi->scan(ap, 30);
131-
132-
for (int i=0; i<size; i++) {
133-
const char *ssid = ap[i].get_ssid();
134-
nsapi_security_t security = ap[i].get_security();
135-
int8_t rssi = ap[i].get_rssi();
136-
char ch = ap[i].get_channel();
137-
138-
printf("BS %i\r\n", i);
139-
printf("ssid %s\r\n", ssid);
140-
printf("security %i\r\n", security);
141-
printf("rssi %i\r\n", rssi);
142-
printf("ch %i\r\n\r\n", ch);
143-
}
144-
#endif
145-
146-
wifi->set_credentials(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, MBED_CONF_APP_WIFI_SECURITY);
147-
wifi->connect();
148-
149-
const char *ip_addr = wifi->get_ip_address();
150-
printf("connected IP %s\r\n\r\n", ip_addr);
151-
152-
TEST_ASSERT(emac_if_init());
153-
#endif
154-
#endif
15598
}
15699

157100
unsigned char *emac_if_get_hw_addr(void)
158101
{
159102
return &eth_mac_addr[0];
160103
}
161104

162-
#if MBED_CONF_APP_TEST_EMAC
163105
EMAC *emac_if_get(void)
164106
{
165107
return &EMAC::get_default_instance();
@@ -170,26 +112,8 @@ EmacTestMemoryManager *emac_m_mngr_get(void)
170112
return &EmacTestMemoryManager::get_instance();
171113
}
172114

173-
#else
174-
175-
emac_interface_t *emac_if_get(void)
176-
{
177-
#if MBED_CONF_APP_TEST_WIFI
178-
#ifdef TARGET_UBLOX_EVK_ODIN_W2
179-
return wifi_emac_get_interface();
180-
#endif
181-
#ifdef TARGET_REALTEK_RTL8195AM
182-
return wlan_emac_init_interface();
183-
#endif
184-
#else
185-
return 0;
186-
#endif
187-
}
188-
#endif
189-
190115
bool emac_if_init(void)
191116
{
192-
#if MBED_CONF_APP_TEST_EMAC
193117
static EMAC *emac = &EMAC::get_default_instance();
194118
static EmacTestMemoryManager *memory_manager = &EmacTestMemoryManager::get_instance();
195119
emac->set_memory_manager(*memory_manager);
@@ -221,34 +145,6 @@ bool emac_if_init(void)
221145
printf("emac if name %s\r\n\r\n", hw_name);
222146

223147
return true;
224-
#else
225-
emac_interface_t *emac_if = emac_if_get();
226-
227-
emac_if->ops.set_link_input_cb(emac_if, emac_if_link_input_cb, emac_if_link_input_cb_data);
228-
emac_if->ops.set_link_state_cb(emac_if, emac_if_link_state_change_cb, emac_if_link_state_change_cb_data);
229-
230-
int hwaddr_len = emac_if->ops.get_hwaddr_size(emac_if);
231-
printf("emac hwaddr length %i\r\n\r\n", hwaddr_len);
232-
233-
if (hwaddr_len == 6) {
234-
emac_if->ops.get_hwaddr(emac_if, eth_mac_addr);
235-
printf("emac hwaddr %x:%x:%x:%x:%x:%x\r\n\r\n", eth_mac_addr[0],eth_mac_addr[1],eth_mac_addr[2],eth_mac_addr[3],eth_mac_addr[4],eth_mac_addr[5]);
236-
}
237-
238-
int mtu_size = emac_if->ops.get_mtu_size(emac_if);
239-
printf("emac mtu %i\r\n\r\n", mtu_size);
240-
emac_if_set_mtu_size(mtu_size);
241-
242-
char hw_name[11];
243-
emac_if->ops.get_ifname(emac_if, hw_name, 10);
244-
printf("emac if name %s\r\n\r\n", hw_name);
245-
246-
if (!emac_if->ops.power_up(emac_if)) {
247-
return false;
248-
}
249-
250-
return true;
251-
#endif
252148
}
253149

254150
#endif

0 commit comments

Comments
 (0)