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 * SPDX-License-Identifier: BSD-3-Clause
35 * -- End of Copyright Notice --
39 * @defgroup IxUARTAccAPI IXP400 UART Access (IxUARTAcc) API
41 * @brief IXP400 UARTAcc Driver Public API
50 * @defgroup DefaultDefines Defines for Default Values
52 * @brief Default values which can be used for UART configuration
58 * @def IX_UART_DEF_OPTS
60 * @brief The default hardware options to set the UART to -
61 * no flow control, 8 bit word, 1 stop bit, no parity
63 * @ingroup DefaultDefines
65 #define IX_UART_DEF_OPTS (CLOCAL | CS8)
68 * @def IX_UART_DEF_XMIT
70 * @brief The default UART FIFO size - must be no bigger than 64
72 * @ingroup DefaultDefines
74 #define IX_UART_DEF_XMIT 64
77 * @def IX_UART_DEF_BAUD
79 * @brief The default UART baud rate - 9600
81 * @ingroup DefaultDefines
83 #define IX_UART_DEF_BAUD 9600
86 * @def IX_UART_MIN_BAUD
88 * @brief The minimum UART baud rate - 9600
90 * @ingroup DefaultDefines
92 #define IX_UART_MIN_BAUD 9600
95 * @def IX_UART_MAX_BAUD
97 * @brief The maximum UART baud rate - 926100
99 * @ingroup DefaultDefines
101 #define IX_UART_MAX_BAUD 926100
106 * @brief The UART clock speed
108 * @ingroup DefaultDefines
110 #define IX_UART_XTAL 14745600
114 /* IOCTL commands (Request codes) */
117 * @defgroup IoctlCommandDefines Defines for IOCTL Commands
119 * @brief IOCTL Commands (Request codes) which can be used
120 * with @ref ixUARTIoctl
125 * @ingroup IoctlCommandDefines
129 * @brief Set the baud rate
131 #define IX_BAUD_SET 0
134 * @ingroup IoctlCommandDefines
138 * @brief Get the baud rate
140 #define IX_BAUD_GET 1
143 * @ingroup IoctlCommandDefines
145 * @brief Set the UART mode of operation
147 #define IX_MODE_SET 2
150 * @ingroup IoctlCommandDefines
154 * @brief Get the current UART mode of operation
156 #define IX_MODE_GET 3
159 * @ingroup IoctlCommandDefines
163 * @brief Set the UART device options
165 #define IX_OPTS_SET 4
168 * @ingroup IoctlCommandDefines
172 * @brief Get the UART device options
174 #define IX_OPTS_GET 5
177 * @ingroup IoctlCommandDefines
181 * @brief Get the UART statistics
183 #define IX_STATS_GET 6
186 /* POSIX style ioctl arguments */
189 * @defgroup IoctlArgDefines Defines for IOCTL Arguments
191 * @brief POSIX style IOCTL arguments which can be used
192 * with @ref ixUARTIoctl
199 * @ingroup IoctlArgDefines
203 * @brief Software flow control
211 * @ingroup IoctlArgDefines
215 * @brief Enable interrupt receiver
223 * @ingroup IoctlArgDefines
227 * @brief Characters size
235 * @ingroup IoctlArgDefines
247 * @ingroup IoctlArgDefines
259 * @ingroup IoctlArgDefines
271 * @ingroup IoctlArgDefines
283 * @ingroup IoctlArgDefines
287 * @brief Send two stop bits (else one)
292 * @ingroup IoctlArgDefines
296 * @brief Parity detection enabled (else disabled)
304 * @ingroup IoctlArgDefines
308 * @brief Odd parity (else even)
317 * @brief The mode to set to UART to.
321 INTERRUPT=0, /**< Interrupt mode */
322 POLLED, /**< Polled mode */
323 LOOPBACK /**< Loopback mode */
327 * @struct ixUARTStats
328 * @brief Statistics for the UART.
342 * @brief Device descriptor for the UART.
346 UINT8 *addr; /**< device base address */
347 ixUARTMode mode; /**< interrupt, polled or loopback */
348 int baudRate; /**< baud rate */
349 int freq; /**< UART clock frequency */
350 int options; /**< hardware options */
351 int fifoSize; /**< FIFO xmit size */
353 ixUARTStats stats; /**< device statistics */
357 * @ingroup IxUARTAccAPI
359 * @fn IX_STATUS ixUARTInit(ixUARTDev* pUART)
361 * @param pUART @ref ixUARTDev [in] - pointer to UART structure describing our device.
363 * @brief Initialise the UART. This puts the chip in a quiescent state.
365 * @pre The base address for the UART must contain a valid value.
366 * Also the baud rate and hardware options must contain sensible values
367 * otherwise the defaults will be used as defined in ixUART.h
369 * @post UART is initialized and ready to send and receive data.
371 * @note This function should only be called once per device.
373 * @retval IX_SUCCESS - UART device successfully initialised.
374 * @retval IX_FAIL - Critical error, device not initialised.
375 ***************************************************************************/
376 PUBLIC IX_STATUS ixUARTInit(ixUARTDev* pUART);
379 * @ingroup IxUARTAccAPI
381 * @fn IX_STATUS ixUARTPollOutput(ixUARTDev* pUART, int outChar)
383 * @param pUART @ref ixUARTDev [out] - pointer to UART structure describing our device.
384 * @param outChar int [out] - character to transmit.
386 * @brief Transmit a character in polled mode.
388 * @pre UART device must be initialised.
390 * @retval IX_SUCCESS - character was successfully transmitted.
391 * @retval IX_FAIL - output buffer is full (try again).
392 ***************************************************************************/
393 PUBLIC IX_STATUS ixUARTPollOutput(ixUARTDev* pUART, int outChar);
396 * @ingroup IxUARTAccAPI
398 * @fn IX_STATUS ixUARTPollInput(ixUARTDev* pUART, char *inChar)
400 * @param pUART @ref ixUARTDev [in] - pointer to UART structure describing our device.
401 * @param *inChar char [in] - character read from the device.
403 * @brief Receive a character in polled mode.
405 * @pre UART device must be initialised.
407 * @retval IX_SUCCESS - character was successfully read.
408 * @retval IX_FAIL - input buffer empty (try again).
409 ***************************************************************************/
410 PUBLIC IX_STATUS ixUARTPollInput(ixUARTDev* pUART, char *inChar);
413 * @ingroup IxUARTAccAPI
415 * @fn IX_STATUS ixUARTIoctl(ixUARTDev* pUART, int cmd, void* arg)
417 * @param pUART @ref ixUARTDev [in] - pointer to UART structure describing our device.
418 * @param cmd int [in] - an ioctl request code.
419 * @param arg void* [in] - optional argument used to set the device mode,
420 * baud rate, and hardware options.
422 * @brief Perform I/O control routines on the device.
424 * @retval IX_SUCCESS - requested feature was set/read successfully.
425 * @retval IX_FAIL - error setting/reading the requested feature.
427 * @sa IoctlCommandDefines
428 * @sa IoctlArgDefines
429 ***************************************************************************/
430 PUBLIC IX_STATUS ixUARTIoctl(ixUARTDev* pUART, int cmd, void* arg);
433 * @} defgroup IxUARTAcc