aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/os/hal/templates/hal_sdc_lld.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/os/hal/templates/hal_sdc_lld.c')
-rw-r--r--lib/chibios/os/hal/templates/hal_sdc_lld.c328
1 files changed, 328 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/templates/hal_sdc_lld.c b/lib/chibios/os/hal/templates/hal_sdc_lld.c
new file mode 100644
index 000000000..693f1c4ce
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_sdc_lld.c
@@ -0,0 +1,328 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file hal_sdc_lld.c
19 * @brief PLATFORM SDC subsystem low level driver source.
20 *
21 * @addtogroup SDC
22 * @{
23 */
24
25#include "hal.h"
26
27#if (HAL_USE_SDC == TRUE) || defined(__DOXYGEN__)
28
29/*===========================================================================*/
30/* Driver local definitions. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver exported variables. */
35/*===========================================================================*/
36
37/**
38 * @brief SDCD1 driver identifier.
39 */
40#if (PLATFORM_SDC_USE_SDC1 == TRUE) || defined(__DOXYGEN__)
41SDCDriver SDCD1;
42#endif
43
44/*===========================================================================*/
45/* Driver local variables and types. */
46/*===========================================================================*/
47
48/*===========================================================================*/
49/* Driver local functions. */
50/*===========================================================================*/
51
52/*===========================================================================*/
53/* Driver interrupt handlers. */
54/*===========================================================================*/
55
56/*===========================================================================*/
57/* Driver exported functions. */
58/*===========================================================================*/
59
60/**
61 * @brief Low level SDC driver initialization.
62 *
63 * @notapi
64 */
65void sdc_lld_init(void) {
66
67#if PLATFORM_SDC_USE_SDC1 == TRUE
68 sdcObjectInit(&SDCD1);
69#endif
70}
71
72/**
73 * @brief Configures and activates the SDC peripheral.
74 *
75 * @param[in] sdcp pointer to the @p SDCDriver object
76 *
77 * @notapi
78 */
79void sdc_lld_start(SDCDriver *sdcp) {
80
81 if (sdcp->state == BLK_STOP) {
82
83 }
84}
85
86/**
87 * @brief Deactivates the SDC peripheral.
88 *
89 * @param[in] sdcp pointer to the @p SDCDriver object
90 *
91 * @notapi
92 */
93void sdc_lld_stop(SDCDriver *sdcp) {
94
95 if (sdcp->state != BLK_STOP) {
96
97 }
98}
99
100/**
101 * @brief Starts the SDIO clock and sets it to init mode (400kHz or less).
102 *
103 * @param[in] sdcp pointer to the @p SDCDriver object
104 *
105 * @notapi
106 */
107void sdc_lld_start_clk(SDCDriver *sdcp) {
108
109 (void)sdcp;
110}
111
112/**
113 * @brief Sets the SDIO clock to data mode (25MHz or less).
114 *
115 * @param[in] sdcp pointer to the @p SDCDriver object
116 * @param[in] clk the clock mode
117 *
118 * @notapi
119 */
120void sdc_lld_set_data_clk(SDCDriver *sdcp, sdcbusclk_t clk) {
121
122 (void)sdcp;
123 (void)clk;
124}
125
126/**
127 * @brief Stops the SDIO clock.
128 *
129 * @param[in] sdcp pointer to the @p SDCDriver object
130 *
131 * @notapi
132 */
133void sdc_lld_stop_clk(SDCDriver *sdcp) {
134
135 (void)sdcp;
136}
137
138/**
139 * @brief Switches the bus to 4 bits mode.
140 *
141 * @param[in] sdcp pointer to the @p SDCDriver object
142 * @param[in] mode bus mode
143 *
144 * @notapi
145 */
146void sdc_lld_set_bus_mode(SDCDriver *sdcp, sdcbusmode_t mode) {
147
148 (void)sdcp;
149
150 switch (mode) {
151 case SDC_MODE_1BIT:
152
153 break;
154 case SDC_MODE_4BIT:
155
156 break;
157 case SDC_MODE_8BIT:
158
159 break;
160 default:
161 osalDbgAssert(false, "invalid bus mode");
162 break;
163 }
164}
165
166/**
167 * @brief Sends an SDIO command with no response expected.
168 *
169 * @param[in] sdcp pointer to the @p SDCDriver object
170 * @param[in] cmd card command
171 * @param[in] arg command argument
172 *
173 * @notapi
174 */
175void sdc_lld_send_cmd_none(SDCDriver *sdcp, uint8_t cmd, uint32_t arg) {
176
177 (void)sdcp;
178 (void)cmd;
179 (void)arg;
180}
181
182/**
183 * @brief Sends an SDIO command with a short response expected.
184 * @note The CRC is not verified.
185 *
186 * @param[in] sdcp pointer to the @p SDCDriver object
187 * @param[in] cmd card command
188 * @param[in] arg command argument
189 * @param[out] resp pointer to the response buffer (one word)
190 *
191 * @return The operation status.
192 * @retval HAL_SUCCESS operation succeeded.
193 * @retval HAL_FAILED operation failed.
194 *
195 * @notapi
196 */
197bool sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
198 uint32_t *resp) {
199
200 (void)sdcp;
201 (void)cmd;
202 (void)arg;
203 (void)resp;
204
205 return HAL_SUCCESS;
206}
207
208/**
209 * @brief Sends an SDIO command with a short response expected and CRC.
210 *
211 * @param[in] sdcp pointer to the @p SDCDriver object
212 * @param[in] cmd card command
213 * @param[in] arg command argument
214 * @param[out] resp pointer to the response buffer (one word)
215 *
216 * @return The operation status.
217 * @retval HAL_SUCCESS operation succeeded.
218 * @retval HAL_FAILED operation failed.
219 *
220 * @notapi
221 */
222bool sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
223 uint32_t *resp) {
224
225 (void)sdcp;
226 (void)cmd;
227 (void)arg;
228 (void)resp;
229
230 return HAL_SUCCESS;
231}
232
233/**
234 * @brief Sends an SDIO command with a long response expected and CRC.
235 *
236 * @param[in] sdcp pointer to the @p SDCDriver object
237 * @param[in] cmd card command
238 * @param[in] arg command argument
239 * @param[out] resp pointer to the response buffer (four words)
240 *
241 * @return The operation status.
242 * @retval HAL_SUCCESS operation succeeded.
243 * @retval HAL_FAILED operation failed.
244 *
245 * @notapi
246 */
247bool sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
248 uint32_t *resp) {
249
250 (void)sdcp;
251 (void)cmd;
252 (void)arg;
253 (void)resp;
254
255 return HAL_SUCCESS;
256}
257
258/**
259 * @brief Reads one or more blocks.
260 *
261 * @param[in] sdcp pointer to the @p SDCDriver object
262 * @param[in] startblk first block to read
263 * @param[out] buf pointer to the read buffer
264 * @param[in] n number of blocks to read
265 *
266 * @return The operation status.
267 * @retval HAL_SUCCESS operation succeeded.
268 * @retval HAL_FAILED operation failed.
269 *
270 * @notapi
271 */
272bool sdc_lld_read(SDCDriver *sdcp, uint32_t startblk,
273 uint8_t *buf, uint32_t n) {
274
275 (void)sdcp;
276 (void)startblk;
277 (void)buf;
278 (void)n;
279
280 return HAL_SUCCESS;
281}
282
283/**
284 * @brief Writes one or more blocks.
285 *
286 * @param[in] sdcp pointer to the @p SDCDriver object
287 * @param[in] startblk first block to write
288 * @param[out] buf pointer to the write buffer
289 * @param[in] n number of blocks to write
290 *
291 * @return The operation status.
292 * @retval HAL_SUCCESS operation succeeded.
293 * @retval HAL_FAILED operation failed.
294 *
295 * @notapi
296 */
297bool sdc_lld_write(SDCDriver *sdcp, uint32_t startblk,
298 const uint8_t *buf, uint32_t n) {
299
300 (void)sdcp;
301 (void)startblk;
302 (void)buf;
303 (void)n;
304
305 return HAL_SUCCESS;
306}
307
308/**
309 * @brief Waits for card idle condition.
310 *
311 * @param[in] sdcp pointer to the @p SDCDriver object
312 *
313 * @return The operation status.
314 * @retval HAL_SUCCESS the operation succeeded.
315 * @retval HAL_FAILED the operation failed.
316 *
317 * @api
318 */
319bool sdc_lld_sync(SDCDriver *sdcp) {
320
321 (void)sdcp;
322
323 return HAL_SUCCESS;
324}
325
326#endif /* HAL_USE_SDC == TRUE */
327
328/** @} */