platform_hw_config.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * ZuluSCSI™ - Copyright (c) 2023-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. /**
  22. * Configuration of the ZuluSCSI set by hardware rotary and standard DIP switches
  23. * Settings include SCSI ID, device type, and if hardware config is active
  24. */
  25. #pragma once
  26. #ifdef ZULUSCSI_HARDWARE_CONFIG
  27. #include <scsi2sd.h>
  28. #include <ZuluSCSI_settings.h>
  29. // C wrappers
  30. #ifdef __cplusplus
  31. extern "C"
  32. {
  33. #endif
  34. S2S_CFG_TYPE hw_config_selected_device();
  35. bool hw_config_is_active();
  36. void hw_config_init_gpios();
  37. void hw_config_init_state(bool is_active);
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41. #ifdef __cplusplus
  42. class HardwareConfig
  43. {
  44. public:
  45. // Initialize GPIOs
  46. void init_gpios();
  47. // Initialize device state settings
  48. void init_state(bool is_active);
  49. // get the device type
  50. // @returns the device type
  51. const S2S_CFG_TYPE& device_type() const {return m_device_type;}
  52. const uint8_t& scsi_id() const {return m_scsi_id;}
  53. const bool& is_active() const {return m_is_active;}
  54. const int blocksize() const {return m_blocksize;}
  55. const scsi_device_preset_t device_preset() const {return m_device_preset;}
  56. protected:
  57. S2S_CFG_TYPE m_device_type;
  58. uint8_t m_scsi_id;
  59. bool m_is_active;
  60. int m_blocksize;
  61. scsi_device_preset_t m_device_preset;
  62. };
  63. // global hardware configuration
  64. extern HardwareConfig g_hw_config;
  65. #endif // __cplusplus
  66. #endif // ZULUSCSI_HARDWARE_CONFIG