ecm.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Koen Zandberg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for
6  * more details.
7  */
8 
22 #ifndef USB_USBUS_CDC_ECM_H
23 #define USB_USBUS_CDC_ECM_H
24 
25 #include <stdint.h>
26 #include <stdlib.h>
27 #include "net/ethernet.h"
28 #include "net/ethernet/hdr.h"
29 #include "usb/descriptor.h"
30 #include "usb/usbus.h"
31 #include "usb/usbus/control.h"
32 #include "net/netdev.h"
33 #include "mutex.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
46 #ifndef USBUS_CDC_ECM_CONFIG_SPEED
47 #define USBUS_CDC_ECM_CONFIG_SPEED 1000000
48 #endif
49 
53 #ifndef USBUS_CDC_ECM_CONFIG_SPEED_DOWNSTREAM
54 #define USBUS_CDC_ECM_CONFIG_SPEED_DOWNSTREAM USBUS_CDC_ECM_CONFIG_SPEED
55 #endif
56 
60 #ifndef USBUS_CDC_ECM_CONFIG_SPEED_UPSTREAM
61 #define USBUS_CDC_ECM_CONFIG_SPEED_UPSTREAM USBUS_CDC_ECM_CONFIG_SPEED
62 #endif
63 
71 #define USBUS_CDCECM_EP_CTRL_SIZE 16
72 
78 #define USBUS_CDCECM_EP_DATA_SIZE 64
79 
84 typedef enum {
89 
93 typedef struct usbus_cdcecm_device {
106  char mac_host[13];
110  size_t tx_len;
112  size_t len;
113  usbus_cdcecm_notif_t notif;
114  unsigned active_iface;
116 
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif /* USB_USBUS_CDC_ECM_H */
130 
USBUS endpoint context.
Definition: usbus.h:261
usbus_endpoint_t * ep_out
Data endpoint out.
Definition: ecm.h:99
USBUS context struct.
Definition: usbus.h:385
event_t rx_flush
Receive flush event.
Definition: ecm.h:102
netdev_t netdev
Netdev context struct.
Definition: ecm.h:104
usbus_cdcecm_notif_t notif
Startup message notification tracker.
Definition: ecm.h:113
usbus_t * usbus
Ptr to the USBUS context.
Definition: ecm.h:108
Definitions low-level network driver interface.
USBUS interface.
Definition: usbus.h:290
event structure
Definition: event.h:139
USBUS string type.
Definition: usbus.h:163
Link speed is notified.
Definition: ecm.h:87
Nothing notified so far.
Definition: ecm.h:85
#define ETHERNET_ADDR_LEN
Length of an Ethernet address.
Definition: hdr.h:33
Ethernet header definitions.
Definitions for USB protocol messages.
Definitions for Ethernet.
usbus_endpoint_t * ep_ctrl
Control endpoint.
Definition: ecm.h:100
void usbus_cdcecm_init(usbus_t *usbus, usbus_cdcecm_device_t *handler)
CDC ECM initialization function.
char mac_host[13]
host side&#39;s MAC address as string
Definition: ecm.h:106
usbus_string_t mac_str
String context for the host side mac address.
Definition: ecm.h:107
#define ETHERNET_FRAME_LEN
maximum number of bytes in an ethernet frame (without FCS)
Definition: ethernet.h:42
USBUS descriptor generator.
Definition: usbus.h:251
usbus_handler_t handler_ctrl
Control interface handler.
Definition: ecm.h:94
usbus_descr_gen_t ecm_descr
ECM descriptor generator.
Definition: ecm.h:101
Structure to hold driver state.
Definition: netdev.h:289
uint8_t in_buf[ETHERNET_FRAME_LEN]
Buffer for the received frames.
Definition: ecm.h:111
uint8_t mac_netdev[ETHERNET_ADDR_LEN]
this device&#39;s MAC address
Definition: ecm.h:105
Mutex for thread synchronization.
usbus_cdcecm_notif_t
notification state, used to track which information must be send to the host
Definition: ecm.h:84
mutex_t out_lock
mutex used for locking netif/USBUS send
Definition: ecm.h:109
event_t tx_xmit
Transmit ready event.
Definition: ecm.h:103
USBUS handler struct.
Definition: usbus.h:373
unsigned active_iface
Current active data interface.
Definition: ecm.h:114
usbus_interface_alt_t iface_data_alt
Data alternative (active) interface.
Definition: ecm.h:97
size_t tx_len
Length of the current tx frame.
Definition: ecm.h:110
struct usbus_cdcecm_device usbus_cdcecm_device_t
USBUS CDC ECM device interface context.
USBUS control endpoint module.
Mutex structure.
Definition: mutex.h:36
size_t len
Length of the current rx frame.
Definition: ecm.h:112
stdlib.h wrapper for MSP430
Link status is notified.
Definition: ecm.h:86
USBUS CDC ECM device interface context.
Definition: ecm.h:93
usbus_interface_t iface_ctrl
Control interface.
Definition: ecm.h:96
USBUS basic interface.
USBUS interface alternative setting.
Definition: usbus.h:279
usbus_interface_t iface_data
Data interface.
Definition: ecm.h:95
usbus_endpoint_t * ep_in
Data endpoint in.
Definition: ecm.h:98