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

Subversion Repositories igor

[/] [igor/] [trunk/] [avr/] [src/] [dev/] [mmc.h] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 atypic
/************************************************************************
2
**
3
**  Copyright (C) 2006  Jesper Hansen <jesper@redegg.net>
4
**  Modified for use with the IGOR Lisp machine
5
**
6
**  Interface functions for MMC/SD cards
7
**
8
**  File mmc_if.h
9
**
10
*************************************************************************
11
**
12
**  This program is free software; you can redistribute it and/or
13
**  modify it under the terms of the GNU General Public License
14
**  as published by the Free Software Foundation; either version 2
15
**  of the License, or (at your option) any later version.
16
**
17
**  This program is distributed in the hope that it will be useful,
18
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
19
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
**  GNU General Public License for more details.
21
**
22
**  You should have received a copy of the GNU General Public License
23
**  along with this program; if not, write to the Free Software Foundation,
24
**  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
**
26
*************************************************************************/
27
 
28
/** \file mmc_if.h
29
    Simple MMC/SD-card functionality
30
*/
31
 
32
#ifndef __MMC_H__
33
#define __MMC_H__
34
#include "spi.h"
35
 
36
//The size of sectors read from SD/MMC
37
#define SECTOR_SIZE 512
38
 
39
/** @name MMC/SD Card I/O lines in SPI mode
40
*/
41
//@{
42
#define MMC_SCK         SPI_SCK
43
#define MMC_MOSI        SPI_MOSI
44
#define MMC_MISO        SPI_MISO
45
#define MMC_CS          SPI_SS_MMC
46
//@}
47
 
48
 
49
 
50
/** Helper structure.
51
    This simplify conversion between bytes and words.
52
*/
53
struct u16bytes
54
{
55
    uint8_t low;        //!< byte member
56
        uint8_t high;   //!< byte member
57
};
58
 
59
/** Helper union.
60
    This simplify conversion between bytes and words.
61
*/
62
union u16convert
63
{
64
    uint16_t value;                     //!< for word access
65
        struct u16bytes bytes;  //!< for byte access
66
};
67
 
68
/** Helper structure.
69
    This simplify conversion between bytes and longs.
70
*/
71
struct u32bytes
72
{
73
    uint8_t byte1;      //!< byte member
74
        uint8_t byte2;  //!< byte member
75
        uint8_t byte3;  //!< byte member
76
        uint8_t byte4;  //!< byte member
77
};
78
 
79
/** Helper structure.
80
    This simplify conversion between words and longs.
81
*/
82
struct u32words
83
{
84
    uint16_t low;               //!< word member
85
        uint16_t high;          //!< word member
86
};
87
 
88
/** Helper union.
89
    This simplify conversion between bytes, words and longs.
90
*/
91
union u32convert
92
{
93
    uint32_t value;                     //!< for long access
94
        struct u32words words;  //!< for word access
95
        struct u32bytes bytes;  //!< for byte access
96
};
97
 
98
//Read a sector into the sector buffer
99
uint8_t read_sector_to_buffer(uint32_t lba);
100
 
101
//Write the sector buffer into a sector
102
uint8_t write_buffer_to_sector(uint32_t lba);
103
 
104
 
105
/** Read MMC/SD sector.
106
     Read a single 512 byte sector from the MMC/SD card
107
    \param lba  Logical sectornumber to read
108
    \param buffer       Pointer to buffer for received data
109
    \return 0 on success, -1 on error
110
*/
111
int mmc_readsector(uint32_t lba, uint8_t *buffer);
112
 
113
//Write MMC/SD sector
114
int mmc_writesector(uint32_t lba, uint8_t *buffer);
115
 
116
/** Init MMC/SD card.
117
    Initialize I/O ports for the MMC/SD interface and
118
    send init commands to the MMC/SD card
119
    \return 0 on success, other values on error
120
*/
121
uint8_t mmc_init(void);
122
 
123
#endif
124
 

powered by: WebSVN 2.1.0

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