/*
** ###################################################################
**
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**
**     Filename  : Bit1.C
**
**     Project   : Full1
** 
**     Processor : MC68HC908AZ60MFU
**
**     Beantype  : BitIO
**
**     Version   : Bean 02.014, Driver 02.10, CPU db: 2.81.019
**
**     Compiler  : Metrowerks HC08 C Compiler V-5.0.13
**
**     Date/Time : 2.4.2002, 9:36
**
**     Abstract  :
**
**         This bean "BitIO" implements an one-bit input/output.
**         It uses one bit/pin of a port.
**         Methods of this bean are mostly implemented as a macros 
**         (if supported by target language and compiler).
**
**     Settings  :
**
**         Used pin                    : 
**             ----------------------------------------------------
**                Number (on package)  |    Name
**             ----------------------------------------------------
**                       53            |  PTD7
**             ----------------------------------------------------
**
**         Port name                   : PTD
**
**         Bit number (in port)        : 7
**         Bit mask of the port        : 128
**
**         Initial direction           : Output (direction can be changed)
**         Safe mode                   : yes
**         Initial output value        : 0
**         Initial pull option         : off
**
**         Port data register          : PTD       [3]
**         Port control register       : DDRD      [7]
**
**         Optimization for            : speed
**
**     Contents  :
**
**         SetDir - void Bit1_SetDir(bool Output);
**         GetVal - bool Bit1_GetVal(void);
**         PutVal - void Bit1_PutVal(bool Output);
**         ClrVal - void Bit1_ClrVal(void);
**         SetVal - void Bit1_SetVal(void);
**
**
**     (c) Copyright UNIS, spol. s r.o. 1997-2002
**
**     UNIS, spol. s r.o.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
**
** ###################################################################
*/

#include "Bit1.h"

/*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"
#include "PE_Timer.h"
#include "PE_Cnvrt.h"
#include "Cpu.h"

/*
** ===================================================================
**     Method      :  Bit1_GetVal (bean BitIO)
**
**     Description :
**         This method returns an input value.
**           a) direction = Input  : reads the input value from the
**                                   pin and returns it
**           b) direction = Output : returns the last written value
**     Parameters  : None
**     Returns     :
**         ---        - Input value (FALSE or TRUE)
**                      FALSE = "0" or "Low", TRUE = "1" or "High"
** ===================================================================
*/
/*
bool Bit1_GetVal(void)

**  This method is implemented as a macro. See Bit1.inc file.  **

*/

/*
** ===================================================================
**     Method      :  Bit1_PutVal (bean BitIO)
**
**     Description :
**         This method writes the new output value.
**           a) direction = Input  : sets the new output value;
**                                   this operation will be shown on
**                                   output after the direction has
**                                   been switched to output
**                                   (SetDir(TRUE);)
**           b) direction = Output : directly writes the value to the
**                                   appropriate pin
**     Parameters  :
**         NAME       - DESCRIPTION
**         Value      - Output value (FALSE or TRUE)
**                      FALSE = "0" or "Low", TRUE = "1" or "High"
**     Returns     : Nothing
** ===================================================================
*/
void Bit1_PutVal(byte Value)
{
  if (Value) {                         /* Is it one to be written? */
    Shadow_PTD |= 128;                 /* Set bit in shadow variable */
    PTD |= 128;                        /* Set bit on port */
  }
  else {                               /* Is it zero to be written? */
    Shadow_PTD &= ~128;                /* Clear bit in shadow variable */
    PTD &= ~128;                       /* Clear bit on port */
  }
}

/*
** ===================================================================
**     Method      :  Bit1_SetVal (bean BitIO)
**
**     Description :
**         This method sets (sets to one) the output value.
**           a) direction = Input  : sets the output value to "1";
**                                   this operation will be shown on
**                                   output after the direction has
**                                   been switched to output
**                                   (SetDir(TRUE);)
**           b) direction = Output : directly writes "1" to the
**                                   appropriate pin
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
/*
void Bit1_SetVal(void)

**  This method is implemented as a macro. See Bit1.inc file.  **
*/

/*
** ===================================================================
**     Method      :  Bit1_ClrVal (bean BitIO)
**
**     Description :
**         This method clears (sets to zero) the output value.
**           a) direction = Input  : sets the output value to "0";
**                                   this operation will be shown on
**                                   output after the direction has
**                                   been switched to output
**                                   (SetDir(TRUE);)
**           b) direction = Output : directly writes "0" to the
**                                   appropriate pin
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
/*
void Bit1_ClrVal(void)

**  This method is implemented as a macro. See Bit1.inc file.  **
*/

/*
** ===================================================================
**     Method      :  Bit1_SetDir (bean BitIO)
**
**     Description :
**         This method sets direction of the bean.
**     Parameters  :
**         NAME       - DESCRIPTION
**         DirOutput  - Direction to set (FALSE or TRUE)
**                      FALSE = Input, TRUE = Output
**     Returns     : Nothing
** ===================================================================
*/
void Bit1_SetDir(byte Output)
{
  if (Output) {                        /* Is given direction output? */
    PTD = (PTD & ~128)|(Shadow_PTD & 128); /* Restore correct value of output from shadow variable */
    DDRD |= 128;                       /* Set direction to output */
  }
  else                                 /* Is given direction input? */
    DDRD &= ~128;                      /* Set direction to input */
}

/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 02.84 for 
**     the Motorola HC08 series of microcontrollers.
**
** ###################################################################
*/
