/*
ARM IP interface
lcd.c:
LCD-driver testboard
pin-info:
P9 - DB4
P10- DB5
P11- DB6
P12- DB7
P13- E: start data read/write
P14- RS: register-select
opmerkingen:
-Let op: deze code werkt niet als optimalisatie aan staat!!!!
-Alle instructies voor het display staan achterstevoren! (maakt
de code wat eenvoudiger)
-Zorg ervoor dat de delay-code ook wordt meegecompileerd, anders
gaat het hier mis...
-Deze code is gebaseerd op
"LCD routines for OLIMEX LPC-MT-2106,16x2 Character LCD 1602K,
4-bit mode operation",
Copyright (c) 2004 senz at arm.dreamislife.com
*/
#include "lcd.h"
#include "delay.h"
static void LCD_writenibble(unsigned char data);
static void LCD_writebyte(unsigned char data);
unsigned char curpos = 0; // remember cursorposition
void LCD_cursor_home(void)
{
LCD_writecontrol(0x02); // cursur home
curpos=0; // reset position
}
void LCD_clear(void)
{
LCD_writecontrol(0x01); // clearscreen
curpos=0; // reset position
}
// init LCD
// Display wordt gebruikt in 4bits modus,1 regel, 5x7 dots font.
void LCD_init(void)
{
PINSEL0 &= LCD_GPIOMASK; // standard i/o
IODIR0 |= LCD_IOALL; // alles output
IOCLR0 |= LCD_RS;
IOCLR0 |= LCD_EN;
delay_ms(15);
LCD_writebyte(0x30); // function-set opstart
delay_ms(50);
LCD_writebyte(0x30);
LCD_writebyte(0x30);
IOSET0 |= LCD_EN; // interface op 4 bits
LCD_writebyte(0x02);
IOCLR0 |= LCD_EN;
delay_ms(5);
LCD_writebyte(0x28); // function set
LCD_writebyte(0x0E); // lcd aan
LCD_writebyte(0x01); // clear screen
LCD_writebyte(0x06); // entry mode set
}
// Zet meegegeven karakter op het scherm
void LCD_putchar(char c)
{
IOSET0 |= LCD_RS;
LCD_writebyte(c);
if (++curpos==16) // remember cursorpos
curpos=0;
}
// Zet meegegeven string op het scherm
void LCD_put(char *c)
{
volatile unsigned char i, j;
// vaag display; teken 8 tot 31 is niet uitgevoerd op het scherm
for (i=0; c[i]; i++)
{
if(curpos==8) // at 8, goto next valid lcd-position
for (j=0; j<32; j++)
LCD_cursor_right();
LCD_putchar(c[i]);
}
}
void LCD_puts(char *c)
{
LCD_clear();
LCD_put(c);
}
/* old version
volatile void _LCD_put(unsigned char *c)
{
volatile unsigned char i, j;
for (i=0; c[i]; i++)
{
if(i==8)
for (j=0; j<32; j++)
{ LCD_cursor_right(); delay_ms(50); }
LCD_putchar(c[i]);
}
}
*/
// Zet het meegegeven positief getal op het scherm
void LCD_putint(unsigned int num)
{
unsigned int rest;
static unsigned char chars[10] = "0123456789"; // possible chars
char s[17]; // display has 16 chars [0..15] + 1 closing null
s[16]='\0'; // closing null set
int i=15; // startposition at last display char
// kinda function itoa, integer to ascii
if(num==0)
s[i--]='0'; // '0' at 14
else
{
while(num>0 && i)
{
rest = num%10;
num /= 10;
s[i--]=chars[rest];
}
}
LCD_put(&s[i+1]); // first, set i to starting pos, undo one i-- too much
}
// Stuurt een 4-bits commando naar het display
static void LCD_writenibble(unsigned char data)
{
IOCLR0 |= LCD_DATA;
IOSET0 |= (data<<STARTBIT);
}
// Stuurt een 8-bits commando naar het display
static void LCD_writebyte(unsigned char data)
{
/* hoogste 4 bits */
IOSET0 |= LCD_EN;
LCD_writenibble((data>>4)&0x0F);
IOCLR0 |= LCD_EN;
delay_ms(5);
/* laagste 4 bits */
IOSET0 |= LCD_EN;
LCD_writenibble(data&0x0F);
IOCLR0 |= LCD_EN;
delay_ms(5);
}
// Stuurt een commando naar het display
void LCD_writecontrol(unsigned char data)
{
IOCLR0 |= LCD_RS;
LCD_writebyte(data);
}
lcd.rar_For You I Will_LPC 2148 _LPC LCD
版权申诉
134 浏览量
2022-09-14
19:44:12
上传
评论
收藏 2KB RAR 举报
林当时
- 粉丝: 100
- 资源: 1万+
最新资源
- 基于matlab实现字符识别的参考程序,用所用的字体识别率挺高,部分手写的也能识别,但是还不能识别扭曲和倾斜的字符 .rar
- 基于matlab实现指纹识别系统 包括数据库导入、图像选择识别、帮助功能、识别图像可视、gabor滤波可视,实现界面操作.rar
- 基于matlab实现指纹识别,利用gabor滤波器,提取指纹特征,只能呢读取bmp图像.rar
- 基于matlab实现于数字图像相关方法中散斑质量评价
- 基于matlab实现遗传算法和佳点集遗传算法的基本思想和不同点,用遗传算法测试一标准函数 佳点集算法测试一标准函数
- tensorflow-gpu-2.5.1-cp38-cp38-manylinux2010-x86-64.whl
- tensorflow-gpu-2.5.0-cp39-cp39-manylinux2010-x86-64.whl
- tensorflow-gpu-2.5.2-cp39-cp39-manylinux2010-x86-64.whl
- 内含方正小标宋简体、仿宋-Gb2312、黑体、楷体、宋体,五个公文常用字体
- 记忆卡牌游戏源码及可运行文件
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈