/*
********************************************************************************
COPYRIGHT 2002 STMicroelectronics
Source File Name : tbu.h
Group            : IPSW, CMG - IPDF
Author           : MCD Application Team
Date First Issued: 21/03/2002
********************************Documentation***********************************
General Purpose - This file conatains the declaration of functions written in
                  TBU.c 
********************************RevisionHistory*********************************
Date : 21/03/2002                  Release:1.0             
Date : 23/09/2003               Release:2.0
Date : 28/04/04                 MISRA changes 
________________________________________________________________________________

1. Added Macro for few functions.
2. Removed the prototype for the previous functions.
3. Added necessary comments.
4. Updated the file for release 2.0.
*******************************************************************************/

#ifndef TBU_H
#define TBU_H

#include "ST7lib_Config.h"
    
/* Description of all the functions defined in this module.                   */

typedef enum {                                 /*TBU initialisation parameters*/
                TBU_DEFAULT           = (unsigned char) 0x00,
             TBU_ART_CASCADE       = (unsigned char) 0x40,
             TBU_IT_ENABLE         = (unsigned char) 0x10
             }TBU_Init_Param;

typedef enum {                                     /*Prescaler values for ART */
             TBU_CasPrescvalue_1   =(unsigned char) 0x00,
             TBU_CasPrescvalue_2   =(unsigned char) 0x10,
             TBU_CasPrescvalue_4   =(unsigned char) 0x20,
             TBU_CasPrescvalue_8   =(unsigned char) 0x30,
             TBU_CasPrescvalue_16  =(unsigned char) 0x40,
             TBU_CasPrescvalue_32  =(unsigned char) 0x50,
             TBU_CasPrescvalue_64  =(unsigned char) 0x60,
             TBU_CasPrescvalue_128 =(unsigned char) 0x70
             }TBU_CasPresc;

typedef enum {                                      /*Prescaler values for TBU*/
             TBU_Prescvalue_2      =(unsigned char) 0x00,
             TBU_Prescvalue_4      =(unsigned char) 0x01,
             TBU_Prescvalue_8      =(unsigned char) 0x02,
             TBU_Prescvalue_16     =(unsigned char) 0x03,
             TBU_Prescvalue_32     =(unsigned char) 0x04,
             TBU_Prescvalue_64     =(unsigned char) 0x05,
             TBU_Prescvalue_128    =(unsigned char) 0x06,
             TBU_Prescvalue_256    =(unsigned char) 0x07
             }TBU_Presc;

/********************** FUNCTIONS WITH MACROS *********************************/ 
     
#define TBU_Enable()  ((TBUCSR)|= (0x08))                  /* Enables the TBU */
#define TBU_Disable_IT() ((TBUCSR) &= (0x08))    /* TBU interrupt is disabled */  
                                            /*Function to clear overflow flag */ 
#define TBU_ClearOverflow() ((TBUCSR) |= (TBUCSR))
#define TBU_Disable() ((TBUCSR) &= (0xf7))                 /* Tbu is disabled */   
#define TBU_ReadCounter() (TBUCV)            /* Returns the TBU counter value */
    
/********************* Functions for the TBU **********************************/

void TBU_Init (TBU_Init_Param);     /*Initialises the TBU in the required mode*/
                       /*Sets the Prescaler factor and loads the counter value*/
void TBU_SetPrescCount8(TBU_Presc , unsigned char ); 
                   /*Sets the ART Prescaler factor and loads the counter value*/
void TBU_SetPrescCount16 (TBU_CasPresc , unsigned int);                        

#endif   /* TBU_H */ 

/**** (c) 2002   STMicroelectronics *************************** END OF FILE ***/
