56 static constexpr bool validpin()
FL_NO_EXCEPT {
return true; }
86#if defined(FASTLED_FORCE_SOFTWARE_PINS) && \
87 (defined(FASTLED_NO_PINMAP) || defined(FL_IS_ESP32) || defined(FL_IS_ESP8266))
88#define FL_FASTPIN_HAS_NO_PINMAP
90#if defined(FL_IS_ESP32) || defined(FL_IS_ESP8266) || \
91 defined(FL_IS_ARM_LPC_845) || defined(FL_IS_ARM_LPC_804)
94template<fl::u8 PIN>
class FastPin :
public NoPinMapPin<PIN> {
96 static constexpr bool validpin()
FL_NO_EXCEPT {
return false; }
102template<fl::u8 PIN>
class FastPin :
public NoPinMapPin<PIN> {};
104#elif defined(FASTLED_FORCE_SOFTWARE_PINS)
105#define FL_FASTPIN_HAS_RUNTIME_PORT
106template<fl::u8 PIN>
class FastPin {
107 static RwReg sPinMask;
108 static volatile RwReg *sPort;
109 static volatile RoReg *sInPort;
110 static void _init() {
111 sPinMask = digitalPinToBitMask(
PIN);
112 sPort = portOutputRegister(digitalPinToPort(
PIN));
113 sInPort = portInputRegister(digitalPinToPort(
PIN));
117 typedef volatile RwReg * port_ptr_t;
118 typedef RwReg port_t;
121 inline static void setOutput() { _init(); (
fl::pinMode)(
PIN, PinMode::Output); }
123 inline static void setInput() { _init(); (
fl::pinMode)(
PIN, PinMode::Input); }
126 inline static void hi() __attribute__ ((always_inline)) { *sPort |= sPinMask; }
128 inline static void lo() __attribute__ ((always_inline)) { *sPort &= ~sPinMask; }
131 inline static void strobe() __attribute__ ((always_inline)) {
toggle();
toggle(); }
134 inline static void toggle() __attribute__ ((always_inline)) {
143 inline static void hi(
FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { *port |= sPinMask; }
145 inline static void lo(
FASTLED_REGISTER port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~sPinMask; }
147 inline static void set(
FASTLED_REGISTER port_t val) __attribute__ ((always_inline)) { *sPort = val; }
153 static port_t hival() __attribute__ ((always_inline)) {
return *sPort | sPinMask; }
155 static port_t loval() __attribute__ ((always_inline)) {
return *sPort & ~sPinMask; }
157 static port_ptr_t port() __attribute__ ((always_inline)) {
return sPort; }
159 static port_t mask() __attribute__ ((always_inline)) {
return sPinMask; }
168template<fl::u8 PIN>
class FastPin {
175#ifdef FASTLED_ALL_PINS_VALID
176 constexpr static bool validpin()
FL_NO_EXCEPT {
return true; }
178 constexpr static bool validpin() {
return false; }
180 constexpr static bool LowSpeedOnlyRecommended()
FL_NO_EXCEPT {
186 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).");
191 typedef volatile RwReg * port_ptr_t;
192 typedef RwReg port_t;
200 inline static void hi()
FL_NO_EXCEPT __attribute__ ((always_inline)) { }
202 inline static void lo()
FL_NO_EXCEPT __attribute__ ((always_inline)) { }
205 inline static void strobe()
FL_NO_EXCEPT __attribute__ ((always_inline)) { }
230 static port_t hival()
FL_NO_EXCEPT __attribute__ ((always_inline)) {
return 0; }
232 static port_t loval()
FL_NO_EXCEPT __attribute__ ((always_inline)) {
return 0;}
234 static port_ptr_t port()
FL_NO_EXCEPT __attribute__ ((always_inline)) {
return nullptr; }
236 static port_t mask()
FL_NO_EXCEPT __attribute__ ((always_inline)) {
return 0; }
246typedef volatile fl::u32 & reg32_t;
247typedef volatile fl::u32 * ptr_reg32_t;
251template<fl::u8 port>
struct __FL_PORT_INFO {
255 static const char *portName()
FL_NO_EXCEPT {
return "--"; }
257 static const void *portAddr()
FL_NO_EXCEPT {
return nullptr; }
267#define _FL_DEFINE_PORT(L, BASE) template<> struct __FL_PORT_INFO<L> { \
268 typedef BASE __t_baseType; \
269 static bool hasPort() { return 1; } \
270 static const char *portName() { return #L; } \
271 static const void *portAddr() { return (void*)&__t_baseType::r(); } };
283#define _FL_DEFINE_PORT3(L, LC, BASE) template<> struct __FL_PORT_INFO<LC> { \
284 typedef BASE __t_baseType; \
285 static bool hasPort() { return 1; } \
286 static const char *portName() { return #L; } \
287 static const void *portAddr() { return (void*)&__t_baseType::r(); } };
void pinMode(int pin, PinMode mode) FL_NO_EXCEPT
Set pin mode (input, output, pull-up, pull-down)