Re: [cc65] Serial port API

Date view Thread view Subject view

From: MagerValp (MagerValp_at_cling.gu.se)
Date: 2001-11-05 18:28:30


>>>>> "gpz" == groepaz  <groepaz_at_gmx.net> writes:

gpz> a) baudrate is obviously an unsigned long

gpz> b) wordlength/parity/stopbit parameters are fixed at 8n1 ...
gpz> programming that kinda stuff for ~10 years i have never ever seen
gpz> anything else used.... if you'd ever need 5o2 or sth i am sure
gpz> you can implement it yourself ;=P

8N2 is often overlooked -- sometimes it makes it possible to use a
higher baudrate. 115200 8N2 might be stable where 115200 8N1 isn't,
and it's 80% faster than 57600 8N1.

MV> Can you control the timeout value?

gpz> no :o) again, i have done that kinda stuff for long and this way
gpz> it always worked perfectly fine for me (infact thats not even a
gpz> real timeout but "check data $ffff times max." ,=))

Well, that works nicely, we're not multitasking or anything :)

MV> [serslave specs]

gpz> reading this, i'd really think we should work together a bit ;=P

I'll release this under the GPL. I'd send it to you straight away, but
I haven't implemented SAVE yet so I can't transfer the TASS source :)

gpz> actually a fileserver is among the features planned for the
gpz> debugger i am working on (actually one of the few things NOT
gpz> implemented by now), and a .d64 reciever is planned for the
gpz> retro-replay software (my debugger would be serving data on the
gpz> pc side for that)....

Feel free to use whatever you want. I'm writing the server in Perl,
but the protocol is simple and could easily be implemented in the
language of your choice. Right now it's limited to a single command.
C64 sends <NAME\r\n and the PC answers with ? if it for some reason
can't send NAME, otherwise it sends a ! followed by the length of the
file. Then it just sends the raw PRG binary. If the C64 tries to load
$ the server lists the current dir and makes a basic listing out of
it, just like a real drive. If NAME is a directory the server CDs
there and sends a listing (just like $). Saving will be implemented
with >NAME\r\n (duh :) followed by the length, wait for ? or !, then
raw data. Oh, it supports @0: too.
  This is good enough for load and save, but open and more advanced
drive emulation needs some sort of packet protocol and a much larger
driver. I probably won't bother.

gpz> also, i have designed the debugger code in a way so that it can
gpz> easily support whatever target is connected, so i'd happily
gpz> support your c64 end aswell. (only thing beeing kinda hard at
gpz> this point, i wouldnt have a swithlink for testing ;=P)

I don't mind testing for you. You'd only have to change a few low
level routines:

; set the SwiftLink register addresses

A_rxd	= $DE00		; ACIA receive data port
A_txd	= $DE00		; ACIA transmit data port
A_sts	= $DE01		; ACIA status port
A_res	= $DE01		; ACIA reset port
A_cmd	= $DE02		; ACIA command port
A_ctl	= $DE03		; ACIA control port
A_t232	= $DE07		; T232 control

; initialise

	STA A_res	; soft reset (value not important)

	LDA #$0B	; set specific modes and functions
			; no parity, no echo, no Tx interrupt
	STA A_cmd	; no Rx interrupt, enable Tx/Rx

for swiftlink:
	LDA #$1F	; 8-N-1, 38400 baud
	STA A_ctl

for turbo232:
	LDA #$10	; 8-N-1, T232 mode
	STA A_ctl
;	LDA #$00	; 230400
	LDA #$01	; 115200
;	LDA #$02	;  57600
	STA A_t232

; To send a character all we need do is wait for the Tx buffer to
; empty then write the byte.

; wait for ACIA and Tx byte

	PHA			; save A
WAIT_Tx
	LDA	A_sts		; get status byte
	AND	#$10		; mask transmit buffer status flag
	BEQ	WAIT_Tx		; loop if tx buffer full

	PLA			; restore A
	STA	A_txd		; save byte to ACIA data port

; To receive a character we need to wait for the Rx buffer to fill
; then read the byte.

; wait for ACIA and Rx byte

WAIT_Rx
	LDA	A_sts		; get ACIA status
	AND	#$08		; mask rx buffer status flag
	BEQ	WAIT_Rx		; loop if rx buffer empty

	LDA	A_rxd		; get byte from ACIA data port

-- 
    ___          .     .  .         .       . +  .         .      o   
  _|___|_   +   .  +     .     +         .   .  Per Olofsson, konstnär
    o-o    .      .     .   o         +          MagerValp_at_cling.gu.se
     -       +            +    .     http://www.cling.gu.se/~cl3polof/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:43 CET