flash/nor/at91samd: Use 32-bit register writes for ST-Link compat
[fw/openocd] / src / jtag / drivers / bitbang.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /***************************************************************************
4  *   Copyright (C) 2005 by Dominic Rath                                    *
5  *   Dominic.Rath@gmx.de                                                   *
6  *                                                                         *
7  *   Copyright (C) 2007,2008 Ã˜yvind Harboe                                 *
8  *   oyvind.harboe@zylin.com                                               *
9  ***************************************************************************/
10
11 #ifndef OPENOCD_JTAG_DRIVERS_BITBANG_H
12 #define OPENOCD_JTAG_DRIVERS_BITBANG_H
13
14 #include <jtag/swd.h>
15
16 typedef enum {
17         BB_LOW,
18         BB_HIGH,
19         BB_ERROR
20 } bb_value_t;
21
22 /** Low level callbacks (for bitbang).
23  *
24  * Either read(), or sample() and read_sample() must be implemented.
25  *
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);
32
33         /** The number of TDO samples that can be buffered up before the caller has
34          * to call read_sample. */
35         size_t buf_size;
36
37         /** Sample TDO and put the result in a buffer. */
38         int (*sample)(void);
39
40         /** Return the next unread value from the buffer. */
41         bb_value_t (*read_sample)(void);
42
43         /** Set TCK, TMS, and TDI to the given values. */
44         int (*write)(int tck, int tms, int tdi);
45
46         /** Blink led (optional). */
47         int (*blink)(int on);
48
49         /** Sample SWDIO and return the value. */
50         int (*swdio_read)(void);
51
52         /** Set direction of SWDIO. */
53         void (*swdio_drive)(bool on);
54
55         /** Set SWCLK and SWDIO to the given value. */
56         int (*swd_write)(int swclk, int swdio);
57 };
58
59 extern const struct swd_driver bitbang_swd;
60
61 int bitbang_execute_queue(void);
62
63 extern struct bitbang_interface *bitbang_interface;
64
65 #endif /* OPENOCD_JTAG_DRIVERS_BITBANG_H */