+karri Posted September 20, 2009 Share Posted September 20, 2009 (edited) I just created a serial driver to the cc65 compiler suite. The driver uses interrupts and is based on the BLL code ideas. To use this driver you need to open the ComLynx by passing a structure: extern char comlynx[]; ser_install(&comlynx); ... struct ser_params params = { SER_BAUD_9600, SER_BITS_8, // only 8 data bits is supported SER_STOP_1, // only 1 stop bit is supported SER_PAR_MARK, // mark, space, even, odd is supported SER_HS_NONE // only "none" is supported }; ser_open(¶ms); After the serial line is open you can write a char by: status = ser_put('A'); If status is SER_ERR_OK the write went ok. If the result is SER_ERR_OVERFLOW the you have to wait a while and try again later because the buffer is full. There is one 256 byte Tx buffer and one 256 byte Rx buffer available in the driver. To read a char from the serial line: status = ser_get(&ch); If status is SER_ERR_OK then the byte was read. If status is SER_ERR_NO_DATA then the input buffer is empty. The driver also supports the Lynx special baud rates SER_BAUD_31250 and SER_BAUD_62500. All other standard baudrates are also available. Unfortunately parity even and odd include the parity bit. From the docs: "most people don't like it this way but it is too late to change it". So just don't use these modes. This version is available from svn only. To include this driver in your compilation you need to do: comlynx.o: $(CP) "$(CC65_INC)/../ser/$*.ser" . $(CO) --code-label _comlynx $*.ser $(AS) -t lynx -o $@ $(AFLAGS) $*.s -- Karri Edited September 20, 2009 by karri 1 Quote Link to comment Share on other sites More sharing options...
LX.NET Posted October 12, 2013 Share Posted October 12, 2013 Since nobody ever replied to this post in the past 4 years, I am guessing that nobody noticed it or used the driver. I can confirm that this driver works like a charm. (There might be a tiny bug for the 31250 baud rate setting, that I reported tonight as well.) Tutorial part to follow Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.