source: branch/giet_vm_ioc_drivers/giet_drivers/sdc_driver.h @ 284

Last change on this file since 284 was 284, checked in by cfuguet, 10 years ago

Modification of comments format on SPI-SDCARD driver to respect
GIET-VM format

File size: 4.1 KB
RevLine 
[284]1///////////////////////////////////////////////////////////////////////////////////
2// File     : sdc_driver.h
3// Date     : 31/08/2012
4// Author   : cesar fuguet
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7#ifndef _GIET_SDC_DRIVER_H_
8#define _GIET_SDC_DRIVER_H_
[283]9
10#include <ioc_driver.h>
11#include <spi_driver.h>
12#include <mapping_info.h>
13
[284]14///////////////////////////////////////////////////////////////////////////////
15// SD card structure definition
16///////////////////////////////////////////////////////////////////////////////
[283]17struct sdcard_dev
18{ 
[284]19    // SPI controller pointer
[283]20    struct spi_dev * spi;
21
[284]22    // block length of the SDCARD
[283]23    unsigned int block_length;
24
[284]25    // access pointer representing the offset in bytes used to read or write in
26    // the SDCARD. This driver is for cards SDSD, therefore this offset must be
27    // multiple of the block length
[283]28    unsigned int access_pointer;
29
[284]30    // slave ID. This ID represents the number of the slave select signal used
31    // in the hardware platform (SPI channel)
32    int slave_id;
[283]33
[284]34    // is the card high capacity ?
[283]35    int sdhc;
36};
37
38unsigned int _sdc_init( unsigned int channel );
39
40
41unsigned int _sdc_read( unsigned int mode,
42                        unsigned int lba,
43                        paddr_t      buffer,
44                        unsigned int count);
45
46
47unsigned int _sdc_write( unsigned int mode,
48                         unsigned int lba,
49                         paddr_t      buffer,
50                         unsigned int count);
51
52unsigned int _sdc_get_block_size();
53
54unsigned int _sdc_get_status( unsigned int channel ,
55                              unsigned int* status );
56
57
[284]58///////////////////////////////////////////////////////////////////////////////
59// SD card constants
60///////////////////////////////////////////////////////////////////////////////
[283]61
[284]62// Number of retries after an unacknowledge command
63#define SDCARD_COMMAND_TIMEOUT  100
[283]64
[284]65// This command is a simple SD commmand
66#define SDCARD_CMD              0
[283]67
[284]68// This is an application specific command
69#define SDCARD_ACMD             1
[283]70
[284]71// The transmition is done in the negative edge of the clock
72#define SDCARD_TX_NEGEDGE       0
[283]73
[284]74// The transmition is done in the positive edge of the clock
75#define SDCARD_TX_POSEDGE       1
[283]76
[284]77// The reception is done in the negative edge of the clock
78#define SDCARD_RX_NEGEDGE       0
[283]79
[284]80// The reception is done in the positive edge of the clock
81#define SDCARD_RX_POSEDGE       1
[283]82
[284]83///////////////////////////////////////////////////////////////////////////////
84// SD card macros
85///////////////////////////////////////////////////////////////////////////////
[283]86
[284]87///////////////////////////////////////////////////////////////////////////////
88//   SDCARD_CHECK_R1_VALID()
89// This macro checks if the SD card response is valid
90// - x: SD card response
91// Returns 1 if valid and 0 otherwise
92///////////////////////////////////////////////////////////////////////////////
[283]93#define SDCARD_CHECK_R1_VALID(x)    (~x & SDCARD_R1_RSP_VALID) ? 1 : 0
94
[284]95///////////////////////////////////////////////////////////////////////////////
96//   SDCARD_CHECK_R1_ERROR()
97// This macro checks if there is an error in SD card response
98// - x: SD card response
99// Returns 1 if error and 0 otherwise
100///////////////////////////////////////////////////////////////////////////////
[283]101#define SDCARD_CHECK_R1_ERROR(x)    ( x & 0x7E)                ? 1 : 0
102
[284]103// SD card response 1 (R1) format constants
104#define SDCARD_R1_IN_IDLE_STATE     ( 1 << 0 ) // R1 bit 0
105#define SDCARD_R1_ERASE_RESET       ( 1 << 1 ) // R1 bit 1
106#define SDCARD_R1_ILLEGAL_CMD       ( 1 << 2 ) // R1 bit 2
107#define SDCARD_R1_COM_CRC_ERR       ( 1 << 3 ) // R1 bit 3
108#define SDCARD_R1_ERASE_SEQ_ERR     ( 1 << 4 ) // R1 bit 4
109#define SDCARD_R1_ADDRESS_ERR       ( 1 << 5 ) // R1 bit 5
110#define SDCARD_R1_PARAMETER_ERR     ( 1 << 6 ) // R1 bit 6
111#define SDCARD_R1_RSP_VALID         ( 1 << 7 ) // R1 bit 7
[283]112
113#endif
114
[284]115// Local Variables:
116// tab-width: 4
117// c-basic-offset: 4
118// c-file-offsets:((innamespace . 0)(inline-open . 0))
119// indent-tabs-mode: nil
120// End:
121// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
Note: See TracBrowser for help on using the repository browser.