ZuluSCSI_v1_0_gpio.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /**
  2. * ZuluSCSI™ - Copyright (c) 2022-2025 Rabbit Hole Computing™
  3. *
  4. * ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
  5. *
  6. * https://www.gnu.org/licenses/gpl-3.0.html
  7. * ----
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version. 
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. * GNU General Public License for more details. 
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  20. **/
  21. // GPIO definitions for ZuluSCSI v1.0
  22. #pragma once
  23. // SCSI data output port.
  24. // The output data is written using BSRR mechanism, so all data pins must be on same GPIO port.
  25. // The output pins are open-drain in hardware, using separate buffer chips for driving.
  26. #define SCSI_OUT_PORT GPIOD
  27. #define SCSI_OUT_DB7 GPIO_PIN_0
  28. #define SCSI_OUT_DB6 GPIO_PIN_1
  29. #define SCSI_OUT_DB5 GPIO_PIN_2
  30. #define SCSI_OUT_DB4 GPIO_PIN_3
  31. #define SCSI_OUT_DB3 GPIO_PIN_4
  32. #define SCSI_OUT_DB2 GPIO_PIN_5
  33. #define SCSI_OUT_DB1 GPIO_PIN_6
  34. #define SCSI_OUT_DB0 GPIO_PIN_7
  35. #define SCSI_OUT_DBP GPIO_PIN_15
  36. #define SCSI_OUT_REQ GPIO_PIN_9
  37. #define SCSI_OUT_DATA_MASK (SCSI_OUT_DB0 | SCSI_OUT_DB1 | SCSI_OUT_DB2 | SCSI_OUT_DB3 | SCSI_OUT_DB4 | SCSI_OUT_DB5 | SCSI_OUT_DB6 | SCSI_OUT_DB7 | SCSI_OUT_DBP)
  38. #define SCSI_OUT_REQ_IDX 9
  39. // SCSI input data port
  40. #define SCSI_IN_PORT GPIOE
  41. #define SCSI_IN_DB7 GPIO_PIN_15
  42. #define SCSI_IN_DB6 GPIO_PIN_14
  43. #define SCSI_IN_DB5 GPIO_PIN_13
  44. #define SCSI_IN_DB4 GPIO_PIN_12
  45. #define SCSI_IN_DB3 GPIO_PIN_11
  46. #define SCSI_IN_DB2 GPIO_PIN_10
  47. #define SCSI_IN_DB1 GPIO_PIN_9
  48. #define SCSI_IN_DB0 GPIO_PIN_8
  49. #define SCSI_IN_DBP GPIO_PIN_7
  50. #define SCSI_IN_MASK (SCSI_IN_DB7|SCSI_IN_DB6|SCSI_IN_DB5|SCSI_IN_DB4|SCSI_IN_DB3|SCSI_IN_DB2|SCSI_IN_DB1|SCSI_IN_DB0|SCSI_IN_DBP)
  51. #define SCSI_IN_SHIFT 8
  52. // SCSI output status lines
  53. #define SCSI_OUT_IO_PORT GPIOD
  54. #define SCSI_OUT_IO_PIN GPIO_PIN_8
  55. #define SCSI_OUT_CD_PORT GPIOD
  56. #define SCSI_OUT_CD_PIN GPIO_PIN_10
  57. #define SCSI_OUT_SEL_PORT GPIOD
  58. #define SCSI_OUT_SEL_PIN GPIO_PIN_11
  59. #define SCSI_OUT_MSG_PORT GPIOD
  60. #define SCSI_OUT_MSG_PIN GPIO_PIN_12
  61. #define SCSI_OUT_RST_PORT GPIOD
  62. #define SCSI_OUT_RST_PIN GPIO_PIN_13
  63. #define SCSI_OUT_BSY_PORT GPIOD
  64. #define SCSI_OUT_BSY_PIN GPIO_PIN_14
  65. #define SCSI_OUT_REQ_PORT SCSI_OUT_PORT
  66. #define SCSI_OUT_REQ_PIN SCSI_OUT_REQ
  67. // SCSI input status signals
  68. #define SCSI_ACK_PORT GPIOB
  69. #define SCSI_ACK_PIN GPIO_PIN_12
  70. #define SCSI_IN_ACK_IDX 12
  71. // The SCSI_ATN pin was PB0 in prototype 2022a, but was moved to PC6 for 5V-tolerance
  72. #ifdef ZULUSCSI_2022A_REVISION
  73. #define SCSI_ATN_PORT GPIOB
  74. #define SCSI_ATN_PIN GPIO_PIN_0
  75. #else
  76. #define SCSI_ATN_PORT GPIOC
  77. #define SCSI_ATN_PIN GPIO_PIN_6
  78. #endif
  79. // SEL pin uses EXTI interrupt
  80. #define SCSI_SEL_PORT GPIOB
  81. #define SCSI_SEL_PIN GPIO_PIN_11
  82. #define SCSI_SEL_EXTI EXTI_11
  83. #define SCSI_SEL_EXTI_SOURCE_PORT GPIO_PORT_SOURCE_GPIOB
  84. #define SCSI_SEL_EXTI_SOURCE_PIN GPIO_PIN_SOURCE_11
  85. #define SCSI_SEL_IRQ EXTI10_15_IRQHandler
  86. #define SCSI_SEL_IRQn EXTI10_15_IRQn
  87. // Unused place holders for compiling
  88. #define SCSI_ODE_SEL_PORT SCSI_SEL_PORT
  89. #define SCSI_ODE_SEL_PIN SCSI_SEL_PIN
  90. #define SCSI_ODE_SEL_EXTI SCSI_SEL_EXTI
  91. #define SCSI_ODE_SEL_EXTI_SOURCE_PORT SCSI_SEL_EXTI_SOURCE_PORT
  92. #define SCSI_ODE_SEL_EXTI_SOURCE_PIN SCSI_SEL_EXTI_SOURCE_PIN
  93. #define SCSI_ODE_SEL_IRQ SCSI_SEL_IRQ
  94. #define SCSI_ODE_SEL_IRQn SCSI_SEL_IRQn
  95. // BSY pin uses EXTI interrupt
  96. #define SCSI_BSY_PORT GPIOB
  97. #define SCSI_BSY_PIN GPIO_PIN_10
  98. #define SCSI_BSY_EXTI EXTI_10
  99. #define SCSI_BSY_EXTI_SOURCE_PORT GPIO_PORT_SOURCE_GPIOB
  100. #define SCSI_BSY_EXTI_SOURCE_PIN GPIO_PIN_SOURCE_10
  101. #define SCSI_BSY_IRQ EXTI10_15_IRQHandler
  102. #define SCSI_BSY_IRQn EXTI10_15_IRQn
  103. // RST pin uses EXTI interrupt
  104. #define SCSI_RST_PORT GPIOB
  105. #define SCSI_RST_PIN GPIO_PIN_13
  106. #define SCSI_RST_EXTI EXTI_13
  107. #define SCSI_RST_EXTI_SOURCE_PORT GPIO_PORT_SOURCE_GPIOB
  108. #define SCSI_RST_EXTI_SOURCE_PIN GPIO_PIN_SOURCE_13
  109. #define SCSI_RST_IRQ EXTI10_15_IRQHandler
  110. #define SCSI_RST_IRQn EXTI10_15_IRQn
  111. // Terminator enable/disable config, active low
  112. #define SCSI_TERM_EN_PORT GPIOC
  113. #define SCSI_TERM_EN_PIN GPIO_PIN_8
  114. // SD card pins
  115. #define SD_PORT GPIOA
  116. #define SD_CS_PIN GPIO_PIN_4
  117. #define SD_CLK_PIN GPIO_PIN_5
  118. #define SD_MISO_PIN GPIO_PIN_6
  119. #define SD_MOSI_PIN GPIO_PIN_7
  120. #define SD_SPI SPI0
  121. #define SD_SPI_RX_DMA_CHANNEL DMA_CH1
  122. #define SD_SPI_TX_DMA_CHANNEL DMA_CH2
  123. // DIP switches
  124. #define DIP_PORT GPIOB
  125. #define DIPSW1_PIN GPIO_PIN_4
  126. #define DIPSW2_PIN GPIO_PIN_5
  127. #define DIPSW3_PIN GPIO_PIN_6
  128. // Status LED pins
  129. #define LED_PORT GPIOC
  130. #define LED_I_PIN GPIO_PIN_4
  131. #define LED_E_PIN GPIO_PIN_5
  132. #define LED_PINS (LED_I_PIN | LED_E_PIN)
  133. // Ejection buttons are available on expansion header J303.
  134. // PE5 = channel 1, PE6 = channel 2
  135. // Connect button between GPIO and GND pin.
  136. #define EJECT_1_PORT GPIOE
  137. #define EJECT_1_PIN GPIO_PIN_5
  138. #define EJECT_2_PORT GPIOE
  139. #define EJECT_2_PIN GPIO_PIN_6