Ticket #1356: spi-sd-card.h

File spi-sd-card.h, 2.0 KB (added by Gene Smith, on Jan 22, 2009 at 3:02:23 PM)

Adds block_addr to driver structure

Line 
1/**
2 * @file
3 *
4 * @brief SD Card LibI2C driver.
5 */
6
7/*
8 * Copyright (c) 2008
9 * Embedded Brains GmbH
10 * Obere Lagerstr. 30
11 * D-82178 Puchheim
12 * Germany
13 * rtems@embedded-brains.de
14 *
15 * The license and distribution terms for this file may be found in the file
16 * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
17 */
18
19#ifndef LIBI2C_SD_CARD_H
20#define LIBI2C_SD_CARD_H
21
22#include <stdint.h>
23#include <stdbool.h>
24
25#include <rtems/libi2c.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif /* __cplusplus */
30
31#define SD_CARD_IDLE_TOKEN 0xff
32
33/**
34 * 1 idle token before command
35 * 6 bytes for the command
36 * 1 to 8 bytes for response start (N_CR)
37 * 1 to 2 bytes for response
38 * 1 idle token after command (minimum N_RC)
39 */
40#define SD_CARD_COMMAND_SIZE 18
41
42#define SD_CARD_TRANSFER_MODE_DEFAULT { .baudrate = 400000, .bits_per_char = 8, .lsb_first = FALSE, .clock_inv = FALSE, .clock_phs = FALSE, .idle_char = SD_CARD_IDLE_TOKEN }
43
44#define SD_CARD_COMMAND_DEFAULT { \
45        SD_CARD_IDLE_TOKEN, \
46        0x40, 0, 0, 0, 0, 0x95, \
47        SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
48        SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
49        SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
50        SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
51        SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
52        SD_CARD_IDLE_TOKEN \
53}
54
55#define SD_CARD_N_AC_MAX_DEFAULT 8
56
57typedef struct {
58        rtems_libi2c_drv_t driver;
59        int table_index;
60        rtems_device_minor_number minor;
61        const char *device_name;
62        const char *disk_device_name;
63        rtems_libi2c_tfr_mode_t transfer_mode;
64        uint8_t command [SD_CARD_COMMAND_SIZE];
65        uint8_t response [SD_CARD_COMMAND_SIZE];
66        int response_index;
67        uint32_t n_ac_max; 
68        uint32_t block_number;
69        uint32_t block_size;
70        uint32_t block_size_shift;
71        bool busy;
72        bool verbose;
73        bool schedule_if_busy;
74        bool block_addr;        /* new gds */
75} sd_card_driver_entry;
76
77extern const rtems_driver_address_table sd_card_driver_ops;
78
79extern sd_card_driver_entry sd_card_driver_table [];
80
81#ifdef __cplusplus
82}
83#endif /* __cplusplus */
84
85#endif /* LIBI2C_SD_CARD_H */