config.h 4.2 KB

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