Current state, serial io not initializing.
This commit is contained in:
parent
777765d4d6
commit
0f2063340f
48
io.c
48
io.c
|
@ -1,3 +1,5 @@
|
||||||
|
#include <Devices.h>
|
||||||
|
#include <Serial.h>
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
@ -5,18 +7,58 @@
|
||||||
#define true 1
|
#define true 1
|
||||||
#define false 0
|
#define false 0
|
||||||
|
|
||||||
|
#define SERIAL_BUFFER_SIZE 16000
|
||||||
|
|
||||||
extern unsigned char trace_active;
|
extern unsigned char trace_active;
|
||||||
|
extern void done(void);
|
||||||
|
|
||||||
|
short driverIn;
|
||||||
|
short driverOut;
|
||||||
|
SerShk handshake;
|
||||||
|
Ptr serial_buffer;
|
||||||
|
|
||||||
void io_init(void)
|
void io_init(void)
|
||||||
{
|
{
|
||||||
|
if (OpenDriver("\p.AOut",&driverOut) != noErr)
|
||||||
|
done();
|
||||||
|
if (OpenDriver("\p.AIn",&driverIn) != noErr)
|
||||||
|
done();
|
||||||
|
|
||||||
|
handshake.fXOn=0;
|
||||||
|
handshake.fCTS=0;
|
||||||
|
handshake.errs=0;
|
||||||
|
handshake.evts=0;
|
||||||
|
handshake.fInX=0;
|
||||||
|
|
||||||
|
SerHShake(driverIn,&handshake);
|
||||||
|
SerReset(driverOut,baud1200+stop10+noParity+data8);
|
||||||
|
serial_buffer=NewPtr(SERIAL_BUFFER_SIZE);
|
||||||
|
|
||||||
|
if (serial_buffer!=noErr)
|
||||||
|
done();
|
||||||
|
|
||||||
|
SerSetBuf(driverIn,serial_buffer,SERIAL_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void io_send_byte(unsigned char b)
|
void io_send_byte(unsigned char b)
|
||||||
{
|
{
|
||||||
|
long count=1;
|
||||||
|
if (NoEcho==padF)
|
||||||
|
return;
|
||||||
|
|
||||||
|
FSWrite(driverOut,&count,&b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void io_main(void)
|
void io_main(void)
|
||||||
{
|
{
|
||||||
|
long count;
|
||||||
|
padByte inBuff[SERIAL_BUFFER_SIZE];
|
||||||
|
SerGetBuf(driverIn,&count);
|
||||||
|
if (count>0)
|
||||||
|
{
|
||||||
|
FSRead(driverIn,&count,inBuff);
|
||||||
|
ShowPLATO(inBuff,(short)count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,4 +106,10 @@ void io_send_back_out(void)
|
||||||
|
|
||||||
void io_done()
|
void io_done()
|
||||||
{
|
{
|
||||||
|
if (serial_buffer!=NULL)
|
||||||
|
{
|
||||||
|
SerSetBuf(driverIn,NULL,0);
|
||||||
|
DisposePtr(serial_buffer);
|
||||||
|
serial_buffer=NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
27
keyboard.c
27
keyboard.c
|
@ -14,13 +14,36 @@ extern char tmp[64];
|
||||||
|
|
||||||
void keyboard_out(int platoKey)
|
void keyboard_out(int platoKey)
|
||||||
{
|
{
|
||||||
|
if (platoKey==0xff)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (platoKey>0x7F)
|
||||||
|
{
|
||||||
|
Key(ACCESS);
|
||||||
|
Key(ACCESS_KEYS[platoKey-0x80]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Key(platoKey);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void keyboard_main(void)
|
void keyboard_main(EventRecord* e)
|
||||||
{
|
{
|
||||||
|
if (TTY)
|
||||||
|
{
|
||||||
|
keyboard_out_tty(e->message&0x7F);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void keyboard_out_tty(int ch)
|
void keyboard_out_tty(padByte ch)
|
||||||
{
|
{
|
||||||
|
ShowPLATO(&ch,1);
|
||||||
|
io_send_byte(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
#ifndef KEYBOARD_H
|
#ifndef KEYBOARD_H
|
||||||
#define KEYBOARD_H
|
#define KEYBOARD_H
|
||||||
|
|
||||||
|
#include <Events.h>
|
||||||
|
#include "protocol.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* keyboard_out - If platoKey < 0x7f, pass off to protocol
|
* keyboard_out - If platoKey < 0x7f, pass off to protocol
|
||||||
* directly. Otherwise, platoKey is an access key, and the
|
* directly. Otherwise, platoKey is an access key, and the
|
||||||
|
@ -21,11 +24,11 @@ void keyboard_out(int platoKey);
|
||||||
/**
|
/**
|
||||||
* keyboard_main - Handle the keyboard presses
|
* keyboard_main - Handle the keyboard presses
|
||||||
*/
|
*/
|
||||||
void keyboard_main(void);
|
void keyboard_main(EventRecord* e);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* keyboard_out_tty - keyboard output to serial I/O in TTY mode
|
* keyboard_out_tty - keyboard output to serial I/O in TTY mode
|
||||||
*/
|
*/
|
||||||
void keyboard_out_tty(int ch);
|
void keyboard_out_tty(padByte ch);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
39
main.c
39
main.c
|
@ -13,27 +13,28 @@
|
||||||
unsigned char already_started=false;
|
unsigned char already_started=false;
|
||||||
unsigned char running=false;
|
unsigned char running=false;
|
||||||
|
|
||||||
void main(void)
|
void done(void)
|
||||||
{
|
{
|
||||||
screen_init();
|
|
||||||
/* touch_init(); */
|
|
||||||
/* help_init(); */
|
|
||||||
/* NoEcho=padT; */
|
|
||||||
ShowPLATO(splash,sizeof(splash));
|
|
||||||
/* NoEcho=padF; */
|
|
||||||
/* terminal_initial_position(); */
|
|
||||||
/* io_init(); */
|
|
||||||
running=true;
|
|
||||||
/* screen_show_dial(); */
|
|
||||||
/* screen_greeting(); */
|
|
||||||
while (running==true)
|
|
||||||
{
|
|
||||||
screen_main();
|
|
||||||
keyboard_main();
|
|
||||||
io_main();
|
|
||||||
touch_main();
|
|
||||||
}
|
|
||||||
io_done();
|
io_done();
|
||||||
touch_done();
|
touch_done();
|
||||||
screen_done();
|
screen_done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void main(void)
|
||||||
|
{
|
||||||
|
screen_init();
|
||||||
|
touch_init();
|
||||||
|
help_init();
|
||||||
|
NoEcho=padT;
|
||||||
|
ShowPLATO(splash,sizeof(splash));
|
||||||
|
NoEcho=padF;
|
||||||
|
terminal_initial_position();
|
||||||
|
io_init();
|
||||||
|
running=true;
|
||||||
|
while (running==true)
|
||||||
|
{
|
||||||
|
screen_main(); /* keyboard_main() and touch_main() are called in here. */
|
||||||
|
io_main();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
6
screen.c
6
screen.c
|
@ -13,6 +13,7 @@
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
#include "keyboard.h"
|
||||||
|
|
||||||
#define true 1
|
#define true 1
|
||||||
#define false 0
|
#define false 0
|
||||||
|
@ -177,7 +178,12 @@ void screen_main(void)
|
||||||
SystemClick(&theEvent,currentWindow);
|
SystemClick(&theEvent,currentWindow);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case keyDown:
|
||||||
|
case autoKey:
|
||||||
|
keyboard_main(&theEvent);
|
||||||
|
break;
|
||||||
case updateEvt:
|
case updateEvt:
|
||||||
|
/* To be implemented, somehow... */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue