Hola Jose,
Adjunto código para LCD de 4 líneas para la TS-7260. No he tratado de operar el
keypad, pero sí tengo algo de experiencia con otras cosas (DIO, COM, RTC,
Jumpers, etc) por si tienes alguna pregunta en particular. Sólo he trabajado en
la TS-7260 y la TS-7250.
Saludos
-S
--- In "josue.cubero" <> wrote:
>
> i am new to this group, and I will start a project with ts7200, I could mount
> the NFS server, compile some basic configurations and applications .... , The
> user manual provides little information on the creation of programs. If
> anyone has any manuals or tutorials on how to handle the LCD screen,
> keyboard, among others. I have knowledge of programming languages like Java,
> C + + and Verilog and knowledge in ubuntu. I also can provide assistance in
> Spanish. I study electronic engineering. Thanks
>
lcdmesg.h ------------------------------------
#include<unistd.h>
#include<sys/types.h>
#include<sys/mman.h>
#include<stdio.h>
#include<fcntl.h>
#include<string.h>
#define GPIOBASE 0x80840000
#define MODELBASE 0x22000000
#define TS7300 0x03
#define PADR 0
#define PADDR (0x10 / sizeof(unsigned int))
#define PAMASK 0x7F
#define PCDR (0x08 / sizeof(unsigned int))
#define PCDDR (0x18 / sizeof(unsigned int))
#define PCMASK 0x01
#define PHDR (0x40 / sizeof(unsigned int))
#define PHDDR (0x44 / sizeof(unsigned int))
// These delay values are calibrated for the EP9301
// CPU running at 166 Mhz, but should work also at 200 Mhz
#define SETUP 15
#define PULSE 36
#define HOLD 22
#define COUNTDOWN(x) asm volatile ( \
"1:\n"\
"subs %1, %1, #1;\n"\
"bne 1b;\n"\
: "=r" ((x)) : "r" ((x)) \
);
volatile unsigned int *model_ptr;
unsigned int model;
volatile unsigned int *gpio;
volatile unsigned int *phdr;
volatile unsigned int *phddr;
volatile unsigned int *pcdr;
volatile unsigned int *pcddr;
volatile unsigned int *padr;
volatile unsigned int *paddr;
void command(unsigned int);
void writechars(unsigned char *);
unsigned int lcdwait(void);
void lcdinit(void);
void lcdinit(void) {
int fd = open("/dev/mem", O_RDWR|O_SYNC);
gpio = (unsigned int *)mmap(0, getpagesize(),
PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIOBASE);
model_ptr = (unsigned int *)mmap(0, getpagesize(),
PROT_READ|PROT_WRITE, MAP_SHARED, fd,
MODELBASE);
model = *model_ptr & 0x03;
phdr = &gpio[PHDR];
padr = &gpio[PADR];
paddr = &gpio[PADDR];
phddr = &gpio[PHDDR];
*paddr = 0x0; // All of port A to inputs
*phddr |= 0x38; // bits 3:5 of port H to outputs
*phdr &= ~0x18; // de-assert EN, de-assert RS
usleep(15000);
command(0x38); // two rows, 5x7, 8 bit
usleep(4100);
command(0x38); // two rows, 5x7, 8 bit
usleep(100);
command(0x38); // two rows, 5x7, 8 bit
command(0x6); // cursor increment mode
lcdwait();
command(0x1); // clear display
lcdwait();
command(0xc); // display on, blink off, cursor off
lcdwait();
command(0x2); // return home
}
unsigned int lcdwait(void) {
int i, dat, tries = 0;
unsigned int ctrl = *phdr;
*paddr = 0x0; // All of port A to inputs
ctrl = *phdr;
do {
// step 1, apply RS & WR
ctrl |= 0x30; // de-assert WR
ctrl &= ~0x10; // de-assert RS
*phdr = ctrl;
// step 2, wait
i = SETUP;
COUNTDOWN(i);
// step 3, assert EN
ctrl |= 0x8;
*phdr = ctrl;
// step 4, wait
i = PULSE;
COUNTDOWN(i);
// step 5, de-assert EN, read result
dat = *padr;
ctrl &= ~0x8; // de-assert EN
*phdr = ctrl;
// step 6, wait
i = HOLD;
COUNTDOWN(i);
} while (dat & 0x80 && tries++ < 1000);
return dat;
}
void command(unsigned int cmd) {
int i;
unsigned int ctrl = *phdr;
*paddr = 0xff; // set port A to outputs
// step 1, apply RS & WR, send data
*padr = cmd;
ctrl &= ~0x30; // de-assert RS, assert WR
*phdr = ctrl;
// step 2, wait
i = SETUP;
COUNTDOWN(i);
// step 3, assert EN
ctrl |= 0x8;
*phdr = ctrl;
// step 4, wait
i = PULSE;
COUNTDOWN(i);
// step 5, de-assert EN
ctrl &= ~0x8; // de-assert EN
*phdr = ctrl;
// step 6, wait
i = HOLD;
COUNTDOWN(i);
}
void writechars(unsigned char *dat) {
int i;
unsigned int ctrl = *phdr;
do {
lcdwait();
*paddr = 0xff; // set port A to outputs
// step 1, apply RS & WR, send data
*padr = *dat++;
ctrl |= 0x10; // assert RS
ctrl &= ~0x20; // assert WR
*phdr = ctrl;
// step 2
i = SETUP;
COUNTDOWN(i);
// step 3, assert EN
ctrl |= 0x8;
*phdr = ctrl;
// step 4, wait 800 nS
i = PULSE;
COUNTDOWN(i);
// step 5, de-assert EN
ctrl &= ~0x8; // de-assert EN
*phdr = ctrl;
// step 6, wait
i = HOLD;
COUNTDOWN(i);
} while(*dat);
}
------------------------------------------------
lcd.c ------------------------------------------
#include <stdio.h>
#include <time.h>
#include<string.h>
#include <math.h>
#include <sys/statvfs.h>
#include "lcdmesg.h"
// Hardware
volatile unsigned int *PEDR, *PEDDR; // Acceso a hw de luces
volatile unsigned int *PBDR, *PBDDR; // Acceso a hw de DIO
volatile unsigned int *GPIOBDB; // Debounce de DIO
unsigned char *start; // Guarda seccion de memoria
int mem_fd; // File descriptor de memoria
unsigned char boton;
int i,j; // Iterador
int AuxInt;
char AuxStr[21];
unsigned char LCDmsg[1000000];
float ktiempo;
char devID[5];
// Funciones
int IniciaHardware();
int EscribeLCD1(unsigned char LCDmsg[]);
int EscribeLCD2(unsigned char LCDmsg[]);
int EscribeLCD3(unsigned char LCDmsg[]);
int EscribeLCD4(unsigned char LCDmsg[]);
int main (int argc, char* argv[]){
IniciaHardware();
EscribeLCD1("Linea 1");
EscribeLCD2("Linea 2");
EscribeLCD3("Linea 3");
EscribeLCD4("Linea 4");
return 0;
}
int IniciaHardware(){
mem_fd = open("/dev/mem", O_RDWR);
// Inicia LCD
lcdinit();
return 0;
}
int EscribeLCD1(unsigned char LCDmsg[]){
lcdwait();
command(0x80);
writechars("--------------------");
lcdwait();
command(0x80);
writechars(LCDmsg);
printf("%s\n",LCDmsg);
return 0;
}
int EscribeLCD2(unsigned char LCDmsg[]){
lcdwait();
command(0xC0);
writechars("--------------------");
lcdwait();
command(0xC0);
writechars(LCDmsg);
printf("%s\n",LCDmsg);
return 0;
}
int EscribeLCD3(unsigned char LCDmsg[]){
char AuxStr[41];
lcdwait();
command(0x94);
writechars("--------------------");
lcdwait();
command(0x94);
sprintf(AuxStr, "%s", LCDmsg);
writechars(AuxStr);
printf("%s\n",AuxStr);
return 0;
}
int EscribeLCD4(unsigned char LCDmsg[]){
lcdwait();
command(0xD4);
writechars("--------------------");
lcdwait();
command(0xD4);
sprintf(AuxStr, "%s", LCDmsg);
writechars(AuxStr);
printf("%s\n",AuxStr);
return 0;
}
------------------------------------------------
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|