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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [drivers/] [Atmel/] [at91lib/] [peripherals/] [mci/] [mci.h] - Blame information for rev 608

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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