ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
MatrixHardware_Teensy4_ShieldV5_RBG.h
Go to the documentation of this file.
1/*
2 * SmartMatrix Library - Hardware-Specific Header File (for SmartMatrix Shield for Teensy 4 V5)
3 *
4 * Copyright (c) 2020 Louis Beaudoin (Pixelmatix)
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy of
7 * this software and associated documentation files (the "Software"), to deal in
8 * the Software without restriction, including without limitation the rights to
9 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 * the Software, and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24// Hardware-specific header file for the SmartLED Shield for Teensy 4 (V5):
25// Only Teensy 4.0/4.1 models are supported.
26//
27// Some of the pin assignments can be changed using solderable jumpers on the adapter board:
28// JP4:
29// Default: Pin 7 connected to BUFFER_CLK, Pin 8 free
30// Alt: Pin 8 connected to BUFFER_CLK, Pin 7 free
31// To use the alternate clock pin, in addition to soldering the jumper you must set flag SMARTMATRIX_OPTIONS_T4_CLK_PIN_ALT in kMatrixOptions
32// JP2 & JP3:
33// Default: Pin 4 connected to APA_CLK, Pin 5 connected to APA_DAT (intended for APA102 driving via SPI emulation), LED Matrix is drivable at the same time
34// Alt: Pins 4 & 5 free, Pin 13 connected to APA_CLK, Pin 11 connected to APA_DAT (intended for APA102 driving via hardware SPI), LED Matrix not drivable at the same time
35
36// Note: only one MatrixHardware_*.h file should be included per project
37
38#ifndef MATRIX_HARDWARE_H
39#define MATRIX_HARDWARE_H
40
41#pragma message "MatrixHardware: SmartLED Shield for Teensy 4 (V5)"
42
43/* an advanced user may need to tweak these values */
44
45// size of latch pulse - can be short for V4 shield which doesn't need to update ADDX lines during latch pulse
46// 20 is minimum working value on DP5020B panel
47// set to 100 for improved support with FM6126A panel
48// don't exceed 150 to avoid interference between latch and data transfer
49#define LATCH_TIMER_PULSE_WIDTH_NS 100
50
51// max delay from rising edge of latch pulse to falling edge of first pixel clock
52// increase this value if DMA use is delaying clock
53// Measured 220 ns delay at 600 MHz clock speed, 160 ns at 816 MHz. Slower speeds are not supported.
54// Using larger delay for safety.
55#define LATCH_TO_CLK_DELAY_NS 400
56
57// Pixel clock frequency is generated using the 480 MHz PLL3 clock and a divide-by-n counter. Frequency is independent of CPU clock speed.
58// Must increment divider value by 2 (division ratio is always even)
59// Minimum tested working value is 20 (corresponding to 24 MHz clock frequency) on DP5020B panel
60// Using value of 26 (corresponding to 18.462 MHz clock frequency) to improve stability and reduce glitching
61// Larger values may be more stable, but will decrease maximum refresh rate
62#define FLEXIO_CLOCK_DIVIDER 26
63
64// Amount of time required to transfer 32 pixels
65// Adding 200 ns overhead time to improve stability
66#define PANEL_32_PIXELDATA_TRANSFER_MAXIMUM_NS ((32*FLEXIO_CLOCK_DIVIDER*1000/480) + 200)
67
68/* this section describes how the microcontroller is attached to the display */
69
70// these defines control the color channel assignments - if your panel has non-standard RGB order, swap signals here
71#define R_0_SIGNAL FLEXIO_PIN_R0_TEENSY_PIN
72#define G_0_SIGNAL FLEXIO_PIN_B0_TEENSY_PIN
73#define B_0_SIGNAL FLEXIO_PIN_G0_TEENSY_PIN
74#define R_1_SIGNAL FLEXIO_PIN_R1_TEENSY_PIN
75#define G_1_SIGNAL FLEXIO_PIN_B1_TEENSY_PIN
76#define B_1_SIGNAL FLEXIO_PIN_G1_TEENSY_PIN
77
78//#define DEBUG_PINS_ENABLED
79#define DEBUG_PIN_1 0
80#define DEBUG_PIN_2 1
81#define DEBUG_PIN_3 23
82
83/************ The below definitions are unlikely to be useful if changed **************/
84
85// active pin number definitions
86// data bit order is calculated in setup using the pin number definitions and color channel assignments
87// these pin definitions are also manually used to reset FM6126A panels
88#define FLEXPWM_PIN_OE_TEENSY_PIN 2
89#define FLEXPWM_PIN_LATCH_TEENSY_PIN 3
90#define FLEXIO_PIN_CLK_TEENSY_PIN 7
91#define FLEXIO_PIN_CLK_TEENSY_PIN_ALT 8
92#define FLEXIO_PIN_B0_TEENSY_PIN 10
93#define FLEXIO_PIN_R0_TEENSY_PIN 6
94#define FLEXIO_PIN_R1_TEENSY_PIN 12
95#define FLEXIO_PIN_G0_TEENSY_PIN 9
96#define FLEXIO_PIN_G1_TEENSY_PIN 11
97#define FLEXIO_PIN_B1_TEENSY_PIN 13
98
99#define SMARTLED_APA_ENABLED_BY_DEFAULT true
100#define SMARTLED_APA_ENABLE_PIN 22
101#define FLEXIO_PIN_APA102_CLK 4
102#define FLEXIO_PIN_APA102_DAT 5
103
104#define ADDX_0_SIGNAL FLEXIO_PIN_R0_TEENSY_PIN
105#define ADDX_1_SIGNAL FLEXIO_PIN_G0_TEENSY_PIN
106#define ADDX_2_SIGNAL FLEXIO_PIN_B0_TEENSY_PIN
107#define ADDX_3_SIGNAL FLEXIO_PIN_R1_TEENSY_PIN
108#define ADDX_4_SIGNAL FLEXIO_PIN_G1_TEENSY_PIN
109
110#else
111 #pragma GCC error "Multiple MatrixHardware*.h files included"
112#endif