1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
5 * Copyright (C) 2007,2008 Øyvind Harboe *
6 * oyvind.harboe@zylin.com *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
20 ***************************************************************************/
22 #ifndef OPENOCD_JTAG_DRIVERS_BITBANG_H
23 #define OPENOCD_JTAG_DRIVERS_BITBANG_H
33 /** Low level callbacks (for bitbang).
35 * Either read(), or sample() and read_sample() must be implemented.
37 * The sample functions allow an interface to batch a number of writes and
38 * sample requests together. Not waiting for a value to come back can greatly
39 * increase throughput. */
40 struct bitbang_interface {
41 /** Sample TDO and return the value. */
42 bb_value_t (*read)(void);
44 /** The number of TDO samples that can be buffered up before the caller has
45 * to call read_sample. */
48 /** Sample TDO and put the result in a buffer. */
51 /** Return the next unread value from the buffer. */
52 bb_value_t (*read_sample)(void);
54 /** Set TCK, TMS, and TDI to the given values. */
55 int (*write)(int tck, int tms, int tdi);
57 /** Blink led (optional). */
60 /** Sample SWDIO and return the value. */
61 int (*swdio_read)(void);
63 /** Set direction of SWDIO. */
64 void (*swdio_drive)(bool on);
66 /** Set SWCLK and SWDIO to the given value. */
67 int (*swd_write)(int swclk, int swdio);
70 extern const struct swd_driver bitbang_swd;
72 int bitbang_execute_queue(void);
74 extern struct bitbang_interface *bitbang_interface;
76 #endif /* OPENOCD_JTAG_DRIVERS_BITBANG_H */