/** ###################################################################
**     THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : uart0.H
**     Project   : ProcessorExpert
**     Processor : MCF52233CAF60
**     Component : AsynchroSerial
**     Version   : Component 02.482, Driver 01.02, CPU db: 3.00.000
**     Compiler  : CodeWarrior MCF C Compiler
**     Date/Time : 26. 3. 2010, 17:30
**     Abstract  :
**         This component "AsynchroSerial" implements an asynchronous serial
**         communication. The component supports different settings of
**         parity, word width, stop-bit and communication speed,
**         user can select interrupt or polling handler.
**         Communication speed can be changed also in runtime.
**         The component requires one on-chip asynchronous serial channel.
**     Settings  :
**         Serial channel              : UART0
**
**         Protocol
**             Init baud rate          : 38400_0baud
**             Width                   : 8 bits
**             Stop bits               : 1.000
**             Parity                  : none
**             Breaks                  : Disabled
**             Input buffer size       : 25
**             Output buffer size      : 25
**
**         Registers
**             Input buffer            : URB0      [0x020C]
**             Output buffer           : UTB0      [0x020C]
**             Control register        : UMR10     [0x0200]
**             Mode register           : UMR20     [0x0200]
**             Baud setting reg.       : UCSR0     [0x0204]
**
**         Input interrupt
**             Vector name             : INT_UART0
**             Priority                : 430
**
**         Output interrupt
**             Vector name             : INT_UART0
**             Priority                : 430
**
**         Used pins:
**         ----------------------------------------------------------
**           Function | On package           |    Name
**         ----------------------------------------------------------
**            Input   |     21               |  URXD0_FEC_RXD0_PUA1
**            Output  |     22               |  UTXD0_FEC_CRS_PUA0
**         ----------------------------------------------------------
**
**
**
**     Contents  :
**         RecvChar - byte uart0_RecvChar(uart0_TComData *Chr);
**         SendChar - byte uart0_SendChar(uart0_TComData Chr);
**
**     Copyright : 1997 - 2010 Freescale Semiconductor, Inc. All Rights Reserved.
**
**     http      : www.freescale.com
**     mail      : support@freescale.com
** ###################################################################*/

#ifndef __uart0
#define __uart0

/* MODULE uart0. */
#include "MCF52233_PE.h"
#include "PE_Const.h"
#include "PE_Types.h"
#include "PE_Error.h"

#include "FreeRTOS.h"
#include "queue.h"
#include "semphr.h"
#include "task.h"


#ifndef __BWUserType_uart0_TError
#define __BWUserType_uart0_TError
  typedef union {
    byte err;
    struct {
      bool OverRun  : 1;               /* Overrun error flag */
      bool Framing  : 1;               /* Framing error flag */
      bool Parity   : 1;               /* Parity error flag */
      bool RxBufOvf : 1;               /* Rx buffer full error flag */
      bool Noise    : 1;               /* Noise error flag */
      bool Break    : 1;               /* Break detect */
      bool LINSync  : 1;               /* LIN synchronization error */
      bool BitError  : 1;              /* Bit error flag - mismatch to the expected value happened. */
    } errName;
  } uart0_TError;                      /* Error flags. For languages which don't support bit access is byte access only to error flags possible. */
#endif

#ifndef __BWUserType_uart0_TComData
#define __BWUserType_uart0_TComData
  typedef byte uart0_TComData;         /* User type for communication. Size of this type depends on the communication data witdh */
#endif

#define uart0_INP_BUF_SIZE  25       /* Length of the RX buffer */

#define uart0_OUT_BUF_SIZE  120       /* Length of the TX buffer */



extern volatile word uart0_OutLen;     /* Length of output bufer's content */
extern volatile word uart0_InpLen;     /* Length of input buffer's content */

void uart0_OnTxChar(void); /* Event pri poslani znaku z TX*/
void uart0_OnRxChar(void); /* Event pri nacitani znaku z RX*/
void uart0_OnFreeTxBuf(void); /* Event pri vyprazdneni TX buffra */

struct {
	xSemaphoreHandle getCharMutex;
	xSemaphoreHandle printfMutex;
	xSemaphoreHandle fullTxBuffer;
	//xSemaphoreHandle scanfMutex;
}uart0_Mutex;


byte uart0_Enable(void);
byte uart0_Disable(void);
/*
 **==========================================================================================
 ** Function: critical_ERROR_WRITE
 ** Arguments: char*
 ** Return:  return_type
 ** Comment: Vypisanie textu na konzolu bez pouzitia delay_funkcii
**===========================================================================================
*/
void critical_ERROR_WRITE(char *data);
/*--END OF FUNCTION: critical_ERROR_WRITE-----------------------------------------------------*/

byte uart0_RecvBlock(uart0_TComData *Ptr, word Size, word *Rcv, portLONG blockTime);

byte uart0_RecvChar(uart0_TComData *Chr);
/*
** ===================================================================
**     Method      :  uart0_RecvChar (component AsynchroSerial)
**
**     Description :
**         If any data is received, this method returns one character,
**         otherwise it returns an error code (it does not wait for
**         data). This method is enabled only if the receiver property
**         is enabled.
**         [Note:] Because the preferred method to handle error and
**         break exception in the interrupt mode is to use events
**         <OnError> and <OnBreak> the return value ERR_RXEMPTY has
**         higher priority than other error codes. As a consequence the
**         information about an exception in interrupt mode is returned
**         only if there is a valid character ready to be read.
**     Parameters  :
**         NAME            - DESCRIPTION
**       * Chr             - Pointer to a received character
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
**                           ERR_RXEMPTY - No data in receiver
**                           ERR_BREAK - Break character is detected
**                           (only when the <Interrupt service> property
**                           is disabled and the <Break signal> property
**                           is enabled)
**                           ERR_COMMON - common error occurred (the
**                           <GetError> method can be used for error
**                           specification)
** ===================================================================
*/

byte uart0_SendChar(uart0_TComData Chr);
/*
** ===================================================================
**     Method      :  uart0_SendChar (component AsynchroSerial)
**
**     Description :
**         Sends one character to the channel. If the component is
**         temporarily disabled (Disable method) SendChar method only
**         stores data into an output buffer. In case of a zero output
**         buffer size, only one character can be stored. Enabling the
**         component (Enable method) starts the transmission of the
**         stored data. This method is available only if the
**         transmitter property is enabled.
**     Parameters  :
**         NAME            - DESCRIPTION
**         Chr             - Character to send
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
**                           ERR_TXFULL - Transmitter is full
** ===================================================================
*/

void uart0_Interrupt(void);
/*
** ===================================================================
**     Method      :  uart0_Interrupt (component AsynchroSerial)
**
**     Description :
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/

void uart0_Init(void);
/*
** ===================================================================
**     Method      :  uart0_Init (component AsynchroSerial)
**
**     Description :
**         Initializes the associated peripheral(s) and the component
**         internal variables. The method is called automatically as a
**         part of the application initialization code.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/



/* END uart0. */

/*
** ###################################################################
**
**     This file was created by Processor Expert 4.00 Beta [04.39]
**     for the Freescale MCF series of microcontrollers.
**
** ###################################################################
*/

#endif /* ifndef __uart0 */
