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.

HAL.h 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* **************************************************************************
  2. Marlin 3D Printer Firmware
  3. Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ****************************************************************************/
  16. /**
  17. * Description: HAL wrapper
  18. *
  19. * Supports platforms :
  20. * ARDUINO_ARCH_SAM : For Arduino Due and other boards based on Atmel SAM3X8E
  21. * ARDUINO_ARCH_AVR : For all Atmel AVR boards
  22. */
  23. #ifndef _HAL_H
  24. #define _HAL_H
  25. #include <stdint.h>
  26. /**
  27. * SPI speed where 0 <= index <= 6
  28. *
  29. * Approximate rates :
  30. *
  31. * 0 : 8 - 10 MHz
  32. * 1 : 4 - 5 MHz
  33. * 2 : 2 - 2.5 MHz
  34. * 3 : 1 - 1.25 MHz
  35. * 4 : 500 - 625 kHz
  36. * 5 : 250 - 312 kHz
  37. * 6 : 125 - 156 kHz
  38. *
  39. * On AVR, actual speed is F_CPU/2^(1 + index).
  40. * On other platforms, speed should be in range given above where possible.
  41. */
  42. /** Set SCK to max rate */
  43. uint8_t const SPI_FULL_SPEED = 0;
  44. /** Set SCK rate to half max rate. */
  45. uint8_t const SPI_HALF_SPEED = 1;
  46. /** Set SCK rate to quarter max rate. */
  47. uint8_t const SPI_QUARTER_SPEED = 2;
  48. /** Set SCK rate to 1/8 max rate. */
  49. uint8_t const SPI_EIGHTH_SPEED = 3;
  50. /** Set SCK rate to 1/16 of max rate. */
  51. uint8_t const SPI_SIXTEENTH_SPEED = 4;
  52. /** Set SCK rate to 1/32 of max rate. */
  53. uint8_t const SPI_SPEED_5 = 5;
  54. /** Set SCK rate to 1/64 of max rate. */
  55. uint8_t const SPI_SPEED_6 = 6;
  56. // Standard SPI functions
  57. /** Initialise SPI bus */
  58. void spiBegin(void);
  59. /** Configure SPI for specified SPI speed */
  60. void spiInit(uint8_t spiRate);
  61. /** Write single byte to SPI */
  62. void spiSend(uint8_t b);
  63. /** Read single byte from SPI */
  64. uint8_t spiRec(void);
  65. /** Read from SPI into buffer */
  66. void spiRead(uint8_t* buf, uint16_t nbyte);
  67. /** Write token and then write from 512 byte buffer to SPI (for SD card) */
  68. void spiSendBlock(uint8_t token, const uint8_t* buf);
  69. #ifdef ARDUINO_ARCH_AVR
  70. #include "HAL_AVR/HAL_AVR.h"
  71. #elif defined(ARDUINO_ARCH_SAM)
  72. #define CPU_32_BIT
  73. #include "HAL_DUE/HAL_Due.h"
  74. #include "math_32bit.h"
  75. #elif defined(__MK64FX512__) || defined(__MK66FX1M0__)
  76. #define CPU_32_BIT
  77. #include "HAL_TEENSY35_36/HAL_Teensy.h"
  78. #include "math_32bit.h"
  79. #else
  80. #error Unsupported Platform!
  81. #endif
  82. #endif /* HAL_H_ */