/** ###################################################################
**     THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : VSync.C
**     Project   : vga2scart
**     Processor : MC9S08QD4CPC
**     Component : Capture
**     Version   : Component 02.211, Driver 01.27, CPU db: 3.00.002
**     Compiler  : CodeWarrior HCS08 C Compiler
**     Date/Time : 7.7.2010, 0:50
**     Abstract  :
**         This bean "Capture" simply implements the capture function
**         of timer. The counter counts the same way as in free run mode. On
**         the selected edge of the input signal (on the input pin), the current
**         content of the counter register is written into the capture
**         register and the OnCapture event is called.
**     Settings  :
**             Timer capture encapsulation : Capture
**
**         Timer
**             Timer                   : TPM1
**             Counter shared          : Yes
**
**         High speed mode
**             Prescaler               : divide-by-1
**           Maximal time for capture register
**             Xtal ticks              : 256
**             microseconds            : 8192
**             milliseconds            : 8
**             seconds (real)          : 0.008192
**             Hz                      : 122
**           One tick of timer is
**             nanoseconds             : 125
**
**         Initialization:
**              Timer                  : Enabled
**              Events                 : Enabled
**
**         Timer registers
**              Capture                : TPMC0V    [$0046]
**              Counter                : TPMCNT    [$0041]
**              Mode                   : TPMSC     [$0040]
**              Run                    : TPMSC     [$0040]
**              Prescaler              : TPMSC     [$0040]
**
**         Used input pin              : 
**             ----------------------------------------------------
**                Number (on package)  |    Name
**             ----------------------------------------------------
**                       8             |  PTA0_KBI1P0_TPM1CH0_ADC1P0
**             ----------------------------------------------------
**
**         Port name                   : PTA
**         Bit number (in port)        : 0
**         Bit mask of the port        : $0001
**
**         Signal edge/level           : falling
**         Pull option                 : up
**
**     Contents  :
**         GetCaptureValue - byte VSync_GetCaptureValue(VSync_TCapturedValue *Value);
**         GetPinValue     - bool VSync_GetPinValue(void);
**
**     Copyright : 1997 - 2009 Freescale Semiconductor, Inc. All Rights Reserved.
**     
**     http      : www.freescale.com
**     mail      : support@freescale.com
** ###################################################################*/

/* MODULE VSync. */

#include "VSync.h"




/*
** ===================================================================
**     Method      :  VSync_GetCaptureValue (component Capture)
**
**     Description :
**         This method gets the last value captured by enabled timer.
**         Note: one tick of timer is
**               125 ns in high speed mode
**     Parameters  :
**         NAME            - DESCRIPTION
**       * Value           - A pointer to the content of the
**                           capture register
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
** ===================================================================
*/
/*
byte VSync_GetCaptureValue(VSync_TCapturedValue *Value)

**  This method is implemented as a macro. See VSync.h file.  **
*/

/*
** ===================================================================
**     Method      :  VSync_GetPinValue (component Capture)
**
**     Description :
**         The method reads the Capture pin value. The method is
**         available only if it is possible to read the pin value
**         (usually not available for internal signals).
**     Parameters  : None
**     Returns     :
**         ---             - Capture pin value.
**                           <true> - high level
**                           <false> - low level.
** ===================================================================
*/
/*
byte VSync_GetPinValue()

**  This method is implemented as a macro. See VSync.h file.  **
*/

/*
** ===================================================================
**     Method      :  VSync_Init (component Capture)
**
**     Description :
**         Initializes the associated peripheral(s) and the bean 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.
** ===================================================================
*/
void VSync_Init(void)
{
  /* TPMC0V: BIT15=0,BIT14=0,BIT13=0,BIT12=0,BIT11=0,BIT10=0,BIT9=0,BIT8=0,BIT7=0,BIT6=0,BIT5=0,BIT4=0,BIT3=0,BIT2=0,BIT1=0,BIT0=0 */
  setReg16(TPMC0V, 0x00U);             /* Clear capture register */ 
  /* TPMC0SC: CH0F=0,CH0IE=0,MS0B=0,MS0A=0,ELS0B=1,ELS0A=0,??=0,??=0 */
  setReg8(TPMC0SC, 0x08);              /* Enable capture function */ 
}


/* END VSync. */

/*
** ###################################################################
**
**     This file was created by Processor Expert 3.07 [04.34]
**     for the Freescale HCS08 series of microcontrollers.
**
** ###################################################################
*/
