RTEMS
6.1-rc4
Loading...
Searching...
No Matches
bsps
include
libchip
spi-sd-card.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
9
/*
10
* Copyright (c) 2008 embedded brains GmbH & Co. KG
11
* Redistribution and use in source and binary forms, with or without
12
* modification, are permitted provided that the following conditions
13
* are met:
14
* 1. Redistributions of source code must retain the above copyright
15
* notice, this list of conditions and the following disclaimer.
16
* 2. Redistributions in binary form must reproduce the above copyright
17
* notice, this list of conditions and the following disclaimer in the
18
* documentation and/or other materials provided with the distribution.
19
*
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
* POSSIBILITY OF SUCH DAMAGE.
31
*/
32
33
#ifndef LIBI2C_SD_CARD_H
34
#define LIBI2C_SD_CARD_H
35
36
#include <stdint.h>
37
#include <stdbool.h>
38
39
#include <
rtems/libi2c.h
>
40
41
#ifdef __cplusplus
42
extern
"C"
{
43
#endif
/* __cplusplus */
44
45
#define SD_CARD_IDLE_TOKEN 0xff
46
54
#define SD_CARD_COMMAND_SIZE 18
55
56
#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 }
57
58
#define SD_CARD_COMMAND_DEFAULT { \
59
SD_CARD_IDLE_TOKEN, \
60
0x40, 0, 0, 0, 0, 0x95, \
61
SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
62
SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
63
SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
64
SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
65
SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \
66
SD_CARD_IDLE_TOKEN \
67
}
68
69
/* Default speed = 400kbps, default timeout = 100ms, n_ac_max is in bytes */
70
#define SD_CARD_N_AC_MAX_DEFAULT 5000
71
72
typedef
struct
{
73
const
char
*device_name;
74
rtems_device_minor_number
bus;
75
rtems_libi2c_tfr_mode_t
transfer_mode;
76
uint8_t command [
SD_CARD_COMMAND_SIZE
];
77
uint8_t response [
SD_CARD_COMMAND_SIZE
];
78
int
response_index;
79
uint32_t n_ac_max;
80
uint32_t block_number;
81
uint32_t block_size;
82
uint32_t block_size_shift;
83
bool
busy;
84
bool
verbose;
85
bool
schedule_if_busy;
86
uint32_t retries;
87
}
sd_card_driver_entry
;
88
89
extern
sd_card_driver_entry
sd_card_driver_table [];
90
91
extern
size_t
sd_card_driver_table_size;
92
93
rtems_status_code
sd_card_register(
void
);
94
95
#ifdef __cplusplus
96
}
97
#endif
/* __cplusplus */
98
99
#endif
/* LIBI2C_SD_CARD_H */
rtems_device_minor_number
uint32_t rtems_device_minor_number
This integer type represents the minor number of devices.
Definition:
io.h:115
rtems_status_code
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition:
status.h:85
libi2c.h
Legacy I2C Library.
SD_CARD_COMMAND_SIZE
#define SD_CARD_COMMAND_SIZE
Definition:
spi-sd-card.h:54
rtems_libi2c_tfr_mode_t
Definition:
libi2c.h:462
sd_card_driver_entry
Definition:
spi-sd-card.h:72
Generated by
1.9.6