summaryrefslogtreecommitdiff
path: root/src/class/net/net_device.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/class/net/net_device.h')
-rw-r--r--src/class/net/net_device.h48
1 files changed, 34 insertions, 14 deletions
diff --git a/src/class/net/net_device.h b/src/class/net/net_device.h
index f030f3077..4c9a92f2d 100644
--- a/src/class/net/net_device.h
+++ b/src/class/net/net_device.h
@@ -1,4 +1,4 @@
-/*
+/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Peter Lawrence
@@ -28,16 +28,29 @@
#ifndef _TUSB_NET_DEVICE_H_
#define _TUSB_NET_DEVICE_H_
+#include <stdint.h>
#include "class/cdc/cdc.h"
+#if CFG_TUD_ECM_RNDIS && CFG_TUD_NCM
+#error "Cannot enable both ECM_RNDIS and NCM network drivers"
+#endif
+
/* declared here, NOT in usb_descriptors.c, so that the driver can intelligently ZLP as needed */
#define CFG_TUD_NET_ENDPOINT_SIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
-/* Maximum Tranmission Unit (in bytes) of the network, including Ethernet header */
+/* Maximum Transmission Unit (in bytes) of the network, including Ethernet header */
#ifndef CFG_TUD_NET_MTU
#define CFG_TUD_NET_MTU 1514
#endif
+
+// Table 4.3 Data Class Interface Protocol Codes
+typedef enum
+{
+ NCM_DATA_PROTOCOL_NETWORK_TRANSFER_BLOCK = 0x01
+} ncm_data_interface_protocol_code_t;
+
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -46,8 +59,18 @@
// Application API
//--------------------------------------------------------------------+
-// client must provide this: initialize any network state back to the beginning
-void tud_network_init_cb(void);
+// indicate to network driver that client has finished with the packet provided to network_recv_cb()
+void tud_network_recv_renew(void);
+
+// poll network driver for its ability to accept another packet to transmit
+bool tud_network_can_xmit(uint16_t size);
+
+// if network_can_xmit() returns true, network_xmit() can be called once
+void tud_network_xmit(void *ref, uint16_t arg);
+
+//--------------------------------------------------------------------+
+// Application Callbacks (WEAK is optional)
+//--------------------------------------------------------------------+
// client must provide this: return false if the packet buffer was not accepted
bool tud_network_recv_cb(const uint8_t *src, uint16_t size);
@@ -55,23 +78,20 @@ bool tud_network_recv_cb(const uint8_t *src, uint16_t size);
// client must provide this: copy from network stack packet pointer to dst
uint16_t tud_network_xmit_cb(uint8_t *dst, void *ref, uint16_t arg);
-// client must provide this: 48-bit MAC address
-// TODO removed later since it is not part of tinyusb stack
-extern const uint8_t tud_network_mac_address[6];
-
-// indicate to network driver that client has finished with the packet provided to network_recv_cb()
-void tud_network_recv_renew(void);
+//------------- ECM/RNDIS -------------//
-// poll network driver for its ability to accept another packet to transmit
-bool tud_network_can_xmit(void);
+// client must provide this: initialize any network state back to the beginning
+void tud_network_init_cb(void);
-// if network_can_xmit() returns true, network_xmit() can be called once
-void tud_network_xmit(void *ref, uint16_t arg);
+// client must provide this: 48-bit MAC address
+// TODO removed later since it is not part of tinyusb stack
+extern uint8_t tud_network_mac_address[6];
//--------------------------------------------------------------------+
// INTERNAL USBD-CLASS DRIVER API
//--------------------------------------------------------------------+
void netd_init (void);
+bool netd_deinit (void);
void netd_reset (uint8_t rhport);
uint16_t netd_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
bool netd_control_xfer_cb (uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);