/** ###################################################################
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : Cpu.H
**     Project   : DC17
**     Processor : MC56F8006_32_LQFP
**     Beantype  : 56F8006_32_LQFP
**     Version   : Bean 01.013, Driver 02.01, CPU db: 3.00.169
**     Datasheet : MC56F8006RM,Rev. 0 Draft B,09/2007
**     Compiler  : Metrowerks DSP C Compiler
**     Date/Time : 4/7/2009, 10:11 AM
**     Abstract  :
**
**     Comment   :
**         If you are hacking the DC17 firmware, you will need to do the following things:
**         
**         1) After re-compiling, open Vector.c (in the Generated Code project folder) and change first two lines of _vect table from _EntryPoint to BOOTLOADER_ADDR. 
**         This ensures that the bootloader will re-launch at power-up, else you are stuck with your user code unless you re-flash the whole device. 
**         
**         2) If the linker file (file ending in .cmd) changes, patch the following areas:
**         
**         a) Paste this code block to the end of the SECTIONS area
**         
**         .ApplicationConfiguration :
**         {
**         # Set the start address of the application
**         WRITEH(F_EntryPoint);
**         # Bootloader start delay in seconds
**         WRITEH(10);
**         } > .xBootCfg
**         
**         b) Add 
**              * (.const.data.pmem)
**         underneath  
**              * (.data.pmem) 
**         in the .ApplicationCode section to enable storage of constants within program area of flash
**         
**         c) Add 
**              F_vba = .;
**         underneath
**              # interrupt vectors
**         
**         ---
**     Settings  :
**
**     Contents  :
**         EnableInt   - void Cpu_EnableInt(void);
**         DisableInt  - void Cpu_DisableInt(void);
**         SetWaitMode - void Cpu_SetWaitMode(void);
**         SetStopMode - void Cpu_SetStopMode(void);
**         Delay100US  - asm void Cpu_Delay100US(word us100);
**
**     (c) Freescale Semiconductor
**     2004 All Rights Reserved
**
**     (c) Copyright UNIS, a.s. 1997-2008
**     UNIS, a.s.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/

#ifndef __Cpu_H
#define __Cpu_H

/* MODULE Cpu. */

/* Active PE project configuration */
#define PEcfg_smmpROMxRAM 1

/* Active CPU bean */
#define PE_CPU_TYPE_56F8006_32_LQFP

/* Active CPU variant */
#define PE_CPU_VARIANT_MC56F8006_32_LQFP

/* Active CPU family */
#define PE_CPU_FAMILY_56800

/* Active CPU subfamily */
#define PE_CPU_SUBFAMILY_56F800x

/*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 "assert.h"

#ifndef __BWUserType_TShadowRegs
#define __BWUserType_TShadowRegs
  typedef struct {                     /* Shadow register type. */
    word* R0;                          /* Shadow register R0. */
    word* R1;                          /* Shadow register R1. */
    int16_t N;                         /* Shadow register N. */
    int16_t M01;                       /* Shadow register M01. */
  } TShadowRegs;
#endif

/* Global variables */
extern volatile word SR_lock;          /* Lock */
extern volatile word SR_reg;           /* Current value of the SR register */

#define   Cpu_SetStopMode()  asm(STOP) /* Set STOP mode */
/*
** ===================================================================
**     Method      :  Cpu_SetStopMode (bean 56F8006_32_LQFP)
**
**     Description :
**         Sets low power mode - Stop mode.
**         For more information about the stop mode see this CPU
**         documentation.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/

#define   Cpu_SetWaitMode()  asm(WAIT) /* Set WAIT mode */
/*
** ===================================================================
**     Method      :  Cpu_SetWaitMode (bean 56F8006_32_LQFP)
**
**     Description :
**         Sets low power mode - Wait mode.
**         For more information about the wait mode see this CPU
**         documentation.
**         Release from wait mode: Reset or interrupt
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/


/* Enum type definition */
typedef enum {CLR, SET, NEG} bitAction; /* Enumeration types for I/O beans */

#define BitIO__GPIO_C_DR 0
#define BitIO__GPIO_B_DR 1
#define BitIO__GPIO_A_DR 2
#define BitIO__GPIO_F_DR 3

/* Port array definition. Array is used by BitIO beans with 'code size' optimization */
typedef struct {
  word *portReg;
  word *portCntrReg;
} tBitIO_portDsc;
extern tBitIO_portDsc BitIO_portDsc[4];

#define BitsIO__GPIO_A_DR 0
#define BitsIO__GPIO_C_DR 1

/* Port array definition. Array is used by BitsIO beans with 'code size' optimization */
typedef struct {
  word *portReg;
  word *portCntrReg;
} tBitsIO_portDsc;
extern tBitsIO_portDsc BitsIO_portDsc[2];

asm void Cpu_Delay100US(word us100);
/*
** ===================================================================
**     Method      :  Cpu_Delay100US (bean 56F8006_32_LQFP)
**
**     Description :
**         This method realizes software delay. The length of delay
**         is at least 100 microsecond multiply input parameter
**         [us100]. As the delay implementation is not based on real
**         clock, the delay time may be increased by interrupt
**         service routines processed during the delay. Adding read
**         wait states for external program memory can cause delay
**         extension as well. The method is independent on selected
**         speed mode.
**     Parameters  :
**         NAME            - DESCRIPTION
**         us100           - Number of 100 us delay repetitions.
**     Returns     : Nothing
** ===================================================================
*/

#define   Cpu_DisableInt()  __DI()     /* Disable interrupts */
/*
** ===================================================================
**     Method      :  Cpu_DisableInt (bean 56F8006_32_LQFP)
**
**     Description :
**         Disables all maskable interrupts
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/

#define   Cpu_EnableInt()  __EI(0)     /* Enable interrupts */
/*
** ===================================================================
**     Method      :  Cpu_EnableInt (bean 56F8006_32_LQFP)
**
**     Description :
**         Enables all maskable interrupts
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/

void PE_low_level_init(void);
/*
** ===================================================================
**     Method      :  PE_low_level_init (bean 56F8006_32_LQFP)
**
**     Description :
**         Initializes beans and provides common register initialization. 
**         The method is called automatically as a part of the 
**         application initialization code.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void Cpu_Interrupt(void);
/*
** ===================================================================
**     Method      :  Cpu_Interrupt (bean 56F8006_32_LQFP)
**
**     Description :
**         The method services unhandled interrupt vectors.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/


void _EntryPoint(void);
/*
** ===================================================================
**     Method      :  _EntryPoint (bean 56F8006_32_LQFP)
**
**     Description :
**         Initializes the whole system like timing and so on. At the end 
**         of this function, the C startup is invoked to initialize stack,
**         memory areas and so on.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/

/* END Cpu. */

#endif
/* __Cpu_H */

/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 2.99 [04.17]
**     for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/
