Jump to content
IGNORED

New cc65 serial driver


karri

Recommended Posts

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(&params);

 

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 by karri
  • Like 1
Link to comment
Share on other sites

  • 4 years later...

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...