14#pragma GCC diagnostic push
15#pragma GCC diagnostic ignored "-Wignored-qualifiers"
18#pragma GCC diagnostic ignored "-Wpragmas"
19#pragma GCC diagnostic ignored "-Wvolatile"
48#if defined(FASTLED_STUB_IMPL) || defined(__EMSCRIPTEN__)
71 inline void hi() __attribute__ ((always_inline)) {}
73 inline void lo() __attribute__ ((always_inline)) {}
76 inline void strobe() __attribute__ ((always_inline)) { }
77 inline void toggle() __attribute__ ((always_inline)) { }
85 port_t hival() __attribute__ ((always_inline)) {
return 0; }
86 port_t loval() __attribute__ ((always_inline)) {
return 0; }
88 static volatile RwReg
port = 0;
91 port_t mask() __attribute__ ((always_inline)) {
return 0xff; }
93 virtual void select()
override {
hi(); }
95 virtual bool isSelected()
override {
return true; }
108#elif !defined(FASTLED_NO_PINMAP)
121 mPort = (
volatile RwReg*)portOutputRegister(digitalPinToPort(
mPin));
122 mInPort = (
volatile RoReg*)portInputRegister(digitalPinToPort(
mPin));
210 volatile RwReg *
mPort;
216 RoReg mInPortFake = 0;
233 void setPin(
int pin) {
mPin = pin;
_init(); }
245 inline void hi() __attribute__ ((always_inline)) { *
mPort |=
mPinMask; }
264 virtual void select()
override {
hi(); }
265 virtual void release()
override {
lo(); }
295#ifdef FASTLED_FORCE_SOFTWARE_PINS
301#if !defined(FASTLED_NO_PINMAP)
303 sPort = portOutputRegister(digitalPinToPort(
PIN));
304 sInPort = portInputRegister(digitalPinToPort(
PIN));
354template<fl::u8 PIN>
class FastPin {
361 constexpr static bool validpin() {
return false; }
362 constexpr static bool LowSpeedOnlyRecommended() {
368 static_assert(validpin(),
"This pin has been marked as an invalid pin, common reasons includes it being a ground pin, read only, or too noisy (e.g. hooked up to the uart).");
370 static void _init() { }
382 inline static void hi() __attribute__ ((always_inline)) { }
384 inline static void lo() __attribute__ ((always_inline)) { }
387 inline static void strobe() __attribute__ ((always_inline)) { }
390 inline static void toggle() __attribute__ ((always_inline)) { }
412 static port_t hival() __attribute__ ((always_inline)) {
return 0; }
414 static port_t loval() __attribute__ ((always_inline)) {
return 0;}
416 static port_ptr_t port() __attribute__ ((always_inline)) {
return NULL; }
418 static port_t mask() __attribute__ ((always_inline)) {
return 0; }
449#define _FL_DEFINE_PORT(L, BASE) template<> struct __FL_PORT_INFO<L> { \
450 static bool hasPort() { return 1; } \
451 static const char *portName() { return #L; } \
452 typedef BASE __t_baseType; \
453 static const void *portAddr() { return (void*)&__t_baseType::r(); } };
465#define _FL_DEFINE_PORT3(L, LC, BASE) template<> struct __FL_PORT_INFO<LC> { \
466 static bool hasPort() { return 1; } \
467 static const char *portName() { return #L; } \
468 typedef BASE __t_baseType; \
469 static const void *portAddr() { return (void*)&__t_baseType::r(); } };
473#pragma GCC diagnostic pop
central include file for FastLED, defines the CFastLED class/object
static volatile RoReg * sInPort
static port_t hival()
Gets the state of the port with this pin HIGH
RwReg port_t
type for a pin read/write register, non-volatile
static void toggle()
Toggle the pin.
static void hi(FASTLED_REGISTER port_ptr_t port)
Set the same pin on another port to HIGH
static port_t loval()
Gets the state of the port with this pin LOW
static void lo(FASTLED_REGISTER port_ptr_t port)
Set the same pin on another port to LOW
static void set(FASTLED_REGISTER port_t val)
Set the state of the output register.
static volatile RwReg * sPort
static port_t mask()
Get the pin mask.
volatile RwReg * port_ptr_t
type for a pin read/write register, volatile
static void lo()
Set the pin state to LOW
static void setOutput()
Set the pin mode as OUTPUT
static void strobe()
Toggle the pin twice to create a short pulse.
static void fastset(FASTLED_REGISTER port_ptr_t port, FASTLED_REGISTER port_t val)
Set the state of a port.
static void hi()
Set the pin state to HIGH
static void setInput()
Set the pin mode as INPUT
FastPin implementation for bit-banded access.
The simplest level of Pin class.
OutputPin(int pin)
Constructor.
I/O pin initially set to OUTPUT.
volatile RwReg * mPort
Output register for the pin.
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_NULL_DEREFERENCE void hi()
Set the pin state to HIGH
void fastset(FASTLED_REGISTER port_ptr_t port, FASTLED_REGISTER port_t val)
Set the state of a port.
void lo(FASTLED_REGISTER port_ptr_t port)
Set the same pin on another port to LOW
void setOutput()
Set the pin mode as OUTPUT
void set(FASTLED_REGISTER port_t val)
Set the state of the output register.
port_t loval()
Gets the state of the port with this pin LOW
void setInput()
Set the pin mode as INPUT
virtual bool isSelected() override
Checks if the pin is currently HIGH
void _init()
Initialize the class by retrieving the register pointers and bitmask.
void toggle()
Toggle the pin.
void hi(FASTLED_REGISTER port_ptr_t port)
Set the same pin on another port to HIGH
virtual void release() override
Set the pin state to LOW
void lo()
Set the pin state to LOW
FL_DISABLE_WARNING_POP void strobe()
Toggle the pin twice to create a short pulse.
volatile RoReg * mInPort
Input register for the pin.
RwReg mPinMask
Bitmask for the pin within its register.
volatile RwReg * port_ptr_t
type for a pin read/write register, volatile
RwReg port_t
type for a pin read/write register, non-volatile
port_t mask()
Get the pin mask.
port_ptr_t port()
Get the output state of the port.
port_t hival()
Gets the state of the port with this pin HIGH
virtual void select() override
Set the pin state to HIGH
fl::u8 mPin
Arduino digital pin number.
Naive fallback solution for low level pin access.
virtual void release()=0
Release this object.
virtual void select()=0
Select this object.
virtual bool isSelected()=0
Check if this object is currently selected.
Abstract class for "selectable" things.
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_NULL_DEREFERENCE
#define FL_DISABLE_WARNING_POP
volatile fl::u32 & reg32_t
Reference to a 32-bit register, volatile.
volatile fl::u32 * ptr_reg32_t
Pointer to a 32-bit register, volatile.
Determines which platform system definitions to include.
#define FASTLED_NAMESPACE_END
#define FASTLED_NAMESPACE_BEGIN
#define FASTLED_REGISTER
Helper macro to replace the deprecated 'register' keyword if we're using modern C++ where it's been r...
static const void * portAddr()
Gets the raw address of the port.
static bool hasPort()
Checks whether a port exists.
static const char * portName()
Gets the name of the port, as a C-string.
Utility template for tracking down information about pins and ports.
#define FASTLED_UNUSED(x)