Skip to content

Commit

Permalink
⛙ Merge w/Marlin
Browse files Browse the repository at this point in the history
  • Loading branch information
classicrocker883 committed Dec 27, 2023
2 parents a8c0011 + 3840663 commit 1e5c248
Show file tree
Hide file tree
Showing 21 changed files with 2,481 additions and 165 deletions.
2 changes: 1 addition & 1 deletion Marlin/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* here we define this default string as the date where the latest release
* version was tagged.
*/
//#define STRING_DISTRIBUTION_DATE "2023-12-25"
//#define STRING_DISTRIBUTION_DATE "2023-12-27"

#define STRING_DISTRIBUTION_DATE __DATE__
#define STRING_DISTRIBUTION_TIME __TIME__
Expand Down
20 changes: 6 additions & 14 deletions Marlin/src/HAL/NATIVE_SIM/u8g/LCD_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,14 @@
*/
#pragma once

/**
* Native/Simulator LCD-specific defines
*/

void usleep(uint64_t microsec);
// The following are optional depending on the platform.

// definitions of HAL specific com and device drivers.
uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);

// connect U8g com generic com names to the desired driver
#define U8G_COM_SW_SPI u8g_com_sw_spi_fn
#define U8G_COM_ST7920_SW_SPI u8g_com_ST7920_sw_spi_fn

// let these default for now
#define U8G_COM_HW_SPI u8g_com_null_fn
#define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
#define U8G_COM_SSD_I2C u8g_com_null_fn
#define U8G_COM_PARALLEL u8g_com_null_fn
#define U8G_COM_T6963 u8g_com_null_fn
#define U8G_COM_FAST_PARALLEL u8g_com_null_fn
#define U8G_COM_UC_I2C u8g_com_null_fn
#define U8G_COM_HAL_SW_SPI_FN u8g_com_sw_spi_fn
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_ST7920_sw_spi_fn
4 changes: 3 additions & 1 deletion Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ static void u8g_com_st7920_write_byte_sw_spi(uint8_t rs, uint8_t val) {
swSpiTransfer(val & 0x0F0, SPI_speed, SCK_pin_ST7920_HAL, -1, MOSI_pin_ST7920_HAL_HAL);
swSpiTransfer(val << 4, SPI_speed, SCK_pin_ST7920_HAL, -1, MOSI_pin_ST7920_HAL_HAL);
}

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -128,7 +129,7 @@ uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
break;

case U8G_COM_MSG_RESET:
if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
break;

case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
Expand Down Expand Up @@ -163,6 +164,7 @@ uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
}
return 1;
}

#ifdef __cplusplus
}
#endif
Expand Down
14 changes: 1 addition & 13 deletions Marlin/src/HAL/SAMD21/u8g/LCD_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

/**
* SAMD21 HAL developed by Bart Meijer (brupje)
* Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician)
*/
#pragma once

/**
* SAMD21 LCD-specific defines
*/

// The following are optional depending on the platform.

// definitions of HAL specific com and device drivers.
uint8_t u8g_com_samd21_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);

// connect U8g com generic com names to the desired driver
#define U8G_COM_HW_SPI u8g_com_samd21_st7920_hw_spi_fn // use SAMD21 specific hardware SPI routine
#define U8G_COM_ST7920_HW_SPI u8g_com_samd21_st7920_hw_spi_fn
#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd21_st7920_hw_spi_fn
32 changes: 32 additions & 0 deletions Marlin/src/HAL/STM32/u8g/LCD_defines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

/**
* STM32 LCD-specific defines
*/

uint8_t u8g_com_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // See U8glib-HAL
uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // See U8glib-HAL

#define U8G_COM_HAL_SW_SPI_FN u8g_com_std_sw_spi_fn
#define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn
8 changes: 4 additions & 4 deletions Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static inline uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, c
return b;
}

static void u8g_sw_spi_HAL_STM32F1_shift_out(uint8_t val) {
static void u8g_sw_spi_shift_out(uint8_t val) {
#if ENABLED(FYSETC_MINI_12864)
swSpiTransfer_mode_3(val, SPI_speed);
#else
Expand Down Expand Up @@ -139,21 +139,21 @@ uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
break;

case U8G_COM_MSG_WRITE_BYTE:
u8g_sw_spi_HAL_STM32F1_shift_out(arg_val);
u8g_sw_spi_shift_out(arg_val);
break;

case U8G_COM_MSG_WRITE_SEQ: {
uint8_t *ptr = (uint8_t *)arg_ptr;
while (arg_val > 0) {
u8g_sw_spi_HAL_STM32F1_shift_out(*ptr++);
u8g_sw_spi_shift_out(*ptr++);
arg_val--;
}
} break;

case U8G_COM_MSG_WRITE_SEQ_P: {
uint8_t *ptr = (uint8_t *)arg_ptr;
while (arg_val > 0) {
u8g_sw_spi_HAL_STM32F1_shift_out(u8g_pgm_read(ptr));
u8g_sw_spi_shift_out(u8g_pgm_read(ptr));
ptr++;
arg_val--;
}
Expand Down
34 changes: 34 additions & 0 deletions Marlin/src/HAL/STM32F1/u8g/LCD_defines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

/**
* STM32F1 (Maple) LCD-specific defines
*/

uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // See U8glib-HAL

#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_STM32F1_sw_spi_fn
#define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn // See U8glib-HAL
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_std_sw_spi_fn // See U8glib-HAL
#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_stm32duino_hw_spi_fn // See U8glib-HAL
1 change: 1 addition & 0 deletions Marlin/src/core/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@
#define BOARD_BTT_OCTOPUS_MAX_EZ_V1_0 6008 // BigTreeTech Octopus Max EZ V1.0 (STM32H723ZE)
#define BOARD_BTT_OCTOPUS_PRO_V1_0_1 6009 // BigTreeTech Octopus Pro v1.0.1 (STM32H723ZE)
#define BOARD_BTT_OCTOPUS_PRO_V1_1 6010 // BigTreeTech Octopus Pro v1.1 (STM32H723ZE)
#define BOARD_BTT_KRAKEN_V1_0 6011 // BigTreeTech Kraken v1.0 (STM32H723ZG)

//
// Espressif ESP32 WiFi
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2023-12-25"
#define STRING_DISTRIBUTION_DATE "2023-12-27"
#endif

/**
Expand Down
112 changes: 15 additions & 97 deletions Marlin/src/lcd/dogm/HAL_LCD_com_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,117 +21,35 @@
*/
#pragma once

// Use this file to select the com driver for device drivers that are NOT in the U8G library
/**
* Assign custom or standard U8G device drivers
*/

#include <U8glib-HAL.h>

#ifndef U8G_HAL_LINKS // Defined by LPC1768/9 environments in platform.ini

#ifdef __SAM3X8E__

uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_HAL_DUE_shared_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_DUE_sw_spi_fn
#define U8G_COM_HAL_HW_SPI_FN u8g_com_HAL_DUE_shared_hw_spi_fn
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_HAL_DUE_ST7920_sw_spi_fn

#elif defined(__SAMD51__)

#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__)

uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_STM32F1_sw_spi_fn
#define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_std_sw_spi_fn
#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_stm32duino_hw_spi_fn

#elif defined(ARDUINO_ARCH_STM32)

uint8_t u8g_com_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
#define U8G_COM_HAL_SW_SPI_FN u8g_com_std_sw_spi_fn
#define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn

#elif defined(ESP32)
#include HAL_PATH(../.., u8g/LCD_defines.h)

uint8_t u8g_eps_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
#define U8G_COM_HAL_HW_SPI_FN u8g_eps_hw_spi_fn

#elif defined(__AVR__)

uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_AVR_sw_sp_fn

#endif

#ifndef U8G_COM_HAL_SW_SPI_FN
#define U8G_COM_HAL_SW_SPI_FN u8g_com_arduino_std_sw_spi_fn
#endif
#ifndef U8G_COM_HAL_HW_SPI_FN
#define U8G_COM_HAL_HW_SPI_FN u8g_com_arduino_hw_spi_fn
#endif
#ifndef U8G_COM_ST7920_HAL_SW_SPI
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_arduino_st7920_spi_fn
#endif
#ifndef U8G_COM_ST7920_HAL_HW_SPI
#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_arduino_st7920_hw_spi_fn
#endif

// This can't be invoked from the current platformio.ini
#ifdef TARGET_LPC1768
uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
#endif

#define U8G_COM_SSD_I2C_HAL u8g_com_arduino_ssd_i2c_fn

#elif defined(TARGET_LPC1768)

uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_LPC1768_sw_spi_fn
#define U8G_COM_HAL_HW_SPI_FN u8g_com_HAL_LPC1768_hw_spi_fn
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_HAL_LPC1768_ST7920_sw_spi_fn
#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_HAL_LPC1768_ST7920_hw_spi_fn
#define U8G_COM_SSD_I2C_HAL u8g_com_HAL_LPC1768_ssd_hw_i2c_fn

#elif defined(__PLAT_NATIVE_SIM__)
uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
#define U8G_COM_HAL_SW_SPI_FN u8g_com_sw_spi_fn
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_ST7920_sw_spi_fn
#if HAS_FSMC_GRAPHICAL_TFT || HAS_SPI_GRAPHICAL_TFT || HAS_LTDC_GRAPHICAL_TFT
uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
#define U8G_COM_HAL_TFT_FN u8g_com_hal_tft_fn
#endif

// U8G_HAL_LINKS is defined for LPC1768/9 and Native envs by -DU8G_HAL_LINKS in platform.ini
#ifndef U8G_COM_HAL_SW_SPI_FN
#define U8G_COM_HAL_SW_SPI_FN u8g_com_null_fn
#define U8G_COM_HAL_SW_SPI_FN TERN(U8G_HAL_LINKS, u8g_com_null_fn, u8g_com_arduino_std_sw_spi_fn)
#endif
#ifndef U8G_COM_HAL_HW_SPI_FN
#define U8G_COM_HAL_HW_SPI_FN u8g_com_null_fn
#define U8G_COM_HAL_HW_SPI_FN TERN(U8G_HAL_LINKS, u8g_com_null_fn, u8g_com_arduino_hw_spi_fn)
#endif
#ifndef U8G_COM_ST7920_HAL_SW_SPI
#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_null_fn
#define U8G_COM_ST7920_HAL_SW_SPI TERN(U8G_HAL_LINKS, u8g_com_null_fn, u8g_com_arduino_st7920_spi_fn)
#endif
#ifndef U8G_COM_ST7920_HAL_HW_SPI
#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_null_fn
#define U8G_COM_ST7920_HAL_HW_SPI TERN(U8G_HAL_LINKS, u8g_com_null_fn, u8g_com_arduino_st7920_hw_spi_fn)
#endif
#ifndef U8G_COM_SSD_I2C_HAL
#define U8G_COM_SSD_I2C_HAL u8g_com_null_fn
#define U8G_COM_SSD_I2C_HAL TERN(U8G_HAL_LINKS, u8g_com_null_fn, u8g_com_arduino_ssd_i2c_fn)
#endif
#if HAS_FSMC_GRAPHICAL_TFT || HAS_SPI_GRAPHICAL_TFT || HAS_LTDC_GRAPHICAL_TFT
uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
#define U8G_COM_HAL_TFT_FN u8g_com_hal_tft_fn
#else
#define U8G_COM_HAL_TFT_FN u8g_com_null_fn
#ifndef U8G_COM_HAL_TFT_FN
#define U8G_COM_HAL_TFT_FN u8g_com_null_fn
#endif
8 changes: 4 additions & 4 deletions Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
*
*/

// 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.
// NOTE - the HAL version of the rrd device uses a generic ST7920 device.
// See u8g_dev_st7920_128x64_HAL.cpp for the HAL version.

#include "../../inc/MarlinConfigPre.h"

#if !defined(U8G_HAL_LINKS) && ANY(__AVR__, ARDUINO_ARCH_STM32, ARDUINO_ARCH_ESP32)
#if ANY(__AVR__, ARDUINO_ARCH_STM32, ARDUINO_ARCH_ESP32)

#include "../../inc/MarlinConfig.h"

Expand Down Expand Up @@ -193,4 +193,4 @@ u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = { u8g_dev_rrd_st7920_128x64_fn, &u8
#endif

#endif // IS_U8GLIB_ST7920
#endif // !U8G_HAL_LINKS && (__AVR__ || ARDUINO_ARCH_STM32 || ARDUINO_ARCH_ESP32)
#endif // __AVR__ || ARDUINO_ARCH_STM32 || ARDUINO_ARCH_ESP32
2 changes: 2 additions & 0 deletions Marlin/src/pins/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,8 @@
#include "stm32h7/pins_BTT_OCTOPUS_PRO_V1_0_1.h" // STM32H7 env:STM32H723ZE_btt
#elif MB(BTT_OCTOPUS_PRO_V1_1)
#include "stm32h7/pins_BTT_OCTOPUS_PRO_V1_1.h" // STM32H7 env:STM32H723ZE_btt
#elif MB(BTT_KRAKEN_V1_0)
#include "stm32h7/pins_BTT_KRAKEN_V1_0.h" // STM32H7 env:STM32H723ZG_btt
#elif MB(TEENSY41)
#include "teensy4/pins_TEENSY41.h" // Teensy-4.x env:teensy41
#elif MB(T41U5XBB)
Expand Down
Loading

0 comments on commit 1e5c248

Please sign in to comment.