source: rtems/bsps/include/libchip/spi-sd-card.h @ fe6d96c

Last change on this file since fe6d96c was fe6d96c, checked in by Joel Sherrill <joel@…>, on 03/01/22 at 21:39:06

bsps/include/: Scripted embedded brains header file clean up

Updates #4625.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/**
2 * @file
3 *
4 * @brief SD Card LibI2C driver.
5 */
6
7/*
8 * Copyright (c) 2008 embedded brains GmbH.  All rights reserved.
9 * The license and distribution terms for this file may be
10 * found in the file LICENSE in this distribution or at
11 * http://www.rtems.org/license/LICENSE.
12 */
13
14#ifndef LIBI2C_SD_CARD_H
15#define LIBI2C_SD_CARD_H
16
17#include <stdint.h>
18#include <stdbool.h>
19
20#include <rtems/libi2c.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif /* __cplusplus */
25
26#define SD_CARD_IDLE_TOKEN 0xff
27
28/**
29 * 1 idle token before command
30 * 6 bytes for the command
31 * 1 to 8 bytes for response start (N_CR)
32 * 1 to 2 bytes for response
33 * 1 idle token after command (minimum N_RC)
34 */
35#define SD_CARD_COMMAND_SIZE 18
36
37#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 }
38
39#define SD_CARD_COMMAND_DEFAULT { \
40        SD_CARD_IDLE_TOKEN, \
41        0x40, 0, 0, 0, 0, 0x95, \
42        SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
43        SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
44        SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
45        SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
46        SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
47        SD_CARD_IDLE_TOKEN \
48}
49
50/* Default speed = 400kbps, default timeout = 100ms, n_ac_max is in bytes */
51#define SD_CARD_N_AC_MAX_DEFAULT 5000
52
53typedef struct {
54        const char *device_name;
55        rtems_device_minor_number bus;
56        rtems_libi2c_tfr_mode_t transfer_mode;
57        uint8_t command [SD_CARD_COMMAND_SIZE];
58        uint8_t response [SD_CARD_COMMAND_SIZE];
59        int response_index;
60        uint32_t n_ac_max;
61        uint32_t block_number;
62        uint32_t block_size;
63        uint32_t block_size_shift;
64        bool busy;
65        bool verbose;
66        bool schedule_if_busy;
67        uint32_t retries;
68} sd_card_driver_entry;
69
70extern sd_card_driver_entry sd_card_driver_table [];
71
72extern size_t sd_card_driver_table_size;
73
74rtems_status_code sd_card_register( void);
75
76#ifdef __cplusplus
77}
78#endif /* __cplusplus */
79
80#endif /* LIBI2C_SD_CARD_H */
Note: See TracBrowser for help on using the repository browser.