OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_AT91SAM3U256_IAR/] [AT91Lib/] [drivers/] [lcd/] [lcdd_hx8347.c] - Blame information for rev 580

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.