1
0
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:
Bart Meijer 2023-08-07 06:12:30 +02:00 committed by GitHub
parent b956001d81
commit 205a679959
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 33 deletions

View File

@ -70,7 +70,7 @@
#include "../../shared/HAL_SPI.h" #include "../../shared/HAL_SPI.h"
#ifndef LCD_SPI_SPEED #ifndef LCD_SPI_SPEED
#define LCD_SPI_SPEED SPI_QUARTER_SPEED #define LCD_SPI_SPEED SPI_HALF_SPEED
#endif #endif
void u8g_SetPIOutput(u8g_t *u8g, uint8_t pin_index) { 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) { 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) { switch (msg) {
case U8G_COM_MSG_STOP: 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); u8g_SetPILevel(u8g, U8G_PI_CS, LOW);
spiBegin(); spiBegin();
lcdSPIConfig = SPISettings(900000, MSBFIRST, SPI_MODE0);
u8g->pin_list[U8G_PI_A0_STATE] = 0; u8g->pin_list[U8G_PI_A0_STATE] = 0;
break; 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; break;
case U8G_COM_MSG_WRITE_BYTE: 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 if (u8g->pin_list[U8G_PI_A0_STATE] == 0) { // command
SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2; 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; break;
case U8G_COM_MSG_WRITE_SEQ: 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 if (u8g->pin_list[U8G_PI_A0_STATE] == 0 ) { // command
SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2; SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2;

View File

@ -41,11 +41,9 @@
#define U8G_COM_HAL_HW_SPI_FN u8g_com_samd51_hw_spi_fn #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 #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd51_st7920_hw_spi_fn
#elif defined(__SAMD21__) #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); 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 #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd21_st7920_hw_spi_fn
#elif defined(__STM32F1__) #elif defined(__STM32F1__)

View File

@ -36,11 +36,15 @@
// RepRapWorld Graphical LCD // RepRapWorld Graphical LCD
#if !HAS_MEDIA && (LCD_PINS_D4 == SD_SCK_PIN) && (LCD_PINS_EN == SD_MOSI_PIN) #if HAS_MEDIA
#ifdef __SAMD21__
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL #define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL
#define U8G_PARAM LCD_PINS_RS #else
#elif HAS_MEDIA && __SAMD21__
#define U8G_CLASS U8GLIB_ST7920_128X64_4X #define U8G_CLASS U8GLIB_ST7920_128X64_4X
#endif
#define U8G_PARAM LCD_PINS_RS
#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 #define U8G_PARAM LCD_PINS_RS
#else #else
#define U8G_CLASS U8GLIB_ST7920_128X64_4X #define U8G_CLASS U8GLIB_ST7920_128X64_4X

View File

@ -16,7 +16,7 @@
platform = atmelsam platform = atmelsam
board = minitronics20 board = minitronics20
build_flags = ${common.build_flags} -std=gnu++17 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 -IMarlin/src/HAL/SAMD21/u8g
build_unflags = -std=gnu++11 build_unflags = -std=gnu++11
build_src_filter = ${common.default_src_filter} +<src/HAL/SAMD21> build_src_filter = ${common.default_src_filter} +<src/HAL/SAMD21>