Skip to content

Commit

Permalink
Apply #ifdef/#ifndef where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Sep 2, 2019
1 parent 4078f26 commit 34b7342
Show file tree
Hide file tree
Showing 32 changed files with 141 additions and 141 deletions.
6 changes: 3 additions & 3 deletions Marlin/src/HAL/HAL_DUE/usb/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@

/* Define NO_INIT attribute */
#if 0 //ndef NO_INIT
#if defined ( __CC_ARM )
#ifdef __CC_ARM
# define NO_INIT __attribute__((zero_init))
#elif defined ( __ICCARM__ )
# define NO_INIT __no_init
Expand Down Expand Up @@ -262,7 +262,7 @@
//! @{
typedef unsigned char Bool; //!< Boolean.
#ifndef __cplusplus
#if !defined(__bool_true_false_are_defined)
#ifndef __bool_true_false_are_defined
typedef unsigned char bool; //!< Boolean.
#endif
#endif
Expand Down Expand Up @@ -443,7 +443,7 @@ typedef struct
#define DISABLE 0
#define ENABLE 1
#ifndef __cplusplus
#if !defined(__bool_true_false_are_defined)
#ifndef __bool_true_false_are_defined
#define false 0
#define true 1
#endif
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/HAL/HAL_DUE/usb/osc.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,27 @@ extern "C" {
* Below BOARD_XXX macros are related to the specific board, and
* should be defined by the board code, otherwise default value are used.
*/
#if !defined(BOARD_FREQ_SLCK_XTAL)
#ifndef BOARD_FREQ_SLCK_XTAL
# warning The board slow clock xtal frequency has not been defined.
# define BOARD_FREQ_SLCK_XTAL (32768UL)
#endif

#if !defined(BOARD_FREQ_SLCK_BYPASS)
#ifndef BOARD_FREQ_SLCK_BYPASS
# warning The board slow clock bypass frequency has not been defined.
# define BOARD_FREQ_SLCK_BYPASS (32768UL)
#endif

#if !defined(BOARD_FREQ_MAINCK_XTAL)
#ifndef BOARD_FREQ_MAINCK_XTAL
# warning The board main clock xtal frequency has not been defined.
# define BOARD_FREQ_MAINCK_XTAL (12000000UL)
#endif

#if !defined(BOARD_FREQ_MAINCK_BYPASS)
#ifndef BOARD_FREQ_MAINCK_BYPASS
# warning The board main clock bypass frequency has not been defined.
# define BOARD_FREQ_MAINCK_BYPASS (12000000UL)
#endif

#if !defined(BOARD_OSC_STARTUP_US)
#ifndef BOARD_OSC_STARTUP_US
# warning The board main clock xtal startup time has not been defined.
# define BOARD_OSC_STARTUP_US (15625UL)
#endif
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/HAL_DUE/usb/spc_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
* \asf_license_stop
*
*/

/*
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
*/
#ifndef _SPC_PROTOCOL_H_
#define _SPC_PROTOCOL_H_

#ifndef _SPC_PROTOCOL_H_
#define _SPC_PROTOCOL_H_

/**
* \ingroup usb_msc_protocol
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_DUE/usb/udi_cdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#include "udi.h"

// Check the number of port
#ifndef UDI_CDC_PORT_NB
#ifndef UDI_CDC_PORT_NB
# define UDI_CDC_PORT_NB 1
#endif
#if (UDI_CDC_PORT_NB < 1) || (UDI_CDC_PORT_NB > 7)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_DUE/usb/udi_cdc_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include "usb_protocol_cdc.h"
#include "conf_usb.h"

#ifndef UDI_CDC_PORT_NB
#ifndef UDI_CDC_PORT_NB
# define UDI_CDC_PORT_NB 1
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_STM32F1/SPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#define SPI_2XCLOCK_MASK 0x01 // SPI2X = bit 0 on SPSR
// define SPI_AVR_EIMSK for AVR boards with external interrupt pins
#if defined(EIMSK)
#ifdef EIMSK
#define SPI_AVR_EIMSK EIMSK
#elif defined(GICR)
#define SPI_AVR_EIMSK GICR
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
* Switching Toolhead requirements
*/
#if ENABLED(SWITCHING_TOOLHEAD)
#if !defined(SWITCHING_TOOLHEAD_SERVO_NR)
#ifndef SWITCHING_TOOLHEAD_SERVO_NR
#error "SWITCHING_TOOLHEAD requires SWITCHING_TOOLHEAD_SERVO_NR."
#elif EXTRUDERS < 2
#error "SWITCHING_TOOLHEAD requires at least 2 EXTRUDERS."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "../compat.h"

#if !defined(__MARLIN_FIRMWARE__)
#ifndef __MARLIN_FIRMWARE__
#define FTDI_BASIC
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/********************************* SPI Functions *********************************/

namespace FTDI {
#if !defined(CLCD_USE_SOFT_SPI)
#ifndef CLCD_USE_SOFT_SPI
SPISettings SPI::spi_settings(SPI_FREQUENCY, MSBFIRST, SPI_MODE0);
#endif

Expand Down Expand Up @@ -108,7 +108,7 @@ namespace FTDI {

void SPI::spi_read_bulk (void *data, uint16_t len) {
uint8_t* p = (uint8_t *)data;
#if !defined(CLCD_USE_SOFT_SPI)
#ifndef CLCD_USE_SOFT_SPI
::SPI.transfer(p, len);
#else
while (len--) *p++ = spi_recv();
Expand All @@ -123,7 +123,7 @@ namespace FTDI {

// CLCD SPI - Chip Select
void SPI::spi_ftdi_select (void) {
#if !defined(CLCD_USE_SOFT_SPI)
#ifndef CLCD_USE_SOFT_SPI
::SPI.beginTransaction(spi_settings);
#endif
WRITE(CLCD_SPI_CS, 0);
Expand All @@ -133,15 +133,15 @@ namespace FTDI {
// CLCD SPI - Chip Deselect
void SPI::spi_ftdi_deselect (void) {
WRITE(CLCD_SPI_CS, 1);
#if !defined(CLCD_USE_SOFT_SPI)
#ifndef CLCD_USE_SOFT_SPI
::SPI.endTransaction();
#endif
}

#ifdef SPI_FLASH_SS
// Serial SPI Flash SPI - Chip Select
void SPI::spi_flash_select () {
#if !defined(CLCD_USE_SOFT_SPI)
#ifndef CLCD_USE_SOFT_SPI
::SPI.beginTransaction(spi_settings);
#endif
WRITE(SPI_FLASH_SS, 0);
Expand All @@ -151,7 +151,7 @@ namespace FTDI {
// Serial SPI Flash SPI - Chip Deselect
void SPI::spi_flash_deselect () {
WRITE(SPI_FLASH_SS, 1);
#if !defined(CLCD_USE_SOFT_SPI)
#ifndef CLCD_USE_SOFT_SPI
::SPI.endTransaction();
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

#pragma once

#if !defined(CLCD_USE_SOFT_SPI)
#ifndef CLCD_USE_SOFT_SPI
#include <SPI.h>
#endif

namespace FTDI {
namespace SPI {
#if !defined(CLCD_USE_SOFT_SPI)
#ifndef CLCD_USE_SOFT_SPI
extern SPISettings spi_settings;
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include <Arduino.h>

#if !defined(CLCD_USE_SOFT_SPI)
#ifndef CLCD_USE_SOFT_SPI
#include <SPI.h>
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "../compat.h"
#include "../basic/ftdi_basic.h"

#if !defined(__MARLIN_FIRMWARE__)
#ifndef __MARLIN_FIRMWARE__
#define FTDI_EXTENDED
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/screens.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class SpinnerDialogBox : public DialogBoxBaseClass, public CachedScreen<SPINNER_
static void enqueueAndWait_P(const progmem_str message, const progmem_str commands);
};

#if !defined(LULZBOT_USE_BIOPRINTER_UI)
#ifndef LULZBOT_USE_BIOPRINTER_UI
class StatusScreen : public BaseScreen, public CachedScreen<STATUS_SCREEN_CACHE,STATUS_SCREEN_DL_SIZE> {
private:
static void draw_axis_position(draw_mode_t);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
// P2_08 E1-Step
// P2_13 E1-Dir

#ifndef X_SERIAL_TX_PIN
#ifndef X_SERIAL_TX_PIN
#define X_SERIAL_TX_PIN P0_01
#endif
#ifndef X_SERIAL_RX_PIN
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Z-Bolt X Series board – based on Arduino Mega2560
*/

#if !defined(__AVR_ATmega2560__)
#ifndef __AVR_ATmega2560__
#error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'"
#elif HOTENDS > 4 || E_STEPPERS > 4
#error "Z-Bolt X Series board supports up to 4 hotends / E-steppers."
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/sd/usb_flashdrive/lib-uhs2/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
// define XMEM_ACQUIRE_SPI and XMEM_RELEASE_SPI to point to your lock and unlock.
// NOTE: NO argument is passed. You have to do this within your routine for
// whatever you are using to lock and unlock.
#if !defined(XMEM_ACQUIRE_SPI)
#ifndef XMEM_ACQUIRE_SPI
#if USE_XMEM_SPI_LOCK || defined(USE_MULTIPLE_APP_API)
#include <xmem.h>
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Web : http://www.circuitsathome.com
e-mail : [email protected]
*/

#if !defined(__UHS_BULK_STORAGE_H__)
#ifndef __UHS_BULK_STORAGE_H__
#define __UHS_BULK_STORAGE_H__


Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_UsbCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ e-mail : [email protected]
#define UHS_HOST_MAX_INTERFACE_DRIVERS 0x10U // Default maximum number of USB interface drivers
#endif

#if !defined(SYSTEM_OR_SPECIAL_YIELD)
#ifndef SYSTEM_OR_SPECIAL_YIELD
#define SYSTEM_OR_SPECIAL_YIELD(...) VOID0
#endif

#if !defined(SYSTEM_OR_SPECIAL_YIELD_FROM_ISR)
#ifndef SYSTEM_OR_SPECIAL_YIELD_FROM_ISR
#define SYSTEM_OR_SPECIAL_YIELD_FROM_ISR(...) SYSTEM_OR_SPECIAL_YIELD
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class AddressPool {
}
thePool[index].address = addr;
#if DEBUG_PRINTF_EXTRA_HUGE
#if defined(UHS_DEBUG_USB_ADDRESS)
#ifdef UHS_DEBUG_USB_ADDRESS
printf("Address: %x (%x.%x.%x)\r\n", addr.devAddress, addr.bmHub, addr.bmParent, addr.bmAddress);
#endif
#endif
Expand Down
16 changes: 8 additions & 8 deletions Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ e-mail : [email protected]
#include "UHS_host_INLINE.h"
#include "UHS_printf_HELPER.h"

#if defined(LOAD_USB_HOST_SHIELD)
#ifdef LOAD_USB_HOST_SHIELD
#include "USB_HOST_SHIELD/USB_HOST_SHIELD.h"
#endif

Expand All @@ -72,24 +72,24 @@ e-mail : [email protected]

// Load USB drivers and multiplexers

#if defined(LOAD_UHS_HUB)
#ifdef LOAD_UHS_HUB
#include "UHS_HUB/UHS_HUB.h"
#endif // HUB loaded

#if defined(LOAD_UHS_BULK_STORAGE)
#ifdef LOAD_UHS_BULK_STORAGE
#include "UHS_BULK_STORAGE/UHS_BULK_STORAGE.h"
#endif

#if defined(LOAD_GENERIC_STORAGE)
#ifdef LOAD_GENERIC_STORAGE
#include "../UHS_FS/UHS_FS.h"
#endif
// Add BT and optionally HID if directed to do so
#if defined(LOAD_UHS_BT)
#ifdef LOAD_UHS_BT
#include "UHS_BT/UHS_BT.h"
#endif // BT and optionally HID loaded

// Add HID
#if defined(LOAD_UHS_HID)
#ifdef LOAD_UHS_HID
#include "UHS_HID/UHS_HID.h"
#endif // HID loaded

Expand All @@ -98,11 +98,11 @@ e-mail : [email protected]
#include "UHS_CDC/UHS_CDC.h"
#endif // CDC loaded

#if defined(LOAD_UHS_ADK)
#ifdef LOAD_UHS_ADK
#include "UHS_ADK/UHS_ADK.h"
#endif

#if defined(LOAD_UHS_MIDI)
#ifdef LOAD_UHS_MIDI
#include "UHS_MIDI/UHS_MIDI.h"
#endif

Expand Down
20 changes: 10 additions & 10 deletions Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Web : http://www.circuitsathome.com
e-mail : [email protected]
*/

#if !defined(MACROS_H)
#ifndef MACROS_H
#define MACROS_H
#include "macro_logic.h"
/*
Expand All @@ -49,18 +49,18 @@ e-mail : [email protected]

// Nuke screwed up macro junk from the IDE.
#ifdef __cplusplus
#if defined(true)
#ifdef true
#undef true
#endif
#if defined(false)
#ifdef false
#undef false
#endif
#endif


#if !defined(UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE)
#ifndef UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE

#if !defined(UHS_BIG_FLASH)
#ifndef UHS_BIG_FLASH

#if defined(FLASHEND) && defined(FLASHSTART)
#if (FLASHEND - FLASHSTART) > 0x0FFFFU
Expand Down Expand Up @@ -122,10 +122,10 @@ e-mail : [email protected]
// TODO: Fast inline code for AVR and SAM based microcontrollers
// This can be done pretty easily.
// For now, this will just work out-of-the-box.
#if !defined(UHS_PIN_WRITE)
#ifndef UHS_PIN_WRITE
#define UHS_PIN_WRITE(p, v) digitalWrite(p, v)
#endif
#if !defined(UHS_PIN_READ)
#ifndef UHS_PIN_READ
#define UHS_PIN_READ(p) digitalRead(p)
#endif

Expand All @@ -134,8 +134,8 @@ e-mail : [email protected]
#edfine noInterrupts() __builtin_disable_interrupts()
#endif

#if !defined(ARDUINO_SAMD_ZERO)
#if defined(ARDUINO_AVR_ADK)
#ifndef ARDUINO_SAMD_ZERO
#ifdef ARDUINO_AVR_ADK
#define UHS_GET_DPI(x) (x == 54 ? 6 : digitalPinToInterrupt(x))
#else
#define UHS_GET_DPI(x) digitalPinToInterrupt(x)
Expand Down Expand Up @@ -386,7 +386,7 @@ e-mail : [email protected]
#define USBTRACE2X(s,r) (USBTRACE3X((s),(r),0x80)); USB_HOST_SERIAL.flush()

#define VOID0 ((void)0)
#if !defined(NOTUSED)
#ifndef NOTUSED
#define NOTUSED(...) __VA_ARGS__ __attribute__((unused))
#endif
#endif /* MACROS_H */
Expand Down
Loading

0 comments on commit 34b7342

Please sign in to comment.