00001 /* ---------------------------------------------------------------------------- 00002 * SAM Software Package License 00003 * ---------------------------------------------------------------------------- 00004 * Copyright (c) 2011, Atmel Corporation 00005 * 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions are met: 00010 * 00011 * - Redistributions of source code must retain the above copyright notice, 00012 * this list of conditions and the disclaimer below. 00013 * 00014 * Atmel's name may not be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 00018 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00019 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00020 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 00021 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00022 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00023 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00024 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00025 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00026 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 * ---------------------------------------------------------------------------- 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 /** 00066 * \brief Turn off the LCD. 00067 */ 00068 void LCDD_Off( void) 00069 { 00070 if (ili9488_lcdMode == ILI9488_SPIMODE ) { 00071 ILI9488_SpiOff(); 00072 } else { 00073 ILI9488_EbiOff(); 00074 } 00075 } 00076 00077 /** 00078 * \brief Set the back-light of the LCD. 00079 * 00080 * \param level Back-light brightness level [1..16], 1 means maximum brightness. 00081 */ 00082 #if defined (BOARD_LCD_SPI_EXT1) 00083 void LCDD_SpiSetBacklight (uint32_t level) 00084 { 00085 /* Ensure valid level */ 00086 level = (level < 1) ? 1 : level; 00087 level = (level > 16) ? 16 : level; 00088 PWMC_SetDutyCycle(PWM0, CHANNEL_PWM_LCD, level); 00089 } 00090 #endif 00091 00092 /** 00093 * \brief Initializes the LCD controller. 00094 * Configure SMC to access LCD controller at 64MHz MCK. 00095 * \param lcdMode LCD_SPI or LCD_EBI mode 00096 * \param cRotate rotate direction 0: H 1:V 00097 */ 00098 void LCDD_Initialize( uint8_t lcdMode, sXdmad * dmad, uint8_t cRotate) 00099 { 00100 ili9488_lcdMode = lcdMode; 00101 /* Initialize LCD controller */ 00102 if (lcdMode == ILI9488_SPIMODE ) { 00103 ILI9488_SpiInitialize(dmad) ; 00104 ILI9488_SpiSetDisplayLandscape(1, cRotate); 00105 } else { 00106 ILI9488_EbiInitialize(dmad) ; 00107 ILI9488_EbiSetDisplayLandscape(1, cRotate); 00108 } 00109 00110 #if defined (BOARD_LCD_SPI_EXT1) 00111 /* Set LCD back-light */ 00112 LCDD_SpiSetBacklight( 16 ); 00113 #endif 00114 00115 } 00116