config.h 4.1 KB

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