PixelKey
NeoPixel USB Key
Loading...
Searching...
No Matches
hal_usb.c File Reference
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "hal_data.h"
#include "hal_device.h"
#include "hal_npdata_transfer.h"
#include "hal_tasks.h"
#include "neopixel.h"
#include "pixelkey.h"
#include "serial.h"
#include "config.h"
#include "r_usb_basic.h"
#include "r_usb_basic_api.h"
#include "r_usb_basic_cfg.h"

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...