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 
19 };
20 
26 };
27 
30  ADAPTER_GPIO_INIT_STATE_INACTIVE, /* Should be zero so it is the default state */
33 };
34 
40 };
41 
54  ADAPTER_GPIO_IDX_NUM, /* must be the last item */
55 };
56 
59  int gpio_num;
60  int chip_num;
61  enum adapter_gpio_drive_mode drive; /* For outputs only */
63  bool active_low;
65 };
66 
67 struct command_context;
68 
71 
73 int adapter_init(struct command_context *cmd_ctx);
74 
76 int adapter_quit(void);
77 
79 bool is_adapter_initialized(void);
80 
82 const char *adapter_usb_get_location(void);
83 
85 bool adapter_usb_location_equal(uint8_t dev_bus, uint8_t *port_path, size_t path_len);
86 
88 int adapter_get_speed(int *speed);
89 
97 int adapter_get_speed_readable(int *speed);
98 
100 int adapter_config_khz(unsigned int khz);
101 
106 int adapter_config_rclk(unsigned int fallback_speed_khz);
107 
109 unsigned int adapter_get_speed_khz(void);
110 
112 const char *adapter_get_required_serial(void);
113 
118 
122 const struct adapter_gpio_config *adapter_gpio_get_config(void);
123 
124 #endif /* OPENOCD_JTAG_ADAPTER_H */
int adapter_config_rclk(unsigned int fallback_speed_khz)
Attempt to enable RTCK/RCLK.
Definition: adapter.c:258
adapter_gpio_init_state
Supported initial states for GPIO.
Definition: adapter.h:29
@ ADAPTER_GPIO_INIT_STATE_ACTIVE
Definition: adapter.h:31
@ ADAPTER_GPIO_INIT_STATE_INPUT
Definition: adapter.h:32
@ ADAPTER_GPIO_INIT_STATE_INACTIVE
Definition: adapter.h:30
const char * adapter_get_required_serial(void)
Retrieves the serial number set with command 'adapter serial'.
Definition: adapter.c:299
bool adapter_usb_location_equal(uint8_t dev_bus, uint8_t *port_path, size_t path_len)
Definition: adapter.c:330
const struct adapter_gpio_config * adapter_gpio_get_config(void)
Retrieves gpio configuration set with command "adapter gpio <signal_name>".
Definition: adapter.c:1223
int adapter_get_speed(int *speed)
Definition: adapter.c:268
bool is_adapter_initialized(void)
Definition: adapter.c:73
int adapter_quit(void)
Shutdown the debug adapter upon program exit.
Definition: adapter.c:186
unsigned int adapter_get_speed_khz(void)
Retrieves the clock speed of the adapter in kHz.
Definition: adapter.c:208
adapter_gpio_config_index
Adapter GPIO.
Definition: adapter.h:43
@ ADAPTER_GPIO_IDX_LED
Definition: adapter.h:53
@ ADAPTER_GPIO_IDX_NUM
Definition: adapter.h:54
@ ADAPTER_GPIO_IDX_SWCLK
Definition: adapter.h:51
@ ADAPTER_GPIO_IDX_SWDIO_DIR
Definition: adapter.h:50
@ ADAPTER_GPIO_IDX_SRST
Definition: adapter.h:52
@ ADAPTER_GPIO_IDX_TRST
Definition: adapter.h:48
@ ADAPTER_GPIO_IDX_TDI
Definition: adapter.h:45
@ ADAPTER_GPIO_IDX_TMS
Definition: adapter.h:46
@ ADAPTER_GPIO_IDX_TCK
Definition: adapter.h:47
@ ADAPTER_GPIO_IDX_TDO
Definition: adapter.h:44
@ ADAPTER_GPIO_IDX_SWDIO
Definition: adapter.h:49
adapter_gpio_direction
Supported GPIO directions.
Definition: adapter.h:22
@ ADAPTER_GPIO_DIRECTION_OUTPUT
Definition: adapter.h:24
@ ADAPTER_GPIO_DIRECTION_INPUT
Definition: adapter.h:23
@ ADAPTER_GPIO_DIRECTION_BIDIRECTIONAL
Definition: adapter.h:25
adapter_gpio_pull
Supported pull directions for GPIO.
Definition: adapter.h:36
@ ADAPTER_GPIO_PULL_UP
Definition: adapter.h:38
@ ADAPTER_GPIO_PULL_DOWN
Definition: adapter.h:39
@ ADAPTER_GPIO_PULL_NONE
Definition: adapter.h:37
int adapter_get_speed_readable(int *speed)
Given a speed setting, use the interface speed_div callback to adjust the setting.
Definition: adapter.c:284
const char * adapter_usb_get_location(void)
Definition: adapter.c:325
int adapter_register_commands(struct command_context *ctx)
Register the adapter's commands.
Definition: adapter.c:1212
int adapter_init(struct command_context *cmd_ctx)
Initialize debug adapter upon startup.
Definition: adapter.c:123
int adapter_config_khz(unsigned int khz)
Attempt to configure the adapter for the specified kHz.
Definition: adapter.c:249
adapter_gpio_drive_mode
Supported output drive modes for adaptor GPIO.
Definition: adapter.h:15
@ ADAPTER_GPIO_DRIVE_MODE_OPEN_SOURCE
Definition: adapter.h:18
@ ADAPTER_GPIO_DRIVE_MODE_OPEN_DRAIN
Definition: adapter.h:17
@ ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL
Definition: adapter.h:16
const char * adapter_gpio_get_name(enum adapter_gpio_config_index idx)
Retrieves gpio name.
Definition: adapter.c:1217
Configuration options for a single GPIO.
Definition: adapter.h:58
enum adapter_gpio_pull pull
Definition: adapter.h:64
enum adapter_gpio_init_state init_state
Definition: adapter.h:62
enum adapter_gpio_drive_mode drive
Definition: adapter.h:61