platform_hw_config.h 1.9 KB

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