diff --git a/avrpins.h b/avrpins.h index c59e9c52..afdf0b85 100644 --- a/avrpins.h +++ b/avrpins.h @@ -952,4 +952,49 @@ MAKE_PIN(P78, PIOB, PIO_PB23); // Unconnected #endif // __arm__ +#if defined(__MIPSEL__) +// MIPSEL (MIPS architecture using a little endian byte order) + +// MIPS size_t = 4 +#define pgm_read_pointer(p) pgm_read_dword(p) + +#define MAKE_PIN(className, pin) \ +class className { \ +public: \ + static void Set() { \ + digitalWrite(pin, HIGH);\ + } \ + static void Clear() { \ + digitalWrite(pin, LOW); \ + } \ + static void SetDirRead() { \ + pinMode(pin, INPUT); \ + } \ + static void SetDirWrite() { \ + pinMode(pin, OUTPUT); \ + } \ + static uint8_t IsSet() { \ + return digitalRead(pin); \ + } \ +}; + +// 0 .. 13 - Digital pins +MAKE_PIN(P0, 0); // RX +MAKE_PIN(P1, 1); // TX +MAKE_PIN(P2, 2); // +MAKE_PIN(P3, 3); // +MAKE_PIN(P4, 4); // +MAKE_PIN(P5, 5); // +MAKE_PIN(P6, 6); // +MAKE_PIN(P7, 7); // +MAKE_PIN(P8, 8); // +MAKE_PIN(P9, 9); // +MAKE_PIN(P10, 10); // +MAKE_PIN(P11, 11); // +MAKE_PIN(P12, 12); // +MAKE_PIN(P13, 13); // + +#undef MAKE_PIN +#endif + #endif //_avrpins_h_ diff --git a/settings.h b/settings.h index e3d0ed1d..82c07036 100644 --- a/settings.h +++ b/settings.h @@ -78,15 +78,7 @@ e-mail : support@circuitsathome.com // No user serviceable parts below this line. // DO NOT change anything below here unless you are a developer! -#if defined(ARDUINO) && ARDUINO >=100 -#include -#else -#include -#include -#include -#include -#define F(str) (str) -#endif +#include "version_helper.h" #if defined(__GNUC__) && defined(__AVR__) #ifndef GCC_VERSION @@ -137,8 +129,10 @@ e-mail : support@circuitsathome.com #define USING_SPI4TEENSY3 0 #endif -#if defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) -#include // Use the Arduino SPI library for the Arduino Due +#if (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) +#include // Use the Arduino SPI library +#endif +#if defined(__PIC32MX__) || defined(__PIC32MZ__) +#include <../../libraries/SPI/SPI.h> // Hack to use the SPI library #endif - #endif /* SETTINGS_H */ diff --git a/usbhost.h b/usbhost.h index cf26c1f0..f0a6962e 100644 --- a/usbhost.h +++ b/usbhost.h @@ -39,12 +39,16 @@ public: SPI_SS::SetDirWrite(); SPI_SS::Set(); } -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif !defined(SPDR) static void init() { SPI_SS::SetDirWrite(); SPI_SS::Set(); SPI.begin(); +#if defined(__MIPSEL__) + SPI.setClockDivider(2); +#else SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz +#endif } #else static void init() { @@ -74,6 +78,8 @@ typedef SPi< Pb7, Pb5, Pb6, Pb4 > spi; typedef SPi< P13, P11, P12, P10 > spi; #elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) typedef SPi< P76, P75, P74, P10 > spi; +#elif defined(__MIPSEL__) +typedef SPi< P13, P11, P12, P10 > spi; #else #error "No SPI entry in usbhost.h" #endif @@ -135,7 +141,7 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) { c[0] = reg | 0x02; c[1] = data; spi4teensy3::send(c, 2); -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif !defined(SPDR) SPI.transfer(reg | 0x02); SPI.transfer(data); #else @@ -159,7 +165,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* spi4teensy3::send(reg | 0x02); spi4teensy3::send(data_p, nbytes); data_p += nbytes; -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif !defined(SPDR) SPI.transfer(reg | 0x02); while(nbytes) { SPI.transfer(*data_p); @@ -201,7 +207,7 @@ uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) { spi4teensy3::send(reg); uint8_t rv = spi4teensy3::receive(); SPI_SS::Set(); -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif !defined(SPDR) SPI.transfer(reg); uint8_t rv = SPI.transfer(0); SPI_SS::Set(); @@ -227,7 +233,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* spi4teensy3::send(reg); spi4teensy3::receive(data_p, nbytes); data_p += nbytes; -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif !defined(SPDR) SPI.transfer(reg); while(nbytes) { *data_p++ = SPI.transfer(0); diff --git a/version_helper.h b/version_helper.h new file mode 100644 index 00000000..b018000e --- /dev/null +++ b/version_helper.h @@ -0,0 +1,222 @@ +/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +This software may be distributed and modified under the terms of the GNU +General Public License version 2 (GPL2) as published by the Free Software +Foundation and appearing in the file GPL2.TXT included in the packaging of +this file. Please note that GPL2 Section 2[b] requires that all works based +on this software must also be made publicly available under the terms of +the GPL2 ("Copyleft"). + +Contact information +------------------- + +Circuits At Home, LTD +Web : http://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +/* + * Universal Arduino(tm) "IDE" fixups. + * Includes fixes for versions as low as 0023, used by Digilent. + */ + +#if defined(ARDUINO) && ARDUINO >=100 +#include +#else +#include +#include +#ifdef __AVR__ +#include +#include +#else +#endif +#endif + +#ifndef __PGMSPACE_H_ +#define __PGMSPACE_H_ 1 + +#include + +#ifndef PROGMEM +#define PROGMEM +#endif +#ifndef PGM_P +#define PGM_P const char * +#endif +#ifndef PSTR +#define PSTR(str) (str) +#endif +#ifndef F +#define F(str) (str) +#endif +#ifndef _SFR_BYTE +#define _SFR_BYTE(n) (n) +#endif + +#ifndef prog_void +typedef void prog_void; +#endif +#ifndef prog_char +typedef char prog_char; +#endif +#ifndef prog_uchar +typedef unsigned char prog_uchar; +#endif +#ifndef prog_int8_t +typedef int8_t prog_int8_t; +#endif +#ifndef prog_uint8_t +typedef uint8_t prog_uint8_t; +#endif +#ifndef prog_int16_t +typedef int16_t prog_int16_t; +#endif +#ifndef prog_uint16_t +typedef uint16_t prog_uint16_t; +#endif +#ifndef prog_int32_t +typedef int32_t prog_int32_t; +#endif +#ifndef prog_uint32_t +typedef uint32_t prog_uint32_t; +#endif + +#ifndef memchr_P +#define memchr_P(str, c, len) memchr((str), (c), (len)) +#endif +#ifndef memcmp_P +#define memcmp_P(a, b, n) memcmp((a), (b), (n)) +#endif +#ifndef memcpy_P +#define memcpy_P(dest, src, num) memcpy((dest), (src), (num)) +#endif +#ifndef memmem_P +#define memmem_P(a, alen, b, blen) memmem((a), (alen), (b), (blen)) +#endif +#ifndef memrchr_P +#define memrchr_P(str, val, len) memrchr((str), (val), (len)) +#endif +#ifndef strcat_P +#define strcat_P(dest, src) strcat((dest), (src)) +#endif +#ifndef strchr_P +#define strchr_P(str, c) strchr((str), (c)) +#endif +#ifndef strchrnul_P +#define strchrnul_P(str, c) strchrnul((str), (c)) +#endif +#ifndef strcmp_P +#define strcmp_P(a, b) strcmp((a), (b)) +#endif +#ifndef strcpy_P +#define strcpy_P(dest, src) strcpy((dest), (src)) +#endif +#ifndef strcasecmp_P +#define strcasecmp_P(a, b) strcasecmp((a), (b)) +#endif +#ifndef strcasestr_P +#define strcasestr_P(a, b) strcasestr((a), (b)) +#endif +#ifndef strlcat_P +#define strlcat_P(dest, src, len) strlcat((dest), (src), (len)) +#endif +#ifndef strlcpy_P +#define strlcpy_P(dest, src, len) strlcpy((dest), (src), (len)) +#endif +#ifndef strlen_P +#define strlen_P(s) strlen((const char *)(s)) +#endif +#ifndef strnlen_P +#define strnlen_P(str, len) strnlen((str), (len)) +#endif +#ifndef strncmp_P +#define strncmp_P(a, b, n) strncmp((a), (b), (n)) +#endif +#ifndef strncasecmp_P +#define strncasecmp_P(a, b, n) strncasecmp((a), (b), (n)) +#endif +#ifndef strncat_P +#define strncat_P(a, b, n) strncat((a), (b), (n)) +#endif +#ifndef strncpy_P +#define strncpy_P(a, b, n) strncmp((a), (b), (n)) +#endif +#ifndef strpbrk_P +#define strpbrk_P(str, chrs) strpbrk((str), (chrs)) +#endif +#ifndef strrchr_P +#define strrchr_P(str, c) strrchr((str), (c)) +#endif +#ifndef strsep_P +#define strsep_P(strp, delim) strsep((strp), (delim)) +#endif +#ifndef strspn_P +#define strspn_P(str, chrs) strspn((str), (chrs)) +#endif +#ifndef strstr_P +#define strstr_P(a, b) strstr((a), (b)) +#endif +#ifndef sprintf_P +#define sprintf_P(s, ...) sprintf((s), __VA_ARGS__) +#endif +#ifndef vfprintf_P +#define vfprintf_P(s, ...) vfprintf((s), __VA_ARGS__) +#endif +#ifndef printf_P +#define printf_P(...) printf(__VA_ARGS__) +#endif +#ifndef snprintf_P +#define snprintf_P(s, n, ...) ((s), (n), __VA_ARGS__) +#endif +#ifndef vsprintf_P +#define vsprintf_P(s, ...) ((s),__VA_ARGS__) +#endif +#ifndef vsnprintf_P +#define vsnprintf_P(s, n, ...) ((s), (n),__VA_ARGS__) +#endif +#ifndef fprintf_P +#define fprintf_P(s, ...) ((s), __VA_ARGS__) +#endif + +#ifndef pgm_read_byte +#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) +#endif +#ifndef pgm_read_word +#define pgm_read_word(addr) (*(const unsigned short *)(addr)) +#endif +#ifndef pgm_read_dword +#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) +#endif +#ifndef pgm_read_float +#define pgm_read_float(addr) (*(const float *)(addr)) +#endif + +#ifndef pgm_read_byte_near +#define pgm_read_byte_near(addr) pgm_read_byte(addr) +#endif +#ifndef pgm_read_word_near +#define pgm_read_word_near(addr) pgm_read_word(addr) +#endif +#ifndef pgm_read_dword_near +#define pgm_read_dword_near(addr) pgm_read_dword(addr) +#endif +#ifndef pgm_read_float_near +#define pgm_read_float_near(addr) pgm_read_float(addr) +#endif +#ifndef pgm_read_byte_far +#define pgm_read_byte_far(addr) pgm_read_byte(addr) +#endif +#ifndef pgm_read_word_far +#define pgm_read_word_far(addr) pgm_read_word(addr) +#endif +#ifndef pgm_read_dword_far +#define pgm_read_dword_far(addr) pgm_read_dword(addr) +#endif +#ifndef pgm_read_float_far +#define pgm_read_float_far(addr) pgm_read_float(addr) +#endif + +#ifndef pgm_read_pointer +#define pgm_read_pointer +#endif +#endif