/** ###################################################################
**     THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : Vystupni_port.C
**     Project   : Generator
**     Processor : MC9S08GT16ACFB
**     Component : ByteIO
**     Version   : Component 02.058, Driver 03.20, CPU db: 2.87.091
**     Compiler  : CodeWarrior HCS08 C Compiler
**     Date/Time : 27.3.2010, 16:08
**     Abstract  :
**         This bean "ByteIO" implements an one-byte input/output.
**         It uses one 8-bit port.
**         Note: This bean is set to work in Output direction only.
**         Methods of this bean are mostly implemented as a macros 
**         (if supported by target langauage and compiler).
**     Settings  :
**         Port name                   : PTA
**
**         Initial direction           : Output (direction cannot be changed)
**         Initial output value        : 0 = 000H
**         Initial pull option         : off
**
**         8-bit data register         : PTAD      [$0000]
**         8-bit control register      : PTADD     [$0003]
**         8-bit function register     : KBIPE     [$0017]
**
**             ----------------------------------------------------
**                   Bit     |   Pin   |   Name
**             ----------------------------------------------------
**                    0      |    32   |   PTA0_KBIP0
**                    1      |    33   |   PTA1_KBIP1
**                    2      |    34   |   PTA2_KBIP2
**                    3      |    35   |   PTA3_KBIP3
**                    4      |    36   |   PTA4_KBIP4
**                    5      |    37   |   PTA5_KBIP5
**                    6      |    38   |   PTA6_KBIP6
**                    7      |    39   |   PTA7_KBIP7
**             ----------------------------------------------------
**     Contents  :
**         GetDir - bool Vystupni_port_GetDir(void);
**         GetVal - byte Vystupni_port_GetVal(void);
**         PutVal - void Vystupni_port_PutVal(byte Val);
**         GetBit - bool Vystupni_port_GetBit(byte Bit);
**         PutBit - void Vystupni_port_PutBit(byte Bit, bool Val);
**         SetBit - void Vystupni_port_SetBit(byte Bit);
**         ClrBit - void Vystupni_port_ClrBit(byte Bit);
**         NegBit - void Vystupni_port_NegBit(byte Bit);
**
**     Copyright : 1997 - 2009 Freescale Semiconductor, Inc. All Rights Reserved.
**     
**     http      : www.freescale.com
**     mail      : support@freescale.com
** ###################################################################*/

/* MODULE Vystupni_port. */

#include "Vystupni_port.h"
  /* Including shared modules, which are used in the whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
#include "Cpu.h"


/*
** ===================================================================
**     Method      :  Vystupni_port_GetMsk (component ByteIO)
**
**     Description :
**         The method returns a bit mask which corresponds to the 
**         required bit position.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
static const byte  Vystupni_port_Table[8] = {
  0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
};                                     /* Table of mask constants */

static byte Vystupni_port_GetMsk (byte PinIndex)
{
  return (byte)(PinIndex<8 ? Vystupni_port_Table[PinIndex] : 0); /* Check range and return appropriate bit mask */
}

/*
** ===================================================================
**     Method      :  Vystupni_port_GetVal (component ByteIO)
**
**     Description :
**         This method returns an input value.
**           a) direction = Input  : reads the input value from the
**                                   pins and returns it
**           b) direction = Output : returns the last written value
**         Note: This bean is set to work in Output direction only.
**     Parameters  : None
**     Returns     :
**         ---        - Input value (0 to 255)
** ===================================================================
*/
/*
byte Vystupni_port_GetVal(void)

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

/*
** ===================================================================
**     Method      :  Vystupni_port_PutVal (component ByteIO)
**
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val        - Output value (0 to 255)
**     Returns     : Nothing
** ===================================================================
*/
/*
void Vystupni_port_PutVal(byte Val)

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

/*
** ===================================================================
**     Method      :  Vystupni_port_GetBit (component ByteIO)
**
**     Description :
**         This method returns the specified bit of the input value.
**           a) direction = Input  : reads the input value from pins
**                                   and returns the specified bit
**           b) direction = Output : returns the specified bit
**                                   of the last written value
**         Note: This bean is set to work in Output direction only.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit to read (0 to 7)
**     Returns     :
**         ---        - Value of the specified bit (FALSE or TRUE)
**                      FALSE = "0" or "Low", TRUE = "1" or "High"
** ===================================================================
*/
bool Vystupni_port_GetBit(byte Bit)
{
  byte const Mask = Vystupni_port_GetMsk(Bit); /* Temporary variable - bit mask to test */
  return (bool)((getReg8(PTAD) & Mask) == Mask); /* Test if specified bit of port data register is set */
}

/*
** ===================================================================
**     Method      :  Vystupni_port_PutBit (component ByteIO)
**
**     Description :
**         This method writes the new value to the specified bit
**         of the output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit (0 to 7)
**         Val        - New value of the bit (FALSE or TRUE)
**                      FALSE = "0" or "Low", TRUE = "1" or "High"
**     Returns     : Nothing
** ===================================================================
*/
void Vystupni_port_PutBit(byte Bit, bool Val)
{
  byte const Mask = Vystupni_port_GetMsk(Bit); /* Temporary variable - put bit mask */
  if (Val) {
    setReg8Bits(PTAD, Mask);           /* [bit Bit]=0x01 */
  } else { /* !Val */
    clrReg8Bits(PTAD, Mask);           /* [bit Bit]=0x00 */
  } /* !Val */
}

/*
** ===================================================================
**     Method      :  Vystupni_port_SetBit (component ByteIO)
**
**     Description :
**         This method sets (sets to one) the specified bit of the
**         output value.
**         [ It is the same as "PutBit(Bit,TRUE);" ]
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit to set (0 to 7)
**     Returns     : Nothing
** ===================================================================
*/
void Vystupni_port_SetBit(byte Bit)
{
  byte const Mask = Vystupni_port_GetMsk(Bit); /* Temporary variable - set bit mask */
  setReg8Bits(PTAD, Mask);             /* [bit Bit]=0x01 */
}

/*
** ===================================================================
**     Method      :  Vystupni_port_ClrBit (component ByteIO)
**
**     Description :
**         This method clears (sets to zero) the specified bit
**         of the output value.
**         [ It is the same as "PutBit(Bit,FALSE);" ]
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit to clear (0 to 7)
**     Returns     : Nothing
** ===================================================================
*/
void Vystupni_port_ClrBit(byte Bit)
{
  byte const Mask = Vystupni_port_GetMsk(Bit); /* Temporary variable - set bit mask */
  clrReg8Bits(PTAD, Mask);             /* [bit Bit]=0x00 */
}

/*
** ===================================================================
**     Method      :  Vystupni_port_NegBit (component ByteIO)
**
**     Description :
**         This method negates (inverts) the specified bit of the
**         output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit to invert (0 to 7)
**     Returns     : Nothing
** ===================================================================
*/
void Vystupni_port_NegBit(byte Bit)
{
  byte const Mask = Vystupni_port_GetMsk(Bit); /* Temporary variable - set bit mask */
  invertReg8Bits(PTAD, Mask);          /* [bit Bit]=invert */
}

/*
** ===================================================================
**     Method      :  Vystupni_port_GetDir (component ByteIO)
**
**     Description :
**         This method returns direction of the bean.
**     Parameters  : None
**     Returns     :
**         ---        - Direction of the bean (always TRUE, Output only)
**                      FALSE = Input, TRUE = Output
** ===================================================================
*/
/*
bool Vystupni_port_GetDir(void)

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


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