OpenOCD
adapter.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (C) 2005 by Dominic Rath <Dominic.Rath@gmx.de>
4  * Copyright (c) 2018 Pengutronix, Oleksij Rempel <kernel@pengutronix.de>
5  */
6 
7 #ifndef OPENOCD_JTAG_ADAPTER_H
8 #define OPENOCD_JTAG_ADAPTER_H
9 
10 #include <stdbool.h>
11 #include <stddef.h>
12 #include <stdint.h>
13 #include <limits.h>
14 
20 };
21 
27 };
28 
31  ADAPTER_GPIO_INIT_STATE_INACTIVE, /* Should be zero so it is the default state */
34 };
35 
41 };
42 
55  ADAPTER_GPIO_IDX_NUM, /* must be the last item */
56 };
57 
60  unsigned int gpio_num;
61  unsigned int chip_num;
62  enum adapter_gpio_drive_mode drive; /* For outputs only */
64  bool active_low;
66 };
67 
68 struct command_context;
69 
72 
74 int adapter_init(struct command_context *cmd_ctx);
75 
77 int adapter_quit(void);
78 
80 bool is_adapter_initialized(void);
81 
83 const char *adapter_usb_get_location(void);
84 
86 bool adapter_usb_location_equal(uint8_t dev_bus, uint8_t *port_path, size_t path_len);
87 
89 int adapter_get_speed(int *speed);
90 
98 int adapter_get_speed_readable(int *speed);
99 
101 int adapter_config_khz(unsigned int khz);
102 
107 int adapter_config_rclk(unsigned int fallback_speed_khz);
108 
110 unsigned int adapter_get_speed_khz(void);
111 
113 const char *adapter_get_required_serial(void);
114 
119 
123 const struct adapter_gpio_config *adapter_gpio_get_config(void);
124 
125 #define ADAPTER_GPIO_NOT_SET UINT_MAX
126 
127 #endif /* OPENOCD_JTAG_ADAPTER_H */
int adapter_config_rclk(unsigned int fallback_speed_khz)
Attempt to enable RTCK/RCLK.
Definition: adapter.c:257
adapter_gpio_init_state
Supported initial states for GPIO.
Definition: adapter.h:30
@ ADAPTER_GPIO_INIT_STATE_ACTIVE
Definition: adapter.h:32
@ ADAPTER_GPIO_INIT_STATE_INPUT
Definition: adapter.h:33
@ ADAPTER_GPIO_INIT_STATE_INACTIVE
Definition: adapter.h:31
const char * adapter_get_required_serial(void)
Retrieves the serial number set with command 'adapter serial'.
Definition: adapter.c:298
bool adapter_usb_location_equal(uint8_t dev_bus, uint8_t *port_path, size_t path_len)
Definition: adapter.c:329
const struct adapter_gpio_config * adapter_gpio_get_config(void)
Retrieves gpio configuration set with command "adapter gpio <signal_name>".
Definition: adapter.c:1221
int adapter_get_speed(int *speed)
Definition: adapter.c:267
bool is_adapter_initialized(void)
Definition: adapter.c:69
int adapter_quit(void)
Shutdown the debug adapter upon program exit.
Definition: adapter.c:185
unsigned int adapter_get_speed_khz(void)
Retrieves the clock speed of the adapter in kHz.
Definition: adapter.c:207
adapter_gpio_config_index
Adapter GPIO.
Definition: adapter.h:44
@ ADAPTER_GPIO_IDX_LED
Definition: adapter.h:54
@ ADAPTER_GPIO_IDX_NUM
Definition: adapter.h:55
@ ADAPTER_GPIO_IDX_SWCLK
Definition: adapter.h:52
@ ADAPTER_GPIO_IDX_SWDIO_DIR
Definition: adapter.h:51
@ ADAPTER_GPIO_IDX_SRST
Definition: adapter.h:53
@ ADAPTER_GPIO_IDX_TRST
Definition: adapter.h:49
@ ADAPTER_GPIO_IDX_TDI
Definition: adapter.h:46
@ ADAPTER_GPIO_IDX_TMS
Definition: adapter.h:47
@ ADAPTER_GPIO_IDX_TCK
Definition: adapter.h:48
@ ADAPTER_GPIO_IDX_TDO
Definition: adapter.h:45
@ ADAPTER_GPIO_IDX_SWDIO
Definition: adapter.h:50
adapter_gpio_direction
Supported GPIO directions.
Definition: adapter.h:23
@ ADAPTER_GPIO_DIRECTION_OUTPUT
Definition: adapter.h:25
@ ADAPTER_GPIO_DIRECTION_INPUT
Definition: adapter.h:24
@ ADAPTER_GPIO_DIRECTION_BIDIRECTIONAL
Definition: adapter.h:26
adapter_gpio_pull
Supported pull directions for GPIO.
Definition: adapter.h:37
@ ADAPTER_GPIO_PULL_UP
Definition: adapter.h:39
@ ADAPTER_GPIO_PULL_DOWN
Definition: adapter.h:40
@ ADAPTER_GPIO_PULL_NONE
Definition: adapter.h:38
int adapter_get_speed_readable(int *speed)
Given a speed setting, use the interface speed_div callback to adjust the setting.
Definition: adapter.c:283
const char * adapter_usb_get_location(void)
Definition: adapter.c:324
int adapter_register_commands(struct command_context *ctx)
Register the adapter's commands.
Definition: adapter.c:1210
int adapter_init(struct command_context *cmd_ctx)
Initialize debug adapter upon startup.
Definition: adapter.c:120
int adapter_config_khz(unsigned int khz)
Attempt to configure the adapter for the specified kHz.
Definition: adapter.c:248
adapter_gpio_drive_mode
Supported output drive modes for adaptor GPIO.
Definition: adapter.h:16
@ ADAPTER_GPIO_DRIVE_MODE_OPEN_SOURCE
Definition: adapter.h:19
@ ADAPTER_GPIO_DRIVE_MODE_OPEN_DRAIN
Definition: adapter.h:18
@ ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL
Definition: adapter.h:17
const char * adapter_gpio_get_name(enum adapter_gpio_config_index idx)
Retrieves gpio name.
Definition: adapter.c:1215
Configuration options for a single GPIO.
Definition: adapter.h:59
unsigned int gpio_num
Definition: adapter.h:60
unsigned int chip_num
Definition: adapter.h:61
enum adapter_gpio_pull pull
Definition: adapter.h:65
enum adapter_gpio_init_state init_state
Definition: adapter.h:63
enum adapter_gpio_drive_mode drive
Definition: adapter.h:62