6 * @brief Public header for the Intel IXP400 internal UART, generic driver.
9 * This driver allows you to perform the following functions:
10 * Device Initialization,
11 * send/receive characters.
13 * Perform Uart IOCTL for the following:
14 * Set/Get the current baud rate,
16 * set the number of Stop bits,
17 * set the character Length (5,6,7,8),
18 * enable/disable Hardware flow control.
20 * Only Polled mode is supported for now.
24 * IXP400 SW Release version 2.0
26 * -- Copyright Notice --
29 * Copyright 2001-2005, Intel Corporation.
30 * All rights reserved.
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
36 * 1. Redistributions of source code must retain the above copyright
37 * notice, this list of conditions and the following disclaimer.
38 * 2. Redistributions in binary form must reproduce the above copyright
39 * notice, this list of conditions and the following disclaimer in the
40 * documentation and/or other materials provided with the distribution.
41 * 3. Neither the name of the Intel Corporation nor the names of its contributors
42 * may be used to endorse or promote products derived from this software
43 * without specific prior written permission.
46 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
47 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
50 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * -- End of Copyright Notice --
63 * @defgroup IxUARTAccAPI IXP400 UART Access (IxUARTAcc) API
65 * @brief IXP400 UARTAcc Driver Public API
74 * @defgroup DefaultDefines Defines for Default Values
76 * @brief Default values which can be used for UART configuration
82 * @def IX_UART_DEF_OPTS
84 * @brief The default hardware options to set the UART to -
85 * no flow control, 8 bit word, 1 stop bit, no parity
87 * @ingroup DefaultDefines
89 #define IX_UART_DEF_OPTS (CLOCAL | CS8)
92 * @def IX_UART_DEF_XMIT
94 * @brief The default UART FIFO size - must be no bigger than 64
96 * @ingroup DefaultDefines
98 #define IX_UART_DEF_XMIT 64
101 * @def IX_UART_DEF_BAUD
103 * @brief The default UART baud rate - 9600
105 * @ingroup DefaultDefines
107 #define IX_UART_DEF_BAUD 9600
110 * @def IX_UART_MIN_BAUD
112 * @brief The minimum UART baud rate - 9600
114 * @ingroup DefaultDefines
116 #define IX_UART_MIN_BAUD 9600
119 * @def IX_UART_MAX_BAUD
121 * @brief The maximum UART baud rate - 926100
123 * @ingroup DefaultDefines
125 #define IX_UART_MAX_BAUD 926100
130 * @brief The UART clock speed
132 * @ingroup DefaultDefines
134 #define IX_UART_XTAL 14745600
138 /* IOCTL commands (Request codes) */
141 * @defgroup IoctlCommandDefines Defines for IOCTL Commands
143 * @brief IOCTL Commands (Request codes) which can be used
144 * with @ref ixUARTIoctl
149 * @ingroup IoctlCommandDefines
153 * @brief Set the baud rate
155 #define IX_BAUD_SET 0
158 * @ingroup IoctlCommandDefines
162 * @brief Get the baud rate
164 #define IX_BAUD_GET 1
167 * @ingroup IoctlCommandDefines
169 * @brief Set the UART mode of operation
171 #define IX_MODE_SET 2
174 * @ingroup IoctlCommandDefines
178 * @brief Get the current UART mode of operation
180 #define IX_MODE_GET 3
183 * @ingroup IoctlCommandDefines
187 * @brief Set the UART device options
189 #define IX_OPTS_SET 4
192 * @ingroup IoctlCommandDefines
196 * @brief Get the UART device options
198 #define IX_OPTS_GET 5
201 * @ingroup IoctlCommandDefines
205 * @brief Get the UART statistics
207 #define IX_STATS_GET 6
210 /* POSIX style ioctl arguments */
213 * @defgroup IoctlArgDefines Defines for IOCTL Arguments
215 * @brief POSIX style IOCTL arguments which can be used
216 * with @ref ixUARTIoctl
223 * @ingroup IoctlArgDefines
227 * @brief Software flow control
235 * @ingroup IoctlArgDefines
239 * @brief Enable interrupt receiver
247 * @ingroup IoctlArgDefines
251 * @brief Characters size
259 * @ingroup IoctlArgDefines
271 * @ingroup IoctlArgDefines
283 * @ingroup IoctlArgDefines
295 * @ingroup IoctlArgDefines
307 * @ingroup IoctlArgDefines
311 * @brief Send two stop bits (else one)
316 * @ingroup IoctlArgDefines
320 * @brief Parity detection enabled (else disabled)
328 * @ingroup IoctlArgDefines
332 * @brief Odd parity (else even)
341 * @brief The mode to set to UART to.
345 INTERRUPT=0, /**< Interrupt mode */
346 POLLED, /**< Polled mode */
347 LOOPBACK /**< Loopback mode */
351 * @struct ixUARTStats
352 * @brief Statistics for the UART.
366 * @brief Device descriptor for the UART.
370 UINT8 *addr; /**< device base address */
371 ixUARTMode mode; /**< interrupt, polled or loopback */
372 int baudRate; /**< baud rate */
373 int freq; /**< UART clock frequency */
374 int options; /**< hardware options */
375 int fifoSize; /**< FIFO xmit size */
377 ixUARTStats stats; /**< device statistics */
381 * @ingroup IxUARTAccAPI
383 * @fn IX_STATUS ixUARTInit(ixUARTDev* pUART)
385 * @param pUART @ref ixUARTDev [in] - pointer to UART structure describing our device.
387 * @brief Initialise the UART. This puts the chip in a quiescent state.
389 * @pre The base address for the UART must contain a valid value.
390 * Also the baud rate and hardware options must contain sensible values
391 * otherwise the defaults will be used as defined in ixUART.h
393 * @post UART is initialized and ready to send and receive data.
395 * @note This function should only be called once per device.
397 * @retval IX_SUCCESS - UART device successfully initialised.
398 * @retval IX_FAIL - Critical error, device not initialised.
399 ***************************************************************************/
400 PUBLIC IX_STATUS ixUARTInit(ixUARTDev* pUART);
403 * @ingroup IxUARTAccAPI
405 * @fn IX_STATUS ixUARTPollOutput(ixUARTDev* pUART, int outChar)
407 * @param pUART @ref ixUARTDev [out] - pointer to UART structure describing our device.
408 * @param outChar int [out] - character to transmit.
410 * @brief Transmit a character in polled mode.
412 * @pre UART device must be initialised.
414 * @retval IX_SUCCESS - character was successfully transmitted.
415 * @retval IX_FAIL - output buffer is full (try again).
416 ***************************************************************************/
417 PUBLIC IX_STATUS ixUARTPollOutput(ixUARTDev* pUART, int outChar);
420 * @ingroup IxUARTAccAPI
422 * @fn IX_STATUS ixUARTPollInput(ixUARTDev* pUART, char *inChar)
424 * @param pUART @ref ixUARTDev [in] - pointer to UART structure describing our device.
425 * @param *inChar char [in] - character read from the device.
427 * @brief Receive a character in polled mode.
429 * @pre UART device must be initialised.
431 * @retval IX_SUCCESS - character was successfully read.
432 * @retval IX_FAIL - input buffer empty (try again).
433 ***************************************************************************/
434 PUBLIC IX_STATUS ixUARTPollInput(ixUARTDev* pUART, char *inChar);
437 * @ingroup IxUARTAccAPI
439 * @fn IX_STATUS ixUARTIoctl(ixUARTDev* pUART, int cmd, void* arg)
441 * @param pUART @ref ixUARTDev [in] - pointer to UART structure describing our device.
442 * @param cmd int [in] - an ioctl request code.
443 * @param arg void* [in] - optional argument used to set the device mode,
444 * baud rate, and hardware options.
446 * @brief Perform I/O control routines on the device.
448 * @retval IX_SUCCESS - requested feature was set/read successfully.
449 * @retval IX_FAIL - error setting/reading the requested feature.
451 * @sa IoctlCommandDefines
452 * @sa IoctlArgDefines
453 ***************************************************************************/
454 PUBLIC IX_STATUS ixUARTIoctl(ixUARTDev* pUART, int cmd, void* arg);
457 * @} defgroup IxUARTAcc