SAMD51 LCD support (#15113)

This commit is contained in:
Giuliano Zaro 2019-09-02 12:45:02 +02:00 committed by Scott Lahteine
parent 23bb40d0ea
commit 12c595c61f
5 changed files with 56 additions and 45 deletions

View File

@ -146,3 +146,11 @@ FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
#pragma GCC diagnostic ignored "-Wunused-function"
int freeMemory(void);
#pragma GCC diagnostic pop
#ifdef __cplusplus
extern "C" {
#endif
char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s);
#ifdef __cplusplus
}
#endif

View File

@ -60,6 +60,11 @@
#define U8G_COM_HAL_HW_SPI_FN u8g_com_arduino_hw_spi_fn
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_arduino_st7920_spi_fn
#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_arduino_st7920_hw_spi_fn
#elif defined(__SAMD51__)
#define U8G_COM_HAL_SW_SPI_FN u8g_com_arduino_std_sw_spi_fn
#define U8G_COM_HAL_HW_SPI_FN u8g_com_samd51_hw_spi_fn
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_arduino_st7920_spi_fn
#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd51_st7920_hw_spi_fn
#else
#define U8G_COM_HAL_SW_SPI_FN u8g_com_arduino_std_sw_spi_fn
#define U8G_COM_HAL_HW_SPI_FN u8g_com_arduino_hw_spi_fn

View File

@ -202,7 +202,7 @@ u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_sw_spi = { u8g_dev_st7920_128x64_HAL_4x_f
U8G_PB_DEV(u8g_dev_st7920_128x64_HAL_hw_spi, LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_HAL_fn, U8G_COM_ST7920_HAL_HW_SPI);
u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_hw_spi = { u8g_dev_st7920_128x64_HAL_4x_fn, &u8g_dev_st7920_128x64_HAL_4x_pb, U8G_COM_ST7920_HAL_HW_SPI };
#if defined(U8G_HAL_LINKS) || defined(__SAM3X8E__)
#if !defined(__AVR__) || defined(U8G_HAL_LINKS)
// Also use this device for HAL version of rrd class. This results in the same device being used
// for the ST7920 for HAL systems no matter what is selected in ultralcd_impl_DOGM.h.
u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = { u8g_dev_st7920_128x64_HAL_4x_fn, &u8g_dev_st7920_128x64_HAL_4x_pb, U8G_COM_ST7920_HAL_SW_SPI };

View File

@ -23,9 +23,11 @@
// NOTE - the HAL version of the rrd device uses a generic ST7920 device. See the
// file u8g_dev_st7920_128x64_HAL.cpp for the HAL version.
#if defined(__AVR__) && !defined(U8G_HAL_LINKS)
#include "../../inc/MarlinConfig.h"
#if ENABLED(U8GLIB_ST7920) && !defined(U8G_HAL_LINKS) && !defined(__SAM3X8E__)
#if ENABLED(U8GLIB_ST7920)
#include "ultralcd_st7920_u8glib_rrd_AVR.h"
@ -149,4 +151,5 @@ u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g
void ST7920_write_byte(const uint8_t val) { ST7920_WRITE_BYTE(val); }
#endif
#endif // U8GLIB_ST7920 && !U8G_HAL_LINKS && !__SAM3X8E__
#endif // U8GLIB_ST7920
#endif // __AVR__ && !U8G_HAL_LINKS

View File

@ -25,9 +25,6 @@
// file u8g_dev_st7920_128x64_HAL.cpp for the HAL version.
#include "../../inc/MarlinConfig.h"
#if ENABLED(U8GLIB_ST7920) && !defined(U8G_HAL_LINKS) && !defined(__SAM3X8E__)
#include "../../HAL/shared/Delay.h"
#define ST7920_CLK_PIN LCD_PINS_D4
@ -94,5 +91,3 @@ void ST7920_SWSPI_SND_8BIT(uint8_t val);
#define ST7920_SET_DAT() { ST7920_SWSPI_SND_8BIT(0xFA); U8G_DELAY(); }
#define ST7920_WRITE_BYTE(a) { ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xF0u)); ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4u)); U8G_DELAY(); }
#define ST7920_WRITE_BYTES(p,l) { for (uint8_t i = l + 1; --i;) { ST7920_SWSPI_SND_8BIT(*p&0xF0); ST7920_SWSPI_SND_8BIT(*p<<4); p++; } U8G_DELAY(); }
#endif // U8GLIB_ST7920 && !U8G_HAL_LINKS && !__SAM3X8E__