Rev Author Line No. Line
1110 kaklik 1  
2 /*
3 * Copyright (c) 2006-2007 by Roland Riegel <feedback@roland-riegel.de>
4 *
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.
9 */
10  
11 #ifndef SD_RAW_CONFIG_H
12 #define SD_RAW_CONFIG_H
13  
14 /**
15 * \addtogroup sd_raw
16 *
17 * @{
18 */
19 /**
20 * \file
21 * MMC/SD support configuration (license: GPLv2 or LGPLv2.1)
22 */
23  
24 /**
25 * \ingroup sd_raw_config
26 * Controls MMC/SD write support.
27 *
28 * Set to 1 to enable MMC/SD write support, set to 0 to disable it.
29 */
30 #define SD_RAW_WRITE_SUPPORT 1
31  
32 /**
33 * \ingroup sd_raw_config
34 * Controls MMC/SD write buffering.
35 *
36 * Set to 1 to buffer write accesses, set to 0 to disable it.
37 *
38 * \note This option has no effect when SD_RAW_WRITE_SUPPORT is 0.
39 */
40 #define SD_RAW_WRITE_BUFFERING 1
41  
42 /**
43 * \ingroup sd_raw_config
44 * Controls MMC/SD access buffering.
45 *
46 * Set to 1 to save static RAM, but be aware that you will
47 * lose performance.
48 *
49 * \note When SD_RAW_WRITE_SUPPORT is 1, SD_RAW_SAVE_RAM will
50 * be reset to 0.
51 */
52 #define SD_RAW_SAVE_RAM 1
53  
54 /* defines for customisation of sd/mmc port access */
55 #if defined(__AVR_ATmega8__) || \
56 defined(__AVR_ATmega48__) || \
57 defined(__AVR_ATmega88__) || \
58 defined(__AVR_ATmega168__)
59 #define configure_pin_mosi() DDRB |= (1 << DDB3)
60 #define configure_pin_sck() DDRB |= (1 << DDB5)
61 #define configure_pin_ss() DDRB |= (1 << DDB2)
62 #define configure_pin_miso() DDRB &= ~(1 << DDB4)
63  
64 #define select_card() PORTB &= ~(1 << PB2)
65 #define unselect_card() PORTB |= (1 << PB2)
66 #elif defined(__AVR_ATmega16__) || \
67 defined(__AVR_ATmega32__)
68 #define configure_pin_mosi() DDRB |= (1 << DDB5)
69 #define configure_pin_sck() DDRB |= (1 << DDB7)
70 #define configure_pin_ss() DDRB |= (1 << DDB4)
71 #define configure_pin_miso() DDRB &= ~(1 << DDB6)
72  
73 #define select_card() PORTB &= ~(1 << PB4)
74 #define unselect_card() PORTB |= (1 << PB4)
75 #elif defined(__AVR_ATmega64__) || \
76 defined(__AVR_ATmega128__) || \
77 defined(__AVR_ATmega169__)
78 #define configure_pin_mosi() DDRB |= (1 << DDB2)
79 #define configure_pin_sck() DDRB |= (1 << DDB1)
80 #define configure_pin_ss() DDRB |= (1 << DDB0)
81 #define configure_pin_miso() DDRB &= ~(1 << DDB3)
82  
83 #define select_card() PORTB &= ~(1 << PB0)
84 #define unselect_card() PORTB |= (1 << PB0)
85 #else
86 #error "no sd/mmc pin mapping available!"
87 #endif
88  
89 #define configure_pin_available() DDRC &= ~(1 << DDC4)
90 #define configure_pin_locked() DDRC &= ~(1 << DDC5)
91  
92 #define get_pin_available() ((PINC >> PC4) & 0x01)
93 #define get_pin_locked() ((PINC >> PC5) & 0x01)
94  
95 /**
96 * @}
97 */
98  
99 /* configuration checks */
100 #if SD_RAW_WRITE_SUPPORT
101 #undef SD_RAW_SAVE_RAM
102 #define SD_RAW_SAVE_RAM 0
103 #else
104 #undef SD_RAW_WRITE_BUFFERING
105 #define SD_RAW_WRITE_BUFFERING 0
106 #endif
107  
108 #endif
109