SAMV71 Xplained Ultra Software Package 1.5

lcdd.c

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------- */
00002 /*                  Atmel Microcontroller Software Support                      */
00003 /*                       SAM Software Package License                           */
00004 /* ---------------------------------------------------------------------------- */
00005 /* Copyright (c) 2015, Atmel Corporation                                        */
00006 /*                                                                              */
00007 /* All rights reserved.                                                         */
00008 /*                                                                              */
00009 /* Redistribution and use in source and binary forms, with or without           */
00010 /* modification, are permitted provided that the following condition is met:    */
00011 /*                                                                              */
00012 /* - Redistributions of source code must retain the above copyright notice,     */
00013 /* this list of conditions and the disclaimer below.                            */
00014 /*                                                                              */
00015 /* Atmel's name may not be used to endorse or promote products derived from     */
00016 /* this software without specific prior written permission.                     */
00017 /*                                                                              */
00018 /* DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR   */
00019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
00020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE   */
00021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,      */
00022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
00023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  */
00024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
00025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING         */
00026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
00027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           */
00028 /* ---------------------------------------------------------------------------- */
00029 
00030 /**
00031  * \file
00032  *
00033  * Implementation of LCD driver, Include LCD initialization,
00034  * LCD on/off and LCD back-light control.
00035  *
00036  */
00037 
00038 /*----------------------------------------------------------------------------
00039  *        Headers
00040  *----------------------------------------------------------------------------*/
00041 #include "board.h"
00042 #include <stdint.h>
00043 
00044 /*----------------------------------------------------------------------------
00045  *        Local variables
00046  *----------------------------------------------------------------------------*/
00047 uint8_t ili9488_lcdMode;
00048 
00049 /*----------------------------------------------------------------------------
00050  *        Exported functions
00051  *----------------------------------------------------------------------------*/
00052 
00053 /**
00054  * \brief Turn on the LCD.
00055  */
00056 void LCDD_On(void)
00057 {
00058     if (ili9488_lcdMode == ILI9488_SPIMODE)
00059         ILI9488_SpiOn();
00060     else
00061         ILI9488_EbiOn();
00062 }
00063 
00064 /**
00065  * \brief Turn off the LCD.
00066  */
00067 void LCDD_Off(void)
00068 {
00069     if (ili9488_lcdMode == ILI9488_SPIMODE)
00070         ILI9488_SpiOff();
00071     else
00072         ILI9488_EbiOff();
00073 }
00074 
00075 /**
00076  * \brief Set the back-light of the LCD.
00077  *
00078  * \param level   Back-light brightness level [1..16], 1 means maximum brightness.
00079  */
00080 #if defined (BOARD_LCD_SPI_EXT1)
00081 void LCDD_SpiSetBacklight (uint32_t level)
00082 {
00083     /* Ensure valid level */
00084     level = (level < 1) ? 1 : level;
00085     level = (level > 16) ? 16 : level;
00086     PWMC_SetDutyCycle(PWM0, CHANNEL_PWM_LCD, level);
00087 }
00088 #endif
00089 
00090 /**
00091  * \brief Initializes the LCD controller.
00092  * Configure SMC to access LCD controller at 64MHz MCK.
00093  * \param lcdMode LCD_SPI or LCD_EBI mode
00094  * \param cRotate rotate direction 0: H 1:V
00095  */
00096 void LCDD_Initialize(uint8_t lcdMode, sXdmad *dmad, uint8_t cRotate)
00097 {
00098     ili9488_lcdMode = lcdMode;
00099 
00100     /* Initialize LCD controller */
00101     if (lcdMode == ILI9488_SPIMODE) {
00102         ILI9488_SpiInitialize(dmad);
00103         ILI9488_SpiSetDisplayLandscape(1, cRotate);
00104     } else {
00105         ILI9488_EbiInitialize(dmad);
00106         ILI9488_EbiSetDisplayLandscape(1, cRotate);
00107     }
00108 
00109 #if defined (BOARD_LCD_SPI_EXT1)
00110     /* Set LCD back-light */
00111     LCDD_SpiSetBacklight(16);
00112 #endif
00113 
00114 }
00115 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines