⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evm5509_lcd.c

📁 dsp 5509a MMC 卡 ID号读取 12Mhzx16=192M
💻 C
字号:
/*
 *  Copyright (C) 2004, Spectrum Digital, Inc.  All Rights Reserved.
 */

#include <csl.h>

#include "evm5509.h"
#include "evm5509_lcd.h"
 
/* Character set, 3 words each, starting from ASCII 32 */ 
static Uint16 charset[96 * 3 ]= {
    0x0000, 0x0000, 0x0000, // ASCII 32
    0x0000, 0x6f00, 0x0000, // ASCII 33, !
    0x0000, 0x0700, 0x0700, // ASCII 34, "
    0x147f, 0x147f, 0x1400, // ASCII 35, #
    0x242a, 0x7f2a, 0x1200, // ASCII 36, $
    0x4333, 0x0866, 0x6100, // ASCII 37, %
    0x324d, 0x5921, 0x7200, // ASCII 38, &
    0x0000, 0x0300, 0x0000, // ASCII 39, '
    0x0000, 0x3e41, 0x0000, // ASCII 40, (
    0x0041, 0x3e00, 0x0000, // ASCII 41, )
    0x0a0c, 0x070c, 0x0a00, // ASCII 42, *
    0x0808, 0x3e08, 0x0800, // ASCII 43, +
    0x0000, 0xe060, 0x0000, // ASCII 44, ,
    0x0808, 0x0808, 0x0800, // ASCII 45, -    
    0x0000, 0x6060, 0x0000, // ASCII 46, .
    0x4030, 0x0806, 0x0100, // ASCII 47, /
    0x3e45, 0x4951, 0x3e00, // ASCII 48, 0
    0x0042, 0x7f40, 0x0000, // ASCII 49, 1
    0x6251, 0x4945, 0x4200, // ASCII 50, 2
    0x2241, 0x4949, 0x3600, // ASCII 51, 3
    0x080c, 0x0a7f, 0x0800, // ASCII 52, 4
    0x2f49, 0x4949, 0x3100, // ASCII 53, 5
    0x3e49, 0x4949, 0x3200, // ASCII 54, 6
    0x0171, 0x0905, 0x0300, // ASCII 55, 7
    0x3649, 0x4949, 0x3600, // ASCII 56, 8
    0x2649, 0x4949, 0x3e00, // ASCII 57, 9
    0x0036, 0x3600, 0x0000, // ASCII 58, :
    0x0000, 0x3616, 0x0000, // ASCII 59, ;
    0x0008, 0x1422, 0x0000, // ASCII 60, <
    0x0014, 0x1414, 0x1400, // ASCII 61, =
    0x0022, 0x1408, 0x0000, // ASCII 62, >
    0x0201, 0x5905, 0x0200, // ASCII 63, ?
    0x3e41, 0x5d55, 0x5e00, // ASCII 64, @
    0x7e09, 0x0909, 0x7e00, // ASCII 65, A
    0x7f49, 0x4949, 0x3600, // ASCII 66, B
    0x3e41, 0x4141, 0x2200, // ASCII 67, C
    0x7f41, 0x4141, 0x3e00, // ASCII 68, D
    0x7f49, 0x4949, 0x4100, // ASCII 69, E
    0x7f09, 0x0909, 0x0100, // ASCII 70, F
    0x3e41, 0x4949, 0x3a00, // ASCII 71, G
    0x7f08, 0x0808, 0x7f00, // ASCII 72, H
    0x4141, 0x7f41, 0x4100, // ASCII 73, I
    0x2040, 0x4040, 0x3f00, // ASCII 74, J
    0x7f08, 0x1422, 0x4100, // ASCII 75, K
    0x7f40, 0x4040, 0x4000, // ASCII 76, L
    0x7f02, 0x0c02, 0x7f00, // ASCII 77, M
    0x7f04, 0x0810, 0x7f00, // ASCII 78, N
    0x3e41, 0x4141, 0x3e00, // ASCII 79, O
    0x7f09, 0x0909, 0x0600, // ASCII 80, P
    0x3e41, 0x5121, 0x5e00, // ASCII 81, Q
    0x7f09, 0x1929, 0x4600, // ASCII 82, R
    0x2649, 0x4949, 0x3200, // ASCII 83, S
    0x0101, 0x7f01, 0x0100, // ASCII 84, T
    0x3f40, 0x4040, 0x3f00, // ASCII 85, U
    0x0718, 0x6018, 0x0700, // ASCII 86, V
    0x1f60, 0x1860, 0x1f00, // ASCII 87, W
    0x6314, 0x0814, 0x6300, // ASCII 88, X
    0x0708, 0x7008, 0x0700, // ASCII 89, Y
    0x6151, 0x4945, 0x4300, // ASCII 90, Z
    0x007f, 0x4141, 0x0000, // ASCII 91, [
    0x0106, 0x0830, 0x4000, // ASCII 92, 
    0x0041, 0x417f, 0x0000, // ASCII 93, ]
    0x0402, 0x0102, 0x0400, // ASCII 94, ^
    0x4040, 0x4040, 0x4000, // ASCII 95, _
    0x0103, 0x0000, 0x0000, // ASCII 96, `
    0x3844, 0x4424, 0x7800, // ASCII 97, a
    0x7f44, 0x4444, 0x3800, // ASCII 98, b
    0x3844, 0x4444, 0x2800, // ASCII 99, c
    0x3844, 0x4444, 0x7f00, // ASCII 100, d
    0x3854, 0x5454, 0x4800, // ASCII 101, e
    0x0008, 0x7e09, 0x0200, // ASCII 102, f
    0x18a4, 0xa4a4, 0x7800, // ASCII 103, g
    0x7f04, 0x0404, 0x7800, // ASCII 104, h
    0x0000, 0x7d40, 0x0000, // ASCII 105, i
    0x4080, 0x807d, 0x0000, // ASCII 106, j
    0x007f, 0x1028, 0x4400, // ASCII 107, k
    0x0000, 0x7f00, 0x0000, // ASCII 108, l
    0x7804, 0x1804, 0x7800, // ASCII 109, m
    0x7c08, 0x0404, 0x7800, // ASCII 110, n
    0x3844, 0x4444, 0x3800, // ASCII 111, o
    0xf824, 0x2424, 0x1800, // ASCII 112, p
    0x1824, 0x2424, 0xf800, // ASCII 113, q
    0x7c08, 0x0404, 0x0400, // ASCII 114, r
    0x4854, 0x5454, 0x2400, // ASCII 115, s
    0x0404, 0x7e44, 0x0400, // ASCII 116, t
    0x3c40, 0x4020, 0x7c00, // ASCII 117, u
    0x0c30, 0x4030, 0x0c00, // ASCII 118, v
    0x3c40, 0x3040, 0x3c00, // ASCII 119, w
    0x4428, 0x1028, 0x4400, // ASCII 120, x
    0x1ca0, 0xa0a0, 0x7c00, // ASCII 121, y
    0x4464, 0x544c, 0x4400, // ASCII 122, z
    0x0808, 0x3641, 0x4100, // ASCII 123, {
    0x0000, 0x7700, 0x0000, // ASCII 124, |
    0x4141, 0x3608, 0x0800, // ASCII 125, }
    0x0201, 0x0102, 0x0100, // ASCII 126, ~
    0xaa55, 0xaa55, 0xaa00  // ASCII 127
};

char hexstr[16] = {'0', '1', '2', '3' ,'4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

/*
 *  ======== EVM5509_LCD_rset ========
 *  Write 8 bits as command (a0 = 0) or data (a0 = 1)
 */
void EVM5509_LCD_rset(Int16 a0, Uint16 data)
{
    /* Wait for display if busy */
    while ((*((unsigned int *)0x3F000a) & 0x80) == 0);
    
    if (a0 == 1)
        *((unsigned int *)0x3F0009) = data;
    else
        *((unsigned int *)0x3F0008) = data;
}

/*
 *  ======== EVM5509_LCD_setPos ========
 *  Set current position
 */
void EVM5509_LCD_setPos(Int16 x, Int16 y)
{
    EVM5509_LCD_rset(0, EVM5509_LCD_SETPAGE | y);
    EVM5509_LCD_rset(0, EVM5509_LCD_SETCOLH | ((x >> 4) & 0xf));
    EVM5509_LCD_rset(0, EVM5509_LCD_SETCOLL | (x & 0xf));
}

/*
 *  ======== EVM5509_LCD_raw ========
 *  Send raw display data to LCD
 */
void EVM5509_LCD_raw(Uint16 *pdata, Int16 len)
{
    Int16 i;
    
    /* Transmit raw display data to the screen */
    for (i = 0; i < len; i++)
    {
        if ((i & 1) == 0)
            EVM5509_LCD_rset(1, *pdata >> 8);
        else 
            EVM5509_LCD_rset(1, *pdata++ & 0xff);
    }
}

/*
 *  ======== EVM5509_LCD_rawPos ========
 *  Display raw data at a specified location
 */
void EVM5509_LCD_rawPos(Int16 x, Int16 y, Uint16 *pdata, Int16 len)
{
    /* Position cursor */
    EVM5509_LCD_setPos(x, y);

    /* Display number */
    EVM5509_LCD_raw(pdata, len);
}

/*
 *  ======== EVM5509_LCD_char ========
 *  Display a character at the current position
 */
void EVM5509_LCD_char(Int16 ch)
{
    /* Change non-printable characters to spaces */
    if (ch < 32)
        ch = 32;
    
    /* Display character */
    EVM5509_LCD_raw(&charset[(ch - 32) * 3], 6);
}

/*
 *  ======== EVM5509_LCD_text ========
 *  Display a text string at the current position
 */
void EVM5509_LCD_text(char *str)
{
    while (*str & 0xff)
        EVM5509_LCD_char(*str++);
}

/*
 *  ======== EVM5509_LCD_textPos ========
 *  Display a text string a specified location
 */
void EVM5509_LCD_textPos(Int16 x, Int16 y, char *str)
{
    /* Position cursor */
    EVM5509_LCD_setPos(x * 6, y);
    
    /* Display text */
    EVM5509_LCD_text(str);
}

/*
 *  ======== EVM5509_LCD_hex ========
 *  Display a 16-bit hex value at the current position
 */
void EVM5509_LCD_hex(Uint16 hexnum)
{
    int i;
    char hextext[5];

    /* Build an ASCII hex string */
    for (i = 3; i >= 0; i--)
    {
        hextext[i] = hexstr[hexnum & 0xf];
        hexnum = hexnum >> 4; 
    }
    hextext[4] = 0;
    
    /* Display the hex number */
    EVM5509_LCD_text(hextext); 
}

/*
 *  ======== EVM5509_LCD_hexPos ========
 *  Display a 16-bit hex value at a specified location
 */
void EVM5509_LCD_hexPos(Int16 x, Int16 y, Uint16 hexnum)
{
    /* Position cursor */
    EVM5509_LCD_setPos(x * 6, y);

    /* Display number */
    EVM5509_LCD_hex(hexnum);
}

/*
 *  ======== EVM5509_LCD_fillScreen ========
 *  Fill the screen with a fixed value
 */
void EVM5509_LCD_fillScreen(Int16 value)
{
    Int16 x, y;
    
    for (y = 0; y < EVM5509_LCD_ROWS; y++)
    {
        EVM5509_LCD_setPos(0, y);
        for (x = 0; x < EVM5509_LCD_PIXELCOLS; x++)
            EVM5509_LCD_rset(1, value);
    }
}

/*
 *  ======== EVM5509_LCD_init ========
 *  Initialize the LCD module
 */
void EVM5509_LCD_init()
{
    /* Configure the display */
    EVM5509_LCD_rset(0, EVM5509_LCD_RESET);          // Reset the display    
    EVM5509_LCD_rset(0, EVM5509_LCD_SETPOWER | 7);   // Turn internal voltage regulator/booster on
    EVM5509_LCD_rset(0, EVM5509_LCD_SETRATIO | 4);   // Set contrast ratio to 4
    EVM5509_LCD_rset(0, EVM5509_LCD_SETBIAS_HI);     // Set LCD bias high
    EVM5509_LCD_rset(0, EVM5509_LCD_DISPLAY_ON);     // Turn display on
    EVM5509_LCD_rset(0, EVM5509_LCD_SETCOMDIR_REV);  // Reverse the row addressing so 0,0 is in upper left
    EVM5509_LCD_rset(0, EVM5509_LCD_SETLINE | 0);    // Set the first line to 0 (normal)
        
    /* Clear the screen */
    EVM5509_LCD_fillScreen(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -