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

4.104.115
Last change on this file since 9814d2dd was 9814d2dd, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 12/23/08 at 08:31:47

spi-sd-card.c, spi-sd-card.h: removed high-level driver IF, added generic block I/O functions

  • Property mode set to 100644
File size: 1.8 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#define SD_CARD_N_AC_MAX_DEFAULT 8
56
57typedef struct {
58        const char *device_name;
59        int bus;
60        rtems_libi2c_tfr_mode_t transfer_mode;
61        uint8_t command [SD_CARD_COMMAND_SIZE];
62        uint8_t response [SD_CARD_COMMAND_SIZE];
63        int response_index;
64        uint32_t n_ac_max;
65        uint32_t block_number;
66        uint32_t block_size;
67        uint32_t block_size_shift;
68        bool busy;
69        bool verbose;
70        bool schedule_if_busy;
71} sd_card_driver_entry;
72
73extern sd_card_driver_entry sd_card_driver_table [];
74
75extern size_t sd_card_driver_table_size;
76
77rtems_status_code sd_card_register( void);
78
79#ifdef __cplusplus
80}
81#endif /* __cplusplus */
82
83#endif /* LIBI2C_SD_CARD_H */
Note: See TracBrowser for help on using the repository browser.