Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:45

0001 /*
0002  *  Generic UART Serial driver for Motorola Coldfire processors definitions
0003  *
0004  *  Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russian Fed.
0005  *  Author: Victor V. Vengerov <vvv@oktet.ru>
0006  *
0007  *  The license and distribution terms for this file may be
0008  *  found in the file LICENSE in this distribution or at
0009  *  http://www.rtems.org/license/LICENSE.
0010  */
0011 
0012 #ifndef __MCFUART_H__
0013 #define __MCFUART_H__
0014 
0015 #include <termios.h>
0016 #include "bsp.h"
0017 #include "mcf5206e.h"
0018 
0019 /*
0020  * The MCF5206e System Clock Frequency; 54MHz default
0021  */
0022 #ifndef SYSTEM_CLOCK_FREQUENCY
0023 #define SYSTEM_CLOCK_FREQUENCY BSP_SYSTEM_FREQUENCY
0024 #endif
0025 
0026 /*
0027  * The following structure is a descriptor of single UART channel.
0028  * It contains the initialization information about channel and
0029  * current operating values
0030  */
0031 typedef struct mcfuart {
0032    uint32_t            chn;              /* UART channel number */
0033    uint8_t             intvec;           /* UART interrupt vector number, or
0034                                                 0 if polled I/O */
0035    void               *tty;              /* termios channel descriptor */
0036 
0037    volatile const char     *tx_buf;      /* Transmit buffer from termios */
0038    volatile uint32_t        tx_buf_len;  /* Transmit buffer length */
0039    volatile uint32_t        tx_ptr;      /* Index of next char to transmit*/
0040    rtems_isr_entry          old_handler; /* Saved interrupt handler */
0041 
0042    tcflag_t                 c_iflag;    /* termios input mode flags */
0043    bool                     parerr_mark_flag; /* Parity error processing
0044                                                   state */
0045 } mcfuart;
0046 
0047 /* mcfuart_init --
0048  *     This function verifies the input parameters and perform initialization
0049  *     of the Motorola Coldfire on-chip UART descriptor structure.
0050  *
0051  */
0052 rtems_status_code
0053 mcfuart_init(mcfuart *uart, void *tty, uint8_t   intvec,
0054              uint32_t   chn);
0055 
0056 /* mcfuart_reset --
0057  *     This function perform the hardware initialization of Motorola
0058  *     Coldfire processor on-chip UART controller using parameters
0059  *     filled by the mcfuart_init function.
0060  */
0061 rtems_status_code
0062 mcfuart_reset(mcfuart *uart);
0063 
0064 /* mcfuart_disable --
0065  *     This function disable the operations on Motorola Coldfire UART
0066  *     controller
0067  */
0068 rtems_status_code
0069 mcfuart_disable(mcfuart *uart);
0070 
0071 /* mcfuart_set_attributes --
0072  *     This function parse the termios attributes structure and perform
0073  *     the appropriate settings in hardware.
0074  */
0075 int
0076 mcfuart_set_attributes(mcfuart *mcf, const struct termios *t);
0077 
0078 /* mcfuart_poll_read --
0079  *     This function tried to read character from MCF UART and perform
0080  *     error handling.
0081  */
0082 int
0083 mcfuart_poll_read(mcfuart *uart);
0084 
0085 /* mcfuart_interrupt_write --
0086  *     This function initiate transmitting of the buffer in interrupt mode.
0087  */
0088 ssize_t
0089 mcfuart_interrupt_write(mcfuart *uart, const char *buf, size_t len);
0090 
0091 /* mcfuart_poll_write --
0092  *     This function transmit buffer byte-by-byte in polling mode.
0093  */
0094 ssize_t
0095 mcfuart_poll_write(mcfuart *uart, const char *buf, size_t len);
0096 
0097 /* mcfuart_stop_remote_tx --
0098  *     This function stop data flow from remote device.
0099  */
0100 int
0101 mcfuart_stop_remote_tx(mcfuart *uart);
0102 
0103 /* mcfuart_start_remote_tx --
0104  *     This function resume data flow from remote device.
0105  */
0106 int
0107 mcfuart_start_remote_tx(mcfuart *uart);
0108 
0109 #endif