eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4dlcdhw_kinetis_spi.h
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
46 #ifndef __D4DLCDHW_KINETIS_SPI_H
47 #define __D4DLCDHW_KINETIS_SPI_H
48 
49  #if (D4D_MK_STR(D4D_LLD_LCD_HW) == d4dlcdhw_kinetis_spi_ID)
50 
51  /******************************************************************************
52  * Includes
53  ******************************************************************************/
54  #include "d4dlcdhw_kinetis_spi_cfg.h"
55 
56 
57  /******************************************************************************
58  * Constants
59  ******************************************************************************/
60 
61  /******************************************************************************
62  * Types
63  ******************************************************************************/
64 
65  /******************************************************************************
66  * Macros
67  ******************************************************************************/
68 
69  #define SET(x) (x##_PORT) |= (1 << (x))
70  #define RESET(x) (x##_PORT) &= ~(1 << (x))
71 
72  #define OUTPUT(x) (x##_DDR) |= (1 << (x)) ; (x##_PCR) = PORT_PCR_MUX(1);
73  #define INPUT(x) (x##_DDR) &= ~(1 << (x)); (x##_PCR) = PORT_PCR_MUX(1);
74 
75  // MISO pin PCR settings
76  #ifndef D4DLCD_SPI_MISO_PCR_VAL
77  #define D4DLCD_SPI_MISO_PCR_VAL (PORT_PCR_MUX(2)|PORT_PCR_DSE_MASK)
78  #endif
79  // MOSI pin PCR settings
80  #ifndef D4DLCD_SPI_MOSI_PCR_VAL
81  #define D4DLCD_SPI_MOSI_PCR_VAL (PORT_PCR_MUX(2)|PORT_PCR_DSE_MASK)
82  #endif
83  // CLK pin PCR settings
84  #ifndef D4DLCD_SPI_CLK_PCR_VAL
85  #define D4DLCD_SPI_CLK_PCR_VAL (PORT_PCR_MUX(2)|PORT_PCR_DSE_MASK)
86  #endif
87  // CS pin PCR settings
88  #ifndef D4DLCD_SPI_CS_PCR_VAL
89  #define D4DLCD_SPI_CS_PCR_VAL (PORT_PCR_MUX(2)|PORT_PCR_DSE_MASK)
90  #endif
91 
92 
93  #ifndef D4DLCD_SPI_PORT_INIT
94  #define D4DLCD_SPI_PORT_INIT D4DLCD_SPI_MISO_PCR = D4DLCD_SPI_MISO_PCR_VAL;\
95  D4DLCD_SPI_MOSI_PCR = D4DLCD_SPI_MOSI_PCR_VAL;\
96  D4DLCD_SPI_CLK_PCR = D4DLCD_SPI_CLK_PCR_VAL;\
97  D4DLCD_SPI_CS_PCR = D4DLCD_SPI_CS_PCR_VAL;
98  #endif
99 
100  #ifndef D4DLCD_INIT_DC
101  #ifndef D4DLCD_DC
102  #error "The Macro D4DLCD_DC must be set in LCD low level driver configuration file."
103  #else
104  #define D4DLCD_INIT_DC OUTPUT(D4DLCD_DC);
105  #endif
106  #endif
107 
108  #ifndef D4DLCD_ASSERT_DC
109  #ifndef D4DLCD_DC
110  #error "The Macro D4DLCD_DC must be set in LCD low level driver configuration file."
111  #else
112  #define D4DLCD_ASSERT_DC RESET(D4DLCD_DC);
113  #endif
114  #endif
115 
116  #ifndef D4DLCD_DEASSERT_DC
117  #ifndef D4DLCD_DC
118  #error "The Macro D4DLCD_DC must be set in LCD low level driver configuration file."
119  #else
120  #define D4DLCD_DEASSERT_DC SET(D4DLCD_DC);
121  #endif
122  #endif
123 
124 
125  // BackLight
126  #ifdef D4DLCD_BACKLIGHT
127 
128  #ifndef D4DLCD_INIT_BACKLIGHT
129  #define D4DLCD_INIT_BACKLIGHT OUTPUT(D4DLCD_BACKLIGHT);
130  #endif
131 
132  #ifndef D4DLCD_ASSERT_BACKLIGHT
133  #define D4DLCD_ASSERT_BACKLIGHT RESET(D4DLCD_BACKLIGHT);
134  #endif
135 
136  #ifndef D4DLCD_DEASSERT_BACKLIGHT
137  #define D4DLCD_DEASSERT_BACKLIGHT SET(D4DLCD_BACKLIGHT);
138  #endif
139 
140  #endif
141 
142  // Reset
143  #ifdef D4DLCD_RESET
144 
145  #ifndef D4DLCD_INIT_RESET
146  #define D4DLCD_INIT_RESET OUTPUT(D4DLCD_RESET);
147  #endif
148 
149  #ifndef D4DLCD_ASSERT_RESET
150  #define D4DLCD_ASSERT_RESET RESET(D4DLCD_RESET);
151  #endif
152 
153  #ifndef D4DLCD_DEASSERT_RESET
154  #define D4DLCD_DEASSERT_RESET SET(D4DLCD_RESET);
155  #endif
156 
157  #endif
158 
159 
160  #ifndef D4DLCD_SPI_ID
161  #error "The D4DLCD_SPI_ID must be set in LCD low level driver configuration file."
162  #endif
163 
164 
165  #if D4DLCD_SPI_ID == 0
166 
167  #define D4DLCD_SPI_MCR SPI0_MCR
168  #define D4DLCD_SPI_CTAR0 SPI0_CTAR0
169  #define D4DLCD_SPI_RSER SPI0_RSER
170  #define D4DLCD_SPI_SR SPI0_SR
171  #define D4DLCD_SPI_PUSHR SPI0_PUSHR
172 
173  #elif D4DLCD_SPI_ID == 1
174 
175  #define D4DLCD_SPI_MCR SPI1_MCR
176  #define D4DLCD_SPI_CTAR0 SPI1_CTAR0
177  #define D4DLCD_SPI_RSER SPI1_RSER
178  #define D4DLCD_SPI_SR SPI1_SR
179  #define D4DLCD_SPI_PUSHR SPI1_PUSHR
180 
181  #elif D4DLCD_SPI_ID == 2
182 
183  #define D4DLCD_SPI_MCR SPI2_MCR
184  #define D4DLCD_SPI_CTAR0 SPI2_CTAR0
185  #define D4DLCD_SPI_RSER SPI2_RSER
186  #define D4DLCD_SPI_SR SPI2_SR
187  #define D4DLCD_SPI_PUSHR SPI2_PUSHR
188 
189  #else
190  #error "The D4DLCD_SPI_ID is invalid"
191  #endif
192 
193 
194 
195 
196 
197  /******************************************************************************
198  * Global variables
199  ******************************************************************************/
200 
201  /******************************************************************************
202  * Global functions
203  ******************************************************************************/
204 
205  #endif
206 #endif /* __D4DLCDHW_KINETIS_SPI_H */
207 
208 
209 
210 
211 
212 
213 
214 
215 
216