/*
** ###################################################################
**
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**
**     Filename  : Cpu.C
**
**     Project   : Full1
** 
**     Processor : MC68HC908AZ60MFU
**
**     Beantype  : MC68HC908AZ60
**
**     Version   : Bean 01.041, Driver 01.03, CPU db: 2.81.019
**
**     Compiler  : Metrowerks HC08 C Compiler V-5.0.13
**
**     Date/Time : 2.4.2002, 9:36
**
**     Abstract  :
**
**         This bean "MC68HC908AZ60" implements properties, methods,
**         and events of the CPU.
**
**     Settings  :
**
**
**     Contents  :
**
**         GetSpeedMode - byte Cpu_GetSpeedMode(void);
**         EnableInt    - void Cpu_EnableInt(void);
**         DisableInt   - void Cpu_DisableInt(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
**
** ###################################################################
*/

/* MODULE Cpu. */
#include "PWM1.h"
#include "PPG1.h"
#include "TI1.h"
#include "AD2.h"
#include "AS1.h"
#include "SM1.h"
#include "CAN1.h"
#include "Byte1.h"
#include "Bits1.h"
#include "Bits2.h"
#include "Bits3.h"
#include "Bit1.h"
#include "Bits4.h"
#include "Bits5.h"
#include "Bits6.h"
#include "EInt1.h"
#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 "Events.h"
#include "Cpu.h"

#define CGM_DELAY  255UL


/* Global variables */
byte CCR_reg;                          /* Current CCR register */
byte CpuMode = HIGH_SPEED;             /* Current speed mode */

/*Definition of global shadow variables*/
byte Shadow_PTA;
byte Shadow_PTC;
byte Shadow_PTF;
byte Shadow_PTD;
byte Shadow_PTG;
byte Shadow_PTH;
byte Shadow_PTE;


/*
** ===================================================================
**     Method      :  Cpu_Interrupt (bean MC68HC908AZ60)
**
**     Description :
**         This method is internal. It is used by Processor Expert
**         only.
** ===================================================================
*/
__interrupt void Cpu_Interrupt(void)
{
}

/*
** ===================================================================
**     Method      :  Cpu_DisableInt (bean MC68HC908AZ60)
**
**     Description :
**         Disable maskable interrupts
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
/*
void Cpu_DisableInt(void)

**      This method is implemented as macro in the header module. **
*/

/*
** ===================================================================
**     Method      :  Cpu_EnableInt (bean MC68HC908AZ60)
**
**     Description :
**         Enable maskable interrupts
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
/*
void Cpu_EnableInt(void)

**      This method is implemented as macro in the header module. **
*/

/*
** ===================================================================
**     Method      :  Cpu_GetSpeedMode (bean MC68HC908AZ60)
**
**     Description :
**         Get current speed mode
**     Parameters  : None
**     Returns     :
**         ---             - Speed mode (HIGH_SPEED, LOW_SPEED,
**                           SLOW_SPEED)
** ===================================================================
*/
byte Cpu_GetSpeedMode(void)
{
  return CpuMode;                      /* Result the actual cpu mode */
}

/*
** ===================================================================
**         There is beginning of initialization code for CPU 
**         and embedded beans.
** ===================================================================
*/
void __low_level_init(void)
{
  byte i;
  /* Common initialization of the CPU registers */
  output( DDRE, input( DDRE ) & ~224 | 24 );
  output( PTC, input( PTC ) & ~63 );
  output( DDRC, input( DDRC ) | 63 );
  output( PTF, input( PTF ) & ~111 );
  output( DDRF, input( DDRF ) | 111 );
  output( PTD, input( PTD ) & ~128 );
  output( DDRD, input( DDRD ) | 128 );
  output( PTG, input( PTG ) & ~7 );
  output( DDRG, input( DDRG ) | 7 );
  output( PTH, input( PTH ) & ~3 );
  output( DDRH, input( DDRH ) | 3 );
  output( PTE, input( PTE ) & ~24 );
  /* ### MC68HC908AZ60 "Cpu" init code ... */
  CONFIG_1 = 1;                        /* Set the CONFIG_1 register */
  CONFIG_2 = 17;                       /* Set the CONFIG_2 register */
  /* ### Shared modules init code ... */
  PE_Cnvrt_Init();
  /* ### Programable pulse generation "PWM1" init code ... */
  PWM1_Init();
  /* ### Programable pulse generation "PPG1" init code ... */
  PPG1_Init();
  /* ### TimerInt "TI1" init code ... */
  TI1_Init();
  /* ###  "AD2" init code ... */
  AD2_Init();
  /* ### Asynchro serial "AS1" init code ... */
  DDRE &= ~2;
  PTE |= 1;
  DDRE |= 1;
  AS1_Init();
  /* ###  Synchro master "SM1" init code ... */
  SM1_Init();
  /* ###  "CAN1" init code ... */
  CAN1_Init();
  /* ### ByteIO "Byte1" init code ... */
  Shadow_PTA = 0;                      /* Initialize shadow variable */
  PTA = 0;                             /* Prepare value for output */
  DDRA = 255;                          /* Set direction to output */
  /* ### BitsIO "Bits1" init code ... */
  Shadow_PTC = Shadow_PTC & ~63 | 0;   /* Initialize shadow variable */
  /* ### BitsIO "Bits2" init code ... */
  Shadow_PTF = Shadow_PTF & ~15 | 0;   /* Initialize shadow variable */
  /* ### BitsIO "Bits3" init code ... */
  Shadow_PTF = Shadow_PTF & ~96 | 0;   /* Initialize shadow variable */
  /* ### BitIO "Bit1" init code ... */
  Shadow_PTD &= ~128;                  /* Initialize shadow variable */
  /* ### BitsIO "Bits4" init code ... */
  Shadow_PTG = Shadow_PTG & ~7 | 0;    /* Initialize shadow variable */
  /* ### BitsIO "Bits5" init code ... */
  Shadow_PTH = Shadow_PTH & ~3 | 0;    /* Initialize shadow variable */
  /* ### BitsIO "Bits6" init code ... */
  Shadow_PTE = Shadow_PTE & ~24 | 0;   /* Initialize shadow variable */
  /* ### External interrupt "EInt1" init code ... */
  ISCR_MODE1 = 0;
  ISCR_IMASK1 = 1;
  ISCR_ACK1 = 1;
  ISCR_IMASK1 = 0;
  __EI();                              /* Enable interrupts */
}

/* END Cpu. */

/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 02.84 for 
**     the Motorola HC08 series of microcontrollers.
**
** ###################################################################
*/
