My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SPI.h 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include <stdint.h>
  2. #if !defined(SPI_FULL_SPEED)
  3. /**
  4. * SPI speed where 0 <= index <= 6
  5. *
  6. * Approximate rates :
  7. *
  8. * 0 : 8 - 10 MHz
  9. * 1 : 4 - 5 MHz
  10. * 2 : 2 - 2.5 MHz
  11. * 3 : 1 - 1.25 MHz
  12. * 4 : 500 - 625 kHz
  13. * 5 : 250 - 312 kHz
  14. * 6 : 125 - 156 kHz
  15. *
  16. * On AVR, actual speed is F_CPU/2^(1 + index).
  17. * On other platforms, speed should be in range given above where possible.
  18. */
  19. /** Set SCK to max rate */
  20. #define SPI_FULL_SPEED 0
  21. /** Set SCK rate to half max rate. */
  22. #define SPI_HALF_SPEED 1
  23. /** Set SCK rate to quarter max rate. */
  24. #define SPI_QUARTER_SPEED 2
  25. /** Set SCK rate to 1/8 max rate. */
  26. #define SPI_EIGHTH_SPEED 3
  27. /** Set SCK rate to 1/16 of max rate. */
  28. #define SPI_SIXTEENTH_SPEED 4
  29. /** Set SCK rate to 1/32 of max rate. */
  30. #define SPI_SPEED_5 5
  31. /** Set SCK rate to 1/64 of max rate. */
  32. #define SPI_SPEED_6 6
  33. // Standard SPI functions
  34. /** Initialise SPI bus */
  35. void spiBegin(void);
  36. /** Configure SPI for specified SPI speed */
  37. void spiInit(uint8_t spiRate);
  38. /** Write single byte to SPI */
  39. void spiSend(uint8_t b);
  40. /** Read single byte from SPI */
  41. uint8_t spiRec(void);
  42. /** Read from SPI into buffer */
  43. void spiRead(uint8_t* buf, uint16_t nbyte);
  44. /** Write token and then write from 512 byte buffer to SPI (for SD card) */
  45. void spiSendBlock(uint8_t token, const uint8_t* buf);
  46. #endif