SoftSpi.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
  3. * SPI Master library for arduino.
  4. *
  5. * This file is free software; you can redistribute it and/or modify
  6. * it under the terms of either the GNU General Public License version 2
  7. * or the GNU Lesser General Public License version 2.1, both as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <Arduino.h>
  11. #include "pins_arduino.h"
  12. #include "SoftSpi.h"
  13. SoftSpi SPI;
  14. void SoftSpi::begin() {
  15. // Set SS to high so a connected chip will be "deselected" by default
  16. digitalWrite(SS, HIGH);
  17. // When the SS pin is set as OUTPUT, it can be used as
  18. // a general purpose output port (it doesn't influence
  19. // SPI operations).
  20. pinMode(SS, OUTPUT);
  21. // Set direction register for SCK and MOSI pin.
  22. // MISO pin automatically overrides to INPUT.
  23. // By doing this AFTER enabling SPI, we avoid accidentally
  24. // clocking in a single bit since the lines go directly
  25. // from "input" to SPI control.
  26. // http://code.google.com/p/arduino/issues/detail?id=888
  27. digitalWrite(SCK, LOW);
  28. pinMode(SCK, OUTPUT);
  29. pinMode(MOSI, OUTPUT);
  30. pinMode(MISO, INPUT);
  31. }
  32. void SoftSpi::end() {
  33. }
  34. void SoftSpi::setBitOrder(uint8_t bitOrder){
  35. }
  36. void SoftSpi::setDataMode(uint8_t mode){
  37. }
  38. void SoftSpi::setClockDivider(uint8_t rate){
  39. }