source: rtems/c/src/libchip/i2c/spi-sd-card.h @ b8fa5013

4.115
Last change on this file since b8fa5013 was d290bbb, checked in by Sebastian Huber <sebastian.huber@…>, on 06/24/10 at 07:54:15

2010-06-24 Arnout Vandecappelle <arnout@…>

PR 1586/misc

  • libchip/i2c/spi-sd-card.h, libchip/i2c/spi-sd-card.c: Add retries to SD card accesses.
  • Property mode set to 100644
File size: 2.0 KB
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/* Default speed = 400kbps, default timeout = 100ms, n_ac_max is in bytes */
56#define SD_CARD_N_AC_MAX_DEFAULT 5000
57
58typedef struct {
59        const char *device_name;
60        rtems_device_minor_number bus;
61        rtems_libi2c_tfr_mode_t transfer_mode;
62        uint8_t command [SD_CARD_COMMAND_SIZE];
63        uint8_t response [SD_CARD_COMMAND_SIZE];
64        int response_index;
65        uint32_t n_ac_max;
66        uint32_t block_number;
67        uint32_t block_size;
68        uint32_t block_size_shift;
69        bool busy;
70        bool verbose;
71        bool schedule_if_busy;
72        uint32_t retries;
73} sd_card_driver_entry;
74
75extern sd_card_driver_entry sd_card_driver_table [];
76
77extern size_t sd_card_driver_table_size;
78
79rtems_status_code sd_card_register( void);
80
81#ifdef __cplusplus
82}
83#endif /* __cplusplus */
84
85#endif /* LIBI2C_SD_CARD_H */
Note: See TracBrowser for help on using the repository browser.