SPI and pins cleanup
This commit is contained in:
@ -64,12 +64,11 @@
|
||||
|
||||
#include "../../../MarlinCore.h"
|
||||
|
||||
void spiBegin();
|
||||
void spiInit(uint8_t spiRate);
|
||||
void spiSend(uint8_t b);
|
||||
void spiSend(const uint8_t* buf, size_t n);
|
||||
#ifndef LCD_SPI_SPEED
|
||||
#define LCD_SPI_SPEED SPI_QUARTER_SPEED
|
||||
#endif
|
||||
|
||||
#include "../../shared/Marduino.h"
|
||||
#include "../../shared/HAL_SPI.h"
|
||||
#include "../fastio.h"
|
||||
|
||||
void u8g_SetPIOutput_DUE_hw_spi(u8g_t *u8g, uint8_t pin_index) {
|
||||
@ -100,11 +99,7 @@ uint8_t u8g_com_HAL_DUE_shared_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va
|
||||
|
||||
spiBegin();
|
||||
|
||||
#ifndef SPI_SPEED
|
||||
#define SPI_SPEED SPI_FULL_SPEED // use same SPI speed as SD card
|
||||
#endif
|
||||
spiInit(2);
|
||||
|
||||
spiInit(LCD_SPI_SPEED);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
|
@ -59,9 +59,6 @@
|
||||
|
||||
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
|
||||
|
||||
#undef SPI_SPEED
|
||||
#define SPI_SPEED 2 // About 2 MHz
|
||||
|
||||
#include "u8g_com_HAL_DUE_sw_spi_shared.h"
|
||||
|
||||
#include "../../shared/Marduino.h"
|
||||
|
@ -37,7 +37,7 @@
|
||||
#define TOUCH_SCK_PIN SCK_PIN
|
||||
#endif
|
||||
#ifndef TOUCH_CS_PIN
|
||||
#define TOUCH_CS_PIN CS_PIN
|
||||
#define TOUCH_CS_PIN SS_PIN
|
||||
#endif
|
||||
#ifndef TOUCH_INT_PIN
|
||||
#define TOUCH_INT_PIN -1
|
||||
|
@ -62,9 +62,11 @@
|
||||
#include <U8glib.h>
|
||||
#include <SoftwareSPI.h>
|
||||
#include "../../shared/Delay.h"
|
||||
#include "../../shared/HAL_SPI.h"
|
||||
|
||||
#undef SPI_SPEED
|
||||
#define SPI_SPEED 3 // About 1 MHz
|
||||
#ifndef LCD_SPI_SPEED
|
||||
#define LCD_SPI_SPEED SPI_EIGHTH_SPEED // About 1 MHz
|
||||
#endif
|
||||
|
||||
static pin_t SCK_pin_ST7920_HAL, MOSI_pin_ST7920_HAL_HAL;
|
||||
static uint8_t SPI_speed = 0;
|
||||
@ -92,7 +94,7 @@ uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t ar
|
||||
u8g_SetPIOutput(u8g, U8G_PI_MOSI);
|
||||
u8g_Delay(5);
|
||||
|
||||
SPI_speed = swSpiInit(SPI_SPEED, SCK_pin_ST7920_HAL, MOSI_pin_ST7920_HAL_HAL);
|
||||
SPI_speed = swSpiInit(LCD_SPI_SPEED, SCK_pin_ST7920_HAL, MOSI_pin_ST7920_HAL_HAL);
|
||||
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 0);
|
||||
u8g_SetPILevel(u8g, U8G_PI_SCK, 0);
|
||||
|
@ -60,9 +60,11 @@
|
||||
#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
|
||||
|
||||
#include <SoftwareSPI.h>
|
||||
#include "../../shared/HAL_SPI.h"
|
||||
|
||||
#undef SPI_SPEED
|
||||
#define SPI_SPEED 2 // About 2 MHz
|
||||
#ifndef LCD_SPI_SPEED
|
||||
#define LCD_SPI_SPEED SPI_QUARTER_SPEED // About 2 MHz
|
||||
#endif
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <algorithm>
|
||||
@ -145,7 +147,7 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
|
||||
u8g_SetPIOutput(u8g, U8G_PI_CS);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_A0);
|
||||
if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPIOutput(u8g, U8G_PI_RESET);
|
||||
SPI_speed = swSpiInit(SPI_SPEED, u8g->pin_list[U8G_PI_SCK], u8g->pin_list[U8G_PI_MOSI]);
|
||||
SPI_speed = swSpiInit(LCD_SPI_SPEED, u8g->pin_list[U8G_PI_SCK], u8g->pin_list[U8G_PI_MOSI]);
|
||||
u8g_SetPILevel(u8g, U8G_PI_SCK, 0);
|
||||
u8g_SetPILevel(u8g, U8G_PI_MOSI, 0);
|
||||
break;
|
||||
|
@ -23,12 +23,14 @@
|
||||
#if BOTH(HAS_MARLINUI_U8GLIB, FORCE_SOFT_SPI)
|
||||
|
||||
#include <U8glib.h>
|
||||
#include "../../shared/HAL_SPI.h"
|
||||
|
||||
#undef SPI_SPEED
|
||||
#define SPI_SPEED 0 // Fastest
|
||||
//#define SPI_SPEED 2 // Slower
|
||||
#ifndef LCD_SPI_SPEED
|
||||
#define LCD_SPI_SPEED SPI_FULL_SPEED // Fastest
|
||||
//#define LCD_SPI_SPEED SPI_QUARTER_SPEED // Slower
|
||||
#endif
|
||||
|
||||
static uint8_t SPI_speed = SPI_SPEED;
|
||||
static uint8_t SPI_speed = LCD_SPI_SPEED;
|
||||
|
||||
static inline uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t miso_pin=-1) {
|
||||
LOOP_L_N(i, 8) {
|
||||
@ -104,7 +106,7 @@ static uint8_t swSpiInit(const uint8_t spi_speed) {
|
||||
uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
switch (msg) {
|
||||
case U8G_COM_MSG_INIT:
|
||||
SPI_speed = swSpiInit(SPI_SPEED);
|
||||
SPI_speed = swSpiInit(LCD_SPI_SPEED);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_STOP:
|
||||
|
@ -37,7 +37,7 @@
|
||||
#define TOUCH_SCK_PIN SCK_PIN
|
||||
#endif
|
||||
#ifndef TOUCH_CS_PIN
|
||||
#define TOUCH_CS_PIN CS_PIN
|
||||
#define TOUCH_CS_PIN SS_PIN
|
||||
#endif
|
||||
#ifndef TOUCH_INT_PIN
|
||||
#define TOUCH_INT_PIN -1
|
||||
|
Reference in New Issue
Block a user