ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_usb_pprn.h
Go to the documentation of this file.
1
32
33#pragma once
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39#include <stdint.h>
40
41#include "ra8_err.h"
42#include "ra8_usb.h"
43
44/* =============================================================================
45 * Constants
46 * =============================================================================
47 */
48
63
72
84
101
115
128
150typedef ra8_err_t (*ra8_usb_pprn_setup_fn_t)(void* ctx, const ra8_usb_setup_t* setup);
151
152/* =============================================================================
153 * Lifecycle
154 * =============================================================================
155 */
156
186[[nodiscard]] ra8_err_t ra8_usb_pprn_init(ra8_usb_speed_t speed);
187
203[[nodiscard]] ra8_err_t ra8_usb_pprn_close(void);
204
205/* =============================================================================
206 * Descriptor + identity handoff
207 * =============================================================================
208 */
209
244[[nodiscard]] ra8_err_t ra8_usb_pprn_set_descriptors(const uint8_t* desc,
245 uint16_t desc_len,
246 const uint8_t* device_id,
247 uint16_t device_id_len);
248
249/* =============================================================================
250 * Print data transport
251 * =============================================================================
252 */
253
275[[nodiscard]] ra8_err_t ra8_usb_pprn_recv(uint8_t* buf, uint16_t max_len, uint16_t* got_len);
276
300[[nodiscard]] ra8_err_t ra8_usb_pprn_send(const uint8_t* data, uint16_t len);
301
302/* =============================================================================
303 * Port-status shadow
304 * =============================================================================
305 */
306
327[[nodiscard]] ra8_err_t ra8_usb_pprn_set_port_status(uint8_t status_byte);
328
346[[nodiscard]] ra8_err_t ra8_usb_pprn_get_port_status(uint8_t* out_status);
347
348/* =============================================================================
349 * Setup-handler attach
350 * =============================================================================
351 */
352
376 void* ctx);
377
378/* =============================================================================
379 * Class SETUP dispatch
380 * =============================================================================
381 */
382
411[[nodiscard]] ra8_err_t ra8_usb_pprn_handle_setup(const ra8_usb_setup_t* setup);
412
413#ifdef __cplusplus
414}
415#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_pprn_get_port_status(uint8_t *out_status)
Read the current port-status byte.
ra8_err_t ra8_usb_pprn_set_descriptors(const uint8_t *desc, uint16_t desc_len, const uint8_t *device_id, uint16_t device_id_len)
Install the caller-supplied descriptor blob and IEEE 1284 device-ID string.
ra8_err_t ra8_usb_pprn_handle_setup(const ra8_usb_setup_t *setup)
Process a class-specific SETUP packet on EP0.
ra8_usb_pprn_pipe_t
PIPE numbers used by the device-Printer function for the local bulk endpoints.
@ k_ra8_pprn_pipe_bulk_in
PIPE4 -> EP2 IN (status).
@ k_ra8_pprn_pipe_bulk_out
PIPE3 -> EP1 OUT (print data).
ra8_err_t ra8_usb_pprn_recv(uint8_t *buf, uint16_t max_len, uint16_t *got_len)
Drain inbound print-job data from the bulk-OUT endpoint.
ra8_usb_pprn_port_status_bit_t
Bit positions in the 1-byte GET_PORT_STATUS response.
@ k_ra8_pprn_status_bit_not_error
1 = no error.
@ k_ra8_pprn_status_bit_select
1 = printer online.
@ k_ra8_pprn_status_bit_paper_empty
1 = paper empty.
ra8_err_t ra8_usb_pprn_attach_setup_handler(ra8_usb_pprn_setup_fn_t setup_fn, void *ctx)
Register the application's printer class-setup handler.
ra8_err_t(* ra8_usb_pprn_setup_fn_t)(void *ctx, const ra8_usb_setup_t *setup)
Caller-supplied printer class-setup handler signature.
ra8_usb_pprn_class_t
Class / subclass / protocol triplet that identifies the local Printer function in the configuration d...
@ k_ra8_pprn_protocol_1284_4
IEEE 1284.4 bi-dir.
@ k_ra8_pprn_protocol_unidir
Uni-directional.
@ k_ra8_pprn_class_printer
Printer interface class.
@ k_ra8_pprn_protocol_bidir
Bi-directional.
@ k_ra8_pprn_subclass_default
Printers subclass.
ra8_usb_pprn_packet_t
Packet sizing for the bulk endpoints.
@ k_ra8_pprn_bulk_max_packet_fs
Bulk size at FS.
@ k_ra8_pprn_bulk_max_packet_hs
Bulk size at HS.
ra8_err_t ra8_usb_pprn_init(ra8_usb_speed_t speed)
Bring up the device-Printer function on a chosen USB controller.
ra8_usb_pprn_ep_t
USB endpoint addresses used by the device-Printer function.
@ k_ra8_pprn_ep_bulk_in_addr
EP2 IN address.
@ k_ra8_pprn_ep_bulk_out_addr
EP1 OUT address.
ra8_err_t ra8_usb_pprn_set_port_status(uint8_t status_byte)
Update the local port-status byte returned by GET_PORT_STATUS.
ra8_err_t ra8_usb_pprn_close(void)
Tear down the device-Printer function and release the controller.
ra8_usb_pprn_request_t
Printer class-specific request codes the host issues to the device.
@ k_ra8_pprn_req_soft_reset
SOFT_RESET.
@ k_ra8_pprn_req_get_device_id
GET_DEVICE_ID.
@ k_ra8_pprn_req_get_port_status
GET_PORT_STATUS.
ra8_err_t ra8_usb_pprn_send(const uint8_t *data, uint16_t len)
Push outbound printer-status bytes on the bulk-IN endpoint.
Decoded 8-byte USB SETUP packet.