ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_usb_pal.h
Go to the documentation of this file.
1
60
61#pragma once
62
63#ifdef __cplusplus
64extern "C" {
65#endif
66
67#include <stdint.h>
68
69#include "ra8_err.h"
70#include "ra8_usb.h"
71
72/* =============================================================================
73 * Constants
74 * =============================================================================
75 */
76
95
104
115
128
129/* =============================================================================
130 * Event bits (relayed from ra8_usb status mask)
131 * =============================================================================
132 */
133
151
163typedef void (*ra8_usb_pal_event_fn_t)(void* ctx, ra8_usb_speed_t speed, uint16_t event_mask);
164
165/* =============================================================================
166 * Lifecycle
167 * =============================================================================
168 */
169
198[[nodiscard]] ra8_err_t ra8_usb_pal_init(ra8_usb_speed_t speed);
199
218[[nodiscard]] ra8_err_t ra8_usb_pal_deinit(void);
219
220/* =============================================================================
221 * Bus state
222 * =============================================================================
223 */
224
242[[nodiscard]] ra8_err_t ra8_usb_pal_attach(bool attached);
243
263[[nodiscard]] ra8_err_t ra8_usb_pal_get_state(ra8_usb_pal_state_t* out_state);
264
265/* =============================================================================
266 * Endpoint I/O
267 * =============================================================================
268 */
269
295[[nodiscard]] ra8_err_t ra8_usb_pal_ep_open(uint8_t ep_addr,
298 uint16_t max_packet);
299
322[[nodiscard]] ra8_err_t ra8_usb_pal_ep_send(uint8_t ep_addr, const uint8_t* data, uint16_t len);
323
346[[nodiscard]] ra8_err_t ra8_usb_pal_ep_recv(uint8_t ep_addr, uint8_t* out_buf, uint16_t* inout_len);
347
348/* =============================================================================
349 * Async event handler
350 * =============================================================================
351 */
352
377
378#ifdef __cplusplus
379}
380#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_usb_pal_ep_dir_t
Endpoint direction.
@ k_ra8_usb_pal_ep_dir_out
Host -> device.
@ k_ra8_usb_pal_ep_dir_in
Device -> host.
ra8_err_t ra8_usb_pal_init(ra8_usb_speed_t speed)
Initialise the USB PAL on a specific controller speed.
ra8_err_t ra8_usb_pal_attach(bool attached)
Raise / drop the D+ pull-up to advertise the device.
ra8_usb_pal_limits_t
USB sizing constants.
Definition ra8_usb_pal.h:87
@ k_ra8_usb_pal_ep_addr_mask
Strip USB-IN dir bit (bit 7) from ep_addr.
Definition ra8_usb_pal.h:93
@ k_ra8_usb_pal_xfer_max
Single-shot xfer cap.
Definition ra8_usb_pal.h:92
@ k_ra8_usb_pal_ep_max
Maximum endpoint number.
Definition ra8_usb_pal.h:88
@ k_ra8_usb_pal_bulk_max_hs
Bulk max packet at high-speed.
Definition ra8_usb_pal.h:91
@ k_ra8_usb_pal_bulk_max_fs
Bulk max packet at full-speed.
Definition ra8_usb_pal.h:90
@ k_ra8_usb_pal_ep0_max_packet
EP0 max packet on FS / HS-FS.
Definition ra8_usb_pal.h:89
ra8_err_t ra8_usb_pal_ep_open(uint8_t ep_addr, ra8_usb_pal_ep_dir_t dir, ra8_usb_pal_ep_type_t type, uint16_t max_packet)
Open a non-control endpoint with a given type / direction / size.
ra8_err_t ra8_usb_pal_get_state(ra8_usb_pal_state_t *out_state)
Read the current PAL state machine.
ra8_err_t ra8_usb_pal_ep_recv(uint8_t ep_addr, uint8_t *out_buf, uint16_t *inout_len)
Receive data from an OUT endpoint (host -> device).
ra8_usb_pal_ep_type_t
USB endpoint transfer type.
@ k_ra8_usb_pal_ep_type_bulk
RA8 USB pal ep type bulk.
@ k_ra8_usb_pal_ep_type_control
RA8 USB pal ep type control.
@ k_ra8_usb_pal_ep_type_intr
RA8 USB pal ep type intr.
@ k_ra8_usb_pal_ep_type_iso
RA8 USB pal ep type iso.
ra8_err_t ra8_usb_pal_set_event_handler(ra8_usb_pal_event_fn_t fn, void *ctx)
Attach a single event handler for bus / endpoint events.
ra8_usb_pal_event_t
Event mask bits passed to ra8_usb_pal_event_fn_t.
@ k_ra8_usb_pal_event_error
Controller error.
@ k_ra8_usb_pal_event_reset
Bus reset.
@ k_ra8_usb_pal_event_resume
Bus resume.
@ k_ra8_usb_pal_event_ep_out
OUT endpoint complete.
@ k_ra8_usb_pal_event_none
RA8 USB pal event none.
@ k_ra8_usb_pal_event_detach
VBUS dropped / cable out.
@ k_ra8_usb_pal_event_setup
SETUP packet on EP0.
@ k_ra8_usb_pal_event_attach
VBUS rose / cable in.
@ k_ra8_usb_pal_event_sof
Start-of-Frame.
@ k_ra8_usb_pal_event_suspend
Bus suspend (idle).
@ k_ra8_usb_pal_event_ep_in
IN endpoint complete.
ra8_err_t ra8_usb_pal_ep_send(uint8_t ep_addr, const uint8_t *data, uint16_t len)
Submit data on an IN endpoint (device -> host).
void(* ra8_usb_pal_event_fn_t)(void *ctx, ra8_usb_speed_t speed, uint16_t event_mask)
Async event callback shape.
ra8_usb_pal_state_t
USB device state per chapter 9 of USB 2.0.
@ k_ra8_usb_pal_state_default
Reset received.
@ k_ra8_usb_pal_state_attached
D+ pull-up on, no reset.
@ k_ra8_usb_pal_state_addressed
Address assigned.
@ k_ra8_usb_pal_state_suspended
Bus idle > 3 ms.
@ k_ra8_usb_pal_state_configd
SET_CONFIGURATION done.
@ k_ra8_usb_pal_state_detached
D+ pull-up off.
ra8_err_t ra8_usb_pal_deinit(void)
Tear down the USB PAL.