<< Previous | Next >>

serXopen

int serXopen( long baud ); /* where X is A-F */

Description

Opens serial port X. This function is non-reentrant.

The user must define the buffer sizes for each port being used with the buffer size macros XINBUFSIZE and XOUTBUFSIZE. The values must be a power of 2 minus 1, e.g.

   

#define XINBUFSIZE   63
#define XOUTBUFSIZE 127

Defining the buffer sizes to 2n - 1 makes the circular buffer operations very efficient. If a value not equal to 2n- 1 is defined, a default of 31 is used and a compiler warning is given.

The functions serEopen() and serFopen() may be used with the Rabbit 3000 and Rabbit 4000.

NOTE The default pin setup of Serial Port E uses parallel port C pins which conflict with the programming port. Opening serial port E with the default settings while in debug mode will therefore kill PC host/target communication.

The user must #define the following if not using the default (PCDR) settings:

SERE_TXPORT define to PEDR or PDDR
SERE_RXPORT define to PEDR or PDDR

NOTE The alternate pins on parallel port D can be used for serial port B by defining SERB_USEPORTD at the beginning of a program. See the section on parallel port D in the Rabbit documentation for more detail on the alternate serial port pins.

For Rabbit 4000 Users: To use DMA for transfers, call serXdmaOn() after this function.

Parameters

baud
Bits per second (bps) of data transfer. Note that the baud rate must be greater than or equal to the peripheral clock frequency divided by 8192.

Return value

1: The Rabbit's bps setting is within 5% of the input baud.
0: The Rabbit's bps setting differs by more than 5% of the input baud.

Library

RS232.LIB

See also

serXgetc, serXpeek, serXputs, serXwrite, cof_serXgetc,
cof_serXgets, cof_serXread, cof_serXputc, cof_serXputs,
cof_serXwrite, serXclose


Dynamic C Functions << Previous | Next >> rabbit.com