12#pragma GCC diagnostic push
13#pragma GCC diagnostic ignored "-Wignored-qualifiers"
16#pragma GCC diagnostic ignored "-Wpragmas"
17#pragma GCC diagnostic ignored "-Wvolatile"
46#if !defined(FASTLED_NO_PINMAP)
59 mPort = (
volatile RwReg*)portOutputRegister(digitalPinToPort(
mPin));
60 mInPort = (
volatile RoReg*)portInputRegister(digitalPinToPort(
mPin));
142 volatile RwReg *
mPort;
162 void setPin(
int pin) {
mPin = pin;
_init(); }
170 inline void hi() __attribute__ ((always_inline)) { *
mPort |=
mPinMask; }
187 virtual void select()
override {
hi(); }
188 virtual void release()
override {
lo(); }
218#ifdef FASTLED_FORCE_SOFTWARE_PINS
224#if !defined(FASTLED_NO_PINMAP)
226 sPort = portOutputRegister(digitalPinToPort(
PIN));
227 sInPort = portInputRegister(digitalPinToPort(
PIN));
277template<u
int8_t PIN>
class FastPin {
284 constexpr static bool validpin() {
return false; }
285 constexpr static bool LowSpeedOnlyRecommended() {
291 static_assert(validpin(),
"Invalid pin specified");
293 static void _init() { }
305 inline static void hi() __attribute__ ((always_inline)) { }
307 inline static void lo() __attribute__ ((always_inline)) { }
310 inline static void strobe() __attribute__ ((always_inline)) { }
313 inline static void toggle() __attribute__ ((always_inline)) { }
335 static port_t hival() __attribute__ ((always_inline)) {
return 0; }
337 static port_t loval() __attribute__ ((always_inline)) {
return 0;}
339 static port_ptr_t port() __attribute__ ((always_inline)) {
return NULL; }
341 static port_t mask() __attribute__ ((always_inline)) {
return 0; }
372#define _FL_DEFINE_PORT(L, BASE) template<> struct __FL_PORT_INFO<L> { \
373 static bool hasPort() { return 1; } \
374 static const char *portName() { return #L; } \
375 typedef BASE __t_baseType; \
376 static const void *portAddr() { return (void*)&__t_baseType::r(); } };
388#define _FL_DEFINE_PORT3(L, LC, BASE) template<> struct __FL_PORT_INFO<LC> { \
389 static bool hasPort() { return 1; } \
390 static const char *portName() { return #L; } \
391 typedef BASE __t_baseType; \
392 static const void *portAddr() { return (void*)&__t_baseType::r(); } };
396#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.
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 hi()
Set the pin state to HIGH
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
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.
uint8_t mPin
Arduino digital pin number.
port_ptr_t port()
Get the output state of the port.
void strobe()
Toggle the pin twice to create a short pulse.
port_t hival()
Gets the state of the port with this pin HIGH
virtual void select() override
Set the pin state to HIGH
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.
volatile uint32_t * ptr_reg32_t
Pointer to a 32-bit register, volatile.
volatile uint32_t & reg32_t
Reference to a 32-bit register, volatile.
Determines which platform system definitions to include.
#define FASTLED_NAMESPACE_END
#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)