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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  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. #pragma once
  23. /**
  24. * HAL/shared/HAL_SPI.h
  25. * Core Marlin definitions for SPI, implemented in the HALs
  26. */
  27. #include "Marduino.h"
  28. #include <stdint.h>
  29. /**
  30. * SPI speed where 0 <= index <= 6
  31. *
  32. * Approximate rates :
  33. *
  34. * 0 : 8 - 10 MHz
  35. * 1 : 4 - 5 MHz
  36. * 2 : 2 - 2.5 MHz
  37. * 3 : 1 - 1.25 MHz
  38. * 4 : 500 - 625 kHz
  39. * 5 : 250 - 312 kHz
  40. * 6 : 125 - 156 kHz
  41. *
  42. * On AVR, actual speed is F_CPU/2^(1 + index).
  43. * On other platforms, speed should be in range given above where possible.
  44. */
  45. #define SPI_FULL_SPEED 0 // Set SCK to max rate
  46. #define SPI_HALF_SPEED 1 // Set SCK rate to half of max rate
  47. #define SPI_QUARTER_SPEED 2 // Set SCK rate to quarter of max rate
  48. #define SPI_EIGHTH_SPEED 3 // Set SCK rate to 1/8 of max rate
  49. #define SPI_SIXTEENTH_SPEED 4 // Set SCK rate to 1/16 of max rate
  50. #define SPI_SPEED_5 5 // Set SCK rate to 1/32 of max rate
  51. #define SPI_SPEED_6 6 // Set SCK rate to 1/64 of max rate
  52. //
  53. // Standard SPI functions
  54. //
  55. // Initialize SPI bus
  56. void spiBegin();
  57. // Configure SPI for specified SPI speed
  58. void spiInit(uint8_t spiRate);
  59. // Write single byte to SPI
  60. void spiSend(uint8_t b);
  61. // Read single byte from SPI
  62. uint8_t spiRec();
  63. // Read from SPI into buffer
  64. void spiRead(uint8_t* buf, uint16_t nbyte);
  65. // Write token and then write from 512 byte buffer to SPI (for SD card)
  66. void spiSendBlock(uint8_t token, const uint8_t* buf);
  67. // Begin SPI transaction, set clock, bit order, data mode
  68. void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode);
  69. //
  70. // Extended SPI functions taking a channel number (Hardware SPI only)
  71. //
  72. // Write single byte to specified SPI channel
  73. void spiSend(uint32_t chan, byte b);
  74. // Write buffer to specified SPI channel
  75. void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
  76. // Read single byte from specified SPI channel
  77. uint8_t spiRec(uint32_t chan);