compiles avr

This commit is contained in:
Michael Miller
2024-04-17 12:01:03 -07:00
parent af2cf886a2
commit 1d3c95d23a
21 changed files with 164 additions and 58 deletions

View File

@@ -42,6 +42,26 @@ const uint16_t PixelIndex_OutOfBounds = 0xffff;
#include "internal/NeoBusChannel.h" #include "internal/NeoBusChannel.h"
#include "internal/NeoMethods.h" #include "internal/NeoMethods.h"
struct BusView
{
BusView(uint16_t stripCount) :
PixelCount(stripCount),
StripCount(stripCount)
{
}
BusView(uint16_t repeatedPixelsCount,
uint16_t stripCount ) :
PixelCount(repeatedPixelsCount),
StripCount(stripCount)
{
}
const uint16_t PixelCount; // exposed count of pixels that will be repeated to fill strip
const uint16_t StripCount; // actual data stream count of pixels
};
// T_COLOR_FEATURE - // T_COLOR_FEATURE -
// The color feature object that defines bit depth, order, and any settings related // The color feature object that defines bit depth, order, and any settings related
// to them // to them
@@ -61,57 +81,61 @@ template<typename T_COLOR_FEATURE,
class NeoPixelBus class NeoPixelBus
{ {
public: public:
NeoPixelBus(uint16_t countPixels, uint8_t pin) : NeoPixelBus(const BusView& busView, uint8_t pin) :
_countPixels(countPixels), _countPixels(busView.PixelCount),
_pixels(nullptr), _pixels(nullptr),
_method(pin, countPixels, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize), _method(pin, busView.StripCount, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize),
_shader() _shader()
{ {
} }
NeoPixelBus(uint16_t countPixels, uint8_t pin, NeoBusChannel channel) : NeoPixelBus(const BusView& busView, uint8_t pin, NeoBusChannel channel) :
_countPixels(countPixels), _countPixels(busView.PixelCount),
_pixels(nullptr), _pixels(nullptr),
_method(pin, countPixels, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize, channel), _method(pin, busView.StripCount, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize, channel),
_shader() _shader()
{ {
} }
NeoPixelBus(uint16_t countPixels, uint8_t pinClock, uint8_t pinData) : NeoPixelBus(const BusView& busView, uint8_t pinClock, uint8_t pinData) :
_countPixels(countPixels), _countPixels(busView.PixelCount),
_pixels(nullptr), _pixels(nullptr),
_method(pinClock, pinData, countPixels, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize), _method(pinClock, pinData, busView.StripCount, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize),
_shader() _shader()
{ {
} }
NeoPixelBus(uint16_t countPixels, uint8_t pinClock, uint8_t pinData, uint8_t pinLatch, uint8_t pinOutputEnable = NOT_A_PIN) : NeoPixelBus(const BusView& busView, uint8_t pinClock, uint8_t pinData, uint8_t pinLatch, uint8_t pinOutputEnable = NOT_A_PIN) :
_countPixels(countPixels), _countPixels(busView.PixelCount),
_pixels(nullptr), _pixels(nullptr),
_method(pinClock, pinData, pinLatch, pinOutputEnable, countPixels, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize), _method(pinClock, pinData, pinLatch, pinOutputEnable, busView.StripCount, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize),
_shader() _shader()
{ {
} }
NeoPixelBus(uint16_t countPixels) : NeoPixelBus(const BusView& busView) :
_countPixels(countPixels), _countPixels(busView.PixelCount),
_pixels(nullptr), _pixels(nullptr),
_method(countPixels, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize), _method(busView.StripCount, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize),
_shader() _shader()
{ {
} }
NeoPixelBus(uint16_t countPixels, Stream* pixieStream) : NeoPixelBus(const BusView& busView, Stream* pixieStream) :
_countPixels(countPixels), _countPixels(busView.PixelCount),
_pixels(nullptr), _pixels(nullptr),
_method(countPixels, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize, pixieStream), _method(busView.StripCount, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize, pixieStream),
_shader() _shader()
{ {
} }
~NeoPixelBus() ~NeoPixelBus()
{ {
#if defined(NEOPIXEBUS_NO_ARRAY_NEW)
free(_pixels);
#else
delete[] _pixels; delete[] _pixels;
#endif
} }
@@ -120,6 +144,7 @@ public:
return NeoBufferContext<T_EXPOSED_COLOR_OBJECT>(_pixels, _countPixels); return NeoBufferContext<T_EXPOSED_COLOR_OBJECT>(_pixels, _countPixels);
} }
void Begin() void Begin()
{ {
_method.Initialize(); _method.Initialize();
@@ -331,7 +356,11 @@ protected:
void _initialize() void _initialize()
{ {
#if defined(NEOPIXEBUS_NO_ARRAY_NEW)
_pixels = static_cast<T_EXPOSED_COLOR_OBJECT*>(malloc(_countPixels * sizeof(T_EXPOSED_COLOR_OBJECT)));
#else
_pixels = new T_EXPOSED_COLOR_OBJECT[_countPixels]; _pixels = new T_EXPOSED_COLOR_OBJECT[_countPixels];
#endif
ClearTo(0); ClearTo(0);
} }

View File

@@ -97,51 +97,51 @@ class NeoPixelBusLg :
LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>> LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>>
{ {
public: public:
NeoPixelBusLg(uint16_t countPixels, uint8_t pin) : NeoPixelBusLg(const BusView& busView, uint8_t pin) :
NeoPixelBus<T_COLOR_FEATURE, NeoPixelBus<T_COLOR_FEATURE,
T_METHOD, T_METHOD,
T_EXPOSED_COLOR_OBJECT, T_EXPOSED_COLOR_OBJECT,
LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>>(countPixels, pin) LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>>(busView, pin)
{ {
} }
NeoPixelBusLg(uint16_t countPixels, uint8_t pin, NeoBusChannel channel) : NeoPixelBusLg(const BusView& busView, uint8_t pin, NeoBusChannel channel) :
NeoPixelBus<T_COLOR_FEATURE, NeoPixelBus<T_COLOR_FEATURE,
T_METHOD, T_METHOD,
T_EXPOSED_COLOR_OBJECT, T_EXPOSED_COLOR_OBJECT,
LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>>(countPixels, pin, channel) LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>>(busView, pin, channel)
{ {
} }
NeoPixelBusLg(uint16_t countPixels, uint8_t pinClock, uint8_t pinData) : NeoPixelBusLg(const BusView& busView, uint8_t pinClock, uint8_t pinData) :
NeoPixelBus<T_COLOR_FEATURE, NeoPixelBus<T_COLOR_FEATURE,
T_METHOD, T_METHOD,
T_EXPOSED_COLOR_OBJECT, T_EXPOSED_COLOR_OBJECT,
LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>>(countPixels, pinClock, pinData) LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>>(busView, pinClock, pinData)
{ {
} }
NeoPixelBusLg(uint16_t countPixels, uint8_t pinClock, uint8_t pinData, uint8_t pinLatch, uint8_t pinOutputEnable = NOT_A_PIN) : NeoPixelBusLg(const BusView& busView, uint8_t pinClock, uint8_t pinData, uint8_t pinLatch, uint8_t pinOutputEnable = NOT_A_PIN) :
NeoPixelBus<T_COLOR_FEATURE, NeoPixelBus<T_COLOR_FEATURE,
T_METHOD, T_METHOD,
T_EXPOSED_COLOR_OBJECT, T_EXPOSED_COLOR_OBJECT,
LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>>(countPixels, pinClock, pinData, pinLatch, pinOutputEnable) LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>>(busView, pinClock, pinData, pinLatch, pinOutputEnable)
{ {
} }
NeoPixelBusLg(uint16_t countPixels) : NeoPixelBusLg(const BusView& busView) :
NeoPixelBus<T_COLOR_FEATURE, NeoPixelBus<T_COLOR_FEATURE,
T_METHOD, T_METHOD,
T_EXPOSED_COLOR_OBJECT, T_EXPOSED_COLOR_OBJECT,
LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>>(countPixels) LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>>(busView)
{ {
} }
NeoPixelBusLg(uint16_t countPixels, Stream* pixieStream) : NeoPixelBusLg(const BusView& busView, Stream* pixieStream) :
NeoPixelBus<T_COLOR_FEATURE, NeoPixelBus<T_COLOR_FEATURE,
T_METHOD, T_METHOD,
T_EXPOSED_COLOR_OBJECT, T_EXPOSED_COLOR_OBJECT,
LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>>(countPixels, pixieStream) LuminanceShader<T_EXPOSED_COLOR_OBJECT, typename T_COLOR_FEATURE::ColorObject, T_GAMMA>>(busView, pixieStream)
{ {
} }

View File

@@ -32,10 +32,33 @@ License along with NeoPixel. If not, see
// ...then you can either add the platform symbol to the list so NEOPIXEBUS_NO_STL gets defined or // ...then you can either add the platform symbol to the list so NEOPIXEBUS_NO_STL gets defined or
// go to boards.txt and enable c++ by adding (teensy31.build.flags.libs=-lstdc++) and set to "smallest code" option in Arduino // go to boards.txt and enable c++ by adding (teensy31.build.flags.libs=-lstdc++) and set to "smallest code" option in Arduino
// //
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR) || defined(STM32L432xx) || defined(STM32L476xx) || defined(ARDUINO_ARCH_SAM) #if defined(ARDUINO_ARCH_AVR) || \
defined(ARDUINO_ARCH_MEGAAVR) || \
defined(STM32L432xx) || \
defined(STM32L476xx) || \
defined(ARDUINO_ARCH_SAM)
#define NEOPIXEBUS_NO_STL 1 #define NEOPIXEBUS_NO_STL 1
#endif #endif
// some platforms do not support a yield statement
#if defined(ARDUINO_TEEONARDU_LEO) || \
defined(ARDUINO_TEEONARDU_FLORA) || \
defined(ARDUINO_AVR_DIGISPARK) || \
defined(ARDUINO_AVR_DIGISPARKPRO)
#define NEOPIXEBUS_NO_YIELD 1
#endif
// some platforms do not support String
#if defined(ARDUINO_AVR_DIGISPARK)
#define NEOPIXEBUS_NO_STRING 1
#endif
// some platforms do not support new []!?
#if defined(ARDUINO_AVR_DIGISPARK) || \
defined(ARDUINO_AVR_DIGISPARKPRO)
#define NEOPIXEBUS_NO_ARRAY_NEW 1
#endif
// some platforms do not define this standard progmem type for some reason // some platforms do not define this standard progmem type for some reason
// //
#ifndef PGM_VOID_P #ifndef PGM_VOID_P

View File

@@ -25,6 +25,7 @@ License along with NeoPixel. If not, see
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
#include <Arduino.h> #include <Arduino.h>
#include "../NeoUtil.h"
#include "../NeoSettings.h" #include "../NeoSettings.h"
#include "RgbColorBase.h" #include "RgbColorBase.h"
#include "RgbColor.h" #include "RgbColor.h"

View File

@@ -26,6 +26,7 @@ License along with NeoPixel. If not, see
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
#include <Arduino.h> #include <Arduino.h>
#include "../NeoUtil.h"
#include "../NeoSettings.h" #include "../NeoSettings.h"
#include "RgbColorBase.h" #include "RgbColorBase.h"
#include "RgbColor.h" #include "RgbColor.h"

View File

@@ -25,6 +25,7 @@ License along with NeoPixel. If not, see
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
#include <Arduino.h> #include <Arduino.h>
#include "../NeoUtil.h"
#include "../NeoSettings.h" #include "../NeoSettings.h"
#include "RgbColorBase.h" #include "RgbColorBase.h"
#include "RgbColor.h" #include "RgbColor.h"

View File

@@ -249,7 +249,7 @@ struct HtmlColor
return Parse<T_HTMLCOLORNAMES>(name, MAX_HTML_COLOR_NAME_LEN + 1); return Parse<T_HTMLCOLORNAMES>(name, MAX_HTML_COLOR_NAME_LEN + 1);
} }
#if !defined(ARDUINO_AVR_DIGISPARK) #if !defined(NEOPIXEBUS_NO_STRING)
template <typename T_HTMLCOLORNAMES> size_t Parse(String const &name) template <typename T_HTMLCOLORNAMES> size_t Parse(String const &name)
{ {
return Parse<T_HTMLCOLORNAMES>(name.c_str(), name.length() + 1); return Parse<T_HTMLCOLORNAMES>(name.c_str(), name.length() + 1);

View File

@@ -25,6 +25,7 @@ License along with NeoPixel. If not, see
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
#include <Arduino.h> #include <Arduino.h>
#include "../NeoUtil.h"
#include "../NeoSettings.h" #include "../NeoSettings.h"
#include "RgbColorBase.h" #include "RgbColorBase.h"
#include "RgbColor.h" #include "RgbColor.h"

View File

@@ -25,6 +25,7 @@ License along with NeoPixel. If not, see
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
#include <Arduino.h> #include <Arduino.h>
#include "../NeoUtil.h"
#include "../NeoSettings.h" #include "../NeoSettings.h"
#include "RgbColorBase.h" #include "RgbColorBase.h"
#include "RgbColor.h" #include "RgbColor.h"

View File

@@ -25,6 +25,7 @@ License along with NeoPixel. If not, see
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
#include <Arduino.h> #include <Arduino.h>
#include "../NeoUtil.h"
#include "../NeoSettings.h" #include "../NeoSettings.h"
#include "RgbColorBase.h" #include "RgbColorBase.h"
#include "RgbColor.h" #include "RgbColor.h"

View File

@@ -25,6 +25,7 @@ License along with NeoPixel. If not, see
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
#include <Arduino.h> #include <Arduino.h>
#include "../NeoUtil.h"
#include "../NeoSettings.h" #include "../NeoSettings.h"
#include "RgbColorBase.h" #include "RgbColorBase.h"
#include "RgbColor.h" #include "RgbColor.h"

View File

@@ -25,6 +25,7 @@ License along with NeoPixel. If not, see
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
#include <Arduino.h> #include <Arduino.h>
#include "../NeoUtil.h"
#include "../NeoSettings.h" #include "../NeoSettings.h"
#include "RgbColorBase.h" #include "RgbColorBase.h"
#include "RgbColor.h" #include "RgbColor.h"

View File

@@ -26,6 +26,7 @@ License along with NeoPixel. If not, see
#include <Arduino.h> #include <Arduino.h>
#include "../NeoUtil.h"
#include "../NeoSettings.h" #include "../NeoSettings.h"
#include "RgbColorBase.h" #include "RgbColorBase.h"
#include "RgbColor.h" #include "RgbColor.h"

View File

@@ -25,6 +25,7 @@ License along with NeoPixel. If not, see
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
#include <Arduino.h> #include <Arduino.h>
#include "../NeoUtil.h"
#include "../NeoSettings.h" #include "../NeoSettings.h"
#include "RgbColorBase.h" #include "RgbColorBase.h"
#include "RgbColor.h" #include "RgbColor.h"

View File

@@ -25,6 +25,7 @@ License along with NeoPixel. If not, see
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
#include <Arduino.h> #include <Arduino.h>
#include "../NeoUtil.h"
#include "../NeoSettings.h" #include "../NeoSettings.h"
#include "RgbColorBase.h" #include "RgbColorBase.h"
#include "RgbColor.h" #include "RgbColor.h"

View File

@@ -174,7 +174,8 @@ public:
[[maybe_unused]] uint16_t pixelCount, [[maybe_unused]] uint16_t pixelCount,
[[maybe_unused]] size_t elementSize, [[maybe_unused]] size_t elementSize,
[[maybe_unused]] size_t settingsSize) : [[maybe_unused]] size_t settingsSize) :
_pin(pin) _pin(pin),
_pixelCount(pixelCount)
{ {
pinMode(pin, OUTPUT); pinMode(pin, OUTPUT);
_port = portOutputRegister(digitalPinToPort(pin)); _port = portOutputRegister(digitalPinToPort(pin));
@@ -211,7 +212,7 @@ public:
{ {
while (!IsReadyToUpdate()) while (!IsReadyToUpdate())
{ {
#if !defined(ARDUINO_TEEONARDU_LEO) && !defined(ARDUINO_TEEONARDU_FLORA) && !defined(ARDUINO_AVR_DIGISPARK) #if !defined(NEOPIXEBUS_NO_YIELD)
yield(); // allows for system yield if needed yield(); // allows for system yield if needed
#endif #endif
} }
@@ -222,26 +223,34 @@ public:
noInterrupts(); // Need 100% focus on instruction timing noInterrupts(); // Need 100% focus on instruction timing
// if there are settings at the front // if there are settings at the front
//
if (T_COLOR_FEATURE::applyFrontSettings(sendData, sendDataSize, featureSettings)) if (T_COLOR_FEATURE::applyFrontSettings(sendData, sendDataSize, featureSettings))
{ {
T_SPEED::send_data(sendData, T_COLOR_FEATURE::SettingsSize, _port, _pinMask); T_SPEED::send_data(sendData, T_COLOR_FEATURE::SettingsSize, _port, _pinMask);
} }
// send primary color data // send primary color data
//
T_COLOR_OBJECT* pixel = pixels; T_COLOR_OBJECT* pixel = pixels;
T_COLOR_OBJECT* pixelEnd = pixel + countPixels; const T_COLOR_OBJECT* pixelEnd = pixel + countPixels;
uint16_t stripCount = _pixelCount;
while (pixel < pixelEnd) while (--stripCount)
{ {
typename T_COLOR_FEATURE::ColorObject color = shader.Apply(*pixel); typename T_COLOR_FEATURE::ColorObject color = shader.Apply(*pixel);
T_COLOR_FEATURE::applyPixelColor(sendData, T_COLOR_FEATURE::PixelSize, color); T_COLOR_FEATURE::applyPixelColor(sendData, T_COLOR_FEATURE::PixelSize, color);
T_SPEED::send_data(sendData, T_COLOR_FEATURE::PixelSize, _port, _pinMask); T_SPEED::send_data(sendData, T_COLOR_FEATURE::PixelSize, _port, _pinMask);
pixel++; if (++pixel == pixelEnd)
{
// restart at first
pixel = pixels;
}
} }
// if there are settings at the back // if there are settings at the back
//
if (T_COLOR_FEATURE::applyBackSettings(sendData, sendDataSize, featureSettings)) if (T_COLOR_FEATURE::applyBackSettings(sendData, sendDataSize, featureSettings))
{ {
T_SPEED::send_data(sendData, T_COLOR_FEATURE::SettingsSize, _port, _pinMask); T_SPEED::send_data(sendData, T_COLOR_FEATURE::SettingsSize, _port, _pinMask);
@@ -259,6 +268,7 @@ public:
protected: protected:
const uint8_t _pin; // output pin number const uint8_t _pin; // output pin number
const uint16_t _pixelCount; // count of pixels in the strip
volatile uint8_t* _port; // Output PORT register volatile uint8_t* _port; // Output PORT register
uint32_t _endTime; // Latch timing reference uint32_t _endTime; // Latch timing reference

View File

@@ -30,6 +30,7 @@ License along with NeoPixel. If not, see
#if defined(ARDUINO_ARCH_ESP32) && !defined(ARDUINO_ESP32C6_DEV) && !defined(ARDUINO_ESP32H2_DEV) #if defined(ARDUINO_ARCH_ESP32) && !defined(ARDUINO_ESP32C6_DEV) && !defined(ARDUINO_ESP32H2_DEV)
#include <Arduino.h> #include <Arduino.h>
#include "../NeoUtil.h"
#include "../NeoSettings.h" #include "../NeoSettings.h"
#include "../NeoBusChannel.h" #include "../NeoBusChannel.h"
#include "NeoEsp32RmtMethod.h" #include "NeoEsp32RmtMethod.h"

View File

@@ -27,6 +27,7 @@ License along with NeoPixel. If not, see
#ifdef ARDUINO_ARCH_ESP8266 #ifdef ARDUINO_ARCH_ESP8266
#include <Arduino.h> #include <Arduino.h>
#include "../NeoUtil.h"
#include "../NeoSettings.h" #include "../NeoSettings.h"
#include "NeoEsp8266UartMethod.h" #include "NeoEsp8266UartMethod.h"
#include <utility> #include <utility>

View File

@@ -33,6 +33,10 @@ License along with NeoPixel. If not, see
<http://www.gnu.org/licenses/>. <http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
// Handy AVR ASM Reference links:
// https://onlinedocs.microchip.com/pr/GUID-317042D4-BCCE-4065-BB05-AC4312DBC2C4-en-US-2/index.html?GUID-E152F8C1-EEE2-4A9D-A728-568E1B02F740
//
// must also check for arm due to Teensy incorrectly having ARDUINO_ARCH_AVR set // must also check for arm due to Teensy incorrectly having ARDUINO_ARCH_AVR set
#if (defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR)) && !defined(__arm__) #if (defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR)) && !defined(__arm__)
@@ -169,10 +173,12 @@ void send_data_8mhz_800_PortD(uint8_t* data, size_t sizeData, uint8_t pinMask)
"mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi
"out %[port] , %[lo]" "\n\t" // 1 PORT = lo "out %[port] , %[lo]" "\n\t" // 1 PORT = lo
"brne headD" "\n" // 2 while(i) (Z flag set above) "brne headD" "\n" // 2 while(i) (Z flag set above)
// outputs
: [byte] "+r" (b), : [byte] "+r" (b),
[n1] "+r" (n1), [n1] "+r" (n1),
[n2] "+r" (n2), [n2] "+r" (n2),
[count] "+w" (i) [count] "+w" (i)
// inputs
: [port] "I" (_SFR_IO_ADDR(PORTD)), : [port] "I" (_SFR_IO_ADDR(PORTD)),
[ptr] "e" (ptr), [ptr] "e" (ptr),
[hi] "r" (hi), [hi] "r" (hi),
@@ -266,8 +272,15 @@ void send_data_8mhz_800_PortB(uint8_t* data, size_t sizeData, uint8_t pinMask)
"mov %[n1] , %[hi]" "\n\t" "mov %[n1] , %[hi]" "\n\t"
"out %[port] , %[lo]" "\n\t" "out %[port] , %[lo]" "\n\t"
"brne headB" "\n" "brne headB" "\n"
: [byte] "+r" (b), [n1] "+r" (n1), [n2] "+r" (n2), [count] "+w" (i) // outputs
: [port] "I" (_SFR_IO_ADDR(PORTB)), [ptr] "e" (ptr), [hi] "r" (hi), : [byte] "+r" (b),
[n1] "+r" (n1),
[n2] "+r" (n2),
[count] "+w" (i)
// inputs
: [port] "I" (_SFR_IO_ADDR(PORTB)),
[ptr] "e" (ptr),
[hi] "r" (hi),
[lo] "r" (lo)); [lo] "r" (lo));
} }
@@ -318,14 +331,16 @@ void send_data_8mhz_400(uint8_t* data, size_t sizeData, volatile uint8_t* port,
"ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 16) "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 16)
"sbiw %[count], 1" "\n\t" // 2 i-- (T = 18) "sbiw %[count], 1" "\n\t" // 2 i-- (T = 18)
"brne head20" "\n" // 2 if(i != 0) -> (next byte) "brne head20" "\n" // 2 if(i != 0) -> (next byte)
// outputs
: [port] "+e" (port), : [port] "+e" (port),
[byte] "+r" (b), [byte] "+r" (b), // l = lower register
[bit] "+r" (bit), [bit] "+d" (bit), // d = upper register, due to ldi, must be upper register
[next] "+r" (next), [next] "+r" (next),
[count] "+w" (i) [count] "+w" (i)
: [hi] "r" (hi), // inputs
[lo] "r" (lo), : [ptr] "e" (ptr),
[ptr] "e" (ptr)); [hi] "r" (hi), // a = simple upper register (16-23)
[lo] "r" (lo));
} }
#elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL) // 12Mhz CPU #elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL) // 12Mhz CPU
@@ -394,9 +409,11 @@ void send_data_12mhz_800_PortD(uint8_t* data, size_t sizeData, uint8_t pinMask)
"out %[port], %[lo]" "\n\t" // 1 PORT = lo (T = 11) "out %[port], %[lo]" "\n\t" // 1 PORT = lo (T = 11)
"ret" "\n\t" // 4 nop nop nop nop (T = 15) "ret" "\n\t" // 4 nop nop nop nop (T = 15)
"doneD:" "\n" "doneD:" "\n"
// outputs
: [byte] "+r" (b), : [byte] "+r" (b),
[next] "+r" (next), [next] "+r" (next),
[count] "+w" (i) [count] "+w" (i)
// inputs
: [port] "I" (_SFR_IO_ADDR(PORTD)), : [port] "I" (_SFR_IO_ADDR(PORTD)),
[ptr] "e" (ptr), [ptr] "e" (ptr),
[hi] "r" (hi), [hi] "r" (hi),
@@ -461,8 +478,14 @@ void send_data_12mhz_800_PortB(uint8_t* data, size_t sizeData, uint8_t pinMask)
"out %[port], %[lo]" "\n\t" "out %[port], %[lo]" "\n\t"
"ret" "\n\t" "ret" "\n\t"
"doneB:" "\n" "doneB:" "\n"
: [byte] "+r" (b), [next] "+r" (next), [count] "+w" (i) // outputs
: [port] "I" (_SFR_IO_ADDR(PORTB)), [ptr] "e" (ptr), [hi] "r" (hi), : [byte] "+r" (b),
[next] "+r" (next),
[count] "+w" (i)
// inputs
: [port] "I" (_SFR_IO_ADDR(PORTB)),
[ptr] "e" (ptr),
[hi] "r" (hi),
[lo] "r" (lo)); [lo] "r" (lo));
} }
@@ -514,14 +537,16 @@ void send_data_12mhz_400(uint8_t* data,
"ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 26) "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 26)
"sbiw %[count], 1" "\n\t" // 2 i-- (T = 28) "sbiw %[count], 1" "\n\t" // 2 i-- (T = 28)
"brne head30" "\n" // 1-2 if(i != 0) -> (next byte) "brne head30" "\n" // 1-2 if(i != 0) -> (next byte)
// outputs
: [port] "+e" (port), : [port] "+e" (port),
[byte] "+r" (b), [byte] "+r" (b),
[bit] "+r" (bit), [bit] "+d" (bit), // d = upper register, due to ldi, must be upper register
[next] "+r" (next), [next] "+r" (next),
[count] "+w" (i) [count] "+w" (i)
: [hi] "r" (hi), // inputs
[lo] "r" (lo), : [ptr] "e" (ptr),
[ptr] "e" (ptr)); [hi] "r" (hi), // a = simple upper register (16-23)
[lo] "r" (lo));
} }
#elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000UL) // 16Mhz CPU #elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000UL) // 16Mhz CPU
@@ -571,13 +596,15 @@ void send_data_16mhz_800(uint8_t* data, size_t sizeData, volatile uint8_t* port,
"nop" "\n\t" // 1 nop (T = 16) "nop" "\n\t" // 1 nop (T = 16)
"sbiw %[count], 1" "\n\t" // 2 i-- (T = 18) "sbiw %[count], 1" "\n\t" // 2 i-- (T = 18)
"brne head20" "\n" // 2 if(i != 0) -> (next byte) "brne head20" "\n" // 2 if(i != 0) -> (next byte)
// outputs
: [port] "+e" (port), : [port] "+e" (port),
[byte] "+r" (b), [byte] "+r" (b), // l = lower register
[bit] "+r" (bit), [bit] "+d" (bit), // d = upper register, due to ldi, must be upper register
[next] "+r" (next), [next] "+r" (next),
[count] "+w" (i) [count] "+w" (i)
// inputs
: [ptr] "e" (ptr), : [ptr] "e" (ptr),
[hi] "r" (hi), [hi] "r" (hi), // a = simple upper register (16-23)
[lo] "r" (lo)); [lo] "r" (lo));
} }
@@ -639,11 +666,13 @@ void send_data_16mhz_400(uint8_t* data,
"rjmp .+0" "\n\t" // 2 nop nop (T = 36) "rjmp .+0" "\n\t" // 2 nop nop (T = 36)
"sbiw %[count], 1" "\n\t" // 2 i-- (T = 38) "sbiw %[count], 1" "\n\t" // 2 i-- (T = 38)
"brne head40" "\n" // 1-2 if(i != 0) -> (next byte) "brne head40" "\n" // 1-2 if(i != 0) -> (next byte)
// outputs
: [port] "+e" (port), : [port] "+e" (port),
[byte] "+r" (b), [byte] "+r" (b),
[bit] "+r" (bit), [bit] "+d" (bit), // d = upper register, due to ldi, must be upper register
[next] "+r" (next), [next] "+r" (next),
[count] "+w" (i) [count] "+w" (i)
// inputs
: [ptr] "e" (ptr), : [ptr] "e" (ptr),
[hi] "r" (hi), [hi] "r" (hi),
[lo] "r" (lo)); [lo] "r" (lo));
@@ -701,11 +730,13 @@ void send_data_16mhz_600(uint8_t* data,
"ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 23) "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 23)
"sbiw %[count], 1" "\n\t" // 2 i-- (T = 25) "sbiw %[count], 1" "\n\t" // 2 i-- (T = 25)
"brne head60" "\n" // 1-2 if(i != 0) -> (next byte) "brne head60" "\n" // 1-2 if(i != 0) -> (next byte)
// outputs
: [port] "+e" (port), : [port] "+e" (port),
[byte] "+r" (b), [byte] "+r" (b),
[bit] "+r" (bit), [bit] "+d" (bit), // d = upper register, due to ldi, must be upper register
[next] "+r" (next), [next] "+r" (next),
[count] "+w" (i) [count] "+w" (i)
// inputs
: [ptr] "e" (ptr), : [ptr] "e" (ptr),
[hi] "r" (hi), [hi] "r" (hi),
[lo] "r" (lo)); [lo] "r" (lo));
@@ -769,7 +800,7 @@ void send_data_32mhz(uint8_t* data,
// outputs // outputs
: [port] "+e" (port), : [port] "+e" (port),
[byte] "+r" (b), [byte] "+r" (b),
[bit] "+r" (bit), [bit] "+d" (bit), // d = upper register, due to ldi, must be upper register
[next] "+r" (next), [next] "+r" (next),
[cycle] "+r" (cycle), [cycle] "+r" (cycle),
[count] "+w" (i) [count] "+w" (i)

View File

@@ -111,7 +111,7 @@ public:
{ {
while (!IsReadyToUpdate()) while (!IsReadyToUpdate())
{ {
#if !defined(ARDUINO_TEEONARDU_LEO) && !defined(ARDUINO_TEEONARDU_FLORA) && !defined(ARDUINO_AVR_DIGISPARK) #if !defined(NEOPIXEBUS_NO_YIELD)
yield(); // allows for system yield if needed yield(); // allows for system yield if needed
#endif #endif
} }

View File

@@ -86,7 +86,7 @@ public:
{ {
while (!IsReadyToUpdate()) while (!IsReadyToUpdate())
{ {
#if !defined(ARDUINO_TEEONARDU_LEO) && !defined(ARDUINO_TEEONARDU_FLORA) && !defined(ARDUINO_AVR_DIGISPARK) #if !defined(NEOPIXEBUS_NO_YIELD)
yield(); // allows for system yield if needed yield(); // allows for system yield if needed
#endif #endif
} }