Browse Source

Update HAL/STM32 platform to 8.0 (#18496)

Jason Smith 4 years ago
parent
commit
4fc1aba848
No account linked to committer's email address

+ 1
- 0
.github/workflows/test-builds.yml View File

70
         - mks_robin_stm32
70
         - mks_robin_stm32
71
         - ARMED
71
         - ARMED
72
         - FYSETC_S6
72
         - FYSETC_S6
73
+        - STM32F070CB_malyan
73
         - STM32F070RB_malyan
74
         - STM32F070RB_malyan
74
         - malyan_M300
75
         - malyan_M300
75
         - mks_robin_lite
76
         - mks_robin_lite

+ 1
- 1
Marlin/Makefile View File

694
   LIB_CXXSRC += usb_api.cpp
694
   LIB_CXXSRC += usb_api.cpp
695
 
695
 
696
 else ifeq ($(HARDWARE_VARIANT), archim)
696
 else ifeq ($(HARDWARE_VARIANT), archim)
697
-  CDEFS      += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSB_VID=0x27b1 -DUSB_PID=0x0001 -DUSBCON '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT="Archim"'
697
+  CDEFS      += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSB_VID=0x27b1 -DUSB_PID=0x0001 -DUSBCON '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT_STRING="Archim"'
698
   LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp UARTClass.cpp  USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp PluggableUSB.cpp USBCore.cpp
698
   LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp UARTClass.cpp  USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp PluggableUSB.cpp USBCore.cpp
699
   LIB_SRC    += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c
699
   LIB_SRC    += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c
700
 
700
 

+ 0
- 396
Marlin/src/HAL/STM32/SoftwareSerial.cpp View File

1
-/*
2
- * SoftwareSerial.cpp (formerly NewSoftSerial.cpp)
3
- *
4
- * Multi-instance software serial library for Arduino/Wiring
5
- * -- Interrupt-driven receive and other improvements by ladyada
6
- *    <https://ladyada.net>
7
- * -- Tuning, circular buffer, derivation from class Print/Stream,
8
- *    multi-instance support, porting to 8MHz processors,
9
- *    various optimizations, PROGMEM delay tables, inverse logic and
10
- *    direct port writing by Mikal Hart <http://www.arduiniana.org>
11
- * -- Pin change interrupt macros by Paul Stoffregen <https://www.pjrc.com>
12
- * -- 20MHz processor support by Garrett Mace <http://www.macetech.com>
13
- * -- ATmega1280/2560 support by Brett Hagman <https://www.roguerobotics.com>
14
- * -- STM32 support by Armin van der Togt
15
- *
16
- * This library is free software; you can redistribute it and/or
17
- * modify it under the terms of the GNU Lesser General Public
18
- * License as published by the Free Software Foundation; either
19
- * version 2.1 of the License, or (at your option) any later version.
20
- *
21
- * This library is distributed in the hope that it will be useful,
22
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24
- * Lesser General Public License for more details.
25
- *
26
- * You should have received a copy of the GNU Lesser General Public
27
- * License along with this library; if not, write to the Free Software
28
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
29
- *
30
- * The latest version of this library can always be found at
31
- * http://arduiniana.org.
32
- */
33
-
34
-//
35
-// Includes
36
-//
37
-#if defined(PLATFORMIO) && defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
38
-
39
-#include "../../inc/MarlinConfig.h"
40
-
41
-#include "SoftwareSerial.h"
42
-
43
-#define OVERSAMPLE 3 // in RX, Timer will generate interruption OVERSAMPLE time during a bit. Thus OVERSAMPLE ticks in a bit. (interrupt not synchonized with edge).
44
-
45
-// defined in bit-periods
46
-#define HALFDUPLEX_SWITCH_DELAY 5
47
-// It's best to define TIMER_SERIAL in variant.h. If not defined, we choose one here
48
-// The order is based on (lack of) features and compare channels, we choose the simplest available
49
-// because we only need an update interrupt
50
-#if !defined(TIMER_SERIAL)
51
-#if  defined(TIM18_BASE)
52
-#define TIMER_SERIAL TIM18
53
-#elif defined(TIM7_BASE)
54
-#define TIMER_SERIAL TIM7
55
-#elif defined(TIM6_BASE)
56
-#define TIMER_SERIAL TIM6
57
-#elif defined(TIM22_BASE)
58
-#define TIMER_SERIAL TIM22
59
-#elif defined(TIM21_BASE)
60
-#define TIMER_SERIAL TIM21
61
-#elif defined(TIM17_BASE)
62
-#define TIMER_SERIAL TIM17
63
-#elif defined(TIM16_BASE)
64
-#define TIMER_SERIAL TIM16
65
-#elif defined(TIM15_BASE)
66
-#define TIMER_SERIAL TIM15
67
-#elif defined(TIM14_BASE)
68
-#define TIMER_SERIAL TIM14
69
-#elif defined(TIM13_BASE)
70
-#define TIMER_SERIAL TIM13
71
-#elif defined(TIM11_BASE)
72
-#define TIMER_SERIAL TIM11
73
-#elif defined(TIM10_BASE)
74
-#define TIMER_SERIAL TIM10
75
-#elif defined(TIM12_BASE)
76
-#define TIMER_SERIAL TIM12
77
-#elif defined(TIM19_BASE)
78
-#define TIMER_SERIAL TIM19
79
-#elif defined(TIM9_BASE)
80
-#define TIMER_SERIAL TIM9
81
-#elif defined(TIM5_BASE)
82
-#define TIMER_SERIAL TIM5
83
-#elif defined(TIM4_BASE)
84
-#define TIMER_SERIAL TIM4
85
-#elif defined(TIM3_BASE)
86
-#define TIMER_SERIAL TIM3
87
-#elif defined(TIM2_BASE)
88
-#define TIMER_SERIAL TIM2
89
-#elif defined(TIM20_BASE)
90
-#define TIMER_SERIAL TIM20
91
-#elif defined(TIM8_BASE)
92
-#define TIMER_SERIAL TIM8
93
-#elif defined(TIM1_BASE)
94
-#define TIMER_SERIAL TIM1
95
-#else
96
-#error No suitable timer found for SoftwareSerial, define TIMER_SERIAL in variant.h
97
-#endif
98
-#endif
99
-//
100
-// Statics
101
-//
102
-HardwareTimer SoftwareSerial::timer(TIMER_SERIAL);
103
-const IRQn_Type SoftwareSerial::timer_interrupt_number = static_cast<IRQn_Type>(getTimerUpIrq(TIMER_SERIAL));
104
-uint32_t SoftwareSerial::timer_interrupt_priority = NVIC_EncodePriority(NVIC_GetPriorityGrouping(), TIM_IRQ_PRIO, TIM_IRQ_SUBPRIO);
105
-SoftwareSerial *SoftwareSerial::active_listener = nullptr;
106
-SoftwareSerial *volatile SoftwareSerial::active_out = nullptr;
107
-SoftwareSerial *volatile SoftwareSerial::active_in = nullptr;
108
-int32_t SoftwareSerial::tx_tick_cnt = 0; // OVERSAMPLE ticks needed for a bit
109
-int32_t volatile SoftwareSerial::rx_tick_cnt = 0;  // OVERSAMPLE ticks needed for a bit
110
-uint32_t SoftwareSerial::tx_buffer = 0;
111
-int32_t SoftwareSerial::tx_bit_cnt = 0;
112
-uint32_t SoftwareSerial::rx_buffer = 0;
113
-int32_t SoftwareSerial::rx_bit_cnt = -1; // rx_bit_cnt = -1 :  waiting for start bit
114
-uint32_t SoftwareSerial::cur_speed = 0;
115
-
116
-void SoftwareSerial::setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority) {
117
-  timer_interrupt_priority = NVIC_EncodePriority(NVIC_GetPriorityGrouping(), preemptPriority, subPriority);
118
-}
119
-
120
-//
121
-// Private methods
122
-//
123
-
124
-void SoftwareSerial::setSpeed(uint32_t speed) {
125
-  if (speed != cur_speed) {
126
-    timer.pause();
127
-    if (speed != 0) {
128
-      // Disable the timer
129
-      uint32_t clock_rate, cmp_value;
130
-      // Get timer clock
131
-      clock_rate = timer.getTimerClkFreq();
132
-      int pre = 1;
133
-      // Calculate prescale an compare value
134
-      do {
135
-        cmp_value = clock_rate / (speed * OVERSAMPLE);
136
-        if (cmp_value >= UINT16_MAX) {
137
-          clock_rate /= 2;
138
-          pre *= 2;
139
-        }
140
-      } while (cmp_value >= UINT16_MAX);
141
-      timer.setPrescaleFactor(pre);
142
-      timer.setOverflow(cmp_value);
143
-      timer.setCount(0);
144
-      timer.attachInterrupt(&handleInterrupt);
145
-      timer.resume();
146
-      NVIC_SetPriority(timer_interrupt_number, timer_interrupt_priority);
147
-    }
148
-    else
149
-      timer.detachInterrupt();
150
-    cur_speed = speed;
151
-  }
152
-}
153
-
154
-// This function sets the current object as the "listening"
155
-// one and returns true if it replaces another
156
-bool SoftwareSerial::listen() {
157
-  if (active_listener != this) {
158
-    // wait for any transmit to complete as we may change speed
159
-    while (active_out);
160
-    active_listener->stopListening();
161
-    rx_tick_cnt = 1; // 1 : next interrupt will decrease rx_tick_cnt to 0 which means RX pin level will be considered.
162
-    rx_bit_cnt = -1; // rx_bit_cnt = -1 :  waiting for start bit
163
-    setSpeed(_speed);
164
-    active_listener = this;
165
-    if (!_half_duplex) active_in = this;
166
-    return true;
167
-  }
168
-  return false;
169
-}
170
-
171
-// Stop listening. Returns true if we were actually listening.
172
-bool SoftwareSerial::stopListening() {
173
-  if (active_listener == this) {
174
-    // wait for any output to complete
175
-    while (active_out);
176
-    if (_half_duplex) setRXTX(false);
177
-    active_listener = nullptr;
178
-    active_in = nullptr;
179
-    // turn off ints
180
-    setSpeed(0);
181
-    return true;
182
-  }
183
-  return false;
184
-}
185
-
186
-inline void SoftwareSerial::setTX() {
187
-  if (_inverse_logic)
188
-    LL_GPIO_ResetOutputPin(_transmitPinPort, _transmitPinNumber);
189
-  else
190
-    LL_GPIO_SetOutputPin(_transmitPinPort, _transmitPinNumber);
191
-  pinMode(_transmitPin, OUTPUT);
192
-}
193
-
194
-inline void SoftwareSerial::setRX() {
195
-  pinMode(_receivePin, _inverse_logic ? INPUT_PULLDOWN : INPUT_PULLUP); // pullup for normal logic!
196
-}
197
-
198
-inline void SoftwareSerial::setRXTX(bool input) {
199
-  if (_half_duplex) {
200
-    if (input) {
201
-      if (active_in != this) {
202
-        setRX();
203
-        rx_bit_cnt = -1; // rx_bit_cnt = -1 :  waiting for start bit
204
-        rx_tick_cnt = 2; // 2 : next interrupt will be discarded. 2 interrupts required to consider RX pin level
205
-        active_in = this;
206
-      }
207
-    }
208
-    else {
209
-      if (active_in == this) {
210
-        setTX();
211
-        active_in = nullptr;
212
-      }
213
-    }
214
-  }
215
-}
216
-
217
-inline void SoftwareSerial::send() {
218
-  if (--tx_tick_cnt <= 0) { // if tx_tick_cnt > 0 interrupt is discarded. Only when tx_tick_cnt reaches 0 is TX pin set.
219
-    if (tx_bit_cnt++ < 10) { // tx_bit_cnt < 10 transmission is not finished (10 = 1 start +8 bits + 1 stop)
220
-      // Send data (including start and stop bits)
221
-      if (tx_buffer & 1)
222
-        LL_GPIO_SetOutputPin(_transmitPinPort, _transmitPinNumber);
223
-      else
224
-        LL_GPIO_ResetOutputPin(_transmitPinPort, _transmitPinNumber);
225
-      tx_buffer >>= 1;
226
-      tx_tick_cnt = OVERSAMPLE; // Wait OVERSAMPLE ticks to send next bit
227
-    }
228
-    else { // Transmission finished
229
-      tx_tick_cnt = 1;
230
-      if (_output_pending) {
231
-        active_out = nullptr;
232
-
233
-        // In half-duplex mode wait HALFDUPLEX_SWITCH_DELAY bit-periods after the byte has
234
-        // been transmitted before allowing the switch to RX mode
235
-      }
236
-      else if (tx_bit_cnt > 10 + OVERSAMPLE * HALFDUPLEX_SWITCH_DELAY) {
237
-        if (_half_duplex && active_listener == this) setRXTX(true);
238
-        active_out = nullptr;
239
-      }
240
-    }
241
-  }
242
-}
243
-
244
-//
245
-// The receive routine called by the interrupt handler
246
-//
247
-inline void SoftwareSerial::recv() {
248
-  if (--rx_tick_cnt <= 0) { // if rx_tick_cnt > 0 interrupt is discarded. Only when rx_tick_cnt reaches 0 is RX pin considered
249
-    bool inbit = LL_GPIO_IsInputPinSet(_receivePinPort, _receivePinNumber) ^ _inverse_logic;
250
-    if (rx_bit_cnt == -1) {  // rx_bit_cnt = -1 :  waiting for start bit
251
-      if (!inbit) {
252
-        // got start bit
253
-        rx_bit_cnt = 0; // rx_bit_cnt == 0 : start bit received
254
-        rx_tick_cnt = OVERSAMPLE + 1; // Wait 1 bit (OVERSAMPLE ticks) + 1 tick in order to sample RX pin in the middle of the edge (and not too close to the edge)
255
-        rx_buffer = 0;
256
-      }
257
-      else
258
-        rx_tick_cnt = 1; // Waiting for start bit, but wrong level. Wait for next Interrupt to check RX pin level
259
-    }
260
-    else if (rx_bit_cnt >= 8) { // rx_bit_cnt >= 8 : waiting for stop bit
261
-      if (inbit) {
262
-        // Stop-bit read complete. Add to buffer.
263
-        uint8_t next = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF;
264
-        if (next != _receive_buffer_head) {
265
-          // save new data in buffer: tail points to byte destination
266
-          _receive_buffer[_receive_buffer_tail] = rx_buffer; // save new byte
267
-          _receive_buffer_tail = next;
268
-        }
269
-        else // rx_bit_cnt = x  with x = [0..7] correspond to new bit x received
270
-          _buffer_overflow = true;
271
-      }
272
-      // Full trame received. Restart waiting for start bit at next interrupt
273
-      rx_tick_cnt = 1;
274
-      rx_bit_cnt = -1;
275
-    }
276
-    else {
277
-      // data bits
278
-      rx_buffer >>= 1;
279
-      if (inbit) rx_buffer |= 0x80;
280
-      rx_bit_cnt++; // Prepare for next bit
281
-      rx_tick_cnt = OVERSAMPLE; // Wait OVERSAMPLE ticks before sampling next bit
282
-    }
283
-  }
284
-}
285
-
286
-//
287
-// Interrupt handling
288
-//
289
-
290
-/* static */
291
-inline void SoftwareSerial::handleInterrupt(HardwareTimer*) {
292
-  if (active_in)   active_in->recv();
293
-  if (active_out) active_out->send();
294
-}
295
-
296
-//
297
-// Constructor
298
-//
299
-SoftwareSerial::SoftwareSerial(uint16_t receivePin, uint16_t transmitPin, bool inverse_logic /* = false */) :
300
-  _receivePin(receivePin),
301
-  _transmitPin(transmitPin),
302
-  _receivePinPort(digitalPinToPort(receivePin)),
303
-  _receivePinNumber(STM_LL_GPIO_PIN(digitalPinToPinName(receivePin))),
304
-  _transmitPinPort(digitalPinToPort(transmitPin)),
305
-  _transmitPinNumber(STM_LL_GPIO_PIN(digitalPinToPinName(transmitPin))),
306
-  _speed(0),
307
-  _buffer_overflow(false),
308
-  _inverse_logic(inverse_logic),
309
-  _half_duplex(receivePin == transmitPin),
310
-  _output_pending(0),
311
-  _receive_buffer_tail(0),
312
-  _receive_buffer_head(0)
313
-{
314
-  if ((receivePin < NUM_DIGITAL_PINS) || (transmitPin < NUM_DIGITAL_PINS)) {
315
-    /* Enable GPIO clock for tx and rx pin*/
316
-    set_GPIO_Port_Clock(STM_PORT(digitalPinToPinName(transmitPin)));
317
-    set_GPIO_Port_Clock(STM_PORT(digitalPinToPinName(receivePin)));
318
-  }
319
-  else
320
-    _Error_Handler("ERROR: invalid pin number\n", -1);
321
-}
322
-
323
-//
324
-// Destructor
325
-//
326
-SoftwareSerial::~SoftwareSerial() { end(); }
327
-
328
-//
329
-// Public methods
330
-//
331
-
332
-void SoftwareSerial::begin(long speed) {
333
-  #ifdef FORCE_BAUD_RATE
334
-    speed = FORCE_BAUD_RATE;
335
-  #endif
336
-  _speed = speed;
337
-  if (!_half_duplex) {
338
-    setTX();
339
-    setRX();
340
-    listen();
341
-  }
342
-  else
343
-    setTX();
344
-}
345
-
346
-void SoftwareSerial::end() {
347
-  stopListening();
348
-}
349
-
350
-// Read data from buffer
351
-int SoftwareSerial::read() {
352
-  // Empty buffer?
353
-  if (_receive_buffer_head == _receive_buffer_tail) return -1;
354
-
355
-  // Read from "head"
356
-  uint8_t d = _receive_buffer[_receive_buffer_head]; // grab next byte
357
-  _receive_buffer_head = (_receive_buffer_head + 1) % _SS_MAX_RX_BUFF;
358
-  return d;
359
-}
360
-
361
-int SoftwareSerial::available() {
362
-  return (_receive_buffer_tail + _SS_MAX_RX_BUFF - _receive_buffer_head) % _SS_MAX_RX_BUFF;
363
-}
364
-
365
-size_t SoftwareSerial::write(uint8_t b) {
366
-  // wait for previous transmit to complete
367
-  _output_pending = 1;
368
-  while (active_out) { /* nada */ }
369
-  // add start and stop bits.
370
-  tx_buffer = b << 1 | 0x200;
371
-  if (_inverse_logic) tx_buffer = ~tx_buffer;
372
-  tx_bit_cnt = 0;
373
-  tx_tick_cnt = OVERSAMPLE;
374
-  setSpeed(_speed);
375
-  if (_half_duplex) setRXTX(false);
376
-  _output_pending = 0;
377
-  // make us active
378
-  active_out = this;
379
-  return 1;
380
-}
381
-
382
-void SoftwareSerial::flush() {
383
-  noInterrupts();
384
-  _receive_buffer_head = _receive_buffer_tail = 0;
385
-  interrupts();
386
-}
387
-
388
-int SoftwareSerial::peek() {
389
-  // Empty buffer?
390
-  if (_receive_buffer_head == _receive_buffer_tail) return -1;
391
-
392
-  // Read from "head"
393
-  return _receive_buffer[_receive_buffer_head];
394
-}
395
-
396
-#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC

+ 0
- 114
Marlin/src/HAL/STM32/SoftwareSerial.h View File

1
-/**
2
- * SoftwareSerial.h (formerly NewSoftSerial.h)
3
- *
4
- * Multi-instance software serial library for Arduino/Wiring
5
- * -- Interrupt-driven receive and other improvements by ladyada
6
- *    (https://ladyada.net)
7
- * -- Tuning, circular buffer, derivation from class Print/Stream,
8
- *    multi-instance support, porting to 8MHz processors,
9
- *    various optimizations, PROGMEM delay tables, inverse logic and
10
- *    direct port writing by Mikal Hart (http://www.arduiniana.org)
11
- * -- Pin change interrupt macros by Paul Stoffregen (https://www.pjrc.com)
12
- * -- 20MHz processor support by Garrett Mace (http://www.macetech.com)
13
- * -- ATmega1280/2560 support by Brett Hagman (https://www.roguerobotics.com/)
14
- *
15
- * This library is free software; you can redistribute it and/or
16
- * modify it under the terms of the GNU Lesser General Public
17
- * License as published by the Free Software Foundation; either
18
- * version 2.1 of the License, or (at your option) any later version.
19
- *
20
- * This library is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23
- * Lesser General Public License for more details.
24
- *
25
- * You should have received a copy of the GNU Lesser General Public
26
- * License along with this library; if not, write to the Free Software
27
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28
- *
29
- * The latest version of this library can always be found at
30
- * http://arduiniana.org.
31
- */
32
-#pragma once
33
-
34
-#include <Arduino.h>
35
-
36
-/******************************************************************************
37
- * Definitions
38
- ******************************************************************************/
39
-
40
-#define _SS_MAX_RX_BUFF 64 // RX buffer size
41
-
42
-class SoftwareSerial : public Stream {
43
-  private:
44
-    // per object data
45
-    uint16_t _receivePin;
46
-    uint16_t _transmitPin;
47
-    GPIO_TypeDef *_receivePinPort;
48
-    uint32_t _receivePinNumber;
49
-    GPIO_TypeDef *_transmitPinPort;
50
-    uint32_t _transmitPinNumber;
51
-    uint32_t _speed;
52
-
53
-    uint16_t _buffer_overflow: 1;
54
-    uint16_t _inverse_logic: 1;
55
-    uint16_t _half_duplex: 1;
56
-    uint16_t _output_pending: 1;
57
-
58
-    unsigned char _receive_buffer[_SS_MAX_RX_BUFF];
59
-    volatile uint8_t _receive_buffer_tail;
60
-    volatile uint8_t _receive_buffer_head;
61
-
62
-    uint32_t delta_start = 0;
63
-
64
-    // static data
65
-    static HardwareTimer timer;
66
-    static const IRQn_Type timer_interrupt_number;
67
-    static uint32_t timer_interrupt_priority;
68
-    static SoftwareSerial *active_listener;
69
-    static SoftwareSerial *volatile active_out;
70
-    static SoftwareSerial *volatile active_in;
71
-    static int32_t tx_tick_cnt;
72
-    static volatile int32_t rx_tick_cnt;
73
-    static uint32_t tx_buffer;
74
-    static int32_t tx_bit_cnt;
75
-    static uint32_t rx_buffer;
76
-    static int32_t rx_bit_cnt;
77
-    static uint32_t cur_speed;
78
-
79
-    // private methods
80
-    void send();
81
-    void recv();
82
-    void setTX();
83
-    void setRX();
84
-    void setSpeed(uint32_t speed);
85
-    void setRXTX(bool input);
86
-    static void handleInterrupt(HardwareTimer *timer);
87
-
88
-  public:
89
-    // public methods
90
-
91
-    SoftwareSerial(uint16_t receivePin, uint16_t transmitPin, bool inverse_logic=false);
92
-    virtual ~SoftwareSerial();
93
-    void begin(long speed);
94
-    bool listen();
95
-    void end();
96
-    bool isListening() { return active_listener == this; }
97
-    bool stopListening();
98
-    bool overflow() {
99
-      bool ret = _buffer_overflow;
100
-      if (ret) _buffer_overflow = false;
101
-      return ret;
102
-    }
103
-    int peek();
104
-
105
-    virtual size_t write(uint8_t byte);
106
-    virtual int read();
107
-    virtual int available();
108
-    virtual void flush();
109
-    operator bool() { return true; }
110
-
111
-    static void setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority);
112
-
113
-    using Print::write;
114
-};

+ 99
- 31
Marlin/src/HAL/STM32/timers.cpp View File

110
 // ------------------------
110
 // ------------------------
111
 
111
 
112
 HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { NULL };
112
 HardwareTimer *timer_instance[NUM_HARDWARE_TIMERS] = { NULL };
113
-bool timer_enabled[NUM_HARDWARE_TIMERS] = { false };
114
 
113
 
115
 // ------------------------
114
 // ------------------------
116
 // Public functions
115
 // Public functions
135
          * which changes the prescaler when an IRQ frequency change is needed
134
          * which changes the prescaler when an IRQ frequency change is needed
136
          * (for example when steppers are turned on)
135
          * (for example when steppers are turned on)
137
          */
136
          */
137
+
138
         timer_instance[timer_num]->setPrescaleFactor(STEPPER_TIMER_PRESCALE); //the -1 is done internally
138
         timer_instance[timer_num]->setPrescaleFactor(STEPPER_TIMER_PRESCALE); //the -1 is done internally
139
         timer_instance[timer_num]->setOverflow(_MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE) /* /frequency */), TICK_FORMAT);
139
         timer_instance[timer_num]->setOverflow(_MIN(hal_timer_t(HAL_TIMER_TYPE_MAX), (HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE) /* /frequency */), TICK_FORMAT);
140
         break;
140
         break;
145
         break;
145
         break;
146
     }
146
     }
147
 
147
 
148
+    // Disable preload. Leaving it default-enabled can cause the timer to stop if it happens
149
+    // to exit the ISR after the start time for the next interrupt has already passed.
150
+    timer_instance[timer_num]->setPreloadEnable(false);
151
+
148
     HAL_timer_enable_interrupt(timer_num);
152
     HAL_timer_enable_interrupt(timer_num);
149
 
153
 
150
-    /*
151
-     * Initializes (and unfortunately starts) the timer.
152
-     * This is needed to set correct IRQ priority at the moment but causes
153
-     * no harm since every call to HAL_timer_start() is actually followed by
154
-     * a call to HAL_timer_enable_interrupt() which means that there isn't
155
-     * a case in which you want the timer to run without a callback.
156
-     */
154
+    // Start the timer.
157
     timer_instance[timer_num]->resume(); // First call to resume() MUST follow the attachInterrupt()
155
     timer_instance[timer_num]->resume(); // First call to resume() MUST follow the attachInterrupt()
158
 
156
 
159
     // This is fixed in Arduino_Core_STM32 1.8.
157
     // This is fixed in Arduino_Core_STM32 1.8.
161
     // timer_instance[timer_num]->setInterruptPriority
159
     // timer_instance[timer_num]->setInterruptPriority
162
     switch (timer_num) {
160
     switch (timer_num) {
163
       case STEP_TIMER_NUM:
161
       case STEP_TIMER_NUM:
164
-        HAL_NVIC_SetPriority(STEP_TIMER_IRQ_NAME, STEP_TIMER_IRQ_PRIO, 0);
162
+        timer_instance[timer_num]->setInterruptPriority(STEP_TIMER_IRQ_PRIO, 0);
165
         break;
163
         break;
166
       case TEMP_TIMER_NUM:
164
       case TEMP_TIMER_NUM:
167
-        HAL_NVIC_SetPriority(TEMP_TIMER_IRQ_NAME, TEMP_TIMER_IRQ_PRIO, 0);
165
+        timer_instance[timer_num]->setInterruptPriority(TEMP_TIMER_IRQ_PRIO, 0);
168
         break;
166
         break;
169
     }
167
     }
170
   }
168
   }
171
 }
169
 }
172
 
170
 
173
 void HAL_timer_enable_interrupt(const uint8_t timer_num) {
171
 void HAL_timer_enable_interrupt(const uint8_t timer_num) {
174
-  if (HAL_timer_initialized(timer_num) && !timer_enabled[timer_num]) {
175
-    timer_enabled[timer_num] = true;
172
+  if (HAL_timer_initialized(timer_num) && !timer_instance[timer_num]->hasInterrupt()) {
176
     switch (timer_num) {
173
     switch (timer_num) {
177
       case STEP_TIMER_NUM:
174
       case STEP_TIMER_NUM:
178
-      timer_instance[timer_num]->attachInterrupt(Step_Handler);
179
-      break;
180
-    case TEMP_TIMER_NUM:
181
-      timer_instance[timer_num]->attachInterrupt(Temp_Handler);
182
-      break;
175
+        timer_instance[timer_num]->attachInterrupt(Step_Handler);
176
+        break;
177
+      case TEMP_TIMER_NUM:
178
+        timer_instance[timer_num]->attachInterrupt(Temp_Handler);
179
+        break;
183
     }
180
     }
184
   }
181
   }
185
 }
182
 }
186
 
183
 
187
 void HAL_timer_disable_interrupt(const uint8_t timer_num) {
184
 void HAL_timer_disable_interrupt(const uint8_t timer_num) {
188
-  if (HAL_timer_interrupt_enabled(timer_num)) {
189
-    timer_instance[timer_num]->detachInterrupt();
190
-    timer_enabled[timer_num] = false;
191
-  }
185
+  if (HAL_timer_initialized(timer_num)) timer_instance[timer_num]->detachInterrupt();
192
 }
186
 }
193
 
187
 
194
 bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
188
 bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
195
-  return HAL_timer_initialized(timer_num) && timer_enabled[timer_num];
196
-}
197
-
198
-// Only for use within the HAL
199
-TIM_TypeDef * HAL_timer_device(const uint8_t timer_num) {
200
-  switch (timer_num) {
201
-    case STEP_TIMER_NUM: return STEP_TIMER_DEV;
202
-    case TEMP_TIMER_NUM: return TEMP_TIMER_DEV;
203
-  }
204
-  return nullptr;
189
+  return HAL_timer_initialized(timer_num) && timer_instance[timer_num]->hasInterrupt();
205
 }
190
 }
206
 
191
 
207
 void SetTimerInterruptPriorities() {
192
 void SetTimerInterruptPriorities() {
209
   TERN_(HAS_SERVOS, libServo::setInterruptPriority(SERVO_TIMER_IRQ_PRIO, 0));
194
   TERN_(HAS_SERVOS, libServo::setInterruptPriority(SERVO_TIMER_IRQ_PRIO, 0));
210
 }
195
 }
211
 
196
 
197
+// This is a terrible hack to replicate the behavior used in the framework's SoftwareSerial.cpp
198
+// to choose a serial timer. It will select TIM7 on most boards used by Marlin, but this is more
199
+// resiliant to new MCUs which may not have a TIM7. Best practice is to explicitly specify
200
+// TIMER_SERIAL to avoid relying on framework selections which may not be predictable.
201
+#if !defined(TIMER_SERIAL)
202
+  #if defined (TIM18_BASE)
203
+    #define TIMER_SERIAL TIM18
204
+  #elif defined (TIM7_BASE)
205
+    #define TIMER_SERIAL TIM7
206
+  #elif defined (TIM6_BASE)
207
+    #define TIMER_SERIAL TIM6
208
+  #elif defined (TIM22_BASE)
209
+    #define TIMER_SERIAL TIM22
210
+  #elif defined (TIM21_BASE)
211
+    #define TIMER_SERIAL TIM21
212
+  #elif defined (TIM17_BASE)
213
+    #define TIMER_SERIAL TIM17
214
+  #elif defined (TIM16_BASE)
215
+    #define TIMER_SERIAL TIM16
216
+  #elif defined (TIM15_BASE)
217
+    #define TIMER_SERIAL TIM15
218
+  #elif defined (TIM14_BASE)
219
+    #define TIMER_SERIAL TIM14
220
+  #elif defined (TIM13_BASE)
221
+    #define TIMER_SERIAL TIM13
222
+  #elif defined (TIM11_BASE)
223
+    #define TIMER_SERIAL TIM11
224
+  #elif defined (TIM10_BASE)
225
+    #define TIMER_SERIAL TIM10
226
+  #elif defined (TIM12_BASE)
227
+    #define TIMER_SERIAL TIM12
228
+  #elif defined (TIM19_BASE)
229
+    #define TIMER_SERIAL TIM19
230
+  #elif defined (TIM9_BASE)
231
+    #define TIMER_SERIAL TIM9
232
+  #elif defined (TIM5_BASE)
233
+    #define TIMER_SERIAL TIM5
234
+  #elif defined (TIM4_BASE)
235
+    #define TIMER_SERIAL TIM4
236
+  #elif defined (TIM3_BASE)
237
+    #define TIMER_SERIAL TIM3
238
+  #elif defined (TIM2_BASE)
239
+    #define TIMER_SERIAL TIM2
240
+  #elif defined (TIM20_BASE)
241
+    #define TIMER_SERIAL TIM20
242
+  #elif defined (TIM8_BASE)
243
+    #define TIMER_SERIAL TIM8
244
+  #elif defined (TIM1_BASE)
245
+    #define TIMER_SERIAL TIM1
246
+  #else
247
+    #error No suitable timer found for SoftwareSerial, define TIMER_SERIAL in variant.h
248
+  #endif
249
+#endif
250
+
251
+// Place all timers used into an array, then recursively check for duplicates during compilation.
252
+// This does not currently account for timers used for PWM, such as for fans.
253
+// Timers are actually pointers. Convert to integers to simplify constexpr logic.
254
+static constexpr uintptr_t timers_in_use[] = {
255
+  uintptr_t(TEMP_TIMER_DEV),  // Override in pins file
256
+  uintptr_t(STEP_TIMER_DEV),  // Override in pins file
257
+  #if HAS_TMC_SW_SERIAL
258
+    uintptr_t(TIMER_SERIAL),  // Set in variant.h, or as a define in platformio.h if not present in variant.h
259
+  #endif
260
+  #if ENABLED(SPEAKER)
261
+    uintptr_t(TIMER_TONE),    // Set in variant.h, or as a define in platformio.h if not present in variant.h
262
+  #endif
263
+  #if HAS_SERVOS
264
+    uintptr_t(TIMER_SERVO),   // Set in variant.h, or as a define in platformio.h if not present in variant.h
265
+  #endif
266
+  };
267
+
268
+static constexpr bool verify_no_duplicate_timers() {
269
+  LOOP_L_N(i, COUNT(timers_in_use))
270
+    LOOP_S_L_N(j, i + 1, COUNT(timers_in_use))
271
+      if (timers_in_use[i] == timers_in_use[j]) return false;
272
+  return true;
273
+}
274
+
275
+// If this assertion fails at compile time, review the timers_in_use array. If default_envs is
276
+// defined properly in platformio.ini, VS Code can evaluate the array when hovering over it,
277
+// making it easy to identify the conflicting timers.
278
+static_assert(verify_no_duplicate_timers(), "One or more timer conflict detected");
279
+
212
 #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
280
 #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC

+ 15
- 7
Marlin/src/HAL/STM32/timers.h View File

30
 
30
 
31
 #define FORCE_INLINE __attribute__((always_inline)) inline
31
 #define FORCE_INLINE __attribute__((always_inline)) inline
32
 
32
 
33
+// STM32 timers may be 16 or 32 bit. Limiting HAL_TIMER_TYPE_MAX to 16 bits
34
+// avoids issues with STM32F0 MCUs, which seem to pause timers if UINT32_MAX
35
+// is written to the register. STM32F4 timers do not manifest this issue,
36
+// even when writing to 16 bit timers.
37
+//
38
+// The range of the timer can be queried at runtime using IS_TIM_32B_COUNTER_INSTANCE.
39
+// This is a more expensive check than a simple compile-time constant, so its
40
+// implementation is deferred until the desire for a 32-bit range outweighs the cost
41
+// of adding a run-time check and HAL_TIMER_TYPE_MAX is refactored to allow unique
42
+// values for each timer.
33
 #define hal_timer_t uint32_t
43
 #define hal_timer_t uint32_t
34
-#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF // Timers can be 16 or 32 bit
44
+#define HAL_TIMER_TYPE_MAX UINT16_MAX
35
 
45
 
36
 #ifndef STEP_TIMER_NUM
46
 #ifndef STEP_TIMER_NUM
37
   #define STEP_TIMER_NUM        0  // Timer Index for Stepper
47
   #define STEP_TIMER_NUM        0  // Timer Index for Stepper
61
 #define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
71
 #define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
62
 #define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
72
 #define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
63
 
73
 
64
-extern void Step_Handler(HardwareTimer *htim);
65
-extern void Temp_Handler(HardwareTimer *htim);
74
+extern void Step_Handler();
75
+extern void Temp_Handler();
66
 
76
 
67
 #ifndef HAL_STEP_TIMER_ISR
77
 #ifndef HAL_STEP_TIMER_ISR
68
-  #define HAL_STEP_TIMER_ISR() void Step_Handler(HardwareTimer *htim)
78
+  #define HAL_STEP_TIMER_ISR() void Step_Handler()
69
 #endif
79
 #endif
70
 #ifndef HAL_TEMP_TIMER_ISR
80
 #ifndef HAL_TEMP_TIMER_ISR
71
-  #define HAL_TEMP_TIMER_ISR() void Temp_Handler(HardwareTimer *htim)
81
+  #define HAL_TEMP_TIMER_ISR() void Temp_Handler()
72
 #endif
82
 #endif
73
 
83
 
74
 // ------------------------
84
 // ------------------------
90
 // Exposed here to allow all timer priority information to reside in timers.cpp
100
 // Exposed here to allow all timer priority information to reside in timers.cpp
91
 void SetTimerInterruptPriorities();
101
 void SetTimerInterruptPriorities();
92
 
102
 
93
-//TIM_TypeDef* HAL_timer_device(const uint8_t timer_num); no need to be public for now. not public = not used externally
94
-
95
 // FORCE_INLINE because these are used in performance-critical situations
103
 // FORCE_INLINE because these are used in performance-critical situations
96
 FORCE_INLINE bool HAL_timer_initialized(const uint8_t timer_num) {
104
 FORCE_INLINE bool HAL_timer_initialized(const uint8_t timer_num) {
97
   return timer_instance[timer_num] != NULL;
105
   return timer_instance[timer_num] != NULL;

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

282
 
282
 
283
 #define BOARD_STM32F103RE             4000  // STM32F103RE Libmaple-based STM32F1 controller
283
 #define BOARD_STM32F103RE             4000  // STM32F103RE Libmaple-based STM32F1 controller
284
 #define BOARD_MALYAN_M200             4001  // STM32C8T6  Libmaple-based STM32F1 controller
284
 #define BOARD_MALYAN_M200             4001  // STM32C8T6  Libmaple-based STM32F1 controller
285
-#define BOARD_MALYAN_M200_V2          4002  // STM32F070RB  Libmaple-based STM32F0 controller
285
+#define BOARD_MALYAN_M200_V2          4002  // STM32F070CB  STM32F0 controller
286
 #define BOARD_STM3R_MINI              4003  // STM32F103RE  Libmaple-based STM32F1 controller
286
 #define BOARD_STM3R_MINI              4003  // STM32F103RE  Libmaple-based STM32F1 controller
287
 #define BOARD_GTM32_PRO_VB            4004  // STM32F103VET6 controller
287
 #define BOARD_GTM32_PRO_VB            4004  // STM32F103VET6 controller
288
 #define BOARD_MORPHEUS                4005  // STM32F103C8 / STM32F103CB  Libmaple-based STM32F1 controller
288
 #define BOARD_MORPHEUS                4005  // STM32F103C8 / STM32F103CB  Libmaple-based STM32F1 controller

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

480
 // STM32 ARM Cortex-M0
480
 // STM32 ARM Cortex-M0
481
 //
481
 //
482
 #elif MB(MALYAN_M200_V2)
482
 #elif MB(MALYAN_M200_V2)
483
-  #include "stm32f0/pins_MALYAN_M200_V2.h"      // STM32F0                                env:STM32F070RB_malyan
483
+  #include "stm32f0/pins_MALYAN_M200_V2.h"      // STM32F0                                env:STM32F070RB_malyan env:STM32F070CB_malyan
484
 #elif MB(MALYAN_M300)
484
 #elif MB(MALYAN_M300)
485
   #include "stm32f0/pins_MALYAN_M300.h"         // STM32F070                              env:malyan_M300
485
   #include "stm32f0/pins_MALYAN_M300.h"         // STM32F070                              env:malyan_M300
486
 
486
 

+ 1
- 1
Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h View File

21
  */
21
  */
22
 #pragma once
22
 #pragma once
23
 
23
 
24
-#ifndef TARGET_STM32F4
24
+#ifndef STM32F4
25
   #error "Oops! Select an STM32F4 board in 'Tools > Board.'"
25
   #error "Oops! Select an STM32F4 board in 'Tools > Board.'"
26
 #elif HOTENDS > 1 || E_STEPPERS > 1
26
 #elif HOTENDS > 1 || E_STEPPERS > 1
27
   #error "BIGTREE BTT002 V1.0 supports up to 1 hotends / E-steppers."
27
   #error "BIGTREE BTT002 V1.0 supports up to 1 hotends / E-steppers."

+ 1
- 1
Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h View File

21
  */
21
  */
22
 #pragma once
22
 #pragma once
23
 
23
 
24
-#ifndef TARGET_STM32F4
24
+#ifndef STM32F4
25
   #error "Oops! Select an STM32F4 board in 'Tools > Board.'"
25
   #error "Oops! Select an STM32F4 board in 'Tools > Board.'"
26
 #elif HOTENDS > 8 || E_STEPPERS > 8
26
 #elif HOTENDS > 8 || E_STEPPERS > 8
27
   #error "BIGTREE GTR V1.0 supports up to 8 hotends / E-steppers."
27
   #error "BIGTREE GTR V1.0 supports up to 8 hotends / E-steppers."

+ 1
- 1
Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h View File

21
  */
21
  */
22
 #pragma once
22
 #pragma once
23
 
23
 
24
-#ifndef TARGET_STM32F4
24
+#ifndef STM32F4
25
   #error "Oops! Select an STM32F4 board in 'Tools > Board.'"
25
   #error "Oops! Select an STM32F4 board in 'Tools > Board.'"
26
 #endif
26
 #endif
27
 
27
 

+ 6
- 5
Marlin/src/pins/stm32f4/pins_RUMBA32_common.h View File

42
 // Configure Timers
42
 // Configure Timers
43
 // TIM6 is used for TONE
43
 // TIM6 is used for TONE
44
 // TIM7 is used for SERVO
44
 // TIM7 is used for SERVO
45
-// TIMER_SERIAL defaults to TIM7 so we'll override it here
46
-//
47
-#define STEP_TIMER                            10
48
-#define TEMP_TIMER                            14
49
-#define TIMER_SERIAL                        TIM9
45
+// TIMER_SERIAL defaults to TIM7 and must be overridden in the platformio.h file if SERVO will also be used.
46
+//              This will be difficult to solve from the Arduino IDE, without modifying the RUMBA32 variant
47
+//              included with the STM32 framework.
48
+
49
+#define STEP_TIMER 10
50
+#define TEMP_TIMER 14
50
 #define HAL_TIMER_RATE                     F_CPU
51
 #define HAL_TIMER_RATE                     F_CPU
51
 
52
 
52
 //
53
 //

+ 2
- 1
buildroot/share/PlatformIO/boards/LERDGE.json View File

15
       ]
15
       ]
16
     ],
16
     ],
17
     "mcu": "stm32f407zgt6",
17
     "mcu": "stm32f407zgt6",
18
-    "variant": "LERDGE"
18
+    "variant": "LERDGE",
19
+    "ldscript": "LERDGE.ld"
19
   },
20
   },
20
   "debug": {
21
   "debug": {
21
     "jlink_device": "STM32F407ZG",
22
     "jlink_device": "STM32F407ZG",

+ 1
- 1
buildroot/share/PlatformIO/boards/malyanM200v2.json View File

4
     "extra_flags": "-DSTM32F070xB",
4
     "extra_flags": "-DSTM32F070xB",
5
     "f_cpu": "48000000L",
5
     "f_cpu": "48000000L",
6
     "mcu": "stm32f070rbt6",
6
     "mcu": "stm32f070rbt6",
7
-    "variant": "MALYANM200_F070CB",
7
+    "variant": "MALYANMx00_F070CB",
8
     "vec_tab_addr": "0x8002000"
8
     "vec_tab_addr": "0x8002000"
9
   },
9
   },
10
   "debug": {
10
   "debug": {

buildroot/share/PlatformIO/boards/fysetc_s6.json → buildroot/share/PlatformIO/boards/marlin_fysetc_s6.json View File

4
     "extra_flags": "-DSTM32F446xx",
4
     "extra_flags": "-DSTM32F446xx",
5
     "f_cpu": "180000000L",
5
     "f_cpu": "180000000L",
6
     "mcu": "stm32f446ret6",
6
     "mcu": "stm32f446ret6",
7
-    "variant": "FYSETC_S6"
7
+    "variant": "MARLIN_FYSETC_S6"
8
   },
8
   },
9
   "connectivity": [
9
   "connectivity": [
10
     "can"
10
     "can"
32
   },
32
   },
33
   "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f446.html",
33
   "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f446.html",
34
   "vendor": "FYSETC"
34
   "vendor": "FYSETC"
35
-}
35
+}

+ 0
- 33
buildroot/share/PlatformIO/scripts/fysetc_STM32S6.py View File

1
-from os.path import join
2
-Import("env")
3
-
4
-import os,shutil
5
-from SCons.Script import DefaultEnvironment
6
-from platformio import util
7
-
8
-env = DefaultEnvironment()
9
-platform = env.PioPlatform()
10
-board = env.BoardConfig()
11
-
12
-FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32")
13
-#FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32@3.10500.190327")
14
-CMSIS_DIR = os.path.join(FRAMEWORK_DIR, "CMSIS", "CMSIS")
15
-assert os.path.isdir(FRAMEWORK_DIR)
16
-assert os.path.isdir(CMSIS_DIR)
17
-assert os.path.isdir("buildroot/share/PlatformIO/variants")
18
-
19
-mcu_type = board.get("build.mcu")[:-2]
20
-variant = board.get("build.variant")
21
-series = mcu_type[:7].upper() + "xx"
22
-variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant)
23
-
24
-source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant)
25
-assert os.path.isdir(source_dir)
26
-
27
-if not os.path.isdir(variant_dir):
28
-    os.mkdir(variant_dir)
29
-
30
-for file_name in os.listdir(source_dir):
31
-    full_file_name = os.path.join(source_dir, file_name)
32
-    if os.path.isfile(full_file_name):
33
-        shutil.copy(full_file_name, variant_dir)

buildroot/share/PlatformIO/variants/FYSETC_S6/PeripheralPins.c → buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/PeripheralPins.c View File


buildroot/share/PlatformIO/variants/FYSETC_S6/PinNamesVar.h → buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/PinNamesVar.h View File


buildroot/share/PlatformIO/variants/FYSETC_S6/ldscript.ld → buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld View File


buildroot/share/PlatformIO/variants/FYSETC_S6/variant.cpp → buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/variant.cpp View File


buildroot/share/PlatformIO/variants/FYSETC_S6/variant.h → buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/variant.h View File

115
 #define NUM_ANALOG_FIRST        80
115
 #define NUM_ANALOG_FIRST        80
116
 
116
 
117
 // PWM resolution
117
 // PWM resolution
118
-#define PWM_RESOLUTION          12
118
+// #define PWM_RESOLUTION          12
119
 #define PWM_FREQUENCY           20000 // >= 20 Khz => inaudible noise for fans
119
 #define PWM_FREQUENCY           20000 // >= 20 Khz => inaudible noise for fans
120
 #define PWM_MAX_DUTY_CYCLE      255
120
 #define PWM_MAX_DUTY_CYCLE      255
121
 
121
 

+ 15
- 0
buildroot/tests/STM32F070CB_malyan-tests View File

1
+#!/usr/bin/env bash
2
+#
3
+# Build tests for STM32F070CB Malyan M200 v2
4
+#
5
+
6
+# exit on first failure
7
+set -e
8
+
9
+restore_configs
10
+opt_set MOTHERBOARD BOARD_MALYAN_M200_V2
11
+opt_set SERIAL_PORT -1
12
+exec_test $1 $2 "Malyan M200 v2 Default Config"
13
+
14
+# cleanup
15
+restore_configs

+ 32
- 36
platformio.ini View File

661
 # HAL/STM32 Base Environment values
661
 # HAL/STM32 Base Environment values
662
 #
662
 #
663
 [common_stm32]
663
 [common_stm32]
664
-platform      = ststm32@~6.1.0
665
-platform_packages = framework-arduinoststm32@>=4.10700,<4.10800
666
-lib_ignore    = SoftwareSerial
664
+platform      = ststm32@~8.0
667
 build_flags   = ${common.build_flags}
665
 build_flags   = ${common.build_flags}
668
-  -IMarlin/src/HAL/STM32 -std=gnu++14
666
+  -std=gnu++14
669
   -DUSBCON -DUSBD_USE_CDC
667
   -DUSBCON -DUSBD_USE_CDC
670
-  -DUSBD_VID=0x0483
671
   -DTIM_IRQ_PRIO=13
668
   -DTIM_IRQ_PRIO=13
672
 build_unflags = -std=gnu++11
669
 build_unflags = -std=gnu++11
673
 src_filter    = ${common.default_src_filter} +<src/HAL/STM32>
670
 src_filter    = ${common.default_src_filter} +<src/HAL/STM32>
676
 # HAL/STM32F1 Common Environment values
673
 # HAL/STM32F1 Common Environment values
677
 #
674
 #
678
 [common_stm32f1]
675
 [common_stm32f1]
679
-platform      = ${common_stm32.platform}
676
+platform      = ststm32@~6.1
680
 build_flags   = !python Marlin/src/HAL/STM32F1/build_flags.py
677
 build_flags   = !python Marlin/src/HAL/STM32F1/build_flags.py
681
   ${common.build_flags} -std=gnu++14 -DHAVE_SW_SERIAL
678
   ${common.build_flags} -std=gnu++14 -DHAVE_SW_SERIAL
682
 build_unflags = -std=gnu11 -std=gnu++11
679
 build_unflags = -std=gnu11 -std=gnu++11
828
 extends       = common_stm32
825
 extends       = common_stm32
829
 board         = armed_v1
826
 board         = armed_v1
830
 build_flags   = ${common_stm32.build_flags}
827
 build_flags   = ${common_stm32.build_flags}
831
-  '-DUSB_PRODUCT="ARMED_V1"'
832
   -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing
828
   -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing
833
 
829
 
834
 #
830
 #
1008
 platform    = ${common_stm32.platform}
1004
 platform    = ${common_stm32.platform}
1009
 extends     = common_stm32
1005
 extends     = common_stm32
1010
 board       = malyanM200v2
1006
 board       = malyanM200v2
1011
-build_flags = ${common_stm32.build_flags} -DSTM32F0xx -DUSB_PRODUCT=\"STM32F070RB\" -DHAL_PCD_MODULE_ENABLED
1012
-  -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing -std=gnu11 -std=gnu++11
1007
+build_flags = ${common_stm32.build_flags} -DHAL_PCD_MODULE_ENABLED
1008
+  -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing
1013
   -DCUSTOM_STARTUP_FILE
1009
   -DCUSTOM_STARTUP_FILE
1014
-lib_ignore  = SoftwareSerial
1010
+
1011
+#
1012
+# Malyan M200 v2 (STM32F070CB)
1013
+#
1014
+[env:STM32F070CB_malyan]
1015
+platform    = ${common_stm32.platform}
1016
+extends     = common_stm32
1017
+board       = malyanm200_f070cb
1018
+build_flags = ${common_stm32.build_flags}
1019
+  -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB -DHAL_UART_MODULE_ENABLED -DCUSTOM_STARTUP_FILE
1015
 
1020
 
1016
 #
1021
 #
1017
 # Malyan M300 (STM32F070CB)
1022
 # Malyan M300 (STM32F070CB)
1018
 #
1023
 #
1019
 [env:malyan_M300]
1024
 [env:malyan_M300]
1020
-platform    = ststm32@>=6.1.0,<6.2.0
1025
+platform    = ${common_stm32.platform}
1026
+extends     = common_stm32
1021
 board       = malyanm300_f070cb
1027
 board       = malyanm300_f070cb
1022
-build_flags = ${common.build_flags}
1023
-  -DUSBCON -DUSBD_VID=0x0483 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"MALYAN_M300\""
1024
-  -DHAL_PCD_MODULE_ENABLED -DUSBD_USE_CDC -DDISABLE_GENERIC_SERIALUSB -DHAL_UART_MODULE_ENABLED
1028
+build_flags = ${common_stm32.build_flags}
1029
+  -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB -DHAL_UART_MODULE_ENABLED
1025
 src_filter  = ${common.default_src_filter} +<src/HAL/STM32>
1030
 src_filter  = ${common.default_src_filter} +<src/HAL/STM32>
1026
 
1031
 
1027
 #
1032
 #
1074
 extends           = common_stm32
1079
 extends           = common_stm32
1075
 board             = STEVAL_STM32F401VE
1080
 board             = STEVAL_STM32F401VE
1076
 build_flags       = ${common_stm32.build_flags}
1081
 build_flags       = ${common_stm32.build_flags}
1077
-  -DTARGET_STM32F4 -DARDUINO_STEVAL -DSTM32F401xE
1078
-  -DUSB_PRODUCT=\"STEVAL_F401VE\"
1082
+  -DARDUINO_STEVAL -DSTM32F401xE
1079
   -DDISABLE_GENERIC_SERIALUSB -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS
1083
   -DDISABLE_GENERIC_SERIALUSB -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS
1080
 extra_scripts     = ${common.extra_scripts}
1084
 extra_scripts     = ${common.extra_scripts}
1081
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1085
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1082
   buildroot/share/PlatformIO/scripts/STEVAL__F401XX.py
1086
   buildroot/share/PlatformIO/scripts/STEVAL__F401XX.py
1083
-lib_ignore        = SoftwareSerial
1084
 
1087
 
1085
 #
1088
 #
1086
 # FLYF407ZG
1089
 # FLYF407ZG
1090
 extends           = common_stm32
1093
 extends           = common_stm32
1091
 board             = FLYF407ZG
1094
 board             = FLYF407ZG
1092
 build_flags       = ${common_stm32.build_flags}
1095
 build_flags       = ${common_stm32.build_flags}
1093
-  -DSTM32F4 -DUSB_PRODUCT=\"STM32F407ZG\"
1094
-  -DTARGET_STM32F4 -DVECT_TAB_OFFSET=0x8000
1096
+  -DVECT_TAB_OFFSET=0x8000
1095
 extra_scripts     = ${common.extra_scripts}
1097
 extra_scripts     = ${common.extra_scripts}
1096
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1098
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1097
 
1099
 
1101
 [env:FYSETC_S6]
1103
 [env:FYSETC_S6]
1102
 platform          = ${common_stm32.platform}
1104
 platform          = ${common_stm32.platform}
1103
 extends           = common_stm32
1105
 extends           = common_stm32
1104
-platform_packages = ${common_stm32.platform_packages}
1105
-   tool-stm32duino
1106
-board             = fysetc_s6
1106
+platform_packages = tool-stm32duino
1107
+board             = marlin_fysetc_s6
1107
 build_flags       = ${common_stm32.build_flags}
1108
 build_flags       = ${common_stm32.build_flags}
1108
-  -DTARGET_STM32F4 -DVECT_TAB_OFFSET=0x10000
1109
-  -DHAL_PCD_MODULE_ENABLED '-DUSB_PRODUCT="FYSETC_S6"'
1109
+  -DVECT_TAB_OFFSET=0x10000
1110
+  -DHAL_PCD_MODULE_ENABLED
1110
 extra_scripts     = ${common.extra_scripts}
1111
 extra_scripts     = ${common.extra_scripts}
1111
-  pre:buildroot/share/PlatformIO/scripts/fysetc_STM32S6.py
1112
+  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1112
 debug_tool        = stlink
1113
 debug_tool        = stlink
1113
 upload_protocol   = dfu
1114
 upload_protocol   = dfu
1114
 upload_command    = dfu-util -a 0 -s 0x08010000:leave -D "$SOURCE"
1115
 upload_command    = dfu-util -a 0 -s 0x08010000:leave -D "$SOURCE"
1123
 extends           = common_stm32
1124
 extends           = common_stm32
1124
 board             = blackSTM32F407VET6
1125
 board             = blackSTM32F407VET6
1125
 build_flags       = ${common_stm32.build_flags}
1126
 build_flags       = ${common_stm32.build_flags}
1126
-  -DTARGET_STM32F4 -DARDUINO_BLACK_F407VE
1127
-  -DUSB_PRODUCT=\"BLACK_F407VE\"
1127
+  -DARDUINO_BLACK_F407VE
1128
   -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS
1128
   -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS
1129
 extra_scripts     = ${common.extra_scripts}
1129
 extra_scripts     = ${common.extra_scripts}
1130
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1130
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1131
-lib_ignore        = SoftwareSerial
1132
 
1131
 
1133
 #
1132
 #
1134
 # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4)
1133
 # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4)
1138
 extends           = common_stm32
1137
 extends           = common_stm32
1139
 board             = BigTree_SKR_Pro
1138
 board             = BigTree_SKR_Pro
1140
 build_flags       = ${common_stm32.build_flags}
1139
 build_flags       = ${common_stm32.build_flags}
1141
-  -DUSB_PRODUCT=\"STM32F407ZG\"
1142
-  -DTARGET_STM32F4 -DSTM32F407_5ZX -DVECT_TAB_OFFSET=0x8000
1140
+  -DSTM32F407_5ZX -DVECT_TAB_OFFSET=0x8000
1143
 extra_scripts     = ${common.extra_scripts}
1141
 extra_scripts     = ${common.extra_scripts}
1144
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1142
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1145
 #upload_protocol   = stlink
1143
 #upload_protocol   = stlink
1151
 # Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4)
1149
 # Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4)
1152
 #
1150
 #
1153
 [env:BIGTREE_GTR_V1_0]
1151
 [env:BIGTREE_GTR_V1_0]
1154
-platform          = ststm32@>=5.7.0,<6.2.0
1152
+platform          = ${common_stm32.platform}
1155
 extends           = common_stm32
1153
 extends           = common_stm32
1156
 board             = BigTree_GTR_v1
1154
 board             = BigTree_GTR_v1
1157
 extra_scripts     = ${common.extra_scripts}
1155
 extra_scripts     = ${common.extra_scripts}
1158
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1156
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1159
 build_flags       = ${common_stm32.build_flags}
1157
 build_flags       = ${common_stm32.build_flags}
1160
-  -DUSB_PRODUCT=\"STM32F407IG\"
1161
-  -DTARGET_STM32F4 -DSTM32F407IX -DVECT_TAB_OFFSET=0x8000
1158
+  -DSTM32F407IX -DVECT_TAB_OFFSET=0x8000
1162
 
1159
 
1163
 #
1160
 #
1164
 # BigTreeTech BTT002 V1.0 (STM32F407VGT6 ARM Cortex-M4)
1161
 # BigTreeTech BTT002 V1.0 (STM32F407VGT6 ARM Cortex-M4)
1168
 extends           = common_stm32
1165
 extends           = common_stm32
1169
 board             = BigTree_Btt002
1166
 board             = BigTree_Btt002
1170
 build_flags       = ${common_stm32.build_flags}
1167
 build_flags       = ${common_stm32.build_flags}
1171
-  -DUSB_PRODUCT=\"STM32F407VG\"
1172
-  -DTARGET_STM32F4 -DSTM32F407_5VX -DVECT_TAB_OFFSET=0x8000
1168
+  -DSTM32F407_5VX -DVECT_TAB_OFFSET=0x8000
1173
   -DHAVE_HWSERIAL2
1169
   -DHAVE_HWSERIAL2
1174
   -DHAVE_HWSERIAL3
1170
   -DHAVE_HWSERIAL3
1175
   -DPIN_SERIAL2_RX=PD_6
1171
   -DPIN_SERIAL2_RX=PD_6
1226
 extends       = common_stm32
1222
 extends       = common_stm32
1227
 build_flags   = ${common_stm32.build_flags}
1223
 build_flags   = ${common_stm32.build_flags}
1228
   -Os
1224
   -Os
1229
-  "-DUSB_PRODUCT=\"RUMBA32\""
1230
   -DHAL_PCD_MODULE_ENABLED
1225
   -DHAL_PCD_MODULE_ENABLED
1231
   -DDISABLE_GENERIC_SERIALUSB
1226
   -DDISABLE_GENERIC_SERIALUSB
1232
   -DHAL_UART_MODULE_ENABLED
1227
   -DHAL_UART_MODULE_ENABLED
1228
+  -DTIMER_SERIAL=TIM9
1233
 board         = rumba32_f446ve
1229
 board         = rumba32_f446ve
1234
 upload_protocol = dfu
1230
 upload_protocol = dfu
1235
 monitor_speed = 500000
1231
 monitor_speed = 500000

Loading…
Cancel
Save