hal_spi.dox 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @defgroup SPI SPI Driver
  15. * @brief Generic SPI Driver.
  16. * @details This module implements a generic SPI (Serial Peripheral Interface)
  17. * driver allowing bidirectional and monodirectional transfers,
  18. * complex atomic transactions are supported as well.
  19. * @pre In order to use the SPI driver the @p HAL_USE_SPI option
  20. * must be enabled in @p halconf.h.
  21. *
  22. * @section spi_1 Driver State Machine
  23. * The driver implements a state machine internally, not all the driver
  24. * functionalities can be used in any moment, any transition not explicitly
  25. * shown in the following diagram has to be considered an error and shall
  26. * be captured by an assertion (if enabled).
  27. * @if LATEX_PDF
  28. * @dot
  29. digraph example {
  30. size="5, 7";
  31. rankdir="LR";
  32. node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true",
  33. width="0.9", height="0.9"];
  34. edge [fontname=Helvetica, fontsize=8];
  35. stop [label="SPI_STOP\nLow Power"];
  36. uninit [label="SPI_UNINIT", style="bold"];
  37. ready [label="SPI_READY\nClock Enabled"];
  38. active [label="SPI_ACTIVE\nBus Active"];
  39. complete [label="SPI_COMPLETE\nComplete"];
  40. uninit -> stop [label="\n spiInit()", constraint=false];
  41. stop -> ready [label="\nspiStart()"];
  42. ready -> ready [label="\nspiSelect()\nspiUnselect()\nspiStart()"];
  43. ready -> stop [label="\nspiStop()"];
  44. stop -> stop [label="\nspiStop()"];
  45. ready -> active [label="\nspiStartXXXI() (async)\nspiXXX() (sync)"];
  46. active -> ready [label="\nsync return"];
  47. active -> complete [label="\nasync callback\n>spc_endcb<"];
  48. complete -> active [label="\nspiStartXXXI() (async)\nthen\ncallback return"];
  49. complete -> ready [label="\ncallback return"];
  50. }
  51. * @enddot
  52. * @else
  53. * @dot
  54. digraph example {
  55. rankdir="LR";
  56. node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.9", height="0.9"];
  57. edge [fontname=Helvetica, fontsize=8];
  58. stop [label="SPI_STOP\nLow Power"];
  59. uninit [label="SPI_UNINIT", style="bold"];
  60. ready [label="SPI_READY\nClock Enabled"];
  61. active [label="SPI_ACTIVE\nBus Active"];
  62. complete [label="SPI_COMPLETE\nComplete"];
  63. uninit -> stop [label="\n spiInit()", constraint=false];
  64. stop -> ready [label="\nspiStart()"];
  65. ready -> ready [label="\nspiSelect()\nspiUnselect()\nspiStart()"];
  66. ready -> stop [label="\nspiStop()"];
  67. stop -> stop [label="\nspiStop()"];
  68. ready -> active [label="\nspiStartXXX() (async)\nspiXXX() (sync)"];
  69. active -> ready [label="\nsync return"];
  70. active -> complete [label="\nasync callback\n>spc_endcb<"];
  71. complete -> active [label="\nspiStartXXXI() (async)\nthen\ncallback return"];
  72. complete -> ready [label="\ncallback return"];
  73. }
  74. * @enddot
  75. * @endif
  76. *
  77. * The driver is not thread safe for performance reasons, if you need to access
  78. * the SPI bus from multiple threads then use the @p spiAcquireBus() and
  79. * @p spiReleaseBus() APIs in order to gain exclusive access.
  80. *
  81. * @ingroup HAL_NORMAL_DRIVERS
  82. */