![]() |
|
|||
File indexing completed on 2025-05-11 08:23:43
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @brief SD Card LibI2C driver. 0007 */ 0008 0009 /* 0010 * Copyright (c) 2008 embedded brains GmbH & Co. KG 0011 * Redistribution and use in source and binary forms, with or without 0012 * modification, are permitted provided that the following conditions 0013 * are met: 0014 * 1. Redistributions of source code must retain the above copyright 0015 * notice, this list of conditions and the following disclaimer. 0016 * 2. Redistributions in binary form must reproduce the above copyright 0017 * notice, this list of conditions and the following disclaimer in the 0018 * documentation and/or other materials provided with the distribution. 0019 * 0020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0021 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0022 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0023 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0024 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0025 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0026 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0029 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0030 * POSSIBILITY OF SUCH DAMAGE. 0031 */ 0032 0033 #ifndef LIBI2C_SD_CARD_H 0034 #define LIBI2C_SD_CARD_H 0035 0036 #include <stdint.h> 0037 #include <stdbool.h> 0038 0039 #include <rtems/libi2c.h> 0040 0041 #ifdef __cplusplus 0042 extern "C" { 0043 #endif /* __cplusplus */ 0044 0045 #define SD_CARD_IDLE_TOKEN 0xff 0046 0047 /** 0048 * 1 idle token before command 0049 * 6 bytes for the command 0050 * 1 to 8 bytes for response start (N_CR) 0051 * 1 to 2 bytes for response 0052 * 1 idle token after command (minimum N_RC) 0053 */ 0054 #define SD_CARD_COMMAND_SIZE 18 0055 0056 #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 } 0057 0058 #define SD_CARD_COMMAND_DEFAULT { \ 0059 SD_CARD_IDLE_TOKEN, \ 0060 0x40, 0, 0, 0, 0, 0x95, \ 0061 SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \ 0062 SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \ 0063 SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \ 0064 SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \ 0065 SD_CARD_IDLE_TOKEN, SD_CARD_IDLE_TOKEN, \ 0066 SD_CARD_IDLE_TOKEN \ 0067 } 0068 0069 /* Default speed = 400kbps, default timeout = 100ms, n_ac_max is in bytes */ 0070 #define SD_CARD_N_AC_MAX_DEFAULT 5000 0071 0072 typedef struct { 0073 const char *device_name; 0074 rtems_device_minor_number bus; 0075 rtems_libi2c_tfr_mode_t transfer_mode; 0076 uint8_t command [SD_CARD_COMMAND_SIZE]; 0077 uint8_t response [SD_CARD_COMMAND_SIZE]; 0078 int response_index; 0079 uint32_t n_ac_max; 0080 uint32_t block_number; 0081 uint32_t block_size; 0082 uint32_t block_size_shift; 0083 bool busy; 0084 bool verbose; 0085 bool schedule_if_busy; 0086 uint32_t retries; 0087 } sd_card_driver_entry; 0088 0089 extern sd_card_driver_entry sd_card_driver_table []; 0090 0091 extern size_t sd_card_driver_table_size; 0092 0093 rtems_status_code sd_card_register( void); 0094 0095 #ifdef __cplusplus 0096 } 0097 #endif /* __cplusplus */ 0098 0099 #endif /* LIBI2C_SD_CARD_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |