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 "net/netdev.h"
32 #include "mutex.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
45 #ifndef USBUS_CDC_ECM_CONFIG_SPEED
46 #define USBUS_CDC_ECM_CONFIG_SPEED 1000000
47 #endif
48 
52 #ifndef USBUS_CDC_ECM_CONFIG_SPEED_DOWNSTREAM
53 #define USBUS_CDC_ECM_CONFIG_SPEED_DOWNSTREAM USBUS_CDC_ECM_CONFIG_SPEED
54 #endif
55 
59 #ifndef USBUS_CDC_ECM_CONFIG_SPEED_UPSTREAM
60 #define USBUS_CDC_ECM_CONFIG_SPEED_UPSTREAM USBUS_CDC_ECM_CONFIG_SPEED
61 #endif
62 
70 #define USBUS_CDCECM_EP_CTRL_SIZE 16
71 
77 #define USBUS_CDCECM_EP_DATA_SIZE 64
78 
83 typedef enum {
88 
92 typedef struct usbus_cdcecm_device {
105  char mac_host[13];
109  size_t tx_len;
111  size_t len;
112  usbus_cdcecm_notif_t notif;
113  unsigned active_iface;
115 
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #endif /* USB_USBUS_CDC_ECM_H */
129 
USBUS endpoint context.
Definition: usbus.h:231
usbus_endpoint_t * ep_out
Data endpoint out.
Definition: ecm.h:98
Definitions low-level network driver interface.
USBUS context struct.
Definition: usbus.h:353
event_t rx_flush
Receive flush event.
Definition: ecm.h:101
netdev_t netdev
Netdev context struct.
Definition: ecm.h:103
usbus_cdcecm_notif_t notif
Startup message notification tracker.
Definition: ecm.h:112
usbus_t * usbus
Ptr to the USBUS context.
Definition: ecm.h:107
USBUS interface.
Definition: usbus.h:259
event structure
Definition: event.h:139
USBUS string type.
Definition: usbus.h:156
Link speed is notified.
Definition: ecm.h:86
Nothing notified so far.
Definition: ecm.h:84
#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:99
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:105
usbus_string_t mac_str
String context for the host side mac address.
Definition: ecm.h:106
#define ETHERNET_FRAME_LEN
maximum number of bytes in an ethernet frame (without FCS)
Definition: ethernet.h:42
usbus_handler_t handler_ctrl
Control interface handler.
Definition: ecm.h:93
Structure to hold driver state.
Definition: netdev.h:283
uint8_t in_buf[ETHERNET_FRAME_LEN]
Buffer for the received frames.
Definition: ecm.h:110
uint8_t mac_netdev[ETHERNET_ADDR_LEN]
this device&#39;s MAC address
Definition: ecm.h:104
usbus_hdr_gen_t ecm_hdr
ECM header generator.
Definition: ecm.h:100
Mutex for thread synchronization.
usbus_cdcecm_notif_t
notification state, used to track which information must be send to the host
Definition: ecm.h:83
mutex_t out_lock
mutex used for locking netif/USBUS send
Definition: ecm.h:108
event_t tx_xmit
Transmit ready event.
Definition: ecm.h:102
USBUS header generator.
Definition: usbus.h:221
USBUS handler struct.
Definition: usbus.h:341
unsigned active_iface
Current active data interface.
Definition: ecm.h:113
usbus_interface_alt_t iface_data_alt
Data alternative (active) interface.
Definition: ecm.h:96
size_t tx_len
Length of the current tx frame.
Definition: ecm.h:109
struct usbus_cdcecm_device usbus_cdcecm_device_t
USBUS CDC ECM device interface context.
Mutex structure.
Definition: mutex.h:36
size_t len
Length of the current rx frame.
Definition: ecm.h:111
stdlib.h wrapper for MSP430
Link status is notified.
Definition: ecm.h:85
USBUS CDC ECM device interface context.
Definition: ecm.h:92
usbus_interface_t iface_ctrl
Control interface.
Definition: ecm.h:95
USBUS basic interface.
USBUS interface alternative setting.
Definition: usbus.h:248
usbus_interface_t iface_data
Data interface.
Definition: ecm.h:94
usbus_endpoint_t * ep_in
Data endpoint in.
Definition: ecm.h:97