1 /* ----------------------------------------------------------------------------
\r
2 * ATMEL Microcontroller Software Support
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2008, Atmel Corporation
\r
6 * All rights reserved.
\r
8 * Redistribution and use in source and binary forms, with or without
\r
9 * modification, are permitted provided that the following conditions are met:
\r
11 * - Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the disclaimer below.
\r
14 * Atmel's name may not be used to endorse or promote products derived from
\r
15 * this software without specific prior written permission.
\r
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
\r
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
\r
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 * ----------------------------------------------------------------------------
\r
30 //------------------------------------------------------------------------------
\r
32 //------------------------------------------------------------------------------
\r
37 #include <pmc/pmc.h>
\r
38 #include <hx8347/hx8347.h>
\r
39 #include <pio/pio.h>
\r
41 #include "FreeRTOS.h"
\r
44 //------------------------------------------------------------------------------
\r
46 //------------------------------------------------------------------------------
\r
48 //------------------------------------------------------------------------------
\r
49 /// Initializes the LCD controller.
\r
50 /// \param pLcdBase LCD base address.
\r
51 //------------------------------------------------------------------------------
\r
52 void LCDD_Initialize(void)
\r
54 const Pin pPins[] = {BOARD_LCD_PINS};
\r
55 AT91PS_HSMC4_CS pSMC = AT91C_BASE_HSMC4_CS2;
\r
59 PIO_Configure(pPins, PIO_LISTSIZE(pPins));
\r
61 // Enable peripheral clock
\r
62 PMC_EnablePeripheral(AT91C_ID_HSMC4);
\r
64 // EBI SMC Configuration
\r
65 pSMC->HSMC4_SETUP = 0
\r
66 | ((4 << 0) & AT91C_HSMC4_NWE_SETUP)
\r
67 | ((2 << 8) & AT91C_HSMC4_NCS_WR_SETUP)
\r
68 | ((4 << 16) & AT91C_HSMC4_NRD_SETUP)
\r
69 | ((2 << 24) & AT91C_HSMC4_NCS_RD_SETUP)
\r
72 pSMC->HSMC4_PULSE = 0
\r
73 | (( 5 << 0) & AT91C_HSMC4_NWE_PULSE)
\r
74 | (( 18 << 8) & AT91C_HSMC4_NCS_WR_PULSE)
\r
75 | (( 5 << 16) & AT91C_HSMC4_NRD_PULSE)
\r
76 | (( 18 << 24) & AT91C_HSMC4_NCS_RD_PULSE)
\r
79 pSMC->HSMC4_CYCLE = 0
\r
80 | ((22 << 0) & AT91C_HSMC4_NWE_CYCLE)
\r
81 | ((22 << 16) & AT91C_HSMC4_NRD_CYCLE)
\r
84 rMode = pSMC->HSMC4_MODE;
\r
85 pSMC->HSMC4_MODE = (rMode & ~(AT91C_HSMC4_DBW | AT91C_HSMC4_READ_MODE
\r
86 | AT91C_HSMC4_WRITE_MODE | AT91C_HSMC4_PMEN))
\r
87 | (AT91C_HSMC4_READ_MODE)
\r
88 | (AT91C_HSMC4_WRITE_MODE)
\r
89 | (AT91C_HSMC4_DBW_WIDTH_SIXTEEN_BITS)
\r
92 // Initialize LCD controller (HX8347)
\r
93 LCD_Initialize((void *)BOARD_LCD_BASE);
\r
95 // Set LCD backlight
\r
96 LCDD_SetBacklight(25);
\r
99 //------------------------------------------------------------------------------
\r
100 /// Turn on the LCD
\r
101 //------------------------------------------------------------------------------
\r
102 void LCDD_Start(void)
\r
104 LCD_On((void *)BOARD_LCD_BASE);
\r
107 //------------------------------------------------------------------------------
\r
108 /// Turn off the LCD
\r
109 //------------------------------------------------------------------------------
\r
110 void LCDD_Stop(void)
\r
112 LCD_Off((void *)BOARD_LCD_BASE);
\r
115 //------------------------------------------------------------------------------
\r
116 /// Set the backlight of the LCD.
\r
117 /// \param level Backlight brightness level [1..32], 32 is maximum level.
\r
118 //------------------------------------------------------------------------------
\r
119 void LCDD_SetBacklight (unsigned int level)
\r
122 const Pin pPins[] = {BOARD_BACKLIGHT_PIN};
\r
125 PIO_Configure(pPins, PIO_LISTSIZE(pPins));
\r
127 // Switch off backlight
\r
131 // Set new backlight level
\r
132 for (i = 0; i < level; i++) {
\r