ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_usb_hcdc_ecm.h
Go to the documentation of this file.
1
48
49#pragma once
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55#include <stdint.h>
56
57#include "ra8_err.h"
58#include "ra8_usb.h"
59
60/* =============================================================================
61 * Constants
62 * =============================================================================
63 */
64
78
94
112
123
140
149
159
184
198typedef void (*ra8_usb_hcdc_ecm_attach_fn_t)(void* ctx, const ra8_usb_hcdc_ecm_device_t* device);
199
200/* =============================================================================
201 * Lifecycle
202 * =============================================================================
203 */
204
233
251[[nodiscard]] ra8_err_t ra8_usb_hcdc_ecm_close(void);
252
253/* =============================================================================
254 * Attach callback
255 * =============================================================================
256 */
257
282 void* ctx);
283
284/* =============================================================================
285 * Bulk frame pipe
286 * =============================================================================
287 */
288
317[[nodiscard]] ra8_err_t ra8_usb_hcdc_ecm_send_frame(const uint8_t* buf, uint16_t len);
318
349[[nodiscard]] ra8_err_t
350ra8_usb_hcdc_ecm_recv_frame(uint8_t* buf, uint16_t max_len, uint16_t* got_len);
351
352/* =============================================================================
353 * Class control transfers
354 * =============================================================================
355 */
356
386[[nodiscard]] ra8_err_t ra8_usb_hcdc_ecm_set_packet_filter(uint16_t filter_mask);
387
417
418/* =============================================================================
419 * Test / introspection helpers
420 * =============================================================================
421 */
422
445[[nodiscard]] ra8_err_t ra8_usb_hcdc_ecm_step(void);
446
478[[nodiscard]] ra8_err_t ra8_usb_hcdc_ecm_parse_mac(const char* chars, uint8_t* out_mac);
479
480#ifdef __cplusplus
481}
482#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Native USB controller driver public API (device + host modes).
ra8_usb_speed_t
Selects which controller instance the call targets.
ra8_err_t ra8_usb_hcdc_ecm_get_link_status(ra8_usb_hcdc_ecm_link_t *out_link)
Issue GET_ETHERNET_STATISTIC (bRequest=0x44) to read the adapter's link state and store the result in...
ra8_err_t ra8_usb_hcdc_ecm_set_packet_filter(uint16_t filter_mask)
Issue SET_ETHERNET_PACKET_FILTER (bRequest=0x43) to the attached CDC-ECM adapter.
ra8_err_t ra8_usb_hcdc_ecm_parse_mac(const char *chars, uint8_t *out_mac)
Parse 12 ASCII hex characters from an iMACAddress string descriptor payload into a 6-byte MAC.
ra8_usb_hcdc_ecm_mac_t
Sizes related to the 6-byte Ethernet MAC + its 12-character ASCII hex representation in the iMACAddre...
@ k_ra8_hcdc_ecm_mac_hex_chars
12 ASCII hex chars in iMACAddr.
@ k_ra8_hcdc_ecm_mac_bytes
Ethernet MAC byte count.
ra8_usb_hcdc_ecm_request_t
CDC-ECM class-specific request codes the host issues to the attached adapter (USB CDC ECM 1....
@ k_ra8_hcdc_ecm_req_get_statistic
GET_ETHERNET_STATISTIC.
@ k_ra8_hcdc_ecm_req_set_packet_filter
SET_ETHERNET_PACKET_FILTER.
ra8_usb_hcdc_ecm_link_t
Adapter link status reported by _get_link_status.
@ k_ra8_hcdc_ecm_link_down
NetworkConnection notification 0.
@ k_ra8_hcdc_ecm_link_up
NetworkConnection notification 1.
ra8_err_t ra8_usb_hcdc_ecm_init(ra8_usb_speed_t speed)
Bring up the host-CDC-ECM driver on a chosen USB controller.
ra8_err_t ra8_usb_hcdc_ecm_close(void)
Tear down the host-CDC-ECM driver and release the controller.
ra8_usb_hcdc_ecm_pipe_t
PIPE numbers used by the host-CDC-ECM driver for the attached adapter's endpoints.
@ k_ra8_hcdc_ecm_pipe_bulk_in
PIPE1 -> attached EP bulk IN.
@ k_ra8_hcdc_ecm_pipe_intr_in
PIPE6 -> attached EP intr IN.
@ k_ra8_hcdc_ecm_pipe_bulk_out
PIPE2 -> attached EP bulk OUT.
ra8_usb_hcdc_ecm_class_t
Class / subclass / protocol triplets that identify a CDC ECM function within an attached USB device's...
@ k_ra8_hcdc_ecm_protocol_none
No protocol.
@ k_ra8_hcdc_ecm_class_comms
CDC control IF class.
@ k_ra8_hcdc_ecm_subclass_zero
Data subclass = 0.
@ k_ra8_hcdc_ecm_class_data
CDC data interface class.
@ k_ra8_hcdc_ecm_subclass_ecm
Ethernet Networking model.
@ k_ra8_hcdc_ecm_protocol_zero
Data protocol = 0.
ra8_usb_hcdc_ecm_filter_t
Filter mask bits passed to ra8_usb_hcdc_ecm_set_packet_filter.
@ k_ra8_hcdc_ecm_filter_all
All bits set.
@ k_ra8_hcdc_ecm_filter_multicast
Listed multicast.
@ k_ra8_hcdc_ecm_filter_all_multicast
All multicast frames.
@ k_ra8_hcdc_ecm_filter_promiscuous
All received frames.
@ k_ra8_hcdc_ecm_filter_broadcast
Broadcast frames.
@ k_ra8_hcdc_ecm_filter_directed
Frames addressed to MAC.
ra8_err_t ra8_usb_hcdc_ecm_send_frame(const uint8_t *buf, uint16_t len)
Send an Ethernet frame OUT to the attached CDC-ECM adapter.
void(* ra8_usb_hcdc_ecm_attach_fn_t)(void *ctx, const ra8_usb_hcdc_ecm_device_t *device)
Attach-callback signature.
ra8_usb_hcdc_ecm_packet_t
Packet sizing for the attached adapter's bulk + interrupt endpoints.
@ k_ra8_hcdc_ecm_bulk_max_packet_fs
Bulk size at full speed.
@ k_ra8_hcdc_ecm_max_ethernet_frame
Ethernet frame ceiling.
@ k_ra8_hcdc_ecm_intr_max_packet
Notification pipe size.
@ k_ra8_hcdc_ecm_bulk_max_packet_hs
Bulk size at high speed.
ra8_err_t ra8_usb_hcdc_ecm_recv_frame(uint8_t *buf, uint16_t max_len, uint16_t *got_len)
Drain an Ethernet frame IN from the attached CDC-ECM adapter.
ra8_err_t ra8_usb_hcdc_ecm_attach_callback(ra8_usb_hcdc_ecm_attach_fn_t on_attach, void *ctx)
Register (or detach) the attach callback.
ra8_err_t ra8_usb_hcdc_ecm_step(void)
Drive the enumeration step machine forward by one step.
Snapshot of the attached CDC-ECM adapter, passed to the attach callback.
uint8_t device_address
Assigned USB address (1..127).
uint16_t vendor_id
idVendor from device descriptor.
uint16_t bulk_in_max_packet
Adapter bulk-IN wMaxPacketSize.
uint8_t i_mac_address
iMACAddress string descr index.
uint16_t bulk_out_max_packet
Adapter bulk-OUT wMaxPacketSize.
uint8_t mac_address[k_ra8_hcdc_ecm_mac_bytes]
6-byte MAC parsed from iMACAddress.
uint8_t bulk_out_ep
Adapter's bulk OUT EP num.
uint8_t intr_in_ep
Adapter's intr IN (notify) EP num.
uint16_t product_id
idProduct from device descriptor.
uint8_t bulk_in_ep
Adapter's bulk IN EP num.