Browse Source

Restore STM32F1 series to working order. (#10229)

The `_O2` attribute is no longer needed on the malyanlcd function, and the macros have broken timer numbers - reset this to a function to return the right device. Also fix the bit order cast in SPI.
pull/1/head
xC0000005 7 years ago
committed by Scott Lahteine
parent
commit
7dc256432f
  1. 1
      Marlin/src/HAL/HAL_STM32F1/HAL_Stm32f1.cpp
  2. 2
      Marlin/src/HAL/HAL_STM32F1/HAL_Stm32f1.h
  3. 3
      Marlin/src/HAL/HAL_STM32F1/HAL_spi_Stm32f1.cpp
  4. 47
      Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.cpp
  5. 7
      Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h
  6. 2
      Marlin/src/lcd/malyanlcd.cpp

1
Marlin/src/HAL/HAL_STM32F1/HAL_Stm32f1.cpp

@ -55,6 +55,7 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Public Variables // Public Variables
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
USBSerial SerialUSB;
uint16_t HAL_adc_result; uint16_t HAL_adc_result;

2
Marlin/src/HAL/HAL_STM32F1/HAL_Stm32f1.h

@ -69,6 +69,7 @@
#error "SERIAL_PORT must be from -1 to 3" #error "SERIAL_PORT must be from -1 to 3"
#endif #endif
#if SERIAL_PORT == -1 #if SERIAL_PORT == -1
extern USBSerial SerialUSB;
#define MYSERIAL0 SerialUSB #define MYSERIAL0 SerialUSB
#elif SERIAL_PORT == 0 #elif SERIAL_PORT == 0
#define MYSERIAL0 Serial #define MYSERIAL0 Serial
@ -88,6 +89,7 @@
#endif #endif
#define NUM_SERIAL 2 #define NUM_SERIAL 2
#if SERIAL_PORT_2 == -1 #if SERIAL_PORT_2 == -1
extern USBSerial SerialUSB;
#define MYSERIAL1 SerialUSB #define MYSERIAL1 SerialUSB
#elif SERIAL_PORT_2 == 0 #elif SERIAL_PORT_2 == 0
#define MYSERIAL1 Serial #define MYSERIAL1 Serial

3
Marlin/src/HAL/HAL_STM32F1/HAL_spi_Stm32f1.cpp

@ -41,6 +41,7 @@
#include "pins_arduino.h" #include "pins_arduino.h"
#include "spi_pins.h" #include "spi_pins.h"
#include "../../core/macros.h" #include "../../core/macros.h"
#include <spi.h>
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Public Variables // Public Variables
@ -166,7 +167,7 @@ void spiSendBlock(uint8_t token, const uint8_t* buf) {
/** Begin SPI transaction, set clock, bit order, data mode */ /** Begin SPI transaction, set clock, bit order, data mode */
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) { void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) {
spiConfig = SPISettings(spiClock, bitOrder, dataMode); spiConfig = SPISettings(spiClock, (BitOrder)bitOrder, dataMode);
SPI.beginTransaction(spiConfig); SPI.beginTransaction(spiConfig);
} }

47
Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.cpp

@ -163,4 +163,51 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
return false; return false;
} }
timer_dev* get_timer_dev(int number) {
switch (number) {
#if STM32_HAVE_TIMER(1)
case 1: return &timer1;
#endif
#if STM32_HAVE_TIMER(2)
case 2: return &timer2;
#endif
#if STM32_HAVE_TIMER(3)
case 3: return &timer3;
#endif
#if STM32_HAVE_TIMER(4)
case 4: return &timer4;
#endif
#if STM32_HAVE_TIMER(5)
case 5: return &timer5;
#endif
#if STM32_HAVE_TIMER(6)
case 6: return &timer6;
#endif
#if STM32_HAVE_TIMER(7)
case 7: return &timer7;
#endif
#if STM32_HAVE_TIMER(8)
case 8: return &timer8;
#endif
#if STM32_HAVE_TIMER(9)
case 9: return &timer9;
#endif
#if STM32_HAVE_TIMER(10)
case 10: return &timer10;
#endif
#if STM32_HAVE_TIMER(11)
case 11: return &timer11;
#endif
#if STM32_HAVE_TIMER(12)
case 12: return &timer12;
#endif
#if STM32_HAVE_TIMER(13)
case 13: return &timer14;
#endif
#if STM32_HAVE_TIMER(14)
case 14: return &timer14;
#endif
}
}
#endif // __STM32F1__ #endif // __STM32F1__

7
Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h

@ -32,6 +32,7 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#include <stdint.h> #include <stdint.h>
#include <libmaple/timer.h>
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Defines // Defines
@ -56,8 +57,9 @@ typedef uint16_t hal_timer_t;
#define TEMP_TIMER_NUM 2 // index of timer to use for temperature #define TEMP_TIMER_NUM 2 // index of timer to use for temperature
#define TEMP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts #define TEMP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts
#define CAT(a, ...) a ## __VA_ARGS__ timer_dev* get_timer_dev(int number);
#define TIMER_DEV(num) CAT (&timer, num)
#define TIMER_DEV(num) get_timer_dev(num)
#define STEP_TIMER_DEV TIMER_DEV(STEP_TIMER_NUM) #define STEP_TIMER_DEV TIMER_DEV(STEP_TIMER_NUM)
#define TEMP_TIMER_DEV TIMER_DEV(TEMP_TIMER_NUM) #define TEMP_TIMER_DEV TIMER_DEV(TEMP_TIMER_NUM)
@ -86,7 +88,6 @@ typedef uint16_t hal_timer_t;
#define HAL_timer_get_count(timer_num) timer_get_count(TIMER_DEV(timer_num)) #define HAL_timer_get_count(timer_num) timer_get_count(TIMER_DEV(timer_num))
#define HAL_ENABLE_ISRs() do { if (thermalManager.in_temp_isr)DISABLE_TEMPERATURE_INTERRUPT(); else ENABLE_TEMPERATURE_INTERRUPT(); ENABLE_STEPPER_DRIVER_INTERRUPT(); } while(0) #define HAL_ENABLE_ISRs() do { if (thermalManager.in_temp_isr)DISABLE_TEMPERATURE_INTERRUPT(); else ENABLE_TEMPERATURE_INTERRUPT(); ENABLE_STEPPER_DRIVER_INTERRUPT(); } while(0)
// TODO change this // TODO change this

2
Marlin/src/lcd/malyanlcd.cpp

@ -393,7 +393,7 @@ void update_usb_status(const bool forceUpdate) {
* The optimize attribute fixes a register Compile * The optimize attribute fixes a register Compile
* error for amtel. * error for amtel.
*/ */
void lcd_update() _O2 { void lcd_update() {
static char inbound_buffer[MAX_CURLY_COMMAND]; static char inbound_buffer[MAX_CURLY_COMMAND];
// First report USB status. // First report USB status.

Loading…
Cancel
Save