PER Firmware
Loading...
Searching...
No Matches
usb_control.h
Go to the documentation of this file.
1
5#ifndef CANNECTOR_USB_CONTROL_H
6#define CANNECTOR_USB_CONTROL_H
7
8#include <stdint.h>
9
10// Zero is a valid address/configuration
11// UINT16_MAX is an out-of-range pending sentinel
12static constexpr uint16_t NO_PENDING_VALUE = UINT16_MAX;
13
14typedef struct {
15 volatile bool configured; // The host has selected configuration 1 and completed its acknowledgement
16 volatile bool bulk_in_halted; // The host has halted the CAN bulk IN endpoint
17 volatile bool bulk_out_halted; // The host has halted the CAN bulk OUT endpoint
18 uint8_t address; // The USB address assigned by the host
19 uint16_t pending_address; // An address change waiting for acknowledgement
20 uint16_t pending_configuration; // A configuration change waiting for acknowledgement
22
23
24// Check whether the bulk IN endpoint is configured and not halted.
25// The caller must exclude USB interrupts through the subsequent packet submission
26// to avoid racing reset/deconfiguration.
27bool usb_bulk_in_enabled(void);
28
29
30#endif
Definition usb_control.h:14
uint16_t pending_address
Definition usb_control.h:19
volatile bool configured
Definition usb_control.h:15
volatile bool bulk_out_halted
Definition usb_control.h:17
uint16_t pending_configuration
Definition usb_control.h:20
uint8_t address
Definition usb_control.h:18
volatile bool bulk_in_halted
Definition usb_control.h:16
static constexpr uint16_t NO_PENDING_VALUE
Definition usb_control.h:12
bool usb_bulk_in_enabled(void)
Definition usb_control.c:389