Browse Source

Bugfixes from Marlin

pull/1/head
Alexander Efimov 5 years ago
parent
commit
172fcfac17
  1. 3
      .gitignore
  2. 16
      Marlin/Configuration.h
  3. 0
      Marlin/src/HAL/LPC1768/upload_extra_script.py
  4. 0
      Marlin/src/HAL/STM32F1/build_flags.py
  5. 4
      Marlin/src/HAL/STM32F1/sdio.h
  6. 189
      Marlin/src/HAL/shared/eeprom_i2c_at24.cpp
  7. 0
      Marlin/src/libs/fatfs/diskio.cpp
  8. 0
      Marlin/src/libs/fatfs/diskio.h
  9. 0
      Marlin/src/libs/fatfs/integer.h
  10. 5
      platformio.ini

3
.gitignore

@ -190,3 +190,6 @@ ozone.jdebug
ozone.jdebug.user ozone.jdebug.user
*.txt *.txt
# Windows users need this to prevent adding build tree to git
buildroot/*

16
Marlin/Configuration.h

@ -480,7 +480,7 @@
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay //#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
//#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders)
// Set/get with gcode: M301 E[extruder number, 0-2] // Set/get with gcode: M301 E[extruder number, 0-2]
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature #define PID_FUNCTIONAL_RANGE 15 // If the temperature difference between the target temperature and the actual temperature
// is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. // is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it // If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
@ -763,11 +763,12 @@
* Override with M201 * Override with M201
* X, Y, Z, E0 [, E1[, E2...]] * X, Y, Z, E0 [, E1[, E2...]]
*/ */
#define DEFAULT_MAX_ACCELERATION { 1000, 1000, 100, 1000 } // @efim-a-efim - decreased E0 acceleration to make it less noisy (yes, even with TMC2208 drivers)
#define DEFAULT_MAX_ACCELERATION { 1000, 1000, 100, 800 }
//#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2 #define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2
#if ENABLED(LIMITED_MAX_ACCEL_EDITING) #if ENABLED(LIMITED_MAX_ACCEL_EDITING)
#define MAX_ACCEL_EDIT_VALUES { 1000, 1000, 100, 1000 } // ...or, set your own edit limits #define MAX_ACCEL_EDIT_VALUES { 2000, 2000, 100, 1000 } // ...or, set your own edit limits
#endif #endif
/** /**
@ -778,8 +779,9 @@
* M204 R Retract Acceleration * M204 R Retract Acceleration
* M204 T Travel Acceleration * M204 T Travel Acceleration
*/ */
// @efim-a-efim - decreased E0 acceleration to make it less noisy (yes, even with TMC2208 drivers)
#define DEFAULT_ACCELERATION 1000 // X, Y, Z and E acceleration for printing moves #define DEFAULT_ACCELERATION 1000 // X, Y, Z and E acceleration for printing moves
#define DEFAULT_RETRACT_ACCELERATION 1000 // E acceleration for retracts #define DEFAULT_RETRACT_ACCELERATION 800 // E acceleration for retracts
#define DEFAULT_TRAVEL_ACCELERATION 1000 // X, Y, Z acceleration for travel (non printing) moves #define DEFAULT_TRAVEL_ACCELERATION 1000 // X, Y, Z acceleration for travel (non printing) moves
/** /**
@ -1077,7 +1079,7 @@
// For direct drive extruder v9 set to true, for geared extruder set to false. // For direct drive extruder v9 set to true, for geared extruder set to false.
#define INVERT_E0_DIR true #define INVERT_E0_DIR true
#define INVERT_E1_DIR false #define INVERT_E1_DIR true
#define INVERT_E2_DIR false #define INVERT_E2_DIR false
#define INVERT_E3_DIR false #define INVERT_E3_DIR false
#define INVERT_E4_DIR false #define INVERT_E4_DIR false
@ -1094,7 +1096,7 @@
#define Z_HOMING_HEIGHT 2 // (mm) Minimal Z height before homing (G28) for Z clearance above the bed, clamps, ... #define Z_HOMING_HEIGHT 2 // (mm) Minimal Z height before homing (G28) for Z clearance above the bed, clamps, ...
// Be sure to have this much clearance over your Z_MAX_POS to prevent grinding. // Be sure to have this much clearance over your Z_MAX_POS to prevent grinding.
//#define Z_AFTER_HOMING 10 // (mm) Height to move to after homing Z #define Z_AFTER_HOMING 10 // (mm) Height to move to after homing Z
// Direction of endstops when homing; 1=MAX, -1=MIN // Direction of endstops when homing; 1=MAX, -1=MIN
// :[-1,1] // :[-1,1]

0
Marlin/src/HAL/LPC1768/upload_extra_script.py

0
Marlin/src/HAL/STM32F1/build_flags.py

4
Marlin/src/HAL/STM32F1/sdio.h

@ -100,7 +100,9 @@
#define SDIO_DATA_TIMEOUT 100U /* Read data transfer timeout */ #define SDIO_DATA_TIMEOUT 100U /* Read data transfer timeout */
#define SDIO_WRITE_TIMEOUT 200U /* Write data transfer timeout */ #define SDIO_WRITE_TIMEOUT 200U /* Write data transfer timeout */
#define SDIO_CLOCK 18000000 /* 18 MHz */ // #define SDIO_CLOCK 18000000 /* 18 MHz */
// Setting SDIO_CLOCK to 4.5 MHz fixes random print interruptions with moving to endstops
#define SDIO_CLOCK 4500000 /* 4.5 MHz */
// ------------------------ // ------------------------
// Types // Types

189
Marlin/src/HAL/shared/eeprom_i2c_at24.cpp

@ -1,189 +0,0 @@
/**
AT24C16, 16K SERIAL EEPROM:
Internally organized with 128 pages of 16 bytes each (2048 bytes)
16K requires an 11-bit data word address for random word addressing.
The 16K does not use any device address bits but instead the 3 bits are used for mem-
ory page addressing. These page addressing bits on the 4K, 8K and 16K devices
should be considered the most significant bits of the data word address which follows.
The A0, A1 and A2 pins are no connect.
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(I2C_EEPROM_AT24C16)
#include "../HAL.h"
#include "../../module/mks_wifi/small_cmsis.h"
#include "../../module/mks_wifi/dwt.h"
#define DEV_ADDR 0xA0
#define FSMC_DISABLE RCC->AHBENR &= ~RCC_AHBENR_FSMCEN //Конфликт на ноге FSMC_NADV с I2C. На время передачи приходится отключать FSMC
#define FSMC_RESTORE RCC->AHBENR |= RCC_AHBENR_FSMCEN;
#define I2C_TIMEOUT 2000 //таймаут на ожидание опереций I2C.
#define CHECK_TIMEOUT do{if(dwt_get_timeout() == 0){ERROR("Timeout");return 0;}}while(0)
static bool waitSRBitSet(uint32_t Bit);
static uint8_t i2c_write(const uint8_t hw_adr, uint8_t *data, uint32_t len);
static uint8_t i2c_read(const uint8_t hw_adr, uint16_t addr, uint8_t *data, uint32_t len);
void eeprom_hw_init(void){
/*
PB6 SCL Alternate function open drain
PB7 SDA Alternate function open drain
*/
dwt_init();
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN|RCC_APB2ENR_AFIOEN;
PORTB->CRL |= (GPIO_CRL_MODE6|GPIO_CRL_MODE7|GPIO_CRL_CNF6|GPIO_CRL_CNF7);
AFIO->MAPR2 |= AFIO_MAPR2_FSMC_NADV_REMAP; //Remap по факту не работает, бит не устанавливается.
RCC->APB1ENR|= RCC_APB1ENR_I2C1EN;
I2C1->CR1 = I2C_CR1_SWRST;
I2C1->CR1 = 0;
//Тактовая 72Mhz, PCLK 36Mhz
I2C1->CCR = (180 << I2C_CCR_CCR_Pos);
I2C1->CR2 = (36 << I2C_CR2_FREQ_Pos);
I2C1->TRISE = 37;
I2C1->CR1 = I2C_CR1_PE;
}
void eeprom_write_byte(uint16_t *pos, unsigned char value) {
uint8_t data[2];
//DEBUG("EEPROM write to pos: %d val %0X",pos,value);
FSMC_DISABLE;
data[0]=(uint8_t)((unsigned)pos % 256);
data[1]=(uint8_t)(value);
if(!i2c_write((DEV_ADDR+(uint8_t)(((unsigned)pos/256)<<1)),data,2)){
ERROR("write failed");
}
safe_delay(20); //Задержка на время пока eeprom пишет.
FSMC_RESTORE;
}
uint8_t eeprom_read_byte(uint16_t *pos) {
uint8_t data;
//DEBUG("EEPROM read from pos: %d",pos);
FSMC_DISABLE;
if(!i2c_read(DEV_ADDR, (uint16_t)((unsigned)pos), &data, 1)){
ERROR("read failed");
data=0;
}
safe_delay(1); //небольшая пауза перед включением FSMC, чтобы состояние STOP успело выставиться на линии.
FSMC_RESTORE;
return data;
}
static uint8_t i2c_write(const uint8_t hw_adr, uint8_t *data, uint32_t len){
DEBUG("i2c write at %d val %0X",data[0],data[1]);
dwt_settimeout(I2C_TIMEOUT);
DEBUG("Wait busy");
while(I2C1->SR2 & I2C_SR2_BUSY) {CHECK_TIMEOUT;};
I2C1->CR1 = I2C_CR1_PE | I2C_CR1_START;
dwt_settimeout(I2C_TIMEOUT);
DEBUG("Wait SB");
while(!(I2C1->SR1 & I2C_SR1_SB)) {CHECK_TIMEOUT;};
I2C1->DR = (hw_adr & 0xFE);
if(!waitSRBitSet(I2C_SR1_ADDR)) return false;
(void)I2C1->SR2;
while(len--){
if(!waitSRBitSet(I2C_SR1_TXE)) return false;
I2C1->DR = *data++;
}
dwt_settimeout(I2C_TIMEOUT);
DEBUG("Wait BTF");
while(!((I2C1->SR1 & I2C_SR1_TXE) && (I2C1->SR1 & I2C_SR1_BTF))) {CHECK_TIMEOUT;};
I2C1->CR1 = I2C_CR1_PE | I2C_CR1_STOP;
return 1;
}
static uint8_t i2c_read(const uint8_t hw_adr, uint16_t addr, uint8_t *data, uint32_t len){
dwt_settimeout(I2C_TIMEOUT);
DEBUG("Wait busy");
while(I2C1->SR2 & I2C_SR2_BUSY) {CHECK_TIMEOUT;};
//Запись адреса
I2C1->CR1 = I2C_CR1_PE | I2C_CR1_START;
dwt_settimeout(I2C_TIMEOUT);
DEBUG("Wait SB");
while(!(I2C1->SR1 & I2C_SR1_SB)) {CHECK_TIMEOUT;}; //Условие старт
I2C1->DR = ((hw_adr & 0xFE) + ((addr/256) << 1));
if(!waitSRBitSet(I2C_SR1_ADDR)) return false; //i2c адрес отправлен
I2C1->SR2;
if(!waitSRBitSet(I2C_SR1_TXE)) return false;
I2C1->DR = addr%256; //адрес в памяти отправлен
dwt_settimeout(I2C_TIMEOUT);
DEBUG("Wait BTF");
while(!((I2C1->SR1 & I2C_SR1_TXE) && (I2C1->SR1 & I2C_SR1_BTF))) {CHECK_TIMEOUT;};
//Чтение
I2C1->CR1 = I2C_CR1_PE | I2C_CR1_START | I2C_CR1_ACK;
dwt_settimeout(I2C_TIMEOUT);
DEBUG("Wait SB");
while(!(I2C1->SR1 & I2C_SR1_SB)) {CHECK_TIMEOUT;};
I2C1->DR = hw_adr|1;
if(!waitSRBitSet(I2C_SR1_ADDR)) return false;
I2C1->SR2;
I2C1->CR1 = I2C_CR1_PE | I2C_CR1_STOP;
if(!waitSRBitSet(I2C_SR1_RXNE)) return false;
*data = I2C1->DR;
return true;
}
static bool waitSRBitSet(uint32_t Bit){
uint32_t sr;
dwt_settimeout(I2C_TIMEOUT);
do{
sr = I2C1->SR1;
if(sr & ( I2C_SR1_AF | I2C_SR1_ARLO | I2C_SR1_BERR)){
I2C1->CR1 = I2C_CR1_PE | I2C_CR1_STOP;
I2C1->SR1 = 0;
ERROR("I2C Error flag %0X",sr);
return false;
}
if(dwt_get_timeout() == 0){
ERROR("Timeout %0X",Bit);
return false;
}
}while(!(sr & Bit));
return true;
};
#endif // I2C_EEPROM

0
Marlin/src/libs/fatfs/diskio.cpp

0
Marlin/src/libs/fatfs/diskio.h

0
Marlin/src/libs/fatfs/integer.h

5
platformio.ini

@ -27,9 +27,10 @@ build_flags = -fmax-errors=5 -g -D__MARLIN_FIRMWARE__ -fmerge-all-constants
lib_deps = lib_deps =
LiquidCrystal LiquidCrystal
TMCStepper@>=0.6.2,<1.0.0 TMCStepper@>=0.6.2,<1.0.0
Adafruit NeoPixel Adafruit NeoPixel@1.4.0
U8glib-HAL=https://github.com/MarlinFirmware/U8glib-HAL/archive/bugfix.zip U8glib-HAL=https://github.com/MarlinFirmware/U8glib-HAL/archive/bugfix.zip
Adafruit_MAX31865=https://github.com/adafruit/Adafruit_MAX31865/archive/master.zip # Adafruit_MAX31865 has broken backward compatibility after 1.1.0 version
Adafruit_MAX31865=https://github.com/adafruit/Adafruit_MAX31865/archive/1.1.0.zip
LiquidTWI2=https://github.com/lincomatic/LiquidTWI2/archive/master.zip LiquidTWI2=https://github.com/lincomatic/LiquidTWI2/archive/master.zip
Arduino-L6470=https://github.com/ameyer/Arduino-L6470/archive/0.8.0.zip Arduino-L6470=https://github.com/ameyer/Arduino-L6470/archive/0.8.0.zip
SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip

Loading…
Cancel
Save