mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-26 13:25:54 +00:00
⚡️ SAMD21 LCD uses HW SPI with media (#26012)
This commit is contained in:
parent
b956001d81
commit
205a679959
@ -70,7 +70,7 @@
|
||||
#include "../../shared/HAL_SPI.h"
|
||||
|
||||
#ifndef LCD_SPI_SPEED
|
||||
#define LCD_SPI_SPEED SPI_QUARTER_SPEED
|
||||
#define LCD_SPI_SPEED SPI_HALF_SPEED
|
||||
#endif
|
||||
|
||||
void u8g_SetPIOutput(u8g_t *u8g, uint8_t pin_index) {
|
||||
@ -85,7 +85,6 @@ void u8g_SetPILevel(u8g_t *u8g, uint8_t pin_index, uint8_t level) {
|
||||
|
||||
uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
|
||||
static SPISettings lcdSPIConfig;
|
||||
|
||||
switch (msg) {
|
||||
case U8G_COM_MSG_STOP:
|
||||
@ -99,7 +98,6 @@ uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, LOW);
|
||||
|
||||
spiBegin();
|
||||
lcdSPIConfig = SPISettings(900000, MSBFIRST, SPI_MODE0);
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = 0;
|
||||
break;
|
||||
|
||||
@ -117,7 +115,7 @@ uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
SPI.beginTransaction(lcdSPIConfig);
|
||||
spiBeginTransaction(LCD_SPI_SPEED, MSBFIRST, SPI_MODE0);
|
||||
|
||||
if (u8g->pin_list[U8G_PI_A0_STATE] == 0) { // command
|
||||
SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
@ -132,7 +130,7 @@ uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
SPI.beginTransaction(lcdSPIConfig);
|
||||
spiBeginTransaction(LCD_SPI_SPEED, MSBFIRST, SPI_MODE0);
|
||||
|
||||
if (u8g->pin_list[U8G_PI_A0_STATE] == 0 ) { // command
|
||||
SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
|
@ -31,12 +31,12 @@ extern u8g_dev_t u8g_dev_st7565_64128n_HAL_2x_hw_spi;
|
||||
class U8GLIB_64128N_2X_HAL : public U8GLIB {
|
||||
public:
|
||||
U8GLIB_64128N_2X_HAL() : U8GLIB() { }
|
||||
U8GLIB_64128N_2X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); }
|
||||
U8GLIB_64128N_2X_HAL(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(cs, a0, reset); }
|
||||
void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) {
|
||||
U8GLIB_64128N_2X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); }
|
||||
U8GLIB_64128N_2X_HAL(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(cs, a0, reset); }
|
||||
void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) {
|
||||
U8GLIB::init(&u8g_dev_st7565_64128n_HAL_2x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset);
|
||||
}
|
||||
void init(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) {
|
||||
void init(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) {
|
||||
U8GLIB::init(&u8g_dev_st7565_64128n_HAL_2x_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset);
|
||||
}
|
||||
};
|
||||
@ -47,12 +47,12 @@ extern u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_hw_spi;
|
||||
class U8GLIB_ST7920_128X64_4X_HAL : public U8GLIB {
|
||||
public:
|
||||
U8GLIB_ST7920_128X64_4X_HAL() : U8GLIB() { }
|
||||
U8GLIB_ST7920_128X64_4X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, reset); }
|
||||
U8GLIB_ST7920_128X64_4X_HAL(pin_t cs, pin_t reset = U8G_PIN_NONE) { init(cs, reset); }
|
||||
void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) {
|
||||
U8GLIB_ST7920_128X64_4X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, reset); }
|
||||
U8GLIB_ST7920_128X64_4X_HAL(pin_t cs, pin_t reset=U8G_PIN_NONE) { init(cs, reset); }
|
||||
void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) {
|
||||
U8GLIB::init(&u8g_dev_st7920_128x64_HAL_4x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE
|
||||
}
|
||||
void init(pin_t cs, pin_t reset = U8G_PIN_NONE) {
|
||||
void init(pin_t cs, pin_t reset=U8G_PIN_NONE) {
|
||||
U8GLIB::init(&u8g_dev_st7920_128x64_HAL_4x_hw_spi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE
|
||||
}
|
||||
};
|
||||
@ -66,8 +66,8 @@ extern u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi;
|
||||
class U8GLIB_ST7920_128X64_RRD : public U8GLIB {
|
||||
public:
|
||||
U8GLIB_ST7920_128X64_RRD() : U8GLIB() { }
|
||||
U8GLIB_ST7920_128X64_RRD(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, reset); }
|
||||
void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) {
|
||||
U8GLIB_ST7920_128X64_RRD(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, reset); }
|
||||
void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) {
|
||||
U8GLIB::init(&u8g_dev_st7920_128x64_rrd_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE
|
||||
}
|
||||
};
|
||||
@ -99,8 +99,8 @@ extern u8g_dev_t u8g_dev_tft_320x240_upscale_from_128x64;
|
||||
class U8GLIB_TFT_320X240_UPSCALE_FROM_128X64 : public U8GLIB {
|
||||
public:
|
||||
U8GLIB_TFT_320X240_UPSCALE_FROM_128X64() : U8GLIB() { }
|
||||
U8GLIB_TFT_320X240_UPSCALE_FROM_128X64(uint8_t cs, uint8_t rs, uint8_t reset = U8G_PIN_NONE) { init(cs, rs, reset); }
|
||||
void init(uint8_t cs, uint8_t rs, uint8_t reset = U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_tft_320x240_upscale_from_128x64, cs, rs, reset); }
|
||||
U8GLIB_TFT_320X240_UPSCALE_FROM_128X64(uint8_t cs, uint8_t rs, uint8_t reset=U8G_PIN_NONE) { init(cs, rs, reset); }
|
||||
void init(uint8_t cs, uint8_t rs, uint8_t reset=U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_tft_320x240_upscale_from_128x64, cs, rs, reset); }
|
||||
};
|
||||
|
||||
|
||||
@ -109,12 +109,12 @@ extern u8g_dev_t u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, u8g_dev_uc1701_mini1286
|
||||
class U8GLIB_MINI12864_2X_HAL : public U8GLIB {
|
||||
public:
|
||||
U8GLIB_MINI12864_2X_HAL() : U8GLIB() { }
|
||||
U8GLIB_MINI12864_2X_HAL(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); }
|
||||
U8GLIB_MINI12864_2X_HAL(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) { init(cs, a0, reset); }
|
||||
void init(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) {
|
||||
U8GLIB_MINI12864_2X_HAL(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); }
|
||||
U8GLIB_MINI12864_2X_HAL(uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { init(cs, a0, reset); }
|
||||
void init(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) {
|
||||
U8GLIB::init(&u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, sck, mosi, cs, a0, reset);
|
||||
}
|
||||
void init(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) {
|
||||
void init(uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) {
|
||||
U8GLIB::init(&u8g_dev_uc1701_mini12864_HAL_2x_hw_spi, cs, a0, reset);
|
||||
}
|
||||
};
|
||||
@ -125,12 +125,12 @@ extern u8g_dev_t u8g_dev_ssd1309_hw_spi;
|
||||
class U8GLIB_SSD1309_128X64_HAL : public U8GLIB {
|
||||
public:
|
||||
U8GLIB_SSD1309_128X64_HAL() : U8GLIB() { }
|
||||
U8GLIB_SSD1309_128X64_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); }
|
||||
U8GLIB_SSD1309_128X64_HAL(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(cs, a0, reset); }
|
||||
void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) {
|
||||
U8GLIB_SSD1309_128X64_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); }
|
||||
U8GLIB_SSD1309_128X64_HAL(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(cs, a0, reset); }
|
||||
void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) {
|
||||
U8GLIB::init(&u8g_dev_ssd1309_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset);
|
||||
}
|
||||
void init(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) {
|
||||
void init(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) {
|
||||
U8GLIB::init(&u8g_dev_ssd1309_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset);
|
||||
}
|
||||
};
|
||||
|
@ -41,11 +41,9 @@
|
||||
#define U8G_COM_HAL_HW_SPI_FN u8g_com_samd51_hw_spi_fn
|
||||
#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd51_st7920_hw_spi_fn
|
||||
|
||||
|
||||
#elif defined(__SAMD21__)
|
||||
|
||||
uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
|
||||
|
||||
#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd21_st7920_hw_spi_fn
|
||||
|
||||
#elif defined(__STM32F1__)
|
||||
|
@ -36,11 +36,15 @@
|
||||
|
||||
// RepRapWorld Graphical LCD
|
||||
|
||||
#if !HAS_MEDIA && (LCD_PINS_D4 == SD_SCK_PIN) && (LCD_PINS_EN == SD_MOSI_PIN)
|
||||
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL
|
||||
#if HAS_MEDIA
|
||||
#ifdef __SAMD21__
|
||||
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL
|
||||
#else
|
||||
#define U8G_CLASS U8GLIB_ST7920_128X64_4X
|
||||
#endif
|
||||
#define U8G_PARAM LCD_PINS_RS
|
||||
#elif HAS_MEDIA && __SAMD21__
|
||||
#define U8G_CLASS U8GLIB_ST7920_128X64_4X
|
||||
#elif (LCD_PINS_D4 == SD_SCK_PIN) && (LCD_PINS_EN == SD_MOSI_PIN)
|
||||
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL
|
||||
#define U8G_PARAM LCD_PINS_RS
|
||||
#else
|
||||
#define U8G_CLASS U8GLIB_ST7920_128X64_4X
|
||||
@ -61,7 +65,7 @@
|
||||
#else
|
||||
#define U8G_CLASS U8GLIB_ST7920_128X64_RRD // Adjust stripes with PAGE_HEIGHT in ultralcd_st7920_u8glib_rrd.h
|
||||
#endif
|
||||
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_EN, LCD_PINS_RS // AVR version ignores these pin settings
|
||||
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_EN, LCD_PINS_RS // AVR version ignores these pin settings
|
||||
// HAL version uses these pin settings
|
||||
#endif
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
platform = atmelsam
|
||||
board = minitronics20
|
||||
build_flags = ${common.build_flags} -std=gnu++17
|
||||
-DUSBCON -DUSBD_USE_CDC -D__SAMD21__ -DARDUINO_SAMD_MINITRONICS20 -Wno-deprecated-declarations -DU8G_HAL_LINKS -DDEBUG
|
||||
-DUSBCON -DUSBD_USE_CDC -D__SAMD21__ -DARDUINO_SAMD_MINITRONICS20 -Wno-deprecated-declarations -DDEBUG
|
||||
-IMarlin/src/HAL/SAMD21/u8g
|
||||
build_unflags = -std=gnu++11
|
||||
build_src_filter = ${common.default_src_filter} +<src/HAL/SAMD21>
|
||||
|
Loading…
Reference in New Issue
Block a user