From 66e16af29d3a92ee902e56996a6951993c04bab6 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Fri, 5 Jul 2019 08:59:37 +0200 Subject: [PATCH] SPI defines cleanup (#14506) --- Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp | 2 +- .../src/HAL/HAL_DUE/u8g_com_HAL_DUE_shared_hw_spi.cpp | 8 -------- .../HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp | 10 +--------- .../u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp | 10 +--------- Marlin/src/HAL/shared/HAL_SPI.h | 8 -------- 5 files changed, 3 insertions(+), 35 deletions(-) diff --git a/Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp b/Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp index c5002345f7..0350847a61 100644 --- a/Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp +++ b/Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp @@ -173,7 +173,7 @@ void spiBegin(void) { // Invert the SPI2X bit clockDiv ^= 0x1; - SPCR = _BV(SPE) | _BV(MSTR) | ((bitOrder == SPI_LSBFIRST) ? _BV(DORD) : 0) | + SPCR = _BV(SPE) | _BV(MSTR) | ((bitOrder == LSBFIRST) ? _BV(DORD) : 0) | (dataMode << CPHA) | ((clockDiv >> 1) << SPR0); SPSR = clockDiv | 0x01; } diff --git a/Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_shared_hw_spi.cpp b/Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_shared_hw_spi.cpp index 1b78e6174e..f90d24dae0 100644 --- a/Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_shared_hw_spi.cpp +++ b/Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_shared_hw_spi.cpp @@ -66,14 +66,6 @@ #include "../../Marlin.h" -#define SPI_FULL_SPEED 0 -#define SPI_HALF_SPEED 1 -#define SPI_QUARTER_SPEED 2 -#define SPI_EIGHTH_SPEED 3 -#define SPI_SIXTEENTH_SPEED 4 -#define SPI_SPEED_5 5 -#define SPI_SPEED_6 6 - void spiBegin(); void spiInit(uint8_t spiRate); void spiSend(uint8_t b); diff --git a/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp b/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp index 1c6b6fabb4..057a137445 100644 --- a/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp @@ -59,16 +59,8 @@ #if HAS_GRAPHICAL_LCD -//#include #include - -#define SPI_FULL_SPEED 0 -#define SPI_HALF_SPEED 1 -#define SPI_QUARTER_SPEED 2 -#define SPI_EIGHTH_SPEED 3 -#define SPI_SIXTEENTH_SPEED 4 -#define SPI_SPEED_5 5 -#define SPI_SPEED_6 6 +#include "../../shared/HAL_SPI.h" void spiBegin(); void spiInit(uint8_t spiRate); diff --git a/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp b/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp index f35c9999c8..ac289c1a20 100644 --- a/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp @@ -59,18 +59,10 @@ #if HAS_GRAPHICAL_LCD -//#include #include +#include "../../shared/HAL_SPI.h" #include "../../shared/Delay.h" -#define SPI_FULL_SPEED 0 -#define SPI_HALF_SPEED 1 -#define SPI_QUARTER_SPEED 2 -#define SPI_EIGHTH_SPEED 3 -#define SPI_SIXTEENTH_SPEED 4 -#define SPI_SPEED_5 5 -#define SPI_SPEED_6 6 - void spiBegin(); void spiInit(uint8_t spiRate); void spiSend(uint8_t b); diff --git a/Marlin/src/HAL/shared/HAL_SPI.h b/Marlin/src/HAL/shared/HAL_SPI.h index 91c8442afb..16a58f673a 100644 --- a/Marlin/src/HAL/shared/HAL_SPI.h +++ b/Marlin/src/HAL/shared/HAL_SPI.h @@ -53,14 +53,6 @@ #define SPI_SPEED_5 5 // Set SCK rate to 1/32 of max rate #define SPI_SPEED_6 6 // Set SCK rate to 1/64 of max rate -#define SPI_LSBFIRST 0 -#define SPI_MSBFIRST 1 - -#define SPI_DATAMODE_0 0x00 -#define SPI_DATAMODE_1 0x04 -#define SPI_DATAMODE_2 0x08 -#define SPI_DATAMODE_3 0x0C - // Standard SPI functions /** Initialize SPI bus */ void spiBegin(void);