Apply #ifdef/#ifndef where possible

2.0.x
Scott Lahteine 5 years ago
parent 4078f2672e
commit 34b73426e5

@ -230,7 +230,7 @@
/* Define NO_INIT attribute */ /* Define NO_INIT attribute */
#if 0 //ndef NO_INIT #if 0 //ndef NO_INIT
#if defined ( __CC_ARM ) #ifdef __CC_ARM
# define NO_INIT __attribute__((zero_init)) # define NO_INIT __attribute__((zero_init))
#elif defined ( __ICCARM__ ) #elif defined ( __ICCARM__ )
# define NO_INIT __no_init # define NO_INIT __no_init
@ -262,7 +262,7 @@
//! @{ //! @{
typedef unsigned char Bool; //!< Boolean. typedef unsigned char Bool; //!< Boolean.
#ifndef __cplusplus #ifndef __cplusplus
#if !defined(__bool_true_false_are_defined) #ifndef __bool_true_false_are_defined
typedef unsigned char bool; //!< Boolean. typedef unsigned char bool; //!< Boolean.
#endif #endif
#endif #endif
@ -443,7 +443,7 @@ typedef struct
#define DISABLE 0 #define DISABLE 0
#define ENABLE 1 #define ENABLE 1
#ifndef __cplusplus #ifndef __cplusplus
#if !defined(__bool_true_false_are_defined) #ifndef __bool_true_false_are_defined
#define false 0 #define false 0
#define true 1 #define true 1
#endif #endif

@ -61,27 +61,27 @@ extern "C" {
* Below BOARD_XXX macros are related to the specific board, and * Below BOARD_XXX macros are related to the specific board, and
* should be defined by the board code, otherwise default value are used. * 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. # warning The board slow clock xtal frequency has not been defined.
# define BOARD_FREQ_SLCK_XTAL (32768UL) # define BOARD_FREQ_SLCK_XTAL (32768UL)
#endif #endif
#if !defined(BOARD_FREQ_SLCK_BYPASS) #ifndef BOARD_FREQ_SLCK_BYPASS
# warning The board slow clock bypass frequency has not been defined. # warning The board slow clock bypass frequency has not been defined.
# define BOARD_FREQ_SLCK_BYPASS (32768UL) # define BOARD_FREQ_SLCK_BYPASS (32768UL)
#endif #endif
#if !defined(BOARD_FREQ_MAINCK_XTAL) #ifndef BOARD_FREQ_MAINCK_XTAL
# warning The board main clock xtal frequency has not been defined. # warning The board main clock xtal frequency has not been defined.
# define BOARD_FREQ_MAINCK_XTAL (12000000UL) # define BOARD_FREQ_MAINCK_XTAL (12000000UL)
#endif #endif
#if !defined(BOARD_FREQ_MAINCK_BYPASS) #ifndef BOARD_FREQ_MAINCK_BYPASS
# warning The board main clock bypass frequency has not been defined. # warning The board main clock bypass frequency has not been defined.
# define BOARD_FREQ_MAINCK_BYPASS (12000000UL) # define BOARD_FREQ_MAINCK_BYPASS (12000000UL)
#endif #endif
#if !defined(BOARD_OSC_STARTUP_US) #ifndef BOARD_OSC_STARTUP_US
# warning The board main clock xtal startup time has not been defined. # warning The board main clock xtal startup time has not been defined.
# define BOARD_OSC_STARTUP_US (15625UL) # define BOARD_OSC_STARTUP_US (15625UL)
#endif #endif

@ -43,13 +43,13 @@
* \asf_license_stop * \asf_license_stop
* *
*/ */
/* /*
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a> * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
*/ */
#ifndef _SPC_PROTOCOL_H_ #ifndef _SPC_PROTOCOL_H_
#define _SPC_PROTOCOL_H_ #define _SPC_PROTOCOL_H_
/** /**
* \ingroup usb_msc_protocol * \ingroup usb_msc_protocol
* \defgroup usb_spc_protocol SCSI Primary Commands protocol definitions * \defgroup usb_spc_protocol SCSI Primary Commands protocol definitions

@ -58,7 +58,7 @@
#define SPI_2XCLOCK_MASK 0x01 // SPI2X = bit 0 on SPSR #define SPI_2XCLOCK_MASK 0x01 // SPI2X = bit 0 on SPSR
// define SPI_AVR_EIMSK for AVR boards with external interrupt pins // define SPI_AVR_EIMSK for AVR boards with external interrupt pins
#if defined(EIMSK) #ifdef EIMSK
#define SPI_AVR_EIMSK EIMSK #define SPI_AVR_EIMSK EIMSK
#elif defined(GICR) #elif defined(GICR)
#define SPI_AVR_EIMSK GICR #define SPI_AVR_EIMSK GICR

@ -892,7 +892,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
* Switching Toolhead requirements * Switching Toolhead requirements
*/ */
#if ENABLED(SWITCHING_TOOLHEAD) #if ENABLED(SWITCHING_TOOLHEAD)
#if !defined(SWITCHING_TOOLHEAD_SERVO_NR) #ifndef SWITCHING_TOOLHEAD_SERVO_NR
#error "SWITCHING_TOOLHEAD requires SWITCHING_TOOLHEAD_SERVO_NR." #error "SWITCHING_TOOLHEAD requires SWITCHING_TOOLHEAD_SERVO_NR."
#elif EXTRUDERS < 2 #elif EXTRUDERS < 2
#error "SWITCHING_TOOLHEAD requires at least 2 EXTRUDERS." #error "SWITCHING_TOOLHEAD requires at least 2 EXTRUDERS."

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

@ -27,7 +27,7 @@
/********************************* SPI Functions *********************************/ /********************************* SPI Functions *********************************/
namespace FTDI { namespace FTDI {
#if !defined(CLCD_USE_SOFT_SPI) #ifndef CLCD_USE_SOFT_SPI
SPISettings SPI::spi_settings(SPI_FREQUENCY, MSBFIRST, SPI_MODE0); SPISettings SPI::spi_settings(SPI_FREQUENCY, MSBFIRST, SPI_MODE0);
#endif #endif
@ -108,7 +108,7 @@ namespace FTDI {
void SPI::spi_read_bulk (void *data, uint16_t len) { void SPI::spi_read_bulk (void *data, uint16_t len) {
uint8_t* p = (uint8_t *)data; uint8_t* p = (uint8_t *)data;
#if !defined(CLCD_USE_SOFT_SPI) #ifndef CLCD_USE_SOFT_SPI
::SPI.transfer(p, len); ::SPI.transfer(p, len);
#else #else
while (len--) *p++ = spi_recv(); while (len--) *p++ = spi_recv();
@ -123,7 +123,7 @@ namespace FTDI {
// CLCD SPI - Chip Select // CLCD SPI - Chip Select
void SPI::spi_ftdi_select (void) { void SPI::spi_ftdi_select (void) {
#if !defined(CLCD_USE_SOFT_SPI) #ifndef CLCD_USE_SOFT_SPI
::SPI.beginTransaction(spi_settings); ::SPI.beginTransaction(spi_settings);
#endif #endif
WRITE(CLCD_SPI_CS, 0); WRITE(CLCD_SPI_CS, 0);
@ -133,7 +133,7 @@ namespace FTDI {
// CLCD SPI - Chip Deselect // CLCD SPI - Chip Deselect
void SPI::spi_ftdi_deselect (void) { void SPI::spi_ftdi_deselect (void) {
WRITE(CLCD_SPI_CS, 1); WRITE(CLCD_SPI_CS, 1);
#if !defined(CLCD_USE_SOFT_SPI) #ifndef CLCD_USE_SOFT_SPI
::SPI.endTransaction(); ::SPI.endTransaction();
#endif #endif
} }
@ -141,7 +141,7 @@ namespace FTDI {
#ifdef SPI_FLASH_SS #ifdef SPI_FLASH_SS
// Serial SPI Flash SPI - Chip Select // Serial SPI Flash SPI - Chip Select
void SPI::spi_flash_select () { void SPI::spi_flash_select () {
#if !defined(CLCD_USE_SOFT_SPI) #ifndef CLCD_USE_SOFT_SPI
::SPI.beginTransaction(spi_settings); ::SPI.beginTransaction(spi_settings);
#endif #endif
WRITE(SPI_FLASH_SS, 0); WRITE(SPI_FLASH_SS, 0);
@ -151,7 +151,7 @@ namespace FTDI {
// Serial SPI Flash SPI - Chip Deselect // Serial SPI Flash SPI - Chip Deselect
void SPI::spi_flash_deselect () { void SPI::spi_flash_deselect () {
WRITE(SPI_FLASH_SS, 1); WRITE(SPI_FLASH_SS, 1);
#if !defined(CLCD_USE_SOFT_SPI) #ifndef CLCD_USE_SOFT_SPI
::SPI.endTransaction(); ::SPI.endTransaction();
#endif #endif
} }

@ -22,13 +22,13 @@
#pragma once #pragma once
#if !defined(CLCD_USE_SOFT_SPI) #ifndef CLCD_USE_SOFT_SPI
#include <SPI.h> #include <SPI.h>
#endif #endif
namespace FTDI { namespace FTDI {
namespace SPI { namespace SPI {
#if !defined(CLCD_USE_SOFT_SPI) #ifndef CLCD_USE_SOFT_SPI
extern SPISettings spi_settings; extern SPISettings spi_settings;
#endif #endif

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

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

@ -209,7 +209,7 @@ class SpinnerDialogBox : public DialogBoxBaseClass, public CachedScreen<SPINNER_
static void enqueueAndWait_P(const progmem_str message, const progmem_str commands); 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> { class StatusScreen : public BaseScreen, public CachedScreen<STATUS_SCREEN_CACHE,STATUS_SCREEN_DL_SIZE> {
private: private:
static void draw_axis_position(draw_mode_t); static void draw_axis_position(draw_mode_t);

@ -25,7 +25,7 @@
* Z-Bolt X Series board based on Arduino Mega2560 * 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.'" #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'"
#elif HOTENDS > 4 || E_STEPPERS > 4 #elif HOTENDS > 4 || E_STEPPERS > 4
#error "Z-Bolt X Series board supports up to 4 hotends / E-steppers." #error "Z-Bolt X Series board supports up to 4 hotends / E-steppers."

@ -153,7 +153,7 @@
// define XMEM_ACQUIRE_SPI and XMEM_RELEASE_SPI to point to your lock and unlock. // 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 // NOTE: NO argument is passed. You have to do this within your routine for
// whatever you are using to lock and unlock. // 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) #if USE_XMEM_SPI_LOCK || defined(USE_MULTIPLE_APP_API)
#include <xmem.h> #include <xmem.h>
#else #else

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

@ -33,11 +33,11 @@ e-mail : support@circuitsathome.com
#define UHS_HOST_MAX_INTERFACE_DRIVERS 0x10U // Default maximum number of USB interface drivers #define UHS_HOST_MAX_INTERFACE_DRIVERS 0x10U // Default maximum number of USB interface drivers
#endif #endif
#if !defined(SYSTEM_OR_SPECIAL_YIELD) #ifndef SYSTEM_OR_SPECIAL_YIELD
#define SYSTEM_OR_SPECIAL_YIELD(...) VOID0 #define SYSTEM_OR_SPECIAL_YIELD(...) VOID0
#endif #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 #define SYSTEM_OR_SPECIAL_YIELD_FROM_ISR(...) SYSTEM_OR_SPECIAL_YIELD
#endif #endif

@ -226,7 +226,7 @@ public:
} }
thePool[index].address = addr; thePool[index].address = addr;
#if DEBUG_PRINTF_EXTRA_HUGE #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); printf("Address: %x (%x.%x.%x)\r\n", addr.devAddress, addr.bmHub, addr.bmParent, addr.bmAddress);
#endif #endif
#endif #endif

@ -58,7 +58,7 @@ e-mail : support@circuitsathome.com
#include "UHS_host_INLINE.h" #include "UHS_host_INLINE.h"
#include "UHS_printf_HELPER.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" #include "USB_HOST_SHIELD/USB_HOST_SHIELD.h"
#endif #endif
@ -72,24 +72,24 @@ e-mail : support@circuitsathome.com
// Load USB drivers and multiplexers // Load USB drivers and multiplexers
#if defined(LOAD_UHS_HUB) #ifdef LOAD_UHS_HUB
#include "UHS_HUB/UHS_HUB.h" #include "UHS_HUB/UHS_HUB.h"
#endif // HUB loaded #endif // HUB loaded
#if defined(LOAD_UHS_BULK_STORAGE) #ifdef LOAD_UHS_BULK_STORAGE
#include "UHS_BULK_STORAGE/UHS_BULK_STORAGE.h" #include "UHS_BULK_STORAGE/UHS_BULK_STORAGE.h"
#endif #endif
#if defined(LOAD_GENERIC_STORAGE) #ifdef LOAD_GENERIC_STORAGE
#include "../UHS_FS/UHS_FS.h" #include "../UHS_FS/UHS_FS.h"
#endif #endif
// Add BT and optionally HID if directed to do so // 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" #include "UHS_BT/UHS_BT.h"
#endif // BT and optionally HID loaded #endif // BT and optionally HID loaded
// Add HID // Add HID
#if defined(LOAD_UHS_HID) #ifdef LOAD_UHS_HID
#include "UHS_HID/UHS_HID.h" #include "UHS_HID/UHS_HID.h"
#endif // HID loaded #endif // HID loaded
@ -98,11 +98,11 @@ e-mail : support@circuitsathome.com
#include "UHS_CDC/UHS_CDC.h" #include "UHS_CDC/UHS_CDC.h"
#endif // CDC loaded #endif // CDC loaded
#if defined(LOAD_UHS_ADK) #ifdef LOAD_UHS_ADK
#include "UHS_ADK/UHS_ADK.h" #include "UHS_ADK/UHS_ADK.h"
#endif #endif
#if defined(LOAD_UHS_MIDI) #ifdef LOAD_UHS_MIDI
#include "UHS_MIDI/UHS_MIDI.h" #include "UHS_MIDI/UHS_MIDI.h"
#endif #endif

@ -24,7 +24,7 @@ Web : http://www.circuitsathome.com
e-mail : support@circuitsathome.com e-mail : support@circuitsathome.com
*/ */
#if !defined(MACROS_H) #ifndef MACROS_H
#define MACROS_H #define MACROS_H
#include "macro_logic.h" #include "macro_logic.h"
/* /*
@ -49,18 +49,18 @@ e-mail : support@circuitsathome.com
// Nuke screwed up macro junk from the IDE. // Nuke screwed up macro junk from the IDE.
#ifdef __cplusplus #ifdef __cplusplus
#if defined(true) #ifdef true
#undef true #undef true
#endif #endif
#if defined(false) #ifdef false
#undef false #undef false
#endif #endif
#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 defined(FLASHEND) && defined(FLASHSTART)
#if (FLASHEND - FLASHSTART) > 0x0FFFFU #if (FLASHEND - FLASHSTART) > 0x0FFFFU
@ -122,10 +122,10 @@ e-mail : support@circuitsathome.com
// TODO: Fast inline code for AVR and SAM based microcontrollers // TODO: Fast inline code for AVR and SAM based microcontrollers
// This can be done pretty easily. // This can be done pretty easily.
// For now, this will just work out-of-the-box. // 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) #define UHS_PIN_WRITE(p, v) digitalWrite(p, v)
#endif #endif
#if !defined(UHS_PIN_READ) #ifndef UHS_PIN_READ
#define UHS_PIN_READ(p) digitalRead(p) #define UHS_PIN_READ(p) digitalRead(p)
#endif #endif
@ -134,8 +134,8 @@ e-mail : support@circuitsathome.com
#edfine noInterrupts() __builtin_disable_interrupts() #edfine noInterrupts() __builtin_disable_interrupts()
#endif #endif
#if !defined(ARDUINO_SAMD_ZERO) #ifndef ARDUINO_SAMD_ZERO
#if defined(ARDUINO_AVR_ADK) #ifdef ARDUINO_AVR_ADK
#define UHS_GET_DPI(x) (x == 54 ? 6 : digitalPinToInterrupt(x)) #define UHS_GET_DPI(x) (x == 54 ? 6 : digitalPinToInterrupt(x))
#else #else
#define UHS_GET_DPI(x) digitalPinToInterrupt(x) #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 USBTRACE2X(s,r) (USBTRACE3X((s),(r),0x80)); USB_HOST_SERIAL.flush()
#define VOID0 ((void)0) #define VOID0 ((void)0)
#if !defined(NOTUSED) #ifndef NOTUSED
#define NOTUSED(...) __VA_ARGS__ __attribute__((unused)) #define NOTUSED(...) __VA_ARGS__ __attribute__((unused))
#endif #endif
#endif /* MACROS_H */ #endif /* MACROS_H */

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

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

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

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

@ -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_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)) #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 BODY(AJKindex) some(C, statement); contaning(a, test[AJKindex]);
#define ZERO_TIMES_TEST 0 #define ZERO_TIMES_TEST 0

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

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

@ -87,11 +87,11 @@ extern "C" {
* This value is used by the RCC HAL module to compute the system frequency * 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). * (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 */ #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */ #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 */ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */ #endif /* HSE_STARTUP_TIMEOUT */
@ -100,14 +100,14 @@ extern "C" {
* This value is used by the RCC HAL module to compute the system frequency * 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). * (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*/ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */ #endif /* HSI_VALUE */
/** /**
* @brief Internal Low Speed oscillator (LSI) 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*/ #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
The real value may vary depending on the variations The real value may vary depending on the variations
@ -115,11 +115,11 @@ in voltage and temperature.*/
/** /**
* @brief External Low Speed oscillator (LSE) value. * @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 */ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
#endif /* LSE_VALUE */ #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 */ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
#endif /* LSE_STARTUP_TIMEOUT */ #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 * 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. * 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*/ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/
#endif /* EXTERNAL_CLOCK_VALUE */ #endif /* EXTERNAL_CLOCK_VALUE */

@ -87,11 +87,11 @@ extern "C" {
* This value is used by the RCC HAL module to compute the system frequency * 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). * (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 */ #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */ #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 */ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */ #endif /* HSE_STARTUP_TIMEOUT */
@ -100,14 +100,14 @@ extern "C" {
* This value is used by the RCC HAL module to compute the system frequency * 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). * (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*/ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */ #endif /* HSI_VALUE */
/** /**
* @brief Internal Low Speed oscillator (LSI) 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*/ #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
The real value may vary depending on the variations The real value may vary depending on the variations
@ -115,11 +115,11 @@ in voltage and temperature.*/
/** /**
* @brief External Low Speed oscillator (LSE) value. * @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 */ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
#endif /* LSE_VALUE */ #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 */ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
#endif /* LSE_STARTUP_TIMEOUT */ #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 * 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. * 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*/ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/
#endif /* EXTERNAL_CLOCK_VALUE */ #endif /* EXTERNAL_CLOCK_VALUE */

@ -592,7 +592,7 @@
#define DEFAULT_bedKd 1164.25 #define DEFAULT_bedKd 1164.25
#endif #endif
#if defined(U20_PLUS) #ifdef U20_PLUS
// These PID setting MUST be updated. // 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. // 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 #define DEFAULT_bedKp 841.68
@ -1114,7 +1114,7 @@
#define Z_MACHINE_MAX 400 #define Z_MACHINE_MAX 400
#endif #endif
#if defined(U20_PLUS) #ifdef U20_PLUS
#define X_BED_SIZE 400 #define X_BED_SIZE 400
#define Y_BED_SIZE 400 #define Y_BED_SIZE 400
#define Z_MACHINE_MAX 500 #define Z_MACHINE_MAX 500

@ -592,7 +592,7 @@
#define DEFAULT_bedKd 1164.25 #define DEFAULT_bedKd 1164.25
#endif #endif
#if defined(U20_PLUS) #ifdef U20_PLUS
// These PID setting MUST be updated. // 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. // 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 #define DEFAULT_bedKp 841.68
@ -1114,7 +1114,7 @@
#define Z_MACHINE_MAX 400 #define Z_MACHINE_MAX 400
#endif #endif
#if defined(U20_PLUS) #ifdef U20_PLUS
#define X_BED_SIZE 400 #define X_BED_SIZE 400
#define Y_BED_SIZE 400 #define Y_BED_SIZE 400
#define Z_MACHINE_MAX 500 #define Z_MACHINE_MAX 500

Loading…
Cancel
Save