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