1.. zephyr:code-sample:: spi-bitbang
2   :name: SPI bitbang
3   :relevant-api: spi_interface
4
5   Use the bitbang SPI driver for communicating with a slave.
6
7Overview
8********
9
10This sample demonstrates using the bitbang SPI driver. The bitbang driver can
11be useful for devices which use a non multiple of 8 word size, for example some
12LCDs which have an extra cmd/data bit.
13
14This sample loops through some different spi transfer configurations.
15
16
17Building and Running
18********************
19
20The application will build only for a target that has a :ref:`devicetree
21<dt-guide>` entry with :dtcompatible:`zephyr,spi-bitbang` as a compatible.
22
23You can connect the MISO and MOSI pins with a wire to provide a basic loopback
24test for receive data.
25
26.. zephyr-app-commands::
27   :zephyr-app: samples/drivers/spi_bitbang
28   :board: nrf52840dk_nrf52840
29   :goals: build flash
30   :compact:
31
32Sample Output
33=============
34
35.. code-block:: console
36
37  *** Booting Zephyr OS build zephyr-v2.6.0-2939-g1882b95b42e2  ***
38  basic_write_9bit_words; ret: 0
39    wrote 0101 00ff 00a5 0000 0102
40  9bit_loopback_partial; ret: 0
41   tx (i)  : 0101 0102
42   tx (ii) : 0003 0004 0105
43   rx (ii) : 0003 0004 0105
44  basic_write_9bit_words; ret: 0
45   wrote 0101 00ff 00a5 0000 0102
46  9bit_loopback_partial; ret: 0
47   tx (i)  : 0101 0102
48   tx (ii) : 0003 0004 0105
49   rx (ii) : 0003 0004 0105
50  basic_write_9bit_words; ret: 0
51   wrote 0101 00ff 00a5 0000 0102
52  9bit_loopback_partial; ret: 0
53   tx (i)  : 0101 0102
54   tx (ii) : 0003 0004 0105
55   rx (ii) : 0003 0004 0105
56