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.
74 /* defines for customisation of sd/mmc port access */
75 #if defined(__AVR_ATmega8__) || \
76 defined(__AVR_ATmega48__) || \
77 defined(__AVR_ATmega48P__) || \
78 defined(__AVR_ATmega88__) || \
79 defined(__AVR_ATmega88P__) || \
80 defined(__AVR_ATmega168__) || \
81 defined(__AVR_ATmega168P__) || \
82 defined(__AVR_ATmega328P__)
83 #define configure_pin_mosi() DDRB |= (1 << DDB3)
84 #define configure_pin_sck() DDRB |= (1 << DDB5)
85 #define configure_pin_ss() DDRB |= (1 << DDB2)
86 #define configure_pin_miso() DDRB &= ~(1 << DDB4)
88 #define select_card() PORTB &= ~(1 << PORTB2)
89 #define unselect_card() PORTB |= (1 << PORTB2)
90 #elif defined(__AVR_ATmega16__) || \
91 defined(__AVR_ATmega32__)
92 #define configure_pin_mosi() DDRB |= (1 << DDB5)
93 #define configure_pin_sck() DDRB |= (1 << DDB7)
94 #define configure_pin_ss() DDRB |= (1 << DDB4)
95 #define configure_pin_miso() DDRB &= ~(1 << DDB6)
97 #define select_card() PORTB &= ~(1 << PORTB4)
98 #define unselect_card() PORTB |= (1 << PORTB4)
99 #elif defined(__AVR_ATmega64__) || \
100 defined(__AVR_ATmega128__) || \
101 defined(__AVR_ATmega169__)
102 #define configure_pin_mosi() DDRB |= (1 << DDB2)
103 #define configure_pin_sck() DDRB |= (1 << DDB1)
104 #define configure_pin_ss() DDRB |= (1 << DDB0)
105 #define configure_pin_miso() DDRB &= ~(1 << DDB3)
107 #define select_card() PORTB &= ~(1 << PORTB0)
108 #define unselect_card() PORTB |= (1 << PORTB0)
110 #error "no sd/mmc pin mapping available!"
113 #define configure_pin_available() DDRC &= ~(1 << DDC4)
114 #define configure_pin_locked() DDRC &= ~(1 << DDC5)
116 #define get_pin_available() (PINC & (1 << PINC4))
117 #define get_pin_locked() (PINC & (1 << PINC5))
120 typedef uint64_t offset_t;
122 typedef uint32_t offset_t;
125 /* configuration checks */
126 #if SD_RAW_WRITE_SUPPORT
127 #undef SD_RAW_SAVE_RAM
128 #define SD_RAW_SAVE_RAM 0
130 #undef SD_RAW_WRITE_BUFFERING
131 #define SD_RAW_WRITE_BUFFERING 0