hal_sdc_lld.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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_sdc_lld.c
  15. * @brief PLATFORM SDC subsystem low level driver source.
  16. *
  17. * @addtogroup SDC
  18. * @{
  19. */
  20. #include "hal.h"
  21. #if (HAL_USE_SDC == TRUE) || defined(__DOXYGEN__)
  22. /*===========================================================================*/
  23. /* Driver local definitions. */
  24. /*===========================================================================*/
  25. /*===========================================================================*/
  26. /* Driver exported variables. */
  27. /*===========================================================================*/
  28. /**
  29. * @brief SDCD1 driver identifier.
  30. */
  31. #if (PLATFORM_SDC_USE_SDC1 == TRUE) || defined(__DOXYGEN__)
  32. SDCDriver SDCD1;
  33. #endif
  34. /*===========================================================================*/
  35. /* Driver local variables and types. */
  36. /*===========================================================================*/
  37. /*===========================================================================*/
  38. /* Driver local functions. */
  39. /*===========================================================================*/
  40. /*===========================================================================*/
  41. /* Driver interrupt handlers. */
  42. /*===========================================================================*/
  43. /*===========================================================================*/
  44. /* Driver exported functions. */
  45. /*===========================================================================*/
  46. /**
  47. * @brief Low level SDC driver initialization.
  48. *
  49. * @notapi
  50. */
  51. void sdc_lld_init(void) {
  52. #if PLATFORM_SDC_USE_SDC1 == TRUE
  53. sdcObjectInit(&SDCD1);
  54. #endif
  55. }
  56. /**
  57. * @brief Configures and activates the SDC peripheral.
  58. *
  59. * @param[in] sdcp pointer to the @p SDCDriver object
  60. *
  61. * @notapi
  62. */
  63. void sdc_lld_start(SDCDriver *sdcp) {
  64. if (sdcp->state == BLK_STOP) {
  65. }
  66. }
  67. /**
  68. * @brief Deactivates the SDC peripheral.
  69. *
  70. * @param[in] sdcp pointer to the @p SDCDriver object
  71. *
  72. * @notapi
  73. */
  74. void sdc_lld_stop(SDCDriver *sdcp) {
  75. if (sdcp->state != BLK_STOP) {
  76. }
  77. }
  78. /**
  79. * @brief Starts the SDIO clock and sets it to init mode (400kHz or less).
  80. *
  81. * @param[in] sdcp pointer to the @p SDCDriver object
  82. *
  83. * @notapi
  84. */
  85. void sdc_lld_start_clk(SDCDriver *sdcp) {
  86. (void)sdcp;
  87. }
  88. /**
  89. * @brief Sets the SDIO clock to data mode (25MHz or less).
  90. *
  91. * @param[in] sdcp pointer to the @p SDCDriver object
  92. * @param[in] clk the clock mode
  93. *
  94. * @notapi
  95. */
  96. void sdc_lld_set_data_clk(SDCDriver *sdcp, sdcbusclk_t clk) {
  97. (void)sdcp;
  98. (void)clk;
  99. }
  100. /**
  101. * @brief Stops the SDIO clock.
  102. *
  103. * @param[in] sdcp pointer to the @p SDCDriver object
  104. *
  105. * @notapi
  106. */
  107. void sdc_lld_stop_clk(SDCDriver *sdcp) {
  108. (void)sdcp;
  109. }
  110. /**
  111. * @brief Switches the bus to 4 bits mode.
  112. *
  113. * @param[in] sdcp pointer to the @p SDCDriver object
  114. * @param[in] mode bus mode
  115. *
  116. * @notapi
  117. */
  118. void sdc_lld_set_bus_mode(SDCDriver *sdcp, sdcbusmode_t mode) {
  119. (void)sdcp;
  120. switch (mode) {
  121. case SDC_MODE_1BIT:
  122. break;
  123. case SDC_MODE_4BIT:
  124. break;
  125. case SDC_MODE_8BIT:
  126. break;
  127. default:
  128. osalDbgAssert(false, "invalid bus mode");
  129. break;
  130. }
  131. }
  132. /**
  133. * @brief Sends an SDIO command with no response expected.
  134. *
  135. * @param[in] sdcp pointer to the @p SDCDriver object
  136. * @param[in] cmd card command
  137. * @param[in] arg command argument
  138. *
  139. * @notapi
  140. */
  141. void sdc_lld_send_cmd_none(SDCDriver *sdcp, uint8_t cmd, uint32_t arg) {
  142. (void)sdcp;
  143. (void)cmd;
  144. (void)arg;
  145. }
  146. /**
  147. * @brief Sends an SDIO command with a short response expected.
  148. * @note The CRC is not verified.
  149. *
  150. * @param[in] sdcp pointer to the @p SDCDriver object
  151. * @param[in] cmd card command
  152. * @param[in] arg command argument
  153. * @param[out] resp pointer to the response buffer (one word)
  154. *
  155. * @return The operation status.
  156. * @retval HAL_SUCCESS operation succeeded.
  157. * @retval HAL_FAILED operation failed.
  158. *
  159. * @notapi
  160. */
  161. bool sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
  162. uint32_t *resp) {
  163. (void)sdcp;
  164. (void)cmd;
  165. (void)arg;
  166. (void)resp;
  167. return HAL_SUCCESS;
  168. }
  169. /**
  170. * @brief Sends an SDIO command with a short response expected and CRC.
  171. *
  172. * @param[in] sdcp pointer to the @p SDCDriver object
  173. * @param[in] cmd card command
  174. * @param[in] arg command argument
  175. * @param[out] resp pointer to the response buffer (one word)
  176. *
  177. * @return The operation status.
  178. * @retval HAL_SUCCESS operation succeeded.
  179. * @retval HAL_FAILED operation failed.
  180. *
  181. * @notapi
  182. */
  183. bool sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
  184. uint32_t *resp) {
  185. (void)sdcp;
  186. (void)cmd;
  187. (void)arg;
  188. (void)resp;
  189. return HAL_SUCCESS;
  190. }
  191. /**
  192. * @brief Sends an SDIO command with a long response expected and CRC.
  193. *
  194. * @param[in] sdcp pointer to the @p SDCDriver object
  195. * @param[in] cmd card command
  196. * @param[in] arg command argument
  197. * @param[out] resp pointer to the response buffer (four words)
  198. *
  199. * @return The operation status.
  200. * @retval HAL_SUCCESS operation succeeded.
  201. * @retval HAL_FAILED operation failed.
  202. *
  203. * @notapi
  204. */
  205. bool sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
  206. uint32_t *resp) {
  207. (void)sdcp;
  208. (void)cmd;
  209. (void)arg;
  210. (void)resp;
  211. return HAL_SUCCESS;
  212. }
  213. /**
  214. * @brief Reads one or more blocks.
  215. *
  216. * @param[in] sdcp pointer to the @p SDCDriver object
  217. * @param[in] startblk first block to read
  218. * @param[out] buf pointer to the read buffer
  219. * @param[in] n number of blocks to read
  220. *
  221. * @return The operation status.
  222. * @retval HAL_SUCCESS operation succeeded.
  223. * @retval HAL_FAILED operation failed.
  224. *
  225. * @notapi
  226. */
  227. bool sdc_lld_read(SDCDriver *sdcp, uint32_t startblk,
  228. uint8_t *buf, uint32_t n) {
  229. (void)sdcp;
  230. (void)startblk;
  231. (void)buf;
  232. (void)n;
  233. return HAL_SUCCESS;
  234. }
  235. /**
  236. * @brief Writes one or more blocks.
  237. *
  238. * @param[in] sdcp pointer to the @p SDCDriver object
  239. * @param[in] startblk first block to write
  240. * @param[out] buf pointer to the write buffer
  241. * @param[in] n number of blocks to write
  242. *
  243. * @return The operation status.
  244. * @retval HAL_SUCCESS operation succeeded.
  245. * @retval HAL_FAILED operation failed.
  246. *
  247. * @notapi
  248. */
  249. bool sdc_lld_write(SDCDriver *sdcp, uint32_t startblk,
  250. const uint8_t *buf, uint32_t n) {
  251. (void)sdcp;
  252. (void)startblk;
  253. (void)buf;
  254. (void)n;
  255. return HAL_SUCCESS;
  256. }
  257. /**
  258. * @brief Waits for card idle condition.
  259. *
  260. * @param[in] sdcp pointer to the @p SDCDriver object
  261. *
  262. * @return The operation status.
  263. * @retval HAL_SUCCESS the operation succeeded.
  264. * @retval HAL_FAILED the operation failed.
  265. *
  266. * @api
  267. */
  268. bool sdc_lld_sync(SDCDriver *sdcp) {
  269. (void)sdcp;
  270. return HAL_SUCCESS;
  271. }
  272. #endif /* HAL_USE_SDC == TRUE */
  273. /** @} */