hal_wspi_lld.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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_wspi_lld.c
  15. * @brief PLATFORM WSPI subsystem low level driver source.
  16. *
  17. * @addtogroup WSPI
  18. * @{
  19. */
  20. #include "hal.h"
  21. #if (HAL_USE_WSPI == TRUE) || defined(__DOXYGEN__)
  22. /*===========================================================================*/
  23. /* Driver local definitions. */
  24. /*===========================================================================*/
  25. /*===========================================================================*/
  26. /* Driver exported variables. */
  27. /*===========================================================================*/
  28. /** @brief WSPID1 driver identifier.*/
  29. #if (PLATFORM_WSPI_USE_WSPI1 == TRUE) || defined(__DOXYGEN__)
  30. WSPIDriver WSPID1;
  31. #endif
  32. /*===========================================================================*/
  33. /* Driver local variables and types. */
  34. /*===========================================================================*/
  35. /*===========================================================================*/
  36. /* Driver local functions. */
  37. /*===========================================================================*/
  38. /*===========================================================================*/
  39. /* Driver interrupt handlers. */
  40. /*===========================================================================*/
  41. /*===========================================================================*/
  42. /* Driver exported functions. */
  43. /*===========================================================================*/
  44. /**
  45. * @brief Low level WSPI driver initialization.
  46. *
  47. * @notapi
  48. */
  49. void wspi_lld_init(void) {
  50. #if PLATFORM_WSPI_USE_WSPI1
  51. wspiObjectInit(&WSPID1);
  52. #endif
  53. }
  54. /**
  55. * @brief Configures and activates the WSPI peripheral.
  56. *
  57. * @param[in] wspip pointer to the @p WSPIDriver object
  58. *
  59. * @notapi
  60. */
  61. void wspi_lld_start(WSPIDriver *wspip) {
  62. /* If in stopped state then full initialization.*/
  63. if (wspip->state == WSPI_STOP) {
  64. #if PLATFORM_WSPI_USE_WSPI1
  65. if (&WSPID1 == wspip) {
  66. }
  67. #endif
  68. /* Common initializations.*/
  69. }
  70. /* WSPI setup and enable.*/
  71. }
  72. /**
  73. * @brief Deactivates the WSPI peripheral.
  74. *
  75. * @param[in] wspip pointer to the @p WSPIDriver object
  76. *
  77. * @notapi
  78. */
  79. void wspi_lld_stop(WSPIDriver *wspip) {
  80. /* If in ready state then disables WSPI.*/
  81. if (wspip->state == WSPI_READY) {
  82. /* WSPI disable.*/
  83. /* Stopping involved clocks.*/
  84. #if PLATFORM_WSPI_USE_WSPI1
  85. if (&WSPID1 == wspip) {
  86. }
  87. #endif
  88. }
  89. }
  90. /**
  91. * @brief Sends a command without data phase.
  92. * @post At the end of the operation the configured callback is invoked.
  93. *
  94. * @param[in] wspip pointer to the @p WSPIDriver object
  95. * @param[in] cmdp pointer to the command descriptor
  96. *
  97. * @notapi
  98. */
  99. void wspi_lld_command(WSPIDriver *wspip, const wspi_command_t *cmdp) {
  100. (void)wspip;
  101. (void)cmdp;
  102. }
  103. /**
  104. * @brief Sends a command with data over the WSPI bus.
  105. * @post At the end of the operation the configured callback is invoked.
  106. *
  107. * @param[in] wspip pointer to the @p WSPIDriver object
  108. * @param[in] cmdp pointer to the command descriptor
  109. * @param[in] n number of bytes to send
  110. * @param[in] txbuf the pointer to the transmit buffer
  111. *
  112. * @notapi
  113. */
  114. void wspi_lld_send(WSPIDriver *wspip, const wspi_command_t *cmdp,
  115. size_t n, const uint8_t *txbuf) {
  116. (void)wspip;
  117. (void)cmdp;
  118. (void)n;
  119. (void)txbuf;
  120. }
  121. /**
  122. * @brief Sends a command then receives data over the WSPI bus.
  123. * @post At the end of the operation the configured callback is invoked.
  124. *
  125. * @param[in] wspip pointer to the @p WSPIDriver object
  126. * @param[in] cmdp pointer to the command descriptor
  127. * @param[in] n number of bytes to send
  128. * @param[out] rxbuf the pointer to the receive buffer
  129. *
  130. * @notapi
  131. */
  132. void wspi_lld_receive(WSPIDriver *wspip, const wspi_command_t *cmdp,
  133. size_t n, uint8_t *rxbuf) {
  134. (void)wspip;
  135. (void)cmdp;
  136. (void)n;
  137. (void)rxbuf;
  138. }
  139. #if (WSPI_SUPPORTS_MEMMAP == TRUE) || defined(__DOXYGEN__)
  140. /**
  141. * @brief Maps in memory space a WSPI flash device.
  142. * @pre The memory flash device must be initialized appropriately
  143. * before mapping it in memory space.
  144. *
  145. * @param[in] wspip pointer to the @p WSPIDriver object
  146. * @param[in] cmdp pointer to the command descriptor
  147. * @param[out] addrp pointer to the memory start address of the mapped
  148. * flash or @p NULL
  149. *
  150. * @notapi
  151. */
  152. void wspi_lld_map_flash(WSPIDriver *wspip,
  153. const wspi_command_t *cmdp,
  154. uint8_t **addrp) {
  155. (void)wspip;
  156. (void)cmdp;
  157. (void)addrp;
  158. }
  159. /**
  160. * @brief Unmaps from memory space a WSPI flash device.
  161. * @post The memory flash device must be re-initialized for normal
  162. * commands exchange.
  163. *
  164. * @param[in] wspip pointer to the @p WSPIDriver object
  165. *
  166. * @notapi
  167. */
  168. void wspi_lld_unmap_flash(WSPIDriver *wspip) {
  169. (void)wspip;
  170. }
  171. #endif /* WSPI_SUPPORTS_MEMMAP == TRUE */
  172. #endif /* HAL_USE_WSPI */
  173. /** @} */