Разработка, производство и продажа радиоэлектронной аппаратуры
|
Требуется программист в Зеленограде - обработка данных с датчиков; ColdFire; 40 тыс.
e-mail: jobsmp@pochta.ru
|
// *********************************************************** //
// //
// (c) Yevgeniy Sorokin, Russia, Yekaterinbourg, mar 2004 //
// E-mail: escorrespondence@mail.ru, Cell phone: +xxxxxxxxxxx //
// //
// T6963 grafical LCD driver v01 //
// AVR-GCC v3.0 compiler //
// //
// *********************************************************** //
#include <avr/io.h>
#include <avr/iom16.h>
#include <avr/pgmspace.h>
#include <avr/signal.h>
#include <avr/interrupt.h>
#include "t6963.h"
//
// ������� ������ ������� �����������
//
unsigned char T6963ReadStatus(void)
{
unsigned char temp;
DDRB = 0xFF;
DDRC = 0x00;
PIN_CD_HI();
PIN_CE_LO();
PIN_RD_LO();
// asm volatile("nop");
// asm volatile("nop");
// asm volatile("nop");
temp = PINC;
PIN_CE_HI();
PIN_RD_HI();
PIN_CD_HI();
return temp;
}
//
// ������� ������ �������� �����������
//
void T6963WriteCommand(unsigned char Command)
{
while((T6963ReadStatus()&0x03)!=0x03);
DDRC = 0xFF;
DDRB = 0xFF;
PORTC = Command;
PIN_CD_HI();
PIN_CE_LO();
PIN_WR_LO();
// asm volatile("nop");
// asm volatile("nop");
// asm volatile("nop");
PIN_CE_HI();
PIN_WR_HI();
PIN_CD_HI();
}
//
// ������� ������ ������ � ��������������� ������� ������� ���������
//
unsigned char T6963ReadData(void)
{
unsigned char temp;
T6963WriteCommand(LCD_DATA_RD_AINC);
DDRC = 0x00;
temp = PINC;
return temp;
}
//
// ������� ������ � ������ � ��������������� ������� ������� ���������
// !!! ���������� !!!
void T6963WriteChar(unsigned char Data)
{
T6963WriteData(Data-0x20);
T6963WriteCommand(LCD_DATA_WR_AINC);
}
//
// ������� ��������� ��������� ������� ������� (������)
//
void T6963SetAdress(unsigned short Adress)
{
T6963WriteData((char)(Adress & 0xFF));
T6963WriteData((char)((Adress >> 8) & 0xFF));
T6963WriteCommand(LCD_ADR_PTR_SET);
}
//
// ������� ��������� ��������� ������� ������� (������)
// ����������� ���������� !!!
void T6963SetPosition(unsigned char xpos, unsigned char ypos)
{
unsigned int adress;
if(xpos >= LCD_X_PIXELS) return;
if(ypos >= LCD_Y_PIXELS) return;
adress = LCD_GRAPH_AREA;
adress += ((LCD_X_PIXELS / 8) * ypos);
adress += xpos / 8;
T6963WriteData((unsigned char)(adress&0xFF));
T6963WriteData((unsigned char)((adress >> 8)&0xFF));
T6963WriteCommand(0x24);
}
//
// ������� ������ ������
//
void T6963WriteData(unsigned char Data)
{
while((T6963ReadStatus()&0x03)!=0x03);
DDRB = 0xFF;
DDRC = 0xFF;
PORTC = Data;
PIN_CD_LO();
PIN_CE_LO();
PIN_WR_LO();
// asm volatile("nop");
// asm volatile("nop");
// asm volatile("nop");
PIN_CE_HI();
PIN_WR_HI();
PIN_CD_HI();
}
//
// ������� ������������� ����������� T6963
//
void T6963Init(unsigned char mode)
{
DDRB = 0xFF;
PORTB = 0xFF;
DDRC = 0xFF;
PIN_RES_LO(); // Do reset
conDelay(10);
PIN_RES_HI();
if(mode == LCD_GRAPH_ON)PIN_FS_LO(); // Set 8*8 hardware font
// set graphics home adress
T6963WriteData((char)(LCD_GRAPH_HOME & 0xFF));
T6963WriteData((char)((LCD_GRAPH_HOME >> 8)&0xFF));
T6963WriteCommand(LCD_GRAPH_HOME_SET);
// set graphics area
T6963WriteData(LCD_GRAPH_AREA);
T6963WriteData(0x00);
T6963WriteCommand(LCD_GRAPH_AREA_SET);
// set text home adress
T6963WriteData((char)(LCD_TEXT_HOME & 0xFF));
T6963WriteData((char)((LCD_TEXT_HOME >> 8)&0xFF));
T6963WriteCommand(LCD_TEXT_HOME_SET);
// set text area
T6963WriteData(LCD_TEXT_AREA);
T6963WriteData(0x00);
T6963WriteCommand(LCD_TEXT_AREA_SET);
T6963WriteData(0x00);
T6963WriteData(0x00);
T6963WriteCommand(0x81); // CG ROM OR mode
T6963WriteCommand(mode);
}
Составить ответ | Вернуться на конференцию.
Ответы