|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
USBX device-controller-driver bridge to ra8_usb – endpoint dispatch. More...
#include <stdint.h>#include <string.h>#include "ra8_check.h"#include "ra8_elc_regs.h"#include "ra8_isr.h"#include "ra8_log.h"#include "ra8_usb_regs.h"#include "tx_api.h"#include "ux_api.h"#include "ux_dcd_ra8_usb.h"#include "ux_dcd_ra8_usb_internal.h"#include "ux_device_stack.h"#include "ux_system.h"#include "ux_utility.h"Go to the source code of this file.
Macros | |
| #define | UX_SOURCE_CODE |
Functions | |
| static void | internal_endpoint_arm_out_pid (uint8_t pipe, uint8_t ep_addr) |
| Set the power-on PID of a freshly created non-control pipe. | |
| static unsigned int | internal_endpoint_create (struct UX_SLAVE_ENDPOINT_STRUCT *ep) |
| Translate a USBX endpoint create request into ra8_usb call. | |
| static unsigned int | internal_endpoint_stall (struct UX_SLAVE_ENDPOINT_STRUCT *ep) |
| Endpoint stall. | |
| static unsigned int | internal_endpoint_destroy (struct UX_SLAVE_ENDPOINT_STRUCT *ep) |
| Drop the bridge's per-pipe transfer stash for a destroyed endpoint. | |
| static void | internal_count_change_state (unsigned long state) |
| Count UX_DCD_CHANGE_STATE notifications by target state. | |
| unsigned int | _ux_dcd_ra8_usb_function (struct UX_SLAVE_DCD_STRUCT *dcd, unsigned int function, void *parameter) |
| USBX device-side DCD function dispatcher. | |
USBX device-controller-driver bridge to ra8_usb – endpoint dispatch.
USBX DCD function trampoline plus the endpoint create / destroy / stall helpers and the CHANGE_STATE accounting.
Split out of ux_dcd_ra8_usb.c to keep each translation unit under the maintainability line cap; the cross-translation-unit contract lives in ux_dcd_ra8_usb_internal.h.
Definition in file ux_dcd_ra8_usb_ep.c.
| #define UX_SOURCE_CODE |
Definition at line 21 of file ux_dcd_ra8_usb_ep.c.
| unsigned int _ux_dcd_ra8_usb_function | ( | struct UX_SLAVE_DCD_STRUCT * | dcd, |
| unsigned int | function, | ||
| void * | parameter ) |
USBX device-side DCD function dispatcher.
ux dcd ra usb function.
Stamped into UX_SLAVE_DCD::ux_slave_dcd_function during ux_dcd_ra8_usb_initialize. The USBX device stack calls this with a UX_DCD_* selector to request endpoint create/destroy, transfer request, transfer abort, stall, and similar primitives; the trampoline routes each to the matching internal_* helper.
| [in,out] | dcd | USBX DCD ownership block (currently unused; the bridge keeps its own static state in g_dcd). |
| [in] | function | USBX UX_DCD_* selector (e.g. UX_DCD_TRANSFER_REQUEST). |
| [in,out] | parameter | Selector-dependent argument (UX_SLAVE_TRANSFER* / UX_SLAVE_ENDPOINT* / opaque). |
| UX_SUCCESS | Function handled. |
| UX_CONTROLLER_UNKNOWN | Bridge has not been initialized. |
| UX_ERROR | Selector unsupported, or helper rejected the call. |
| UX_TRANSFER_ERROR | Transfer-request helper failed. |
Definition at line 281 of file ux_dcd_ra8_usb_ep.c.
References g_dcd, internal_count_change_state(), internal_endpoint_create(), internal_endpoint_destroy(), internal_endpoint_stall(), k_ux_dcd_ra8_usb_state_active, k_ux_dcd_ra8_usb_state_ready, k_ux_dcd_ra8_usb_state_uninit, and priv_transfer_request().
Referenced by internal_init_bind_owner(), and internal_init_setup_ep0().
|
static |
Count UX_DCD_CHANGE_STATE notifications by target state.
Diagnostic brackets around the chapter-9 configuration walk: the stack notifies ATTACHED during teardown and CONFIGURED at the end, so the counter pair shows how far configuration processing ran (read via JLink alongside g_diag).
| [in] | state | The UX device state being announced. |
Definition at line 238 of file ux_dcd_ra8_usb_ep.c.
References g_diag, and RA8_INTERNAL.
Referenced by _ux_dcd_ra8_usb_function().
|
static |
Set the power-on PID of a freshly created non-control pipe.
Called once from internal_endpoint_create after ra8_usb_configure_endpoint. An IN pipe is left as configured – the queue_in path and internal_submit_pipe own its PID. An OUT pipe is armed to PID=BUF only when the in-ISR auto-echo path drains it (CDC loopback); every other OUT pipe is parked at PID=NAK so a host OUT token arriving before internal_submit_pipe arms a real receiver is NAK-flow-controlled rather than ACKed into a FIFO with no waiter – the latter latches BRDYSTS and storms the ISR (GitHub issue #6). Nested ifs keep the auto-echo test out of the MC/DC inventory.
| [in] | pipe | Pipe index (1..max_pipes-1). |
| [in] | ep_addr | Endpoint address (bit 7 = direction). |
Definition at line 64 of file ux_dcd_ra8_usb_ep.c.
References g_dcd, g_dcd_auto_echo_enable, g_dcd_auto_echo_out_pipe, g_orphan_len, k_ra8_usb_ep_addr_dir_in_bit, RA8_INTERNAL, ra8_usb_park_out_pipe(), and ra8_usb_rearm_out_pipe().
Referenced by internal_endpoint_create().
|
static |
Translate a USBX endpoint create request into ra8_usb call.
See implementation for details.
| [in,out] | ep | See function signature. |
| 0 | Success or default value. |
Definition at line 100 of file ux_dcd_ra8_usb_ep.c.
References g_dcd, g_diag, internal_endpoint_arm_out_pid(), k_ra8_ok, k_ra8_usb_ep_addr_dir_in_bit, k_ra8_usb_ep_addr_num_mask, k_ra8_usb_ep_dir_in, k_ra8_usb_ep_dir_out, k_ra8_usb_ep_type_bulk, k_ra8_usb_ep_type_intr, k_ra8_usb_ep_type_iso, k_ux_dcd_ra8_usb_max_pipes, priv_ep_to_pipe(), RA8_INTERNAL, and ra8_usb_configure_endpoint().
Referenced by _ux_dcd_ra8_usb_function().
|
static |
Drop the bridge's per-pipe transfer stash for a destroyed endpoint.
USBX calls UX_DCD_DESTROY_ENDPOINT when a class driver tears down an interface (e.g. SET_CONFIGURATION(0) or device detach). The ra8_usb register layer has no per-pipe destroy primitive, so the cleanup we owe is forgetting any cached UX_SLAVE_TRANSFER* so the IRQ path cannot post a completion against a defunct request.
| [in] | ep | USBX endpoint pointer (the parameter from the dispatch). |
| UX_SUCCESS | Pipe stash cleared (or pipe was out of range). |
| UX_ERROR | ep was null. |
Definition at line 208 of file ux_dcd_ra8_usb_ep.c.
References g_dcd, k_ux_dcd_ra8_usb_max_pipes, priv_ep_to_pipe(), and RA8_INTERNAL.
Referenced by _ux_dcd_ra8_usb_function().
|
static |
Endpoint stall.
See implementation for details.
| [in,out] | ep | See function signature for type and usage. |
| 0 | Success or default value. |
Definition at line 169 of file ux_dcd_ra8_usb_ep.c.
References g_dcd, k_ra8_ok, k_ux_dcd_ra8_usb_max_pipes, priv_ep_to_pipe(), RA8_INTERNAL, and ra8_usb_stall_endpoint().
Referenced by _ux_dcd_ra8_usb_function().