1 /*
2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
3 * Copyright 2016-2019, 2021, 2023 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9 #ifndef _FSL_SLCD_H_
10 #define _FSL_SLCD_H_
11
12 #include "fsl_common.h"
13
14 /*!
15 * @addtogroup slcd
16 * @{
17 */
18
19 /*******************************************************************************
20 * Definitions
21 ******************************************************************************/
22
23 /*! @name Driver version */
24 /*@{*/
25 /*! @brief SLCD driver version. */
26 #define FSL_SLCD_DRIVER_VERSION (MAKE_VERSION(2, 0, 4))
27 /*@}*/
28
29 /*! @brief SLCD power supply option. */
30 typedef enum _slcd_power_supply_option
31 {
32 kSLCD_InternalVll3UseChargePump =
33 2U, /*!< VLL3 connected to VDD internally, charge pump is used to generate VLL1 and VLL2. */
34 kSLCD_ExternalVll3UseResistorBiasNetwork =
35 4U, /*!< VLL3 is driven externally and resistor bias network is used to generate VLL1 and VLL2. */
36 kSLCD_ExteranlVll3UseChargePump =
37 6U, /*!< VLL3 is driven externally and charge pump is used to generate VLL1 and VLL2. */
38 kSLCD_InternalVll1UseChargePump =
39 7U /*!< VIREG is connected to VLL1 internally and charge pump is used to generate VLL2 and VLL3. */
40 } slcd_power_supply_option_t;
41
42 /*! @brief SLCD regulated voltage trim parameter, be used to meet the desired contrast. */
43 typedef enum _slcd_regulated_voltage_trim
44 {
45 kSLCD_RegulatedVolatgeTrim00 = 0U, /*!< Increase the voltage to 0.91 V. */
46 kSLCD_RegulatedVolatgeTrim01, /*!< Increase the voltage to 1.01 V. */
47 kSLCD_RegulatedVolatgeTrim02, /*!< Increase the voltage to 0.96 V. */
48 kSLCD_RegulatedVolatgeTrim03, /*!< Increase the voltage to 1.06 V. */
49 kSLCD_RegulatedVolatgeTrim04, /*!< Increase the voltage to 0.93 V. */
50 kSLCD_RegulatedVolatgeTrim05, /*!< Increase the voltage to 1.02 V. */
51 kSLCD_RegulatedVolatgeTrim06, /*!< Increase the voltage to 0.98 V. */
52 kSLCD_RegulatedVolatgeTrim07, /*!< Increase the voltage to 1.08 V. */
53 kSLCD_RegulatedVolatgeTrim08, /*!< Increase the voltage to 0.92 V. */
54 kSLCD_RegulatedVolatgeTrim09, /*!< Increase the voltage to 1.02 V. */
55 kSLCD_RegulatedVolatgeTrim10, /*!< Increase the voltage to 0.97 V. */
56 kSLCD_RegulatedVolatgeTrim11, /*!< Increase the voltage to 1.07 V. */
57 kSLCD_RegulatedVolatgeTrim12, /*!< Increase the voltage to 0.94 V. */
58 kSLCD_RegulatedVolatgeTrim13, /*!< Increase the voltage to 1.05 V. */
59 kSLCD_RegulatedVolatgeTrim14, /*!< Increase the voltage to 0.99 V. */
60 kSLCD_RegulatedVolatgeTrim15 /*!< Increase the voltage to 1.09 V. */
61 } slcd_regulated_voltage_trim_t;
62
63 /*! @brief SLCD load adjust to handle different LCD glass capacitance or
64 * configure the LCD charge pump clock source.
65 * Adjust the LCD glass capacitance if resistor bias network is enabled:
66 * kSLCD_LowLoadOrFastestClkSrc - Low load (LCD glass capacitance 2000pF or lower.
67 * LCD or GPIO function can be used on VLL1,VLL2,Vcap1 and Vcap2 pins)
68 * kSLCD_LowLoadOrIntermediateClkSrc - low load (LCD glass capacitance 2000pF or lower.
69 * LCD or GPIO function can be used on VLL1,VLL2,Vcap1 and Vcap2 pins)
70 * kSLCD_HighLoadOrIntermediateClkSrc - high load (LCD glass capacitance 8000pF or lower.
71 * LCD or GPIO function can be used on Vcap1 and Vcap2 pins)
72 * kSLCD_HighLoadOrSlowestClkSrc - high load (LCD glass capacitance 8000pF or lower
73 * LCD or GPIO function can be used on Vcap1 and Vcap2 pins)
74 * Adjust clock for charge pump if charge pump is enabled:
75 * kSLCD_LowLoadOrFastestClkSrc - Fasten clock source (LCD glass capacitance
76 * 8000pF or 4000pF or lower if Fast Frame Rate is set)
77 * kSLCD_LowLoadOrIntermediateClkSrc - Intermediate clock source (LCD glass
78 * capacitance 4000pF or 2000pF or lower if Fast Frame Rate is set)
79 * kSLCD_HighLoadOrIntermediateClkSrc - Intermediate clock source (LCD glass
80 * capacitance 2000pF or 1000pF or lower if Fast Frame Rate is set)
81 * kSLCD_HighLoadOrSlowestClkSrc - slowest clock source (LCD glass capacitance
82 * 1000pF or 500pF or lower if Fast Frame Rate is set)
83 */
84 typedef enum _slcd_load_adjust
85 {
86 kSLCD_LowLoadOrFastestClkSrc = 0U, /*!< Adjust in low load or selects fastest clock. */
87 kSLCD_LowLoadOrIntermediateClkSrc, /*!< Adjust in low load or selects intermediate clock. */
88 kSLCD_HighLoadOrIntermediateClkSrc, /*!< Adjust in high load or selects intermediate clock. */
89 kSLCD_HighLoadOrSlowestClkSrc /*!< Adjust in high load or selects slowest clock. */
90 } slcd_load_adjust_t;
91
92 /*! @brief SLCD clock source. */
93 typedef enum _slcd_clock_src
94 {
95 kSLCD_DefaultClk = 0U, /*!< Select default clock ERCLK32K. */
96 kSLCD_AlternateClk1 = 1U, /*!< Select alternate clock source 1 : MCGIRCLK. */
97 #if FSL_FEATURE_SLCD_HAS_MULTI_ALTERNATE_CLOCK_SOURCE
98 kSLCD_AlternateClk2 = 3U /*!< Select alternate clock source 2 : OSCERCLK. */
99 #endif /* FSL_FEATURE_SLCD_HAS_MULTI_ALTERNATE_CLOCK_SOURCE */
100 } slcd_clock_src_t;
101
102 /*! @brief SLCD alternate clock divider. */
103 typedef enum _slcd_alt_clock_div
104 {
105 kSLCD_AltClkDivFactor1 = 0U, /*!< No divide for alternate clock. */
106 kSLCD_AltClkDivFactor64, /*!< Divide alternate clock with factor 64. */
107 kSLCD_AltClkDivFactor256, /*!< Divide alternate clock with factor 256. */
108 kSLCD_AltClkDivFactor512 /*!< Divide alternate clock with factor 512. */
109 } slcd_alt_clock_div_t;
110
111 /*! @brief SLCD clock prescaler to generate frame frequency. */
112 typedef enum _slcd_clock_prescaler
113 {
114 kSLCD_ClkPrescaler00 = 0U, /*!< Prescaler 0. */
115 kSLCD_ClkPrescaler01, /*!< Prescaler 1. */
116 kSLCD_ClkPrescaler02, /*!< Prescaler 2. */
117 kSLCD_ClkPrescaler03, /*!< Prescaler 3. */
118 kSLCD_ClkPrescaler04, /*!< Prescaler 4. */
119 kSLCD_ClkPrescaler05, /*!< Prescaler 5. */
120 kSLCD_ClkPrescaler06, /*!< Prescaler 6. */
121 kSLCD_ClkPrescaler07 /*!< Prescaler 7. */
122 } slcd_clock_prescaler_t;
123
124 /*! @brief SLCD duty cycle. */
125 typedef enum _slcd_duty_cycle
126 {
127 kSLCD_1Div1DutyCycle = 0U, /*!< LCD use 1 BP 1/1 duty cycle. */
128 kSLCD_1Div2DutyCycle, /*!< LCD use 2 BP 1/2 duty cycle. */
129 kSLCD_1Div3DutyCycle, /*!< LCD use 3 BP 1/3 duty cycle. */
130 kSLCD_1Div4DutyCycle, /*!< LCD use 4 BP 1/4 duty cycle. */
131 kSLCD_1Div5DutyCycle, /*!< LCD use 5 BP 1/5 duty cycle. */
132 kSLCD_1Div6DutyCycle, /*!< LCD use 6 BP 1/6 duty cycle. */
133 kSLCD_1Div7DutyCycle, /*!< LCD use 7 BP 1/7 duty cycle. */
134 kSLCD_1Div8DutyCycle /*!< LCD use 8 BP 1/8 duty cycle. */
135 } slcd_duty_cycle_t;
136
137 /*! @brief SLCD segment phase type. */
138 typedef enum _slcd_phase_type
139 {
140 kSLCD_NoPhaseActivate = 0x00U, /*!< LCD wareform no phase activates. */
141 kSLCD_PhaseAActivate = 0x01U, /*!< LCD waveform phase A activates. */
142 kSLCD_PhaseBActivate = 0x02U, /*!< LCD waveform phase B activates. */
143 kSLCD_PhaseCActivate = 0x04U, /*!< LCD waveform phase C activates. */
144 kSLCD_PhaseDActivate = 0x08U, /*!< LCD waveform phase D activates. */
145 kSLCD_PhaseEActivate = 0x10U, /*!< LCD waveform phase E activates. */
146 kSLCD_PhaseFActivate = 0x20U, /*!< LCD waveform phase F activates. */
147 kSLCD_PhaseGActivate = 0x40U, /*!< LCD waveform phase G activates. */
148 kSLCD_PhaseHActivate = 0x80U /*!< LCD waveform phase H activates. */
149 } slcd_phase_type_t;
150
151 /*! @brief SLCD segment phase bit index. */
152 typedef enum _slcd_phase_index
153 {
154 kSLCD_PhaseAIndex = 0x0U, /*!< LCD phase A bit index. */
155 kSLCD_PhaseBIndex = 0x1U, /*!< LCD phase B bit index. */
156 kSLCD_PhaseCIndex = 0x2U, /*!< LCD phase C bit index. */
157 kSLCD_PhaseDIndex = 0x3U, /*!< LCD phase D bit index. */
158 kSLCD_PhaseEIndex = 0x4U, /*!< LCD phase E bit index. */
159 kSLCD_PhaseFIndex = 0x5U, /*!< LCD phase F bit index. */
160 kSLCD_PhaseGIndex = 0x6U, /*!< LCD phase G bit index. */
161 kSLCD_PhaseHIndex = 0x7U /*!< LCD phase H bit index. */
162 } slcd_phase_index_t;
163
164 /*! @brief SLCD display mode. */
165 typedef enum _slcd_display_mode
166 {
167 kSLCD_NormalMode = 0U, /*!< LCD Normal display mode. */
168 kSLCD_AlternateMode, /*!< LCD Alternate display mode. For four back planes or less. */
169 kSLCD_BlankMode /*!< LCD Blank display mode. */
170 } slcd_display_mode_t;
171
172 /*! @brief SLCD blink mode. */
173 typedef enum _slcd_blink_mode
174 {
175 kSLCD_BlankDisplayBlink = 0U, /*!< Display blank during the blink period. */
176 kSLCD_AltDisplayBlink /*!< Display alternate display during the blink period if duty cycle is lower than 5. */
177 } slcd_blink_mode_t;
178
179 /*! @brief SLCD blink rate. */
180 typedef enum _slcd_blink_rate
181 {
182 kSLCD_BlinkRate00 = 0U, /*!< SLCD blink rate is LCD clock/((2^12)). */
183 kSLCD_BlinkRate01, /*!< SLCD blink rate is LCD clock/((2^13)). */
184 kSLCD_BlinkRate02, /*!< SLCD blink rate is LCD clock/((2^14)). */
185 kSLCD_BlinkRate03, /*!< SLCD blink rate is LCD clock/((2^15)). */
186 kSLCD_BlinkRate04, /*!< SLCD blink rate is LCD clock/((2^16)). */
187 kSLCD_BlinkRate05, /*!< SLCD blink rate is LCD clock/((2^17)). */
188 kSLCD_BlinkRate06, /*!< SLCD blink rate is LCD clock/((2^18)). */
189 kSLCD_BlinkRate07 /*!< SLCD blink rate is LCD clock/((2^19)). */
190 } slcd_blink_rate_t;
191
192 /*! @brief SLCD fault detect clock prescaler. */
193 typedef enum _slcd_fault_detect_clock_prescaler
194 {
195 kSLCD_FaultSampleFreqDivider1 = 0U, /*!< Fault detect sample clock frequency is 1/1 bus clock. */
196 kSLCD_FaultSampleFreqDivider2, /*!< Fault detect sample clock frequency is 1/2 bus clock. */
197 kSLCD_FaultSampleFreqDivider4, /*!< Fault detect sample clock frequency is 1/4 bus clock. */
198 kSLCD_FaultSampleFreqDivider8, /*!< Fault detect sample clock frequency is 1/8 bus clock. */
199 kSLCD_FaultSampleFreqDivider16, /*!< Fault detect sample clock frequency is 1/16 bus clock. */
200 kSLCD_FaultSampleFreqDivider32, /*!< Fault detect sample clock frequency is 1/32 bus clock. */
201 kSLCD_FaultSampleFreqDivider64, /*!< Fault detect sample clock frequency is 1/64 bus clock. */
202 kSLCD_FaultSampleFreqDivider128 /*!< Fault detect sample clock frequency is 1/128 bus clock. */
203 } slcd_fault_detect_clock_prescaler_t;
204
205 /*! @brief SLCD fault detect sample window width. */
206 typedef enum _slcd_fault_detect_sample_window_width
207 {
208 kSLCD_FaultDetectWindowWidth4SampleClk = 0U, /*!< Sample window width is 4 sample clock cycles. */
209 kSLCD_FaultDetectWindowWidth8SampleClk, /*!< Sample window width is 8 sample clock cycles. */
210 kSLCD_FaultDetectWindowWidth16SampleClk, /*!< Sample window width is 16 sample clock cycles. */
211 kSLCD_FaultDetectWindowWidth32SampleClk, /*!< Sample window width is 32 sample clock cycles. */
212 kSLCD_FaultDetectWindowWidth64SampleClk, /*!< Sample window width is 64 sample clock cycles. */
213 kSLCD_FaultDetectWindowWidth128SampleClk, /*!< Sample window width is 128 sample clock cycles. */
214 kSLCD_FaultDetectWindowWidth256SampleClk, /*!< Sample window width is 256 sample clock cycles. */
215 kSLCD_FaultDetectWindowWidth512SampleClk /*!< Sample window width is 512 sample clock cycles. */
216 } slcd_fault_detect_sample_window_width_t;
217
218 /*! @brief SLCD interrupt source. */
219 typedef enum _slcd_interrupt_enable
220 {
221 kSLCD_FaultDetectCompleteInterrupt = 1U, /*!< SLCD fault detection complete interrupt source. */
222 #if FSL_FEATURE_SLCD_HAS_FRAME_FREQUENCY_INTERRUPT
223 kSLCD_FrameFreqInterrupt = 2U /*!< SLCD frame frequency interrupt source. Not available in all low-power modes. */
224 #endif /* FSL_FEATURE_SLCD_HAS_FRAME_FREQUENCY_INTERRUPT */
225 } slcd_interrupt_enable_t;
226
227 /*! @brief SLCD behavior in low power mode. */
228 typedef enum _slcd_lowpower_behavior
229 {
230 kSLCD_EnabledInWaitStop = 0, /*!< SLCD works in wait and stop mode. */
231 kSLCD_EnabledInWaitOnly, /*!< SLCD works in wait mode and is disabled in stop mode. */
232 kSLCD_EnabledInStopOnly, /*!< SLCD works in stop mode and is disabled in wait mode. */
233 kSLCD_DisabledInWaitStop /*!< SLCD is disabled in stop mode and wait mode. */
234 } slcd_lowpower_behavior;
235
236 /*! @brief SLCD fault frame detection configuration structure. */
237 typedef struct _slcd_fault_detect_config
238 {
239 bool faultDetectIntEnable; /*!< Fault frame detection interrupt enable flag.*/
240 bool faultDetectBackPlaneEnable; /*!< True means the pin id fault detected is back plane otherwise front plane. */
241 uint8_t faultDetectPinIndex; /*!< Fault detected pin id from 0 to 63. */
242 slcd_fault_detect_clock_prescaler_t faultPrescaler; /*!< Fault detect clock prescaler. */
243 slcd_fault_detect_sample_window_width_t width; /*!< Fault detect sample window width. */
244 } slcd_fault_detect_config_t;
245
246 /*! @brief SLCD clock configuration structure. */
247 typedef struct _slcd_clock_config
248 {
249 slcd_clock_src_t clkSource; /*!< Clock source. "slcd_clock_src_t" is recommended to be used.
250 The SLCD is optimized to operate using a 32.768kHz clock input. */
251 slcd_alt_clock_div_t
252 altClkDivider; /*!< The divider to divide the alternate clock used for alternate clock source. */
253 slcd_clock_prescaler_t clkPrescaler; /*!< Clock prescaler. */
254 #if FSL_FEATURE_SLCD_HAS_FAST_FRAME_RATE
255 bool fastFrameRateEnable; /*!< Fast frame rate enable flag. */
256 #endif /* FSL_FEATURE_SLCD_HAS_FAST_FRAME_RATE */
257 } slcd_clock_config_t;
258
259 /*! @brief SLCD configuration structure. */
260 typedef struct _slcd_config
261 {
262 slcd_power_supply_option_t powerSupply; /*!< Power supply option. */
263 slcd_regulated_voltage_trim_t voltageTrim; /*!< Regulated voltage trim used for the internal regulator VIREG to
264 adjust to facilitate contrast control. */
265 slcd_clock_config_t *clkConfig; /*!< Clock configure. */
266 slcd_display_mode_t displayMode; /*!< SLCD display mode. */
267 slcd_load_adjust_t loadAdjust; /*!< Load adjust to handle glass capacitance. */
268 slcd_duty_cycle_t dutyCycle; /*!< Duty cycle. */
269 slcd_lowpower_behavior lowPowerBehavior; /*!< SLCD behavior in low power mode. */
270 #if FSL_FEATURE_SLCD_HAS_FRAME_FREQUENCY_INTERRUPT
271 bool frameFreqIntEnable; /*!< Frame frequency interrupt enable flag.*/
272 #endif /* FSL_FEATURE_SLCD_HAS_FAST_FRAME_RATE */
273 uint32_t slcdLowPinEnabled; /*!< Setting enabled SLCD pin 0 ~ pin 31. Setting bit n to 1 means enable pin n. */
274 uint32_t
275 slcdHighPinEnabled; /*!< Setting enabled SLCD pin 32 ~ pin 63. Setting bit n to 1 means enable pin (n + 32). */
276 uint32_t backPlaneLowPin; /*!< Setting back plane pin 0 ~ pin 31. Setting bit n to 1 means setting pin n as back
277 plane. It should never have the same bit setting as the frontPlane Pin. */
278 uint32_t backPlaneHighPin; /*!< Setting back plane pin 32 ~ pin 63. Setting bit n to 1 means setting pin (n + 32) as
279 back plane. It should never have the same bit setting as the frontPlane Pin. */
280 slcd_fault_detect_config_t *faultConfig; /*!< Fault frame detection configure. If not requirement, set to NULL. */
281 } slcd_config_t;
282 /*******************************************************************************
283 * API
284 ******************************************************************************/
285
286 #if defined(__cplusplus)
287 extern "C" {
288 #endif /* __cplusplus*/
289
290 /*!
291 * @name Initialization and deinitialization
292 * @{
293 */
294
295 /*!
296 * @brief Initializes the SLCD, ungates the module clock, initializes the power
297 * setting, enables all used plane pins, and sets with interrupt and work mode
298 * with the configuration.
299 *
300 * @param base SLCD peripheral base address.
301 * @param configure SLCD configuration pointer.
302 * For the configuration structure, many parameters have the default setting
303 * and the SLCD_Getdefaultconfig() is provided to get them. Use it
304 * verified for their applications.
305 * The others have no default settings, such as "clkConfig", and must be provided
306 * by the application before calling the SLCD_Init() API.
307 */
308 void SLCD_Init(LCD_Type *base, slcd_config_t *configure);
309
310 /*!
311 * @brief Deinitializes the SLCD module, gates the module clock, disables an interrupt,
312 * and displays the SLCD.
313 *
314 * @param base SLCD peripheral base address.
315 */
316 void SLCD_Deinit(LCD_Type *base);
317
318 /*!
319 * @brief Gets the SLCD default configuration structure. The
320 * purpose of this API is to get default parameters of the configuration structure
321 * for the SLCD_Init(). Use these initialized parameters unchanged in SLCD_Init()
322 * or modify fields of the structure before the calling SLCD_Init().
323 * All default parameters of the configure structuration are listed.
324 * @code
325 config.displayMode = kSLCD_NormalMode;
326 config.powerSupply = kSLCD_InternalVll3UseChargePump;
327 config.voltageTrim = kSLCD_RegulatedVolatgeTrim00;
328 config.lowPowerBehavior = kSLCD_EnabledInWaitStop;
329 config.interruptSrc = 0;
330 config.faultConfig = NULL;
331 config.frameFreqIntEnable = false;
332 @endcode
333 * @param configure The SLCD configuration structure pointer.
334 */
335 void SLCD_GetDefaultConfig(slcd_config_t *configure);
336
337 /* @}*/
338
339 /*!
340 * @name Plane Setting and Display Control
341 * @{
342 */
343
344 /*!
345 * @brief Enables the SLCD controller, starts generation, and displays the front plane and back plane waveform.
346 *
347 * @param base SLCD peripheral base address.
348 */
SLCD_StartDisplay(LCD_Type * base)349 static inline void SLCD_StartDisplay(LCD_Type *base)
350 {
351 base->GCR |= LCD_GCR_LCDEN_MASK;
352 }
353
354 /*!
355 * @brief Stops the SLCD controller. There is no waveform generator and all enabled pins
356 * only output a low value.
357 *
358 * @param base SLCD peripheral base address.
359 */
SLCD_StopDisplay(LCD_Type * base)360 static inline void SLCD_StopDisplay(LCD_Type *base)
361 {
362 base->GCR &= ~LCD_GCR_LCDEN_MASK;
363 }
364
365 /*!
366 * @brief Starts the SLCD blink mode.
367 *
368 * @param base SLCD peripheral base address.
369 * @param mode SLCD blink mode.
370 * @param rate SLCD blink rate.
371 */
372 void SLCD_StartBlinkMode(LCD_Type *base, slcd_blink_mode_t mode, slcd_blink_rate_t rate);
373
374 /*!
375 * @brief Stops the SLCD blink mode.
376 *
377 * @param base SLCD peripheral base address.
378 */
SLCD_StopBlinkMode(LCD_Type * base)379 static inline void SLCD_StopBlinkMode(LCD_Type *base)
380 {
381 base->AR &= ~LCD_AR_BLINK_MASK;
382 }
383
384 /*!
385 * @brief Sets the SLCD back plane pin phase.
386 *
387 * This function sets the SLCD back plane pin phase. "kSLCD_PhaseXActivate" setting
388 * means the phase X is active for the back plane pin. "kSLCD_NoPhaseActivate" setting
389 * means there is no phase active for the back plane pin.
390 * For example, set the back plane pin 20 for phase A.
391 * @code
392 * SLCD_SetBackPlanePhase(LCD, 20, kSLCD_PhaseAActivate);
393 * @endcode
394 *
395 * @param base SLCD peripheral base address.
396 * @param pinIndx SLCD back plane pin index. Range from 0 to 63.
397 * @param phase The phase activates for the back plane pin.
398 */
SLCD_SetBackPlanePhase(LCD_Type * base,uint32_t pinIndx,slcd_phase_type_t phase)399 static inline void SLCD_SetBackPlanePhase(LCD_Type *base, uint32_t pinIndx, slcd_phase_type_t phase)
400 {
401 base->WF8B[pinIndx] = (uint8_t)phase;
402 }
403
404 /*!
405 * @brief Sets the SLCD front plane segment operation for a front plane pin.
406 *
407 * This function sets the SLCD front plane segment on or off operation.
408 * Each bit turns on or off the segments associated with the front plane pin in
409 * the following pattern: HGFEDCBA (most significant bit controls segment H and
410 * least significant bit controls segment A).
411 * For example, turn on the front plane pin 20 for phase B and phase C.
412 * @code
413 * SLCD_SetFrontPlaneSegments(LCD, 20, (kSLCD_PhaseBActivate | kSLCD_PhaseCActivate));
414 * @endcode
415 *
416 * @param base SLCD peripheral base address.
417 * @param pinIndx SLCD back plane pin index. Range from 0 to 63.
418 * @param operation The operation for the segment on the front plane pin.
419 * This is a logical OR of the enumeration :: slcd_phase_type_t.
420 */
SLCD_SetFrontPlaneSegments(LCD_Type * base,uint32_t pinIndx,uint8_t operation)421 static inline void SLCD_SetFrontPlaneSegments(LCD_Type *base, uint32_t pinIndx, uint8_t operation)
422 {
423 base->WF8B[pinIndx] = operation;
424 }
425
426 /*!
427 * @brief Sets one SLCD front plane pin for one phase.
428 *
429 * This function can be used to set one phase on or off for the front plane pin.
430 * It can be call many times to set the plane pin for different phase indexes.
431 * For example, turn on the front plane pin 20 for phase B and phase C.
432 * @code
433 * SLCD_SetFrontPlaneOnePhase(LCD, 20, kSLCD_PhaseBIndex, true);
434 * SLCD_SetFrontPlaneOnePhase(LCD, 20, kSLCD_PhaseCIndex, true);
435 * @endcode
436 *
437 * @param base SLCD peripheral base address.
438 * @param pinIndx SLCD back plane pin index. Range from 0 to 63.
439 * @param phaseIndx The phase bit index @ref slcd_phase_index_t.
440 * @param enable True to turn on the segment for phaseIndx phase
441 * false to turn off the segment for phaseIndx phase.
442 */
SLCD_SetFrontPlaneOnePhase(LCD_Type * base,uint32_t pinIndx,slcd_phase_index_t phaseIndx,bool enable)443 static inline void SLCD_SetFrontPlaneOnePhase(LCD_Type *base,
444 uint32_t pinIndx,
445 slcd_phase_index_t phaseIndx,
446 bool enable)
447 {
448 uint8_t reg = base->WF8B[pinIndx];
449
450 if (enable)
451 {
452 base->WF8B[pinIndx] = (reg | (1U << (uint32_t)phaseIndx));
453 }
454 else
455 {
456 base->WF8B[pinIndx] = (reg & ~(1U << (uint32_t)phaseIndx));
457 }
458 }
459
460 #if FSL_FEATURE_SLCD_HAS_PAD_SAFE
461 /*!
462 * @brief Enables/disables the SLCD pad safe state.
463 *
464 * Forces the safe state on the LCD pad controls. All LCD front plane
465 * and backplane functions are disabled.
466 *
467 * @param base SLCD peripheral base address.
468 * @param enable True enable, false disable.
469 */
SLCD_EnablePadSafeState(LCD_Type * base,bool enable)470 static inline void SLCD_EnablePadSafeState(LCD_Type *base, bool enable)
471 {
472 if (enable)
473 { /* Enable. */
474 base->GCR |= LCD_GCR_PADSAFE_MASK;
475 }
476 else
477 { /* Disable. */
478 base->GCR &= ~LCD_GCR_PADSAFE_MASK;
479 }
480 }
481 #endif /* FSL_FEATURE_SLCD_HAS_PAD_SAFE */
482
483 /*!
484 * @brief Gets the SLCD fault detect counter.
485 *
486 * This function gets the number of samples inside the
487 * fault detection sample window.
488 *
489 * @param base SLCD peripheral base address.
490 * @return The fault detect counter. The maximum return value is 255.
491 * If the maximum 255 returns, the overflow may happen.
492 * Reconfigure the fault detect sample window and fault detect clock prescaler
493 * for proper sampling.
494 */
SLCD_GetFaultDetectCounter(LCD_Type * base)495 static inline uint32_t SLCD_GetFaultDetectCounter(LCD_Type *base)
496 {
497 return base->FDSR & LCD_FDSR_FDCNT_MASK;
498 }
499
500 /* @} */
501
502 /*!
503 * @name Interrupts.
504 * @{
505 */
506
507 /*!
508 * @brief Enables the SLCD interrupt.
509 * For example, to enable fault detect complete interrupt and frame frequency interrupt,
510 * for FSL_FEATURE_SLCD_HAS_FRAME_FREQUENCY_INTERRUPT enabled case, do the following.
511 * @code
512 * SLCD_EnableInterrupts(LCD,kSLCD_FaultDetectCompleteInterrupt | kSLCD_FrameFreqInterrupt);
513 * @endcode
514 *
515 * @param base SLCD peripheral base address.
516 * @param mask SLCD interrupts to enable. This is a logical OR of the
517 * enumeration :: slcd_interrupt_enable_t.
518 */
519 void SLCD_EnableInterrupts(LCD_Type *base, uint32_t mask);
520
521 /*!
522 * @brief Disables the SLCD interrupt.
523 * For example, to disable fault detect complete interrupt and frame frequency interrupt,
524 * for FSL_FEATURE_SLCD_HAS_FRAME_FREQUENCY_INTERRUPT enabled case, do the following.
525 * @code
526 * SLCD_DisableInterrupts(LCD,kSLCD_FaultDetectCompleteInterrupt | kSLCD_FrameFreqInterrupt);
527 * @endcode
528 *
529 * @param base SLCD peripheral base address.
530 * @param mask SLCD interrupts to disable. This is a logical OR of the
531 * enumeration :: slcd_interrupt_enable_t.
532 */
533 void SLCD_DisableInterrupts(LCD_Type *base, uint32_t mask);
534
535 /*!
536 * @brief Gets the SLCD interrupt status flag.
537 *
538 * @param base SLCD peripheral base address.
539 * @return The event status of the interrupt source. This is the logical OR of members
540 * of the enumeration :: slcd_interrupt_enable_t.
541 */
542 uint32_t SLCD_GetInterruptStatus(LCD_Type *base);
543
544 /*!
545 * @brief Clears the SLCD interrupt events status flag.
546 *
547 * @param base SLCD peripheral base address.
548 * @param mask SLCD interrupt source to be cleared.
549 * This is the logical OR of members of the enumeration :: slcd_interrupt_enable_t.
550 */
551 void SLCD_ClearInterruptStatus(LCD_Type *base, uint32_t mask);
552
553 /* @} */
554
555 #if defined(__cplusplus)
556 }
557 #endif /* __cplusplus*/
558
559 /*! @}*/
560
561 #endif /* _FSL_SLCD_H_*/
562