platform_hw_config.h 2.1 KB

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