libnx  v4.2.0
usb_comms.h
Go to the documentation of this file.
1 /**
2  * @file usb_comms.h
3  * @brief USB comms.
4  * @author yellows8
5  * @author plutoo
6  * @copyright libnx Authors
7  */
8 #pragma once
9 #include "../../types.h"
10 
11 typedef struct {
12  u8 bInterfaceClass;
13  u8 bInterfaceSubClass;
14  u8 bInterfaceProtocol;
16 
17 /// Initializes usbComms with the default number of interfaces (1)
19 
20 /// Initializes usbComms with a specific number of interfaces.
21 Result usbCommsInitializeEx(u32 num_interfaces, const UsbCommsInterfaceInfo *infos);
22 
23 /// Exits usbComms.
24 void usbCommsExit(void);
25 
26 /// Sets whether to throw a fatal error in usbComms{Read/Write}* on failure, or just return the transferred size. By default (false) the latter is used.
27 void usbCommsSetErrorHandling(bool flag);
28 
29 /// Read data with the default interface.
30 size_t usbCommsRead(void* buffer, size_t size);
31 
32 /// Write data with the default interface.
33 size_t usbCommsWrite(const void* buffer, size_t size);
34 
35 /// Same as usbCommsRead except with the specified interface.
36 size_t usbCommsReadEx(void* buffer, size_t size, u32 interface);
37 
38 /// Same as usbCommsWrite except with the specified interface.
39 size_t usbCommsWriteEx(const void* buffer, size_t size, u32 interface);
usbCommsReadEx
size_t usbCommsReadEx(void *buffer, size_t size, u32 interface)
Same as usbCommsRead except with the specified interface.
u8
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
usbCommsExit
void usbCommsExit(void)
Exits usbComms.
usbCommsWrite
size_t usbCommsWrite(const void *buffer, size_t size)
Write data with the default interface.
usbCommsInitialize
Result usbCommsInitialize(void)
Initializes usbComms with the default number of interfaces (1)
u32
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21
usbCommsWriteEx
size_t usbCommsWriteEx(const void *buffer, size_t size, u32 interface)
Same as usbCommsWrite except with the specified interface.
usbCommsRead
size_t usbCommsRead(void *buffer, size_t size)
Read data with the default interface.
Result
u32 Result
Function error code result type.
Definition: types.h:44
usbCommsSetErrorHandling
void usbCommsSetErrorHandling(bool flag)
Sets whether to throw a fatal error in usbComms{Read/Write}* on failure, or just return the transferr...
usbCommsInitializeEx
Result usbCommsInitializeEx(u32 num_interfaces, const UsbCommsInterfaceInfo *infos)
Initializes usbComms with a specific number of interfaces.
UsbCommsInterfaceInfo
Definition: usb_comms.h:11