MakingThings
Make Controller Kit
Firmware API
MAKE Zine

serial2.c File Reference

Functions for working with the Serial Interface on the Make Controller Board. More...

Go to the source code of this file.


Functions

int Serial2_SetActive (int index, int state)
 Set the active state of the Serial subsystem.
int Serial2_GetActive (int index)
 Read the active state of the Serial subsystem.
int Serial2_Write (int index, uchar *buffer, int count, int timeout)
 Write a block of data to the Serial port.
int Serial2_Read (int index, uchar *buffer, int size, int timeout)
 Read data from the Serial port.
int Serial2_GetReadable (int index)
 Returns the number of bytes in the queue waiting to be read.
int Serial2_SetChar (int index, int character)
 Sends a character (in the range of 0 to 255) to the write queue.
int Serial2_SetBaud (int index, int baud)
 Sets the serial baud rate.
int Serial2_SetBits (int index, int bits)
 Sets the number of bits per character.
int Serial2_SetParity (int index, int parity)
 Sets the parity.
int Serial2_SetStopBits (int index, int stopBits)
 Sets the stop bits per character.
int Serial2_SetHardwareHandshake (int index, int hardwareHandshake)
 Sets whether hardware handshaking is being used.
int Serial2_GetChar (int index)
 Returns a single character from the receive queue if available.
int Serial2_GetBaud (int index)
 Returns the current baud rate.
int Serial2_GetBits (int index)
 Returns the number of bits for each character.
int Serial2_GetParity (int index)
 Returns the current parity.
int Serial2_GetStopBits (int index)
 Returns the number of stop bits.
int Serial2_GetHardwareHandshake (int index)
 Returns whether hardware handshaking is being employed or not.

Detailed Description

Functions for working with the Serial Interface on the Make Controller Board.

Definition in file serial2.c.


Function Documentation

int Serial2_GetActive ( int  index  ) 

Read the active state of the Serial subsystem.

Returns:
State - 1/non-zero (on) or 0 (off).

Definition at line 87 of file serial2.c.

int Serial2_GetBaud ( int  index  ) 

Returns the current baud rate.

Returns:
baud

Definition at line 373 of file serial2.c.

int Serial2_GetBits ( int  index  ) 

Returns the number of bits for each character.

Returns:
bits

Definition at line 391 of file serial2.c.

int Serial2_GetChar ( int  index  ) 

Returns a single character from the receive queue if available.

This character is returned unsigned - i.e. having a value of 0 - 255. The return value is -1 if there is no character waiting.

Returns:
character from the queue or -1 if there is no character.

Definition at line 343 of file serial2.c.

int Serial2_GetHardwareHandshake ( int  index  ) 

Returns whether hardware handshaking is being employed or not.

Returns:
hardwareHandshake

Definition at line 445 of file serial2.c.

int Serial2_GetParity ( int  index  ) 

Returns the current parity.

-1 means odd, 0 means none, 1 means even

Returns:
parity

Definition at line 409 of file serial2.c.

int Serial2_GetReadable ( int  index  ) 

Returns the number of bytes in the queue waiting to be read.

Returns:
bytes in the receive queue.

Definition at line 177 of file serial2.c.

int Serial2_GetStopBits ( int  index  ) 

Returns the number of stop bits.

Returns:
stopBits

Definition at line 427 of file serial2.c.

int Serial2_Read ( int  index,
uchar *  buffer,
int  size,
int  timeout 
)

Read data from the Serial port.

Will block for the time specified (in ms) if there are insufficient characters. Blocking can be avoided if Serial2_GetReadable( ) is used to determine how many characters are available to read prior to calling this function.

Parameters:
buffer A pointer to the buffer to read into.
size An integer specifying the maximum number of bytes to read.
timeout Time in milliseconds to block waiting for the specified number of bytes. 0 means don't wait.
Returns:
number of bytes read (>=0) or error <0 .

Definition at line 146 of file serial2.c.

int Serial2_SetActive ( int  index,
int  state 
)

Set the active state of the Serial subsystem.

This is automatically set to true by any call to Serial2_Write or Serial2_Read.

Parameters:
state An integer specifying the active state - 1 (on) or 0 (off).
Returns:
CONTROLLER_OK (=0) on success.

Definition at line 56 of file serial2.c.

int Serial2_SetBaud ( int  index,
int  baud 
)

Sets the serial baud rate.

Parameters:
baud The desired baud rate.
Returns:
status.

Definition at line 222 of file serial2.c.

int Serial2_SetBits ( int  index,
int  bits 
)

Sets the number of bits per character.

5 - 8 are legal values. 8 is the default.

Parameters:
bits bits per character
Returns:
status.

Definition at line 244 of file serial2.c.

int Serial2_SetChar ( int  index,
int  character 
)

Sends a character (in the range of 0 to 255) to the write queue.

Parameters:
character The character to be sent. Must be 0 <= c < 256.
Returns:
status.

Definition at line 192 of file serial2.c.

int Serial2_SetHardwareHandshake ( int  index,
int  hardwareHandshake 
)

Sets whether hardware handshaking is being used.

Parameters:
hardwareHandshake sets hardware handshaking on (1) or off (0)
Returns:
status.

Definition at line 321 of file serial2.c.

int Serial2_SetParity ( int  index,
int  parity 
)

Sets the parity.

-1 is odd, 0 is none, 1 is even. The default is none - 0.

Parameters:
parity -1, 0 or 1.
Returns:
status.

Definition at line 270 of file serial2.c.

int Serial2_SetStopBits ( int  index,
int  stopBits 
)

Sets the stop bits per character.

1 or 2 are legal values. 1 is the default.

Parameters:
stopBits stop bits per character
Returns:
status.

Definition at line 295 of file serial2.c.

int Serial2_Write ( int  index,
uchar *  buffer,
int  count,
int  timeout 
)

Write a block of data to the Serial port.

Will block for the time specified (in ms) if the queue fills up.

Parameters:
buffer A pointer to the buffer to write from.
count An integer specifying the number of bytes to write.
timeout Time in milliseconds to block waiting for the queue to free up. 0 means don't wait.
Returns:
status.

Definition at line 105 of file serial2.c.

Make Controller Kit