Просмотр исходного кода

Relocate SPI.h to the HAL folder

Scott Lahteine 7 лет назад
Родитель
Сommit
60af705e6d

+ 1
- 1
Marlin/src/HAL/HAL.h Просмотреть файл

@@ -29,7 +29,7 @@
29 29
 #ifndef _HAL_H
30 30
 #define _HAL_H
31 31
 
32
-#include "../inc/SPI.h"
32
+#include "SPI.h"
33 33
 
34 34
 #ifdef __AVR__
35 35
   #include "HAL_AVR/HAL_AVR.h"

+ 1
- 1
Marlin/src/HAL/HAL_STM32F1/HAL_spi_Stm32f1.cpp Просмотреть файл

@@ -37,7 +37,7 @@
37 37
 // --------------------------------------------------------------------------
38 38
 
39 39
 #include "../HAL.h"
40
-#include "SPI.h"
40
+#include "../SPI.h"
41 41
 #include "pins_arduino.h"
42 42
 #include "spi_pins.h"
43 43
 #include "../../core/macros.h"

+ 78
- 0
Marlin/src/HAL/SPI.h Просмотреть файл

@@ -0,0 +1,78 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * HAL/SPI.h
25
+ * Core Marlin definitions for SPI, implemented in the HALs
26
+ */
27
+
28
+#ifndef _SPI_H_
29
+#define _SPI_H_
30
+
31
+//#include "../inc/MarlinConfig.h"
32
+
33
+#include <stdint.h>
34
+
35
+#ifndef SPI_FULL_SPEED
36
+
37
+/**
38
+ * SPI speed where 0 <= index <= 6
39
+ *
40
+ * Approximate rates :
41
+ *
42
+ *  0 :  8 - 10 MHz
43
+ *  1 :  4 - 5 MHz
44
+ *  2 :  2 - 2.5 MHz
45
+ *  3 :  1 - 1.25 MHz
46
+ *  4 :  500 - 625 kHz
47
+ *  5 :  250 - 312 kHz
48
+ *  6 :  125 - 156 kHz
49
+ *
50
+ *  On AVR, actual speed is F_CPU/2^(1 + index).
51
+ *  On other platforms, speed should be in range given above where possible.
52
+ */
53
+
54
+#define SPI_FULL_SPEED      0   // Set SCK to max rate
55
+#define SPI_HALF_SPEED      1   // Set SCK rate to half of max rate
56
+#define SPI_QUARTER_SPEED   2   // Set SCK rate to quarter of max rate
57
+#define SPI_EIGHTH_SPEED    3   // Set SCK rate to 1/8 of max rate
58
+#define SPI_SIXTEENTH_SPEED 4   // Set SCK rate to 1/16 of max rate
59
+#define SPI_SPEED_5         5   // Set SCK rate to 1/32 of max rate
60
+#define SPI_SPEED_6         6   // Set SCK rate to 1/64 of max rate
61
+
62
+// Standard SPI functions
63
+/** Initialise SPI bus */
64
+void spiBegin(void);
65
+/** Configure SPI for specified SPI speed */
66
+void spiInit(uint8_t spiRate);
67
+/** Write single byte to SPI */
68
+void spiSend(uint8_t b);
69
+/** Read single byte from SPI */
70
+uint8_t spiRec(void);
71
+/** Read from SPI into buffer */
72
+void spiRead(uint8_t* buf, uint16_t nbyte);
73
+/** Write token and then write from 512 byte buffer to SPI (for SD card) */
74
+void spiSendBlock(uint8_t token, const uint8_t* buf);
75
+
76
+#endif // SPI_FULL_SPEED
77
+
78
+#endif // _SPI_H_

+ 1
- 1
Marlin/src/inc/MarlinConfig.h Просмотреть файл

@@ -26,7 +26,7 @@
26 26
 #include "../core/boards.h"
27 27
 #include "../core/macros.h"
28 28
 #include "Version.h"
29
-#include "SPI.h"
29
+#include "../HAL/SPI.h"
30 30
 #include "../../Configuration.h"
31 31
 #include "Conditionals_LCD.h"
32 32
 #include "../../Configuration_adv.h"

+ 0
- 52
Marlin/src/inc/SPI.h Просмотреть файл

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

Загрузка…
Отмена
Сохранить