OpenOCD
usbtopwr.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2009 - 2010 by Simon Qian <SimonQian@SimonQian.com> *
5  ***************************************************************************/
6 
7 #ifdef HAVE_CONFIG_H
8 #include "config.h"
9 #endif
10 
11 #include <string.h>
12 
13 #include "../versaloon_include.h"
14 #include "../versaloon.h"
15 #include "../versaloon_internal.h"
16 #include "usbtoxxx.h"
17 #include "usbtoxxx_internal.h"
18 
19 RESULT usbtopwr_init(uint8_t interface_index)
20 {
21  return usbtoxxx_init_command(USB_TO_POWER, interface_index);
22 }
23 
24 RESULT usbtopwr_fini(uint8_t interface_index)
25 {
26  return usbtoxxx_fini_command(USB_TO_POWER, interface_index);
27 }
28 
29 RESULT usbtopwr_config(uint8_t interface_index)
30 {
31 #if PARAM_CHECK
32  if (interface_index > 7) {
33  LOG_BUG(ERRMSG_INVALID_INTERFACE_NUM, interface_index);
34  return ERROR_FAIL;
35  }
36 #endif
37 
38  return usbtoxxx_conf_command(USB_TO_POWER, interface_index, NULL, 0);
39 }
40 
41 RESULT usbtopwr_output(uint8_t interface_index, uint16_t millivolt)
42 {
43 #if PARAM_CHECK
44  if (interface_index > 7) {
45  LOG_BUG(ERRMSG_INVALID_INTERFACE_NUM, interface_index);
46  return ERROR_FAIL;
47  }
48 #endif
49 
50  return usbtoxxx_out_command(USB_TO_POWER, interface_index, (uint8_t *)&millivolt,
51  2, 0);
52 }
#define ERROR_FAIL
Definition: log.h:161
#define NULL
Definition: usb.h:16
RESULT usbtopwr_init(uint8_t interface_index)
Definition: usbtopwr.c:19
RESULT usbtopwr_fini(uint8_t interface_index)
Definition: usbtopwr.c:24
RESULT usbtopwr_output(uint8_t interface_index, uint16_t millivolt)
Definition: usbtopwr.c:41
RESULT usbtopwr_config(uint8_t interface_index)
Definition: usbtopwr.c:29
#define usbtoxxx_conf_command(type, port, cmdbuf, cmdlen)
#define usbtoxxx_init_command(type, port)
#define USB_TO_POWER
#define usbtoxxx_out_command(type, port, cmdbuf, cmdlen, c)
#define usbtoxxx_fini_command(type, port)
#define RESULT
#define ERRMSG_INVALID_INTERFACE_NUM
#define LOG_BUG