36#ifndef LIBOPENCM3_STM32_COMMON_LTDC_COMMON_F47_H_
38#define LIBOPENCM3_STM32_COMMON_LTDC_COMMON_F47_H_
49#define LTDC_SSCR (MMIO32(LTDC_BASE + 0x08))
50#define LTDC_BPCR (MMIO32(LTDC_BASE + 0x0C))
51#define LTDC_AWCR (MMIO32(LTDC_BASE + 0x10))
52#define LTDC_TWCR (MMIO32(LTDC_BASE + 0x14))
53#define LTDC_GCR (MMIO32(LTDC_BASE + 0x18))
54#define LTDC_SRCR (MMIO32(LTDC_BASE + 0x24))
55#define LTDC_BCCR (MMIO32(LTDC_BASE + 0x2C))
56#define LTDC_IER (MMIO32(LTDC_BASE + 0x34))
57#define LTDC_ISR (MMIO32(LTDC_BASE + 0x38))
58#define LTDC_ICR (MMIO32(LTDC_BASE + 0x3C))
59#define LTDC_LIPCR (MMIO32(LTDC_BASE + 0x40))
60#define LTDC_CPSR (MMIO32(LTDC_BASE + 0x44))
61#define LTDC_CDSR (MMIO32(LTDC_BASE + 0x48))
64#define LTDC_LxCR(x) (MMIO32(LTDC_BASE + 0x84 + 0x80 * ((x) - 1)))
65#define LTDC_L1CR LTDC_LxCR(LTDC_LAYER_1)
66#define LTDC_L2CR LTDC_LxCR(LTDC_LAYER_2)
68#define LTDC_LxWHPCR(x) (MMIO32(LTDC_BASE + 0x88 + 0x80 * ((x) - 1)))
69#define LTDC_L1WHPCR LTDC_LxWHPCR(LTDC_LAYER_1)
70#define LTDC_L2WHPCR LTDC_LxWHPCR(LTDC_LAYER_2)
72#define LTDC_LxWVPCR(x) (MMIO32(LTDC_BASE + 0x8C + 0x80 * ((x) - 1)))
73#define LTDC_L1WVPCR LTDC_LxWVPCR(LTDC_LAYER_1)
74#define LTDC_L2WVPCR LTDC_LxWVPCR(LTDC_LAYER_2)
76#define LTDC_LxCKCR(x) (MMIO32(LTDC_BASE + 0x90 + 0x80 * ((x) - 1)))
77#define LTDC_L1CKCR LTDC_LxCKCR(LTDC_LAYER_1)
78#define LTDC_L2CKCR LTDC_LxCKCR(LTDC_LAYER_2)
80#define LTDC_LxPFCR(x) (MMIO32(LTDC_BASE + 0x94 + 0x80 * ((x) - 1)))
81#define LTDC_L1PFCR LTDC_LxPFCR(LTDC_LAYER_1)
82#define LTDC_L2PFCR LTDC_LxPFCR(LTDC_LAYER_2)
84#define LTDC_LxCACR(x) (MMIO32(LTDC_BASE + 0x98 + 0x80 * ((x) - 1)))
85#define LTDC_L1CACR LTDC_LxCACR(LTDC_LAYER_1)
86#define LTDC_L2CACR LTDC_LxCACR(LTDC_LAYER_2)
88#define LTDC_LxDCCR(x) (MMIO32(LTDC_BASE + 0x9C + 0x80 * ((x) - 1)))
89#define LTDC_L1DCCR LTDC_LxDCCR(LTDC_LAYER_1)
90#define LTDC_L2DCCR LTDC_LxDCCR(LTDC_LAYER_2)
92#define LTDC_LxBFCR(x) (MMIO32(LTDC_BASE + 0xA0 + 0x80 * ((x) - 1)))
93#define LTDC_L1BFCR LTDC_LxBFCR(LTDC_LAYER_1)
94#define LTDC_L2BFCR LTDC_LxBFCR(LTDC_LAYER_2)
96#define LTDC_LxCFBAR(x) (MMIO32(LTDC_BASE + 0xAC + 0x80 * ((x) - 1)))
97#define LTDC_L1CFBAR LTDC_LxCFBAR(LTDC_LAYER_1)
98#define LTDC_L2CFBAR LTDC_LxCFBAR(LTDC_LAYER_2)
100#define LTDC_LxCFBLR(x) (MMIO32(LTDC_BASE + 0xB0 + 0x80 * ((x) - 1)))
101#define LTDC_L1CFBLR LTDC_LxCFBLR(LTDC_LAYER_1)
102#define LTDC_L2CFBLR LTDC_LxCFBLR(LTDC_LAYER_2)
104#define LTDC_LxCFBLNR(x) (MMIO32(LTDC_BASE + 0xB4 + 0x80 * ((x) - 1)))
105#define LTDC_L1CFBLNR LTDC_LxCFBLNR(LTDC_LAYER_1)
106#define LTDC_L2CFBLNR LTDC_LxCFBLNR(LTDC_LAYER_2)
108#define LTDC_LxCLUTWR(x) (MMIO32(LTDC_BASE + 0xC4 + 0x80 * ((x) - 1)))
109#define LTDC_L1CLUTWR LTDC_LxCLUTWR(LTDC_LAYER_1)
110#define LTDC_L2CLUTWR LTDC_LxCLUTWR(LTDC_LAYER_2)
117#define LTDC_LAYER_1 1
118#define LTDC_LAYER_2 2
125#define LTDC_SSCR_HSW_SHIFT 16
126#define LTDC_SSCR_HSW_MASK 0xfff
129#define LTDC_SSCR_VSH_SHIFT 0
130#define LTDC_SSCR_VSH_MASK 0x7ff
135#define LTDC_BPCR_AHBP_SHIFT 16
136#define LTDC_BPCR_AHBP_MASK 0xfff
139#define LTDC_BPCR_AVBP_SHIFT 0
140#define LTDC_BPCR_AVBP_MASK 0x7FF
145#define LTDC_AWCR_AAW_SHIFT 16
146#define LTDC_AWCR_AAW_MASK 0xfff
149#define LTDC_AWCR_AAH_SHIFT 0
150#define LTDC_AWCR_AAH_MASK 0x7ff
155#define LTDC_TWCR_TOTALW_SHIFT 16
156#define LTDC_TWCR_TOTALW_MASK 0xfff
159#define LTDC_TWCR_TOTALH_SHIFT 0
160#define LTDC_TWCR_TOTALH_MASK 0x7ff
163#define LTDC_GCR_LTDC_ENABLE (1<<0)
164#define LTDC_GCR_DITHER_ENABLE (1<<16)
166#define LTDC_GCR_PCPOL_ACTIVE_LOW (0<<28)
167#define LTDC_GCR_PCPOL_ACTIVE_HIGH (1<<28)
169#define LTDC_GCR_DEPOL_ACTIVE_LOW (0<<29)
170#define LTDC_GCR_DEPOL_ACTIVE_HIGH (1<<29)
172#define LTDC_GCR_VSPOL_ACTIVE_LOW (0<<30)
173#define LTDC_GCR_VSPOL_ACTIVE_HIGH (1<<30)
175#define LTDC_GCR_HSPOL_ACTIVE_LOW (0<<31)
176#define LTDC_GCR_HSPOL_ACTIVE_HIGH (1<<31)
179#define LTDC_GCR_HSPOL (1 << 31)
180#define LTDC_GCR_VSPOL (1 << 30)
181#define LTDC_GCR_DEPOL (1 << 29)
182#define LTDC_GCR_PCPOL (1 << 28)
183#define LTDC_GCR_DITHER (1 << 16)
184#define LTDC_GCR_LTDCEN (1 << 0)
189#define LTDC_SRCR_VBR (1 << 1)
192#define LTDC_SRCR_IMR (1 << 0)
195#define LTDC_SRCR_RELOAD_IMR (1<<0)
196#define LTDC_SRCR_RELOAD_VBR (1<<1)
201#define LTDC_IER_RRIE (1 << 3)
204#define LTDC_IER_TERRIE (1 << 2)
207#define LTDC_IER_FUIE (1 << 1)
210#define LTDC_IER_LIE (1 << 0)
215#define LTDC_ISR_RRIF (1 << 3)
218#define LTDC_ISR_TERRIF (1 << 2)
221#define LTDC_ISR_FUIF (1 << 1)
224#define LTDC_ISR_LIF (1 << 0)
229#define LTDC_ICR_CRRIF (1 << 3)
232#define LTDC_ICR_CTERRIF (1 << 2)
235#define LTDC_ICR_CFUIF (1 << 1)
238#define LTDC_ICR_CLIF (1 << 0)
243#define LTDC_LIPCR_LIPOS_SHIFT 0
244#define LTDC_LIPCR_LIPOS_MASK 0x7ff
249#define LTDC_CPSR_CXPOS_SHIFT 16
250#define LTDC_CPSR_CXPOS_MASK 0xffff
253#define LTDC_CPSR_CYPOS_SHIFT 0
254#define LTDC_CPSR_CYPOS_MASK 0xffff
257#define LTDC_CDSR_VDES (1<<0)
258#define LTDC_CDSR_HDES (1<<1)
259#define LTDC_CDSR_VSYNCS (1<<2)
260#define LTDC_CDSR_HSYNCS (1<<3)
263#define LTDC_LxCR_LAYER_ENABLE (1<<0)
264#define LTDC_LxCR_COLKEY_ENABLE (1<<1)
265#define LTDC_LxCR_COLTAB_ENABLE (1<<4)
270#define LTDC_LxWHPCR_WHSPPOS_SHIFT 16
271#define LTDC_LxWHPCR_WHSPPOS_MASK 0xfff
274#define LTDC_LxWHPCR_WHSTPOS_SHIFT 0
275#define LTDC_LxWHPCR_WHSTPOS_MASK 0xfff
280#define LTDC_LxWVPCR_WVSPPOS_SHIFT 16
281#define LTDC_LxWVPCR_WVSPPOS_MASK 0x7ff
284#define LTDC_LxWVPCR_WVSTPOS_SHIFT 0
285#define LTDC_LxWVPCR_WVSTPOS_MASK 0x7ff
290#define LTDC_LxCKCR_CKRED_SHIFT 16
291#define LTDC_LxCKCR_CKRED_MASK 0xff
294#define LTDC_LxCKCR_CKGREEN_SHIFT 16
295#define LTDC_LxCKCR_CKGREEN_MASK 0xff
298#define LTDC_LxCKCR_CKBLUE_SHIFT 16
299#define LTDC_LxCKCR_CKBLUE_MASK 0xff
302#define LTDC_LxPFCR_ARGB8888 (0b000)
303#define LTDC_LxPFCR_RGB888 (0b001)
304#define LTDC_LxPFCR_RGB565 (0b010)
305#define LTDC_LxPFCR_ARGB1555 (0b011)
306#define LTDC_LxPFCR_ARGB4444 (0b100)
307#define LTDC_LxPFCR_L8 (0b101)
308#define LTDC_LxPFCR_AL44 (0b110)
309#define LTDC_LxPFCR_AL88 (0b111)
314#define LTDC_LxCACR_CONSTA_SHIFT 0
315#define LTDC_LxCACR_CONSTA_MASK 0xff
320#define LTDC_LxDCCR_DCALPHA_SHIFT 24
321#define LTDC_LxDCCR_DCALPHA_MASK 1
324#define LTDC_LxDCCR_DCRED_SHIFT 16
325#define LTDC_LxDCCR_DCRED_MASK 1
328#define LTDC_LxDCCR_DCGREEN_SHIFT 8
329#define LTDC_LxDCCR_DCGREEN_MASK 1
332#define LTDC_LxDCCR_DCBLUE_SHIFT 0
333#define LTDC_LxDCCR_DCBLUE_MASK 1
336#define LTDC_LxBFCR_BF1_CONST_ALPHA (0b100)
337#define LTDC_LxBFCR_BF1_PIXEL_ALPHA_x_CONST_ALPHA (0b110)
339#define LTDC_LxBFCR_BF2_CONST_ALPHA (0b101)
340#define LTDC_LxBFCR_BF2_PIXEL_ALPHA_x_CONST_ALPHA (0b111)
345#define LTDC_LxCFBAR_CFBAR_SHIFT 0
346#define LTDC_LxCFBAR_CFBAR_MASK 0xffffffff
351#define LTDC_LxCFBLR_CFBP_SHIFT 16
352#define LTDC_LxCFBLR_CFBP_MASK 0x1fff
355#define LTDC_LxCFBLR_CFBLL_SHIFT 0
356#define LTDC_LxCFBLR_CFBLL_MASK 0x1fff
361#define LTDC_LxCFBLNR_CFBLNBR_SHIFT 0
362#define LTDC_LxCFBLNR_CFBLNBR_MASK 0x3ff
367#define LTDC_LxCLUTWR_CLUTADD_SHIFT 24
368#define LTDC_LxCLUTWR_CLUTADD_MASK 0xff
371#define LTDC_LxCLUTWR_RED_SHIFT 16
372#define LTDC_LxCLUTWR_RED_MASK 0xff
375#define LTDC_LxCLUTWR_GREEN_SHIFT 8
376#define LTDC_LxCLUTWR_GREEN_MASK 0xff
379#define LTDC_LxCLUTWR_BLUE_SHIFT 0
380#define LTDC_LxCLUTWR_BLUE_MASK 0xff
443 uint8_t r, uint8_t g, uint8_t b)
462 uint8_t r, uint8_t g, uint8_t b)
471 uint8_t bf1, uint8_t bf2)
487 uint16_t len, uint16_t pitch)
489 LTDC_LxCFBLR(layer) = ((((pitch)&0x1FFF)<<16) | (((len)&0x1FFF)<<0));
501 uint16_t sync_width, uint16_t sync_height,
502 uint16_t h_back_porch, uint16_t v_back_porch,
503 uint16_t active_width, uint16_t active_height,
504 uint16_t h_front_porch, uint16_t v_front_porch
507 uint8_t layer_number,
508 uint16_t h_back_porch, uint16_t v_back_porch,
509 uint16_t h_sync, uint16_t v_sync,
510 uint16_t width, uint16_t height
532 uint32_t rgb565_32 = (uint32_t)rgb565;
533 return ((((rgb565_32) & 0xF800) >> (11-8))/31)<<16
534 | ((((rgb565_32) & 0x07E0) << (8-5))/63)<<8
535 | ((((rgb565_32) & 0x001F) << (8-0))/31)<<0;
#define LTDC_SRCR_RELOAD_IMR
static void ltdc_set_color_key(uint32_t layer, uint8_t r, uint8_t g, uint8_t b)
static void ltdc_set_constant_alpha(uint32_t layer, uint8_t alpha)
static void ltdc_set_fbuffer_address(uint32_t layer, uint32_t address)
static void ltdc_ctrl_disable(uint32_t ctrl_flags)
static void ltdc_set_default_colors(uint32_t layer, uint8_t a, uint8_t r, uint8_t g, uint8_t b)
static void ltdc_layer_ctrl_disable(uint32_t layer, uint32_t ctrl_flags)
static void ltdc_set_background_color(uint8_t r, uint8_t g, uint8_t b)
static uint16_t ltdc_get_current_position_x(void)
static bool LTDC_SRCR_IS_RELOADING(void)
Helper function to wait for SRCR reload to complete or so.
static uint32_t ltdc_get_display_status(uint32_t status_flags)
static void ltdc_reload(uint32_t reload_flags)
static void ltdc_set_fb_line_count(uint32_t layer, uint16_t linecount)
static void ltdc_set_pixel_format(uint32_t layer, uint32_t format)
void ltdc_set_tft_sync_timings(uint16_t sync_width, uint16_t sync_height, uint16_t h_back_porch, uint16_t v_back_porch, uint16_t active_width, uint16_t active_height, uint16_t h_front_porch, uint16_t v_front_porch)
more complicated helper functions
static uint32_t ltdc_get_fbuffer_address(uint32_t layer)
static void ltdc_layer_ctrl_enable(uint32_t layer, uint32_t ctrl_flags)
static void ltdc_ctrl_enable(uint32_t ctrl_flags)
simple helper macros
static uint32_t ltdc_get_rgb888_from_rgb565(uint16_t rgb565)
color conversion helper function (simulate the ltdc color conversion)
void ltdc_setup_windowing(uint8_t layer_number, uint16_t h_back_porch, uint16_t v_back_porch, uint16_t h_sync, uint16_t v_sync, uint16_t width, uint16_t height)
LTDC Windowing Setup.
#define LTDC_SRCR_RELOAD_VBR
static void ltdc_set_fb_line_length(uint32_t layer, uint16_t len, uint16_t pitch)
static void ltdc_set_blending_factors(uint32_t layer, uint8_t bf1, uint8_t bf2)
static uint16_t ltdc_get_current_position_y(void)
static void ltdc_get_current_position(uint16_t *x, uint16_t *y)