00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef SD_RAW_CONFIG_H
00012 #define SD_RAW_CONFIG_H
00013
00014 #include <stdint.h>
00015
00016 #ifdef __cplusplus
00017 extern "C"
00018 {
00019 #endif
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #define SD_RAW_WRITE_SUPPORT 1
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #define SD_RAW_WRITE_BUFFERING 1
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #define SD_RAW_SAVE_RAM 1
00060
00061
00062
00063
00064
00065
00066
00067
00068 #define SD_RAW_SDHC 0
00069
00070
00071
00072
00073
00074
00075 #if defined(__AVR_ATmega8__) || \
00076 defined(__AVR_ATmega48__) || \
00077 defined(__AVR_ATmega88__) || \
00078 defined(__AVR_ATmega168__)
00079 #define configure_pin_mosi() DDRB |= (1 << DDB3)
00080 #define configure_pin_sck() DDRB |= (1 << DDB5)
00081 #define configure_pin_ss() DDRB |= (1 << DDB2)
00082 #define configure_pin_miso() DDRB &= ~(1 << DDB4)
00083
00084 #define select_card() PORTB &= ~(1 << PB2)
00085 #define unselect_card() PORTB |= (1 << PB2)
00086 #elif defined(__AVR_ATmega16__) || \
00087 defined(__AVR_ATmega32__)
00088 #define configure_pin_mosi() DDRB |= (1 << DDB5)
00089 #define configure_pin_sck() DDRB |= (1 << DDB7)
00090 #define configure_pin_ss() DDRB |= (1 << DDB4)
00091 #define configure_pin_miso() DDRB &= ~(1 << DDB6)
00092
00093 #define select_card() PORTB &= ~(1 << PB4)
00094 #define unselect_card() PORTB |= (1 << PB4)
00095 #elif defined(__AVR_ATmega64__) || \
00096 defined(__AVR_ATmega128__) || \
00097 defined(__AVR_ATmega1281__) || \
00098 defined(__AVR_ATmega169__)
00099 #define configure_pin_mosi() DDRB |= (1 << DDB2)
00100 #define configure_pin_sck() DDRB |= (1 << DDB1)
00101 #define configure_pin_ss() DDRB |= (1 << DDB0)
00102 #define configure_pin_miso() DDRB &= ~(1 << DDB3)
00103
00104 #define select_card() PORTB &= ~(1 << PB0)
00105 #define unselect_card() PORTB |= (1 << PB0)
00106 #else
00107 #error "no sd/mmc pin mapping available!"
00108 #endif
00109
00110
00111 #define configure_pin_available() DDRC &= ~(1 << DDC0)
00112 #define configure_pin_locked() DDRC &= ~(1 << DDC5)
00113
00114
00115 #define get_pin_available() ((PINC >> PC0) & 0x01)
00116 #define get_pin_locked() ((PINC >> PC5) & 0x01)
00117
00118
00119 #if SD_RAW_SDHC
00120 typedef uint64_t offset_t;
00121 #else
00122 typedef uint32_t offset_t;
00123 #endif
00124
00125
00126 #if SD_RAW_WRITE_SUPPORT
00127 #undef SD_RAW_SAVE_RAM
00128 #define SD_RAW_SAVE_RAM 0
00129 #else
00130 #undef SD_RAW_WRITE_BUFFERING
00131 #define SD_RAW_WRITE_BUFFERING 0
00132 #endif
00133
00134 #ifdef __cplusplus
00135 }
00136 #endif
00137
00138 #endif
00139