update net class to follow API naming convention

This commit is contained in:
Peter Lawrence
2020-03-03 10:31:46 -06:00
parent fee79d7466
commit 4a4682a80a
5 changed files with 30 additions and 30 deletions

View File

@@ -48,12 +48,12 @@ The MCU appears to the host as IP address 192.168.7.1, and provides a DHCP serve
/* lwip context */ /* lwip context */
static struct netif netif_data; static struct netif netif_data;
/* shared between network_recv_callback() and service_traffic() */ /* shared between tud_network_recv_cb() and service_traffic() */
static struct pbuf *received_frame; static struct pbuf *received_frame;
/* this is used by this code, ./class/net/net_driver.c, and usb_descriptors.c */ /* this is used by this code, ./class/net/net_driver.c, and usb_descriptors.c */
/* ideally speaking, this should be generated from the hardware's unique ID (if available) */ /* ideally speaking, this should be generated from the hardware's unique ID (if available) */
const uint8_t network_mac_address[6] = {0x20,0x89,0x84,0x6A,0x96,0x00}; const uint8_t tud_network_mac_address[6] = {0x20,0x89,0x84,0x6A,0x96,0x00};
/* network parameters of this MCU */ /* network parameters of this MCU */
static const ip_addr_t ipaddr = IPADDR4_INIT_BYTES(192, 168, 7, 1); static const ip_addr_t ipaddr = IPADDR4_INIT_BYTES(192, 168, 7, 1);
@@ -90,9 +90,9 @@ static err_t linkoutput_fn(struct netif *netif, struct pbuf *p)
return ERR_USE; return ERR_USE;
/* if the network driver can accept another packet, we make it happen */ /* if the network driver can accept another packet, we make it happen */
if (network_can_xmit()) if (tud_network_can_xmit())
{ {
network_xmit(p); tud_network_xmit(p);
return ERR_OK; return ERR_OK;
} }
@@ -124,8 +124,8 @@ static void init_lwip(void)
struct netif *netif = &netif_data; struct netif *netif = &netif_data;
lwip_init(); lwip_init();
netif->hwaddr_len = sizeof(network_mac_address); netif->hwaddr_len = sizeof(tud_network_mac_address);
memcpy(netif->hwaddr, network_mac_address, sizeof(network_mac_address)); memcpy(netif->hwaddr, tud_network_mac_address, sizeof(tud_network_mac_address));
netif = netif_add(netif, &ipaddr, &netmask, &gateway, NULL, netif_init_cb, ip_input); netif = netif_add(netif, &ipaddr, &netmask, &gateway, NULL, netif_init_cb, ip_input);
netif_set_default(netif); netif_set_default(netif);
@@ -142,7 +142,7 @@ bool dns_query_proc(const char *name, ip_addr_t *addr)
return false; return false;
} }
bool network_recv_callback(struct pbuf *p) bool tud_network_recv_cb(struct pbuf *p)
{ {
/* this shouldn't happen, but if we get another packet before /* this shouldn't happen, but if we get another packet before
parsing the previous, we must signal our inability to accept it */ parsing the previous, we must signal our inability to accept it */
@@ -155,17 +155,17 @@ bool network_recv_callback(struct pbuf *p)
static void service_traffic(void) static void service_traffic(void)
{ {
/* handle any packet received by network_recv_callback() */ /* handle any packet received by tud_network_recv_cb() */
if (received_frame) if (received_frame)
{ {
ethernet_input(received_frame, &netif_data); ethernet_input(received_frame, &netif_data);
pbuf_free(received_frame); pbuf_free(received_frame);
received_frame = NULL; received_frame = NULL;
network_recv_renew(); tud_network_recv_renew();
} }
} }
void network_init_callback(void) void tud_network_init_cb(void)
{ {
/* if the network is re-initializing and we have a leftover packet, we must do a cleanup */ /* if the network is re-initializing and we have a leftover packet, we must do a cleanup */
if (received_frame) if (received_frame)

View File

@@ -168,10 +168,10 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
{ {
// Convert MAC address into UTF-16 // Convert MAC address into UTF-16
for (unsigned i=0; i<sizeof(network_mac_address); i++) for (unsigned i=0; i<sizeof(tud_network_mac_address); i++)
{ {
_desc_str[1+chr_count++] = "0123456789ABCDEF"[(network_mac_address[i] >> 4) & 0xf]; _desc_str[1+chr_count++] = "0123456789ABCDEF"[(tud_network_mac_address[i] >> 4) & 0xf];
_desc_str[1+chr_count++] = "0123456789ABCDEF"[(network_mac_address[i] >> 0) & 0xf]; _desc_str[1+chr_count++] = "0123456789ABCDEF"[(tud_network_mac_address[i] >> 0) & 0xf];
} }
} }
else else

View File

@@ -36,8 +36,8 @@
#define RNDIS_LINK_SPEED 12000000 /* Link baudrate (12Mbit/s for USB-FS) */ #define RNDIS_LINK_SPEED 12000000 /* Link baudrate (12Mbit/s for USB-FS) */
#define RNDIS_VENDOR "TinyUSB" /* NIC vendor name */ #define RNDIS_VENDOR "TinyUSB" /* NIC vendor name */
static const uint8_t *const station_hwaddr = network_mac_address; static const uint8_t *const station_hwaddr = tud_network_mac_address;
static const uint8_t *const permanent_hwaddr = network_mac_address; static const uint8_t *const permanent_hwaddr = tud_network_mac_address;
static usb_eth_stat_t usb_eth_stat = { 0, 0, 0, 0 }; static usb_eth_stat_t usb_eth_stat = { 0, 0, 0, 0 };
static uint32_t oid_packet_filter = 0x0000000; static uint32_t oid_packet_filter = 0x0000000;

View File

@@ -74,7 +74,7 @@ CFG_TUSB_MEM_SECTION static netd_interface_t _netd_itf;
static bool can_xmit; static bool can_xmit;
void network_recv_renew(void) void tud_network_recv_renew(void)
{ {
usbd_edpt_xfer(TUD_OPT_RHPORT, _netd_itf.ep_out, received, sizeof(received)); usbd_edpt_xfer(TUD_OPT_RHPORT, _netd_itf.ep_out, received, sizeof(received));
} }
@@ -156,13 +156,13 @@ bool netd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t
(*p_length) += 2*sizeof(tusb_desc_endpoint_t); (*p_length) += 2*sizeof(tusb_desc_endpoint_t);
} }
network_init_callback(); tud_network_init_cb();
// we are ready to transmit a packet // we are ready to transmit a packet
can_xmit = true; can_xmit = true;
// prepare for incoming packets // prepare for incoming packets
network_recv_renew(); tud_network_recv_renew();
return true; return true;
} }
@@ -237,7 +237,7 @@ static void handle_incoming_packet(uint32_t len)
if (hdr->bmType) if (hdr->bmType)
{ {
/* EEM Control Packet: discard it */ /* EEM Control Packet: discard it */
network_recv_renew(); tud_network_recv_renew();
} }
else else
{ {
@@ -256,13 +256,13 @@ static void handle_incoming_packet(uint32_t len)
{ {
memcpy(p->payload, pnt, size); memcpy(p->payload, pnt, size);
p->len = size; p->len = size;
accepted = network_recv_callback(p); accepted = tud_network_recv_cb(p);
} }
if (!p || !accepted) if (!p || !accepted)
{ {
/* if a buffer couldn't be allocated or accepted by the callback, we must discard this packet */ /* if a buffer couldn't be allocated or accepted by the callback, we must discard this packet */
network_recv_renew(); tud_network_recv_renew();
} }
} }
} }
@@ -297,12 +297,12 @@ bool netd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
return true; return true;
} }
bool network_can_xmit(void) bool tud_network_can_xmit(void)
{ {
return can_xmit; return can_xmit;
} }
void network_xmit(struct pbuf *p) void tud_network_xmit(struct pbuf *p)
{ {
struct pbuf *q; struct pbuf *q;
uint8_t *data; uint8_t *data;

View File

@@ -49,22 +49,22 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// client must provide this: initialize any network state back to the beginning // client must provide this: initialize any network state back to the beginning
void network_init_callback(void); void tud_network_init_cb(void);
// client must provide this: return false if the packet buffer was not accepted // client must provide this: return false if the packet buffer was not accepted
bool network_recv_callback(struct pbuf *p); bool tud_network_recv_cb(struct pbuf *p);
// client must provide this: 48-bit MAC address // client must provide this: 48-bit MAC address
extern const uint8_t network_mac_address[6]; extern const uint8_t tud_network_mac_address[6];
// indicate to network driver that client has finished with the packet provided to network_recv_callback() // indicate to network driver that client has finished with the packet provided to network_recv_cb()
void network_recv_renew(void); void tud_network_recv_renew(void);
// poll network driver for its ability to accept another packet to transmit // poll network driver for its ability to accept another packet to transmit
bool network_can_xmit(void); bool tud_network_can_xmit(void);
// if network_can_xmit() returns true, network_xmit() can be called once // if network_can_xmit() returns true, network_xmit() can be called once
void network_xmit(struct pbuf *p); void tud_network_xmit(struct pbuf *p);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// INTERNAL USBD-CLASS DRIVER API // INTERNAL USBD-CLASS DRIVER API