USB APIs

Note

USB is not available within M4 programs.

USB device

namespace coralmicro
class UsbDeviceTask
#include <usb_device_task.h>

Operates the Dev Board Micro as a USB device.

Public Functions

UsbDeviceTask()
UsbDeviceTask(const UsbDeviceTask&) = delete
UsbDeviceTask &operator=(const UsbDeviceTask&) = delete
void AddDevice(const usb_device_class_config_struct_t &config, UsbSetHandleCallback sh_cb, UsbHandleEventCallback he_cb, const void *descriptor_data, size_t descriptor_data_size)
void UsbDeviceTaskFn()
inline uint8_t next_descriptor_value()
inline uint8_t next_interface_value()
inline usb_device_handle device_handle() const

Public Static Functions

static inline UsbDeviceTask *GetSingleton()

Public Types

using UsbSetHandleCallback = std::function<void(class_handle_t)>
using UsbHandleEventCallback = std::function<bool(uint32_t, void*)>

USB host

namespace coralmicro
class UsbHostTask
#include <usb_host_task.h>

Operates the Dev Board Micro as a USB host.

Public Functions

UsbHostTask()
UsbHostTask(const UsbHostTask&) = delete
UsbHostTask &operator=(const UsbHostTask&) = delete
void RegisterUsbHostEventCallback(uint32_t vid, uint32_t pid, UsbHostEventCallback fn)
usb_status_t HostEvent(usb_device_handle device_handle, usb_host_configuration_handle config_handle, uint32_t event_code)
inline usb_host_handle host_handle() const

Public Static Functions

static inline UsbHostTask *GetSingleton()

Public Types

using UsbHostEventCallback = std::function<usb_status_t(usb_host_handle, usb_device_handle, usb_host_configuration_handle, uint32_t)>

USB host communication (CDC-ACM)

namespace coralmicro
class CdcAcm
#include <cdc_acm.h>

Public Functions

CdcAcm() = default
CdcAcm(const CdcAcm&) = delete
CdcAcm &operator=(const CdcAcm&) = delete
void Init(uint8_t interrupt_in_ep, uint8_t bulk_in_ep, uint8_t bulk_out_ep, uint8_t comm_iface, uint8_t data_iface, RxHandler rx_handler)
inline const usb_device_class_config_struct_t &config_data() const
inline const void *descriptor_data() const
inline size_t descriptor_data_size() const
inline void SetClassHandle(class_handle_t class_handle)

TODO(atv): Make me private.

bool HandleEvent(uint32_t event, void *param)
bool Transmit(const uint8_t *buffer, const size_t length)

Public Types

using RxHandler = std::function<void(const uint8_t*, const uint32_t)>
struct _usb_host_cdc_line_coding_struct
#include <cdc_acm.h>

Public Members

uint32_t dwDTERate

Data terminal rate, in bits per second

uint8_t bCharFormat

Stop bits

uint8_t bParityType

Parity

uint8_t bDataBits

Data bits (5, 6, 7, 8 or 16).

Functions

struct _usb_host_cdc_line_coding_struct __attribute__ ((packed)) usb_host_cdc_line_coding_struct_t

USB Ethernet emulation (CDC-EEM)

namespace coralmicro
class CdcEem
#include <cdc_eem.h>

Public Functions

CdcEem() = default
CdcEem(const CdcEem&) = delete
CdcEem &operator=(const CdcEem&) = delete
void Init(uint8_t bulk_in_ep, uint8_t bulk_out_ep, uint8_t data_iface)
inline const usb_device_class_config_struct_t &config_data() const
inline const void *descriptor_data() const
inline size_t descriptor_data_size() const
inline void SetClassHandle(class_handle_t class_handle)
bool HandleEvent(uint32_t event, void *param)