PER Firmware
Loading...
Searching...
No Matches
usb_control.c File Reference

Host enumeration and endpoint-zero control transfers (USB ISR context) More...

#include "usb_control.h"
#include <string.h>
#include "usb_device.h"
#include "usb_descriptors.h"
Include dependency graph for usb_control.c:

Functions

static void stall_control (void)
 
static void respond (const void *data, uint16_t size, uint16_t requested)
 
static bool valid_endpoint (uint16_t index)
 
static bool handle_get_descriptor (const PHAL_USB_SetupPacket_t *setup)
 
static bool handle_set_address (const PHAL_USB_SetupPacket_t *setup)
 
static bool handle_get_configuration (const PHAL_USB_SetupPacket_t *setup)
 
static bool handle_set_configuration (const PHAL_USB_SetupPacket_t *setup)
 
static bool handle_get_status (const PHAL_USB_SetupPacket_t *setup)
 
static bool handle_get_interface (const PHAL_USB_SetupPacket_t *setup)
 
static bool handle_set_interface (const PHAL_USB_SetupPacket_t *setup)
 
static bool handle_endpoint_halt (const PHAL_USB_SetupPacket_t *setup)
 
static void handle_setup (const PHAL_USB_SetupPacket_t *setup)
 
static void handle_control_out (bool is_setup)
 
static void handle_control_in (void)
 
static void handle_bulk_out (void)
 
void PHAL_USB_callback (const PHAL_USB_Event_t *event)
 Handle USB events.
 
bool usb_bulk_in_enabled (void)
 

Variables

static usb_context_t g_usb_context
 

Detailed Description

Host enumeration and endpoint-zero control transfers (USB ISR context)

Function Documentation

◆ handle_bulk_out()

static void handle_bulk_out ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_control_in()

static void handle_control_in ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_control_out()

static void handle_control_out ( bool is_setup)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_endpoint_halt()

static bool handle_endpoint_halt ( const PHAL_USB_SetupPacket_t * setup)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_get_configuration()

static bool handle_get_configuration ( const PHAL_USB_SetupPacket_t * setup)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_get_descriptor()

static bool handle_get_descriptor ( const PHAL_USB_SetupPacket_t * setup)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_get_interface()

static bool handle_get_interface ( const PHAL_USB_SetupPacket_t * setup)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_get_status()

static bool handle_get_status ( const PHAL_USB_SetupPacket_t * setup)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_set_address()

static bool handle_set_address ( const PHAL_USB_SetupPacket_t * setup)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_set_configuration()

static bool handle_set_configuration ( const PHAL_USB_SetupPacket_t * setup)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_set_interface()

static bool handle_set_interface ( const PHAL_USB_SetupPacket_t * setup)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_setup()

static void handle_setup ( const PHAL_USB_SetupPacket_t * setup)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PHAL_USB_callback()

void PHAL_USB_callback ( const PHAL_USB_Event_t * event)

Handle USB events.

Applications define this callback to process bus resets, SETUP packets, OUT packets, and IN completions. Check event->transfer before accessing transfer_data. The HAL provides a weak empty implementation. OUT data remains available through PHAL_USB_read(). An IN completion marks the endpoint ready for PHAL_USB_write(). If SETUP and a prior IN completion are both pending, the HAL delivers the IN completion first so SETUP cannot erase pending state.

Parameters
eventUSB event for the current interrupt.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ respond()

static void respond ( const void * data,
uint16_t size,
uint16_t requested )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stall_control()

static void stall_control ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ usb_bulk_in_enabled()

bool usb_bulk_in_enabled ( void )
Here is the caller graph for this function:

◆ valid_endpoint()

static bool valid_endpoint ( uint16_t index)
static
Here is the caller graph for this function:

Variable Documentation

◆ g_usb_context

usb_context_t g_usb_context
static
Initial value:
= {
.configured = false,
.bulk_in_halted = false,
.bulk_out_halted = false,
.address = 0U,
.pending_address = NO_PENDING_VALUE,
.pending_configuration = NO_PENDING_VALUE,
}
static constexpr uint16_t NO_PENDING_VALUE
Definition usb_control.h:12