BlueSCSI_v1_0_gpio.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // GPIO definitions for BlueSCSI v1.0
  2. #pragma once
  3. // SCSI data output port.
  4. // The output data is written using BSRR mechanism, so all data pins must be on same GPIO port.
  5. // The output pins are open-drain in hardware, using separate buffer chips for driving.
  6. #define SCSI_OUT_PORT GPIOD
  7. #define SCSI_OUT_DB7 GPIO_PIN_0
  8. #define SCSI_OUT_DB6 GPIO_PIN_1
  9. #define SCSI_OUT_DB5 GPIO_PIN_2
  10. #define SCSI_OUT_DB4 GPIO_PIN_3
  11. #define SCSI_OUT_DB3 GPIO_PIN_4
  12. #define SCSI_OUT_DB2 GPIO_PIN_5
  13. #define SCSI_OUT_DB1 GPIO_PIN_6
  14. #define SCSI_OUT_DB0 GPIO_PIN_7
  15. #define SCSI_OUT_DBP GPIO_PIN_15
  16. #define SCSI_OUT_REQ GPIO_PIN_9
  17. #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)
  18. #define SCSI_OUT_REQ_IDX 9
  19. // SCSI input data port
  20. #define SCSI_IN_PORT GPIOE
  21. #define SCSI_IN_DB7 GPIO_PIN_15
  22. #define SCSI_IN_DB6 GPIO_PIN_14
  23. #define SCSI_IN_DB5 GPIO_PIN_13
  24. #define SCSI_IN_DB4 GPIO_PIN_12
  25. #define SCSI_IN_DB3 GPIO_PIN_11
  26. #define SCSI_IN_DB2 GPIO_PIN_10
  27. #define SCSI_IN_DB1 GPIO_PIN_9
  28. #define SCSI_IN_DB0 GPIO_PIN_8
  29. #define SCSI_IN_DBP GPIO_PIN_7
  30. #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)
  31. #define SCSI_IN_SHIFT 8
  32. // SCSI output status lines
  33. #define SCSI_OUT_IO_PORT GPIOD
  34. #define SCSI_OUT_IO_PIN GPIO_PIN_8
  35. #define SCSI_OUT_CD_PORT GPIOD
  36. #define SCSI_OUT_CD_PIN GPIO_PIN_10
  37. #define SCSI_OUT_SEL_PORT GPIOD
  38. #define SCSI_OUT_SEL_PIN GPIO_PIN_11
  39. #define SCSI_OUT_MSG_PORT GPIOD
  40. #define SCSI_OUT_MSG_PIN GPIO_PIN_12
  41. #define SCSI_OUT_RST_PORT GPIOD
  42. #define SCSI_OUT_RST_PIN GPIO_PIN_13
  43. #define SCSI_OUT_BSY_PORT GPIOD
  44. #define SCSI_OUT_BSY_PIN GPIO_PIN_14
  45. #define SCSI_OUT_REQ_PORT SCSI_OUT_PORT
  46. #define SCSI_OUT_REQ_PIN SCSI_OUT_REQ
  47. // SCSI input status signals
  48. #define SCSI_ACK_PORT GPIOB
  49. #define SCSI_ACK_PIN GPIO_PIN_12
  50. #define SCSI_IN_ACK_IDX 12
  51. // The SCSI_ATN pin was PB0 in prototype 2022a, but was moved to PC6 for 5V-tolerance
  52. #ifdef BlueSCSI_2022A_REVISION
  53. #define SCSI_ATN_PORT GPIOB
  54. #define SCSI_ATN_PIN GPIO_PIN_0
  55. #else
  56. #define SCSI_ATN_PORT GPIOC
  57. #define SCSI_ATN_PIN GPIO_PIN_6
  58. #endif
  59. // SEL pin uses EXTI interrupt
  60. #define SCSI_SEL_PORT GPIOB
  61. #define SCSI_SEL_PIN GPIO_PIN_11
  62. #define SCSI_SEL_EXTI EXTI_11
  63. #define SCSI_SEL_EXTI_SOURCE_PORT GPIO_PORT_SOURCE_GPIOB
  64. #define SCSI_SEL_EXTI_SOURCE_PIN GPIO_PIN_SOURCE_11
  65. #define SCSI_SEL_IRQ EXTI10_15_IRQHandler
  66. #define SCSI_SEL_IRQn EXTI10_15_IRQn
  67. // BSY pin uses EXTI interrupt
  68. #define SCSI_BSY_PORT GPIOB
  69. #define SCSI_BSY_PIN GPIO_PIN_10
  70. #define SCSI_BSY_EXTI EXTI_10
  71. #define SCSI_BSY_EXTI_SOURCE_PORT GPIO_PORT_SOURCE_GPIOB
  72. #define SCSI_BSY_EXTI_SOURCE_PIN GPIO_PIN_SOURCE_10
  73. #define SCSI_BSY_IRQ EXTI10_15_IRQHandler
  74. #define SCSI_BSY_IRQn EXTI10_15_IRQn
  75. // RST pin uses EXTI interrupt
  76. #define SCSI_RST_PORT GPIOB
  77. #define SCSI_RST_PIN GPIO_PIN_13
  78. #define SCSI_RST_EXTI EXTI_13
  79. #define SCSI_RST_EXTI_SOURCE_PORT GPIO_PORT_SOURCE_GPIOB
  80. #define SCSI_RST_EXTI_SOURCE_PIN GPIO_PIN_SOURCE_13
  81. #define SCSI_RST_IRQ EXTI10_15_IRQHandler
  82. #define SCSI_RST_IRQn EXTI10_15_IRQn
  83. // Terminator enable/disable config, active low
  84. #define SCSI_TERM_EN_PORT GPIOC
  85. #define SCSI_TERM_EN_PIN GPIO_PIN_8
  86. // SD card pins
  87. #define SD_PORT GPIOA
  88. #define SD_CS_PIN GPIO_PIN_4
  89. #define SD_CLK_PIN GPIO_PIN_5
  90. #define SD_MISO_PIN GPIO_PIN_6
  91. #define SD_MOSI_PIN GPIO_PIN_7
  92. #define SD_SPI SPI0
  93. #define SD_SPI_RX_DMA_CHANNEL DMA_CH1
  94. #define SD_SPI_TX_DMA_CHANNEL DMA_CH2
  95. // DIP switches
  96. #define DIP_PORT GPIOB
  97. #define DIPSW1_PIN GPIO_PIN_4
  98. #define DIPSW2_PIN GPIO_PIN_5
  99. #define DIPSW3_PIN GPIO_PIN_6
  100. // Status LED pins
  101. #define LED_PORT GPIOC
  102. #define LED_I_PIN GPIO_PIN_4
  103. #define LED_E_PIN GPIO_PIN_5
  104. #define LED_PINS (LED_I_PIN | LED_E_PIN)
  105. #define LED_ON() gpio_bit_reset(LED_PORT, LED_PINS)
  106. #define LED_OFF() gpio_bit_set(LED_PORT, LED_PINS)