libspandsp 0.0.4

async.h File Reference

Go to the source code of this file.

Classes

struct  async_tx_state_t
struct  async_rx_state_t

Typedefs

typedef void(* put_msg_func_t )(void *user_data, const uint8_t *msg, int len)
typedef int(* get_msg_func_t )(void *user_data, uint8_t *msg, int max_len)
typedef void(* put_byte_func_t )(void *user_data, int byte)
typedef int(* get_byte_func_t )(void *user_data)
typedef void(* put_bit_func_t )(void *user_data, int bit)
typedef int(* get_bit_func_t )(void *user_data)

Enumerations

enum  {
  PUTBIT_CARRIER_DOWN = -1, PUTBIT_CARRIER_UP = -2, PUTBIT_TRAINING_IN_PROGRESS = -3, PUTBIT_TRAINING_SUCCEEDED = -4,
  PUTBIT_TRAINING_FAILED = -5, PUTBIT_FRAMING_OK = -6, PUTBIT_END_OF_DATA = -7, PUTBIT_ABORT = -8,
  PUTBIT_BREAK = -9, PUTBIT_OCTET_REPORT = -10
}
enum  { ASYNC_PARITY_NONE = 0, ASYNC_PARITY_EVEN, ASYNC_PARITY_ODD }

Functions

async_tx_state_tasync_tx_init (async_tx_state_t *s, int data_bits, int parity_bits, int stop_bits, int use_v14, get_byte_func_t get_byte, void *user_data)
 Initialise an asynchronous data transmit context.
int async_tx_get_bit (void *user_data)
 Get the next bit of a transmitted serial bit stream.
async_rx_state_tasync_rx_init (async_rx_state_t *s, int data_bits, int parity_bits, int stop_bits, int use_v14, put_byte_func_t put_byte, void *user_data)
 Initialise an asynchronous data receiver context.
void async_rx_put_bit (void *user_data, int bit)
 Accept a bit from a received serial bit stream.

Detailed Description


Typedef Documentation

typedef int(* get_bit_func_t)(void *user_data)

Bit get function for data pumps

typedef int(* get_byte_func_t)(void *user_data)

Byte get function for data pumps

typedef int(* get_msg_func_t)(void *user_data, uint8_t *msg, int max_len)

Message get function for data pumps

typedef void(* put_bit_func_t)(void *user_data, int bit)

Bit put function for data pumps

typedef void(* put_byte_func_t)(void *user_data, int byte)

Byte put function for data pumps

typedef void(* put_msg_func_t)(void *user_data, const uint8_t *msg, int len)

Message put function for data pumps


Enumeration Type Documentation

anonymous enum

Special "bit" values for the put and get bit functions

Enumerator:
PUTBIT_CARRIER_DOWN 

The carrier signal has dropped.

PUTBIT_CARRIER_UP 

The carrier signal is up. This merely indicates that carrier energy has been seen. It is not an indication that the carrier is either valid, or of the expected type.

PUTBIT_TRAINING_IN_PROGRESS 

The modem is training. This is an early indication that the signal seems to be of the right type. This may be needed in time critical applications, like T.38, to forward an early indication of what is happening on the wire.

PUTBIT_TRAINING_SUCCEEDED 

The modem has trained, and is ready for data exchange.

PUTBIT_TRAINING_FAILED 

The modem has failed to train.

PUTBIT_FRAMING_OK 

Packet framing (e.g. HDLC framing) is OK.

PUTBIT_END_OF_DATA 

The data stream has ended.

PUTBIT_ABORT 

An abort signal (e.g. an HDLC abort) has been received.

PUTBIT_BREAK 

A break signal (e.g. an async break) has been received.

PUTBIT_OCTET_REPORT 

Regular octet report for things like HDLC to the MTP standards.

anonymous enum
Enumerator:
ASYNC_PARITY_NONE 

No parity bit should be used

ASYNC_PARITY_EVEN 

An even parity bit will exist, after the data bits

ASYNC_PARITY_ODD 

An odd parity bit will exist, after the data bits


Function Documentation

async_rx_state_t* async_rx_init ( async_rx_state_t s,
int  data_bits,
int  parity_bits,
int  stop_bits,
int  use_v14,
put_byte_func_t  put_byte,
void *  user_data 
)

Initialise an asynchronous data receiver context.

Initialise an asynchronous data receiver context.

Parameters:
sThe receiver context.
data_bitsThe number of data bits.
parity_bitsThe type of parity.
stop_bitsThe number of stop bits.
use_v14TRUE if V.14 rate adaption processing should be used.
put_byteThe callback routine used to put the received data.
user_dataAn opaque pointer.
Returns:
A pointer to the initialised context, or NULL if there was a problem.

References async_rx_state_t::bitpos, async_rx_state_t::byte_in_progress, async_rx_state_t::data_bits, async_rx_state_t::framing_errors, async_rx_state_t::parity, async_rx_state_t::parity_bit, async_rx_state_t::parity_errors, async_rx_state_t::put_byte, async_rx_state_t::stop_bits, async_rx_state_t::use_v14, and async_rx_state_t::user_data.

Referenced by adsi_rx_init().

void async_rx_put_bit ( void *  user_data,
int  bit 
)

Accept a bit from a received serial bit stream.

Accept a bit from a received serial bit stream

Parameters:
user_dataAn opaque point which must point to a receiver context.
bitThe new bit. Some special values are supported for this field.

  • PUTBIT_CARRIER_UP
  • PUTBIT_CARRIER_DOWN
  • PUTBIT_TRAINING_SUCCEEDED
  • PUTBIT_TRAINING_FAILED
  • PUTBIT_END_OF_DATA

References ASYNC_PARITY_ODD, async_rx_state_t::bitpos, async_rx_state_t::byte_in_progress, async_rx_state_t::data_bits, async_rx_state_t::framing_errors, async_rx_state_t::parity, async_rx_state_t::parity_bit, async_rx_state_t::parity_errors, async_rx_state_t::put_byte, PUTBIT_CARRIER_DOWN, PUTBIT_CARRIER_UP, PUTBIT_END_OF_DATA, PUTBIT_TRAINING_FAILED, PUTBIT_TRAINING_IN_PROGRESS, PUTBIT_TRAINING_SUCCEEDED, async_rx_state_t::use_v14, and async_rx_state_t::user_data.

Referenced by adsi_rx_init().

int async_tx_get_bit ( void *  user_data)

Get the next bit of a transmitted serial bit stream.

Get the next bit of a transmitted serial bit stream.

Parameters:
user_dataAn opaque point which must point to a transmitter context.
Returns:
the next bit, or PUTBIT_END_OF_DATA to indicate the data stream has ended.

References ASYNC_PARITY_ODD, async_tx_state_t::bitpos, async_tx_state_t::byte_in_progress, async_tx_state_t::data_bits, async_tx_state_t::get_byte, async_tx_state_t::parity, async_tx_state_t::parity_bit, PUTBIT_END_OF_DATA, async_tx_state_t::stop_bits, and async_tx_state_t::user_data.

async_tx_state_t* async_tx_init ( async_tx_state_t s,
int  data_bits,
int  parity_bits,
int  stop_bits,
int  use_v14,
get_byte_func_t  get_byte,
void *  user_data 
)

Initialise an asynchronous data transmit context.

Initialise an asynchronous data transmit context.

Parameters:
sThe transmitter context.
data_bitsThe number of data bit.
parity_bitsThe type of parity.
stop_bitsThe number of stop bits.
use_v14TRUE if V.14 rate adaption processing should be used.
get_byteThe callback routine used to get the data to be transmitted.
user_dataAn opaque pointer.
Returns:
A pointer to the initialised context, or NULL if there was a problem.

References ASYNC_PARITY_NONE, async_tx_state_t::bitpos, async_tx_state_t::byte_in_progress, async_tx_state_t::data_bits, async_tx_state_t::get_byte, async_tx_state_t::parity, async_tx_state_t::parity_bit, async_tx_state_t::stop_bits, and async_tx_state_t::user_data.