41 static constexpr bool validpin()
FL_NOEXCEPT {
return true; }
69#ifdef FASTLED_FORCE_SOFTWARE_PINS
70template<fl::u8 PIN>
class FastPin {
71 static RwReg sPinMask;
72 static volatile RwReg *sPort;
73 static volatile RoReg *sInPort;
75#if !defined(FASTLED_NO_PINMAP)
76 sPinMask = digitalPinToBitMask(
PIN);
77 sPort = portOutputRegister(digitalPinToPort(
PIN));
78 sInPort = portInputRegister(digitalPinToPort(
PIN));
83 typedef volatile RwReg * port_ptr_t;
87 inline static void setOutput() { _init(); pinMode(
PIN, PinMode::Output); }
89 inline static void setInput() { _init(); pinMode(
PIN, PinMode::Input); }
92 inline static void hi() __attribute__ ((always_inline)) { *sPort |= sPinMask; }
94 inline static void lo() __attribute__ ((always_inline)) { *sPort &= ~sPinMask; }
97 inline static void strobe() __attribute__ ((always_inline)) {
toggle();
toggle(); }
100 inline static void toggle() __attribute__ ((always_inline)) { *sInPort = sPinMask; }
103 inline static void hi(
FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { *port |= sPinMask; }
105 inline static void lo(
FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~sPinMask; }
107 inline static void set(
FASTLED_REGISTER port_t val) __attribute__ ((always_inline)) { *sPort = val; }
113 static port_t hival() __attribute__ ((always_inline)) {
return *sPort | sPinMask; }
115 static port_t loval() __attribute__ ((always_inline)) {
return *sPort & ~sPinMask; }
117 static port_ptr_t port() __attribute__ ((always_inline)) {
return sPort; }
119 static port_t mask() __attribute__ ((always_inline)) {
return sPinMask; }
128template<fl::u8 PIN>
class FastPin {
135#ifdef FASTLED_ALL_PINS_VALID
136 constexpr static bool validpin()
FL_NOEXCEPT {
return true; }
138 constexpr static bool validpin() {
return false; }
140 constexpr static bool LowSpeedOnlyRecommended()
FL_NOEXCEPT {
146 FL_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).");
151 typedef volatile RwReg * port_ptr_t;
152 typedef RwReg port_t;
160 inline static void hi()
FL_NOEXCEPT __attribute__ ((always_inline)) { }
162 inline static void lo()
FL_NOEXCEPT __attribute__ ((always_inline)) { }
165 inline static void strobe()
FL_NOEXCEPT __attribute__ ((always_inline)) { }
190 static port_t hival()
FL_NOEXCEPT __attribute__ ((always_inline)) {
return 0; }
192 static port_t loval()
FL_NOEXCEPT __attribute__ ((always_inline)) {
return 0;}
194 static port_ptr_t port()
FL_NOEXCEPT __attribute__ ((always_inline)) {
return nullptr; }
196 static port_t mask()
FL_NOEXCEPT __attribute__ ((always_inline)) {
return 0; }
206typedef volatile fl::u32 & reg32_t;
207typedef volatile fl::u32 * ptr_reg32_t;
211template<fl::u8 port>
struct __FL_PORT_INFO {
215 static const char *portName()
FL_NOEXCEPT {
return "--"; }
217 static const void *portAddr()
FL_NOEXCEPT {
return nullptr; }
227#define _FL_DEFINE_PORT(L, BASE) template<> struct __FL_PORT_INFO<L> { \
228 typedef BASE __t_baseType; \
229 static bool hasPort() { return 1; } \
230 static const char *portName() { return #L; } \
231 static const void *portAddr() { return (void*)&__t_baseType::r(); } };
243#define _FL_DEFINE_PORT3(L, LC, BASE) template<> struct __FL_PORT_INFO<LC> { \
244 typedef BASE __t_baseType; \
245 static bool hasPort() { return 1; } \
246 static const char *portName() { return #L; } \
247 static const void *portAddr() { return (void*)&__t_baseType::r(); } };