zephyr/samples/drivers/spi_bitbang
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
..
boards samples: Remove label property from devicetree overlays 2022-08-01 17:59:32 +02:00
src includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h> 2022-09-05 16:31:47 +02:00
CMakeLists.txt cmake: Update cmake_minimum_required to 3.20.0 2022-07-04 10:18:45 +02:00
README.rst
prj.conf
sample.yaml

README.rst

.. _spi-bitbang-sample:

SPI-Bitbang Sample
####################

Overview
********

This sample demonstrates using the bitbang SPI driver. The bitbang driver can
be useful for devices which use a non multiple of 8 word size, for example some
LCDs which have an extra cmd/data bit.

This sample loops through some different spi transfer configurations.


Building and Running
********************

The application will build only for a target that has a :ref:`devicetree
<dt-guide>` entry with :dtcompatible:`zephyr,spi-bitbang` as a compatible.

You can connect the MISO and MOSI pins with a wire to provide a basic loopback
test for receive data.

.. zephyr-app-commands::
   :zephyr-app: samples/drivers/spi_bitbang
   :board: nrf52840dk_nrf52840
   :goals: build flash
   :compact:

Sample Output
=============

.. code-block:: console

  *** Booting Zephyr OS build zephyr-v2.6.0-2939-g1882b95b42e2  ***
  basic_write_9bit_words; ret: 0
    wrote 0101 00ff 00a5 0000 0102
  9bit_loopback_partial; ret: 0
   tx (i)  : 0101 0102
   tx (ii) : 0003 0004 0105
   rx (ii) : 0003 0004 0105
  basic_write_9bit_words; ret: 0
   wrote 0101 00ff 00a5 0000 0102
  9bit_loopback_partial; ret: 0
   tx (i)  : 0101 0102
   tx (ii) : 0003 0004 0105
   rx (ii) : 0003 0004 0105
  basic_write_9bit_words; ret: 0
   wrote 0101 00ff 00a5 0000 0102
  9bit_loopback_partial; ret: 0
   tx (i)  : 0101 0102
   tx (ii) : 0003 0004 0105
   rx (ii) : 0003 0004 0105