Apply #ifdef/#ifndef where possible

This commit is contained in:
Scott Lahteine 2019-09-01 23:54:41 -05:00
parent 4078f2672e
commit 34b73426e5
32 changed files with 141 additions and 141 deletions

View file

@ -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
@ -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
@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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."

View file

@ -24,7 +24,7 @@
#include "../compat.h"
#if !defined(__MARLIN_FIRMWARE__)
#ifndef __MARLIN_FIRMWARE__
#define FTDI_BASIC
#endif

View file

@ -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
@ -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();
@ -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);
@ -133,7 +133,7 @@ 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
}
@ -141,7 +141,7 @@ namespace FTDI {
#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);
@ -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
}

View file

@ -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

View file

@ -31,7 +31,7 @@
#include <Arduino.h>
#if !defined(CLCD_USE_SOFT_SPI)
#ifndef CLCD_USE_SOFT_SPI
#include <SPI.h>
#endif

View file

@ -25,7 +25,7 @@
#include "../compat.h"
#include "../basic/ftdi_basic.h"
#if !defined(__MARLIN_FIRMWARE__)
#ifndef __MARLIN_FIRMWARE__
#define FTDI_EXTENDED
#endif

View file

@ -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);

View file

@ -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

View file

@ -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."

View file

@ -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

View file

@ -24,7 +24,7 @@ Web : http://www.circuitsathome.com
e-mail : support@circuitsathome.com
*/
#if !defined(__UHS_BULK_STORAGE_H__)
#ifndef __UHS_BULK_STORAGE_H__
#define __UHS_BULK_STORAGE_H__

View file

@ -33,11 +33,11 @@ e-mail : support@circuitsathome.com
#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

View file

@ -226,7 +226,7 @@ public:
}
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

View file

@ -58,7 +58,7 @@ e-mail : support@circuitsathome.com
#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
@ -72,24 +72,24 @@ e-mail : support@circuitsathome.com
// 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
@ -98,11 +98,11 @@ e-mail : support@circuitsathome.com
#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

View file

@ -24,7 +24,7 @@ Web : http://www.circuitsathome.com
e-mail : support@circuitsathome.com
*/
#if !defined(MACROS_H)
#ifndef MACROS_H
#define MACROS_H
#include "macro_logic.h"
/*
@ -49,18 +49,18 @@ e-mail : support@circuitsathome.com
// 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
@ -122,10 +122,10 @@ e-mail : support@circuitsathome.com
// 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
@ -134,8 +134,8 @@ e-mail : support@circuitsathome.com
#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)
@ -386,7 +386,7 @@ e-mail : support@circuitsathome.com
#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 */

View file

@ -27,7 +27,7 @@ e-mail : support@circuitsathome.com
#ifndef UHS_PRINTF_HELPER_H
#define UHS_PRINTF_HELPER_H
#if defined(LOAD_UHS_PRINTF_HELPER)
#ifdef LOAD_UHS_PRINTF_HELPER
#include <Arduino.h>
#ifdef true
#undef true
@ -36,14 +36,14 @@ e-mail : support@circuitsathome.com
#undef false
#endif
#if !defined(STDIO_IS_OK_TO_USE_AS_IS)
#ifndef STDIO_IS_OK_TO_USE_AS_IS
#if defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAM_DUE) || defined(ARDUINO_spresense_ast)
// STDIO patching not required.
#define STDIO_IS_OK_TO_USE_AS_IS
#endif
#endif
#if !defined(STDIO_IS_OK_TO_USE_AS_IS)
#ifndef STDIO_IS_OK_TO_USE_AS_IS
// We need to patch STDIO so it can be used.
#ifndef SERIAL_PORT_MONITOR
@ -64,7 +64,7 @@ e-mail : support@circuitsathome.com
#endif
#endif
#if !defined(NOTUSED)
#ifndef NOTUSED
#define NOTUSED(...) __VA_ARGS__ __attribute__((unused))
#endif
@ -74,7 +74,7 @@ e-mail : support@circuitsathome.com
#endif
#endif
#if defined(ARDUINO_ARCH_PIC32)
#ifdef ARDUINO_ARCH_PIC32
/*
* For printf() output with pic32 Arduino
*/
@ -169,7 +169,7 @@ extern "C" {
#if defined(__AVR__)
#ifdef __AVR__
// The only wierdo in the bunch...
void UHS_AVR_printf_HELPER_init(void) {
// Set up stdio/stderr
@ -194,7 +194,7 @@ void UHS_AVR_printf_HELPER_init(void) {
#endif /* STDIO_IS_OK_TO_USE_AS_IS */
#endif /* load.... */
#if !defined(UHS_printf_HELPER_init)
#ifndef UHS_printf_HELPER_init
#define UHS_printf_HELPER_init() (void(0))
#endif
#endif /* UHS_PRINTF_HELPER_H */

View file

@ -24,19 +24,19 @@ Web : http://www.circuitsathome.com
e-mail : support@circuitsathome.com
*/
#if !defined(_UHS_host_h_)
#ifndef _UHS_host_h_
#error "Never include UHS_usbhost.h directly; include UHS_host.h instead"
#else
#if !defined(_USBHOST_H_)
#ifndef _USBHOST_H_
#define _USBHOST_H_
// Very early prototypes
#if defined(UHS_LOAD_BT)
#ifdef UHS_LOAD_BT
void UHS_BT_SetUSBInterface(UHS_USB_HOST_BASE *host, ENUMERATION_INFO *ei);
void UHS_BT_ScanUninitialized(UHS_USB_HOST_BASE *host);
void UHS_BT_Poll(UHS_USB_HOST_BASE *host);
#endif
#if defined(UHS_LOAD_HID)
#ifdef UHS_LOAD_HID
void UHS_HID_SetUSBInterface(UHS_USB_HOST_BASE *host, ENUMERATION_INFO *ei);
void UHS_HID_ScanUninitialized(UHS_USB_HOST_BASE *host);
void UHS_HID_Poll(UHS_USB_HOST_BASE *host);
@ -185,10 +185,10 @@ public:
/////////////////////////////////////////////
// these two probably will go away, and won't be used, TBD
inline void Poll_Others(void) {
#if defined(UHS_LOAD_BT)
#ifdef UHS_LOAD_BT
UHS_BT_Poll(this);
#endif
#if defined(UHS_LOAD_HID)
#ifdef UHS_LOAD_HID
UHS_HID_Poll(this);
#endif
}

View file

@ -28,10 +28,10 @@ e-mail : support@circuitsathome.com
#include <SPI.h>
#if !defined(SPI_HAS_TRANSACTION)
#ifndef SPI_HAS_TRANSACTION
#error "Your SPI library installation is too old."
#else
#if !defined(SPI_ATOMIC_VERSION)
#ifndef SPI_ATOMIC_VERSION
#warning "Your SPI library installation lacks 'SPI_ATOMIC_VERSION'. Please complain to the maintainer."
#elif SPI_ATOMIC_VERSION < 1
#error "Your SPI library installation is too old."
@ -48,8 +48,8 @@ e-mail : support@circuitsathome.com
#define MAX_HOST_DEBUG(...) VOID0
#endif
#if !defined(USB_HOST_SHIELD_USE_ISR)
#if defined(USE_MULTIPLE_APP_API)
#ifndef USB_HOST_SHIELD_USE_ISR
#ifdef USE_MULTIPLE_APP_API
#define USB_HOST_SHIELD_USE_ISR 0
#else
#define USB_HOST_SHIELD_USE_ISR 1
@ -66,7 +66,7 @@ e-mail : support@circuitsathome.com
//
// Polled defaults
//
#if defined(BOARD_BLACK_WIDDOW)
#ifdef BOARD_BLACK_WIDDOW
#define UHS_MAX3421E_SS_ 6
#define UHS_MAX3421E_INT_ 3
#elif defined(CORE_TEENSY) && (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__))
@ -91,7 +91,7 @@ e-mail : support@circuitsathome.com
#endif
#else
#if defined(ARDUINO_ARCH_PIC32)
#ifdef ARDUINO_ARCH_PIC32
// PIC32 only allows edge interrupts, isn't that lovely? We'll emulate it...
#if CHANGE < 2
#error core too old.
@ -113,8 +113,8 @@ e-mail : support@circuitsathome.com
#endif
// More stupidity from our friends @ Sony...
#if defined(ARDUINO_spresense_ast)
#if !defined(NOT_AN_INTERRUPT)
#ifdef ARDUINO_spresense_ast
#ifndef NOT_AN_INTERRUPT
#define NOT_AN_INTERRUPT -1
#endif
#endif
@ -158,7 +158,7 @@ e-mail : support@circuitsathome.com
#else
#define UHS_MAX3421E_SS_ 10
#ifdef __AVR__
#if defined(__AVR_ATmega32U4__)
#ifdef __AVR_ATmega32U4__
#define INT_FOR_PIN2 1
#define INT_FOR_PIN3 0
#else
@ -169,7 +169,7 @@ e-mail : support@circuitsathome.com
#define UHS_MAX3421E_INT_ 3
#else
// Non-avr
#if defined(ARDUINO_ARCH_PIC32)
#ifdef ARDUINO_ARCH_PIC32
// UNO32 External Interrupts:
// Pin 38 (INT0), Pin 2 (INT1), Pin 7 (INT2), Pin 8 (INT3), Pin 35 (INT4)
#define UHS_MAX3421E_INT_ 7
@ -182,7 +182,7 @@ e-mail : support@circuitsathome.com
#if defined(NO_AUTO_SPEED)
#ifdef NO_AUTO_SPEED
// Ugly details section...
// MAX3421E characteristics
// SPI Serial - Clock Input. An external SPI master supplies SCLK with frequencies up to 26MHz. The
@ -195,8 +195,8 @@ e-mail : support@circuitsathome.com
// Theoretical deadline for reply 17.7ns
// 26MHz 38.4615ns period <-- MAX3421E theoretical maximum
#if !defined(UHS_MAX3421E_SPD)
#if defined(ARDUINO_SAMD_ZERO)
#ifndef UHS_MAX3421E_SPD
#ifdef ARDUINO_SAMD_ZERO
// Zero violates spec early, needs a long setup time, or doesn't like high latency.
#define UHS_MAX3421E_SPD 10000000
#elif defined(ARDUINO_ARCH_PIC32)
@ -225,7 +225,7 @@ e-mail : support@circuitsathome.com
// Why not 26MHz? Because I have not found any MCU board that
// can actually go that fast without problems.
// Could be a shield limitation too.
#if !defined(UHS_MAX3421E_SPD)
#ifndef UHS_MAX3421E_SPD
#define UHS_MAX3421E_SPD 25000000
#endif
#endif
@ -271,7 +271,7 @@ e-mail : support@circuitsathome.com
// |______| |______| |______| |______________|
//
#define IRQ_SENSE FALLING
#if defined(ARDUINO_ARCH_PIC32)
#ifdef ARDUINO_ARCH_PIC32
//#define bmPULSEWIDTH PUSLEWIDTH10_6
#define bmPULSEWIDTH 0
#define bmIRQ_SENSE 0
@ -280,20 +280,20 @@ e-mail : support@circuitsathome.com
#define bmIRQ_SENSE 0
#endif
#else
#if !defined(IRQ_SENSE)
#ifndef IRQ_SENSE
#define IRQ_SENSE LOW
#endif
#if !defined(bmPULSEWIDTH)
#ifndef bmPULSEWIDTH
#define bmPULSEWIDTH 0
#endif
#if !defined(bmIRQ_SENSE)
#ifndef bmIRQ_SENSE
#define bmIRQ_SENSE bmINTLEVEL
#endif
#endif
class MAX3421E_HOST :
public UHS_USB_HOST_BASE
#if defined(SWI_IRQ_NUM)
#ifdef SWI_IRQ_NUM
, public dyn_SWI
#endif
{
@ -487,7 +487,7 @@ public:
uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p);
// ARM/NVIC specific, used to emulate reentrant ISR.
#if defined(SWI_IRQ_NUM)
#ifdef SWI_IRQ_NUM
void dyn_SWISR(void) {
ISRbottom();
@ -498,7 +498,7 @@ public:
// Used on MCU that lack control of IRQ priority (AVR).
// Suspends ISRs, for critical code. IRQ will be serviced after it is resumed.
// NOTE: you must track the state yourself!
#if defined(__AVR__)
#ifdef __AVR__
noInterrupts();
detachInterrupt(UHS_GET_DPI(irq_pin));
interrupts();
@ -507,10 +507,10 @@ public:
virtual void UHS_NI resume_host(void);
};
#if !defined(SPIclass)
#ifndef SPIclass
#define SPIclass SPI
#endif
#if !defined(USB_HOST_SHIELD_LOADED)
#ifndef USB_HOST_SHIELD_LOADED
#include "USB_HOST_SHIELD_INLINE.h"
#endif
#else

View file

@ -21,7 +21,7 @@ e-mail : support@circuitsathome.com
#define USB_HOST_SHIELD_LOADED
#include <Arduino.h>
#if !defined(digitalPinToInterrupt)
#ifndef digitalPinToInterrupt
#error digitalPinToInterrupt not defined, complain to your board maintainer.
#endif
@ -49,7 +49,7 @@ void UHS_NI MAX3421E_HOST::resume_host(void) {
// Used on MCU that lack control of IRQ priority (AVR).
// Resumes ISRs.
// NOTE: you must track the state yourself!
#if defined(__AVR__)
#ifdef __AVR__
noInterrupts();
if(irq_pin & 1) {
ISRodd = this;
@ -314,7 +314,7 @@ int16_t UHS_NI MAX3421E_HOST::Init(int16_t mseconds) {
#if USB_HOST_SHIELD_USE_ISR
int intr = digitalPinToInterrupt(irq_pin);
if(intr == NOT_AN_INTERRUPT) {
#if defined(ARDUINO_AVR_ADK)
#ifdef ARDUINO_AVR_ADK
if(irq_pin == 54)
intr = 6;
else
@ -325,7 +325,7 @@ int16_t UHS_NI MAX3421E_HOST::Init(int16_t mseconds) {
#else
SPIclass.usingInterrupt(255);
#endif
#if !defined(NO_AUTO_SPEED)
#ifndef NO_AUTO_SPEED
// test to get to reset acceptance.
uint32_t spd = UHS_MAX3421E_SPD;
again:
@ -901,7 +901,7 @@ void UHS_NI MAX3421E_HOST::ISRTask(void)
{
DDSB();
#if !defined(SWI_IRQ_NUM)
#ifndef SWI_IRQ_NUM
suspend_host();
#if USB_HOST_SHIELD_USE_ISR
// Enable interrupts
@ -965,7 +965,7 @@ void UHS_NI MAX3421E_HOST::ISRTask(void)
// usb_task_polling_disabled? "T" : "F");
DDSB();
regWr(rHIRQ, HIRQ_sendback);
#if !defined(SWI_IRQ_NUM)
#ifndef SWI_IRQ_NUM
resume_host();
#if USB_HOST_SHIELD_USE_ISR
// Disable interrupts
@ -981,7 +981,7 @@ void UHS_NI MAX3421E_HOST::ISRTask(void)
UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, HIGH);
#endif
#if defined(SWI_IRQ_NUM)
#ifdef SWI_IRQ_NUM
// MAX_HOST_DEBUG(PSTR("--------------- Doing SWI ----------------"));
exec_SWI(this);
#else

View file

@ -139,7 +139,7 @@ AJK_IIF(AJK_BITAND(AJK_IS_COMPARABLE(x))(AJK_IS_COMPARABLE(y)) ) \
#define AJK_FUN(AJK_count, AJK_v, AJK_args, AJK_body) AJK_v ## AJK_count (AJK_args) { AJK_body(AJK_count) }
#define AJK_MAKE_FUNS(AJK_v, AJK_args, AJK_count, AJK_body) AJK_EVAL(AJK_REPEAT(AJK_count, AJK_FUN, AJK_v, AJK_args, AJK_body))
#if defined(AJK_TEST_MACRO_LOGIC)
#ifdef AJK_TEST_MACRO_LOGIC
#define BODY(AJKindex) some(C, statement); contaning(a, test[AJKindex]);
#define ZERO_TIMES_TEST 0

View file

@ -35,8 +35,8 @@
static char dyn_SWI_initied = 0;
static dyn_SWI* dyn_SWI_LIST[SWI_MAXIMUM_ALLOWED];
static dyn_SWI* dyn_SWI_EXEC[SWI_MAXIMUM_ALLOWED];
#if defined(__arm__)
#if defined(__USE_CMSIS_VECTORS__)
#ifdef __arm__
#ifdef __USE_CMSIS_VECTORS__
extern "C" {
void (*_VectorsRam[VECTORTABLE_SIZE])(void)__attribute__((aligned(VECTORTABLE_ALIGNMENT)));
}
@ -55,20 +55,20 @@ __attribute__((always_inline)) static inline void __DSB(void) {
/**
* Execute queued class ISR routines.
*/
#if defined(ARDUINO_ARCH_PIC32)
#ifdef ARDUINO_ARCH_PIC32
static p32_regset *ifs = ((p32_regset *) & IFS0) + (SWI_IRQ_NUM / 32); //interrupt flag register set
static p32_regset *iec = ((p32_regset *) & IEC0) + (SWI_IRQ_NUM / 32); //interrupt enable control reg set
static uint32_t swibit = 1 << (SWI_IRQ_NUM % 32);
void
#if defined(__PIC32MZXX__)
#ifdef __PIC32MZXX__
__attribute__((nomips16,at_vector(SWI_VECTOR),interrupt(SWI_IPL)))
#else
__attribute__((interrupt(),nomips16))
#endif
softISR(void) {
#else
#if defined(ARDUINO_spresense_ast)
#ifdef ARDUINO_spresense_ast
unsigned int softISR(void) {
#else
void softISR(void) {
@ -82,7 +82,7 @@ void softISR(void) {
// Make a working copy, while clearing the queue.
noInterrupts();
#if defined(ARDUINO_ARCH_PIC32)
#ifdef ARDUINO_ARCH_PIC32
//ifs->clr = swibit;
#endif
for(int i = 0; i < SWI_MAXIMUM_ALLOWED; i++) {
@ -95,21 +95,21 @@ void softISR(void) {
// Execute each class SWI
for(int i = 0; i < SWI_MAXIMUM_ALLOWED; i++) {
if(dyn_SWI_EXEC[i]) {
#if defined(__DYN_SWI_DEBUG_LED__)
#ifdef __DYN_SWI_DEBUG_LED__
digitalWrite(__DYN_SWI_DEBUG_LED__, HIGH);
#endif
dyn_SWI_EXEC[i]->dyn_SWISR();
#if defined(__DYN_SWI_DEBUG_LED__)
#ifdef __DYN_SWI_DEBUG_LED__
digitalWrite(__DYN_SWI_DEBUG_LED__, LOW);
#endif
}
}
#if defined(ARDUINO_ARCH_PIC32)
#ifdef ARDUINO_ARCH_PIC32
noInterrupts();
if(!dyn_SWI_EXEC[0]) ifs->clr = swibit;
interrupts();
#endif
#if defined(ARDUINO_spresense_ast)
#ifdef ARDUINO_spresense_ast
return 0;
#endif
}
@ -118,7 +118,7 @@ void softISR(void) {
#endif
#if defined(__arm__)
#ifdef __arm__
#ifndef interruptsStatus
#define interruptsStatus() __interruptsStatus()
static inline unsigned char __interruptsStatus(void) __attribute__((always_inline, unused));
@ -136,7 +136,7 @@ static inline unsigned char __interruptsStatus(void) {
*/
static void Init_dyn_SWI(void) {
if(!dyn_SWI_initied) {
#if defined(__USE_CMSIS_VECTORS__)
#ifdef __USE_CMSIS_VECTORS__
uint32_t *X_Vectors = (uint32_t*)SCB->VTOR;
for(int i = 0; i < VECTORTABLE_SIZE; i++) {
_VectorsRam[i] = reinterpret_cast<void (*)()>(X_Vectors[i]); /* copy vector table to RAM */
@ -147,7 +147,7 @@ static void Init_dyn_SWI(void) {
DDSB();
interrupts();
#endif
#if !defined(ARDUINO_spresense_ast)
#ifndef ARDUINO_spresense_ast
for(int i = 0; i < SWI_MAXIMUM_ALLOWED; i++) dyn_SWI_LIST[i] = NULL;
noInterrupts();
_VectorsRam[SWI_IRQ_NUM + 16] = reinterpret_cast<void (*)()>(softISR);
@ -156,7 +156,7 @@ static void Init_dyn_SWI(void) {
NVIC_SET_PRIORITY(SWI_IRQ_NUM, 255);
NVIC_ENABLE_IRQ(SWI_IRQ_NUM);
#endif
#if defined(__DYN_SWI_DEBUG_LED__)
#ifdef __DYN_SWI_DEBUG_LED__
pinMode(__DYN_SWI_DEBUG_LED__, OUTPUT);
digitalWrite(__DYN_SWI_DEBUG_LED__, LOW);
#endif
@ -180,7 +180,7 @@ int exec_SWI(const dyn_SWI* klass) {
if(!dyn_SWI_LIST[i]) {
rc = 1 + i; // Success!
dyn_SWI_LIST[i] = (dyn_SWI*)klass;
#if !defined(ARDUINO_spresense_ast)
#ifndef ARDUINO_spresense_ast
if(!NVIC_GET_PENDING(SWI_IRQ_NUM)) NVIC_SET_PENDING(SWI_IRQ_NUM);
#else
// Launch 1-shot timer as an emulated SWI
@ -211,7 +211,7 @@ static void Init_dyn_SWI(void) {
iec->clr = swibit;
iec->set = swibit;
restoreInterrupts(sreg);
#if defined(__DYN_SWI_DEBUG_LED__)
#ifdef __DYN_SWI_DEBUG_LED__
pinMode(__DYN_SWI_DEBUG_LED__, OUTPUT);
UHS_PIN_WRITE(__DYN_SWI_DEBUG_LED__, LOW);
#endif

View file

@ -24,26 +24,26 @@
#if defined(__arm__) || defined(ARDUINO_ARCH_PIC32)
#if defined(ARDUINO_ARCH_PIC32)
#ifdef ARDUINO_ARCH_PIC32
#include <p32xxxx.h>
#endif
#ifdef __cplusplus
#if defined(true)
#ifdef true
#undef true
#endif
#if defined(false)
#ifdef false
#undef false
#endif
#endif
#if defined(ARDUINO_spresense_ast)
#ifdef ARDUINO_spresense_ast
#define SWI_IRQ_NUM 666 // because this board is totally evil.
#elif defined(ARDUINO_ARCH_PIC32)
#ifndef SWI_IRQ_NUM
#if defined(_DSPI0_IPL_ISR)
#ifdef _DSPI0_IPL_ISR
#define SWI_IPL _DSPI0_IPL_ISR
#define SWI_VECTOR _DSPI0_ERR_IRQ
#define SWI_IRQ_NUM _DSPI0_ERR_IRQ
@ -57,7 +57,7 @@
extern "C"
{
void
#if defined(__PIC32MZXX__)
#ifdef __PIC32MZXX__
__attribute__((nomips16,at_vector(SWI_VECTOR),interrupt(SWI_IPL)))
#else
__attribute__((interrupt(),nomips16))
@ -69,7 +69,7 @@ extern "C"
#elif !defined(NVIC_NUM_INTERRUPTS)
// Assume CMSIS
#define __USE_CMSIS_VECTORS__
#if defined(NUMBER_OF_INT_VECTORS)
#ifdef NUMBER_OF_INT_VECTORS
#define NVIC_NUM_INTERRUPTS (NUMBER_OF_INT_VECTORS-16)
#else
#define NVIC_NUM_INTERRUPTS ((int)PERIPH_COUNT_IRQn)
@ -114,7 +114,7 @@ extern "C"
#ifndef NVIC_GET_PENDING
#define NVIC_GET_PENDING(n) (*((volatile uint32_t *)0xE000E200 + ((n) >> 5)) & (1 << ((n) & 31)))
#ifndef SWI_IRQ_NUM
#if defined(__MK20DX256__)
#ifdef __MK20DX256__
#define SWI_IRQ_NUM 17
#elif defined(__MK20DX128__)
#define SWI_IRQ_NUM 5
@ -165,7 +165,7 @@ extern int exec_SWI(const dyn_SWI* klass);
// if no SWI for CPU (e.g. AVR) make a void stub.
#ifndef SWI_NO_STUB
#define Init_dyn_SWI() (void(0))
#if !defined(DDSB)
#ifndef DDSB
#define DDSB() (void(0))
#endif
#endif

View file

@ -87,11 +87,11 @@ extern "C" {
* This value is used by the RCC HAL module to compute the system frequency
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
#ifndef HSE_VALUE
#define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSE_STARTUP_TIMEOUT)
#ifndef HSE_STARTUP_TIMEOUT
#define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */
@ -100,14 +100,14 @@ extern "C" {
* This value is used by the RCC HAL module to compute the system frequency
* (when HSI is used as system clock source, directly or through the PLL).
*/
#if !defined (HSI_VALUE)
#ifndef HSI_VALUE
#define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */
/**
* @brief Internal Low Speed oscillator (LSI) value.
*/
#if !defined (LSI_VALUE)
#ifndef LSI_VALUE
#define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
The real value may vary depending on the variations
@ -115,11 +115,11 @@ in voltage and temperature.*/
/**
* @brief External Low Speed oscillator (LSE) value.
*/
#if !defined (LSE_VALUE)
#ifndef LSE_VALUE
#define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
#endif /* LSE_VALUE */
#if !defined (LSE_STARTUP_TIMEOUT)
#ifndef LSE_STARTUP_TIMEOUT
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
#endif /* LSE_STARTUP_TIMEOUT */
@ -128,7 +128,7 @@ in voltage and temperature.*/
* This value is used by the I2S HAL module to compute the I2S clock source
* frequency, this source is inserted directly through I2S_CKIN pad.
*/
#if !defined (EXTERNAL_CLOCK_VALUE)
#ifndef EXTERNAL_CLOCK_VALUE
#define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/
#endif /* EXTERNAL_CLOCK_VALUE */
@ -455,7 +455,7 @@ in voltage and temperature.*/
#endif /* HAL_MMC_MODULE_ENABLED */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function

View file

@ -87,11 +87,11 @@ extern "C" {
* This value is used by the RCC HAL module to compute the system frequency
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
#ifndef HSE_VALUE
#define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSE_STARTUP_TIMEOUT)
#ifndef HSE_STARTUP_TIMEOUT
#define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */
@ -100,14 +100,14 @@ extern "C" {
* This value is used by the RCC HAL module to compute the system frequency
* (when HSI is used as system clock source, directly or through the PLL).
*/
#if !defined (HSI_VALUE)
#ifndef HSI_VALUE
#define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */
/**
* @brief Internal Low Speed oscillator (LSI) value.
*/
#if !defined (LSI_VALUE)
#ifndef LSI_VALUE
#define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
The real value may vary depending on the variations
@ -115,11 +115,11 @@ in voltage and temperature.*/
/**
* @brief External Low Speed oscillator (LSE) value.
*/
#if !defined (LSE_VALUE)
#ifndef LSE_VALUE
#define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
#endif /* LSE_VALUE */
#if !defined (LSE_STARTUP_TIMEOUT)
#ifndef LSE_STARTUP_TIMEOUT
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
#endif /* LSE_STARTUP_TIMEOUT */
@ -128,7 +128,7 @@ in voltage and temperature.*/
* This value is used by the I2S HAL module to compute the I2S clock source
* frequency, this source is inserted directly through I2S_CKIN pad.
*/
#if !defined (EXTERNAL_CLOCK_VALUE)
#ifndef EXTERNAL_CLOCK_VALUE
#define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/
#endif /* EXTERNAL_CLOCK_VALUE */
@ -455,7 +455,7 @@ in voltage and temperature.*/
#endif /* HAL_MMC_MODULE_ENABLED */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function

View file

@ -592,7 +592,7 @@
#define DEFAULT_bedKd 1164.25
#endif
#if defined(U20_PLUS)
#ifdef U20_PLUS
// These PID setting MUST be updated.
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
#define DEFAULT_bedKp 841.68
@ -1114,7 +1114,7 @@
#define Z_MACHINE_MAX 400
#endif
#if defined(U20_PLUS)
#ifdef U20_PLUS
#define X_BED_SIZE 400
#define Y_BED_SIZE 400
#define Z_MACHINE_MAX 500

View file

@ -592,7 +592,7 @@
#define DEFAULT_bedKd 1164.25
#endif
#if defined(U20_PLUS)
#ifdef U20_PLUS
// These PID setting MUST be updated.
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
#define DEFAULT_bedKp 841.68
@ -1114,7 +1114,7 @@
#define Z_MACHINE_MAX 400
#endif
#if defined(U20_PLUS)
#ifdef U20_PLUS
#define X_BED_SIZE 400
#define Y_BED_SIZE 400
#define Z_MACHINE_MAX 500