libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
ltdc_common_f47.c
Go to the documentation of this file.
1/** @defgroup ltdc_file LTDC peripheral API
2 *
3 * @ingroup peripheral_apis
4 *
5 * @version 1.0.0
6 *
7 * @author @htmlonly © @endhtmlonly 2014
8 * Oliver Meier <h2obrain@gmail.com>
9 *
10 * @date 5 December 2014
11 *
12 * This library supports the LCD controller (LTDC) in the STM32F4xx and
13 * STM32F7xx series of ARM Cortex Microcontrollers by ST Microelectronics.
14 *
15 * LGPL License Terms @ref lgpl_license
16 */
17
18/*
19 * This file is part of the libopencm3 project.
20 *
21 * Copyright (C) 2014 Oliver Meier <h2obrain@gmail.com>
22 *
23 * This library is free software: you can redistribute it and/or modify
24 * it under the terms of the GNU Lesser General Public License as published by
25 * the Free Software Foundation, either version 3 of the License, or
26 * (at your option) any later version.
27 *
28 * This library is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU Lesser General Public License for more details.
32 *
33 * You should have received a copy of the GNU Lesser General Public License
34 * along with this library. If not, see <http://www.gnu.org/licenses/>.
35 */
36
37/**@{*/
38
40
41void ltdc_set_tft_sync_timings(uint16_t sync_width, uint16_t sync_height,
42 uint16_t h_back_porch, uint16_t v_back_porch,
43 uint16_t active_width, uint16_t active_height,
44 uint16_t h_front_porch, uint16_t v_front_porch)
45{
46 /*assert((active_width <= 0x400) && (active_height <= 0x300));*/
47
48 uint16_t w, h;
49 w = sync_width - 1;
50 h = sync_height - 1;
51 /*assert((w&0xfff == w) && (h&0x7ff == h));*/
52 LTDC_SSCR = (w << 16) | (h << 0);
53
54 w += h_back_porch;
55 h += v_back_porch;
56 /*assert((w&0xfff == w) && (h&0x7ff == h));*/
57 LTDC_BPCR = (w << 16) | (h << 0);
58
59 w += active_width;
60 h += active_height;
61 /*assert((w&0xfff == w) && (h&0x7ff == h));*/
62 LTDC_AWCR = (w << 16) | (h << 0);
63
64 w += h_front_porch;
65 h += v_front_porch;
66 /*assert((w&0xfff == w) && (h&0x7ff == h));*/
67 LTDC_TWCR = (w << 16) | (h << 0);
68}
69
70/*---------------------------------------------------------------------------*/
71/** @brief LTDC Windowing Setup
72@param[in] layer_number unsigned int8. @ref ltdc_layer_num
73@param[in] h_back_porch unsigned int16. Horizontal Back Porch
74@param[in] v_back_porch unsigned int16. Vertical Back Porch
75@param[in] h_sync unsigned int16. Horizontal Sync
76@param[in] v_sync unsigned int16. Vertical Sync
77@param[in] width unsigned int16. Width of the screen (e.g. LCD is 320x240, width
78would be 320)
79@param[in] height unsigned int16. Height of the screen (e.g. LCD is 320x240,
80height would be 240)
81*/
82void ltdc_setup_windowing(uint8_t layer_number, uint16_t h_back_porch,
83 uint16_t v_back_porch, uint16_t h_sync,
84 uint16_t v_sync, uint16_t width, uint16_t height) {
85 LTDC_LxWHPCR(layer_number) = (h_back_porch + width + h_sync - 1) << LTDC_LxWHPCR_WHSPPOS_SHIFT |
86 (h_sync + h_back_porch) << LTDC_LxWHPCR_WHSTPOS_SHIFT;
87 LTDC_LxWVPCR(layer_number) = (v_back_porch + height + v_sync - 1) << LTDC_LxWVPCR_WVSPPOS_SHIFT |
88 (v_back_porch + v_sync) << LTDC_LxWVPCR_WVSTPOS_SHIFT;
89}
90
91/**@}*/
92
#define LTDC_LxWHPCR_WHSPPOS_SHIFT
#define LTDC_LxWVPCR_WVSTPOS_SHIFT
#define LTDC_AWCR
#define LTDC_LxWHPCR_WHSTPOS_SHIFT
#define LTDC_TWCR
#define LTDC_LxWVPCR(x)
#define LTDC_BPCR
#define LTDC_SSCR
LTDC.
#define LTDC_LxWVPCR_WVSPPOS_SHIFT
#define LTDC_LxWHPCR(x)
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
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.