From 8186fce29f3cac693e8e0be3ad1d4596ebe9bf86 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Tue, 22 Dec 2020 04:51:29 -0800 Subject: [PATCH] Anet ET4 / ET4P and Anet TFT28 / TFT35 (#20280) --- Marlin/src/HAL/STM32/tft/tft_fsmc.cpp | 35 ++-- Marlin/src/HAL/STM32/tft/tft_fsmc.h | 41 +++-- Marlin/src/HAL/STM32/tft/xpt2046.h | 9 +- Marlin/src/core/macros.h | 4 +- Marlin/src/lcd/tft/canvas.cpp | 2 +- Marlin/src/lcd/tft/tft.h | 7 + Marlin/src/lcd/tft/tft_queue.cpp | 27 +-- Marlin/src/lcd/tft/ui_320x240.cpp | 14 +- Marlin/src/lcd/tft_io/tft_io.h | 14 +- Marlin/src/pins/pins.h | 4 + Marlin/src/pins/stm32f4/pins_ANET_ET4.h | 223 +++++++++++++++++++++++ Marlin/src/pins/stm32f4/pins_ANET_ET4P.h | 34 ++++ platformio.ini | 23 +++ 13 files changed, 374 insertions(+), 63 deletions(-) create mode 100644 Marlin/src/pins/stm32f4/pins_ANET_ET4.h create mode 100644 Marlin/src/pins/stm32f4/pins_ANET_ET4P.h diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp index b6bc7fcd84261..2a5ad4595b716 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp @@ -48,13 +48,14 @@ void TFT_FSMC::Init() { uint32_t NSBank = (uint32_t)pinmap_peripheral(digitalPinToPinName(TFT_CS_PIN), PinMap_FSMC_CS); + // Perform the SRAM1 memory initialization sequence SRAMx.Instance = FSMC_NORSRAM_DEVICE; SRAMx.Extended = FSMC_NORSRAM_EXTENDED_DEVICE; - /* SRAMx.Init */ + // SRAMx.Init SRAMx.Init.NSBank = NSBank; SRAMx.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE; SRAMx.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM; - SRAMx.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16; + SRAMx.Init.MemoryDataWidth = TERN(TFT_INTERFACE_FSMC_8BIT, FSMC_NORSRAM_MEM_BUS_WIDTH_8, FSMC_NORSRAM_MEM_BUS_WIDTH_16); SRAMx.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE; SRAMx.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW; SRAMx.Init.WrapMode = FSMC_WRAP_MODE_DISABLE; @@ -67,8 +68,8 @@ void TFT_FSMC::Init() { #ifdef STM32F4xx SRAMx.Init.PageSize = FSMC_PAGE_SIZE_NONE; #endif - /* Read Timing - relatively slow to ensure ID information is correctly read from TFT controller */ - /* Can be decreases from 15-15-24 to 4-4-8 with risk of stability loss */ + // Read Timing - relatively slow to ensure ID information is correctly read from TFT controller + // Can be decreases from 15-15-24 to 4-4-8 with risk of stability loss Timing.AddressSetupTime = 15; Timing.AddressHoldTime = 15; Timing.DataSetupTime = 24; @@ -76,8 +77,8 @@ void TFT_FSMC::Init() { Timing.CLKDivision = 16; Timing.DataLatency = 17; Timing.AccessMode = FSMC_ACCESS_MODE_A; - /* Write Timing */ - /* Can be decreases from 8-15-8 to 0-0-1 with risk of stability loss */ + // Write Timing + // Can be decreases from 8-15-8 to 0-0-1 with risk of stability loss ExtTiming.AddressSetupTime = 8; ExtTiming.AddressHoldTime = 15; ExtTiming.DataSetupTime = 8; @@ -131,7 +132,7 @@ void TFT_FSMC::Init() { uint32_t TFT_FSMC::GetID() { uint32_t id; - WriteReg(0x0000); + WriteReg(0); id = LCD->RAM; if (id == 0) @@ -141,16 +142,16 @@ uint32_t TFT_FSMC::GetID() { return id; } - uint32_t TFT_FSMC::ReadID(uint16_t Reg) { - uint32_t id; - WriteReg(Reg); - id = LCD->RAM; // dummy read - id = Reg << 24; - id |= (LCD->RAM & 0x00FF) << 16; - id |= (LCD->RAM & 0x00FF) << 8; - id |= LCD->RAM & 0x00FF; - return id; - } +uint32_t TFT_FSMC::ReadID(tft_data_t Reg) { + uint32_t id; + WriteReg(Reg); + id = LCD->RAM; // dummy read + id = Reg << 24; + id |= (LCD->RAM & 0x00FF) << 16; + id |= (LCD->RAM & 0x00FF) << 8; + id |= LCD->RAM & 0x00FF; + return id; +} bool TFT_FSMC::isBusy() { if (__IS_DMA_ENABLED(&DMAtx)) diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.h b/Marlin/src/HAL/STM32/tft/tft_fsmc.h index cbec7613ef4af..98654b7cfef6b 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.h +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.h @@ -46,9 +46,12 @@ #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR & DMA_SxCR_EN) #endif +#define TFT_DATASIZE TERN(TFT_INTERFACE_FSMC_8BIT, DATASIZE_8BIT, DATASIZE_16BIT) +typedef TERN(TFT_INTERFACE_FSMC_8BIT, uint8_t, uint16_t) tft_data_t; + typedef struct { - __IO uint16_t REG; - __IO uint16_t RAM; + __IO tft_data_t REG; + __IO tft_data_t RAM; } LCD_CONTROLLER_TypeDef; class TFT_FSMC { @@ -58,8 +61,8 @@ class TFT_FSMC { static LCD_CONTROLLER_TypeDef *LCD; - static uint32_t ReadID(uint16_t Reg); - static void Transmit(uint16_t Data) { LCD->RAM = Data; __DSB(); } + static uint32_t ReadID(tft_data_t Reg); + static void Transmit(tft_data_t Data) { LCD->RAM = Data; __DSB(); } static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); public: @@ -68,11 +71,11 @@ class TFT_FSMC { static bool isBusy(); static void Abort() { __HAL_DMA_DISABLE(&DMAtx); } - static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT) {} + static void DataTransferBegin(uint16_t DataWidth = TFT_DATASIZE) {} static void DataTransferEnd() {}; - static void WriteData(uint16_t Data) { Transmit(Data); } - static void WriteReg(uint16_t Reg) { LCD->REG = Reg; __DSB(); } + static void WriteData(uint16_t Data) { Transmit(tft_data_t(Data)); } + static void WriteReg(uint16_t Reg) { LCD->REG = tft_data_t(Reg); __DSB(); } static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); } @@ -100,14 +103,16 @@ const PinMap PinMap_FSMC[] = { {PE_8, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D05 {PE_9, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D06 {PE_10, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D07 - {PE_11, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D08 - {PE_12, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D09 - {PE_13, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D10 - {PE_14, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D11 - {PE_15, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D12 - {PD_8, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D13 - {PD_9, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D14 - {PD_10, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D15 + #if DISABLED(TFT_INTERFACE_FSMC_8BIT) + {PE_11, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D08 + {PE_12, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D09 + {PE_13, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D10 + {PE_14, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D11 + {PE_15, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D12 + {PD_8, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D13 + {PD_9, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D14 + {PD_10, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D15 + #endif {PD_4, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_NOE {PD_5, FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_NWE {NC, NP, 0} @@ -123,7 +128,11 @@ const PinMap PinMap_FSMC_CS[] = { {NC, NP, 0} }; -#define FSMC_RS(A) (void *)((2 << A) - 2) +#if ENABLED(TFT_INTERFACE_FSMC_8BIT) + #define FSMC_RS(A) (void *)((2 << (A-1)) - 1) +#else + #define FSMC_RS(A) (void *)((2 << A) - 2) +#endif const PinMap PinMap_FSMC_RS[] = { #ifdef PF0 diff --git a/Marlin/src/HAL/STM32/tft/xpt2046.h b/Marlin/src/HAL/STM32/tft/xpt2046.h index 7a6d8439c59c9..57ce95a9a6fc5 100644 --- a/Marlin/src/HAL/STM32/tft/xpt2046.h +++ b/Marlin/src/HAL/STM32/tft/xpt2046.h @@ -20,8 +20,10 @@ #ifdef STM32F1xx #include + #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CCR & DMA_CCR_EN) #elif defined(STM32F4xx) #include + #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR & DMA_SxCR_EN) #endif #include "../../../inc/MarlinConfig.h" @@ -57,13 +59,6 @@ enum XPTCoordinate : uint8_t { #define XPT2046_Z1_THRESHOLD 10 #endif -#ifdef STM32F1xx - #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CCR & DMA_CCR_EN) -#elif defined(STM32F4xx) - #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR & DMA_SxCR_EN) -#endif - - class XPT2046 { private: static SPI_HandleTypeDef SPIx; diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index d272d08665789..cf1d7b3a860eb 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -151,7 +151,7 @@ #endif -// Macros to chain up to 12 conditions +// Macros to chain up to 14 conditions #define _DO_1(W,C,A) (_##W##_1(A)) #define _DO_2(W,C,A,B) (_##W##_1(A) C _##W##_1(B)) #define _DO_3(W,C,A,V...) (_##W##_1(A) C _DO_2(W,C,V)) @@ -164,6 +164,8 @@ #define _DO_10(W,C,A,V...) (_##W##_1(A) C _DO_9(W,C,V)) #define _DO_11(W,C,A,V...) (_##W##_1(A) C _DO_10(W,C,V)) #define _DO_12(W,C,A,V...) (_##W##_1(A) C _DO_11(W,C,V)) +#define _DO_13(W,C,A,V...) (_##W##_1(A) C _DO_12(W,C,V)) +#define _DO_14(W,C,A,V...) (_##W##_1(A) C _DO_13(W,C,V)) #define __DO_N(W,C,N,V...) _DO_##N(W,C,V) #define _DO_N(W,C,N,V...) __DO_N(W,C,N,V) #define DO(W,C,V...) _DO_N(W,C,NUM_ARGS(V),V) diff --git a/Marlin/src/lcd/tft/canvas.cpp b/Marlin/src/lcd/tft/canvas.cpp index f6a5046b8d049..308f72a15c72d 100644 --- a/Marlin/src/lcd/tft/canvas.cpp +++ b/Marlin/src/lcd/tft/canvas.cpp @@ -95,7 +95,7 @@ void CANVAS::AddImage(int16_t x, int16_t y, MarlinImage image, uint16_t *colors) if (line >= startLine && line < endLine) { uint16_t *pixel = buffer + x + (line - startLine) * width; for (int16_t j = 0; j < image_width; j++) { - if ((x + j >= 0) && (x + j < width)) *pixel = *data; + if ((x + j >= 0) && (x + j < width)) *pixel = ENDIAN_COLOR(*data); pixel++; data++; } diff --git a/Marlin/src/lcd/tft/tft.h b/Marlin/src/lcd/tft/tft.h index ed3d5e35c1578..159d0e1c196d3 100644 --- a/Marlin/src/lcd/tft/tft.h +++ b/Marlin/src/lcd/tft/tft.h @@ -30,6 +30,13 @@ #include "../../inc/MarlinConfig.h" +#if TFT_INTERFACE_FSMC_8BIT + // When we have a 8 bit interface, we need to invert the bytes of the color + #define ENDIAN_COLOR(C) (((C) >> 8) | ((C) << 8)) +#else + #define ENDIAN_COLOR(C) (C) +#endif + #if HAS_UI_320x240 #define TFT_WIDTH 320 #define TFT_HEIGHT 240 diff --git a/Marlin/src/lcd/tft/tft_queue.cpp b/Marlin/src/lcd/tft/tft_queue.cpp index e77afaf716bfa..a8d55ca0e35dd 100644 --- a/Marlin/src/lcd/tft/tft_queue.cpp +++ b/Marlin/src/lcd/tft/tft_queue.cpp @@ -176,7 +176,7 @@ void TFT_Queue::fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, ui task_parameters->y = y; task_parameters->width = width; task_parameters->height = height; - task_parameters->color = color; + task_parameters->color = ENDIAN_COLOR(color); task_parameters->count = width * height; *end_of_queue = TASK_END_OF_QUEUE; @@ -215,7 +215,7 @@ void TFT_Queue::set_background(uint16_t color) { parametersCanvasBackground_t *parameters = (parametersCanvasBackground_t *)end_of_queue; parameters->type = CANVAS_SET_BACKGROUND; - parameters->color = color; + parameters->color = ENDIAN_COLOR(color); end_of_queue += sizeof(parametersCanvasBackground_t); task_parameters->count++; @@ -230,7 +230,7 @@ void TFT_Queue::add_text(uint16_t x, uint16_t y, uint16_t color, uint8_t *string parameters->type = CANVAS_ADD_TEXT; parameters->x = x; parameters->y = y; - parameters->color = color; + parameters->color = ENDIAN_COLOR(color); parameters->stringLength = 0; parameters->maxWidth = maxWidth; @@ -260,18 +260,19 @@ void TFT_Queue::add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *col if (color_mode == HIGHCOLOR) return; uint16_t *color = (uint16_t *)end_of_queue; - uint8_t number_of_color = 0; + uint8_t color_count = 0; switch (color_mode) { - case GREYSCALE1: number_of_color = 1; break; - case GREYSCALE2: number_of_color = 3; break; - case GREYSCALE4: number_of_color = 15; break; - default: - break; + case GREYSCALE1: color_count = 1; break; + case GREYSCALE2: color_count = 3; break; + case GREYSCALE4: color_count = 15; break; + default: break; } - while (number_of_color--) { - *color++ = *colors++; + uint16_t tmp; + while (color_count--) { + tmp = *colors++; + *color++ = ENDIAN_COLOR(tmp); } end_of_queue = (uint8_t *)color; @@ -322,7 +323,7 @@ void TFT_Queue::add_bar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, parameters->y = y; parameters->width = width; parameters->height = height; - parameters->color = color; + parameters->color = ENDIAN_COLOR(color); end_of_queue += sizeof(parametersCanvasBar_t); task_parameters->count++; @@ -337,7 +338,7 @@ void TFT_Queue::add_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t h parameters->y = y; parameters->width = width; parameters->height = height; - parameters->color = color; + parameters->color = ENDIAN_COLOR(color); end_of_queue += sizeof(parametersCanvasRectangle_t); task_parameters->count++; diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 00dd50292bc08..d4beb4fbe6b71 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -414,21 +414,21 @@ void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const valu extern screenFunc_t _manual_move_func_ptr; if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) { - #define SLIDER_LENGHT 224 + #define SLIDER_LENGTH 224 #define SLIDER_Y_POSITION 140 - tft.canvas((TFT_WIDTH - SLIDER_LENGHT) / 2, SLIDER_Y_POSITION, SLIDER_LENGHT, 16); + tft.canvas((TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION, SLIDER_LENGTH, 16); tft.set_background(COLOR_BACKGROUND); - int16_t position = (SLIDER_LENGHT - 2) * ui.encoderPosition / maxEditValue; + int16_t position = (SLIDER_LENGTH - 2) * ui.encoderPosition / maxEditValue; tft.add_bar(0, 7, 1, 2, ui.encoderPosition == 0 ? COLOR_SLIDER_INACTIVE : COLOR_SLIDER); tft.add_bar(1, 6, position, 4, COLOR_SLIDER); - tft.add_bar(position + 1, 6, SLIDER_LENGHT - 2 - position, 4, COLOR_SLIDER_INACTIVE); - tft.add_bar(SLIDER_LENGHT - 1, 7, 1, 2, int32_t(ui.encoderPosition) == maxEditValue ? COLOR_SLIDER : COLOR_SLIDER_INACTIVE); + tft.add_bar(position + 1, 6, SLIDER_LENGTH - 2 - position, 4, COLOR_SLIDER_INACTIVE); + tft.add_bar(SLIDER_LENGTH - 1, 7, 1, 2, int32_t(ui.encoderPosition) == maxEditValue ? COLOR_SLIDER : COLOR_SLIDER_INACTIVE); #if ENABLED(TOUCH_SCREEN) - tft.add_image((SLIDER_LENGHT - 8) * ui.encoderPosition / maxEditValue, 0, imgSlider, COLOR_SLIDER); - touch.add_control(SLIDER, (TFT_WIDTH - SLIDER_LENGHT) / 2, SLIDER_Y_POSITION - 8, SLIDER_LENGHT, 32, maxEditValue); + tft.add_image((SLIDER_LENGTH - 8) * ui.encoderPosition / maxEditValue, 0, imgSlider, COLOR_SLIDER); + touch.add_control(SLIDER, (TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION - 8, SLIDER_LENGTH, 32, maxEditValue); #endif } diff --git a/Marlin/src/lcd/tft_io/tft_io.h b/Marlin/src/lcd/tft_io/tft_io.h index 50b0ce4463835..aa081be486bc9 100644 --- a/Marlin/src/lcd/tft_io/tft_io.h +++ b/Marlin/src/lcd/tft_io/tft_io.h @@ -75,8 +75,20 @@ #define TOUCH_LANDSCAPE 1 #define TOUCH_PORTRAIT 2 +#ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X 0 +#endif +#ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 0 +#endif +#ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 0 +#endif +#ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y 0 +#endif #ifndef TOUCH_ORIENTATION - #define TOUCH_ORIENTATION TOUCH_LANDSCAPE + #define TOUCH_ORIENTATION TOUCH_LANDSCAPE #endif #define SSD1963 0x5761 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 96e8f8b458533..1f21935f23fb0 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -644,6 +644,10 @@ #include "stm32f4/pins_MKS_ROBIN_PRO_V2.h" // STM32F4 env:mks_robin_pro2 #elif MB(MKS_ROBIN_NANO_V3) #include "stm32f4/pins_MKS_ROBIN_NANO_V3.h" // STM32F4 env:mks_robin_nano_v3 +#elif MB(ANET_ET4) + #include "stm32f4/pins_ANET_ET4.h" // STM32F4 env:Anet_ET4_OpenBLT +#elif MB(ANET_ET4P) + #include "stm32f4/pins_ANET_ET4P.h" // STM32F4 env:Anet_ET4_OpenBLT // // ARM Cortex M7 diff --git a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h new file mode 100644 index 0000000000000..c0bbe2f423f9c --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h @@ -0,0 +1,223 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ + +#pragma once + +#if NOT_TARGET(STM32F4) + #error "Oops! Select an STM32F4 board in 'Tools > Board.'" +#elif HOTENDS > 1 || E_STEPPERS > 1 + #error "Anet ET4 only supports one hotend / E-stepper. Comment out this line to continue." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Anet ET4 1.x" +#endif + +// +// EEPROM +// + +// Use one of these or SDCard-based Emulation will be used +#if NO_EEPROM_SELECTED + //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation + #define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation + //#define IIC_BL24CXX_EEPROM // Use I2C EEPROM onboard IC (AT24C04C, Size 4KB, PageSize 16B) +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across the + // 128 kB sector allocated for EEPROM emulation. + #define FLASH_EEPROM_LEVELING +#elif ENABLED(IIC_BL24CXX_EEPROM) + #define IIC_EEPROM_SDA PB11 + #define IIC_EEPROM_SCL PB10 + #define EEPROM_DEVICE_ADDRESS 0xA0 + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PC13 +#define Y_STOP_PIN PE12 +#define Z_STOP_PIN PE11 + +// +// Z Probe +// +#if ENABLED(BLTOUCH) + #error "You will need to use 24V to 5V converter and remove one resistor and capacitor from the motherboard. See https://github.com/davidtgbe/Marlin/blob/bugfix-2.0.x/docs/Tutorials/bltouch-en.md for more information. Comment out this line to proceed at your own risk." + #define SERVO0_PIN PC3 +#elif !defined(Z_MIN_PROBE_PIN) + #define Z_MIN_PROBE_PIN PC3 +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA2 +#endif + +// +// Power Loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PA8 +#endif + +// +// LED PIN +// +#define LED_PIN PD12 + +// +// Steppers +// +#define X_STEP_PIN PB6 +#define X_DIR_PIN PB5 +#define X_ENABLE_PIN PB7 + +#define Y_STEP_PIN PB3 +#define Y_DIR_PIN PD6 +#define Y_ENABLE_PIN PB4 + +#define Z_STEP_PIN PA12 +#define Z_DIR_PIN PA11 +#define Z_ENABLE_PIN PA15 + +#define E0_STEP_PIN PB9 +#define E0_DIR_PIN PB8 +#define E0_ENABLE_PIN PE0 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA1 +#define TEMP_BED_PIN PA4 + +// +// Heaters +// +#define HEATER_0_PIN PA0 +#define HEATER_BED_PIN PE2 + +// +// Fans +// +#define FAN_PIN PE3 // Layer fan +#define FAN1_PIN PE1 // Hotend fan + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN FAN1_PIN +#endif + +// +// LCD / Controller +// +#define TFT_RESET_PIN PE6 +#define TFT_CS_PIN PD7 +#define TFT_RS_PIN PD13 +#define TFT_INTERFACE_FSMC_8BIT + +// +// Touch Screen +// https://ldm-systems.ru/f/doc/catalog/HY-TFT-2,8/XPT2046.pdf +// +#if ENABLED(TOUCH_SCREEN) + #define TOUCH_CS_PIN PB2 + #define TOUCH_SCK_PIN PB0 + #define TOUCH_MOSI_PIN PE5 + #define TOUCH_MISO_PIN PE4 + #define TOUCH_INT_PIN PB1 +#endif + +// Touchscreen calibration does not work correctly with ANET_ET5_TFT35 or ANET_ET4_TFT28 +#if ENABLED(TOUCH_SCREEN_CALIBRATION) + #undef TOUCH_SCREEN_CALIBRATION +#endif + +#if ENABLED(ANET_ET5_TFT35) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X 17125 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y -11307 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X -26 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y 337 + #endif + #ifndef TOUCH_ORIENTATION + #define TOUCH_ORIENTATION TOUCH_PORTRAIT + #endif +#elif ENABLED(ANET_ET4_TFT28) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X -11838 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 8776 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 333 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y -17 + #endif + #ifndef TOUCH_ORIENTATION + #define TOUCH_ORIENTATION TOUCH_PORTRAIT + #endif +#endif + +// +// SD Card +// +//#define SDIO_SUPPORT + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION CUSTOM_CABLE +#endif + +#if ENABLED(SDSUPPORT) + + #define SDIO_D0_PIN PC8 + #define SDIO_D1_PIN PC9 + #define SDIO_D2_PIN PC10 + #define SDIO_D3_PIN PC11 + #define SDIO_CK_PIN PC12 + #define SDIO_CMD_PIN PD2 + + #if DISABLED(SDIO_SUPPORT) + #define SOFTWARE_SPI + #define SDSS SDIO_D3_PIN + #define SCK_PIN SDIO_CK_PIN + #define MISO_PIN SDIO_D0_PIN + #define MOSI_PIN SDIO_CMD_PIN + #endif + + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN PD3 + #endif + +#endif diff --git a/Marlin/src/pins/stm32f4/pins_ANET_ET4P.h b/Marlin/src/pins/stm32f4/pins_ANET_ET4P.h new file mode 100644 index 0000000000000..eecabbaf9866d --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_ANET_ET4P.h @@ -0,0 +1,34 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ + +#pragma once + +#define BOARD_INFO_NAME "Anet ET4P 1.x" + +// +// TMC2208 Configuration_adv defaults for Anet ET4P-MB_V1.x +// +#if !AXIS_DRIVER_TYPE_X(TMC2208_STANDALONE) || !AXIS_DRIVER_TYPE_Y(TMC2208_STANDALONE) || !AXIS_DRIVER_TYPE_Z(TMC2208_STANDALONE) || !AXIS_DRIVER_TYPE_E0(TMC2208_STANDALONE) + #error "ANET_ET4P requires ([XYZ]|E0)_DRIVER_TYPE set to TMC2208_STANDALONE." +#endif + +#include "pins_ANET_ET4.h" diff --git a/platformio.ini b/platformio.ini index 9de20a5ec4e61..def351b4b5b17 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1197,6 +1197,29 @@ build_flags = ${common_stm32.build_flags} extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py +# +# Anet ET4-MB_V1.x/ET4P-MB_V1.x (STM32F407VGT6 ARM Cortex-M4) +# For use with with davidtgbe's OpenBLT bootloader https://github.com/davidtgbe/openblt/releases +# Comment out board_build.offset = 0x10000 if you don't plan to use OpenBLT/flashing directly to 0x08000000. +# +[env:Anet_ET4_OpenBLT] +platform = ${common_stm32.platform} +extends = common_stm32 +build_flags = ${common_stm32.build_flags} -DHAL_SD_MODULE_ENABLED -DHAL_SRAM_MODULE_ENABLED +board = genericSTM32F407VGT6 +board_build.core = stm32 +board_build.variant = MARLIN_F4x7Vx +board_build.ldscript = ldscript.ld +board_build.firmware = firmware.srec +board_build.offset = 0x10000 +board_upload.offset_address = 0x08010000 +build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 +debug_tool = jlink +upload_protocol = jlink +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py + # # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) #