1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Copyright (C) 2005 by Dominic Rath *
5 * Dominic.Rath@gmx.de *
7 * Copyright (C) 2007,2008 Øyvind Harboe *
8 * oyvind.harboe@zylin.com *
9 ***************************************************************************/
11 #ifndef OPENOCD_JTAG_DRIVERS_BITBANG_H
12 #define OPENOCD_JTAG_DRIVERS_BITBANG_H
22 /** Low level callbacks (for bitbang).
24 * Either read(), or sample() and read_sample() must be implemented.
26 * The sample functions allow an interface to batch a number of writes and
27 * sample requests together. Not waiting for a value to come back can greatly
28 * increase throughput. */
29 struct bitbang_interface {
30 /** Sample TDO and return the value. */
31 bb_value_t (*read)(void);
33 /** The number of TDO samples that can be buffered up before the caller has
34 * to call read_sample. */
37 /** Sample TDO and put the result in a buffer. */
40 /** Return the next unread value from the buffer. */
41 bb_value_t (*read_sample)(void);
43 /** Set TCK, TMS, and TDI to the given values. */
44 int (*write)(int tck, int tms, int tdi);
46 /** Blink led (optional). */
49 /** Sample SWDIO and return the value. */
50 int (*swdio_read)(void);
52 /** Set direction of SWDIO. */
53 void (*swdio_drive)(bool on);
55 /** Set SWCLK and SWDIO to the given value. */
56 int (*swd_write)(int swclk, int swdio);
59 extern const struct swd_driver bitbang_swd;
61 int bitbang_execute_queue(void);
63 extern struct bitbang_interface *bitbang_interface;
65 #endif /* OPENOCD_JTAG_DRIVERS_BITBANG_H */