diff --git a/Marlin/src/HAL/HAL_DUE/HAL.h b/Marlin/src/HAL/HAL_DUE/HAL.h index 7cba8097c..b5d1d4580 100644 --- a/Marlin/src/HAL/HAL_DUE/HAL.h +++ b/Marlin/src/HAL/HAL_DUE/HAL.h @@ -41,26 +41,13 @@ #include "watchdog_Due.h" #include "HAL_timers_Due.h" -// -// Defines -// #define NUM_SERIAL 1 +// Required before the include or compilation fails #define MYSERIAL0 customizedSerial -// We need the previous define before the include, or compilation bombs... #include "MarlinSerial_Due.h" #include "MarlinSerialUSB_Due.h" -#ifndef analogInputToDigitalPin - #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1) -#endif - -#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() - // On AVR this is in math.h? #define square(x) ((x)*(x)) @@ -86,19 +73,18 @@ #define RST_SOFTWARE 32 #define RST_BACKUP 64 -// -------------------------------------------------------------------------- -// Types -// -------------------------------------------------------------------------- - typedef int8_t pin_t; #define HAL_SERVO_LIB Servo -// -------------------------------------------------------------------------- -// Public Variables -// -------------------------------------------------------------------------- - -extern uint16_t HAL_adc_result; // result of last ADC conversion +// +// Interrupts +// +#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END if (!primask) __enable_irq() +#define ISRS_ENABLED() (!__get_PRIMASK()) +#define ENABLE_ISRS() __enable_irq() +#define DISABLE_ISRS() __disable_irq() void cli(void); // Disable interrupts void sei(void); // Enable interrupts @@ -106,13 +92,9 @@ void sei(void); // Enable interrupts void HAL_clear_reset_source(void); // clear reset reason uint8_t HAL_get_reset_source(void); // get reset reason -void _delay_ms(const int delay); - -int freeMemory(void); - -/** - * SPI: Extended functions taking a channel number (hardware SPI only) - */ +// +// SPI: Extended functions taking a channel number (Hardware SPI only) +// // Write single byte to specified SPI channel void spiSend(uint32_t chan, byte b); @@ -123,18 +105,22 @@ void spiSend(uint32_t chan, const uint8_t* buf, size_t n); // Read single byte from specified SPI channel uint8_t spiRec(uint32_t chan); -/** - * EEPROM - */ - +// +// EEPROM +// void eeprom_write_byte(unsigned char *pos, unsigned char value); unsigned char eeprom_read_byte(unsigned char *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); -/** - * ADC - */ +// +// ADC +// +extern uint16_t HAL_adc_result; // result of last ADC conversion + +#ifndef analogInputToDigitalPin + #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1) +#endif #define HAL_ANALOG_SELECT(pin) @@ -154,16 +140,16 @@ uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false); void HAL_enable_AdcFreerun(void); //void HAL_disable_AdcFreerun(uint8_t chan); -/** - * Pin Map - */ +// +// Pin Map +// #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -/** - * Tone - */ +// +// Tone +// void toneInit(); void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0); void noTone(const pin_t _pin); @@ -174,6 +160,12 @@ void noTone(const pin_t _pin); void HAL_idletask(void); void HAL_init(void); +// +// Utility functions +// +void _delay_ms(const int delay); +int freeMemory(void); + #ifdef __cplusplus extern "C" { #endif diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL.h b/Marlin/src/HAL/HAL_LPC1768/HAL.h index 5a90dafa6..1447b45d6 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL.h +++ b/Marlin/src/HAL/HAL_LPC1768/HAL.h @@ -64,10 +64,11 @@ extern "C" volatile uint32_t _millis; #include "../shared/HAL_SPI.h" #include "fastio.h" #include "watchdog.h" -#include "serial.h" #include "HAL_timers.h" -#include "HardwareSerial.h" +// +// Default graphical display delays +// #ifndef ST7920_DELAY_1 #define ST7920_DELAY_1 DELAY_NS(600) #endif @@ -78,6 +79,12 @@ extern "C" volatile uint32_t _millis; #define ST7920_DELAY_3 DELAY_NS(750) #endif +// +// Arduino-style serial ports +// +#include "serial.h" +#include "HardwareSerial.h" + extern HalSerial usb_serial; #if !WITHIN(SERIAL_PORT, -1, 3) @@ -126,24 +133,34 @@ extern HalSerial usb_serial; #define NUM_SERIAL 1 #endif +// +// Interrupts +// #define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq() #define CRITICAL_SECTION_END if (!primask) __enable_irq() #define ISRS_ENABLED() (!__get_PRIMASK()) #define ENABLE_ISRS() __enable_irq() #define DISABLE_ISRS() __disable_irq() -//Utility functions +// +// Utility functions +// int freeMemory(void); -// SPI: Extended functions which take a channel number (hardware SPI only) -/** Write single byte to specified SPI channel */ +// +// SPI: Extended functions taking a channel number (Hardware SPI only) +// + +// 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); +// // ADC +// #define HAL_ANALOG_SELECT(pin) HAL_adc_enable_channel(pin) #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) #define HAL_READ_ADC() HAL_adc_get_result() diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL.h b/Marlin/src/HAL/HAL_STM32F1/HAL.h index bf925c0a1..dcb9b260e 100644 --- a/Marlin/src/HAL/HAL_STM32F1/HAL.h +++ b/Marlin/src/HAL/HAL_STM32F1/HAL.h @@ -73,7 +73,7 @@ #error "SERIAL_PORT must be from -1 to 3" #endif #if SERIAL_PORT == -1 -extern USBSerial SerialUSB; + extern USBSerial SerialUSB; #define MYSERIAL0 SerialUSB #elif SERIAL_PORT == 0 #define MYSERIAL0 Serial @@ -93,7 +93,7 @@ extern USBSerial SerialUSB; #endif #define NUM_SERIAL 2 #if SERIAL_PORT_2 == -1 - extern USBSerial SerialUSB; + extern USBSerial SerialUSB; #define MYSERIAL1 SerialUSB #elif SERIAL_PORT_2 == 0 #define MYSERIAL1 Serial