Digi XBee(R) ANSI C Host Library
Macros | Functions
xbee_serial_dos.c File Reference

Serial Interface for XBee Module (DOS Platform) More...

#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include "xbee/serial.h"
#include "xbee/cbuf.h"

Macros

#define UART_RBR   0
 Receive Buffer DLAB = 0, read.
 
#define UART_THR   0
 Transmitter Holding DLAB = 0, write.
 
#define UART_DLL   0
 Divisor Latch LSB DLAB = 1.
 
#define UART_IER   1
 Interrupt Enable DLAB = 0.
 
#define UART_DLM   1
 Divisor Latch MSB DLAB = 1.
 
#define UART_IIR   2
 Interrupt Identification read.
 
#define UART_FCR   2
 FIFO Control write.
 
#define UART_LCR   3
 Line Control.
 
#define UART_MCR   4
 Modem Control.
 
#define UART_LSR   5
 Line Status read.
 
#define UART_MSR   6
 Modem Status read.
 
#define UART_SCR   7
 Scratch.
 
#define IER_NONE   0
 
#define IER_RX_DATA   (1<<0)
 
#define IER_TX_EMPTY   (1<<1)
 
#define IER_LSR_CHANGE   (1<<2)
 
#define IER_MSR_CHANGE   (1<<3)
 
#define IER_DEFAULT   (IER_RX_DATA | IER_TX_EMPTY | IER_LSR_CHANGE)
 
#define FCR_DISABLE_FIFOS   (0<<0)
 
#define FCR_ENABLE_FIFOS   (1<<0)
 
#define FCR_CLEAR_RX_FIFO   (1<<1)
 
#define FCR_CLEAR_TX_FIFO   (1<<2)
 
#define FCR_DMA_MODE_0   (0<<3)
 
#define FCR_DMA_MODE_1   (1<<3)
 
#define FCR_ENABLE_64BYTE   (1<<5)
 
#define FCR_INT_TRIGGER_1BYTE   (0<<6)
 
#define FCR_INT_TRIGGER_4BYTE   (1<<6)
 
#define FCR_INT_TRIGGER_8BYTE   (2<<6)
 
#define FCR_INT_TRIGGER_14BYTE   (3<<6)
 
#define FCR_DEFAULT   (FCR_ENABLE_FIFOS | FCR_DMA_MODE_0)
 
#define LCR_5BIT   (0<<0)
 
#define LCR_6BIT   (1<<0)
 
#define LCR_7BIT   (2<<0)
 
#define LCR_8BIT   (3<<0)
 
#define LCR_1STOP   (0<<2)
 
#define LCR_2STOP   (1<<2)
 
#define LCR_PARITY_NONE   (0<<3)
 
#define LCR_PARITY_ODD   (1<<3)
 
#define LCR_PARITY_EVEN   (3<<3)
 
#define LCR_PARITY_MARK   (5<<3)
 
#define LCR_PARITY_SPACE   (7<<3)
 
#define LCR_BREAK_ENABLE   (1<<6)
 
#define LCR_DIVISOR_LATCH   (1<<7)
 
#define LCR_DEFAULT   (LCR_8BIT | LCR_1STOP | LCR_PARITY_NONE)
 
#define MCR_NONE   0
 
#define MCR_DTR   (1<<0)
 
#define MCR_RTS   (1<<1)
 
#define MCR_OUT1   (1<<2)
 
#define MCR_OUT2   (1<<3)
 
#define MCR_LOOPBACK   (1<<4)
 
#define MCR_AUTOFLOW   (1<<5)
 
#define MCR_DEFAULT   (MCR_DTR | MCR_RTS | MCR_OUT2)
 
#define MSR_CTS_CHANGED   (1<<0)
 
#define MSR_DSR_CHANGED   (1<<1)
 
#define MSR_RI_EDGE   (1<<2)
 
#define MSR_CD_CHANGED   (1<<3)
 
#define MSR_CTS   (1<<4)
 
#define MSR_DSR   (1<<5)
 
#define MSR_RI   (1<<6)
 
#define MSR_CD   (1<<7)
 
#define XBEE_SER_CHECK(ptr)
 
#define CBUF_SIZE   255
 

Functions

void __interrupt __far xbee_ser_isr ()
 
int xbee_ser_invalid (xbee_serial_t *serial)
 Helper function used by other xbee_serial functions to validate the serial parameter. More...
 
const char * xbee_ser_portname (xbee_serial_t *serial)
 Returns a human-readable string describing the serial port. More...
 
int xbee_ser_write (xbee_serial_t *serial, const void FAR *buffer, int length)
 Transmits length bytes from buffer to the XBee serial port serial. More...
 
int xbee_ser_read (xbee_serial_t *serial, void FAR *buffer, int bufsize)
 Reads up to bufsize bytes from XBee serial port serial and into buffer. More...
 
int xbee_ser_putchar (xbee_serial_t *serial, uint8_t ch)
 Transmits a single character, ch, to the XBee serial port serial. More...
 
int xbee_ser_getchar (xbee_serial_t *serial)
 Reads a single character from the XBee serial port serial. More...
 
int xbee_ser_tx_free (xbee_serial_t *serial)
 Returns the number of bytes of unused space in the serial transmit buffer for XBee serial port serial. More...
 
int xbee_ser_tx_used (xbee_serial_t *serial)
 Returns the number of queued bytes in the serial transmit buffer for XBee serial port serial. More...
 
int xbee_ser_tx_flush (xbee_serial_t *serial)
 Flushes (i.e., deletes and does not transmit) characters in the serial transmit buffer for XBee serial port serial. More...
 
int xbee_ser_rx_free (xbee_serial_t *serial)
 Returns the number of bytes of unused space in the serial receive buffer for XBee serial port serial. More...
 
int xbee_ser_rx_used (xbee_serial_t *serial)
 Returns the number of queued bytes in the serial receive buffer for XBee serial port serial. More...
 
int xbee_ser_rx_flush (xbee_serial_t *serial)
 Deletes all characters in the serial receive buffer for XBee serial port serial. More...
 
int xbee_ser_baudrate (xbee_serial_t *serial, uint32_t baudrate)
 Change the baud rate of XBee serial port serial to baudrate bits/second. More...
 
int xbee_ser_open (xbee_serial_t *serial, uint32_t baudrate)
 Opens the serial port connected to XBee serial port serial at baudrate bits/second. More...
 
int xbee_ser_close (xbee_serial_t *serial)
 Close the serial port attached to XBee serial port serial. More...
 
int xbee_ser_break (xbee_serial_t *serial, int enabled)
 Disable the serial transmit pin and pull it low to send a break to the XBee serial port. More...
 
int xbee_ser_flowcontrol (xbee_serial_t *serial, int enabled)
 Enable or disable hardware flow control (CTS/RTS) on the serial port for XBee serial port serial. More...
 
int xbee_ser_set_rts (xbee_serial_t *serial, int asserted)
 Disable hardware flow control and manually set the RTS (ready to send) pin on the XBee device's serial port. More...
 
int xbee_ser_get_cts (xbee_serial_t *serial)
 Read the status of the /CTS (clear to send) pin on the serial port connected to XBee serial port serial. More...
 

Detailed Description

Serial Interface for XBee Module (DOS Platform)

Warning: This module is incomplete. It only supports COM1.