3 * Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
5 * This file is free software; you can redistribute it and/or modify
6 * it under the terms of either the GNU General Public License version 2
7 * or the GNU Lesser General Public License version 2.1, both as
8 * published by the Free Software Foundation.
11 #ifndef SD_RAW_CONFIG_H
12 #define SD_RAW_CONFIG_H
28 * MMC/SD support configuration (license: GPLv2 or LGPLv2.1)
32 * \ingroup sd_raw_config
33 * Controls MMC/SD write support.
35 * Set to 1 to enable MMC/SD write support, set to 0 to disable it.
37 #define SD_RAW_WRITE_SUPPORT 1
40 * \ingroup sd_raw_config
41 * Controls MMC/SD write buffering.
43 * Set to 1 to buffer write accesses, set to 0 to disable it.
45 * \note This option has no effect when SD_RAW_WRITE_SUPPORT is 0.
47 #define SD_RAW_WRITE_BUFFERING 1
50 * \ingroup sd_raw_config
51 * Controls MMC/SD access buffering.
53 * Set to 1 to save static RAM, but be aware that you will
56 * \note When SD_RAW_WRITE_SUPPORT is 1, SD_RAW_SAVE_RAM will
59 #define SD_RAW_SAVE_RAM 1
62 * \ingroup sd_raw_config
63 * Controls support for SDHC cards.
65 * Set to 1 to support so-called SDHC memory cards, i.e. SD
66 * cards with more than 2 gigabytes of memory.
76 #define configure_pin_mosi() DDRB |= (1 << DDB5)
77 #define configure_pin_sck() DDRB |= (1 << DDB7)
78 #define configure_pin_ss() DDRC |= (1 << DDC6)
79 #define configure_pin_miso() DDRB &= ~(1 << DDB6)
81 #define select_card() PORTC &= ~(1 << PORTC6)
82 #define unselect_card() PORTC |= (1 << PORTC6)
85 /* defines for customisation of sd/mmc port access */
86 #if defined(__AVR_ATmega8__) || \
87 defined(__AVR_ATmega48__) || \
88 defined(__AVR_ATmega48P__) || \
89 defined(__AVR_ATmega88__) || \
90 defined(__AVR_ATmega88P__) || \
91 defined(__AVR_ATmega168__) || \
92 defined(__AVR_ATmega168P__) || \
93 defined(__AVR_ATmega328P__)
94 #define configure_pin_mosi() DDRB |= (1 << DDB3)
95 #define configure_pin_sck() DDRB |= (1 << DDB5)
96 #define configure_pin_ss() DDRB |= (1 << DDB2)
97 #define configure_pin_miso() DDRB &= ~(1 << DDB4)
99 #define select_card() PORTB &= ~(1 << PORTB2)
100 #define unselect_card() PORTB |= (1 << PORTB2)
101 #elif defined(__AVR_ATmega16__) || \
102 defined(__AVR_ATmega32__)
103 #define configure_pin_mosi() DDRB |= (1 << DDB5)
104 #define configure_pin_sck() DDRB |= (1 << DDB7)
105 #define configure_pin_ss() DDRB |= (1 << DDB4)
106 #define configure_pin_miso() DDRB &= ~(1 << DDB6)
108 #define select_card() PORTB &= ~(1 << PORTB4)
109 #define unselect_card() PORTB |= (1 << PORTB4)
110 #elif defined(__AVR_ATmega64__) || \
111 defined(__AVR_ATmega128__) || \
112 defined(__AVR_ATmega169__)
113 #define configure_pin_mosi() DDRB |= (1 << DDB2)
114 #define configure_pin_sck() DDRB |= (1 << DDB1)
115 #define configure_pin_ss() DDRB |= (1 << DDB0)
116 #define configure_pin_miso() DDRB &= ~(1 << DDB3)
118 #define select_card() PORTB &= ~(1 << PORTB0)
119 #define unselect_card() PORTB |= (1 << PORTB0)
121 #error "no sd/mmc pin mapping available!"
125 #define configure_pin_available() do {} while (0) // DDRC &= ~(1 << DDC4)
126 #define configure_pin_locked() do {} while (0) // DDRC &= ~(1 << DDC5)
128 #define get_pin_available() (0) // (PINC & (1 << PINC4))
129 #define get_pin_locked() (1) // (PINC & (1 << PINC5))
132 typedef uint64_t offset_t;
134 typedef uint32_t offset_t;
137 /* configuration checks */
138 #if SD_RAW_WRITE_SUPPORT
139 #undef SD_RAW_SAVE_RAM
140 #define SD_RAW_SAVE_RAM 0
142 #undef SD_RAW_WRITE_BUFFERING
143 #define SD_RAW_WRITE_BUFFERING 0