1 /* 2 * SpanDSP - a series of DSP components for telephony 3 * 4 * private/async.h - Asynchronous serial bit stream encoding and decoding 5 * 6 * Written by Steve Underwood <steveu@coppice.org> 7 * 8 * Copyright (C) 2003 Steve Underwood 9 * 10 * All rights reserved. 11 * 12 * This program is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU Lesser General Public License version 2.1, 14 * as published by the Free Software Foundation. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this program; if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 */ 25 26 #if !defined(_SPANDSP_PRIVATE_ASYNC_H_) 27 #define _SPANDSP_PRIVATE_ASYNC_H_ 28 29 /*! 30 Asynchronous data transmit descriptor. This defines the state of a single 31 working instance of a byte to asynchronous serial converter, for use 32 in FSK modems. 33 */ 34 struct async_tx_state_s 35 { 36 /*! \brief The number of data bits per character. */ 37 int data_bits; 38 /*! \brief The type of parity. */ 39 int parity; 40 /*! \brief The number of stop bits per character. */ 41 int stop_bits; 42 /*! \brief Total number of bits per character, including the parity and stop bits. */ 43 int total_bits; 44 /*! \brief A pointer to the callback routine used to get characters to be transmitted. */ 45 get_byte_func_t get_byte; 46 /*! \brief An opaque pointer passed when calling get_byte. */ 47 void *user_data; 48 /*! \brief The minimum number of stop bits to send before character transmission begins. */ 49 int presend_bits; 50 51 /*! \brief A current, partially transmitted, character. */ 52 int32_t byte_in_progress; 53 /*! \brief The current bit position within a partially transmitted character. */ 54 int bitpos; 55 /*! \brief Parity bit. */ 56 int parity_bit; 57 }; 58 59 /*! 60 Asynchronous data receive descriptor. This defines the state of a single 61 working instance of an asynchronous serial to byte converter, for use 62 in FSK modems. 63 */ 64 struct async_rx_state_s 65 { 66 /*! \brief The number of data bits per character. */ 67 int data_bits; 68 /*! \brief The type of parity. */ 69 int parity; 70 /*! \brief The number of stop bits per character. */ 71 int stop_bits; 72 /*! \brief True if V.14 rate adaption processing should be performed. */ 73 bool use_v14; 74 /*! \brief A pointer to the callback routine used to handle received characters. */ 75 put_byte_func_t put_byte; 76 /*! \brief An opaque pointer passed when calling put_byte. */ 77 void *user_data; 78 79 /*! \brief A current, partially complete, character. */ 80 int32_t byte_in_progress; 81 /*! \brief The current bit position within a partially complete character. */ 82 int bitpos; 83 /*! \brief Parity bit. */ 84 int parity_bit; 85 86 /*! A count of the number of parity errors seen. */ 87 int parity_errors; 88 /*! A count of the number of character framing errors seen. */ 89 int framing_errors; 90 }; 91 92 #endif 93 /*- End of file ------------------------------------------------------------*/ 94