diff options
| author | hathach <[email protected]> | 2021-10-05 12:32:07 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2021-10-05 16:00:07 +0700 |
| commit | a867d87072e6f25e47f209e9615e00b97a9eb36f (patch) | |
| tree | 953346cbb1aa11697cf5b5f183c41952fbeb1681 /src | |
| parent | 31cfd5a68443db941dbce88cebaf8fdf2d16a6a0 (diff) | |
rename CFG_TUD_NET to CFG_TUD_ECM_RNDIS
Diffstat (limited to 'src')
| -rw-r--r-- | src/class/net/ecm_rndis_device.c (renamed from src/class/net/ecmrndis_device.c) | 2 | ||||
| -rw-r--r-- | src/class/net/ncm_device.c | 24 | ||||
| -rw-r--r-- | src/class/net/net_device.h | 34 | ||||
| -rw-r--r-- | src/device/usbd.c | 2 | ||||
| -rw-r--r-- | src/tusb.h | 2 | ||||
| -rw-r--r-- | src/tusb_option.h | 10 |
6 files changed, 43 insertions, 31 deletions
diff --git a/src/class/net/ecmrndis_device.c b/src/class/net/ecm_rndis_device.c index 288ecb7e2..c6cd388e3 100644 --- a/src/class/net/ecmrndis_device.c +++ b/src/class/net/ecm_rndis_device.c @@ -27,7 +27,7 @@ #include "tusb_option.h" -#if ( TUSB_OPT_DEVICE_ENABLED && CFG_TUD_NET && !CFG_TUD_NCM ) +#if ( TUSB_OPT_DEVICE_ENABLED && CFG_TUD_ECM_RNDIS ) #include "device/usbd.h" #include "device/usbd_pvt.h" diff --git a/src/class/net/ncm_device.c b/src/class/net/ncm_device.c index 1f592401e..2f7d58f99 100644 --- a/src/class/net/ncm_device.c +++ b/src/class/net/ncm_device.c @@ -28,7 +28,7 @@ #include "tusb_option.h" -#if ( TUSB_OPT_DEVICE_ENABLED && CFG_TUD_NET && CFG_TUD_NCM ) +#if ( TUSB_OPT_DEVICE_ENABLED && CFG_TUD_NCM ) #include "device/usbd.h" #include "device/usbd_pvt.h" @@ -131,18 +131,18 @@ typedef struct //--------------------------------------------------------------------+ CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN static const ntb_parameters_t ntb_parameters = { - .wLength = sizeof(ntb_parameters_t), - .bmNtbFormatsSupported = 0x01, - .dwNtbInMaxSize = CFG_TUD_NCM_IN_NTB_MAX_SIZE, - .wNdbInDivisor = 4, - .wNdbInPayloadRemainder = 0, - .wNdbInAlignment = CFG_TUD_NCM_ALIGNMENT, - .wReserved = 0, - .dwNtbOutMaxSize = CFG_TUD_NCM_OUT_NTB_MAX_SIZE, - .wNdbOutDivisor = 4, + .wLength = sizeof(ntb_parameters_t), + .bmNtbFormatsSupported = 0x01, + .dwNtbInMaxSize = CFG_TUD_NCM_IN_NTB_MAX_SIZE, + .wNdbInDivisor = 4, + .wNdbInPayloadRemainder = 0, + .wNdbInAlignment = CFG_TUD_NCM_ALIGNMENT, + .wReserved = 0, + .dwNtbOutMaxSize = CFG_TUD_NCM_OUT_NTB_MAX_SIZE, + .wNdbOutDivisor = 4, .wNdbOutPayloadRemainder = 0, - .wNdbOutAlignment = CFG_TUD_NCM_ALIGNMENT, - .wNtbOutMaxDatagrams = 0 + .wNdbOutAlignment = CFG_TUD_NCM_ALIGNMENT, + .wNtbOutMaxDatagrams = 0 }; CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN static transmit_ntb_t transmit_ntb[2]; diff --git a/src/class/net/net_device.h b/src/class/net/net_device.h index e6cdc8b8b..ad369b680 100644 --- a/src/class/net/net_device.h +++ b/src/class/net/net_device.h @@ -30,10 +30,14 @@ #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 @@ -62,8 +66,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); @@ -71,18 +85,16 @@ 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); +//------------- ECM/RNDIS -------------// + +// client must provide this: initialize any network state back to the beginning +void tud_network_init_cb(void); + // 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); - -// 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); +//------------- NCM -------------// // callback to client providing optional indication of internal state of network driver void tud_network_link_state_cb(bool state); diff --git a/src/device/usbd.c b/src/device/usbd.c index a33d778db..ab1837895 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -203,7 +203,7 @@ static usbd_class_driver_t const _usbd_driver[] = }, #endif - #if CFG_TUD_NET + #if CFG_TUD_ECM_RNDIS || CFG_TUD_NCM { DRIVER_NAME("NET") .init = netd_init, diff --git a/src/tusb.h b/src/tusb.h index b52f8839a..2e1b7a43d 100644 --- a/src/tusb.h +++ b/src/tusb.h @@ -100,7 +100,7 @@ #include "class/dfu/dfu_device.h" #endif - #if CFG_TUD_NET + #if CFG_TUD_ECM_RNDIS || CFG_TUD_NCM #include "class/net/net_device.h" #endif diff --git a/src/tusb_option.h b/src/tusb_option.h index 3cb672d80..369c35e2d 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -261,16 +261,16 @@ #define CFG_TUD_DFU 0 #endif -#ifndef CFG_TUD_NET - #define CFG_TUD_NET 0 -#endif - #ifndef CFG_TUD_BTH #define CFG_TUD_BTH 0 #endif +#ifndef CFG_TUD_ECM_RNDIS + #define CFG_TUD_ECM_RNDIS 0 +#endif + #ifndef CFG_TUD_NCM - #define CFG_TUD_NCM 0 + #define CFG_TUD_NCM 0 #endif //-------------------------------------------------------------------- |
