Serial Port Control


Defines

#define COM0PROTOCOL   RS232
#define COM1PROTOCOL   RS232
#define ECHO   1
#define NO_ECHO   0
#define _USE_INTERRUPTS_
#define EIGHT_BIT   0x00
#define NINE_BIT   0x10
#define EVEN_PARITY   0x02
#define ODD_PARITY   0x03
#define NO_PARITY   0

Typedefs

typedef void(* SCICallback )(int, void *)

Functions

int Serial_Initialize (int channel, char mode, long baud)
char Ser_Send_Byte (char channel, char sendta)
char Ser_Send_String (char channel, char *sendta)
ssize_t SCIrx (int port, int count, u8 *buffer)
char ser_getch (int port)
int ser_getline (int port, char *buffer, int max, int echo)
int SCItx_En (int port)
int SCItx_Dis (int port)

Detailed Description

This module contains functions from controlling the serial port. This includes string transmission, getch and getline. a ser printf is also implemented, but kept at a higher level in the Ipac module. All of these functions depend on Serial_Initialize first being called to intialize the serial ports and their data structures. Serial_Initialize is called by IpacInit to set up the serial ports to a default of 8BITS 9600 baud.

Define Documentation

#define COM0PROTOCOL   RS232
 

Define COM Protocols legacy, this may not be needed

Definition at line 29 of file ser.h.


Function Documentation

ssize_t SCIrx int  port,
int  count,
u8 *  buffer
 

Pull data from the a serial fifo.

SCIrx pulls up to count bytes from it's fifo and stores them in the array pointed to by buffer. It returns the number of characters successfully pulled from the fifo. The serial port must first be Initialized before it can be read from.

Parameters:
port the serial port to address, PORT232 or PORT422
count the number of characters to try to pull.
*buffer pointer to an array of data to store the received characters in
Returns:
the number of characters stored in the buffer
See also:
Serial_Initialize

int SCItx_Dis int  port  ) 
 

Disable the Transmitter (Hardware handshaking and 422)

Waits for any pending serial transmissions to finish and sets RTS inactive

Parameters:
port the serial port to address, PORT232 or PORT422
Returns:
SUCCESS

int SCItx_En int  port  ) 
 

Enable the Transmitter (Hardware handshaking and 422)

Sets RTS active and inserts a short delay to allow transmitter hardware to turn on if it exists.

Parameters:
port the serial port to address, PORT232 or PORT422
Returns:
SUCCESS

char ser_getch int  port  ) 
 

Block until a character is received from a serial port.

Blocks until a character is received from an initialized serial port.

Parameters:
port the serial port to address, PORT232 or PORT422
Returns:
the character received
See also:
Serial_Initialize

int ser_getline int  port,
char *  buffer,
int  max,
int  echo
 

Block until a line is recieved from a serial port

Blocks until a line(terminated by a linefeed) is received. The linefeed is then overwritten with a zero to make it a string and placed in the array pointed to by buffer.

Parameters:
port the serial port to address, PORT232 or PORT422
buffer pointer to an array to store the line in.
max the maximum number of characters that the line can contain.
echo ECHO or NO_ECHO setting echo causes characters received to "echo" to the serial port.
Returns:
the number of characters received

char Ser_Send_Byte char  channel,
char  sendta
 

transmit one byte over a serial port.

This function transmits a single byte out of a configured serial port. The serial port used must be pre configured bye Serial_Initialize.

Parameters:
channel the serial port to address, PORT232 or PORT422
sendta the char to send
Returns:
0
See also:
Serial_Initialize

char Ser_Send_String char  channel,
char *  sendta
 

transmit a string over a serial port.

This function uses Ser_Send_Byte to transmit a string out of a serial port. This happens in the foreground and blocks until the string is sent.

Parameters:
channel the serial port to address, PORT232 or PORT422
*sendta the string to send
Returns:
0
See also:
Ser_Send_Byte

int Serial_Initialize int  channel,
char  mode,
long  baud
 

Initialize a serial port.

This function initiailizes and configures a serial port It must be called at least once before the a serial port is used After that it can be called at any time to change the serial ports configuration. IpacInit calls this once for each port and initializes them to 8BIT 9600 baud.

Parameters:
channel the serial port to address, PORT232 or PORT422
mode flags for the serial port to control the parity and number of bits, see "Mode flags" in the defines
baud rate the serial ports baud rate.
Returns:
SUCCESS
See also:
IpacInit


Generated on Fri Mar 3 17:25:46 2006 for EMAC-HCS12-SDK by  doxygen 1.4.6