summaryrefslogtreecommitdiff
path: root/util/comm-usb.h
blob: b43d1bf66f4887313d51367c6193681e331d4168 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Copyright 2022 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 *
 * Header file for a USB interface.
 */

#ifndef __UTIL_COMM_USB_H
#define __UTIL_COMM_USB_H

#include "common.h"

/**
 * Parse USB vendor ID and product ID pair (e.g. '18d1:5022').
 *
 * @param input    Input string to be parsed.
 * @param vid_ptr  Parsed vendor ID.
 * @param pid_ptr  Parsed product ID
 * @return 1 if parsed successfully or 0 on error.
 */
int parse_vidpid(const char *input, uint16_t *vid_ptr, uint16_t *pid_ptr);

/**
 * Initialize USB communication.
 *
 * @param vid  Vendor ID of the endpoint device.
 * @param pid  Product ID of the endpoint device.
 * @return     Zero if success or non-zero otherwise.
 */
int comm_init_usb(uint16_t vid, uint16_t pid);

/**
 * Clean up USB communication.
 */
void comm_usb_exit(void);

#endif /* __UTIL_COMM_USB_H */