iSensor-SPI-Buffer  1.15
Firmware for the iSensor-SPI-Buffer board to enable full throughput buffered data capture on Analog Devices IMUs
Functions | Variables
usb.c File Reference

Implementation file for iSensor-SPI-Buffer USB command line register interface. More...

#include "usb.h"
#include "reg.h"
#include "main.h"
#include "usbd_cdc_if.h"
#include "script.h"
#include "timer.h"
Include dependency graph for usb.c:

Functions

void USB_Reset ()
 Toggle USB PU to force a re-enumeration on the host side. More...
 
void USB_Rx_Handler ()
 Handler for received USB data. More...
 
void USB_Tx_Handler (const uint8_t *buf, uint32_t count)
 USB write handler. More...
 
bool USB_Wait_For_Tx_Done (uint32_t TimeoutMs)
 Helper function to wait for the USB Tx to be free. More...
 
void USB_Watermark_Autoset ()
 Helper function to set the watermark interrupt level for optimal USB streams. More...
 

Variables

USBD_HandleTypeDef hUsbDeviceFS
 
uint8_t UserRxBufferFS [APP_RX_DATA_SIZE]
 
uint8_t UserTxBufferFS [APP_TX_DATA_SIZE]
 
uint32_t USBRxCount
 
static uint8_t CurrentCommand [64]
 
static script scr = {}
 
static uint8_t EchoBuf [4]
 
static const uint8_t NewLineStr [] = "\r\n"
 

Detailed Description

Implementation file for iSensor-SPI-Buffer USB command line register interface.

Copyright (c) Analog Devices Inc, 2020 All Rights Reserved.

Date
6/26/2020
Author
A. Nolan (alex..nosp@m.nola.nosp@m.n@ana.nosp@m.log..nosp@m.com)

Function Documentation

◆ USB_Reset()

void USB_Reset ( )

Toggle USB PU to force a re-enumeration on the host side.

Returns
void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USB_Rx_Handler()

void USB_Rx_Handler ( )

Handler for received USB data.

Returns
void

This function should be called periodically from the main loop to check if new USB data has been received

◆ USB_Tx_Handler()

void USB_Tx_Handler ( const uint8_t *  buf,
uint32_t  count 
)

USB write handler.

Parameters
bufBuffer containing data to write
countNumber of bytes to write
Returns
void

This function is called by the script execution routines, when a script object is executed from a USB CLI context.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ USB_Wait_For_Tx_Done()

bool USB_Wait_For_Tx_Done ( uint32_t  TimeoutMs)

Helper function to wait for the USB Tx to be free.

Parameters
TimeoutMsOperation timeout (in ms). Must keep under watchdog reset period
Returns
true if Tx is free, false is timeout elapses
Here is the caller graph for this function:

◆ USB_Watermark_Autoset()

void USB_Watermark_Autoset ( )

Helper function to set the watermark interrupt level for optimal USB streams.

Returns
void

This function can be called to configure the watermark interrupt level for ideal operation using a USB CLI stream. To get maximum throughput over the USB CLI stream, while maintaining minimal latency, the watermark interrupt level should be set such that each USB transmission occupies a single full buffer (512 bytes).

After calling this function, WATERMARK_INT_CONFIG will be set based on the current buffer length setting.

Variable Documentation

◆ CurrentCommand

uint8_t CurrentCommand[64]
static

Current command string

◆ EchoBuf

uint8_t EchoBuf[4]
static

Byte buffer for echoing to console

◆ hUsbDeviceFS

USBD_HandleTypeDef hUsbDeviceFS
extern

USB handle (from usb_device.c)

◆ NewLineStr

const uint8_t NewLineStr[] = "\r\n"
static

newline string

◆ scr

script scr = {}
static

Script object (parsed from current command)

◆ USBRxCount

uint32_t USBRxCount
extern

USB Rx count (from usbd_cdc_if.c)

◆ UserRxBufferFS

uint8_t UserRxBufferFS[APP_RX_DATA_SIZE]
extern

USB Rx buffer (from usbd_cdc_if.c)

◆ UserTxBufferFS

uint8_t UserTxBufferFS[APP_TX_DATA_SIZE]
extern

USB Tx buffer (from usbd_cdc_if.c)