

/* MODULE PortA. */

#include "PortA.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"

#pragma DATA_SEG PortA_DATA
#pragma CODE_SEG PortA_CODE
#pragma CONST_SEG PortA_CONST          /* Constant section for this module */
/*
** ===================================================================
**     Method      :  PortA_GetMsk (bean 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 PortA_Table[8] = {
  1, 2, 4, 8, 16, 32, 64, 128
};                                     /* Table of mask constants */

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

/*
** ===================================================================
**     Method      :  PortA_GetVal (bean 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 Input direction only.
**     Parameters  : None
**     Returns     :
**         ---        - Input value (0 to 255)
** ===================================================================
*/
/*
byte PortA_GetVal(void)

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

/*
** ===================================================================
**     Method      :  PortA_GetBit (bean 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 Input 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 PortA_GetBit(byte Bit)
{
  byte const Mask = PortA_GetMsk(Bit); /* Temporary variable - bit mask to test */
  return (bool)((getReg8(PORTA) & Mask) == Mask); /* Test if specified bit of port data register is set */
}

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

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


/* END PortA. */
/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 3.00 [04.12]
**     for the Freescale HCS12X series of microcontrollers.
**
** ###################################################################
*/
