/******************************************************************************
* *
* License Agreement *
* *
* Copyright (c) 2006 Altera Corporation, San Jose, California, USA. *
* All rights reserved. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
* DEALINGS IN THE SOFTWARE. *
* *
* This agreement shall be governed in all respects by the laws of the State *
* of California and by the laws of the United States of America. *
* *
******************************************************************************/
/* ===================================================================== */
/*
* This file provides the implementation of the functions used to drive a
* LCD panel.
*
* Characters written to the device will appear on the LCD panel as though
* it is a very small terminal. If the lines written to the terminal are
* longer than the number of characters on the terminal then it will scroll
* the lines of text automatically to display them all.
*
* If more lines are written than will fit on the terminal then it will scroll
* when characters are written to the line "below" the last displayed one -
* the cursor is allowed to sit below the visible area of the screen providing
* that this line is entirely blank.
*
* The following control sequences may be used to move around and do useful
* stuff:
* CR Moves back to the start of the current line
* LF Moves down a line and back to the start
* BS Moves back a character without erasing
* ESC Starts a VT100 style escape sequence
*
* The following escape sequences are recognised:
* ESC [ <row> ; <col> H Move to row and column specified (positions are
* counted from the top left which is 1;1)
* ESC [ K Clear from current position to end of line
* ESC [ 2 J Clear screen and go to top left
*
*/
/* ===================================================================== */
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include "sys/alt_alarm.h"
#include "altera_avalon_lcd_16207_regs.h"
#include "altera_avalon_lcd_16207.h"
/* --------------------------------------------------------------------- */
/* Commands which can be written to the COMMAND register */
enum /* Write to character RAM */
{
LCD_CMD_WRITE_DATA = 0x80
/* Bits 6:0 hold character RAM address */
};
enum /* Write to character generator RAM */
{
LCD_CMD_WRITE_CGR = 0x40
/* Bits 5:0 hold character generator RAM address */
};
enum /* Function Set command */
{
LCD_CMD_FUNCTION_SET = 0x20,
LCD_CMD_8BIT = 0x10,
LCD_CMD_TWO_LINE = 0x08,
LCD_CMD_BIGFONT = 0x04
};
enum /* Shift command */
{
LCD_CMD_SHIFT = 0x10,
LCD_CMD_SHIFT_DISPLAY = 0x08,
LCD_CMD_SHIFT_RIGHT = 0x04
};
enum /* On/Off command */
{
LCD_CMD_ONOFF = 0x08,
LCD_CMD_ENABLE_DISP = 0x04,
LCD_CMD_ENABLE_CURSOR = 0x02,
LCD_CMD_ENABLE_BLINK = 0x01
};
enum /* Entry Mode command */
{
LCD_CMD_MODES = 0x04,
LCD_CMD_MODE_INC = 0x02,
LCD_CMD_MODE_SHIFT = 0x01
};
enum /* Home command */
{
LCD_CMD_HOME = 0x02
};
enum /* Clear command */
{
LCD_CMD_CLEAR = 0x01
};
/* Where in LCD character space do the rows start */
static char colstart[4] = { 0x00, 0x40, 0x20, 0x60 };
/* --------------------------------------------------------------------- */
static void lcd_write_command(altera_avalon_lcd_16207_state* sp,
unsigned char command)
{
unsigned int base = sp->base;
/* We impose a timeout on the driver in case the LCD panel isn't connected.
* The first time we call this function the timeout is approx 25ms
* (assuming 5 cycles per loop and a 200MHz clock). Obviously systems
* with slower clocks, or debug builds, or slower memory will take longer.
*/
int i = 1000000;
/* Don't bother if the LCD panel didn't work before */
if (sp->broken)
return;
/* Wait until LCD isn't busy. */
while (IORD_ALTERA_AVALON_LCD_16207_STATUS(base) & ALTERA_AVALON_LCD_16207_STATUS_BUSY_MSK)
if (--i == 0)
{
sp->broken = 1;
return;
}
/* Despite what it says in the datasheet, the LCD isn't ready to accept
* a write immediately after it returns BUSY=0. Wait for 100us more.
*/
usleep(100);
IOWR_ALTERA_AVALON_LCD_16207_COMMAND(base, command);
}
/* --------------------------------------------------------------------- */
static void lcd_write_data(altera_avalon_lcd_16207_state* sp,
unsigned char data)
{
unsigned int base = sp->base;
/* We impose a timeout on the driver in case the LCD panel isn't connected.
* The first time we call this function the timeout is approx 25ms
* (assuming 5 cycles per loop and a 200MHz clock). Obviously systems
* with slower clocks, or debug builds, or slower memory will take longer.
*/
int i = 1000000;
/* Don't bother if the LCD panel didn't work before */
if (sp->broken)
return;
/* Wait until LCD isn't busy. */
while (IORD_ALTERA_AVALON_LCD_16207_STATUS(base) & ALTERA_AVALON_LCD_16207_STATUS_BUSY_MSK)
if (--i == 0)
{
sp->broken = 1;
return;
}
/* Despite what it says in the datasheet, the LCD isn't ready to accept
* a write immediately after it returns BUSY=0. Wait for 100us more.
*/
usleep(100);
IOWR_ALTERA_AVALON_LCD_16207_DATA(base, data);
sp->address++;
}
/* --------------------------------------------------------------------- */
static void lcd_clear_screen(altera_avalon_lcd_16207_state* sp)
{
int y;
lcd_write_command(sp, LCD_CMD_CLEAR);
sp->x = 0;
sp->y = 0;
sp->address = 0;
for (y = 0 ; y < ALT_LCD_HEIGHT ; y++)
{
memset(sp->line[y].data, ' ', sizeof(sp->line[0].data));
memset(sp->line[y].visible, ' ', sizeof(sp->line[0].visible));
sp->line[y].width = 0;
}
}
/* --------------------------------------------------------------------- */
没有合适的资源?快使用搜索试试~ 我知道了~
_3_seg7x8_test_bsp.rar_断码表7seg
共176个文件
c:91个
h:66个
s:8个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 7 浏览量
2022-09-24
16:36:51
上传
评论
收藏 326KB RAR 举报
温馨提示
基于nios的7断码显示与控制,nios主频100兆
资源推荐
资源详情
资源评论
收起资源包目录
_3_seg7x8_test_bsp.rar_断码表7seg (176个子文件)
settings.bsp 61KB
altera_avalon_lcd_16207.c 18KB
altera_avalon_epcs_flash_controller.c 14KB
alt_log_printf.c 14KB
altera_avalon_uart_init.c 11KB
altera_avalon_jtag_uart_init.c 10KB
alt_gmon.c 9KB
alt_instruction_exception_entry.c 9KB
altera_avalon_uart_read.c 9KB
altera_avalon_uart_write.c 8KB
altera_avalon_jtag_uart_write.c 7KB
altera_avalon_jtag_uart_read.c 7KB
alt_irq_handler.c 6KB
alt_main.c 6KB
altera_avalon_timer_ts.c 6KB
alt_ioctl.c 6KB
epcs_commands.c 6KB
altera_avalon_uart_ioctl.c 6KB
alt_open.c 6KB
alt_dev.c 6KB
altera_avalon_spi.c 5KB
alt_tick.c 5KB
alt_sbrk.c 5KB
alt_printf.c 5KB
alt_write.c 5KB
alt_iic.c 5KB
alt_gettod.c 5KB
alt_fstat.c 5KB
altera_avalon_timer_sc.c 5KB
alt_isatty.c 5KB
alt_alarm_start.c 5KB
alt_iic_isr_register.c 5KB
alt_read.c 5KB
alt_fcntl.c 4KB
alt_irq_register.c 4KB
alt_io_redirect.c 4KB
altera_avalon_uart_fd.c 4KB
alt_lseek.c 4KB
altera_avalon_sysid.c 4KB
alt_instruction_exception_register.c 4KB
alt_settod.c 4KB
alt_kill.c 4KB
alt_get_fd.c 4KB
alt_dcache_flush_no_writeback.c 4KB
alt_busy_sleep.c 4KB
alt_close.c 4KB
alt_dcache_flush.c 4KB
altera_avalon_jtag_uart_fd.c 4KB
alt_find_file.c 4KB
alt_exit.c 4KB
alt_load.c 4KB
alt_do_ctors.c 4KB
alt_do_dtors.c 4KB
alt_fs_reg.c 4KB
alt_find_dev.c 4KB
alt_flash_dev.c 4KB
alt_sys_init.c 4KB
altera_avalon_jtag_uart_ioctl.c 4KB
alt_times.c 3KB
alt_fd_lock.c 3KB
alt_icache_flush.c 3KB
alt_dma_rxchan_open.c 3KB
alt_dma_txchan_open.c 3KB
alt_getchar.c 3KB
alt_stat.c 3KB
alt_fork.c 3KB
alt_link.c 3KB
alt_execve.c 3KB
alt_rename.c 3KB
alt_fd_unlock.c 3KB
alt_unlink.c 3KB
alt_putchar.c 3KB
alt_putstr.c 3KB
alt_release_fd.c 3KB
alt_env_lock.c 3KB
alt_malloc_lock.c 3KB
alt_wait.c 3KB
alt_dev_llist_insert.c 3KB
alt_uncached_malloc.c 3KB
alt_remap_uncached.c 3KB
altera_avalon_timer_vars.c 3KB
alt_getpid.c 3KB
alt_remap_cached.c 3KB
altera_avalon_lcd_16207_fd.c 3KB
alt_environ.c 3KB
alt_uncached_free.c 3KB
alt_dcache_flush_all.c 3KB
alt_errno.c 3KB
alt_irq_vars.c 3KB
alt_icache_flush_all.c 3KB
alt_usleep.c 2KB
altera_nios2_irq.c 2KB
.cproject 25KB
create-this-bsp 759B
.force_relink 0B
memory.gdb 2KB
alt_log_printf.h 16KB
altera_avalon_uart.h 14KB
system.h 13KB
altera_avalon_timer_regs.h 10KB
共 176 条
- 1
- 2
资源评论
周楷雯
- 粉丝: 80
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功