PixelKey
NeoPixel USB Key
Loading...
Searching...
No Matches
USB Comms Internals

Macros

#define USB_BUFFER_LENGTH   (64)
 Buffer length for USB operations, must be a multiple of 64.
 

Enumerations

enum  usb_op_state_t {
  USB_OP_STATE_OFFLINE , USB_OP_STATE_ONLINE , USB_OP_STATE_CONTROL_SEQUENCE , USB_OP_STATE_READ ,
  USB_OP_STATE_WRITE
}
 USB operational state. More...
 

Functions

static bool rx_start (void)
 Starts read processing.
 
static void rx_end (usb_event_info_t const *const p_event_info)
 Finishes read processing on USB_STATUS_READ_COMPLETE event.
 
static bool tx_start (void)
 Starts write processing.
 
static void tx_end (void)
 Finishes write processing on USB_STATUS_WRITE_COMPLETE event.
 
static pixelkey_error_t usb_serial_read (uint8_t *p_buffer, size_t *p_read_length)
 Provides a read method for the serial_api_t API. More...
 
static pixelkey_error_t usb_serial_write (uint8_t *p_buffer, size_t write_length)
 Provides a write method for the serial_api_t API. More...
 
static pixelkey_error_t usb_serial_flush (void)
 Provides a flush method for the serial_api_t API. More...
 
static bool usb_serial_rts (void)
 Gets the RTS signal state.
 
static uint8_t rx_buffer[(64)] __attribute__ ((aligned(2)))
 RX data buffer. More...
 
void hal_usb_idle (void)
 Idle function to check the status of the USB comms and handle CDC specific messaging.
 

Variables

static usb_op_state_t op_state = USB_OP_STATE_OFFLINE
 Current operational state of the USB.
 
static usb_pcdc_linecoding_t line_coding = {0}
 The currently configured line coding. More...
 
static usb_pcdc_ctrllinestate_t line_state = {0}
 
static size_t rx_length = 0
 Number of bytes received.
 
static size_t tx_length = 0
 Number of bytes to transmit.
 
const serial_api_t g_hal_usb_serial
 Serial instance for USB. More...
 

Detailed Description

Enumeration Type Documentation

◆ usb_op_state_t

USB operational state.

Enumerator
USB_OP_STATE_OFFLINE 

USB is offline or not yet enumerated.

USB_OP_STATE_ONLINE 

USB is online and enumerated, possibly idle.

USB_OP_STATE_CONTROL_SEQUENCE 

Control sequence processing is active.

USB_OP_STATE_READ 

Read data processing is active.

USB_OP_STATE_WRITE 

Write data processing is active.

Function Documentation

◆ __attribute__()

static uint8_t rx_buffer[(64)] __attribute__ ( (aligned(2))  )
static

RX data buffer.

TX data buffer.

◆ usb_serial_flush()

static pixelkey_error_t usb_serial_flush ( void  )
static

Provides a flush method for the serial_api_t API.

Return values
PIXELKEY_ERROR_COMMUNICATION_ERRORThe USB connection is offline or has yet to be enumerated.
PIXELKEY_ERROR_NONEWrite was performed successfully.

◆ usb_serial_read()

static pixelkey_error_t usb_serial_read ( uint8_t *  p_buffer,
size_t *  p_read_length 
)
static

Provides a read method for the serial_api_t API.

Parameters
[in]p_bufferPointer to the buffer to store read data.
[in,out]p_read_lengthPointer to the maximum read length, updated afterwards with the actual read length.
Return values
PIXELKEY_ERROR_COMMUNICATION_ERRORThe USB connection is offline or has yet to be enumerated.
PIXELKEY_ERROR_NONERead was performed successfully.

◆ usb_serial_write()

static pixelkey_error_t usb_serial_write ( uint8_t *  p_buffer,
size_t  write_length 
)
static

Provides a write method for the serial_api_t API.

Parameters
[in]p_bufferPointer to the buffer of data to write.
write_lengthTotal number of bytes to write.
Return values
PIXELKEY_ERROR_COMMUNICATION_ERRORThe USB connection is offline or has yet to be enumerated.
PIXELKEY_ERROR_BUFFER_FULLWriting the requested amount of data will overrun the transmit buffer.
PIXELKEY_ERROR_NONEWrite was performed successfully.

Variable Documentation

◆ g_hal_usb_serial

const serial_api_t g_hal_usb_serial
Initial value:
= {
.read = usb_serial_read,
.write = usb_serial_write,
.flush = usb_serial_flush,
.rts_get = usb_serial_rts,
}
static pixelkey_error_t usb_serial_read(uint8_t *p_buffer, size_t *p_read_length)
Provides a read method for the serial_api_t API.
Definition: hal_usb.c:285
static pixelkey_error_t usb_serial_flush(void)
Provides a flush method for the serial_api_t API.
Definition: hal_usb.c:345
static pixelkey_error_t usb_serial_write(uint8_t *p_buffer, size_t write_length)
Provides a write method for the serial_api_t API.
Definition: hal_usb.c:315
static bool usb_serial_rts(void)
Gets the RTS signal state.
Definition: hal_usb.c:364

Serial instance for USB.

◆ line_coding

usb_pcdc_linecoding_t line_coding = {0}
static

The currently configured line coding.

Unused for this application but required for USB CDC.