Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ltdc_common_f47.c « common « stm32 « lib - github.com/thirdpin/libopencm3.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3255f3568392754d72e0d49fc797e3e7a84ee447 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/** @defgroup ltdc_file LTDC peripheral API
 *
 * @ingroup peripheral_apis
 *
 * @version 1.0.0
 *
 * @author @htmlonly © @endhtmlonly 2014
 * Oliver Meier <h2obrain@gmail.com>
 *
 * @date 5 December 2014
 *
 * This library supports the LCD controller (LTDC) in the STM32F4xx and
 * STM32F7xx series of ARM Cortex Microcontrollers by ST Microelectronics.
 *
 * LGPL License Terms @ref lgpl_license
 */

/*
 * This file is part of the libopencm3 project.
 *
 * Copyright (C) 2014 Oliver Meier <h2obrain@gmail.com>
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

/**@{*/

#include <libopencm3/stm32/common/ltdc_common_f47.h>

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)
{
	/*assert((active_width <= 0x400) && (active_height <= 0x300));*/

	uint16_t w, h;
	w = sync_width   - 1;
	h = sync_height  - 1;
	/*assert((w&0xfff == w) && (h&0x7ff == h));*/
	LTDC_SSCR = (w << 16) | (h << 0);

	w += h_back_porch;
	h += v_back_porch;
	/*assert((w&0xfff == w) && (h&0x7ff == h));*/
	LTDC_BPCR = (w << 16) | (h << 0);

	w += active_width;
	h += active_height;
	/*assert((w&0xfff == w) && (h&0x7ff == h));*/
	LTDC_AWCR = (w << 16) | (h << 0);

	w += h_front_porch;
	h += v_front_porch;
	/*assert((w&0xfff == w) && (h&0x7ff == h));*/
	LTDC_TWCR = (w << 16) | (h << 0);
}

void ltdc_setup_windowing(uint8_t  layer_number,
			  uint16_t h_back_porch, uint16_t v_back_porch,
			  uint16_t active_width, uint16_t active_height)
{
	active_width  += h_back_porch - 1;
	active_height += v_back_porch - 1;
	/*assert((h_back_porch & 0xfff == h_back_porch) &&
		 (v_back_porch  & 0xfff == v_back_porch) &&
		 (active_width & 0xfff == active_width) &&
		 (active_height & 0xfff == active_height));*/
	LTDC_LxWHPCR(layer_number) = (active_width  << 16) |
				     (h_back_porch << 0);
	LTDC_LxWVPCR(layer_number) = (active_height << 16) |
				     (v_back_porch << 0);
}

/**@}*/