OpenOCD
adapter.h File Reference
Include dependency graph for adapter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  adapter_gpio_config
 Configuration options for a single GPIO. More...
 

Macros

#define ADAPTER_GPIO_NOT_SET   UINT_MAX
 

Enumerations

enum  adapter_gpio_config_index {
  ADAPTER_GPIO_IDX_TDO , ADAPTER_GPIO_IDX_TDI , ADAPTER_GPIO_IDX_TMS , ADAPTER_GPIO_IDX_TCK ,
  ADAPTER_GPIO_IDX_TRST , ADAPTER_GPIO_IDX_SWDIO , ADAPTER_GPIO_IDX_SWDIO_DIR , ADAPTER_GPIO_IDX_SWCLK ,
  ADAPTER_GPIO_IDX_SRST , ADAPTER_GPIO_IDX_LED , ADAPTER_GPIO_IDX_NUM
}
 Adapter GPIO. More...
 
enum  adapter_gpio_direction { ADAPTER_GPIO_DIRECTION_INPUT , ADAPTER_GPIO_DIRECTION_OUTPUT , ADAPTER_GPIO_DIRECTION_BIDIRECTIONAL }
 Supported GPIO directions. More...
 
enum  adapter_gpio_drive_mode { ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL , ADAPTER_GPIO_DRIVE_MODE_OPEN_DRAIN , ADAPTER_GPIO_DRIVE_MODE_OPEN_SOURCE }
 Supported output drive modes for adaptor GPIO. More...
 
enum  adapter_gpio_init_state { ADAPTER_GPIO_INIT_STATE_INACTIVE , ADAPTER_GPIO_INIT_STATE_ACTIVE , ADAPTER_GPIO_INIT_STATE_INPUT }
 Supported initial states for GPIO. More...
 
enum  adapter_gpio_pull { ADAPTER_GPIO_PULL_NONE , ADAPTER_GPIO_PULL_UP , ADAPTER_GPIO_PULL_DOWN }
 Supported pull directions for GPIO. More...
 

Functions

int adapter_config_khz (unsigned int khz)
 Attempt to configure the adapter for the specified kHz. More...
 
int adapter_config_rclk (unsigned int fallback_speed_khz)
 Attempt to enable RTCK/RCLK. More...
 
const char * adapter_get_required_serial (void)
 Retrieves the serial number set with command 'adapter serial'. More...
 
int adapter_get_speed (int *speed)
 
unsigned int adapter_get_speed_khz (void)
 Retrieves the clock speed of the adapter in kHz. More...
 
int adapter_get_speed_readable (int *speed)
 Given a speed setting, use the interface speed_div callback to adjust the setting. More...
 
const struct adapter_gpio_configadapter_gpio_get_config (void)
 Retrieves gpio configuration set with command "adapter gpio <signal_name>". More...
 
const char * adapter_gpio_get_name (enum adapter_gpio_config_index idx)
 Retrieves gpio name. More...
 
int adapter_init (struct command_context *cmd_ctx)
 Initialize debug adapter upon startup. More...
 
int adapter_quit (void)
 Shutdown the debug adapter upon program exit. More...
 
int adapter_register_commands (struct command_context *ctx)
 Register the adapter's commands. More...
 
const char * adapter_usb_get_location (void)
 
bool adapter_usb_location_equal (uint8_t dev_bus, uint8_t *port_path, size_t path_len)
 
bool is_adapter_initialized (void)
 

Macro Definition Documentation

◆ ADAPTER_GPIO_NOT_SET

#define ADAPTER_GPIO_NOT_SET   UINT_MAX

Definition at line 125 of file adapter.h.

Enumeration Type Documentation

◆ adapter_gpio_config_index

Adapter GPIO.

Enumerator
ADAPTER_GPIO_IDX_TDO 
ADAPTER_GPIO_IDX_TDI 
ADAPTER_GPIO_IDX_TMS 
ADAPTER_GPIO_IDX_TCK 
ADAPTER_GPIO_IDX_TRST 
ADAPTER_GPIO_IDX_SWDIO 
ADAPTER_GPIO_IDX_SWDIO_DIR 
ADAPTER_GPIO_IDX_SWCLK 
ADAPTER_GPIO_IDX_SRST 
ADAPTER_GPIO_IDX_LED 
ADAPTER_GPIO_IDX_NUM 

Definition at line 44 of file adapter.h.

◆ adapter_gpio_direction

Supported GPIO directions.

Enumerator
ADAPTER_GPIO_DIRECTION_INPUT 
ADAPTER_GPIO_DIRECTION_OUTPUT 
ADAPTER_GPIO_DIRECTION_BIDIRECTIONAL 

Definition at line 23 of file adapter.h.

◆ adapter_gpio_drive_mode

Supported output drive modes for adaptor GPIO.

Enumerator
ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL 
ADAPTER_GPIO_DRIVE_MODE_OPEN_DRAIN 
ADAPTER_GPIO_DRIVE_MODE_OPEN_SOURCE 

Definition at line 16 of file adapter.h.

◆ adapter_gpio_init_state

Supported initial states for GPIO.

Enumerator
ADAPTER_GPIO_INIT_STATE_INACTIVE 
ADAPTER_GPIO_INIT_STATE_ACTIVE 
ADAPTER_GPIO_INIT_STATE_INPUT 

Definition at line 30 of file adapter.h.

◆ adapter_gpio_pull

Supported pull directions for GPIO.

Enumerator
ADAPTER_GPIO_PULL_NONE 
ADAPTER_GPIO_PULL_UP 
ADAPTER_GPIO_PULL_DOWN 

Definition at line 37 of file adapter.h.

Function Documentation

◆ adapter_config_khz()

int adapter_config_khz ( unsigned int  khz)

Attempt to configure the adapter for the specified kHz.

Definition at line 248 of file adapter.c.

References adapter_config, adapter_khz_to_speed(), adapter_set_speed(), CLOCK_MODE_KHZ, ERROR_OK, and LOG_DEBUG.

Referenced by adapter_init(), and COMMAND_HANDLER().

◆ adapter_config_rclk()

int adapter_config_rclk ( unsigned int  fallback_speed_khz)

Attempt to enable RTCK/RCLK.

If that fails, fallback to the specified frequency.

Definition at line 257 of file adapter.c.

References adapter_config, adapter_rclk_to_speed(), adapter_set_speed(), CLOCK_MODE_RCLK, ERROR_OK, and LOG_DEBUG.

Referenced by COMMAND_HANDLER().

◆ adapter_get_required_serial()

const char* adapter_get_required_serial ( void  )

Retrieves the serial number set with command 'adapter serial'.

Definition at line 298 of file adapter.c.

References adapter_config.

Referenced by cmsis_dap_open(), ft232r_init(), ftdi_initialize(), jlink_init(), jtag_libusb_open(), presto_jtag_init(), stlink_open(), usb_connect(), vsllink_check_usb_strings(), and xds110_show_info().

◆ adapter_get_speed()

int adapter_get_speed ( int *  speed)

◆ adapter_get_speed_khz()

◆ adapter_get_speed_readable()

int adapter_get_speed_readable ( int *  speed)

Given a speed setting, use the interface speed_div callback to adjust the setting.

Parameters
speedThe speed setting to convert back to readable kHz.
Returns
ERROR_OK if the interface has not been initialized or on success; otherwise, the error code produced by the speed_div callback.

Definition at line 283 of file adapter.c.

References adapter_get_speed(), ERROR_FAIL, ERROR_OK, is_adapter_initialized(), LOG_ERROR, and adapter_driver::speed_div.

Referenced by adapter_init(), and COMMAND_HANDLER().

◆ adapter_gpio_get_config()

const struct adapter_gpio_config* adapter_gpio_get_config ( void  )

Retrieves gpio configuration set with command "adapter gpio <signal_name>".

Definition at line 1221 of file adapter.c.

References adapter_config.

Referenced by am335xgpio_init(), bcm2835gpio_init(), and linuxgpiod_init().

◆ adapter_gpio_get_name()

const char* adapter_gpio_get_name ( enum adapter_gpio_config_index  idx)

Retrieves gpio name.

Definition at line 1215 of file adapter.c.

References gpio_map::name.

Referenced by helper_get_line(), and initialize_gpio().

◆ adapter_init()

◆ adapter_quit()

int adapter_quit ( void  )

Shutdown the debug adapter upon program exit.

Definition at line 185 of file adapter.c.

References adapter_config, ERROR_OK, is_adapter_initialized(), jtag_all_taps(), jtag_tap_free(), LOG_ERROR, jtag_tap::next_tap, and adapter_driver::quit.

Referenced by openocd_main().

◆ adapter_register_commands()

int adapter_register_commands ( struct command_context ctx)

Register the adapter's commands.

Register the adapter's commands.

Todo:
Remove internal assumptions that all debug adapters use JTAG for transport. Various types and data structures are not named generically.

Definition at line 1210 of file adapter.c.

References interface_command_handlers, NULL, and register_commands().

Referenced by setup_command_handler().

◆ adapter_usb_get_location()

const char* adapter_usb_get_location ( void  )
Returns
USB location string set with command 'adapter usb location'

Definition at line 324 of file adapter.c.

References adapter_config.

Referenced by adapter_usb_location_equal(), ftdi_initialize(), jlink_open_device(), and jtag_libusb_open().

◆ adapter_usb_location_equal()

bool adapter_usb_location_equal ( uint8_t  dev_bus,
uint8_t *  port_path,
size_t  path_len 
)
Returns
true if USB location string is "<dev_bus>-<port_path[0]>[.<port_path[1]>[...]]"

Definition at line 329 of file adapter.c.

References adapter_usb_get_location(), LOG_WARNING, NULL, strndup(), strnlen(), and USB_MAX_LOCATION_LENGTH.

Referenced by jlink_usb_location_equal().

◆ is_adapter_initialized()

bool is_adapter_initialized ( void  )
Returns
true if adapter has been initialized

Definition at line 69 of file adapter.c.

References adapter_config.

Referenced by adapter_get_speed_readable(), adapter_init(), adapter_khz_to_speed(), adapter_quit(), adapter_set_speed(), default_interface_jtag_execute_queue(), and jtag_power_dropout().