/** ###################################################################
**     THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : HSync.H
**     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                : TPMC1V    [$0049]
**              Counter                : TPMCNT    [$0041]
**              Mode                   : TPMSC     [$0040]
**              Run                    : TPMSC     [$0040]
**              Prescaler              : TPMSC     [$0040]
**
**         Used input pin              : 
**             ----------------------------------------------------
**                Number (on package)  |    Name
**             ----------------------------------------------------
**                       7             |  PTA1_KBI1P1_TPM1CH1_ADC1P1
**             ----------------------------------------------------
**
**         Port name                   : PTA
**         Bit number (in port)        : 1
**         Bit mask of the port        : $0002
**
**         Signal edge/level           : falling
**         Priority                    : 
**         Pull option                 : up
**
**     Contents  :
**         GetCaptureValue - byte HSync_GetCaptureValue(HSync_TCapturedValue *Value);
**         GetPinValue     - bool HSync_GetPinValue(void);
**
**     Copyright : 1997 - 2009 Freescale Semiconductor, Inc. All Rights Reserved.
**     
**     http      : www.freescale.com
**     mail      : support@freescale.com
** ###################################################################*/

#ifndef __HSync
#define __HSync

/*Include shared modules, which are used for whole project*/
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"

/* MODULE HSync. */

#include "Cpu.h"

/* PUBLISHED CONSTANTS */
#define HSync_PRESCALER_VALUE           0x01U /* Prescaler value of the timer in high speed mode */
#define HSync_COUNTER_INPUT_CLOCK_HZ    0x007A1200LU /* Initial counter input clock frequency [Hz] */
#define HSync_TIMER_INPUT_CLOCK         0x007A1200LU /* Deprecated, Initial timer input clock frequency [Hz] */
#define HSync_PRESCALER_VALUE_HIGH      0x01U /* Prescaler value of the timer in high speed mode */
#define HSync_COUNTER_INPUT_CLOCK_HZ_HIGH 0x007A1200LU /* Counter input clock frequency in high speed mode [Hz] */
#define HSync_TIMER_INPUT_CLOCK_HIGH    0x007A1200LU /* Deprecated, Timer input clock frequency in high speed mode[Hz] */

#ifndef __BWUserType_HSync_TCapturedValue
#define __BWUserType_HSync_TCapturedValue
  #define HSync_TCapturedValue word    /* Type of the captured value */
#endif



#define HSync_GetCaptureValue(Value) \
  (*(HSync_TCapturedValue*)(Value) = (HSync_TCapturedValue)TPMC1V , (byte)ERR_OK)
/*
** ===================================================================
**     Method      :  HSync_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
** ===================================================================
*/

#define HSync_GetPinValue() ((bool)(PTAD & 0x02))
/*
** ===================================================================
**     Method      :  HSync_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.
** ===================================================================
*/

void HSync_Init(void);
/*
** ===================================================================
**     Method      :  HSync_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.
** ===================================================================
*/

__interrupt void HSync_Interrupt(void);
/*
** ===================================================================
**     Method      :  Interrupt (component Capture)
**
**     Description :
**         The method services the interrupt of the selected peripheral(s)
**         and eventually invokes of the bean event(s).
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/


/* END HSync. */

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