/**************************************************************************
 *
 * Title: Declarations for eSCI_library.c file and SCI Registers
 *
 * Filename: eSCI_library.h
 *
 *
 * First used on: MPC5554
 *
 * Compiler:
 *
 * Creation date:		02/21/06
 * Date last modified:	$Author: Jyotsna Chitri
 *
 *
 *
 *************************************************************************/
#ifndef _eSCI_library_H
#define _eSCI_library_H

#include "circular_buffer.h"

#define ESCIA_DR_U                      0xFFFB0006
#define ESCIA_DR_L                      0xFFFB0007
#define ESCIB_DR_U                      0xFFFB4006
#define ESCIB_DR_L                      0xFFFB4007

typedef enum
{
  esci_mod_A,
  esci_mod_B,
  num_sci_modules
} sci_mod_t;

extern circ_buff_t tx_buffers[num_sci_modules];
extern vuint32_t tx_in_progress_flags[num_sci_modules];

/* Check for Transmit Flag TDRE */
uint8_t esci_check_transmit_flag_fnc(uint8_t sci_mod);

/* Check for Receive Flag RDRF */
uint8_t esci_check_receive_flag_fnc(uint8_t sci_mod);

/* Clear the TDRE Transmit flag */
void esci_clear_transmit_flag_fnc(uint8_t sci_mod);

/* Clear the TDRE Transmit flag */
void esci_clear_receive_flag_fnc(uint8_t sci_mod);

/* Transmit the data over eSCI */
void esci_transmit_fnc(uint8_t sci_mod,uint16_t data );

/* Receive the data over eSCI */
uint16_t esci_receive_fnc(uint8_t sci_mod);

/* Update the data to be transmitted over eSCI using DMA */
void esci_dma_data_update_fcn(uint8_t sci_mod,int buff_len,uint32_t data_buf);

void esci_transmit_dma_fcn(sci_mod_t mod_num, uint32_t buff_len,const uint8_t
 *pData);

/*To Clear the interrupt flag for the DMA channel*/
void clear_dma_esci_interrupt_flag_fnc(uint8_t sci_mod);

/*To check if 9 bit data format is selected for the sci module*/
uint8_t esci_check_9bit_fnc(uint8_t sci_mod);

/*To package the data and to transmit the data over eSCI using DMA*/
void esci_package_to_transmit_fnc(uint8_t sci_mod,uint16_t data );

/*To package the 9 bit data and to transmit the data over eSCI using DMA*/
void esci_transmit_9bit_dma_fcn(sci_mod_t mod_num, uint32_t buff_len, const
 uint8_t *pData);

/* Update the 9 bit data to be transmitted over eSCI using DMA */
void esci_dma_9bit_data_update_fcn(uint8_t sci_mod,int buff_len,uint32_t
 data_buf);

#endif
