Skip to content

Commit

Permalink
Merge pull request #52 from MarlinFirmware/bugfix-2.0.x
Browse files Browse the repository at this point in the history
sync Bugfix 2.0.x
  • Loading branch information
Msq001 authored Aug 12, 2019
2 parents 5528206 + 13d8dc0 commit 66fc599
Show file tree
Hide file tree
Showing 84 changed files with 10,530 additions and 490 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: http://www.thinkyhead.com/donate-to-marlin
3 changes: 3 additions & 0 deletions Marlin/src/HAL/HAL_AVR/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ void HAL_init(void);
inline void HAL_clear_reset_source(void) { MCUSR = 0; }
inline uint8_t HAL_get_reset_source(void) { return MCUSR; }

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
extern "C" {
int freeMemory(void);
}
#pragma GCC diagnostic pop

// timers
#define HAL_TIMER_RATE ((F_CPU) / 8) // i.e., 2MHz or 2.5MHz
Expand Down
6 changes: 5 additions & 1 deletion Marlin/src/HAL/HAL_DUE/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,16 @@ void HAL_init(void);
// Utility functions
//
void _delay_ms(const int delay);

#pragma GCC diagnostic push
#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);
char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s);
#ifdef __cplusplus
}
#endif
3 changes: 3 additions & 0 deletions Marlin/src/HAL/HAL_ESP32/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ uint8_t HAL_get_reset_source(void);

void _delay_ms(int delay);

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
int freeMemory(void);
#pragma GCC diagnostic pop

void analogWrite(pin_t pin, int value);

Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/HAL/HAL_LINUX/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ extern HalSerial usb_serial;
inline void HAL_init(void) { }

// Utility functions
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
int freeMemory(void);
#pragma GCC diagnostic pop

// SPI: Extended functions which take a channel number (hardware SPI only)
/** Write single byte to specified SPI channel */
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/HAL/HAL_LPC1768/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ extern "C" volatile uint32_t _millis;
//
// Utility functions
//
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
int freeMemory(void);
#pragma GCC diagnostic pop

//
// SPI: Extended functions taking a channel number (Hardware SPI only)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_LPC1768/upload_extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def print_error(e):
print('\nUnable to find destination disk (' + e + ')\n' \
'Please select it in platformio.ini using the upload_port keyword ' \
'(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html) ' \
'or copy the firmware (.pioenvs/' + env.get('PIOENV') + '/firmware.bin) manually to the appropriate disk\n')
'or copy the firmware (.pio/build/' + env.get('PIOENV') + '/firmware.bin) manually to the appropriate disk\n')

try:
if current_OS == 'Windows':
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/HAL_SAMD51/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
#else
#define GET_TEMP_5_ADC() -1
#endif
#if HAS_HEATED_BED
#if HAS_TEMP_ADC_BED
#define GET_BED_ADC() PIN_TO_ADC(TEMP_BED_PIN)
#else
#define GET_BED_ADC() -1
#endif
#if HAS_HEATED_CHAMBER
#if HAS_TEMP_ADC_CHAMBER
#define GET_CHAMBER_ADC() PIN_TO_ADC(TEMP_CHAMBER_PIN)
#else
#define GET_CHAMBER_ADC() -1
Expand Down
10 changes: 8 additions & 2 deletions Marlin/src/HAL/HAL_SAMD51/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,17 @@ void noTone(const pin_t _pin);

// Enable hooks into idle and setup for HAL
void HAL_init(void);
/*#define HAL_IDLETASK 1
void HAL_idletask(void);*/
/*
#define HAL_IDLETASK 1
void HAL_idletask(void);
*/

//
// Utility functions
//
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
int freeMemory(void);
#pragma GCC diagnostic pop
1 change: 1 addition & 0 deletions Marlin/src/HAL/HAL_SAMD51/fastio_SAMD51.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
#define DIO5_PIN PIN_PC21
#define DIO16_PIN PIN_PC22
#define DIO17_PIN PIN_PC23
#define DIO88_PIN PIN_PC24 // NEOPIXEL
// PORTD
#define DIO22_PIN PIN_PD12
#define DIO6_PIN PIN_PD20
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#endif

#if ENABLED(EMERGENCY_PARSER)
#error "EMERGENCY_PARSER is not yet implemented for STM32F4. Disable EMERGENCY_PARSER to continue."
#error "EMERGENCY_PARSER is not yet implemented for SAMD51. Disable EMERGENCY_PARSER to continue."
#endif

#if ENABLED(SDIO_SUPPORT)
Expand Down
21 changes: 13 additions & 8 deletions Marlin/src/HAL/HAL_STM32/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ typedef int16_t pin_t;
// Public Variables
// ------------------------

/** result of last ADC conversion */
// result of last ADC conversion
extern uint16_t HAL_adc_result;

// ------------------------
Expand All @@ -149,30 +149,35 @@ extern uint16_t HAL_adc_result;
// Enable hooks into setup for HAL
void HAL_init(void);

/** clear reset reason */
// Clear reset reason
void HAL_clear_reset_source (void);

/** reset reason */
// Reset reason
uint8_t HAL_get_reset_source(void);

void _delay_ms(const int delay);

extern "C" char* _sbrk(int incr);

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"

static inline int freeMemory() {
volatile char top;
return &top - reinterpret_cast<char*>(_sbrk(0));
}

#pragma GCC diagnostic pop

//
// SPI: Extended functions which take a channel number (hardware SPI only)
//

/** Write single byte to specified SPI channel */
// Write single byte to specified SPI channel
void spiSend(uint32_t chan, byte b);
/** Write buffer to specified SPI channel */
// Write buffer to specified SPI channel
void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
/** Read single byte from specified SPI channel */
// Read single byte from specified SPI channel
uint8_t spiRec(uint32_t chan);

//
Expand All @@ -182,8 +187,8 @@ uint8_t spiRec(uint32_t chan);
// Wire library should work for i2c EEPROMs
void eeprom_write_byte(uint8_t *pos, unsigned char value);
uint8_t eeprom_read_byte(uint8_t *pos);
void eeprom_read_block (void *__dst, const void *__src, size_t __n);
void eeprom_update_block (const void *__src, void *__dst, size_t __n);
void eeprom_read_block(void *__dst, const void *__src, size_t __n);
void eeprom_update_block(const void *__src, void *__dst, size_t __n);

//
// ADC
Expand Down
27 changes: 13 additions & 14 deletions Marlin/src/HAL/HAL_STM32/persistent_store_sdcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,23 @@
*/

/**
* HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
* Implementation of EEPROM settings in SD Card
*/

#ifdef TARGET_STM32F4
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)

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

#if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)
#if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM)

#include "../shared/persistent_store_api.h"

#ifndef E2END
#define E2END 0xFFF // 4KB
#endif
#define HAL_EEPROM_SIZE (E2END + 1) // 16KB
#define HAL_EEPROM_SIZE int(E2END + 1)

#define _ALIGN(x) __attribute__ ((aligned(x))) // SDIO uint32_t* compat.
#define _ALIGN(x) __attribute__ ((aligned(x)))
static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];

#if ENABLED(SDSUPPORT)
Expand All @@ -52,11 +51,11 @@ static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];

SdFile file, root = card.getroot();
if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
return false;
return true;

int16_t bytes_read = file.read(HAL_eeprom_data, HAL_STM32F4_EEPROM_SIZE);
int bytes_read = file.read(HAL_eeprom_data, HAL_EEPROM_SIZE);
if (bytes_read < 0) return false;
for (; bytes_read < HAL_STM32F4_EEPROM_SIZE; bytes_read++)
for (; bytes_read < HAL_EEPROM_SIZE; bytes_read++)
HAL_eeprom_data[bytes_read] = 0xFF;
file.close();
return true;
Expand All @@ -66,17 +65,17 @@ static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
if (!card.isDetected()) return false;

SdFile file, root = card.getroot();
int16_t bytes_written = 0;
int bytes_written = 0;
if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
bytes_written = file.write(HAL_eeprom_data, HAL_STM32F4_EEPROM_SIZE);
bytes_written = file.write(HAL_eeprom_data, HAL_EEPROM_SIZE);
file.close();
}
return (bytes_written == HAL_STM32F4_EEPROM_SIZE);
return (bytes_written == HAL_EEPROM_SIZE);
}

#else // !SDSUPPORT

#error "Please define SPI_EEPROM (in Configuration.h) or disable EEPROM_SETTINGS."
#error "Please define an EEPROM, a SDCARD or disable EEPROM_SETTINGS."

#endif // !SDSUPPORT

Expand All @@ -98,7 +97,7 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin
return false;
}

size_t PersistentStore::capacity() { return HAL_STM32F4_EEPROM_SIZE; }
size_t PersistentStore::capacity() { return HAL_EEPROM_SIZE; }

#endif // EEPROM_SETTINGS
#endif // __STM32F4__
#endif // STM32
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_STM32/pinsDebug_STM32duino.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void port_print(const pin_t Ard_num) {
for (Index = 0; Index < NUMBER_PINS_TOTAL; Index++)
if (Ard_num == GET_PIN_MAP_PIN_M43(Index)) break;

char * const ppa = pin_xref[Index].Port_pin_alpha;
const char * ppa = pin_xref[Index].Port_pin_alpha;
sprintf_P(buffer, PSTR("%s"), ppa);
SERIAL_ECHO(buffer);
if (ppa[3] == '\0') SERIAL_CHAR(' ');
Expand Down
19 changes: 10 additions & 9 deletions Marlin/src/HAL/HAL_STM32F1/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ typedef int8_t pin_t;
// Public Variables
// ------------------------

/** result of last ADC conversion */
// Result of last ADC conversion
extern uint16_t HAL_adc_result;

// ------------------------
Expand All @@ -174,21 +174,25 @@ extern uint16_t HAL_adc_result;
// Memory related
#define __bss_end __bss_end__

/** clear reset reason */
// Clear reset reason
void HAL_clear_reset_source(void);

/** reset reason */
// Reset reason
uint8_t HAL_get_reset_source(void);

void _delay_ms(const int delay);

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"

/*
extern "C" {
int freeMemory(void);
}
*/

extern "C" char* _sbrk(int incr);

/*
static int freeMemory() {
volatile int top;
Expand All @@ -197,9 +201,6 @@ static int freeMemory() {
}
*/

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"

static int freeMemory() {
volatile char top;
return &top - reinterpret_cast<char*>(_sbrk(0));
Expand All @@ -211,11 +212,11 @@ static int freeMemory() {
// SPI: Extended functions which take a channel number (hardware SPI only)
//

/** Write single byte to specified SPI channel */
// Write single byte to specified SPI channel
void spiSend(uint32_t chan, byte b);
/** Write buffer to specified SPI channel */
// Write buffer to specified SPI channel
void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
/** Read single byte from specified SPI channel */
// Read single byte from specified SPI channel
uint8_t spiRec(uint32_t chan);

//
Expand Down
5 changes: 2 additions & 3 deletions Marlin/src/HAL/HAL_STM32F1/HAL_spi_STM32F1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@
* @details Only configures SS pin since libmaple creates and initialize the SPI object
*/
void spiBegin() {
#if !PIN_EXISTS(SS)
#error "SS_PIN not defined!"
#if PIN_EXISTS(SS)
OUT_WRITE(SS_PIN, HIGH);
#endif
OUT_WRITE(SS_PIN, HIGH);
}

/**
Expand Down
Loading

0 comments on commit 66fc599

Please sign in to comment.