9#pragma GCC diagnostic push
10#pragma GCC diagnostic ignored "-Wignored-qualifiers"
15FASTLED_NAMESPACE_BEGIN
35#if !defined(FASTLED_NO_PINMAP)
39 volatile RwReg *mPort;
40 volatile RoReg *mInPort;
47 mPinMask = digitalPinToBitMask(mPin);
48 mPort = (
volatile RwReg*)portOutputRegister(digitalPinToPort(mPin));
49 mInPort = (
volatile RoReg*)portInputRegister(digitalPinToPort(mPin));
55 Pin(
int pin) : mPin(pin) { _init(); }
64 inline void setInput() { pinMode(mPin, INPUT); }
67 inline void hi() __attribute__ ((always_inline)) { *mPort |= mPinMask; }
69 inline void lo() __attribute__ ((always_inline)) { *mPort &= ~mPinMask; }
75 inline void toggle() __attribute__ ((always_inline)) { *mInPort = mPinMask; }
86 inline void set(FASTLED_REGISTER
port_t val) __attribute__ ((always_inline)) { *mPort = val; }
94 port_t hival() __attribute__ ((always_inline)) {
return *mPort | mPinMask; }
96 port_t loval() __attribute__ ((always_inline)) {
return *mPort & ~mPinMask; }
100 port_t mask() __attribute__ ((always_inline)) {
return mPinMask; }
107 virtual bool isSelected() {
return (*mPort & mPinMask) == mPinMask; }
128 volatile RwReg *mPort;
129 volatile RoReg *mInPort;
141 Pin(
int pin) : mPin(pin) { _init(); }
143 void setPin(
int pin) { mPin = pin; _init(); }
151 inline void hi() __attribute__ ((always_inline)) { *mPort |= mPinMask; }
152 inline void lo() __attribute__ ((always_inline)) { *mPort &= ~mPinMask; }
155 inline void toggle() __attribute__ ((always_inline)) { *mInPort = mPinMask; }
157 inline void hi(FASTLED_REGISTER
port_ptr_t port) __attribute__ ((always_inline)) { *
port |= mPinMask; }
158 inline void lo(FASTLED_REGISTER
port_ptr_t port) __attribute__ ((always_inline)) { *
port &= ~mPinMask; }
159 inline void set(FASTLED_REGISTER
port_t val) __attribute__ ((always_inline)) { *mPort = val; }
163 port_t hival() __attribute__ ((always_inline)) {
return *mPort | mPinMask; }
164 port_t loval() __attribute__ ((always_inline)) {
return *mPort & ~mPinMask; }
165 port_ptr_t port() __attribute__ ((always_inline)) {
return mPort; }
166 port_t mask() __attribute__ ((always_inline)) {
return mPinMask; }
170 virtual bool isSelected() {
return (*mPort & mPinMask) == mPinMask; }
199#ifdef FASTLED_FORCE_SOFTWARE_PINS
201 static RwReg sPinMask;
202 static volatile RwReg *sPort;
203 static volatile RoReg *sInPort;
204 static void _init() {
205#if !defined(FASTLED_NO_PINMAP)
206 sPinMask = digitalPinToBitMask(PIN);
207 sPort = portOutputRegister(digitalPinToPort(PIN));
208 sInPort = portInputRegister(digitalPinToPort(PIN));
217 inline static void setOutput() { _init(); pinMode(PIN, OUTPUT); }
219 inline static void setInput() { _init(); pinMode(PIN, INPUT); }
222 inline static void hi() __attribute__ ((always_inline)) { *sPort |= sPinMask; }
224 inline static void lo() __attribute__ ((always_inline)) { *sPort &= ~sPinMask; }
230 inline static void toggle() __attribute__ ((always_inline)) { *sInPort = sPinMask; }
235 inline static void lo(FASTLED_REGISTER
port_ptr_t port) __attribute__ ((always_inline)) { *
port &= ~sPinMask; }
237 inline static void set(FASTLED_REGISTER
port_t val) __attribute__ ((always_inline)) { *sPort = val; }
243 static port_t hival() __attribute__ ((always_inline)) {
return *sPort | sPinMask; }
245 static port_t loval() __attribute__ ((always_inline)) {
return *sPort & ~sPinMask; }
249 static port_t mask() __attribute__ ((always_inline)) {
return sPinMask; }
258template<u
int8_t PIN>
class FastPin {
259 constexpr static bool validpin() {
return false; }
261 static_assert(validpin(),
"Invalid pin specified");
263 static void _init() { }
275 inline static void hi() __attribute__ ((always_inline)) { }
277 inline static void lo() __attribute__ ((always_inline)) { }
280 inline static void strobe() __attribute__ ((always_inline)) { }
283 inline static void toggle() __attribute__ ((always_inline)) { }
286 inline static void hi(FASTLED_REGISTER
port_ptr_t port) __attribute__ ((always_inline)) { }
288 inline static void lo(FASTLED_REGISTER
port_ptr_t port) __attribute__ ((always_inline)) { }
290 inline static void set(FASTLED_REGISTER
port_t val) __attribute__ ((always_inline)) { }
296 static port_t hival() __attribute__ ((always_inline)) {
return 0; }
298 static port_t loval() __attribute__ ((always_inline)) {
return 0;}
300 static port_ptr_t port() __attribute__ ((always_inline)) {
return NULL; }
302 static port_t mask() __attribute__ ((always_inline)) {
return 0; }
333#define _FL_DEFINE_PORT(L, BASE) template<> struct __FL_PORT_INFO<L> { \
334 static bool hasPort() { return 1; } \
335 static const char *portName() { return #L; } \
336 typedef BASE __t_baseType; \
337 static const void *portAddr() { return (void*)&__t_baseType::r(); } };
349#define _FL_DEFINE_PORT3(L, LC, BASE) template<> struct __FL_PORT_INFO<LC> { \
350 static bool hasPort() { return 1; } \
351 static const char *portName() { return #L; } \
352 typedef BASE __t_baseType; \
353 static const void *portAddr() { return (void*)&__t_baseType::r(); } };
357#pragma GCC diagnostic pop
central include file for FastLED, defines the CFastLED class/object
FastPin implementation for bit-banded access.
The simplest level of Pin class.
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 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 port_ptr_t port()
Get the output state of the port.
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
I/O pin initially set to OUTPUT.
OutputPin(int pin)
Constructor.
Naive fallback solution for low level pin access.
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
virtual void release()
Set the pin state 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
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
void lo()
Set the pin state to LOW
virtual void select()
Set the pin state to HIGH
volatile RwReg * port_ptr_t
type for a pin read/write register, volatile
virtual bool isSelected()
Checks if the pin is currently HIGH
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.
void strobe()
Toggle the pin twice to create a short pulse.
port_t hival()
Gets the state of the port with this pin HIGH
Abstract class for "selectable" things.
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.
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.
Utility template for tracking down information about pins and ports.
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.