Skip to content

Commit 0eca8d3

Browse files
authored
Merge pull request #12715 from RyoheiHagimoto/rza1-eth-deprecation
RZ_A1H remove usage of ethernet hal API
2 parents 7a0a168 + 7794221 commit 0eca8d3

File tree

4 files changed

+101
-68
lines changed

4 files changed

+101
-68
lines changed

features/netsocket/emac-drivers/TARGET_RZ_A1_EMAC/rza1_emac.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include "rtos/ThisThread.h"
1818
#include "netsocket/nsapi_types.h"
1919
#include "mbed_shared_queues.h"
20-
#include "ethernet_api.h"
21-
#include "ethernetext_api.h"
20+
#include "rza1_eth.h"
21+
#include "rza1_eth_ext.h"
2222
#include "rza1_emac.h"
2323

2424
#define RZ_A1_ETH_IF_NAME "en"
@@ -70,7 +70,7 @@ void RZ_A1_EMAC::set_hwaddr(const uint8_t *addr)
7070

7171
/* Reconnect */
7272
if (power_on != false) {
73-
ethernet_cfg_t ethcfg;
73+
rza1_ethernet_cfg_t ethcfg;
7474
ethcfg.int_priority = 6;
7575
ethcfg.recv_cb = &_recv_callback;
7676
ethcfg.ether_mac = NULL;
@@ -89,7 +89,7 @@ bool RZ_A1_EMAC::link_out(emac_mem_buf_t *buf)
8989

9090
while ((copy_buf != NULL) && (memory_manager->get_ptr(copy_buf) != NULL) && (memory_manager->get_len(copy_buf) != 0)) {
9191
for (retry_cnt = 0; retry_cnt < 100; retry_cnt++) {
92-
write_size = ethernet_write((char *)memory_manager->get_ptr(copy_buf), memory_manager->get_len(copy_buf));
92+
write_size = rza1_ethernet_write((char *)memory_manager->get_ptr(copy_buf), memory_manager->get_len(copy_buf));
9393
if (write_size != 0) {
9494
total_write_size += write_size;
9595
break;
@@ -101,7 +101,7 @@ bool RZ_A1_EMAC::link_out(emac_mem_buf_t *buf)
101101
memory_manager->free(buf);
102102

103103
if (total_write_size > 0) {
104-
if (ethernet_send() == 1) {
104+
if (rza1_ethernet_send() == 1) {
105105
result = true;
106106
}
107107
}
@@ -115,7 +115,7 @@ bool RZ_A1_EMAC::power_up()
115115
return true;
116116
}
117117

118-
ethernet_cfg_t ethcfg;
118+
rza1_ethernet_cfg_t ethcfg;
119119
ethcfg.int_priority = 6;
120120
ethcfg.recv_cb = &_recv_callback;
121121
ethcfg.ether_mac = NULL;
@@ -184,13 +184,13 @@ void RZ_A1_EMAC::recv_task(void) {
184184
while (1) {
185185
rtos::ThisThread::flags_wait_all(1);
186186
for (cnt = 0; cnt < 16; cnt++) {
187-
recv_size = ethernet_receive();
187+
recv_size = rza1_ethernet_receive();
188188
if (recv_size == 0) {
189189
break;
190190
}
191191
buf = memory_manager->alloc_heap(recv_size, 0);
192192
if (buf != NULL) {
193-
(void)ethernet_read((char *)memory_manager->get_ptr(buf), memory_manager->get_len(buf));
193+
(void)rza1_ethernet_read((char *)memory_manager->get_ptr(buf), memory_manager->get_len(buf));
194194
emac_link_input_cb(buf);
195195
}
196196
}
@@ -199,7 +199,7 @@ void RZ_A1_EMAC::recv_task(void) {
199199

200200
void RZ_A1_EMAC::phy_task(void)
201201
{
202-
if (ethernet_link() == 1) {
202+
if (rza1_ethernet_link() == 1) {
203203
int link_mode = ethernetext_chk_link_mode();
204204
if (link_mode != link_mode_last) {
205205
if (connect_sts != false) {

targets/TARGET_RENESAS/TARGET_RZ_A1XX/ethernet_api.c renamed to features/netsocket/emac-drivers/TARGET_RZ_A1_EMAC/rza1_eth.c

Lines changed: 23 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2006-2013 ARM Limited
1+
/* Copyright (c) 2020 Renesas Electronics Corporation.
2+
* SPDX-License-Identifier: Apache-2.0
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,13 +14,13 @@
1414
* limitations under the License.
1515
*/
1616
#include <string.h>
17-
#include "ethernet_api.h"
17+
#include "rza1_eth.h"
1818
#include "cmsis.h"
1919
#include "mbed_interface.h"
2020
#include "mbed_toolchain.h"
2121
#include "mbed_error.h"
2222
#include "iodefine.h"
23-
#include "ethernetext_api.h"
23+
#include "rza1_eth_ext.h"
2424

2525
#if DEVICE_ETHERNET
2626

@@ -89,8 +89,8 @@
8989
/* 0x00000001 : Receive frame CRC error */
9090
#define EDMAC_EESIPR_INI_EtherC (0x00400000) /* 0x00400000 : E-MAC status register */
9191

92-
void ethernet_address(char *);
93-
void ethernet_set_link(int, int);
92+
void rza1_ethernet_address(char *);
93+
void rza1_ethernet_set_link(int, int);
9494

9595

9696
/* Send descriptor */
@@ -114,13 +114,13 @@ typedef struct tag_edmac_recv_desc {
114114
/* Transmit/receive buffers (must be allocated in 16-byte boundaries) */
115115
#if defined(__ICCARM__)
116116
#pragma data_alignment=16
117-
static uint8_t ethernet_nc_memory[(sizeof(edmac_send_desc_t) * NUM_OF_TX_DESCRIPTOR) +
117+
static uint8_t rza1_ethernet_nc_memory[(sizeof(edmac_send_desc_t) * NUM_OF_TX_DESCRIPTOR) +
118118
(sizeof(edmac_recv_desc_t) * NUM_OF_RX_DESCRIPTOR) +
119119
(NUM_OF_TX_DESCRIPTOR * SIZE_OF_BUFFER) +
120120
(NUM_OF_RX_DESCRIPTOR * SIZE_OF_BUFFER)] //16 bytes aligned!
121121
@ ".mirrorram";
122122
#else
123-
static uint8_t ethernet_nc_memory[(sizeof(edmac_send_desc_t) * NUM_OF_TX_DESCRIPTOR) +
123+
static uint8_t rza1_ethernet_nc_memory[(sizeof(edmac_send_desc_t) * NUM_OF_TX_DESCRIPTOR) +
124124
(sizeof(edmac_recv_desc_t) * NUM_OF_RX_DESCRIPTOR) +
125125
(NUM_OF_TX_DESCRIPTOR * SIZE_OF_BUFFER) +
126126
(NUM_OF_RX_DESCRIPTOR * SIZE_OF_BUFFER)]
@@ -162,7 +162,7 @@ static void set_ether_pir(uint32_t set_data);
162162
static void wait_100us(int32_t wait_cnt);
163163

164164

165-
int ethernetext_init(ethernet_cfg_t *p_ethcfg) {
165+
int ethernetext_init(rza1_ethernet_cfg_t *p_ethcfg) {
166166
int32_t i;
167167
uint16_t val;
168168

@@ -210,38 +210,6 @@ int ethernetext_init(ethernet_cfg_t *p_ethcfg) {
210210
wait_100us(250); /* 25msec */
211211
GPIOP4 |= 0x0004; /* P4_2 Outputs high level */
212212
wait_100us(100); /* 10msec */
213-
#elif defined(TARGET_VK_RZ_A1H)
214-
/* -->4F<-- P1_14(ET_COL) */
215-
GPIOPMC1 |= 0x4000;
216-
GPIOPFCAE1 &= ~0x4000;
217-
GPIOPFCE1 |= 0x4000;
218-
GPIOPFC1 |= 0x4000;
219-
GPIOPIPC1 |= 0x4000;
220-
221-
/* -->2F<-- P2_0(ET_TXCLK), P2_1(ET_TXER), P2_2(ET_TXEN), P2_3(ET_CRS), P2_4(ET_TXD0),
222-
P2_5(ET_TXD1), P2_6(ET_TXD2), P2_7(ET_TXD3), P2_8(ET_RXD0), P2_9(ET_RXD1), P2_10(ET_RXD2) P2_11(ET_RXD3) */
223-
GPIOPMC2 |= 0x0FFF;
224-
GPIOPFCAE2 &= ~0x0FFF;
225-
GPIOPFCE2 &= ~0x0FFF;
226-
GPIOPFC2 |= 0x0FFF;
227-
GPIOPIPC2 |= 0x0FFF;
228-
229-
/* -->3F<-- P3_3(ET_MDIO), P3_4(ET_RXCLK), P3_5(ET_RXER), P3_6(ET_RXDV) */
230-
GPIOPMC3 |= 0x0078;
231-
GPIOPFCAE3 &= ~0x0078;
232-
GPIOPFCE3 &= ~0x0078;
233-
GPIOPFC3 |= 0x0078;
234-
GPIOPIPC3 |= 0x0078;
235-
236-
/* -->3F<-- P7_0(ET_MDC) */
237-
GPIOPMC7 |= 0x0001;
238-
GPIOPFCAE7 &= ~0x0001;
239-
GPIOPFCE7 |= 0x0001;
240-
GPIOPFC7 &= ~0x0001;
241-
GPIOPIPC7 |= 0x0001;
242-
243-
/* Resets the E-MAC,E-DMAC */
244-
lan_reg_reset();
245213
#else
246214
#error "There is no initialization processing."
247215
#endif
@@ -265,7 +233,7 @@ int ethernetext_init(ethernet_cfg_t *p_ethcfg) {
265233
if (p_ethcfg->ether_mac != NULL) {
266234
(void)memcpy(mac_addr, p_ethcfg->ether_mac, sizeof(mac_addr));
267235
} else {
268-
ethernet_address(mac_addr); /* Get MAC Address */
236+
rza1_ethernet_address(mac_addr); /* Get MAC Address */
269237
}
270238

271239
return 0;
@@ -390,24 +358,24 @@ void ethernetext_set_all_multicast(int all) {
390358
}
391359

392360

393-
int ethernet_init() {
394-
ethernet_cfg_t ethcfg;
361+
int rza1_ethernet_init() {
362+
rza1_ethernet_cfg_t ethcfg;
395363

396364
ethcfg.int_priority = 5;
397365
ethcfg.recv_cb = NULL;
398366
ethcfg.ether_mac = NULL;
399367
ethernetext_init(&ethcfg);
400-
ethernet_set_link(-1, 0); /* Auto-Negotiation */
368+
rza1_ethernet_set_link(-1, 0); /* Auto-Negotiation */
401369

402370
return 0;
403371
}
404372

405-
void ethernet_free() {
373+
void rza1_ethernet_free() {
406374
ETHERARSTR |= 0x00000001; /* ETHER software reset */
407375
CPGSTBCR7 |= CPG_STBCR7_BIT_MSTP74; /* disable ETHER clock */
408376
}
409377

410-
int ethernet_write(const char *data, int slen) {
378+
int rza1_ethernet_write(const char *data, int slen) {
411379
edmac_send_desc_t *p_send_desc;
412380
int32_t copy_size;
413381

@@ -431,7 +399,7 @@ int ethernet_write(const char *data, int slen) {
431399
return copy_size;
432400
}
433401

434-
int ethernet_send() {
402+
int rza1_ethernet_send() {
435403
edmac_send_desc_t *p_send_desc;
436404
int32_t ret;
437405

@@ -463,7 +431,7 @@ int ethernet_send() {
463431
return ret;
464432
}
465433

466-
int ethernet_receive() {
434+
int rza1_ethernet_receive() {
467435
edmac_recv_desc_t *p_recv_desc;
468436
int32_t receive_size = 0;
469437

@@ -507,7 +475,7 @@ int ethernet_receive() {
507475
return receive_size;
508476
}
509477

510-
int ethernet_read(char *data, int dlen) {
478+
int rza1_ethernet_read(char *data, int dlen) {
511479
edmac_recv_desc_t *p_recv_desc = p_recv_end_desc; /* Read top descriptor */
512480
int32_t copy_size;
513481

@@ -525,13 +493,13 @@ int ethernet_read(char *data, int dlen) {
525493
return copy_size;
526494
}
527495

528-
void ethernet_address(char *mac) {
496+
void rza1_ethernet_address(char *mac) {
529497
if (mac != NULL) {
530498
mbed_mac_address(mac); /* Get MAC Address */
531499
}
532500
}
533501

534-
int ethernet_link(void) {
502+
int rza1_ethernet_link(void) {
535503
int32_t ret;
536504
uint16_t data;
537505

@@ -545,7 +513,7 @@ int ethernet_link(void) {
545513
return ret;
546514
}
547515

548-
void ethernet_set_link(int speed, int duplex) {
516+
void rza1_ethernet_set_link(int speed, int duplex) {
549517
uint16_t data;
550518
int32_t i;
551519
int32_t link;
@@ -612,8 +580,8 @@ static void lan_desc_create(void) {
612580
int32_t i;
613581
uint8_t *p_memory_top;
614582

615-
(void)memset((void *)ethernet_nc_memory, 0, sizeof(ethernet_nc_memory));
616-
p_memory_top = ethernet_nc_memory;
583+
(void)memset((void *)rza1_ethernet_nc_memory, 0, sizeof(rza1_ethernet_nc_memory));
584+
p_memory_top = rza1_ethernet_nc_memory;
617585

618586
/* Descriptor area configuration */
619587
p_eth_desc_dsend = (edmac_send_desc_t *)p_memory_top;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* Copyright (c) 2020 Renesas Electronics Corporation.
2+
* SPDX-License-Identifier: Apache-2.0
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+
#ifndef MBED_ETHERNET_API_H
17+
#define MBED_ETHERNET_API_H
18+
19+
#include "device.h"
20+
#include "platform/mbed_toolchain.h"
21+
22+
#if DEVICE_ETHERNET
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
// Connection constants
29+
int rza1_ethernet_init(void);
30+
void rza1_ethernet_free(void);
31+
32+
// write size bytes from data to ethernet buffer
33+
// return num bytes written
34+
// or -1 if size is too big
35+
int rza1_ethernet_write(const char *data, int size);
36+
37+
// send ethernet write buffer, returning the packet size sent
38+
int rza1_ethernet_send(void);
39+
40+
// receive from ethernet buffer, returning packet size, or 0 if no packet
41+
int rza1_ethernet_receive(void);
42+
43+
// read size bytes in to data, return actual num bytes read (0..size)
44+
// if data == NULL, throw the bytes away
45+
int rza1_ethernet_read(char *data, int size);
46+
47+
// get the ethernet address
48+
void rza1_ethernet_address(char *mac);
49+
50+
// see if the link is up
51+
int rza1_ethernet_link(void);
52+
53+
// force link settings
54+
void rza1_ethernet_set_link(int speed, int duplex);
55+
56+
#ifdef __cplusplus
57+
}
58+
#endif
59+
60+
#endif
61+
62+
#endif
63+
64+
65+
/** @}*/

targets/TARGET_RENESAS/TARGET_RZ_A1XX/ethernetext_api.h renamed to features/netsocket/emac-drivers/TARGET_RZ_A1_EMAC/rza1_eth_ext.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2014 Renesas Electronics Corporation.
1+
/* Copyright (c) 2020 Renesas Electronics Corporation.
22
* SPDX-License-Identifier: Apache-2.0
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,13 +29,13 @@ extern "C" {
2929

3030
typedef void (ethernetext_cb_fnc)(void);
3131

32-
typedef struct tag_ethernet_cfg {
32+
typedef struct tag_rza1_ethernet_cfg {
3333
int int_priority;
3434
ethernetext_cb_fnc *recv_cb;
3535
char *ether_mac;
36-
} ethernet_cfg_t;
36+
} rza1_ethernet_cfg_t;
3737

38-
extern int ethernetext_init(ethernet_cfg_t *p_ethcfg);
38+
extern int ethernetext_init(rza1_ethernet_cfg_t *p_ethcfg);
3939
extern void ethernetext_start_stop(int32_t mode);
4040
extern int ethernetext_chk_link_mode(void);
4141
extern void ethernetext_set_link_mode(int32_t link);

0 commit comments

Comments
 (0)