]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/Driver/src/Driver_MCI.c
Aligned develop branch with master after release.
[cmsis] / CMSIS / DoxyGen / Driver / src / Driver_MCI.c
1 /* -----------------------------------------------------------------------------
2  * Copyright (c) 2013-2014 ARM Limited. All rights reserved.
3  *  
4  * $Date:        2. January 2014
5  * $Revision:    V2.00
6  *  
7  * Project:      MCI Driver API
8  * -------------------------------------------------------------------------- */
9
10
11 /**
12 \defgroup mci_interface_gr MCI Interface
13 \brief    Driver API for Memory Card Interface using SD/MMC interface (%Driver_MCI.h)
14
15 \details
16 The <b>Memory Card Interface</b> (MCI) implements the hardware abstraction layer for Secure Digital (SD) and Multi Media Card (MMC)
17 memory that is typically used as file storage. For embedded systems, SD/MMC devices are available as memory cards in several 
18 forms (SD, miniSD, microSD, MMC, MMCmicro) or as non-removable devic
19 es that are directly soldered to the PCB (eMMC).  
20
21 \b References:
22 - Wikipedia offers more information about the <a href="http://en.wikipedia.org/wiki/SD_card" target="_blank"><b>Secure Digital</b> memory</a>.
23 - Wikipedia offers more information about the <a href="http://en.wikipedia.org/wiki/MultiMediaCard" target="_blank"><b>MultiMediaCard</b></a>.
24 - The SD Association provides detailed documentation under <a href="http://www.sdcard.org">www.sdcard.org</a>.
25 - The MultiMediaCard Association (merged with JEDEC) provides detailed documentation under <a href="http://www.jedec.org">www.jedec.org</a>.
26
27 <b>Block Diagram</b>
28
29 The MCI driver allows you to exchange data of the SD/MMC memory via SD/MMC interface.
30
31 The following modes are supported by SD/MMC memory cards:
32
33 - SPI bus mode: Serial Peripheral Interface Bus supported by most microcontrollers.
34 - 1-bit SD/MMC Bus mode: proprietary data transfer protocol supported by SD/MMC interfaces.
35 - 4-bit SD/MMC Bus mode: high-speed version of the SD/MMC interface using 4 data I/O pins. 
36 - 8-bit SD/MMC Bus mode: high-speed version of the SD/MMC interface using 8 data I/O pins. 
37
38 \image html SPI_BusMode.png  "SD memory connected via SPI interface"
39 <p>&nbsp;</p>
40 \image html SD_1BitBusMode.png  "SD memory connected via 1-bit SD Bus Mode"
41 <p>&nbsp;</p>
42 \image html SD_4BitBusMode.png  "SD memory connected via 4-bit SD Bus Mode"
43
44
45 <b>MCI API</b>
46
47 The following header files define the Application Programming Interface (API) for the MCI interface:
48   - \b %Driver_MCI.h : Driver API for Memory Card Interface using SD/MMC interface
49
50 The driver implementation is a typical part of the Device Family Pack (DFP) that supports the 
51 peripherals of the microcontroller family.
52
53 \note
54 For parameters, the value marked with (default) is the setting after the driver initialization.
55
56  
57 <b>Driver Functions</b>
58
59 The driver functions are published in the access struct as explained in \ref DriverFunctions
60   - \ref ARM_DRIVER_MCI : access struct for MCI driver functions
61 @{
62 */
63 /**
64 A typical setup sequence for the driver is shown below:
65
66 <b>Example Code:</b>
67
68 \code
69  
70 #include "Driver_MCI.h"
71  
72 /* Usage example: ARM_MCI_Initialize ----------------------------------------*/
73  
74 // ARM_MCI_SignalEvent callback function prototype
75 void MCI_SignalEvent_Callback (uint32_t event);
76  
77 void init_driver (ARM_DRIVER_MCI *drv) {
78   int32_t status;
79   
80   status = drv->Initialize (&MCI_SignalEvent_Callback);
81   
82   if (status != ARM_DRIVER_OK) {
83     // Initialization and event callback registration failed
84   }
85 }
86  
87 /* Usage example: ARM_MCI_Uninitialize --------------------------------------*/
88  
89 void uninit_driver (ARM_DRIVER_MCI *drv) {
90   int32_t status;
91   
92   status = drv->Uninitialize ();
93   
94   if (status == ARM_DRIVER_OK) {
95     // Driver successfully uninitialized
96   }
97 }
98  
99 /* Usage example: ARM_MCI_PowerControl --------------------------------------*/
100  
101 void control_driver_power (ARM_DRIVER_MCI *drv, bool enable) {
102   int32_t status;
103   
104   if (enable == true) {
105     status = drv->PowerControl (ARM_POWER_FULL);
106   }
107   else {
108     status = drv->PowerControl (ARM_POWER_OFF);
109   }
110   
111   if (status == ARM_DRIVER_OK) {
112     // Driver power enabled/disabled
113   }
114 }
115  
116 /* Usage example: ARM_MCI_CardPower -----------------------------------------*/
117  
118 ARM_MCI_CAPABILITIES drv_capabilities;
119  
120 void set_card_vdd_3v3 (ARM_DRIVER_MCI *drv) {
121   int32_t status;
122   
123   if (drv_capabilities.vdd == 1) {
124     // Power switching to 3.3V supported
125     status = drv->CardPower (ARM_MCI_POWER_VDD_3V3);
126     
127     if (status == ARM_DRIVER_OK) {
128       // Card power set to 3.3V
129     }
130   }
131 }
132  
133 /* Usage example: ARM_MCI_ReadCD --------------------------------------------*/
134  
135 void read_card_detect_state (ARM_DRIVER_MCI *drv) {
136   int32_t status;
137   
138   status = drv->ReadCD();
139   
140   if (status == 1) {
141     // Memory card is detected
142   }
143   else {
144     if (status == 0) {
145       // Memory card is not detected
146     }
147     else {
148       // Error reading card detect pin state
149     }
150   }
151 }
152  
153 /* Usage example: ARM_MCI_ReadWP --------------------------------------------*/
154  
155 void read_write_protect_state (ARM_DRIVER_MCI *drv) {
156   int32_t status;
157   
158   status = drv->ReadWP();
159   
160   if (status == 1) {
161     // Memory card write protection is enabled
162   }
163   else {
164     if (status == 0) {
165       // Memory card write protection is disabled
166     }
167     else {
168       // Error reading write protect pin state
169     }
170   }
171 }
172  
173 /* Usage example: ARM_MCI_SendCommand ---------------------------------------*/
174  
175 volatile uint32_t MCI_Events;
176  
177 void MCI_SignalEvent_Callback (uint32_t event) {
178   // Save current event
179   MCI_Events |= event;
180 }
181  
182 void send_CMD0 (ARM_DRIVER_MCI *drv) {
183   int32_t  status;
184   uint32_t cmd;
185  
186   MCI_Events = 0; //Clear MCI driver event flags
187   cmd = 0;        // Set GO_IDLE_STATE command code
188  
189   status = drv->SendCommand (cmd, 0, ARM_MCI_CARD_INITIALIZE | ARM_MCI_RESPONSE_NONE, NULL);
190  
191   if (status == ARM_DRIVER_OK) {
192     /* Wait for event */
193     while ((MCI_Events & ARM_MCI_EVENT_COMMAND_COMPLETE) == 0U);
194     // Command was successfully sent to memory card
195     // ..
196   }
197   else {
198     // Error
199   }
200 }
201  
202 /* Usage example: ARM_MCI_SetupTransfer -------------------------------------*/
203  
204 volatile uint32_t MCI_Events;
205  
206 void MCI_SignalEvent_Callback (uint32_t event) {
207   MCI_Events |= event;  // Save current event
208 }
209  
210 void read_sector (ARM_DRIVER_MCI *drv, uint8_t *buf, uint32_t sz) {
211   int32_t status;
212   uint32_t cmd, arg;
213   uint32_t resp;
214  
215   if (sz < 512) {
216     // Invalid buffer size, sector consists of 512 bytes
217     //...
218   } 
219  
220   status = drv->SetupTransfer (buf, 1, 512, ARM_MCI_TRANSFER_READ | ARM_MCI_TRANSFER_BLOCK);
221  
222   if (status == ARM_DRIVER_OK) {
223     MCI_Events = 0; //Clear MCI driver event flags
224
225     cmd = 17;       // Set READ_SINGLE_BLOCK command
226     arg = 0;        // Set sector number
227  
228     status  = drv->SendCommand (cmd, arg, ARM_MCI_RESPONSE_SHORT | ARM_MCI_RESPONSE_CRC | ARM_MCI_TRANSFER_DATA, &resp);
229  
230     if (status == ARM_DRIVER_OK) {
231       /* Wait for event */
232       while ((MCI_Events & ARM_MCI_EVENT_COMMAND_COMPLETE) == 0U);
233       // Command was successfully sent to memory card
234       if ((resp & 0x03) == 0) {
235         // Sector number is valid, wait until data transfer completes
236         while ((MCI_Events & ARM_MCI_EVENT_TRANSFER_COMPLETE) == 0U);
237         // Data was successfully read from memory card
238         // ...
239       }
240     }
241   }
242 }
243  
244 /* Usage example: ARM_MCI_AbortTransfer -------------------------------------*/
245  
246 void abort_data_transfer (ARM_DRIVER_MCI *drv) {
247   ARM_MCI_STATUS drv_status;
248
249   drv_status = drv->GetStatus();
250   
251   if (drv_status.transfer_active == 1U) {
252     // Data transfer is active, abort the transfer
253     if (drv->AbortTransfer() == ARM_DRIVER_OK) {
254       // Transfer aborted
255       // ...
256     }
257   }
258 }
259  
260 /* Usage example: ARM_MCI_GetStatus -----------------------------------------*/
261  
262 void check_transfer_status (ARM_DRIVER_MCI *drv) {
263   ARM_MCI_STATUS drv_status;
264
265   drv_status = drv->GetStatus();
266
267   if (drv_status.transfer_active == 1U) {
268     // Data transfer is active
269   }
270   
271   if (drv_status.transfer_timeout == 1U) {
272     // Data not received, timeout expired
273   }
274   
275   if (drv_status.transfer_error == 1U) {
276     // Data transfer ended with error
277   }
278 }
279  
280 /* Usage example: ARM_MCI_SignalEvent ---------------------------------------*/
281  
282 void MCI_SignalEvent_Callback (uint32_t event) {
283   if ((event & ARM_MCI_EVENT_CARD_INSERTED) != 0U) {
284     // Memory card was inserted into socket
285   }
286   if ((event & ARM_MCI_EVENT_CARD_REMOVED) != 0U) {
287     // Memory card was removed from socket
288   }
289
290   if ((event & ARM_MCI_EVENT_COMMAND_COMPLETE) != 0U) {
291     // Command was successfully sent to memory card
292   }
293   if ((event & ARM_MCI_EVENT_COMMAND_TIMEOUT) != 0U) {
294     // Command response was not received in time
295   }
296   if ((event & ARM_MCI_EVENT_COMMAND_ERROR) != 0U) {
297     // Command response was invalid
298   }
299
300   if ((event & ARM_MCI_EVENT_TRANSFER_COMPLETE) != 0U) {
301     // Data successfully transferred from/to memory card
302   }
303   if ((event & ARM_MCI_EVENT_TRANSFER_TIMEOUT) != 0U) {
304     // Data not transferred from/to memory card, timeout expired
305   }
306   if ((event & ARM_MCI_EVENT_TRANSFER_ERROR) != 0U) {
307     // Data transfer ended with errors
308   }
309   
310   if ((event & ARM_MCI_EVENT_SDIO_INTERRUPT) != 0U) {
311     // SD I/O card sent interrupt request
312   }
313   
314   if ((event & ARM_MCI_EVENT_CCS) != 0U) {
315     // CE-ATA command completion signal received
316   }
317   if ((event & ARM_MCI_EVENT_CCS_TIMEOUT) != 0U) {
318     // CE-ATA command completion signal wait timeout expired
319   }
320 }
321
322 \endcode
323
324 */
325
326 /*************   Structures ******************************************************************************************************/
327 /** 
328 \struct     ARM_DRIVER_MCI 
329 \details 
330 The functions of the MCI are accessed by function pointers exposed by this structure. Refer to \ref DriverFunctions for overview information.
331
332 Each instance of an MCI provides such an access structure. 
333 The instance is identified by a postfix number in the symbol name of the access structure, for example:
334  - \b Driver_MCI0 is the name of the access struct of the first instance (no. 0).
335  - \b Driver_MCI1 is the name of the access struct of the second instance (no. 1).
336
337 A configuration setting in the middleware allows connecting the middleware to a specific driver instance <b>Driver_MCI<i>n</i></b>.
338 The default is \token{0}, which connects a middleware to the first instance of a driver.
339 *******************************************************************************************************************/
340
341 /** 
342 \struct     ARM_MCI_CAPABILITIES 
343 \details 
344 A MCI driver can be implemented with different capabilities.  
345 The data fields of this struct encode the capabilities implemented by this driver.
346
347 <b>Returned by:</b>
348   - \ref ARM_MCI_GetCapabilities
349 *******************************************************************************************************************/
350
351 /**
352 \defgroup mci_event_gr MCI Events
353 \brief The MCI driver generates call back events that are notified via the function \ref ARM_MCI_SignalEvent.
354 \details
355 This section provides the event values for the \ref ARM_MCI_SignalEvent callback function.
356
357 The following call back notification events are generated:
358 @{
359 \def ARM_MCI_EVENT_CARD_INSERTED   
360 \sa \ref ARM_MCI_SignalEvent
361 \def ARM_MCI_EVENT_CARD_REMOVED    
362 \sa \ref  ARM_MCI_SignalEvent
363 \def ARM_MCI_EVENT_COMMAND_COMPLETE 
364 \sa \ref ARM_MCI_SignalEvent
365 \def ARM_MCI_EVENT_COMMAND_TIMEOUT  
366 \sa \ref ARM_MCI_SignalEvent
367 \def ARM_MCI_EVENT_COMMAND_ERROR    
368 \sa \ref ARM_MCI_SignalEvent
369 \def ARM_MCI_EVENT_TRANSFER_COMPLETE
370 \sa \ref ARM_MCI_SignalEvent
371 \def ARM_MCI_EVENT_TRANSFER_TIMEOUT 
372 \sa \ref ARM_MCI_SignalEvent
373 \def ARM_MCI_EVENT_TRANSFER_ERROR   
374 \sa \ref ARM_MCI_SignalEvent
375 \def ARM_MCI_EVENT_SDIO_INTERRUPT   
376 \sa \ref ARM_MCI_SignalEvent
377 \def ARM_MCI_EVENT_CCS              
378 \sa \ref ARM_MCI_SignalEvent
379 \def ARM_MCI_EVENT_CCS_TIMEOUT      
380 \sa \ref ARM_MCI_SignalEvent
381 @}
382 *******************************************************************************************************************/
383
384 //open mci_contorl_gr
385 /**  
386 @{
387 */
388 /**
389 \defgroup mci_control_gr MCI Control Codes
390 \ingroup mci_interface_gr
391 \brief Configure and control the MCI using the \ref ARM_MCI_Control.
392 \details
393 @{
394 Many parameters of the MCI driver are configured using the \ref ARM_MCI_Control function.
395
396 The various MCI control codes define:
397   - \ref mci_mode_ctrls configures and controls the MCI interface
398   - \ref mci_bus_speed_ctrls specifies the bus speed mode
399   - \ref mci_bus_data_width_ctrls specifies the data bus width
400   - \ref mci_cmd_line_ctrls specifies the CMD line mode
401   - \ref mci_driver_strength_ctrls specifies the driver strength
402
403 Refer to the function \ref ARM_MCI_Control for further details.
404 @}
405 *******************************************************************************************************************/
406
407
408 /**
409 \defgroup mci_mode_ctrls MCI Controls
410 \ingroup mci_control_gr
411 \brief Configure and control the MCI interface.
412 \details
413 The following codes are used as values for the parameter \em control of the function \ref ARM_MCI_Control to setup the MCI interface.
414 @{
415 \def ARM_MCI_BUS_SPEED       
416 \def ARM_MCI_BUS_SPEED_MODE       
417 \def ARM_MCI_BUS_CMD_MODE         
418 \def ARM_MCI_BUS_DATA_WIDTH       
419 \def ARM_MCI_DRIVER_STRENGTH       
420 \def ARM_MCI_CONTROL_RESET         
421 \def ARM_MCI_CONTROL_CLOCK_IDLE    
422 \def ARM_MCI_UHS_TUNING_OPERATION 
423 \def ARM_MCI_UHS_TUNING_RESULT
424 \def ARM_MCI_DATA_TIMEOUT          
425 \def ARM_MCI_CSS_TIMEOUT            
426 \def ARM_MCI_MONITOR_SDIO_INTERRUPT 
427 \def ARM_MCI_CONTROL_READ_WAIT      
428 \def ARM_MCI_SUSPEND_TRANSFER       
429 \def ARM_MCI_RESUME_TRANSFER        
430 @}
431 *******************************************************************************************************************/
432
433
434 /**
435 \defgroup mci_bus_speed_ctrls MCI Bus Speed Mode
436 \ingroup mci_control_gr
437 \brief Specify the bus speed mode.
438 \details
439 @{
440 The function \ref ARM_MCI_Control with \em control = \ref ARM_MCI_BUS_SPEED configures the bus speed of the MCI to the
441 requested bits/s specified with \em arg.
442
443 The function \ref ARM_MCI_Control with \em control = \ref ARM_MCI_BUS_SPEED_MODE configures the bus speed mode of the MCI
444 as specified with \em arg listed bellow.
445
446 The function \ref ARM_MCI_GetCapabilities lists the supported bus speed modes. Initially, all SD cards use a 3.3 volt electrical interface. 
447 Some SD cards can switch to 1.8 volt operation. For example, the use of ultra-high-speed (UHS) 
448 SD cards requires 1.8 volt operation and a 4-bit bus data width. The data field \em uhs_signaling of the structure ARM_MCI_CAPABILITIES encodes 
449 whether the driver supports 1.8 volt UHS signaling.
450
451 \sa 
452  - \ref mci_driver_strength_ctrls
453
454 The following codes are defined:
455
456 \def ARM_MCI_BUS_DEFAULT_SPEED     
457 \def ARM_MCI_BUS_HIGH_SPEED        
458 \def ARM_MCI_BUS_UHS_SDR12         
459 \def ARM_MCI_BUS_UHS_SDR25         
460 \def ARM_MCI_BUS_UHS_SDR50         
461 \def ARM_MCI_BUS_UHS_SDR104        
462 \def ARM_MCI_BUS_UHS_DDR50         
463 @}
464 *******************************************************************************************************************/
465
466
467 /**
468 \defgroup mci_bus_data_width_ctrls MCI Bus Data Width
469 \ingroup mci_control_gr
470 \brief Specify the data bus width.
471 \details
472 @{
473 The function \ref ARM_MCI_Control with \em control = \ref ARM_MCI_BUS_DATA_WIDTH specifies with \em arg the number of data I/O pins on the SD/MMC interface.
474
475 For high-speed memory cards, a 4-bit bus data width should be used (or 8-bit for eMMC). The data fields \em data_width_4 and \em data_width_8 
476 of the structure ARM_MCI_CAPABILITIES encode whether the driver supports a specific bus data with.
477
478 The following codes are defined:
479
480 \def ARM_MCI_BUS_DATA_WIDTH_1        
481 \def ARM_MCI_BUS_DATA_WIDTH_4        
482 \def ARM_MCI_BUS_DATA_WIDTH_8        
483 \def ARM_MCI_BUS_DATA_WIDTH_4_DDR    
484 \def ARM_MCI_BUS_DATA_WIDTH_8_DDR    
485 @}
486 *******************************************************************************************************************/
487
488
489 /**
490 \defgroup mci_cmd_line_ctrls MCI CMD Line Mode
491 \ingroup mci_control_gr
492 \brief Specify the CMD line mode (Push-Pull or Open Drain).
493 \details
494 @{
495 Set the CMD line type with the function \ref ARM_MCI_Control. 
496 The CMD line mode is push-pull (default) or open drain (needed for older MMC).
497
498 \def ARM_MCI_BUS_CMD_PUSH_PULL       
499 \def ARM_MCI_BUS_CMD_OPEN_DRAIN      
500 @}
501 *******************************************************************************************************************/
502
503
504 /**
505 \defgroup mci_driver_strength_ctrls MCI Driver Strength
506 \ingroup mci_control_gr
507 \brief Specify the driver strength.
508 \details
509 @{
510 The function \ref ARM_MCI_Control with \em control = \ref ARM_MCI_DRIVER_STRENGTH specifies with \em arg the driver type of the SD interface.
511
512 \sa
513   - \ref mci_bus_speed_ctrls
514
515 The following codes are defined:
516
517 \def ARM_MCI_DRIVER_TYPE_A      
518 \def ARM_MCI_DRIVER_TYPE_B      
519 \def ARM_MCI_DRIVER_TYPE_C      
520 \def ARM_MCI_DRIVER_TYPE_D      
521 @}
522 *******************************************************************************************************************/
523
524 /**
525 @}
526 */   // close group mci_control_gr
527
528 /**
529 \defgroup mci_send_command_flags_ctrls MCI Send Command Flags
530 \ingroup mci_interface_gr
531 \brief Specify various options for sending commands to the card and the expected response.
532 \details
533 \b ARM_MCI_xxx flags are sent with the function \ref ARM_MCI_SendCommand as the parameter \em flag. 
534 It controls the behavior of the command sent to the card and provides information about the expected response from the card.
535
536 The following codes are defined:
537 @{
538 \def ARM_MCI_RESPONSE_NONE           
539 \def ARM_MCI_RESPONSE_SHORT          
540 \def ARM_MCI_RESPONSE_SHORT_BUSY     
541 \def ARM_MCI_RESPONSE_LONG           
542 \def ARM_MCI_RESPONSE_INDEX          
543 \def ARM_MCI_RESPONSE_CRC            
544 \def ARM_MCI_WAIT_BUSY             
545 \def ARM_MCI_TRANSFER_DATA         
546 \def ARM_MCI_CARD_INITIALIZE       
547 \def ARM_MCI_INTERRUPT_COMMAND     
548 \def ARM_MCI_INTERRUPT_RESPONSE    
549 \def ARM_MCI_BOOT_OPERATION        
550 \def ARM_MCI_BOOT_ALTERNATIVE      
551 \def ARM_MCI_BOOT_ACK              
552 \def ARM_MCI_CCSD                  
553 \def ARM_MCI_CCS                   
554 @}
555 *******************************************************************************************************************/
556
557 /**
558 \defgroup mci_transfer_ctrls MCI Transfer Controls
559 \ingroup mci_interface_gr
560 \brief  Specify data transfer mode.
561 \details
562 Data transfer codes specifies the transfer direction and type and are used with the function \ref ARM_MCI_SetupTransfer as the parameter \em mode.
563
564 The following codes are defined:
565 @{
566 \def ARM_MCI_TRANSFER_READ          
567 \def ARM_MCI_TRANSFER_WRITE         
568 \def ARM_MCI_TRANSFER_BLOCK         
569 \def ARM_MCI_TRANSFER_STREAM        
570 @}
571 *******************************************************************************************************************/
572
573 /**
574 \defgroup mci_card_power_ctrls MCI Card Power Controls
575 \ingroup mci_interface_gr
576 \brief Specify Memory Card Power supply voltage
577 \details
578 Specifies the power supply volatge for a memory card. Used with the function \ref ARM_MCI_CardPower as the parameter \em voltage.
579
580 The following codes are defined:
581 @{
582 \def ARM_MCI_POWER_VDD_OFF      
583 \def ARM_MCI_POWER_VDD_3V3      
584 \def ARM_MCI_POWER_VDD_1V8      
585 \def ARM_MCI_POWER_VCCQ_OFF     
586 \def ARM_MCI_POWER_VCCQ_3V3     
587 \def ARM_MCI_POWER_VCCQ_1V8     
588 \def ARM_MCI_POWER_VCCQ_1V2     
589 @}
590 *******************************************************************************************************************/
591
592
593 /**
594 \struct   ARM_MCI_STATUS
595 \details 
596 Structure with information about the status of the MCI.
597
598 <b>Returned by:</b>
599   - \ref ARM_MCI_GetStatus
600 *******************************************************************************************************************/
601
602 /**
603 \typedef    ARM_MCI_SignalEvent_t
604 \details
605 Provides the typedef for the callback function \ref ARM_MCI_SignalEvent.
606
607 <b>Parameter for:</b>
608   - \ref ARM_MCI_Initialize
609 *******************************************************************************************************************/
610
611
612 //
613 //   Functions 
614 //
615 ARM_DRIVER_VERSION ARM_MCI_GetVersion (void)  {
616   return { 0, 0 };
617 }
618 /**
619 \fn       ARM_DRIVER_VERSION ARM_MCI_GetVersion (void)
620 \details
621 The function \b ARM_MCI_GetVersion returns version information of the driver implementation in \ref ARM_DRIVER_VERSION
622  - API version is the version of the CMSIS-Driver specification used to implement this driver.
623  - Driver version is source code version of the actual driver implementation.
624
625 Example:
626 \code
627 extern ARM_DRIVER_MCI Driver_MCI0;
628 ARM_DRIVER_MCI *drv_info;
629  
630 void setup_mci (void)  {
631   ARM_DRIVER_VERSION  version;
632  
633   drv_info = &Driver_MCI0;
634   version = drv_info->GetVersion ();
635   if (version.api < 0x10A)   {      // requires at minimum API version 1.10 or higher
636     // error handling
637     return;
638   }
639 }
640 \endcode
641 *******************************************************************************************************************/
642
643 ARM_MCI_CAPABILITIES ARM_MCI_GetCapabilities (void)  {
644   return { 0 };
645 }
646 /**
647 \fn       ARM_MCI_CAPABILITIES ARM_MCI_GetCapabilities (void)
648 \details
649 The function \b ARM_MCI_GetCapabilities returns information about capabilities in this driver implementation.
650 The data fields of the structure \ref ARM_MCI_CAPABILITIES encode various capabilities, for example
651 supported bus modes ...
652  
653 Example:
654 \code
655 extern ARM_DRIVER_MCI Driver_MCI0;
656 ARM_DRIVER_MCI *drv_info;
657   
658 void read_capabilities (void)  {
659   ARM_MCI_CAPABILITIES drv_capabilities;
660  
661   drv_info = &Driver_MCI0;  
662   drv_capabilities = drv_info->GetCapabilities ();
663   // interrogate capabilities
664  
665 }
666 \endcode
667 *******************************************************************************************************************/
668
669 int32_t ARM_MCI_Initialize (ARM_MCI_SignalEvent_t cb_event)  {
670   return ARM_DRIVER_OK;
671 }
672 /**
673 \fn       int32_t ARM_MCI_Initialize (ARM_MCI_SignalEvent_t cb_event)
674 \details
675 The function \b ARM_MCI_Initialize initializes the MCI interface. 
676 It is called when the middleware component starts operation.
677
678 The function performs the following operations:
679   - Initializes the resources needed for the MCI interface.
680   - Registers the \ref ARM_MCI_SignalEvent callback function.
681
682 The parameter \em cb_event is a pointer to the \ref ARM_MCI_SignalEvent callback function; use a NULL pointer 
683 when no callback signals are required.
684
685 \b Example:
686  - see \ref mci_interface_gr - Driver Functions
687
688 *******************************************************************************************************************/
689
690 int32_t ARM_MCI_Uninitialize (void)  {
691   return ARM_DRIVER_OK;
692 }
693 /**
694 \fn       int32_t ARM_MCI_Uninitialize (void)
695 \details
696 The function \b ARM_MCI_Uninitialize de-initializes the resources of I2C interface.
697
698 It is called when the middleware component stops operation and releases the software resources used by the interface.
699 *******************************************************************************************************************/
700
701 int32_t ARM_MCI_PowerControl (ARM_POWER_STATE state)  {
702   return ARM_DRIVER_OK;
703 }
704 /**
705 \fn int32_t ARM_MCI_PowerControl (ARM_POWER_STATE state)
706 \details     
707 The function \b ARM_MCI_PowerControl operates the power modes of the MCI interface.  
708
709 The parameter \em state can have the following values:
710   - \ref ARM_POWER_FULL : set-up peripheral for data transfers, enable interrupts (NVIC) and optionally DMA. Can be called multiple times. 
711                           If the peripheral is already in this mode, then the function performs no operation and returns with \ref ARM_DRIVER_OK.
712   - \ref ARM_POWER_LOW : may use power saving. Returns \ref ARM_DRIVER_ERROR_UNSUPPORTED when not implemented.
713   - \ref ARM_POWER_OFF : terminates any pending data transfers, disables peripheral, disables related interrupts and DMA.
714       
715 Refer to \ref CallSequence for more information.
716 *******************************************************************************************************************/
717
718 int32_t ARM_MCI_CardPower (uint32_t voltage)  {
719   return ARM_DRIVER_OK;
720 }
721 /**
722 \fn int32_t ARM_MCI_CardPower (uint32_t voltage)
723 \details
724 The function \b ARM_MCI_CardPower operates the memory card power supply voltage. 
725
726 The parameter \em voltage sets the voltage. Not every voltage might be supported by the driver implementation.
727 The structure \ref ARM_MCI_CAPABILITIES encodes the supported voltage. Retrieve the information with the function \ref ARM_MCI_GetCapabilities and
728 verify the data fields.
729
730 The following values:
731
732 Parameter \em voltage                 | Description                   | supported when ARM_MCI_CAPABILITIES
733 :-------------------------------------|:------------------------------|-----------------------------------------
734 \ref ARM_MCI_POWER_VDD_OFF            | VDD (VCC) turned off          | <i>allways supported</i>
735 \ref ARM_MCI_POWER_VDD_3V3            | VDD (VCC) = \token{3.3V}      | data field \em vdd = \token{1}
736 \ref ARM_MCI_POWER_VDD_1V8            | VDD (VCC) = \token{1.8V}      | data field \em vdd_1v8 = \token{1} 
737 \ref ARM_MCI_POWER_VCCQ_OFF           | eMMC VCCQ turned off          | <i>allways supported</i>
738 \ref ARM_MCI_POWER_VCCQ_3V3           | eMMC VCCQ = \token{3.3V}      | data field \em vccq = \token{1}
739 \ref ARM_MCI_POWER_VCCQ_1V8           | eMMC VCCQ = \token{1.8V}      | data field \em vccq_1v8 = \token{1}
740 \ref ARM_MCI_POWER_VCCQ_1V2           | eMMC VCCQ = \token{1.2V}      | data field \em vccq_1v2 = \token{1}
741
742 *******************************************************************************************************************/
743
744 int32_t ARM_MCI_ReadCD (void)  {
745   return 0;
746 }
747 /**
748 \fn int32_t ARM_MCI_ReadCD (void)
749 \details
750 The function \b ARM_MCI_ReadCD reads the status of the Card Detect (CD) pin.
751 *******************************************************************************************************************/
752
753 int32_t ARM_MCI_ReadWP (void)  {
754   return 0;
755 }
756 /**
757 \fn int32_t ARM_MCI_ReadWP (void)
758 \details
759 The function \b ARM_MCI_ReadWP reads the status of the Write Protect (WP) pin.
760 *******************************************************************************************************************/
761
762 int32_t ARM_MCI_SendCommand (uint32_t cmd, uint32_t arg, uint32_t flags, uint32_t *response)  {
763   return ARM_DRIVER_OK;
764 }
765 /**
766 \fn int32_t ARM_MCI_SendCommand (uint32_t cmd, uint32_t arg, uint32_t flags, uint32_t *response)
767 \details
768 The function \b ARM_MCI_SendCommand 
769  - sends commands to the memory card 
770  - retrieve the response from the card 
771  - optionally, start the data transfer.
772
773 The parameter \em cmd is the command sent to the card. \n
774 The parameter \em arg contains arguments for the command \em cmd. \n
775 The parameter \em flags controls the behavior of the operation and takes predefined values listed in the table below. \n
776 The parameter \em response is a pointer to receive data.
777
778 The parameter \em flags can have the following values:
779
780 Parameter \em flags                   | Description
781 :-------------------------------------|:------------
782 \ref ARM_MCI_RESPONSE_NONE            | No response expected (default)
783 \ref ARM_MCI_RESPONSE_SHORT           | Short response (\token{48}-bit) expected
784 \ref ARM_MCI_RESPONSE_SHORT_BUSY      | Short response with busy signal (\token{48}-bit) expected
785 \ref ARM_MCI_RESPONSE_LONG            | Long response (\token{136}-bit) expected
786 \ref ARM_MCI_RESPONSE_INDEX           | Check command index in response
787 \ref ARM_MCI_RESPONSE_CRC             | Check CRC in response
788 \ref ARM_MCI_WAIT_BUSY                | Wait until busy before sending the command
789 \ref ARM_MCI_TRANSFER_DATA            | Activate Data transfer
790 \ref ARM_MCI_CARD_INITIALIZE          | Execute Memory Card initialization sequence
791 \ref ARM_MCI_INTERRUPT_COMMAND        | Send Interrupt command (CMD40 - MMC only)
792 \ref ARM_MCI_INTERRUPT_RESPONSE       | Send Interrupt response (CMD40 - MMC only)
793 \ref ARM_MCI_BOOT_OPERATION           | Execute Boot operation (MMC only)
794 \ref ARM_MCI_BOOT_ALTERNATIVE         | Execute Alternative Boot operation (MMC only)
795 \ref ARM_MCI_BOOT_ACK                 | Expect Boot Acknowledge (MMC only)
796 \ref ARM_MCI_CCSD                     | Send Command Completion Signal Disable (CCSD) for CE-ATA device
797 \ref ARM_MCI_CCS                      | Expect Command Completion Signal (CCS) for CE-ATA device
798
799 Calling the function <b>ARM_MCI_SendCommand</b> only starts the operation.
800 The function is non-blocking and returns as soon as the driver has started the operation.
801 It is not allowed to call this function again until the operation is in progress.
802
803 After the command is sent the response is retrieved if specified with <b>ARM_MCI_RESPONSE_xxx</b> flags.
804 When the command completes successfully (requested response is received without errors) the \ref ARM_MCI_EVENT_COMMAND_COMPLETE event is generated.
805 In case that response is requested but not received the \ref ARM_MCI_EVENT_COMMAND_TIMEOUT event is generated instead.
806 In case of invalid response (or CRC error) the \ref ARM_MCI_EVENT_COMMAND_ERROR event is generated instead.
807 Progress of command operation can be monitored by calling the \ref ARM_MCI_GetStatus and checking the \em command_active flag.
808
809 After the command operation the data transfer operation is started if specified with <b>ARM_MCI_TRANSFER_DATA</b> flag.
810 The data transfer needs to be configured before that by calling the \ref ARM_MCI_SetupTransfer.
811 When the data transfer completes successfully the \ref ARM_MCI_EVENT_TRANSFER_COMPLETE event is generated.
812 In case that data transfer is not completed in-time (specified by \ref ARM_MCI_DATA_TIMEOUT) the \ref ARM_MCI_EVENT_TRANSFER_TIMEOUT event is generated instead.
813 In case of CRC errors the \ref ARM_MCI_EVENT_TRANSFER_ERROR event is generated instead.
814 Progress of data transfer operation can be monitored by calling the \ref ARM_MCI_GetStatus and checking the \em transfer_active flag.
815
816 <b>See also:</b>
817  - \ref ARM_MCI_SignalEvent
818 *******************************************************************************************************************/
819
820 int32_t ARM_MCI_SetupTransfer (uint8_t  *data, uint32_t block_count, uint32_t block_size, uint32_t mode)  {
821   return ARM_DRIVER_OK;
822 }
823 /**
824 \fn int32_t ARM_MCI_SetupTransfer (uint8_t  *data, uint32_t block_count, uint32_t block_size, uint32_t mode) 
825 \details
826 The function \b ARM_MCI_SetupTransfer prepares the data transfer operation that is initiated 
827 by calling the function \ref ARM_MCI_SendCommand with the parameter \em flags = \ref ARM_MCI_TRANSFER_DATA.
828
829 The parameter \em data is a pointer to the data to transfer. \n
830 The parameter \em block_count is the number of blocks to transfer. \n
831 The parameter \em block_size is the size of a block. \n
832 The parameter \em mode sets the transfer mode and can have the values liste in the table below:
833
834 Transfer Directions                   | Description
835 :-------------------------------------|:------------
836 \ref ARM_MCI_TRANSFER_READ            | Read data from MCI
837 \ref ARM_MCI_TRANSFER_WRITE           | Write data to MCI
838 \ref ARM_MCI_TRANSFER_BLOCK (default) | Block Data transfer 
839 \ref ARM_MCI_TRANSFER_STREAM          | Stream Data transfer (MMC only)
840                                     
841 *******************************************************************************************************************/
842
843 int32_t ARM_MCI_AbortTransfer (void)  {
844   return ARM_DRIVER_OK;
845 }
846 /**
847 \fn int32_t ARM_MCI_AbortTransfer (void)
848 \details
849 The function \b ARM_MCI_AbortTransfer aborts the active data transfer operation initiated with \ref ARM_MCI_SendCommand.
850 *******************************************************************************************************************/
851
852
853 int32_t ARM_MCI_Control (uint32_t control, uint32_t arg)  {
854   return ARM_DRIVER_OK;
855 }
856 /**
857 \fn            int32_t ARM_MCI_Control (uint32_t control, uint32_t arg)
858 \details
859 Th function \b ARM_MCI_Control controls the MCI interface and executes various operations.
860
861 The parameter \em control specifies the operation.  
862 Values for \em control cannot be ORed, but must be called separately in the code. \n
863 The parameter \em arg provides, depending on the operation, additional information or sets values.
864
865 \note
866 For parameters, the values marked with (default) are the setting after the driver initialization.
867
868 The table lists values for the parameter \em control.
869
870 Parameter \em control                 | Operation
871 :-------------------------------------|:------------
872 \ref ARM_MCI_BUS_SPEED                | Set the Bus Speed. The parameter \em arg specifies the speed in bits/s; The function returns the bus speed configured in bits/s.
873 \ref ARM_MCI_BUS_SPEED_MODE           | Set the Bus Speed Mode. Predefined values for \em arg are listed in the table <b>Bus Speed Mode</b>.
874 \ref ARM_MCI_BUS_CMD_MODE             | Set the CMD Line Mode. Predefined values for \em arg are listed in the table <b>Bus CMD Line Mode</b>.
875 \ref ARM_MCI_BUS_DATA_WIDTH           | Set data bus width. Predefined values for \em arg are encoded in <b>Bus Data Width</b>.
876 \ref ARM_MCI_DRIVER_STRENGTH          | Set driver strength. Predefined values for \em arg are listed in the table <b>Driver Type</b>
877 \ref ARM_MCI_CONTROL_RESET            | Control optional RST_n Pin (eMMC). The parameter \em arg can have the values \token{[0:inactive(default); 1:active]}
878 \ref ARM_MCI_CONTROL_CLOCK_IDLE       | Control clock generation on CLK Pin when idle. The parameter \em arg  can have the values \token{[0:disabled; 1:enabled]}
879 \ref ARM_MCI_UHS_TUNING_OPERATION     | Sampling clock Tuning operation (SD UHS-I). The parameter \em arg  can have the values  \token{[0:reset; 1:execute]}
880 \ref ARM_MCI_UHS_TUNING_RESULT        | Sampling clock Tuning result (SD UHS-I). Returns \token{[0:done; 1:in progress; -1:error]}
881 \ref ARM_MCI_DATA_TIMEOUT             | Set Data timeout;  The parameter \em arg sets the timeout in bus cycles.
882 \ref ARM_MCI_CSS_TIMEOUT              | Set Command Completion Signal (CCS) timeout. The parameter \em arg sets timeout in bus cycles.
883 \ref ARM_MCI_MONITOR_SDIO_INTERRUPT   | Monitor SD I/O interrupt. The parameter \em arg  can have the values \token{[0:disabled(default); 1:enabled]}. Monitoring is automatically disabled when an interrupt is recognized.
884 \ref ARM_MCI_CONTROL_READ_WAIT        | Control Read/Wait states for SD I/O. The parameter \em arg  can have the values \token{[0:disabled(default); 1:enabled]}.
885 \ref ARM_MCI_SUSPEND_TRANSFER         | Suspend Data transfer (SD I/O). Returns the number of remaining bytes to transfer.
886 \ref ARM_MCI_RESUME_TRANSFER          | Resume Data transfer (SD I/O).
887  
888  
889 <b>Bus Speed Mode</b>
890  
891 The function \ref ARM_MCI_GetCapabilities lists the supported bus speed modes. Initially, all SD cards use a 3.3 volt electrical interface. 
892 Some SD cards can switch to 1.8 volt operation. For example, the use of ultra-high-speed (UHS) 
893 SD cards requires 1.8 volt operation and a 4-bit bus data width. The bit field ARM_MCI_CAPABILITIES.uhs_signaling encodes 
894 whether the driver supports 1.8 volt UHS signaling.
895
896 The \em control operation \b ARM_MCI_BUS_SPEED_MODE  sets the bus speed mode using the parameter \em arg.
897
898 Parameter \em arg                                             | Bus Speed Mode
899 :-------------------------------------------------------------|:------------------------------------------
900 \ref  ARM_MCI_BUS_DEFAULT_SPEED (default)                     | Set the bus speed for SD/MMC cards: Default Speed mode up to \token{[25;26]MHz} 
901 \ref  ARM_MCI_BUS_HIGH_SPEED                                  | Set the bus speed for SD/MMC: High    Speed mode up to \token{[50;52]MHz}
902 \ref  ARM_MCI_BUS_UHS_SDR12                                   | Set the bus speed for SD: SDR12  (Single Data Rate) up to  \token{25MHz,  12.5MB/s: UHS-I (Ultra High Speed) 1.8V signalling}
903 \ref  ARM_MCI_BUS_UHS_SDR25                                   | Set the bus speed for SD: SDR25  (Single Data Rate) up to  \token{50MHz,  25  MB/s: UHS-I (Ultra High Speed) 1.8V signalling}
904 \ref  ARM_MCI_BUS_UHS_SDR50                                   | Set the bus speed for SD: SDR50  (Single Data Rate) up to \token{100MHz,  50  MB/s: UHS-I (Ultra High Speed) 1.8V signalling}
905 \ref  ARM_MCI_BUS_UHS_SDR104                                  | Set the bus speed for SD: SDR104 (Single Data Rate) up to \token{208MHz, 104  MB/s: UHS-I (Ultra High Speed) 1.8V signalling}
906 \ref  ARM_MCI_BUS_UHS_DDR50                                   | Set the bus speed for SD: DDR50  (Dual Data Rate)   up to  \token{50MHz,  50  MB/s: UHS-I (Ultra High Speed) 1.8V signalling}
907  
908  
909 <b>Bus CMD Line Mode</b> 
910  
911 The \em control operation \b ARM_MCI_BUS_CMD_MODE sets the bus command line mode using the parameter \em arg.
912
913 Parameter \em arg                                             | Bus CMD Line Mode  
914 :-------------------------------------------------------------|:------------------------------------------
915 \ref ARM_MCI_BUS_CMD_PUSH_PULL  (default)                     | Set the Push-Pull CMD line
916 \ref ARM_MCI_BUS_CMD_OPEN_DRAIN                               | Set the Open Drain CMD line (MMC only)
917  
918  
919 <b>Bus Data Width</b> 
920  
921 Specifies the bus data width (the number of data I/O pins on the SD/MMC interface).
922  
923 For high speed memory cards, a 4-bit bus data width should be used (or 8-bit for eMMC). The bit fields ARM_MCI_CAPABILITIES.data_width_4 and
924 ARM_MCI_CAPABILITIES.data_width_8 encode whether the driver supports a specific bus data with.
925
926 The \em control operation \b ARM_MCI_BUS_DATA_WIDTH  sets the bus data width using the parameter \em arg.
927
928 Parameter \em arg                                             | Bus Data Width
929 :-------------------------------------------------------------|:------------------------------------------
930 \ref ARM_MCI_BUS_DATA_WIDTH_1 (default)                       | Set the Bus data width to \token{1 bit} 
931 \ref ARM_MCI_BUS_DATA_WIDTH_4                                 | Set the Bus data width to \token{4 bits}
932 \ref ARM_MCI_BUS_DATA_WIDTH_8                                 | Set the Bus data width to \token{8 bits}
933 \ref ARM_MCI_BUS_DATA_WIDTH_4_DDR                             | Set the Bus data width to \token{4 bits}, DDR (Dual Data Rate) - MMC only
934 \ref ARM_MCI_BUS_DATA_WIDTH_8_DDR                             | Set the Bus data width to \token{8 bits}, DDR (Dual Data Rate) - MMC only
935  
936  
937 <b>Driver Type</b> 
938  
939 Specifies the interface driver type.
940
941 The \em control operation \b ARM_MCI_DRIVER_STRENGTH  sets the interface driver type using the parameter \em arg.
942
943 Parameter \em arg                                             | Driver Type 
944 :-------------------------------------------------------------|:------------------------------------------
945 \ref ARM_MCI_DRIVER_TYPE_A                                    | Set the interface to SD UHS-I Driver Type A
946 \ref ARM_MCI_DRIVER_TYPE_B  (default)                         | Set the interface to SD UHS-I Driver Type B 
947 \ref ARM_MCI_DRIVER_TYPE_C                                    | Set the interface to SD UHS-I Driver Type C
948 \ref ARM_MCI_DRIVER_TYPE_D                                    | Set the interface to SD UHS-I Driver Type D
949
950 \b Examples:
951 \code
952 // Set Bus Speed to 25MHz
953 MCIdrv->Control(ARM_MCI_BUS_SPEED, 25000000);
954  
955 // Set High Speed mode
956 MCIdrv->Control(ARM_MCI_BUS_SPEED_MODE, ARM_MCI_BUS_HIGH_SPEED);
957  
958 // Configure CMD line as Open Drain (MMC only)
959 MCIdrv->Control(ARM_MCI_BUS_CMD_MODE, ARM_MCI_BUS_CMD_OPEN_DRAIN);
960  
961 // Set Bus Data Width = 4bits
962 MCIdrv->Control(ARM_MCI_BUS_DATA_WIDTH, ARM_MCI_BUS_DATA_WIDTH_4);
963  
964 // Set SD UHS-I Driver Type B
965 MCIdrv->Control(ARM_MCI_DRIVER_STRENGTH, ARM_MCI_DRIVER_TYPE_B);
966  
967 // RTS_n Pin is not active by default
968 // Assert RTS_n Pin (eMMC)
969 MCIdrv->Control(ARM_MCI_CONTROL_RESET, 1);
970 // De-assert RTS_n Pin (eMMC)
971 MCIdrv->Control(ARM_MCI_CONTROL_RESET, 0);
972  
973 // Clock generation on CLK when Idle: hardware specific default behavior
974 // Enable Clock generation on CLK when Idle
975 MCIdrv->Control(ARM_MCI_CONTROL_CLOCK_IDLE, 1);
976 // Disable Clock generation on CLK when Idle
977 MCIdrv->Control(ARM_MCI_CONTROL_CLOCK_IDLE, 0);
978  
979 // UHS Tuning
980 MCIdrv->Control(ARM_MCI_UHS_TUNING_OPERATION, 1);  // start tuning
981 do {
982   status = MCIdrv->Control(ARM_MCI_UHS_TUNING_RESULT, 0/*argument not used*/);
983   if (status == -1) { break; /* tuning failed */ }
984 } while (status == 1);
985  
986 // Set Data Timeout to 12500000 bus cycles (0.5s @25MHz Bus Speed)
987 // Default value is hardware specific (typically 2^32-1)
988 MCIdrv->Control(ARM_MCI_DATA_TIMEOUT, 12500000);
989   
990 // Set CSS Timeout to 1000000 bus cycles
991 // Default value is hardware specific
992 MCIdrv->Control(ARM_MCI_CSS_TIMEOUT, 1000000);
993  
994 // SD I/O Interrupt Monitoring is disabled by default
995 // Enable SD I/O Interrupt Monitoring
996 MCIdrv->Control(ARM_MCI_MONITOR_SDIO_INTERRUPT, 1);
997 // Disable SD I/O Interrupt Monitoring
998 MCIdrv->Control(ARM_MCI_MONITOR_SDIO_INTERRUPT, 0);
999  
1000 // Read/Wait for SD I/O is disabled by default
1001 // Enable Read/Wait for SD I/O
1002 MCIdrv->Control(ARM_MCI_CONTROL_READ_WAIT, 1);
1003 // Disable Read/Wait for SD I/O
1004 MCIdrv->Control(ARM_MCI_CONTROL_READ_WAIT, 0);
1005  
1006 // Suspend Data transfer (SD I/O)
1007 MCIdrv->Control(ARM_MCI_SUSPEND_TRANSFER, 0/*argument not used*/);
1008  
1009 // Resume Data transfer (SD I/O)
1010 MCIdrv->Control(ARM_MCI_RESUME_TRANSFER, 0/*argument not used*/);
1011 \endcode
1012 *******************************************************************************************************************/
1013
1014 ARM_MCI_STATUS ARM_MCI_GetStatus (void)  {
1015   return ARM_DRIVER_OK;
1016 }
1017 /**
1018 \fn            ARM_MCI_STATUS ARM_MCI_GetStatus (void)
1019 \details
1020 The function \b ARM_MCI_GetStatus returns the current MCI interface status.
1021 *******************************************************************************************************************/
1022
1023 void ARM_MCI_SignalEvent (uint32_t event)  {
1024  // function body
1025 }
1026 /**
1027 \fn void ARM_MCI_SignalEvent (uint32_t event)
1028 \details
1029 The function \b ARM_MCI_SignalEvent is a callback function registered by the function \ref ARM_MCI_Initialize. 
1030
1031 The parameter \em event indicates one or more events that occurred during driver operation.
1032 Each event is encoded in a separate bit and therefore it is possible to signal multiple events within the same call. 
1033
1034 Not every event is necessarily generated by the driver. This depends on the implemented capabilities stored in the 
1035 data fields of the structure \ref ARM_NAND_CAPABILITIES, which can be retrieved with the function \ref ARM_NAND_GetCapabilities.
1036
1037 The following events can be generated:
1038
1039 Parameter \em event                        |Bit | Description                                                           | supported when \ref ARM_NAND_CAPABILITIES
1040 :------------------------------------------|---:|:----------------------------------------------------------------------|:---------------------------------------------
1041 \ref ARM_MCI_EVENT_CARD_INSERTED           | 0  | Occurs after Memory Card inserted                                     | <i>always supported</i>
1042 \ref ARM_MCI_EVENT_CARD_REMOVED            | 1  | Occurs after Memory Card removal                                      | <i>always supported</i>
1043 \ref ARM_MCI_EVENT_COMMAND_COMPLETE        | 2  | Occurs after command completed successfully                           | <i>always supported</i>
1044 \ref ARM_MCI_EVENT_COMMAND_TIMEOUT         | 3  | Occurs after command timeout                                          | <i>always supported</i>
1045 \ref ARM_MCI_EVENT_COMMAND_ERROR           | 4  | Occurs after command response error (CRC error or invalid response)   | <i>always supported</i>
1046 \ref ARM_MCI_EVENT_TRANSFER_COMPLETE       | 5  | Occurs after data transfer completed successfully                     | <i>always supported</i>
1047 \ref ARM_MCI_EVENT_TRANSFER_TIMEOUT        | 6  | Occurs after data transfer timeout                                    | <i>always supported</i>
1048 \ref ARM_MCI_EVENT_TRANSFER_ERROR          | 7  | Occurs after data transfer error (CRC failed)                         | <i>always supported</i>
1049 \ref ARM_MCI_EVENT_SDIO_INTERRUPT          | 8  | Indicates SD I/O Interrupt                                            | data field \em sdio_interrupt = \token{1}
1050 \ref ARM_MCI_EVENT_CCS                     | 9  | Indicates a Command Completion Signal (CCS)                           | data field \em ccs = \token{1}
1051 \ref ARM_MCI_EVENT_CCS_TIMEOUT             |10  | Indicates a Command Completion Signal (CCS) Timeout                   | data field \em css_timeout = \token{1}
1052
1053 <b>See also:</b>
1054  - \ref ARM_MCI_SendCommand
1055  
1056 *******************************************************************************************************************/
1057
1058
1059 /**
1060 @}
1061 */ 
1062 // End MCI Interface