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.
This commit is contained in:
xC0000005 2018-03-28 11:07:52 -07:00 committed by Scott Lahteine
parent d1f14202a9
commit 7dc256432f
6 changed files with 57 additions and 5 deletions

View File

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

View File

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

View File

@ -41,6 +41,7 @@
#include "pins_arduino.h"
#include "spi_pins.h"
#include "../../core/macros.h"
#include <spi.h>
// --------------------------------------------------------------------------
// Public Variables
@ -166,7 +167,7 @@ void spiSendBlock(uint8_t token, const uint8_t* buf) {
/** Begin SPI transaction, set clock, bit order, data mode */
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);
}

View File

@ -163,4 +163,51 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
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__

View File

@ -32,6 +32,7 @@
// --------------------------------------------------------------------------
#include <stdint.h>
#include <libmaple/timer.h>
// --------------------------------------------------------------------------
// 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_CHAN 1 // Channel of the timer to use for compare and interrupts
#define CAT(a, ...) a ## __VA_ARGS__
#define TIMER_DEV(num) CAT (&timer, num)
timer_dev* get_timer_dev(int number);
#define TIMER_DEV(num) get_timer_dev(num)
#define STEP_TIMER_DEV TIMER_DEV(STEP_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_ENABLE_ISRs() do { if (thermalManager.in_temp_isr)DISABLE_TEMPERATURE_INTERRUPT(); else ENABLE_TEMPERATURE_INTERRUPT(); ENABLE_STEPPER_DRIVER_INTERRUPT(); } while(0)
// TODO change this

View File

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