FastLED 3.9.15
Loading...
Searching...
No Matches

◆ validate_teensy4_pin()

PinValidationResult objectfled::validate_teensy4_pin ( uint8_t pin)
inline

Definition at line 30 of file ObjectFLEDPinValidation.h.

30 {
31 // Teensy 4.0 supports pins 0-39
32 // Teensy 4.1 adds pins 40-54, but we'll be permissive and allow
33 // any pin that could theoretically exist on a Teensy 4.x variant
34
35 // First check: pin number range
36 // NUM_DIGITAL_PINS from Teensy core should handle board-specific limits
37 // But we can do basic range checking here
38
39 if (pin >= NUM_DIGITAL_PINS) {
40 return {false, PinIssueType::OUT_OF_RANGE, "Pin number exceeds NUM_DIGITAL_PINS for this board - pin is out of valid range"};
41 }
42
43 // Check if pin maps to a valid GPIO port (GPIO6-9)
44 // Use the same logic as ObjectFLED::begin() to verify pin is usable
45 uint8_t offset = ((uint32_t)portOutputRegister(pin) - (uint32_t)&GPIO6_DR) >> 14;
46 if (offset > 3) {
47 return {false, PinIssueType::INVALID_GPIO, "Pin does not map to a valid GPIO port (GPIO6-9) - may be a ground/power/read-only pin"};
48 }
49
50 // Warn about potentially problematic pins
51 // These are based on common Teensy 4.x pin usage patterns
52
53 // UART pins - noise/signal integrity issues
54 if (pin == 0 || pin == 1) {
55 return {true, PinIssueType::UART_PIN, "WARNING: Pin is Serial1 UART (0=RX1, 1=TX1) - may cause noise/signal issues and affect serial debugging"};
56 }
57
58 if (pin == 7 || pin == 8) {
59 return {true, PinIssueType::UART_PIN, "WARNING: Pin is Serial2 UART (7=RX2, 8=TX2) - may cause noise/signal issues"};
60 }
61
62 // SPI pins - may interfere with flash/SD card communication
63 if (pin == 11 || pin == 12 || pin == 13) {
64 return {true, PinIssueType::SPI_PIN, "WARNING: Pin is SPI bus (11=MOSI, 12=MISO, 13=SCK) - may cause noise and conflict with flash/SD peripherals"};
65 }
66
67 if (pin == 26 || pin == 27) {
68 return {true, PinIssueType::SPI_PIN, "WARNING: Pin is SPI1 bus (26=MOSI1, 27=SCK1) - may cause noise and conflict with peripherals"};
69 }
70
71 // I2C pins - may interfere with I2C devices
72 if (pin == 18 || pin == 19) {
73 return {true, PinIssueType::I2C_PIN, "WARNING: Pin is I2C bus (18=SDA0, 19=SCL0) - may cause noise and conflict with I2C devices"};
74 }
75
76 if (pin == 16 || pin == 17) {
77 return {true, PinIssueType::I2C_PIN, "WARNING: Pin is I2C bus (16=SCL1, 17=SDA1) - may cause noise and conflict with I2C devices"};
78 }
79
80 // LED pin on most Teensy boards
81 if (pin == 13) {
82 return {true, PinIssueType::LED_PIN, "WARNING: Pin 13 is the onboard LED - may cause unexpected visual feedback"};
83 }
84
85 // Pin is valid
86 return {true, PinIssueType::NONE, nullptr};
87}
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
fl::u32 uint32_t
Definition s16x16x4.h:219
unsigned char uint8_t
Definition s16x16x4.h:209

References I2C_PIN, INVALID_GPIO, LED_PIN, NONE, offset(), OUT_OF_RANGE, SPI_PIN, and UART_PIN.

Referenced by is_valid_teensy4_pin().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: