error_config: do not dump file line in logs
[protos/imu.git] / sd_raw_config.h
1
2 /*
3  * Copyright (c) 2006-2012 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 #include <stdint.h>
15
16 #ifdef __cplusplus
17 extern "C"
18 {
19 #endif
20
21 /**
22  * \addtogroup sd_raw
23  *
24  * @{
25  */
26 /**
27  * \file
28  * MMC/SD support configuration (license: GPLv2 or LGPLv2.1)
29  */
30
31 /**
32  * \ingroup sd_raw_config
33  * Controls MMC/SD write support.
34  *
35  * Set to 1 to enable MMC/SD write support, set to 0 to disable it.
36  */
37 #define SD_RAW_WRITE_SUPPORT 1
38
39 /**
40  * \ingroup sd_raw_config
41  * Controls MMC/SD write buffering.
42  *
43  * Set to 1 to buffer write accesses, set to 0 to disable it.
44  *
45  * \note This option has no effect when SD_RAW_WRITE_SUPPORT is 0.
46  */
47 #define SD_RAW_WRITE_BUFFERING 1
48
49 /**
50  * \ingroup sd_raw_config
51  * Controls MMC/SD access buffering.
52  * 
53  * Set to 1 to save static RAM, but be aware that you will
54  * lose performance.
55  *
56  * \note When SD_RAW_WRITE_SUPPORT is 1, SD_RAW_SAVE_RAM will
57  *       be reset to 0.
58  */
59 #define SD_RAW_SAVE_RAM 1
60
61 /**
62  * \ingroup sd_raw_config
63  * Controls support for SDHC cards.
64  *
65  * Set to 1 to support so-called SDHC memory cards, i.e. SD
66  * cards with more than 2 gigabytes of memory.
67  */
68 #define SD_RAW_SDHC 0
69
70 /**
71  * @}
72  */
73
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)
87
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)
96
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)
106
107     #define select_card() PORTB &= ~(1 << PORTB0)
108     #define unselect_card() PORTB |= (1 << PORTB0)
109 #else
110     #error "no sd/mmc pin mapping available!"
111 #endif
112
113 #define configure_pin_available() DDRC &= ~(1 << DDC4)
114 #define configure_pin_locked() DDRC &= ~(1 << DDC5)
115
116 #define get_pin_available() (PINC & (1 << PINC4))
117 #define get_pin_locked() (PINC & (1 << PINC5))
118
119 #if SD_RAW_SDHC
120     typedef uint64_t offset_t;
121 #else
122     typedef uint32_t offset_t;
123 #endif
124
125 /* configuration checks */
126 #if SD_RAW_WRITE_SUPPORT
127 #undef SD_RAW_SAVE_RAM
128 #define SD_RAW_SAVE_RAM 0
129 #else
130 #undef SD_RAW_WRITE_BUFFERING
131 #define SD_RAW_WRITE_BUFFERING 0
132 #endif
133
134 #ifdef __cplusplus
135 }
136 #endif
137
138 #endif
139