hal_spi_lld.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. * @file hal_spi_lld.h
  15. * @brief PLATFORM SPI subsystem low level driver header.
  16. *
  17. * @addtogroup SPI
  18. * @{
  19. */
  20. #ifndef HAL_SPI_LLD_H
  21. #define HAL_SPI_LLD_H
  22. #if (HAL_USE_SPI == TRUE) || defined(__DOXYGEN__)
  23. /*===========================================================================*/
  24. /* Driver constants. */
  25. /*===========================================================================*/
  26. /**
  27. * @brief Circular mode support flag.
  28. */
  29. #define SPI_SUPPORTS_CIRCULAR TRUE
  30. /*===========================================================================*/
  31. /* Driver pre-compile time settings. */
  32. /*===========================================================================*/
  33. /**
  34. * @name PLATFORM configuration options
  35. * @{
  36. */
  37. /**
  38. * @brief SPI1 driver enable switch.
  39. * @details If set to @p TRUE the support for SPI1 is included.
  40. * @note The default is @p FALSE.
  41. */
  42. #if !defined(PLATFORM_SPI_USE_SPI1) || defined(__DOXYGEN__)
  43. #define PLATFORM_SPI_USE_SPI1 FALSE
  44. #endif
  45. /** @} */
  46. /*===========================================================================*/
  47. /* Derived constants and error checks. */
  48. /*===========================================================================*/
  49. /*===========================================================================*/
  50. /* Driver data structures and types. */
  51. /*===========================================================================*/
  52. /*===========================================================================*/
  53. /* Driver macros. */
  54. /*===========================================================================*/
  55. /**
  56. * @brief Low level fields of the SPI driver structure.
  57. */
  58. #define spi_lld_driver_fields \
  59. /* Dummy field, it is not needed.*/ \
  60. uint32_t dummy
  61. /**
  62. * @brief Low level fields of the SPI configuration structure.
  63. */
  64. #define spi_lld_config_fields \
  65. /* Dummy configuration, it is not needed.*/ \
  66. uint32_t dummy
  67. /*===========================================================================*/
  68. /* External declarations. */
  69. /*===========================================================================*/
  70. #if (PLATFORM_SPI_USE_SPI1 == TRUE) && !defined(__DOXYGEN__)
  71. extern SPIDriver SPID1;
  72. #endif
  73. #ifdef __cplusplus
  74. extern "C" {
  75. #endif
  76. void spi_lld_init(void);
  77. void spi_lld_start(SPIDriver *spip);
  78. void spi_lld_stop(SPIDriver *spip);
  79. #if (SPI_SELECT_MODE == SPI_SELECT_MODE_LLD) || defined(__DOXYGEN__)
  80. void spi_lld_select(SPIDriver *spip);
  81. void spi_lld_unselect(SPIDriver *spip);
  82. #endif
  83. void spi_lld_select(SPIDriver *spip);
  84. void spi_lld_unselect(SPIDriver *spip);
  85. void spi_lld_ignore(SPIDriver *spip, size_t n);
  86. void spi_lld_exchange(SPIDriver *spip, size_t n,
  87. const void *txbuf, void *rxbuf);
  88. void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf);
  89. void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf);
  90. #if (SPI_SUPPORTS_CIRCULAR == TRUE) || defined(__DOXYGEN__)
  91. void spi_lld_abort(SPIDriver *spip);
  92. #endif
  93. uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame);
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #endif /* HAL_USE_SPI == TRUE */
  98. #endif /* HAL_SPI_LLD_H */
  99. /** @} */