OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_AT91SAM3U256_IAR/] [AT91Lib/] [peripherals/] [mci/] [mci.h] - Blame information for rev 609

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 580 jeremybenn
/* ----------------------------------------------------------------------------
2
 *         ATMEL Microcontroller Software Support
3
 * ----------------------------------------------------------------------------
4
 * Copyright (c) 2008, Atmel Corporation
5
 *
6
 * All rights reserved.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions are met:
10
 *
11
 * - Redistributions of source code must retain the above copyright notice,
12
 * this list of conditions and the disclaimer below.
13
 *
14
 * Atmel's name may not be used to endorse or promote products derived from
15
 * this software without specific prior written permission.
16
 *
17
 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20
 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 * ----------------------------------------------------------------------------
28
 */
29
 
30
//------------------------------------------------------------------------------
31
/// \page "mci"
32
///
33
/// !Purpose
34
///  
35
/// mci-interface driver
36
///
37
/// !Usage
38
///
39
/// -# MCI_Init: Initializes a MCI driver instance and the underlying peripheral.
40
/// -# MCI_SetSpeed : Configure the  MCI CLKDIV in the MCI_MR register.
41
/// -# MCI_SendCommand: Starts a MCI  transfer.
42
/// -# MCI_Handler : Interrupt handler which is called by ISR handler.
43
/// -# MCI_SetBusWidth : Configure the  MCI SDCBUS in the MCI_SDCR register.
44
//------------------------------------------------------------------------------
45
 
46
 
47
#ifndef MCI_H
48
#define MCI_H
49
 
50
//------------------------------------------------------------------------------
51
//         Headers
52
//------------------------------------------------------------------------------
53
 
54
#include <board.h>
55
 
56
//------------------------------------------------------------------------------
57
//         Constants
58
//------------------------------------------------------------------------------
59
 
60
/// Transfer is pending.
61
#define MCI_STATUS_PENDING      1
62
/// Transfer has been aborted because an error occured.
63
#define MCI_STATUS_ERROR        2
64
/// Card did not answer command.
65
#define MCI_STATUS_NORESPONSE   3
66
 
67
/// MCI driver is currently in use.
68
#define MCI_ERROR_LOCK    1
69
 
70
/// MCI configuration with 1-bit data bus on slot A (for MMC cards).
71
#define MCI_MMC_SLOTA           0
72
/// MCI configuration with 1-bit data bus on slot B (for MMC cards).
73
#define MCI_MMC_SLOTB           1
74
/// MCI configuration with 4-bit data bus on slot A (for SD cards).
75
#define MCI_SD_SLOTA            AT91C_MCI_SCDBUS
76
/// MCI configuration with 4-bit data bus on slot B (for SD cards).
77
#define MCI_SD_SLOTB            (AT91C_MCI_SCDBUS | 1)
78
 
79
/// Start new data transfer
80
#define MCI_NEW_TRANSFER        0
81
/// Continue data transfer
82
#define MCI_CONTINUE_TRANSFER   1
83
 
84
/// MCI SD Bus Width 1-bit
85
#define MCI_SDCBUS_1BIT (0 << 7)
86
/// MCI SD Bus Width 4-bit
87
#define MCI_SDCBUS_4BIT (1 << 7)
88
 
89
//------------------------------------------------------------------------------
90
//         Types
91
//------------------------------------------------------------------------------
92
 
93
/// MCI end-of-transfer callback function.
94
typedef void (*MciCallback)(unsigned char status, void *pCommand);
95
 
96
//------------------------------------------------------------------------------
97
/// MCI Transfer Request prepared by the application upper layer. This structure
98
/// is sent to the MCI_SendCommand function to start the transfer. At the end of
99
/// the transfer, the callback is invoked by the interrupt handler.
100
//------------------------------------------------------------------------------
101
typedef struct _MciCmd {
102
 
103
    /// Command status.
104
        volatile char status;
105
    /// Command code.
106
        unsigned int cmd;
107
    /// Command argument.
108
        unsigned int arg;
109
    /// Data buffer.
110
        unsigned char *pData;
111
    /// Size of data buffer in bytes.
112
        unsigned short blockSize;
113
        /// Number of blocks to be transfered
114
        unsigned short nbBlock;
115
        /// Indicate if continue to transfer data
116
        unsigned char conTrans;
117
    /// Indicates if the command is a read operation.
118
        unsigned char isRead;
119
    /// Response buffer.
120
    unsigned int  *pResp;
121
    /// SD card response type.
122
        unsigned char  resType;
123
        /// Optional user-provided callback function.
124
        MciCallback callback;
125
    /// Optional argument to the callback function.
126
        void *pArg;
127
 
128
} MciCmd;
129
 
130
//------------------------------------------------------------------------------
131
/// MCI driver structure. Holds the internal state of the MCI driver and
132
/// prevents parallel access to a MCI peripheral.
133
//------------------------------------------------------------------------------
134
typedef struct {
135
 
136
    /// Pointer to a MCI peripheral.
137
        AT91S_MCI *pMciHw;
138
    /// MCI peripheral identifier.
139
    unsigned char mciId;
140
    /// Pointer to currently executing command.
141
        MciCmd *pCommand;
142
        /// Mutex.
143
        volatile char semaphore;
144
 
145
} Mci;
146
 
147
//------------------------------------------------------------------------------
148
//         Global functions
149
//------------------------------------------------------------------------------
150
 
151
extern void MCI_Init(
152
    Mci *pMci,
153
    AT91PS_MCI pMciHw,
154
    unsigned char mciId,
155
    unsigned int mode);
156
 
157
extern void MCI_SetSpeed(Mci *pMci, unsigned int mciSpeed);
158
 
159
extern unsigned char MCI_SendCommand(Mci *pMci, MciCmd *pMciCmd);
160
 
161
extern void MCI_Handler(Mci *pMci);
162
 
163
extern unsigned char MCI_IsTxComplete(MciCmd *pMciCmd);
164
 
165
extern unsigned char MCI_CheckBusy(Mci *pMci);
166
 
167
extern void MCI_Close(Mci *pMci);
168
 
169
extern void MCI_SetBusWidth(Mci *pMci, unsigned char busWidth);
170
 
171
#endif //#ifndef MCI_H
172
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.