SdSpiChipSelect.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Copyright (c) 2011-2022 Bill Greiman
  3. * This file is part of the SdFat library for SD memory cards.
  4. *
  5. * MIT License
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included
  15. * in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. #include "SdSpiDriver.h"
  26. #if ENABLE_ARDUINO_FEATURES
  27. #if SD_CHIP_SELECT_MODE == 0
  28. //------------------------------------------------------------------------------
  29. void sdCsInit(SdCsPin_t pin) {
  30. pinMode(pin, OUTPUT);
  31. }
  32. //------------------------------------------------------------------------------
  33. void sdCsWrite(SdCsPin_t pin, bool level) {
  34. digitalWrite(pin, level);
  35. }
  36. #elif SD_CHIP_SELECT_MODE == 1
  37. //------------------------------------------------------------------------------
  38. __attribute__((weak))
  39. void sdCsInit(SdCsPin_t pin) {
  40. pinMode(pin, OUTPUT);
  41. }
  42. //------------------------------------------------------------------------------
  43. __attribute__((weak))
  44. void sdCsWrite(SdCsPin_t pin, bool level) {
  45. digitalWrite(pin, level);
  46. }
  47. #endif // SD_CHIP_SELECT_MODE == 0
  48. #endif // ENABLE_ARDUINO_FEATURES