summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2016-06-03 02:32:40 +0200
committerChristian Pointner <equinox@spreadspace.org>2016-06-03 02:32:40 +0200
commitf4050e53de1ba899dcdb75d9cb63a95b46063314 (patch)
tree250386fe83bb462aa2ff5eb030c02d39d703f7c3
parentbmp180 pressure sensor, just lacks arduino i2c-wire-lib and testing (diff)
fastled now works on mimimus32
-rw-r--r--contrib/Makefile9
-rw-r--r--contrib/fastled4minimus32.patch25
-rw-r--r--defines.mk1
-rw-r--r--lib/Arduino.h2
-rw-r--r--lib/arduino-leonardo/pins_arduino.h (renamed from lib/arduino-leonardo/arduino_pins.h)0
-rw-r--r--lib/arduino-minimus32/pins_arduino.h246
-rw-r--r--lib/arduino-standard/pins_arduino.h (renamed from lib/arduino-standard/arduino_pins.h)0
-rw-r--r--usb-fastled/Makefile3
-rw-r--r--usb-fastled/usb-fastled.cpp4
9 files changed, 281 insertions, 9 deletions
diff --git a/contrib/Makefile b/contrib/Makefile
index be93ef2..6e87923 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -23,7 +23,7 @@
##
LUFA_VERSION := 151115
-FASTLED_VERSION := v3.1.0
+FASTLED_VERSION := 3.1.0
BMP180_VERSION := V_1.1.2
all: download-lufa download-fastled update-pjon update-teensy-loader download-bmp180
@@ -34,11 +34,12 @@ LUFA-${LUFA_VERSION}.zip:
wget "http://www.github.com/abcminiuser/lufa/archive/$@" -O "$@"
unzip $@
-download-fastled: FastLED-${FASTLED_VERSION}.zip
+download-fastled: FastLED-v${FASTLED_VERSION}.zip
-FastLED-${FASTLED_VERSION}.zip:
- wget "https://github.com/FastLED/FastLED/archive/${FASTLED_VERSION}.zip" -O "$@"
+FastLED-v${FASTLED_VERSION}.zip:
+ wget "https://github.com/FastLED/FastLED/archive/v${FASTLED_VERSION}.zip" -O "$@"
unzip $@
+ cd FastLED-${FASTLED_VERSION}; patch -p1 < ../fastled4minimus32.patch
download-bmp180: BMP180-${BMP180_VERSION}.zip
diff --git a/contrib/fastled4minimus32.patch b/contrib/fastled4minimus32.patch
new file mode 100644
index 0000000..beb5e47
--- /dev/null
+++ b/contrib/fastled4minimus32.patch
@@ -0,0 +1,25 @@
+diff -Nur FastLED-3.1.0.orig/platforms/avr/fastpin_avr.h FastLED-3.1.0/platforms/avr/fastpin_avr.h
+--- FastLED-3.1.0.orig/platforms/avr/fastpin_avr.h 2015-09-23 18:22:19.000000000 +0200
++++ FastLED-3.1.0/platforms/avr/fastpin_avr.h 2016-06-03 02:03:19.167138941 +0200
+@@ -105,7 +105,7 @@
+ #define AVR_HARDWARE_SPI 1
+
+ #define HAS_HARDWARE_PIN_SUPPORT 1
+-#elif defined(ARDUINO_HOODLOADER2) && (defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)) || defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__)
++#elif (defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)) || defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__)
+
+ _IO(D); _IO(B); _IO(C);
+
+@@ -120,9 +120,9 @@
+ _DEFPIN_AVR( 20, 0x80, D);
+
+ #define HAS_HARDWARE_PIN_SUPPORT 1
+-// #define SPI_DATA 2
+-// #define SPI_CLOCK 1
+-// #define AVR_HARDWARE_SPI 1
++#define SPI_DATA 2
++#define SPI_CLOCK 1
++#define AVR_HARDWARE_SPI 1
+
+ #elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega8__)
+ // Accelerated port definitions for arduino avrs
diff --git a/defines.mk b/defines.mk
index 1e87037..3fe303c 100644
--- a/defines.mk
+++ b/defines.mk
@@ -70,6 +70,7 @@ ifeq ($(BOARD_TYPE),minimus32)
F_USB = $(F_CPU)
PROG := DFU
LUFA_BOARD = MINIMUS
+ ARDUINO_PINS = minimus32
RESET_FUNC := $(SPREADAVR_PATH)/tools/reset_minimus
RESET_PARAM = "03eb:2ff0"
endif
diff --git a/lib/Arduino.h b/lib/Arduino.h
index 0e8de94..3698392 100644
--- a/lib/Arduino.h
+++ b/lib/Arduino.h
@@ -231,7 +231,7 @@ void randomSeed(unsigned long);
long map(long, long, long, long, long);
#ifdef ARDUINO_PINS
-#include "arduino_pins.h"
+#include "pins_arduino.h"
#else
#warning "no arduino pin definitions found....."
#endif
diff --git a/lib/arduino-leonardo/arduino_pins.h b/lib/arduino-leonardo/pins_arduino.h
index 6027223..6027223 100644
--- a/lib/arduino-leonardo/arduino_pins.h
+++ b/lib/arduino-leonardo/pins_arduino.h
diff --git a/lib/arduino-minimus32/pins_arduino.h b/lib/arduino-minimus32/pins_arduino.h
new file mode 100644
index 0000000..7e2cd8f
--- /dev/null
+++ b/lib/arduino-minimus32/pins_arduino.h
@@ -0,0 +1,246 @@
+/*
+ pins_arduino.h - Pin definition functions for Arduino
+ Part of Arduino - http://www.arduino.cc/
+
+ Copyright (c) 2007 David A. Mellis
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General
+ Public License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ Boston, MA 02111-1307 USA
+
+ $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
+*/
+
+#ifndef Pins_Arduino_h
+#define Pins_Arduino_h
+
+#include <avr/pgmspace.h>
+
+#define NUM_ANALOG_INPUTS 0
+#define NUM_DIGITAL_PINS 24
+
+// We only have a small USB buffer
+#define USB_EP_SIZE 16
+
+extern uint8_t usb_rxtx_leds;
+static inline void
+usb_rxtx_update_leds(uint8_t state, uint8_t mask)
+{
+ if (usb_rxtx_leds & 0x80)
+ return;
+ usb_rxtx_leds = (usb_rxtx_leds & ~mask) | (state & mask);
+ if (usb_rxtx_leds)
+ PORTD &= ~(1<<6);
+ else
+ PORTD |= 1<<6;
+}
+
+#define USB_RXTX_LED_PIN 7
+
+// Use LED A (D7 - PD6) for USB activity
+#define TX_RX_LED_INIT DDRD |= (1<<6), PORTD |= (1<<6)
+#define TXLED0 usb_rxtx_update_leds(0, 1)
+#define TXLED1 usb_rxtx_update_leds(1, 1)
+#define RXLED0 usb_rxtx_update_leds(0, 2)
+#define RXLED1 usb_rxtx_update_leds(2, 2)
+
+static const uint8_t SS = 9;
+static const uint8_t MOSI = 12;
+static const uint8_t MISO = 13;
+static const uint8_t SCK = 10;
+
+extern const uint8_t PROGMEM pin_to_pcint_PGM[24];
+#define digitalPinToPCICR(p) ((pgm_read_byte(pin_to_pcint_PGM + (p)) < 12) ? &PCICR : (uint8_t *)0)
+#define digitalPinToPCICRbit(p) (pgm_read_byte(pin_to_pcint_PGM + (p)) >> 3)
+#define digitalPinToPCMSK(p) ((pgm_read_byte(pin_to_pcint_PGM + (p)) < 8) ? &PCMSK0 : &PCMSK1)
+#define digitalPinToPCMSKbit(p) (pgm_read_byte(pin_to_pcint_PGM + (p)) & 7)
+
+#define analogPinToChannel(P) ( -1 )
+
+#ifdef ARDUINO_MAIN
+
+// On the Arduino board, digital pins are also used
+// for the analog output (software PWM). Analog input
+// pins are a separate set.
+
+// ATMEL ATMEGA32U2 / Minimus 32
+//
+// Pins numbered counter-clockwise starting from USB connector
+//
+// D0 PC2 PCINT11
+// D1# PD0 OC0B
+// D2 PD1
+// D3 PD2 RX
+// D4 PD3 TX
+// D5 PD4
+// D6 PD5 LEB B (Blue)
+// D7 PD6 LED A (Red/USB)
+// D8 PD7 HWB
+// D9 PB0 SS/PCINT0
+// D10 PB1 SCK/PCINT1
+// [D11] GND
+//
+// D12 PB2 MOSI/PCINT2
+// D13 PB3 MISO/PCINT3
+// D14 PB4 PCINT4
+// D15 PB5 PCINT5
+// D16 PB6 PCINT6
+// D17# PB7 PCINT7/OC0A/OC1C
+// D18 PC7
+// D19# PC6 PCINT8/OC1A
+// [D20] !RESET
+// D21# PC5 PCINT9/OC1B
+// D22 PC4 PCINT10
+// [D23] VCC
+
+const uint8_t PROGMEM pin_to_pcint_PGM[24] = {
+ 11, // D0 - PC2
+ 0xff, // D1 - PD0
+ 0xff, // D2 - PD1
+ 0xff, // D3 - PD2
+ 0xff, // D4 - PD3
+ 0xff, // D5 - PD4
+ 0xff, // D6 - PD5
+ 0xff, // D7 - PD6
+ 0xff, // D8 - PD7
+ 0, // D9 - PB0
+ 1, // D10 - PB1
+ 0xff, // GND
+ 2, // D12 - PB2
+ 3, // D13 - PB3
+ 4, // D14 - PB4
+ 5, // D15 - PB5
+ 6, // D16 - PB6
+ 7, // D17 - PB7
+ 0xff, // D18 - PC7
+ 8, // D19 - PC6
+ 0xff, // !RESET
+ 9, // D21 - PC5
+ 10, // D22 - PC4
+ 0xff // VCC
+};
+
+// these arrays map port names (e.g. port B) to the
+// appropriate addresses for various functions (e.g. reading
+// and writing)
+const uint16_t PROGMEM port_to_mode_PGM[] = {
+ NOT_A_PORT,
+ NOT_A_PORT,
+ (uint16_t) &DDRB,
+ (uint16_t) &DDRC,
+ (uint16_t) &DDRD,
+};
+
+const uint16_t PROGMEM port_to_output_PGM[] = {
+ NOT_A_PORT,
+ NOT_A_PORT,
+ (uint16_t) &PORTB,
+ (uint16_t) &PORTC,
+ (uint16_t) &PORTD,
+};
+
+const uint16_t PROGMEM port_to_input_PGM[] = {
+ NOT_A_PORT,
+ NOT_A_PORT,
+ (uint16_t) &PINB,
+ (uint16_t) &PINC,
+ (uint16_t) &PIND,
+};
+
+const uint8_t PROGMEM digital_pin_to_port_PGM[24] = {
+ PC, // D0 - PC2
+ PD, // D1 - PD0
+ PD, // D2 - PD1
+ PD, // D3 - PD2
+ PD, // D4 - PD3
+ PD, // D5 - PD4
+ PD, // D6 - PD5
+ PD, // D7 - PD6
+ PD, // D8 - PD7
+ PB, // D9 - PB0
+ PB, // D10 - PB1
+ NOT_A_PIN, // GND
+ PB, // D12 - PB2
+ PB, // D13 - PB3
+ PB, // D14 - PB4
+ PB, // D15 - PB5
+ PB, // D16 - PB6
+ PB, // D17 - PB7
+ PC, // D18 - PC7
+ PC, // D19 - PC6
+ NOT_A_PIN, // !RESET
+ PC, // D21 - PC5
+ PC, // D22 - PC4
+ NOT_A_PIN // VCC
+};
+
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[24] = {
+ _BV(2), // D0 - PC2
+ _BV(0), // D1 - PD0
+ _BV(1), // D2 - PD1
+ _BV(2), // D3 - PD2
+ _BV(3), // D4 - PD3
+ _BV(4), // D5 - PD4
+ _BV(5), // D6 - PD5
+ _BV(6), // D7 - PD6
+ _BV(7), // D8 - PD7
+ _BV(0), // D9 - PB0
+ _BV(1), // D10 - PB1
+ 0, // GND
+ _BV(2), // D12 - PB2
+ _BV(3), // D13 - PB3
+ _BV(4), // D14 - PB4
+ _BV(5), // D15 - PB5
+ _BV(6), // D16 - PB6
+ _BV(7), // D17 - PB7
+ _BV(7), // D18 - PC7
+ _BV(6), // D19 - PC6
+ 0, // !RESET
+ _BV(5), // D21 - PC5
+ _BV(4), // D22 - PC4
+ 0, // VCC
+};
+
+const uint8_t PROGMEM digital_pin_to_timer_PGM[24] = {
+ NOT_ON_TIMER,
+ TIMER0B, /* 1 */
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ TIMER0A, /* 17 */
+ NOT_ON_TIMER,
+ TIMER1A, /* 19 */
+ NOT_ON_TIMER,
+ TIMER1B, /* 21 */
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+};
+
+uint8_t usb_rxtx_leds;
+
+#endif /* ARDUINO_MAIN */
+#endif /* Pins_Arduino_h */
diff --git a/lib/arduino-standard/arduino_pins.h b/lib/arduino-standard/pins_arduino.h
index a3f349e..a3f349e 100644
--- a/lib/arduino-standard/arduino_pins.h
+++ b/lib/arduino-standard/pins_arduino.h
diff --git a/usb-fastled/Makefile b/usb-fastled/Makefile
index fc7a0b3..e660cb3 100644
--- a/usb-fastled/Makefile
+++ b/usb-fastled/Makefile
@@ -21,7 +21,7 @@
##
NAME := usb-fastled
-BOARD_TYPE := teensy2
+BOARD_TYPE := minimus32
CXX_OBJ := $(NAME).o
LIBS := util led lufa-descriptor-usbserial usbio
CXX_LIBS := arduino-stub
@@ -31,7 +31,6 @@ RESET_FUNC := $(SPREADAVR_PATH)/tools/reset_lufa_cdc_nowait
RESET_PARAM := '!'
FASTLED_PATH := $(SPREADAVR_PATH)/contrib/FastLED-3.1.0
-FASTLED_OPTS := -DCORE_TEENSY
LUFA_PATH := $(SPREADAVR_PATH)/contrib/lufa-LUFA-151115
LUFA_OPTS = -D USB_DEVICE_ONLY
diff --git a/usb-fastled/usb-fastled.cpp b/usb-fastled/usb-fastled.cpp
index a0fcc75..2868ecd 100644
--- a/usb-fastled/usb-fastled.cpp
+++ b/usb-fastled/usb-fastled.cpp
@@ -42,8 +42,8 @@
// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
-#define DATA_PIN 23 // PD5 @ Atmega32U4
-#define CLOCK_PIN 2 // PD1 @ Atmega32U4
+#define DATA_PIN 1
+#define CLOCK_PIN 2
// Define the array of leds
CRGB leds[NUM_LEDS];