Skip to content

USB ACM/UART

Defines

MIRA_IODEF_USB

#define MIRA_IODEF_USB

Types

mira_usb_uart_input_callback_t

typedef int(* mira_usb_uart_input_callback_t) (uint8_t c, void *storage);

Structs

mira_usb_config_t

Name Type Description
vendor_id unsigned short USB Vendor ID from USB-IF register
product_id unsigned short Product ID

Functions

mira_usb_uart_init

mira_status_t mira_usb_uart_init(const mira_usb_config_t *config);

Initialize a USB uart module.

The custom config is passed as a parameter (NULL for platform default).

Note

this might start a higher resolution clock in the CPU, which can significantly increase the power consumption until CPU is restarted.

Parameters

Name Description
config Pointer to a configuration to setup.

Return value

Name Description
MIRA_SUCCESS USB was successfully initialized.
MIRA_USB_ERROR_INIT USB could not initialize.
MIRA_ERROR_NOT_SUPPORTED Invalid USB id.

mira_usb_uart_set_input_callback

mira_status_t mira_usb_uart_set_input_callback(mira_usb_uart_input_callback_t cb, void *storage);

Set a callback to be called on usb byte input.

Parameters

Name Description
usb_id The index of the USB peripheral.
cb The callback to call.
storage Storage pointer which is used to store optional information to be used by the callback function. E.g. it could be used as an identifier or to pass on a configuration struct.

Return value

Name Description
MIRA_SUCCESS The callback was successfully set.

mira_usb_uart_is_connected

bool mira_usb_uart_is_connected(void);

Is the uart open?

Return value

true when the host has the uart open.

Back to top