forked from mrehkopf/sd2snes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.h
119 lines (100 loc) · 4.2 KB
/
config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* sd2snes - SD card based universal cartridge for the SNES
Copyright (C) 2009-2010 Maximilian Rehkopf <[email protected]>
This file was adapted from sd2iec, written by Ingo Korb.
Original copyright header follows:
*/
/*
sd2iec - SD/MMC to Commodore serial bus interface/controller
Copyright (C) 2007-2009 Ingo Korb <[email protected]>
Inspiration and low-level SD/MMC access based on code from MMC2IEC
by Lars Pontoppidan et al., see sdcard.c|h and config.h.
FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License only.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
config.h: User-configurable options to simplify hardware changes and/or
reduce the code/ram requirements of the code.
Based on MMC2IEC, original copyright header follows:
//
// Title : MMC2IEC - Configuration
// Author : Lars Pontoppidan
// Date : Jan. 2007
// Version : 0.7
// Target MCU : AtMega32(L) at 8 MHz
//
//
// DISCLAIMER:
// The author is in no way responsible for any problems or damage caused by
// using this code. Use at your own risk.
//
// LICENSE:
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
*/
#ifndef CONFIG_H
#define CONFIG_H
#include "autoconf.h"
# define HW_NAME "SD2IEC"
# define HAVE_SD
# define SDCARD_DETECT (!(PIND & _BV(PD2)))
# define SDCARD_DETECT_SETUP() do { DDRD &= ~_BV(PD2); PORTD |= _BV(PD2); } while(0)
# if defined __AVR_ATmega32__
# define SD_CHANGE_SETUP() do { MCUCR |= _BV(ISC00); GICR |= _BV(INT0); } while(0)
# elif defined __AVR_ATmega644__ || defined __AVR_ATmega644P__
# define SD_CHANGE_SETUP() do { EICRA |= _BV(ISC00); EIMSK |= _BV(INT0); } while(0)
# else
# error Unknown chip!
# endif
# define SD_CHANGE_VECT INT0_vect
# define SDCARD_WP (PINA & _BV(PA0))
# define SDCARD_WP_SETUP() do { DDRA &= ~ _BV(PA0); PORTA |= _BV(PA0); } while(0)
# define SD_CHANGE_ICR MCUCR
# define SD_SUPPLY_VOLTAGE (1L<<21)
# define DEVICE_SELECT (8+!(PINA & _BV(PA2))+2*!(PINA & _BV(PA3)))
# define DEVICE_SELECT_SETUP() do { \
DDRA &= ~(_BV(PA2)|_BV(PA3)); \
PORTA |= _BV(PA2)|_BV(PA3); \
} while (0)
# define BUSY_LED_SETDDR() DDRA |= _BV(PA0)
# define BUSY_LED_ON() PORTA &= ~_BV(PA0)
# define BUSY_LED_OFF() PORTA |= _BV(PA0)
# define DIRTY_LED_SETDDR() DDRA |= _BV(PA1)
# define DIRTY_LED_ON() PORTA &= ~_BV(PA1)
# define DIRTY_LED_OFF() PORTA |= _BV(PA1)
# define DIRTY_LED_PORT PORTA
# define DIRTY_LED_BIT() _BV(PA1)
# define AUX_LED_SETDDR() do {} while (0)
# define AUX_LED_ON() do {} while (0)
# define AUX_LED_OFF() do {} while (0)
# define BUTTON_PIN PINA
# define BUTTON_PORT PORTA
# define BUTTON_DDR DDRA
# define BUTTON_MASK (_BV(PA4)|_BV(PA5))
# define BUTTON_NEXT _BV(PA4)
# define BUTTON_PREV _BV(PA5)
/* An interrupt for detecting card changes implies hotplugging capability */
#if defined(SD_CHANGE_VECT) || defined (CF_CHANGE_VECT)
# define HAVE_HOTPLUG
#endif
/* Generate dummy functions for the BUSY LED if required */
#ifdef SINGLE_LED
# define BUSY_LED_SETDDR() do {} while(0)
# define BUSY_LED_ON() do {} while(0)
# define BUSY_LED_OFF() do {} while(0)
#endif
/* Create some temporary symbols so we can calculate the number of */
/* enabled storage devices. */
#ifdef HAVE_SD
# define TMP_SD 1
#endif
/* Remove the temporary symbols */
#undef TMP_SD
#endif