Browse Source

STM32F1 HAL

Adding files for STM32F1 HAL based on libmaple/stm32duino core.
Current persistent_store uses cardreader changes to be sent in separate
commit, but could be changed to use i2c eeprom.
victorpv 6 years ago
parent
commit
e9acb63290

+ 4
- 0
Marlin/src/HAL/HAL.h View File

@@ -91,6 +91,10 @@ void spiSendBlock(uint8_t token, const uint8_t* buf);
91 91
   #define CPU_32_BIT
92 92
   #include "math_32bit.h"
93 93
   #include "HAL_LPC1768/HAL.h"
94
+#elif defined(__STM32F1__)
95
+  #define CPU_32_BIT
96
+  #include "math_32bit.h"
97
+  #include "HAL_STM32F1/HAL_Stm32f1.h"
94 98
 #else
95 99
   #error "Unsupported Platform!"
96 100
 #endif

+ 52
- 0
Marlin/src/HAL/HAL_STM32F1/HAL_Servo_Stm32f1.cpp View File

@@ -0,0 +1,52 @@
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
+ * Copyright (C) 2017 Victor Perez
8
+ *
9
+ * This program is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+#ifdef __STM32F1__
25
+
26
+#include "../../../src/inc/MarlinConfig.h"
27
+
28
+#if HAS_SERVOS
29
+
30
+#include "HAL_Servo_Stm32f1.h"
31
+
32
+int8_t libServo::attach(const int pin) {
33
+  if (this->servoIndex >= MAX_SERVOS) return -1;
34
+  return Servo::attach(pin);
35
+}
36
+
37
+int8_t libServo::attach(const int pin, const int min, const int max) {
38
+  return Servo::attach(pin, min, max);
39
+}
40
+
41
+void libServo::move(const int value) {
42
+  if (this->attach(0) >= 0) {
43
+    this->write(value);
44
+    delay(SERVO_DELAY);
45
+    #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
46
+      this->detach();
47
+    #endif
48
+  }
49
+}
50
+#endif // HAS_SERVOS
51
+
52
+#endif // __STM32F1__

+ 41
- 0
Marlin/src/HAL/HAL_STM32F1/HAL_Servo_Stm32f1.h View File

@@ -0,0 +1,41 @@
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
+ * Copyright (C) 2017 Victor Perez
8
+ *
9
+ * This program is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+#ifndef HAL_SERVO_STM32F1_H
25
+#define HAL_SERVO_STM32F1_H
26
+
27
+#include <../../libraries/Servo/src/Servo.h>
28
+
29
+// Inherit and expand on the official library
30
+class libServo : public Servo {
31
+public:
32
+    int8_t attach(const int pin);
33
+    int8_t attach(const int pin, const int min, const int max);
34
+    void move(const int value);
35
+private:
36
+    uint16_t min_ticks;
37
+    uint16_t max_ticks;
38
+    uint8_t servoIndex;               // index into the channel data for this servo
39
+};
40
+
41
+#endif // HAL_SERVO_STM32F1_H

+ 138
- 0
Marlin/src/HAL/HAL_STM32F1/HAL_Stm32f1.cpp View File

@@ -0,0 +1,138 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ *
4
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
7
+ * Copyright (c) 2017 Victor Perez
8
+ *
9
+ * This program is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+/**
25
+ * HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
26
+ */
27
+
28
+#ifdef __STM32F1__
29
+
30
+// --------------------------------------------------------------------------
31
+// Includes
32
+// --------------------------------------------------------------------------
33
+
34
+#include "../HAL.h"
35
+
36
+//#include <Wire.h>
37
+
38
+// --------------------------------------------------------------------------
39
+// Externals
40
+// --------------------------------------------------------------------------
41
+
42
+// --------------------------------------------------------------------------
43
+// Local defines
44
+// --------------------------------------------------------------------------
45
+
46
+// --------------------------------------------------------------------------
47
+// Types
48
+// --------------------------------------------------------------------------
49
+
50
+// --------------------------------------------------------------------------
51
+// Variables
52
+// --------------------------------------------------------------------------
53
+
54
+// --------------------------------------------------------------------------
55
+// Public Variables
56
+// --------------------------------------------------------------------------
57
+
58
+uint16_t HAL_adc_result;
59
+
60
+// --------------------------------------------------------------------------
61
+// Private Variables
62
+// --------------------------------------------------------------------------
63
+
64
+// --------------------------------------------------------------------------
65
+// Function prototypes
66
+// --------------------------------------------------------------------------
67
+
68
+// --------------------------------------------------------------------------
69
+// Private functions
70
+// --------------------------------------------------------------------------
71
+
72
+// --------------------------------------------------------------------------
73
+// Public functions
74
+// --------------------------------------------------------------------------
75
+
76
+/* VGPV Done with defines
77
+// disable interrupts
78
+void cli(void) { noInterrupts(); }
79
+
80
+// enable interrupts
81
+void sei(void) { interrupts(); }
82
+*/
83
+
84
+void HAL_clear_reset_source(void) { }
85
+
86
+/**
87
+ * TODO: Check this and change or remove.
88
+ * currently returns 1 that's equal to poweron reset.
89
+ */
90
+uint8_t HAL_get_reset_source(void) { return 1; }
91
+
92
+void _delay_ms(const int delay_ms) { delay(delay_ms); }
93
+
94
+extern "C" {
95
+  extern unsigned int _ebss; // end of bss section
96
+}
97
+
98
+/**
99
+ * TODO: Change this to correct it for libmaple
100
+ */
101
+
102
+// return free memory between end of heap (or end bss) and whatever is current
103
+
104
+/*
105
+#include "wirish/syscalls.c"
106
+//extern caddr_t _sbrk(int incr);
107
+#ifndef CONFIG_HEAP_END
108
+extern char _lm_heap_end;
109
+#define CONFIG_HEAP_END ((caddr_t)&_lm_heap_end)
110
+#endif
111
+
112
+extern "C" {
113
+  static int freeMemory() {
114
+    char top = 't';
115
+    return &top - reinterpret_cast<char*>(sbrk(0));
116
+  }
117
+  int freeMemory() {
118
+    int free_memory;
119
+    int heap_end = (int)_sbrk(0);
120
+    free_memory = ((int)&free_memory) - ((int)heap_end);
121
+    return free_memory;
122
+  }
123
+}
124
+*/
125
+
126
+// --------------------------------------------------------------------------
127
+// ADC
128
+// --------------------------------------------------------------------------
129
+
130
+void HAL_adc_start_conversion(const uint8_t adc_pin) {
131
+  HAL_adc_result = (analogRead(adc_pin) >> 2) & 0x3ff; // shift to get 10 bits only.
132
+}
133
+
134
+uint16_t HAL_adc_get_result(void) {
135
+  return HAL_adc_result;
136
+}
137
+
138
+#endif // __STM32F1__

+ 195
- 0
Marlin/src/HAL/HAL_STM32F1/HAL_Stm32f1.h View File

@@ -0,0 +1,195 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ *
4
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
7
+ * Copyright (c) 2017 Victor Perez
8
+ *
9
+ * This program is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+/**
25
+ * HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
26
+ */
27
+
28
+#ifndef _HAL_STM32F1_H
29
+#define _HAL_STM32F1_H
30
+
31
+#undef DEBUG_NONE
32
+
33
+#ifndef vsnprintf_P
34
+  #define vsnprintf_P vsnprintf
35
+#endif
36
+
37
+// --------------------------------------------------------------------------
38
+// Includes
39
+// --------------------------------------------------------------------------
40
+
41
+#include <stdint.h>
42
+
43
+#include "Arduino.h"
44
+
45
+#include "fastio_Stm32f1.h"
46
+#include "watchdog_Stm32f1.h"
47
+
48
+#include "HAL_timers_Stm32f1.h"
49
+
50
+// --------------------------------------------------------------------------
51
+// Defines
52
+// --------------------------------------------------------------------------
53
+
54
+#if SERIAL_PORT == -1
55
+  #define MYSERIAL SerialUSB
56
+#elif SERIAL_PORT == 0
57
+  #define MYSERIAL Serial
58
+#elif SERIAL_PORT == 1
59
+  #define MYSERIAL Serial1
60
+#elif SERIAL_PORT == 2
61
+  #define MYSERIAL Serial2
62
+#elif SERIAL_PORT == 3
63
+  #define MYSERIAL Serial3
64
+#endif
65
+
66
+#define _BV(bit) 	(1 << (bit))
67
+
68
+/**
69
+ * TODO: review this to return 1 for pins that are not analog input
70
+ */
71
+#ifndef analogInputToDigitalPin
72
+  #define analogInputToDigitalPin(p) (p)
73
+#endif
74
+
75
+#define CRITICAL_SECTION_START	noInterrupts();
76
+#define CRITICAL_SECTION_END    interrupts();
77
+
78
+// On AVR this is in math.h?
79
+#define square(x) ((x)*(x))
80
+
81
+#ifndef strncpy_P
82
+  #define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
83
+#endif
84
+
85
+// Fix bug in pgm_read_ptr
86
+#undef pgm_read_ptr
87
+#define pgm_read_ptr(addr) (*(addr))
88
+
89
+#define RST_POWER_ON   1
90
+#define RST_EXTERNAL   2
91
+#define RST_BROWN_OUT  4
92
+#define RST_WATCHDOG   8
93
+#define RST_JTAG       16
94
+#define RST_SOFTWARE   32
95
+#define RST_BACKUP     64
96
+
97
+// --------------------------------------------------------------------------
98
+// Types
99
+// --------------------------------------------------------------------------
100
+
101
+// --------------------------------------------------------------------------
102
+// Public Variables
103
+// --------------------------------------------------------------------------
104
+
105
+/** result of last ADC conversion */
106
+extern uint16_t HAL_adc_result;
107
+
108
+// --------------------------------------------------------------------------
109
+// Public functions
110
+// --------------------------------------------------------------------------
111
+
112
+// Disable interrupts
113
+#define cli() noInterrupts()
114
+
115
+// Enable interrupts
116
+#define sei() interrupts()
117
+
118
+// Memory related
119
+#define __bss_end __bss_end__
120
+
121
+/** clear reset reason */
122
+void HAL_clear_reset_source (void);
123
+
124
+/** reset reason */
125
+uint8_t HAL_get_reset_source (void);
126
+
127
+void _delay_ms(const int delay);
128
+
129
+/*
130
+extern "C" {
131
+  int freeMemory(void);
132
+}
133
+*/
134
+
135
+extern "C" char* _sbrk(int incr);
136
+/*
137
+static int freeMemory() {
138
+  volatile int top;
139
+  top = (int)((char*)&top - reinterpret_cast<char*>(_sbrk(0)));
140
+  return top;
141
+}
142
+*/
143
+static int freeMemory() {
144
+  volatile char top;
145
+  return &top - reinterpret_cast<char*>(_sbrk(0));
146
+}
147
+
148
+// SPI: Extended functions which take a channel number (hardware SPI only)
149
+/** Write single byte to specified SPI channel */
150
+void spiSend(uint32_t chan, byte b);
151
+/** Write buffer to specified SPI channel */
152
+void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
153
+/** Read single byte from specified SPI channel */
154
+uint8_t spiRec(uint32_t chan);
155
+
156
+
157
+// EEPROM
158
+
159
+/**
160
+ * TODO: Write all this eeprom stuff. Can emulate eeprom in flash as last resort.
161
+ * Wire library should work for i2c eeproms.
162
+ */
163
+void eeprom_write_byte(unsigned char *pos, unsigned char value);
164
+unsigned char eeprom_read_byte(unsigned char *pos);
165
+void eeprom_read_block (void *__dst, const void *__src, size_t __n);
166
+void eeprom_update_block (const void *__src, void *__dst, size_t __n);
167
+
168
+// ADC
169
+
170
+#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT_ANALOG);
171
+
172
+inline void HAL_adc_init(void) {}
173
+
174
+#define HAL_START_ADC(pin)  HAL_adc_start_conversion(pin)
175
+#define HAL_READ_ADC        HAL_adc_result
176
+
177
+void HAL_adc_start_conversion(const uint8_t adc_pin);
178
+
179
+uint16_t HAL_adc_get_result(void);
180
+
181
+/* Todo: Confirm none of this is needed.
182
+uint16_t HAL_getAdcReading(uint8_t chan);
183
+
184
+void HAL_startAdcConversion(uint8_t chan);
185
+uint8_t HAL_pinToAdcChannel(int pin);
186
+
187
+uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
188
+//uint16_t HAL_getAdcSuperSample(uint8_t chan);
189
+
190
+void HAL_enable_AdcFreerun(void);
191
+//void HAL_disable_AdcFreerun(uint8_t chan);
192
+
193
+*/
194
+
195
+#endif // _HAL_STM32F1_H

+ 169
- 0
Marlin/src/HAL/HAL_STM32F1/HAL_spi_Stm32f1.cpp View File

@@ -0,0 +1,169 @@
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
+ * Copyright (C) 2017 Victor Perez
8
+ *
9
+ * This program is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+/**
25
+ * Software SPI functions originally from Arduino Sd2Card Library
26
+ * Copyright (C) 2009 by William Greiman
27
+ */
28
+
29
+/**
30
+ * Adapted to the STM32F1 HAL
31
+ */
32
+
33
+#ifdef __STM32F1__
34
+
35
+// --------------------------------------------------------------------------
36
+// Includes
37
+// --------------------------------------------------------------------------
38
+
39
+#include "../HAL.h"
40
+#include "SPI.h"
41
+#include "pins_arduino.h"
42
+#include "spi_pins.h"
43
+#include "../../core/macros.h"
44
+
45
+// --------------------------------------------------------------------------
46
+// Public Variables
47
+// --------------------------------------------------------------------------
48
+
49
+static SPISettings spiConfig;
50
+
51
+// --------------------------------------------------------------------------
52
+// Public functions
53
+// --------------------------------------------------------------------------
54
+
55
+#if ENABLED(SOFTWARE_SPI)
56
+  // --------------------------------------------------------------------------
57
+  // Software SPI
58
+  // --------------------------------------------------------------------------
59
+  #error "Software SPI not supported for STM32F1. Use hardware SPI."
60
+
61
+#else
62
+
63
+// --------------------------------------------------------------------------
64
+// Hardware SPI
65
+// --------------------------------------------------------------------------
66
+
67
+/**
68
+ * VGPV SPI speed start and F_CPU/2, by default 72/2 = 36Mhz
69
+ */
70
+
71
+/**
72
+ * @brief  Begin SPI port setup
73
+ *
74
+ * @return Nothing
75
+ *
76
+ * @details Only configures SS pin since libmaple creates and initialize the SPI object
77
+ */
78
+void spiBegin() {
79
+  #ifndef SS_PIN
80
+    #error "SS_PIN not defined!"
81
+  #endif
82
+  SET_OUTPUT(SS_PIN);
83
+  WRITE(SS_PIN, HIGH);
84
+}
85
+
86
+/**
87
+ * @brief  Initializes SPI port to required speed rate and transfer mode (MSB, SPI MODE 0)
88
+ *
89
+ * @param  spiRate Rate as declared in HAL.h (speed do not match AVR)
90
+ * @return Nothing
91
+ *
92
+ * @details
93
+ */
94
+void spiInit(uint8_t spiRate) {
95
+  uint8_t  clock;
96
+  switch (spiRate) {
97
+  case SPI_FULL_SPEED:    clock = SPI_CLOCK_DIV2 ;  break;
98
+  case SPI_HALF_SPEED:    clock =  SPI_CLOCK_DIV4 ; break;
99
+  case SPI_QUARTER_SPEED: clock =  SPI_CLOCK_DIV8 ; break;
100
+  case SPI_EIGHTH_SPEED:  clock =  SPI_CLOCK_DIV16; break;
101
+  case SPI_SPEED_5:       clock =   SPI_CLOCK_DIV32;  break;
102
+  case SPI_SPEED_6:       clock =   SPI_CLOCK_DIV64;  break;
103
+  default:
104
+    clock = SPI_CLOCK_DIV2; // Default from the SPI library
105
+  }
106
+  spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
107
+  SPI.begin();
108
+}
109
+
110
+/**
111
+ * @brief  Receives a single byte from the SPI port.
112
+ *
113
+ * @return Byte received
114
+ *
115
+ * @details
116
+ */
117
+uint8_t spiRec(void) {
118
+  SPI.beginTransaction(spiConfig);
119
+  uint8_t returnByte = SPI.transfer(0xFF);
120
+  SPI.endTransaction();
121
+  return returnByte;
122
+}
123
+
124
+/**
125
+ * @brief  Receives a number of bytes from the SPI port to a buffer
126
+ *
127
+ * @param  buf   Pointer to starting address of buffer to write to.
128
+ * @param  nbyte Number of bytes to receive.
129
+ * @return Nothing
130
+ *
131
+ * @details Uses DMA
132
+ */
133
+void spiRead(uint8_t* buf, uint16_t nbyte) {
134
+  SPI.beginTransaction(spiConfig);
135
+  SPI.dmaTransfer(0, const_cast<uint8*>(buf), nbyte);
136
+  SPI.endTransaction();
137
+}
138
+
139
+/**
140
+ * @brief  Sends a single byte on SPI port
141
+ *
142
+ * @param  b Byte to send
143
+ *
144
+ * @details
145
+ */
146
+void spiSend(uint8_t b) {
147
+  SPI.beginTransaction(spiConfig);
148
+  SPI.send(b);
149
+  SPI.endTransaction();
150
+}
151
+
152
+/**
153
+ * @brief  Write token and then write from 512 byte buffer to SPI (for SD card)
154
+ *
155
+ * @param  buf   Pointer with buffer start address
156
+ * @return Nothing
157
+ *
158
+ * @details Use DMA
159
+ */
160
+void spiSendBlock(uint8_t token, const uint8_t* buf) {
161
+  SPI.beginTransaction(spiConfig);
162
+  SPI.send(token);
163
+  SPI.dmaSend(const_cast<uint8*>(buf), 512);
164
+  SPI.endTransaction();
165
+}
166
+
167
+#endif // SOFTWARE_SPI
168
+
169
+#endif // __STM32F1__

+ 145
- 0
Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.cpp View File

@@ -0,0 +1,145 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ *
4
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
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 for stm32duino.com based on Libmaple and compatible (STM32F1)
25
+ */
26
+
27
+#ifdef __STM32F1__
28
+
29
+// --------------------------------------------------------------------------
30
+// Includes
31
+// --------------------------------------------------------------------------
32
+
33
+#include "../HAL.h"
34
+
35
+#include "HAL_timers_Stm32f1.h"
36
+
37
+// --------------------------------------------------------------------------
38
+// Externals
39
+// --------------------------------------------------------------------------
40
+
41
+// --------------------------------------------------------------------------
42
+// Local defines
43
+// --------------------------------------------------------------------------
44
+
45
+#define NUM_HARDWARE_TIMERS 4
46
+
47
+//#define PRESCALER 1
48
+// --------------------------------------------------------------------------
49
+// Types
50
+// --------------------------------------------------------------------------
51
+
52
+
53
+// --------------------------------------------------------------------------
54
+// Public Variables
55
+// --------------------------------------------------------------------------
56
+
57
+// --------------------------------------------------------------------------
58
+// Private Variables
59
+// --------------------------------------------------------------------------
60
+/* VGPV
61
+const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
62
+{ TC0, 0, TC0_IRQn, 0},  // 0 - [servo timer5]
63
+{ TC0, 1, TC1_IRQn, 0},  // 1
64
+{ TC0, 2, TC2_IRQn, 0},  // 2
65
+{ TC1, 0, TC3_IRQn, 2},  // 3 - stepper
66
+{ TC1, 1, TC4_IRQn, 15}, // 4 - temperature
67
+{ TC1, 2, TC5_IRQn, 0},  // 5 - [servo timer3]
68
+{ TC2, 0, TC6_IRQn, 0},  // 6
69
+{ TC2, 1, TC7_IRQn, 0},  // 7
70
+{ TC2, 2, TC8_IRQn, 0},  // 8
71
+};
72
+*/
73
+// --------------------------------------------------------------------------
74
+// Function prototypes
75
+// --------------------------------------------------------------------------
76
+
77
+// --------------------------------------------------------------------------
78
+// Private functions
79
+// --------------------------------------------------------------------------
80
+
81
+// --------------------------------------------------------------------------
82
+// Public functions
83
+// --------------------------------------------------------------------------
84
+
85
+/*
86
+Timer_clock1: Prescaler 2 -> 42MHz
87
+Timer_clock2: Prescaler 8 -> 10.5MHz
88
+Timer_clock3: Prescaler 32 -> 2.625MHz
89
+Timer_clock4: Prescaler 128 -> 656.25kHz
90
+*/
91
+
92
+/**
93
+ * TODO: Calculate Timer prescale value, so we get the 32bit to adjust
94
+ */
95
+
96
+void HAL_timer_start (uint8_t timer_num, uint32_t frequency) {
97
+  switch (timer_num) {
98
+    case STEP_TIMER_NUM:
99
+      StepperTimer.pause();
100
+      StepperTimer.setCount(0);
101
+      StepperTimer.setPrescaleFactor(STEPPER_TIMER_PRESCALE);
102
+      StepperTimer.setOverflow(0xFFFF);
103
+      StepperTimer.setCompare (STEP_TIMER_CHAN, (HAL_STEPPER_TIMER_RATE / frequency));
104
+      StepperTimer.refresh();
105
+      StepperTimer.resume();
106
+      break;
107
+    case TEMP_TIMER_NUM:
108
+      TempTimer.pause();
109
+      TempTimer.setCount(0);
110
+      TempTimer.setPrescaleFactor(TEMP_TIMER_PRESCALE);
111
+      TempTimer.setOverflow(0xFFFF);
112
+      TempTimer.setCompare (TEMP_TIMER_CHAN, ((F_CPU / TEMP_TIMER_PRESCALE) / frequency));
113
+      TempTimer.refresh();
114
+      TempTimer.resume();
115
+      break;
116
+  }
117
+}
118
+
119
+void HAL_timer_enable_interrupt (uint8_t timer_num) {
120
+  switch (timer_num) {
121
+    case STEP_TIMER_NUM:
122
+      StepperTimer.attachInterrupt(STEP_TIMER_CHAN, stepTC_Handler);
123
+      break;
124
+    case TEMP_TIMER_NUM:
125
+      TempTimer.attachInterrupt(STEP_TIMER_CHAN, tempTC_Handler);
126
+      break;
127
+    default:
128
+      break;
129
+  }
130
+}
131
+
132
+void HAL_timer_disable_interrupt (uint8_t timer_num) {
133
+  switch (timer_num) {
134
+    case STEP_TIMER_NUM:
135
+      StepperTimer.detachInterrupt(STEP_TIMER_CHAN);
136
+      break;
137
+    case TEMP_TIMER_NUM:
138
+      TempTimer.detachInterrupt(STEP_TIMER_CHAN);
139
+      break;
140
+    default:
141
+      break;
142
+  }
143
+}
144
+
145
+#endif // __STM32F1__

+ 183
- 0
Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h View File

@@ -0,0 +1,183 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ *
4
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6
+ * Copyright (c) 2017 Victor Perez
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 for stm32duino.com based on Libmaple and compatible (STM32F1)
25
+ */
26
+
27
+#ifndef _HAL_TIMERS_STM32F1_H
28
+#define _HAL_TIMERS_STM32F1_H
29
+
30
+// --------------------------------------------------------------------------
31
+// Includes
32
+// --------------------------------------------------------------------------
33
+
34
+#include <stdint.h>
35
+
36
+// --------------------------------------------------------------------------
37
+// Defines
38
+// --------------------------------------------------------------------------
39
+
40
+/**
41
+ * TODO: Check and confirm what timer we will use for each Temps and stepper driving.
42
+ * We should probable drive temps with PWM.
43
+ */
44
+#define FORCE_INLINE __attribute__((always_inline)) inline
45
+
46
+#define HAL_TIMER_TYPE uint16_t
47
+#define HAL_TIMER_TYPE_MAX 0xFFFF
48
+
49
+#define STEP_TIMER_NUM 5  // index of timer to use for stepper
50
+#define STEP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts
51
+#define TEMP_TIMER_NUM 2  // index of timer to use for temperature
52
+#define TEMP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts
53
+
54
+
55
+#define HAL_TIMER_RATE         (F_CPU)  // frequency of timers peripherals
56
+#define STEPPER_TIMER_PRESCALE 36             // prescaler for setting stepper timer, 2Mhz
57
+#define HAL_STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)   // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
58
+#define HAL_TICKS_PER_US       ((HAL_STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per us
59
+
60
+#define TEMP_TIMER_PRESCALE     1000 // prescaler for setting Temp timer, 72Khz
61
+#define TEMP_TIMER_FREQUENCY    1000 // temperature interrupt frequency
62
+
63
+#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt (STEP_TIMER_NUM)
64
+#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt (STEP_TIMER_NUM)
65
+
66
+#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt (TEMP_TIMER_NUM)
67
+#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt (TEMP_TIMER_NUM)
68
+
69
+#define HAL_ENABLE_ISRs() do { if (thermalManager.in_temp_isr)DISABLE_TEMPERATURE_INTERRUPT(); else ENABLE_TEMPERATURE_INTERRUPT(); ENABLE_STEPPER_DRIVER_INTERRUPT(); } while(0)
70
+// TODO change this
71
+
72
+
73
+#define HAL_TEMP_TIMER_ISR extern "C" void tempTC_Handler(void)
74
+#define HAL_STEP_TIMER_ISR extern "C" void stepTC_Handler(void)
75
+
76
+extern "C" void tempTC_Handler(void);
77
+extern "C" void stepTC_Handler(void);
78
+
79
+// --------------------------------------------------------------------------
80
+// Types
81
+// --------------------------------------------------------------------------
82
+
83
+
84
+// --------------------------------------------------------------------------
85
+// Public Variables
86
+// --------------------------------------------------------------------------
87
+
88
+static HardwareTimer StepperTimer(STEP_TIMER_NUM);
89
+static HardwareTimer TempTimer(TEMP_TIMER_NUM);
90
+
91
+// --------------------------------------------------------------------------
92
+// Public functions
93
+// --------------------------------------------------------------------------
94
+
95
+void HAL_timer_start (uint8_t timer_num, uint32_t frequency);
96
+void HAL_timer_enable_interrupt(uint8_t timer_num);
97
+void HAL_timer_disable_interrupt(uint8_t timer_num);
98
+
99
+/**
100
+ * NOTE: By default libmaple sets ARPE = 1, which means the Auto reload register is preloaded (will only update with an update event)
101
+ * Thus we have to pause the timer, update the value, refresh, resume the timer.
102
+ * That seems like a big waste of time and may be better to change the timer config to ARPE = 0, so ARR can be updated any time.
103
+ * We are using a Channel in each timer in Capture/Compare mode. We could also instead use the Time Update Event Interrupt, but need to disable ARPE
104
+ * so we can change the ARR value on the fly (without calling refresh), and not get an interrupt right there because we caused an UEV.
105
+ * This mode pretty much makes 2 timers unusable for PWM since they have their counts updated all the time on ISRs.
106
+ * The way Marlin manages timer interrupts doesn't make for an efficient usage in STM32F1
107
+ * Todo: Look at that possibility later.
108
+ */
109
+
110
+static FORCE_INLINE void HAL_timer_set_count (uint8_t timer_num, uint32_t count) {
111
+  switch (timer_num) {
112
+  case STEP_TIMER_NUM:
113
+    StepperTimer.pause();
114
+    StepperTimer.setCompare (STEP_TIMER_CHAN, count);
115
+    StepperTimer.refresh ();
116
+    StepperTimer.resume ();
117
+    break;
118
+  case TEMP_TIMER_NUM:
119
+    TempTimer.pause();
120
+    TempTimer.setCompare (TEMP_TIMER_CHAN, count);
121
+    TempTimer.refresh ();
122
+    TempTimer.resume ();
123
+    break;
124
+  default:
125
+    break;
126
+  }
127
+}
128
+
129
+static FORCE_INLINE HAL_TIMER_TYPE HAL_timer_get_count (uint8_t timer_num) {
130
+  HAL_TIMER_TYPE temp;
131
+  switch (timer_num) {
132
+  case STEP_TIMER_NUM:
133
+    temp = StepperTimer.getCompare(STEP_TIMER_CHAN);
134
+    break;
135
+  case TEMP_TIMER_NUM:
136
+    temp = TempTimer.getCompare(TEMP_TIMER_CHAN);
137
+    break;
138
+  default:
139
+    temp = 0;
140
+    break;
141
+  }
142
+  return temp;
143
+}
144
+
145
+static FORCE_INLINE HAL_TIMER_TYPE HAL_timer_get_current_count(uint8_t timer_num) {
146
+  HAL_TIMER_TYPE temp;
147
+  switch (timer_num) {
148
+  case STEP_TIMER_NUM:
149
+    temp = StepperTimer.getCount();
150
+    break;
151
+  case TEMP_TIMER_NUM:
152
+    temp = TempTimer.getCount();
153
+    break;
154
+  default:
155
+    temp = 0;
156
+    break;
157
+  }
158
+  return temp;
159
+}
160
+
161
+
162
+//void HAL_timer_isr_prologue (uint8_t timer_num);
163
+
164
+static FORCE_INLINE void HAL_timer_isr_prologue(uint8_t timer_num) {
165
+  switch (timer_num) {
166
+  case STEP_TIMER_NUM:
167
+    StepperTimer.pause();
168
+    StepperTimer.setCount(0);
169
+    StepperTimer.refresh();
170
+    StepperTimer.resume();
171
+    break;
172
+  case TEMP_TIMER_NUM:
173
+    TempTimer.pause();
174
+    TempTimer.setCount(0);
175
+    TempTimer.refresh();
176
+    TempTimer.resume();
177
+    break;
178
+  default:
179
+    break;
180
+  }
181
+}
182
+
183
+#endif // _HAL_TIMERS_STM32F1_H

+ 32
- 0
Marlin/src/HAL/HAL_STM32F1/README.md View File

@@ -0,0 +1,32 @@
1
+# This HAL is for STM32F103 boards used with libmaple/stm32duino Arduino core.
2
+
3
+# This HAL is in development and has not been tested with an actual printer.
4
+
5
+### The stm32 core needs a modification in the file util.h to avoid conflict with Marlin macros for Debug.
6
+Since only 1 file needs change in the stm32duino core, it's preferable over making changes to Marlin.
7
+
8
+
9
+After these lines:
10
+<>
11
+#else
12
+#define ASSERT_FAULT(exp) (void)((0))
13
+#endif
14
+<>
15
+
16
+Add the following 3 lines:
17
+<>
18
+#undef DEBUG_NONE
19
+#undef DEBUG_FAULT
20
+#undef DEBUG_ALL
21
+<>
22
+
23
+### Main developers:
24
+Victorpv
25
+
26
+
27
+### Most up to date repository for this HAL:
28
+https://github.com/victorpv/Marlin/tree/bugfix-2.0.x
29
+
30
+PRs should be first sent to that fork, and once tested merged to Marlin bugfix-2.0.x branch.
31
+
32
+

+ 70
- 0
Marlin/src/HAL/HAL_STM32F1/SanityCheck_Stm32f1.h View File

@@ -0,0 +1,70 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016, 2017 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 for stm32duino.com based on Libmaple and compatible (STM32F1)
25
+ */
26
+
27
+/**
28
+ * Test Re-ARM specific configuration values for errors at compile-time.
29
+ */
30
+#if ENABLED(SPINDLE_LASER_ENABLE)
31
+  #if !PIN_EXISTS(SPINDLE_LASER_ENABLE)
32
+    #error "SPINDLE_LASER_ENABLE requires SPINDLE_LASER_ENABLE_PIN."
33
+  #elif SPINDLE_DIR_CHANGE && !PIN_EXISTS(SPINDLE_DIR)
34
+    #error "SPINDLE_DIR_PIN not defined."
35
+  #elif ENABLED(SPINDLE_LASER_PWM) && PIN_EXISTS(SPINDLE_LASER_PWM)
36
+    #if !PWM_PIN(SPINDLE_LASER_PWM_PIN)
37
+      #error "SPINDLE_LASER_PWM_PIN not assigned to a PWM pin."
38
+    #elif !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11)
39
+      #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
40
+    #elif SPINDLE_LASER_POWERUP_DELAY < 1
41
+      #error "SPINDLE_LASER_POWERUP_DELAY must be greater than 0."
42
+    #elif SPINDLE_LASER_POWERDOWN_DELAY < 1
43
+      #error "SPINDLE_LASER_POWERDOWN_DELAY must be greater than 0."
44
+    #elif !defined(SPINDLE_LASER_PWM_INVERT)
45
+      #error "SPINDLE_LASER_PWM_INVERT missing."
46
+    #elif !defined(SPEED_POWER_SLOPE) || !defined(SPEED_POWER_INTERCEPT) || !defined(SPEED_POWER_MIN) || !defined(SPEED_POWER_MAX)
47
+      #error "SPINDLE_LASER_PWM equation constant(s) missing."
48
+    #elif PIN_EXISTS(CASE_LIGHT) && SPINDLE_LASER_PWM_PIN == CASE_LIGHT_PIN
49
+      #error "SPINDLE_LASER_PWM_PIN is used by CASE_LIGHT_PIN."
50
+    #elif PIN_EXISTS(E0_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E0_AUTO_FAN_PIN
51
+      #error "SPINDLE_LASER_PWM_PIN is used by E0_AUTO_FAN_PIN."
52
+    #elif PIN_EXISTS(E1_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E1_AUTO_FAN_PIN
53
+      #error "SPINDLE_LASER_PWM_PIN is used by E1_AUTO_FAN_PIN."
54
+    #elif PIN_EXISTS(E2_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E2_AUTO_FAN_PIN
55
+      #error "SPINDLE_LASER_PWM_PIN is used by E2_AUTO_FAN_PIN."
56
+    #elif PIN_EXISTS(E3_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E3_AUTO_FAN_PIN
57
+      #error "SPINDLE_LASER_PWM_PIN is used by E3_AUTO_FAN_PIN."
58
+    #elif PIN_EXISTS(E4_AUTO_FAN) && SPINDLE_LASER_PWM_PIN == E4_AUTO_FAN_PIN
59
+      #error "SPINDLE_LASER_PWM_PIN is used by E4_AUTO_FAN_PIN."
60
+    #elif PIN_EXISTS(FAN) && SPINDLE_LASER_PWM_PIN == FAN_PIN
61
+      #error "SPINDLE_LASER_PWM_PIN is used FAN_PIN."
62
+    #elif PIN_EXISTS(FAN1) && SPINDLE_LASER_PWM_PIN == FAN1_PIN
63
+      #error "SPINDLE_LASER_PWM_PIN is used FAN1_PIN."
64
+    #elif PIN_EXISTS(FAN2) && SPINDLE_LASER_PWM_PIN == FAN2_PIN
65
+      #error "SPINDLE_LASER_PWM_PIN is used FAN2_PIN."
66
+    #elif PIN_EXISTS(CONTROLLERFAN) && SPINDLE_LASER_PWM_PIN == CONTROLLERFAN_PIN
67
+      #error "SPINDLE_LASER_PWM_PIN is used by CONTROLLERFAN_PIN."
68
+    #endif
69
+  #endif
70
+#endif // SPINDLE_LASER_ENABLE

+ 91
- 0
Marlin/src/HAL/HAL_STM32F1/endstop_interrupts.h View File

@@ -0,0 +1,91 @@
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
+ * Copyright (C) 2017 Victor Perez
8
+ *
9
+ * This program is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+/**
25
+ * Endstop interrupts for Libmaple STM32F1 based targets.
26
+ *
27
+ * On STM32F, all pins support external interrupt capability.
28
+ * Any pin can be used for external interrupts, but there are some restrictions.
29
+ * At most 16 different external interrupts can be used at one time.
30
+ * Further, you can’t just pick any 16 pins to use. This is because every pin on the STM32
31
+ * connects to what is called an EXTI line, and only one pin per EXTI line can be used for external interrupts at a time
32
+ * Check the Reference Manual of the MCU to confirm which line is used by each pin
33
+ */
34
+
35
+/**
36
+ * Endstop Interrupts
37
+ *
38
+ * Without endstop interrupts the endstop pins must be polled continually in
39
+ * the stepper-ISR via endstops.update(), most of the time finding no change.
40
+ * With this feature endstops.update() is called only when we know that at
41
+ * least one endstop has changed state, saving valuable CPU cycles.
42
+ *
43
+ * This feature only works when all used endstop pins can generate an 'external interrupt'.
44
+ *
45
+ * Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
46
+ * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
47
+ */
48
+
49
+#ifndef _ENDSTOP_INTERRUPTS_H_
50
+#define _ENDSTOP_INTERRUPTS_H_
51
+
52
+void setup_endstop_interrupts(void) {
53
+  #if HAS_X_MAX
54
+    pinMode(X_MAX_PIN, INPUT);
55
+    attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE); // assign it
56
+  #endif
57
+  #if HAS_X_MIN
58
+    pinMode(X_MIN_PIN, INPUT);
59
+    attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
60
+  #endif
61
+  #if HAS_Y_MAX
62
+    pinMode(Y_MAX_PIN, INPUT);
63
+    attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
64
+  #endif
65
+  #if HAS_Y_MIN
66
+    pinMode(Y_MIN_PIN, INPUT);
67
+    attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
68
+  #endif
69
+  #if HAS_Z_MAX
70
+    pinMode(Z_MAX_PIN, INPUT);
71
+    attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
72
+  #endif
73
+  #if HAS_Z_MIN
74
+    pinMode(Z_MIN_PIN, INPUT);
75
+    attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
76
+  #endif
77
+  #if HAS_Z2_MAX
78
+    pinMode(Z2_MAX_PIN, INPUT);
79
+    attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
80
+  #endif
81
+  #if HAS_Z2_MIN
82
+    pinMode(Z2_MIN_PIN, INPUT);
83
+    attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
84
+  #endif
85
+  #if HAS_Z_MIN_PROBE_PIN
86
+    pinMode(Z_MIN_PROBE_PIN, INPUT);
87
+    attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
88
+  #endif
89
+}
90
+
91
+#endif //_ENDSTOP_INTERRUPTS_H_

+ 53
- 0
Marlin/src/HAL/HAL_STM32F1/fastio_Stm32f1.h View File

@@ -0,0 +1,53 @@
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
+ * Copyright (C) 2017 Victor Perez
8
+ *
9
+ * This program is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+/**
25
+ * Fast I/O interfaces for STM32F1
26
+ * These use GPIO functions instead of Direct Port Manipulation, as on AVR.
27
+ */
28
+
29
+#ifndef	_FASTIO_STM32F1_H
30
+#define	_FASTIO_STM32F1_H
31
+
32
+#include <libmaple/gpio.h>
33
+
34
+#define READ(IO)              (gpio_read_bit(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit) ? HIGH : LOW)
35
+#define WRITE(IO, v)          do{ gpio_write_bit(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit, v); } while (0)
36
+#define TOGGLE(IO)            do{ gpio_toggle_bit(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit); } while (0)
37
+#define WRITE_VAR(IO, v)      WRITE(io, v)
38
+
39
+#define _GET_MODE(IO)         (gpio_get_mode(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit))
40
+#define _SET_MODE(IO,M)       do{ gpio_set_mode(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit, M); } while (0)
41
+#define _SET_OUTPUT(IO)       _SET_MODE(IO, GPIO_OUTPUT_PP)
42
+
43
+#define SET_INPUT(IO)         _SET_MODE(IO, GPIO_INPUT_FLOATING)
44
+#define SET_INPUT_PULLUP(IO)  _SET_MODE(IO, GPIO_INPUT_PU)
45
+#define SET_OUTPUT(IO)        do{ _SET_OUTPUT(IO); WRITE(IO, LOW); }while(0)
46
+
47
+#define GET_INPUT(IO)         (_GET_MODE(IO) == GPIO_INPUT_FLOATING || _GET_MODE(IO) == GPIO_INPUT_ANALOG || _GET_MODE(IO) == GPIO_INPUT_PU || _GET_MODE(IO) == GPIO_INPUT_PD)
48
+#define GET_OUTPUT(IO)        (_GET_MODE(IO) == GPIO_OUTPUT_PP)
49
+#define GET_TIMER(IO)         (PIN_MAP[IO].timer_device != NULL)
50
+
51
+#define OUT_WRITE(IO, v) { _SET_OUTPUT(IO); WRITE(IO, v); }
52
+
53
+#endif	/* _FASTIO_STM32F1_H */

+ 98
- 0
Marlin/src/HAL/HAL_STM32F1/persistent_store_impl.cpp View File

@@ -0,0 +1,98 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ *
4
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
7
+ * Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
8
+ *
9
+ * This program is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+/**
25
+ * HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
26
+ */
27
+
28
+#ifdef __STM32F1__
29
+
30
+#include "../../inc/MarlinConfig.h"
31
+
32
+#if ENABLED(EEPROM_SETTINGS)
33
+
34
+#include "../persistent_store_api.h"
35
+
36
+//#include "../../core/types.h"
37
+//#include "../../core/language.h"
38
+//#include "../../core/serial.h"
39
+//#include "../../core/utility.h"
40
+
41
+#include "../../sd/cardreader.h"
42
+
43
+
44
+namespace HAL {
45
+namespace PersistentStore {
46
+
47
+#define CONFIG_FILE_NAME "eeprom.dat"
48
+#define HAL_STM32F1_EEPROM_SIZE 4096
49
+char HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
50
+
51
+bool access_start() {
52
+	if (!card.cardOK) return false;
53
+	int16_t bytes_read = 0;
54
+	const char eeprom_zero = 0xFF;
55
+	card.openFile((char *)CONFIG_FILE_NAME,true);
56
+	bytes_read = card.read (HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
57
+	if (bytes_read == -1) return false;
58
+	for (; bytes_read < HAL_STM32F1_EEPROM_SIZE; bytes_read++) {
59
+		HAL_STM32F1_eeprom_content[bytes_read] = eeprom_zero;
60
+	}
61
+	card.closefile();
62
+	return true;
63
+}
64
+
65
+
66
+bool access_finish(){
67
+	if (!card.cardOK) return false;
68
+	int16_t bytes_written = 0;
69
+	card.openFile((char *)CONFIG_FILE_NAME,true);
70
+	bytes_written = card.write (HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
71
+	card.closefile();
72
+	return (bytes_written == HAL_STM32F1_EEPROM_SIZE);
73
+}
74
+
75
+bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
76
+	for (int i = 0; i < size; i++) {
77
+		HAL_STM32F1_eeprom_content [pos + i] = value[i];
78
+	}
79
+	crc16(crc, value, size);
80
+	pos += size;
81
+	return true;
82
+}
83
+
84
+void read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
85
+	for (int i = 0; i < size; i++) {
86
+		value[i] = HAL_STM32F1_eeprom_content [pos + i];
87
+	}
88
+	crc16(crc, value, size);
89
+	pos += size;
90
+}
91
+
92
+} // PersistentStore::
93
+} // HAL::
94
+
95
+#endif // EEPROM_SETTINGS
96
+
97
+#endif // __STM32F1__
98
+

+ 37
- 0
Marlin/src/HAL/HAL_STM32F1/spi_pins.h View File

@@ -0,0 +1,37 @@
1
+/**
2
+* Marlin 3D Printer Firmware
3
+* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+*
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
+*
10
+* This program is distributed in the hope that it will be useful,
11
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+* GNU General Public License for more details.
14
+*
15
+* You should have received a copy of the GNU General Public License
16
+* along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
+*
18
+*/
19
+
20
+/**
21
+ * HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
22
+ */
23
+
24
+#ifndef SPI_PINS_H_
25
+#define SPI_PINS_H_
26
+
27
+/**
28
+ * Define SPI Pins: SCK, MISO, MOSI, SS
29
+ *
30
+ * Available chip select pins for HW SPI are 4 10 52 77
31
+ */
32
+#define SCK_PIN   PA5
33
+#define MISO_PIN  PA6
34
+#define MOSI_PIN  PA7
35
+#define SS_PIN    PA4
36
+
37
+#endif // SPI_PINS_H_

+ 53
- 0
Marlin/src/HAL/HAL_STM32F1/watchdog_Stm32f1.cpp View File

@@ -0,0 +1,53 @@
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 for stm32duino.com based on Libmaple and compatible (STM32F1)
25
+ */
26
+
27
+#ifdef __STM32F1__
28
+
29
+#include "../../inc/MarlinConfig.h"
30
+
31
+#if ENABLED(USE_WATCHDOG)
32
+
33
+#include <libmaple/iwdg.h>
34
+#include "watchdog_Stm32f1.h"
35
+
36
+void watchdogSetup(void) {
37
+  // do whatever. don't remove this function.
38
+}
39
+
40
+/**
41
+ * @brief  Initialized the independent hardware watchdog.
42
+ *
43
+ * @return No return
44
+ *
45
+ * @details The watchdog clock is 40Khz. We need a 4 seconds interval, so use a /256 preescaler and 625 reload value (counts down to 0)
46
+ */
47
+void watchdog_init(void) {
48
+  //iwdg_init(IWDG_PRE_256, STM32F1_WD_RELOAD);
49
+}
50
+
51
+#endif // USE_WATCHDOG
52
+
53
+#endif // __STM32F1__

+ 44
- 0
Marlin/src/HAL/HAL_STM32F1/watchdog_Stm32f1.h View File

@@ -0,0 +1,44 @@
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 for stm32duino.com based on Libmaple and compatible (STM32F1)
25
+ */
26
+
27
+#ifndef WATCHDOG_STM32F1_H
28
+#define WATCHDOG_STM32F1_H
29
+#include <libmaple/iwdg.h>
30
+
31
+#include "../../../src/inc/MarlinConfig.h"
32
+#define STM32F1_WD_RELOAD 625
33
+
34
+
35
+// Arduino STM32F1 core now has watchdog support
36
+
37
+// Initialize watchdog with a 4 second countdown time
38
+void watchdog_init();
39
+
40
+// Reset watchdog. MUST be called at least every 4 seconds after the
41
+// first watchdog_init or STM32F1 will reset.
42
+inline void watchdog_reset() { iwdg_feed(); }
43
+
44
+#endif // WATCHDOG_STM32F1_H

+ 2
- 0
Marlin/src/HAL/HAL_SanityCheck.h View File

@@ -30,6 +30,8 @@
30 30
   #include "HAL_TEENSY35_36/SanityCheck_Teensy_35_36.h"
31 31
 #elif defined(TARGET_LPC1768)
32 32
   #include "HAL_LPC1768/SanityCheck_Re_ARM.h"
33
+#elif defined(__STM32F1__)
34
+    #include "HAL_STM32F1/SanityCheck_Stm32f1.h"
33 35
 #else
34 36
   #error Unsupported Platform!
35 37
 #endif

+ 2
- 1
Marlin/src/HAL/HAL_spi_pins.h View File

@@ -34,7 +34,8 @@
34 34
 
35 35
 #elif defined(TARGET_LPC1768)
36 36
   #include "HAL_LPC1768/spi_pins.h"
37
-
37
+#elif defined(__STM32F1__)
38
+    #include "HAL_STM32F1/spi_pins.h"
38 39
 #else
39 40
   #error "Unsupported Platform!"
40 41
 #endif

+ 1643
- 0
Marlin/src/config/examples/stm32f103ret6/Configuration.h
File diff suppressed because it is too large
View File


+ 1
- 0
Marlin/src/core/boards.h View File

@@ -128,6 +128,7 @@
128 128
 #define BOARD_RAMPS_14_RE_ARM_EFF      1745   // Re-ARM with RAMPS 1.4 (Power outputs: Hotend, Fan0, Fan1)
129 129
 #define BOARD_RAMPS_14_RE_ARM_EEF      1746   // Re-ARM with RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Fan)
130 130
 #define BOARD_RAMPS_14_RE_ARM_SF       1748   // Re-ARM with RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
131
+#define BOARD_STM32F1R         1800  // STM3R Libmaple based stm32f1 controller
131 132
 
132 133
 #define MB(board) (MOTHERBOARD==BOARD_##board)
133 134
 

+ 2
- 0
Marlin/src/pins/pins.h View File

@@ -298,6 +298,8 @@
298 298
   #include "pins_RAMPS4DUE.h"
299 299
 #elif MB(ALLIGATOR)
300 300
   #include "pins_ALLIGATOR_R2.h"
301
+#elif MB(STM32F1R)
302
+  #include "pins_STM32F1R.h"
301 303
 #else
302 304
   #error "Unknown MOTHERBOARD value set in Configuration.h"
303 305
 #endif

+ 11
- 1
Marlin/src/pins/pins_5DPRINT.h View File

@@ -77,6 +77,14 @@
77 77
 #define LARGE_FLASH        true
78 78
 
79 79
 //
80
+// Servos
81
+//
82
+#define SERVO0_PIN        41
83
+#define SERVO1_PIN        42
84
+#define SERVO2_PIN        43
85
+#define SERVO3_PIN        44
86
+
87
+//
80 88
 // Limit Switches
81 89
 //
82 90
 #define X_STOP_PIN         37   // E5
@@ -102,7 +110,9 @@
102 110
 #define E0_DIR_PIN         35   // A7
103 111
 #define E0_ENABLE_PIN      11   // C1
104 112
 
105
-
113
+//
114
+// Digital Microstepping
115
+//
106 116
 #define X_MS1_PIN          25   // B5
107 117
 #define X_MS2_PIN          26   // B6
108 118
 #define Y_MS1_PIN           9   // E1

+ 283
- 0
Marlin/src/pins/pins_STM32F1R.h View File

@@ -0,0 +1,283 @@
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
+#if !defined(__STM32F1__)
24
+    #error "Oops!  Make sure you have an STM32F1 board selected from the 'Tools -> Boards' menu."
25
+#endif
26
+
27
+/**
28
+ * 21017 Victor Perez Marlin for stm32f1 test
29
+ */
30
+
31
+#define DEFAULT_MACHINE_NAME "STM32F103RET6"
32
+#define BOARD_NAME "Marlin for STM32"
33
+
34
+#define LARGE_FLASH true
35
+
36
+// Ignore temp readings during develpment.
37
+#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
38
+
39
+//
40
+// Steppers
41
+//
42
+#define X_STEP_PIN         PC0
43
+#define X_DIR_PIN          PC1
44
+#define X_ENABLE_PIN       PA8
45
+#define X_MIN_PIN          PB3
46
+#define X_MAX_PIN          -1
47
+
48
+#define Y_STEP_PIN         PC2
49
+#define Y_DIR_PIN          PC3
50
+#define Y_ENABLE_PIN       PA8
51
+#define Y_MIN_PIN          -1
52
+#define Y_MAX_PIN          PB4
53
+
54
+#define Z_STEP_PIN         PC4
55
+#define Z_DIR_PIN          PC5
56
+#define Z_ENABLE_PIN       PA8
57
+#define Z_MIN_PIN          -1
58
+#define Z_MAX_PIN          PB5
59
+
60
+#define Y2_STEP_PIN        -1
61
+#define Y2_DIR_PIN         -1
62
+#define Y2_ENABLE_PIN      -1
63
+
64
+#define Z2_STEP_PIN        -1
65
+#define Z2_DIR_PIN         -1
66
+#define Z2_ENABLE_PIN      -1
67
+
68
+#define E0_STEP_PIN        PC6
69
+#define E0_DIR_PIN         PC7
70
+#define E0_ENABLE_PIN      PA8
71
+
72
+/**
73
+ * TODO: Currently using same Enable pin to all steppers.
74
+ */
75
+
76
+#define E1_STEP_PIN        PC8
77
+#define E1_DIR_PIN         PC9
78
+#define E1_ENABLE_PIN      PA8
79
+
80
+#define E2_STEP_PIN        PC10
81
+#define E2_DIR_PIN         PC11
82
+#define E2_ENABLE_PIN      PA8
83
+
84
+//
85
+// Misc. Functions
86
+//
87
+#define SDPOWER            -1
88
+#define SDSS               PA4
89
+#define LED_PIN            PD2
90
+
91
+#define PS_ON_PIN          -1
92
+#define KILL_PIN           -1
93
+
94
+//
95
+// Heaters / Fans
96
+//
97
+#define HEATER_0_PIN       PB0   // EXTRUDER 1
98
+#define HEATER_1_PIN       PB1
99
+#define HEATER_2_PIN       -1
100
+
101
+#define HEATER_BED_PIN     PA3   // BED
102
+#define HEATER_BED2_PIN    -1    // BED2
103
+#define HEATER_BED3_PIN    -1    // BED3
104
+
105
+#define FAN_PIN            -1 // (Sprinter config)
106
+
107
+//
108
+// Temperature Sensors
109
+//
110
+#define TEMP_BED_PIN       PA0   // ANALOG NUMBERING
111
+#define TEMP_0_PIN         PA1   // ANALOG NUMBERING
112
+#define TEMP_1_PIN         PA2   // ANALOG NUMBERING
113
+#define TEMP_2_PIN         -1   // ANALOG NUMBERING
114
+
115
+//
116
+// LCD Pins
117
+//
118
+#if ENABLED(ULTRA_LCD)
119
+
120
+  #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
121
+    #define LCD_PINS_RS         49 // CS chip select /SS chip slave select
122
+    #define LCD_PINS_ENABLE     51 // SID (MOSI)
123
+    #define LCD_PINS_D4         52 // SCK (CLK) clock
124
+  #elif ENABLED(NEWPANEL) && ENABLED(PANEL_ONE)
125
+    #define LCD_PINS_RS         PB8
126
+    #define LCD_PINS_ENABLE     PD2
127
+    #define LCD_PINS_D4         PB12
128
+    #define LCD_PINS_D5         PB13
129
+    #define LCD_PINS_D6         PB14
130
+    #define LCD_PINS_D7         PB15
131
+  #else
132
+    #define LCD_PINS_RS         PB8
133
+    #define LCD_PINS_ENABLE     PD2
134
+    #define LCD_PINS_D4         PB12
135
+    #define LCD_PINS_D5         PB13
136
+    #define LCD_PINS_D6         PB14
137
+    #define LCD_PINS_D7         PB15
138
+    #if DISABLED(NEWPANEL)
139
+      #define BEEPER_PIN        33
140
+      // Buttons are attached to a shift register
141
+      // Not wired yet
142
+      //#define SHIFT_CLK 38
143
+      //#define SHIFT_LD 42
144
+      //#define SHIFT_OUT 40
145
+      //#define SHIFT_EN 17
146
+    #endif
147
+  #endif
148
+
149
+  #if ENABLED(NEWPANEL)
150
+
151
+    #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
152
+
153
+      #define BEEPER_PIN        37
154
+
155
+      #define BTN_EN1           31
156
+      #define BTN_EN2           33
157
+      #define BTN_ENC           35
158
+
159
+      #define SD_DETECT_PIN     49
160
+      #define KILL_PIN          41
161
+
162
+      #if ENABLED(BQ_LCD_SMART_CONTROLLER)
163
+        #define LCD_BACKLIGHT_PIN 39
164
+      #endif
165
+
166
+    #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
167
+
168
+      #define BTN_EN1           64
169
+      #define BTN_EN2           59
170
+      #define BTN_ENC           63
171
+      #define SD_DETECT_PIN     42
172
+
173
+    #elif ENABLED(LCD_I2C_PANELOLU2)
174
+
175
+      #define BTN_EN1           47
176
+      #define BTN_EN2           43
177
+      #define BTN_ENC           32
178
+      #define LCD_SDSS          53
179
+      #define SD_DETECT_PIN     -1
180
+      #define KILL_PIN          41
181
+
182
+    #elif ENABLED(LCD_I2C_VIKI)
183
+
184
+      #define BTN_EN1           22 // http://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42.
185
+      #define BTN_EN2            7 // 22/7 are unused on RAMPS_14. 22 is unused and 7 the SERVO0_PIN on RAMPS_13.
186
+
187
+      #define BTN_ENC           -1
188
+      #define LCD_SDSS          53
189
+      #define SD_DETECT_PIN     49
190
+
191
+    #elif ENABLED(VIKI2) || ENABLED(miniVIKI)
192
+
193
+      #define BEEPER_PIN        33
194
+
195
+      // Pins for DOGM SPI LCD Support
196
+      #define DOGLCD_A0         44
197
+      #define DOGLCD_CS         45
198
+      #define LCD_SCREEN_ROT_180
199
+
200
+      #define BTN_EN1           22
201
+      #define BTN_EN2            7
202
+      #define BTN_ENC           39
203
+
204
+      #define SDSS              53
205
+      #define SD_DETECT_PIN     -1 // Pin 49 for display sd interface, 72 for easy adapter board
206
+
207
+      #define KILL_PIN          31
208
+
209
+      #define STAT_LED_RED_PIN  32
210
+      #define STAT_LED_BLUE_PIN 35
211
+
212
+    #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
213
+      #define BTN_EN1           35
214
+      #define BTN_EN2           37
215
+      #define BTN_ENC           31
216
+      #define SD_DETECT_PIN     49
217
+      #define LCD_SDSS          53
218
+      #define KILL_PIN          41
219
+      #define BEEPER_PIN        23
220
+      #define DOGLCD_CS         29
221
+      #define DOGLCD_A0         27
222
+      #define LCD_BACKLIGHT_PIN 33
223
+    #elif ENABLED(MINIPANEL)
224
+      #define BEEPER_PIN        42
225
+      // Pins for DOGM SPI LCD Support
226
+      #define DOGLCD_A0         44
227
+      #define DOGLCD_CS         66
228
+      #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65
229
+      #define SDSS              53
230
+
231
+      #define KILL_PIN          64
232
+      // GLCD features
233
+      //#define LCD_CONTRAST   190
234
+      // Uncomment screen orientation
235
+      //#define LCD_SCREEN_ROT_90
236
+      //#define LCD_SCREEN_ROT_180
237
+      //#define LCD_SCREEN_ROT_270
238
+      // The encoder and click button
239
+      #define BTN_EN1           40
240
+      #define BTN_EN2           63
241
+      #define BTN_ENC           59
242
+      // not connected to a pin
243
+      #define SD_DETECT_PIN     49
244
+
245
+    #else
246
+
247
+      // Beeper on AUX-4
248
+      #define BEEPER_PIN        33
249
+
250
+      // buttons are directly attached using AUX-2
251
+      #if ENABLED(REPRAPWORLD_KEYPAD)
252
+        #define BTN_EN1         64
253
+        #define BTN_EN2         59
254
+        #define BTN_ENC         63
255
+        #define SHIFT_OUT       40
256
+        #define SHIFT_CLK       44
257
+        #define SHIFT_LD        42
258
+      #elif ENABLED(PANEL_ONE)
259
+        #define BTN_EN1         59 // AUX2 PIN 3
260
+        #define BTN_EN2         63 // AUX2 PIN 4
261
+        #define BTN_ENC         49 // AUX3 PIN 7
262
+      #else
263
+        #define BTN_EN1         37
264
+        #define BTN_EN2         35
265
+        #define BTN_ENC         31
266
+      #endif
267
+
268
+      #if ENABLED(G3D_PANEL)
269
+        #define SD_DETECT_PIN   49
270
+        #define KILL_PIN        41
271
+      #else
272
+        //#define SD_DETECT_PIN -1 // Ramps doesn't use this
273
+      #endif
274
+
275
+    #endif
276
+  #endif // NEWPANEL
277
+
278
+#endif // ULTRA_LCD
279
+
280
+#define U_MIN_PIN          -1
281
+#define V_MIN_PIN          -1
282
+#define W_MIN_PIN          -1
283
+

Loading…
Cancel
Save