fix gps message when position is not correct
[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 1
69
70 /**
71  * @}
72  */
73
74 #define zer0
75 #ifdef zer0
76     #define configure_pin_mosi() DDRB |= (1 << DDB5)
77     #define configure_pin_sck() DDRB |= (1 << DDB7)
78     #define configure_pin_ss() DDRC |= (1 << DDC6)
79     #define configure_pin_miso() DDRB &= ~(1 << DDB6)
80
81 #define select_card() PORTC &= ~(1 << PORTC6)
82 #define unselect_card() PORTC |= (1 << PORTC6)
83
84 #else
85 /* defines for customisation of sd/mmc port access */
86 #if defined(__AVR_ATmega8__) || \
87     defined(__AVR_ATmega48__) || \
88     defined(__AVR_ATmega48P__) || \
89     defined(__AVR_ATmega88__) || \
90     defined(__AVR_ATmega88P__) || \
91     defined(__AVR_ATmega168__) || \
92     defined(__AVR_ATmega168P__) || \
93     defined(__AVR_ATmega328P__)
94     #define configure_pin_mosi() DDRB |= (1 << DDB3)
95     #define configure_pin_sck() DDRB |= (1 << DDB5)
96     #define configure_pin_ss() DDRB |= (1 << DDB2)
97     #define configure_pin_miso() DDRB &= ~(1 << DDB4)
98
99     #define select_card() PORTB &= ~(1 << PORTB2)
100     #define unselect_card() PORTB |= (1 << PORTB2)
101 #elif defined(__AVR_ATmega16__) || \
102       defined(__AVR_ATmega32__)
103     #define configure_pin_mosi() DDRB |= (1 << DDB5)
104     #define configure_pin_sck() DDRB |= (1 << DDB7)
105     #define configure_pin_ss() DDRB |= (1 << DDB4)
106     #define configure_pin_miso() DDRB &= ~(1 << DDB6)
107
108     #define select_card() PORTB &= ~(1 << PORTB4)
109     #define unselect_card() PORTB |= (1 << PORTB4)
110 #elif defined(__AVR_ATmega64__) || \
111       defined(__AVR_ATmega128__) || \
112       defined(__AVR_ATmega169__)
113     #define configure_pin_mosi() DDRB |= (1 << DDB2)
114     #define configure_pin_sck() DDRB |= (1 << DDB1)
115     #define configure_pin_ss() DDRB |= (1 << DDB0)
116     #define configure_pin_miso() DDRB &= ~(1 << DDB3)
117
118     #define select_card() PORTB &= ~(1 << PORTB0)
119     #define unselect_card() PORTB |= (1 << PORTB0)
120 #else
121     #error "no sd/mmc pin mapping available!"
122 #endif
123 #endif
124
125 #define configure_pin_available() do {} while (0) // DDRC &= ~(1 << DDC4)
126 #define configure_pin_locked() do {} while (0) // DDRC &= ~(1 << DDC5)
127
128 #define get_pin_available() (0) // (PINC & (1 << PINC4))
129 #define get_pin_locked() (1) // (PINC & (1 << PINC5))
130
131 #if SD_RAW_SDHC
132     typedef uint64_t offset_t;
133 #else
134     typedef uint32_t offset_t;
135 #endif
136
137 /* configuration checks */
138 #if SD_RAW_WRITE_SUPPORT
139 #undef SD_RAW_SAVE_RAM
140 #define SD_RAW_SAVE_RAM 0
141 #else
142 #undef SD_RAW_WRITE_BUFFERING
143 #define SD_RAW_WRITE_BUFFERING 0
144 #endif
145
146 #ifdef __cplusplus
147 }
148 #endif
149
150 #endif
151